powerpagestoolkit 2.6.3213 → 2.6.3311

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 CHANGED
@@ -37,7 +37,7 @@ createRef(
37
37
  root: HTMLElement,
38
38
  timeout: number
39
39
  }
40
- ): Promise<DOMNodeReference | DOMNodeReferenceArray>;
40
+ ): Promise<DOMNodeReference | DOMNodeReference[]>;
41
41
  ```
42
42
 
43
43
  createRef takes two main arguments:
@@ -158,7 +158,7 @@ _Method signature:_
158
158
  ```typescript
159
159
  configureConditionalRendering(
160
160
  condition: () => boolean,
161
- dependencies?: Array<DOMNodeReference>,
161
+ dependencies?: DOMNodeReference[],
162
162
  clearValuesOnHide: boolean = true
163
163
  ): DOMNodeReference /* Instance of this returned
164
164
  for optional method chaining */
@@ -216,9 +216,9 @@ node.configureValidationAndRequirements(
216
216
 
217
217
  ##### Element Manipulation
218
218
 
219
- ```typescript
220
- /****/ Value management /****/
219
+ _Value management_
221
220
 
221
+ ```typescript
222
222
  // set a static value
223
223
  node.setValue("new value");
224
224
 
@@ -233,25 +233,31 @@ node.setValue(() => {
233
233
  node.updateValue();
234
234
 
235
235
  // Clear the value for both the instance and the target element
236
- node.clearValue()
236
+ node.clearValue();
237
+ ```
237
238
 
238
- /****/ Content manipulation /****/
239
+ _Content manipulation_
239
240
 
241
+ ```typescript
240
242
  node.setInnerHTML("<span>New content</span>");
241
243
  node.append(childElement);
242
244
  node.prepend(headerElement);
243
245
  node.after(siblingElement);
244
246
  node.before(labelElement);
247
+ ```
245
248
 
246
- /****/ Styling /****/
249
+ _Styling_
247
250
 
251
+ ```typescript
248
252
  node.setStyle({
249
253
  display: "block",
250
254
  color: "red",
251
255
  });
256
+ ```
252
257
 
253
- /****/ State management /****/
258
+ _Enabling/Disabling inputs_
254
259
 
260
+ ```typescript
255
261
  node.disable();
256
262
  node.enable();
257
263
 
@@ -7,16 +7,17 @@ declare const _updateRadioGroup: unique symbol;
7
7
  declare const _attachVisibilityController: unique symbol;
8
8
  declare const _attachRadioButtons: unique symbol;
9
9
  declare const _bindMethods: unique symbol;
10
- declare const observers: unique symbol;
11
- declare const boundEventListeners: unique symbol;
10
+ declare const _debounceTime: unique symbol;
11
+ declare const _observers: unique symbol;
12
+ declare const _boundEventListeners: unique symbol;
12
13
  export default class DOMNodeReference {
13
- target: HTMLElement | string;
14
+ target: HTMLElement | QuerySelector;
14
15
  root: HTMLElement;
15
- private debounceTime;
16
+ private [_debounceTime];
16
17
  private isLoaded;
17
18
  private defaultDisplay;
18
- private [observers];
19
- private [boundEventListeners];
19
+ private [_observers];
20
+ private [_boundEventListeners];
20
21
  /**
21
22
  * The value of the element that this node represents
22
23
  * stays in syncs with the live DOM elements?.,m via event handler
@@ -48,7 +49,7 @@ export default class DOMNodeReference {
48
49
  * @param root - Optionally specify the element within to search for the element targeted by 'target'
49
50
  * Defaults to 'document.body'
50
51
  */
51
- /******/ /******/ constructor(target: HTMLElement | string, root?: HTMLElement, debounceTime?: number);
52
+ /******/ /******/ constructor(target: HTMLElement | string, root: HTMLElement | undefined, debounceTime: number);
52
53
  [_init](): Promise<void>;
53
54
  /**
54
55
  * Initializes value synchronization with appropriate event listeners
package/dist/bundle.js CHANGED
@@ -279,17 +279,18 @@ var _updateRadioGroup = Symbol("_URG");
279
279
  var _attachVisibilityController = Symbol("_AVC");
280
280
  var _attachRadioButtons = Symbol("_ARB");
281
281
  var _bindMethods = Symbol("_B");
282
- var observers = Symbol("O");
283
- var boundEventListeners = Symbol("BEV");
282
+ var _debounceTime = Symbol("DT");
283
+ var _observers = Symbol("O");
284
+ var _boundEventListeners = Symbol("BEV");
284
285
  var DOMNodeReference = class _DOMNodeReference {
285
286
  // properties initialized in the constructor
286
287
  target;
287
288
  root;
288
- debounceTime;
289
+ [_debounceTime];
289
290
  isLoaded;
290
291
  defaultDisplay;
291
- [observers] = [];
292
- [boundEventListeners] = [];
292
+ [_observers] = [];
293
+ [_boundEventListeners] = [];
293
294
  /**
294
295
  * The value of the element that this node represents
295
296
  * stays in syncs with the live DOM elements?.,m via event handler
@@ -303,10 +304,10 @@ var DOMNodeReference = class _DOMNodeReference {
303
304
  */
304
305
  /******/
305
306
  /******/
306
- constructor(target, root = document.body, debounceTime = 5e3) {
307
+ constructor(target, root = document.body, debounceTime) {
307
308
  this.target = target;
308
309
  this.root = root;
309
- this.debounceTime = debounceTime;
310
+ this[_debounceTime] = debounceTime;
310
311
  this.isLoaded = false;
311
312
  this.defaultDisplay = "";
312
313
  this.value = null;
@@ -317,7 +318,7 @@ var DOMNodeReference = class _DOMNodeReference {
317
318
  if (this.target instanceof HTMLElement) {
318
319
  this.element = this.target;
319
320
  } else {
320
- this.element = await waitFor(this.target, this.root, false, this.debounceTime);
321
+ this.element = await waitFor(this.target, this.root, false, this[_debounceTime]);
321
322
  }
322
323
  if (!this.element) {
323
324
  throw new DOMNodeNotFoundError(this);
@@ -376,7 +377,7 @@ var DOMNodeReference = class _DOMNodeReference {
376
377
  this.element.addEventListener(eventType, this.updateValue);
377
378
  const _element = this.element;
378
379
  const _updateValue = this.updateValue;
379
- this[boundEventListeners].push({
380
+ this[_boundEventListeners].push({
380
381
  element: _element,
381
382
  handler: _updateValue,
382
383
  event: eventType
@@ -399,7 +400,7 @@ var DOMNodeReference = class _DOMNodeReference {
399
400
  const dateNode = await waitFor("[data-date-format]", parentElement, false, 1500);
400
401
  dateNode.addEventListener("select", this.updateValue);
401
402
  const _handler = this.updateValue;
402
- this[boundEventListeners].push({
403
+ this[_boundEventListeners].push({
403
404
  element: dateNode,
404
405
  handler: _handler,
405
406
  event: "select"
@@ -488,10 +489,10 @@ var DOMNodeReference = class _DOMNodeReference {
488
489
  }
489
490
  }
490
491
  [_destroy]() {
491
- this[boundEventListeners]?.forEach((binding) => {
492
+ this[_boundEventListeners]?.forEach((binding) => {
492
493
  binding.element?.removeEventListener(binding.event, binding.handler);
493
494
  });
494
- this[observers]?.forEach((observer) => {
495
+ this[_observers]?.forEach((observer) => {
495
496
  observer.disconnect();
496
497
  });
497
498
  this.yesRadio?.[_destroy]();
@@ -530,7 +531,7 @@ var DOMNodeReference = class _DOMNodeReference {
530
531
  this.element.addEventListener(eventType, eventHandler.bind(this));
531
532
  const _element = this.element;
532
533
  const _handler = eventHandler;
533
- this[boundEventListeners].push({
534
+ this[_boundEventListeners].push({
534
535
  element: _element,
535
536
  handler: _handler,
536
537
  event: eventType
@@ -933,14 +934,14 @@ var DOMNodeReference = class _DOMNodeReference {
933
934
  }
934
935
  };
935
936
  dep.on("change", handleChange);
936
- this[boundEventListeners].push({
937
+ this[_boundEventListeners].push({
937
938
  element: dep.element,
938
939
  event: "change",
939
940
  handler: handleChange
940
941
  });
941
942
  if (trackInputEvents) {
942
943
  dep.on("input", handleChange);
943
- this[boundEventListeners].push({
944
+ this[_boundEventListeners].push({
944
945
  element: dep.element,
945
946
  event: "input",
946
947
  handler: handleChange
@@ -960,12 +961,12 @@ var DOMNodeReference = class _DOMNodeReference {
960
961
  attributeFilter: ["style"],
961
962
  subtree: false
962
963
  });
963
- this[observers].push(observer);
964
+ this[_observers].push(observer);
964
965
  }
965
966
  if (trackRadioButtons && dep.yesRadio && dep.noRadio) {
966
967
  [dep.yesRadio, dep.noRadio].forEach((radio) => {
967
968
  radio.on("change", handleChange);
968
- this[boundEventListeners].push({
969
+ this[_boundEventListeners].push({
969
970
  element: radio.element,
970
971
  event: "change",
971
972
  handler: handleChange
@@ -1017,7 +1018,7 @@ var DOMNodeReference = class _DOMNodeReference {
1017
1018
  subtree: true,
1018
1019
  childList: true
1019
1020
  });
1020
- this[observers].push(observer);
1021
+ this[_observers].push(observer);
1021
1022
  }
1022
1023
  };
1023
1024
 
@@ -1025,7 +1026,7 @@ var DOMNodeReference = class _DOMNodeReference {
1025
1026
  async function createDOMNodeReference(target, options = {
1026
1027
  multiple: false,
1027
1028
  root: document.body,
1028
- timeout: 0
1029
+ timeout: 50
1029
1030
  }) {
1030
1031
  const { multiple = false, root = document.body, timeout = 0 } = options;
1031
1032
  try {
@@ -1039,7 +1040,7 @@ async function createDOMNodeReference(target, options = {
1039
1040
  const elements = await waitFor(target, root, true, timeout);
1040
1041
  const initializedElements = await Promise.all(
1041
1042
  elements.map(async (element) => {
1042
- const instance2 = new DOMNodeReference(element);
1043
+ const instance2 = new DOMNodeReference(element, root, timeout);
1043
1044
  await instance2[_init]();
1044
1045
  return new Proxy(instance2, createProxyHandler());
1045
1046
  })
@@ -1,10 +1,10 @@
1
1
  import DOMNodeReference from "./DOMNodeReference.js";
2
- export default function createDOMNodeReference(target: HTMLElement | string, options?: {
2
+ export default function createDOMNodeReference(target: HTMLElement | QuerySelector, options?: {
3
3
  multiple?: (() => boolean) | false;
4
4
  root?: HTMLElement;
5
5
  timeout?: number;
6
6
  }): Promise<DOMNodeReference>;
7
- export default function createDOMNodeReference(target: HTMLElement | string, options?: {
7
+ export default function createDOMNodeReference(target: HTMLElement | QuerySelector, options?: {
8
8
  multiple?: (() => true) | true;
9
9
  root?: HTMLElement;
10
10
  timeout?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powerpagestoolkit",
3
- "version": "2.6.3213",
3
+ "version": "2.6.3311",
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",