@aemforms/af-core 0.22.16 → 0.22.17

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/lib/FileUpload.js CHANGED
@@ -22,8 +22,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
22
22
  const Controller_1 = require("./controller/Controller");
23
23
  const Field_1 = __importDefault(require("./Field"));
24
24
  const FormUtils_1 = require("./utils/FormUtils");
25
- const ValidationUtils_1 = require("./utils/ValidationUtils");
26
25
  const FileObject_1 = require("./FileObject");
26
+ const ValidationUtils_1 = require("./utils/ValidationUtils");
27
27
  function addNameToDataURL(dataURL, name) {
28
28
  return dataURL.replace(';base64', `;name=${encodeURIComponent(name)};base64`);
29
29
  }
@@ -32,7 +32,7 @@ function processFiles(files) {
32
32
  }
33
33
  function processFile(file) {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
- const { name, size, mediaType } = file;
35
+ const { name, size, type } = file;
36
36
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
37
  const fileObj = yield new Promise((resolve, reject) => {
38
38
  const reader = new FileReader();
@@ -40,7 +40,7 @@ function processFile(file) {
40
40
  resolve(new FileObject_1.FileObject({
41
41
  // @ts-ignore
42
42
  data: addNameToDataURL(event.target.result, name),
43
- mediaType: mediaType,
43
+ type,
44
44
  name,
45
45
  size
46
46
  }));
@@ -99,124 +99,23 @@ class FileUpload extends Field_1.default {
99
99
  return acc;
100
100
  }, {});
101
101
  }
102
- typeCheck(value) {
103
- const type = this._jsonModel.type || 'file';
104
- switch (type) {
105
- case 'string':
106
- return { valid: true, value: value };
107
- default:
108
- return ValidationUtils_1.Constraints.type(type, value);
109
- }
102
+ getInternalType() {
103
+ var _a;
104
+ return ((_a = this.type) === null || _a === void 0 ? void 0 : _a.endsWith('[]')) ? 'file[]' : 'file';
110
105
  }
111
- checkFileType(type) {
112
- let accepts = this.accept || '';
113
- let validFileType = false;
114
- if (!accepts || !type) {
115
- return true;
116
- }
117
- accepts = Array.isArray(accepts) ? accepts : accepts.split(',');
118
- accepts.forEach((accept) => {
119
- const trimmedAccept = accept.trim();
120
- const prefixAccept = trimmedAccept.split('/')[0];
121
- const suffixAccept = trimmedAccept.split('.')[1];
122
- if ((trimmedAccept.includes('*') && type.startsWith(prefixAccept)) ||
123
- (trimmedAccept.includes('.') && type.endsWith(suffixAccept)) ||
124
- (trimmedAccept === type)) {
125
- validFileType = true;
106
+ getDataNodeValue(typedValue) {
107
+ var _a;
108
+ let dataNodeValue = typedValue;
109
+ if (dataNodeValue != null) {
110
+ if (this.type === 'string') {
111
+ dataNodeValue = (_a = dataNodeValue.data) === null || _a === void 0 ? void 0 : _a.toString();
126
112
  }
127
- });
128
- return validFileType;
129
- }
130
- acceptCheck(value) {
131
- const tempValue = value instanceof Array ? value : [value];
132
- const invalidFile = tempValue.some((file) => !this.checkFileType(file.type || file.mediaType));
133
- return {
134
- valid: !invalidFile,
135
- value
136
- };
137
- }
138
- get value() {
139
- // @ts-ignore
140
- this.ruleEngine.trackDependency(this);
141
- if (this._jsonModel.value === undefined) {
142
- return null;
143
- }
144
- let val = this._jsonModel.value;
145
- // always return file object irrespective of data schema
146
- if (val != null) {
147
- // @ts-ignore
148
- val = this.coerce((val instanceof Array ? val : [val])
149
- .map(file => {
150
- let retVal = file;
151
- if (!(retVal instanceof FileObject_1.FileObject)) {
152
- retVal = new FileObject_1.FileObject({
153
- 'name': file.name,
154
- 'mediaType': file.mediaType,
155
- 'size': file.size,
156
- 'data': file.data
157
- });
158
- }
159
- // define serialization here
160
- /*
161
- Object.defineProperty(retVal, 'data', {
162
- get: async function() {
163
- if (file.data instanceof File) {
164
- return processFile(file);
165
- } else {
166
- return file.data;
167
- }
168
- }
169
- });
170
- */
171
- return retVal;
172
- }));
173
- }
174
- return val;
175
- }
176
- set value(value) {
177
- if (value !== undefined) {
178
- // store file list here
179
- const typeRes = this.typeCheck(value);
180
- const acceptRes = this.acceptCheck(value);
181
- let fileInfoPayload = (0, FormUtils_1.extractFileInfo)(value);
182
- fileInfoPayload = this.coerce(fileInfoPayload);
183
- const changes = this._setProperty('value', fileInfoPayload, false);
184
- if (changes.length > 0) {
185
- const dataNode = this.getDataNode();
186
- if (typeof dataNode !== 'undefined') {
187
- let val = this._jsonModel.value;
188
- const retVal = (val instanceof Array ? val : [val]).map(file => {
189
- if (this.type === 'file' || this.type === 'file[]') {
190
- return file;
191
- }
192
- else if (this.type === 'string' || this.type === 'string[]') {
193
- // @ts-ignore
194
- return file.data.toString();
195
- }
196
- });
197
- val = this.coerce(retVal);
198
- if (dataNode !== undefined) {
199
- dataNode.setValue(val, this._jsonModel.value);
200
- }
201
- }
202
- let updates;
203
- if (typeRes.valid && acceptRes.valid) {
204
- updates = this.evaluateConstraints();
205
- }
206
- else {
207
- const changes = {
208
- 'valid': typeRes.valid && acceptRes.valid,
209
- 'errorMessage': typeRes.valid && acceptRes.valid ? '' : this.getErrorMessage('type')
210
- };
211
- updates = this._applyUpdates(['valid', 'errorMessage'], changes);
212
- }
213
- if (updates.valid) {
214
- this.triggerValidationEvent(updates);
215
- }
216
- const changeAction = new Controller_1.Change({ changes: changes.concat(Object.values(updates)) });
217
- this.dispatch(changeAction);
113
+ else if (this.type === 'string[]') {
114
+ dataNodeValue = dataNodeValue instanceof Array ? dataNodeValue : [dataNodeValue];
115
+ dataNodeValue = dataNodeValue.map((_) => { var _a; return (_a = _ === null || _ === void 0 ? void 0 : _.data) === null || _a === void 0 ? void 0 : _a.toString(); });
218
116
  }
219
117
  }
118
+ return dataNodeValue;
220
119
  }
221
120
  _serialize() {
222
121
  return __awaiter(this, void 0, void 0, function* () {
@@ -229,28 +128,24 @@ class FileUpload extends Field_1.default {
229
128
  return filesInfo;
230
129
  });
231
130
  }
232
- coerce(val) {
233
- let retVal = val;
234
- if ((this.type === 'string' || this.type === 'file') && retVal instanceof Array) {
235
- // @ts-ignore
236
- retVal = val[0];
237
- }
238
- return retVal;
239
- }
240
131
  importData(dataModel) {
241
132
  this._bindToDataModel(dataModel);
242
133
  const dataNode = this.getDataNode();
243
134
  if (dataNode !== undefined) {
244
135
  const value = dataNode === null || dataNode === void 0 ? void 0 : dataNode.$value;
245
- let newValue = value;
246
136
  // only if not undefined, proceed further
247
137
  if (value != null) {
248
- const fileObj = (0, FormUtils_1.extractFileInfo)(value);
249
- newValue = this.coerce(fileObj);
138
+ const res = ValidationUtils_1.Constraints.type(this.getInternalType(), value);
139
+ if (!res.valid) {
140
+ this.form.logger.error(`unable to bind ${this.name} to data`);
141
+ }
250
142
  // is this needed ?
251
- this.form.getEventQueue().queue(this, (0, Controller_1.propertyChange)('value', newValue, this._jsonModel.value));
143
+ this.form.getEventQueue().queue(this, (0, Controller_1.propertyChange)('value', res.value, this._jsonModel.value));
144
+ this._jsonModel.value = res.value;
145
+ }
146
+ else {
147
+ this._jsonModel.value = null;
252
148
  }
253
- this._jsonModel.value = newValue;
254
149
  }
255
150
  }
256
151
  }
package/lib/Form.d.ts CHANGED
@@ -1,25 +1,9 @@
1
1
  import Container from './Container';
2
- import { Action, FieldJson, FieldModel, FieldsetJson, FieldsetModel, FormJson, FormModel, Items } from './types';
2
+ import { Action, BaseModel, FieldJson, FieldModel, FieldsetJson, FieldsetModel, FormJson, FormModel, Items } from './types';
3
3
  import FormMetaData from './FormMetaData';
4
4
  import EventQueue from './controller/EventQueue';
5
+ import { Logger, LogLevel } from './controller/Logger';
5
6
  import RuleEngine from './rules/RuleEngine';
6
- declare type LogFunction = 'info' | 'warn' | 'error' | 'debug';
7
- /**
8
- * Logging levels.
9
- */
10
- export declare type LogLevel = 'off' | LogFunction;
11
- /**
12
- * @private
13
- */
14
- export declare class Logger {
15
- debug(msg: string): void;
16
- info(msg: string): void;
17
- warn(msg: string): void;
18
- error(msg: string): void;
19
- log(msg: string, level: LogFunction): void;
20
- private logLevel;
21
- constructor(logLevel?: LogLevel);
22
- }
23
7
  /**
24
8
  * Defines `form model` which implements {@link FormModel | form model}
25
9
  */
@@ -54,6 +38,7 @@ declare class Form extends Container<FormJson> implements FormModel {
54
38
  protected _createChild(child: FieldsetJson | FieldJson): FieldModel | FieldsetModel;
55
39
  importData(dataModel: any): void;
56
40
  exportData(): any;
41
+ setFocus(field: BaseModel): void;
57
42
  /**
58
43
  * Returns the current state of the form
59
44
  *
@@ -104,6 +89,7 @@ declare class Form extends Container<FormJson> implements FormModel {
104
89
  } & {
105
90
  items: (FieldJson | import("./types").ContainerJson)[];
106
91
  initialItems?: number | undefined;
92
+ activeChild?: string | undefined;
107
93
  } & {
108
94
  metadata?: import("./types").MetaDataJson | undefined;
109
95
  data?: any;
@@ -287,6 +273,7 @@ declare class Form extends Container<FormJson> implements FormModel {
287
273
  } & {
288
274
  items: (FieldJson | import("./types").ContainerJson)[];
289
275
  initialItems?: number | undefined;
276
+ activeChild?: string | undefined;
290
277
  } & {
291
278
  id: string;
292
279
  items: (({
@@ -381,9 +368,11 @@ declare class Form extends Container<FormJson> implements FormModel {
381
368
  } & {
382
369
  items: (FieldJson | import("./types").ContainerJson)[];
383
370
  initialItems?: number | undefined;
371
+ activeChild?: string | undefined;
384
372
  } & any))[];
385
373
  }))[];
386
374
  initialItems?: number | undefined;
375
+ activeChild?: string | undefined;
387
376
  id: string;
388
377
  })[];
389
378
  id: string;
@@ -421,6 +410,7 @@ declare class Form extends Container<FormJson> implements FormModel {
421
410
  */
422
411
  submit(action: Action, context: any): void;
423
412
  getElement(id: string): FieldModel | FieldsetModel | this;
413
+ get qualifiedName(): string;
424
414
  /**
425
415
  * @private
426
416
  */
package/lib/Form.js CHANGED
@@ -10,48 +10,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Logger = void 0;
14
13
  const Container_1 = __importDefault(require("./Container"));
15
14
  const FormMetaData_1 = __importDefault(require("./FormMetaData"));
16
15
  const Fieldset_1 = require("./Fieldset");
17
16
  const EventQueue_1 = __importDefault(require("./controller/EventQueue"));
17
+ const Logger_1 = require("./controller/Logger");
18
18
  const FormUtils_1 = require("./utils/FormUtils");
19
19
  const DataGroup_1 = __importDefault(require("./data/DataGroup"));
20
20
  const FunctionRuntime_1 = require("./rules/FunctionRuntime");
21
21
  const controller_1 = require("./controller");
22
- const levels = {
23
- off: 0,
24
- debug: 1,
25
- info: 2,
26
- warn: 3,
27
- error: 4
28
- };
29
- /**
30
- * @private
31
- */
32
- class Logger {
33
- constructor(logLevel = 'off') {
34
- this.logLevel = levels[logLevel];
35
- }
36
- debug(msg) {
37
- this.log(msg, 'debug');
38
- }
39
- info(msg) {
40
- this.log(msg, 'info');
41
- }
42
- warn(msg) {
43
- this.log(msg, 'warn');
44
- }
45
- error(msg) {
46
- this.log(msg, 'error');
47
- }
48
- log(msg, level) {
49
- if (this.logLevel !== 0 && this.logLevel <= levels[level]) {
50
- console[level](msg);
51
- }
52
- }
53
- }
54
- exports.Logger = Logger;
55
22
  /**
56
23
  * Defines `form model` which implements {@link FormModel | form model}
57
24
  */
@@ -77,7 +44,7 @@ class Form extends Container_1.default {
77
44
  */
78
45
  this._invalidFields = [];
79
46
  this.dataRefRegex = /("[^"]+?"|[^.]+?)(?:\.|$)/g;
80
- this._logger = new Logger(logLevel);
47
+ this._logger = new Logger_1.Logger(logLevel);
81
48
  this.queueEvent(new controller_1.Initialize());
82
49
  this.queueEvent(new controller_1.ExecuteRule());
83
50
  this._ids = (0, FormUtils_1.IdGenerator)();
@@ -107,6 +74,13 @@ class Form extends Container_1.default {
107
74
  var _a;
108
75
  return (_a = this.getDataNode()) === null || _a === void 0 ? void 0 : _a.$value;
109
76
  }
77
+ setFocus(field) {
78
+ const parent = field.parent;
79
+ const currentField = field;
80
+ while (parent != null && parent.activeChild != currentField) {
81
+ parent.activeChild = currentField;
82
+ }
83
+ }
110
84
  /**
111
85
  * Returns the current state of the form
112
86
  *
@@ -231,6 +205,9 @@ class Form extends Container_1.default {
231
205
  }
232
206
  return this._fields[id];
233
207
  }
208
+ get qualifiedName() {
209
+ return '$form';
210
+ }
234
211
  /**
235
212
  * @private
236
213
  */
@@ -1,5 +1,5 @@
1
- import { LogLevel } from './Form';
2
1
  import { FormModel } from './types';
2
+ import { LogLevel } from './controller/Logger';
3
3
  /**
4
4
  * Creates form instance using form model definition as per `adaptive form specification`
5
5
  * @param formModel form model definition
@@ -6,39 +6,17 @@
6
6
  *
7
7
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
8
  */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
- Object.defineProperty(o, "default", { enumerable: true, value: v });
22
- }) : function(o, v) {
23
- o["default"] = v;
24
- });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
32
9
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
10
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
11
  };
35
12
  Object.defineProperty(exports, "__esModule", { value: true });
36
13
  exports.fetchForm = exports.validateFormData = exports.validateFormInstance = exports.createFormInstance = void 0;
37
- const Form_1 = __importStar(require("./Form"));
14
+ const Form_1 = __importDefault(require("./Form"));
38
15
  const JsonUtils_1 = require("./utils/JsonUtils");
39
16
  const Fetch_1 = require("./utils/Fetch");
40
17
  const RuleEngine_1 = __importDefault(require("./rules/RuleEngine"));
41
18
  const EventQueue_1 = __importDefault(require("./controller/EventQueue"));
19
+ const Logger_1 = require("./controller/Logger");
42
20
  /**
43
21
  * Creates form instance using form model definition as per `adaptive form specification`
44
22
  * @param formModel form model definition
@@ -52,7 +30,7 @@ const createFormInstance = (formModel, callback, logLevel = 'error', fModel = un
52
30
  try {
53
31
  let f = fModel;
54
32
  if (f == null) {
55
- f = new Form_1.default(Object.assign({}, formModel), new RuleEngine_1.default(), new EventQueue_1.default(new Form_1.Logger(logLevel)), logLevel);
33
+ f = new Form_1.default(Object.assign({}, formModel), new RuleEngine_1.default(), new EventQueue_1.default(new Logger_1.Logger(logLevel)), logLevel);
56
34
  }
57
35
  const formData = formModel === null || formModel === void 0 ? void 0 : formModel.data;
58
36
  if (formData) {
@@ -57,6 +57,7 @@ export declare class Change extends ActionImpl {
57
57
  * @param [dispatch] true to trigger the event on all the fields in DFS order starting from the top level form element, false otherwise
58
58
  */
59
59
  constructor(payload: ChangePayload, dispatch?: boolean);
60
+ withAdditionalChange(change: Change): Change;
60
61
  }
61
62
  /**
62
63
  * Implementation of `invalid` event. The invalid event is triggered when a Field’s value becomes invalid after a change event or whenever its value property change
@@ -60,6 +60,9 @@ class Change extends ActionImpl {
60
60
  constructor(payload, dispatch = false) {
61
61
  super(payload, 'change', { dispatch });
62
62
  }
63
+ withAdditionalChange(change) {
64
+ return new Change(this.payload.changes.concat(change.payload.changes), this.metadata);
65
+ }
63
66
  }
64
67
  exports.Change = Change;
65
68
  /**
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { Action, BaseJson } from '../types';
5
5
  import { BaseNode } from '../BaseNode';
6
- import { Logger } from '../Form';
6
+ import { Logger } from './Logger';
7
7
  /**
8
8
  * Implementation of event queue. When a user event, like change or click, is captured the expression to be evaluated
9
9
  * must be put in an Event Queue and then evaluated.
@@ -7,7 +7,7 @@
7
7
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- const Form_1 = require("../Form");
10
+ const Logger_1 = require("./Logger");
11
11
  /**
12
12
  * Implementation of event node
13
13
  * @private
@@ -39,7 +39,7 @@ class EventNode {
39
39
  * @private
40
40
  */
41
41
  class EventQueue {
42
- constructor(logger = new Form_1.Logger('off')) {
42
+ constructor(logger = new Logger_1.Logger('off')) {
43
43
  this.logger = logger;
44
44
  this._isProcessing = false;
45
45
  this._pendingEvents = [];
@@ -0,0 +1,17 @@
1
+ export declare type LogFunction = 'info' | 'warn' | 'error' | 'debug';
2
+ /**
3
+ * Logging levels.
4
+ */
5
+ export declare type LogLevel = 'off' | LogFunction;
6
+ /**
7
+ * @private
8
+ */
9
+ export declare class Logger {
10
+ debug(msg: string): void;
11
+ info(msg: string): void;
12
+ warn(msg: string): void;
13
+ error(msg: string): void;
14
+ log(msg: string, level: LogFunction): void;
15
+ private logLevel;
16
+ constructor(logLevel?: LogLevel);
17
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logger = void 0;
4
+ const levels = {
5
+ off: 0,
6
+ debug: 1,
7
+ info: 2,
8
+ warn: 3,
9
+ error: 4
10
+ };
11
+ /**
12
+ * @private
13
+ */
14
+ class Logger {
15
+ constructor(logLevel = 'off') {
16
+ this.logLevel = levels[logLevel];
17
+ }
18
+ debug(msg) {
19
+ this.log(msg, 'debug');
20
+ }
21
+ info(msg) {
22
+ this.log(msg, 'info');
23
+ }
24
+ warn(msg) {
25
+ this.log(msg, 'warn');
26
+ }
27
+ error(msg) {
28
+ this.log(msg, 'error');
29
+ }
30
+ log(msg, level) {
31
+ if (this.logLevel !== 0 && this.logLevel <= levels[level]) {
32
+ console[level](msg);
33
+ }
34
+ }
35
+ }
36
+ exports.Logger = Logger;
@@ -14,7 +14,7 @@ export default class DataValue {
14
14
  valueOf(): any;
15
15
  get $name(): string | number;
16
16
  get $value(): any;
17
- setValue(typedValue: any, originalValue: any): void;
17
+ setValue(typedValue: any, originalValue: any, fromField: FieldModel): void;
18
18
  get $type(): string;
19
19
  $bindToField(field: FieldModel): void;
20
20
  $convertToDataValue(): DataValue;
@@ -26,10 +26,12 @@ class DataValue {
26
26
  get $value() {
27
27
  return this.$_value;
28
28
  }
29
- setValue(typedValue, originalValue) {
29
+ setValue(typedValue, originalValue, fromField) {
30
30
  this.$_value = typedValue;
31
31
  this.$_fields.forEach(x => {
32
- x.value = originalValue;
32
+ if (fromField !== x) {
33
+ x.value = originalValue;
34
+ }
33
35
  });
34
36
  }
35
37
  get $type() {
@@ -32,6 +32,10 @@ declare class FunctionRuntimeImpl {
32
32
  _func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
33
33
  _signature: never[];
34
34
  };
35
+ setFocus: {
36
+ _func: (args: Array<unknown>, data: unknown, interpreter: any) => void;
37
+ _signature: never[];
38
+ };
35
39
  getData: {
36
40
  _func: (args: unknown, data: unknown, interpreter: any) => any;
37
41
  _signature: never[];
@@ -270,6 +270,19 @@ class FunctionRuntimeImpl {
270
270
  },
271
271
  _signature: []
272
272
  },
273
+ setFocus: {
274
+ _func: (args, data, interpreter) => {
275
+ const element = args[0];
276
+ try {
277
+ const field = interpreter.globals.form.getElement(element.$id);
278
+ interpreter.globals.form.setFocus(field);
279
+ }
280
+ catch (e) {
281
+ interpreter.globals.form.logger.error('Invalid argument passed in setFocus. An element is expected');
282
+ }
283
+ },
284
+ _signature: []
285
+ },
273
286
  getData: {
274
287
  _func: (args, data, interpreter) => {
275
288
  // deprecated. left for backward compatability.
@@ -103,6 +103,7 @@ export declare type FieldJson = BaseJson & TranslationFieldJson & {
103
103
  export declare type ContainerJson = BaseJson & {
104
104
  items: Array<FieldJson | ContainerJson>;
105
105
  initialItems?: number;
106
+ activeChild?: string;
106
107
  };
107
108
  /** Type for `form metadata` based on `adaptive form specification` */
108
109
  export declare type MetaDataJson = {
@@ -5,7 +5,7 @@ import { ConstraintsJson, ContainerJson, FieldJson, FieldsetJson, FormJson, Labe
5
5
  import RuleEngine from '../rules/RuleEngine';
6
6
  import EventQueue from '../controller/EventQueue';
7
7
  import DataGroup from '../data/DataGroup';
8
- import { Logger } from '../Form';
8
+ import { Logger } from '../controller/Logger';
9
9
  /**
10
10
  * Generic Scriptable field interface. All non-transparent fields which support rule/events
11
11
  * should implement this interface
@@ -124,6 +124,10 @@ export interface BaseModel extends ConstraintsJson, WithController {
124
124
  * The index of the Field within its parent.
125
125
  */
126
126
  readonly index: number;
127
+ /**
128
+ *
129
+ */
130
+ readonly qualifiedName: string;
127
131
  /**
128
132
  * Label to be used for the field.
129
133
  */
@@ -276,6 +280,7 @@ export interface ContainerModel extends BaseModel, ScriptableField {
276
280
  */
277
281
  indexOf(f: FieldModel | FieldsetModel): number;
278
282
  isTransparent(): boolean;
283
+ activeChild: BaseModel | null;
279
284
  }
280
285
  /**
281
286
  * Generic field set model interface.
@@ -339,7 +344,7 @@ export interface IFileObject {
339
344
  /**
340
345
  * Media type of the file data
341
346
  */
342
- mediaType: string;
347
+ type: string;
343
348
  /**
344
349
  * Data of the file attachment. It can be uri or any file interface specific to channel (in web, it is file object).
345
350
  */
@@ -1,5 +1,4 @@
1
1
  import { ContainerModel } from '../types';
2
- import { FileObject } from '../FileObject';
3
2
  /**
4
3
  * Utility to generate a random word from seed
5
4
  * @param l seed value
@@ -24,13 +23,6 @@ export declare const getAttachments: (input: ContainerModel) => any;
24
23
  * @returns file size as bytes (in kb) based on IEC specification
25
24
  */
26
25
  export declare const getFileSizeInBytes: (str: any) => number;
27
- /**
28
- * Converts number to bytes based on the symbol as per IEC specification
29
- * @param size size as number
30
- * @param symbol symbol to use (for example, kb, mb, gb or tb)
31
- * @returns number as bytes based on the symbol
32
- */
33
- export declare const sizeToBytes: (size: number, symbol: string) => number;
34
26
  /**
35
27
  * ID Generator
36
28
  * @param initial
@@ -40,16 +32,16 @@ export declare const sizeToBytes: (size: number, symbol: string) => number;
40
32
  export declare const IdGenerator: (initial?: number) => Generator<string, void, string>;
41
33
  /**
42
34
  * Utility to extract {@link FileObject} from string or HTML File data type
43
- * @param files list of files as string , string [] of file[]
35
+ * @param file
44
36
  * @returns list of {@link FileObject}
45
37
  */
46
- export declare const extractFileInfo: (files: string[] | string | File[]) => FileObject[];
38
+ export declare const extractFileInfo: (file: any) => any;
47
39
  /**
48
40
  * Utility to convert data URI to a `blob` object
49
41
  * @param dataURI uri to convert to blob
50
42
  * @returns `Blob` object for the data URI
51
43
  */
52
44
  export declare const dataURItoBlob: (dataURI: string) => {
53
- blob: Blob;
54
45
  name: string;
55
- };
46
+ blob: Blob;
47
+ } | null;