powerpagestoolkit 3.0.3 → 3.0.52
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 +44 -45
- package/dist/src/{core → ancillary}/DOMNodeReference.d.ts +31 -69
- package/dist/src/ancillary/EventManager.d.ts +25 -0
- package/dist/src/ancillary/InfoElement.d.ts +25 -0
- package/dist/src/ancillary/LoadingSpinner.d.ts +16 -0
- package/dist/src/ancillary/Radio.d.ts +11 -0
- package/dist/src/ancillary/ValueManager.d.ts +19 -0
- package/dist/src/ancillary/VisibilityManager.d.ts +12 -0
- package/dist/src/constants/EventTypes.d.ts +2 -2
- package/dist/src/core/API.d.ts +7 -3
- package/dist/src/core/PowerPagesElement.d.ts +53 -0
- package/dist/src/core/PowerPagesElementArray.d.ts +12 -0
- package/dist/src/core/bindForm.d.ts +7 -7
- package/dist/src/core/{createDOMNodeReferences.d.ts → getPowerPagesElement.d.ts} +14 -48
- package/dist/src/errors/errors.d.ts +32 -9
- package/dist/src/globals.d.ts +179 -155
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +4 -4
- package/dist/src/utils/InputMask.d.ts +11 -0
- package/dist/src/utils/MoneyMask.d.ts +36 -0
- package/dist/src/utils/PhoneNumberMask.d.ts +25 -0
- package/dist/src/utils/enhanceArray.d.ts +4 -4
- package/dist/src/utils/safeAjax.d.ts +1 -1
- package/package.json +8 -4
- package/dist/src/core/DOMNodeReferenceArray.d.ts +0 -12
- package/dist/src/managers/ReferenceManager.d.ts +0 -6
- package/dist/src/utils/createInfoElement.d.ts +0 -8
package/README.md
CHANGED
|
@@ -21,26 +21,26 @@ npm install powerpagestoolkit
|
|
|
21
21
|
|
|
22
22
|
# Core Modules
|
|
23
23
|
|
|
24
|
-
###
|
|
24
|
+
### PowerPagesElement
|
|
25
25
|
|
|
26
26
|
A powerful class for managing DOM elements with automatic value synchronization and event handling.
|
|
27
27
|
|
|
28
28
|
#### Basic Usage
|
|
29
29
|
|
|
30
|
-
|
|
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,
|
|
37
37
|
root: HTMLElement,
|
|
38
38
|
timeoutMs:number
|
|
39
39
|
}
|
|
40
|
-
): Promise<
|
|
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>
|
|
@@ -76,20 +76,20 @@ createRef takes two main arguments:
|
|
|
76
76
|
</tbody>
|
|
77
77
|
</table>
|
|
78
78
|
|
|
79
|
-
Import the utility function for creating
|
|
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
|
-
Instantiate one, or multiple instances of a
|
|
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
|
|
|
@@ -151,8 +151,8 @@ _Method Signature:_
|
|
|
151
151
|
```typescript
|
|
152
152
|
applyBusinessRule(
|
|
153
153
|
rule: BusinessRule,
|
|
154
|
-
dependencies:
|
|
155
|
-
):
|
|
154
|
+
dependencies: PowerPagesElement[]
|
|
155
|
+
): PowerPagesElement; /* Instance of this is returned for optional
|
|
156
156
|
method chaining */
|
|
157
157
|
```
|
|
158
158
|
|
|
@@ -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
|
```
|
|
@@ -370,7 +369,7 @@ bindForm("form-guid").then((form) => {
|
|
|
370
369
|
* @param formGuid Unique identifier for the form
|
|
371
370
|
* @returns Promise resolving to form element references
|
|
372
371
|
*/
|
|
373
|
-
function bindForm(formGuid: string): Promise<
|
|
372
|
+
function bindForm(formGuid: string): Promise<PowerPagesElementArray & Record<string: PowerPagesElement>>;
|
|
374
373
|
```
|
|
375
374
|
|
|
376
375
|
##### Benefits
|
|
@@ -447,10 +446,10 @@ await API.updateRecord("contacts", "record-guid", {
|
|
|
447
446
|
|
|
448
447
|
## Best Practices
|
|
449
448
|
|
|
450
|
-
1. Always await
|
|
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:
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/// <reference path="../globals.d.ts" />
|
|
2
|
-
|
|
2
|
+
import type EventManager from "../ancillary/EventManager.d.ts";
|
|
3
|
+
import type ValueManager from "../ancillary/ValueManager.d.ts";
|
|
4
|
+
import type VisibilityManager from "./VisibilityManager.d.ts";
|
|
5
|
+
export default abstract class DOMNodeReference {
|
|
3
6
|
static instances: DOMNodeReference[];
|
|
4
7
|
[key: symbol]: (...arg: any[]) => any;
|
|
5
8
|
target: Element | string;
|
|
@@ -7,38 +10,23 @@ export default class DOMNodeReference {
|
|
|
7
10
|
root: Element;
|
|
8
11
|
protected timeoutMs: number;
|
|
9
12
|
protected isLoaded: boolean;
|
|
10
|
-
protected defaultDisplay: string;
|
|
11
|
-
protected observers: Array<MutationObserver | ResizeObserver>;
|
|
12
|
-
protected boundListeners: Array<BoundEventListener>;
|
|
13
|
-
protected dependents: Dependents;
|
|
14
|
-
protected isRadio: boolean;
|
|
15
|
-
protected radioType: RadioType | null;
|
|
16
13
|
/**
|
|
17
14
|
* The value of the element that this node represents
|
|
18
15
|
* stays in syncs with the live DOM elements?.,m via event handler
|
|
19
16
|
*/
|
|
20
|
-
value: any;
|
|
17
|
+
get value(): any;
|
|
18
|
+
set value(newValue: any);
|
|
19
|
+
get checked(): boolean;
|
|
20
|
+
set defaultDisplay(newValue: string | null);
|
|
21
21
|
/**
|
|
22
22
|
* The element targeted when instantiating DOMNodeReference.
|
|
23
23
|
* Made available in order to perform normal DOM traversal,
|
|
24
24
|
* or access properties not available through this class.
|
|
25
25
|
*/
|
|
26
26
|
element: HTMLElement;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Represents the 'yes' option of a boolean radio field.
|
|
32
|
-
* This property is only available when the parent node
|
|
33
|
-
* is a main field for a boolean radio input.
|
|
34
|
-
*/
|
|
35
|
-
yesRadio: DOMNodeReference | null;
|
|
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
|
-
*/
|
|
41
|
-
noRadio: DOMNodeReference | null;
|
|
27
|
+
visibilityManager: VisibilityManager | null;
|
|
28
|
+
valueManager: ValueManager | null;
|
|
29
|
+
eventManager: EventManager | null;
|
|
42
30
|
/**
|
|
43
31
|
* Creates an instance of DOMNodeReference.
|
|
44
32
|
* @param target - The CSS selector to find the desired DOM element.
|
|
@@ -46,25 +34,15 @@ export default class DOMNodeReference {
|
|
|
46
34
|
* Defaults to 'document.body'
|
|
47
35
|
*/
|
|
48
36
|
/******/ /******/ constructor(target: Element | string, root: Element | undefined, timeoutMs: number);
|
|
37
|
+
protected abstract initValueManager(): void;
|
|
38
|
+
protected abstract initVisibilityManager(): void;
|
|
39
|
+
protected abstract initEventManager(): void;
|
|
49
40
|
protected _extractLogicalName(target: Element | string): string;
|
|
50
|
-
/**
|
|
51
|
-
* Initializes value synchronization with appropriate event listeners
|
|
52
|
-
* based on element type.
|
|
53
|
-
*/
|
|
54
41
|
protected _valueSync(): void;
|
|
55
|
-
protected _determineEventType(): keyof
|
|
42
|
+
protected _determineEventType(): keyof GlobalEventHandlersEventMap;
|
|
56
43
|
protected _isDateInput(): boolean;
|
|
57
44
|
protected _isValidFormElement(element: Element): element is FormElement;
|
|
58
|
-
protected _registerEventListener(element: Element, eventType: keyof HTMLElementEventMap, handler: (e: Event) => unknown): void;
|
|
59
45
|
protected _dateSync(element: HTMLInputElement): Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* Gets the current value of the element based on its type
|
|
62
|
-
* @protected
|
|
63
|
-
* @returns Object containing value and optional checked state
|
|
64
|
-
*/
|
|
65
|
-
protected _getElementValue(): Promise<ElementValue>;
|
|
66
|
-
protected _attachVisibilityController(): void;
|
|
67
|
-
protected _attachRadioButtons(): Promise<void>;
|
|
68
46
|
protected _bindMethods(): void;
|
|
69
47
|
/**
|
|
70
48
|
* Updates the value and checked state based on element type
|
|
@@ -72,7 +50,6 @@ export default class DOMNodeReference {
|
|
|
72
50
|
*/
|
|
73
51
|
updateValue(e?: Event): Promise<void>;
|
|
74
52
|
protected triggerDependentsHandlers(): void;
|
|
75
|
-
protected _validateValue(value: any): any;
|
|
76
53
|
/**
|
|
77
54
|
* Sets up an event listener based on the specified event type, executing the specified
|
|
78
55
|
* event handler
|
|
@@ -81,7 +58,7 @@ export default class DOMNodeReference {
|
|
|
81
58
|
* specified event occurs.
|
|
82
59
|
* @returns - Instance of this [provides option to method chain]
|
|
83
60
|
*/
|
|
84
|
-
on(eventType:
|
|
61
|
+
on<K extends keyof GlobalEventHandlersEventMap>(eventType: K, eventHandler: (this: DOMNodeReference, e: GlobalEventHandlersEventMap[K]) => void): DOMNodeReference;
|
|
85
62
|
/**
|
|
86
63
|
* Hides the element by setting its display style to "none".
|
|
87
64
|
* @returns - Instance of this [provides option to method chain]
|
|
@@ -97,7 +74,7 @@ export default class DOMNodeReference {
|
|
|
97
74
|
* or a natural boolean to determine the visibility of this
|
|
98
75
|
* @returns - Instance of this [provides option to method chain]
|
|
99
76
|
*/
|
|
100
|
-
toggleVisibility(shouldShow:
|
|
77
|
+
toggleVisibility(shouldShow: EvaluationFunction | boolean): DOMNodeReference;
|
|
101
78
|
/**
|
|
102
79
|
* Sets the value of the HTML element.
|
|
103
80
|
* @param value - The value to set for the HTML element.
|
|
@@ -115,13 +92,10 @@ export default class DOMNodeReference {
|
|
|
115
92
|
* Clears all values and states of the element.
|
|
116
93
|
* Handles different input types appropriately, and can be called
|
|
117
94
|
* on an element containing N child inputs to clear all
|
|
118
|
-
*
|
|
119
|
-
* @returns - Instance of this [provides option to method chain]
|
|
120
|
-
* @throws If clearing values fails
|
|
121
95
|
*/
|
|
122
|
-
clearValue():
|
|
96
|
+
clearValue(): void;
|
|
123
97
|
protected _getChildren(): DOMNodeReference[] | null;
|
|
124
|
-
protected
|
|
98
|
+
protected callAgainstChildrenInputs(callback: (child: DOMNodeReference) => any): void;
|
|
125
99
|
/**
|
|
126
100
|
* Enables the element so that users can input data
|
|
127
101
|
* @returns - Instance of this [provides option to method chain]
|
|
@@ -174,22 +148,18 @@ export default class DOMNodeReference {
|
|
|
174
148
|
* @param string - The text to set as the inner HTML of the element.
|
|
175
149
|
* @returns - Instance of this [provides option to method chain]
|
|
176
150
|
*/
|
|
177
|
-
|
|
151
|
+
set innerHTML(innerHTML: string);
|
|
178
152
|
/**
|
|
179
153
|
* Removes this element from the DOM
|
|
180
154
|
* @returns - Instance of this [provides option to method chain]
|
|
181
155
|
*/
|
|
182
156
|
remove(): this;
|
|
183
157
|
/**
|
|
184
|
-
*
|
|
185
|
-
* @
|
|
186
|
-
|
|
187
|
-
setStyle(options: Partial<CSSStyleDeclaration>): this;
|
|
188
|
-
/**
|
|
189
|
-
* Unchecks both the yes and no radio buttons if they exist.
|
|
190
|
-
* @returns - Instance of this [provides option to method chain]
|
|
158
|
+
* Sets inline CSS styles on the element.
|
|
159
|
+
* @param options - An object containing CSS property-value pairs, e.g., { display: 'block' }.
|
|
160
|
+
* @returns The instance, enabling method chaining.
|
|
191
161
|
*/
|
|
192
|
-
|
|
162
|
+
setStyle(options: Partial<CSSStyleDeclaration>): DOMNodeReference;
|
|
193
163
|
/**
|
|
194
164
|
* Applies a business rule to manage visibility, required state, value, and disabled state dynamically.
|
|
195
165
|
* @see {@link BusinessRule}
|
|
@@ -197,19 +167,11 @@ export default class DOMNodeReference {
|
|
|
197
167
|
* @param dependencies For re-evaluation of conditions when the state of the dependencies change
|
|
198
168
|
* @returns Instance of this for method chaining.
|
|
199
169
|
*/
|
|
200
|
-
applyBusinessRule(rule: BusinessRule, dependencies: DOMNodeReference
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
* @protected
|
|
206
|
-
* @param handler The function to execute when dependencies change
|
|
207
|
-
* @param dependencies Array of dependent DOM nodes to track
|
|
208
|
-
* all other options defaults to true
|
|
209
|
-
*/
|
|
210
|
-
protected _configureDependencyTracking(handler: DependencyHandler, dependencies: DOMNodeReference[]): void;
|
|
211
|
-
protected _getVisibility(): boolean;
|
|
212
|
-
protected _receiveNotification(): void;
|
|
170
|
+
applyBusinessRule(rule: BusinessRule, dependencies: DependencyArray<DOMNodeReference>): DOMNodeReference;
|
|
171
|
+
private _setupRequirementsValidator;
|
|
172
|
+
private _createBusinessRuleHandler;
|
|
173
|
+
private _createValidator;
|
|
174
|
+
private _configureDependencyTracking;
|
|
213
175
|
/**
|
|
214
176
|
* Sets the required level for the field by adding or removing the "required-field" class on the label.
|
|
215
177
|
*
|
|
@@ -217,7 +179,7 @@ export default class DOMNodeReference {
|
|
|
217
179
|
* If true, the "required-field" class is added to the label; if false, it is removed.
|
|
218
180
|
* @returns Instance of this [provides option to method chain]
|
|
219
181
|
*/
|
|
220
|
-
setRequiredLevel(isRequired:
|
|
182
|
+
setRequiredLevel(isRequired: EvaluationFunction | boolean): DOMNodeReference;
|
|
221
183
|
/**
|
|
222
184
|
* Executes a callback function once the element is fully loaded.
|
|
223
185
|
* If the element is already loaded, the callback is called immediately.
|
|
@@ -225,5 +187,5 @@ export default class DOMNodeReference {
|
|
|
225
187
|
* @param callback A callback function to execute once the element is loaded.
|
|
226
188
|
* Receives instance of 'this' as an argument
|
|
227
189
|
*/
|
|
228
|
-
onceLoaded(callback: (instance: DOMNodeReference) => any):
|
|
190
|
+
onceLoaded(callback: (instance: DOMNodeReference) => any): void;
|
|
229
191
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
2
|
+
import type DOMNodeReference from "./DOMNodeReference.d.ts";
|
|
3
|
+
declare type EventType = string;
|
|
4
|
+
declare type Handler = (this: DOMNodeReference, ...args: any[]) => void;
|
|
5
|
+
/********/ /********/ export default class EventManager {
|
|
6
|
+
private readonly events;
|
|
7
|
+
private readonly listeners;
|
|
8
|
+
private readonly dependencyHandlers;
|
|
9
|
+
private observers;
|
|
10
|
+
private boundListeners;
|
|
11
|
+
constructor();
|
|
12
|
+
/********/ dispatchDependencyHandlers(): void;
|
|
13
|
+
/********/ registerDependent(dependency: DOMNodeReference, handler: Handler): "success" | Error;
|
|
14
|
+
/********/ registerEvent(event: EventType, handler: Handler): "success" | Error;
|
|
15
|
+
/********/ registerListener(event: EventType, listener: DOMNodeReference): "success" | Error;
|
|
16
|
+
/********/ emit(eventType: EventType, ...args: any[]): void;
|
|
17
|
+
/********/ stopListening(listener: DOMNodeReference): void;
|
|
18
|
+
/********/ registerObserver(observer: MutationObserver | ResizeObserver, observerOptions: {
|
|
19
|
+
nodeToObserve: Element;
|
|
20
|
+
options: Partial<ResizeObserverOptions> | Partial<MutationObserverInit>;
|
|
21
|
+
}): void;
|
|
22
|
+
/********/ registerDOMEventListener(element: Element, eventType: keyof HTMLElementEventMap, handler: (e: Event) => unknown): void;
|
|
23
|
+
/********/ destroy(): void;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {string} titleString The text to display in the tooltip flyout content
|
|
5
|
+
* @param iconStyle Optional CSS styles to apply to the info icon
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
/********/ /********/ export default class InfoElement extends HTMLElement {
|
|
9
|
+
private flyoutContent;
|
|
10
|
+
private icon;
|
|
11
|
+
private observers;
|
|
12
|
+
/********/ constructor(titleString: string, iconStyle?: Partial<CSSStyleDeclaration>);
|
|
13
|
+
/********/ private attachEventListeners;
|
|
14
|
+
/********/ private setupObservers;
|
|
15
|
+
/********/ private getDesiredWidth;
|
|
16
|
+
/********/ private positionFlyout;
|
|
17
|
+
/********/ private updateFlyoutWidth;
|
|
18
|
+
/********/ private handleClick;
|
|
19
|
+
/********/ private handleResize;
|
|
20
|
+
/********/ private handleTouchStart;
|
|
21
|
+
/********/ private handleMouseEnter;
|
|
22
|
+
/********/ private handleMouseLeave;
|
|
23
|
+
/********/ private handleScroll;
|
|
24
|
+
/********/ private destroy;
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
2
|
+
/**
|
|
3
|
+
* @class LoadingSpinner - instantiate a spinner to handle loading state in your powerpages site
|
|
4
|
+
*/
|
|
5
|
+
/********/ /********/ export default class LoadingSpinner extends HTMLElement {
|
|
6
|
+
private element;
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* @method hide - Hides the loading spinner
|
|
10
|
+
*/
|
|
11
|
+
hide(): void;
|
|
12
|
+
/**
|
|
13
|
+
* @method show - Shows the loading spinner
|
|
14
|
+
*/
|
|
15
|
+
show(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
2
|
+
import DOMNodeReference from "./DOMNodeReference.d.ts";
|
|
3
|
+
export default class Radio extends DOMNodeReference {
|
|
4
|
+
[key: symbol]: (...arg: any[]) => any;
|
|
5
|
+
radioType: RadioType | undefined;
|
|
6
|
+
radioParent: DOMNodeReference | undefined;
|
|
7
|
+
constructor(parent: DOMNodeReference, target: Element | string, root: Element | undefined, timeoutMs: number, radioType: RadioType);
|
|
8
|
+
protected initEventManager(): void;
|
|
9
|
+
protected initValueManager(): void;
|
|
10
|
+
protected initVisibilityManager(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
2
|
+
import type DOMNodeReference from "./DOMNodeReference.d.ts";
|
|
3
|
+
export default class ValueManager {
|
|
4
|
+
value: any;
|
|
5
|
+
checked: true | false;
|
|
6
|
+
element: HTMLElement | null;
|
|
7
|
+
private noRadio;
|
|
8
|
+
private yesRadio;
|
|
9
|
+
radioParent?: DOMNodeReference | undefined;
|
|
10
|
+
private isRadio;
|
|
11
|
+
private radioType;
|
|
12
|
+
constructor(instance: DOMNodeReference);
|
|
13
|
+
setValue(value: any): void;
|
|
14
|
+
updateValue(e?: Event): Promise<void>;
|
|
15
|
+
getElementValue(): Promise<ElementValue>;
|
|
16
|
+
protected _validateValue(value: any): any;
|
|
17
|
+
clearValue(): void;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
2
|
+
export default class VisibilityManager {
|
|
3
|
+
private visibilityController;
|
|
4
|
+
private defaultVisibility;
|
|
5
|
+
set defaultDisplay(newValue: string | null);
|
|
6
|
+
constructor(target: HTMLElement);
|
|
7
|
+
hide(): void;
|
|
8
|
+
show(): void;
|
|
9
|
+
toggleVisibility(shouldShow: boolean): void;
|
|
10
|
+
getVisibility(): true | false;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference path="../globals.d.ts" />
|
|
2
2
|
/**
|
|
3
|
-
* For use in setting up event management in the instances of
|
|
4
|
-
* @see {@link
|
|
3
|
+
* For use in setting up event management in the instances of PowerPagesElement
|
|
4
|
+
* @see {@link PowerPagesElement}
|
|
5
5
|
*/
|
|
6
6
|
export declare const EventTypes: {
|
|
7
7
|
readonly CHECKBOX: "click";
|
package/dist/src/core/API.d.ts
CHANGED
|
@@ -20,17 +20,21 @@ declare abstract class API {
|
|
|
20
20
|
*
|
|
21
21
|
* @param tableSetName The DataVerse SET name of the table being queried
|
|
22
22
|
* @param recordID the GUID of the records to be retrieved
|
|
23
|
-
* @param
|
|
23
|
+
* @param ODataQueryString *OPTIONAL* if desired, enter your own custom OData query for advanced GET results. e.g.: ?$select=column1,column2,column3
|
|
24
24
|
* @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
|
|
25
25
|
*/
|
|
26
|
-
static getRecord<T>(tableSetName: string, recordID: string,
|
|
26
|
+
static getRecord<T>(tableSetName: string, recordID: string, ODataQueryString?: string): Promise<T>;
|
|
27
|
+
/**
|
|
28
|
+
* More flexible method for building completely custom queries
|
|
29
|
+
*/
|
|
30
|
+
static request<T>(query: string, options?: JQuery.AjaxSettings): Promise<T | Error>;
|
|
27
31
|
/**
|
|
28
32
|
*
|
|
29
33
|
* @param tableSetName The dataverse set name of the table being queried
|
|
30
34
|
* @param queryParameters *OPTIONAL* the OData query parameters for refining search results: *format = $filter=filters&$select=columns*
|
|
31
35
|
* @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
|
|
32
36
|
*/
|
|
33
|
-
static getMultiple(tableSetName: string, queryParameters?: string): Promise<Array<
|
|
37
|
+
static getMultiple<T = object>(tableSetName: string, queryParameters?: string): Promise<Array<T>>;
|
|
34
38
|
/**
|
|
35
39
|
*
|
|
36
40
|
* @param tableSetName The dataverse set name for the table that you are updating a record in
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
2
|
+
import DOMNodeReference from "../ancillary/DOMNodeReference.d.ts";
|
|
3
|
+
import Radio from "../ancillary/Radio.d.ts";
|
|
4
|
+
/********/ /********/ export default class PowerPagesElement extends DOMNodeReference {
|
|
5
|
+
[key: symbol]: (...arg: any[]) => any;
|
|
6
|
+
private isMasked;
|
|
7
|
+
/**
|
|
8
|
+
* Represents the 'yes' option of a boolean radio field.
|
|
9
|
+
* This property is only available when the parent node
|
|
10
|
+
* is a main field for a boolean radio input.
|
|
11
|
+
*/
|
|
12
|
+
yesRadio: Radio | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Represents the 'no' option of a boolean radio field.
|
|
15
|
+
* This property is only available when the parent node
|
|
16
|
+
* is a main field for a boolean radio input.
|
|
17
|
+
*/
|
|
18
|
+
noRadio: Radio | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Creates an instance of PowerPagesElement.
|
|
21
|
+
* @param target - The CSS selector to find the desired DOM element.
|
|
22
|
+
* @param root - Optionally specify the element within to search for the element targeted by 'target'
|
|
23
|
+
* Defaults to 'document.body'
|
|
24
|
+
*/
|
|
25
|
+
/******/ constructor(target: Element | string, root: Element | undefined, timeoutMs: number);
|
|
26
|
+
protected initValueManager(): void;
|
|
27
|
+
protected initVisibilityManager(): void;
|
|
28
|
+
protected initEventManager(): void;
|
|
29
|
+
protected _attachRadioButtons(): Promise<void>;
|
|
30
|
+
clearValue(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Unchecks both the yes and no radio buttons if they exist.
|
|
33
|
+
* @returns - Instance of this [provides option to method chain]
|
|
34
|
+
*/
|
|
35
|
+
uncheckRadios(): PowerPagesElement;
|
|
36
|
+
/**
|
|
37
|
+
* Apply an input mask to this element
|
|
38
|
+
* @param type The type of input mask to apply to this element
|
|
39
|
+
* @param options The options to specify the behavior of the mask
|
|
40
|
+
*/
|
|
41
|
+
inputMask(type: "phone" | "money", options: InputMaskOptions): void;
|
|
42
|
+
inputMask(type: "phone", options?: {
|
|
43
|
+
format?: PhoneNumberFormats;
|
|
44
|
+
countryCode?: CountryCodeFormats;
|
|
45
|
+
}): void;
|
|
46
|
+
inputMask(type: "money", options?: {
|
|
47
|
+
prefix?: CurrencySymbol;
|
|
48
|
+
decimalPlaces?: number;
|
|
49
|
+
thousandsSeparator?: string;
|
|
50
|
+
decimalSeparator?: string;
|
|
51
|
+
allowNegative?: boolean;
|
|
52
|
+
}): void;
|
|
53
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
2
|
+
import type PowerPagesElement from "./PowerPagesElement.d.ts";
|
|
3
|
+
export default class PowerPagesElementArray extends Array<PowerPagesElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Hides all the containers of the PowerPagesElement instances in the array.
|
|
6
|
+
*/
|
|
7
|
+
hideAll(this: PowerPagesElementArray): PowerPagesElementArray;
|
|
8
|
+
/**
|
|
9
|
+
* Shows all the containers of the PowerPagesElement instances in the array.
|
|
10
|
+
*/
|
|
11
|
+
showAll(this: PowerPagesElementArray): PowerPagesElementArray;
|
|
12
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/// <reference path="../globals.d.ts" />
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
2
|
+
import type PowerPagesElementArray from "./PowerPagesElementArray.d.ts";
|
|
3
|
+
import type PowerPagesElement from "./PowerPagesElement.d.ts";
|
|
4
4
|
/**
|
|
5
5
|
* When loading into a page in PowerPages that has a form,
|
|
6
6
|
* you can use this function by passing in the GUID of the form, and you will receive an array/record
|
|
7
|
-
* of {@link
|
|
7
|
+
* of {@link PowerPagesElement}s that represent all fields, sections, sub-grids, and tabs of the given form.
|
|
8
8
|
* Access these properties of the {@link BoundForm} using the logical name of the control you need to access: form['logical_name']
|
|
9
|
-
* you can then execute all the methods available from
|
|
9
|
+
* you can then execute all the methods available from PowerPagesElement
|
|
10
10
|
* @param formId - The string GUID of the form you want to bind to
|
|
11
|
-
* @returns An array of
|
|
11
|
+
* @returns An array of PowerPagesElements, accessible as properties of a Record<string, PowerPagesElement> i.e. formProp = form["some_logicalName"]
|
|
12
12
|
* @example
|
|
13
13
|
* ```js
|
|
14
14
|
* bindForm("form-guid-0000").then((form) => {
|
|
@@ -23,6 +23,6 @@ import type DOMNodeReferenceArray from "./DOMNodeReferenceArray.d.ts";
|
|
|
23
23
|
* const form = await bindForm("form-guid-0000")
|
|
24
24
|
* ```
|
|
25
25
|
* @see {@link BoundForm}
|
|
26
|
-
* @see {@link
|
|
26
|
+
* @see {@link PowerPagesElement}
|
|
27
27
|
*/
|
|
28
|
-
export default function bindForm(formId: string): Promise<
|
|
28
|
+
export default function bindForm(formId: string): Promise<PowerPagesElementArray & Record<string, PowerPagesElement>>;
|