powerpagestoolkit 1.1.1 → 1.1.22

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.
@@ -0,0 +1,2 @@
1
+ /*! For license information please see index.bundle.js.LICENSE.txt */
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.powerpagestoolkit=t():e.powerpagestoolkit=t()}(this,(()=>(()=>{"use strict";var e={628:(e,t,n)=>{n.d(t,{A:()=>c});var r=n(601),o=n.n(r),i=n(314),a=n.n(i)()(o());a.push([e.id,".info-icon {\n position: relative;\n display: inline-block;\n}\n\n.info-icon .fa-info-circle {\n cursor: pointer; /* Ensures the icon is recognized as interactive */\n}\n\n.info-icon .flyout-content {\n display: none; /* Initially hidden */\n position: absolute;\n top: 100%;\n left: 50%; /* Center horizontally */\n transform: translateX(-50%); /* Adjust positioning */\n background-color: #f9f9f9;\n padding: 10px;\n border: 1px solid #ddd;\n z-index: 1;\n max-width: 90vw; /* Ensure it doesn't overflow on mobile */\n min-width: 200px; /* Minimum width for better readability */\n box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);\n border-radius: 4px; /* Rounded corners */\n}\n",""]);const c=a},314:e=>{e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",r=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),r&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),r&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,r,o,i){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(r)for(var c=0;c<this.length;c++){var u=this[c][0];null!=u&&(a[u]=!0)}for(var l=0;l<e.length;l++){var s=[].concat(e[l]);r&&a[s[0]]||(void 0!==i&&(void 0===s[5]||(s[1]="@layer".concat(s[5].length>0?" ".concat(s[5]):""," {").concat(s[1],"}")),s[5]=i),n&&(s[2]?(s[1]="@media ".concat(s[2]," {").concat(s[1],"}"),s[2]=n):s[2]=n),o&&(s[4]?(s[1]="@supports (".concat(s[4],") {").concat(s[1],"}"),s[4]=o):s[4]="".concat(o)),t.push(s))}},t}},601:e=>{e.exports=function(e){return e[1]}},72:e=>{var t=[];function n(e){for(var n=-1,r=0;r<t.length;r++)if(t[r].identifier===e){n=r;break}return n}function r(e,r){for(var i={},a=[],c=0;c<e.length;c++){var u=e[c],l=r.base?u[0]+r.base:u[0],s=i[l]||0,f="".concat(l," ").concat(s);i[l]=s+1;var d=n(f),p={css:u[1],media:u[2],sourceMap:u[3],supports:u[4],layer:u[5]};if(-1!==d)t[d].references++,t[d].updater(p);else{var h=o(p,r);r.byIndex=c,t.splice(c,0,{identifier:f,updater:h,references:1})}a.push(f)}return a}function o(e,t){var n=t.domAPI(t);return n.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;n.update(e=t)}else n.remove()}}e.exports=function(e,o){var i=r(e=e||[],o=o||{});return function(e){e=e||[];for(var a=0;a<i.length;a++){var c=n(i[a]);t[c].references--}for(var u=r(e,o),l=0;l<i.length;l++){var s=n(i[l]);0===t[s].references&&(t[s].updater(),t.splice(s,1))}i=u}}},659:e=>{var t={};e.exports=function(e,n){var r=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},540:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56:(e,t,n)=>{e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},825:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,o&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nc=void 0;var r={};function o(e){var t=$.Deferred();return shell.getTokenDeferred().done((function(n){e.headers?e.headers.__RequestVerificationToken=n:$.extend(e,{headers:{__RequestVerificationToken:n}}),$.ajax(e).done((function(e,n,r){validateLoginSession(e,n,r,t.resolve)})).fail(t.reject)})).fail((function(){t.rejectWith(this,arguments)})),t.promise()}n.r(r),n.d(r,{API:()=>i,createDOMNodeReference:()=>N});const i={createRecord:function(e){return new Promise((function(t,n){o({type:"POST",url:"/_api/".concat(e.logicalName()),data:e.value(),contentType:"application/json",success:function(e,n,r){t(r.getResponseHeader("entityid"))},error:function(e){n(e)}})}))},getRecord:function(e,t,n){return new Promise((function(r,i){o({type:"GET",url:"/_api/".concat(e,"(").concat(t,")").concat(n?"?$".concat(n):""),success:r,error:i})}))},getMultiple:function(e,t){return new Promise((function(n,r){o({type:"GET",url:"/_api/".concat(e).concat(t?"?".concat(t):""),success:function(e){n(e.value)},error:r})}))}};function a(e){return new Promise((function(t){if(document.querySelector(e))return t(document.querySelector(e));var n=new MutationObserver((function(){document.querySelector(e)&&(n.disconnect(),t(document.querySelector(e)))}));n.observe(document.body,{subtree:!0})}))}function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,s(r.key),r)}}function l(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){var t=function(e){if("object"!=c(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=c(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==c(t)?t:t+""}var f=l((function e(t,n,r){var o,i,a;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o=this,a=function(){if("undefined"!=typeof Page_Validators){var e=document.createElement("span");e.style.display="none",e.id="".concat(this.fieldLogicalName,"Validator"),e.controltovalidate="".concat(this.fieldLogicalName),e.errormessage="<a href='#".concat(this.fieldDisplayname,"_label'>").concat(this.fieldDisplayname," is a required field</a>"),e.validationGroup="",e.initialvalue="",e.evaluationfunction=this.evaluationFunction,Page_Validators.push(e)}},(i=s(i="createValidator"))in o?Object.defineProperty(o,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[i]=a,this.fieldLogicalName=t,this.fieldDisplayname=n,this.evaluationFunction=r.bind(this),this.createValidator()})),d=n(72),p=n.n(d),h=n(825),y=n.n(h),v=n(659),m=n.n(v),b=n(56),g=n.n(b),w=n(540),x=n.n(w),E=n(113),L=n.n(E),k=n(628),S={};function P(e){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P(e)}function j(){j=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function s(e,t,n,r){var i=t&&t.prototype instanceof m?t:m,a=Object.create(i.prototype),c=new A(r||[]);return o(a,"_invoke",{value:T(e,n,c)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=s;var d="suspendedStart",p="suspendedYield",h="executing",y="completed",v={};function m(){}function b(){}function g(){}var w={};l(w,a,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(N([])));E&&E!==n&&r.call(E,a)&&(w=E);var L=g.prototype=m.prototype=Object.create(w);function k(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(o,i,a,c){var u=f(e[o],e,i);if("throw"!==u.type){var l=u.arg,s=l.value;return s&&"object"==P(s)&&r.call(s,"__await")?t.resolve(s.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(s).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function T(t,n,r){var o=d;return function(i,a){if(o===h)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:e,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var u=_(c,r);if(u){if(u===v)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===d)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=h;var l=f(t,n,r);if("normal"===l.type){if(o=r.done?y:p,l.arg===v)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(o=y,r.method="throw",r.arg=l.arg)}}}function _(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,_(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,v;var a=i.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function N(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(P(t)+" is not iterable")}return b.prototype=g,o(L,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:b,configurable:!0}),b.displayName=l(g,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,l(e,u,"GeneratorFunction")),e.prototype=Object.create(L),e},t.awrap=function(e){return{__await:e}},k(S.prototype),l(S.prototype,c,(function(){return this})),t.AsyncIterator=S,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new S(s(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},k(L),l(L,u,"Generator"),l(L,a,(function(){return this})),l(L,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=N,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(C),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return c.type="throw",c.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),l=r.call(a,"finallyLoc");if(u&&l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),C(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;C(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:N(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function T(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function _(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){T(i,r,o,a,c,"next",e)}function c(e){T(i,r,o,a,c,"throw",e)}a(void 0)}))}}function O(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,C(r.key),r)}}function C(e){var t=function(e){if("object"!=P(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=P(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==P(t)?t:t+""}S.styleTagTransform=L(),S.setAttributes=g(),S.insert=m().bind(null,"head"),S.domAPI=y(),S.insertStyleElement=x(),p()(k.A,S),k.A&&k.A.locals&&k.A.locals;var A=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.querySelector=t,this.element=null,this.isLoaded=!1},t=[{key:"init",value:(n=_(j().mark((function e(){var t;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a(this.querySelector);case 2:if(t=e.sent){e.next=5;break}throw new Error("[SYNACT] No Element could be found with the provided query selector: ".concat(this.querySelector));case 5:if(this.element=t,this.parentElement=t.parentElement,this.container=t.parentElement.parentElement.parentElement,this.isLoaded=!0,!this.element.classList.contains("boolean-radio")){e.next=16;break}return e.next=12,N("#".concat(this.element.id,"_1"));case 12:return this.yesRadio=e.sent,e.next=15,N("#".concat(this.element.id,"_0"));case 15:this.noRadio=e.sent;case 16:this.defaultDisplay=this.element.style.display||"block",this.defaultParentDisplay=this.parentElement.style.display||"block",this.defaultContainerDisplay=this.container.style.display||"block";case 19:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"hide",value:function(){this.element.style.display="none"}},{key:"show",value:function(){this.element.style.display=this.defaultDisplay}},{key:"hideParent",value:function(){this.parentElement.style.display="none"}},{key:"showParent",value:function(){this.parentElement.style.display=this.defaultParentDisplay}},{key:"hideContainer",value:function(){this.element.parentElement.parentElement.parentElement.style.display="none"}},{key:"showContainer",value:function(){this.element.parentElement.parentElement.parentElement.style.display=this.defaultContainerDisplay}},{key:"setValue",value:function(e){this.element.value=e}},{key:"getValue",value:function(){return this.element.value}},{key:"append",value:function(){var e;(e=this.element).append.apply(e,arguments)}},{key:"after",value:function(){var e;(e=this.element).after.apply(e,arguments)}},{key:"getLabel",value:function(){return document.querySelector("#".concat(this.element.id,"_label"))}},{key:"appendToLabel",value:function(){for(var e=this.getLabel(),t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];e.append.apply(e,[" "].concat(n))}},{key:"addClickListener",value:function(e){this.element.addEventListener("click",(function(t){t.preventDefault(),e()}))}},{key:"addChangeListener",value:function(e){this.element.addEventListener("change",(function(t){t.preventDefault(),e()}))}},{key:"uncheckRadios",value:function(){this.yesRadio&&this.noRadio?(this.yesRadio.element.checked=!1,this.noRadio.element.checked=!1):console.error("[SYNACT] Attempted to uncheck radios for an element that has no radios")}},{key:"createValidation",value:function(e,t){new f(this.id,"'".concat(t,"'"),e)}},{key:"addLabelTooltip",value:function(e){this.appendToLabel(function(e){var t=document.createElement("span");t.classList.add("info-icon");var n=document.createElement("i");n.classList.add("fa","fa-solid","fa-info-circle"),n.setAttribute("aria-label","Info"),n.style.cursor="pointer";var r=document.createElement("div");return r.innerHTML=e,r.classList.add("flyout-content"),t.appendChild(n),t.appendChild(r),n.addEventListener("mouseenter",(function(){r.style.display="block"})),n.addEventListener("mouseleave",(function(){r.style.display="none"})),n.addEventListener("touchstart",(function(e){e.preventDefault(),r.style.display="none"===r.style.display?"block":"none"})),document.body.addEventListener("click",(function(e){t.contains(e.target)||(r.style.display="none")})),t}(e))}},{key:"setTextContent",value:function(e){this.element.innerHTML=e}},{key:"onceLoaded",value:function(e){var t=this;if(console.log("loading element"),this.isLoaded)e(this);else{var n=new MutationObserver((function(){document.querySelector(t.querySelector)&&(n.disconnect(),t.isLoaded=!0,e(t))}));n.observe(document.body,{subtree:!0,childList:!0})}}}],t&&O(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n}();function N(e){return M.apply(this,arguments)}function M(){return M=_(j().mark((function e(t){var n;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new A(t),e.next=3,n.init();case 3:return e.abrupt("return",new Proxy(n,{get:function(e,t){if("init"!=t){var n=e[t];return"function"==typeof n&&"onceLoaded"!==t?function(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return e.onceLoaded((function(){return n.apply(e,r)}))}:n}}}));case 4:case"end":return e.stop()}}),e)}))),M.apply(this,arguments)}return r})()));
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "powerpagestoolkit",
3
- "version": "1.1.001",
3
+ "version": "1.1.22",
4
4
  "description": "Reference, manipulate, and engage with Power Pages sites through the nodes in the DOM; use a variety of custom methods that allow customizing your power pages site quicker and easier. ",
5
- "main": "index.js",
5
+ "main": "out/index.bundle.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1"
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "build": "webpack --config webpack.config.cjs"
9
10
  },
10
11
  "devDependencies": {
11
12
  "@babel/core": "^7.25.8",
12
13
  "@babel/preset-env": "^7.25.8",
13
14
  "@types/node": "^22.8.0",
14
15
  "babel-loader": "^9.2.1",
16
+ "css-loader": "^7.1.2",
15
17
  "eslint": "^8.57.1",
18
+ "style-loader": "^4.0.0",
16
19
  "typescript": "^5.6.3",
17
20
  "webpack": "^5.95.0",
18
21
  "webpack-cli": "^5.1.4"
@@ -25,8 +28,7 @@
25
28
  "url": "https://github.com/Keaton-Brewster/PowerPagesToolKit"
26
29
  },
27
30
  "files": [
28
- "index.js",
29
- "index.d.ts",
30
- "lib"
31
+ "out/index.bundle.js",
32
+ "index.d.ts"
31
33
  ]
32
34
  }
package/index.js DELETED
@@ -1,4 +0,0 @@
1
- import API from "./lib/API.js";
2
- import createDOMNodeReference from "./lib/DOMNodeReferences.js";
3
-
4
- export { API, createDOMNodeReference };
package/lib/API.js DELETED
@@ -1,70 +0,0 @@
1
- import safeAjax from "./safeAjax.js";
2
- const API = {
3
- /**
4
- *
5
- * @param {Class} schema an instance of a schema class, containing the desired information for the POST request
6
- * @returns a Promise resolving the successful results *[record id]* of the POST request, or rejecting the failed results *[error]* of the POST request.
7
- */
8
- createRecord(schema) {
9
- return new Promise((resolve, reject) => {
10
- safeAjax({
11
- type: "POST",
12
- url: `/_api/${schema.logicalName()}`,
13
- data: schema.value(),
14
- contentType: "application/json",
15
- success: function (response, status, xhr) {
16
- resolve(xhr.getResponseHeader("entityid"));
17
- },
18
- error: (error) => {
19
- reject(error);
20
- },
21
- });
22
- });
23
- },
24
- /**
25
- *
26
- * @param {string} tableSetName The DataVerse SET name of the table being queried
27
- * @param {string} recordID the GUID of the records to be retrieved
28
- * @param {string} selectColumns *OPTIONAL* if desired, enter your own custom OData query for advanced GET results. Format = select=column1,column2,column3...
29
- * @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
30
- */
31
- getRecord(tableSetName, recordID, selectColumns) {
32
- return new Promise((resolve, reject) => {
33
- const url = `/_api/${tableSetName}(${recordID})${
34
- selectColumns ? `?$${selectColumns}` : ""
35
- }`;
36
-
37
- safeAjax({
38
- type: "GET",
39
- url: url,
40
- success: resolve,
41
- error: reject,
42
- });
43
- });
44
- },
45
- /**
46
- *
47
- * @param {String} tableSetName The DataVerse SET name of the table being queried
48
- * @param {String} queryParameters *OPTIONAL* the OData query parameters for refining search results: *format = $filter=filters&$select=columns*
49
- * @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
50
- */
51
- getMultiple(tableSetName, queryParameters) {
52
- return new Promise((resolve, reject) => {
53
- // Construct the URL based on the presence of query parameters
54
- const url = `/_api/${tableSetName}${
55
- queryParameters ? `?${queryParameters}` : ""
56
- }`;
57
-
58
- safeAjax({
59
- type: "GET",
60
- url: url,
61
- success: function (response) {
62
- resolve(response.value);
63
- },
64
- error: reject,
65
- });
66
- });
67
- },
68
- };
69
-
70
- export default API;
@@ -1,271 +0,0 @@
1
- import { waitFor } from "./common_functions.js";
2
- import FieldValidation from "./FieldValidation.class.js";
3
- import createInfoEl from "./createInfoElement.js";
4
-
5
- /**
6
- * Class representing a reference to a DOM node.
7
- */
8
- class DOMNodeReference {
9
- /**
10
- * Creates an instance of DOMNodeReference.
11
- * @param {string} querySelector - The CSS selector to find the desired DOM element.
12
- */
13
- constructor(querySelector) {
14
- this.querySelector = querySelector;
15
- this.element = null;
16
- this.isLoaded = false;
17
- // Deferred initialization
18
- }
19
-
20
- /**
21
- * Initializes the DOMNodeReference instance by waiting for the element to be available in the DOM.
22
- * @returns {Promise<Proxy>} A promise that resolves to a Proxy of the DOMNodeReference instance.
23
- * @throws {Error} Throws an error if the element cannot be found using the provided query selector.
24
- */
25
- async init() {
26
- const element = await waitFor(this.querySelector);
27
- if (!element) {
28
- throw new Error(
29
- `[SYNACT] No Element could be found with the provided query selector: ${this.querySelector}`
30
- );
31
- }
32
-
33
- this.element = element;
34
- this.parentElement = element.parentElement;
35
- this.container = element.parentElement.parentElement.parentElement;
36
- this.isLoaded = true;
37
-
38
- if (this.element.classList.contains("boolean-radio")) {
39
- this.yesRadio = new DOMNodeReference(`#${this.element.id}_1`);
40
- this.noRadio = new DOMNodeReference(`#${this.element.id}_0`);
41
- }
42
-
43
- this.defaultDisplay = this.element.style.display || "block";
44
- this.defaultParentDisplay = this.parentElement.style.display || "block";
45
- this.defaultContainerDisplay = this.container.style.display || "block";
46
- }
47
-
48
- /**
49
- * Hides the element by setting its display style to "none".
50
- * @method hide
51
- */
52
- hide() {
53
- this.element.style.display = "none";
54
- }
55
-
56
- /**
57
- * Shows the element by restoring its default display style.
58
- * @method show
59
- */
60
- show() {
61
- this.element.style.display = this.defaultDisplay;
62
- }
63
-
64
- /**
65
- * Hides the parent element by setting its display style to "none".
66
- * @method hideParent
67
- */
68
- hideParent() {
69
- this.parentElement.style.display = "none";
70
- }
71
-
72
- /**
73
- * Shows the parent element by restoring its default display style.
74
- * @method showParent
75
- */
76
- showParent() {
77
- this.parentElement.style.display = this.defaultParentDisplay;
78
- }
79
-
80
- /**
81
- * Hides the container (grandparent of the element) by setting its display style to "none".
82
- * @method hideContainer
83
- */
84
- hideContainer() {
85
- this.element.parentElement.parentElement.parentElement.style.display =
86
- "none";
87
- }
88
-
89
- /**
90
- * Shows the container (grandparent of the element) by restoring its default display style.
91
- * @method showContainer
92
- */
93
- showContainer() {
94
- this.element.parentElement.parentElement.parentElement.style.display =
95
- this.defaultContainerDisplay;
96
- }
97
-
98
- /**
99
- * Sets the value of the HTML element.
100
- * @method setValue
101
- * @param {string} value - The value to set for the HTML element.
102
- */
103
- setValue(value) {
104
- this.element.value = value;
105
- }
106
-
107
- /**
108
- * Gets the value of the HTML element.
109
- * @method getValue
110
- * @returns {string} The current value of the HTML element.
111
- */
112
- getValue() {
113
- return this.element.value;
114
- }
115
-
116
- /**
117
- * Appends child elements to the HTML element.
118
- * @method append
119
- * @param {...HTMLElement} elements - The elements to append to the HTML element.
120
- */
121
- append(...elements) {
122
- this.element.append(...elements);
123
- }
124
-
125
- /**
126
- * Inserts elements after the HTML element.
127
- * @method after
128
- * @param {...HTMLElement} elements - The elements to insert after the HTML element.
129
- */
130
- after(...elements) {
131
- this.element.after(...elements);
132
- }
133
-
134
- /**
135
- * Retrieves the label associated with the HTML element.
136
- * @method getLabel
137
- * @returns {HTMLElement} The label element associated with this element.
138
- * @throws {Error} Throws an error if the label cannot be found.
139
- */
140
- getLabel() {
141
- return document.querySelector(`#${this.element.id}_label`);
142
- }
143
-
144
- /**
145
- * Appends child elements to the label associated with the HTML element.
146
- * @method appendToLabel
147
- * @param {...HTMLElement} elements - The elements to append to the label.
148
- */
149
- appendToLabel(...elements) {
150
- let label = this.getLabel();
151
- label.append(" ", ...elements);
152
- }
153
-
154
- /**
155
- * Adds a click event listener to the HTML element.
156
- * @method addClickListener
157
- * @param {Function} eventHandler - The function to execute when the element is clicked.
158
- */
159
- addClickListener(eventHandler) {
160
- this.element.addEventListener("click", (e) => {
161
- e.preventDefault();
162
- eventHandler();
163
- });
164
- }
165
-
166
- /**
167
- * Adds a change event listener to the HTML element.
168
- * @method addChangeListener
169
- * @param {Function} eventHandler - The function to execute when the element's value changes.
170
- */
171
- addChangeListener(eventHandler) {
172
- this.element.addEventListener("change", (e) => {
173
- e.preventDefault();
174
- eventHandler();
175
- });
176
- }
177
-
178
- /**
179
- * Unchecks both the yes and no radio buttons if they exist.
180
- * @method uncheckRadios
181
- */
182
- uncheckRadios() {
183
- if (this.yesRadio && this.noRadio) {
184
- this.yesRadio.element.checked = false;
185
- this.noRadio.element.checked = false;
186
- } else {
187
- console.error(
188
- "[SYNACT] Attempted to uncheck radios for an element that has no radios"
189
- );
190
- }
191
- }
192
-
193
- /**
194
- * Creates a validation instance for the field.
195
- * @method createValidation
196
- * @param {Function} evaluationFunction - The function used to evaluate the field.
197
- * @param {string} fieldDisplayName - The field name to display in error if validation fails.
198
- */
199
- createValidation(evaluationFunction, fieldDisplayName) {
200
- new FieldValidation(this.id, `'${fieldDisplayName}'`, evaluationFunction);
201
- }
202
-
203
- /**
204
- * Adds a tooltip with specified text to the label associated with the HTML element.
205
- * @method addLabelTooltip
206
- * @param {string} text - The text to display in the tooltip.
207
- */
208
- addLabelTooltip(text) {
209
- this.appendToLabel(createInfoEl(text));
210
- }
211
-
212
- /**
213
- * Sets the inner HTML content of the HTML element.
214
- * @method setTextContent
215
- * @param {string} text - The text to set as the inner HTML of the element.
216
- */
217
- setTextContent(text) {
218
- this.element.innerHTML = text;
219
- }
220
-
221
- /**
222
- * Executes a callback function once the element is fully loaded.
223
- * If the element is already loaded, the callback is called immediately.
224
- * Otherwise, a MutationObserver is used to detect when the element is added to the DOM.
225
- * @method onceLoaded
226
- * @param {Function} callback - A callback function to execute once the element is loaded.
227
- */
228
- onceLoaded(callback) {
229
- console.log("loading element");
230
- if (this.isLoaded) {
231
- callback(this);
232
- } else {
233
- const observer = new MutationObserver(() => {
234
- if (document.querySelector(this.querySelector)) {
235
- observer.disconnect(); // Stop observing once loaded
236
- this.isLoaded = true;
237
- callback(this); // Call the provided callback
238
- }
239
- });
240
-
241
- observer.observe(document.body, {
242
- subtree: true,
243
- childList: true,
244
- });
245
- }
246
- }
247
- }
248
-
249
- /**
250
- * Creates and initializes a DOMNodeReference instance.
251
- * @async
252
- * @function createDOMNodeReference
253
- * @param {string} querySelector - The CSS selector for the desired DOM element.
254
- * @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
255
- */
256
- export default async function createDOMNodeReference(querySelector) {
257
- const instance = new DOMNodeReference(querySelector);
258
- await instance.init();
259
-
260
- return new Proxy(instance, {
261
- get: (target, prop) => {
262
- if (prop == "init") return undefined;
263
-
264
- const value = target[prop];
265
- if (typeof value === "function" && prop !== "onceLoaded") {
266
- return (...args) => target.onceLoaded(() => value.apply(target, args));
267
- }
268
- return value;
269
- },
270
- });
271
- }
@@ -1,25 +0,0 @@
1
- export default class FieldValidation {
2
- constructor(fieldLogicalName, fieldDisplayname, evaluationFunction) {
3
- this.fieldLogicalName = fieldLogicalName;
4
- this.fieldDisplayname = fieldDisplayname;
5
- this.evaluationFunction = evaluationFunction.bind(this);
6
-
7
- this.createValidator();
8
- }
9
-
10
- createValidator = function () {
11
- if (typeof Page_Validators == "undefined") return;
12
- // Create new validator
13
- var newValidator = document.createElement("span");
14
- newValidator.style.display = "none";
15
- newValidator.id = `${this.fieldLogicalName}Validator`;
16
- newValidator.controltovalidate = `${this.fieldLogicalName}`;
17
- newValidator.errormessage = `<a href='#${this.fieldDisplayname}_label'>${this.fieldDisplayname} is a required field</a>`;
18
- newValidator.validationGroup = ""; // Set this if you have set ValidationGroup on the form
19
- newValidator.initialvalue = "";
20
- newValidator.evaluationfunction = this.evaluationFunction;
21
- // Add the new validator to the page validators array:
22
- // eslint-disable-next-line no-undef
23
- Page_Validators.push(newValidator);
24
- };
25
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * @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
3
- * @param {String} selector a query selector expression to target a specific element that you want to appear in the DOM before taking further action
4
- * @returns {Promise} the element targeted by ID *selector*
5
- */
6
-
7
- export function waitFor(selector) {
8
- return new Promise((resolve) => {
9
- if (document.querySelector(selector)) {
10
- return resolve(document.querySelector(selector));
11
- }
12
-
13
- const observer = new MutationObserver(() => {
14
- if (document.querySelector(selector)) {
15
- observer.disconnect();
16
- resolve(document.querySelector(selector));
17
- }
18
- });
19
-
20
- observer.observe(document.body, {
21
- subtree: true,
22
- });
23
- });
24
- }
@@ -1,62 +0,0 @@
1
- export default function CreateInfoEl(titleString) {
2
- // Create a container span
3
- const span = document.createElement("span");
4
- span.style.position = "relative";
5
- span.style.display = "inline-block"; // Ensure proper placement
6
-
7
- // Create the "i" icon
8
- const icon = document.createElement("i");
9
- icon.classList.add("fa", "fa-solid", "fa-info-circle");
10
- icon.setAttribute("aria-label", "Info"); // For accessibility
11
- icon.style.cursor = "pointer"; // Ensure it's clear it's interactive
12
-
13
- // Create the flyout content
14
- const flyoutContent = document.createElement("div");
15
- flyoutContent.innerHTML = titleString;
16
- flyoutContent.style.display = "none";
17
- flyoutContent.style.position = "absolute";
18
- flyoutContent.style.top = "100%";
19
- flyoutContent.style.left = "0";
20
- flyoutContent.style.backgroundColor = "#f9f9f9";
21
- flyoutContent.style.padding = "10px";
22
- flyoutContent.style.border = "1px solid #ddd";
23
- flyoutContent.style.zIndex = "1";
24
- flyoutContent.style.width = "max-content"; // Default for larger screens
25
-
26
- // Responsive Design Adjustments
27
- flyoutContent.style.maxWidth = "90vw"; // Ensure it doesn't overflow on mobile
28
- flyoutContent.style.boxShadow = "0px 4px 8px rgba(0, 0, 0, 0.1)"; // Add shadow for clarity
29
- flyoutContent.style.borderRadius = "4px"; // Make it more modern with rounded corners
30
-
31
- // Append the icon and flyout content to the container
32
- span.appendChild(icon);
33
- span.appendChild(flyoutContent);
34
-
35
- // Event listeners for desktop (hover)
36
- icon.addEventListener("mouseenter", () => {
37
- flyoutContent.style.display = "block";
38
- });
39
- icon.addEventListener("mouseleave", () => {
40
- flyoutContent.style.display = "none";
41
- });
42
-
43
- // Event listeners for mobile (touch)
44
- icon.addEventListener("touchstart", (event) => {
45
- event.preventDefault(); // Prevent triggering other touch events like click
46
- if (flyoutContent.style.display === "none") {
47
- flyoutContent.style.display = "block";
48
- } else {
49
- flyoutContent.style.display = "none";
50
- }
51
- });
52
-
53
- // Optional: Add an "x" button or click-away to close the flyout on mobile
54
- document.body.addEventListener("click", (event) => {
55
- if (!span.contains(event.target)) {
56
- flyoutContent.style.display = "none"; // Hide if clicked outside
57
- }
58
- });
59
-
60
- // Return the span element which holds the icon and flyout content
61
- return span;
62
- }
package/lib/safeAjax.js DELETED
@@ -1,31 +0,0 @@
1
- export default function safeAjax(ajaxOptions) {
2
- var deferredAjax = $.Deferred();
3
-
4
- // shell is only available via runtime in a PowerPages portal
5
- //eslint-disable-next-line
6
- shell
7
- .getTokenDeferred()
8
- .done(function (token) {
9
- // add headers for AJAX
10
- if (!ajaxOptions.headers) {
11
- $.extend(ajaxOptions, {
12
- headers: {
13
- __RequestVerificationToken: token,
14
- },
15
- });
16
- } else {
17
- ajaxOptions.headers["__RequestVerificationToken"] = token;
18
- }
19
- $.ajax(ajaxOptions)
20
- .done(function (data, textStatus, jqXHR) {
21
- //eslint-disable-next-line
22
- validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve);
23
- })
24
- .fail(deferredAjax.reject); //AJAX
25
- })
26
- .fail(function () {
27
- deferredAjax.rejectWith(this, arguments); // on token failure pass the token AJAX and args
28
- });
29
-
30
- return deferredAjax.promise();
31
- }