powerpagestoolkit 2.7.135 → 2.7.211

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;
@@ -99,6 +70,7 @@ export default class DOMNodeReference {
99
70
  * @public
100
71
  */
101
72
  updateValue(e?: Event): void;
73
+ protected validateValue(value: any): any;
102
74
  /**
103
75
  * Sets up an event listener based on the specified event type, executing the specified
104
76
  * event handler
@@ -119,7 +91,6 @@ export default class DOMNodeReference {
119
91
  */
120
92
  show(): DOMNodeReference;
121
93
  /**
122
- *
123
94
  * @param shouldShow - Either a function that returns true or false,
124
95
  * or a natural boolean to determine the visibility of this
125
96
  * @returns - Instance of this [provides option to method chain]
@@ -153,7 +124,6 @@ export default class DOMNodeReference {
153
124
  */
154
125
  enable(): DOMNodeReference;
155
126
  /**
156
- *
157
127
  * @param elements - The elements to prepend to the element targeted by this.
158
128
  * @returns - Instance of this [provides option to method chain]
159
129
  */
@@ -207,7 +177,6 @@ export default class DOMNodeReference {
207
177
  */
208
178
  remove(): this;
209
179
  /**
210
- *
211
180
  * @param options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}
212
181
  * @returns - Instance of this [provides option to method chain]
213
182
  */
@@ -225,31 +194,6 @@ export default class DOMNodeReference {
225
194
  * @returns Instance of this for method chaining.
226
195
  */
227
196
  applyBusinessRule(rule: BusinessRule, dependencies: DOMNodeReference[]): DOMNodeReference;
228
- /**
229
- * Configures conditional rendering for the target element based on a condition
230
- * and the visibility of one or more trigger elements.
231
- * @deprecated Use the new 'applyBusinessRule Method
232
- * @param condition A function that returns a boolean to determine
233
- * the visibility of the target element. If `condition()` returns true, the element is shown;
234
- * otherwise, it is hidden.
235
- * @param dependencies - An array of `DOMNodeReference` instances. Event listeners are
236
- * registered on each to toggle the visibility of the target element based on the `condition` and the visibility of
237
- * the target node.
238
- * @throws When there's an error in setting up conditional rendering
239
- * @returns Instance of this [provides option to method chain]
240
- */
241
- configureConditionalRendering(condition: () => boolean, dependencies?: Array<DOMNodeReference>, clearValuesOnHide?: boolean): DOMNodeReference;
242
- /**
243
- * Sets up validation and requirement rules for the field with enhanced error handling and dynamic updates.
244
- * @deprecated Use the new 'applyBusinessRule Method
245
- * @param isRequired Function determining if field is required
246
- * @param isValid Function validating field input
247
- * @param fieldDisplayName Display name for error messages
248
- * @param dependencies Fields that trigger requirement/validation updates
249
- * @returns Instance of this
250
- * @throws If validation setup fails
251
- */
252
- configureValidationAndRequirements(isRequired: () => boolean, isValid: () => boolean, fieldDisplayName: string, dependencies: Array<DOMNodeReference>): DOMNodeReference;
253
197
  /**
254
198
  * Sets up tracking for dependencies using both event listeners and mutation observers.
255
199
  * @protected
@@ -281,4 +225,3 @@ export default class DOMNodeReference {
281
225
  */
282
226
  onceLoaded(callback: (instance: DOMNodeReference) => any): any;
283
227
  }
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,152 @@
1
+ /// <reference path="../core/DOMNodeReference.ts"/>
2
+
3
+ declare type EventCallback = () => any;
4
+
5
+ declare interface CreationOptions {
6
+ /**
7
+ * Should this call return an array of instantiated references, or just a single?
8
+ * Defaults to false, returning a single instance.
9
+ */
10
+ multiple?: (() => boolean) | boolean;
11
+
12
+ /**
13
+ * Optionally specify the element within which to search for the element targeted by 'target'.
14
+ * Defaults to 'document.body'.
15
+ */
16
+ root?: HTMLElement;
17
+
18
+ /**
19
+ * Optionally specify the amount of time that should be waited to find the targeted element before throwing an error.
20
+ * Useful for async DOM loading. Relies on MutationObserver.
21
+ * WARNING: Implementing multiple references with timeout can result in infinite loading.
22
+ */
23
+ timeoutMs?: number;
24
+ }
25
+
26
+ declare interface SystemForm extends Object {
27
+ "@odata.context": string;
28
+ "@odata.etag": string;
29
+ "overwritetime@OData.Community.Display.V1.FormattedValue": string;
30
+ overwritetime: Date;
31
+ "isdesktopenabled@OData.Community.Display.V1.FormattedValue": string;
32
+ isdesktopenabled: boolean;
33
+ "publishedon@OData.Community.Display.V1.FormattedValue": Date;
34
+ publishedon: Date;
35
+ "_organizationid_value@OData.Community.Display.V1.FormattedValue": string;
36
+ "_organizationid_value@Microsoft.Dynamics.CRM.associatednavigationproperty": string;
37
+ "_organizationid_value@Microsoft.Dynamics.CRM.lookuplogicalname": string;
38
+ _organizationid_value: string;
39
+ formxml: string;
40
+ introducedversion: string;
41
+ "isairmerged@OData.Community.Display.V1.FormattedValue": string;
42
+ isairmerged: boolean;
43
+ "istabletenabled@OData.Community.Display.V1.FormattedValue": string;
44
+ istabletenabled: boolean;
45
+ solutionid: string;
46
+ formidunique: string;
47
+ "ismanaged@OData.Community.Display.V1.FormattedValue": string;
48
+ ismanaged: boolean;
49
+ "isdefault@OData.Community.Display.V1.FormattedValue": string;
50
+ isdefault: boolean;
51
+ "objecttypecode@OData.Community.Display.V1.FormattedValue": string;
52
+ objecttypecode: string;
53
+ "type@OData.Community.Display.V1.FormattedValue": string;
54
+ type: number;
55
+ "componentstate@OData.Community.Display.V1.FormattedValue": string;
56
+ componentstate: number;
57
+ "formpresentation@OData.Community.Display.V1.FormattedValue": string;
58
+ formpresentation: number;
59
+ "formactivationstate@OData.Community.Display.V1.FormattedValue": string;
60
+ formactivationstate: number;
61
+ name: string;
62
+ "versionnumber@OData.Community.Display.V1.FormattedValue": string;
63
+ versionnumber: number;
64
+ formjson: string;
65
+ description: string;
66
+ formid: string;
67
+ }
68
+
69
+ declare interface Form extends Partial<SystemForm> {
70
+ formxml: string;
71
+ }
72
+
73
+ declare interface BusinessRule {
74
+ /**
75
+ * @param condition A function that returns a boolean to determine
76
+ * the visibility of the target element. If `condition()` returns true, the element is shown;
77
+ * otherwise, it is hidden.
78
+
79
+ * @param clearValuesOnHide Should the values in the targeted field be cleared when hidden? Defaults to true
80
+ */
81
+ setVisibility?: [
82
+ condition: (this: DOMNodeReference) => boolean,
83
+ clearValuesOnHide?: boolean
84
+ ];
85
+ /**
86
+ * @param isRequired Function determining if field is required
87
+ * @param isValid Function validating field input.
88
+ */
89
+ setRequired?: [
90
+ isRequired: () => boolean,
91
+ isValid: (this: DOMNodeReference, isRequired: boolean) => boolean
92
+ ];
93
+ /**
94
+ * @param condition A function to determine if the value provided should be applied to this field
95
+ * @param value The value to set for the HTML element.
96
+ * for parents of boolean radios, pass true or false as value, or
97
+ * an expression returning a boolean
98
+ */
99
+ setValue?: [
100
+ condition: (this: DOMNodeReference) => boolean,
101
+ value: (() => any) | any
102
+ ];
103
+ /**
104
+ * @param condition A function to determine if this field
105
+ * should be enabled in a form, or disabled. True || 1 = disabled. False || 0 = enabled
106
+ */
107
+ setDisabled?: () => boolean;
108
+ }
109
+
110
+ declare interface CreationOptions {
111
+ /**
112
+ * Should this call return an array of instantiated references, or just a single?
113
+ * Defaults to false, returning a single instance.
114
+ */
115
+ multiple?: (() => boolean) | boolean;
116
+
117
+ /**
118
+ * Optionally specify the element within which to search for the element targeted by 'target'.
119
+ * Defaults to 'document.body'.
120
+ */
121
+ root?: HTMLElement;
122
+
123
+ /**
124
+ * Optionally specify the amount of time that should be waited to find the targeted element before throwing an error.
125
+ * Useful for async DOM loading. Relies on MutationObserver.
126
+ * WARNING: Implementing multiple references with timeout can result in infinite loading.
127
+ */
128
+ timeoutMs?: number;
129
+ }
130
+
131
+ declare const Page_Validators: any[];
132
+
133
+ declare interface ElementValue {
134
+ value: any;
135
+ checked?: boolean;
136
+ }
137
+
138
+ declare type RadioType = "truthy" | "falsy";
139
+
140
+ declare interface BoundEventListener {
141
+ element: Element;
142
+ event: keyof HTMLElementEventMap;
143
+ handler: (e: Event) => unknown;
144
+ }
145
+
146
+ declare type FormElement =
147
+ | HTMLInputElement
148
+ | HTMLSelectElement
149
+ | HTMLTextAreaElement
150
+ | HTMLSpanElement
151
+ | HTMLButtonElement
152
+ | 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 };