@aemforms/af-core 0.22.20 → 0.22.23

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.
Files changed (54) hide show
  1. package/LICENSE +18 -4
  2. package/README.md +14 -5
  3. package/lib/cjs/index.cjs +267 -1876
  4. package/lib/esm/BaseNode-dc59ab07.js +478 -0
  5. package/lib/esm/BaseNode.js +26 -454
  6. package/lib/esm/Checkbox.js +37 -1
  7. package/lib/esm/CheckboxGroup.js +38 -1
  8. package/lib/esm/Container.js +30 -9
  9. package/lib/esm/DateField.js +38 -2
  10. package/lib/esm/Field.d.ts +2 -2
  11. package/lib/esm/Field.js +62 -26
  12. package/lib/esm/Fieldset.js +36 -3
  13. package/lib/esm/FileObject.js +23 -1
  14. package/lib/esm/FileUpload.js +34 -1
  15. package/lib/esm/Form.d.ts +1 -1
  16. package/lib/esm/Form.js +40 -8
  17. package/lib/esm/FormInstance.js +53 -5
  18. package/lib/esm/FormMetaData.js +26 -1
  19. package/lib/esm/InstanceManager.js +35 -8
  20. package/lib/esm/Node.js +25 -1
  21. package/lib/esm/Scriptable.js +29 -2
  22. package/lib/esm/controller/EventQueue.js +23 -1
  23. package/lib/esm/controller/Events.d.ts +1 -1
  24. package/lib/esm/controller/Events.js +41 -19
  25. package/lib/esm/controller/Logger.d.ts +2 -2
  26. package/lib/esm/controller/Logger.js +23 -1
  27. package/lib/esm/data/DataGroup.js +24 -1
  28. package/lib/esm/data/DataValue.js +23 -1
  29. package/lib/esm/data/EmptyDataValue.js +23 -1
  30. package/lib/esm/index.js +55 -21
  31. package/lib/esm/rules/FunctionRuntime.d.ts +3 -3
  32. package/lib/esm/rules/FunctionRuntime.js +31 -6
  33. package/lib/esm/rules/RuleEngine.js +30 -1
  34. package/lib/esm/types/Json.d.ts +16 -16
  35. package/lib/esm/types/Json.js +24 -2
  36. package/lib/esm/types/Model.d.ts +4 -4
  37. package/lib/esm/types/Model.js +23 -1
  38. package/lib/esm/types/index.js +22 -2
  39. package/lib/esm/utils/DataRefParser.d.ts +2 -2
  40. package/lib/esm/utils/DataRefParser.js +31 -6
  41. package/lib/esm/utils/Fetch.d.ts +1 -1
  42. package/lib/esm/utils/Fetch.js +24 -2
  43. package/lib/esm/utils/FormCreationUtils.js +40 -2
  44. package/lib/esm/utils/FormUtils.js +33 -8
  45. package/lib/esm/utils/JsonUtils.js +34 -11
  46. package/lib/esm/utils/LogUtils.js +23 -1
  47. package/lib/esm/utils/SchemaUtils.js +24 -2
  48. package/lib/esm/utils/TranslationUtils.d.ts +1 -1
  49. package/lib/esm/utils/TranslationUtils.js +32 -9
  50. package/lib/esm/utils/ValidationUtils.d.ts +4 -4
  51. package/lib/esm/utils/ValidationUtils.js +30 -4
  52. package/package.json +4 -3
  53. package/lib/browser/afb-events.js +0 -151
  54. package/lib/browser/afb-runtime.js +0 -3620
@@ -1,5 +1,29 @@
1
- import { extractFileInfo, getFileSizeInBytes } from './FormUtils.js';
1
+ /*************************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * ___________________
4
+ *
5
+ * Copyright 2022 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+
17
+ * Adobe permits you to use and modify this file solely in accordance with
18
+ * the terms of the Adobe license agreement accompanying it.
19
+ *************************************************************************/
20
+
21
+ import { getFileSizeInBytes, extractFileInfo } from './FormUtils.js';
2
22
  import { FileObject } from '../FileObject.js';
23
+ import './JsonUtils.js';
24
+ import '../types/Json.js';
25
+ import './SchemaUtils.js';
26
+
3
27
  const dateRegex = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
4
28
  const days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
5
29
  const daysInMonth = (leapYear, month) => {
@@ -11,7 +35,7 @@ const daysInMonth = (leapYear, month) => {
11
35
  const isLeapYear = (year) => {
12
36
  return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
13
37
  };
14
- export const coerceType = (param, type) => {
38
+ const coerceType = (param, type) => {
15
39
  let num;
16
40
  switch (type) {
17
41
  case 'string':
@@ -105,14 +129,14 @@ const partitionArray = (inputVal, validatorFn) => {
105
129
  return acc;
106
130
  }, [[], []]);
107
131
  };
108
- export const ValidConstraints = {
132
+ const ValidConstraints = {
109
133
  date: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'format'],
110
134
  string: ['minLength', 'maxLength', 'pattern'],
111
135
  number: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'],
112
136
  array: ['minItems', 'maxItems', 'uniqueItems'],
113
137
  file: ['accept', 'maxFileSize']
114
138
  };
115
- export const Constraints = {
139
+ const Constraints = {
116
140
  type: (constraint, inputVal) => {
117
141
  let value = inputVal;
118
142
  if (inputVal == undefined) {
@@ -272,3 +296,5 @@ export const Constraints = {
272
296
  };
273
297
  }
274
298
  };
299
+
300
+ export { Constraints, ValidConstraints, coerceType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.20",
3
+ "version": "0.22.23",
4
4
  "description": "Core Module for Forms Runtime",
5
5
  "author": "Adobe Systems",
6
6
  "license": "Adobe Proprietary",
@@ -34,14 +34,15 @@
34
34
  "eslint": "npx eslint src/**",
35
35
  "eslint:fix": "npx eslint --fix src/**",
36
36
  "test:ci": "NODE_OPTIONS=--experimental-vm-modules jest --silent --coverage",
37
- "build": "npm run clean && npm run eslint && npx tsc && rollup -c rollup.config.js",
37
+ "prebuild": "npm run clean && npm run eslint",
38
+ "build": "rollup -c rollup.config.js",
38
39
  "clean": "rm -rf lib target",
39
40
  "prepublishOnly": "npm run build && npm run test",
40
41
  "docs": "npx typedoc --options .typedoc.cjs"
41
42
  },
42
43
  "dependencies": {
43
44
  "@adobe/json-formula": "0.1.50",
44
- "@aemforms/af-formatters": "^0.22.20"
45
+ "@aemforms/af-formatters": "^0.22.23"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@types/jest": "29.2.4",
@@ -1,151 +0,0 @@
1
- class ActionImpl {
2
- _metadata;
3
- _type;
4
- _payload;
5
- _target;
6
- constructor(payload, type, _metadata) {
7
- this._metadata = _metadata;
8
- this._payload = payload;
9
- this._type = type;
10
- }
11
- get type() {
12
- return this._type;
13
- }
14
- get payload() {
15
- return this._payload;
16
- }
17
- get metadata() {
18
- return this._metadata;
19
- }
20
- get target() {
21
- return this._target;
22
- }
23
- get isCustomEvent() {
24
- return false;
25
- }
26
- payloadToJson() {
27
- return this.payload;
28
- }
29
- toJson() {
30
- return {
31
- payload: this.payloadToJson(),
32
- type: this.type,
33
- isCustomEvent: this.isCustomEvent
34
- };
35
- }
36
- toString() {
37
- return JSON.stringify(this.toJson());
38
- }
39
- }
40
- class Change extends ActionImpl {
41
- constructor(payload, dispatch = false) {
42
- super(payload, 'change', { dispatch });
43
- }
44
- withAdditionalChange(change) {
45
- return new Change(this.payload.changes.concat(change.payload.changes), this.metadata);
46
- }
47
- }
48
- class Invalid extends ActionImpl {
49
- constructor(payload = {}) {
50
- super(payload, 'invalid', {});
51
- }
52
- }
53
- class Valid extends ActionImpl {
54
- constructor(payload = {}) {
55
- super(payload, 'valid', {});
56
- }
57
- }
58
- class ExecuteRule extends ActionImpl {
59
- constructor(payload = {}, dispatch = false) {
60
- super(payload, 'executeRule', { dispatch });
61
- }
62
- }
63
- const propertyChange = (propertyName, currentValue, prevValue) => {
64
- return new Change({
65
- changes: [
66
- {
67
- propertyName,
68
- currentValue,
69
- prevValue
70
- }
71
- ]
72
- });
73
- };
74
- class Initialize extends ActionImpl {
75
- constructor(payload, dispatch = false) {
76
- super(payload, 'initialize', { dispatch });
77
- }
78
- }
79
- class FormLoad extends ActionImpl {
80
- constructor() {
81
- super({}, 'load', { dispatch: false });
82
- }
83
- }
84
- class Click extends ActionImpl {
85
- constructor(payload, dispatch = false) {
86
- super(payload, 'click', { dispatch });
87
- }
88
- }
89
- class Blur extends ActionImpl {
90
- constructor(payload, dispatch = false) {
91
- super(payload, 'blur', { dispatch });
92
- }
93
- }
94
- class ValidationComplete extends ActionImpl {
95
- constructor(payload, dispatch = false) {
96
- super(payload, 'validationComplete', { dispatch });
97
- }
98
- }
99
- class Focus extends ActionImpl {
100
- constructor() {
101
- super({}, 'focus', { dispatch: false });
102
- }
103
- }
104
- class Submit extends ActionImpl {
105
- constructor(payload, dispatch = false) {
106
- super(payload, 'submit', { dispatch });
107
- }
108
- }
109
- class Reset extends ActionImpl {
110
- constructor(payload, dispatch = false) {
111
- super(payload, 'reset', { dispatch });
112
- }
113
- }
114
- class FieldChanged extends ActionImpl {
115
- constructor(changes, field) {
116
- super({
117
- field,
118
- changes
119
- }, 'fieldChanged');
120
- }
121
- }
122
- class CustomEvent extends ActionImpl {
123
- constructor(eventName, payload = {}, dispatch = false) {
124
- super(payload, eventName, { dispatch });
125
- }
126
- get isCustomEvent() {
127
- return true;
128
- }
129
- }
130
- class AddItem extends ActionImpl {
131
- constructor(payload) {
132
- super(payload, 'addItem');
133
- }
134
- }
135
- class RemoveItem extends ActionImpl {
136
- constructor(payload) {
137
- super(payload, 'removeItem');
138
- }
139
- }
140
- class AddInstance extends ActionImpl {
141
- constructor(payload) {
142
- super(payload, 'addInstance');
143
- }
144
- }
145
- class RemoveInstance extends ActionImpl {
146
- constructor(payload) {
147
- super(payload, 'removeInstance');
148
- }
149
- }
150
-
151
- export { AddInstance, AddItem, Blur, Change, Click, CustomEvent, ExecuteRule, FieldChanged, Focus, FormLoad, Initialize, Invalid, RemoveInstance, RemoveItem, Reset, Submit, Valid, ValidationComplete, propertyChange };