powerpagestoolkit 1.3.4 → 1.3.5

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/bundle.js ADDED
@@ -0,0 +1,711 @@
1
+ // src/safeAjax.ts
2
+ function safeAjax(ajaxOptions) {
3
+ const deferredAjax = $.Deferred();
4
+ shell.getTokenDeferred().done(function(token) {
5
+ if (!ajaxOptions.headers) {
6
+ $.extend(ajaxOptions, {
7
+ headers: {
8
+ __RequestVerificationToken: token
9
+ }
10
+ });
11
+ } else {
12
+ ajaxOptions.headers["__RequestVerificationToken"] = token;
13
+ }
14
+ $.ajax(ajaxOptions).done(function(data, textStatus, jqXHR) {
15
+ validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve);
16
+ }).fail(deferredAjax.reject);
17
+ }).fail(function() {
18
+ deferredAjax.rejectWith(this, arguments);
19
+ });
20
+ return deferredAjax.promise();
21
+ }
22
+
23
+ // src/API.ts
24
+ var API = {
25
+ /**
26
+ *
27
+ * @param {Schema} schema an instance of a schema class, containing the desired information for the POST request
28
+ * @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
+ createRecord(schema) {
31
+ return new Promise((resolve, reject) => {
32
+ safeAjax({
33
+ type: "POST",
34
+ url: `/_api/${schema.logicalName()}`,
35
+ data: schema.value(),
36
+ contentType: "application/json",
37
+ success: function(response, status, xhr) {
38
+ resolve(xhr.getResponseHeader("entityid"));
39
+ },
40
+ error: (error) => {
41
+ reject(error);
42
+ }
43
+ });
44
+ });
45
+ },
46
+ /**
47
+ *
48
+ * @param {string} tableSetName The DataVerse SET name of the table being queried
49
+ * @param {string} recordID the GUID of the records to be retrieved
50
+ * @param {string} selectColumns *OPTIONAL* if desired, enter your own custom OData query for advanced GET results. Format = select=column1,column2,column3...
51
+ * @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
52
+ */
53
+ getRecord(tableSetName, recordID, selectColumns) {
54
+ return new Promise((resolve, reject) => {
55
+ const url = `/_api/${tableSetName}(${recordID})${selectColumns ? `?$${selectColumns}` : ""}`;
56
+ safeAjax({
57
+ type: "GET",
58
+ url,
59
+ success: resolve,
60
+ error: reject
61
+ });
62
+ });
63
+ },
64
+ /**
65
+ *
66
+ * @param {String} tableSetName The DataVerse SET name of the table being queried
67
+ * @param {String} queryParameters *OPTIONAL* the OData query parameters for refining search results: *format = $filter=filters&$select=columns*
68
+ * @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
69
+ */
70
+ getMultiple(tableSetName, queryParameters) {
71
+ return new Promise((resolve, reject) => {
72
+ const url = `/_api/${tableSetName}${queryParameters ? `?${queryParameters}` : ""}`;
73
+ safeAjax({
74
+ type: "GET",
75
+ url,
76
+ success: function(response) {
77
+ resolve(response.value);
78
+ },
79
+ error: reject
80
+ });
81
+ });
82
+ }
83
+ };
84
+ var API_default = API;
85
+
86
+ // src/waitFor.ts
87
+ function waitFor(target) {
88
+ return new Promise((resolve, reject) => {
89
+ const observer = new MutationObserver(() => {
90
+ const observedElement = document.querySelector(target);
91
+ if (observedElement) {
92
+ clearTimeout(timeout);
93
+ observer.disconnect();
94
+ resolve(observedElement);
95
+ }
96
+ });
97
+ const timeout = setTimeout(() => {
98
+ observer.disconnect();
99
+ reject(new Error(`Element not found: ${target} within 5 seconds`));
100
+ }, 5e3);
101
+ if (target instanceof HTMLElement) {
102
+ clearTimeout(timeout);
103
+ return resolve(target);
104
+ }
105
+ const element = document.querySelector(target);
106
+ if (element) {
107
+ clearTimeout(timeout);
108
+ return resolve(element);
109
+ }
110
+ observer.observe(document.body, {
111
+ subtree: true,
112
+ attributes: true,
113
+ childList: true
114
+ // Detects added/removed child elements
115
+ });
116
+ });
117
+ }
118
+
119
+ // src/createInfoElement.ts
120
+ function CreateInfoEl(titleString) {
121
+ const span = document.createElement("span");
122
+ span.classList.add("info-icon");
123
+ const icon = document.createElement("i");
124
+ icon.classList.add("fa", "fa-solid", "fa-info-circle");
125
+ icon.setAttribute("aria-label", "Info");
126
+ icon.style.cursor = "pointer";
127
+ const flyoutContent = document.createElement("div");
128
+ flyoutContent.innerHTML = titleString;
129
+ flyoutContent.classList.add("flyout-content");
130
+ span.appendChild(icon);
131
+ span.appendChild(flyoutContent);
132
+ const positionFlyout = () => {
133
+ flyoutContent.style.display = "block";
134
+ const flyoutRect = flyoutContent.getBoundingClientRect();
135
+ const viewportWidth = window.innerWidth;
136
+ if (flyoutRect.right > viewportWidth) {
137
+ const overflowAmount = flyoutRect.right - viewportWidth;
138
+ flyoutContent.style.left = `calc(50% - ${overflowAmount}px)`;
139
+ }
140
+ if (flyoutRect.left < 0) {
141
+ const overflowAmount = Math.abs(flyoutRect.left);
142
+ flyoutContent.style.left = `calc(50% + ${overflowAmount}px)`;
143
+ }
144
+ };
145
+ icon.addEventListener("mouseenter", positionFlyout);
146
+ icon.addEventListener("mouseleave", () => {
147
+ flyoutContent.style.display = "none";
148
+ });
149
+ icon.addEventListener("touchstart", (event) => {
150
+ event.preventDefault();
151
+ flyoutContent.style.display = flyoutContent.style.display === "block" ? "none" : "block";
152
+ if (flyoutContent.style.display === "block") {
153
+ positionFlyout();
154
+ }
155
+ });
156
+ document.body.addEventListener("click", (event) => {
157
+ if (!span.contains(event.target)) {
158
+ flyoutContent.style.display = "none";
159
+ }
160
+ });
161
+ flyoutContent.style.display = "none";
162
+ return span;
163
+ }
164
+
165
+ // src/errors.ts
166
+ var DOMNodeInitializationError = class extends Error {
167
+ constructor(instance, error) {
168
+ super(
169
+ `There was an error initializing a DOMNodeReference for target: ${instance.target}, :: ${error}`
170
+ );
171
+ this.name = "DOMNodeInitializationError";
172
+ }
173
+ };
174
+ var DOMNodeNotFoundError = class extends Error {
175
+ constructor(instance) {
176
+ super(`The targeted DOM element was not found: ${instance.target}`);
177
+ }
178
+ };
179
+ var ConditionalRenderingError = class extends Error {
180
+ constructor(instance, error) {
181
+ super(
182
+ `There was an error condiguring conditional rendering for target: ${instance.target} :: ${error}`
183
+ );
184
+ }
185
+ };
186
+
187
+ // src/DOMNodeReference.ts
188
+ var _init = Symbol("_init");
189
+ var DOMNodeReference = class {
190
+ // properties initialized in the constructor
191
+ target;
192
+ isLoaded;
193
+ defaultDisplay;
194
+ /**
195
+ * The value of the element that this node represents
196
+ * stays in syncs with the live DOM elements via event handler
197
+ * @type {any}
198
+ */
199
+ value;
200
+ /**
201
+ * Creates an instance of DOMNodeReference.
202
+ * @param {string} target - The CSS selector to find the desired DOM element.
203
+ */
204
+ /******/
205
+ /******/
206
+ constructor(target) {
207
+ this.target = target;
208
+ this.isLoaded = false;
209
+ this.defaultDisplay = "";
210
+ this.value = null;
211
+ }
212
+ async [_init]() {
213
+ try {
214
+ const element = await waitFor(this.target);
215
+ this.element = element;
216
+ if (!this.element) {
217
+ throw new DOMNodeNotFoundError(this);
218
+ }
219
+ if (this.element.classList.contains("boolean-radio")) {
220
+ await this._attachRadioButtons();
221
+ }
222
+ this._initValueSync();
223
+ this._attachVisibilityController();
224
+ this.defaultDisplay = this.visibilityController.style.display;
225
+ this.isLoaded = true;
226
+ } catch (e) {
227
+ throw new DOMNodeInitializationError(this, e);
228
+ }
229
+ }
230
+ // Function to update this.value based on element type
231
+ _initValueSync() {
232
+ this.updateValue();
233
+ const elementType = this.element.type;
234
+ if (elementType === "checkbox" || elementType === "radio") {
235
+ this.element.addEventListener("click", this.updateValue.bind(this));
236
+ } else if (elementType === "select-one" || elementType === "select-multiple") {
237
+ this.element.addEventListener("change", this.updateValue.bind(this));
238
+ } else {
239
+ this.element.addEventListener("input", this.updateValue.bind(this));
240
+ }
241
+ }
242
+ updateValue() {
243
+ switch (this.element.type) {
244
+ case "checkbox":
245
+ case "radio":
246
+ this.value = this.element.checked;
247
+ this.checked = this.element.checked;
248
+ break;
249
+ case "select-multiple":
250
+ this.value = Array.from(
251
+ this.element.selectedOptions
252
+ ).map((option) => option.value);
253
+ break;
254
+ case "number":
255
+ this.value = this.element.value !== "" ? Number(this.element.value) : null;
256
+ break;
257
+ default:
258
+ this.value = null;
259
+ break;
260
+ }
261
+ if (this.element.classList.contains("boolean-radio")) {
262
+ this.yesRadio.updateValue();
263
+ this.noRadio.updateValue();
264
+ }
265
+ }
266
+ _attachVisibilityController() {
267
+ this.visibilityController = this.element;
268
+ if (this.element.tagName === "TABLE") {
269
+ const fieldset = this.element.closest("fieldset");
270
+ if (fieldset) {
271
+ this.visibilityController = fieldset;
272
+ }
273
+ return;
274
+ }
275
+ const tagsRequiringTdParent = [
276
+ "SPAN",
277
+ "INPUT",
278
+ "TEXTAREA",
279
+ "SELECT",
280
+ "TABLE"
281
+ ];
282
+ if (tagsRequiringTdParent.includes(this.element.tagName)) {
283
+ const tdParent = this.element.closest("td");
284
+ if (tdParent) {
285
+ this.visibilityController = tdParent;
286
+ }
287
+ }
288
+ }
289
+ async _attachRadioButtons() {
290
+ this.yesRadio = await createDOMNodeReference(`#${this.element.id}_1`);
291
+ this.noRadio = await createDOMNodeReference(`#${this.element.id}_0`);
292
+ }
293
+ /**
294
+ * Sets up an event listener based on the specified event type, executing the specified
295
+ * event handler
296
+ * @param {string} eventType - The DOM event to watch for
297
+ * @param {(this: DOMNodeReference, e: Event) => void} eventHandler - The callback function that runs when the
298
+ * specified event occurs
299
+ * @returns - Instance of this
300
+ */
301
+ on(eventType, eventHandler) {
302
+ this.element.addEventListener(eventType, eventHandler.bind(this));
303
+ return this;
304
+ }
305
+ /**
306
+ * Hides the element by setting its display style to "none".
307
+ * @returns - Instance of this
308
+ */
309
+ hide() {
310
+ this.visibilityController.style.display = "none";
311
+ return this;
312
+ }
313
+ /**
314
+ * Shows the element by restoring its default display style.
315
+ * @returns - Instance of this
316
+ */
317
+ show() {
318
+ this.visibilityController.style.display = this.defaultDisplay;
319
+ return this;
320
+ }
321
+ /**
322
+ *
323
+ * @param {function(this: DOMNodeReference): boolean | boolean} shouldShow - Either a function that returns true or false,
324
+ * or a natural boolean to determine the visibility of this
325
+ * @returns - Instance of this
326
+ */
327
+ toggleVisibility(shouldShow) {
328
+ if (shouldShow instanceof Function) {
329
+ shouldShow(this) ? this.show() : this.hide();
330
+ } else {
331
+ shouldShow ? this.show() : this.hide();
332
+ }
333
+ return this;
334
+ }
335
+ /**
336
+ * Sets the value of the HTML element.
337
+ * @param {() => any} value - The value to set for the HTML element.
338
+ * for parents of boolean radios, pass true or false as value, or
339
+ * an expression returning a boolean
340
+ * @returns - Instance of this
341
+ */
342
+ setValue(value) {
343
+ if (this.element.classList.contains("boolean-radio")) {
344
+ this.yesRadio.element.checked = value;
345
+ this.noRadio.element.checked = !value;
346
+ } else {
347
+ this.element.value = value;
348
+ }
349
+ return this;
350
+ }
351
+ /**
352
+ * Disables the element so that users cannot input any data
353
+ * @returns - Instance of this
354
+ */
355
+ disable() {
356
+ try {
357
+ this.element.disabled = true;
358
+ } catch (e) {
359
+ throw new Error(
360
+ `There was an error trying to disable the target: ${this.target}`
361
+ );
362
+ }
363
+ return this;
364
+ }
365
+ /**
366
+ * Enables the element so that users can input data
367
+ * @returns - Instance of this
368
+ */
369
+ enable() {
370
+ try {
371
+ this.element.disabled = false;
372
+ } catch (e) {
373
+ throw new Error(
374
+ `There was an error trying to disable the target: ${this.target}`
375
+ );
376
+ }
377
+ return this;
378
+ }
379
+ /**
380
+ *
381
+ * @param {...HTMLElement} elements - The elements to prepend to the element targeted by this.
382
+ * @returns - Instance of this
383
+ */
384
+ prepend(...elements) {
385
+ this.element.prepend(...elements);
386
+ return this;
387
+ }
388
+ /**
389
+ * Appends child elements to the HTML element.
390
+ * @param {...HTMLElement} elements - The elements to append to the element targeted by this.
391
+ * @returns - Instance of this
392
+ */
393
+ append(...elements) {
394
+ this.element.append(...elements);
395
+ return this;
396
+ }
397
+ /**
398
+ * Inserts elements before the HTML element.
399
+ * @param {...HTMLElement} elements - The elements to insert before the HTML element.
400
+ * @returns - Instance of this
401
+ */
402
+ before(...elements) {
403
+ this.element.before(...elements);
404
+ return this;
405
+ }
406
+ /**
407
+ * Inserts elements after the HTML element.
408
+ * @param {...HTMLElement} elements - The elements to insert after the HTML element.
409
+ * @returns - Instance of this
410
+ */
411
+ after(...elements) {
412
+ this.element.after(...elements);
413
+ return this;
414
+ }
415
+ /**
416
+ * Retrieves the label associated with the HTML element.
417
+ * @returns {HTMLElement} The label element associated with this element.
418
+ */
419
+ getLabel() {
420
+ return document.querySelector(`#${this.element.id}_label`) || null;
421
+ }
422
+ /**
423
+ * Appends child elements to the label associated with the HTML element.
424
+ * @param {...HTMLElement} elements - The elements to append to the label.
425
+ * @returns - Instance of this
426
+ */
427
+ appendToLabel(...elements) {
428
+ const label = this.getLabel();
429
+ if (label) {
430
+ label.append(" ", ...elements);
431
+ }
432
+ return this;
433
+ }
434
+ /**
435
+ * Adds a tooltip with specified text to the label associated with the HTML element.
436
+ * @param {string} text - The text to display in the tooltip.
437
+ * @returns - Instance of this
438
+ */
439
+ addLabelTooltip(text) {
440
+ this.appendToLabel(CreateInfoEl(text));
441
+ return this;
442
+ }
443
+ /**
444
+ * Adds a tooltip with the specified text to the element
445
+ * @param {string} text - The text to display in the tooltip
446
+ * @returns - Instance of this
447
+ */
448
+ addTooltip(text) {
449
+ this.append(CreateInfoEl(text));
450
+ return this;
451
+ }
452
+ /**
453
+ * Sets the inner HTML content of the HTML element.
454
+ * @param {string} string - The text to set as the inner HTML of the element.
455
+ * @returns - Instance of this
456
+ */
457
+ setInnerHTML(string) {
458
+ this.element.innerHTML = string;
459
+ return this;
460
+ }
461
+ /**
462
+ * Removes this element from the DOM
463
+ * @returns - Instance of this
464
+ */
465
+ remove() {
466
+ this.element.remove();
467
+ return this;
468
+ }
469
+ /**
470
+ *
471
+ * @param {Partial<CSSStyleDeclaration} options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}
472
+ * @returns - Instance of this
473
+ */
474
+ setStyle(options) {
475
+ if (Object.prototype.toString.call(options) !== "[object Object]") {
476
+ throw new Error(
477
+ `powerpagestoolkit: 'DOMNodeReference.setStyle' required options to be in the form of an object. Argument passed was of type: ${typeof options}`
478
+ );
479
+ }
480
+ for (const key in options) {
481
+ this.element.style[key] = options[key];
482
+ }
483
+ return this;
484
+ }
485
+ /**
486
+ * Unchecks both the yes and no radio buttons if they exist.
487
+ * @returns - Instance of this
488
+ */
489
+ uncheckRadios() {
490
+ if (this.yesRadio && this.noRadio) {
491
+ this.yesRadio.element.checked = false;
492
+ this.noRadio.element.checked = false;
493
+ } else {
494
+ console.error(
495
+ "[SYNACT] Attempted to uncheck radios for an element that has no radios"
496
+ );
497
+ }
498
+ return this;
499
+ }
500
+ /**
501
+ * Configures conditional rendering for the target element based on a condition
502
+ * and the visibility of one or more trigger elements.
503
+ *
504
+ * @param {(this: DOMNodeReference) => boolean} condition - A function that returns a boolean to determine
505
+ * the visibility of the target element. If `condition()` returns true, the element is shown;
506
+ * otherwise, it is hidden.
507
+ * @param {Array<DOMNodeReference>} [dependencies] - An array of `DOMNodeReference` instances. Event listeners are
508
+ * registered on each to toggle the visibility of the target element based on the `condition` and the visibility of
509
+ * the target node.
510
+ * @returns - Instance of this
511
+ */
512
+ configureConditionalRendering(condition, dependencies) {
513
+ try {
514
+ this.toggleVisibility(condition());
515
+ if (!dependencies) {
516
+ console.warn(
517
+ `powerpagestoolkit: No dependencies were found when configuring conditional rendering for ${this}. Be sure that if you are referencing other nodes in your rendering logic, that you include those nodes in the dependency array`
518
+ );
519
+ return this;
520
+ }
521
+ dependencies.forEach((node) => {
522
+ node.on("change", () => this.toggleVisibility(condition()));
523
+ const observer = new MutationObserver(() => {
524
+ const display = window.getComputedStyle(
525
+ node.visibilityController
526
+ ).display;
527
+ this.toggleVisibility(display !== "none" && condition());
528
+ });
529
+ observer.observe(node.visibilityController, {
530
+ attributes: true,
531
+ attributeFilter: ["style"]
532
+ });
533
+ });
534
+ return this;
535
+ } catch (e) {
536
+ throw new ConditionalRenderingError(this, e);
537
+ }
538
+ }
539
+ /**
540
+ * Sets up validation and requirement rules for the field. This function dynamically updates the field's required status and validates its input based on the specified conditions.
541
+ *
542
+ * @param {function(this: DOMNodeReference): boolean} isRequired - A function that determines whether the field should be required. Returns `true` if required, `false` otherwise.
543
+ * @param {function(this: DOMNodeReference): boolean} isValid - A function that checks if the field's input is valid. Returns `true` if valid, `false` otherwise.
544
+ * @param {string} fieldDisplayName - The name of the field, used in error messages if validation fails.
545
+ * @param {Array<DOMNodeReference>} [dependencies] Other fields that this field’s requirement depends on. When these fields change, the required status of this field is re-evaluated. Make sure any DOMNodeReference used in `isRequired` or `isValid` is included in this array.
546
+ * @returns - Instance of this
547
+ */
548
+ configureValidationAndRequirements(isRequired, isValid, fieldDisplayName, dependencies) {
549
+ if (typeof Page_Validators !== "undefined") {
550
+ const newValidator = document.createElement("span");
551
+ newValidator.style.display = "none";
552
+ newValidator.id = `${this.element.id}Validator`;
553
+ newValidator.controltovalidate = this.element.id;
554
+ newValidator.errormessage = `<a href='#${this.element.id}_label'>${fieldDisplayName} is a required field</a>`;
555
+ newValidator.evaluationfunction = isValid.bind(this);
556
+ Page_Validators.push(newValidator);
557
+ } else {
558
+ throw new Error(
559
+ "Attempted to add to Validator where Page_Validators do not exist"
560
+ );
561
+ }
562
+ this.setRequiredLevel(isRequired(this));
563
+ if (!dependencies) {
564
+ console.warn(
565
+ `powerpagestoolkit: No dependencies were found when configuring requirement and validation for ${this}. Be sure that if you are referencing other nodes in your requirement or validation logic, that you include those nodes in the dependency array`
566
+ );
567
+ return this;
568
+ }
569
+ dependencies.forEach((dep) => {
570
+ dep.element.addEventListener(
571
+ "change",
572
+ () => this.setRequiredLevel(isRequired(this))
573
+ );
574
+ });
575
+ return this;
576
+ }
577
+ /**
578
+ * Sets the required level for the field by adding or removing the "required-field" class on the label.
579
+ *
580
+ * @param {boolean} isRequired - Determines whether the field should be marked as required.
581
+ * If true, the "required-field" class is added to the label; if false, it is removed.
582
+ * @returns - Instance of this
583
+ */
584
+ setRequiredLevel(isRequired) {
585
+ if (isRequired instanceof Function) {
586
+ isRequired() ? this.getLabel()?.classList.add("required-field") : this.getLabel()?.classList.remove("required-field");
587
+ return this;
588
+ } else {
589
+ isRequired ? this.getLabel()?.classList.add("required-field") : this.getLabel()?.classList.remove("required-field");
590
+ return this;
591
+ }
592
+ }
593
+ /**
594
+ * Executes a callback function once the element is fully loaded.
595
+ * If the element is already loaded, the callback is called immediately.
596
+ * Otherwise, a MutationObserver is used to detect when the element is added to the DOM.
597
+ * @param {Function} callback - A callback function to execute once the element is loaded.
598
+ */
599
+ onceLoaded(callback) {
600
+ if (this.isLoaded) {
601
+ callback(this);
602
+ return;
603
+ }
604
+ if (this.target instanceof HTMLElement) {
605
+ callback(this);
606
+ return;
607
+ }
608
+ const observer = new MutationObserver(() => {
609
+ if (document.querySelector(this.target)) {
610
+ observer.disconnect();
611
+ this.isLoaded = true;
612
+ callback(this);
613
+ }
614
+ });
615
+ observer.observe(document.body, {
616
+ subtree: true,
617
+ childList: true
618
+ });
619
+ }
620
+ };
621
+
622
+ // src/createDOMNodeReferences.ts
623
+ async function createDOMNodeReference(target) {
624
+ try {
625
+ const instance = new DOMNodeReference(target);
626
+ await instance[_init]();
627
+ return new Proxy(instance, {
628
+ get: (target2, prop) => {
629
+ if (prop.toString().startsWith("_")) return void 0;
630
+ const value = target2[prop];
631
+ if (typeof value === "function" && prop !== "onceLoaded") {
632
+ return (...args) => {
633
+ target2.onceLoaded(() => value.apply(target2, args));
634
+ return target2;
635
+ };
636
+ }
637
+ return value;
638
+ }
639
+ });
640
+ } catch (e) {
641
+ throw new Error(e);
642
+ }
643
+ }
644
+ async function createMultipleDOMNodeReferences(querySelector) {
645
+ try {
646
+ const elements = Array.from(
647
+ document.querySelectorAll(querySelector)
648
+ );
649
+ const initializedElements = await Promise.all(
650
+ elements.map((element) => createDOMNodeReference(element))
651
+ );
652
+ const domNodeArray = initializedElements;
653
+ domNodeArray.hideAll = () => domNodeArray.forEach((instance) => instance.hide());
654
+ domNodeArray.showAll = () => domNodeArray.forEach((instance) => instance.show());
655
+ return domNodeArray;
656
+ } catch (e) {
657
+ console.error(
658
+ `There was an error creating multiple DOMNodeReferences: ${e}`
659
+ );
660
+ throw new Error(e);
661
+ }
662
+ }
663
+
664
+ // src/List.ts
665
+ var _listInit = Symbol("_listInit");
666
+ var List = class extends DOMNodeReference {
667
+ constructor(target) {
668
+ super(target);
669
+ this.listItems = [];
670
+ }
671
+ async [_listInit]() {
672
+ await super[_init]();
673
+ const li = await createMultipleDOMNodeReferences(
674
+ "div.ms-DetailsRow-fields"
675
+ );
676
+ console.log(li);
677
+ setTimeout(() => {
678
+ console.log(li);
679
+ }, 1e3);
680
+ }
681
+ };
682
+
683
+ // src/getList.ts
684
+ async function getList_default() {
685
+ try {
686
+ const instance = new List("div.ms-DetailsList");
687
+ await instance[_listInit]();
688
+ return new Proxy(instance, {
689
+ get: (target, prop) => {
690
+ if (prop.toString().startsWith("_")) return void 0;
691
+ const value = target[prop];
692
+ if (typeof value === "function" && prop !== "onceLoaded") {
693
+ return (...args) => {
694
+ target.onceLoaded(() => value.apply(target, args));
695
+ return target;
696
+ };
697
+ }
698
+ return value;
699
+ }
700
+ });
701
+ } catch (e) {
702
+ throw new Error(e);
703
+ }
704
+ }
705
+ export {
706
+ API_default as API,
707
+ createDOMNodeReference,
708
+ createMultipleDOMNodeReferences,
709
+ getList_default as getList
710
+ };
711
+ //# sourceMappingURL=bundle.js.map