@insticc/genericform 2.0.0 → 2.0.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/build/index.js CHANGED
@@ -37,8 +37,8 @@ var _CustomToggle = _interopRequireDefault(require("./FormFields/CustomToggle"))
37
37
  var _Demo = _interopRequireDefault(require("./Demo"));
38
38
  var _Demo2 = _interopRequireDefault(require("./Demo2"));
39
39
  require("./index.css");
40
+ var _jsxRuntime = require("react/jsx-runtime");
40
41
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
41
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
42
42
  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); }
43
43
  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; }
44
44
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
@@ -231,7 +231,7 @@ var GenericForm = function GenericForm(_ref) {
231
231
 
232
232
  // #region Validation
233
233
  var validateField = (0, _react.useCallback)(function (field, value, currentFormData) {
234
- if (['hr', 'label', 'component', 'accordion'].includes(field.type)) return null;
234
+ if (['hr', 'label', 'accordion'].includes(field.type)) return null;
235
235
  var errs = [];
236
236
  if (field.required) {
237
237
  var empty = value === undefined || value === null || value === '' || Array.isArray(value) && value.length === 0;
@@ -466,76 +466,63 @@ var GenericForm = function GenericForm(_ref) {
466
466
  switch (field.type) {
467
467
  // Abstract
468
468
  case 'hr':
469
- return /*#__PURE__*/React.createElement(_CustomSeparator["default"], {
470
- key: field.name || "sep-".concat(Math.random()),
469
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomSeparator["default"], {
471
470
  mainDivStyle: field.style
472
- });
471
+ }, field.name || "sep-".concat(Math.random()));
473
472
  case 'label':
474
- return /*#__PURE__*/React.createElement(_CustomLabel["default"], _extends({
475
- key: field.name
476
- }, cp, {
473
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomLabel["default"], _objectSpread(_objectSpread({}, cp), {}, {
477
474
  mainDivStyle: field.style,
478
475
  labelStyle: field.labelStyle
479
- }));
476
+ }), field.name);
480
477
 
481
478
  // Simple
482
479
  case 'string':
483
480
  case 'text':
484
481
  case 'email':
485
482
  case 'password':
486
- return /*#__PURE__*/React.createElement(_CustomInput["default"], _extends({
487
- key: field.name
488
- }, cp, sp, fp, {
483
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomInput["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
489
484
  value: value,
490
485
  type: field.type === 'email' ? 'email' : field.type === 'password' ? 'password' : 'text',
491
486
  placeholder: field.placeholder,
492
487
  onChange: fieldHandler(field),
493
488
  inputStyle: field.inputStyle,
494
489
  className: field.className
495
- }));
490
+ }), field.name);
496
491
  case 'int':
497
492
  case 'number':
498
- return /*#__PURE__*/React.createElement(_CustomNumberInput["default"], _extends({
499
- key: field.name
500
- }, cp, sp, fp, {
493
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomNumberInput["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
501
494
  value: value,
502
495
  placeholder: field.placeholder,
503
496
  min: field.min,
504
497
  max: field.max,
505
498
  step: field.step,
506
499
  onChange: fieldHandler(field)
507
- }));
500
+ }), field.name);
508
501
  case 'textArea':
509
- return /*#__PURE__*/React.createElement(_CustomTextArea["default"], _extends({
510
- key: field.name
511
- }, cp, sp, fp, {
502
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomTextArea["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
512
503
  value: value,
513
504
  placeholder: field.placeholder,
514
505
  rows: field.rows,
515
506
  height: field.height,
516
507
  onChange: fieldHandler(field)
517
- }));
508
+ }), field.name);
518
509
 
519
510
  // Date
520
511
  case 'date':
521
512
  case 'datetime':
522
513
  case 'time':
523
514
  case 'year':
524
- return /*#__PURE__*/React.createElement(_CustomDatePicker["default"], _extends({
525
- key: field.name
526
- }, cp, sp, fp, {
515
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomDatePicker["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
527
516
  value: value,
528
517
  placeholder: field.placeholder,
529
518
  onChange: dateFieldHandler(field),
530
519
  dateFormat: field.type === 'time' ? false : field.type === 'year' ? 'YYYY' : 'DD/MM/YYYY',
531
520
  timeFormat: field.type === 'datetime' || field.type === 'time' ? 'HH:mm' : false
532
- }));
521
+ }), field.name);
533
522
 
534
523
  // Option
535
524
  case 'select':
536
- return /*#__PURE__*/React.createElement(_CustomDropdown["default"], _extends({
537
- key: field.name
538
- }, cp, sp, fp, {
525
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomDropdown["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
539
526
  value: value,
540
527
  options: field.options,
541
528
  placeholder: field.placeholder,
@@ -548,20 +535,16 @@ var GenericForm = function GenericForm(_ref) {
548
535
  option: fullOption
549
536
  });
550
537
  }
551
- }));
538
+ }), field.name);
552
539
  case 'multipleDropdown':
553
- return /*#__PURE__*/React.createElement(_CustomMultiDropdown["default"], _extends({
554
- key: field.name
555
- }, cp, sp, fp, {
540
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomMultiDropdown["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
556
541
  value: value,
557
542
  options: field.options,
558
543
  placeholder: field.placeholder,
559
544
  onChange: fieldHandler(field)
560
- }));
545
+ }), field.name);
561
546
  case 'search':
562
- return /*#__PURE__*/React.createElement(_CustomSearch["default"], _extends({
563
- key: field.name
564
- }, cp, sp, fp, {
547
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomSearch["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
565
548
  value: value,
566
549
  options: field.options,
567
550
  placeholder: field.placeholder,
@@ -569,65 +552,52 @@ var GenericForm = function GenericForm(_ref) {
569
552
  onChange: handleSearchChange,
570
553
  handleResultSelect: handleResultSelect,
571
554
  resultRenderer: resultRenderer
572
- }));
555
+ }), field.name);
573
556
  case 'accordion':
574
- return /*#__PURE__*/React.createElement(_CustomAccordion["default"], {
575
- key: field.name,
557
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomAccordion["default"], {
576
558
  name: field.name,
577
559
  sections: field.sections,
578
560
  defaultOpen: field.defaultOpen,
579
561
  activeAllIndex: field.activeAllIndex,
580
562
  mainDivStyle: field.style,
581
563
  inputStyle: field.inputStyle
582
- });
564
+ }, field.name);
583
565
  case 'toggle':
584
- return /*#__PURE__*/React.createElement(_CustomToggle["default"], _extends({
585
- key: field.name
586
- }, cp, sp, fp, {
566
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomToggle["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
587
567
  value: !!value,
588
568
  onChange: fieldHandler(field)
589
- }));
569
+ }), field.name);
590
570
  case 'checkbox':
591
- return /*#__PURE__*/React.createElement(_CustomCheckbox["default"], _extends({
592
- key: field.name
593
- }, cp, sp, fp, {
571
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomCheckbox["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
594
572
  checked: !!value,
595
573
  onChange: fieldHandler(field),
596
574
  onOptionChange: field.onOptionChange
597
- }));
575
+ }), field.name);
598
576
  case 'checkboxGroup':
599
- return /*#__PURE__*/React.createElement(_CustomCheckboxGroup["default"], _extends({
600
- key: field.name
601
- }, cp, sp, fp, {
577
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomCheckboxGroup["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
602
578
  checked: value !== null && value !== void 0 ? value : [],
603
579
  options: field.options,
604
580
  onChange: fieldHandler(field),
605
581
  onOptionChange: field.onOptionChange
606
- }));
582
+ }), field.name);
607
583
  case 'radioGroup':
608
584
  case 'radioGroupInline':
609
- return /*#__PURE__*/React.createElement(_CustomRadioGroup["default"], _extends({
610
- key: field.name
611
- }, cp, sp, fp, {
585
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomRadioGroup["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
612
586
  value: value,
613
587
  options: field.options,
614
588
  inline: field.type === 'radioGroupInline',
615
589
  onChange: fieldHandler(field),
616
590
  onOptionChange: field.onOptionChange,
617
591
  formData: internalFormData
618
- }));
592
+ }), field.name);
619
593
 
620
594
  // Other
621
595
  case 'component':
622
- return /*#__PURE__*/React.createElement(_CustomComponent["default"], _extends({
623
- key: field.name || "cmp-".concat(Math.random())
624
- }, cp, sp, {
596
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomComponent["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
625
597
  component: field.component
626
- }));
598
+ }), field.name || "cmp-".concat(Math.random()));
627
599
  case 'json':
628
- return /*#__PURE__*/React.createElement(_CustomJson["default"], _extends({
629
- key: field.name
630
- }, cp, sp, fp, {
600
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomJson["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
631
601
  value: value,
632
602
  datatype: field.datatype,
633
603
  allowModeSwitch: field.allowModeSwitch,
@@ -645,18 +615,15 @@ var GenericForm = function GenericForm(_ref) {
645
615
  onValidate: function onValidate(name, raw, isMulti) {
646
616
  return validateJsonField(name, raw, isMulti, false, field);
647
617
  }
648
- }));
618
+ }), field.name);
649
619
  default:
650
- return /*#__PURE__*/React.createElement(_CustomInput["default"], _extends({
651
- key: field.name
652
- }, cp, sp, fp, {
620
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomInput["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
653
621
  value: value,
654
622
  type: "text",
655
623
  placeholder: field.placeholder,
656
624
  onChange: fieldHandler(field),
657
- inputStyle: field.inputStyle,
658
625
  className: field.className
659
- }));
626
+ }), field.name);
660
627
  }
661
628
  }, [
662
629
  // eslint-disable-line react-hooks/exhaustive-deps
@@ -674,21 +641,23 @@ var GenericForm = function GenericForm(_ref) {
674
641
  }, [sortedFields]);
675
642
  var renderFields = function renderFields(fieldList) {
676
643
  return groupByInline(fieldList).map(function (group, idx) {
677
- return group.type === 'inline' ? /*#__PURE__*/React.createElement("div", {
678
- key: idx,
679
- className: "ufg-field-row"
680
- }, group.fields.map(function (_ref9) {
681
- var field = _ref9.field;
682
- return renderField(field);
683
- })) : renderField(group.field);
644
+ return group.type === 'inline' ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
645
+ className: "ufg-field-row",
646
+ children: group.fields.map(function (_ref9) {
647
+ var field = _ref9.field;
648
+ return renderField(field);
649
+ })
650
+ }, idx) : renderField(group.field);
684
651
  });
685
652
  };
686
653
  var renderGroupSection = function renderGroupSection(g, fieldList) {
687
- return /*#__PURE__*/React.createElement("div", {
688
- key: g,
654
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
689
655
  className: "ufg-form",
690
- style: formStyle
691
- }, g !== 'ungrouped' && /*#__PURE__*/React.createElement("h2", null, g), renderFields(fieldList));
656
+ style: formStyle,
657
+ children: [g !== 'ungrouped' && /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
658
+ children: g
659
+ }), renderFields(fieldList)]
660
+ }, g);
692
661
  };
693
662
  var splitByField = function splitByField(fieldList) {
694
663
  var idx = fieldList.findIndex(function (f) {
@@ -714,24 +683,34 @@ var GenericForm = function GenericForm(_ref) {
714
683
  if (splitIdx === -1) return groups.map(function (g) {
715
684
  return renderGroupSection(g, groupedFields[g]);
716
685
  });
717
- return /*#__PURE__*/React.createElement("div", {
718
- className: "ufg-form-columns"
719
- }, /*#__PURE__*/React.createElement("div", null, groups.slice(0, splitIdx + 1).map(function (g) {
720
- return renderGroupSection(g, groupedFields[g]);
721
- })), /*#__PURE__*/React.createElement("div", null, groups.slice(splitIdx + 1).map(function (g) {
722
- return renderGroupSection(g, groupedFields[g]);
723
- })));
686
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
687
+ className: "ufg-form-columns",
688
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
689
+ children: groups.slice(0, splitIdx + 1).map(function (g) {
690
+ return renderGroupSection(g, groupedFields[g]);
691
+ })
692
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
693
+ children: groups.slice(splitIdx + 1).map(function (g) {
694
+ return renderGroupSection(g, groupedFields[g]);
695
+ })
696
+ })]
697
+ });
724
698
  }
725
699
  if (splitForm && splitField) {
726
- return /*#__PURE__*/React.createElement("div", {
727
- className: "ufg-form-columns"
728
- }, /*#__PURE__*/React.createElement("div", null, groups.map(function (g) {
729
- return renderGroupSection(g, splitByField(groupedFields[g]).left);
730
- })), /*#__PURE__*/React.createElement("div", null, groups.map(function (g) {
731
- var _splitByField = splitByField(groupedFields[g]),
732
- right = _splitByField.right;
733
- return right.length ? renderGroupSection(g, right) : null;
734
- })));
700
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
701
+ className: "ufg-form-columns",
702
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
703
+ children: groups.map(function (g) {
704
+ return renderGroupSection(g, splitByField(groupedFields[g]).left);
705
+ })
706
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
707
+ children: groups.map(function (g) {
708
+ var _splitByField = splitByField(groupedFields[g]),
709
+ right = _splitByField.right;
710
+ return right.length ? renderGroupSection(g, right) : null;
711
+ })
712
+ })]
713
+ });
735
714
  }
736
715
  return groups.map(function (g) {
737
716
  return renderGroupSection(g, groupedFields[g]);
@@ -741,51 +720,67 @@ var GenericForm = function GenericForm(_ref) {
741
720
  // #endregion
742
721
  // #region Actions bar
743
722
  var hasErrors = Object.values(errors).some(Boolean);
744
- var actionsBar = /*#__PURE__*/React.createElement("div", {
745
- className: "ufg-actions"
746
- }, customActions.map(function (action, idx) {
747
- return /*#__PURE__*/React.createElement("button", {
748
- key: idx,
723
+ var actionsBar = /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
724
+ className: "ufg-actions",
725
+ children: [customActions.map(function (action, idx) {
726
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
727
+ type: "button",
728
+ className: "ufg-button ".concat(action.className || 'ufg-button-secondary'),
729
+ onClick: action.onClick,
730
+ disabled: !!action.disabled,
731
+ style: action.style,
732
+ children: [action.icon, action.label]
733
+ }, idx);
734
+ }), showSubmit && haveSaveButton && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
735
+ type: "submit",
736
+ className: "ufg-button ufg-button-primary",
737
+ disabled: isSubmitting || hasErrors,
738
+ children: isSubmitting ? 'Saving…' : submitText
739
+ }), onCancel && showCancel && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
749
740
  type: "button",
750
- className: "ufg-button ".concat(action.className || 'ufg-button-secondary'),
751
- onClick: action.onClick,
752
- disabled: !!action.disabled,
753
- style: action.style
754
- }, action.icon, action.label);
755
- }), showSubmit && haveSaveButton && /*#__PURE__*/React.createElement("button", {
756
- type: "submit",
757
- className: "ufg-button ufg-button-primary",
758
- disabled: isSubmitting || hasErrors
759
- }, isSubmitting ? 'Saving…' : submitText), onCancel && showCancel && /*#__PURE__*/React.createElement("button", {
760
- type: "button",
761
- className: "ufg-button ufg-button-secondary",
762
- onClick: onCancel
763
- }, cancelText));
741
+ className: "ufg-button ufg-button-secondary",
742
+ onClick: onCancel,
743
+ children: cancelText
744
+ })]
745
+ });
764
746
 
765
747
  // #endregion
766
748
  // #region Form JSX
767
- var formJSX = /*#__PURE__*/React.createElement("form", {
749
+ var formJSX = /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
768
750
  className: "ufg-form",
769
751
  style: formStyle || {
770
752
  margin: 'auto'
771
753
  },
772
- onSubmit: onFormSubmit
773
- }, buildContent(), actionsBar);
754
+ onSubmit: onFormSubmit,
755
+ children: [buildContent(), actionsBar]
756
+ });
774
757
  if (enableModal) {
775
- return /*#__PURE__*/React.createElement(_reactBootstrap.Modal, {
758
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Modal, {
776
759
  show: modalShow,
777
760
  onHide: onCancel,
778
761
  size: modalSize,
779
- style: containerStyle
780
- }, /*#__PURE__*/React.createElement(_reactBootstrap.Modal.Header, {
781
- closeButton: true
782
- }, /*#__PURE__*/React.createElement(_reactBootstrap.Modal.Title, null, titleIcon, " ", /*#__PURE__*/React.createElement("span", null, title))), /*#__PURE__*/React.createElement(_reactBootstrap.Modal.Body, null, formJSX));
762
+ style: containerStyle,
763
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Modal.Header, {
764
+ closeButton: true,
765
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Modal.Title, {
766
+ children: [titleIcon, " ", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
767
+ children: title
768
+ })]
769
+ })
770
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Modal.Body, {
771
+ children: formJSX
772
+ })]
773
+ });
783
774
  }
784
- return /*#__PURE__*/React.createElement("div", {
775
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
785
776
  className: disableDefaultContainer ? '' : 'ufg-container',
786
- style: containerStyle
787
- }, title && /*#__PURE__*/React.createElement("div", {
788
- className: "ufg-title"
789
- }, titleIcon, /*#__PURE__*/React.createElement("span", null, title)), formJSX);
777
+ style: containerStyle,
778
+ children: [title && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
779
+ className: "ufg-title",
780
+ children: [titleIcon, /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
781
+ children: title
782
+ })]
783
+ }), formJSX]
784
+ });
790
785
  };
791
786
  var _default = exports["default"] = GenericForm;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insticc/genericform",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "A generic form with a comprehensive set of field types, validation, and external state management",
5
5
  "main": "build/index.js",
6
6
  "scripts": {