@aemforms/af-core 0.22.158 → 0.22.161

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/README.md CHANGED
@@ -33,6 +33,24 @@ const data = {...}
33
33
  const valid = validateFormInstance(formJson, data)
34
34
  ```
35
35
 
36
+ ## Testing Local Changes
37
+
38
+ ```bash
39
+ # Login to download dependencies
40
+ npm login
41
+
42
+ # Build the package
43
+ npm run build
44
+
45
+ # Link it for local testing
46
+ npm link
47
+ ```
48
+
49
+ In your project that uses this package:
50
+ ```bash
51
+ npm link @aemforms/af-core
52
+ ```
53
+
36
54
  ## License
37
55
 
38
56
  Copyright 2022 Adobe
@@ -545,7 +545,7 @@ const isAlphaNum = function (ch) {
545
545
  return (ch >= 'a' && ch <= 'z')
546
546
  || (ch >= 'A' && ch <= 'Z')
547
547
  || (ch >= '0' && ch <= '9')
548
- || ch === '_';
548
+ || ch === '_' || ch === '-';
549
549
  };
550
550
  const isGlobal = (prev, stream, pos) => {
551
551
  return prev === null && stream[pos] === globalStartToken;
@@ -560,7 +560,7 @@ const isIdentifier = (stream, pos) => {
560
560
  }
561
561
  return (ch >= 'a' && ch <= 'z')
562
562
  || (ch >= 'A' && ch <= 'Z')
563
- || ch === '_';
563
+ || ch === '_' || ch === '-';
564
564
  };
565
565
  const isNum = (ch) => {
566
566
  return (ch >= '0' && ch <= '9');
@@ -1366,7 +1366,8 @@ const editableProperties = [
1366
1366
  'maxItems',
1367
1367
  'minimum',
1368
1368
  'minItems',
1369
- 'checked'
1369
+ 'checked',
1370
+ 'placeholder'
1370
1371
  ];
1371
1372
  const dynamicProps = [
1372
1373
  ...editableProperties,
@@ -4628,6 +4629,9 @@ class Field extends Scriptable {
4628
4629
  get placeholder() {
4629
4630
  return this._jsonModel.placeholder;
4630
4631
  }
4632
+ set placeholder(value) {
4633
+ this._setProperty('placeholder', value);
4634
+ }
4631
4635
  get readOnly() {
4632
4636
  if (this.parent.readOnly !== undefined) {
4633
4637
  return this.parent.readOnly === true ? true : this._jsonModel.readOnly;
@@ -4729,7 +4733,7 @@ class Field extends Scriptable {
4729
4733
  }
4730
4734
  get editValue() {
4731
4735
  const df = this.editFormat;
4732
- if (df && this.isNotEmpty(this.value) && this.valid !== false) {
4736
+ if (df && this.isNotEmpty(this.value) && this?.validity?.typeMismatch !== true) {
4733
4737
  try {
4734
4738
  return format(this.value, this.lang, df);
4735
4739
  }
@@ -5439,6 +5443,20 @@ class CheckboxGroup extends Field {
5439
5443
  }
5440
5444
  }
5441
5445
 
5446
+ const warnedPatterns = new Set();
5447
+ function normalizeDatePattern(pattern) {
5448
+ if (!pattern || typeof pattern !== 'string') {
5449
+ return pattern;
5450
+ }
5451
+ const normalized = pattern
5452
+ .replace(/DD/g, 'dd')
5453
+ .replace(/YYYY/g, 'yyyy');
5454
+ if (normalized !== pattern && !warnedPatterns.has(pattern)) {
5455
+ warnedPatterns.add(pattern);
5456
+ console.warn(`[AEM Forms] Date field pattern "${pattern}" uses deprecated format. Auto-corrected to "${normalized}". Please update to use lowercase 'y' for year and 'd' for day.`);
5457
+ }
5458
+ return normalized;
5459
+ }
5442
5460
  class DateField extends Field {
5443
5461
  locale;
5444
5462
  _dataFormat = 'yyyy-MM-dd';
@@ -5448,9 +5466,13 @@ class DateField extends Field {
5448
5466
  if (!this._jsonModel.editFormat) {
5449
5467
  this._jsonModel.editFormat = 'short';
5450
5468
  }
5469
+ this._jsonModel.editFormat = normalizeDatePattern(this._jsonModel.editFormat);
5451
5470
  if (!this._jsonModel.displayFormat) {
5452
5471
  this._jsonModel.displayFormat = this._jsonModel.editFormat;
5453
5472
  }
5473
+ else {
5474
+ this._jsonModel.displayFormat = normalizeDatePattern(this._jsonModel.displayFormat);
5475
+ }
5454
5476
  if (!this._jsonModel.placeholder) {
5455
5477
  this._jsonModel.placeholder = parseDateSkeleton(this._jsonModel.editFormat, this.locale);
5456
5478
  }
@@ -32,6 +32,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
32
32
  get displayFormat(): string | undefined;
33
33
  get displayValueExpression(): string | undefined;
34
34
  get placeholder(): string | undefined;
35
+ set placeholder(value: string | undefined);
35
36
  get readOnly(): boolean | undefined;
36
37
  set readOnly(e: boolean | undefined);
37
38
  get enabled(): boolean | undefined;
package/lib/BaseNode.js CHANGED
@@ -35,7 +35,8 @@ exports.editableProperties = [
35
35
  'maxItems',
36
36
  'minimum',
37
37
  'minItems',
38
- 'checked'
38
+ 'checked',
39
+ 'placeholder'
39
40
  ];
40
41
  exports.dynamicProps = [
41
42
  ...exports.editableProperties,
package/lib/DateField.js CHANGED
@@ -11,6 +11,20 @@ var _DateField_instances, _DateField_convertNumberToDate;
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const Field_1 = __importDefault(require("./Field"));
13
13
  const af_formatters_1 = require("@aemforms/af-formatters");
14
+ const warnedPatterns = new Set();
15
+ function normalizeDatePattern(pattern) {
16
+ if (!pattern || typeof pattern !== 'string') {
17
+ return pattern;
18
+ }
19
+ const normalized = pattern
20
+ .replace(/DD/g, 'dd')
21
+ .replace(/YYYY/g, 'yyyy');
22
+ if (normalized !== pattern && !warnedPatterns.has(pattern)) {
23
+ warnedPatterns.add(pattern);
24
+ console.warn(`[AEM Forms] Date field pattern "${pattern}" uses deprecated format. Auto-corrected to "${normalized}". Please update to use lowercase 'y' for year and 'd' for day.`);
25
+ }
26
+ return normalized;
27
+ }
14
28
  class DateField extends Field_1.default {
15
29
  constructor() {
16
30
  super(...arguments);
@@ -23,9 +37,13 @@ class DateField extends Field_1.default {
23
37
  if (!this._jsonModel.editFormat) {
24
38
  this._jsonModel.editFormat = 'short';
25
39
  }
40
+ this._jsonModel.editFormat = normalizeDatePattern(this._jsonModel.editFormat);
26
41
  if (!this._jsonModel.displayFormat) {
27
42
  this._jsonModel.displayFormat = this._jsonModel.editFormat;
28
43
  }
44
+ else {
45
+ this._jsonModel.displayFormat = normalizeDatePattern(this._jsonModel.displayFormat);
46
+ }
29
47
  if (!this._jsonModel.placeholder) {
30
48
  this._jsonModel.placeholder = (0, af_formatters_1.parseDateSkeleton)(this._jsonModel.editFormat, this.locale);
31
49
  }
package/lib/Field.d.ts CHANGED
@@ -32,6 +32,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
32
32
  get displayFormat(): string | undefined;
33
33
  get displayValueExpression(): string | undefined;
34
34
  get placeholder(): string | undefined;
35
+ set placeholder(value: string | undefined);
35
36
  get readOnly(): boolean | undefined;
36
37
  set readOnly(e: boolean | undefined);
37
38
  get enabled(): boolean | undefined;
package/lib/Field.js CHANGED
@@ -212,6 +212,9 @@ class Field extends Scriptable_1.default {
212
212
  get placeholder() {
213
213
  return this._jsonModel.placeholder;
214
214
  }
215
+ set placeholder(value) {
216
+ this._setProperty('placeholder', value);
217
+ }
215
218
  get readOnly() {
216
219
  if (this.parent.readOnly !== undefined) {
217
220
  return this.parent.readOnly === true ? true : this._jsonModel.readOnly;
@@ -311,8 +314,9 @@ class Field extends Scriptable_1.default {
311
314
  return df;
312
315
  }
313
316
  get editValue() {
317
+ var _a;
314
318
  const df = this.editFormat;
315
- if (df && this.isNotEmpty(this.value) && this.valid !== false) {
319
+ 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) {
316
320
  try {
317
321
  return (0, af_formatters_1.format)(this.value, this.lang, df);
318
322
  }
@@ -49,7 +49,7 @@ const isAlphaNum = function (ch) {
49
49
  return (ch >= 'a' && ch <= 'z')
50
50
  || (ch >= 'A' && ch <= 'Z')
51
51
  || (ch >= '0' && ch <= '9')
52
- || ch === '_';
52
+ || ch === '_' || ch === '-';
53
53
  };
54
54
  const isGlobal = (prev, stream, pos) => {
55
55
  return prev === null && stream[pos] === globalStartToken;
@@ -64,7 +64,7 @@ const isIdentifier = (stream, pos) => {
64
64
  }
65
65
  return (ch >= 'a' && ch <= 'z')
66
66
  || (ch >= 'A' && ch <= 'Z')
67
- || ch === '_';
67
+ || ch === '_' || ch === '-';
68
68
  };
69
69
  const isNum = (ch) => {
70
70
  return (ch >= '0' && ch <= '9');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.158",
3
+ "version": "0.22.161",
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.158"
40
+ "@aemforms/af-formatters": "^0.22.161"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",