powerpagestoolkit 2.8.101 → 2.8.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.
@@ -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,7 @@ export default class DOMNodeReference {
70
72
  * @public
71
73
  */
72
74
  updateValue(e?: Event): void;
75
+ protected triggerDependentsHandlers(): Promise<void>;
73
76
  protected validateValue(value: any): any;
74
77
  /**
75
78
  * Sets up an event listener based on the specified event type, executing the specified
@@ -148,7 +151,7 @@ export default class DOMNodeReference {
148
151
  after(...elements: HTMLElement[]): DOMNodeReference;
149
152
  /**
150
153
  * Retrieves the label associated with the HTML element.
151
- * @returns {HTMLElement} The label element associated with this element.
154
+ * @returns The label element associated with this element.
152
155
  */
153
156
  getLabel(): HTMLElement | null;
154
157
  /**
@@ -167,7 +170,7 @@ export default class DOMNodeReference {
167
170
  addTooltip(innerHTML: string, containerStyle?: Partial<CSSStyleDeclaration>): DOMNodeReference;
168
171
  /**
169
172
  * Sets the inner HTML content of the HTML element.
170
- * @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.
171
174
  * @returns - Instance of this [provides option to method chain]
172
175
  */
173
176
  setInnerHTML(string: string): this;
@@ -190,24 +193,21 @@ export default class DOMNodeReference {
190
193
  * Applies a business rule to manage visibility, required state, value, and disabled state dynamically.
191
194
  * @see {@link BusinessRule}
192
195
  * @param rule The business rule containing conditions for various actions.
193
- * @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
194
197
  * @returns Instance of this for method chaining.
195
198
  */
196
199
  applyBusinessRule(rule: BusinessRule, dependencies: DOMNodeReference[]): DOMNodeReference;
200
+ protected createValidator(evaluationFunction: () => boolean): HTMLSpanElement;
197
201
  /**
198
202
  * Sets up tracking for dependencies using both event listeners and mutation observers.
199
203
  * @protected
200
204
  * @param handler The function to execute when dependencies change
201
205
  * @param dependencies Array of dependent DOM nodes to track
202
- * @param options Additional configuration options. clearValuesOnHide defaults to false.
203
206
  * all other options defaults to true
204
207
  */
205
- protected _configDependencyTracking(handler: () => void, dependencies: Array<DOMNodeReference>, options?: {
206
- clearValuesOnHide?: boolean;
207
- observeVisibility?: boolean;
208
- trackInputEvents?: boolean;
209
- trackRadioButtons?: boolean;
210
- }): void;
208
+ protected _configDependencyTracking(handler: DependencyHandlerFunction, dependencies: Array<DOMNodeReference>): void;
209
+ protected getVisibility(): boolean;
210
+ protected receiveNotification(): void;
211
211
  /**
212
212
  * Sets the required level for the field by adding or removing the "required-field" class on the label.
213
213
  *
@@ -70,41 +70,47 @@ declare interface Form extends Partial<SystemForm> {
70
70
  formxml: string;
71
71
  }
72
72
 
73
+ declare type IsValid = (
74
+ this: DOMNodeReference,
75
+ isRequired: ReturnType<Condition>
76
+ ) => boolean;
77
+
73
78
  declare interface BusinessRule {
74
79
  /**
75
80
  * @param condition A function that returns a boolean to determine
76
81
  * the visibility of the target element. If `condition()` returns true, the element is shown;
77
82
  * otherwise, it is hidden.
78
83
 
79
- * @param clearValuesOnHide Should the values in the targeted field be cleared when hidden? Defaults to true
80
84
  */
81
- setVisibility?: [
82
- condition: (this: DOMNodeReference) => boolean,
83
- clearValuesOnHide?: boolean
84
- ];
85
+ setVisibility?: (this: DOMNodeReference) => boolean;
85
86
  /**
86
- * @param isRequired Function determining if field is required
87
- * @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
88
93
  */
89
- setRequired?: [
90
- isRequired: () => boolean,
91
- isValid: (this: DOMNodeReference, isRequired: boolean) => boolean
92
- ];
94
+ setRequirements?: () => {
95
+ isRequired?: (this: DOMNodeReference) => boolean;
96
+ isValid?: (this: DOMNodeReference, isRequiredResult?: boolean) => boolean;
97
+ };
98
+
93
99
  /**
94
100
  * @param condition A function to determine if the value provided should be applied to this field
95
101
  * @param value The value to set for the HTML element.
96
102
  * for parents of boolean radios, pass true or false as value, or
97
103
  * an expression returning a boolean
98
104
  */
99
- setValue?: [
100
- condition: (this: DOMNodeReference) => boolean,
101
- value: (() => any) | any
102
- ];
105
+ setValue?: () => {
106
+ condition: (this: DOMNodeReference) => boolean;
107
+ value: (() => any) | any;
108
+ };
103
109
  /**
104
110
  * @param condition A function to determine if this field
105
111
  * should be enabled in a form, or disabled. True || 1 = disabled. False || 0 = enabled
106
112
  */
107
- setDisabled?: () => boolean;
113
+ setDisabled?: (this: DOMNodeReference) => boolean;
108
114
  }
109
115
 
110
116
  declare interface CreationOptions {
@@ -128,6 +134,16 @@ declare interface CreationOptions {
128
134
  timeoutMs?: number;
129
135
  }
130
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
+
131
147
  declare const Page_Validators: any[];
132
148
 
133
149
  declare interface ElementValue {