powerpagestoolkit 1.3.3001 → 2.0.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.
package/README.md CHANGED
@@ -67,7 +67,7 @@ yesRadio: DOMNodeReference;
67
67
  noRadio: DOMNodeReference;
68
68
  // and if 'this' is the instance of a yesRadio or noRadio
69
69
  // checked will represent wether the radio has been checked or not
70
- checked: boolean
70
+ checked: boolean;
71
71
  ```
72
72
 
73
73
  ##### Methods
@@ -200,6 +200,9 @@ setValue(value: any)
200
200
  // Sets the inner HTML content of the associated HTML element.
201
201
  setTextContent(text: string)
202
202
 
203
+ // set any style attribute for 'this' with standard CSS style declaration
204
+ setStyle(options: Partial<CSSStyleDeclaration>): void;
205
+
203
206
  // Appends child elements to the associated HTML element.
204
207
  append(...elements: HTMLElement[])
205
208
 
@@ -0,0 +1,32 @@
1
+ declare const API: {
2
+ /**
3
+ *
4
+ * @param {Schema} schema an instance of a schema class, containing the desired information for the POST request
5
+ * @returns a Promise resolving the successful results *[record id]* of the POST request, or rejecting the failed results *[error]* of the POST request.
6
+ */
7
+ createRecord(schema: Schema): Promise<string>;
8
+ /**
9
+ *
10
+ * @param tableSetName The DataVerse SET name of the table being queried
11
+ * @param recordID the GUID of the records to be retrieved
12
+ * @param selectColumns *OPTIONAL* if desired, enter your own custom OData query for advanced GET results. Format = select=column1,column2,column3...
13
+ * @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
14
+ */
15
+ getRecord(tableSetName: string, recordID: string, selectColumns?: string): Promise<object>;
16
+ /**
17
+ *
18
+ * @param tableSetName The dataverse set name of the table being queried
19
+ * @param queryParameters *OPTIONAL* the OData query parameters for refining search results: *format = $filter=filters&$select=columns*
20
+ * @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
21
+ */
22
+ getMultiple(tableSetName: string, queryParameters?: string): Promise<Array<object>>;
23
+ /**
24
+ *
25
+ * @param tableSetName The dataverse set name for the table that you are updating a record in
26
+ * @param recordId The GUID of the record that is being updated
27
+ * @param data The JSON of the fields and data that are to be updated on the targeted record
28
+ * @returns A Promise with the results of the API execution
29
+ */
30
+ updateRecord(tableSetName: string, recordId: string, data: object): Promise<any>;
31
+ };
32
+ export default API;
@@ -0,0 +1,196 @@
1
+ export declare const _init: unique symbol;
2
+ /******/ /******/ /******/ export default class DOMNodeReference {
3
+ target: HTMLElement | string;
4
+ private isLoaded;
5
+ private defaultDisplay;
6
+ /**
7
+ * The value of the element that this node represents
8
+ * stays in syncs with the live DOM elements?.,m via event handler
9
+ * @type {any}
10
+ */
11
+ value: any;
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
+ * @property {HTMLElement | null}
17
+ */
18
+ element: HTMLElement;
19
+ private visibilityController;
20
+ checked: boolean;
21
+ /**
22
+ * Represents the 'yes' option of a boolean radio field.
23
+ * This property is only available when the parent node
24
+ * is a main field for a boolean radio input.
25
+ * @property {DOMNodeReferenceProxy | null}
26
+ */
27
+ yesRadio?: DOMNodeReference | null;
28
+ /**
29
+ * Represents the 'no' 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
+ * @property {DOMNodeReferenceProxy | null}
33
+ */
34
+ noRadio?: DOMNodeReference | null;
35
+ /**
36
+ * Creates an instance of DOMNodeReference.
37
+ * @param {string} target - The CSS selector to find the desired DOM element.
38
+ */
39
+ /******/ /******/ constructor(target: HTMLElement | string);
40
+ [_init](): Promise<void>;
41
+ private _initValueSync;
42
+ updateValue(): void;
43
+ private _attachVisibilityController;
44
+ private _attachRadioButtons;
45
+ /**
46
+ * Sets up an event listener based on the specified event type, executing the specified
47
+ * event handler
48
+ * @param {string} eventType - The DOM event to watch for
49
+ * @param {(this: DOMNodeReference, e: Event) => void} eventHandler - The callback function that runs when the
50
+ * specified event occurs
51
+ * @returns - Instance of this
52
+ */
53
+ on(eventType: string, eventHandler: (e: Event) => void): DOMNodeReference;
54
+ /**
55
+ * Hides the element by setting its display style to "none".
56
+ * @returns - Instance of this
57
+ */
58
+ hide(): DOMNodeReference;
59
+ /**
60
+ * Shows the element by restoring its default display style.
61
+ * @returns - Instance of this
62
+ */
63
+ show(): DOMNodeReference;
64
+ /**
65
+ *
66
+ * @param {function(this: DOMNodeReference): boolean | boolean} shouldShow - Either a function that returns true or false,
67
+ * or a natural boolean to determine the visibility of this
68
+ * @returns - Instance of this
69
+ */
70
+ toggleVisibility(shouldShow: Function | boolean): DOMNodeReference;
71
+ /**
72
+ * Sets the value of the HTML element.
73
+ * @param {() => any} value - The value to set for the HTML element.
74
+ * for parents of boolean radios, pass true or false as value, or
75
+ * an expression returning a boolean
76
+ * @returns - Instance of this
77
+ */
78
+ setValue(value: any): DOMNodeReference;
79
+ /**
80
+ * Disables the element so that users cannot input any data
81
+ * @returns - Instance of this
82
+ */
83
+ disable(): DOMNodeReference;
84
+ /**
85
+ * Enables the element so that users can input data
86
+ * @returns - Instance of this
87
+ */
88
+ enable(): DOMNodeReference;
89
+ /**
90
+ *
91
+ * @param {...HTMLElement} elements - The elements to prepend to the element targeted by this.
92
+ * @returns - Instance of this
93
+ */
94
+ prepend(...elements: HTMLElement[]): DOMNodeReference;
95
+ /**
96
+ * Appends child elements to the HTML element.
97
+ * @param {...HTMLElement} elements - The elements to append to the element targeted by this.
98
+ * @returns - Instance of this
99
+ */
100
+ append(...elements: HTMLElement[]): DOMNodeReference;
101
+ /**
102
+ * Inserts elements before the HTML element.
103
+ * @param {...HTMLElement} elements - The elements to insert before the HTML element.
104
+ * @returns - Instance of this
105
+ */
106
+ before(...elements: HTMLElement[]): DOMNodeReference;
107
+ /**
108
+ * Inserts elements after the HTML element.
109
+ * @param {...HTMLElement} elements - The elements to insert after the HTML element.
110
+ * @returns - Instance of this
111
+ */
112
+ after(...elements: HTMLElement[]): DOMNodeReference;
113
+ /**
114
+ * Retrieves the label associated with the HTML element.
115
+ * @returns {HTMLElement} The label element associated with this element.
116
+ */
117
+ getLabel(): HTMLElement | null;
118
+ /**
119
+ * Appends child elements to the label associated with the HTML element.
120
+ * @param {...HTMLElement} elements - The elements to append to the label.
121
+ * @returns - Instance of this
122
+ */
123
+ appendToLabel(...elements: HTMLElement[]): DOMNodeReference;
124
+ /**
125
+ * Adds a tooltip with specified text to the label associated with the HTML element.
126
+ * @param {string} text - The text to display in the tooltip.
127
+ * @returns - Instance of this
128
+ */
129
+ addLabelTooltip(text: string): DOMNodeReference;
130
+ /**
131
+ * Adds a tooltip with the specified text to the element
132
+ * @param {string} text - The text to display in the tooltip
133
+ * @returns - Instance of this
134
+ */
135
+ addTooltip(text: string): DOMNodeReference;
136
+ /**
137
+ * Sets the inner HTML content of the HTML element.
138
+ * @param {string} string - The text to set as the inner HTML of the element.
139
+ * @returns - Instance of this
140
+ */
141
+ setInnerHTML(string: string): this;
142
+ /**
143
+ * Removes this element from the DOM
144
+ * @returns - Instance of this
145
+ */
146
+ remove(): this;
147
+ /**
148
+ *
149
+ * @param {Partial<CSSStyleDeclaration} options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}
150
+ * @returns - Instance of this
151
+ */
152
+ setStyle(options: Partial<CSSStyleDeclaration>): this;
153
+ /**
154
+ * Unchecks both the yes and no radio buttons if they exist.
155
+ * @returns - Instance of this
156
+ */
157
+ uncheckRadios(): DOMNodeReference;
158
+ /**
159
+ * Configures conditional rendering for the target element based on a condition
160
+ * and the visibility of one or more trigger elements.
161
+ *
162
+ * @param {(this: DOMNodeReference) => boolean} condition - A function that returns a boolean to determine
163
+ * the visibility of the target element. If `condition()` returns true, the element is shown;
164
+ * otherwise, it is hidden.
165
+ * @param {Array<DOMNodeReference>} [dependencies] - An array of `DOMNodeReference` instances. Event listeners are
166
+ * registered on each to toggle the visibility of the target element based on the `condition` and the visibility of
167
+ * the target node.
168
+ * @returns - Instance of this
169
+ */
170
+ configureConditionalRendering(condition: () => boolean, dependencies: Array<DOMNodeReference>): DOMNodeReference;
171
+ /**
172
+ * 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.
173
+ *
174
+ * @param {function(this: DOMNodeReference): boolean} isRequired - A function that determines whether the field should be required. Returns `true` if required, `false` otherwise.
175
+ * @param {function(this: DOMNodeReference): boolean} isValid - A function that checks if the field's input is valid. Returns `true` if valid, `false` otherwise.
176
+ * @param {string} fieldDisplayName - The name of the field, used in error messages if validation fails.
177
+ * @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.
178
+ * @returns - Instance of this
179
+ */
180
+ configureValidationAndRequirements(isRequired: (instance: DOMNodeReference) => boolean, isValid: (instance: DOMNodeReference) => boolean, fieldDisplayName: string, dependencies: Array<DOMNodeReference>): DOMNodeReference;
181
+ /**
182
+ * Sets the required level for the field by adding or removing the "required-field" class on the label.
183
+ *
184
+ * @param {boolean} isRequired - Determines whether the field should be marked as required.
185
+ * If true, the "required-field" class is added to the label; if false, it is removed.
186
+ * @returns - Instance of this
187
+ */
188
+ setRequiredLevel(isRequired: Function | boolean): DOMNodeReference;
189
+ /**
190
+ * Executes a callback function once the element is fully loaded.
191
+ * If the element is already loaded, the callback is called immediately.
192
+ * Otherwise, a MutationObserver is used to detect when the element is added to the DOM.
193
+ * @param {Function} callback - A callback function to execute once the element is loaded.
194
+ */
195
+ onceLoaded(callback: (instance: DOMNodeReference) => any): any;
196
+ }
@@ -0,0 +1,11 @@
1
+ import DOMNodeReference from "./DOMNodeReference.js";
2
+ import ListItem from "./ListItem.js";
3
+ export declare const _listInit: unique symbol;
4
+ /******/ /******/ /******/ export default class List extends DOMNodeReference {
5
+ /**
6
+ * @property an array of List Items contained within this list
7
+ */
8
+ listItems: ListItem[];
9
+ constructor(target: HTMLElement | string);
10
+ [_listInit](): Promise<void>;
11
+ }
@@ -0,0 +1,10 @@
1
+ import DOMNodeReference from "./DOMNodeReference.js";
2
+ /******/ /******/ /******/ export default class ListItem extends DOMNodeReference {
3
+ /**
4
+ * @property The First Column in this specific list item
5
+ */
6
+ firstColumn: HTMLElement;
7
+ constructor(target: HTMLElement | string);
8
+ removeTarget(): void;
9
+ setFirstRowLink(path: string): ListItem;
10
+ }
@@ -0,0 +1,15 @@
1
+ import DOMNodeReference from "./DOMNodeReference.js";
2
+ /**
3
+ * Creates and initializes a DOMNodeReference instance.
4
+ * @async
5
+ * @param {string | HTMLElement} target - The CSS selector for the desired DOM element, or, optionally, the element itself for which to create a DOMNodeReference.
6
+ * @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
7
+ */
8
+ export declare function createDOMNodeReference(target: HTMLElement | string): Promise<DOMNodeReference>;
9
+ /**
10
+ * Creates and initializes multiple DOMNodeReference instances.
11
+ * @async
12
+ * @param {string} querySelector - The CSS selector for the desired DOM elements.
13
+ * @returns {Promise<DOMNodeReference[]>} A promise that resolves to an array of Proxies of initialized DOMNodeReference instances.
14
+ */
15
+ export declare function createMultipleDOMNodeReferences(querySelector: string): Promise<DOMNodeReference[]>;
@@ -0,0 +1 @@
1
+ export default function CreateInfoEl(titleString: string): HTMLSpanElement;
@@ -0,0 +1,10 @@
1
+ import DOMNodeReference from "./DOMNodeReference.js";
2
+ export declare class DOMNodeInitializationError extends Error {
3
+ constructor(instance: DOMNodeReference, error: string);
4
+ }
5
+ export declare class DOMNodeNotFoundError extends Error {
6
+ constructor(instance: DOMNodeReference);
7
+ }
8
+ export declare class ConditionalRenderingError extends Error {
9
+ constructor(instance: DOMNodeReference, error: string);
10
+ }
@@ -0,0 +1,2 @@
1
+ import List from "./List.js";
2
+ export default function (): Promise<List>;
@@ -0,0 +1,4 @@
1
+ import API from "./API.js";
2
+ import { createDOMNodeReference, createMultipleDOMNodeReferences } from "./createDOMNodeReferences.js";
3
+ import "./style.css";
4
+ export { API, createDOMNodeReference, createMultipleDOMNodeReferences };
@@ -0,0 +1 @@
1
+ export default function safeAjax(ajaxOptions: any): any;
@@ -0,0 +1 @@
1
+ export default function waitFor(target: HTMLElement | string): Promise<HTMLElement>;