powerpagestoolkit 2.7.0 → 2.7.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.
@@ -0,0 +1,88 @@
1
+ /// <reference path="../globals.d.ts" />
2
+ import DOMNodeReference from "./DOMNodeReference.d.ts";
3
+ import type DOMNodeReferenceArray from "./DOMNodeReferenceArray.d.ts";
4
+ /**
5
+ * Creates and initializes a DOMNodeReference instance.
6
+ * @see {@link CreationOptions}
7
+ * @param **target** - The selector, using `querySelector` syntax, for the desired DOM element. Or, the `HTMLElement` itself for which to create a DOMNodeReference.
8
+ * @param **options** - Options for advanced retrieval of elements
9
+ * @param **options.multiple** - Should this call return an array of instantiated references, or just a single? Defaults to false, returning a single instance
10
+ * @param **options.root** - Optionally specify the element within to search for the element targeted by 'target'. Defaults to `document.body`
11
+ * @param **options.timeoutMs** - Optionally specify the amount of time that should be waited to find the targeted element before throwing error - useful for async DOM loading. Relies on MutationObserver. ***WARNING***: Implementing multiple references with timeout can result in infinite loading.
12
+ * @returns A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
13
+ *
14
+ * @see {@link DOMNodeReference}
15
+ * @see {@link DOMNodeReferenceArray}
16
+ * @see {@link enhanceArray}
17
+ */
18
+ export default function createDOMNodeReference(target: string | HTMLElement, options?: {
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<DOMNodeReference>;
36
+ export default function createDOMNodeReference(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<DOMNodeReference>;
54
+ export default function createDOMNodeReference(target: Element, options?: {
55
+ /**
56
+ * Optionally specify the element within which to search for the element targeted by 'target'.
57
+ * Defaults to 'document.body'.
58
+ */
59
+ root?: HTMLElement;
60
+ /**
61
+ * Optionally specify the amount of time that should be waited to find the targeted element before throwing an error.
62
+ * Useful for async DOM loading. Relies on MutationObserver.
63
+ * WARNING: Implementing multiple references with timeout can result in infinite loading.
64
+ */
65
+ timeoutMs?: number;
66
+ }): Promise<DOMNodeReference>;
67
+ export default function createDOMNodeReference(target: string, options?: {
68
+ /**
69
+ * Should this call return an array of instantiated references, or just a single?
70
+ * Defaults to false, returning a single instance.
71
+ */
72
+ multiple?: true;
73
+ /**
74
+ * Optionally specify the element within which to search for the element targeted by 'target'.
75
+ * Defaults to 'document.body'.
76
+ */
77
+ root?: HTMLElement;
78
+ /**
79
+ * Optionally specify the amount of time that should be waited to find the targeted element before throwing an error.
80
+ * Useful for async DOM loading. Relies on MutationObserver.
81
+ * WARNING: Implementing multiple references with timeout can result in infinite loading.
82
+ */
83
+ timeoutMs?: number;
84
+ }): Promise<DOMNodeReferenceArray>;
85
+ export declare function validateOptions(options: Partial<CreationOptions>): void;
86
+ export declare function createProxyHandler(): {
87
+ get: (target: DOMNodeReference, prop: string | symbol) => any;
88
+ };
@@ -0,0 +1,9 @@
1
+ /// <reference path="../globals.d.ts" />
2
+ /**
3
+ * Provides an async way to capture DOM elements; for when querySelector cannot capture the target due to async DOM content loading
4
+ * @param **target** - basic querySelector syntax to select an element
5
+ * @param **root** - optional parameter to replace document as the root from which to perform the node search
6
+ * @returns the element(s) targeted by the `querySelector` string
7
+ */
8
+ export default function waitFor(target: string, root: Element | Document, multiple: false, debounceTime: number): Promise<HTMLElement>;
9
+ export default function waitFor(target: string, root: Element | Document, multiple: true, debounceTime: number): Promise<HTMLElement[]>;
@@ -1,4 +1,5 @@
1
- import DOMNodeReference from "./DOMNodeReference.js";
1
+ /// <reference path="../globals.d.ts" />
2
+ import type DOMNodeReference from "../core/DOMNodeReference.d.ts";
2
3
  export declare class DOMNodeInitializationError extends Error {
3
4
  constructor(instance: DOMNodeReference, error: string);
4
5
  }
@@ -0,0 +1,150 @@
1
+ /// <reference path="../core/DOMNodeReference.ts"/>
2
+
3
+ declare interface CreationOptions {
4
+ /**
5
+ * Should this call return an array of instantiated references, or just a single?
6
+ * Defaults to false, returning a single instance.
7
+ */
8
+ multiple?: (() => boolean) | boolean;
9
+
10
+ /**
11
+ * Optionally specify the element within which to search for the element targeted by 'target'.
12
+ * Defaults to 'document.body'.
13
+ */
14
+ root?: HTMLElement;
15
+
16
+ /**
17
+ * Optionally specify the amount of time that should be waited to find the targeted element before throwing an error.
18
+ * Useful for async DOM loading. Relies on MutationObserver.
19
+ * WARNING: Implementing multiple references with timeout can result in infinite loading.
20
+ */
21
+ timeoutMs?: number;
22
+ }
23
+
24
+ declare interface SystemForm extends Object {
25
+ "@odata.context": string;
26
+ "@odata.etag": string;
27
+ "overwritetime@OData.Community.Display.V1.FormattedValue": string;
28
+ overwritetime: Date;
29
+ "isdesktopenabled@OData.Community.Display.V1.FormattedValue": string;
30
+ isdesktopenabled: boolean;
31
+ "publishedon@OData.Community.Display.V1.FormattedValue": Date;
32
+ publishedon: Date;
33
+ "_organizationid_value@OData.Community.Display.V1.FormattedValue": string;
34
+ "_organizationid_value@Microsoft.Dynamics.CRM.associatednavigationproperty": string;
35
+ "_organizationid_value@Microsoft.Dynamics.CRM.lookuplogicalname": string;
36
+ _organizationid_value: string;
37
+ formxml: string;
38
+ introducedversion: string;
39
+ "isairmerged@OData.Community.Display.V1.FormattedValue": string;
40
+ isairmerged: boolean;
41
+ "istabletenabled@OData.Community.Display.V1.FormattedValue": string;
42
+ istabletenabled: boolean;
43
+ solutionid: string;
44
+ formidunique: string;
45
+ "ismanaged@OData.Community.Display.V1.FormattedValue": string;
46
+ ismanaged: boolean;
47
+ "isdefault@OData.Community.Display.V1.FormattedValue": string;
48
+ isdefault: boolean;
49
+ "objecttypecode@OData.Community.Display.V1.FormattedValue": string;
50
+ objecttypecode: string;
51
+ "type@OData.Community.Display.V1.FormattedValue": string;
52
+ type: number;
53
+ "componentstate@OData.Community.Display.V1.FormattedValue": string;
54
+ componentstate: number;
55
+ "formpresentation@OData.Community.Display.V1.FormattedValue": string;
56
+ formpresentation: number;
57
+ "formactivationstate@OData.Community.Display.V1.FormattedValue": string;
58
+ formactivationstate: number;
59
+ name: string;
60
+ "versionnumber@OData.Community.Display.V1.FormattedValue": string;
61
+ versionnumber: number;
62
+ formjson: string;
63
+ description: string;
64
+ formid: string;
65
+ }
66
+
67
+ declare interface Form extends Partial<SystemForm> {
68
+ formxml: string;
69
+ }
70
+
71
+ declare interface BusinessRule {
72
+ /**
73
+ * @param condition A function that returns a boolean to determine
74
+ * the visibility of the target element. If `condition()` returns true, the element is shown;
75
+ * otherwise, it is hidden.
76
+
77
+ * @param clearValuesOnHide Should the values in the targeted field be cleared when hidden? Defaults to true
78
+ */
79
+ setVisibility?: [
80
+ condition: (this: DOMNodeReference) => boolean,
81
+ clearValuesOnHide?: boolean
82
+ ];
83
+ /**
84
+ * @param isRequired Function determining if field is required
85
+ * @param isValid Function validating field input.
86
+ */
87
+ setRequired?: [
88
+ isRequired: () => boolean,
89
+ isValid: (this: DOMNodeReference, isRequired: boolean) => boolean
90
+ ];
91
+ /**
92
+ * @param condition A function to determine if the value provided should be applied to this field
93
+ * @param value The value to set for the HTML element.
94
+ * for parents of boolean radios, pass true or false as value, or
95
+ * an expression returning a boolean
96
+ */
97
+ setValue?: [
98
+ condition: (this: DOMNodeReference) => boolean,
99
+ value: (() => any) | any
100
+ ];
101
+ /**
102
+ * @param condition A function to determine if this field
103
+ * should be enabled in a form, or disabled. True || 1 = disabled. False || 0 = enabled
104
+ */
105
+ setDisabled?: () => boolean;
106
+ }
107
+
108
+ declare interface CreationOptions {
109
+ /**
110
+ * Should this call return an array of instantiated references, or just a single?
111
+ * Defaults to false, returning a single instance.
112
+ */
113
+ multiple?: (() => boolean) | boolean;
114
+
115
+ /**
116
+ * Optionally specify the element within which to search for the element targeted by 'target'.
117
+ * Defaults to 'document.body'.
118
+ */
119
+ root?: HTMLElement;
120
+
121
+ /**
122
+ * Optionally specify the amount of time that should be waited to find the targeted element before throwing an error.
123
+ * Useful for async DOM loading. Relies on MutationObserver.
124
+ * WARNING: Implementing multiple references with timeout can result in infinite loading.
125
+ */
126
+ timeoutMs?: number;
127
+ }
128
+
129
+ declare const Page_Validators: any[];
130
+
131
+ declare interface ElementValue {
132
+ value: any;
133
+ checked?: boolean;
134
+ }
135
+
136
+ declare type RadioType = "truthy" | "falsy";
137
+
138
+ declare interface BoundEventListener {
139
+ element: Element;
140
+ event: keyof HTMLElementEventMap;
141
+ handler: (e: Event) => unknown;
142
+ }
143
+
144
+ declare type FormElement =
145
+ | HTMLInputElement
146
+ | HTMLSelectElement
147
+ | HTMLTextAreaElement
148
+ | HTMLSpanElement
149
+ | HTMLButtonElement
150
+ | HTMLFieldSetElement;
@@ -0,0 +1,5 @@
1
+ import API from "./core/API.d.ts";
2
+ import createRef from "./core/createDOMNodeReferences.d.ts";
3
+ import waitFor from "./core/waitFor.d.ts";
4
+ import bindForm from "./core/bindForm.d.ts";
5
+ export { API, bindForm, createRef, waitFor };