powerpagestoolkit 2.7.134 → 2.7.202

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,6 @@
1
+ {
2
+ "imports": {
3
+ "powerpagestoolkit/": "./",
4
+ "powerpagestoolkit": "./index.js"
5
+ }
6
+ }
@@ -0,0 +1,7 @@
1
+ /// <reference path="../globals.d.ts" />
2
+ /**
3
+ * For use in setting up event management in the instances of DOMNodeReference
4
+ * @see {@link DOMNodeReference}
5
+ */
6
+ declare const eventMapping: Record<string, keyof HTMLElementEventMap>;
7
+ export default eventMapping;
@@ -1,3 +1,4 @@
1
+ /// <reference path="../globals.d.ts" />
1
2
  export declare const init: unique symbol;
2
3
  export declare const destroy: unique symbol;
3
4
  export declare const valueSync: unique symbol;
@@ -1,10 +1,18 @@
1
- declare const API: {
1
+ /// <reference path="../globals.d.ts" />
2
+ /**
3
+ * Provides abstract class `API` that allows basic create, read, and update operations in DataVerse via the PowerPages API
4
+ * @method `createRecord` - Create a record in DataVerse
5
+ * @method `getRecord<T>` - Get a record by ID from DataVerse
6
+ * @method `getMultiple` - Get multiple records from DataVerse; with optional OData filtering
7
+ * @method `updateRecord` - Update a record by ID in DataVerse
8
+ */
9
+ declare abstract class API {
2
10
  /**
3
11
  * @param tableSetName The dataverse set name for the table that you are updating a record in
4
12
  * @param data The JSON of the fields and data that are to be updated on the targeted record
5
13
  * @returns a Promise resolving the successful results *[record id]* of the POST request, or rejecting the failed results *[error]* of the POST request.
6
14
  */
7
- createRecord(tableSetName: string, data: object): Promise<string>;
15
+ static createRecord(tableSetName: string, data: JSON): Promise<string>;
8
16
  /**
9
17
  *
10
18
  * @param tableSetName The DataVerse SET name of the table being queried
@@ -12,14 +20,14 @@ declare const API: {
12
20
  * @param selectColumns *OPTIONAL* if desired, enter your own custom OData query for advanced GET results. Format = select=column1,column2,column3...
13
21
  * @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
14
22
  */
15
- getRecord<T>(tableSetName: string, recordID: string, selectColumns?: string): Promise<T>;
23
+ static getRecord<T>(tableSetName: string, recordID: string, selectColumns?: string): Promise<T>;
16
24
  /**
17
25
  *
18
26
  * @param tableSetName The dataverse set name of the table being queried
19
27
  * @param queryParameters *OPTIONAL* the OData query parameters for refining search results: *format = $filter=filters&$select=columns*
20
28
  * @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
21
29
  */
22
- getMultiple(tableSetName: string, queryParameters?: string): Promise<Array<object>>;
30
+ static getMultiple(tableSetName: string, queryParameters?: string): Promise<Array<object>>;
23
31
  /**
24
32
  *
25
33
  * @param tableSetName The dataverse set name for the table that you are updating a record in
@@ -27,6 +35,6 @@ declare const API: {
27
35
  * @param data The JSON of the fields and data that are to be updated on the targeted record
28
36
  * @returns A Promise with the results of the API execution
29
37
  */
30
- updateRecord(tableSetName: string, recordId: string, data: object): Promise<any>;
31
- };
38
+ static updateRecord(tableSetName: string, recordId: string, data: object): Promise<any>;
39
+ }
32
40
  export default API;
@@ -1,34 +1,5 @@
1
- import * as s from "@/constants/symbols.js";
2
- declare type BusinessRule = {
3
- /**
4
- * @param condition A function that returns a boolean to determine
5
- * the visibility of the target element. If `condition()` returns true, the element is shown;
6
- * otherwise, it is hidden.
7
-
8
- * @param clearValuesOnHide Should the values in the targeted field be cleared when hidden? Defaults to true
9
- */
10
- setVisibility?: [condition: () => boolean, clearValuesOnHide?: boolean];
11
- /**
12
- * @param isRequired Function determining if field is required
13
- * @param isValid Function validating field input.
14
- */
15
- setRequired?: [
16
- isRequired: () => boolean,
17
- isValid: (isRequired: boolean) => boolean
18
- ];
19
- /**
20
- * @param condition A function to determine if the value provided should be applied to this field
21
- * @param value The value to set for the HTML element.
22
- * for parents of boolean radios, pass true or false as value, or
23
- * an expression returning a boolean
24
- */
25
- setValue?: [condition: () => boolean, value: () => any | any];
26
- /**
27
- * @param condition A function to determine if this field
28
- * should be enabled in a form, or disabled. True || 1 = disabled. False || 0 = enabled
29
- */
30
- setDisabled?: () => boolean;
31
- };
1
+ /// <reference path="../globals.d.ts" />
2
+ import * as s from "../constants/symbols.d.ts";
32
3
  export default class DOMNodeReference {
33
4
  target: Element | string;
34
5
  logicalName?: string;
@@ -119,7 +90,6 @@ export default class DOMNodeReference {
119
90
  */
120
91
  show(): DOMNodeReference;
121
92
  /**
122
- *
123
93
  * @param shouldShow - Either a function that returns true or false,
124
94
  * or a natural boolean to determine the visibility of this
125
95
  * @returns - Instance of this [provides option to method chain]
@@ -153,7 +123,6 @@ export default class DOMNodeReference {
153
123
  */
154
124
  enable(): DOMNodeReference;
155
125
  /**
156
- *
157
126
  * @param elements - The elements to prepend to the element targeted by this.
158
127
  * @returns - Instance of this [provides option to method chain]
159
128
  */
@@ -207,7 +176,6 @@ export default class DOMNodeReference {
207
176
  */
208
177
  remove(): this;
209
178
  /**
210
- *
211
179
  * @param options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}
212
180
  * @returns - Instance of this [provides option to method chain]
213
181
  */
@@ -281,4 +249,3 @@ export default class DOMNodeReference {
281
249
  */
282
250
  onceLoaded(callback: (instance: DOMNodeReference) => any): any;
283
251
  }
284
- export {};
@@ -1,4 +1,5 @@
1
- import DOMNodeReference from "./DOMNodeReference.js";
1
+ /// <reference path="../globals.d.ts" />
2
+ import type DOMNodeReference from "./DOMNodeReference.d.ts";
2
3
  export default class DOMNodeReferenceArray extends Array<DOMNodeReference> {
3
4
  /**
4
5
  * Hides all the containers of the DOMNodeReference instances in the array.
@@ -0,0 +1,13 @@
1
+ /// <reference path="../globals.d.ts" />
2
+ export default class List {
3
+ private static _instance;
4
+ private _root;
5
+ private _listItems;
6
+ private _observer;
7
+ private constructor();
8
+ static get(): List;
9
+ private _observe;
10
+ private _update;
11
+ private _destroy;
12
+ destroy(): void;
13
+ }
@@ -0,0 +1,28 @@
1
+ /// <reference path="../globals.d.ts" />
2
+ import type DOMNodeReference from "./DOMNodeReference.d.ts";
3
+ import type DOMNodeReferenceArray from "./DOMNodeReferenceArray.d.ts";
4
+ /**
5
+ * When loading into a page in PowerPages that has a form,
6
+ * you can use this function by passing in the GUID of the form, and you will receive an array/record
7
+ * of {@link DOMNodeReference}s that represent all fields, sections, sub-grids, and tabs of the given form.
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 DOMNodeReference
10
+ * @param formId - The string GUID of the form you want to bind to
11
+ * @returns An array of DOMNodeReferences, accessible as properties of a Record<string, DOMNodeReference> i.e. formProp = form["some_logicalName"]
12
+ * @example
13
+ * ```js
14
+ * bindForm("form-guid-0000").then((form) => {
15
+ * //...use the form
16
+ * const field = form["field_logical_name"]
17
+ * // or
18
+ * form["other_logical_name"].someMethod()
19
+ * })
20
+ *
21
+ * // or
22
+ *
23
+ * const form = await bindForm("form-guid-0000")
24
+ * ```
25
+ * @see {@link BoundForm}
26
+ * @see {@link DOMNodeReference}
27
+ */
28
+ export default function bindForm(formId: string): Promise<DOMNodeReferenceArray & Record<string, DOMNodeReference>>;
@@ -1,14 +1,19 @@
1
- import DOMNodeReference from "./DOMNodeReference.js";
2
- import DOMNodeReferenceArray from "./DOMNodeReferenceArray.js";
1
+ /// <reference path="../globals.d.ts" />
2
+ import DOMNodeReference from "./DOMNodeReference.d.ts";
3
+ import type DOMNodeReferenceArray from "./DOMNodeReferenceArray.d.ts";
3
4
  /**
4
5
  * Creates and initializes a DOMNodeReference instance.
5
6
  * @see {@link CreationOptions}
6
- * @param target The CSS selector for the desired DOM element, or, optionally, the element itself for which to create a DOMNodeReference.
7
- * @param options Options for advanced retrieval of elements
8
- * @param options.multiple - Should this call return an array of instantiated references, or just a single? Defaults to false, returning a single instance
9
- * @param options.root - Optionally specify the element within to search for the element targeted by 'target'. Defaults to 'document.body'
10
- * @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.
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.
11
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}
12
17
  */
13
18
  export default function createDOMNodeReference(target: string | HTMLElement, options?: {
14
19
  /**
@@ -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 "../core/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 };