powerpagestoolkit 1.2.202 → 1.3.2

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.
Files changed (4) hide show
  1. package/README.md +275 -1
  2. package/dist/index.bundle.js +444 -334
  3. package/index.d.ts +272 -181
  4. package/package.json +61 -40
package/index.d.ts CHANGED
@@ -1,182 +1,273 @@
1
- declare module "powerpagestoolkit" {
2
- /**
3
- * Class representing a reference to a DOM node.
4
- */
5
- class DOMNodeReference {
6
- /**
7
- * Creates an instance of DOMNodeReference.
8
- * @param {string} querySelector - The CSS selector to find the desired DOM element.
9
- */
10
- constructor(querySelector: string);
11
-
12
- element: HTMLElement | null;
13
- isLoaded: boolean;
14
-
15
- /**
16
- * Initializes the DOMNodeReference instance by waiting for the element to be available in the DOM.
17
- * @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the DOMNodeReference instance.
18
- * @throws {Error} Throws an error if the element cannot be found using the provided query selector.
19
- */
20
- private init(): Promise<this>;
21
-
22
- /**
23
- * Hides the element by setting its display style to "none".
24
- */
25
- hide(): void;
26
-
27
- /**
28
- * Shows the element by restoring its default display style.
29
- */
30
- show(): void;
31
-
32
- /**
33
- * Hides the parent element by setting its display style to "none".
34
- */
35
- hideParent(): void;
36
-
37
- /**
38
- * Shows the parent element by restoring its default display style.
39
- */
40
- showParent(): void;
41
-
42
- /**
43
- * Hides the container (grandparent of the element) by setting its display style to "none".
44
- */
45
- hideContainer(): void;
46
-
47
- /**
48
- * Shows the container (grandparent of the element) by restoring its default display style.
49
- */
50
- showContainer(): void;
51
-
52
- /**
53
- * Sets the value of the HTML element.
54
- * @param {string} value - The value to set for the HTML element.
55
- */
56
- setValue(value: string): void;
57
-
58
- /**
59
- * Gets the value of the HTML element.
60
- * @returns {string} The current value of the HTML element.
61
- */
62
- getValue(): string;
63
-
64
- /**
65
- * Appends child elements to the HTML element.
66
- * @param {...HTMLElement} elements - The elements to append to the HTML element.
67
- */
68
- append(...elements: HTMLElement[]): void;
69
-
70
- /**
71
- * Inserts elements after the HTML element.
72
- * @param {...HTMLElement} elements - The elements to insert after the HTML element.
73
- */
74
- after(...elements: HTMLElement[]): void;
75
-
76
- /**
77
- * Retrieves the label associated with the HTML element.
78
- * @returns {HTMLElement} The label element associated with this element.
79
- * @throws {Error} Throws an error if the label cannot be found.
80
- */
81
- getLabel(): HTMLElement;
82
-
83
- /**
84
- * Appends child elements to the label associated with the HTML element.
85
- * @param {...HTMLElement} elements - The elements to append to the label.
86
- */
87
- appendToLabel(...elements: HTMLElement[]): void;
88
-
89
- /**
90
- * Adds a click event listener to the HTML element.
91
- * @param {Function} eventHandler - The function to execute when the element is clicked.
92
- */
93
- addClickListener(eventHandler: () => void): void;
94
-
95
- /**
96
- * Adds a change event listener to the HTML element.
97
- * @param {Function} eventHandler - The function to execute when the element's value changes.
98
- */
99
- addChangeListener(eventHandler: () => void): void;
100
-
101
- /**
102
- * Unchecks both the yes and no radio buttons if they exist.
103
- */
104
- uncheckRadios(): void;
105
-
106
- /**
107
- * Creates a validation instance for the field.
108
- * @param {Function} evaluationFunction - The function used to evaluate the field.
109
- * @param {string} fieldDisplayName - The field name to display in error if validation fails.
110
- */
111
- createValidation(
112
- evaluationFunction: (value: any) => boolean,
113
- fieldDisplayName: string
114
- ): void;
115
-
116
- /**
117
- * Adds a tooltip with specified text to the label associated with the HTML element.
118
- * @param {string} text - The text to display in the tooltip.
119
- */
120
- addLabelTooltip(text: string): void;
121
-
122
- /**
123
- * Sets the inner HTML content of the HTML element.
124
- * @param {string} text - The text to set as the inner HTML of the element.
125
- */
126
- setTextContent(text: string): void;
127
-
128
- /**
129
- * Executes a callback function once the element is fully loaded.
130
- * If the element is already loaded, the callback is called immediately.
131
- * Otherwise, a MutationObserver is used to detect when the element is added to the DOM.
132
- * @param {Function} callback - A callback function to execute once the element is loaded.
133
- */
134
- onceLoaded(callback: (instance: this) => void): void;
135
- }
136
-
137
- /**
138
- * Creates and initializes a DOMNodeReference instance.
139
- * @async
140
- * @function createDOMNodeReference
141
- * @param {string} querySelector - The CSS selector for the desired DOM element.
142
- * @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
143
- */
144
- export async function createDOMNodeReference(
145
- querySelector: string
146
- ): Promise<DOMNodeReference>;
147
-
148
- interface Schema {
149
- logicalName(): string;
150
- value(): any; // Adjust this type based on the structure of your schema values
151
- }
152
-
153
- export const API: {
154
- /**
155
- * Creates a new record in DataVerse.
156
- * @param schema An instance of a schema class, containing the desired information for the POST request.
157
- * @returns A Promise resolving the successful results (record ID) of the POST request, or rejecting with the error.
158
- */
159
- createRecord(schema: Schema): Promise<string>;
160
-
161
- /**
162
- * Retrieves a single record from DataVerse.
163
- * @param tableSetName The DataVerse SET name of the table being queried.
164
- * @param recordID The GUID of the record to be retrieved.
165
- * @param selectColumns *OPTIONAL* Custom OData query for advanced GET results. Format: select=column1,column2,column3...
166
- * @returns A Promise resolving the successful results of the GET request, or rejecting with the error.
167
- */
168
- getRecord(
169
- tableSetName: string,
170
- recordID: string,
171
- selectColumns?: string
172
- ): Promise<any>; // Adjust return type as necessary
173
-
174
- /**
175
- * Retrieves multiple records from DataVerse.
176
- * @param tableSetName The DataVerse SET name of the table being queried.
177
- * @param queryParameters *OPTIONAL* OData query parameters for refining search results: format = $filter=filters&$select=columns
178
- * @returns A Promise resolving the successful results of the GET request, or rejecting with the error.
179
- */
180
- getMultiple(tableSetName: string, queryParameters?: string): Promise<any>; // Adjust return type as necessary
181
- };
1
+ /**
2
+ * Class representing a reference to a DOM node.
3
+ */
4
+ class DOMNodeReference {
5
+ /**
6
+ * Creates an instance of DOMNodeReference.
7
+ * @param {string} querySelector - The CSS selector to find the desired DOM element.
8
+ */
9
+ constructor(target: string): DOMNodeReference;
10
+
11
+ target: string;
12
+ /**
13
+ * The element targeted when instantiating DOMNodeReference.
14
+ * Made available in order to perform normal DOM traversal,
15
+ * or access properties not available through this class.
16
+ * @type {HTMLElement | null}
17
+ */
18
+ element: HTMLElement | null;
19
+ isLoaded: boolean;
20
+ visibilityController: HTMLElement | null;
21
+ defaultDisplay: string;
22
+ /**
23
+ * The value of the element that this node represents
24
+ * stays in syncs with the live DOM elements via event handler
25
+ * @type {string | null}
26
+ */
27
+ value: string | null;
28
+ /**
29
+ * Represents the 'yes' option of a boolean radio field.
30
+ * This property is only available when the parent node
31
+ * is a main field for a boolean radio input.
32
+ * @type {DOMNodeReference | undefined}
33
+ */
34
+ yesRadio?: DOMNodeReference;
35
+
36
+ /**
37
+ * Represents the 'no' option of a boolean radio field.
38
+ * This property is only available when the parent node
39
+ * is a main field for a boolean radio input.
40
+ * @type {DOMNodeReference | undefined}
41
+ */
42
+ noRadio?: DOMNodeReference;
43
+
44
+ /**
45
+ * Initializes the DOMNodeReference instance by waiting for the element to be available in the DOM.
46
+ * @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the DOMNodeReference instance.
47
+ * @throws {Error} Throws an error if the element cannot be found using the provided query selector.
48
+ */
49
+ private init(): Promise<this>;
50
+
51
+ /**
52
+ * Hides the element by setting its display style to "none".
53
+ */
54
+ hide(): void;
55
+
56
+ /**
57
+ * Shows the element by restoring its default display style.
58
+ */
59
+ show(): void;
60
+
61
+ /**
62
+ * Sets the value of the HTML element.
63
+ * @param {() => any} value - The value to set for the HTML element.
64
+ * for parents of boolean radios, pass true or false as value, or
65
+ * an expression returning a boolean
66
+ */
67
+ setValue(value: string): void;
68
+
69
+ /**
70
+ * Disables the element so that users cannot input any data
71
+ */
72
+ disable(): void;
73
+
74
+ /**
75
+ * Enables the element so that users can input data
76
+ */
77
+ enable(): void;
78
+
79
+ /**
80
+ * Prepends elements to the target
81
+ * @param {...HTMLElement} elements - The elements to prepend to the HTML element
82
+ */
83
+ prepend(...elements: HTMLElement[]): void;
84
+
85
+ /**
86
+ * Appends child elements to the HTML element.
87
+ * @param {...HTMLElement} elements - The elements to append to the HTML element.
88
+ */
89
+ append(...elements: HTMLElement[]): void;
90
+
91
+ /**
92
+ * Inserts elements before the HTML element.
93
+ * @param {...HTMLElement} elements - The elements to insert before the HTML element.
94
+ */
95
+ before(...elements: HTMLElement[]): void;
96
+
97
+ /**
98
+ * Inserts elements after the HTML element.
99
+ * @param {...HTMLElement} elements - The elements to insert after the HTML element.
100
+ */
101
+ after(...elements: HTMLElement[]): void;
102
+
103
+ /**
104
+ * Retrieves the label associated with the HTML element.
105
+ * @returns {HTMLElement} The label element associated with this element.
106
+ * @throws {Error} Throws an error if the label cannot be found.
107
+ */
108
+ getLabel(): HTMLElement;
109
+
110
+ /**
111
+ * Appends child elements to the label associated with the HTML element.
112
+ * @param {...HTMLElement} elements - The elements to append to the label.
113
+ */
114
+ appendToLabel(...elements: HTMLElement[]): void;
115
+
116
+ /**
117
+ * Sets up an event listener based on the specified event type, executing the specified
118
+ * event handler
119
+ * @param {string} eventType - The DOM event to watch for
120
+ * @param {(this: DOMNodeReference, e: Event) => void} eventHandler - The callback function that runs when the
121
+ * specified event occurs
122
+ */
123
+ on(eventType: string, eventHandler: (event: Event) => void): void;
124
+ /**
125
+ * Unchecks both the yes and no radio buttons if they exist.
126
+ */
127
+ uncheckRadios(): void;
128
+
129
+ /**
130
+ * 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.
131
+ *
132
+ * @param {function(this: DOMNodeReference): boolean} isRequired - A function that determines whether the field should be required. Returns `true` if required, `false` otherwise.
133
+ * @param {function(this: DOMNodeReference): boolean} isValid - A function that checks if the field's input is valid. Returns `true` if valid, `false` otherwise.
134
+ * @param {string} fieldDisplayName - The name of the field, used in error messages if validation fails.
135
+ * @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
+ */
137
+ configureValidationAndRequirements(
138
+ isRequired: (this: this) => boolean,
139
+ isValid: (this: this) => boolean,
140
+ fieldDisplayName: string,
141
+ dependencies: Array<DOMNodeReference>
142
+ ): void;
143
+
144
+ /**
145
+ * Sets the required level for the field by adding or removing the "required-field" class on the label.
146
+ *
147
+ * @param {boolean} isRequired - Determines whether the field should be marked as required.
148
+ * If true, the "required-field" class is added to the label; if false, it is removed.
149
+ */
150
+ setRequiredLevel(isRequired: boolean): void;
151
+
152
+ /**
153
+ * Adds a tooltip with specified text to the label associated with the HTML element.
154
+ * @param {string} text - The text to display in the tooltip.
155
+ */
156
+ addLabelTooltip(text: string): void;
157
+
158
+ /**
159
+ * Adds a tooltip with the specified text to the element
160
+ * @param {string} text - The text to display in the tooltip
161
+ */
162
+ addTooltip(text: string): void;
163
+
164
+ /**
165
+ * Sets the inner HTML content of the HTML element.
166
+ * @param {string} text - The text to set as the inner HTML of the element.
167
+ */
168
+ setTextContent(text: string): void;
169
+
170
+ /**
171
+ *
172
+ * @param {boolean} shouldShow shows or hides the target
173
+ * if = true => show, if = false => hide
174
+ */
175
+ toggleVisibility(shouldShow: boolean): void;
176
+
177
+ /**
178
+ * Configures conditional rendering for the target element based on a condition
179
+ * and the visibility of one or more trigger elements.
180
+ *
181
+ * @param {(this: DOMNodeReference) => boolean} condition - A function that returns a boolean to determine
182
+ * the visibility of the target element. If `condition()` returns true, the element is shown;
183
+ * otherwise, it is hidden.
184
+ * @param {DOMNodeReference[]} triggerNodes - An array of `DOMNodeReference` instances. Event listeners are
185
+ * registered on each to toggle the visibility of the target element based on the `condition` and the visibility of
186
+ * the target node.
187
+ */
188
+ configureConditionalRendering(
189
+ condition: (this: DOMNodeReference) => boolean,
190
+ triggerNodes: DOMNodeReference[]
191
+ ): void;
192
+
193
+ /**
194
+ * Executes a callback function once the element is fully loaded.
195
+ * If the element is already loaded, the callback is called immediately.
196
+ * Otherwise, a MutationObserver is used to detect when the element is added to the DOM.
197
+ * @param {Function} callback - A callback function to execute once the element is loaded.
198
+ */
199
+ onceLoaded(callback: (instance: this) => void): void;
200
+ }
201
+
202
+ /**
203
+ * Creates and initializes a DOMNodeReference instance.
204
+ * @async
205
+ * @function createDOMNodeReference
206
+ * @param {string} target - The CSS selector for the desired DOM element.
207
+ * @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
208
+ */
209
+ export declare async function createDOMNodeReference(
210
+ querySelector: string | HTMLElement
211
+ ): Promise<DOMNodeReference>;
212
+
213
+ /**
214
+ * Interface representing an array of DOMNodeReference instances with additional methods.
215
+ */
216
+ export interface DOMNodeReferenceArray extends Array<DOMNodeReference> {
217
+ /**
218
+ * Hides all the containers of the DOMNodeReference instances in the array.
219
+ */
220
+ hideAll(): void;
221
+
222
+ /**
223
+ * Shows all the containers of the DOMNodeReference instances in the array.
224
+ */
225
+ showAll(): void;
182
226
  }
227
+
228
+ /**
229
+ * Creates and initializes multiple DOMNodeReference instances.
230
+ * @function createMultipleDOMNodeReferences
231
+ * @param {string} querySelector - The CSS selector for the desired DOM elements.
232
+ * @returns {Promise<DOMNodeReferenceArray>}
233
+ * A promise that resolves to an array of Proxies of initialized
234
+ * DOMNodeReference instances.
235
+ */
236
+ export declare async function createMultipleDOMNodeReferences(
237
+ querySelector: string
238
+ ): Promise<DOMNodeReferenceArray>;
239
+
240
+ interface Schema {
241
+ logicalName(): string;
242
+ value(): any; // Adjust this type based on the structure of your schema values
243
+ }
244
+
245
+ export declare const API: {
246
+ /**
247
+ * Creates a new record in DataVerse.
248
+ * @param schema An instance of a schema class, containing the desired information for the POST request.
249
+ * @returns A Promise resolving the successful results (record ID) of the POST request, or rejecting with the error.
250
+ */
251
+ createRecord(schema: Schema): Promise<string>;
252
+
253
+ /**
254
+ * Retrieves a single record from DataVerse.
255
+ * @param tableSetName The DataVerse SET name of the table being queried.
256
+ * @param recordID The GUID of the record to be retrieved.
257
+ * @param selectColumns *OPTIONAL* Custom OData query for advanced GET results. Format: select=column1,column2,column3...
258
+ * @returns A Promise resolving the successful results of the GET request, or rejecting with the error.
259
+ */
260
+ getRecord(
261
+ tableSetName: string,
262
+ recordID: string,
263
+ selectColumns?: string
264
+ ): Promise<any>; // Adjust return type as necessary
265
+
266
+ /**
267
+ * Retrieves multiple records from DataVerse.
268
+ * @param tableSetName The DataVerse SET name of the table being queried.
269
+ * @param queryParameters *OPTIONAL* OData query parameters for refining search results: format = $filter=filters&$select=columns
270
+ * @returns A Promise resolving the successful results of the GET request, or rejecting with the error.
271
+ */
272
+ getMultiple(tableSetName: string, queryParameters?: string): Promise<any>; // Adjust return type as necessary
273
+ };
package/package.json CHANGED
@@ -1,40 +1,61 @@
1
- {
2
- "name": "powerpagestoolkit",
3
- "version": "1.2.202",
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
- "main": "./dist/index.bundle.js",
6
- "types": "index.d.ts",
7
- "scripts": {
8
- "build": "webpack"
9
- },
10
- "devDependencies": {
11
- "@babel/core": "^7.25.8",
12
- "@babel/node": "^7.26.0",
13
- "@babel/preset-env": "^7.25.8",
14
- "@types/node": "^22.8.0",
15
- "babel-loader": "^9.2.1",
16
- "clean-webpack-plugin": "^4.0.0",
17
- "css-loader": "^7.1.2",
18
- "eslint": "^8.57.1",
19
- "rimraf": "^6.0.1",
20
- "style-loader": "^4.0.0",
21
- "terser-webpack-plugin": "^5.3.4",
22
- "typescript": "^5.6.3",
23
- "webpack": "^5.95.0",
24
- "webpack-cli": "^5.1.4"
25
- },
26
- "author": "KeatonBrewster",
27
- "license": "SSPL-1.0",
28
- "type": "module",
29
- "repository": {
30
- "type": "git",
31
- "url": "https://github.com/Keaton-Brewster/PowerPagesToolKit"
32
- },
33
- "files": [
34
- "dist",
35
- "index.d.ts"
36
- ],
37
- "exports": {
38
- ".": "./dist/index.bundle.js"
39
- }
40
- }
1
+ {
2
+ "name": "powerpagestoolkit",
3
+ "version": "1.3.2",
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
+ "main": "./dist/index.bundle.js",
6
+ "types": "index.d.ts",
7
+ "scripts": {
8
+ "build": "webpack",
9
+ "lint": "eslint ./src/JS/*"
10
+ },
11
+ "devDependencies": {
12
+ "@babel/core": "^7.25.8",
13
+ "@babel/node": "^7.26.0",
14
+ "@babel/preset-env": "^7.25.8",
15
+ "@types/node": "^22.8.0",
16
+ "babel-loader": "^9.2.1",
17
+ "clean-webpack-plugin": "^4.0.0",
18
+ "css-loader": "^7.1.2",
19
+ "eslint": "^8.57.1",
20
+ "eslint-plugin-import": "^2.31.0",
21
+ "style-loader": "^4.0.0",
22
+ "terser-webpack-plugin": "^5.3.4",
23
+ "typescript": "^5.6.3",
24
+ "webpack": "^5.95.0",
25
+ "webpack-cli": "^5.1.4"
26
+ },
27
+ "author": "KeatonBrewster",
28
+ "license": "SSPL-1.0",
29
+ "type": "module",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/Keaton-Brewster/PowerPagesToolKit"
33
+ },
34
+ "keywords": [
35
+ "powerpages",
36
+ "power pages",
37
+ "power platform",
38
+ "dynamics 365",
39
+ "power apps portal",
40
+ "dynamics 365 portal",
41
+ "portal",
42
+ "portal management",
43
+ "api",
44
+ "javascript",
45
+ "ajax",
46
+ "dataverse",
47
+ "dom-manipulation",
48
+ "node",
49
+ "http-request",
50
+ "json",
51
+ "rest-api",
52
+ "ajax-wrapper",
53
+ "form-management",
54
+ "frontend",
55
+ "web-development"
56
+ ],
57
+ "files": [
58
+ "dist",
59
+ "index.d.ts"
60
+ ]
61
+ }