@aemforms/af-core 0.22.120 → 0.22.121

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-events.js CHANGED
@@ -111,8 +111,8 @@ class ValidationComplete extends ActionImpl {
111
111
  }
112
112
  }
113
113
  class Focus extends ActionImpl {
114
- constructor() {
115
- super({}, 'focus', { dispatch: false });
114
+ constructor(payload, dispatch = false) {
115
+ super(payload, 'focus', { dispatch });
116
116
  }
117
117
  }
118
118
  class Submit extends ActionImpl {
@@ -1,4 +1,4 @@
1
- import { propertyChange, ExecuteRule, Initialize, RemoveItem, SubmitSuccess, CustomEvent, SubmitError, SubmitFailure, Submit, Save, Valid, Invalid, RemoveInstance, AddInstance, Reset, AddItem, Click, Change, FormLoad, FieldChanged, ValidationComplete } from './afb-events.js';
1
+ import { propertyChange, ExecuteRule, Initialize, RemoveItem, SubmitSuccess, CustomEvent, SubmitError, SubmitFailure, Submit, Save, Focus, Valid, Invalid, RemoveInstance, AddInstance, Reset, AddItem, Click, Change, FormLoad, FieldChanged, ValidationComplete } from './afb-events.js';
2
2
  import Formula from '@adobe/json-formula';
3
3
  import { parseDefaultDate, datetimeToNumber, format, parseDateSkeleton, numberToDatetime, formatDate, parseDate } from '@aemforms/af-formatters';
4
4
 
@@ -2050,7 +2050,6 @@ class Container extends Scriptable {
2050
2050
  return {
2051
2051
  ...super.getState(forRestore),
2052
2052
  ...(forRestore ? {
2053
- initialItems: this.items.length,
2054
2053
  ':items': undefined,
2055
2054
  ':itemsOrder': undefined
2056
2055
  } : {}),
@@ -2176,7 +2175,8 @@ class Container extends Scriptable {
2176
2175
  if (typeof (this._jsonModel.initialItems) !== 'number') {
2177
2176
  this._jsonModel.initialItems = Math.max(1, this._jsonModel.minItems);
2178
2177
  }
2179
- for (let i = 0; i < this._jsonModel.initialItems; i++) {
2178
+ const itemsLength = mode === 'restore' ? this._jsonModel.items.length : this._jsonModel.initialItems;
2179
+ for (let i = 0; i < itemsLength; i++) {
2180
2180
  let child;
2181
2181
  if (mode === 'restore') {
2182
2182
  let itemTemplate = this._itemTemplate;
@@ -2825,6 +2825,8 @@ const createAction = (name, payload = {}, dispatch = false) => {
2825
2825
  return new Valid(payload);
2826
2826
  case 'initialize':
2827
2827
  return new Initialize(payload);
2828
+ case 'focus':
2829
+ return new Focus(payload);
2828
2830
  default:
2829
2831
  console.error('invalid action');
2830
2832
  }
@@ -3891,7 +3893,7 @@ class Field extends Scriptable {
3891
3893
  this._jsonModel.value = undefined;
3892
3894
  }
3893
3895
  else if (this.fieldType === 'image') {
3894
- this._jsonModel.value = this._jsonModel.properties['fd:repoPath'] ?? this._jsonModel.value;
3896
+ this._jsonModel.value = this._jsonModel?.properties?.['fd:repoPath'] ?? this._jsonModel.value;
3895
3897
  }
3896
3898
  else {
3897
3899
  this._jsonModel.default = this._jsonModel.default || this._jsonModel.value;
@@ -4098,7 +4100,7 @@ class Field extends Scriptable {
4098
4100
  return this.executeExpression(this.displayValueExpression);
4099
4101
  }
4100
4102
  const df = this.displayFormat;
4101
- if (df && this.isNotEmpty(this.value) && this.valid !== false) {
4103
+ if (df && this.isNotEmpty(this.value) && this?.validity?.typeMismatch !== true) {
4102
4104
  try {
4103
4105
  return format(this.value, this.lang, df);
4104
4106
  }
@@ -32,7 +32,6 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
32
32
  items: any[];
33
33
  enabled: boolean | undefined;
34
34
  readOnly: any;
35
- initialItems?: number | undefined;
36
35
  ':items'?: undefined;
37
36
  ':itemsOrder'?: undefined;
38
37
  _dependents?: string[] | undefined;
@@ -100,7 +100,6 @@ declare class Form extends Container<FormJson> implements FormModel {
100
100
  items: any[];
101
101
  enabled: boolean | undefined;
102
102
  readOnly: any;
103
- initialItems?: number | undefined;
104
103
  ':items'?: undefined;
105
104
  ':itemsOrder'?: undefined;
106
105
  _dependents?: string[] | undefined;
@@ -69,7 +69,7 @@ export declare class ValidationComplete extends ActionImpl {
69
69
  constructor(payload?: Array<ValidationError>, dispatch?: boolean);
70
70
  }
71
71
  export declare class Focus extends ActionImpl {
72
- constructor();
72
+ constructor(payload?: any, dispatch?: boolean);
73
73
  }
74
74
  export declare class Submit extends ActionImpl {
75
75
  constructor(payload?: any, dispatch?: boolean);
@@ -15,7 +15,7 @@ export interface ScriptableField {
15
15
  readonly ruleEngine: RuleEngine;
16
16
  }
17
17
  interface WithState<T> {
18
- getState: () => any;
18
+ getState: (forRestore?: boolean) => any;
19
19
  }
20
20
  type stateProps = {
21
21
  id: string;
@@ -32,7 +32,6 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
32
32
  items: any[];
33
33
  enabled: boolean | undefined;
34
34
  readOnly: any;
35
- initialItems?: number | undefined;
36
35
  ':items'?: undefined;
37
36
  ':itemsOrder'?: undefined;
38
37
  _dependents?: string[] | undefined;
package/lib/Container.js CHANGED
@@ -114,7 +114,6 @@ class Container extends Scriptable_1.default {
114
114
  }
115
115
  getState(isRepeatableChild = false, forRestore = false) {
116
116
  return Object.assign(Object.assign(Object.assign({}, super.getState(forRestore)), (forRestore ? {
117
- initialItems: this.items.length,
118
117
  ':items': undefined,
119
118
  ':itemsOrder': undefined
120
119
  } : {})), { items: this.getItemsState(isRepeatableChild, forRestore), enabled: this.enabled, readOnly: this.readOnly });
@@ -228,7 +227,8 @@ class Container extends Scriptable_1.default {
228
227
  if (typeof (this._jsonModel.initialItems) !== 'number') {
229
228
  this._jsonModel.initialItems = Math.max(1, this._jsonModel.minItems);
230
229
  }
231
- for (let i = 0; i < this._jsonModel.initialItems; i++) {
230
+ const itemsLength = mode === 'restore' ? this._jsonModel.items.length : this._jsonModel.initialItems;
231
+ for (let i = 0; i < itemsLength; i++) {
232
232
  let child;
233
233
  if (mode === 'restore') {
234
234
  let itemTemplate = this._itemTemplate;
package/lib/Field.js CHANGED
@@ -100,7 +100,7 @@ class Field extends Scriptable_1.default {
100
100
  return finalType;
101
101
  }
102
102
  _applyDefaults() {
103
- var _a;
103
+ var _a, _b, _c;
104
104
  super._applyDefaultsInModel();
105
105
  this.coerceParam('required', 'boolean');
106
106
  this.coerceParam('readOnly', 'boolean');
@@ -113,7 +113,7 @@ class Field extends Scriptable_1.default {
113
113
  this._jsonModel.value = undefined;
114
114
  }
115
115
  else if (this.fieldType === 'image') {
116
- this._jsonModel.value = (_a = this._jsonModel.properties['fd:repoPath']) !== null && _a !== void 0 ? _a : this._jsonModel.value;
116
+ this._jsonModel.value = (_c = (_b = (_a = this._jsonModel) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b['fd:repoPath']) !== null && _c !== void 0 ? _c : this._jsonModel.value;
117
117
  }
118
118
  else {
119
119
  this._jsonModel.default = this._jsonModel.default || this._jsonModel.value;
@@ -315,11 +315,12 @@ class Field extends Scriptable_1.default {
315
315
  }
316
316
  }
317
317
  get displayValue() {
318
+ var _a;
318
319
  if (this.displayValueExpression && typeof this.displayValueExpression === 'string' && this.displayValueExpression.length !== 0) {
319
320
  return this.executeExpression(this.displayValueExpression);
320
321
  }
321
322
  const df = this.displayFormat;
322
- if (df && this.isNotEmpty(this.value) && this.valid !== false) {
323
+ if (df && this.isNotEmpty(this.value) && ((_a = this === null || this === void 0 ? void 0 : this.validity) === null || _a === void 0 ? void 0 : _a.typeMismatch) !== true) {
323
324
  try {
324
325
  return (0, af_formatters_1.format)(this.value, this.lang, df);
325
326
  }
package/lib/Form.d.ts CHANGED
@@ -100,7 +100,6 @@ declare class Form extends Container<FormJson> implements FormModel {
100
100
  items: any[];
101
101
  enabled: boolean | undefined;
102
102
  readOnly: any;
103
- initialItems?: number | undefined;
104
103
  ':items'?: undefined;
105
104
  ':itemsOrder'?: undefined;
106
105
  _dependents?: string[] | undefined;
@@ -69,7 +69,7 @@ export declare class ValidationComplete extends ActionImpl {
69
69
  constructor(payload?: Array<ValidationError>, dispatch?: boolean);
70
70
  }
71
71
  export declare class Focus extends ActionImpl {
72
- constructor();
72
+ constructor(payload?: any, dispatch?: boolean);
73
73
  }
74
74
  export declare class Submit extends ActionImpl {
75
75
  constructor(payload?: any, dispatch?: boolean);
@@ -120,8 +120,8 @@ class ValidationComplete extends ActionImpl {
120
120
  }
121
121
  exports.ValidationComplete = ValidationComplete;
122
122
  class Focus extends ActionImpl {
123
- constructor() {
124
- super({}, 'focus', { dispatch: false });
123
+ constructor(payload, dispatch = false) {
124
+ super(payload, 'focus', { dispatch });
125
125
  }
126
126
  }
127
127
  exports.Focus = Focus;
@@ -191,6 +191,8 @@ const createAction = (name, payload = {}, dispatch = false) => {
191
191
  return new Events_1.Valid(payload);
192
192
  case 'initialize':
193
193
  return new Events_1.Initialize(payload);
194
+ case 'focus':
195
+ return new Events_1.Focus(payload);
194
196
  default:
195
197
  console.error('invalid action');
196
198
  }
@@ -15,7 +15,7 @@ export interface ScriptableField {
15
15
  readonly ruleEngine: RuleEngine;
16
16
  }
17
17
  interface WithState<T> {
18
- getState: () => any;
18
+ getState: (forRestore?: boolean) => any;
19
19
  }
20
20
  declare type stateProps = {
21
21
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.120",
3
+ "version": "0.22.121",
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.120"
40
+ "@aemforms/af-formatters": "^0.22.121"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",