powerpagestoolkit 3.0.401 → 3.0.402
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 +36 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,10 +27,10 @@ A powerful class for managing DOM elements with automatic value synchronization
|
|
|
27
27
|
|
|
28
28
|
#### Basic Usage
|
|
29
29
|
|
|
30
|
-
PowerPagesElements are instantiated with the help of the following factory function: `
|
|
30
|
+
PowerPagesElements are instantiated with the help of the following factory function: `get`
|
|
31
31
|
|
|
32
32
|
```typescript
|
|
33
|
-
|
|
33
|
+
get(
|
|
34
34
|
target: HTMLElement | string,
|
|
35
35
|
options: {
|
|
36
36
|
multiple: (() => boolean) | boolean = false,
|
|
@@ -40,7 +40,7 @@ createRef(
|
|
|
40
40
|
): Promise<PowerPagesElement | PowerPagesElement[]>;
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
get takes two main arguments:
|
|
44
44
|
|
|
45
45
|
<table style="width: 100%; border-collapse: collapse;">
|
|
46
46
|
<thead>
|
|
@@ -79,17 +79,17 @@ createRef takes two main arguments:
|
|
|
79
79
|
Import the utility function for creating PowerPagesElement(s)
|
|
80
80
|
|
|
81
81
|
```typescript
|
|
82
|
-
import {
|
|
82
|
+
import { get } from "powerpagestoolkit";
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
Instantiate one, or multiple instances of a PowerPagesElement, and optionally configure advanced options
|
|
86
86
|
|
|
87
87
|
```javascript
|
|
88
88
|
// Create a single reference (i.e. 'querySelector')
|
|
89
|
-
const node = await
|
|
89
|
+
const node = await get("#myElement");
|
|
90
90
|
|
|
91
91
|
// Create multiple references (i.e. 'querySelectorAll')
|
|
92
|
-
const nodes = await
|
|
92
|
+
const nodes = await get(".my-class", { multiple: true });
|
|
93
93
|
|
|
94
94
|
/******************/
|
|
95
95
|
// ADVANCED OPTIONS
|
|
@@ -98,31 +98,31 @@ const nodes = await createRef(".my-class", { multiple: true });
|
|
|
98
98
|
|
|
99
99
|
// If the node you are targeting is not available at the initial execution
|
|
100
100
|
// of the script, set a timeout for 2 seconds
|
|
101
|
-
const node2 = await
|
|
101
|
+
const node2 = await get("#target", { timeoutMs: 2000 });
|
|
102
102
|
|
|
103
103
|
// need to target a node within a specific node? use that node as the root
|
|
104
104
|
const otherElement = document.getElementById("id");
|
|
105
|
-
const node3 = await
|
|
105
|
+
const node3 = await get("#target", { root: otherElement });
|
|
106
106
|
|
|
107
107
|
// implement all options:
|
|
108
|
-
const nodes2 = await
|
|
108
|
+
const nodes2 = await get("#target", {
|
|
109
109
|
multiple: true,
|
|
110
|
-
timeoutMs:4000,
|
|
110
|
+
timeoutMs: 4000,
|
|
111
111
|
root: otherElement,
|
|
112
112
|
});
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
#### Properties
|
|
116
116
|
|
|
117
|
-
| Property | Type
|
|
118
|
-
| -------- |
|
|
119
|
-
| element | HTMLElement
|
|
120
|
-
| value | any
|
|
121
|
-
| isLoaded | boolean
|
|
122
|
-
| target | HTMLElement \| string
|
|
123
|
-
| yesRadio |
|
|
124
|
-
| noRadio |
|
|
125
|
-
| checked | boolean
|
|
117
|
+
| Property | Type | Description |
|
|
118
|
+
| -------- | --------------------- | -------------------------------------------- |
|
|
119
|
+
| element | HTMLElement | The referenced DOM element |
|
|
120
|
+
| value | any | Current synchronized value of the element |
|
|
121
|
+
| isLoaded | boolean | Element load status |
|
|
122
|
+
| target | HTMLElement \| string | Original target selector or element |
|
|
123
|
+
| yesRadio | Radio \| null | Reference to 'yes' radio (for yes/no fields) |
|
|
124
|
+
| noRadio | Radio \| null | Reference to 'no' radio (for yes/no fields) |
|
|
125
|
+
| checked | boolean | Checkbox/radio checked state |
|
|
126
126
|
|
|
127
127
|
#### Key Methods
|
|
128
128
|
|
|
@@ -161,14 +161,14 @@ applyBusinessRule(
|
|
|
161
161
|
```typescript
|
|
162
162
|
interface BusinessRule {
|
|
163
163
|
setVisibility?: () => boolean;
|
|
164
|
-
setRequirements?: () =>
|
|
165
|
-
isRequired: () => boolean
|
|
166
|
-
isValid: () => boolean
|
|
167
|
-
}
|
|
168
|
-
setValue?: () =>
|
|
169
|
-
condition: () => boolean
|
|
170
|
-
value: () => any | any
|
|
171
|
-
}
|
|
164
|
+
setRequirements?: () => {
|
|
165
|
+
isRequired: () => boolean;
|
|
166
|
+
isValid: () => boolean;
|
|
167
|
+
};
|
|
168
|
+
setValue?: () => {
|
|
169
|
+
condition: () => boolean;
|
|
170
|
+
value: () => any | any;
|
|
171
|
+
};
|
|
172
172
|
setDisabled?: () => boolean;
|
|
173
173
|
}
|
|
174
174
|
```
|
|
@@ -180,10 +180,9 @@ interface BusinessRule {
|
|
|
180
180
|
// 'businessTypeField' is set to 'Corporation' or 'LLC'
|
|
181
181
|
taxIdField.applyBusinessRule(
|
|
182
182
|
{
|
|
183
|
-
setVisibility:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
businessTypeField.value === "LLC"
|
|
183
|
+
setVisibility: () =>
|
|
184
|
+
businessTypeField.value === "Corporation" ||
|
|
185
|
+
businessTypeField.value === "LLC",
|
|
187
186
|
},
|
|
188
187
|
[businessTypeField] // Re-evaluate when businessTypeField changes
|
|
189
188
|
);
|
|
@@ -205,7 +204,7 @@ taxIdField.applyBusinessRule(
|
|
|
205
204
|
isValid: function () {
|
|
206
205
|
return this.value != null && this.value !== "";
|
|
207
206
|
},
|
|
208
|
-
})
|
|
207
|
+
}),
|
|
209
208
|
},
|
|
210
209
|
[businessTypeField] // Revalidate when businessTypeField changes
|
|
211
210
|
);
|
|
@@ -219,8 +218,8 @@ industryField.applyBusinessRule(
|
|
|
219
218
|
{
|
|
220
219
|
setValue: () => ({
|
|
221
220
|
condition: () => businessTypeField.value === "Corporation",
|
|
222
|
-
value: "Corporate"
|
|
223
|
-
})
|
|
221
|
+
value: "Corporate",
|
|
222
|
+
}),
|
|
224
223
|
},
|
|
225
224
|
[businessTypeField] // Apply value when businessTypeField changes
|
|
226
225
|
);
|
|
@@ -308,9 +307,9 @@ node.addTooltip(
|
|
|
308
307
|
_Example:_
|
|
309
308
|
|
|
310
309
|
```typescript
|
|
311
|
-
import {
|
|
310
|
+
import { get } from "powerpagestoolkit";
|
|
312
311
|
|
|
313
|
-
const title = await
|
|
312
|
+
const title = await get("#myTitle");
|
|
314
313
|
|
|
315
314
|
title.addTooltip("This is an Example of a tooltip!", { color: "red" });
|
|
316
315
|
```
|
|
@@ -450,7 +449,7 @@ await API.updateRecord("contacts", "record-guid", {
|
|
|
450
449
|
1. Always await PowerPagesElement creation:
|
|
451
450
|
|
|
452
451
|
```typescript
|
|
453
|
-
const node = await
|
|
452
|
+
const node = await get("#element");
|
|
454
453
|
```
|
|
455
454
|
|
|
456
455
|
2. Include all referenced nodes in dependency arrays:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powerpagestoolkit",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.402",
|
|
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/src/index.js",
|
|
6
6
|
"module": "./dist/src/index.js",
|