powerpagestoolkit 2.7.135 → 2.7.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.
- package/dist/import_map.json +6 -0
- package/dist/src/constants/eventMapping.d.ts +7 -0
- package/dist/{types → src}/constants/symbols.d.ts +1 -0
- package/dist/{types → src}/core/API.d.ts +14 -6
- package/dist/{types → src}/core/DOMNodeReference.d.ts +3 -60
- package/dist/{types → src}/core/DOMNodeReferenceArray.d.ts +2 -1
- package/dist/src/core/List.d.ts +13 -0
- package/dist/src/core/bindForm.d.ts +28 -0
- package/dist/{types → src}/core/createDOMNodeReferences.d.ts +12 -7
- package/dist/src/core/waitFor.d.ts +9 -0
- package/dist/{types → src}/errors/errors.d.ts +2 -1
- package/dist/src/globals.d.ts +152 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/{bundle.js → src/index.js} +89 -195
- package/dist/src/index.js.LEGAL.txt +0 -0
- package/dist/src/index.js.map +7 -0
- package/dist/{types → src}/managers/ReferenceManager.d.ts +2 -1
- package/dist/{types → src}/utils/createInfoElement.d.ts +1 -0
- package/dist/src/utils/enhanceArray.d.ts +13 -0
- package/dist/src/utils/safeAjax.d.ts +5 -0
- package/package.json +16 -26
- package/assets/infoIconExample.gif +0 -0
- package/dist/bundle.css +0 -36
- package/dist/index.global.js +0 -1373
- package/dist/types/constants/eventMapping.d.ts +0 -2
- package/dist/types/core/bindForm.d.ts +0 -13
- package/dist/types/core/waitFor.d.ts +0 -2
- package/dist/types/index.d.ts +0 -18
- package/dist/types/utils/enhanceArray.d.ts +0 -3
- package/dist/types/utils/safeAjax.d.ts +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* @ts-self-types="./index.d.ts" */
|
|
1
2
|
// src/utils/safeAjax.ts
|
|
2
3
|
function safeAjax(ajaxOptions) {
|
|
3
4
|
const deferredAjax = $.Deferred();
|
|
@@ -21,20 +22,20 @@ function safeAjax(ajaxOptions) {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
// src/core/API.ts
|
|
24
|
-
var API = {
|
|
25
|
+
var API = class {
|
|
25
26
|
/**
|
|
26
27
|
* @param tableSetName The dataverse set name for the table that you are updating a record in
|
|
27
28
|
* @param data The JSON of the fields and data that are to be updated on the targeted record
|
|
28
29
|
* @returns a Promise resolving the successful results *[record id]* of the POST request, or rejecting the failed results *[error]* of the POST request.
|
|
29
30
|
*/
|
|
30
|
-
createRecord(tableSetName, data) {
|
|
31
|
+
static createRecord(tableSetName, data) {
|
|
31
32
|
return new Promise((resolve, reject) => {
|
|
32
33
|
safeAjax({
|
|
33
34
|
type: "POST",
|
|
34
35
|
url: `/_api/${tableSetName}`,
|
|
35
36
|
data: JSON.stringify(data),
|
|
36
37
|
contentType: "application/json",
|
|
37
|
-
success: function(
|
|
38
|
+
success: function(_response, _status, xhr) {
|
|
38
39
|
resolve(xhr.getResponseHeader("entityid"));
|
|
39
40
|
},
|
|
40
41
|
error: (error) => {
|
|
@@ -42,7 +43,7 @@ var API = {
|
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
45
|
});
|
|
45
|
-
}
|
|
46
|
+
}
|
|
46
47
|
/**
|
|
47
48
|
*
|
|
48
49
|
* @param tableSetName The DataVerse SET name of the table being queried
|
|
@@ -50,7 +51,7 @@ var API = {
|
|
|
50
51
|
* @param selectColumns *OPTIONAL* if desired, enter your own custom OData query for advanced GET results. Format = select=column1,column2,column3...
|
|
51
52
|
* @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
|
|
52
53
|
*/
|
|
53
|
-
getRecord(tableSetName, recordID, selectColumns) {
|
|
54
|
+
static getRecord(tableSetName, recordID, selectColumns) {
|
|
54
55
|
return new Promise((resolve, reject) => {
|
|
55
56
|
const url = `/_api/${tableSetName}(${recordID})${selectColumns ? `?$${selectColumns}` : ""}`;
|
|
56
57
|
safeAjax({
|
|
@@ -60,14 +61,14 @@ var API = {
|
|
|
60
61
|
error: reject
|
|
61
62
|
});
|
|
62
63
|
});
|
|
63
|
-
}
|
|
64
|
+
}
|
|
64
65
|
/**
|
|
65
66
|
*
|
|
66
67
|
* @param tableSetName The dataverse set name of the table being queried
|
|
67
68
|
* @param queryParameters *OPTIONAL* the OData query parameters for refining search results: *format = $filter=filters&$select=columns*
|
|
68
69
|
* @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
|
|
69
70
|
*/
|
|
70
|
-
getMultiple(tableSetName, queryParameters) {
|
|
71
|
+
static getMultiple(tableSetName, queryParameters) {
|
|
71
72
|
return new Promise((resolve, reject) => {
|
|
72
73
|
const url = `/_api/${tableSetName}${queryParameters ? `?${queryParameters}` : ""}`;
|
|
73
74
|
safeAjax({
|
|
@@ -79,7 +80,7 @@ var API = {
|
|
|
79
80
|
error: reject
|
|
80
81
|
});
|
|
81
82
|
});
|
|
82
|
-
}
|
|
83
|
+
}
|
|
83
84
|
/**
|
|
84
85
|
*
|
|
85
86
|
* @param tableSetName The dataverse set name for the table that you are updating a record in
|
|
@@ -87,7 +88,7 @@ var API = {
|
|
|
87
88
|
* @param data The JSON of the fields and data that are to be updated on the targeted record
|
|
88
89
|
* @returns A Promise with the results of the API execution
|
|
89
90
|
*/
|
|
90
|
-
updateRecord(tableSetName, recordId, data) {
|
|
91
|
+
static updateRecord(tableSetName, recordId, data) {
|
|
91
92
|
return new Promise((resolve, reject) => {
|
|
92
93
|
const url = `/_api/${tableSetName}(${recordId})`;
|
|
93
94
|
safeAjax({
|
|
@@ -106,7 +107,7 @@ var API_default = API;
|
|
|
106
107
|
function waitFor(target, root = document, multiple = false, debounceTime2) {
|
|
107
108
|
return new Promise((resolve, reject) => {
|
|
108
109
|
if (multiple) {
|
|
109
|
-
let
|
|
110
|
+
let timeout;
|
|
110
111
|
const observedElements = [];
|
|
111
112
|
const observedSet = /* @__PURE__ */ new Set();
|
|
112
113
|
if (debounceTime2 < 1) {
|
|
@@ -122,8 +123,8 @@ function waitFor(target, root = document, multiple = false, debounceTime2) {
|
|
|
122
123
|
observedElements.push(element);
|
|
123
124
|
}
|
|
124
125
|
});
|
|
125
|
-
clearTimeout(
|
|
126
|
-
|
|
126
|
+
clearTimeout(timeout);
|
|
127
|
+
timeout = setTimeout(() => {
|
|
127
128
|
if (observedElements.length > 0) {
|
|
128
129
|
observer.disconnect();
|
|
129
130
|
resolve(observedElements);
|
|
@@ -158,10 +159,6 @@ function waitFor(target, root = document, multiple = false, debounceTime2) {
|
|
|
158
159
|
)
|
|
159
160
|
);
|
|
160
161
|
}, debounceTime2);
|
|
161
|
-
if (target instanceof HTMLElement) {
|
|
162
|
-
clearTimeout(timeout);
|
|
163
|
-
return resolve(target);
|
|
164
|
-
}
|
|
165
162
|
const element = root.querySelector(target);
|
|
166
163
|
if (element) {
|
|
167
164
|
clearTimeout(timeout);
|
|
@@ -270,13 +267,6 @@ var DOMNodeNotFoundError = class extends Error {
|
|
|
270
267
|
super(`The targeted DOM element was not found: ${instance.target}`);
|
|
271
268
|
}
|
|
272
269
|
};
|
|
273
|
-
var ConditionalRenderingError = class extends Error {
|
|
274
|
-
constructor(instance, error) {
|
|
275
|
-
super(
|
|
276
|
-
`There was an error condiguring conditional rendering for target: ${instance.target} :: ${error}`
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
270
|
var ValidationConfigError = class extends Error {
|
|
281
271
|
constructor(node, message) {
|
|
282
272
|
super(`Validation configuration error for ${node.target}: ${message}`);
|
|
@@ -436,6 +426,7 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
436
426
|
checked: this.yesRadio.checked
|
|
437
427
|
};
|
|
438
428
|
}
|
|
429
|
+
let returnValue;
|
|
439
430
|
switch (input.type) {
|
|
440
431
|
case "checkbox":
|
|
441
432
|
case "radio":
|
|
@@ -457,14 +448,21 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
457
448
|
return {
|
|
458
449
|
value: input.value !== "" ? Number(input.value) : null
|
|
459
450
|
};
|
|
460
|
-
default:
|
|
451
|
+
default: {
|
|
461
452
|
let cleanValue = input.value;
|
|
462
|
-
if (this.element.classList.contains("decimal") || this.element.classList.contains("money"))
|
|
453
|
+
if (this.element.classList.contains("decimal") || this.element.classList.contains("money")) {
|
|
463
454
|
cleanValue = input.value.replace(/[$,]/g, "");
|
|
464
|
-
|
|
455
|
+
}
|
|
456
|
+
returnValue = {
|
|
465
457
|
value: this.element.classList.contains("decimal") || this.element.classList.contains("money") ? parseFloat(cleanValue) : cleanValue
|
|
466
458
|
};
|
|
459
|
+
}
|
|
467
460
|
}
|
|
461
|
+
returnValue = {
|
|
462
|
+
...returnValue,
|
|
463
|
+
value: this.validateValue(returnValue.value)
|
|
464
|
+
};
|
|
465
|
+
return returnValue;
|
|
468
466
|
}
|
|
469
467
|
[attachVisibilityController]() {
|
|
470
468
|
this.visibilityController = this.element;
|
|
@@ -536,6 +534,7 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
536
534
|
* @public
|
|
537
535
|
*/
|
|
538
536
|
updateValue(e) {
|
|
537
|
+
if (e && !e.isTrusted) return;
|
|
539
538
|
if (e) {
|
|
540
539
|
e.stopPropagation();
|
|
541
540
|
}
|
|
@@ -548,6 +547,16 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
548
547
|
if (elementValue.checked !== void 0) {
|
|
549
548
|
this.checked = elementValue.checked;
|
|
550
549
|
}
|
|
550
|
+
console.log("updated this element: ", this);
|
|
551
|
+
}
|
|
552
|
+
validateValue(value) {
|
|
553
|
+
if (value === null || value === "") {
|
|
554
|
+
return value;
|
|
555
|
+
}
|
|
556
|
+
if (!isNaN(Number(value))) {
|
|
557
|
+
return Number(value);
|
|
558
|
+
}
|
|
559
|
+
return value;
|
|
551
560
|
}
|
|
552
561
|
/**
|
|
553
562
|
* Sets up an event listener based on the specified event type, executing the specified
|
|
@@ -587,7 +596,6 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
587
596
|
return this;
|
|
588
597
|
}
|
|
589
598
|
/**
|
|
590
|
-
*
|
|
591
599
|
* @param shouldShow - Either a function that returns true or false,
|
|
592
600
|
* or a natural boolean to determine the visibility of this
|
|
593
601
|
* @returns - Instance of this [provides option to method chain]
|
|
@@ -611,8 +619,6 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
611
619
|
if (value instanceof Function) {
|
|
612
620
|
value = value();
|
|
613
621
|
}
|
|
614
|
-
const eventType = this.determineEventType();
|
|
615
|
-
this.element.dispatchEvent(new Event(eventType, { bubbles: false }));
|
|
616
622
|
if (this.yesRadio instanceof _DOMNodeReference && this.noRadio instanceof _DOMNodeReference) {
|
|
617
623
|
this.yesRadio.element.checked = value;
|
|
618
624
|
this.noRadio.element.checked = !value;
|
|
@@ -625,6 +631,7 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
625
631
|
} else {
|
|
626
632
|
this.element.value = value;
|
|
627
633
|
}
|
|
634
|
+
this.value = this.validateValue(value);
|
|
628
635
|
return this;
|
|
629
636
|
}
|
|
630
637
|
/**
|
|
@@ -721,7 +728,7 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
721
728
|
enable() {
|
|
722
729
|
try {
|
|
723
730
|
this.element.disabled = false;
|
|
724
|
-
} catch (
|
|
731
|
+
} catch (_error) {
|
|
725
732
|
throw new Error(
|
|
726
733
|
`There was an error trying to disable the target: ${this.target}`
|
|
727
734
|
);
|
|
@@ -729,7 +736,6 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
729
736
|
return this;
|
|
730
737
|
}
|
|
731
738
|
/**
|
|
732
|
-
*
|
|
733
739
|
* @param elements - The elements to prepend to the element targeted by this.
|
|
734
740
|
* @returns - Instance of this [provides option to method chain]
|
|
735
741
|
*/
|
|
@@ -811,7 +817,6 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
811
817
|
return this;
|
|
812
818
|
}
|
|
813
819
|
/**
|
|
814
|
-
*
|
|
815
820
|
* @param options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}
|
|
816
821
|
* @returns - Instance of this [provides option to method chain]
|
|
817
822
|
*/
|
|
@@ -852,32 +857,19 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
852
857
|
applyBusinessRule(rule, dependencies) {
|
|
853
858
|
try {
|
|
854
859
|
if (rule.setVisibility) {
|
|
855
|
-
const [condition
|
|
856
|
-
const initialState = condition.
|
|
860
|
+
const [condition] = rule.setVisibility;
|
|
861
|
+
const initialState = condition.call(this);
|
|
857
862
|
this.toggleVisibility(initialState);
|
|
858
|
-
if (dependencies.length) {
|
|
859
|
-
this._configDependencyTracking(
|
|
860
|
-
() => this.toggleVisibility(condition.bind(this)()),
|
|
861
|
-
dependencies,
|
|
862
|
-
{
|
|
863
|
-
clearValuesOnHide,
|
|
864
|
-
observeVisibility: true,
|
|
865
|
-
trackInputEvents: false,
|
|
866
|
-
trackRadioButtons: false
|
|
867
|
-
}
|
|
868
|
-
);
|
|
869
|
-
}
|
|
870
863
|
}
|
|
871
864
|
if (rule.setRequired) {
|
|
872
865
|
const [isRequired, isValid] = rule.setRequired;
|
|
873
866
|
const fieldDisplayName = (() => {
|
|
874
867
|
let label = this.getLabel();
|
|
875
|
-
if (!label)
|
|
876
|
-
|
|
877
|
-
`There was an error accessing the label for this element: ${
|
|
878
|
-
this.target
|
|
879
|
-
)}`
|
|
868
|
+
if (!label) {
|
|
869
|
+
throw new Error(
|
|
870
|
+
`There was an error accessing the label for this element: ${this.target}`
|
|
880
871
|
);
|
|
872
|
+
}
|
|
881
873
|
label = label.innerHTML;
|
|
882
874
|
if (label.length > 50) {
|
|
883
875
|
label = label.substring(0, 50) + "...";
|
|
@@ -895,159 +887,63 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
895
887
|
controltovalidate: this.element.id,
|
|
896
888
|
errormessage: `<a href='#${this.element.id}_label'>${fieldDisplayName} is a required field</a>`,
|
|
897
889
|
evaluationfunction: () => {
|
|
898
|
-
const isFieldRequired = isRequired.
|
|
890
|
+
const isFieldRequired = isRequired.call(this);
|
|
899
891
|
const isFieldVisible = window.getComputedStyle(this.visibilityController).display !== "none";
|
|
900
|
-
return !isFieldRequired || !isFieldVisible || isValid.
|
|
892
|
+
return !isFieldRequired || !isFieldVisible || isValid.call(this, isFieldRequired);
|
|
901
893
|
}
|
|
902
894
|
});
|
|
903
895
|
Page_Validators.push(newValidator);
|
|
904
|
-
this.setRequiredLevel(isRequired.
|
|
905
|
-
this._configDependencyTracking(
|
|
906
|
-
() => this.setRequiredLevel(isRequired.bind(this)()),
|
|
907
|
-
dependencies,
|
|
908
|
-
{ clearValuesOnHide: false }
|
|
909
|
-
);
|
|
896
|
+
this.setRequiredLevel(isRequired.call(this));
|
|
910
897
|
}
|
|
911
898
|
if (rule.setValue) {
|
|
912
899
|
let [condition, value] = rule.setValue;
|
|
913
900
|
if (value instanceof Function) value = value();
|
|
914
|
-
if (condition.
|
|
915
|
-
this.setValue.
|
|
916
|
-
}
|
|
917
|
-
if (dependencies.length) {
|
|
918
|
-
this._configDependencyTracking(
|
|
919
|
-
() => {
|
|
920
|
-
if (condition.bind(this)()) {
|
|
921
|
-
this.setValue.bind(this)(value);
|
|
922
|
-
}
|
|
923
|
-
},
|
|
924
|
-
dependencies,
|
|
925
|
-
{ clearValuesOnHide: false }
|
|
926
|
-
);
|
|
901
|
+
if (condition.call(this)) {
|
|
902
|
+
this.setValue.call(this, value);
|
|
927
903
|
}
|
|
928
904
|
}
|
|
929
905
|
if (rule.setDisabled) {
|
|
930
906
|
const condition = rule.setDisabled;
|
|
931
|
-
condition.
|
|
932
|
-
if (dependencies.length) {
|
|
933
|
-
this._configDependencyTracking(
|
|
934
|
-
() => {
|
|
935
|
-
condition.bind(this)() ? this.enable() : this.disable();
|
|
936
|
-
},
|
|
937
|
-
dependencies,
|
|
938
|
-
{
|
|
939
|
-
clearValuesOnHide: false,
|
|
940
|
-
observeVisibility: true,
|
|
941
|
-
trackInputEvents: true,
|
|
942
|
-
trackRadioButtons: true
|
|
943
|
-
}
|
|
944
|
-
);
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
return this;
|
|
948
|
-
} catch (error) {
|
|
949
|
-
throw new ValidationConfigError(
|
|
950
|
-
this,
|
|
951
|
-
`Failed to apply business rule: ${error}`
|
|
952
|
-
);
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
/**
|
|
956
|
-
* Configures conditional rendering for the target element based on a condition
|
|
957
|
-
* and the visibility of one or more trigger elements.
|
|
958
|
-
* @deprecated Use the new 'applyBusinessRule Method
|
|
959
|
-
* @param condition A function that returns a boolean to determine
|
|
960
|
-
* the visibility of the target element. If `condition()` returns true, the element is shown;
|
|
961
|
-
* otherwise, it is hidden.
|
|
962
|
-
* @param dependencies - An array of `DOMNodeReference` instances. Event listeners are
|
|
963
|
-
* registered on each to toggle the visibility of the target element based on the `condition` and the visibility of
|
|
964
|
-
* the target node.
|
|
965
|
-
* @throws When there's an error in setting up conditional rendering
|
|
966
|
-
* @returns Instance of this [provides option to method chain]
|
|
967
|
-
*/
|
|
968
|
-
configureConditionalRendering(condition, dependencies, clearValuesOnHide = true) {
|
|
969
|
-
try {
|
|
970
|
-
if (typeof condition !== "function") {
|
|
971
|
-
throw new TypeError("Condition must be a function");
|
|
907
|
+
condition.call(this) ? this.disable() : this.enable();
|
|
972
908
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
909
|
+
if (dependencies.length) {
|
|
910
|
+
let visibilityCondition, clearValuesOnHide, isRequired, valueCondition, value, disabledCondition;
|
|
911
|
+
const aggregateHandler = (rule2) => {
|
|
912
|
+
if (rule2.setVisibility) {
|
|
913
|
+
[visibilityCondition, clearValuesOnHide = true] = rule2.setVisibility;
|
|
914
|
+
this.toggleVisibility(visibilityCondition.call(this));
|
|
915
|
+
}
|
|
916
|
+
if (rule2.setRequired) {
|
|
917
|
+
[isRequired] = rule2.setRequired;
|
|
918
|
+
this.setRequiredLevel(isRequired.call(this));
|
|
919
|
+
}
|
|
920
|
+
if (rule2.setValue) {
|
|
921
|
+
[valueCondition, value] = rule2.setValue;
|
|
922
|
+
if (valueCondition.call(this)) this.setValue.call(this, value);
|
|
923
|
+
}
|
|
924
|
+
if (rule2.setDisabled) {
|
|
925
|
+
disabledCondition = rule2.setDisabled;
|
|
926
|
+
disabledCondition.call(this) ? this.disable() : this.enable;
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
this._configDependencyTracking(
|
|
930
|
+
() => aggregateHandler(rule),
|
|
931
|
+
dependencies,
|
|
932
|
+
{
|
|
933
|
+
clearValuesOnHide,
|
|
934
|
+
observeVisibility: true,
|
|
935
|
+
trackInputEvents: false,
|
|
936
|
+
trackRadioButtons: false
|
|
937
|
+
}
|
|
979
938
|
);
|
|
980
|
-
return this;
|
|
981
939
|
}
|
|
982
|
-
this._configDependencyTracking(
|
|
983
|
-
() => this.toggleVisibility(condition()),
|
|
984
|
-
dependencies,
|
|
985
|
-
{
|
|
986
|
-
clearValuesOnHide,
|
|
987
|
-
observeVisibility: true,
|
|
988
|
-
trackInputEvents: false,
|
|
989
|
-
trackRadioButtons: false
|
|
990
|
-
}
|
|
991
|
-
);
|
|
992
940
|
return this;
|
|
993
|
-
} catch (error) {
|
|
994
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
995
|
-
throw new ConditionalRenderingError(this, errorMessage);
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
* Sets up validation and requirement rules for the field with enhanced error handling and dynamic updates.
|
|
1000
|
-
* @deprecated Use the new 'applyBusinessRule Method
|
|
1001
|
-
* @param isRequired Function determining if field is required
|
|
1002
|
-
* @param isValid Function validating field input
|
|
1003
|
-
* @param fieldDisplayName Display name for error messages
|
|
1004
|
-
* @param dependencies Fields that trigger requirement/validation updates
|
|
1005
|
-
* @returns Instance of this
|
|
1006
|
-
* @throws If validation setup fails
|
|
1007
|
-
*/
|
|
1008
|
-
configureValidationAndRequirements(isRequired, isValid, fieldDisplayName, dependencies) {
|
|
1009
|
-
if (!fieldDisplayName?.trim()) {
|
|
1010
|
-
throw new ValidationConfigError(this, "Field display name is required");
|
|
1011
|
-
}
|
|
1012
|
-
if (!Array.isArray(dependencies)) {
|
|
1013
|
-
throw new ValidationConfigError(this, "Dependencies must be an array");
|
|
1014
|
-
}
|
|
1015
|
-
try {
|
|
1016
|
-
isRequired = isRequired.bind(this);
|
|
1017
|
-
isValid = isValid.bind(this);
|
|
1018
|
-
if (typeof Page_Validators === "undefined") {
|
|
1019
|
-
throw new ValidationConfigError(this, "Page_Validators not found");
|
|
1020
|
-
}
|
|
1021
|
-
const validatorId = `${this.element.id}Validator`;
|
|
1022
|
-
const newValidator = document.createElement("span");
|
|
1023
|
-
newValidator.style.display = "none";
|
|
1024
|
-
newValidator.id = validatorId;
|
|
1025
|
-
const validatorConfig = {
|
|
1026
|
-
controltovalidate: this.element.id,
|
|
1027
|
-
errormessage: `<a href='#${this.element.id}_label'>${fieldDisplayName} is a required field</a>`,
|
|
1028
|
-
evaluationfunction: () => {
|
|
1029
|
-
const isFieldRequired = isRequired();
|
|
1030
|
-
const isFieldVisible = window.getComputedStyle(this.visibilityController).display !== "none";
|
|
1031
|
-
if (!isFieldRequired || !isFieldVisible) {
|
|
1032
|
-
return true;
|
|
1033
|
-
}
|
|
1034
|
-
return isValid();
|
|
1035
|
-
}
|
|
1036
|
-
};
|
|
1037
|
-
Object.assign(newValidator, validatorConfig);
|
|
1038
|
-
Page_Validators.push(newValidator);
|
|
1039
|
-
this.setRequiredLevel(isRequired());
|
|
1040
|
-
this._configDependencyTracking(
|
|
1041
|
-
() => this.setRequiredLevel(isRequired()),
|
|
1042
|
-
dependencies
|
|
1043
|
-
);
|
|
1044
941
|
} catch (error) {
|
|
1045
942
|
throw new ValidationConfigError(
|
|
1046
943
|
this,
|
|
1047
|
-
`Failed to
|
|
944
|
+
`Failed to apply business rule: ${error}`
|
|
1048
945
|
);
|
|
1049
946
|
}
|
|
1050
|
-
return this;
|
|
1051
947
|
}
|
|
1052
948
|
/**
|
|
1053
949
|
* Sets up tracking for dependencies using both event listeners and mutation observers.
|
|
@@ -1331,26 +1227,24 @@ function getIdentifyingAttribute(tagName) {
|
|
|
1331
1227
|
}
|
|
1332
1228
|
function createReferenceString(tagName, datafieldname) {
|
|
1333
1229
|
if (tagName === "control") return `#${datafieldname}`;
|
|
1334
|
-
if (tagName === "tab" || tagName === "section")
|
|
1230
|
+
if (tagName === "tab" || tagName === "section") {
|
|
1335
1231
|
return `[data-name="${datafieldname}"]`;
|
|
1232
|
+
}
|
|
1336
1233
|
return null;
|
|
1337
1234
|
}
|
|
1338
|
-
|
|
1339
|
-
// src/index.ts
|
|
1340
|
-
var toolkit = { API: API_default, createRef: createDOMNodeReference, waitFor, bindForm };
|
|
1341
|
-
var src_default = toolkit;
|
|
1342
1235
|
export {
|
|
1343
1236
|
API_default as API,
|
|
1344
1237
|
bindForm,
|
|
1345
1238
|
createDOMNodeReference as createRef,
|
|
1346
|
-
src_default as default,
|
|
1347
1239
|
waitFor
|
|
1348
1240
|
};
|
|
1241
|
+
/*! For license information please see index.js.LEGAL.txt */
|
|
1242
|
+
//# sourceMappingURL=index.js.map
|
|
1349
1243
|
|
|
1350
1244
|
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1245
|
+
if (typeof document !== 'undefined') {
|
|
1246
|
+
const style = document.createElement('style');
|
|
1247
|
+
style.textContent = ".info-icon {\r\n position: relative;\r\n display: inline-block;\r\n}\r\n\r\n.info-icon .fa-info-circle {\r\n cursor: pointer; /* Ensures the icon is recognized as interactive */\r\n}\r\n\r\n.info-icon .flyout-content {\r\n max-width: calc(100vw - 20px); /* 20px margin on both sides */\r\n display: none; /* Initially hidden */\r\n position: absolute;\r\n left: 50%; /* Center horizontally */\r\n transform: translateX(-50%); /* Adjust positioning */\r\n color: #000;\r\n background-color: #f9f9f9;\r\n padding: 10px;\r\n border: 1px solid #ddd;\r\n z-index: 1;\r\n min-width: 200px; /* Minimum width for better readability */\r\n box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);\r\n border-radius: 4px; /* Rounded corners */\r\n}\r\n\r\n@media (max-width: 600px) {\r\n .info-icon .flyout-content {\r\n max-width: 95vw;\r\n padding: 12px;\r\n font-size: 0.9em;\r\n display: block;\r\n right: auto;\r\n }\r\n}\r\n\r\n.required-field::after {\r\n content: \" *\" !important;\r\n color: #f00 !important;\r\n}\r\n";
|
|
1248
|
+
document.head.appendChild(style);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
File without changes
|