@aemforms/af-core 0.22.142 → 0.22.144

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.
@@ -3050,10 +3050,9 @@ class FunctionRuntimeImpl {
3050
3050
  event: interpreter.globals.$event,
3051
3051
  functions: {
3052
3052
  setProperty: (target, payload) => {
3053
- const field = interpreter.globals.form.getElement(target.$id);
3054
- Object.entries(payload).forEach(([key, value]) => {
3055
- field[key] = value;
3056
- });
3053
+ const eventName = 'custom:setProperty';
3054
+ const args = [target, eventName, payload];
3055
+ return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
3057
3056
  },
3058
3057
  reset: (target) => {
3059
3058
  const eventName = 'reset';
@@ -3638,6 +3637,10 @@ class FunctionRuntimeImpl {
3638
3637
  }
3639
3638
  const FunctionRuntime = FunctionRuntimeImpl.getInstance();
3640
3639
 
3640
+ const transformFieldName = (fieldName) => {
3641
+ return fieldName.split('.').slice(1).map(p => p.match(/\[\d+\]$/) ? p : p !== '' ? `${p}[0]` : p).join('.');
3642
+ };
3643
+
3641
3644
  class Version {
3642
3645
  #minor;
3643
3646
  #major;
@@ -3805,36 +3808,39 @@ class Form extends Container {
3805
3808
  return foundFormElement;
3806
3809
  }
3807
3810
  exportSubmitMetaData() {
3808
- const captchaInfoObj = {};
3809
- this.visit(field => {
3810
- if (field.fieldType === 'captcha') {
3811
- captchaInfoObj[field.qualifiedName] = field.value;
3811
+ return this.withDependencyTrackingControl(true, () => {
3812
+ const captchaInfoObj = {};
3813
+ this.visit(field => {
3814
+ if (field.fieldType === 'captcha') {
3815
+ captchaInfoObj[field.qualifiedName] = field.value;
3816
+ }
3817
+ });
3818
+ const additionalMeta = {};
3819
+ const draftId = this.properties['fd:draftId'] || '';
3820
+ if (draftId) {
3821
+ additionalMeta['fd:draftId'] = draftId;
3822
+ }
3823
+ const dorProps = this.properties['fd:dor'];
3824
+ if (dorProps && dorProps.dorType !== 'none') {
3825
+ const excludeFromDoRIfHidden = dorProps['fd:excludeFromDoRIfHidden'];
3826
+ let excludeFromDoR = [];
3827
+ excludeFromDoR = Object.values(this._fields)
3828
+ .filter(field => field.enabled === false || (excludeFromDoRIfHidden && field.visible === false))
3829
+ .map(field => transformFieldName(field.qualifiedName));
3830
+ if (excludeFromDoR && excludeFromDoR.length > 0) {
3831
+ additionalMeta.excludeFromDoR = excludeFromDoR;
3832
+ }
3812
3833
  }
3813
- });
3814
- const additionalMeta = {};
3815
- const draftId = this.properties['fd:draftId'] || '';
3816
- if (draftId) {
3817
- additionalMeta['fd:draftId'] = draftId;
3818
- }
3819
- const dorProps = this.properties['fd:dor'];
3820
- if (dorProps && dorProps.dorType !== 'none') {
3821
- const excludeFromDoRIfHidden = dorProps['fd:excludeFromDoRIfHidden'];
3822
- const excludeFromDoR = Object.values(this._fields)
3823
- .filter(field => field.enabled === false || (excludeFromDoRIfHidden && field.visible === false))
3824
- .map(field => field.qualifiedName);
3825
- if (excludeFromDoR && excludeFromDoR.length > 0) {
3826
- additionalMeta.excludeFromDoR = excludeFromDoR;
3834
+ if (Object.keys(additionalMeta).length > 0) {
3835
+ this.setAdditionalSubmitMetadata(additionalMeta);
3827
3836
  }
3828
- }
3829
- if (Object.keys(additionalMeta).length > 0) {
3830
- this.setAdditionalSubmitMetadata(additionalMeta);
3831
- }
3832
- const options = {
3833
- lang: this.lang,
3834
- captchaInfo: captchaInfoObj,
3835
- ...this.additionalSubmitMetadata
3836
- };
3837
- return new SubmitMetaData(options);
3837
+ const options = {
3838
+ lang: this.lang,
3839
+ captchaInfo: captchaInfoObj,
3840
+ ...this.additionalSubmitMetadata
3841
+ };
3842
+ return new SubmitMetaData(options);
3843
+ });
3838
3844
  }
3839
3845
  #getNavigableChildren(children) {
3840
3846
  return children.filter(child => child.visible === true);
@@ -0,0 +1 @@
1
+ export declare const transformFieldName: (fieldName: string) => string;
package/lib/Form.js CHANGED
@@ -29,6 +29,7 @@ const DataGroup_1 = __importDefault(require("./data/DataGroup"));
29
29
  const FunctionRuntime_1 = require("./rules/FunctionRuntime");
30
30
  const index_1 = require("./types/index");
31
31
  const FormUtils_1 = require("./utils/FormUtils");
32
+ const DorUtils_1 = require("./utils/DorUtils");
32
33
  const Version_1 = require("./utils/Version");
33
34
  exports.currentVersion = new Version_1.Version('0.13');
34
35
  const changeEventVersion = new Version_1.Version('0.13');
@@ -153,32 +154,35 @@ class Form extends Container_1.default {
153
154
  return foundFormElement;
154
155
  }
155
156
  exportSubmitMetaData() {
156
- const captchaInfoObj = {};
157
- this.visit(field => {
158
- if (field.fieldType === 'captcha') {
159
- captchaInfoObj[field.qualifiedName] = field.value;
157
+ return this.withDependencyTrackingControl(true, () => {
158
+ const captchaInfoObj = {};
159
+ this.visit(field => {
160
+ if (field.fieldType === 'captcha') {
161
+ captchaInfoObj[field.qualifiedName] = field.value;
162
+ }
163
+ });
164
+ const additionalMeta = {};
165
+ const draftId = this.properties['fd:draftId'] || '';
166
+ if (draftId) {
167
+ additionalMeta['fd:draftId'] = draftId;
160
168
  }
161
- });
162
- const additionalMeta = {};
163
- const draftId = this.properties['fd:draftId'] || '';
164
- if (draftId) {
165
- additionalMeta['fd:draftId'] = draftId;
166
- }
167
- const dorProps = this.properties['fd:dor'];
168
- if (dorProps && dorProps.dorType !== 'none') {
169
- const excludeFromDoRIfHidden = dorProps['fd:excludeFromDoRIfHidden'];
170
- const excludeFromDoR = Object.values(this._fields)
171
- .filter(field => field.enabled === false || (excludeFromDoRIfHidden && field.visible === false))
172
- .map(field => field.qualifiedName);
173
- if (excludeFromDoR && excludeFromDoR.length > 0) {
174
- additionalMeta.excludeFromDoR = excludeFromDoR;
169
+ const dorProps = this.properties['fd:dor'];
170
+ if (dorProps && dorProps.dorType !== 'none') {
171
+ const excludeFromDoRIfHidden = dorProps['fd:excludeFromDoRIfHidden'];
172
+ let excludeFromDoR = [];
173
+ excludeFromDoR = Object.values(this._fields)
174
+ .filter(field => field.enabled === false || (excludeFromDoRIfHidden && field.visible === false))
175
+ .map(field => (0, DorUtils_1.transformFieldName)(field.qualifiedName));
176
+ if (excludeFromDoR && excludeFromDoR.length > 0) {
177
+ additionalMeta.excludeFromDoR = excludeFromDoR;
178
+ }
175
179
  }
176
- }
177
- if (Object.keys(additionalMeta).length > 0) {
178
- this.setAdditionalSubmitMetadata(additionalMeta);
179
- }
180
- const options = Object.assign({ lang: this.lang, captchaInfo: captchaInfoObj }, this.additionalSubmitMetadata);
181
- return new SubmitMetaData_1.default(options);
180
+ if (Object.keys(additionalMeta).length > 0) {
181
+ this.setAdditionalSubmitMetadata(additionalMeta);
182
+ }
183
+ const options = Object.assign({ lang: this.lang, captchaInfo: captchaInfoObj }, this.additionalSubmitMetadata);
184
+ return new SubmitMetaData_1.default(options);
185
+ });
182
186
  }
183
187
  setFocus(field, focusOption) {
184
188
  const dependencyTracking = this._ruleEngine.getDependencyTracking();
@@ -248,10 +248,9 @@ class FunctionRuntimeImpl {
248
248
  event: interpreter.globals.$event,
249
249
  functions: {
250
250
  setProperty: (target, payload) => {
251
- const field = interpreter.globals.form.getElement(target.$id);
252
- Object.entries(payload).forEach(([key, value]) => {
253
- field[key] = value;
254
- });
251
+ const eventName = 'custom:setProperty';
252
+ const args = [target, eventName, payload];
253
+ return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
255
254
  },
256
255
  reset: (target) => {
257
256
  const eventName = 'reset';
@@ -0,0 +1 @@
1
+ export declare const transformFieldName: (fieldName: string) => string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformFieldName = void 0;
4
+ const transformFieldName = (fieldName) => {
5
+ return fieldName.split('.').slice(1).map(p => p.match(/\[\d+\]$/) ? p : p !== '' ? `${p}[0]` : p).join('.');
6
+ };
7
+ exports.transformFieldName = transformFieldName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.142",
3
+ "version": "0.22.144",
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.142"
40
+ "@aemforms/af-formatters": "^0.22.144"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",