powerpagestoolkit 1.2.2 → 1.3.0

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 +203 -1
  2. package/dist/index.bundle.js +206 -194032
  3. package/index.d.ts +205 -181
  4. package/package.json +5 -7
package/index.d.ts CHANGED
@@ -1,182 +1,206 @@
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
+ element: HTMLElement | null;
13
+ isLoaded: boolean;
14
+ visibilityController: HTMLElement | null;
15
+ defaultDisplay: string;
16
+ value: string | null;
17
+
18
+ /**
19
+ * Initializes the DOMNodeReference instance by waiting for the element to be available in the DOM.
20
+ * @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the DOMNodeReference instance.
21
+ * @throws {Error} Throws an error if the element cannot be found using the provided query selector.
22
+ */
23
+ private init(): Promise<this>;
24
+
25
+ /**
26
+ * Hides the element by setting its display style to "none".
27
+ */
28
+ hide(): void;
29
+
30
+ /**
31
+ * Shows the element by restoring its default display style.
32
+ */
33
+ show(): void;
34
+
35
+ /**
36
+ * Sets the value of the HTML element.
37
+ * @param {string} value - The value to set for the HTML element.
38
+ */
39
+ setValue(value: string): void;
40
+
41
+ /**
42
+ * Appends child elements to the HTML element.
43
+ * @param {...HTMLElement} elements - The elements to append to the HTML element.
44
+ */
45
+ append(...elements: HTMLElement[]): void;
46
+
47
+ /**
48
+ * Inserts elements after the HTML element.
49
+ * @param {...HTMLElement} elements - The elements to insert after the HTML element.
50
+ */
51
+ after(...elements: HTMLElement[]): void;
52
+
53
+ /**
54
+ * Retrieves the label associated with the HTML element.
55
+ * @returns {HTMLElement} The label element associated with this element, or **null** if no label element is present
56
+ */
57
+ getLabel(): HTMLElement | null;
58
+
59
+ /**
60
+ * Appends child elements to the label associated with the HTML element.
61
+ * @param {...HTMLElement} elements - The elements to append to the label.
62
+ */
63
+ appendToLabel(...elements: HTMLElement[]): void;
64
+
65
+ /**
66
+ * Adds a click event listener to the HTML element.
67
+ * @param {Function} eventHandler - The function to execute when the element is clicked.
68
+ */
69
+ addClickListener(eventHandler: () => void): void;
70
+
71
+ /**
72
+ * Adds a change event listener to the HTML element.
73
+ * @param {Function} eventHandler - The function to execute when the element's value changes.
74
+ */
75
+ addChangeListener(eventHandler: () => void): void;
76
+
77
+ /**
78
+ * Unchecks both the yes and no radio buttons if they exist.
79
+ */
80
+ uncheckRadios(): void;
81
+
82
+ /**
83
+ * Creates a validation instance for the field.
84
+ * @param {Function} evaluationFunction - The function used to evaluate the field.
85
+ * @param {string} fieldDisplayName - The field name to display in error if validation
86
+ * fails.
87
+ */
88
+ createValidation(
89
+ evaluationFunction: (value: any) => boolean,
90
+ fieldDisplayName: string
91
+ ): void;
92
+
93
+ /**
94
+ * Adds a tooltip with specified text to the label associated with the HTML element.
95
+ * @param {string} text - The text to display in the tooltip.
96
+ */
97
+ addLabelTooltip(text: string): void;
98
+
99
+ /**
100
+ * Sets the inner HTML content of the HTML element.
101
+ * @param {string} text - The text to set as the inner HTML of the element.
102
+ */
103
+ setTextContent(text: string): void;
104
+
105
+ /**
106
+ *
107
+ * @param {boolean} shouldShow shows or hides the target
108
+ * if = true => show, if = false => hide
109
+ */
110
+ toggleVisibility(shouldShow: boolean): void;
111
+
112
+ /**
113
+ *
114
+ * @param {Function} condition A Function that return a boolean value to set the
115
+ * visibility of the targeted element. if condition() returns true, element is shown.
116
+ * If false, element is hidden
117
+ * @param {DOMNodeReference} triggerNode The DOMNodeReference to which an
118
+ * event listener will be registered to change the visibility state of the calling
119
+ * DOMNodeReference
120
+ */
121
+ configureConditionalRendering(
122
+ condition: () => boolean,
123
+ triggerNode: DOMNodeReference
124
+ ): void;
125
+
126
+ /**
127
+ * Executes a callback function once the element is fully loaded.
128
+ * If the element is already loaded, the callback is called immediately.
129
+ * Otherwise, a MutationObserver is used to detect when the element is added to the DOM.
130
+ * @param {Function} callback - A callback function to execute once the element is loaded.
131
+ */
132
+ onceLoaded(callback: (instance: this) => void): void;
182
133
  }
134
+
135
+ /**
136
+ * Creates and initializes a DOMNodeReference instance.
137
+ * @async
138
+ * @function createDOMNodeReference
139
+ * @param {string} target - The CSS selector for the desired DOM element.
140
+ * @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
141
+ */
142
+ export declare async function createDOMNodeReference(
143
+ querySelector: string | HTMLElement
144
+ ): Promise<DOMNodeReference>;
145
+
146
+ /**
147
+ * Interface representing an array of DOMNodeReference instances with additional methods.
148
+ */
149
+ export interface DOMNodeReferenceArray extends Array<DOMNodeReference> {
150
+ /**
151
+ * Hides all the containers of the DOMNodeReference instances in the array.
152
+ */
153
+ hideAll(): void;
154
+
155
+ /**
156
+ * Shows all the containers of the DOMNodeReference instances in the array.
157
+ */
158
+ showAll(): void;
159
+ }
160
+
161
+ /**
162
+ * Creates and initializes multiple DOMNodeReference instances.
163
+ * @function createMultipleDOMNodeReferences
164
+ * @param {string} querySelector - The CSS selector for the desired DOM elements.
165
+ * @returns {Promise<DOMNodeReferenceArray>}
166
+ * A promise that resolves to an array of Proxies of initialized
167
+ * DOMNodeReference instances.
168
+ */
169
+ export declare async function createMultipleDOMNodeReferences(
170
+ querySelector: string
171
+ ): Promise<DOMNodeReferenceArray>;
172
+
173
+ interface Schema {
174
+ logicalName(): string;
175
+ value(): any; // Adjust this type based on the structure of your schema values
176
+ }
177
+
178
+ export declare const API: {
179
+ /**
180
+ * Creates a new record in DataVerse.
181
+ * @param schema An instance of a schema class, containing the desired information for the POST request.
182
+ * @returns A Promise resolving the successful results (record ID) of the POST request, or rejecting with the error.
183
+ */
184
+ createRecord(schema: Schema): Promise<string>;
185
+
186
+ /**
187
+ * Retrieves a single record from DataVerse.
188
+ * @param tableSetName The DataVerse SET name of the table being queried.
189
+ * @param recordID The GUID of the record to be retrieved.
190
+ * @param selectColumns *OPTIONAL* Custom OData query for advanced GET results. Format: select=column1,column2,column3...
191
+ * @returns A Promise resolving the successful results of the GET request, or rejecting with the error.
192
+ */
193
+ getRecord(
194
+ tableSetName: string,
195
+ recordID: string,
196
+ selectColumns?: string
197
+ ): Promise<any>; // Adjust return type as necessary
198
+
199
+ /**
200
+ * Retrieves multiple records from DataVerse.
201
+ * @param tableSetName The DataVerse SET name of the table being queried.
202
+ * @param queryParameters *OPTIONAL* OData query parameters for refining search results: format = $filter=filters&$select=columns
203
+ * @returns A Promise resolving the successful results of the GET request, or rejecting with the error.
204
+ */
205
+ getMultiple(tableSetName: string, queryParameters?: string): Promise<any>; // Adjust return type as necessary
206
+ };
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "powerpagestoolkit",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
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",
7
7
  "scripts": {
8
- "build": "webpack"
8
+ "build": "webpack",
9
+ "lint": "eslint ./src/JS/*"
9
10
  },
10
11
  "devDependencies": {
11
12
  "@babel/core": "^7.25.8",
@@ -16,7 +17,7 @@
16
17
  "clean-webpack-plugin": "^4.0.0",
17
18
  "css-loader": "^7.1.2",
18
19
  "eslint": "^8.57.1",
19
- "rimraf": "^6.0.1",
20
+ "eslint-plugin-import": "^2.31.0",
20
21
  "style-loader": "^4.0.0",
21
22
  "terser-webpack-plugin": "^5.3.4",
22
23
  "typescript": "^5.6.3",
@@ -33,8 +34,5 @@
33
34
  "files": [
34
35
  "dist",
35
36
  "index.d.ts"
36
- ],
37
- "exports": {
38
- ".": "./dist/index.bundle.js"
39
- }
37
+ ]
40
38
  }