@bolttech/form-engine-core 0.0.2-beta.1 → 0.0.2-beta.2
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/index.esm.js +16 -11
- package/package.json +1 -1
package/index.esm.js
CHANGED
|
@@ -3238,6 +3238,15 @@ class FormCore {
|
|
|
3238
3238
|
* @returns {string[]} An array of extracted parameters.
|
|
3239
3239
|
*/
|
|
3240
3240
|
extractParams(expression) {
|
|
3241
|
+
const getTemplateValue = function getTemplvalue(pathOrValue) {
|
|
3242
|
+
const element = pathOrValue.split('.');
|
|
3243
|
+
return element.length > 1 ? this.getValue({
|
|
3244
|
+
scope: element[0],
|
|
3245
|
+
key: element[1],
|
|
3246
|
+
property: element[2],
|
|
3247
|
+
path: element.slice(3)
|
|
3248
|
+
}) : element[0];
|
|
3249
|
+
}.bind(this);
|
|
3241
3250
|
const extractedValues = [];
|
|
3242
3251
|
let match;
|
|
3243
3252
|
while (!isNil(match = TEMPLATE_REGEX_DELIMITATOR.exec(expression))) {
|
|
@@ -3245,19 +3254,16 @@ class FormCore {
|
|
|
3245
3254
|
}
|
|
3246
3255
|
const splittedString = extractedValues.map(el => el.split(TEMPLATE_REGEX_OPERATOR_SPLITTER));
|
|
3247
3256
|
const result = splittedString.map(splittedStringVal => {
|
|
3257
|
+
// skip operator logic parsing and pass element directly
|
|
3258
|
+
if (splittedStringVal.length <= 1) {
|
|
3259
|
+
return getTemplateValue(splittedStringVal[0]);
|
|
3260
|
+
}
|
|
3248
3261
|
return splittedStringVal.filter(Boolean).reduce((acc, curr) => {
|
|
3249
3262
|
if (curr.match(TEMPLATE_REGEX_OPERATOR_MATCHER)) {
|
|
3250
3263
|
return `${acc}${curr}`;
|
|
3251
3264
|
}
|
|
3252
3265
|
let value;
|
|
3253
|
-
|
|
3254
|
-
const element = curr.split('.');
|
|
3255
|
-
const currElementContent = element.length > 1 ? this.getValue({
|
|
3256
|
-
scope: element[0],
|
|
3257
|
-
key: element[1],
|
|
3258
|
-
property: element[2],
|
|
3259
|
-
path: element.slice(3)
|
|
3260
|
-
}) : curr;
|
|
3266
|
+
const currElementContent = getTemplateValue(curr);
|
|
3261
3267
|
let currValue;
|
|
3262
3268
|
// if any parsable content was passed to the conditions, parse them
|
|
3263
3269
|
// required to be able to apply conditions
|
|
@@ -3295,9 +3301,8 @@ class FormCore {
|
|
|
3295
3301
|
return result.map(el => {
|
|
3296
3302
|
try {
|
|
3297
3303
|
return new Function(`return ${el}`)();
|
|
3298
|
-
} catch (
|
|
3299
|
-
|
|
3300
|
-
return 'lil error here.. :(';
|
|
3304
|
+
} catch (_a) {
|
|
3305
|
+
return el;
|
|
3301
3306
|
}
|
|
3302
3307
|
});
|
|
3303
3308
|
}
|