powerpagestoolkit 1.3.204 → 1.3.304
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 +5 -2
- package/dist/index.bundle.js +41 -10
- package/index.d.ts +7 -3
- package/package.json +1 -1
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
|
|
package/dist/index.bundle.js
CHANGED
|
@@ -935,16 +935,19 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
935
935
|
key: "on",
|
|
936
936
|
value: function on(eventType, eventHandler) {
|
|
937
937
|
this.element.addEventListener(eventType, eventHandler.bind(this));
|
|
938
|
+
return this;
|
|
938
939
|
}
|
|
939
940
|
}, {
|
|
940
941
|
key: "hide",
|
|
941
942
|
value: function hide() {
|
|
942
943
|
this.visibilityController.style.display = "none";
|
|
944
|
+
return this;
|
|
943
945
|
}
|
|
944
946
|
}, {
|
|
945
947
|
key: "show",
|
|
946
948
|
value: function show() {
|
|
947
949
|
this.visibilityController.style.display = this.defaultDisplay;
|
|
950
|
+
return this;
|
|
948
951
|
}
|
|
949
952
|
}, {
|
|
950
953
|
key: "toggleVisibility",
|
|
@@ -954,6 +957,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
954
957
|
} else {
|
|
955
958
|
shouldShow ? this.show() : this.hide();
|
|
956
959
|
}
|
|
960
|
+
return this;
|
|
957
961
|
}
|
|
958
962
|
}, {
|
|
959
963
|
key: "setValue",
|
|
@@ -964,6 +968,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
964
968
|
} else {
|
|
965
969
|
this.element.value = value;
|
|
966
970
|
}
|
|
971
|
+
return this;
|
|
967
972
|
}
|
|
968
973
|
}, {
|
|
969
974
|
key: "disable",
|
|
@@ -973,6 +978,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
973
978
|
} catch (e) {
|
|
974
979
|
throw new Error("There was an error trying to disable the target: ".concat(this.target));
|
|
975
980
|
}
|
|
981
|
+
return this;
|
|
976
982
|
}
|
|
977
983
|
}, {
|
|
978
984
|
key: "enable",
|
|
@@ -982,6 +988,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
982
988
|
} catch (e) {
|
|
983
989
|
throw new Error("There was an error trying to disable the target: ".concat(this.target));
|
|
984
990
|
}
|
|
991
|
+
return this;
|
|
985
992
|
}
|
|
986
993
|
}, {
|
|
987
994
|
key: "prepend",
|
|
@@ -997,6 +1004,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
997
1004
|
_this.element.prepend(node);
|
|
998
1005
|
}
|
|
999
1006
|
});
|
|
1007
|
+
return this;
|
|
1000
1008
|
}
|
|
1001
1009
|
}, {
|
|
1002
1010
|
key: "append",
|
|
@@ -1012,6 +1020,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1012
1020
|
_this2.element.append(node);
|
|
1013
1021
|
}
|
|
1014
1022
|
});
|
|
1023
|
+
return this;
|
|
1015
1024
|
}
|
|
1016
1025
|
}, {
|
|
1017
1026
|
key: "before",
|
|
@@ -1027,6 +1036,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1027
1036
|
_this3.element.before(node);
|
|
1028
1037
|
}
|
|
1029
1038
|
});
|
|
1039
|
+
return this;
|
|
1030
1040
|
}
|
|
1031
1041
|
}, {
|
|
1032
1042
|
key: "after",
|
|
@@ -1042,6 +1052,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1042
1052
|
_this4.element.after(node);
|
|
1043
1053
|
}
|
|
1044
1054
|
});
|
|
1055
|
+
return this;
|
|
1045
1056
|
}
|
|
1046
1057
|
}, {
|
|
1047
1058
|
key: "getLabel",
|
|
@@ -1058,21 +1069,37 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1058
1069
|
}
|
|
1059
1070
|
label.append.apply(label, [" "].concat(elements));
|
|
1060
1071
|
}
|
|
1072
|
+
return this;
|
|
1061
1073
|
}
|
|
1062
1074
|
}, {
|
|
1063
1075
|
key: "addLabelTooltip",
|
|
1064
1076
|
value: function addLabelTooltip(text) {
|
|
1065
1077
|
this.appendToLabel(CreateInfoEl(text));
|
|
1078
|
+
return this;
|
|
1066
1079
|
}
|
|
1067
1080
|
}, {
|
|
1068
1081
|
key: "addTooltip",
|
|
1069
1082
|
value: function addTooltip(text) {
|
|
1070
1083
|
this.append(CreateInfoEl(text));
|
|
1084
|
+
return this;
|
|
1071
1085
|
}
|
|
1072
1086
|
}, {
|
|
1073
1087
|
key: "setTextContent",
|
|
1074
1088
|
value: function setTextContent(text) {
|
|
1075
1089
|
this.element.innerHTML = text;
|
|
1090
|
+
return this;
|
|
1091
|
+
}
|
|
1092
|
+
}, {
|
|
1093
|
+
key: "setStyle",
|
|
1094
|
+
value: function setStyle(options) {
|
|
1095
|
+
var _this5 = this;
|
|
1096
|
+
if (Object.prototype.toString.call(options) !== "[object Object]") {
|
|
1097
|
+
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)));
|
|
1098
|
+
}
|
|
1099
|
+
Object.keys(options).forEach(function (key) {
|
|
1100
|
+
_this5.element.style[key] = options[key];
|
|
1101
|
+
});
|
|
1102
|
+
return this;
|
|
1076
1103
|
}
|
|
1077
1104
|
}, {
|
|
1078
1105
|
key: "uncheckRadios",
|
|
@@ -1083,22 +1110,23 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1083
1110
|
} else {
|
|
1084
1111
|
console.error("[SYNACT] Attempted to uncheck radios for an element that has no radios");
|
|
1085
1112
|
}
|
|
1113
|
+
return this;
|
|
1086
1114
|
}
|
|
1087
1115
|
}, {
|
|
1088
1116
|
key: "configureConditionalRendering",
|
|
1089
1117
|
value: function configureConditionalRendering(condition, triggerNodes) {
|
|
1090
|
-
var
|
|
1118
|
+
var _this6 = this;
|
|
1091
1119
|
try {
|
|
1092
1120
|
this.toggleVisibility(condition(this));
|
|
1093
1121
|
if (triggerNodes) {
|
|
1094
1122
|
var nodes = Array.isArray(triggerNodes) ? triggerNodes : [triggerNodes];
|
|
1095
1123
|
nodes.forEach(function (node) {
|
|
1096
1124
|
node.on("change", function () {
|
|
1097
|
-
return
|
|
1125
|
+
return _this6.toggleVisibility(condition(_this6));
|
|
1098
1126
|
});
|
|
1099
1127
|
var observer = new MutationObserver(function () {
|
|
1100
1128
|
var display = window.getComputedStyle(node.visibilityController).display;
|
|
1101
|
-
|
|
1129
|
+
_this6.toggleVisibility(display !== "none" && condition(_this6));
|
|
1102
1130
|
});
|
|
1103
1131
|
observer.observe(node.visibilityController, {
|
|
1104
1132
|
attributes: true,
|
|
@@ -1109,11 +1137,12 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1109
1137
|
} catch (e) {
|
|
1110
1138
|
throw new ConditionalRenderingError(this, e);
|
|
1111
1139
|
}
|
|
1140
|
+
return this;
|
|
1112
1141
|
}
|
|
1113
1142
|
}, {
|
|
1114
1143
|
key: "configureValidationAndRequirements",
|
|
1115
1144
|
value: function configureValidationAndRequirements(isRequired, isValid, fieldDisplayName) {
|
|
1116
|
-
var
|
|
1145
|
+
var _this7 = this;
|
|
1117
1146
|
var dependencies = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
1118
1147
|
if (typeof Page_Validators !== "undefined") {
|
|
1119
1148
|
var newValidator = document.createElement("span");
|
|
@@ -1128,13 +1157,14 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1128
1157
|
throw new Error("Attempted to add to Validator where Page_Validators do not exist");
|
|
1129
1158
|
}
|
|
1130
1159
|
this.setRequiredLevel(isRequired(this));
|
|
1131
|
-
if (!dependencies) return;
|
|
1160
|
+
if (!dependencies) return this;
|
|
1132
1161
|
dependencies = Array.isArray(dependencies) ? dependencies : [dependencies];
|
|
1133
1162
|
dependencies.forEach(function (dep) {
|
|
1134
1163
|
dep.element.addEventListener("change", function () {
|
|
1135
|
-
return
|
|
1164
|
+
return _this7.setRequiredLevel(isRequired(_this7));
|
|
1136
1165
|
});
|
|
1137
1166
|
});
|
|
1167
|
+
return this;
|
|
1138
1168
|
}
|
|
1139
1169
|
}, {
|
|
1140
1170
|
key: "setRequiredLevel",
|
|
@@ -1144,19 +1174,20 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1144
1174
|
} else {
|
|
1145
1175
|
this.getLabel().classList.remove("required-field");
|
|
1146
1176
|
}
|
|
1177
|
+
return this;
|
|
1147
1178
|
}
|
|
1148
1179
|
}, {
|
|
1149
1180
|
key: "onceLoaded",
|
|
1150
1181
|
value: function onceLoaded(callback) {
|
|
1151
|
-
var
|
|
1182
|
+
var _this8 = this;
|
|
1152
1183
|
if (this.isLoaded) {
|
|
1153
1184
|
callback(this);
|
|
1154
1185
|
} else {
|
|
1155
1186
|
var observer = new MutationObserver(function () {
|
|
1156
|
-
if (document.querySelector(
|
|
1187
|
+
if (document.querySelector(_this8.target)) {
|
|
1157
1188
|
observer.disconnect(); // Stop observing once loaded
|
|
1158
|
-
|
|
1159
|
-
callback(
|
|
1189
|
+
_this8.isLoaded = true;
|
|
1190
|
+
callback(_this8); // Call the provided callback
|
|
1160
1191
|
}
|
|
1161
1192
|
});
|
|
1162
1193
|
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.
|
|
3
|
+
"version": "1.3.304",
|
|
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",
|