react-survey-builder 1.0.82 → 1.0.84

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.
@@ -1,11 +1,11 @@
1
- var _excluded = ["name", "onChange", "value", "style", "item"],
2
- _excluded2 = ["name", "onChange", "value", "style", "item"],
3
- _excluded3 = ["name", "onChange", "value", "style", "item"],
4
- _excluded4 = ["name", "onChange", "value", "style", "item"],
5
- _excluded5 = ["name", "onChange", "value", "style", "item"],
6
- _excluded6 = ["name", "onChange", "value", "style", "item"],
7
- _excluded7 = ["name", "onChange", "value", "style", "item"],
8
- _excluded8 = ["name", "onChange", "value", "style", "item"],
1
+ var _excluded = ["name", "onChange", "defaultValue", "style", "item"],
2
+ _excluded2 = ["name", "onChange", "defaultValue", "style", "item"],
3
+ _excluded3 = ["name", "onChange", "defaultValue", "style", "item"],
4
+ _excluded4 = ["name", "onChange", "defaultValue", "style", "item"],
5
+ _excluded5 = ["name", "onChange", "defaultValue", "style", "item"],
6
+ _excluded6 = ["name", "onChange", "defaultValue", "style", "item"],
7
+ _excluded7 = ["name", "onChange", "defaultValue", "style", "item"],
8
+ _excluded8 = ["name", "onChange", "defaultValue", "style", "item"],
9
9
  _excluded9 = ["name", "onChange", "value", "style", "item"];
10
10
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
11
11
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
@@ -51,8 +51,10 @@ import { Controller, useFormContext } from 'react-hook-form';
51
51
  import { IMask, IMaskInput } from 'react-imask';
52
52
  import { isValidPhoneNumber } from 'libphonenumber-js';
53
53
  import ID from '../UUID';
54
+ import { replaceInText } from '../utils/objectUtils';
54
55
  var SurveyElements = {};
55
56
  export var Header = function Header(props) {
57
+ var _props$item;
56
58
  var classNames = 'static';
57
59
  if (props.item.bold) {
58
60
  classNames += ' bold';
@@ -73,11 +75,12 @@ export var Header = function Header(props) {
73
75
  }, /*#__PURE__*/React.createElement(ComponentHeader, props), /*#__PURE__*/React.createElement("h3", {
74
76
  className: classNames,
75
77
  dangerouslySetInnerHTML: {
76
- __html: myxss.process(props.item.content)
78
+ __html: myxss.process(replaceInText(props.item.content, (_props$item = props.item) === null || _props$item === void 0 ? void 0 : _props$item.staticVariables))
77
79
  }
78
80
  }));
79
81
  };
80
82
  export var ContentBody = function ContentBody(props) {
83
+ var _props$item2;
81
84
  var classNames = 'static';
82
85
  var baseClasses = 'SortableItem rfb-item';
83
86
  if (props.item.pageBreakBefore) {
@@ -89,11 +92,12 @@ export var ContentBody = function ContentBody(props) {
89
92
  }, /*#__PURE__*/React.createElement(ComponentHeader, props), /*#__PURE__*/React.createElement("div", {
90
93
  className: classNames,
91
94
  dangerouslySetInnerHTML: {
92
- __html: myContentXSS.process(props.item.content)
95
+ __html: myContentXSS.process(replaceInText(props.item.content, (_props$item2 = props.item) === null || _props$item2 === void 0 ? void 0 : _props$item2.staticVariables))
93
96
  }
94
97
  }));
95
98
  };
96
99
  export var Paragraph = function Paragraph(props) {
100
+ var _props$item3;
97
101
  var classNames = 'static';
98
102
  if (props.item.bold) {
99
103
  classNames += ' bold';
@@ -114,11 +118,12 @@ export var Paragraph = function Paragraph(props) {
114
118
  }, /*#__PURE__*/React.createElement(ComponentHeader, props), /*#__PURE__*/React.createElement("p", {
115
119
  className: classNames,
116
120
  dangerouslySetInnerHTML: {
117
- __html: myxss.process(props.item.content)
121
+ __html: myxss.process(replaceInText(props.item.content, (_props$item3 = props.item) === null || _props$item3 === void 0 ? void 0 : _props$item3.staticVariables))
118
122
  }
119
123
  }));
120
124
  };
121
125
  export var Label = function Label(props) {
126
+ var _props$item4;
122
127
  var classNames = 'static';
123
128
  if (props.item.bold) {
124
129
  classNames += ' bold';
@@ -137,9 +142,9 @@ export var Label = function Label(props) {
137
142
  style: _objectSpread({}, props.style),
138
143
  className: baseClasses
139
144
  }, /*#__PURE__*/React.createElement(ComponentHeader, props), /*#__PURE__*/React.createElement("label", {
140
- className: "".concat(classNames, " form-label"),
145
+ className: "form-label ".concat(classNames),
141
146
  dangerouslySetInnerHTML: {
142
- __html: myxss.process(props.item.content)
147
+ __html: myxss.process(replaceInText(props.item.content, (_props$item4 = props.item) === null || _props$item4 === void 0 ? void 0 : _props$item4.staticVariables))
143
148
  }
144
149
  }));
145
150
  };
@@ -157,7 +162,7 @@ export var TextInput = function TextInput(_ref) {
157
162
  var _item$required, _item$disabled, _item$required2;
158
163
  var name = _ref.name,
159
164
  onChange = _ref.onChange,
160
- value = _ref.value,
165
+ defaultValue = _ref.defaultValue,
161
166
  style = _ref.style,
162
167
  item = _ref.item,
163
168
  props = _objectWithoutProperties(_ref, _excluded);
@@ -215,8 +220,8 @@ export var TextInput = function TextInput(_ref) {
215
220
  id: name + '-' + ID.uuid()
216
221
  }, inputProps));
217
222
  };
218
- if (value !== undefined) {
219
- controllerProps.defaultValue = value;
223
+ if (defaultValue !== undefined) {
224
+ controllerProps.defaultValue = defaultValue;
220
225
  }
221
226
  if ((item === null || item === void 0 ? void 0 : item.disabled) !== undefined) {
222
227
  var _item$disabled2;
@@ -243,7 +248,7 @@ export var TextInput = function TextInput(_ref) {
243
248
  }, props)), /*#__PURE__*/React.createElement(Form.Group, {
244
249
  className: "form-group mb-3"
245
250
  }, labelLocation === "FLOATING" ? /*#__PURE__*/React.createElement(Form.Floating, null, /*#__PURE__*/React.createElement(Form.Control, _extends({
246
- value: value,
251
+ value: defaultValue,
247
252
  name: name,
248
253
  id: name + '-2-' + ID.uuid()
249
254
  }, inputProps)), /*#__PURE__*/React.createElement(ComponentLabel, {
@@ -255,7 +260,7 @@ export var TextInput = function TextInput(_ref) {
255
260
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
256
261
  htmlFor: name
257
262
  }), /*#__PURE__*/React.createElement(Form.Control, _extends({
258
- value: value,
263
+ value: defaultValue,
259
264
  name: name,
260
265
  id: name + '-2-' + ID.uuid()
261
266
  }, inputProps))), item !== null && item !== void 0 && item.help ? /*#__PURE__*/React.createElement(Form.Text, {
@@ -274,7 +279,7 @@ export var TextInput = function TextInput(_ref) {
274
279
  item: item,
275
280
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
276
281
  htmlFor: name
277
- }), /*#__PURE__*/React.createElement("div", null, value !== null && value !== void 0 ? value : '')));
282
+ }), /*#__PURE__*/React.createElement("div", null, defaultValue !== null && defaultValue !== void 0 ? defaultValue : '')));
278
283
  }
279
284
  return /*#__PURE__*/React.createElement("div", {
280
285
  style: _objectSpread({}, style),
@@ -305,7 +310,7 @@ export var EmailInput = function EmailInput(_ref3) {
305
310
  var _item$required4, _item$disabled3, _item$required5;
306
311
  var name = _ref3.name,
307
312
  onChange = _ref3.onChange,
308
- value = _ref3.value,
313
+ defaultValue = _ref3.defaultValue,
309
314
  style = _ref3.style,
310
315
  item = _ref3.item,
311
316
  props = _objectWithoutProperties(_ref3, _excluded2);
@@ -376,8 +381,8 @@ export var EmailInput = function EmailInput(_ref3) {
376
381
  id: name + '-' + ID.uuid()
377
382
  }, inputProps));
378
383
  };
379
- if (value !== undefined) {
380
- controllerProps.defaultValue = value;
384
+ if (defaultValue !== undefined) {
385
+ controllerProps.defaultValue = defaultValue;
381
386
  }
382
387
  if ((item === null || item === void 0 ? void 0 : item.disabled) !== undefined) {
383
388
  var _item$disabled4;
@@ -404,7 +409,7 @@ export var EmailInput = function EmailInput(_ref3) {
404
409
  }, props)), /*#__PURE__*/React.createElement(Form.Group, {
405
410
  className: "form-group mb-3"
406
411
  }, labelLocation === "FLOATING" ? /*#__PURE__*/React.createElement(Form.Floating, null, /*#__PURE__*/React.createElement(Form.Control, _extends({
407
- value: value,
412
+ value: defaultValue,
408
413
  name: name,
409
414
  id: name + '-2-' + ID.uuid()
410
415
  }, inputProps)), /*#__PURE__*/React.createElement(ComponentLabel, {
@@ -416,7 +421,7 @@ export var EmailInput = function EmailInput(_ref3) {
416
421
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
417
422
  htmlFor: name
418
423
  }), /*#__PURE__*/React.createElement(Form.Control, _extends({
419
- value: value,
424
+ value: defaultValue,
420
425
  name: name,
421
426
  id: name + '-2-' + ID.uuid()
422
427
  }, inputProps))), item !== null && item !== void 0 && item.help ? /*#__PURE__*/React.createElement(Form.Text, {
@@ -435,7 +440,7 @@ export var EmailInput = function EmailInput(_ref3) {
435
440
  item: item,
436
441
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
437
442
  htmlFor: name
438
- }), /*#__PURE__*/React.createElement("div", null, value !== null && value !== void 0 ? value : '')));
443
+ }), /*#__PURE__*/React.createElement("div", null, defaultValue !== null && defaultValue !== void 0 ? defaultValue : '')));
439
444
  }
440
445
  return /*#__PURE__*/React.createElement("div", {
441
446
  style: _objectSpread({}, style),
@@ -466,8 +471,8 @@ export var PhoneNumber = function PhoneNumber(_ref5) {
466
471
  var _item$required7, _item$disabled5, _item$required8;
467
472
  var name = _ref5.name,
468
473
  onChange = _ref5.onChange,
469
- _ref5$value = _ref5.value,
470
- value = _ref5$value === void 0 ? '' : _ref5$value,
474
+ _ref5$defaultValue = _ref5.defaultValue,
475
+ defaultValue = _ref5$defaultValue === void 0 ? '' : _ref5$defaultValue,
471
476
  style = _ref5.style,
472
477
  item = _ref5.item,
473
478
  props = _objectWithoutProperties(_ref5, _excluded3);
@@ -601,8 +606,8 @@ export var PhoneNumber = function PhoneNumber(_ref5) {
601
606
  }, inputProps));
602
607
  };
603
608
  }
604
- if (value !== undefined) {
605
- controllerProps.defaultValue = value;
609
+ if (defaultValue !== undefined) {
610
+ controllerProps.defaultValue = defaultValue;
606
611
  }
607
612
  if ((item === null || item === void 0 ? void 0 : item.disabled) !== undefined) {
608
613
  var _item$disabled6;
@@ -658,7 +663,7 @@ export var PhoneNumber = function PhoneNumber(_ref5) {
658
663
  item: item,
659
664
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
660
665
  htmlFor: name
661
- }), /*#__PURE__*/React.createElement("div", null, value !== null && value !== void 0 ? value : '')));
666
+ }), /*#__PURE__*/React.createElement("div", null, defaultValue !== null && defaultValue !== void 0 ? defaultValue : '')));
662
667
  }
663
668
  return /*#__PURE__*/React.createElement("div", {
664
669
  style: _objectSpread({}, style),
@@ -689,7 +694,7 @@ export var DatePicker = function DatePicker(_ref8) {
689
694
  var _item$required10, _item$disabled7, _item$required11;
690
695
  var name = _ref8.name,
691
696
  onChange = _ref8.onChange,
692
- value = _ref8.value,
697
+ defaultValue = _ref8.defaultValue,
693
698
  style = _ref8.style,
694
699
  item = _ref8.item,
695
700
  props = _objectWithoutProperties(_ref8, _excluded4);
@@ -883,8 +888,8 @@ export var DatePicker = function DatePicker(_ref8) {
883
888
  }, inputProps));
884
889
  };
885
890
  }
886
- if (value !== undefined) {
887
- controllerProps.defaultValue = value;
891
+ if (defaultValue !== undefined) {
892
+ controllerProps.defaultValue = defaultValue;
888
893
  }
889
894
  if ((item === null || item === void 0 ? void 0 : item.disabled) !== undefined) {
890
895
  var _item$disabled8;
@@ -914,7 +919,7 @@ export var DatePicker = function DatePicker(_ref8) {
914
919
  }, props)), /*#__PURE__*/React.createElement(Form.Group, {
915
920
  className: "form-group mb-3"
916
921
  }, labelLocation === "FLOATING" ? /*#__PURE__*/React.createElement(Form.Floating, null, /*#__PURE__*/React.createElement(Form.Control, _extends({
917
- value: value,
922
+ value: defaultValue,
918
923
  name: name,
919
924
  id: name + '-' + ID.uuid()
920
925
  }, inputProps)), /*#__PURE__*/React.createElement(ComponentLabel, {
@@ -926,7 +931,7 @@ export var DatePicker = function DatePicker(_ref8) {
926
931
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
927
932
  htmlFor: name
928
933
  }), /*#__PURE__*/React.createElement(Form.Control, _extends({
929
- value: value,
934
+ value: defaultValue,
930
935
  name: name,
931
936
  id: name + '-' + ID.uuid()
932
937
  }, inputProps))), item !== null && item !== void 0 && item.help ? /*#__PURE__*/React.createElement(Form.Text, {
@@ -945,7 +950,7 @@ export var DatePicker = function DatePicker(_ref8) {
945
950
  item: item,
946
951
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
947
952
  htmlFor: name
948
- }), /*#__PURE__*/React.createElement("div", null, value !== null && value !== void 0 ? value : '')));
953
+ }), /*#__PURE__*/React.createElement("div", null, defaultValue !== null && defaultValue !== void 0 ? defaultValue : '')));
949
954
  }
950
955
  return /*#__PURE__*/React.createElement("div", {
951
956
  style: _objectSpread({}, style),
@@ -976,7 +981,7 @@ export var NumberInput = function NumberInput(_ref11) {
976
981
  var _item$required13, _item$disabled9, _item$required14;
977
982
  var name = _ref11.name,
978
983
  onChange = _ref11.onChange,
979
- value = _ref11.value,
984
+ defaultValue = _ref11.defaultValue,
980
985
  style = _ref11.style,
981
986
  item = _ref11.item,
982
987
  props = _objectWithoutProperties(_ref11, _excluded5);
@@ -1034,8 +1039,8 @@ export var NumberInput = function NumberInput(_ref11) {
1034
1039
  id: name + '-' + ID.uuid()
1035
1040
  }, inputProps));
1036
1041
  };
1037
- if (value !== undefined) {
1038
- controllerProps.defaultValue = value;
1042
+ if (defaultValue !== undefined) {
1043
+ controllerProps.defaultValue = defaultValue;
1039
1044
  }
1040
1045
  if ((item === null || item === void 0 ? void 0 : item.disabled) !== undefined) {
1041
1046
  var _item$disabled10;
@@ -1062,7 +1067,7 @@ export var NumberInput = function NumberInput(_ref11) {
1062
1067
  }, props)), /*#__PURE__*/React.createElement(Form.Group, {
1063
1068
  className: "form-group mb-3"
1064
1069
  }, labelLocation === "FLOATING" ? /*#__PURE__*/React.createElement(Form.Floating, null, /*#__PURE__*/React.createElement(Form.Control, _extends({
1065
- value: value,
1070
+ value: defaultValue,
1066
1071
  name: name,
1067
1072
  id: name + '-2-' + ID.uuid()
1068
1073
  }, inputProps)), /*#__PURE__*/React.createElement(ComponentLabel, {
@@ -1074,7 +1079,7 @@ export var NumberInput = function NumberInput(_ref11) {
1074
1079
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
1075
1080
  htmlFor: name
1076
1081
  }), /*#__PURE__*/React.createElement(Form.Control, _extends({
1077
- value: value,
1082
+ value: defaultValue,
1078
1083
  name: name,
1079
1084
  id: name + '-2-' + ID.uuid()
1080
1085
  }, inputProps))), item !== null && item !== void 0 && item.help ? /*#__PURE__*/React.createElement(Form.Text, {
@@ -1093,7 +1098,7 @@ export var NumberInput = function NumberInput(_ref11) {
1093
1098
  item: item,
1094
1099
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
1095
1100
  htmlFor: name
1096
- }), /*#__PURE__*/React.createElement("div", null, value !== null && value !== void 0 ? value : '')));
1101
+ }), /*#__PURE__*/React.createElement("div", null, defaultValue !== null && defaultValue !== void 0 ? defaultValue : '')));
1097
1102
  }
1098
1103
  return /*#__PURE__*/React.createElement("div", {
1099
1104
  style: _objectSpread({}, style),
@@ -1124,7 +1129,7 @@ export var TextArea = function TextArea(_ref13) {
1124
1129
  var _item$required16, _item$disabled11, _item$required17;
1125
1130
  var name = _ref13.name,
1126
1131
  onChange = _ref13.onChange,
1127
- value = _ref13.value,
1132
+ defaultValue = _ref13.defaultValue,
1128
1133
  style = _ref13.style,
1129
1134
  item = _ref13.item,
1130
1135
  props = _objectWithoutProperties(_ref13, _excluded6);
@@ -1183,8 +1188,8 @@ export var TextArea = function TextArea(_ref13) {
1183
1188
  as: "textarea"
1184
1189
  }, inputProps));
1185
1190
  };
1186
- if (value !== undefined) {
1187
- controllerProps.defaultValue = value;
1191
+ if (defaultValue !== undefined) {
1192
+ controllerProps.defaultValue = defaultValue;
1188
1193
  }
1189
1194
  if ((item === null || item === void 0 ? void 0 : item.disabled) !== undefined) {
1190
1195
  var _item$disabled12;
@@ -1211,7 +1216,7 @@ export var TextArea = function TextArea(_ref13) {
1211
1216
  }, props)), /*#__PURE__*/React.createElement(Form.Group, {
1212
1217
  className: "form-group mb-3"
1213
1218
  }, labelLocation === "FLOATING" ? /*#__PURE__*/React.createElement(Form.Floating, null, /*#__PURE__*/React.createElement(Form.Control, _extends({
1214
- value: value,
1219
+ value: defaultValue,
1215
1220
  name: name,
1216
1221
  id: name + '-2-' + ID.uuid(),
1217
1222
  as: "textarea"
@@ -1224,7 +1229,7 @@ export var TextArea = function TextArea(_ref13) {
1224
1229
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
1225
1230
  htmlFor: name
1226
1231
  }), /*#__PURE__*/React.createElement(Form.Control, _extends({
1227
- value: value,
1232
+ value: defaultValue,
1228
1233
  name: name,
1229
1234
  id: name + '-2-' + ID.uuid(),
1230
1235
  as: "textarea"
@@ -1244,7 +1249,7 @@ export var TextArea = function TextArea(_ref13) {
1244
1249
  item: item,
1245
1250
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
1246
1251
  htmlFor: name
1247
- }), /*#__PURE__*/React.createElement("div", null, value !== null && value !== void 0 ? value : '')));
1252
+ }), /*#__PURE__*/React.createElement("div", null, defaultValue !== null && defaultValue !== void 0 ? defaultValue : '')));
1248
1253
  }
1249
1254
  return /*#__PURE__*/React.createElement("div", {
1250
1255
  style: _objectSpread({}, style),
@@ -1275,7 +1280,7 @@ export var Dropdown = function Dropdown(_ref15) {
1275
1280
  var _item$required19, _item$disabled13, _item$required20;
1276
1281
  var name = _ref15.name,
1277
1282
  onChange = _ref15.onChange,
1278
- value = _ref15.value,
1283
+ defaultValue = _ref15.defaultValue,
1279
1284
  style = _ref15.style,
1280
1285
  item = _ref15.item,
1281
1286
  props = _objectWithoutProperties(_ref15, _excluded7);
@@ -1341,8 +1346,8 @@ export var Dropdown = function Dropdown(_ref15) {
1341
1346
  }, option.text);
1342
1347
  }));
1343
1348
  };
1344
- if (value !== undefined) {
1345
- controllerProps.defaultValue = value;
1349
+ if (defaultValue !== undefined) {
1350
+ controllerProps.defaultValue = defaultValue;
1346
1351
  }
1347
1352
  if ((item === null || item === void 0 ? void 0 : item.disabled) !== undefined) {
1348
1353
  var _item$disabled14;
@@ -1370,7 +1375,7 @@ export var Dropdown = function Dropdown(_ref15) {
1370
1375
  className: "form-group mb-3"
1371
1376
  }, labelLocation === "FLOATING" ? /*#__PURE__*/React.createElement(Form.Floating, null, /*#__PURE__*/React.createElement(Form.Select, _extends({
1372
1377
  id: name + '-' + ID.uuid(),
1373
- value: value,
1378
+ value: defaultValue,
1374
1379
  name: name
1375
1380
  }, inputProps), inputProps.placeholder ? /*#__PURE__*/React.createElement("option", {
1376
1381
  value: ""
@@ -1390,7 +1395,7 @@ export var Dropdown = function Dropdown(_ref15) {
1390
1395
  htmlFor: name
1391
1396
  }), /*#__PURE__*/React.createElement(Form.Select, _extends({
1392
1397
  id: name + '-' + ID.uuid(),
1393
- value: value,
1398
+ value: defaultValue,
1394
1399
  name: name
1395
1400
  }, inputProps), inputProps.placeholder ? /*#__PURE__*/React.createElement("option", {
1396
1401
  value: ""
@@ -1418,7 +1423,7 @@ export var Dropdown = function Dropdown(_ref15) {
1418
1423
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
1419
1424
  htmlFor: name
1420
1425
  }), /*#__PURE__*/React.createElement("div", null, item === null || item === void 0 || (_item$options$find = item.options.find(function (option) {
1421
- return option.value === value;
1426
+ return option.value === defaultValue;
1422
1427
  })) === null || _item$options$find === void 0 ? void 0 : _item$options$find.text)));
1423
1428
  }
1424
1429
  return /*#__PURE__*/React.createElement("div", {
@@ -1637,7 +1642,7 @@ export var Tags = function Tags(_ref18) {
1637
1642
  var _item$required22, _item$disabled15, _item$required23;
1638
1643
  var name = _ref18.name,
1639
1644
  onChange = _ref18.onChange,
1640
- value = _ref18.value,
1645
+ defaultValue = _ref18.defaultValue,
1641
1646
  style = _ref18.style,
1642
1647
  item = _ref18.item,
1643
1648
  props = _objectWithoutProperties(_ref18, _excluded8);
@@ -1727,8 +1732,8 @@ export var Tags = function Tags(_ref18) {
1727
1732
  id: name + '-' + ID.uuid()
1728
1733
  }, inputProps));
1729
1734
  };
1730
- if (value !== undefined) {
1731
- controllerProps.defaultValue = value;
1735
+ if (defaultValue !== undefined) {
1736
+ controllerProps.defaultValue = defaultValue;
1732
1737
  }
1733
1738
  if ((item === null || item === void 0 ? void 0 : item.disabled) !== undefined) {
1734
1739
  var _item$disabled16;
@@ -1793,7 +1798,7 @@ export var Tags = function Tags(_ref18) {
1793
1798
  className: item === null || item === void 0 ? void 0 : item.labelClassName,
1794
1799
  htmlFor: name
1795
1800
  }), /*#__PURE__*/React.createElement("div", null, item === null || item === void 0 ? void 0 : item.options.filter(function (option) {
1796
- return value === null || value === void 0 ? void 0 : value.includes(option.value);
1801
+ return defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.includes(option.value);
1797
1802
  }).map(function (option) {
1798
1803
  return option.text;
1799
1804
  }).join(', '))));
@@ -1880,9 +1885,9 @@ export var Checkboxes = /*#__PURE__*/function (_React$Component2) {
1880
1885
  className: "form-group mb-3"
1881
1886
  }, /*#__PURE__*/React.createElement(ComponentLabel, _extends({}, this.props, {
1882
1887
  htmlFor: name
1883
- })), this.props.item.help ? /*#__PURE__*/React.createElement(Form.Text, {
1888
+ })), this.props.item.help ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Form.Text, {
1884
1889
  muted: true
1885
- }, this.props.item.help) : null, this.props.item.options.map(function (option) {
1890
+ }, this.props.item.help)) : null, this.props.item.options.map(function (option) {
1886
1891
  var _this4$props$checkbox;
1887
1892
  var props = {};
1888
1893
  props.name = "option_".concat(option.key);
@@ -2062,7 +2067,9 @@ export var RadioButtons = /*#__PURE__*/function (_React$Component4) {
2062
2067
  className: baseClasses
2063
2068
  }, /*#__PURE__*/React.createElement(ComponentHeader, self.props), /*#__PURE__*/React.createElement(Form.Group, {
2064
2069
  className: "form-group mb-3"
2065
- }, /*#__PURE__*/React.createElement(ComponentLabel, self.props), self.props.item.options.map(function (option) {
2070
+ }, /*#__PURE__*/React.createElement(ComponentLabel, self.props), self.props.item.help ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Form.Text, {
2071
+ muted: true
2072
+ }, self.props.item.help)) : null, self.props.item.options.map(function (option) {
2066
2073
  var _self$props$checkboxB, _self$props7, _self$props8, _self$props10, _self$props11;
2067
2074
  // console.log('option', option);
2068
2075
  return /*#__PURE__*/React.createElement(ToggleButton, {
@@ -2103,9 +2110,7 @@ export var RadioButtons = /*#__PURE__*/function (_React$Component4) {
2103
2110
  __html: option.text
2104
2111
  }
2105
2112
  }))));
2106
- }), self.props.item.help ? /*#__PURE__*/React.createElement(Form.Text, {
2107
- muted: true
2108
- }, self.props.item.help) : null, /*#__PURE__*/React.createElement(ComponentErrorMessage, {
2113
+ }), /*#__PURE__*/React.createElement(ComponentErrorMessage, {
2109
2114
  name: name
2110
2115
  })));
2111
2116
  }
package/lib/toolbar.js CHANGED
@@ -226,7 +226,7 @@ var _defaultItems = [{
226
226
  answerType: 'FILE',
227
227
  hideLabel: false
228
228
  }, {
229
- key: 'FieldSet',
229
+ key: 'Fieldset',
230
230
  name: "Fieldset",
231
231
  label: "Fieldset",
232
232
  icon: FaBars,
@@ -11,6 +11,12 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
12
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
13
  import { isArrayLikeObject, isEmpty } from 'lodash';
14
+ export var replaceInText = function replaceInText(content) {
15
+ var staticVariables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
16
+ return content.replace(/{{(\w*)}}/g, function (m, key) {
17
+ return isObjectNotEmpty(staticVariables) && staticVariables !== null && staticVariables !== void 0 && staticVariables.hasOwnProperty(key) ? staticVariables[key] : "";
18
+ }).replace('\t', '').replace('\n', '').replace('\r', '');
19
+ };
14
20
  export var isListNotEmpty = function isListNotEmpty(list) {
15
21
  return isArrayLikeObject(list) && list !== undefined && list !== null && list.length > 0;
16
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-survey-builder",
3
- "version": "1.0.82",
3
+ "version": "1.0.84",
4
4
  "description": "A complete survey builder for react.",
5
5
  "main": "lib/index.js",
6
6
  "types": "types/index.d.ts",
package/types/index.d.ts CHANGED
@@ -178,6 +178,7 @@ export interface SurveyGeneratorProps {
178
178
  readOnly?: boolean;
179
179
  // eslint-disable-next-line no-undef
180
180
  variables?: Record<any, any>;
181
+ staticVariables?: Record<any, any>;
181
182
  submitButton?: JSX.Element;
182
183
  backButton?: JSX.Element;
183
184
  buttons?: JSX.Element;
@@ -185,6 +186,7 @@ export interface SurveyGeneratorProps {
185
186
  checkboxButtonClassName?: string;
186
187
  headerClassName?: string;
187
188
  labelClassName?: string;
189
+ paragraphClassName?: string;
188
190
  formId?: string;
189
191
  methods?: Record<any, any>;
190
192
  print?: boolean;