powerpagestoolkit 1.3.1041 → 1.3.2041
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 +139 -28
- package/dist/index.bundle.js +69 -21
- package/index.d.ts +27 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,8 @@ The `DOMNodeReference` module simplifies DOM element management. It provides fun
|
|
|
30
30
|
|
|
31
31
|
- **`createMultipleDOMNodeReferences(selector)`**: Creates multiple `DOMNodeReference` instances for all elements matching the specified CSS selector. Returns an array of `DOMNodeReference` instances.
|
|
32
32
|
|
|
33
|
+
`selector` uses standard ED6 `document.querySelector()` syntax. For more information, read [here](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector)
|
|
34
|
+
|
|
33
35
|
```javascript
|
|
34
36
|
// single instance of DOMNodeReference
|
|
35
37
|
const node = await createDOMNodeReference("#my-element");
|
|
@@ -48,22 +50,34 @@ nodeArray.forEach((node) => {
|
|
|
48
50
|
})
|
|
49
51
|
```
|
|
50
52
|
|
|
51
|
-
##### Properties
|
|
53
|
+
##### Available Properties
|
|
54
|
+
|
|
55
|
+
These properties are public and can be used in any custom logic/configurations
|
|
52
56
|
|
|
53
57
|
```typescript
|
|
54
|
-
target: string;
|
|
55
|
-
element: HTMLElement
|
|
58
|
+
target: HTMLElement | string;
|
|
59
|
+
element: HTMLElement;
|
|
56
60
|
isLoaded: boolean;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
value: any;
|
|
62
|
+
/**
|
|
63
|
+
* If the element targeted is the main input for a yes/no radio control,
|
|
64
|
+
* yesRadio and noRadio will be available as properties of 'this'
|
|
65
|
+
*/
|
|
66
|
+
yesRadio: DOMNodeReference;
|
|
67
|
+
noRadio: DOMNodeReference;
|
|
68
|
+
// and if 'this' is the instance of a yesRadio or noRadio
|
|
69
|
+
// checked will represent wether the radio has been checked or not
|
|
70
|
+
checked: boolean
|
|
60
71
|
```
|
|
61
72
|
|
|
62
73
|
##### Methods
|
|
63
74
|
|
|
64
75
|
Here are the key methods you can use with a DOMNodeReference instance:
|
|
65
76
|
|
|
66
|
-
```
|
|
77
|
+
```javascript
|
|
78
|
+
|
|
79
|
+
/********/
|
|
80
|
+
// VISIBILITY / ACCESSIBILITY
|
|
67
81
|
|
|
68
82
|
// Hides the associated DOM element.
|
|
69
83
|
hide()
|
|
@@ -71,8 +85,120 @@ hide()
|
|
|
71
85
|
// Shows the associated DOM element.
|
|
72
86
|
show()
|
|
73
87
|
|
|
88
|
+
/**
|
|
89
|
+
* advanced visibility control in the case you need to apply
|
|
90
|
+
* custom logic to the visibility of an element
|
|
91
|
+
*/
|
|
92
|
+
toggleVisibility(shouldShow: boolean | () => boolean)
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Configures conditional rendering for the target element
|
|
96
|
+
* based on a condition and the visibility of one or more trigger elements.
|
|
97
|
+
*
|
|
98
|
+
* @param {(this: DOMNodeReference) => boolean} condition -
|
|
99
|
+
* A function that returns a boolean to determine the visibility
|
|
100
|
+
* of the target element. If `condition()` returns true, the
|
|
101
|
+
* element is shown; otherwise, it is hidden.
|
|
102
|
+
* @param {Array<DOMNodeReference>} dependencies - An array
|
|
103
|
+
* of `DOMNodeReference` instances. Event listeners are
|
|
104
|
+
* registered on each to toggle the visibility of the
|
|
105
|
+
* target element based on the `condition` and the
|
|
106
|
+
* visibility of the target node.
|
|
107
|
+
*/
|
|
108
|
+
configureConditionalRendering(
|
|
109
|
+
condition: (this: DOMNodeReference) => boolean,
|
|
110
|
+
dependencies: Array<DOMNodeReference>
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
// EXAMPLE:
|
|
115
|
+
const your_node = await createDOMNodeReference("#element_id")
|
|
116
|
+
const other_node = await createDOMNodeReference(".element_class")
|
|
117
|
+
|
|
118
|
+
your_node.configureConditionalRendering(() =>
|
|
119
|
+
other_node.value == "3",
|
|
120
|
+
/* your_node will only be
|
|
121
|
+
visible when the value of other_node is "3"
|
|
122
|
+
*/
|
|
123
|
+
[other_node]
|
|
124
|
+
/* and we have to include any DOMNodeReferences used
|
|
125
|
+
in the evaluation logic, so that changes to them can
|
|
126
|
+
be watched and the condition evaluated again
|
|
127
|
+
*/
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Sets up validation and requirement rules for the field.
|
|
133
|
+
* This function dynamically updates the field's required status
|
|
134
|
+
* and validates its input based on the specified conditions.
|
|
135
|
+
*
|
|
136
|
+
* @param {function(this: DOMNodeReference): boolean} isRequired
|
|
137
|
+
* A function that determines whether the field should be required.
|
|
138
|
+
* Return `true` if required, `false` to not be required.
|
|
139
|
+
* @param {function(this: DOMNodeReference): boolean} isValid
|
|
140
|
+
* A function that checks if the field's input is valid.
|
|
141
|
+
* Return `true` if validation satisfied, `false` if not.
|
|
142
|
+
* @param {string} fieldDisplayName - The name of the field, used
|
|
143
|
+
* in error messages if validation fails.
|
|
144
|
+
* @param {Array<DOMNodeReference>} [dependencies]
|
|
145
|
+
* Other fields that this field’s requirement depends on. When
|
|
146
|
+
* these Nodes or their values change, the required status
|
|
147
|
+
* of this field is re-evaluated. Make sure any DOMNodeReference
|
|
148
|
+
* used in `isRequired` or `isValid` is included in this array.
|
|
149
|
+
*/
|
|
150
|
+
configureValidationAndRequirements(
|
|
151
|
+
isRequired: (this: this) => boolean,
|
|
152
|
+
isValid: (this: this) => boolean,
|
|
153
|
+
fieldDisplayName: string,
|
|
154
|
+
dependencies: Array<DOMNodeReference>
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
// EXAMPLE:
|
|
158
|
+
const your_node = await createDOMNodeReference("#element_id")
|
|
159
|
+
const other_node = await createDOMNodeReference(".element_class")
|
|
160
|
+
|
|
161
|
+
your_node.configureValidationAndRequirements(
|
|
162
|
+
() => other_node.yesRadio.checked,
|
|
163
|
+
/* if 'yes' is checked for this other node,
|
|
164
|
+
this function will evaluate to true,
|
|
165
|
+
meaning that 'your_node' will be required */
|
|
166
|
+
|
|
167
|
+
function () {
|
|
168
|
+
/* important to use standard 'function' declaration,
|
|
169
|
+
instead of arrow function when needing to
|
|
170
|
+
access 'this' (the instance of 'your_node') */
|
|
171
|
+
|
|
172
|
+
if (other_node.yesRadio.checked) {
|
|
173
|
+
// when other_node radio is checked 'yes'
|
|
174
|
+
return this.value; // this is only 'valid' if it has a value
|
|
175
|
+
} else return true;
|
|
176
|
+
},
|
|
177
|
+
"Your Field Name",
|
|
178
|
+
[other_node]
|
|
179
|
+
/* since our conditions depend on
|
|
180
|
+
'other_node' it must be included in the dependency
|
|
181
|
+
array so that the requirement conditions can be
|
|
182
|
+
re-evaluated when the value of 'other_node' changes */
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
/* sets the elements 'disabled' to true - useful for inputs
|
|
187
|
+
that need to be enabled/disabled conditionally */
|
|
188
|
+
disable()
|
|
189
|
+
|
|
190
|
+
// Sets the element 'disabled' to false
|
|
191
|
+
enable()
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
```javascript
|
|
195
|
+
// OTHER METHODS
|
|
196
|
+
|
|
74
197
|
// Sets the value of the associated HTML element.
|
|
75
|
-
setValue(value:
|
|
198
|
+
setValue(value: any)
|
|
199
|
+
|
|
200
|
+
// Sets the inner HTML content of the associated HTML element.
|
|
201
|
+
setTextContent(text: string)
|
|
76
202
|
|
|
77
203
|
// Appends child elements to the associated HTML element.
|
|
78
204
|
append(...elements: HTMLElement[])
|
|
@@ -86,33 +212,18 @@ getLabel(): HTMLElement | null
|
|
|
86
212
|
// Appends child elements to the label associated with the HTML element.
|
|
87
213
|
appendToLabel(...elements: HTMLElement[])
|
|
88
214
|
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// Adds a change event listener to the associated HTML element.
|
|
93
|
-
addChangeListener(eventHandler: () => void)
|
|
215
|
+
// Create an event listener on the target element. Provide access to 'this'
|
|
216
|
+
// in the event handler function
|
|
217
|
+
on(eventType: string, eventHandler: (this: DOMNodeReference) => void)
|
|
94
218
|
|
|
95
219
|
// Unchecks both yes and no radio buttons if they exist.
|
|
96
220
|
uncheckRadios()
|
|
97
221
|
|
|
98
|
-
//Creates a validation instance for the field.
|
|
99
|
-
createValidation(evaluationFunction: () => boolean, fieldDisplayName: string)
|
|
100
|
-
|
|
101
222
|
// Adds a tooltip to the label associated with the HTML element.
|
|
102
223
|
addLabelTooltip(text: string)
|
|
103
224
|
|
|
104
|
-
// Adds a tooltip
|
|
105
|
-
|
|
106
|
-
addToolTip(text: string)
|
|
107
|
-
|
|
108
|
-
// Sets the inner HTML content of the associated HTML element.
|
|
109
|
-
setTextContent(text: string)
|
|
110
|
-
|
|
111
|
-
// Toggles visibility based on the provided boolean value.
|
|
112
|
-
toggleVisibility(shouldShow: boolean)
|
|
113
|
-
|
|
114
|
-
// Sets the visibility of the element based on a condition and binds it to another DOMNodeReference.
|
|
115
|
-
configureConditionalRendering(condition: () => boolean, triggerNode?: DOMNodeReference)
|
|
225
|
+
// Adds a tooltip with the specified text to the element
|
|
226
|
+
addTooltip(text: string)
|
|
116
227
|
|
|
117
228
|
// Executes a callback function once the element is fully loaded.
|
|
118
229
|
onceLoaded(callback: (instance: DOMNodeReference) => void)
|
package/dist/index.bundle.js
CHANGED
|
@@ -815,7 +815,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
815
815
|
case 10:
|
|
816
816
|
this._initValueSync();
|
|
817
817
|
this._attachVisibilityController();
|
|
818
|
-
this.defaultDisplay = this.visibilityController.style.display;
|
|
818
|
+
this.defaultDisplay = this.visibilityController.style.display || "inline-block";
|
|
819
819
|
this.isLoaded = true;
|
|
820
820
|
_context.next = 19;
|
|
821
821
|
break;
|
|
@@ -983,17 +983,65 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
983
983
|
throw new Error("There was an error trying to disable the target: ".concat(this.target));
|
|
984
984
|
}
|
|
985
985
|
}
|
|
986
|
+
}, {
|
|
987
|
+
key: "prepend",
|
|
988
|
+
value: function prepend() {
|
|
989
|
+
var _this = this;
|
|
990
|
+
for (var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
991
|
+
nodes[_key] = arguments[_key];
|
|
992
|
+
}
|
|
993
|
+
nodes.forEach(function (node) {
|
|
994
|
+
if (node instanceof DOMNodeReference) {
|
|
995
|
+
_this.element.prepend(node.element);
|
|
996
|
+
} else {
|
|
997
|
+
_this.element.prepend(node);
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
986
1001
|
}, {
|
|
987
1002
|
key: "append",
|
|
988
1003
|
value: function append() {
|
|
989
|
-
var
|
|
990
|
-
(
|
|
1004
|
+
var _this2 = this;
|
|
1005
|
+
for (var _len2 = arguments.length, nodes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1006
|
+
nodes[_key2] = arguments[_key2];
|
|
1007
|
+
}
|
|
1008
|
+
nodes.forEach(function (node) {
|
|
1009
|
+
if (node instanceof DOMNodeReference) {
|
|
1010
|
+
_this2.element.append(node.element);
|
|
1011
|
+
} else {
|
|
1012
|
+
_this2.element.append(node);
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
}, {
|
|
1017
|
+
key: "before",
|
|
1018
|
+
value: function before() {
|
|
1019
|
+
var _this3 = this;
|
|
1020
|
+
for (var _len3 = arguments.length, nodes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
1021
|
+
nodes[_key3] = arguments[_key3];
|
|
1022
|
+
}
|
|
1023
|
+
nodes.forEach(function (node) {
|
|
1024
|
+
if (node instanceof DOMNodeReference) {
|
|
1025
|
+
_this3.element.before(node.element);
|
|
1026
|
+
} else {
|
|
1027
|
+
_this3.element.before(node);
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
991
1030
|
}
|
|
992
1031
|
}, {
|
|
993
1032
|
key: "after",
|
|
994
1033
|
value: function after() {
|
|
995
|
-
var
|
|
996
|
-
(
|
|
1034
|
+
var _this4 = this;
|
|
1035
|
+
for (var _len4 = arguments.length, nodes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
1036
|
+
nodes[_key4] = arguments[_key4];
|
|
1037
|
+
}
|
|
1038
|
+
nodes.forEach(function (node) {
|
|
1039
|
+
if (node instanceof DOMNodeReference) {
|
|
1040
|
+
_this4.element.after(node.element);
|
|
1041
|
+
} else {
|
|
1042
|
+
_this4.element.after(node);
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
997
1045
|
}
|
|
998
1046
|
}, {
|
|
999
1047
|
key: "getLabel",
|
|
@@ -1005,8 +1053,8 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1005
1053
|
value: function appendToLabel() {
|
|
1006
1054
|
var label = this.getLabel();
|
|
1007
1055
|
if (label) {
|
|
1008
|
-
for (var
|
|
1009
|
-
elements[
|
|
1056
|
+
for (var _len5 = arguments.length, elements = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
1057
|
+
elements[_key5] = arguments[_key5];
|
|
1010
1058
|
}
|
|
1011
1059
|
label.append.apply(label, [" "].concat(elements));
|
|
1012
1060
|
}
|
|
@@ -1017,8 +1065,8 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1017
1065
|
this.appendToLabel(CreateInfoEl(text));
|
|
1018
1066
|
}
|
|
1019
1067
|
}, {
|
|
1020
|
-
key: "
|
|
1021
|
-
value: function
|
|
1068
|
+
key: "addTooltip",
|
|
1069
|
+
value: function addTooltip(text) {
|
|
1022
1070
|
this.append(CreateInfoEl(text));
|
|
1023
1071
|
}
|
|
1024
1072
|
}, {
|
|
@@ -1039,18 +1087,18 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1039
1087
|
}, {
|
|
1040
1088
|
key: "configureConditionalRendering",
|
|
1041
1089
|
value: function configureConditionalRendering(condition, triggerNodes) {
|
|
1042
|
-
var
|
|
1090
|
+
var _this5 = this;
|
|
1043
1091
|
try {
|
|
1044
|
-
this.toggleVisibility(condition());
|
|
1092
|
+
this.toggleVisibility(condition(this));
|
|
1045
1093
|
if (triggerNodes) {
|
|
1046
1094
|
var nodes = Array.isArray(triggerNodes) ? triggerNodes : [triggerNodes];
|
|
1047
1095
|
nodes.forEach(function (node) {
|
|
1048
1096
|
node.on("change", function () {
|
|
1049
|
-
return
|
|
1097
|
+
return _this5.toggleVisibility(condition(_this5));
|
|
1050
1098
|
});
|
|
1051
1099
|
var observer = new MutationObserver(function () {
|
|
1052
1100
|
var display = window.getComputedStyle(node.visibilityController).display;
|
|
1053
|
-
|
|
1101
|
+
_this5.toggleVisibility(display !== "none" && condition(_this5));
|
|
1054
1102
|
});
|
|
1055
1103
|
observer.observe(node.visibilityController, {
|
|
1056
1104
|
attributes: true,
|
|
@@ -1065,7 +1113,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1065
1113
|
}, {
|
|
1066
1114
|
key: "configureValidationAndRequirements",
|
|
1067
1115
|
value: function configureValidationAndRequirements(isRequired, isValid, fieldDisplayName) {
|
|
1068
|
-
var
|
|
1116
|
+
var _this6 = this;
|
|
1069
1117
|
var dependencies = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
1070
1118
|
if (typeof Page_Validators !== "undefined") {
|
|
1071
1119
|
var newValidator = document.createElement("span");
|
|
@@ -1084,7 +1132,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1084
1132
|
dependencies = Array.isArray(dependencies) ? dependencies : [dependencies];
|
|
1085
1133
|
dependencies.forEach(function (dep) {
|
|
1086
1134
|
dep.element.addEventListener("change", function () {
|
|
1087
|
-
return
|
|
1135
|
+
return _this6.setRequiredLevel(isRequired(_this6));
|
|
1088
1136
|
});
|
|
1089
1137
|
});
|
|
1090
1138
|
}
|
|
@@ -1100,15 +1148,15 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1100
1148
|
}, {
|
|
1101
1149
|
key: "onceLoaded",
|
|
1102
1150
|
value: function onceLoaded(callback) {
|
|
1103
|
-
var
|
|
1151
|
+
var _this7 = this;
|
|
1104
1152
|
if (this.isLoaded) {
|
|
1105
1153
|
callback(this);
|
|
1106
1154
|
} else {
|
|
1107
1155
|
var observer = new MutationObserver(function () {
|
|
1108
|
-
if (document.querySelector(
|
|
1156
|
+
if (document.querySelector(_this7.target)) {
|
|
1109
1157
|
observer.disconnect(); // Stop observing once loaded
|
|
1110
|
-
|
|
1111
|
-
callback(
|
|
1158
|
+
_this7.isLoaded = true;
|
|
1159
|
+
callback(_this7); // Call the provided callback
|
|
1112
1160
|
}
|
|
1113
1161
|
});
|
|
1114
1162
|
observer.observe(document.body, {
|
|
@@ -1159,8 +1207,8 @@ function _createDOMNodeReference() {
|
|
|
1159
1207
|
var value = target[prop];
|
|
1160
1208
|
if (typeof value === "function" && prop !== "onceLoaded") {
|
|
1161
1209
|
return function () {
|
|
1162
|
-
for (var
|
|
1163
|
-
args[
|
|
1210
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
1211
|
+
args[_key6] = arguments[_key6];
|
|
1164
1212
|
}
|
|
1165
1213
|
return target.onceLoaded(function () {
|
|
1166
1214
|
return value.apply(target, args);
|
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
|
|
@@ -78,27 +75,27 @@ class DOMNodeReference {
|
|
|
78
75
|
|
|
79
76
|
/**
|
|
80
77
|
* Prepends elements to the target
|
|
81
|
-
* @param {
|
|
78
|
+
* @param {HTMLElement[] | DOMNodeReference[]} nodes - The elements to prepend to the HTML element
|
|
82
79
|
*/
|
|
83
|
-
prepend(...
|
|
80
|
+
prepend(...nodes: HTMLElement[] | DOMNodeReference[]): void;
|
|
84
81
|
|
|
85
82
|
/**
|
|
86
83
|
* Appends child elements to the HTML element.
|
|
87
|
-
* @param {
|
|
84
|
+
* @param {HTMLElement[] | DOMNodeReference[]} nodes - The elements to append to the HTML element.
|
|
88
85
|
*/
|
|
89
|
-
append(...
|
|
86
|
+
append(...nodes: HTMLElement[] | DOMNodeReference[]): void;
|
|
90
87
|
|
|
91
88
|
/**
|
|
92
89
|
* Inserts elements before the HTML element.
|
|
93
|
-
* @param {
|
|
90
|
+
* @param {HTMLElement[] | DOMNodeReference[]} nodes - The elements to insert before the HTML element.
|
|
94
91
|
*/
|
|
95
|
-
before(...
|
|
92
|
+
before(...nodes: HTMLElement[] | DOMNodeReference[]): void;
|
|
96
93
|
|
|
97
94
|
/**
|
|
98
95
|
* Inserts elements after the HTML element.
|
|
99
|
-
* @param {
|
|
96
|
+
* @param {HTMLElement[] | DOMNodeReference[]} nodes - The elements to insert after the HTML element.
|
|
100
97
|
*/
|
|
101
|
-
after(...
|
|
98
|
+
after(...nodes: HTMLElement[] | DOMNodeReference[]): void;
|
|
102
99
|
|
|
103
100
|
/**
|
|
104
101
|
* Retrieves the label associated with the HTML element.
|
|
@@ -127,18 +124,18 @@ class DOMNodeReference {
|
|
|
127
124
|
uncheckRadios(): void;
|
|
128
125
|
|
|
129
126
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* @param {(this: DOMNodeReference)
|
|
133
|
-
* @param {(this: DOMNodeReference)
|
|
134
|
-
* @param {string} fieldDisplayName -
|
|
135
|
-
* @param {Array<DOMNodeReference>} [dependencies]
|
|
127
|
+
* 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.
|
|
128
|
+
*
|
|
129
|
+
* @param {function(this: DOMNodeReference): boolean} isRequired - A function that determines whether the field should be required. Returns `true` if required, `false` otherwise.
|
|
130
|
+
* @param {function(this: DOMNodeReference): boolean} isValid - A function that checks if the field's input is valid. Returns `true` if valid, `false` otherwise.
|
|
131
|
+
* @param {string} fieldDisplayName - The name of the field, used in error messages if validation fails.
|
|
132
|
+
* @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.
|
|
136
133
|
*/
|
|
137
134
|
configureValidationAndRequirements(
|
|
138
135
|
isRequired: (this: this) => boolean,
|
|
139
136
|
isValid: (this: this) => boolean,
|
|
140
137
|
fieldDisplayName: string,
|
|
141
|
-
dependencies
|
|
138
|
+
dependencies: Array<DOMNodeReference>
|
|
142
139
|
): void;
|
|
143
140
|
|
|
144
141
|
/**
|
|
@@ -155,6 +152,12 @@ class DOMNodeReference {
|
|
|
155
152
|
*/
|
|
156
153
|
addLabelTooltip(text: string): void;
|
|
157
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Adds a tooltip with the specified text to the element
|
|
157
|
+
* @param {string} text - The text to display in the tooltip
|
|
158
|
+
*/
|
|
159
|
+
addTooltip(text: string): void;
|
|
160
|
+
|
|
158
161
|
/**
|
|
159
162
|
* Sets the inner HTML content of the HTML element.
|
|
160
163
|
* @param {string} text - The text to set as the inner HTML of the element.
|
|
@@ -172,16 +175,16 @@ class DOMNodeReference {
|
|
|
172
175
|
* Configures conditional rendering for the target element based on a condition
|
|
173
176
|
* and the visibility of one or more trigger elements.
|
|
174
177
|
*
|
|
175
|
-
* @param {
|
|
178
|
+
* @param {(this: DOMNodeReference) => boolean} condition - A function that returns a boolean to determine
|
|
176
179
|
* the visibility of the target element. If `condition()` returns true, the element is shown;
|
|
177
180
|
* otherwise, it is hidden.
|
|
178
|
-
* @param {DOMNodeReference
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
+
* @param {Array<DOMNodeReference>} dependencies - An array of `DOMNodeReference` instances. Event listeners are
|
|
182
|
+
* registered on each to toggle the visibility of the target element based on the `condition` and the visibility of
|
|
183
|
+
* the target node.
|
|
181
184
|
*/
|
|
182
185
|
configureConditionalRendering(
|
|
183
|
-
condition: () => boolean,
|
|
184
|
-
|
|
186
|
+
condition: (this: DOMNodeReference) => boolean,
|
|
187
|
+
dependencies: DOMNodeReference[]
|
|
185
188
|
): void;
|
|
186
189
|
|
|
187
190
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powerpagestoolkit",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2041",
|
|
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",
|