@aemforms/af-core 0.22.120 → 0.22.122

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 {
@@ -182,5 +182,15 @@ class RemoveInstance extends ActionImpl {
182
182
  super(payload, 'removeInstance');
183
183
  }
184
184
  }
185
+ class RequestSuccess extends ActionImpl {
186
+ constructor(payload, dispatch = false) {
187
+ super(payload, 'requestSuccess', { dispatch });
188
+ }
189
+ }
190
+ class RequestFailure extends ActionImpl {
191
+ constructor(payload, dispatch = false) {
192
+ super(payload, 'requestFailure', { dispatch });
193
+ }
194
+ }
185
195
 
186
- export { AddInstance, AddItem, Blur, Change, Click, CustomEvent, ExecuteRule, FieldChanged, Focus, FormLoad, Initialize, Invalid, RemoveInstance, RemoveItem, Reset, Save, Submit, SubmitError, SubmitFailure, SubmitSuccess, UIChange, Valid, ValidationComplete, propertyChange };
196
+ export { AddInstance, AddItem, Blur, Change, Click, CustomEvent, ExecuteRule, FieldChanged, Focus, FormLoad, Initialize, Invalid, RemoveInstance, RemoveItem, RequestFailure, RequestSuccess, Reset, Save, Submit, SubmitError, SubmitFailure, SubmitSuccess, UIChange, Valid, ValidationComplete, propertyChange };
@@ -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, RequestSuccess, SubmitError, SubmitFailure, RequestFailure, 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
 
@@ -156,6 +156,10 @@ const isEmailInput = function (item) {
156
156
  const fieldType = item?.fieldType || defaultFieldTypes(item);
157
157
  return (fieldType === 'text-input' && item?.format === 'email') || fieldType === 'email';
158
158
  };
159
+ const isDateTimeField = function (item) {
160
+ const fieldType = item?.fieldType || defaultFieldTypes(item);
161
+ return (fieldType === 'text-input' && item?.format === 'date-time') || fieldType === 'datetime-input';
162
+ };
159
163
  const isDateField = function (item) {
160
164
  const fieldType = item?.fieldType || defaultFieldTypes(item);
161
165
  return (fieldType === 'text-input' && item?.format === 'date') || fieldType === 'date-input';
@@ -1030,7 +1034,8 @@ const ValidConstraints = {
1030
1034
  number: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'],
1031
1035
  array: ['minItems', 'maxItems', 'uniqueItems'],
1032
1036
  file: ['accept', 'maxFileSize'],
1033
- email: ['minLength', 'maxLength', 'format', 'pattern']
1037
+ email: ['minLength', 'maxLength', 'format', 'pattern'],
1038
+ datetime: ['minimum', 'maximum']
1034
1039
  };
1035
1040
  const validationConstraintsList = ['type', 'format', 'minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'minItems',
1036
1041
  'maxItems', 'uniqueItems', 'minLength', 'maxLength', 'pattern', 'required', 'enum', 'accept', 'maxFileSize'];
@@ -1914,6 +1919,7 @@ class Scriptable extends BaseNode {
1914
1919
  target: this.getRuleNode()
1915
1920
  }
1916
1921
  };
1922
+ this.ruleEngine.setDependencyTracking(['change', 'executeRule'].includes(action.type));
1917
1923
  const eventName = action.isCustomEvent ? `custom:${action.type}` : action.type;
1918
1924
  const funcName = action.isCustomEvent ? `custom_${action.type}` : action.type;
1919
1925
  const node = this.getCompiledEvent(eventName);
@@ -2050,7 +2056,6 @@ class Container extends Scriptable {
2050
2056
  return {
2051
2057
  ...super.getState(forRestore),
2052
2058
  ...(forRestore ? {
2053
- initialItems: this.items.length,
2054
2059
  ':items': undefined,
2055
2060
  ':itemsOrder': undefined
2056
2061
  } : {}),
@@ -2176,7 +2181,8 @@ class Container extends Scriptable {
2176
2181
  if (typeof (this._jsonModel.initialItems) !== 'number') {
2177
2182
  this._jsonModel.initialItems = Math.max(1, this._jsonModel.minItems);
2178
2183
  }
2179
- for (let i = 0; i < this._jsonModel.initialItems; i++) {
2184
+ const itemsLength = mode === 'restore' ? this._jsonModel.items.length : this._jsonModel.initialItems;
2185
+ for (let i = 0; i < itemsLength; i++) {
2180
2186
  let child;
2181
2187
  if (mode === 'restore') {
2182
2188
  let itemTemplate = this._itemTemplate;
@@ -2724,6 +2730,7 @@ const request = async (context, uri, httpVerb, payload, success, error, headers)
2724
2730
  else {
2725
2731
  context.form.dispatch(new CustomEvent(eName, response, true));
2726
2732
  }
2733
+ context.form.dispatch(new RequestSuccess(response, true));
2727
2734
  }
2728
2735
  else {
2729
2736
  context.form.logger.error('Error invoking a rest API');
@@ -2735,6 +2742,7 @@ const request = async (context, uri, httpVerb, payload, success, error, headers)
2735
2742
  else {
2736
2743
  context.form.dispatch(new CustomEvent(eName, response, true));
2737
2744
  }
2745
+ context.form.dispatch(new RequestFailure(response, true));
2738
2746
  }
2739
2747
  };
2740
2748
  const urlEncoded = (data) => {
@@ -2825,6 +2833,8 @@ const createAction = (name, payload = {}, dispatch = false) => {
2825
2833
  return new Valid(payload);
2826
2834
  case 'initialize':
2827
2835
  return new Initialize(payload);
2836
+ case 'focus':
2837
+ return new Focus(payload);
2828
2838
  default:
2829
2839
  console.error('invalid action');
2830
2840
  }
@@ -3868,6 +3878,7 @@ class Field extends Scriptable {
3868
3878
  'multiline-input': 'string',
3869
3879
  'number-input': 'number',
3870
3880
  'date-input': 'string',
3881
+ 'date-time': 'string',
3871
3882
  'email': 'string',
3872
3883
  'plain-text': 'string',
3873
3884
  'image': 'string',
@@ -3891,7 +3902,7 @@ class Field extends Scriptable {
3891
3902
  this._jsonModel.value = undefined;
3892
3903
  }
3893
3904
  else if (this.fieldType === 'image') {
3894
- this._jsonModel.value = this._jsonModel.properties['fd:repoPath'] ?? this._jsonModel.value;
3905
+ this._jsonModel.value = this._jsonModel?.properties?.['fd:repoPath'] ?? this._jsonModel.value;
3895
3906
  }
3896
3907
  else {
3897
3908
  this._jsonModel.default = this._jsonModel.default || this._jsonModel.value;
@@ -3942,7 +3953,7 @@ class Field extends Scriptable {
3942
3953
  }
3943
3954
  this.coerceParam('minLength', 'number');
3944
3955
  this.coerceParam('maxLength', 'number');
3945
- if (this._jsonModel.type !== 'number' && this._jsonModel.format !== 'date' && this._jsonModel.type !== 'integer') {
3956
+ if (this._jsonModel.type !== 'number' && this._jsonModel.format !== 'date' && this._jsonModel.format !== 'date-time' && this._jsonModel.type !== 'integer') {
3946
3957
  this.unset('step', ...props);
3947
3958
  }
3948
3959
  props.forEach(c => {
@@ -4045,22 +4056,22 @@ class Field extends Scriptable {
4045
4056
  this._setProperty('required', r);
4046
4057
  }
4047
4058
  get maximum() {
4048
- if (this.type === 'number' || this.format === 'date' || this.type === 'integer') {
4059
+ if (this.type === 'number' || this.format === 'date' || this.format === 'date-time' || this.type === 'integer') {
4049
4060
  return this._jsonModel.maximum;
4050
4061
  }
4051
4062
  }
4052
4063
  set maximum(m) {
4053
- if (this.type === 'number' || this.format === 'date' || this.type === 'integer') {
4064
+ if (this.type === 'number' || this.format === 'date' || this.format === 'date-time' || this.type === 'integer') {
4054
4065
  this._setProperty('maximum', m);
4055
4066
  }
4056
4067
  }
4057
4068
  get minimum() {
4058
- if (this.type === 'number' || this.format === 'date' || this.type === 'integer') {
4069
+ if (this.type === 'number' || this.format === 'date' || this.format === 'date-time' || this.type === 'integer') {
4059
4070
  return this._jsonModel.minimum;
4060
4071
  }
4061
4072
  }
4062
4073
  set minimum(m) {
4063
- if (this.type === 'number' || this.format === 'date' || this.type === 'integer') {
4074
+ if (this.type === 'number' || this.format === 'date' || this.format === 'date-time' || this.type === 'integer') {
4064
4075
  this._setProperty('minimum', m);
4065
4076
  }
4066
4077
  }
@@ -4098,7 +4109,7 @@ class Field extends Scriptable {
4098
4109
  return this.executeExpression(this.displayValueExpression);
4099
4110
  }
4100
4111
  const df = this.displayFormat;
4101
- if (df && this.isNotEmpty(this.value) && this.valid !== false) {
4112
+ if (df && this.isNotEmpty(this.value) && this?.validity?.typeMismatch !== true) {
4102
4113
  try {
4103
4114
  return format(this.value, this.lang, df);
4104
4115
  }
@@ -4305,6 +4316,8 @@ class Field extends Scriptable {
4305
4316
  switch (this.format) {
4306
4317
  case 'date':
4307
4318
  return ValidConstraints.date;
4319
+ case 'date-time':
4320
+ return ValidConstraints.datetime;
4308
4321
  case 'email':
4309
4322
  return ValidConstraints.email;
4310
4323
  case 'binary':
@@ -4335,6 +4348,9 @@ class Field extends Scriptable {
4335
4348
  case 'file-input':
4336
4349
  this._jsonModel.format = 'data-url';
4337
4350
  break;
4351
+ case 'date-time':
4352
+ this._jsonModel.format = 'date-time';
4353
+ break;
4338
4354
  }
4339
4355
  }
4340
4356
  }
@@ -4555,7 +4571,7 @@ __decorate([
4555
4571
  dependencyTracked()
4556
4572
  ], Field.prototype, "errorMessage", null);
4557
4573
  __decorate([
4558
- include('text-input', 'date-input', 'file-input', 'email')
4574
+ include('text-input', 'date-input', 'file-input', 'email', 'datetime-input')
4559
4575
  ], Field.prototype, "format", null);
4560
4576
  __decorate([
4561
4577
  include('text-input')
@@ -4846,6 +4862,19 @@ class DateField extends Field {
4846
4862
  }
4847
4863
  }
4848
4864
 
4865
+ class DateTimeField extends DateField {
4866
+ _dataFormat = 'yyyy-MM-ddTHH:mm';
4867
+ _applyDefaults() {
4868
+ super._applyDefaults();
4869
+ }
4870
+ get value() {
4871
+ return super.value;
4872
+ }
4873
+ set value(value) {
4874
+ super.value = value;
4875
+ }
4876
+ }
4877
+
4849
4878
  class EmailInput extends Field {
4850
4879
  _getDefaults() {
4851
4880
  return {
@@ -4960,6 +4989,9 @@ class FormFieldFactoryImpl {
4960
4989
  else if (isDateField(child)) {
4961
4990
  retVal = new DateField(child, options);
4962
4991
  }
4992
+ else if (isDateTimeField(child)) {
4993
+ retVal = new DateTimeField(child, options);
4994
+ }
4963
4995
  else if (isCaptcha(child)) {
4964
4996
  retVal = new Captcha(child, options);
4965
4997
  }
@@ -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;
@@ -2,7 +2,7 @@ import Field from './Field';
2
2
  declare class DateField extends Field {
3
3
  #private;
4
4
  private locale?;
5
- private _dataFormat;
5
+ protected _dataFormat: string;
6
6
  protected _applyDefaults(): void;
7
7
  get value(): any;
8
8
  set value(value: any);
@@ -0,0 +1,8 @@
1
+ import DateField from './DateField';
2
+ declare class DateTimeField extends DateField {
3
+ protected _dataFormat: string;
4
+ protected _applyDefaults(): void;
5
+ get value(): any;
6
+ set value(value: any);
7
+ }
8
+ export default DateTimeField;
@@ -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);
@@ -108,4 +108,10 @@ export declare class AddInstance extends ActionImpl {
108
108
  export declare class RemoveInstance extends ActionImpl {
109
109
  constructor(payload?: number);
110
110
  }
111
+ export declare class RequestSuccess extends ActionImpl {
112
+ constructor(payload?: any, dispatch?: boolean);
113
+ }
114
+ export declare class RequestFailure extends ActionImpl {
115
+ constructor(payload?: any, dispatch?: boolean);
116
+ }
111
117
  export {};
@@ -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;
@@ -5,6 +5,7 @@ export declare const checkIfConstraintsArePresent: (item: FieldsetJson | FieldJs
5
5
  export declare const isCheckbox: (item: FieldsetJson | FieldJson) => boolean;
6
6
  export declare const isCheckboxGroup: (item: FieldsetJson | FieldJson) => boolean;
7
7
  export declare const isEmailInput: (item: FieldsetJson | FieldJson) => boolean;
8
+ export declare const isDateTimeField: (item: FieldsetJson | FieldJson) => boolean;
8
9
  export declare const isDateField: (item: FieldsetJson | FieldJson) => boolean;
9
10
  export declare const isCaptcha: (item: FieldsetJson | FieldJson) => boolean;
10
11
  export declare const isButton: (item: FieldsetJson | FieldJson) => boolean;
@@ -10,6 +10,7 @@ type ValidConstraintsType = {
10
10
  array: ValidationConstraints[];
11
11
  file: ValidationConstraints[];
12
12
  email: ValidationConstraints[];
13
+ datetime: ValidationConstraints[];
13
14
  };
14
15
  export declare const ValidConstraints: ValidConstraintsType;
15
16
  export declare const validationConstraintsList: readonly ["type", "format", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "minItems", "maxItems", "uniqueItems", "minLength", "maxLength", "pattern", "required", "enum", "accept", "maxFileSize"];
@@ -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;
@@ -2,7 +2,7 @@ import Field from './Field';
2
2
  declare class DateField extends Field {
3
3
  #private;
4
4
  private locale?;
5
- private _dataFormat;
5
+ protected _dataFormat: string;
6
6
  protected _applyDefaults(): void;
7
7
  get value(): any;
8
8
  set value(value: any);
@@ -0,0 +1,8 @@
1
+ import DateField from './DateField';
2
+ declare class DateTimeField extends DateField {
3
+ protected _dataFormat: string;
4
+ protected _applyDefaults(): void;
5
+ get value(): any;
6
+ set value(value: any);
7
+ }
8
+ export default DateTimeField;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const DateField_1 = __importDefault(require("./DateField"));
7
+ class DateTimeField extends DateField_1.default {
8
+ constructor() {
9
+ super(...arguments);
10
+ this._dataFormat = 'yyyy-MM-ddTHH:mm';
11
+ }
12
+ _applyDefaults() {
13
+ super._applyDefaults();
14
+ }
15
+ get value() {
16
+ return super.value;
17
+ }
18
+ set value(value) {
19
+ super.value = value;
20
+ }
21
+ }
22
+ exports.default = DateTimeField;
package/lib/Field.js CHANGED
@@ -89,6 +89,7 @@ class Field extends Scriptable_1.default {
89
89
  'multiline-input': 'string',
90
90
  'number-input': 'number',
91
91
  'date-input': 'string',
92
+ 'date-time': 'string',
92
93
  'email': 'string',
93
94
  'plain-text': 'string',
94
95
  'image': 'string',
@@ -100,7 +101,7 @@ class Field extends Scriptable_1.default {
100
101
  return finalType;
101
102
  }
102
103
  _applyDefaults() {
103
- var _a;
104
+ var _a, _b, _c;
104
105
  super._applyDefaultsInModel();
105
106
  this.coerceParam('required', 'boolean');
106
107
  this.coerceParam('readOnly', 'boolean');
@@ -113,7 +114,7 @@ class Field extends Scriptable_1.default {
113
114
  this._jsonModel.value = undefined;
114
115
  }
115
116
  else if (this.fieldType === 'image') {
116
- this._jsonModel.value = (_a = this._jsonModel.properties['fd:repoPath']) !== null && _a !== void 0 ? _a : this._jsonModel.value;
117
+ 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
118
  }
118
119
  else {
119
120
  this._jsonModel.default = this._jsonModel.default || this._jsonModel.value;
@@ -164,7 +165,7 @@ class Field extends Scriptable_1.default {
164
165
  }
165
166
  this.coerceParam('minLength', 'number');
166
167
  this.coerceParam('maxLength', 'number');
167
- if (this._jsonModel.type !== 'number' && this._jsonModel.format !== 'date' && this._jsonModel.type !== 'integer') {
168
+ if (this._jsonModel.type !== 'number' && this._jsonModel.format !== 'date' && this._jsonModel.format !== 'date-time' && this._jsonModel.type !== 'integer') {
168
169
  this.unset('step', ...props);
169
170
  }
170
171
  props.forEach(c => {
@@ -266,22 +267,22 @@ class Field extends Scriptable_1.default {
266
267
  this._setProperty('required', r);
267
268
  }
268
269
  get maximum() {
269
- if (this.type === 'number' || this.format === 'date' || this.type === 'integer') {
270
+ if (this.type === 'number' || this.format === 'date' || this.format === 'date-time' || this.type === 'integer') {
270
271
  return this._jsonModel.maximum;
271
272
  }
272
273
  }
273
274
  set maximum(m) {
274
- if (this.type === 'number' || this.format === 'date' || this.type === 'integer') {
275
+ if (this.type === 'number' || this.format === 'date' || this.format === 'date-time' || this.type === 'integer') {
275
276
  this._setProperty('maximum', m);
276
277
  }
277
278
  }
278
279
  get minimum() {
279
- if (this.type === 'number' || this.format === 'date' || this.type === 'integer') {
280
+ if (this.type === 'number' || this.format === 'date' || this.format === 'date-time' || this.type === 'integer') {
280
281
  return this._jsonModel.minimum;
281
282
  }
282
283
  }
283
284
  set minimum(m) {
284
- if (this.type === 'number' || this.format === 'date' || this.type === 'integer') {
285
+ if (this.type === 'number' || this.format === 'date' || this.format === 'date-time' || this.type === 'integer') {
285
286
  this._setProperty('minimum', m);
286
287
  }
287
288
  }
@@ -315,11 +316,12 @@ class Field extends Scriptable_1.default {
315
316
  }
316
317
  }
317
318
  get displayValue() {
319
+ var _a;
318
320
  if (this.displayValueExpression && typeof this.displayValueExpression === 'string' && this.displayValueExpression.length !== 0) {
319
321
  return this.executeExpression(this.displayValueExpression);
320
322
  }
321
323
  const df = this.displayFormat;
322
- if (df && this.isNotEmpty(this.value) && this.valid !== false) {
324
+ 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
325
  try {
324
326
  return (0, af_formatters_1.format)(this.value, this.lang, df);
325
327
  }
@@ -526,6 +528,8 @@ class Field extends Scriptable_1.default {
526
528
  switch (this.format) {
527
529
  case 'date':
528
530
  return ValidationUtils_1.ValidConstraints.date;
531
+ case 'date-time':
532
+ return ValidationUtils_1.ValidConstraints.datetime;
529
533
  case 'email':
530
534
  return ValidationUtils_1.ValidConstraints.email;
531
535
  case 'binary':
@@ -556,6 +560,9 @@ class Field extends Scriptable_1.default {
556
560
  case 'file-input':
557
561
  this._jsonModel.format = 'data-url';
558
562
  break;
563
+ case 'date-time':
564
+ this._jsonModel.format = 'date-time';
565
+ break;
559
566
  }
560
567
  }
561
568
  }
@@ -759,7 +766,7 @@ __decorate([
759
766
  (0, BaseNode_1.dependencyTracked)()
760
767
  ], Field.prototype, "errorMessage", null);
761
768
  __decorate([
762
- (0, BaseNode_1.include)('text-input', 'date-input', 'file-input', 'email')
769
+ (0, BaseNode_1.include)('text-input', 'date-input', 'file-input', 'email', 'datetime-input')
763
770
  ], Field.prototype, "format", null);
764
771
  __decorate([
765
772
  (0, BaseNode_1.include)('text-input')
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;
package/lib/Scriptable.js CHANGED
@@ -182,6 +182,7 @@ class Scriptable extends BaseNode_1.BaseNode {
182
182
  target: this.getRuleNode()
183
183
  }
184
184
  };
185
+ this.ruleEngine.setDependencyTracking(['change', 'executeRule'].includes(action.type));
185
186
  const eventName = action.isCustomEvent ? `custom:${action.type}` : action.type;
186
187
  const funcName = action.isCustomEvent ? `custom_${action.type}` : action.type;
187
188
  const node = this.getCompiledEvent(eventName);
@@ -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);
@@ -108,4 +108,10 @@ export declare class AddInstance extends ActionImpl {
108
108
  export declare class RemoveInstance extends ActionImpl {
109
109
  constructor(payload?: number);
110
110
  }
111
+ export declare class RequestSuccess extends ActionImpl {
112
+ constructor(payload?: any, dispatch?: boolean);
113
+ }
114
+ export declare class RequestFailure extends ActionImpl {
115
+ constructor(payload?: any, dispatch?: boolean);
116
+ }
111
117
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RemoveInstance = exports.AddInstance = exports.RemoveItem = exports.AddItem = exports.CustomEvent = exports.FieldChanged = exports.Reset = exports.SubmitError = exports.SubmitFailure = exports.SubmitSuccess = exports.Save = exports.Submit = exports.Focus = exports.ValidationComplete = exports.Blur = exports.Click = exports.FormLoad = exports.Initialize = exports.propertyChange = exports.ExecuteRule = exports.Valid = exports.Invalid = exports.UIChange = exports.Change = void 0;
3
+ exports.RequestFailure = exports.RequestSuccess = exports.RemoveInstance = exports.AddInstance = exports.RemoveItem = exports.AddItem = exports.CustomEvent = exports.FieldChanged = exports.Reset = exports.SubmitError = exports.SubmitFailure = exports.SubmitSuccess = exports.Save = exports.Submit = exports.Focus = exports.ValidationComplete = exports.Blur = exports.Click = exports.FormLoad = exports.Initialize = exports.propertyChange = exports.ExecuteRule = exports.Valid = exports.Invalid = exports.UIChange = exports.Change = void 0;
4
4
  var EventSource;
5
5
  (function (EventSource) {
6
6
  EventSource["CODE"] = "code";
@@ -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;
@@ -204,3 +204,15 @@ class RemoveInstance extends ActionImpl {
204
204
  }
205
205
  }
206
206
  exports.RemoveInstance = RemoveInstance;
207
+ class RequestSuccess extends ActionImpl {
208
+ constructor(payload, dispatch = false) {
209
+ super(payload, 'requestSuccess', { dispatch });
210
+ }
211
+ }
212
+ exports.RequestSuccess = RequestSuccess;
213
+ class RequestFailure extends ActionImpl {
214
+ constructor(payload, dispatch = false) {
215
+ super(payload, 'requestFailure', { dispatch });
216
+ }
217
+ }
218
+ exports.RequestFailure = RequestFailure;
@@ -88,6 +88,7 @@ const request = (context, uri, httpVerb, payload, success, error, headers) => __
88
88
  else {
89
89
  context.form.dispatch(new Events_1.CustomEvent(eName, response, true));
90
90
  }
91
+ context.form.dispatch(new Events_1.RequestSuccess(response, true));
91
92
  }
92
93
  else {
93
94
  context.form.logger.error('Error invoking a rest API');
@@ -99,6 +100,7 @@ const request = (context, uri, httpVerb, payload, success, error, headers) => __
99
100
  else {
100
101
  context.form.dispatch(new Events_1.CustomEvent(eName, response, true));
101
102
  }
103
+ context.form.dispatch(new Events_1.RequestFailure(response, true));
102
104
  }
103
105
  });
104
106
  exports.request = request;
@@ -191,6 +193,8 @@ const createAction = (name, payload = {}, dispatch = false) => {
191
193
  return new Events_1.Valid(payload);
192
194
  case 'initialize':
193
195
  return new Events_1.Initialize(payload);
196
+ case 'focus':
197
+ return new Events_1.Focus(payload);
194
198
  default:
195
199
  console.error('invalid action');
196
200
  }
@@ -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;
@@ -11,6 +11,7 @@ const FileUpload_1 = __importDefault(require("../FileUpload"));
11
11
  const Checkbox_1 = __importDefault(require("../Checkbox"));
12
12
  const CheckboxGroup_1 = __importDefault(require("../CheckboxGroup"));
13
13
  const DateField_1 = __importDefault(require("../DateField"));
14
+ const DateTimeField_1 = __importDefault(require("../DateTimeField"));
14
15
  const Field_1 = __importDefault(require("../Field"));
15
16
  const EmailInput_1 = __importDefault(require("../EmailInput"));
16
17
  const Captcha_1 = __importDefault(require("../Captcha"));
@@ -66,6 +67,9 @@ class FormFieldFactoryImpl {
66
67
  else if ((0, JsonUtils_1.isDateField)(child)) {
67
68
  retVal = new DateField_1.default(child, options);
68
69
  }
70
+ else if ((0, JsonUtils_1.isDateTimeField)(child)) {
71
+ retVal = new DateTimeField_1.default(child, options);
72
+ }
69
73
  else if ((0, JsonUtils_1.isCaptcha)(child)) {
70
74
  retVal = new Captcha_1.default(child, options);
71
75
  }
@@ -5,6 +5,7 @@ export declare const checkIfConstraintsArePresent: (item: FieldsetJson | FieldJs
5
5
  export declare const isCheckbox: (item: FieldsetJson | FieldJson) => boolean;
6
6
  export declare const isCheckboxGroup: (item: FieldsetJson | FieldJson) => boolean;
7
7
  export declare const isEmailInput: (item: FieldsetJson | FieldJson) => boolean;
8
+ export declare const isDateTimeField: (item: FieldsetJson | FieldJson) => boolean;
8
9
  export declare const isDateField: (item: FieldsetJson | FieldJson) => boolean;
9
10
  export declare const isCaptcha: (item: FieldsetJson | FieldJson) => boolean;
10
11
  export declare const isButton: (item: FieldsetJson | FieldJson) => boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRepeatable = exports.jsonString = exports.checkIfKeyAdded = exports.deepClone = exports.isButton = exports.isCaptcha = exports.isDateField = exports.isEmailInput = exports.isCheckboxGroup = exports.isCheckbox = exports.checkIfConstraintsArePresent = exports.isFile = exports.getProperty = void 0;
3
+ exports.isRepeatable = exports.jsonString = exports.checkIfKeyAdded = exports.deepClone = exports.isButton = exports.isCaptcha = exports.isDateField = exports.isDateTimeField = exports.isEmailInput = exports.isCheckboxGroup = exports.isCheckbox = exports.checkIfConstraintsArePresent = exports.isFile = exports.getProperty = void 0;
4
4
  const index_1 = require("../types/index");
5
5
  const SchemaUtils_1 = require("./SchemaUtils");
6
6
  const getProperty = (data, key, def) => {
@@ -42,6 +42,11 @@ const isEmailInput = function (item) {
42
42
  return (fieldType === 'text-input' && (item === null || item === void 0 ? void 0 : item.format) === 'email') || fieldType === 'email';
43
43
  };
44
44
  exports.isEmailInput = isEmailInput;
45
+ const isDateTimeField = function (item) {
46
+ const fieldType = (item === null || item === void 0 ? void 0 : item.fieldType) || (0, SchemaUtils_1.defaultFieldTypes)(item);
47
+ return (fieldType === 'text-input' && (item === null || item === void 0 ? void 0 : item.format) === 'date-time') || fieldType === 'datetime-input';
48
+ };
49
+ exports.isDateTimeField = isDateTimeField;
45
50
  const isDateField = function (item) {
46
51
  const fieldType = (item === null || item === void 0 ? void 0 : item.fieldType) || (0, SchemaUtils_1.defaultFieldTypes)(item);
47
52
  return (fieldType === 'text-input' && (item === null || item === void 0 ? void 0 : item.format) === 'date') || fieldType === 'date-input';
@@ -10,6 +10,7 @@ declare type ValidConstraintsType = {
10
10
  array: ValidationConstraints[];
11
11
  file: ValidationConstraints[];
12
12
  email: ValidationConstraints[];
13
+ datetime: ValidationConstraints[];
13
14
  };
14
15
  export declare const ValidConstraints: ValidConstraintsType;
15
16
  export declare const validationConstraintsList: readonly ["type", "format", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "minItems", "maxItems", "uniqueItems", "minLength", "maxLength", "pattern", "required", "enum", "accept", "maxFileSize"];
@@ -116,7 +116,8 @@ exports.ValidConstraints = {
116
116
  number: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'],
117
117
  array: ['minItems', 'maxItems', 'uniqueItems'],
118
118
  file: ['accept', 'maxFileSize'],
119
- email: ['minLength', 'maxLength', 'format', 'pattern']
119
+ email: ['minLength', 'maxLength', 'format', 'pattern'],
120
+ datetime: ['minimum', 'maximum']
120
121
  };
121
122
  exports.validationConstraintsList = ['type', 'format', 'minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'minItems',
122
123
  'maxItems', 'uniqueItems', 'minLength', 'maxLength', 'pattern', 'required', 'enum', 'accept', 'maxFileSize'];
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.122",
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.122"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",