powerpagestoolkit 1.3.303 → 1.3.501
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/dist/index.bundle.js +41 -14
- package/index.d.ts +47 -20
- package/package.json +1 -1
package/dist/index.bundle.js
CHANGED
|
@@ -804,7 +804,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
804
804
|
_context.next = 7;
|
|
805
805
|
break;
|
|
806
806
|
}
|
|
807
|
-
|
|
807
|
+
return _context.abrupt("return", new DOMNodeNotFoundError(this));
|
|
808
808
|
case 7:
|
|
809
809
|
if (!this.element.classList.contains("boolean-radio")) {
|
|
810
810
|
_context.next = 10;
|
|
@@ -822,7 +822,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
822
822
|
case 16:
|
|
823
823
|
_context.prev = 16;
|
|
824
824
|
_context.t0 = _context["catch"](0);
|
|
825
|
-
|
|
825
|
+
return _context.abrupt("return", new DOMNodeInitializationError(this, _context.t0));
|
|
826
826
|
case 19:
|
|
827
827
|
case "end":
|
|
828
828
|
return _context.stop();
|
|
@@ -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",
|
|
@@ -971,8 +976,9 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
971
976
|
try {
|
|
972
977
|
this.element.disabled = true;
|
|
973
978
|
} catch (e) {
|
|
974
|
-
|
|
979
|
+
return 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",
|
|
@@ -980,8 +986,9 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
980
986
|
try {
|
|
981
987
|
this.element.disabled = false;
|
|
982
988
|
} catch (e) {
|
|
983
|
-
|
|
989
|
+
return 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,32 +1069,43 @@ 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
|
-
key: "
|
|
1074
|
-
value: function
|
|
1075
|
-
this.element.innerHTML =
|
|
1087
|
+
key: "setInnerHTML",
|
|
1088
|
+
value: function setInnerHTML(string) {
|
|
1089
|
+
this.element.innerHTML = string;
|
|
1090
|
+
return this;
|
|
1091
|
+
}
|
|
1092
|
+
}, {
|
|
1093
|
+
key: "remove",
|
|
1094
|
+
value: function remove() {
|
|
1095
|
+
this.element.remove();
|
|
1096
|
+
return this;
|
|
1076
1097
|
}
|
|
1077
1098
|
}, {
|
|
1078
1099
|
key: "setStyle",
|
|
1079
1100
|
value: function setStyle(options) {
|
|
1080
1101
|
var _this5 = this;
|
|
1081
1102
|
if (Object.prototype.toString.call(options) !== "[object Object]") {
|
|
1082
|
-
|
|
1103
|
+
return 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
1104
|
}
|
|
1084
1105
|
Object.keys(options).forEach(function (key) {
|
|
1085
1106
|
_this5.element.style[key] = options[key];
|
|
1086
1107
|
});
|
|
1108
|
+
return this;
|
|
1087
1109
|
}
|
|
1088
1110
|
}, {
|
|
1089
1111
|
key: "uncheckRadios",
|
|
@@ -1094,6 +1116,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1094
1116
|
} else {
|
|
1095
1117
|
console.error("[SYNACT] Attempted to uncheck radios for an element that has no radios");
|
|
1096
1118
|
}
|
|
1119
|
+
return this;
|
|
1097
1120
|
}
|
|
1098
1121
|
}, {
|
|
1099
1122
|
key: "configureConditionalRendering",
|
|
@@ -1118,8 +1141,9 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1118
1141
|
});
|
|
1119
1142
|
}
|
|
1120
1143
|
} catch (e) {
|
|
1121
|
-
|
|
1144
|
+
return new ConditionalRenderingError(this, e);
|
|
1122
1145
|
}
|
|
1146
|
+
return this;
|
|
1123
1147
|
}
|
|
1124
1148
|
}, {
|
|
1125
1149
|
key: "configureValidationAndRequirements",
|
|
@@ -1136,16 +1160,17 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1136
1160
|
//eslint-disable-next-line
|
|
1137
1161
|
Page_Validators.push(newValidator);
|
|
1138
1162
|
} else {
|
|
1139
|
-
|
|
1163
|
+
return new Error("Attempted to add to Validator where Page_Validators do not exist");
|
|
1140
1164
|
}
|
|
1141
1165
|
this.setRequiredLevel(isRequired(this));
|
|
1142
|
-
if (!dependencies) return;
|
|
1166
|
+
if (!dependencies) return this;
|
|
1143
1167
|
dependencies = Array.isArray(dependencies) ? dependencies : [dependencies];
|
|
1144
1168
|
dependencies.forEach(function (dep) {
|
|
1145
1169
|
dep.element.addEventListener("change", function () {
|
|
1146
1170
|
return _this7.setRequiredLevel(isRequired(_this7));
|
|
1147
1171
|
});
|
|
1148
1172
|
});
|
|
1173
|
+
return this;
|
|
1149
1174
|
}
|
|
1150
1175
|
}, {
|
|
1151
1176
|
key: "setRequiredLevel",
|
|
@@ -1155,6 +1180,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1155
1180
|
} else {
|
|
1156
1181
|
this.getLabel().classList.remove("required-field");
|
|
1157
1182
|
}
|
|
1183
|
+
return this;
|
|
1158
1184
|
}
|
|
1159
1185
|
}, {
|
|
1160
1186
|
key: "onceLoaded",
|
|
@@ -1221,9 +1247,10 @@ function _createDOMNodeReference() {
|
|
|
1221
1247
|
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
1222
1248
|
args[_key6] = arguments[_key6];
|
|
1223
1249
|
}
|
|
1224
|
-
|
|
1250
|
+
target.onceLoaded(function () {
|
|
1225
1251
|
return value.apply(target, args);
|
|
1226
1252
|
});
|
|
1253
|
+
return target;
|
|
1227
1254
|
};
|
|
1228
1255
|
}
|
|
1229
1256
|
return value;
|
|
@@ -1233,7 +1260,7 @@ function _createDOMNodeReference() {
|
|
|
1233
1260
|
_context3.prev = 7;
|
|
1234
1261
|
_context3.t0 = _context3["catch"](0);
|
|
1235
1262
|
console.error("There was an error creating a DOMNodeReference: ".concat(_context3.t0));
|
|
1236
|
-
|
|
1263
|
+
return _context3.abrupt("return", new Error(_context3.t0));
|
|
1237
1264
|
case 11:
|
|
1238
1265
|
case "end":
|
|
1239
1266
|
return _context3.stop();
|
|
@@ -1274,7 +1301,7 @@ function _createMultipleDOMNodeReferences() {
|
|
|
1274
1301
|
_context4.prev = 10;
|
|
1275
1302
|
_context4.t0 = _context4["catch"](0);
|
|
1276
1303
|
console.error("There was an error creating multiple DOMNodeReferences: ".concat(_context4.t0));
|
|
1277
|
-
|
|
1304
|
+
return _context4.abrupt("return", new Error(_context4.t0));
|
|
1278
1305
|
case 14:
|
|
1279
1306
|
case "end":
|
|
1280
1307
|
return _context4.stop();
|
package/index.d.ts
CHANGED
|
@@ -47,55 +47,64 @@ class DOMNodeReference {
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Hides the element by setting its display style to "none".
|
|
50
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
50
51
|
*/
|
|
51
|
-
hide():
|
|
52
|
+
hide(): DOMNodeReference;
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
55
|
* Shows the element by restoring its default display style.
|
|
56
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
55
57
|
*/
|
|
56
|
-
show():
|
|
58
|
+
show(): DOMNodeReference;
|
|
57
59
|
|
|
58
60
|
/**
|
|
59
61
|
* Sets the value of the HTML element.
|
|
60
62
|
* @param {() => any} value - The value to set for the HTML element.
|
|
61
63
|
* for parents of boolean radios, pass true or false as value, or
|
|
62
64
|
* an expression returning a boolean
|
|
65
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
63
66
|
*/
|
|
64
|
-
setValue(value: string):
|
|
67
|
+
setValue(value: string): DOMNodeReference;
|
|
65
68
|
|
|
66
69
|
/**
|
|
67
70
|
* Disables the element so that users cannot input any data
|
|
71
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
68
72
|
*/
|
|
69
|
-
disable():
|
|
73
|
+
disable(): DOMNodeReference;
|
|
70
74
|
|
|
71
75
|
/**
|
|
72
76
|
* Enables the element so that users can input data
|
|
77
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
73
78
|
*/
|
|
74
|
-
enable():
|
|
79
|
+
enable(): DOMNodeReference;
|
|
75
80
|
|
|
76
81
|
/**
|
|
77
82
|
* Prepends elements to the target
|
|
78
83
|
* @param {HTMLElement[] | DOMNodeReference[]} nodes - The elements to prepend to the HTML element
|
|
84
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
79
85
|
*/
|
|
80
|
-
prepend(...nodes: HTMLElement[] | DOMNodeReference[]):
|
|
86
|
+
prepend(...nodes: HTMLElement[] | DOMNodeReference[]): DOMNodeReference;
|
|
81
87
|
|
|
82
88
|
/**
|
|
83
89
|
* Appends child elements to the HTML element.
|
|
84
90
|
* @param {HTMLElement[] | DOMNodeReference[]} nodes - The elements to append to the HTML element.
|
|
91
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
85
92
|
*/
|
|
86
|
-
append(...nodes: HTMLElement[] | DOMNodeReference[]):
|
|
93
|
+
append(...nodes: HTMLElement[] | DOMNodeReference[]): DOMNodeReference;
|
|
87
94
|
|
|
88
95
|
/**
|
|
89
96
|
* Inserts elements before the HTML element.
|
|
90
97
|
* @param {HTMLElement[] | DOMNodeReference[]} nodes - The elements to insert before the HTML element.
|
|
98
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
91
99
|
*/
|
|
92
|
-
before(...nodes: HTMLElement[] | DOMNodeReference[]):
|
|
100
|
+
before(...nodes: HTMLElement[] | DOMNodeReference[]): DOMNodeReference;
|
|
93
101
|
|
|
94
102
|
/**
|
|
95
103
|
* Inserts elements after the HTML element.
|
|
96
104
|
* @param {HTMLElement[] | DOMNodeReference[]} nodes - The elements to insert after the HTML element.
|
|
105
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
97
106
|
*/
|
|
98
|
-
after(...nodes: HTMLElement[] | DOMNodeReference[]):
|
|
107
|
+
after(...nodes: HTMLElement[] | DOMNodeReference[]): DOMNodeReference;
|
|
99
108
|
|
|
100
109
|
/**
|
|
101
110
|
* Retrieves the label associated with the HTML element.
|
|
@@ -107,8 +116,9 @@ class DOMNodeReference {
|
|
|
107
116
|
/**
|
|
108
117
|
* Appends child elements to the label associated with the HTML element.
|
|
109
118
|
* @param {...HTMLElement} elements - The elements to append to the label.
|
|
119
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
110
120
|
*/
|
|
111
|
-
appendToLabel(...elements: HTMLElement[]):
|
|
121
|
+
appendToLabel(...elements: HTMLElement[]): DOMNodeReference;
|
|
112
122
|
|
|
113
123
|
/**
|
|
114
124
|
* Sets up an event listener based on the specified event type, executing the specified
|
|
@@ -116,12 +126,15 @@ class DOMNodeReference {
|
|
|
116
126
|
* @param {string} eventType - The DOM event to watch for
|
|
117
127
|
* @param {(this: DOMNodeReference, e: Event) => void} eventHandler - The callback function that runs when the
|
|
118
128
|
* specified event occurs
|
|
129
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
119
130
|
*/
|
|
120
|
-
on(eventType: string, eventHandler: (event: Event) => void):
|
|
131
|
+
on(eventType: string, eventHandler: (event: Event) => void): DOMNodeReference;
|
|
132
|
+
|
|
121
133
|
/**
|
|
122
134
|
* Unchecks both the yes and no radio buttons if they exist.
|
|
135
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
123
136
|
*/
|
|
124
|
-
uncheckRadios():
|
|
137
|
+
uncheckRadios(): DOMNodeReference;
|
|
125
138
|
|
|
126
139
|
/**
|
|
127
140
|
* Sets up validation and requirement rules for the field. This function dynamically updates the field's required status and validates its input based on the specified conditions.
|
|
@@ -130,53 +143,66 @@ class DOMNodeReference {
|
|
|
130
143
|
* @param {function(this: DOMNodeReference): boolean} isValid - A function that checks if the field's input is valid. Returns `true` if valid, `false` otherwise.
|
|
131
144
|
* @param {string} fieldDisplayName - The name of the field, used in error messages if validation fails.
|
|
132
145
|
* @param {Array<DOMNodeReference>} [dependencies] Other fields that this field’s requirement depends on. When these fields change, the required status of this field is re-evaluated. Make sure any DOMNodeReference used in `isRequired` or `isValid` is included in this array.
|
|
146
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
133
147
|
*/
|
|
134
148
|
configureValidationAndRequirements(
|
|
135
149
|
isRequired: (this: this) => boolean,
|
|
136
150
|
isValid: (this: this) => boolean,
|
|
137
151
|
fieldDisplayName: string,
|
|
138
152
|
dependencies: Array<DOMNodeReference>
|
|
139
|
-
):
|
|
153
|
+
): DOMNodeReference;
|
|
140
154
|
|
|
141
155
|
/**
|
|
142
156
|
* Sets the required level for the field by adding or removing the "required-field" class on the label.
|
|
143
157
|
*
|
|
144
158
|
* @param {boolean} isRequired - Determines whether the field should be marked as required.
|
|
145
159
|
* If true, the "required-field" class is added to the label; if false, it is removed.
|
|
160
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
146
161
|
*/
|
|
147
|
-
setRequiredLevel(isRequired: boolean):
|
|
162
|
+
setRequiredLevel(isRequired: boolean): DOMNodeReference;
|
|
148
163
|
|
|
149
164
|
/**
|
|
150
165
|
* Adds a tooltip with specified text to the label associated with the HTML element.
|
|
151
166
|
* @param {string} text - The text to display in the tooltip.
|
|
167
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
152
168
|
*/
|
|
153
|
-
addLabelTooltip(text: string):
|
|
169
|
+
addLabelTooltip(text: string): DOMNodeReference;
|
|
154
170
|
|
|
155
171
|
/**
|
|
156
172
|
* Adds a tooltip with the specified text to the element
|
|
157
173
|
* @param {string} text - The text to display in the tooltip
|
|
174
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
158
175
|
*/
|
|
159
|
-
addTooltip(text: string):
|
|
176
|
+
addTooltip(text: string): DOMNodeReference;
|
|
160
177
|
|
|
161
178
|
/**
|
|
162
179
|
* Sets the inner HTML content of the HTML element.
|
|
163
180
|
* @param {string} text - The text to set as the inner HTML of the element.
|
|
181
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
182
|
+
*/
|
|
183
|
+
setInnerHTML(text: string): DOMNodeReference;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Removes the element from the DOM
|
|
187
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
164
188
|
*/
|
|
165
|
-
|
|
189
|
+
remove(): DOMNodeReference;
|
|
166
190
|
|
|
167
191
|
/**
|
|
168
192
|
*
|
|
169
193
|
* @param {Partial<CSSStyleDeclaration>} options - An object with the style properties (keys) and updated styles (values)
|
|
170
194
|
* to apply to the this. {"key": "value"}
|
|
195
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
171
196
|
*/
|
|
172
|
-
setStyle(options: Partial<CSSStyleDeclaration>):
|
|
197
|
+
setStyle(options: Partial<CSSStyleDeclaration>): DOMNodeReference;
|
|
173
198
|
|
|
174
199
|
/**
|
|
175
200
|
*
|
|
176
201
|
* @param {boolean} shouldShow shows or hides the target
|
|
177
202
|
* if = true => show, if = false => hide
|
|
203
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
178
204
|
*/
|
|
179
|
-
toggleVisibility(shouldShow: boolean):
|
|
205
|
+
toggleVisibility(shouldShow: boolean): DOMNodeReference;
|
|
180
206
|
|
|
181
207
|
/**
|
|
182
208
|
* Configures conditional rendering for the target element based on a condition
|
|
@@ -188,11 +214,12 @@ class DOMNodeReference {
|
|
|
188
214
|
* @param {Array<DOMNodeReference>} dependencies - An array of `DOMNodeReference` instances. Event listeners are
|
|
189
215
|
* registered on each to toggle the visibility of the target element based on the `condition` and the visibility of
|
|
190
216
|
* the target node.
|
|
217
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
191
218
|
*/
|
|
192
219
|
configureConditionalRendering(
|
|
193
220
|
condition: (this: DOMNodeReference) => boolean,
|
|
194
221
|
dependencies: DOMNodeReference[]
|
|
195
|
-
):
|
|
222
|
+
): DOMNodeReference;
|
|
196
223
|
|
|
197
224
|
/**
|
|
198
225
|
* Executes a callback function once the element is fully loaded.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powerpagestoolkit",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.501",
|
|
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",
|