powerpagestoolkit 2.7.1443 → 2.8.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.
@@ -1,4 +1,7 @@
1
1
  /// <reference path="../globals.d.ts" />
2
+ interface ODataJSON extends object {
3
+ [key: `${string}@odata.bind` | string]: any;
4
+ }
2
5
  /**
3
6
  * Provides abstract class `API` that allows basic create, read, and update operations in DataVerse via the PowerPages API
4
7
  * @method `createRecord` - Create a record in DataVerse
@@ -12,7 +15,7 @@ declare abstract class API {
12
15
  * @param data The JSON of the fields and data that are to be updated on the targeted record
13
16
  * @returns a Promise resolving the successful results *[record id]* of the POST request, or rejecting the failed results *[error]* of the POST request.
14
17
  */
15
- static createRecord(tableSetName: string, data: JSON): Promise<string>;
18
+ static createRecord(tableSetName: string, data: ODataJSON): Promise<string>;
16
19
  /**
17
20
  *
18
21
  * @param tableSetName The DataVerse SET name of the table being queried
@@ -35,6 +38,6 @@ declare abstract class API {
35
38
  * @param data The JSON of the fields and data that are to be updated on the targeted record
36
39
  * @returns A Promise with the results of the API execution
37
40
  */
38
- static updateRecord(tableSetName: string, recordId: string, data: object): Promise<any>;
41
+ static updateRecord(tableSetName: string, recordId: string, data: ODataJSON): Promise<any>;
39
42
  }
40
43
  export default API;
@@ -4,11 +4,12 @@ export default class DOMNodeReference {
4
4
  target: Element | string;
5
5
  logicalName?: string;
6
6
  root: Element;
7
- protected [s.debounceTime]: number;
7
+ protected timeoutMs: number;
8
8
  protected isLoaded: boolean;
9
9
  protected defaultDisplay: string;
10
- protected [s.observers]: Array<MutationObserver>;
10
+ protected [s.observers]: Array<MutationObserver | ResizeObserver>;
11
11
  protected [s.boundEventListeners]: Array<BoundEventListener>;
12
+ protected dependents: Dependants;
12
13
  protected isRadio: boolean;
13
14
  protected radioType: RadioType | null;
14
15
  /**
@@ -24,6 +25,7 @@ export default class DOMNodeReference {
24
25
  element: HTMLElement;
25
26
  protected visibilityController: HTMLElement;
26
27
  checked: boolean;
28
+ radioParent: DOMNodeReference | null;
27
29
  /**
28
30
  * Represents the 'yes' option of a boolean radio field.
29
31
  * This property is only available when the parent node
@@ -42,7 +44,7 @@ export default class DOMNodeReference {
42
44
  * @param root - Optionally specify the element within to search for the element targeted by 'target'
43
45
  * Defaults to 'document.body'
44
46
  */
45
- /******/ /******/ constructor(target: Element | string, root: Element | undefined, debounceTime: number);
47
+ /******/ /******/ constructor(target: Element | string, root: Element | undefined, timeoutMs: number);
46
48
  private extractLogicalName;
47
49
  [s.init](): Promise<void>;
48
50
  /**
@@ -70,6 +72,8 @@ export default class DOMNodeReference {
70
72
  * @public
71
73
  */
72
74
  updateValue(e?: Event): void;
75
+ protected triggerDependentsHandlers(): Promise<void>;
76
+ protected validateValue(value: any): any;
73
77
  /**
74
78
  * Sets up an event listener based on the specified event type, executing the specified
75
79
  * event handler
@@ -147,7 +151,7 @@ export default class DOMNodeReference {
147
151
  after(...elements: HTMLElement[]): DOMNodeReference;
148
152
  /**
149
153
  * Retrieves the label associated with the HTML element.
150
- * @returns {HTMLElement} The label element associated with this element.
154
+ * @returns The label element associated with this element.
151
155
  */
152
156
  getLabel(): HTMLElement | null;
153
157
  /**
@@ -166,7 +170,7 @@ export default class DOMNodeReference {
166
170
  addTooltip(innerHTML: string, containerStyle?: Partial<CSSStyleDeclaration>): DOMNodeReference;
167
171
  /**
168
172
  * Sets the inner HTML content of the HTML element.
169
- * @param {string} string - The text to set as the inner HTML of the element.
173
+ * @param string - The text to set as the inner HTML of the element.
170
174
  * @returns - Instance of this [provides option to method chain]
171
175
  */
172
176
  setInnerHTML(string: string): this;
@@ -189,49 +193,21 @@ export default class DOMNodeReference {
189
193
  * Applies a business rule to manage visibility, required state, value, and disabled state dynamically.
190
194
  * @see {@link BusinessRule}
191
195
  * @param rule The business rule containing conditions for various actions.
192
- * @param dependencies For re-evaluation conditions when the state of the dependencies change
196
+ * @param dependencies For re-evaluation of conditions when the state of the dependencies change
193
197
  * @returns Instance of this for method chaining.
194
198
  */
195
199
  applyBusinessRule(rule: BusinessRule, dependencies: DOMNodeReference[]): DOMNodeReference;
196
- /**
197
- * Configures conditional rendering for the target element based on a condition
198
- * and the visibility of one or more trigger elements.
199
- * @deprecated Use the new 'applyBusinessRule Method
200
- * @param condition A function that returns a boolean to determine
201
- * the visibility of the target element. If `condition()` returns true, the element is shown;
202
- * otherwise, it is hidden.
203
- * @param dependencies - An array of `DOMNodeReference` instances. Event listeners are
204
- * registered on each to toggle the visibility of the target element based on the `condition` and the visibility of
205
- * the target node.
206
- * @throws When there's an error in setting up conditional rendering
207
- * @returns Instance of this [provides option to method chain]
208
- */
209
- configureConditionalRendering(condition: () => boolean, dependencies?: Array<DOMNodeReference>, clearValuesOnHide?: boolean): DOMNodeReference;
210
- /**
211
- * Sets up validation and requirement rules for the field with enhanced error handling and dynamic updates.
212
- * @deprecated Use the new 'applyBusinessRule Method
213
- * @param isRequired Function determining if field is required
214
- * @param isValid Function validating field input
215
- * @param fieldDisplayName Display name for error messages
216
- * @param dependencies Fields that trigger requirement/validation updates
217
- * @returns Instance of this
218
- * @throws If validation setup fails
219
- */
220
- configureValidationAndRequirements(isRequired: () => boolean, isValid: () => boolean, fieldDisplayName: string, dependencies: Array<DOMNodeReference>): DOMNodeReference;
200
+ protected createValidator(evaluationFunction: () => boolean): HTMLSpanElement;
221
201
  /**
222
202
  * Sets up tracking for dependencies using both event listeners and mutation observers.
223
203
  * @protected
224
204
  * @param handler The function to execute when dependencies change
225
205
  * @param dependencies Array of dependent DOM nodes to track
226
- * @param options Additional configuration options. clearValuesOnHide defaults to false.
227
206
  * all other options defaults to true
228
207
  */
229
- protected _configDependencyTracking(handler: () => void, dependencies: Array<DOMNodeReference>, options?: {
230
- clearValuesOnHide?: boolean;
231
- observeVisibility?: boolean;
232
- trackInputEvents?: boolean;
233
- trackRadioButtons?: boolean;
234
- }): void;
208
+ protected _configDependencyTracking(handler: DependencyHandlerFunction, dependencies: Array<DOMNodeReference>): void;
209
+ protected getVisibility(): boolean;
210
+ protected receiveNotification(): void;
235
211
  /**
236
212
  * Sets the required level for the field by adding or removing the "required-field" class on the label.
237
213
  *
@@ -1,5 +1,7 @@
1
1
  /// <reference path="../core/DOMNodeReference.ts"/>
2
2
 
3
+ declare type EventCallback = () => any;
4
+
3
5
  declare interface CreationOptions {
4
6
  /**
5
7
  * Should this call return an array of instantiated references, or just a single?
@@ -68,41 +70,47 @@ declare interface Form extends Partial<SystemForm> {
68
70
  formxml: string;
69
71
  }
70
72
 
73
+ declare type IsValid = (
74
+ this: DOMNodeReference,
75
+ isRequired: ReturnType<Condition>
76
+ ) => boolean;
77
+
71
78
  declare interface BusinessRule {
72
79
  /**
73
80
  * @param condition A function that returns a boolean to determine
74
81
  * the visibility of the target element. If `condition()` returns true, the element is shown;
75
82
  * otherwise, it is hidden.
76
83
 
77
- * @param clearValuesOnHide Should the values in the targeted field be cleared when hidden? Defaults to true
78
84
  */
79
- setVisibility?: [
80
- condition: (this: DOMNodeReference) => boolean,
81
- clearValuesOnHide?: boolean
82
- ];
85
+ setVisibility?: (this: DOMNodeReference) => boolean;
83
86
  /**
84
- * @param isRequired Function determining if field is required
85
- * @param isValid Function validating field input.
87
+ * Configuration function for determining the required level, and field validity of the given fields
88
+ * @param isRequired - Function determining if field is required
89
+ * @param isRequired.this - Reference to this DOMNodeReference
90
+ * @param isValid - Function validating field input.
91
+ * @param isValid.this - Reference to this DOMNodeReference
92
+ * @param isValid.isRequiredResult - Only available if 'isRequired' is also returned from the configuration function
86
93
  */
87
- setRequired?: [
88
- isRequired: () => boolean,
89
- isValid: (this: DOMNodeReference, isRequired: boolean) => boolean
90
- ];
94
+ setRequirements?: () => {
95
+ isRequired?: (this: DOMNodeReference) => boolean;
96
+ isValid?: (this: DOMNodeReference, isRequiredResult?: boolean) => boolean;
97
+ };
98
+
91
99
  /**
92
100
  * @param condition A function to determine if the value provided should be applied to this field
93
101
  * @param value The value to set for the HTML element.
94
102
  * for parents of boolean radios, pass true or false as value, or
95
103
  * an expression returning a boolean
96
104
  */
97
- setValue?: [
98
- condition: (this: DOMNodeReference) => boolean,
99
- value: () => any | any
100
- ];
105
+ setValue?: () => {
106
+ condition: (this: DOMNodeReference) => boolean;
107
+ value: (() => any) | any;
108
+ };
101
109
  /**
102
110
  * @param condition A function to determine if this field
103
111
  * should be enabled in a form, or disabled. True || 1 = disabled. False || 0 = enabled
104
112
  */
105
- setDisabled?: () => boolean;
113
+ setDisabled?: (this: DOMNodeReference) => boolean;
106
114
  }
107
115
 
108
116
  declare interface CreationOptions {
@@ -126,6 +134,16 @@ declare interface CreationOptions {
126
134
  timeoutMs?: number;
127
135
  }
128
136
 
137
+ declare type DependencyHandlerFunction = () => Promise<void>;
138
+
139
+ declare type Dependants = Map<DOMNodeReference, DependencyHandlerFunction>;
140
+
141
+ declare type ValueElement =
142
+ | HTMLInputElement
143
+ | HTMLSelectElement
144
+ | HTMLTextAreaElement
145
+ | HTMLOptionElement;
146
+
129
147
  declare const Page_Validators: any[];
130
148
 
131
149
  declare interface ElementValue {