@bigbinary/neeto-form-frontend 1.2.2 → 1.2.3

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/dist/index.cjs.js CHANGED
@@ -4,10 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React$2 = require('react');
6
6
  var formik = require('formik');
7
- var pure = require('@bigbinary/neeto-commons-frontend/pure');
7
+ var ramda = require('ramda');
8
8
  var PageLoader = require('neetomolecules/PageLoader');
9
9
  var neetoui = require('@bigbinary/neetoui');
10
- var ramda = require('ramda');
11
10
  var ReactDOM = require('react-dom');
12
11
  var i18next = require('i18next');
13
12
  var neetoIcons = require('@bigbinary/neeto-icons');
@@ -76,22 +75,22 @@ function _extends$8() {
76
75
  return _extends$8.apply(this, arguments);
77
76
  }
78
77
 
79
- function _typeof$6(obj) {
78
+ function _typeof$7(obj) {
80
79
  "@babel/helpers - typeof";
81
80
 
82
- return _typeof$6 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
81
+ return _typeof$7 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
83
82
  return typeof obj;
84
83
  } : function (obj) {
85
84
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
86
- }, _typeof$6(obj);
85
+ }, _typeof$7(obj);
87
86
  }
88
87
 
89
88
  function _toPrimitive$1(input, hint) {
90
- if (_typeof$6(input) !== "object" || input === null) return input;
89
+ if (_typeof$7(input) !== "object" || input === null) return input;
91
90
  var prim = input[Symbol.toPrimitive];
92
91
  if (prim !== undefined) {
93
92
  var res = prim.call(input, hint || "default");
94
- if (_typeof$6(res) !== "object") return res;
93
+ if (_typeof$7(res) !== "object") return res;
95
94
  throw new TypeError("@@toPrimitive must return a primitive value.");
96
95
  }
97
96
  return (hint === "string" ? String : Number)(input);
@@ -99,7 +98,7 @@ function _toPrimitive$1(input, hint) {
99
98
 
100
99
  function _toPropertyKey$1(arg) {
101
100
  var key = _toPrimitive$1(arg, "string");
102
- return _typeof$6(key) === "symbol" ? key : String(key);
101
+ return _typeof$7(key) === "symbol" ? key : String(key);
103
102
  }
104
103
 
105
104
  function _defineProperty$7(obj, key, value) {
@@ -244,6 +243,131 @@ var QUERY_KEYS = (cov_4tvsihi60().s[4]++, {
244
243
  });
245
244
  var DEFAULT_STALE_TIME = (cov_4tvsihi60().s[5]++, 3200000); // 1 hour
246
245
 
246
+ function _arrayWithHoles$5(arr) {
247
+ if (Array.isArray(arr)) return arr;
248
+ }
249
+
250
+ function _iterableToArrayLimit$5(arr, i) {
251
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
252
+ if (null != _i) {
253
+ var _s,
254
+ _e,
255
+ _x,
256
+ _r,
257
+ _arr = [],
258
+ _n = !0,
259
+ _d = !1;
260
+ try {
261
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
262
+ if (Object(_i) !== _i) return;
263
+ _n = !1;
264
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
265
+ } catch (err) {
266
+ _d = !0, _e = err;
267
+ } finally {
268
+ try {
269
+ if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
270
+ } finally {
271
+ if (_d) throw _e;
272
+ }
273
+ }
274
+ return _arr;
275
+ }
276
+ }
277
+
278
+ function _arrayLikeToArray$h(arr, len) {
279
+ if (len == null || len > arr.length) len = arr.length;
280
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
281
+ return arr2;
282
+ }
283
+
284
+ function _unsupportedIterableToArray$h(o, minLen) {
285
+ if (!o) return;
286
+ if (typeof o === "string") return _arrayLikeToArray$h(o, minLen);
287
+ var n = Object.prototype.toString.call(o).slice(8, -1);
288
+ if (n === "Object" && o.constructor) n = o.constructor.name;
289
+ if (n === "Map" || n === "Set") return Array.from(o);
290
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$h(o, minLen);
291
+ }
292
+
293
+ function _nonIterableRest$5() {
294
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
295
+ }
296
+
297
+ function _slicedToArray$5(arr, i) {
298
+ return _arrayWithHoles$5(arr) || _iterableToArrayLimit$5(arr, i) || _unsupportedIterableToArray$h(arr, i) || _nonIterableRest$5();
299
+ }
300
+
301
+ function _typeof$6(obj) {
302
+ "@babel/helpers - typeof";
303
+
304
+ return _typeof$6 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
305
+ return typeof obj;
306
+ } : function (obj) {
307
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
308
+ }, _typeof$6(obj);
309
+ }
310
+
311
+ /**
312
+ * @template {Function} T
313
+ * @param {T} func
314
+ * @returns {T}
315
+ */
316
+ var nullSafe = function nullSafe(func) {
317
+ return (
318
+ // @ts-ignore
319
+ ramda.curryN(func.length, function () {
320
+ var _ref;
321
+ var dataArg = (_ref = func.length - 1, _ref < 0 || arguments.length <= _ref ? undefined : arguments[_ref]);
322
+ return ramda.isNil(dataArg) ? dataArg : func.apply(void 0, arguments);
323
+ })
324
+ );
325
+ };
326
+ var noop$4 = function noop() {};
327
+ var isNotPresent = /*#__PURE__*/ramda.either(ramda.isNil, ramda.isEmpty);
328
+ var isPresent = /*#__PURE__*/ramda.complement(isNotPresent);
329
+
330
+ var matchesImpl = function matchesImpl(pattern, object) {
331
+ var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
332
+ if (object === pattern) return true;
333
+ if (typeof pattern === "function" && pattern(object, __parent)) return true;
334
+ if (ramda.isNil(pattern) || ramda.isNil(object)) return false;
335
+ if (_typeof$6(pattern) !== "object") return false;
336
+ return Object.entries(pattern).every(function (_ref) {
337
+ var _ref2 = _slicedToArray$5(_ref, 2),
338
+ key = _ref2[0],
339
+ value = _ref2[1];
340
+ return matchesImpl(value, object[key], __parent);
341
+ });
342
+ };
343
+ var matches = /*#__PURE__*/ramda.curry(function (pattern, object) {
344
+ return matchesImpl(pattern, object);
345
+ });
346
+ var filterNonNull = function filterNonNull(object) {
347
+ return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
348
+ var _ref6 = _slicedToArray$5(_ref5, 2),
349
+ v = _ref6[1];
350
+ return !ramda.isNil(v);
351
+ }).map(function (_ref7) {
352
+ var _ref8 = _slicedToArray$5(_ref7, 2),
353
+ k = _ref8[0],
354
+ v = _ref8[1];
355
+ return [k, _typeof$6(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
356
+ }));
357
+ };
358
+ nullSafe(filterNonNull);
359
+ var findById = /*#__PURE__*/ramda.curry(function (id, array) {
360
+ return array.find(function (item) {
361
+ return item.id === id;
362
+ });
363
+ });
364
+ var findBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
365
+ return array.find(matches(pattern));
366
+ });
367
+ var removeBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
368
+ return array.filter(ramda.complement(matches(pattern)));
369
+ });
370
+
247
371
  function _setPrototypeOf$2(o, p) {
248
372
  _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
249
373
  o.__proto__ = p;
@@ -19180,8 +19304,8 @@ var useBuildFormStore = (cov_2rhjwge57i().s[0]++, zustand.create(reactUtils.with
19180
19304
  isSubmitting: false,
19181
19305
  isValid: true,
19182
19306
  errors: [],
19183
- submitForm: pure.noop,
19184
- resetForm: pure.noop
19307
+ submitForm: noop$4,
19308
+ resetForm: noop$4
19185
19309
  },
19186
19310
  setFormData: function setFormData(payload) {
19187
19311
  cov_2rhjwge57i().f[1]++;
@@ -30121,7 +30245,7 @@ var getActiveQuestionKindDetails = function getActiveQuestionKindDetails(_ref) {
30121
30245
  var _ref2 = (cov_18silvsqg9().s[1]++, item),
30122
30246
  kind = _ref2.kind,
30123
30247
  label = _ref2.label;
30124
- var _ref3 = (cov_18silvsqg9().s[2]++, pure.findBy({
30248
+ var _ref3 = (cov_18silvsqg9().s[2]++, findBy({
30125
30249
  type: kind
30126
30250
  }, allQuestionKinds)),
30127
30251
  FieldComponent = _ref3.component,
@@ -31710,7 +31834,7 @@ var BuildForm = function BuildForm(_ref) {
31710
31834
  cov_2nbnnlcv5p().s[20]++;
31711
31835
  return false;
31712
31836
  }));
31713
- var defaultQuestionKinds = (cov_2nbnnlcv5p().s[21]++, allowAdditionalGuests ? (cov_2nbnnlcv5p().b[17][0]++, QUESTION_KINDS) : (cov_2nbnnlcv5p().b[17][1]++, pure.removeBy({
31837
+ var defaultQuestionKinds = (cov_2nbnnlcv5p().s[21]++, allowAdditionalGuests ? (cov_2nbnnlcv5p().b[17][0]++, QUESTION_KINDS) : (cov_2nbnnlcv5p().b[17][1]++, removeBy({
31714
31838
  type: QUESTION_KIND.ADDITIONAL_GUESTS.value
31715
31839
  }, QUESTION_KINDS)));
31716
31840
  cov_2nbnnlcv5p().s[22]++;
@@ -31741,7 +31865,7 @@ var BuildForm = function BuildForm(_ref) {
31741
31865
  showActionBlock: showActionBlock,
31742
31866
  showAddQuestionDivider: showAddQuestionDivider,
31743
31867
  submitButtonProps: submitButtonProps,
31744
- questionKinds: pure.isPresent(questionKinds) ? (cov_2nbnnlcv5p().b[18][0]++, questionKinds) : (cov_2nbnnlcv5p().b[18][1]++, defaultQuestionKinds),
31868
+ questionKinds: isPresent(questionKinds) ? (cov_2nbnnlcv5p().b[18][0]++, questionKinds) : (cov_2nbnnlcv5p().b[18][1]++, defaultQuestionKinds),
31745
31869
  onValueChange: onValueChange,
31746
31870
  onChange: function onChange(event) {
31747
31871
  cov_2nbnnlcv5p().f[10]++;
@@ -33834,7 +33958,7 @@ var Callout = function Callout(_ref) {
33834
33958
  "neeto-form-engine-callout--static": position === CALLOUT_POSITIONS.STATIC,
33835
33959
  "neeto-form-engine-callout--absolute": position === CALLOUT_POSITIONS.ABSOLUTE
33836
33960
  }, className, className))
33837
- }, (cov_5g983l5mw().b[4][0]++, pure.isPresent(onClose)) && (cov_5g983l5mw().b[4][1]++, /*#__PURE__*/React__default["default"].createElement("button", {
33961
+ }, (cov_5g983l5mw().b[4][0]++, isPresent(onClose)) && (cov_5g983l5mw().b[4][1]++, /*#__PURE__*/React__default["default"].createElement("button", {
33838
33962
  className: "neeto-form-engine-callout__close",
33839
33963
  onClick: onClose
33840
33964
  }, /*#__PURE__*/React__default["default"].createElement(neetoIcons.Close, {
@@ -38136,7 +38260,7 @@ var MultipleEmailInput = function MultipleEmailInput(_ref) {
38136
38260
  _ref4$ = _ref4[2],
38137
38261
  setValue = _ref4$.setValue,
38138
38262
  setTouched = _ref4$.setTouched;
38139
- var _ref5 = (cov_2bcewcub9k().s[3]++, React$2.useState(pure.isPresent(field.value))),
38263
+ var _ref5 = (cov_2bcewcub9k().s[3]++, React$2.useState(isPresent(field.value))),
38140
38264
  _ref6 = _slicedToArray$4(_ref5, 2),
38141
38265
  isInputVisible = _ref6[0],
38142
38266
  setIsInputVisible = _ref6[1];
@@ -47109,7 +47233,7 @@ var generateFormResponse = function generateFormResponse(response, questions) {
47109
47233
  cov_1l3yhm377b().s[35]++;
47110
47234
  if ((cov_1l3yhm377b().b[14][0]++, kind === QUESTION_KIND.RADIO.value) || (cov_1l3yhm377b().b[14][1]++, kind === QUESTION_KIND.DROPDOWN.value)) {
47111
47235
  cov_1l3yhm377b().b[13][0]++;
47112
- var option = (cov_1l3yhm377b().s[36]++, pure.findById(responseValue, optionsAttributes));
47236
+ var option = (cov_1l3yhm377b().s[36]++, findById(responseValue, optionsAttributes));
47113
47237
  cov_1l3yhm377b().s[37]++;
47114
47238
  if (option) {
47115
47239
  cov_1l3yhm377b().b[15][0]++;
@@ -49084,7 +49208,7 @@ var OptionsField = function OptionsField(_ref) {
49084
49208
  name: name,
49085
49209
  options: transformedOptions,
49086
49210
  type: kind,
49087
- value: kind === QUESTION_KIND.DROPDOWN.value ? (cov_1i8uylwhkg().b[3][0]++, pure.findBy({
49211
+ value: kind === QUESTION_KIND.DROPDOWN.value ? (cov_1i8uylwhkg().b[3][0]++, findBy({
49088
49212
  value: value
49089
49213
  }, transformedOptions)) : (cov_1i8uylwhkg().b[3][1]++, value),
49090
49214
  onChange: kind === QUESTION_KIND.DROPDOWN.value ? (cov_1i8uylwhkg().b[4][0]++, handleSelect) : (cov_1i8uylwhkg().b[4][1]++, onChange)
@@ -55450,7 +55574,7 @@ var ExternalForm = function ExternalForm(_ref) {
55450
55574
  questions: []
55451
55575
  }) : _ref16$data,
55452
55576
  isLoading = _ref16.isLoading;
55453
- var keyPressRef = (cov_2jkcclu7mz().s[68]++, reactUtils.useHotKeys("command+enter", (cov_2jkcclu7mz().b[27][0]++, (_formikInnerRef$curre = formikInnerRef.current) === null || _formikInnerRef$curre === void 0 ? void 0 : _formikInnerRef$curre.handleSubmit) || (cov_2jkcclu7mz().b[27][1]++, pure.noop), {
55577
+ var keyPressRef = (cov_2jkcclu7mz().s[68]++, reactUtils.useHotKeys("command+enter", (cov_2jkcclu7mz().b[27][0]++, (_formikInnerRef$curre = formikInnerRef.current) === null || _formikInnerRef$curre === void 0 ? void 0 : _formikInnerRef$curre.handleSubmit) || (cov_2jkcclu7mz().b[27][1]++, noop$4), {
55454
55578
  mode: "scoped"
55455
55579
  }));
55456
55580
  cov_2jkcclu7mz().s[69]++;
@@ -55560,7 +55684,7 @@ var ExternalForm = function ExternalForm(_ref) {
55560
55684
  label: "Cancel"
55561
55685
  }, cancelButtonProps)))))), (cov_2jkcclu7mz().b[44][0]++, !customSubmitHandler) && (cov_2jkcclu7mz().b[44][1]++, /*#__PURE__*/React__default["default"].createElement(Callout, {
55562
55686
  callout: {
55563
- isVisible: pure.isPresent(error),
55687
+ isVisible: isPresent(error),
55564
55688
  title: t("neetoForm.callouts.submitError"),
55565
55689
  message: error
55566
55690
  },