powerpagestoolkit 1.2.202 → 1.3.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.
Files changed (4) hide show
  1. package/README.md +275 -1
  2. package/dist/index.bundle.js +444 -334
  3. package/index.d.ts +272 -181
  4. package/package.json +61 -40
@@ -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___);
@@ -472,8 +477,9 @@ var __webpack_exports__ = {};
472
477
 
473
478
  // EXPORTS
474
479
  __webpack_require__.d(__webpack_exports__, {
475
- n: () => (/* reexport */ JS_API),
476
- m: () => (/* reexport */ createDOMNodeReference)
480
+ nC: () => (/* reexport */ JS_API),
481
+ mI: () => (/* reexport */ createDOMNodeReference),
482
+ xq: () => (/* reexport */ createMultipleDOMNodeReferences)
477
483
  });
478
484
 
479
485
  ;// ./src/JS/safeAjax.js
@@ -567,110 +573,40 @@ var API = {
567
573
  };
568
574
  /* harmony default export */ const JS_API = (API);
569
575
  ;// ./src/JS/waitFor.js
570
- /**
571
- * @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
572
- * @param {String} selector a query selector expression to target a specific element that you want to appear in the DOM before taking further action
573
- * @returns {Promise} the element targeted by ID *selector*
574
- */
575
-
576
- function waitFor(selector) {
577
- return new Promise(function (resolve) {
578
- if (document.querySelector(selector)) {
579
- return resolve(document.querySelector(selector));
580
- }
576
+ function waitFor(target) {
577
+ return new Promise(function (resolve, reject) {
578
+ // Create observer to watch for target in DOM
581
579
  var observer = new MutationObserver(function () {
582
- if (document.querySelector(selector)) {
580
+ var observedElement = document.querySelector(target);
581
+ if (observedElement) {
582
+ clearTimeout(timeout);
583
583
  observer.disconnect();
584
- resolve(document.querySelector(selector));
584
+ resolve(observedElement);
585
585
  }
586
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
+ }
587
602
  observer.observe(document.body, {
588
603
  subtree: true,
589
- attributes: true
604
+ attributes: true,
605
+ childList: true // Detects added/removed child elements
590
606
  });
591
607
  });
592
608
  }
593
- ;// ./src/JS/FieldValidation.class.js
594
- 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); }
595
- 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); } }
596
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
597
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
598
- 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; }
599
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
600
- 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); }
601
- var FieldValidation = /*#__PURE__*/_createClass(function FieldValidation(fieldLogicalName, fieldDisplayname, evaluationFunction) {
602
- _classCallCheck(this, FieldValidation);
603
- _defineProperty(this, "createValidator", function () {
604
- if (typeof Page_Validators == "undefined") return;
605
- // Create new validator
606
- var newValidator = document.createElement("span");
607
- newValidator.style.display = "none";
608
- newValidator.id = "".concat(this.fieldLogicalName, "Validator");
609
- newValidator.controltovalidate = "".concat(this.fieldLogicalName);
610
- newValidator.errormessage = "<a href='#".concat(this.fieldDisplayname, "_label'>").concat(this.fieldDisplayname, " is a required field</a>");
611
- newValidator.validationGroup = ""; // Set this if you have set ValidationGroup on the form
612
- newValidator.initialvalue = "";
613
- newValidator.evaluationfunction = this.evaluationFunction;
614
- // Add the new validator to the page validators array:
615
- // eslint-disable-next-line no-undef
616
- Page_Validators.push(newValidator);
617
- });
618
- this.fieldLogicalName = fieldLogicalName;
619
- this.fieldDisplayname = fieldDisplayname;
620
- this.evaluationFunction = evaluationFunction.bind(this);
621
- this.createValidator();
622
- });
623
-
624
- // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js
625
- var injectStylesIntoStyleTag = __webpack_require__(72);
626
- var injectStylesIntoStyleTag_default = /*#__PURE__*/__webpack_require__.n(injectStylesIntoStyleTag);
627
- // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleDomAPI.js
628
- var styleDomAPI = __webpack_require__(825);
629
- var styleDomAPI_default = /*#__PURE__*/__webpack_require__.n(styleDomAPI);
630
- // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertBySelector.js
631
- var insertBySelector = __webpack_require__(659);
632
- var insertBySelector_default = /*#__PURE__*/__webpack_require__.n(insertBySelector);
633
- // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js
634
- var setAttributesWithoutAttributes = __webpack_require__(56);
635
- var setAttributesWithoutAttributes_default = /*#__PURE__*/__webpack_require__.n(setAttributesWithoutAttributes);
636
- // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertStyleElement.js
637
- var insertStyleElement = __webpack_require__(540);
638
- var insertStyleElement_default = /*#__PURE__*/__webpack_require__.n(insertStyleElement);
639
- // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleTagTransform.js
640
- var styleTagTransform = __webpack_require__(113);
641
- var styleTagTransform_default = /*#__PURE__*/__webpack_require__.n(styleTagTransform);
642
- // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./src/CSS/infoEl.style.css
643
- var infoEl_style = __webpack_require__(693);
644
- ;// ./src/CSS/infoEl.style.css
645
-
646
-
647
-
648
-
649
-
650
-
651
-
652
-
653
-
654
-
655
-
656
- var options = {};
657
-
658
- options.styleTagTransform = (styleTagTransform_default());
659
- options.setAttributes = (setAttributesWithoutAttributes_default());
660
- options.insert = insertBySelector_default().bind(null, "head");
661
- options.domAPI = (styleDomAPI_default());
662
- options.insertStyleElement = (insertStyleElement_default());
663
-
664
- var update = injectStylesIntoStyleTag_default()(infoEl_style/* default */.A, options);
665
-
666
-
667
-
668
-
669
- /* harmony default export */ const CSS_infoEl_style = (infoEl_style/* default */.A && infoEl_style/* default */.A.locals ? infoEl_style/* default */.A.locals : undefined);
670
-
671
609
  ;// ./src/JS/createInfoElement.js
672
- // Import the CSS file
673
-
674
610
  function CreateInfoEl(titleString) {
675
611
  var span = document.createElement("span");
676
612
  span.classList.add("info-icon");
@@ -724,6 +660,97 @@ function CreateInfoEl(titleString) {
724
660
  });
725
661
  return span;
726
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
+
727
754
  ;// ./src/JS/DOMNodeReferences.js
728
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); }
729
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; }
@@ -738,258 +765,252 @@ function DOMNodeReferences_toPrimitive(t, r) { if ("object" != DOMNodeReferences
738
765
 
739
766
 
740
767
 
768
+
741
769
  /**
742
770
  * Class representing a reference to a DOM node.
743
771
  */
772
+ /******/ /******/ /******/
744
773
  var DOMNodeReference = /*#__PURE__*/function () {
745
774
  /**
746
775
  * Creates an instance of DOMNodeReference.
747
- * @param {string} querySelector - The CSS selector to find the desired DOM element.
776
+ * @param {string} target - The CSS selector to find the desired DOM element.
748
777
  */
749
- function DOMNodeReference(querySelector) {
778
+ /******/ /******/
779
+ function DOMNodeReference(target) {
750
780
  DOMNodeReferences_classCallCheck(this, DOMNodeReference);
751
- this.querySelector = querySelector;
781
+ this.target = target;
752
782
  this.element = null;
753
783
  this.isLoaded = false;
754
- // Deferred initialization
784
+ this.visibilityController = null;
785
+ this.defaultDisplay = "";
786
+ this.value = null;
787
+ // we defer the rest of initialization
755
788
  }
756
-
757
- /**
758
- * Initializes the DOMNodeReference instance by waiting for the element to be available in the DOM.
759
- */
760
789
  return DOMNodeReferences_createClass(DOMNodeReference, [{
761
- key: "init",
762
- value: (function () {
763
- var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
790
+ key: "_init",
791
+ value: function () {
792
+ var _init2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
764
793
  var element;
765
794
  return _regeneratorRuntime().wrap(function _callee$(_context) {
766
795
  while (1) switch (_context.prev = _context.next) {
767
796
  case 0:
768
- _context.next = 2;
769
- return waitFor(this.querySelector);
770
- case 2:
797
+ _context.prev = 0;
798
+ _context.next = 3;
799
+ return waitFor(this.target);
800
+ case 3:
771
801
  element = _context.sent;
772
- if (element) {
773
- _context.next = 5;
802
+ this.element = element;
803
+ if (this.element) {
804
+ _context.next = 7;
774
805
  break;
775
806
  }
776
- throw new Error("[SYNACT] No Element could be found with the provided query selector: ".concat(this.querySelector));
777
- case 5:
778
- this.element = element;
779
- this.value = element.value;
780
- this.parentElement = element.parentElement;
781
- this.container = element.parentElement.parentElement.parentElement;
782
- this.isLoaded = true;
807
+ throw new DOMNodeNotFoundError(this);
808
+ case 7:
783
809
  if (!this.element.classList.contains("boolean-radio")) {
784
- _context.next = 17;
810
+ _context.next = 10;
785
811
  break;
786
812
  }
787
- _context.next = 13;
788
- return createDOMNodeReference("#".concat(this.element.id, "_1"));
789
- case 13:
790
- this.yesRadio = _context.sent;
791
- _context.next = 16;
792
- return createDOMNodeReference("#".concat(this.element.id, "_0"));
813
+ _context.next = 10;
814
+ return this._attachRadioButtons();
815
+ case 10:
816
+ this._initValueSync();
817
+ this._attachVisibilityController();
818
+ this.defaultDisplay = this.visibilityController.style.display;
819
+ this.isLoaded = true;
820
+ _context.next = 19;
821
+ break;
793
822
  case 16:
794
- this.noRadio = _context.sent;
795
- case 17:
796
- this.defaultDisplay = this.element.style.display || "block";
797
- this.defaultParentDisplay = this.parentElement.style.display || "block";
798
- this.defaultContainerDisplay = this.container.style.display || "block";
799
- case 20:
823
+ _context.prev = 16;
824
+ _context.t0 = _context["catch"](0);
825
+ throw new DOMNodeInitializationError(this, _context.t0);
826
+ case 19:
800
827
  case "end":
801
828
  return _context.stop();
802
829
  }
803
- }, _callee, this);
830
+ }, _callee, this, [[0, 16]]);
804
831
  }));
805
- function init() {
806
- return _init.apply(this, arguments);
832
+ function _init() {
833
+ return _init2.apply(this, arguments);
807
834
  }
808
- return init;
835
+ return _init;
809
836
  }()
810
- /**
811
- * Hides the element by setting its display style to "none".
812
- * @method hide
813
- */
814
- )
815
837
  }, {
816
- key: "hide",
817
- value: function hide() {
818
- this.element.style.display = "none";
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
+ }
819
854
  }
820
-
821
- /**
822
- * Shows the element by restoring its default display style.
823
- * @method show
824
- */
825
855
  }, {
826
- key: "show",
827
- value: function show() {
828
- this.element.style.display = this.defaultDisplay;
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
+ }
829
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
+ }
830
898
 
831
- /**
832
- * Hides the parent element by setting its display style to "none".
833
- * @method hideParent
834
- */
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
+ }
835
908
  }, {
836
- key: "hideParent",
837
- value: function hideParent() {
838
- this.parentElement.style.display = "none";
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);
928
+ }));
929
+ function _attachRadioButtons() {
930
+ return _attachRadioButtons2.apply(this, arguments);
931
+ }
932
+ return _attachRadioButtons;
933
+ }()
934
+ }, {
935
+ key: "on",
936
+ value: function on(eventType, eventHandler) {
937
+ this.element.addEventListener(eventType, eventHandler.bind(this));
839
938
  }
840
-
841
- /**
842
- * Shows the parent element by restoring its default display style.
843
- * @method showParent
844
- */
845
939
  }, {
846
- key: "showParent",
847
- value: function showParent() {
848
- this.parentElement.style.display = this.defaultParentDisplay;
940
+ key: "hide",
941
+ value: function hide() {
942
+ this.visibilityController.style.display = "none";
849
943
  }
850
-
851
- /**
852
- * Hides the container (grandparent of the element) by setting its display style to "none".
853
- * @method hideContainer
854
- */
855
944
  }, {
856
- key: "hideContainer",
857
- value: function hideContainer() {
858
- this.element.parentElement.parentElement.parentElement.style.display = "none";
945
+ key: "show",
946
+ value: function show() {
947
+ this.visibilityController.style.display = this.defaultDisplay;
859
948
  }
860
-
861
- /**
862
- * Shows the container (grandparent of the element) by restoring its default display style.
863
- * @method showContainer
864
- */
865
949
  }, {
866
- key: "showContainer",
867
- value: function showContainer() {
868
- this.element.parentElement.parentElement.parentElement.style.display = this.defaultContainerDisplay;
950
+ key: "toggleVisibility",
951
+ value: function toggleVisibility(shouldShow) {
952
+ if (shouldShow instanceof Function) {
953
+ shouldShow() ? this.show() : this.hide();
954
+ } else {
955
+ shouldShow ? this.show() : this.hide();
956
+ }
869
957
  }
870
-
871
- /**
872
- * Sets the value of the HTML element.
873
- * @method setValue
874
- * @param {string} value - The value to set for the HTML element.
875
- */
876
958
  }, {
877
959
  key: "setValue",
878
960
  value: function setValue(value) {
879
- this.element.value = value;
961
+ if (this.element.classList.contains("boolean-radio")) {
962
+ this.yesRadio.element.checked = value;
963
+ this.noRadio.element.checked = !value;
964
+ } else {
965
+ this.element.value = value;
966
+ }
967
+ }
968
+ }, {
969
+ key: "disable",
970
+ value: function disable() {
971
+ try {
972
+ this.element.disabled = true;
973
+ } catch (e) {
974
+ throw new Error("There was an error trying to disable the target: ".concat(this.target));
975
+ }
976
+ }
977
+ }, {
978
+ key: "enable",
979
+ value: function enable() {
980
+ try {
981
+ this.element.disabled = false;
982
+ } catch (e) {
983
+ throw new Error("There was an error trying to disable the target: ".concat(this.target));
984
+ }
880
985
  }
881
-
882
- /**
883
- * Appends child elements to the HTML element.
884
- * @method append
885
- * @param {...HTMLElement} elements - The elements to append to the HTML element.
886
- */
887
986
  }, {
888
987
  key: "append",
889
988
  value: function append() {
890
989
  var _this$element;
891
990
  (_this$element = this.element).append.apply(_this$element, arguments);
892
991
  }
893
-
894
- /**
895
- * Inserts elements after the HTML element.
896
- * @method after
897
- * @param {...HTMLElement} elements - The elements to insert after the HTML element.
898
- */
899
992
  }, {
900
993
  key: "after",
901
994
  value: function after() {
902
995
  var _this$element2;
903
996
  (_this$element2 = this.element).after.apply(_this$element2, arguments);
904
997
  }
905
-
906
- /**
907
- * Retrieves the label associated with the HTML element.
908
- * @method getLabel
909
- * @returns {HTMLElement} The label element associated with this element.
910
- * @throws {Error} Throws an error if the label cannot be found.
911
- */
912
998
  }, {
913
999
  key: "getLabel",
914
1000
  value: function getLabel() {
915
- return document.querySelector("#".concat(this.element.id, "_label"));
1001
+ return document.querySelector("#".concat(this.element.id, "_label")) || null;
916
1002
  }
917
-
918
- /**
919
- * Appends child elements to the label associated with the HTML element.
920
- * @method appendToLabel
921
- * @param {...HTMLElement} elements - The elements to append to the label.
922
- */
923
1003
  }, {
924
1004
  key: "appendToLabel",
925
1005
  value: function appendToLabel() {
926
1006
  var label = this.getLabel();
927
- for (var _len = arguments.length, elements = new Array(_len), _key = 0; _key < _len; _key++) {
928
- elements[_key] = arguments[_key];
929
- }
930
- label.append.apply(label, [" "].concat(elements));
931
- }
932
-
933
- /**
934
- * Adds a click event listener to the HTML element.
935
- * @method addClickListener
936
- * @param {Function} eventHandler - The function to execute when the element is clicked.
937
- */
938
- }, {
939
- key: "addClickListener",
940
- value: function addClickListener(eventHandler) {
941
- this.element.addEventListener("click", function (e) {
942
- e.preventDefault();
943
- eventHandler();
944
- });
945
- }
946
-
947
- /**
948
- * Adds a change event listener to the HTML element.
949
- * @method addChangeListener
950
- * @param {Function} eventHandler - The function to execute when the element's value changes.
951
- */
952
- }, {
953
- key: "addChangeListener",
954
- value: function addChangeListener(eventHandler) {
955
- this.element.addEventListener("change", function (e) {
956
- e.preventDefault();
957
- eventHandler();
958
- });
959
- }
960
-
961
- /**
962
- * Unchecks both the yes and no radio buttons if they exist.
963
- * @method uncheckRadios
964
- */
965
- }, {
966
- key: "uncheckRadios",
967
- value: function uncheckRadios() {
968
- if (this.yesRadio && this.noRadio) {
969
- this.yesRadio.element.checked = false;
970
- this.noRadio.element.checked = false;
971
- } else {
972
- console.error("[SYNACT] Attempted to uncheck radios for an element that has no radios");
1007
+ if (label) {
1008
+ for (var _len = arguments.length, elements = new Array(_len), _key = 0; _key < _len; _key++) {
1009
+ elements[_key] = arguments[_key];
1010
+ }
1011
+ label.append.apply(label, [" "].concat(elements));
973
1012
  }
974
1013
  }
975
-
976
- /**
977
- * Creates a validation instance for the field.
978
- * @method createValidation
979
- * @param {Function} evaluationFunction - The function used to evaluate the field.
980
- * @param {string} fieldDisplayName - The field name to display in error if validation fails.
981
- */
982
- }, {
983
- key: "createValidation",
984
- value: function createValidation(evaluationFunction, fieldDisplayName) {
985
- new FieldValidation(this.id, "'".concat(fieldDisplayName, "'"), evaluationFunction);
986
- }
987
-
988
- /**
989
- * Adds a tooltip with specified text to the label associated with the HTML element.
990
- * @method addLabelTooltip
991
- * @param {string} text - The text to display in the tooltip.
992
- */
993
1014
  }, {
994
1015
  key: "addLabelTooltip",
995
1016
  value: function addLabelTooltip(text) {
@@ -1000,61 +1021,94 @@ var DOMNodeReference = /*#__PURE__*/function () {
1000
1021
  value: function addToolTip(text) {
1001
1022
  this.append(CreateInfoEl(text));
1002
1023
  }
1003
-
1004
- /**
1005
- * Sets the inner HTML content of the HTML element.
1006
- * @method setTextContent
1007
- * @param {string} text - The text to set as the inner HTML of the element.
1008
- */
1009
1024
  }, {
1010
1025
  key: "setTextContent",
1011
1026
  value: function setTextContent(text) {
1012
1027
  this.element.innerHTML = text;
1013
1028
  }
1014
-
1015
- /**
1016
- *
1017
- * @param {Array<Function>} conditions an array of functions that return a boolean value to set the visibility of the targeted element.
1018
- * if condition() returns true, element is shown. If false, element is hidden
1019
- */
1029
+ }, {
1030
+ key: "uncheckRadios",
1031
+ value: function uncheckRadios() {
1032
+ if (this.yesRadio && this.noRadio) {
1033
+ this.yesRadio.element.checked = false;
1034
+ this.noRadio.element.checked = false;
1035
+ } else {
1036
+ console.error("[SYNACT] Attempted to uncheck radios for an element that has no radios");
1037
+ }
1038
+ }
1020
1039
  }, {
1021
1040
  key: "configureConditionalRendering",
1022
- value: function configureConditionalRendering() {
1041
+ value: function configureConditionalRendering(condition, triggerNodes) {
1023
1042
  var _this = this;
1024
- for (var _len2 = arguments.length, conditions = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1025
- conditions[_key2] = arguments[_key2];
1043
+ try {
1044
+ this.toggleVisibility(condition(this));
1045
+ if (triggerNodes) {
1046
+ var nodes = Array.isArray(triggerNodes) ? triggerNodes : [triggerNodes];
1047
+ nodes.forEach(function (node) {
1048
+ node.on("change", function () {
1049
+ return _this.toggleVisibility(condition(_this));
1050
+ });
1051
+ var observer = new MutationObserver(function () {
1052
+ var display = window.getComputedStyle(node.visibilityController).display;
1053
+ _this.toggleVisibility(display !== "none" && condition(_this));
1054
+ });
1055
+ observer.observe(node.visibilityController, {
1056
+ attributes: true,
1057
+ attributeFilter: ["style"]
1058
+ });
1059
+ });
1060
+ }
1061
+ } catch (e) {
1062
+ throw new ConditionalRenderingError(this, e);
1026
1063
  }
1027
- conditions.forEach(function (condition) {
1028
- var o = new MutationObserver(function () {
1029
- if (condition()) _this.show();else _this.hide();
1030
- });
1031
- o.observe(document.body, {
1032
- subtree: true,
1033
- childList: true,
1034
- attributes: true
1064
+ }
1065
+ }, {
1066
+ key: "configureValidationAndRequirements",
1067
+ value: function configureValidationAndRequirements(isRequired, isValid, fieldDisplayName) {
1068
+ var _this2 = this;
1069
+ var dependencies = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
1070
+ if (typeof Page_Validators !== "undefined") {
1071
+ var newValidator = document.createElement("span");
1072
+ newValidator.style.display = "none";
1073
+ newValidator.id = "".concat(this.id, "Validator");
1074
+ newValidator.controltovalidate = this.id;
1075
+ newValidator.errormessage = "<a href='#".concat(this.element.id, "_label'>").concat(fieldDisplayName, " is a required field</a>");
1076
+ newValidator.evaluationfunction = isValid.bind(this);
1077
+ //eslint-disable-next-line
1078
+ Page_Validators.push(newValidator);
1079
+ } else {
1080
+ throw new Error("Attempted to add to Validator where Page_Validators do not exist");
1081
+ }
1082
+ this.setRequiredLevel(isRequired(this));
1083
+ if (!dependencies) return;
1084
+ dependencies = Array.isArray(dependencies) ? dependencies : [dependencies];
1085
+ dependencies.forEach(function (dep) {
1086
+ dep.element.addEventListener("change", function () {
1087
+ return _this2.setRequiredLevel(isRequired(_this2));
1035
1088
  });
1036
1089
  });
1037
1090
  }
1038
-
1039
- /**
1040
- * Executes a callback function once the element is fully loaded.
1041
- * If the element is already loaded, the callback is called immediately.
1042
- * Otherwise, a MutationObserver is used to detect when the element is added to the DOM.
1043
- * @method onceLoaded
1044
- * @param {Function} callback - A callback function to execute once the element is loaded.
1045
- */
1091
+ }, {
1092
+ key: "setRequiredLevel",
1093
+ value: function setRequiredLevel(isRequired) {
1094
+ if (isRequired) {
1095
+ this.getLabel().classList.add("required-field");
1096
+ } else {
1097
+ this.getLabel().classList.remove("required-field");
1098
+ }
1099
+ }
1046
1100
  }, {
1047
1101
  key: "onceLoaded",
1048
1102
  value: function onceLoaded(callback) {
1049
- var _this2 = this;
1103
+ var _this3 = this;
1050
1104
  if (this.isLoaded) {
1051
1105
  callback(this);
1052
1106
  } else {
1053
1107
  var observer = new MutationObserver(function () {
1054
- if (document.querySelector(_this2.querySelector)) {
1108
+ if (document.querySelector(_this3.target)) {
1055
1109
  observer.disconnect(); // Stop observing once loaded
1056
- _this2.isLoaded = true;
1057
- callback(_this2); // Call the provided callback
1110
+ _this3.isLoaded = true;
1111
+ callback(_this3); // Call the provided callback
1058
1112
  }
1059
1113
  });
1060
1114
  observer.observe(document.body, {
@@ -1069,35 +1123,44 @@ var DOMNodeReference = /*#__PURE__*/function () {
1069
1123
  * Creates and initializes a DOMNodeReference instance.
1070
1124
  * @async
1071
1125
  * @function createDOMNodeReference
1072
- * @param {string} querySelector - The CSS selector for the desired DOM element.
1126
+ * @param {string | HTMLElement} target - The CSS selector for the desired DOM element.
1073
1127
  * @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
1074
1128
  */
1075
1129
  function createDOMNodeReference(_x) {
1076
1130
  return _createDOMNodeReference.apply(this, arguments);
1077
1131
  }
1132
+
1133
+ /**
1134
+ * Creates and initializes multiple DOMNodeReference instances.
1135
+ * @async
1136
+ * @function createMultipleDOMNodeReferences
1137
+ * @param {string} querySelector - The CSS selector for the desired DOM elements.
1138
+ * @returns {Promise<DOMNodeReference[]>} A promise that resolves to an array of Proxies of initialized DOMNodeReference instances.
1139
+ */
1078
1140
  function _createDOMNodeReference() {
1079
- _createDOMNodeReference = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(querySelector) {
1141
+ _createDOMNodeReference = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(target) {
1080
1142
  var instance;
1081
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1082
- while (1) switch (_context2.prev = _context2.next) {
1143
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1144
+ while (1) switch (_context3.prev = _context3.next) {
1083
1145
  case 0:
1084
- instance = new DOMNodeReference(querySelector);
1085
- _context2.next = 3;
1086
- return instance.init();
1087
- case 3:
1088
- return _context2.abrupt("return", new Proxy(instance, {
1146
+ _context3.prev = 0;
1147
+ instance = new DOMNodeReference(target);
1148
+ _context3.next = 4;
1149
+ return instance._init();
1150
+ case 4:
1151
+ return _context3.abrupt("return", new Proxy(instance, {
1089
1152
  get: function get(target, prop) {
1090
1153
  // do not proxy the initialization method
1091
1154
  // init() is only needed in this factory function
1092
- if (prop == "init") return undefined;
1155
+ if (prop.toString().startsWith("_")) return undefined;
1093
1156
 
1094
1157
  // proxy the class to wrap all methods in the 'onceLoaded' method, to make sure the
1095
1158
  // element is always available before executing method
1096
1159
  var value = target[prop];
1097
1160
  if (typeof value === "function" && prop !== "onceLoaded") {
1098
1161
  return function () {
1099
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
1100
- args[_key3] = arguments[_key3];
1162
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1163
+ args[_key2] = arguments[_key2];
1101
1164
  }
1102
1165
  return target.onceLoaded(function () {
1103
1166
  return value.apply(target, args);
@@ -1107,18 +1170,65 @@ function _createDOMNodeReference() {
1107
1170
  return value;
1108
1171
  }
1109
1172
  }));
1110
- case 4:
1173
+ case 7:
1174
+ _context3.prev = 7;
1175
+ _context3.t0 = _context3["catch"](0);
1176
+ console.error("There was an error creating a DOMNodeReference: ".concat(_context3.t0));
1177
+ throw new Error(_context3.t0);
1178
+ case 11:
1111
1179
  case "end":
1112
- return _context2.stop();
1180
+ return _context3.stop();
1113
1181
  }
1114
- }, _callee2);
1182
+ }, _callee3, null, [[0, 7]]);
1115
1183
  }));
1116
1184
  return _createDOMNodeReference.apply(this, arguments);
1117
1185
  }
1186
+ function createMultipleDOMNodeReferences(_x2) {
1187
+ return _createMultipleDOMNodeReferences.apply(this, arguments);
1188
+ }
1189
+ function _createMultipleDOMNodeReferences() {
1190
+ _createMultipleDOMNodeReferences = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(querySelector) {
1191
+ var elements;
1192
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1193
+ while (1) switch (_context4.prev = _context4.next) {
1194
+ case 0:
1195
+ _context4.prev = 0;
1196
+ elements = Array.from(document.querySelectorAll(querySelector));
1197
+ _context4.next = 4;
1198
+ return Promise.all(elements.map(function (element) {
1199
+ return createDOMNodeReference(element);
1200
+ }));
1201
+ case 4:
1202
+ elements = _context4.sent;
1203
+ elements.hideAll = function () {
1204
+ return elements.forEach(function (instance) {
1205
+ return instance.hide();
1206
+ });
1207
+ };
1208
+ elements.showAll = function () {
1209
+ return elements.forEach(function (instance) {
1210
+ return instance.show();
1211
+ });
1212
+ };
1213
+ return _context4.abrupt("return", elements);
1214
+ case 10:
1215
+ _context4.prev = 10;
1216
+ _context4.t0 = _context4["catch"](0);
1217
+ console.error("There was an error creating multiple DOMNodeReferences: ".concat(_context4.t0));
1218
+ throw new Error(_context4.t0);
1219
+ case 14:
1220
+ case "end":
1221
+ return _context4.stop();
1222
+ }
1223
+ }, _callee4, null, [[0, 10]]);
1224
+ }));
1225
+ return _createMultipleDOMNodeReferences.apply(this, arguments);
1226
+ }
1118
1227
  ;// ./src/index.js
1119
1228
 
1120
1229
 
1121
1230
 
1122
- var __webpack_exports__API = __webpack_exports__.n;
1123
- var __webpack_exports__createDOMNodeReference = __webpack_exports__.m;
1124
- export { __webpack_exports__API as API, __webpack_exports__createDOMNodeReference as createDOMNodeReference };
1231
+ var __webpack_exports__API = __webpack_exports__.nC;
1232
+ var __webpack_exports__createDOMNodeReference = __webpack_exports__.mI;
1233
+ var __webpack_exports__createMultipleDOMNodeReferences = __webpack_exports__.xq;
1234
+ export { __webpack_exports__API as API, __webpack_exports__createDOMNodeReference as createDOMNodeReference, __webpack_exports__createMultipleDOMNodeReferences as createMultipleDOMNodeReferences };