@formio/js 5.0.0-rc.45 → 5.0.0-rc.47

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 (60) hide show
  1. package/dist/formio.embed.js +1 -1
  2. package/dist/formio.embed.min.js +1 -1
  3. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  4. package/dist/formio.form.js +6 -476
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.full.js +6 -186
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  10. package/dist/formio.js +2 -2
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +1 -1
  13. package/dist/formio.utils.js +1897 -429
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +9 -1
  16. package/lib/cjs/Webform.d.ts +2 -2
  17. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +2 -2
  18. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.form.d.ts +2 -2
  19. package/lib/cjs/addons/index.d.ts +2 -2
  20. package/lib/cjs/components/Components.d.ts +3 -3
  21. package/lib/cjs/components/_classes/component/editForm/Component.edit.addons.d.ts +2 -2
  22. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.d.ts +1 -1
  23. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +1 -1
  24. package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.d.ts +1 -1
  25. package/lib/cjs/components/_classes/component/editForm/utils.d.ts +1 -1
  26. package/lib/cjs/components/datetime/editForm/DateTime.edit.date.d.ts +1 -1
  27. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.templates.d.ts +1 -1
  28. package/lib/cjs/components/form/editForm/Form.edit.data.d.ts +1 -1
  29. package/lib/cjs/components/panel/editForm/Panel.edit.conditional.d.ts +1 -1
  30. package/lib/cjs/formio.form.d.ts +1 -0
  31. package/lib/cjs/formio.form.js +3 -1
  32. package/lib/cjs/utils/Evaluator.d.ts +7 -3
  33. package/lib/cjs/utils/Evaluator.js +12 -18
  34. package/lib/cjs/utils/formUtils.d.ts +38 -165
  35. package/lib/cjs/utils/formUtils.js +36 -566
  36. package/lib/cjs/utils/utils.d.ts +2 -2
  37. package/lib/cjs/utils/utils.js +9 -9
  38. package/lib/mjs/Webform.d.ts +2 -2
  39. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +2 -2
  40. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.form.d.ts +2 -2
  41. package/lib/mjs/addons/index.d.ts +2 -2
  42. package/lib/mjs/components/Components.d.ts +3 -3
  43. package/lib/mjs/components/_classes/component/editForm/Component.edit.addons.d.ts +2 -2
  44. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.d.ts +1 -1
  45. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +1 -1
  46. package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.d.ts +1 -1
  47. package/lib/mjs/components/_classes/component/editForm/utils.d.ts +1 -1
  48. package/lib/mjs/components/datetime/editForm/DateTime.edit.date.d.ts +1 -1
  49. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.templates.d.ts +1 -1
  50. package/lib/mjs/components/form/editForm/Form.edit.data.d.ts +1 -1
  51. package/lib/mjs/components/panel/editForm/Panel.edit.conditional.d.ts +1 -1
  52. package/lib/mjs/formio.form.d.ts +1 -0
  53. package/lib/mjs/formio.form.js +1 -0
  54. package/lib/mjs/utils/Evaluator.d.ts +7 -3
  55. package/lib/mjs/utils/Evaluator.js +10 -18
  56. package/lib/mjs/utils/formUtils.d.ts +38 -165
  57. package/lib/mjs/utils/formUtils.js +3 -550
  58. package/lib/mjs/utils/utils.d.ts +2 -2
  59. package/lib/mjs/utils/utils.js +1 -1
  60. package/package.json +1 -1
@@ -1,184 +1,45 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.flattenComponents = exports.applyFormChanges = exports.generateFormChange = exports.removeComponent = exports.findComponent = exports.findComponents = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.eachComponent = exports.isLayoutComponent = void 0;
7
- const get_1 = __importDefault(require("lodash/get"));
8
- const set_1 = __importDefault(require("lodash/set"));
9
- const has_1 = __importDefault(require("lodash/has"));
10
- const clone_1 = __importDefault(require("lodash/clone"));
11
- const forOwn_1 = __importDefault(require("lodash/forOwn"));
12
- const isString_1 = __importDefault(require("lodash/isString"));
13
- const isNaN_1 = __importDefault(require("lodash/isNaN"));
14
- const isNil_1 = __importDefault(require("lodash/isNil"));
15
- const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
16
- const round_1 = __importDefault(require("lodash/round"));
17
- const chunk_1 = __importDefault(require("lodash/chunk"));
18
- const pad_1 = __importDefault(require("lodash/pad"));
19
- const fast_json_patch_1 = require("fast-json-patch");
20
- const lodash_1 = __importDefault(require("lodash"));
21
- const utils_1 = require("./utils");
22
- /**
23
- * Determine if a component is a layout component or not.
24
- *
25
- * @param {Object} component
26
- * The component to check.
27
- *
28
- * @returns {Boolean}
29
- * Whether or not the component is a layout component.
30
- */
31
- function isLayoutComponent(component) {
32
- return Boolean((component.columns && Array.isArray(component.columns)) ||
33
- (component.rows && Array.isArray(component.rows)) ||
34
- (component.components && Array.isArray(component.components)));
35
- }
36
- exports.isLayoutComponent = isLayoutComponent;
37
- /**
38
- * Iterate through each component within a form.
39
- *
40
- * @param {Object} components
41
- * The components to iterate.
42
- * @param {Function} fn
43
- * The iteration function to invoke for each component.
44
- * @param {Boolean} includeAll
45
- * Whether or not to include layout components.
46
- * @param {String} path
47
- * The current data path of the element. Example: data.user.firstName
48
- * @param {Object} parent
49
- * The parent object.
50
- */
51
- function eachComponent(components, fn, includeAll, path, parent, inRecursion) {
52
- if (!components)
53
- return;
54
- path = path || '';
55
- if (inRecursion) {
56
- if (components.noRecurse) {
57
- delete components.noRecurse;
58
- return;
59
- }
60
- components.noRecurse = true;
61
- }
62
- components.forEach((component) => {
63
- if (!component) {
64
- return;
65
- }
66
- const hasColumns = component.columns && Array.isArray(component.columns);
67
- const hasRows = component.rows && Array.isArray(component.rows);
68
- const hasComps = component.components && Array.isArray(component.components);
69
- let noRecurse = false;
70
- const newPath = component.key ? (path ? (`${path}.${component.key}`) : component.key) : '';
71
- // Keep track of parent references.
72
- if (parent) {
73
- // Ensure we don't create infinite JSON structures.
74
- component.parent = (0, clone_1.default)(parent);
75
- delete component.parent.components;
76
- delete component.parent.componentMap;
77
- delete component.parent.columns;
78
- delete component.parent.rows;
79
- }
80
- // there's no need to add other layout components here because we expect that those would either have columns, rows or components
81
- const layoutTypes = ['htmlelement', 'content'];
82
- const isLayoutComponent = hasColumns || hasRows || (hasComps && !component.input) || layoutTypes.indexOf(component.type) > -1;
83
- if (includeAll || component.tree || !isLayoutComponent) {
84
- noRecurse = fn(component, newPath, components);
85
- }
86
- const subPath = () => {
87
- if (component.key &&
88
- !['panel', 'table', 'well', 'columns', 'fieldset', 'tabs', 'form'].includes(component.type) &&
89
- (['datagrid', 'container', 'editgrid', 'address', 'dynamicWizard', 'datatable', 'tagpad'].includes(component.type) ||
90
- component.tree)) {
91
- return newPath;
92
- }
93
- else if (component.key &&
94
- component.type === 'form') {
95
- return `${newPath}.data`;
96
- }
97
- return path;
98
- };
99
- if (!noRecurse) {
100
- if (hasColumns) {
101
- component.columns.forEach((column) => eachComponent(column.components, fn, includeAll, subPath(), parent ? component : null), true);
102
- }
103
- else if (hasRows) {
104
- component.rows.forEach((row) => {
105
- if (Array.isArray(row)) {
106
- row.forEach((column) => eachComponent(column.components, fn, includeAll, subPath(), parent ? component : null), true);
107
- }
108
- });
109
- }
110
- else if (hasComps) {
111
- eachComponent(component.components, fn, includeAll, subPath(), parent ? component : null, true);
112
- }
113
- }
114
- });
115
- if (components.noRecurse) {
116
- delete components.noRecurse;
117
- }
118
- }
3
+ exports.isComponentDataEmpty = exports.getEmptyValue = exports.findComponent = exports.applyFormChanges = exports.generateFormChange = exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.removeComponent = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.isLayoutComponent = exports.getComponentActualValue = exports.getComponentData = exports.eachComponentAsync = exports.eachComponent = exports.componentInfo = exports.getContextualRowData = exports.getContextualRowPath = exports.getComponentKey = exports.eachComponentData = exports.eachComponentDataAsync = exports.componentChildPath = exports.componentPath = exports.isComponentNestedDataType = exports.isComponentModelType = exports.getComponentPath = exports.getComponentAbsolutePath = exports.getModelType = exports.MODEL_TYPES = exports.uniqueName = exports.guid = exports.flattenComponents = exports.findComponents = void 0;
4
+ const core_1 = require("@formio/core");
5
+ const { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentModelType, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty } = core_1.Utils;
6
+ exports.flattenComponents = flattenComponents;
7
+ exports.guid = guid;
8
+ exports.uniqueName = uniqueName;
9
+ exports.MODEL_TYPES = MODEL_TYPES;
10
+ exports.getModelType = getModelType;
11
+ exports.getComponentAbsolutePath = getComponentAbsolutePath;
12
+ exports.getComponentPath = getComponentPath;
13
+ exports.isComponentModelType = isComponentModelType;
14
+ exports.isComponentNestedDataType = isComponentNestedDataType;
15
+ exports.componentPath = componentPath;
16
+ exports.componentChildPath = componentChildPath;
17
+ exports.eachComponentDataAsync = eachComponentDataAsync;
18
+ exports.eachComponentData = eachComponentData;
19
+ exports.getComponentKey = getComponentKey;
20
+ exports.getContextualRowPath = getContextualRowPath;
21
+ exports.getContextualRowData = getContextualRowData;
22
+ exports.componentInfo = componentInfo;
119
23
  exports.eachComponent = eachComponent;
120
- /**
121
- * Matches if a component matches the query.
122
- *
123
- * @param component
124
- * @param query
125
- * @return {boolean}
126
- */
127
- function matchComponent(component, query) {
128
- if ((0, isString_1.default)(query)) {
129
- return (component.key === query) || (component.path === query);
130
- }
131
- else {
132
- let matches = false;
133
- (0, forOwn_1.default)(query, (value, key) => {
134
- matches = ((0, get_1.default)(component, key) === value);
135
- if (!matches) {
136
- return false;
137
- }
138
- });
139
- return matches;
140
- }
141
- }
24
+ exports.eachComponentAsync = eachComponentAsync;
25
+ exports.getComponentData = getComponentData;
26
+ exports.getComponentActualValue = getComponentActualValue;
27
+ exports.isLayoutComponent = isLayoutComponent;
142
28
  exports.matchComponent = matchComponent;
143
- /**
144
- * Get a component by its key
145
- *
146
- * @param {Object} components
147
- * The components to iterate.
148
- * @param {String|Object} key
149
- * The key of the component to get, or a query of the component to search.
150
- *
151
- * @returns {Object}
152
- * The component that matches the given key, or undefined if not found.
153
- */
154
- function getComponent(components, key, includeAll) {
155
- let result;
156
- eachComponent(components, (component, path) => {
157
- if ((path === key) || (component.path === key)) {
158
- result = component;
159
- return true;
160
- }
161
- }, includeAll);
162
- return result;
163
- }
164
29
  exports.getComponent = getComponent;
165
- /**
166
- * Finds a component provided a query of properties of that component.
167
- *
168
- * @param components
169
- * @param query
170
- * @return {*}
171
- */
172
- function searchComponents(components, query) {
173
- const results = [];
174
- eachComponent(components, (component) => {
175
- if (matchComponent(component, query)) {
176
- results.push(component);
177
- }
178
- }, true);
179
- return results;
180
- }
181
30
  exports.searchComponents = searchComponents;
31
+ exports.removeComponent = removeComponent;
32
+ exports.hasCondition = hasCondition;
33
+ exports.parseFloatExt = parseFloatExt;
34
+ exports.formatAsCurrency = formatAsCurrency;
35
+ exports.escapeRegExCharacters = escapeRegExCharacters;
36
+ exports.getValue = getValue;
37
+ exports.getStrings = getStrings;
38
+ exports.generateFormChange = generateFormChange;
39
+ exports.applyFormChanges = applyFormChanges;
40
+ exports.findComponent = findComponent;
41
+ exports.getEmptyValue = getEmptyValue;
42
+ exports.isComponentDataEmpty = isComponentDataEmpty;
182
43
  /**
183
44
  * Deprecated version of findComponents. Renamed to searchComponents.
184
45
  *
@@ -191,394 +52,3 @@ function findComponents(components, query) {
191
52
  return searchComponents(components, query);
192
53
  }
193
54
  exports.findComponents = findComponents;
194
- /**
195
- * This function will find a component in a form and return the component AND THE PATH to the component in the form.
196
- * Path to the component is stored as an array of nested components and their indexes.The Path is being filled recursively
197
- * when you iterating through the nested structure.
198
- * If the component is not found the callback won't be called and function won't return anything.
199
- *
200
- * @param components
201
- * @param key
202
- * @param fn
203
- * @param path
204
- * @returns {*}
205
- */
206
- function findComponent(components, key, path, fn) {
207
- if (!components)
208
- return;
209
- path = path || [];
210
- if (!key) {
211
- return fn(components);
212
- }
213
- components.forEach(function (component, index) {
214
- var newPath = path.slice();
215
- // Add an index of the component it iterates through in nested structure
216
- newPath.push(index);
217
- if (!component)
218
- return;
219
- if (component.hasOwnProperty('columns') && Array.isArray(component.columns)) {
220
- newPath.push('columns');
221
- component.columns.forEach(function (column, index) {
222
- var colPath = newPath.slice();
223
- colPath.push(index);
224
- colPath.push('components');
225
- findComponent(column.components, key, colPath, fn);
226
- });
227
- }
228
- if (component.hasOwnProperty('rows') && Array.isArray(component.rows)) {
229
- newPath.push('rows');
230
- component.rows.forEach(function (row, index) {
231
- var rowPath = newPath.slice();
232
- rowPath.push(index);
233
- row.forEach(function (column, index) {
234
- var colPath = rowPath.slice();
235
- colPath.push(index);
236
- colPath.push('components');
237
- findComponent(column.components, key, colPath, fn);
238
- });
239
- });
240
- }
241
- if (component.hasOwnProperty('components') && Array.isArray(component.components)) {
242
- newPath.push('components');
243
- findComponent(component.components, key, newPath, fn);
244
- }
245
- if (component.key === key) {
246
- //Final callback if the component is found
247
- fn(component, newPath, components);
248
- }
249
- });
250
- }
251
- exports.findComponent = findComponent;
252
- /**
253
- * Remove a component by path.
254
- *
255
- * @param components
256
- * @param path
257
- */
258
- function removeComponent(components, path) {
259
- // Using _.unset() leave a null value. Use Array splice instead.
260
- var index = path.pop();
261
- if (path.length !== 0) {
262
- components = (0, get_1.default)(components, path);
263
- }
264
- components.splice(index, 1);
265
- }
266
- exports.removeComponent = removeComponent;
267
- function generateFormChange(type, data) {
268
- let change;
269
- switch (type) {
270
- case 'add':
271
- change = {
272
- op: 'add',
273
- key: data.component.key,
274
- container: data.parent.key, // Parent component
275
- path: data.path, // Path to container within parent component.
276
- index: data.index, // Index of component in parent container.
277
- component: data.component
278
- };
279
- break;
280
- case 'edit':
281
- change = {
282
- op: 'edit',
283
- key: data.originalComponent.key,
284
- patches: (0, fast_json_patch_1.compare)(data.originalComponent, data.component)
285
- };
286
- // Don't save if nothing changed.
287
- if (!change.patches.length) {
288
- change = null;
289
- }
290
- break;
291
- case 'remove':
292
- change = {
293
- op: 'remove',
294
- key: data.component.key,
295
- };
296
- break;
297
- }
298
- return change;
299
- }
300
- exports.generateFormChange = generateFormChange;
301
- function applyFormChanges(form, changes) {
302
- const failed = [];
303
- changes.forEach(function (change) {
304
- var found = false;
305
- switch (change.op) {
306
- case 'add':
307
- var newComponent = change.component;
308
- // Find the container to set the component in.
309
- findComponent(form.components, change.container, null, function (parent) {
310
- if (!change.container) {
311
- parent = form;
312
- }
313
- // A move will first run an add so remove any existing components with matching key before inserting.
314
- findComponent(form.components, change.key, null, function (component, path) {
315
- // If found, use the existing component. (If someone else edited it, the changes would be here)
316
- newComponent = component;
317
- removeComponent(form.components, path);
318
- });
319
- found = true;
320
- var container = (0, get_1.default)(parent, change.path);
321
- container.splice(change.index, 0, newComponent);
322
- });
323
- break;
324
- case 'remove':
325
- findComponent(form.components, change.key, null, function (component, path) {
326
- found = true;
327
- const oldComponent = (0, get_1.default)(form.components, path);
328
- if (oldComponent.key !== component.key) {
329
- path.pop();
330
- }
331
- removeComponent(form.components, path);
332
- });
333
- break;
334
- case 'edit':
335
- findComponent(form.components, change.key, null, function (component, path) {
336
- found = true;
337
- try {
338
- const oldComponent = (0, get_1.default)(form.components, path);
339
- const newComponent = (0, fast_json_patch_1.applyPatch)(component, change.patches).newDocument;
340
- if (oldComponent.key !== newComponent.key) {
341
- path.pop();
342
- }
343
- (0, set_1.default)(form.components, path, newComponent);
344
- }
345
- catch (err) {
346
- failed.push(change);
347
- }
348
- });
349
- break;
350
- case 'move':
351
- break;
352
- }
353
- if (!found) {
354
- failed.push(change);
355
- }
356
- });
357
- return {
358
- form,
359
- failed
360
- };
361
- }
362
- exports.applyFormChanges = applyFormChanges;
363
- /**
364
- * Flatten the form components for data manipulation.
365
- *
366
- * @param {Object} components
367
- * The components to iterate.
368
- * @param {Boolean} includeAll
369
- * Whether or not to include layout components.
370
- *
371
- * @returns {Object}
372
- * The flattened components map.
373
- */
374
- function flattenComponents(components, includeAll = false) {
375
- const flattened = {};
376
- eachComponent(components, (component, path) => {
377
- flattened[path] = component;
378
- }, includeAll);
379
- return flattened;
380
- }
381
- exports.flattenComponents = flattenComponents;
382
- /**
383
- * Returns if this component has a conditional statement.
384
- *
385
- * @param component - The component JSON schema.
386
- *
387
- * @returns {boolean} - TRUE - This component has a conditional, FALSE - No conditional provided.
388
- */
389
- function hasCondition(component) {
390
- return Boolean((component.customConditional) ||
391
- (component.conditional && (component.conditional.when ||
392
- (lodash_1.default.some(component.conditional.conditions || [], (condition => condition.component && condition.operator))) ||
393
- component.conditional.json ||
394
- component.conditional.condition)));
395
- }
396
- exports.hasCondition = hasCondition;
397
- /**
398
- * Extension of standard #parseFloat(value) function, that also clears input string.
399
- *
400
- * @param {any} value
401
- * The value to parse.
402
- *
403
- * @returns {Number}
404
- * Parsed value.
405
- */
406
- function parseFloatExt(value) {
407
- return parseFloat((0, isString_1.default)(value)
408
- ? value.replace(/[^\de.+-]/gi, '')
409
- : value);
410
- }
411
- exports.parseFloatExt = parseFloatExt;
412
- /**
413
- * Formats provided value in way how Currency component uses it.
414
- *
415
- * @param {any} value
416
- * The value to format.
417
- *
418
- * @returns {String}
419
- * Value formatted for Currency component.
420
- */
421
- function formatAsCurrency(value) {
422
- const parsedValue = parseFloatExt(value);
423
- if ((0, isNaN_1.default)(parsedValue)) {
424
- return '';
425
- }
426
- const parts = (0, round_1.default)(parsedValue, 2)
427
- .toString()
428
- .split('.');
429
- parts[0] = (0, chunk_1.default)(Array.from(parts[0]).reverse(), 3)
430
- .reverse()
431
- .map((part) => part
432
- .reverse()
433
- .join(''))
434
- .join(',');
435
- parts[1] = (0, pad_1.default)(parts[1], 2, '0');
436
- return parts.join('.');
437
- }
438
- exports.formatAsCurrency = formatAsCurrency;
439
- /**
440
- * Escapes RegEx characters in provided String value.
441
- *
442
- * @param {String} value
443
- * String for escaping RegEx characters.
444
- * @returns {string}
445
- * String with escaped RegEx characters.
446
- */
447
- function escapeRegExCharacters(value) {
448
- return value.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
449
- }
450
- exports.escapeRegExCharacters = escapeRegExCharacters;
451
- /**
452
- * Get the value for a component key, in the given submission.
453
- *
454
- * @param {Object} submission
455
- * A submission object to search.
456
- * @param {String} key
457
- * A for components API key to search for.
458
- */
459
- function getValue(submission, key) {
460
- const search = (data) => {
461
- if ((0, isPlainObject_1.default)(data)) {
462
- if ((0, has_1.default)(data, key)) {
463
- return lodash_1.default.get(data, key);
464
- }
465
- let value = null;
466
- (0, forOwn_1.default)(data, (prop) => {
467
- const result = search(prop);
468
- if (!(0, isNil_1.default)(result)) {
469
- value = result;
470
- return false;
471
- }
472
- });
473
- return value;
474
- }
475
- else {
476
- return null;
477
- }
478
- };
479
- return search(submission.data);
480
- }
481
- exports.getValue = getValue;
482
- /**
483
- * Iterate over all components in a form and get string values for translation.
484
- * @param form
485
- */
486
- function getStrings(form) {
487
- const properties = ['label', 'title', 'legend', 'tooltip', 'description', 'placeholder', 'prefix', 'suffix', 'errorLabel', 'content', 'html'];
488
- const strings = [];
489
- eachComponent(form.components, component => {
490
- properties.forEach(property => {
491
- if (component.hasOwnProperty(property) && component[property]) {
492
- strings.push({
493
- key: component.key,
494
- type: component.type,
495
- property,
496
- string: component[property]
497
- });
498
- }
499
- });
500
- if ((!component.dataSrc || component.dataSrc === 'values') && component.hasOwnProperty('values') && Array.isArray(component.values) && component.values.length) {
501
- component.values.forEach((value, index) => {
502
- strings.push({
503
- key: component.key,
504
- property: `value[${index}].label`,
505
- string: component.values[index].label
506
- });
507
- });
508
- }
509
- // Hard coded values from Day component
510
- if (component.type === 'day') {
511
- [
512
- 'day',
513
- 'month',
514
- 'year',
515
- 'Day',
516
- 'Month',
517
- 'Year',
518
- 'january',
519
- 'february',
520
- 'march',
521
- 'april',
522
- 'may',
523
- 'june',
524
- 'july',
525
- 'august',
526
- 'september',
527
- 'october',
528
- 'november',
529
- 'december'
530
- ].forEach(string => {
531
- strings.push({
532
- key: component.key,
533
- property: 'day',
534
- string,
535
- });
536
- });
537
- if (component.fields.day.placeholder) {
538
- strings.push({
539
- key: component.key,
540
- property: 'fields.day.placeholder',
541
- string: component.fields.day.placeholder,
542
- });
543
- }
544
- if (component.fields.month.placeholder) {
545
- strings.push({
546
- key: component.key,
547
- property: 'fields.month.placeholder',
548
- string: component.fields.month.placeholder,
549
- });
550
- }
551
- if (component.fields.year.placeholder) {
552
- strings.push({
553
- key: component.key,
554
- property: 'fields.year.placeholder',
555
- string: component.fields.year.placeholder,
556
- });
557
- }
558
- }
559
- if (component.type === 'editgrid') {
560
- const string = component.addAnother || 'Add Another';
561
- if (component.addAnother) {
562
- strings.push({
563
- key: component.key,
564
- property: 'addAnother',
565
- string,
566
- });
567
- }
568
- }
569
- if (component.type === 'select') {
570
- [
571
- 'loading...',
572
- 'Type to search'
573
- ].forEach(string => {
574
- strings.push({
575
- key: component.key,
576
- property: 'select',
577
- string,
578
- });
579
- });
580
- }
581
- }, true);
582
- return strings;
583
- }
584
- exports.getStrings = getStrings;
@@ -372,6 +372,6 @@ export namespace componentValueTypes {
372
372
  export function interpolateErrors(component: any, errors: FieldError[], interpolateFn: any): [];
373
373
  import jsonLogic from 'json-logic-js';
374
374
  import ConditionOperators from './conditionOperators';
375
- import Evaluator from './Evaluator';
376
- export const interpolate: (rawTemplate: any, data: any, _options: any) => any;
375
+ import { Evaluator } from './Evaluator';
376
+ export const interpolate: typeof Evaluator.interpolate;
377
377
  export { jsonLogic, ConditionOperators, Evaluator, _ };
@@ -42,11 +42,11 @@ const jstimezonedetect_1 = __importDefault(require("jstimezonedetect"));
42
42
  const operators_1 = require("./jsonlogic/operators");
43
43
  const dompurify_1 = __importDefault(require("dompurify"));
44
44
  const formUtils_1 = require("./formUtils");
45
- const Evaluator_1 = __importDefault(require("./Evaluator"));
46
- exports.Evaluator = Evaluator_1.default;
45
+ const Evaluator_1 = require("./Evaluator");
46
+ Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
47
47
  const conditionOperators_1 = __importDefault(require("./conditionOperators"));
48
48
  exports.ConditionOperators = conditionOperators_1.default;
49
- const interpolate = Evaluator_1.default.interpolate;
49
+ const interpolate = Evaluator_1.Evaluator.interpolate;
50
50
  exports.interpolate = interpolate;
51
51
  const { fetch } = (0, fetch_ponyfill_1.default)({
52
52
  Promise: Promise
@@ -106,7 +106,7 @@ function evaluate(func, args, ret, tokenize) {
106
106
  });
107
107
  }
108
108
  try {
109
- func = Evaluator_1.default.evaluator(func, args);
109
+ func = Evaluator_1.Evaluator.evaluator(func, args);
110
110
  args = lodash_1.default.values(args);
111
111
  }
112
112
  catch (err) {
@@ -117,7 +117,7 @@ function evaluate(func, args, ret, tokenize) {
117
117
  }
118
118
  if (typeof func === 'function') {
119
119
  try {
120
- returnVal = Evaluator_1.default.evaluate(func, args);
120
+ returnVal = Evaluator_1.Evaluator.evaluate(func, args);
121
121
  }
122
122
  catch (err) {
123
123
  returnVal = null;
@@ -424,7 +424,7 @@ function setActionProperty(component, action, result, row, data, instance) {
424
424
  const currentValue = lodash_1.default.get(component, property, '');
425
425
  const newValue = (instance && instance.interpolate)
426
426
  ? instance.interpolate(textValue, evalData)
427
- : Evaluator_1.default.interpolate(textValue, evalData);
427
+ : Evaluator_1.Evaluator.interpolate(textValue, evalData);
428
428
  if (newValue !== currentValue) {
429
429
  lodash_1.default.set(component, property, newValue);
430
430
  }
@@ -483,7 +483,7 @@ function uniqueName(name, template, evalContext) {
483
483
  guid: guid()
484
484
  });
485
485
  //only letters, numbers, dots, dashes, underscores and spaces are allowed. Anything else will be replaced with dash
486
- const uniqueName = `${Evaluator_1.default.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\-_ ]/g, '-');
486
+ const uniqueName = `${Evaluator_1.Evaluator.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\-_ ]/g, '-');
487
487
  return uniqueName;
488
488
  }
489
489
  exports.uniqueName = uniqueName;
@@ -519,7 +519,7 @@ function getDateSetting(date) {
519
519
  }
520
520
  dateSetting = null;
521
521
  try {
522
- const value = Evaluator_1.default.evaluator(`return ${date};`, 'moment')(moment_timezone_1.default);
522
+ const value = Evaluator_1.Evaluator.evaluator(`return ${date};`, 'moment')(moment_timezone_1.default);
523
523
  if (typeof value === 'string') {
524
524
  dateSetting = (0, moment_timezone_1.default)(value);
525
525
  }
@@ -1149,7 +1149,7 @@ function translateElemValue(elem, translate) {
1149
1149
  if (!elem.innerText) {
1150
1150
  return elem.innerHTML;
1151
1151
  }
1152
- const elemValue = elem.innerText.replace(Evaluator_1.default.templateSettings.interpolate, '').replace(/\s\s+/g, ' ').trim();
1152
+ const elemValue = elem.innerText.replace(Evaluator_1.Evaluator.templateSettings.interpolate, '').replace(/\s\s+/g, ' ').trim();
1153
1153
  const translatedValue = translate(elemValue);
1154
1154
  if (elemValue !== translatedValue) {
1155
1155
  const links = elem.innerHTML.match(/<a[^>]*>(.*?)<\/a>/g);