powerpagestoolkit 1.3.204 → 1.3.303

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -67,7 +67,7 @@ yesRadio: DOMNodeReference;
67
67
  noRadio: DOMNodeReference;
68
68
  // and if 'this' is the instance of a yesRadio or noRadio
69
69
  // checked will represent wether the radio has been checked or not
70
- checked: boolean
70
+ checked: boolean;
71
71
  ```
72
72
 
73
73
  ##### Methods
@@ -107,7 +107,7 @@ toggleVisibility(shouldShow: boolean | () => boolean)
107
107
  */
108
108
  configureConditionalRendering(
109
109
  condition: (this: DOMNodeReference) => boolean,
110
- dependencies: DOMNodeReference[]
110
+ dependencies: Array<DOMNodeReference>
111
111
  )
112
112
 
113
113
 
@@ -200,6 +200,9 @@ setValue(value: any)
200
200
  // Sets the inner HTML content of the associated HTML element.
201
201
  setTextContent(text: string)
202
202
 
203
+ // set any style attribute for 'this' with standard CSS style declaration
204
+ setStyle(options: Partial<CSSStyleDeclaration>): void;
205
+
203
206
  // Appends child elements to the associated HTML element.
204
207
  append(...elements: HTMLElement[])
205
208
 
@@ -1074,6 +1074,17 @@ var DOMNodeReference = /*#__PURE__*/function () {
1074
1074
  value: function setTextContent(text) {
1075
1075
  this.element.innerHTML = text;
1076
1076
  }
1077
+ }, {
1078
+ key: "setStyle",
1079
+ value: function setStyle(options) {
1080
+ var _this5 = this;
1081
+ if (Object.prototype.toString.call(options) !== "[object Object]") {
1082
+ 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)));
1083
+ }
1084
+ Object.keys(options).forEach(function (key) {
1085
+ _this5.element.style[key] = options[key];
1086
+ });
1087
+ }
1077
1088
  }, {
1078
1089
  key: "uncheckRadios",
1079
1090
  value: function uncheckRadios() {
@@ -1087,18 +1098,18 @@ var DOMNodeReference = /*#__PURE__*/function () {
1087
1098
  }, {
1088
1099
  key: "configureConditionalRendering",
1089
1100
  value: function configureConditionalRendering(condition, triggerNodes) {
1090
- var _this5 = this;
1101
+ var _this6 = this;
1091
1102
  try {
1092
1103
  this.toggleVisibility(condition(this));
1093
1104
  if (triggerNodes) {
1094
1105
  var nodes = Array.isArray(triggerNodes) ? triggerNodes : [triggerNodes];
1095
1106
  nodes.forEach(function (node) {
1096
1107
  node.on("change", function () {
1097
- return _this5.toggleVisibility(condition(_this5));
1108
+ return _this6.toggleVisibility(condition(_this6));
1098
1109
  });
1099
1110
  var observer = new MutationObserver(function () {
1100
1111
  var display = window.getComputedStyle(node.visibilityController).display;
1101
- _this5.toggleVisibility(display !== "none" && condition(_this5));
1112
+ _this6.toggleVisibility(display !== "none" && condition(_this6));
1102
1113
  });
1103
1114
  observer.observe(node.visibilityController, {
1104
1115
  attributes: true,
@@ -1113,7 +1124,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
1113
1124
  }, {
1114
1125
  key: "configureValidationAndRequirements",
1115
1126
  value: function configureValidationAndRequirements(isRequired, isValid, fieldDisplayName) {
1116
- var _this6 = this;
1127
+ var _this7 = this;
1117
1128
  var dependencies = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
1118
1129
  if (typeof Page_Validators !== "undefined") {
1119
1130
  var newValidator = document.createElement("span");
@@ -1132,7 +1143,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
1132
1143
  dependencies = Array.isArray(dependencies) ? dependencies : [dependencies];
1133
1144
  dependencies.forEach(function (dep) {
1134
1145
  dep.element.addEventListener("change", function () {
1135
- return _this6.setRequiredLevel(isRequired(_this6));
1146
+ return _this7.setRequiredLevel(isRequired(_this7));
1136
1147
  });
1137
1148
  });
1138
1149
  }
@@ -1148,15 +1159,15 @@ var DOMNodeReference = /*#__PURE__*/function () {
1148
1159
  }, {
1149
1160
  key: "onceLoaded",
1150
1161
  value: function onceLoaded(callback) {
1151
- var _this7 = this;
1162
+ var _this8 = this;
1152
1163
  if (this.isLoaded) {
1153
1164
  callback(this);
1154
1165
  } else {
1155
1166
  var observer = new MutationObserver(function () {
1156
- if (document.querySelector(_this7.target)) {
1167
+ if (document.querySelector(_this8.target)) {
1157
1168
  observer.disconnect(); // Stop observing once loaded
1158
- _this7.isLoaded = true;
1159
- callback(_this7); // Call the provided callback
1169
+ _this8.isLoaded = true;
1170
+ callback(_this8); // Call the provided callback
1160
1171
  }
1161
1172
  });
1162
1173
  observer.observe(document.body, {
package/index.d.ts CHANGED
@@ -8,7 +8,6 @@ class DOMNodeReference {
8
8
  */
9
9
  constructor(target: string): DOMNodeReference;
10
10
 
11
- target: string;
12
11
  /**
13
12
  * The element targeted when instantiating DOMNodeReference.
14
13
  * Made available in order to perform normal DOM traversal,
@@ -17,8 +16,6 @@ class DOMNodeReference {
17
16
  */
18
17
  element: HTMLElement | null;
19
18
  isLoaded: boolean;
20
- visibilityController: HTMLElement | null;
21
- defaultDisplay: string;
22
19
  /**
23
20
  * The value of the element that this node represents
24
21
  * stays in syncs with the live DOM elements via event handler
@@ -167,6 +164,13 @@ class DOMNodeReference {
167
164
  */
168
165
  setTextContent(text: string): void;
169
166
 
167
+ /**
168
+ *
169
+ * @param {Partial<CSSStyleDeclaration>} options - An object with the style properties (keys) and updated styles (values)
170
+ * to apply to the this. {"key": "value"}
171
+ */
172
+ setStyle(options: Partial<CSSStyleDeclaration>): void;
173
+
170
174
  /**
171
175
  *
172
176
  * @param {boolean} shouldShow shows or hides the target
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powerpagestoolkit",
3
- "version": "1.3.204",
3
+ "version": "1.3.303",
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
5
  "main": "./dist/index.bundle.js",
6
6
  "types": "index.d.ts",