powerpagestoolkit 2.3.101 → 2.3.311
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/DOMNodeReference.d.ts +4 -5
- package/dist/bundle.css +35 -0
- package/dist/bundle.js +15 -18
- package/dist/index.d.ts +1 -1
- package/package.json +7 -3
|
@@ -40,7 +40,6 @@ export declare const _init: unique symbol;
|
|
|
40
40
|
[_init](): Promise<void>;
|
|
41
41
|
private _initValueSync;
|
|
42
42
|
updateValue(): void;
|
|
43
|
-
private _observeValueChanges;
|
|
44
43
|
private _attachVisibilityController;
|
|
45
44
|
private _attachRadioButtons;
|
|
46
45
|
/**
|
|
@@ -71,12 +70,12 @@ export declare const _init: unique symbol;
|
|
|
71
70
|
toggleVisibility(shouldShow: Function | boolean): DOMNodeReference;
|
|
72
71
|
/**
|
|
73
72
|
* Sets the value of the HTML element.
|
|
74
|
-
* @param {() => any} value - The value to set for the HTML element.
|
|
73
|
+
* @param {(() => any) | any} value - The value to set for the HTML element.
|
|
75
74
|
* for parents of boolean radios, pass true or false as value, or
|
|
76
75
|
* an expression returning a boolean
|
|
77
76
|
* @returns - Instance of this
|
|
78
77
|
*/
|
|
79
|
-
setValue(value: any): DOMNodeReference;
|
|
78
|
+
setValue(value: (() => any) | any): DOMNodeReference;
|
|
80
79
|
/**
|
|
81
80
|
* Disables the element so that users cannot input any data
|
|
82
81
|
* @returns - Instance of this
|
|
@@ -182,11 +181,11 @@ export declare const _init: unique symbol;
|
|
|
182
181
|
/**
|
|
183
182
|
* Sets the required level for the field by adding or removing the "required-field" class on the label.
|
|
184
183
|
*
|
|
185
|
-
* @param {boolean} isRequired - Determines whether the field should be marked as required.
|
|
184
|
+
* @param {Function | boolean} isRequired - Determines whether the field should be marked as required.
|
|
186
185
|
* If true, the "required-field" class is added to the label; if false, it is removed.
|
|
187
186
|
* @returns - Instance of this
|
|
188
187
|
*/
|
|
189
|
-
setRequiredLevel(isRequired:
|
|
188
|
+
setRequiredLevel(isRequired: (() => boolean) | boolean): DOMNodeReference;
|
|
190
189
|
/**
|
|
191
190
|
* Executes a callback function once the element is fully loaded.
|
|
192
191
|
* If the element is already loaded, the callback is called immediately.
|
package/dist/bundle.css
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* src/style.css */
|
|
2
|
+
.info-icon {
|
|
3
|
+
position: relative;
|
|
4
|
+
display: inline-block;
|
|
5
|
+
}
|
|
6
|
+
.info-icon .fa-info-circle {
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
}
|
|
9
|
+
.info-icon .flyout-content {
|
|
10
|
+
max-width: calc(100vw - 20px);
|
|
11
|
+
display: none;
|
|
12
|
+
position: absolute;
|
|
13
|
+
left: 50%;
|
|
14
|
+
transform: translateX(-50%);
|
|
15
|
+
background-color: #f9f9f9;
|
|
16
|
+
padding: 10px;
|
|
17
|
+
border: 1px solid #ddd;
|
|
18
|
+
z-index: 1;
|
|
19
|
+
min-width: 200px;
|
|
20
|
+
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
|
|
21
|
+
border-radius: 4px;
|
|
22
|
+
}
|
|
23
|
+
@media (max-width: 600px) {
|
|
24
|
+
.info-icon .flyout-content {
|
|
25
|
+
max-width: 95vw;
|
|
26
|
+
padding: 12px;
|
|
27
|
+
font-size: 0.9em;
|
|
28
|
+
display: block;
|
|
29
|
+
right: auto;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
.required-field::after {
|
|
33
|
+
content: " *" !important;
|
|
34
|
+
color: #f00 !important;
|
|
35
|
+
}
|
package/dist/bundle.js
CHANGED
|
@@ -257,14 +257,10 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
257
257
|
} else {
|
|
258
258
|
this.element.addEventListener("input", this.updateValue.bind(this));
|
|
259
259
|
}
|
|
260
|
-
this._observeValueChanges();
|
|
261
260
|
}
|
|
262
261
|
updateValue() {
|
|
263
262
|
switch (this.element.type) {
|
|
264
263
|
case "checkbox":
|
|
265
|
-
this.value = +this.element.checked;
|
|
266
|
-
this.checked = this.element.checked;
|
|
267
|
-
break;
|
|
268
264
|
case "radio":
|
|
269
265
|
this.value = this.element.checked;
|
|
270
266
|
this.checked = this.element.checked;
|
|
@@ -276,6 +272,7 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
276
272
|
break;
|
|
277
273
|
case "select-one":
|
|
278
274
|
this.value = this.element.value;
|
|
275
|
+
break;
|
|
279
276
|
case "number":
|
|
280
277
|
this.value = this.element.value !== "" ? Number(this.element.value) : null;
|
|
281
278
|
break;
|
|
@@ -287,19 +284,9 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
287
284
|
this.yesRadio.updateValue();
|
|
288
285
|
this.noRadio.updateValue();
|
|
289
286
|
this.checked = this.yesRadio.checked;
|
|
290
|
-
this.value =
|
|
287
|
+
this.value = this.yesRadio.checked;
|
|
291
288
|
}
|
|
292
289
|
}
|
|
293
|
-
// Add a method to observe value changes using MutationObserver
|
|
294
|
-
_observeValueChanges() {
|
|
295
|
-
const observer = new MutationObserver(() => {
|
|
296
|
-
this.updateValue();
|
|
297
|
-
});
|
|
298
|
-
observer.observe(this.element, {
|
|
299
|
-
attributes: true,
|
|
300
|
-
attributeFilter: ["value"]
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
290
|
_attachVisibilityController() {
|
|
304
291
|
this.visibilityController = this.element;
|
|
305
292
|
if (this.element.tagName === "TABLE") {
|
|
@@ -371,12 +358,15 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
371
358
|
}
|
|
372
359
|
/**
|
|
373
360
|
* Sets the value of the HTML element.
|
|
374
|
-
* @param {() => any} value - The value to set for the HTML element.
|
|
361
|
+
* @param {(() => any) | any} value - The value to set for the HTML element.
|
|
375
362
|
* for parents of boolean radios, pass true or false as value, or
|
|
376
363
|
* an expression returning a boolean
|
|
377
364
|
* @returns - Instance of this
|
|
378
365
|
*/
|
|
379
366
|
setValue(value) {
|
|
367
|
+
if (value instanceof Function) {
|
|
368
|
+
value = value();
|
|
369
|
+
}
|
|
380
370
|
if (this.element.classList.contains("boolean-radio")) {
|
|
381
371
|
this.yesRadio.element.checked = value;
|
|
382
372
|
this.noRadio.element.checked = !value;
|
|
@@ -614,7 +604,7 @@ var DOMNodeReference = class _DOMNodeReference {
|
|
|
614
604
|
/**
|
|
615
605
|
* Sets the required level for the field by adding or removing the "required-field" class on the label.
|
|
616
606
|
*
|
|
617
|
-
* @param {boolean} isRequired - Determines whether the field should be marked as required.
|
|
607
|
+
* @param {Function | boolean} isRequired - Determines whether the field should be marked as required.
|
|
618
608
|
* If true, the "required-field" class is added to the label; if false, it is removed.
|
|
619
609
|
* @returns - Instance of this
|
|
620
610
|
*/
|
|
@@ -702,4 +692,11 @@ export {
|
|
|
702
692
|
createDOMNodeReference,
|
|
703
693
|
createMultipleDOMNodeReferences
|
|
704
694
|
};
|
|
705
|
-
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
(function() {
|
|
698
|
+
const style = document.createElement('style');
|
|
699
|
+
style.textContent = "/* src/style.css */\n.info-icon {\n position: relative;\n display: inline-block;\n}\n.info-icon .fa-info-circle {\n cursor: pointer;\n}\n.info-icon .flyout-content {\n max-width: calc(100vw - 20px);\n display: none;\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n background-color: #f9f9f9;\n padding: 10px;\n border: 1px solid #ddd;\n z-index: 1;\n min-width: 200px;\n box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);\n border-radius: 4px;\n}\n@media (max-width: 600px) {\n .info-icon .flyout-content {\n max-width: 95vw;\n padding: 12px;\n font-size: 0.9em;\n display: block;\n right: auto;\n }\n}\n.required-field::after {\n content: \" *\" !important;\n color: #f00 !important;\n}\n";
|
|
700
|
+
document.head.appendChild(style);
|
|
701
|
+
})();
|
|
702
|
+
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powerpagestoolkit",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.311",
|
|
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/bundle.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"typecheck": "tsc",
|
|
9
|
-
"build": "node build.js",
|
|
9
|
+
"node:build": "node build.js",
|
|
10
10
|
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
11
|
-
"build
|
|
11
|
+
"build": "npm run typecheck && npm run node:build && npm run build:types",
|
|
12
12
|
"dev": "tsc --watch"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
],
|
|
56
56
|
"files": [
|
|
57
57
|
"dist/bundle.js",
|
|
58
|
+
"dist/bundle.css",
|
|
58
59
|
"dist/**/*.d.ts"
|
|
59
60
|
],
|
|
60
61
|
"exports": {
|
|
@@ -65,6 +66,9 @@
|
|
|
65
66
|
"./createDOMNodeReference": {
|
|
66
67
|
"import": "./dist/createDOMNodeReference.js",
|
|
67
68
|
"types": "./dist/createDOMNodeReference.d.ts"
|
|
69
|
+
},
|
|
70
|
+
"./style.css": {
|
|
71
|
+
"import": "./dist/bundle.css"
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
}
|