powerpagestoolkit 3.0.3215 → 3.0.4041
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/dist/src/ancillary/DOMNodeReference.d.ts +14 -31
- package/dist/src/ancillary/EventManager.d.ts +9 -9
- 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 +4 -1
- package/dist/src/ancillary/ValueManager.d.ts +2 -1
- package/dist/src/core/PowerPagesElement.d.ts +24 -3
- package/dist/src/core/getPowerPagesElement.d.ts +2 -36
- package/dist/src/globals.d.ts +27 -23
- package/dist/src/index.d.ts +2 -1
- 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/package.json +6 -3
- package/dist/src/utils/createInfoElement.d.ts +0 -8
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:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference path="../globals.d.ts" />
|
|
2
|
+
import type EventManager from "../ancillary/EventManager.d.ts";
|
|
2
3
|
import type ValueManager from "../ancillary/ValueManager.d.ts";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export default class DOMNodeReference {
|
|
4
|
+
import type VisibilityManager from "./VisibilityManager.d.ts";
|
|
5
|
+
export default abstract class DOMNodeReference {
|
|
6
6
|
static instances: DOMNodeReference[];
|
|
7
7
|
[key: symbol]: (...arg: any[]) => any;
|
|
8
8
|
target: Element | string;
|
|
@@ -27,16 +27,6 @@ export default class DOMNodeReference {
|
|
|
27
27
|
visibilityManager: VisibilityManager | null;
|
|
28
28
|
valueManager: ValueManager | null;
|
|
29
29
|
eventManager: EventManager | null;
|
|
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
|
-
/**
|
|
36
|
-
* Represents the 'no' option of a boolean radio field.
|
|
37
|
-
* This property is only available when the parent node
|
|
38
|
-
* is a main field for a boolean radio input.
|
|
39
|
-
*/
|
|
40
30
|
/**
|
|
41
31
|
* Creates an instance of DOMNodeReference.
|
|
42
32
|
* @param target - The CSS selector to find the desired DOM element.
|
|
@@ -44,11 +34,10 @@ export default class DOMNodeReference {
|
|
|
44
34
|
* Defaults to 'document.body'
|
|
45
35
|
*/
|
|
46
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;
|
|
47
40
|
protected _extractLogicalName(target: Element | string): string;
|
|
48
|
-
/**
|
|
49
|
-
* Initializes value synchronization with appropriate event listeners
|
|
50
|
-
* based on element type.
|
|
51
|
-
*/
|
|
52
41
|
protected _valueSync(): void;
|
|
53
42
|
protected _determineEventType(): keyof GlobalEventHandlersEventMap;
|
|
54
43
|
protected _isDateInput(): boolean;
|
|
@@ -159,7 +148,7 @@ export default class DOMNodeReference {
|
|
|
159
148
|
* @param string - The text to set as the inner HTML of the element.
|
|
160
149
|
* @returns - Instance of this [provides option to method chain]
|
|
161
150
|
*/
|
|
162
|
-
|
|
151
|
+
set innerHTML(innerHTML: string);
|
|
163
152
|
/**
|
|
164
153
|
* Removes this element from the DOM
|
|
165
154
|
* @returns - Instance of this [provides option to method chain]
|
|
@@ -170,7 +159,7 @@ export default class DOMNodeReference {
|
|
|
170
159
|
* @param options - An object containing CSS property-value pairs, e.g., { display: 'block' }.
|
|
171
160
|
* @returns The instance, enabling method chaining.
|
|
172
161
|
*/
|
|
173
|
-
setStyle(options: Partial<CSSStyleDeclaration>):
|
|
162
|
+
setStyle(options: Partial<CSSStyleDeclaration>): DOMNodeReference;
|
|
174
163
|
/**
|
|
175
164
|
* Applies a business rule to manage visibility, required state, value, and disabled state dynamically.
|
|
176
165
|
* @see {@link BusinessRule}
|
|
@@ -179,16 +168,10 @@ export default class DOMNodeReference {
|
|
|
179
168
|
* @returns Instance of this for method chaining.
|
|
180
169
|
*/
|
|
181
170
|
applyBusinessRule(rule: BusinessRule, dependencies: DependencyArray<DOMNodeReference>): DOMNodeReference;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
* @protected
|
|
187
|
-
* @param handler The function to execute when dependencies change
|
|
188
|
-
* @param dependencies Array of dependent DOM nodes to track
|
|
189
|
-
* all other options defaults to true
|
|
190
|
-
*/
|
|
191
|
-
protected _configureDependencyTracking(handler: DependencyHandler, dependencies: DOMNodeReference[]): void;
|
|
171
|
+
private _setupRequirementsValidator;
|
|
172
|
+
private _createBusinessRuleHandler;
|
|
173
|
+
private _createValidator;
|
|
174
|
+
private _configureDependencyTracking;
|
|
192
175
|
/**
|
|
193
176
|
* Sets the required level for the field by adding or removing the "required-field" class on the label.
|
|
194
177
|
*
|
|
@@ -196,7 +179,7 @@ export default class DOMNodeReference {
|
|
|
196
179
|
* If true, the "required-field" class is added to the label; if false, it is removed.
|
|
197
180
|
* @returns Instance of this [provides option to method chain]
|
|
198
181
|
*/
|
|
199
|
-
setRequiredLevel(isRequired:
|
|
182
|
+
setRequiredLevel(isRequired: Evaluator | boolean): DOMNodeReference;
|
|
200
183
|
/**
|
|
201
184
|
* Executes a callback function once the element is fully loaded.
|
|
202
185
|
* If the element is already loaded, the callback is called immediately.
|
|
@@ -204,5 +187,5 @@ export default class DOMNodeReference {
|
|
|
204
187
|
* @param callback A callback function to execute once the element is loaded.
|
|
205
188
|
* Receives instance of 'this' as an argument
|
|
206
189
|
*/
|
|
207
|
-
onceLoaded(callback: (instance: DOMNodeReference) => any):
|
|
190
|
+
onceLoaded(callback: (instance: DOMNodeReference) => any): void;
|
|
208
191
|
}
|
|
@@ -9,17 +9,17 @@ declare type Handler = (this: DOMNodeReference, ...args: any[]) => void;
|
|
|
9
9
|
private observers;
|
|
10
10
|
private boundListeners;
|
|
11
11
|
constructor();
|
|
12
|
-
dispatchDependencyHandlers(): void;
|
|
13
|
-
registerDependent(dependency: DOMNodeReference, handler: Handler):
|
|
14
|
-
registerEvent(event: EventType, handler: Handler):
|
|
15
|
-
registerListener(event: EventType, listener: DOMNodeReference):
|
|
16
|
-
emit(eventType: EventType, ...args: any[]): void;
|
|
17
|
-
stopListening(listener: DOMNodeReference): void;
|
|
18
|
-
registerObserver(observer: MutationObserver | ResizeObserver, observerOptions: {
|
|
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
19
|
nodeToObserve: Element;
|
|
20
20
|
options: Partial<ResizeObserverOptions> | Partial<MutationObserverInit>;
|
|
21
21
|
}): void;
|
|
22
|
-
registerDOMEventListener(element: Element, eventType: keyof HTMLElementEventMap, handler: (e: Event) => unknown): void;
|
|
23
|
-
destroy(): void;
|
|
22
|
+
/********/ registerDOMEventListener(element: Element, eventType: keyof HTMLElementEventMap, handler: (e: Event) => unknown): void;
|
|
23
|
+
/********/ destroy(): void;
|
|
24
24
|
}
|
|
25
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
|
+
}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import DOMNodeReference from "./DOMNodeReference.d.ts";
|
|
3
3
|
export default class Radio extends DOMNodeReference {
|
|
4
4
|
[key: symbol]: (...arg: any[]) => any;
|
|
5
|
-
|
|
5
|
+
radioType: RadioType | undefined;
|
|
6
6
|
radioParent: DOMNodeReference | undefined;
|
|
7
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;
|
|
8
11
|
}
|
|
@@ -3,11 +3,12 @@ import type DOMNodeReference from "./DOMNodeReference.d.ts";
|
|
|
3
3
|
export default class ValueManager {
|
|
4
4
|
value: any;
|
|
5
5
|
checked: true | false;
|
|
6
|
-
|
|
6
|
+
element: HTMLElement | null;
|
|
7
7
|
private noRadio;
|
|
8
8
|
private yesRadio;
|
|
9
9
|
radioParent?: DOMNodeReference | undefined;
|
|
10
10
|
private isRadio;
|
|
11
|
+
private radioType;
|
|
11
12
|
constructor(instance: DOMNodeReference);
|
|
12
13
|
setValue(value: any): void;
|
|
13
14
|
updateValue(e?: Event): Promise<void>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference path="../globals.d.ts" />
|
|
2
2
|
import DOMNodeReference from "../ancillary/DOMNodeReference.d.ts";
|
|
3
3
|
import Radio from "../ancillary/Radio.d.ts";
|
|
4
|
-
export default class PowerPagesElement extends DOMNodeReference {
|
|
4
|
+
/********/ /********/ export default class PowerPagesElement extends DOMNodeReference {
|
|
5
5
|
[key: symbol]: (...arg: any[]) => any;
|
|
6
|
+
private isMasked;
|
|
6
7
|
/**
|
|
7
8
|
* Represents the 'yes' option of a boolean radio field.
|
|
8
9
|
* This property is only available when the parent node
|
|
@@ -21,12 +22,32 @@ export default class PowerPagesElement extends DOMNodeReference {
|
|
|
21
22
|
* @param root - Optionally specify the element within to search for the element targeted by 'target'
|
|
22
23
|
* Defaults to 'document.body'
|
|
23
24
|
*/
|
|
24
|
-
/******/
|
|
25
|
+
/******/ constructor(target: Element | string, root: Element | undefined, timeoutMs: number);
|
|
26
|
+
protected initValueManager(): void;
|
|
27
|
+
protected initVisibilityManager(): void;
|
|
28
|
+
protected initEventManager(): void;
|
|
25
29
|
protected _attachRadioButtons(): Promise<void>;
|
|
26
30
|
clearValue(): void;
|
|
27
31
|
/**
|
|
28
32
|
* Unchecks both the yes and no radio buttons if they exist.
|
|
29
33
|
* @returns - Instance of this [provides option to method chain]
|
|
30
34
|
*/
|
|
31
|
-
uncheckRadios():
|
|
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;
|
|
32
53
|
}
|
|
@@ -15,43 +15,9 @@ import PowerPagesElement from "./PowerPagesElement.d.ts";
|
|
|
15
15
|
* @see {@link PowerPagesElementArray}
|
|
16
16
|
* @see {@link enhanceArray}
|
|
17
17
|
*/
|
|
18
|
-
export default function createPowerPagesElement(target: string |
|
|
19
|
-
|
|
20
|
-
* Should this call return an array of instantiated references, or just a single?
|
|
21
|
-
* Defaults to false, returning a single instance.
|
|
22
|
-
*/
|
|
23
|
-
multiple?: (() => boolean) | boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Optionally specify the element within which to search for the element targeted by 'target'.
|
|
26
|
-
* Defaults to 'document.body'.
|
|
27
|
-
*/
|
|
28
|
-
root?: HTMLElement;
|
|
29
|
-
/**
|
|
30
|
-
* Optionally specify the amount of time that should be waited to find the targeted element before throwing an error.
|
|
31
|
-
* Useful for async DOM loading. Relies on MutationObserver.
|
|
32
|
-
* WARNING: Implementing multiple references with timeout can result in infinite loading.
|
|
33
|
-
*/
|
|
34
|
-
timeoutMs?: number;
|
|
35
|
-
}): Promise<PowerPagesElement>;
|
|
18
|
+
export default function createPowerPagesElement(target: string | Element): Promise<PowerPagesElement>;
|
|
19
|
+
export default function createPowerPagesElement(target: Element): Promise<PowerPagesElement>;
|
|
36
20
|
export default function createPowerPagesElement(target: string, options?: {
|
|
37
|
-
/**
|
|
38
|
-
* Should this call return an array of instantiated references, or just a single?
|
|
39
|
-
* Defaults to false, returning a single instance.
|
|
40
|
-
*/
|
|
41
|
-
multiple?: false;
|
|
42
|
-
/**
|
|
43
|
-
* Optionally specify the element within which to search for the element targeted by 'target'.
|
|
44
|
-
* Defaults to 'document.body'.
|
|
45
|
-
*/
|
|
46
|
-
root?: HTMLElement;
|
|
47
|
-
/**
|
|
48
|
-
* Optionally specify the amount of time that should be waited to find the targeted element before throwing an error.
|
|
49
|
-
* Useful for async DOM loading. Relies on MutationObserver.
|
|
50
|
-
* WARNING: Implementing multiple references with timeout can result in infinite loading.
|
|
51
|
-
*/
|
|
52
|
-
timeoutMs?: number;
|
|
53
|
-
}): Promise<PowerPagesElement>;
|
|
54
|
-
export default function createPowerPagesElement(target: Element, options?: {
|
|
55
21
|
/**
|
|
56
22
|
* Optionally specify the element within which to search for the element targeted by 'target'.
|
|
57
23
|
* Defaults to 'document.body'.
|
package/dist/src/globals.d.ts
CHANGED
|
@@ -87,8 +87,8 @@ declare interface BusinessRule {
|
|
|
87
87
|
* @param isValid.isRequiredResult - Only available if 'isRequired' is also returned from the configuration function
|
|
88
88
|
*/
|
|
89
89
|
setRequirements?: () => {
|
|
90
|
-
isRequired?:
|
|
91
|
-
isValid?:
|
|
90
|
+
isRequired?: Evaluator<DOMNodeReference>;
|
|
91
|
+
isValid?: Evaluator<DOMNodeReference, boolean>;
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -118,27 +118,6 @@ type NonEmptyArray<T extends unknown[]> = T extends []
|
|
|
118
118
|
// but if someone passes an empty array (i.e. []), the type becomes a custom error.
|
|
119
119
|
declare type DependencyArray<T> = NonEmptyArray<[T, ...T[]]>;
|
|
120
120
|
|
|
121
|
-
declare interface CreationOptions {
|
|
122
|
-
/**
|
|
123
|
-
* Should this call return an array of instantiated references, or just a single?
|
|
124
|
-
* Defaults to false, returning a single instance.
|
|
125
|
-
*/
|
|
126
|
-
multiple?: (() => boolean) | boolean;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Optionally specify the element within which to search for the element targeted by 'target'.
|
|
130
|
-
* Defaults to 'document.body'.
|
|
131
|
-
*/
|
|
132
|
-
root?: HTMLElement;
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Optionally specify the amount of time that should be waited to find the targeted element before throwing an error.
|
|
136
|
-
* Useful for async DOM loading. Relies on MutationObserver.
|
|
137
|
-
* WARNING: Implementing multiple references with timeout can result in infinite loading.
|
|
138
|
-
*/
|
|
139
|
-
timeoutMs?: number;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
121
|
declare type DependencyHandler = () => void;
|
|
143
122
|
|
|
144
123
|
declare interface BusinessRuleHandler extends DependencyHandler {}
|
|
@@ -173,3 +152,28 @@ declare type FormElement =
|
|
|
173
152
|
| HTMLSpanElement
|
|
174
153
|
| HTMLButtonElement
|
|
175
154
|
| HTMLFieldSetElement;
|
|
155
|
+
|
|
156
|
+
declare type PhoneNumberFormats =
|
|
157
|
+
| "xxx-xxx-xxxx"
|
|
158
|
+
| "(xxx) xxx-xxxx"
|
|
159
|
+
| "xxx xxx-xxxx"
|
|
160
|
+
| "xxx.xxx.xxxx";
|
|
161
|
+
|
|
162
|
+
declare type CountryCodeFormats = "+" | "()";
|
|
163
|
+
|
|
164
|
+
declare type CurrencySymbol = "$" | "€" | "£" | "¥" | "¢";
|
|
165
|
+
|
|
166
|
+
declare interface InputMaskOptions {
|
|
167
|
+
format?: PhoneNumberFormats;
|
|
168
|
+
countryCode?: CountryCodeFormats;
|
|
169
|
+
prefix?: CurrencySymbol; // Currency symbol (e.g., "$")
|
|
170
|
+
decimalPlaces?: number; // Number of decimal places (default: 2)
|
|
171
|
+
thousandsSeparator?: string; // Character for separating thousands (e.g., ",")
|
|
172
|
+
decimalSeparator?: string; // Character for decimal point (e.g., ".")
|
|
173
|
+
allowNegative?: boolean; // Whether to allow negative values
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare type Evaluator<T = any, A = unknown> = (
|
|
177
|
+
this: T,
|
|
178
|
+
...args: A[]
|
|
179
|
+
) => boolean;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import API from "./core/API.d.ts";
|
|
|
2
2
|
import get from "./core/getPowerPagesElement.d.ts";
|
|
3
3
|
import waitFor from "./core/waitFor.d.ts";
|
|
4
4
|
import bindForm from "./core/bindForm.d.ts";
|
|
5
|
-
|
|
5
|
+
import LoadingSpinner from "./ancillary/LoadingSpinner.d.ts";
|
|
6
|
+
export { API, bindForm, get, waitFor, LoadingSpinner };
|