@formio/js 5.0.0-rc.31 → 5.0.0-rc.33

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- /*! formiojs v5.0.0-rc.31 | https://unpkg.com/formiojs@5.0.0-rc.31/LICENSE.txt */
1
+ /*! formiojs v5.0.0-rc.33 | https://unpkg.com/formiojs@5.0.0-rc.33/LICENSE.txt */
2
2
 
3
3
  /**
4
4
  * @license
@@ -37,7 +37,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
37
37
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
38
38
 
39
39
  "use strict";
40
- eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Evaluator = exports.BaseEvaluator = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"../core/node_modules/lodash/lodash.js\");\n// BaseEvaluator is for extending.\nclass BaseEvaluator {\n static evaluator(func, ...params) {\n if (Evaluator.noeval) {\n console.warn('No evaluations allowed for this renderer.');\n return lodash_1.noop;\n }\n if (typeof func === 'function') {\n return func;\n }\n if (typeof params[0] === 'object') {\n params = (0, lodash_1.keys)(params[0]);\n }\n return new Function(...params, func);\n }\n ;\n static interpolateString(rawTemplate, data, options = {}) {\n return rawTemplate.replace(/({{\\s*(.*?)\\s*}})/g, (match, $1, $2) => {\n // If this is a function call and we allow evals.\n if ($2.indexOf('(') !== -1) {\n return $2.replace(/([^\\(]+)\\(([^\\)]+)\\s*\\);?/, (evalMatch, funcName, args) => {\n funcName = (0, lodash_1.trim)(funcName);\n const func = (0, lodash_1.get)(data, funcName);\n if (func) {\n if (args) {\n args = args.split(',').map((arg) => {\n arg = (0, lodash_1.trim)(arg);\n if ((arg.indexOf('\"') === 0) || (arg.indexOf(\"'\") === 0)) {\n return arg.substring(1, arg.length - 1);\n }\n return (0, lodash_1.get)(data, arg);\n });\n }\n return Evaluator.evaluate(func, args, '', false, data, options);\n }\n return '';\n });\n }\n else {\n let dataPath = $2;\n if ($2.indexOf('?') !== -1) {\n dataPath = $2.replace(/\\?\\./g, '.');\n }\n // Allow for conditional values.\n const parts = dataPath.split('||').map((item) => item.trim());\n let value = '';\n let path = '';\n for (let i = 0; i < parts.length; i++) {\n path = parts[i];\n value = (0, lodash_1.get)(data, path);\n if (value) {\n break;\n }\n }\n if (options.data) {\n (0, lodash_1.set)(options.data, path, value);\n }\n return value;\n }\n });\n }\n static interpolate(rawTemplate, data, options = {}) {\n if (typeof rawTemplate === 'function') {\n try {\n return rawTemplate(data);\n }\n catch (err) {\n console.warn('Error interpolating template', err, data);\n return err.message;\n }\n }\n return Evaluator.interpolateString(String(rawTemplate), data, options);\n }\n ;\n /**\n * Evaluate a method.\n *\n * @param func\n * @param args\n * @return {*}\n */\n static evaluate(func, args = {}, ret = '', interpolate = false, context = {}, options = {}) {\n let returnVal = null;\n options = (0, lodash_1.isObject)(options) ? options : { noeval: options };\n const component = args.component ? args.component : { key: 'unknown' };\n if (!args.form && args.instance) {\n args.form = (0, lodash_1.get)(args.instance, 'root._form', {});\n }\n const componentKey = component.key;\n if (typeof func === 'string') {\n if (ret) {\n func += `;return ${ret}`;\n }\n if (interpolate) {\n func = BaseEvaluator.interpolate(func, args, options);\n }\n try {\n if (Evaluator.noeval || options.noeval) {\n func = lodash_1.noop;\n }\n else {\n func = Evaluator.evaluator(func, args, context);\n }\n args = (0, lodash_1.values)(args);\n }\n catch (err) {\n console.warn(`An error occured within the custom function for ${componentKey}`, err);\n returnVal = null;\n func = false;\n }\n }\n if (typeof func === 'function') {\n try {\n returnVal = Evaluator.execute(func, args, context, options);\n }\n catch (err) {\n returnVal = null;\n console.warn(`An error occured within custom function for ${componentKey}`, err);\n }\n }\n else if (func) {\n console.warn(`Unknown function type for ${componentKey}`);\n }\n return returnVal;\n }\n /**\n * Execute a function.\n *\n * @param func\n * @param args\n * @returns\n */\n static execute(func, args, context = {}, options = {}) {\n options = (0, lodash_1.isObject)(options) ? options : { noeval: options };\n if (Evaluator.noeval || options.noeval) {\n console.warn('No evaluations allowed for this renderer.');\n return;\n }\n return Array.isArray(args) ? func.apply(context, args) : func.call(context, args);\n }\n ;\n}\nexports.BaseEvaluator = BaseEvaluator;\nBaseEvaluator.templateSettings = {\n interpolate: /{{([\\s\\S]+?)}}/g,\n evaluate: /\\{%([\\s\\S]+?)%\\}/g,\n escape: /\\{\\{\\{([\\s\\S]+?)\\}\\}\\}/g\n};\nBaseEvaluator.noeval = false;\n// The extendable evaluator\nclass Evaluator extends BaseEvaluator {\n /**\n * Allow external modules the ability to extend the Evaluator.\n * @param evaluator\n */\n static registerEvaluator(evaluator) {\n Object.keys(evaluator).forEach((key) => {\n Evaluator[key] = evaluator[key];\n });\n }\n}\nexports.Evaluator = Evaluator;\n\n\n//# sourceURL=webpack://Formio/../core/lib/utils/Evaluator.js?");
40
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Evaluator = exports.BaseEvaluator = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"../core/node_modules/lodash/lodash.js\");\n// BaseEvaluator is for extending.\nclass BaseEvaluator {\n static evaluator(func, ...params) {\n if (Evaluator.noeval) {\n console.warn('No evaluations allowed for this renderer.');\n return lodash_1.noop;\n }\n if (typeof func === 'function') {\n return func;\n }\n if (typeof params[0] === 'object') {\n params = (0, lodash_1.keys)(params[0]);\n }\n return new Function(...params, func);\n }\n ;\n static interpolateString(rawTemplate, data, options = {}) {\n if (!rawTemplate) {\n return '';\n }\n if (typeof rawTemplate !== 'string') {\n return rawTemplate.toString();\n }\n return rawTemplate.replace(/({{\\s*(.*?)\\s*}})/g, (match, $1, $2) => {\n // If this is a function call and we allow evals.\n if ($2.indexOf('(') !== -1) {\n return $2.replace(/([^\\(]+)\\(([^\\)]+)\\s*\\);?/, (evalMatch, funcName, args) => {\n funcName = (0, lodash_1.trim)(funcName);\n const func = (0, lodash_1.get)(data, funcName);\n if (func) {\n if (args) {\n args = args.split(',').map((arg) => {\n arg = (0, lodash_1.trim)(arg);\n if ((arg.indexOf('\"') === 0) || (arg.indexOf(\"'\") === 0)) {\n return arg.substring(1, arg.length - 1);\n }\n return (0, lodash_1.get)(data, arg);\n });\n }\n return Evaluator.evaluate(func, args, '', false, data, options);\n }\n return '';\n });\n }\n else {\n let dataPath = $2;\n if ($2.indexOf('?') !== -1) {\n dataPath = $2.replace(/\\?\\./g, '.');\n }\n // Allow for conditional values.\n const parts = dataPath.split('||').map((item) => item.trim());\n let value = '';\n let path = '';\n for (let i = 0; i < parts.length; i++) {\n path = parts[i];\n value = (0, lodash_1.get)(data, path);\n if (value) {\n break;\n }\n }\n if (options.data) {\n (0, lodash_1.set)(options.data, path, value);\n }\n return value;\n }\n });\n }\n static interpolate(rawTemplate, data, options = {}) {\n if (typeof rawTemplate === 'function') {\n try {\n return rawTemplate(data);\n }\n catch (err) {\n console.warn('Error interpolating template', err, data);\n return err.message;\n }\n }\n return Evaluator.interpolateString(String(rawTemplate), data, options);\n }\n ;\n /**\n * Evaluate a method.\n *\n * @param func\n * @param args\n * @return {*}\n */\n static evaluate(func, args = {}, ret = '', interpolate = false, context = {}, options = {}) {\n let returnVal = null;\n options = (0, lodash_1.isObject)(options) ? options : { noeval: options };\n const component = args.component ? args.component : { key: 'unknown' };\n if (!args.form && args.instance) {\n args.form = (0, lodash_1.get)(args.instance, 'root._form', {});\n }\n const componentKey = component.key;\n if (typeof func === 'string') {\n if (ret) {\n func += `;return ${ret}`;\n }\n if (interpolate) {\n func = BaseEvaluator.interpolate(func, args, options);\n }\n try {\n if (Evaluator.noeval || options.noeval) {\n func = lodash_1.noop;\n }\n else {\n func = Evaluator.evaluator(func, args, context);\n }\n args = (0, lodash_1.values)(args);\n }\n catch (err) {\n console.warn(`An error occured within the custom function for ${componentKey}`, err);\n returnVal = null;\n func = false;\n }\n }\n if (typeof func === 'function') {\n try {\n returnVal = Evaluator.execute(func, args, context, options);\n }\n catch (err) {\n returnVal = null;\n console.warn(`An error occured within custom function for ${componentKey}`, err);\n }\n }\n else if (func) {\n console.warn(`Unknown function type for ${componentKey}`);\n }\n return returnVal;\n }\n /**\n * Execute a function.\n *\n * @param func\n * @param args\n * @returns\n */\n static execute(func, args, context = {}, options = {}) {\n options = (0, lodash_1.isObject)(options) ? options : { noeval: options };\n if (Evaluator.noeval || options.noeval) {\n console.warn('No evaluations allowed for this renderer.');\n return;\n }\n return Array.isArray(args) ? func.apply(context, args) : func.call(context, args);\n }\n ;\n}\nexports.BaseEvaluator = BaseEvaluator;\nBaseEvaluator.templateSettings = {\n interpolate: /{{([\\s\\S]+?)}}/g,\n evaluate: /\\{%([\\s\\S]+?)%\\}/g,\n escape: /\\{\\{\\{([\\s\\S]+?)\\}\\}\\}/g\n};\nBaseEvaluator.noeval = false;\n// The extendable evaluator\nclass Evaluator extends BaseEvaluator {\n /**\n * Allow external modules the ability to extend the Evaluator.\n * @param evaluator\n */\n static registerEvaluator(evaluator) {\n Object.keys(evaluator).forEach((key) => {\n Evaluator[key] = evaluator[key];\n });\n }\n}\nexports.Evaluator = Evaluator;\n\n\n//# sourceURL=webpack://Formio/../core/lib/utils/Evaluator.js?");
41
41
 
42
42
  /***/ }),
43
43