powerpagestoolkit 2.6.1 → 2.6.3

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.
@@ -1,4 +1,12 @@
1
1
  export declare const _init: unique symbol;
2
+ declare const _destroy: unique symbol;
3
+ declare const _valueSync: unique symbol;
4
+ declare const _dateSync: unique symbol;
5
+ declare const _getElementValue: unique symbol;
6
+ declare const _updateRadioGroup: unique symbol;
7
+ declare const _attachVisibilityController: unique symbol;
8
+ declare const _attachRadioButtons: unique symbol;
9
+ declare const _bindMethods: unique symbol;
2
10
  export default class DOMNodeReference {
3
11
  target: HTMLElement | string;
4
12
  private isLoaded;
@@ -23,13 +31,13 @@ export default class DOMNodeReference {
23
31
  * This property is only available when the parent node
24
32
  * is a main field for a boolean radio input.
25
33
  */
26
- yesRadio?: DOMNodeReference | null;
34
+ yesRadio: DOMNodeReference | null;
27
35
  /**
28
36
  * Represents the 'no' option of a boolean radio field.
29
37
  * This property is only available when the parent node
30
38
  * is a main field for a boolean radio input.
31
39
  */
32
- noRadio?: DOMNodeReference | null;
40
+ noRadio: DOMNodeReference | null;
33
41
  /**
34
42
  * Creates an instance of DOMNodeReference.
35
43
  * @param target - The CSS selector to find the desired DOM element.
@@ -41,23 +49,23 @@ export default class DOMNodeReference {
41
49
  * based on element type.
42
50
  * @private
43
51
  */
44
- private _initValueSync;
45
- private _initDateSync;
52
+ private [_valueSync];
53
+ private [_dateSync];
46
54
  /**
47
55
  * Gets the current value of the element based on its type
48
56
  * @private
49
- * @returns {ElementValue} Object containing value and optional checked state
57
+ * @returns Object containing value and optional checked state
50
58
  */
51
- private _getElementValue;
59
+ private [_getElementValue];
52
60
  /**
53
61
  * Updates related radio buttons if this is part of a radio group
54
62
  * @private
55
63
  */
56
- private _updateRadioGroup;
57
- private _attachVisibilityController;
58
- private _attachRadioButtons;
59
- private _bindMethods;
60
- private _destroy;
64
+ private [_updateRadioGroup];
65
+ private [_attachVisibilityController];
66
+ private [_attachRadioButtons];
67
+ private [_bindMethods];
68
+ private [_destroy];
61
69
  /**
62
70
  * Updates the value and checked state based on element type
63
71
  * @public
@@ -231,3 +239,4 @@ export default class DOMNodeReference {
231
239
  */
232
240
  onceLoaded(callback: (instance: DOMNodeReference) => any): any;
233
241
  }
242
+ export {};
package/dist/bundle.js CHANGED
@@ -228,14 +228,22 @@ var ValidationConfigError = class extends Error {
228
228
  };
229
229
 
230
230
  // src/DOMNodeReference.ts
231
- var _init = Symbol("_init");
231
+ var _init = Symbol("_I");
232
+ var _destroy = Symbol("_D");
233
+ var _valueSync = Symbol("_VS");
234
+ var _dateSync = Symbol("_DS");
235
+ var _getElementValue = Symbol("_GEV");
236
+ var _updateRadioGroup = Symbol("_URG");
237
+ var _attachVisibilityController = Symbol("_AVC");
238
+ var _attachRadioButtons = Symbol("_ARB");
239
+ var _bindMethods = Symbol("_B");
232
240
  var DOMNodeReference = class _DOMNodeReference {
233
241
  // properties initialized in the constructor
234
242
  target;
235
243
  isLoaded;
236
244
  defaultDisplay;
237
- observers;
238
- boundEventListeners;
245
+ observers = [];
246
+ boundEventListeners = [];
239
247
  /**
240
248
  * The value of the element that this node represents
241
249
  * stays in syncs with the live DOM elements?.,m via event handler
@@ -252,9 +260,7 @@ var DOMNodeReference = class _DOMNodeReference {
252
260
  this.isLoaded = false;
253
261
  this.defaultDisplay = "";
254
262
  this.value = null;
255
- this.observers = [];
256
- this.boundEventListeners = [];
257
- this._bindMethods();
263
+ this[_bindMethods]();
258
264
  }
259
265
  async [_init]() {
260
266
  try {
@@ -264,15 +270,15 @@ var DOMNodeReference = class _DOMNodeReference {
264
270
  throw new DOMNodeNotFoundError(this);
265
271
  }
266
272
  if (this.element.classList.contains("boolean-radio")) {
267
- await this._attachRadioButtons();
273
+ await this[_attachRadioButtons]();
268
274
  }
269
- this._initValueSync();
270
- this._attachVisibilityController();
275
+ this[_valueSync]();
276
+ this[_attachVisibilityController]();
271
277
  this.defaultDisplay = this.visibilityController.style.display;
272
278
  const observer = new MutationObserver((mutations) => {
273
279
  for (const mutation of mutations) {
274
280
  if (Array.from(mutation.removedNodes).includes(this.element)) {
275
- this._destroy();
281
+ this[_destroy]();
276
282
  observer.disconnect();
277
283
  break;
278
284
  }
@@ -293,7 +299,7 @@ var DOMNodeReference = class _DOMNodeReference {
293
299
  * based on element type.
294
300
  * @private
295
301
  */
296
- async _initValueSync() {
302
+ async [_valueSync]() {
297
303
  try {
298
304
  this.updateValue();
299
305
  if (!(this.element instanceof HTMLElement)) {
@@ -323,7 +329,7 @@ var DOMNodeReference = class _DOMNodeReference {
323
329
  event: eventType
324
330
  });
325
331
  if (this.element instanceof HTMLInputElement && this.element.dataset.type === "date") {
326
- await this._initDateSync(this.element);
332
+ await this[_dateSync](this.element);
327
333
  }
328
334
  } catch (error) {
329
335
  throw new DOMNodeInitializationError(
@@ -332,7 +338,7 @@ var DOMNodeReference = class _DOMNodeReference {
332
338
  );
333
339
  }
334
340
  }
335
- async _initDateSync(element) {
341
+ async [_dateSync](element) {
336
342
  const parentElement = element.parentElement;
337
343
  if (!parentElement) {
338
344
  throw new Error("Date input must have a parent element");
@@ -349,9 +355,9 @@ var DOMNodeReference = class _DOMNodeReference {
349
355
  /**
350
356
  * Gets the current value of the element based on its type
351
357
  * @private
352
- * @returns {ElementValue} Object containing value and optional checked state
358
+ * @returns Object containing value and optional checked state
353
359
  */
354
- _getElementValue() {
360
+ [_getElementValue]() {
355
361
  const input = this.element;
356
362
  const select = this.element;
357
363
  switch (input.type) {
@@ -385,7 +391,7 @@ var DOMNodeReference = class _DOMNodeReference {
385
391
  * Updates related radio buttons if this is part of a radio group
386
392
  * @private
387
393
  */
388
- _updateRadioGroup() {
394
+ [_updateRadioGroup]() {
389
395
  if (this.yesRadio instanceof _DOMNodeReference && this.noRadio instanceof _DOMNodeReference) {
390
396
  this.yesRadio.updateValue();
391
397
  this.noRadio?.updateValue();
@@ -393,7 +399,7 @@ var DOMNodeReference = class _DOMNodeReference {
393
399
  this.value = this.yesRadio.checked;
394
400
  }
395
401
  }
396
- _attachVisibilityController() {
402
+ [_attachVisibilityController]() {
397
403
  this.visibilityController = this.element;
398
404
  if (this.element.tagName === "TABLE") {
399
405
  const fieldset = this.element.closest("fieldset");
@@ -416,11 +422,11 @@ var DOMNodeReference = class _DOMNodeReference {
416
422
  }
417
423
  }
418
424
  }
419
- async _attachRadioButtons() {
425
+ async [_attachRadioButtons]() {
420
426
  this.yesRadio = await createDOMNodeReference(`#${this.element.id}_1`);
421
427
  this.noRadio = await createDOMNodeReference(`#${this.element.id}_0`);
422
428
  }
423
- _bindMethods() {
429
+ [_bindMethods]() {
424
430
  for (const key of Object.getOwnPropertyNames(Object.getPrototypeOf(this))) {
425
431
  const value = this[key];
426
432
  if (key !== "constructor" && typeof value === "function") {
@@ -428,19 +434,15 @@ var DOMNodeReference = class _DOMNodeReference {
428
434
  }
429
435
  }
430
436
  }
431
- _destroy() {
432
- if (this.boundEventListeners.length > 0) {
433
- this.boundEventListeners.forEach((binding) => {
434
- binding.element?.removeEventListener(binding.event, binding.handler);
435
- });
436
- }
437
- if (this.observers.length > 0) {
438
- this.observers.forEach((observer) => {
439
- observer.disconnect();
440
- });
441
- }
442
- this.yesRadio?._destroy();
443
- this.noRadio?._destroy();
437
+ [_destroy]() {
438
+ this.boundEventListeners?.forEach((binding) => {
439
+ binding.element?.removeEventListener(binding.event, binding.handler);
440
+ });
441
+ this.observers?.forEach((observer) => {
442
+ observer.disconnect();
443
+ });
444
+ this.yesRadio?.[_destroy]();
445
+ this.noRadio?.[_destroy]();
444
446
  this.yesRadio = null;
445
447
  this.noRadio = null;
446
448
  this.isLoaded = false;
@@ -451,12 +453,12 @@ var DOMNodeReference = class _DOMNodeReference {
451
453
  * @public
452
454
  */
453
455
  updateValue() {
454
- const elementValue = this._getElementValue();
456
+ const elementValue = this[_getElementValue]();
455
457
  this.value = elementValue.value;
456
458
  if (elementValue.checked !== void 0) {
457
459
  this.checked = elementValue.checked;
458
460
  }
459
- this._updateRadioGroup();
461
+ this[_updateRadioGroup]();
460
462
  }
461
463
  /**
462
464
  * Sets up an event listener based on the specified event type, executing the specified
@@ -878,8 +880,18 @@ var DOMNodeReference = class _DOMNodeReference {
878
880
  }
879
881
  };
880
882
  dep.on("change", handleChange);
883
+ this.boundEventListeners.push({
884
+ element: dep.element,
885
+ event: "change",
886
+ handler: handleChange
887
+ });
881
888
  if (trackInputEvents) {
882
889
  dep.on("input", handleChange);
890
+ this.boundEventListeners.push({
891
+ element: dep.element,
892
+ event: "input",
893
+ handler: handleChange
894
+ });
883
895
  }
884
896
  if (observeVisibility) {
885
897
  const observer = new MutationObserver(() => {
@@ -897,9 +909,14 @@ var DOMNodeReference = class _DOMNodeReference {
897
909
  });
898
910
  this.observers.push(observer);
899
911
  }
900
- if (trackRadioButtons && (dep.yesRadio || dep.noRadio)) {
912
+ if (trackRadioButtons && dep.yesRadio && dep.noRadio) {
901
913
  [dep.yesRadio, dep.noRadio].forEach((radio) => {
902
- radio?.on("change", handleChange);
914
+ radio.on("change", handleChange);
915
+ this.boundEventListeners.push({
916
+ element: radio.element,
917
+ event: "change",
918
+ handler: handleChange
919
+ });
903
920
  });
904
921
  }
905
922
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powerpagestoolkit",
3
- "version": "2.6.01",
3
+ "version": "2.6.03",
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",