powerpagestoolkit 2.7.1420 → 2.7.1433
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/dist/src/constants/eventMapping.d.ts +5 -0
- package/dist/src/constants/symbols.d.ts +1 -0
- package/dist/src/core/API.d.ts +7 -4
- package/dist/src/core/DOMNodeReference.d.ts +1 -3
- package/dist/src/core/DOMNodeReferenceArray.d.ts +1 -0
- package/dist/src/core/List.d.ts +13 -0
- package/dist/src/core/bindForm.d.ts +15 -12
- package/dist/src/core/createDOMNodeReferences.d.ts +5 -5
- package/dist/src/core/waitFor.d.ts +6 -3
- package/dist/src/errors/errors.d.ts +1 -0
- package/dist/src/globals.d.ts +1 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +11 -19
- package/dist/src/index.js.map +2 -2
- package/dist/src/managers/ReferenceManager.d.ts +1 -0
- package/dist/src/utils/createInfoElement.d.ts +1 -0
- package/dist/src/utils/enhanceArray.d.ts +10 -0
- package/dist/src/utils/safeAjax.d.ts +4 -0
- package/package.json +1 -1
- package/dist/README.md +0 -508
|
@@ -1,2 +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
|
+
*/
|
|
1
6
|
declare const eventMapping: Record<string, keyof HTMLElementEventMap>;
|
|
2
7
|
export default eventMapping;
|
package/dist/src/core/API.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
|
5
8
|
*/
|
|
6
9
|
declare abstract class API {
|
|
7
10
|
/**
|
|
@@ -9,7 +12,7 @@ declare abstract class API {
|
|
|
9
12
|
* @param data The JSON of the fields and data that are to be updated on the targeted record
|
|
10
13
|
* @returns a Promise resolving the successful results *[record id]* of the POST request, or rejecting the failed results *[error]* of the POST request.
|
|
11
14
|
*/
|
|
12
|
-
static createRecord(tableSetName: string, data:
|
|
15
|
+
static createRecord(tableSetName: string, data: JSON): Promise<string>;
|
|
13
16
|
/**
|
|
14
17
|
*
|
|
15
18
|
* @param tableSetName The DataVerse SET name of the table being queried
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
1
2
|
import * as s from "../constants/symbols.d.ts";
|
|
2
3
|
export default class DOMNodeReference {
|
|
3
4
|
target: Element | string;
|
|
@@ -89,7 +90,6 @@ export default class DOMNodeReference {
|
|
|
89
90
|
*/
|
|
90
91
|
show(): DOMNodeReference;
|
|
91
92
|
/**
|
|
92
|
-
*
|
|
93
93
|
* @param shouldShow - Either a function that returns true or false,
|
|
94
94
|
* or a natural boolean to determine the visibility of this
|
|
95
95
|
* @returns - Instance of this [provides option to method chain]
|
|
@@ -123,7 +123,6 @@ export default class DOMNodeReference {
|
|
|
123
123
|
*/
|
|
124
124
|
enable(): DOMNodeReference;
|
|
125
125
|
/**
|
|
126
|
-
*
|
|
127
126
|
* @param elements - The elements to prepend to the element targeted by this.
|
|
128
127
|
* @returns - Instance of this [provides option to method chain]
|
|
129
128
|
*/
|
|
@@ -177,7 +176,6 @@ export default class DOMNodeReference {
|
|
|
177
176
|
*/
|
|
178
177
|
remove(): this;
|
|
179
178
|
/**
|
|
180
|
-
*
|
|
181
179
|
* @param options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}
|
|
182
180
|
* @returns - Instance of this [provides option to method chain]
|
|
183
181
|
*/
|
|
@@ -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
|
+
}
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
1
2
|
/**
|
|
2
3
|
* @module
|
|
3
|
-
* This module provides the bindForm function. When loading into a page in PowerPages that has a form,
|
|
4
|
-
* you can use this function by passing in the GUID of the form, and you will receive an array/record
|
|
5
|
-
* of DOMNodeReferences that represent all fields, sections, sub-grids, and tabs of the given form.
|
|
6
|
-
* @see {@link DOMNodeReference}
|
|
7
|
-
* Access these properties of the BoundForm {@link BoundForm} using the logical name of the control you need to access: form['logical_name']
|
|
8
|
-
* you can then execute all the methods available from DOMNodeReference
|
|
9
4
|
*/
|
|
5
|
+
import type DOMNodeReference from "./DOMNodeReference.d.ts";
|
|
6
|
+
import type DOMNodeReferenceArray from "./DOMNodeReferenceArray.d.ts";
|
|
10
7
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* When loading into a page in PowerPages that has a form,
|
|
9
|
+
* you can use this function by passing in the GUID of the form, and you will receive an array/record
|
|
10
|
+
* of {@link DOMNodeReference}s that represent all fields, sections, sub-grids, and tabs of the given form.
|
|
11
|
+
* Access these properties of the {@link BoundForm} using the logical name of the control you need to access: form['logical_name']
|
|
12
|
+
* you can then execute all the methods available from DOMNodeReference
|
|
14
13
|
* @param formId - The string GUID of the form you want to bind to
|
|
15
|
-
* @callback `callbackFn` - Function to execute after the form has been retrieved and bound; the form itself is provided as the argument
|
|
16
14
|
* @returns An array of DOMNodeReferences, accessible as properties of a Record<string, DOMNodeReference> i.e. formProp = form["some_logicalName"]
|
|
17
15
|
* @example
|
|
18
16
|
* ```js
|
|
19
|
-
* bindForm("
|
|
17
|
+
* bindForm("form-guid-0000").then((form) => {
|
|
20
18
|
* //...use the form
|
|
21
19
|
* const field = form["field_logical_name"]
|
|
22
20
|
* // or
|
|
23
21
|
* form["other_logical_name"].someMethod()
|
|
24
22
|
* })
|
|
23
|
+
*
|
|
24
|
+
* // or
|
|
25
|
+
*
|
|
26
|
+
* const form = await bindForm("form-guid-0000")
|
|
25
27
|
* ```
|
|
26
28
|
* @see {@link BoundForm}
|
|
29
|
+
* @see {@link DOMNodeReference}
|
|
27
30
|
*/
|
|
28
|
-
export default function bindForm(formId: string
|
|
31
|
+
export default function bindForm(formId: string): Promise<DOMNodeReferenceArray & Record<string, DOMNodeReference>>;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @module createRef
|
|
3
|
-
* Provides a factory function for creating new DOMNodeReferences
|
|
4
|
-
* @see {@link DOMNodeReference}
|
|
5
|
-
*/
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
6
2
|
import DOMNodeReference from "./DOMNodeReference.d.ts";
|
|
7
3
|
import type DOMNodeReferenceArray from "./DOMNodeReferenceArray.d.ts";
|
|
8
4
|
/**
|
|
@@ -14,6 +10,10 @@ import type DOMNodeReferenceArray from "./DOMNodeReferenceArray.d.ts";
|
|
|
14
10
|
* @param **options.root** - Optionally specify the element within to search for the element targeted by 'target'. Defaults to `document.body`
|
|
15
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.
|
|
16
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}
|
|
17
17
|
*/
|
|
18
18
|
export default function createDOMNodeReference(target: string | HTMLElement, options?: {
|
|
19
19
|
/**
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
1
2
|
/**
|
|
2
|
-
* @module waitFor
|
|
3
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
|
|
4
7
|
*/
|
|
5
|
-
export default function waitFor(target:
|
|
6
|
-
export default function waitFor(target:
|
|
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[]>;
|
package/dist/src/globals.d.ts
CHANGED
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference path="../globals.d.ts" />
|
|
1
2
|
import API from "./core/API.d.ts";
|
|
2
3
|
import createRef from "./core/createDOMNodeReferences.d.ts";
|
|
3
4
|
import waitFor from "./core/waitFor.d.ts";
|
|
4
5
|
import bindForm from "./core/bindForm.d.ts";
|
|
5
|
-
export { API, createRef, waitFor
|
|
6
|
+
export { API, bindForm, createRef, waitFor };
|
package/dist/src/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var API = class {
|
|
|
35
35
|
url: `/_api/${tableSetName}`,
|
|
36
36
|
data: JSON.stringify(data),
|
|
37
37
|
contentType: "application/json",
|
|
38
|
-
success: function(
|
|
38
|
+
success: function(_response, _status, xhr) {
|
|
39
39
|
resolve(xhr.getResponseHeader("entityid"));
|
|
40
40
|
},
|
|
41
41
|
error: (error) => {
|
|
@@ -159,10 +159,6 @@ function waitFor(target, root = document, multiple = false, debounceTime2) {
|
|
|
159
159
|
)
|
|
160
160
|
);
|
|
161
161
|
}, debounceTime2);
|
|
162
|
-
if (target instanceof HTMLElement) {
|
|
163
|
-
clearTimeout(timeout);
|
|
164
|
-
return resolve(target);
|
|
165
|
-
}
|
|
166
162
|
const element = root.querySelector(target);
|
|
167
163
|
if (element) {
|
|
168
164
|
clearTimeout(timeout);
|
|
@@ -458,13 +454,15 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
458
454
|
return {
|
|
459
455
|
value: input.value !== "" ? Number(input.value) : null
|
|
460
456
|
};
|
|
461
|
-
default:
|
|
457
|
+
default: {
|
|
462
458
|
let cleanValue = input.value;
|
|
463
|
-
if (this.element.classList.contains("decimal") || this.element.classList.contains("money"))
|
|
459
|
+
if (this.element.classList.contains("decimal") || this.element.classList.contains("money")) {
|
|
464
460
|
cleanValue = input.value.replace(/[$,]/g, "");
|
|
461
|
+
}
|
|
465
462
|
return {
|
|
466
463
|
value: this.element.classList.contains("decimal") || this.element.classList.contains("money") ? parseFloat(cleanValue) : cleanValue
|
|
467
464
|
};
|
|
465
|
+
}
|
|
468
466
|
}
|
|
469
467
|
}
|
|
470
468
|
[attachVisibilityController]() {
|
|
@@ -588,7 +586,6 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
588
586
|
return this;
|
|
589
587
|
}
|
|
590
588
|
/**
|
|
591
|
-
*
|
|
592
589
|
* @param shouldShow - Either a function that returns true or false,
|
|
593
590
|
* or a natural boolean to determine the visibility of this
|
|
594
591
|
* @returns - Instance of this [provides option to method chain]
|
|
@@ -722,7 +719,7 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
722
719
|
enable() {
|
|
723
720
|
try {
|
|
724
721
|
this.element.disabled = false;
|
|
725
|
-
} catch (
|
|
722
|
+
} catch (_error) {
|
|
726
723
|
throw new Error(
|
|
727
724
|
`There was an error trying to disable the target: ${this.target}`
|
|
728
725
|
);
|
|
@@ -730,7 +727,6 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
730
727
|
return this;
|
|
731
728
|
}
|
|
732
729
|
/**
|
|
733
|
-
*
|
|
734
730
|
* @param elements - The elements to prepend to the element targeted by this.
|
|
735
731
|
* @returns - Instance of this [provides option to method chain]
|
|
736
732
|
*/
|
|
@@ -812,7 +808,6 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
812
808
|
return this;
|
|
813
809
|
}
|
|
814
810
|
/**
|
|
815
|
-
*
|
|
816
811
|
* @param options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}
|
|
817
812
|
* @returns - Instance of this [provides option to method chain]
|
|
818
813
|
*/
|
|
@@ -873,12 +868,13 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
873
868
|
const [isRequired, isValid] = rule.setRequired;
|
|
874
869
|
const fieldDisplayName = (() => {
|
|
875
870
|
let label = this.getLabel();
|
|
876
|
-
if (!label)
|
|
871
|
+
if (!label) {
|
|
877
872
|
return new Error(
|
|
878
873
|
`There was an error accessing the label for this element: ${String(
|
|
879
874
|
this.target
|
|
880
875
|
)}`
|
|
881
876
|
);
|
|
877
|
+
}
|
|
882
878
|
label = label.innerHTML;
|
|
883
879
|
if (label.length > 50) {
|
|
884
880
|
label = label.substring(0, 50) + "...";
|
|
@@ -1285,7 +1281,7 @@ function createProxyHandler() {
|
|
|
1285
1281
|
}
|
|
1286
1282
|
|
|
1287
1283
|
// src/core/bindForm.ts
|
|
1288
|
-
async function bindForm(formId
|
|
1284
|
+
async function bindForm(formId) {
|
|
1289
1285
|
try {
|
|
1290
1286
|
const form = await API_default.getRecord("systemforms", formId);
|
|
1291
1287
|
const { formxml } = form;
|
|
@@ -1295,11 +1291,6 @@ async function bindForm(formId, callbackFn) {
|
|
|
1295
1291
|
const sections = processElements(xmlDoc.getElementsByTagName("section"));
|
|
1296
1292
|
const tabs = processElements(xmlDoc.getElementsByTagName("tab"));
|
|
1297
1293
|
const resolvedRefs = await Promise.all([...controls, ...sections, ...tabs]);
|
|
1298
|
-
callbackFn(
|
|
1299
|
-
enhanceArray(
|
|
1300
|
-
resolvedRefs.filter((ref) => ref !== null)
|
|
1301
|
-
)
|
|
1302
|
-
);
|
|
1303
1294
|
return enhanceArray(
|
|
1304
1295
|
resolvedRefs.filter((ref) => ref !== null)
|
|
1305
1296
|
);
|
|
@@ -1337,8 +1328,9 @@ function getIdentifyingAttribute(tagName) {
|
|
|
1337
1328
|
}
|
|
1338
1329
|
function createReferenceString(tagName, datafieldname) {
|
|
1339
1330
|
if (tagName === "control") return `#${datafieldname}`;
|
|
1340
|
-
if (tagName === "tab" || tagName === "section")
|
|
1331
|
+
if (tagName === "tab" || tagName === "section") {
|
|
1341
1332
|
return `[data-name="${datafieldname}"]`;
|
|
1333
|
+
}
|
|
1342
1334
|
return null;
|
|
1343
1335
|
}
|
|
1344
1336
|
export {
|