powerpagestoolkit 1.2.202 → 1.3.101
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 +203 -1
- package/dist/index.bundle.js +196 -113
- package/index.d.ts +205 -181
- package/package.json +5 -7
package/README.md
CHANGED
|
@@ -1 +1,203 @@
|
|
|
1
|
-
#
|
|
1
|
+
# PowerPages Tool Kit
|
|
2
|
+
|
|
3
|
+
This package provides utilities for managing and interacting with the DOM and making AJAX requests to a DataVerse API. It includes the `API` module for handling CRUD operations and the `DOMNodeReference` class for seamless DOM manipulations.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
After installing
|
|
8
|
+
|
|
9
|
+
`npm install powerpagestoolkit`
|
|
10
|
+
|
|
11
|
+
You can then import into your JavaScript files as follows:
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
import {
|
|
15
|
+
API,
|
|
16
|
+
createDOMNodeReference,
|
|
17
|
+
createMultipleDOMNodeReferences,
|
|
18
|
+
} from "powerpagestoolkit";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
# Modules
|
|
22
|
+
|
|
23
|
+
### `DOMNodereference`
|
|
24
|
+
|
|
25
|
+
The `DOMNodeReference` module simplifies DOM element management. It provides functionalities for creating and interacting with DOM elements:
|
|
26
|
+
|
|
27
|
+
#### Usage
|
|
28
|
+
|
|
29
|
+
- **`createDOMNodeReference(selector)`**: Creates a `DOMNodeReference` instance for a single DOM element specified by a CSS selector or HTMLElement. Returns a `DOMNodeReference` instance.
|
|
30
|
+
|
|
31
|
+
- **`createMultipleDOMNodeReferences(selector)`**: Creates multiple `DOMNodeReference` instances for all elements matching the specified CSS selector. Returns an array of `DOMNodeReference` instances.
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
// single instance of DOMNodeReference
|
|
35
|
+
const node = await createDOMNodeReference("#my-element");
|
|
36
|
+
|
|
37
|
+
node.onceLoaded(() => {
|
|
38
|
+
console.log("Element is loaded: ", node.element);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// to imitate 'querySelectorAll', and return an array of DOMNodeReferences
|
|
42
|
+
const nodeArray = await createMultipleDOMNodeReferences('div[class="row"]');
|
|
43
|
+
|
|
44
|
+
nodeArray.forEach((node) => {
|
|
45
|
+
node.oneLoaded(() => {
|
|
46
|
+
console.log("Element loaded: ", node.element")
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
##### Properties
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
target: string;
|
|
55
|
+
element: HTMLElement | null;
|
|
56
|
+
isLoaded: boolean;
|
|
57
|
+
visibilityController: HTMLElement | null;
|
|
58
|
+
defaultDisplay: string;
|
|
59
|
+
value: string | null;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
##### Methods
|
|
63
|
+
|
|
64
|
+
Here are the key methods you can use with a DOMNodeReference instance:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
|
|
68
|
+
// Hides the associated DOM element.
|
|
69
|
+
hide()
|
|
70
|
+
|
|
71
|
+
// Shows the associated DOM element.
|
|
72
|
+
show()
|
|
73
|
+
|
|
74
|
+
// Sets the value of the associated HTML element.
|
|
75
|
+
setValue(value: string)
|
|
76
|
+
|
|
77
|
+
// Appends child elements to the associated HTML element.
|
|
78
|
+
append(...elements: HTMLElement[])
|
|
79
|
+
|
|
80
|
+
// Inserts elements after the associated HTML element.
|
|
81
|
+
after(...elements: HTMLElement[])
|
|
82
|
+
|
|
83
|
+
// Retrieves the label associated with the HTML element.
|
|
84
|
+
getLabel(): HTMLElement | null
|
|
85
|
+
|
|
86
|
+
// Appends child elements to the label associated with the HTML element.
|
|
87
|
+
appendToLabel(...elements: HTMLElement[])
|
|
88
|
+
|
|
89
|
+
// Adds a click event listener to the associated HTML element.
|
|
90
|
+
addClickListener(eventHandler: () => void)
|
|
91
|
+
|
|
92
|
+
// Adds a change event listener to the associated HTML element.
|
|
93
|
+
addChangeListener(eventHandler: () => void)
|
|
94
|
+
|
|
95
|
+
// Unchecks both yes and no radio buttons if they exist.
|
|
96
|
+
uncheckRadios()
|
|
97
|
+
|
|
98
|
+
//Creates a validation instance for the field.
|
|
99
|
+
createValidation(evaluationFunction: () => boolean, fieldDisplayName: string)
|
|
100
|
+
|
|
101
|
+
// Adds a tooltip to the label associated with the HTML element.
|
|
102
|
+
addLabelTooltip(text: string)
|
|
103
|
+
|
|
104
|
+
// Adds a tooltip to the associated HTML element.
|
|
105
|
+
|
|
106
|
+
addToolTip(text: string)
|
|
107
|
+
|
|
108
|
+
// Sets the inner HTML content of the associated HTML element.
|
|
109
|
+
setTextContent(text: string)
|
|
110
|
+
|
|
111
|
+
// Toggles visibility based on the provided boolean value.
|
|
112
|
+
toggleVisibility(shouldShow: boolean)
|
|
113
|
+
|
|
114
|
+
// Sets the visibility of the element based on a condition and binds it to another DOMNodeReference.
|
|
115
|
+
configureConditionalRendering(condition: () => boolean, triggerNode?: DOMNodeReference)
|
|
116
|
+
|
|
117
|
+
// Executes a callback function once the element is fully loaded.
|
|
118
|
+
onceLoaded(callback: (instance: DOMNodeReference) => void)
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### `API`
|
|
123
|
+
|
|
124
|
+
The `API` module provides functions for creating and retrieving records from a DataVerse. It includes the following methods:
|
|
125
|
+
|
|
126
|
+
- **`createRecord(schema)`**: Creates a new record in the DataVerse using the provided schema instance. Returns a Promise that resolves with the record ID or rejects with an error.
|
|
127
|
+
- **`getRecord(tableSetName, recordID, selectColumns)`**: Retrieves a specific record from the DataVerse. Returns a Promise that resolves with the retrieved record or rejects with an error.
|
|
128
|
+
|
|
129
|
+
- **`getMultiple(tableSetName, queryParameters)`**: Retrieves multiple records from the DataVerse based on specified query parameters. Returns a Promise that resolves with the list of retrieved records or rejects with an error.
|
|
130
|
+
|
|
131
|
+
#### Usage
|
|
132
|
+
|
|
133
|
+
###### 1. Creating a Record
|
|
134
|
+
|
|
135
|
+
To create a new record in the DataVerse, you can use the `createRecord` method. This method takes an instance of a schema class containing the data for the record.
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
// Assuming you have a schema class defined
|
|
139
|
+
const schema = new YourSchemaClass({
|
|
140
|
+
name: "Sample Record",
|
|
141
|
+
description: "This is a sample record for demonstration.",
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
API.createRecord(schema)
|
|
145
|
+
.then((recordId) => {
|
|
146
|
+
console.log("Record created successfully with ID:", recordId);
|
|
147
|
+
})
|
|
148
|
+
.catch((error) => {
|
|
149
|
+
console.error("Error creating record:", error);
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
###### 2. Getting a Single Record
|
|
154
|
+
|
|
155
|
+
To retrieve a specific record from the DataVerse, use the `getRecord` method. You need to provide the table set name and the record ID.
|
|
156
|
+
|
|
157
|
+
```javascript
|
|
158
|
+
const tableSetName = "accounts"; // The DataVerse table set name
|
|
159
|
+
const recordID = "your-record-id"; // The GUID of the record to retrieve
|
|
160
|
+
|
|
161
|
+
API.getRecord(tableSetName, recordID)
|
|
162
|
+
.then((record) => {
|
|
163
|
+
console.log("Retrieved record:", record);
|
|
164
|
+
})
|
|
165
|
+
.catch((error) => {
|
|
166
|
+
console.error("Error retrieving record:", error);
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
###### 3. Getting Multiple Records
|
|
171
|
+
|
|
172
|
+
If you need to retrieve multiple records with specific query parameters, you can use the `getMultiple` method. This method accepts the table set name and optional query parameters for filtering.
|
|
173
|
+
|
|
174
|
+
```javascript
|
|
175
|
+
const tableSetName = "contacts"; // The DataVerse table set name
|
|
176
|
+
const queryParameters =
|
|
177
|
+
"$filter=firstName eq 'John'&$select=firstName,lastName"; // OData query parameters
|
|
178
|
+
|
|
179
|
+
API.getMultiple(tableSetName, queryParameters)
|
|
180
|
+
.then((records) => {
|
|
181
|
+
console.log("Retrieved records:", records);
|
|
182
|
+
})
|
|
183
|
+
.catch((error) => {
|
|
184
|
+
console.error("Error retrieving records:", error);
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
##### Example Schema Class
|
|
189
|
+
|
|
190
|
+
Here's a simple example of a schema class that you might use with the createRecord method:
|
|
191
|
+
|
|
192
|
+
```javascript
|
|
193
|
+
class YourSchemaClass {
|
|
194
|
+
constructor(tableSetName, data) {
|
|
195
|
+
this.setName = tableSetName;
|
|
196
|
+
this.data = data;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
value() {
|
|
200
|
+
return JSON.stringify(this.data); // Convert data to JSON format for the API
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
package/dist/index.bundle.js
CHANGED
|
@@ -472,8 +472,9 @@ var __webpack_exports__ = {};
|
|
|
472
472
|
|
|
473
473
|
// EXPORTS
|
|
474
474
|
__webpack_require__.d(__webpack_exports__, {
|
|
475
|
-
|
|
476
|
-
|
|
475
|
+
nC: () => (/* reexport */ JS_API),
|
|
476
|
+
mI: () => (/* reexport */ createDOMNodeReference),
|
|
477
|
+
xq: () => (/* reexport */ createMultipleDOMNodeReferences)
|
|
477
478
|
});
|
|
478
479
|
|
|
479
480
|
;// ./src/JS/safeAjax.js
|
|
@@ -569,19 +570,22 @@ var API = {
|
|
|
569
570
|
;// ./src/JS/waitFor.js
|
|
570
571
|
/**
|
|
571
572
|
* @description a function that will wait for a targeted element to appear in the DOM, and then resolve a promise to allow further action to be performed after the targeted elements appears
|
|
572
|
-
* @param {String}
|
|
573
|
-
* @returns {Promise} the element targeted by ID *
|
|
573
|
+
* @param {String} target a query target expression to target a specific element that you want to appear in the DOM before taking further action
|
|
574
|
+
* @returns {Promise} the element targeted by ID *target*
|
|
574
575
|
*/
|
|
575
576
|
|
|
576
|
-
function waitFor(
|
|
577
|
+
function waitFor(target) {
|
|
577
578
|
return new Promise(function (resolve) {
|
|
578
|
-
if (
|
|
579
|
-
return resolve(
|
|
579
|
+
if (target instanceof HTMLElement) {
|
|
580
|
+
return resolve(target);
|
|
581
|
+
}
|
|
582
|
+
if (document.querySelector(target)) {
|
|
583
|
+
return resolve(document.querySelector(target));
|
|
580
584
|
}
|
|
581
585
|
var observer = new MutationObserver(function () {
|
|
582
|
-
if (document.querySelector(
|
|
586
|
+
if (document.querySelector(target)) {
|
|
583
587
|
observer.disconnect();
|
|
584
|
-
resolve(document.querySelector(
|
|
588
|
+
resolve(document.querySelector(target));
|
|
585
589
|
}
|
|
586
590
|
});
|
|
587
591
|
observer.observe(document.body, {
|
|
@@ -741,66 +745,94 @@ function DOMNodeReferences_toPrimitive(t, r) { if ("object" != DOMNodeReferences
|
|
|
741
745
|
/**
|
|
742
746
|
* Class representing a reference to a DOM node.
|
|
743
747
|
*/
|
|
748
|
+
/******/ /******/ /******/
|
|
744
749
|
var DOMNodeReference = /*#__PURE__*/function () {
|
|
745
750
|
/**
|
|
746
751
|
* Creates an instance of DOMNodeReference.
|
|
747
|
-
* @param {string}
|
|
752
|
+
* @param {string} target - The CSS selector to find the desired DOM element.
|
|
748
753
|
*/
|
|
749
|
-
|
|
754
|
+
/******/ /******/
|
|
755
|
+
function DOMNodeReference(target) {
|
|
750
756
|
DOMNodeReferences_classCallCheck(this, DOMNodeReference);
|
|
751
|
-
this.
|
|
757
|
+
this.target = target;
|
|
752
758
|
this.element = null;
|
|
753
759
|
this.isLoaded = false;
|
|
754
|
-
|
|
760
|
+
this.visibilityController = null;
|
|
761
|
+
this.defaultDisplay = "";
|
|
762
|
+
this.value = null;
|
|
763
|
+
// we defer the rest of initialization
|
|
755
764
|
}
|
|
756
765
|
|
|
757
766
|
/**
|
|
758
767
|
* Initializes the DOMNodeReference instance by waiting for the element to be available in the DOM.
|
|
759
768
|
*/
|
|
769
|
+
/******/ /******/
|
|
760
770
|
return DOMNodeReferences_createClass(DOMNodeReference, [{
|
|
761
771
|
key: "init",
|
|
762
772
|
value: (function () {
|
|
763
773
|
var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
774
|
+
var _this = this;
|
|
764
775
|
var element;
|
|
765
776
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
766
777
|
while (1) switch (_context.prev = _context.next) {
|
|
767
778
|
case 0:
|
|
768
|
-
_context.
|
|
769
|
-
|
|
770
|
-
|
|
779
|
+
_context.prev = 0;
|
|
780
|
+
_context.next = 3;
|
|
781
|
+
return waitFor(this.target);
|
|
782
|
+
case 3:
|
|
771
783
|
element = _context.sent;
|
|
772
|
-
|
|
773
|
-
|
|
784
|
+
this.element = element;
|
|
785
|
+
if (this.element) {
|
|
786
|
+
_context.next = 7;
|
|
774
787
|
break;
|
|
775
788
|
}
|
|
776
|
-
throw new Error("[SYNACT] No Element could be found with the provided query selector: ".concat(this.
|
|
777
|
-
case
|
|
778
|
-
this.
|
|
779
|
-
this.value = element.value;
|
|
780
|
-
this.parentElement = element.parentElement;
|
|
781
|
-
this.container = element.parentElement.parentElement.parentElement;
|
|
782
|
-
this.isLoaded = true;
|
|
789
|
+
throw new Error("[SYNACT] No Element could be found with the provided query selector: ".concat(this.target));
|
|
790
|
+
case 7:
|
|
791
|
+
this.value = this.element.value;
|
|
783
792
|
if (!this.element.classList.contains("boolean-radio")) {
|
|
784
|
-
_context.next =
|
|
793
|
+
_context.next = 15;
|
|
785
794
|
break;
|
|
786
795
|
}
|
|
787
|
-
_context.next =
|
|
796
|
+
_context.next = 11;
|
|
788
797
|
return createDOMNodeReference("#".concat(this.element.id, "_1"));
|
|
789
|
-
case
|
|
798
|
+
case 11:
|
|
790
799
|
this.yesRadio = _context.sent;
|
|
791
|
-
_context.next =
|
|
800
|
+
_context.next = 14;
|
|
792
801
|
return createDOMNodeReference("#".concat(this.element.id, "_0"));
|
|
793
|
-
case
|
|
802
|
+
case 14:
|
|
794
803
|
this.noRadio = _context.sent;
|
|
795
|
-
case
|
|
796
|
-
this.
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
804
|
+
case 15:
|
|
805
|
+
this.element.addEventListener("change", function () {
|
|
806
|
+
_this.value = _this.element.value;
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
// based on the type of element we have targeted in instantiation
|
|
810
|
+
// we now grab the parent element that will be responsible for
|
|
811
|
+
// 'showing' and 'hiding' the target element
|
|
812
|
+
// this is needed also in order to observe changes to visibility so that
|
|
813
|
+
// changes to target can cascade to dependent DOMNodeReferences
|
|
814
|
+
_context.t0 = this.element.tagName;
|
|
815
|
+
_context.next = _context.t0 === "SPAN" ? 19 : _context.t0 === "INPUT" ? 19 : _context.t0 === "TEXTAREA" ? 19 : _context.t0 === "SELECT" ? 19 : _context.t0 === "FIELDSET" ? 21 : 21;
|
|
816
|
+
break;
|
|
817
|
+
case 19:
|
|
818
|
+
this.visibilityController = this.element.closest("td");
|
|
819
|
+
return _context.abrupt("break", 22);
|
|
820
|
+
case 21:
|
|
821
|
+
this.visibilityController = this.element;
|
|
822
|
+
case 22:
|
|
823
|
+
this.defaultDisplay = this.visibilityController.style.display;
|
|
824
|
+
this.isLoaded = true;
|
|
825
|
+
_context.next = 29;
|
|
826
|
+
break;
|
|
827
|
+
case 26:
|
|
828
|
+
_context.prev = 26;
|
|
829
|
+
_context.t1 = _context["catch"](0);
|
|
830
|
+
throw new Error("powerpagestoolkit: There was an error initializing a DOMNodeReference with the target: ".concat(this.target, " :: ").concat(_context.t1));
|
|
831
|
+
case 29:
|
|
800
832
|
case "end":
|
|
801
833
|
return _context.stop();
|
|
802
834
|
}
|
|
803
|
-
}, _callee, this);
|
|
835
|
+
}, _callee, this, [[0, 26]]);
|
|
804
836
|
}));
|
|
805
837
|
function init() {
|
|
806
838
|
return _init.apply(this, arguments);
|
|
@@ -811,61 +843,23 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
811
843
|
* Hides the element by setting its display style to "none".
|
|
812
844
|
* @method hide
|
|
813
845
|
*/
|
|
846
|
+
/******/
|
|
814
847
|
)
|
|
815
848
|
}, {
|
|
816
849
|
key: "hide",
|
|
817
850
|
value: function hide() {
|
|
818
|
-
this.
|
|
851
|
+
this.visibilityController.style.display = "none";
|
|
819
852
|
}
|
|
820
853
|
|
|
821
854
|
/**
|
|
822
855
|
* Shows the element by restoring its default display style.
|
|
823
856
|
* @method show
|
|
824
857
|
*/
|
|
858
|
+
/******/
|
|
825
859
|
}, {
|
|
826
860
|
key: "show",
|
|
827
861
|
value: function show() {
|
|
828
|
-
this.
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
/**
|
|
832
|
-
* Hides the parent element by setting its display style to "none".
|
|
833
|
-
* @method hideParent
|
|
834
|
-
*/
|
|
835
|
-
}, {
|
|
836
|
-
key: "hideParent",
|
|
837
|
-
value: function hideParent() {
|
|
838
|
-
this.parentElement.style.display = "none";
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
/**
|
|
842
|
-
* Shows the parent element by restoring its default display style.
|
|
843
|
-
* @method showParent
|
|
844
|
-
*/
|
|
845
|
-
}, {
|
|
846
|
-
key: "showParent",
|
|
847
|
-
value: function showParent() {
|
|
848
|
-
this.parentElement.style.display = this.defaultParentDisplay;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
/**
|
|
852
|
-
* Hides the container (grandparent of the element) by setting its display style to "none".
|
|
853
|
-
* @method hideContainer
|
|
854
|
-
*/
|
|
855
|
-
}, {
|
|
856
|
-
key: "hideContainer",
|
|
857
|
-
value: function hideContainer() {
|
|
858
|
-
this.element.parentElement.parentElement.parentElement.style.display = "none";
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
/**
|
|
862
|
-
* Shows the container (grandparent of the element) by restoring its default display style.
|
|
863
|
-
* @method showContainer
|
|
864
|
-
*/
|
|
865
|
-
}, {
|
|
866
|
-
key: "showContainer",
|
|
867
|
-
value: function showContainer() {
|
|
868
|
-
this.element.parentElement.parentElement.parentElement.style.display = this.defaultContainerDisplay;
|
|
862
|
+
this.visibilityController.style.display = this.defaultDisplay;
|
|
869
863
|
}
|
|
870
864
|
|
|
871
865
|
/**
|
|
@@ -873,6 +867,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
873
867
|
* @method setValue
|
|
874
868
|
* @param {string} value - The value to set for the HTML element.
|
|
875
869
|
*/
|
|
870
|
+
/******/
|
|
876
871
|
}, {
|
|
877
872
|
key: "setValue",
|
|
878
873
|
value: function setValue(value) {
|
|
@@ -884,6 +879,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
884
879
|
* @method append
|
|
885
880
|
* @param {...HTMLElement} elements - The elements to append to the HTML element.
|
|
886
881
|
*/
|
|
882
|
+
/******/
|
|
887
883
|
}, {
|
|
888
884
|
key: "append",
|
|
889
885
|
value: function append() {
|
|
@@ -896,6 +892,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
896
892
|
* @method after
|
|
897
893
|
* @param {...HTMLElement} elements - The elements to insert after the HTML element.
|
|
898
894
|
*/
|
|
895
|
+
/******/
|
|
899
896
|
}, {
|
|
900
897
|
key: "after",
|
|
901
898
|
value: function after() {
|
|
@@ -909,10 +906,11 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
909
906
|
* @returns {HTMLElement} The label element associated with this element.
|
|
910
907
|
* @throws {Error} Throws an error if the label cannot be found.
|
|
911
908
|
*/
|
|
909
|
+
/******/
|
|
912
910
|
}, {
|
|
913
911
|
key: "getLabel",
|
|
914
912
|
value: function getLabel() {
|
|
915
|
-
return document.querySelector("#".concat(this.element.id, "_label"));
|
|
913
|
+
return document.querySelector("#".concat(this.element.id, "_label")) || null;
|
|
916
914
|
}
|
|
917
915
|
|
|
918
916
|
/**
|
|
@@ -920,14 +918,17 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
920
918
|
* @method appendToLabel
|
|
921
919
|
* @param {...HTMLElement} elements - The elements to append to the label.
|
|
922
920
|
*/
|
|
921
|
+
/******/
|
|
923
922
|
}, {
|
|
924
923
|
key: "appendToLabel",
|
|
925
924
|
value: function appendToLabel() {
|
|
926
925
|
var label = this.getLabel();
|
|
927
|
-
|
|
928
|
-
elements
|
|
926
|
+
if (label) {
|
|
927
|
+
for (var _len = arguments.length, elements = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
928
|
+
elements[_key] = arguments[_key];
|
|
929
|
+
}
|
|
930
|
+
label.append.apply(label, [" "].concat(elements));
|
|
929
931
|
}
|
|
930
|
-
label.append.apply(label, [" "].concat(elements));
|
|
931
932
|
}
|
|
932
933
|
|
|
933
934
|
/**
|
|
@@ -935,6 +936,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
935
936
|
* @method addClickListener
|
|
936
937
|
* @param {Function} eventHandler - The function to execute when the element is clicked.
|
|
937
938
|
*/
|
|
939
|
+
/******/
|
|
938
940
|
}, {
|
|
939
941
|
key: "addClickListener",
|
|
940
942
|
value: function addClickListener(eventHandler) {
|
|
@@ -949,6 +951,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
949
951
|
* @method addChangeListener
|
|
950
952
|
* @param {Function} eventHandler - The function to execute when the element's value changes.
|
|
951
953
|
*/
|
|
954
|
+
/******/
|
|
952
955
|
}, {
|
|
953
956
|
key: "addChangeListener",
|
|
954
957
|
value: function addChangeListener(eventHandler) {
|
|
@@ -962,6 +965,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
962
965
|
* Unchecks both the yes and no radio buttons if they exist.
|
|
963
966
|
* @method uncheckRadios
|
|
964
967
|
*/
|
|
968
|
+
/******/
|
|
965
969
|
}, {
|
|
966
970
|
key: "uncheckRadios",
|
|
967
971
|
value: function uncheckRadios() {
|
|
@@ -979,6 +983,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
979
983
|
* @param {Function} evaluationFunction - The function used to evaluate the field.
|
|
980
984
|
* @param {string} fieldDisplayName - The field name to display in error if validation fails.
|
|
981
985
|
*/
|
|
986
|
+
/******/
|
|
982
987
|
}, {
|
|
983
988
|
key: "createValidation",
|
|
984
989
|
value: function createValidation(evaluationFunction, fieldDisplayName) {
|
|
@@ -990,11 +995,14 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
990
995
|
* @method addLabelTooltip
|
|
991
996
|
* @param {string} text - The text to display in the tooltip.
|
|
992
997
|
*/
|
|
998
|
+
/******/
|
|
993
999
|
}, {
|
|
994
1000
|
key: "addLabelTooltip",
|
|
995
1001
|
value: function addLabelTooltip(text) {
|
|
996
1002
|
this.appendToLabel(CreateInfoEl(text));
|
|
997
1003
|
}
|
|
1004
|
+
|
|
1005
|
+
/******/
|
|
998
1006
|
}, {
|
|
999
1007
|
key: "addToolTip",
|
|
1000
1008
|
value: function addToolTip(text) {
|
|
@@ -1006,6 +1014,7 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1006
1014
|
* @method setTextContent
|
|
1007
1015
|
* @param {string} text - The text to set as the inner HTML of the element.
|
|
1008
1016
|
*/
|
|
1017
|
+
/******/
|
|
1009
1018
|
}, {
|
|
1010
1019
|
key: "setTextContent",
|
|
1011
1020
|
value: function setTextContent(text) {
|
|
@@ -1014,26 +1023,43 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1014
1023
|
|
|
1015
1024
|
/**
|
|
1016
1025
|
*
|
|
1017
|
-
* @param {
|
|
1018
|
-
*
|
|
1026
|
+
* @param {boolean} shouldShow shows or hides the target
|
|
1027
|
+
* if = true => show, if = false => hide
|
|
1019
1028
|
*/
|
|
1029
|
+
}, {
|
|
1030
|
+
key: "toggleVisibility",
|
|
1031
|
+
value: function toggleVisibility(shouldShow) {
|
|
1032
|
+
shouldShow ? this.show() : this.hide();
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
*
|
|
1037
|
+
* @param {Function} condition A Function that return a boolean value to set the
|
|
1038
|
+
* visibility of the targeted element. if condition() returns true, element is shown.
|
|
1039
|
+
* If false, element is hidden
|
|
1040
|
+
* @param {DOMNodeReference} triggerNode The DOMNodeReference to which an
|
|
1041
|
+
* event listener will be registered to change the visibility state of the calling
|
|
1042
|
+
* DOMNodeReference
|
|
1043
|
+
*/
|
|
1044
|
+
/******/
|
|
1020
1045
|
}, {
|
|
1021
1046
|
key: "configureConditionalRendering",
|
|
1022
|
-
value: function configureConditionalRendering() {
|
|
1023
|
-
var
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
var o = new MutationObserver(function () {
|
|
1029
|
-
if (condition()) _this.show();else _this.hide();
|
|
1047
|
+
value: function configureConditionalRendering(condition, triggerNode) {
|
|
1048
|
+
var _this2 = this;
|
|
1049
|
+
this.toggleVisibility(condition());
|
|
1050
|
+
if (triggerNode) {
|
|
1051
|
+
triggerNode.addChangeListener(function () {
|
|
1052
|
+
_this2.toggleVisibility(condition());
|
|
1030
1053
|
});
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
attributes: true
|
|
1054
|
+
var observer = new MutationObserver(function () {
|
|
1055
|
+
var display = window.getComputedStyle(triggerNode.visibilityController).display;
|
|
1056
|
+
_this2.toggleVisibility(display !== "none" && condition());
|
|
1035
1057
|
});
|
|
1036
|
-
|
|
1058
|
+
observer.observe(triggerNode.visibilityController, {
|
|
1059
|
+
attributes: true,
|
|
1060
|
+
attributeFilter: ["style"]
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1037
1063
|
}
|
|
1038
1064
|
|
|
1039
1065
|
/**
|
|
@@ -1043,18 +1069,19 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1043
1069
|
* @method onceLoaded
|
|
1044
1070
|
* @param {Function} callback - A callback function to execute once the element is loaded.
|
|
1045
1071
|
*/
|
|
1072
|
+
/******/
|
|
1046
1073
|
}, {
|
|
1047
1074
|
key: "onceLoaded",
|
|
1048
1075
|
value: function onceLoaded(callback) {
|
|
1049
|
-
var
|
|
1076
|
+
var _this3 = this;
|
|
1050
1077
|
if (this.isLoaded) {
|
|
1051
1078
|
callback(this);
|
|
1052
1079
|
} else {
|
|
1053
1080
|
var observer = new MutationObserver(function () {
|
|
1054
|
-
if (document.querySelector(
|
|
1081
|
+
if (document.querySelector(_this3.target)) {
|
|
1055
1082
|
observer.disconnect(); // Stop observing once loaded
|
|
1056
|
-
|
|
1057
|
-
callback(
|
|
1083
|
+
_this3.isLoaded = true;
|
|
1084
|
+
callback(_this3); // Call the provided callback
|
|
1058
1085
|
}
|
|
1059
1086
|
});
|
|
1060
1087
|
observer.observe(document.body, {
|
|
@@ -1069,22 +1096,31 @@ var DOMNodeReference = /*#__PURE__*/function () {
|
|
|
1069
1096
|
* Creates and initializes a DOMNodeReference instance.
|
|
1070
1097
|
* @async
|
|
1071
1098
|
* @function createDOMNodeReference
|
|
1072
|
-
* @param {string}
|
|
1099
|
+
* @param {string | HTMLElement} target - The CSS selector for the desired DOM element.
|
|
1073
1100
|
* @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
|
|
1074
1101
|
*/
|
|
1075
1102
|
function createDOMNodeReference(_x) {
|
|
1076
1103
|
return _createDOMNodeReference.apply(this, arguments);
|
|
1077
1104
|
}
|
|
1105
|
+
|
|
1106
|
+
/**
|
|
1107
|
+
* Creates and initializes multiple DOMNodeReference instances.
|
|
1108
|
+
* @async
|
|
1109
|
+
* @function createMultipleDOMNodeReferences
|
|
1110
|
+
* @param {string} querySelector - The CSS selector for the desired DOM elements.
|
|
1111
|
+
* @returns {Promise<DOMNodeReference[]>} A promise that resolves to an array of Proxies of initialized DOMNodeReference instances.
|
|
1112
|
+
*/
|
|
1078
1113
|
function _createDOMNodeReference() {
|
|
1079
|
-
_createDOMNodeReference = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(
|
|
1114
|
+
_createDOMNodeReference = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(target) {
|
|
1080
1115
|
var instance;
|
|
1081
1116
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1082
1117
|
while (1) switch (_context2.prev = _context2.next) {
|
|
1083
1118
|
case 0:
|
|
1084
|
-
|
|
1085
|
-
|
|
1119
|
+
_context2.prev = 0;
|
|
1120
|
+
instance = new DOMNodeReference(target);
|
|
1121
|
+
_context2.next = 4;
|
|
1086
1122
|
return instance.init();
|
|
1087
|
-
case
|
|
1123
|
+
case 4:
|
|
1088
1124
|
return _context2.abrupt("return", new Proxy(instance, {
|
|
1089
1125
|
get: function get(target, prop) {
|
|
1090
1126
|
// do not proxy the initialization method
|
|
@@ -1096,8 +1132,8 @@ function _createDOMNodeReference() {
|
|
|
1096
1132
|
var value = target[prop];
|
|
1097
1133
|
if (typeof value === "function" && prop !== "onceLoaded") {
|
|
1098
1134
|
return function () {
|
|
1099
|
-
for (var
|
|
1100
|
-
args[
|
|
1135
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1136
|
+
args[_key2] = arguments[_key2];
|
|
1101
1137
|
}
|
|
1102
1138
|
return target.onceLoaded(function () {
|
|
1103
1139
|
return value.apply(target, args);
|
|
@@ -1107,18 +1143,65 @@ function _createDOMNodeReference() {
|
|
|
1107
1143
|
return value;
|
|
1108
1144
|
}
|
|
1109
1145
|
}));
|
|
1110
|
-
case
|
|
1146
|
+
case 7:
|
|
1147
|
+
_context2.prev = 7;
|
|
1148
|
+
_context2.t0 = _context2["catch"](0);
|
|
1149
|
+
console.error("There was an error creating a DOMNodeReference: ".concat(_context2.t0));
|
|
1150
|
+
throw new Error(_context2.t0);
|
|
1151
|
+
case 11:
|
|
1111
1152
|
case "end":
|
|
1112
1153
|
return _context2.stop();
|
|
1113
1154
|
}
|
|
1114
|
-
}, _callee2);
|
|
1155
|
+
}, _callee2, null, [[0, 7]]);
|
|
1115
1156
|
}));
|
|
1116
1157
|
return _createDOMNodeReference.apply(this, arguments);
|
|
1117
1158
|
}
|
|
1159
|
+
function createMultipleDOMNodeReferences(_x2) {
|
|
1160
|
+
return _createMultipleDOMNodeReferences.apply(this, arguments);
|
|
1161
|
+
}
|
|
1162
|
+
function _createMultipleDOMNodeReferences() {
|
|
1163
|
+
_createMultipleDOMNodeReferences = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(querySelector) {
|
|
1164
|
+
var elements;
|
|
1165
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1166
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1167
|
+
case 0:
|
|
1168
|
+
_context3.prev = 0;
|
|
1169
|
+
elements = Array.from(document.querySelectorAll(querySelector));
|
|
1170
|
+
_context3.next = 4;
|
|
1171
|
+
return Promise.all(elements.map(function (element) {
|
|
1172
|
+
return createDOMNodeReference(element);
|
|
1173
|
+
}));
|
|
1174
|
+
case 4:
|
|
1175
|
+
elements = _context3.sent;
|
|
1176
|
+
elements.hideAll = function () {
|
|
1177
|
+
return elements.forEach(function (instance) {
|
|
1178
|
+
return instance.hide();
|
|
1179
|
+
});
|
|
1180
|
+
};
|
|
1181
|
+
elements.showAll = function () {
|
|
1182
|
+
return elements.forEach(function (instance) {
|
|
1183
|
+
return instance.show();
|
|
1184
|
+
});
|
|
1185
|
+
};
|
|
1186
|
+
return _context3.abrupt("return", elements);
|
|
1187
|
+
case 10:
|
|
1188
|
+
_context3.prev = 10;
|
|
1189
|
+
_context3.t0 = _context3["catch"](0);
|
|
1190
|
+
console.error("There was an error creating multiple DOMNodeReferences: ".concat(_context3.t0));
|
|
1191
|
+
throw new Error(_context3.t0);
|
|
1192
|
+
case 14:
|
|
1193
|
+
case "end":
|
|
1194
|
+
return _context3.stop();
|
|
1195
|
+
}
|
|
1196
|
+
}, _callee3, null, [[0, 10]]);
|
|
1197
|
+
}));
|
|
1198
|
+
return _createMultipleDOMNodeReferences.apply(this, arguments);
|
|
1199
|
+
}
|
|
1118
1200
|
;// ./src/index.js
|
|
1119
1201
|
|
|
1120
1202
|
|
|
1121
1203
|
|
|
1122
|
-
var __webpack_exports__API = __webpack_exports__.
|
|
1123
|
-
var __webpack_exports__createDOMNodeReference = __webpack_exports__.
|
|
1124
|
-
|
|
1204
|
+
var __webpack_exports__API = __webpack_exports__.nC;
|
|
1205
|
+
var __webpack_exports__createDOMNodeReference = __webpack_exports__.mI;
|
|
1206
|
+
var __webpack_exports__createMultipleDOMNodeReferences = __webpack_exports__.xq;
|
|
1207
|
+
export { __webpack_exports__API as API, __webpack_exports__createDOMNodeReference as createDOMNodeReference, __webpack_exports__createMultipleDOMNodeReferences as createMultipleDOMNodeReferences };
|
package/index.d.ts
CHANGED
|
@@ -1,182 +1,206 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*/
|
|
134
|
-
onceLoaded(callback: (instance: this) => void): void;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Creates and initializes a DOMNodeReference instance.
|
|
139
|
-
* @async
|
|
140
|
-
* @function createDOMNodeReference
|
|
141
|
-
* @param {string} querySelector - The CSS selector for the desired DOM element.
|
|
142
|
-
* @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
|
|
143
|
-
*/
|
|
144
|
-
export async function createDOMNodeReference(
|
|
145
|
-
querySelector: string
|
|
146
|
-
): Promise<DOMNodeReference>;
|
|
147
|
-
|
|
148
|
-
interface Schema {
|
|
149
|
-
logicalName(): string;
|
|
150
|
-
value(): any; // Adjust this type based on the structure of your schema values
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export const API: {
|
|
154
|
-
/**
|
|
155
|
-
* Creates a new record in DataVerse.
|
|
156
|
-
* @param schema An instance of a schema class, containing the desired information for the POST request.
|
|
157
|
-
* @returns A Promise resolving the successful results (record ID) of the POST request, or rejecting with the error.
|
|
158
|
-
*/
|
|
159
|
-
createRecord(schema: Schema): Promise<string>;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Retrieves a single record from DataVerse.
|
|
163
|
-
* @param tableSetName The DataVerse SET name of the table being queried.
|
|
164
|
-
* @param recordID The GUID of the record to be retrieved.
|
|
165
|
-
* @param selectColumns *OPTIONAL* Custom OData query for advanced GET results. Format: select=column1,column2,column3...
|
|
166
|
-
* @returns A Promise resolving the successful results of the GET request, or rejecting with the error.
|
|
167
|
-
*/
|
|
168
|
-
getRecord(
|
|
169
|
-
tableSetName: string,
|
|
170
|
-
recordID: string,
|
|
171
|
-
selectColumns?: string
|
|
172
|
-
): Promise<any>; // Adjust return type as necessary
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Retrieves multiple records from DataVerse.
|
|
176
|
-
* @param tableSetName The DataVerse SET name of the table being queried.
|
|
177
|
-
* @param queryParameters *OPTIONAL* OData query parameters for refining search results: format = $filter=filters&$select=columns
|
|
178
|
-
* @returns A Promise resolving the successful results of the GET request, or rejecting with the error.
|
|
179
|
-
*/
|
|
180
|
-
getMultiple(tableSetName: string, queryParameters?: string): Promise<any>; // Adjust return type as necessary
|
|
181
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Class representing a reference to a DOM node.
|
|
3
|
+
*/
|
|
4
|
+
class DOMNodeReference {
|
|
5
|
+
/**
|
|
6
|
+
* Creates an instance of DOMNodeReference.
|
|
7
|
+
* @param {string} querySelector - The CSS selector to find the desired DOM element.
|
|
8
|
+
*/
|
|
9
|
+
constructor(target: string): DOMNodeReference;
|
|
10
|
+
|
|
11
|
+
target: string;
|
|
12
|
+
element: HTMLElement | null;
|
|
13
|
+
isLoaded: boolean;
|
|
14
|
+
visibilityController: HTMLElement | null;
|
|
15
|
+
defaultDisplay: string;
|
|
16
|
+
value: string | null;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Initializes the DOMNodeReference instance by waiting for the element to be available in the DOM.
|
|
20
|
+
* @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the DOMNodeReference instance.
|
|
21
|
+
* @throws {Error} Throws an error if the element cannot be found using the provided query selector.
|
|
22
|
+
*/
|
|
23
|
+
private init(): Promise<this>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Hides the element by setting its display style to "none".
|
|
27
|
+
*/
|
|
28
|
+
hide(): void;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Shows the element by restoring its default display style.
|
|
32
|
+
*/
|
|
33
|
+
show(): void;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Sets the value of the HTML element.
|
|
37
|
+
* @param {string} value - The value to set for the HTML element.
|
|
38
|
+
*/
|
|
39
|
+
setValue(value: string): void;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Appends child elements to the HTML element.
|
|
43
|
+
* @param {...HTMLElement} elements - The elements to append to the HTML element.
|
|
44
|
+
*/
|
|
45
|
+
append(...elements: HTMLElement[]): void;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Inserts elements after the HTML element.
|
|
49
|
+
* @param {...HTMLElement} elements - The elements to insert after the HTML element.
|
|
50
|
+
*/
|
|
51
|
+
after(...elements: HTMLElement[]): void;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves the label associated with the HTML element.
|
|
55
|
+
* @returns {HTMLElement} The label element associated with this element, or **null** if no label element is present
|
|
56
|
+
*/
|
|
57
|
+
getLabel(): HTMLElement | null;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Appends child elements to the label associated with the HTML element.
|
|
61
|
+
* @param {...HTMLElement} elements - The elements to append to the label.
|
|
62
|
+
*/
|
|
63
|
+
appendToLabel(...elements: HTMLElement[]): void;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Adds a click event listener to the HTML element.
|
|
67
|
+
* @param {Function} eventHandler - The function to execute when the element is clicked.
|
|
68
|
+
*/
|
|
69
|
+
addClickListener(eventHandler: () => void): void;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Adds a change event listener to the HTML element.
|
|
73
|
+
* @param {Function} eventHandler - The function to execute when the element's value changes.
|
|
74
|
+
*/
|
|
75
|
+
addChangeListener(eventHandler: () => void): void;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Unchecks both the yes and no radio buttons if they exist.
|
|
79
|
+
*/
|
|
80
|
+
uncheckRadios(): void;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Creates a validation instance for the field.
|
|
84
|
+
* @param {Function} evaluationFunction - The function used to evaluate the field.
|
|
85
|
+
* @param {string} fieldDisplayName - The field name to display in error if validation
|
|
86
|
+
* fails.
|
|
87
|
+
*/
|
|
88
|
+
createValidation(
|
|
89
|
+
evaluationFunction: (value: any) => boolean,
|
|
90
|
+
fieldDisplayName: string
|
|
91
|
+
): void;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Adds a tooltip with specified text to the label associated with the HTML element.
|
|
95
|
+
* @param {string} text - The text to display in the tooltip.
|
|
96
|
+
*/
|
|
97
|
+
addLabelTooltip(text: string): void;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Sets the inner HTML content of the HTML element.
|
|
101
|
+
* @param {string} text - The text to set as the inner HTML of the element.
|
|
102
|
+
*/
|
|
103
|
+
setTextContent(text: string): void;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @param {boolean} shouldShow shows or hides the target
|
|
108
|
+
* if = true => show, if = false => hide
|
|
109
|
+
*/
|
|
110
|
+
toggleVisibility(shouldShow: boolean): void;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param {Function} condition A Function that return a boolean value to set the
|
|
115
|
+
* visibility of the targeted element. if condition() returns true, element is shown.
|
|
116
|
+
* If false, element is hidden
|
|
117
|
+
* @param {DOMNodeReference} triggerNode The DOMNodeReference to which an
|
|
118
|
+
* event listener will be registered to change the visibility state of the calling
|
|
119
|
+
* DOMNodeReference
|
|
120
|
+
*/
|
|
121
|
+
configureConditionalRendering(
|
|
122
|
+
condition: () => boolean,
|
|
123
|
+
triggerNode: DOMNodeReference
|
|
124
|
+
): void;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Executes a callback function once the element is fully loaded.
|
|
128
|
+
* If the element is already loaded, the callback is called immediately.
|
|
129
|
+
* Otherwise, a MutationObserver is used to detect when the element is added to the DOM.
|
|
130
|
+
* @param {Function} callback - A callback function to execute once the element is loaded.
|
|
131
|
+
*/
|
|
132
|
+
onceLoaded(callback: (instance: this) => void): void;
|
|
182
133
|
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Creates and initializes a DOMNodeReference instance.
|
|
137
|
+
* @async
|
|
138
|
+
* @function createDOMNodeReference
|
|
139
|
+
* @param {string} target - The CSS selector for the desired DOM element.
|
|
140
|
+
* @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
|
|
141
|
+
*/
|
|
142
|
+
export declare async function createDOMNodeReference(
|
|
143
|
+
querySelector: string | HTMLElement
|
|
144
|
+
): Promise<DOMNodeReference>;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Interface representing an array of DOMNodeReference instances with additional methods.
|
|
148
|
+
*/
|
|
149
|
+
export interface DOMNodeReferenceArray extends Array<DOMNodeReference> {
|
|
150
|
+
/**
|
|
151
|
+
* Hides all the containers of the DOMNodeReference instances in the array.
|
|
152
|
+
*/
|
|
153
|
+
hideAll(): void;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Shows all the containers of the DOMNodeReference instances in the array.
|
|
157
|
+
*/
|
|
158
|
+
showAll(): void;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Creates and initializes multiple DOMNodeReference instances.
|
|
163
|
+
* @function createMultipleDOMNodeReferences
|
|
164
|
+
* @param {string} querySelector - The CSS selector for the desired DOM elements.
|
|
165
|
+
* @returns {Promise<DOMNodeReferenceArray>}
|
|
166
|
+
* A promise that resolves to an array of Proxies of initialized
|
|
167
|
+
* DOMNodeReference instances.
|
|
168
|
+
*/
|
|
169
|
+
export declare async function createMultipleDOMNodeReferences(
|
|
170
|
+
querySelector: string
|
|
171
|
+
): Promise<DOMNodeReferenceArray>;
|
|
172
|
+
|
|
173
|
+
interface Schema {
|
|
174
|
+
logicalName(): string;
|
|
175
|
+
value(): any; // Adjust this type based on the structure of your schema values
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export declare const API: {
|
|
179
|
+
/**
|
|
180
|
+
* Creates a new record in DataVerse.
|
|
181
|
+
* @param schema An instance of a schema class, containing the desired information for the POST request.
|
|
182
|
+
* @returns A Promise resolving the successful results (record ID) of the POST request, or rejecting with the error.
|
|
183
|
+
*/
|
|
184
|
+
createRecord(schema: Schema): Promise<string>;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Retrieves a single record from DataVerse.
|
|
188
|
+
* @param tableSetName The DataVerse SET name of the table being queried.
|
|
189
|
+
* @param recordID The GUID of the record to be retrieved.
|
|
190
|
+
* @param selectColumns *OPTIONAL* Custom OData query for advanced GET results. Format: select=column1,column2,column3...
|
|
191
|
+
* @returns A Promise resolving the successful results of the GET request, or rejecting with the error.
|
|
192
|
+
*/
|
|
193
|
+
getRecord(
|
|
194
|
+
tableSetName: string,
|
|
195
|
+
recordID: string,
|
|
196
|
+
selectColumns?: string
|
|
197
|
+
): Promise<any>; // Adjust return type as necessary
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Retrieves multiple records from DataVerse.
|
|
201
|
+
* @param tableSetName The DataVerse SET name of the table being queried.
|
|
202
|
+
* @param queryParameters *OPTIONAL* OData query parameters for refining search results: format = $filter=filters&$select=columns
|
|
203
|
+
* @returns A Promise resolving the successful results of the GET request, or rejecting with the error.
|
|
204
|
+
*/
|
|
205
|
+
getMultiple(tableSetName: string, queryParameters?: string): Promise<any>; // Adjust return type as necessary
|
|
206
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powerpagestoolkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.101",
|
|
4
4
|
"description": "Reference, manipulate, and engage with Power Pages sites through the nodes in the DOM; use a variety of custom methods that allow customizing your power pages site quicker and easier. ",
|
|
5
5
|
"main": "./dist/index.bundle.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "webpack"
|
|
8
|
+
"build": "webpack",
|
|
9
|
+
"lint": "eslint ./src/JS/*"
|
|
9
10
|
},
|
|
10
11
|
"devDependencies": {
|
|
11
12
|
"@babel/core": "^7.25.8",
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
"clean-webpack-plugin": "^4.0.0",
|
|
17
18
|
"css-loader": "^7.1.2",
|
|
18
19
|
"eslint": "^8.57.1",
|
|
19
|
-
"
|
|
20
|
+
"eslint-plugin-import": "^2.31.0",
|
|
20
21
|
"style-loader": "^4.0.0",
|
|
21
22
|
"terser-webpack-plugin": "^5.3.4",
|
|
22
23
|
"typescript": "^5.6.3",
|
|
@@ -33,8 +34,5 @@
|
|
|
33
34
|
"files": [
|
|
34
35
|
"dist",
|
|
35
36
|
"index.d.ts"
|
|
36
|
-
]
|
|
37
|
-
"exports": {
|
|
38
|
-
".": "./dist/index.bundle.js"
|
|
39
|
-
}
|
|
37
|
+
]
|
|
40
38
|
}
|