powerpagestoolkit 1.3.0 → 1.3.4

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.
Files changed (4) hide show
  1. package/README.md +146 -32
  2. package/dist/index.bundle.js +467 -354
  3. package/index.d.ts +140 -42
  4. package/package.json +61 -38
@@ -1,6 +1,6 @@
1
1
  /******/ var __webpack_modules__ = ({
2
2
 
3
- /***/ 693:
3
+ /***/ 672:
4
4
  /***/ ((module, __webpack_exports__, __webpack_require__) => {
5
5
 
6
6
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
@@ -48,6 +48,11 @@ ___CSS_LOADER_EXPORT___.push([module.id, `.info-icon {
48
48
  right: auto;
49
49
  }
50
50
  }
51
+
52
+ .required-field::after {
53
+ content: " *" !important;
54
+ color: #f00 !important;
55
+ }
51
56
  `, ""]);
52
57
  // Exports
53
58
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
@@ -568,113 +573,40 @@ var API = {
568
573
  };
569
574
  /* harmony default export */ const JS_API = (API);
570
575
  ;// ./src/JS/waitFor.js
571
- /**
572
- * @description a function that will wait for a targeted element to appear in the DOM, and then resolve a promise to allow further action to be performed after the targeted elements appears
573
- * @param {String} target a query target expression to target a specific element that you want to appear in the DOM before taking further action
574
- * @returns {Promise} the element targeted by ID *target*
575
- */
576
-
577
576
  function waitFor(target) {
578
- return new Promise(function (resolve) {
579
- if (target instanceof HTMLElement) {
580
- return resolve(target);
581
- }
582
- if (document.querySelector(target)) {
583
- return resolve(document.querySelector(target));
584
- }
577
+ return new Promise(function (resolve, reject) {
578
+ // Create observer to watch for target in DOM
585
579
  var observer = new MutationObserver(function () {
586
- if (document.querySelector(target)) {
580
+ var observedElement = document.querySelector(target);
581
+ if (observedElement) {
582
+ clearTimeout(timeout);
587
583
  observer.disconnect();
588
- resolve(document.querySelector(target));
584
+ resolve(observedElement);
589
585
  }
590
586
  });
587
+ var timeout = setTimeout(function () {
588
+ observer.disconnect();
589
+ reject(new Error("Element not found: ".concat(target, " within 5 seconds")));
590
+ }, 5000);
591
+
592
+ // Check if target is already in DOM
593
+ if (target instanceof HTMLElement) {
594
+ clearTimeout(timeout);
595
+ return resolve(target);
596
+ }
597
+ var element = document.querySelector(target);
598
+ if (element) {
599
+ clearTimeout(timeout);
600
+ return resolve(element);
601
+ }
591
602
  observer.observe(document.body, {
592
603
  subtree: true,
593
- attributes: true
604
+ attributes: true,
605
+ childList: true // Detects added/removed child elements
594
606
  });
595
607
  });
596
608
  }
597
- ;// ./src/JS/FieldValidation.class.js
598
- 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); }
599
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
600
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
601
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
602
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
603
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
604
- 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); }
605
- var FieldValidation = /*#__PURE__*/_createClass(function FieldValidation(fieldLogicalName, fieldDisplayname, evaluationFunction) {
606
- _classCallCheck(this, FieldValidation);
607
- _defineProperty(this, "createValidator", function () {
608
- if (typeof Page_Validators == "undefined") return;
609
- // Create new validator
610
- var newValidator = document.createElement("span");
611
- newValidator.style.display = "none";
612
- newValidator.id = "".concat(this.fieldLogicalName, "Validator");
613
- newValidator.controltovalidate = "".concat(this.fieldLogicalName);
614
- newValidator.errormessage = "<a href='#".concat(this.fieldDisplayname, "_label'>").concat(this.fieldDisplayname, " is a required field</a>");
615
- newValidator.validationGroup = ""; // Set this if you have set ValidationGroup on the form
616
- newValidator.initialvalue = "";
617
- newValidator.evaluationfunction = this.evaluationFunction;
618
- // Add the new validator to the page validators array:
619
- // eslint-disable-next-line no-undef
620
- Page_Validators.push(newValidator);
621
- });
622
- this.fieldLogicalName = fieldLogicalName;
623
- this.fieldDisplayname = fieldDisplayname;
624
- this.evaluationFunction = evaluationFunction.bind(this);
625
- this.createValidator();
626
- });
627
-
628
- // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js
629
- var injectStylesIntoStyleTag = __webpack_require__(72);
630
- var injectStylesIntoStyleTag_default = /*#__PURE__*/__webpack_require__.n(injectStylesIntoStyleTag);
631
- // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleDomAPI.js
632
- var styleDomAPI = __webpack_require__(825);
633
- var styleDomAPI_default = /*#__PURE__*/__webpack_require__.n(styleDomAPI);
634
- // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertBySelector.js
635
- var insertBySelector = __webpack_require__(659);
636
- var insertBySelector_default = /*#__PURE__*/__webpack_require__.n(insertBySelector);
637
- // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js
638
- var setAttributesWithoutAttributes = __webpack_require__(56);
639
- var setAttributesWithoutAttributes_default = /*#__PURE__*/__webpack_require__.n(setAttributesWithoutAttributes);
640
- // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertStyleElement.js
641
- var insertStyleElement = __webpack_require__(540);
642
- var insertStyleElement_default = /*#__PURE__*/__webpack_require__.n(insertStyleElement);
643
- // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleTagTransform.js
644
- var styleTagTransform = __webpack_require__(113);
645
- var styleTagTransform_default = /*#__PURE__*/__webpack_require__.n(styleTagTransform);
646
- // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./src/CSS/infoEl.style.css
647
- var infoEl_style = __webpack_require__(693);
648
- ;// ./src/CSS/infoEl.style.css
649
-
650
-
651
-
652
-
653
-
654
-
655
-
656
-
657
-
658
-
659
-
660
- var options = {};
661
-
662
- options.styleTagTransform = (styleTagTransform_default());
663
- options.setAttributes = (setAttributesWithoutAttributes_default());
664
- options.insert = insertBySelector_default().bind(null, "head");
665
- options.domAPI = (styleDomAPI_default());
666
- options.insertStyleElement = (insertStyleElement_default());
667
-
668
- var update = injectStylesIntoStyleTag_default()(infoEl_style/* default */.A, options);
669
-
670
-
671
-
672
-
673
- /* harmony default export */ const CSS_infoEl_style = (infoEl_style/* default */.A && infoEl_style/* default */.A.locals ? infoEl_style/* default */.A.locals : undefined);
674
-
675
609
  ;// ./src/JS/createInfoElement.js
676
- // Import the CSS file
677
-
678
610
  function CreateInfoEl(titleString) {
679
611
  var span = document.createElement("span");
680
612
  span.classList.add("info-icon");
@@ -728,6 +660,97 @@ function CreateInfoEl(titleString) {
728
660
  });
729
661
  return span;
730
662
  }
663
+ ;// ./src/JS/errors.js
664
+ 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); }
665
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
666
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
667
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
668
+ 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); }
669
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
670
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
671
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
672
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
673
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
674
+ function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
675
+ function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
676
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
677
+ function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
678
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
679
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
680
+ var DOMNodeInitializationError = /*#__PURE__*/function (_Error) {
681
+ function DOMNodeInitializationError(instance, error) {
682
+ var _this;
683
+ _classCallCheck(this, DOMNodeInitializationError);
684
+ _this = _callSuper(this, DOMNodeInitializationError, ["There was an error initializing a DOMNodeReference for target: ".concat(instance.target, ", :: ").concat(error)]);
685
+ _this.name = "DOMNodeInitializationError";
686
+ return _this;
687
+ }
688
+ _inherits(DOMNodeInitializationError, _Error);
689
+ return _createClass(DOMNodeInitializationError);
690
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
691
+ var DOMNodeNotFoundError = /*#__PURE__*/function (_Error2) {
692
+ function DOMNodeNotFoundError(instance) {
693
+ _classCallCheck(this, DOMNodeNotFoundError);
694
+ return _callSuper(this, DOMNodeNotFoundError, ["The targeted DOM element was not found: ".concat(instance.target)]);
695
+ }
696
+ _inherits(DOMNodeNotFoundError, _Error2);
697
+ return _createClass(DOMNodeNotFoundError);
698
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
699
+ var ConditionalRenderingError = /*#__PURE__*/function (_Error3) {
700
+ function ConditionalRenderingError(instance, error) {
701
+ _classCallCheck(this, ConditionalRenderingError);
702
+ return _callSuper(this, ConditionalRenderingError, ["There was an error condiguring conditional rendering for target: ".concat(instance.target, " :: ").concat(error)]);
703
+ }
704
+ _inherits(ConditionalRenderingError, _Error3);
705
+ return _createClass(ConditionalRenderingError);
706
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
707
+ // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js
708
+ var injectStylesIntoStyleTag = __webpack_require__(72);
709
+ var injectStylesIntoStyleTag_default = /*#__PURE__*/__webpack_require__.n(injectStylesIntoStyleTag);
710
+ // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleDomAPI.js
711
+ var styleDomAPI = __webpack_require__(825);
712
+ var styleDomAPI_default = /*#__PURE__*/__webpack_require__.n(styleDomAPI);
713
+ // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertBySelector.js
714
+ var insertBySelector = __webpack_require__(659);
715
+ var insertBySelector_default = /*#__PURE__*/__webpack_require__.n(insertBySelector);
716
+ // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js
717
+ var setAttributesWithoutAttributes = __webpack_require__(56);
718
+ var setAttributesWithoutAttributes_default = /*#__PURE__*/__webpack_require__.n(setAttributesWithoutAttributes);
719
+ // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertStyleElement.js
720
+ var insertStyleElement = __webpack_require__(540);
721
+ var insertStyleElement_default = /*#__PURE__*/__webpack_require__.n(insertStyleElement);
722
+ // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleTagTransform.js
723
+ var styleTagTransform = __webpack_require__(113);
724
+ var styleTagTransform_default = /*#__PURE__*/__webpack_require__.n(styleTagTransform);
725
+ // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./src/CSS/style.css
726
+ var style = __webpack_require__(672);
727
+ ;// ./src/CSS/style.css
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+ var options = {};
740
+
741
+ options.styleTagTransform = (styleTagTransform_default());
742
+ options.setAttributes = (setAttributesWithoutAttributes_default());
743
+ options.insert = insertBySelector_default().bind(null, "head");
744
+ options.domAPI = (styleDomAPI_default());
745
+ options.insertStyleElement = (insertStyleElement_default());
746
+
747
+ var update = injectStylesIntoStyleTag_default()(style/* default */.A, options);
748
+
749
+
750
+
751
+
752
+ /* harmony default export */ const CSS_style = (style/* default */.A && style/* default */.A.locals ? style/* default */.A.locals : undefined);
753
+
731
754
  ;// ./src/JS/DOMNodeReferences.js
732
755
  function DOMNodeReferences_typeof(o) { "@babel/helpers - typeof"; return DOMNodeReferences_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; }, DOMNodeReferences_typeof(o); }
733
756
  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" == DOMNodeReferences_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(DOMNodeReferences_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; }
@@ -742,6 +765,7 @@ function DOMNodeReferences_toPrimitive(t, r) { if ("object" != DOMNodeReferences
742
765
 
743
766
 
744
767
 
768
+
745
769
  /**
746
770
  * Class representing a reference to a DOM node.
747
771
  */
@@ -762,16 +786,10 @@ var DOMNodeReference = /*#__PURE__*/function () {
762
786
  this.value = null;
763
787
  // we defer the rest of initialization
764
788
  }
765
-
766
- /**
767
- * Initializes the DOMNodeReference instance by waiting for the element to be available in the DOM.
768
- */
769
- /******/ /******/
770
789
  return DOMNodeReferences_createClass(DOMNodeReference, [{
771
- key: "init",
772
- value: (function () {
773
- var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
774
- var _this = this;
790
+ key: "_init",
791
+ value: function () {
792
+ var _init2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
775
793
  var element;
776
794
  return _regeneratorRuntime().wrap(function _callee$(_context) {
777
795
  while (1) switch (_context.prev = _context.next) {
@@ -786,186 +804,309 @@ var DOMNodeReference = /*#__PURE__*/function () {
786
804
  _context.next = 7;
787
805
  break;
788
806
  }
789
- throw new Error("[SYNACT] No Element could be found with the provided query selector: ".concat(this.target));
807
+ throw new DOMNodeNotFoundError(this);
790
808
  case 7:
791
- this.value = this.element.value;
792
809
  if (!this.element.classList.contains("boolean-radio")) {
793
- _context.next = 15;
810
+ _context.next = 10;
794
811
  break;
795
812
  }
796
- _context.next = 11;
797
- return createDOMNodeReference("#".concat(this.element.id, "_1"));
798
- case 11:
799
- this.yesRadio = _context.sent;
800
- _context.next = 14;
801
- return createDOMNodeReference("#".concat(this.element.id, "_0"));
802
- case 14:
803
- this.noRadio = _context.sent;
804
- case 15:
805
- this.element.addEventListener("change", function () {
806
- _this.value = _this.element.value;
807
- });
808
-
809
- // based on the type of element we have targeted in instantiation
810
- // we now grab the parent element that will be responsible for
811
- // 'showing' and 'hiding' the target element
812
- // this is needed also in order to observe changes to visibility so that
813
- // changes to target can cascade to dependent DOMNodeReferences
814
- _context.t0 = this.element.tagName;
815
- _context.next = _context.t0 === "SPAN" ? 19 : _context.t0 === "INPUT" ? 19 : _context.t0 === "TEXTAREA" ? 19 : _context.t0 === "SELECT" ? 19 : _context.t0 === "FIELDSET" ? 21 : 21;
816
- break;
817
- case 19:
818
- this.visibilityController = this.element.closest("td");
819
- return _context.abrupt("break", 22);
820
- case 21:
821
- this.visibilityController = this.element;
822
- case 22:
823
- this.defaultDisplay = this.visibilityController.style.display;
813
+ _context.next = 10;
814
+ return this._attachRadioButtons();
815
+ case 10:
816
+ this._initValueSync();
817
+ this._attachVisibilityController();
818
+ this.defaultDisplay = this.visibilityController.style.display || "inline-block";
824
819
  this.isLoaded = true;
825
- _context.next = 29;
820
+ _context.next = 19;
826
821
  break;
827
- case 26:
828
- _context.prev = 26;
829
- _context.t1 = _context["catch"](0);
830
- throw new Error("powerpagestoolkit: There was an error initializing a DOMNodeReference with the target: ".concat(this.target, " :: ").concat(_context.t1));
831
- case 29:
822
+ case 16:
823
+ _context.prev = 16;
824
+ _context.t0 = _context["catch"](0);
825
+ throw new DOMNodeInitializationError(this, _context.t0);
826
+ case 19:
832
827
  case "end":
833
828
  return _context.stop();
834
829
  }
835
- }, _callee, this, [[0, 26]]);
830
+ }, _callee, this, [[0, 16]]);
831
+ }));
832
+ function _init() {
833
+ return _init2.apply(this, arguments);
834
+ }
835
+ return _init;
836
+ }()
837
+ }, {
838
+ key: "_initValueSync",
839
+ value: function _initValueSync() {
840
+ // Function to update this.value based on element type
841
+
842
+ // Initial sync
843
+ this.updateValue();
844
+
845
+ // Event listeners for real-time changes based on element type
846
+ var elementType = this.element.type;
847
+ if (elementType === "checkbox" || elementType === "radio") {
848
+ this.element.addEventListener("click", this.updateValue.bind(this));
849
+ } else if (elementType === "select-one" || elementType === "select-multiple") {
850
+ this.element.addEventListener("change", this.updateValue.bind(this));
851
+ } else {
852
+ this.element.addEventListener("input", this.updateValue.bind(this));
853
+ }
854
+ }
855
+ }, {
856
+ key: "updateValue",
857
+ value: function updateValue() {
858
+ switch (this.element.type) {
859
+ case "checkbox":
860
+ case "radio":
861
+ this.value = this.element.checked;
862
+ this.checked = this.element.checked;
863
+ break;
864
+ case "select-multiple":
865
+ this.value = Array.from(this.element.selectedOptions).map(function (option) {
866
+ return option.value;
867
+ });
868
+ break;
869
+ case "file":
870
+ this.value = this.element.files.length > 0 ? Array.from(this.element.files) : null;
871
+ break;
872
+ case "number":
873
+ this.value = this.element.value !== "" ? Number(this.element.value) : null;
874
+ break;
875
+ default:
876
+ this.value = this.element.value || null;
877
+ break;
878
+ }
879
+ if (this.element.classList.contains("boolean-radio")) {
880
+ this.yesRadio.updateValue();
881
+ this.noRadio.updateValue();
882
+ }
883
+ }
884
+ }, {
885
+ key: "_attachVisibilityController",
886
+ value: function _attachVisibilityController() {
887
+ // Set the default visibility controller to the element itself
888
+ this.visibilityController = this.element;
889
+
890
+ // If the element is a table, use its closest fieldset as the controller
891
+ if (this.element.tagName === "TABLE") {
892
+ var fieldset = this.element.closest("fieldset");
893
+ if (fieldset) {
894
+ this.visibilityController = fieldset;
895
+ }
896
+ return;
897
+ }
898
+
899
+ // For specific tag types, use the closest 'td' if available as the controller
900
+ var tagsRequiringTdParent = ["SPAN", "INPUT", "TEXTAREA", "SELECT", "TABLE"];
901
+ if (tagsRequiringTdParent.includes(this.element.tagName)) {
902
+ var tdParent = this.element.closest("td");
903
+ if (tdParent) {
904
+ this.visibilityController = tdParent;
905
+ }
906
+ }
907
+ }
908
+ }, {
909
+ key: "_attachRadioButtons",
910
+ value: function () {
911
+ var _attachRadioButtons2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
912
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
913
+ while (1) switch (_context2.prev = _context2.next) {
914
+ case 0:
915
+ _context2.next = 2;
916
+ return createDOMNodeReference("#".concat(this.element.id, "_1"));
917
+ case 2:
918
+ this.yesRadio = _context2.sent;
919
+ _context2.next = 5;
920
+ return createDOMNodeReference("#".concat(this.element.id, "_0"));
921
+ case 5:
922
+ this.noRadio = _context2.sent;
923
+ case 6:
924
+ case "end":
925
+ return _context2.stop();
926
+ }
927
+ }, _callee2, this);
836
928
  }));
837
- function init() {
838
- return _init.apply(this, arguments);
929
+ function _attachRadioButtons() {
930
+ return _attachRadioButtons2.apply(this, arguments);
839
931
  }
840
- return init;
932
+ return _attachRadioButtons;
841
933
  }()
842
- /**
843
- * Hides the element by setting its display style to "none".
844
- * @method hide
845
- */
846
- /******/
847
- )
934
+ }, {
935
+ key: "on",
936
+ value: function on(eventType, eventHandler) {
937
+ this.element.addEventListener(eventType, eventHandler.bind(this));
938
+ return this;
939
+ }
848
940
  }, {
849
941
  key: "hide",
850
942
  value: function hide() {
851
943
  this.visibilityController.style.display = "none";
944
+ return this;
852
945
  }
853
-
854
- /**
855
- * Shows the element by restoring its default display style.
856
- * @method show
857
- */
858
- /******/
859
946
  }, {
860
947
  key: "show",
861
948
  value: function show() {
862
949
  this.visibilityController.style.display = this.defaultDisplay;
950
+ return this;
951
+ }
952
+ }, {
953
+ key: "toggleVisibility",
954
+ value: function toggleVisibility(shouldShow) {
955
+ if (shouldShow instanceof Function) {
956
+ shouldShow() ? this.show() : this.hide();
957
+ } else {
958
+ shouldShow ? this.show() : this.hide();
959
+ }
960
+ return this;
863
961
  }
864
-
865
- /**
866
- * Sets the value of the HTML element.
867
- * @method setValue
868
- * @param {string} value - The value to set for the HTML element.
869
- */
870
- /******/
871
962
  }, {
872
963
  key: "setValue",
873
964
  value: function setValue(value) {
874
- this.element.value = value;
965
+ if (this.element.classList.contains("boolean-radio")) {
966
+ this.yesRadio.element.checked = value;
967
+ this.noRadio.element.checked = !value;
968
+ } else {
969
+ this.element.value = value;
970
+ }
971
+ return this;
972
+ }
973
+ }, {
974
+ key: "disable",
975
+ value: function disable() {
976
+ try {
977
+ this.element.disabled = true;
978
+ } catch (e) {
979
+ throw new Error("There was an error trying to disable the target: ".concat(this.target));
980
+ }
981
+ return this;
982
+ }
983
+ }, {
984
+ key: "enable",
985
+ value: function enable() {
986
+ try {
987
+ this.element.disabled = false;
988
+ } catch (e) {
989
+ throw new Error("There was an error trying to disable the target: ".concat(this.target));
990
+ }
991
+ return this;
992
+ }
993
+ }, {
994
+ key: "prepend",
995
+ value: function prepend() {
996
+ var _this = this;
997
+ for (var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++) {
998
+ nodes[_key] = arguments[_key];
999
+ }
1000
+ nodes.forEach(function (node) {
1001
+ if (node instanceof DOMNodeReference) {
1002
+ _this.element.prepend(node.element);
1003
+ } else {
1004
+ _this.element.prepend(node);
1005
+ }
1006
+ });
1007
+ return this;
875
1008
  }
876
-
877
- /**
878
- * Appends child elements to the HTML element.
879
- * @method append
880
- * @param {...HTMLElement} elements - The elements to append to the HTML element.
881
- */
882
- /******/
883
1009
  }, {
884
1010
  key: "append",
885
1011
  value: function append() {
886
- var _this$element;
887
- (_this$element = this.element).append.apply(_this$element, arguments);
1012
+ var _this2 = this;
1013
+ for (var _len2 = arguments.length, nodes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1014
+ nodes[_key2] = arguments[_key2];
1015
+ }
1016
+ nodes.forEach(function (node) {
1017
+ if (node instanceof DOMNodeReference) {
1018
+ _this2.element.append(node.element);
1019
+ } else {
1020
+ _this2.element.append(node);
1021
+ }
1022
+ });
1023
+ return this;
1024
+ }
1025
+ }, {
1026
+ key: "before",
1027
+ value: function before() {
1028
+ var _this3 = this;
1029
+ for (var _len3 = arguments.length, nodes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
1030
+ nodes[_key3] = arguments[_key3];
1031
+ }
1032
+ nodes.forEach(function (node) {
1033
+ if (node instanceof DOMNodeReference) {
1034
+ _this3.element.before(node.element);
1035
+ } else {
1036
+ _this3.element.before(node);
1037
+ }
1038
+ });
1039
+ return this;
888
1040
  }
889
-
890
- /**
891
- * Inserts elements after the HTML element.
892
- * @method after
893
- * @param {...HTMLElement} elements - The elements to insert after the HTML element.
894
- */
895
- /******/
896
1041
  }, {
897
1042
  key: "after",
898
1043
  value: function after() {
899
- var _this$element2;
900
- (_this$element2 = this.element).after.apply(_this$element2, arguments);
1044
+ var _this4 = this;
1045
+ for (var _len4 = arguments.length, nodes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
1046
+ nodes[_key4] = arguments[_key4];
1047
+ }
1048
+ nodes.forEach(function (node) {
1049
+ if (node instanceof DOMNodeReference) {
1050
+ _this4.element.after(node.element);
1051
+ } else {
1052
+ _this4.element.after(node);
1053
+ }
1054
+ });
1055
+ return this;
901
1056
  }
902
-
903
- /**
904
- * Retrieves the label associated with the HTML element.
905
- * @method getLabel
906
- * @returns {HTMLElement} The label element associated with this element.
907
- * @throws {Error} Throws an error if the label cannot be found.
908
- */
909
- /******/
910
1057
  }, {
911
1058
  key: "getLabel",
912
1059
  value: function getLabel() {
913
1060
  return document.querySelector("#".concat(this.element.id, "_label")) || null;
914
1061
  }
915
-
916
- /**
917
- * Appends child elements to the label associated with the HTML element.
918
- * @method appendToLabel
919
- * @param {...HTMLElement} elements - The elements to append to the label.
920
- */
921
- /******/
922
1062
  }, {
923
1063
  key: "appendToLabel",
924
1064
  value: function appendToLabel() {
925
1065
  var label = this.getLabel();
926
1066
  if (label) {
927
- for (var _len = arguments.length, elements = new Array(_len), _key = 0; _key < _len; _key++) {
928
- elements[_key] = arguments[_key];
1067
+ for (var _len5 = arguments.length, elements = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
1068
+ elements[_key5] = arguments[_key5];
929
1069
  }
930
1070
  label.append.apply(label, [" "].concat(elements));
931
1071
  }
1072
+ return this;
932
1073
  }
933
-
934
- /**
935
- * Adds a click event listener to the HTML element.
936
- * @method addClickListener
937
- * @param {Function} eventHandler - The function to execute when the element is clicked.
938
- */
939
- /******/
940
1074
  }, {
941
- key: "addClickListener",
942
- value: function addClickListener(eventHandler) {
943
- this.element.addEventListener("click", function (e) {
944
- e.preventDefault();
945
- eventHandler();
946
- });
1075
+ key: "addLabelTooltip",
1076
+ value: function addLabelTooltip(text) {
1077
+ this.appendToLabel(CreateInfoEl(text));
1078
+ return this;
947
1079
  }
948
-
949
- /**
950
- * Adds a change event listener to the HTML element.
951
- * @method addChangeListener
952
- * @param {Function} eventHandler - The function to execute when the element's value changes.
953
- */
954
- /******/
955
1080
  }, {
956
- key: "addChangeListener",
957
- value: function addChangeListener(eventHandler) {
958
- this.element.addEventListener("change", function (e) {
959
- e.preventDefault();
960
- eventHandler();
1081
+ key: "addTooltip",
1082
+ value: function addTooltip(text) {
1083
+ this.append(CreateInfoEl(text));
1084
+ return this;
1085
+ }
1086
+ }, {
1087
+ key: "setInnerHTML",
1088
+ value: function setInnerHTML(string) {
1089
+ this.element.innerHTML = string;
1090
+ return this;
1091
+ }
1092
+ }, {
1093
+ key: "remove",
1094
+ value: function remove() {
1095
+ this.element.remove();
1096
+ return this;
1097
+ }
1098
+ }, {
1099
+ key: "setStyle",
1100
+ value: function setStyle(options) {
1101
+ var _this5 = this;
1102
+ if (Object.prototype.toString.call(options) !== "[object Object]") {
1103
+ throw new Error("powerpagestoolkit: 'DOMNodeReference.setStyle' required options to be in the form of an object. Argument passed was of type: ".concat(DOMNodeReferences_typeof(options)));
1104
+ }
1105
+ Object.keys(options).forEach(function (key) {
1106
+ _this5.element.style[key] = options[key];
961
1107
  });
1108
+ return this;
962
1109
  }
963
-
964
- /**
965
- * Unchecks both the yes and no radio buttons if they exist.
966
- * @method uncheckRadios
967
- */
968
- /******/
969
1110
  }, {
970
1111
  key: "uncheckRadios",
971
1112
  value: function uncheckRadios() {
@@ -975,113 +1116,84 @@ var DOMNodeReference = /*#__PURE__*/function () {
975
1116
  } else {
976
1117
  console.error("[SYNACT] Attempted to uncheck radios for an element that has no radios");
977
1118
  }
1119
+ return this;
978
1120
  }
979
-
980
- /**
981
- * Creates a validation instance for the field.
982
- * @method createValidation
983
- * @param {Function} evaluationFunction - The function used to evaluate the field.
984
- * @param {string} fieldDisplayName - The field name to display in error if validation fails.
985
- */
986
- /******/
987
- }, {
988
- key: "createValidation",
989
- value: function createValidation(evaluationFunction, fieldDisplayName) {
990
- new FieldValidation(this.id, "'".concat(fieldDisplayName, "'"), evaluationFunction);
991
- }
992
-
993
- /**
994
- * Adds a tooltip with specified text to the label associated with the HTML element.
995
- * @method addLabelTooltip
996
- * @param {string} text - The text to display in the tooltip.
997
- */
998
- /******/
999
1121
  }, {
1000
- key: "addLabelTooltip",
1001
- value: function addLabelTooltip(text) {
1002
- this.appendToLabel(CreateInfoEl(text));
1003
- }
1004
-
1005
- /******/
1006
- }, {
1007
- key: "addToolTip",
1008
- value: function addToolTip(text) {
1009
- this.append(CreateInfoEl(text));
1010
- }
1011
-
1012
- /**
1013
- * Sets the inner HTML content of the HTML element.
1014
- * @method setTextContent
1015
- * @param {string} text - The text to set as the inner HTML of the element.
1016
- */
1017
- /******/
1018
- }, {
1019
- key: "setTextContent",
1020
- value: function setTextContent(text) {
1021
- this.element.innerHTML = text;
1122
+ key: "configureConditionalRendering",
1123
+ value: function configureConditionalRendering(condition, triggerNodes) {
1124
+ var _this6 = this;
1125
+ try {
1126
+ this.toggleVisibility(condition(this));
1127
+ if (triggerNodes) {
1128
+ var nodes = Array.isArray(triggerNodes) ? triggerNodes : [triggerNodes];
1129
+ nodes.forEach(function (node) {
1130
+ node.on("change", function () {
1131
+ return _this6.toggleVisibility(condition(_this6));
1132
+ });
1133
+ var observer = new MutationObserver(function () {
1134
+ var display = window.getComputedStyle(node.visibilityController).display;
1135
+ _this6.toggleVisibility(display !== "none" && condition(_this6));
1136
+ });
1137
+ observer.observe(node.visibilityController, {
1138
+ attributes: true,
1139
+ attributeFilter: ["style"]
1140
+ });
1141
+ });
1142
+ }
1143
+ } catch (e) {
1144
+ throw new ConditionalRenderingError(this, e);
1145
+ }
1146
+ return this;
1022
1147
  }
1023
-
1024
- /**
1025
- *
1026
- * @param {boolean} shouldShow shows or hides the target
1027
- * if = true => show, if = false => hide
1028
- */
1029
1148
  }, {
1030
- key: "toggleVisibility",
1031
- value: function toggleVisibility(shouldShow) {
1032
- shouldShow ? this.show() : this.hide();
1149
+ key: "configureValidationAndRequirements",
1150
+ value: function configureValidationAndRequirements(isRequired, isValid, fieldDisplayName) {
1151
+ var _this7 = this;
1152
+ var dependencies = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
1153
+ if (typeof Page_Validators !== "undefined") {
1154
+ var newValidator = document.createElement("span");
1155
+ newValidator.style.display = "none";
1156
+ newValidator.id = "".concat(this.id, "Validator");
1157
+ newValidator.controltovalidate = this.id;
1158
+ newValidator.errormessage = "<a href='#".concat(this.element.id, "_label'>").concat(fieldDisplayName, " is a required field</a>");
1159
+ newValidator.evaluationfunction = isValid.bind(this);
1160
+ //eslint-disable-next-line
1161
+ Page_Validators.push(newValidator);
1162
+ } else {
1163
+ throw new Error("Attempted to add to Validator where Page_Validators do not exist");
1164
+ }
1165
+ this.setRequiredLevel(isRequired(this));
1166
+ if (!dependencies) return this;
1167
+ dependencies = Array.isArray(dependencies) ? dependencies : [dependencies];
1168
+ dependencies.forEach(function (dep) {
1169
+ dep.element.addEventListener("change", function () {
1170
+ return _this7.setRequiredLevel(isRequired(_this7));
1171
+ });
1172
+ });
1173
+ return this;
1033
1174
  }
1034
-
1035
- /**
1036
- *
1037
- * @param {Function} condition A Function that return a boolean value to set the
1038
- * visibility of the targeted element. if condition() returns true, element is shown.
1039
- * If false, element is hidden
1040
- * @param {DOMNodeReference} triggerNode The DOMNodeReference to which an
1041
- * event listener will be registered to change the visibility state of the calling
1042
- * DOMNodeReference
1043
- */
1044
- /******/
1045
1175
  }, {
1046
- key: "configureConditionalRendering",
1047
- value: function configureConditionalRendering(condition, triggerNode) {
1048
- var _this2 = this;
1049
- this.toggleVisibility(condition());
1050
- if (triggerNode) {
1051
- triggerNode.addChangeListener(function () {
1052
- _this2.toggleVisibility(condition());
1053
- });
1054
- var observer = new MutationObserver(function () {
1055
- var display = window.getComputedStyle(triggerNode.visibilityController).display;
1056
- _this2.toggleVisibility(display !== "none" && condition());
1057
- });
1058
- observer.observe(triggerNode.visibilityController, {
1059
- attributes: true,
1060
- attributeFilter: ["style"]
1061
- });
1176
+ key: "setRequiredLevel",
1177
+ value: function setRequiredLevel(isRequired) {
1178
+ if (isRequired) {
1179
+ this.getLabel().classList.add("required-field");
1180
+ } else {
1181
+ this.getLabel().classList.remove("required-field");
1062
1182
  }
1183
+ return this;
1063
1184
  }
1064
-
1065
- /**
1066
- * Executes a callback function once the element is fully loaded.
1067
- * If the element is already loaded, the callback is called immediately.
1068
- * Otherwise, a MutationObserver is used to detect when the element is added to the DOM.
1069
- * @method onceLoaded
1070
- * @param {Function} callback - A callback function to execute once the element is loaded.
1071
- */
1072
- /******/
1073
1185
  }, {
1074
1186
  key: "onceLoaded",
1075
1187
  value: function onceLoaded(callback) {
1076
- var _this3 = this;
1188
+ var _this8 = this;
1077
1189
  if (this.isLoaded) {
1078
1190
  callback(this);
1079
1191
  } else {
1080
1192
  var observer = new MutationObserver(function () {
1081
- if (document.querySelector(_this3.target)) {
1193
+ if (document.querySelector(_this8.target)) {
1082
1194
  observer.disconnect(); // Stop observing once loaded
1083
- _this3.isLoaded = true;
1084
- callback(_this3); // Call the provided callback
1195
+ _this8.isLoaded = true;
1196
+ callback(_this8); // Call the provided callback
1085
1197
  }
1086
1198
  });
1087
1199
  observer.observe(document.body, {
@@ -1111,48 +1223,49 @@ function createDOMNodeReference(_x) {
1111
1223
  * @returns {Promise<DOMNodeReference[]>} A promise that resolves to an array of Proxies of initialized DOMNodeReference instances.
1112
1224
  */
1113
1225
  function _createDOMNodeReference() {
1114
- _createDOMNodeReference = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(target) {
1226
+ _createDOMNodeReference = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(target) {
1115
1227
  var instance;
1116
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1117
- while (1) switch (_context2.prev = _context2.next) {
1228
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1229
+ while (1) switch (_context3.prev = _context3.next) {
1118
1230
  case 0:
1119
- _context2.prev = 0;
1231
+ _context3.prev = 0;
1120
1232
  instance = new DOMNodeReference(target);
1121
- _context2.next = 4;
1122
- return instance.init();
1233
+ _context3.next = 4;
1234
+ return instance._init();
1123
1235
  case 4:
1124
- return _context2.abrupt("return", new Proxy(instance, {
1236
+ return _context3.abrupt("return", new Proxy(instance, {
1125
1237
  get: function get(target, prop) {
1126
1238
  // do not proxy the initialization method
1127
1239
  // init() is only needed in this factory function
1128
- if (prop == "init") return undefined;
1240
+ if (prop.toString().startsWith("_")) return undefined;
1129
1241
 
1130
1242
  // proxy the class to wrap all methods in the 'onceLoaded' method, to make sure the
1131
1243
  // element is always available before executing method
1132
1244
  var value = target[prop];
1133
1245
  if (typeof value === "function" && prop !== "onceLoaded") {
1134
1246
  return function () {
1135
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1136
- args[_key2] = arguments[_key2];
1247
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
1248
+ args[_key6] = arguments[_key6];
1137
1249
  }
1138
- return target.onceLoaded(function () {
1250
+ target.onceLoaded(function () {
1139
1251
  return value.apply(target, args);
1140
1252
  });
1253
+ return target;
1141
1254
  };
1142
1255
  }
1143
1256
  return value;
1144
1257
  }
1145
1258
  }));
1146
1259
  case 7:
1147
- _context2.prev = 7;
1148
- _context2.t0 = _context2["catch"](0);
1149
- console.error("There was an error creating a DOMNodeReference: ".concat(_context2.t0));
1150
- throw new Error(_context2.t0);
1260
+ _context3.prev = 7;
1261
+ _context3.t0 = _context3["catch"](0);
1262
+ console.error("There was an error creating a DOMNodeReference: ".concat(_context3.t0));
1263
+ throw new Error(_context3.t0);
1151
1264
  case 11:
1152
1265
  case "end":
1153
- return _context2.stop();
1266
+ return _context3.stop();
1154
1267
  }
1155
- }, _callee2, null, [[0, 7]]);
1268
+ }, _callee3, null, [[0, 7]]);
1156
1269
  }));
1157
1270
  return _createDOMNodeReference.apply(this, arguments);
1158
1271
  }
@@ -1160,19 +1273,19 @@ function createMultipleDOMNodeReferences(_x2) {
1160
1273
  return _createMultipleDOMNodeReferences.apply(this, arguments);
1161
1274
  }
1162
1275
  function _createMultipleDOMNodeReferences() {
1163
- _createMultipleDOMNodeReferences = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(querySelector) {
1276
+ _createMultipleDOMNodeReferences = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(querySelector) {
1164
1277
  var elements;
1165
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1166
- while (1) switch (_context3.prev = _context3.next) {
1278
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1279
+ while (1) switch (_context4.prev = _context4.next) {
1167
1280
  case 0:
1168
- _context3.prev = 0;
1281
+ _context4.prev = 0;
1169
1282
  elements = Array.from(document.querySelectorAll(querySelector));
1170
- _context3.next = 4;
1283
+ _context4.next = 4;
1171
1284
  return Promise.all(elements.map(function (element) {
1172
1285
  return createDOMNodeReference(element);
1173
1286
  }));
1174
1287
  case 4:
1175
- elements = _context3.sent;
1288
+ elements = _context4.sent;
1176
1289
  elements.hideAll = function () {
1177
1290
  return elements.forEach(function (instance) {
1178
1291
  return instance.hide();
@@ -1183,17 +1296,17 @@ function _createMultipleDOMNodeReferences() {
1183
1296
  return instance.show();
1184
1297
  });
1185
1298
  };
1186
- return _context3.abrupt("return", elements);
1299
+ return _context4.abrupt("return", elements);
1187
1300
  case 10:
1188
- _context3.prev = 10;
1189
- _context3.t0 = _context3["catch"](0);
1190
- console.error("There was an error creating multiple DOMNodeReferences: ".concat(_context3.t0));
1191
- throw new Error(_context3.t0);
1301
+ _context4.prev = 10;
1302
+ _context4.t0 = _context4["catch"](0);
1303
+ console.error("There was an error creating multiple DOMNodeReferences: ".concat(_context4.t0));
1304
+ throw new Error(_context4.t0);
1192
1305
  case 14:
1193
1306
  case "end":
1194
- return _context3.stop();
1307
+ return _context4.stop();
1195
1308
  }
1196
- }, _callee3, null, [[0, 10]]);
1309
+ }, _callee4, null, [[0, 10]]);
1197
1310
  }));
1198
1311
  return _createMultipleDOMNodeReferences.apply(this, arguments);
1199
1312
  }