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.
package/README.md CHANGED
@@ -35,7 +35,7 @@ createRef(
35
35
  options: {
36
36
  multiple: (() => boolean) | boolean = false,
37
37
  root: HTMLElement,
38
- timeout: number
38
+ timeoutMs:number
39
39
  }
40
40
  ): Promise<DOMNodeReference | DOMNodeReference[]>;
41
41
  ```
@@ -66,7 +66,7 @@ createRef takes two main arguments:
66
66
  <pre><code class="language-javascript">{
67
67
  multiple: () => boolean | boolean,
68
68
  root: HTMLElement,
69
- timeout: number
69
+ timeoutMs:number
70
70
  }</code></pre>
71
71
  </td>
72
72
  <td style="border: 1px solid #ddd; padding: 8px;">
@@ -85,10 +85,10 @@ import { createRef } from "powerpagestoolkit";
85
85
  Instantiate one, or multiple instances of a DOMNodeReference, and optionally configure advanced options
86
86
 
87
87
  ```javascript
88
- // Create a single reference
88
+ // Create a single reference (i.e. 'querySelector')
89
89
  const node = await createRef("#myElement");
90
90
 
91
- // Create multiple references
91
+ // Create multiple references (i.e. 'querySelectorAll')
92
92
  const nodes = await createRef(".my-class", { multiple: true });
93
93
 
94
94
  /******************/
@@ -98,7 +98,7 @@ 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 createRef("#target", { timeout: 2000 });
101
+ const node2 = await createRef("#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");
@@ -107,7 +107,7 @@ const node3 = await createRef("#target", { root: otherElement });
107
107
  // implement all options:
108
108
  const nodes2 = await createRef("#target", {
109
109
  multiple: true,
110
- timeout: 4000,
110
+ timeoutMs:4000,
111
111
  root: otherElement,
112
112
  });
113
113
  ```
@@ -142,76 +142,116 @@ node.on("click", function (e) {
142
142
  ...
143
143
  ```
144
144
 
145
- ##### Visibility Control
145
+ ##### Business Rule Application
146
146
 
147
- ```typescript
148
- // Basic visibility
149
- node.hide();
150
- node.show();
151
- ```
147
+ This utility provides a flexible way to dynamically control field visibility, requirement status, values, and enabled states based on dependencies within PowerPages forms.
152
148
 
153
- **_Advanced conditional rendering_**
149
+ _Method Signature:_
154
150
 
155
- Out of the box, Microsoft does not provide PowerPages developers the ability to hide or show fields or form elements based on the value of another field. This method allows such configurations
151
+ ```typescript
152
+ applyBusinessRule(
153
+ rule: BusinessRule,
154
+ dependencies: DOMNodeReference[]
155
+ ): DOMNodeReference; /* Instance of this is returned for optional
156
+ method chaining */
157
+ ```
156
158
 
157
- _Method signature:_
159
+ **BusinessRule Definition**
158
160
 
159
161
  ```typescript
160
- configureConditionalRendering(
162
+ interface BusinessRule {
163
+ setVisibility?: [
161
164
  condition: () => boolean,
162
- dependencies?: DOMNodeReference[],
163
- clearValuesOnHide: boolean = true
164
- ): DOMNodeReference /* Instance of this returned
165
- for optional method chaining */
165
+ clearValuesOnHide?: boolean = true
166
+ ];
167
+ setRequired?: [
168
+ isRequired: () => boolean,
169
+ isValid: () => boolean
170
+ ];
171
+ setValue?: [
172
+ condition: () => boolean,
173
+ value: () => any | any
174
+ ];
175
+ setDisabled?: () => boolean;
176
+ }
166
177
  ```
167
178
 
168
- _Example implementation:_
179
+ ##### Visibility Control
169
180
 
170
181
  ```typescript
171
- node.configureConditionalRendering(
172
- function () // Function to evaluate wether this node should be visible or not
182
+ // Show the 'taxIdField' only when
183
+ // 'businessTypeField' is set to 'Corporation' or 'LLC'
184
+ taxIdField.applyBusinessRule(
173
185
  {
174
- return otherNode.value === "some value";
186
+ setVisibility: [
187
+ () =>
188
+ businessTypeField.value === "Corporation" ||
189
+ businessTypeField.value === "LLC",
190
+ ],
175
191
  },
176
- [otherNode] /* Dependency array | if the values or visibility of these
177
- change, the function is re-evaluated */,
192
+ [businessTypeField] // Re-evaluate when businessTypeField changes
193
+ );
178
194
 
179
- true /* should the values in the targeted elements (this.element)
180
- be cleared if this node is hidden? Default = true */
195
+ // Optionally disable 'clearValuesOnHide':
196
+ taxIdField.applyBusinessRule(
197
+ {
198
+ setVisibility: [
199
+ () =>
200
+ businessTypeField.value === "Corporation" ||
201
+ businessTypeField.value === "LLC",
202
+ false, // defaults to true. False will prevent the fields from losing it's value if it is hidden
203
+ ],
204
+ },
205
+ [businessTypeField] // Re-evaluate when businessTypeField changes
181
206
  );
182
207
  ```
183
208
 
184
209
  ##### Validation and Requirements
185
210
 
186
- This utility enhances PowerPages forms by adding dynamic field validation and conditional requirements based on other field values.
187
-
188
- _Method signature:_
189
-
190
211
  ```typescript
191
- configureValidationAndRequirements(
192
- isRequired: () => boolean,
193
- isValid: () => boolean,
194
- fieldDisplayName: string,
195
- dependencies: DOMNodeReference[]
196
- ): DOMNodeReference; /* instance of this is returned for optional
197
- method chaining */
212
+ // Require 'taxIdField' when 'businessTypeField' is 'Corporation' or 'LLC'
213
+ taxIdField.applyBusinessRule(
214
+ {
215
+ setRequired: [
216
+ function () {
217
+ return (
218
+ businessTypeField.value === "Corporation" ||
219
+ businessTypeField.value === "LLC"
220
+ );
221
+ },
222
+ function () {
223
+ return this.value != null && this.value !== "";
224
+ },
225
+ ],
226
+ },
227
+ [businessTypeField] // Revalidate when businessTypeField changes
228
+ );
198
229
  ```
199
230
 
200
- _Example implementation:_
231
+ ##### Setting Field Values Conditionally
201
232
 
202
233
  ```typescript
203
- node.configureValidationAndRequirements(
204
- // Make field required only when "Yes" is checked
205
- () => dependentNode.yesRadio?.checked ?? false,
206
-
207
- // Basic validation: ensure field isn't empty
208
- function () {
209
- return this.value != null && this.value !== "";
234
+ // Set default industry value when 'businessTypeField' is 'Corporation'
235
+ industryField.applyBusinessRule(
236
+ {
237
+ setValue: [
238
+ () => businessTypeField.value === "Corporation",
239
+ "Corporate"
240
+ ],
210
241
  },
242
+ [businessTypeField] // Apply value when businessTypeField changes
243
+ );
244
+ ```
211
245
 
212
- "Contact Phone", // Shows in error message: "Contact Phone is required"
246
+ ##### Enabling and Disabling Fields
213
247
 
214
- [dependentNode] // Revalidate when dependentNode changes
248
+ ```typescript
249
+ // Disable 'taxIdField' when 'businessTypeField' is 'Individual'
250
+ taxIdField.applyBusinessRule(
251
+ {
252
+ setDisabled: () => businessTypeField.value === "Individual",
253
+ },
254
+ [businessTypeField] // Enable/disable when businessTypeField changes
215
255
  );
216
256
  ```
217
257
 
@@ -261,7 +301,6 @@ _Enabling/Disabling inputs_
261
301
  ```typescript
262
302
  node.disable();
263
303
  node.enable();
264
-
265
304
  ```
266
305
 
267
306
  ##### Label and Tooltip Management
@@ -295,6 +334,89 @@ title.addTooltip("This is an Example of a tooltip!", { color: "red" });
295
334
 
296
335
  ![Example](./assets//infoIconExample.gif)
297
336
 
337
+ Here's an improved markdown documentation with more comprehensive details:
338
+
339
+ ### BindForm Method
340
+
341
+ The `bindForm` method simplifies form element management in DataVerse by providing a semantic and efficient way to access form controls, sections, and tabs.
342
+
343
+ ##### Key Features
344
+
345
+ - Retrieves form definition directly from DataVerse
346
+ - Automatically generates references for:
347
+ - Controls
348
+ - Sections
349
+ - Tabs
350
+
351
+ ##### Element Types
352
+
353
+ | Element Type | Description | Accessibility |
354
+ | ------------ | ------------------------------------------- | ------------------------- |
355
+ | `control` | Includes all form fields and sub-grids | Accessed via logical name |
356
+ | `section` | Standard PowerApps form sections | Accessed via logical name |
357
+ | `tab` | Form tabs corresponding to PowerApps layout | Accessed via logical name |
358
+
359
+ ##### Usage Example
360
+
361
+ ```javascript
362
+ import { bindForm } from "powerpagestoolkit";
363
+
364
+ // Basic form binding
365
+ bindForm("form-guid").then((form) => {
366
+ // Access elements by their logical name
367
+ const nameField = form["name"];
368
+
369
+ // execute custom methods
370
+ nameField.applyBusinessRule(
371
+ {
372
+ setVisibility: [() => someNode.value === "desired value"],
373
+ },
374
+ [someNode]
375
+ );
376
+
377
+ // Or executes methods immediately upon accessing
378
+ form["phonenumber"].addTooltip("Example tooltip text");
379
+ });
380
+ ```
381
+
382
+ ##### Method Signature
383
+
384
+ ```typescript
385
+ /**
386
+ * Binds a form by its GUID and returns a collection of form elements
387
+ * @param formGuid Unique identifier for the form
388
+ * @returns Promise resolving to form element references
389
+ */
390
+ function bindForm(formGuid: string): Promise<DOMNodeReferenceArray & Record<string: DOMNodeReference>>;
391
+ ```
392
+
393
+ ##### Benefits
394
+
395
+ - Reduces code complexity
396
+ - Improves readability
397
+ - Provides type-safe access to form elements
398
+ - Supports flexible form interactions
399
+
400
+ ##### Best Practices
401
+
402
+ - Use logical names consistently
403
+ - Handle async nature of form binding
404
+ - Leverage TypeScript for enhanced type checking
405
+
406
+ ##### Error Handling
407
+
408
+ Ensure proper error handling for form binding:
409
+
410
+ ```javascript
411
+ bindForm("form-guid")
412
+ .then((form) => {
413
+ // Form processing
414
+ })
415
+ .catch((error) => {
416
+ console.error("Form binding failed", error);
417
+ });
418
+ ```
419
+
298
420
  ### DataVerse API
299
421
 
300
422
  Perform secure API calls to DataVerse from your PowerPages site. This method implements the shell deferred token to send requests with `__RequestVerificationToken`
@@ -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;
@@ -0,0 +1,14 @@
1
+ /// <reference path="../globals.d.ts" />
2
+ export declare const init: unique symbol;
3
+ export declare const destroy: unique symbol;
4
+ export declare const valueSync: unique symbol;
5
+ export declare const dateSync: unique symbol;
6
+ export declare const getElementValue: unique symbol;
7
+ export declare const attachVisibilityController: unique symbol;
8
+ export declare const attachRadioButtons: unique symbol;
9
+ export declare const bindMethods: unique symbol;
10
+ export declare const debounceTime: unique symbol;
11
+ export declare const observers: unique symbol;
12
+ export declare const boundEventListeners: unique symbol;
13
+ export declare const isValidFormElement: unique symbol;
14
+ export declare const registerEventListener: 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,54 +1,16 @@
1
- interface IBusinessRule {
2
- /**
3
- * @param condition A function that returns a boolean to determine
4
- * the visibility of the target element. If `condition()` returns true, the element is shown;
5
- * otherwise, it is hidden.
6
-
7
- * @param clearValuesOnHide Should the values in the targeted field be cleared when hidden? Defaults to true
8
- */
9
- setVisibility?: [condition: () => boolean, clearValuesOnHide?: boolean];
10
- /**
11
- * @param isRequired Function determining if field is required
12
- * @param isValid Function validating field input. allows access to the invoked expression passed by {@link isRequired}
13
- */
14
- setRequired?: [
15
- isRequired: () => boolean,
16
- isValid: (isRequired: () => boolean) => boolean
17
- ];
18
- /**
19
- * @param condition A function to determine if the value provided should be applied to this field
20
- * @param value The value to set for the HTML element.
21
- * for parents of boolean radios, pass true or false as value, or
22
- * an expression returning a boolean
23
- */
24
- setValue?: [condition: () => boolean, value: any];
25
- /**
26
- * @param condition A function to determine if this field
27
- * should be enabled in a form, or disabled. True || 1 = disabled. False || 0 = enabled
28
- */
29
- setDisabled?: [condition: () => boolean];
30
- }
31
- export declare const _init: unique symbol;
32
- declare const _destroy: unique symbol;
33
- declare const _valueSync: unique symbol;
34
- declare const _dateSync: unique symbol;
35
- declare const _getElementValue: unique symbol;
36
- declare const _updateRadioGroup: unique symbol;
37
- declare const _attachVisibilityController: unique symbol;
38
- declare const _attachRadioButtons: unique symbol;
39
- declare const _bindMethods: unique symbol;
40
- declare const _debounceTime: unique symbol;
41
- declare const _observers: unique symbol;
42
- declare const _boundEventListeners: unique symbol;
1
+ /// <reference path="../globals.d.ts" />
2
+ import * as s from "../constants/symbols.d.ts";
43
3
  export default class DOMNodeReference {
44
4
  target: Element | string;
45
5
  logicalName?: string;
46
6
  root: Element;
47
- private [_debounceTime];
48
- private isLoaded;
49
- private defaultDisplay;
50
- private [_observers];
51
- private [_boundEventListeners];
7
+ protected [s.debounceTime]: number;
8
+ protected isLoaded: boolean;
9
+ protected defaultDisplay: string;
10
+ protected [s.observers]: Array<MutationObserver>;
11
+ protected [s.boundEventListeners]: Array<BoundEventListener>;
12
+ protected isRadio: boolean;
13
+ protected radioType: RadioType | null;
52
14
  /**
53
15
  * The value of the element that this node represents
54
16
  * stays in syncs with the live DOM elements?.,m via event handler
@@ -60,7 +22,7 @@ export default class DOMNodeReference {
60
22
  * or access properties not available through this class.
61
23
  */
62
24
  element: HTMLElement;
63
- private visibilityController;
25
+ protected visibilityController: HTMLElement;
64
26
  checked: boolean;
65
27
  /**
66
28
  * Represents the 'yes' option of a boolean radio field.
@@ -81,35 +43,33 @@ export default class DOMNodeReference {
81
43
  * Defaults to 'document.body'
82
44
  */
83
45
  /******/ /******/ constructor(target: Element | string, root: Element | undefined, debounceTime: number);
84
- [_init](): Promise<void>;
85
- private eventMapping;
46
+ private extractLogicalName;
47
+ [s.init](): Promise<void>;
86
48
  /**
87
49
  * Initializes value synchronization with appropriate event listeners
88
50
  * based on element type.
89
- * @private
90
51
  */
91
- private [_valueSync];
92
- private [_dateSync];
52
+ protected [s.valueSync](): void;
53
+ private determineEventType;
54
+ private isDateInput;
55
+ protected [s.isValidFormElement](element: Element): element is FormElement;
56
+ protected [s.registerEventListener](element: Element, eventType: keyof HTMLElementEventMap, handler: (e: Event) => unknown): void;
57
+ protected [s.dateSync](element: HTMLInputElement): Promise<void>;
93
58
  /**
94
59
  * Gets the current value of the element based on its type
95
- * @private
60
+ * @protected
96
61
  * @returns Object containing value and optional checked state
97
62
  */
98
- private [_getElementValue];
99
- /**
100
- * Updates related radio buttons if this is part of a radio group
101
- * @private
102
- */
103
- private [_updateRadioGroup];
104
- private [_attachVisibilityController];
105
- private [_attachRadioButtons];
106
- private [_bindMethods];
107
- private [_destroy];
63
+ protected [s.getElementValue](): ElementValue;
64
+ protected [s.attachVisibilityController](): void;
65
+ protected [s.attachRadioButtons](): Promise<void>;
66
+ protected [s.bindMethods](): void;
67
+ protected [s.destroy](): void;
108
68
  /**
109
69
  * Updates the value and checked state based on element type
110
70
  * @public
111
71
  */
112
- updateValue(): void;
72
+ updateValue(e?: Event): void;
113
73
  /**
114
74
  * Sets up an event listener based on the specified event type, executing the specified
115
75
  * event handler
@@ -130,7 +90,6 @@ export default class DOMNodeReference {
130
90
  */
131
91
  show(): DOMNodeReference;
132
92
  /**
133
- *
134
93
  * @param shouldShow - Either a function that returns true or false,
135
94
  * or a natural boolean to determine the visibility of this
136
95
  * @returns - Instance of this [provides option to method chain]
@@ -164,7 +123,6 @@ export default class DOMNodeReference {
164
123
  */
165
124
  enable(): DOMNodeReference;
166
125
  /**
167
- *
168
126
  * @param elements - The elements to prepend to the element targeted by this.
169
127
  * @returns - Instance of this [provides option to method chain]
170
128
  */
@@ -218,7 +176,6 @@ export default class DOMNodeReference {
218
176
  */
219
177
  remove(): this;
220
178
  /**
221
- *
222
179
  * @param options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}
223
180
  * @returns - Instance of this [provides option to method chain]
224
181
  */
@@ -230,12 +187,12 @@ export default class DOMNodeReference {
230
187
  uncheckRadios(): DOMNodeReference;
231
188
  /**
232
189
  * Applies a business rule to manage visibility, required state, value, and disabled state dynamically.
233
- *
190
+ * @see {@link BusinessRule}
234
191
  * @param rule The business rule containing conditions for various actions.
235
192
  * @param dependencies For re-evaluation conditions when the state of the dependencies change
236
193
  * @returns Instance of this for method chaining.
237
194
  */
238
- applyBusinessRule(rule: IBusinessRule, dependencies: DOMNodeReference[]): DOMNodeReference;
195
+ applyBusinessRule(rule: BusinessRule, dependencies: DOMNodeReference[]): DOMNodeReference;
239
196
  /**
240
197
  * Configures conditional rendering for the target element based on a condition
241
198
  * and the visibility of one or more trigger elements.
@@ -263,13 +220,18 @@ export default class DOMNodeReference {
263
220
  configureValidationAndRequirements(isRequired: () => boolean, isValid: () => boolean, fieldDisplayName: string, dependencies: Array<DOMNodeReference>): DOMNodeReference;
264
221
  /**
265
222
  * Sets up tracking for dependencies using both event listeners and mutation observers.
266
- * @private
223
+ * @protected
267
224
  * @param handler The function to execute when dependencies change
268
225
  * @param dependencies Array of dependent DOM nodes to track
269
226
  * @param options Additional configuration options. clearValuesOnHide defaults to false.
270
227
  * all other options defaults to true
271
228
  */
272
- private _configDependencyTracking;
229
+ protected _configDependencyTracking(handler: () => void, dependencies: Array<DOMNodeReference>, options?: {
230
+ clearValuesOnHide?: boolean;
231
+ observeVisibility?: boolean;
232
+ trackInputEvents?: boolean;
233
+ trackRadioButtons?: boolean;
234
+ }): void;
273
235
  /**
274
236
  * Sets the required level for the field by adding or removing the "required-field" class on the label.
275
237
  *
@@ -287,4 +249,3 @@ export default class DOMNodeReference {
287
249
  */
288
250
  onceLoaded(callback: (instance: DOMNodeReference) => any): any;
289
251
  }
290
- export {};
@@ -1,5 +1,6 @@
1
- import DOMNodeReference from "./DOMNodeReference.js";
2
- export declare class DOMNodeReferenceArray extends Array<DOMNodeReference> {
1
+ /// <reference path="../globals.d.ts" />
2
+ import type DOMNodeReference from "./DOMNodeReference.d.ts";
3
+ export default class DOMNodeReferenceArray extends Array<DOMNodeReference> {
3
4
  /**
4
5
  * Hides all the containers of the DOMNodeReference instances in the array.
5
6
  */
@@ -9,4 +10,3 @@ export declare class DOMNodeReferenceArray extends Array<DOMNodeReference> {
9
10
  */
10
11
  showAll(this: DOMNodeReferenceArray): DOMNodeReferenceArray;
11
12
  }
12
- export declare function enhanceArray<T extends string>(array: DOMNodeReference[]): DOMNodeReferenceArray & Record<T, DOMNodeReference>;
@@ -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>>;