powerpagestoolkit 1.3.2 → 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/README.md +66 -24
- package/dist/@types/API.d.ts +24 -0
- package/dist/@types/DOMNodeReference.d.ts +196 -0
- package/dist/@types/List.d.ts +11 -0
- package/dist/@types/ListItem.d.ts +10 -0
- package/dist/@types/createDOMNodeReferences.d.ts +15 -0
- package/dist/@types/createInfoElement.d.ts +1 -0
- package/dist/@types/errors.d.ts +10 -0
- package/dist/@types/getList.d.ts +2 -0
- package/dist/@types/index.d.ts +5 -0
- package/dist/@types/safeAjax.d.ts +1 -0
- package/dist/@types/waitFor.d.ts +1 -0
- package/dist/API.js +65 -0
- package/dist/API.js.map +1 -0
- package/dist/DOMNodeReference.js +447 -0
- package/dist/DOMNodeReference.js.map +1 -0
- package/dist/List.js +18 -0
- package/dist/List.js.map +1 -0
- package/dist/ListItem.js +28 -0
- package/dist/ListItem.js.map +1 -0
- package/dist/bundle.css +36 -0
- package/dist/bundle.css.map +7 -0
- package/dist/bundle.js +711 -0
- package/dist/bundle.js.map +7 -0
- package/dist/createDOMNodeReferences.js +55 -0
- package/dist/createDOMNodeReferences.js.map +1 -0
- package/dist/createInfoElement.js +51 -0
- package/dist/createInfoElement.js.map +1 -0
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -0
- package/dist/getList.js +29 -0
- package/dist/getList.js.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/safeAjax.js +31 -0
- package/dist/safeAjax.js.map +1 -0
- package/dist/waitFor.js +33 -0
- package/dist/waitFor.js.map +1 -0
- package/index.d.ts +59 -28
- package/package.json +1 -1
- package/dist/index.bundle.js +0 -1234
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/safeAjax.ts", "../src/API.ts", "../src/waitFor.ts", "../src/createInfoElement.ts", "../src/errors.ts", "../src/DOMNodeReference.ts", "../src/createDOMNodeReferences.ts", "../src/List.ts", "../src/getList.ts"],
|
|
4
|
+
"sourcesContent": ["// @ts-nocheck\r\nexport default function safeAjax(ajaxOptions) {\r\n const deferredAjax = $.Deferred();\r\n\r\n // shell is only available via runtime in a PowerPages portal\r\n\r\n shell\r\n .getTokenDeferred()\r\n .done(function (token) {\r\n // add headers for AJAX\r\n if (!ajaxOptions.headers) {\r\n $.extend(ajaxOptions, {\r\n headers: {\r\n __RequestVerificationToken: token,\r\n },\r\n });\r\n } else {\r\n ajaxOptions.headers[\"__RequestVerificationToken\"] = token;\r\n }\r\n $.ajax(ajaxOptions)\r\n .done(function (data, textStatus, jqXHR) {\r\n //eslint-disable-next-line\r\n validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve);\r\n })\r\n .fail(deferredAjax.reject); //AJAX\r\n })\r\n .fail(function () {\r\n deferredAjax.rejectWith(this, arguments); // on token failure pass the token AJAX and args\r\n });\r\n\r\n return deferredAjax.promise();\r\n}\r\n", "//@ts-nocheck\r\nimport safeAjax from \"./safeAjax.js\";\r\nconst API = {\r\n /**\r\n *\r\n * @param {Schema} schema an instance of a schema class, containing the desired information for the POST request\r\n * @returns a Promise resolving the successful results *[record id]* of the POST request, or rejecting the failed results *[error]* of the POST request.\r\n */\r\n createRecord(schema: Schema): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n safeAjax({\r\n type: \"POST\",\r\n url: `/_api/${schema.logicalName()}`,\r\n data: schema.value(),\r\n contentType: \"application/json\",\r\n success: function (response, status, xhr) {\r\n resolve(xhr.getResponseHeader(\"entityid\"));\r\n },\r\n error: (error) => {\r\n reject(error);\r\n },\r\n });\r\n });\r\n },\r\n /**\r\n *\r\n * @param {string} tableSetName The DataVerse SET name of the table being queried\r\n * @param {string} recordID the GUID of the records to be retrieved\r\n * @param {string} selectColumns *OPTIONAL* if desired, enter your own custom OData query for advanced GET results. Format = select=column1,column2,column3...\r\n * @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request\r\n */\r\n getRecord(\r\n tableSetName: string,\r\n recordID: string,\r\n selectColumns: string\r\n ): Promise<object> {\r\n return new Promise((resolve, reject) => {\r\n const url = `/_api/${tableSetName}(${recordID})${\r\n selectColumns ? `?$${selectColumns}` : \"\"\r\n }`;\r\n\r\n safeAjax({\r\n type: \"GET\",\r\n url: url,\r\n success: resolve,\r\n error: reject,\r\n });\r\n });\r\n },\r\n /**\r\n *\r\n * @param {String} tableSetName The DataVerse SET name of the table being queried\r\n * @param {String} queryParameters *OPTIONAL* the OData query parameters for refining search results: *format = $filter=filters&$select=columns*\r\n * @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request\r\n */\r\n getMultiple(\r\n tableSetName: string,\r\n queryParameters: string\r\n ): Promise<Array<object>> {\r\n return new Promise((resolve, reject) => {\r\n // Construct the URL based on the presence of query parameters\r\n const url = `/_api/${tableSetName}${\r\n queryParameters ? `?${queryParameters}` : \"\"\r\n }`;\r\n\r\n safeAjax({\r\n type: \"GET\",\r\n url: url,\r\n success: function (response) {\r\n resolve(response.value);\r\n },\r\n error: reject,\r\n });\r\n });\r\n },\r\n};\r\n\r\nexport default API;\r\n", "export default function waitFor(\r\n target: HTMLElement | string\r\n): Promise<HTMLElement> {\r\n return new Promise((resolve, reject) => {\r\n // Create observer to watch for target in DOM\r\n const observer = new MutationObserver(() => {\r\n const observedElement = <HTMLElement>(\r\n document.querySelector(<string>target)\r\n );\r\n if (observedElement) {\r\n clearTimeout(timeout);\r\n observer.disconnect();\r\n resolve(observedElement);\r\n }\r\n });\r\n const timeout = setTimeout(() => {\r\n observer.disconnect();\r\n reject(new Error(`Element not found: ${target} within 5 seconds`));\r\n }, 5000);\r\n\r\n // Check if target is already in DOM\r\n if (target instanceof HTMLElement) {\r\n clearTimeout(timeout);\r\n return resolve(target);\r\n }\r\n const element = <HTMLElement>document.querySelector(target);\r\n if (element) {\r\n clearTimeout(timeout);\r\n return resolve(element);\r\n }\r\n\r\n observer.observe(document.body, {\r\n subtree: true,\r\n attributes: true,\r\n childList: true, // Detects added/removed child elements\r\n });\r\n });\r\n}\r\n", "export default function CreateInfoEl(titleString: string) {\r\n const span = document.createElement(\"span\");\r\n span.classList.add(\"info-icon\");\r\n\r\n const icon = document.createElement(\"i\");\r\n icon.classList.add(\"fa\", \"fa-solid\", \"fa-info-circle\");\r\n icon.setAttribute(\"aria-label\", \"Info\");\r\n icon.style.cursor = \"pointer\";\r\n\r\n const flyoutContent = document.createElement(\"div\");\r\n flyoutContent.innerHTML = titleString;\r\n flyoutContent.classList.add(\"flyout-content\");\r\n\r\n span.appendChild(icon);\r\n span.appendChild(flyoutContent);\r\n\r\n // Function to position flyout content\r\n const positionFlyout = () => {\r\n flyoutContent.style.display = \"block\"; // Show the flyout to calculate dimensions\r\n\r\n const flyoutRect = flyoutContent.getBoundingClientRect();\r\n const viewportWidth = window.innerWidth;\r\n\r\n // Position the flyout\r\n\r\n // Adjust if flyout is too far to the right\r\n if (flyoutRect.right > viewportWidth) {\r\n const overflowAmount = flyoutRect.right - viewportWidth;\r\n flyoutContent.style.left = `calc(50% - ${overflowAmount}px)`; // Shift left\r\n }\r\n\r\n // Adjust if flyout is too far to the left\r\n if (flyoutRect.left < 0) {\r\n const overflowAmount = Math.abs(flyoutRect.left);\r\n flyoutContent.style.left = `calc(50% + ${overflowAmount}px)`; // Shift right\r\n }\r\n };\r\n\r\n icon.addEventListener(\"mouseenter\", positionFlyout);\r\n\r\n icon.addEventListener(\"mouseleave\", () => {\r\n flyoutContent.style.display = \"none\"; // Hide on mouse leave\r\n });\r\n\r\n icon.addEventListener(\"touchstart\", (event) => {\r\n event.preventDefault();\r\n // Toggle flyout visibility on touch\r\n flyoutContent.style.display =\r\n flyoutContent.style.display === \"block\" ? \"none\" : \"block\";\r\n if (flyoutContent.style.display === \"block\") {\r\n positionFlyout(); // Position the flyout when displayed\r\n }\r\n });\r\n\r\n document.body.addEventListener(\"click\", (event: Event) => {\r\n if (!span.contains(<Node>event.target)) {\r\n flyoutContent.style.display = \"none\"; // Hide on body click\r\n }\r\n });\r\n\r\n flyoutContent.style.display = \"none\";\r\n return span;\r\n}\r\n", "import DOMNodeReference from \"./DOMNodeReference.js\";\r\n\r\nexport class DOMNodeInitializationError extends Error {\r\n constructor(instance: DOMNodeReference, error: string) {\r\n super(\r\n `There was an error initializing a DOMNodeReference for target: ${instance.target}, :: ${error}`\r\n );\r\n this.name = \"DOMNodeInitializationError\";\r\n }\r\n}\r\n\r\nexport class DOMNodeNotFoundError extends Error {\r\n constructor(instance: DOMNodeReference) {\r\n super(`The targeted DOM element was not found: ${instance.target}`);\r\n }\r\n}\r\n\r\nexport class ConditionalRenderingError extends Error {\r\n constructor(instance: DOMNodeReference, error: string) {\r\n super(\r\n `There was an error condiguring conditional rendering for target: ${instance.target} :: ${error}`\r\n );\r\n }\r\n}\r\n", "import waitFor from \"@/waitFor.js\";\r\nimport createInfoEl from \"@/createInfoElement.js\";\r\nimport {\r\n DOMNodeInitializationError,\r\n DOMNodeNotFoundError,\r\n ConditionalRenderingError,\r\n} from \"@/errors.js\";\r\nimport { createDOMNodeReference } from \"@/createDOMNodeReferences.js\";\r\n\r\nexport const _init = Symbol(\"_init\");\r\n\r\n/******/ /******/ /******/ export default class DOMNodeReference {\r\n // properties initialized in the constructor\r\n public target: HTMLElement | string;\r\n private isLoaded: boolean;\r\n private defaultDisplay: string;\r\n /**\r\n * The value of the element that this node represents\r\n * stays in syncs with the live DOM elements via event handler\r\n * @type {any}\r\n */\r\n public value: any;\r\n\r\n // other properties made available after async _init\r\n /**\r\n * The element targeted when instantiating DOMNodeReference.\r\n * Made available in order to perform normal DOM traversal,\r\n * or access properties not available through this class.\r\n * @property {HTMLElement | null}\r\n */\r\n public declare element: HTMLElement;\r\n private declare visibilityController: HTMLElement;\r\n public declare checked: boolean;\r\n /**\r\n * Represents the 'yes' option of a boolean radio field.\r\n * This property is only available when the parent node\r\n * is a main field for a boolean radio input.\r\n * @property {DOMNodeReferenceProxy | null}\r\n */\r\n public declare yesRadio?: DOMNodeReference | null;\r\n /**\r\n * Represents the 'no' option of a boolean radio field.\r\n * This property is only available when the parent node\r\n * is a main field for a boolean radio input.\r\n * @property {DOMNodeReferenceProxy | null}\r\n */\r\n public declare noRadio?: DOMNodeReference | null;\r\n\r\n /**\r\n * Creates an instance of DOMNodeReference.\r\n * @param {string} target - The CSS selector to find the desired DOM element.\r\n */\r\n /******/ /******/ constructor(target: HTMLElement | string) {\r\n this.target = target;\r\n this.isLoaded = false;\r\n this.defaultDisplay = \"\";\r\n this.value = null;\r\n\r\n // we defer the rest of initialization\r\n }\r\n\r\n public async [_init](): Promise<void> {\r\n /**\r\n * dynamically define the _init method using our custom symbol\r\n * this makes it so that the _init method cannot be accessed outside\r\n * of this package: i.e. by any consumers of the package\r\n */\r\n try {\r\n const element = await waitFor(this.target);\r\n this.element = element;\r\n\r\n if (!this.element) {\r\n throw new DOMNodeNotFoundError(this);\r\n }\r\n if (this.element.classList.contains(\"boolean-radio\")) {\r\n await this._attachRadioButtons();\r\n }\r\n\r\n this._initValueSync();\r\n this._attachVisibilityController();\r\n this.defaultDisplay = this.visibilityController.style.display;\r\n\r\n this.isLoaded = true;\r\n } catch (e) {\r\n throw new DOMNodeInitializationError(this, e as string);\r\n }\r\n }\r\n\r\n // Function to update this.value based on element type\r\n private _initValueSync() {\r\n // Initial sync\r\n this.updateValue();\r\n\r\n // Event listeners for real-time changes based on element type\r\n const elementType = (this.element as HTMLInputElement).type;\r\n if (elementType === \"checkbox\" || elementType === \"radio\") {\r\n this.element.addEventListener(\"click\", this.updateValue.bind(this));\r\n } else if (\r\n elementType === \"select-one\" ||\r\n elementType === \"select-multiple\"\r\n ) {\r\n this.element.addEventListener(\"change\", this.updateValue.bind(this));\r\n } else {\r\n this.element.addEventListener(\"input\", this.updateValue.bind(this));\r\n }\r\n }\r\n\r\n public updateValue(): void {\r\n switch ((this.element as HTMLInputElement).type) {\r\n case \"checkbox\":\r\n case \"radio\":\r\n this.value = (this.element as HTMLInputElement).checked;\r\n this.checked = (this.element as HTMLInputElement).checked;\r\n break;\r\n case \"select-multiple\":\r\n this.value = Array.from(\r\n (this.element as HTMLSelectElement).selectedOptions\r\n ).map((option) => option.value);\r\n break;\r\n case \"number\":\r\n this.value =\r\n (this.element as HTMLInputElement).value !== \"\"\r\n ? Number((this.element as HTMLInputElement).value)\r\n : null;\r\n break;\r\n default:\r\n this.value = null;\r\n break;\r\n }\r\n\r\n if (this.element.classList.contains(\"boolean-radio\")) {\r\n (this.yesRadio as DOMNodeReference).updateValue();\r\n (this.noRadio as DOMNodeReference).updateValue();\r\n }\r\n }\r\n\r\n private _attachVisibilityController(): void {\r\n // Set the default visibility controller to the element itself\r\n this.visibilityController = this.element;\r\n\r\n // If the element is a table, use its closest fieldset as the controller\r\n if (this.element.tagName === \"TABLE\") {\r\n const fieldset = this.element.closest(\"fieldset\");\r\n if (fieldset) {\r\n this.visibilityController = fieldset;\r\n }\r\n return;\r\n }\r\n\r\n // For specific tag types, use the closest 'td' if available as the controller\r\n const tagsRequiringTdParent = [\r\n \"SPAN\",\r\n \"INPUT\",\r\n \"TEXTAREA\",\r\n \"SELECT\",\r\n \"TABLE\",\r\n ];\r\n if (tagsRequiringTdParent.includes(this.element.tagName)) {\r\n const tdParent = this.element.closest(\"td\");\r\n if (tdParent) {\r\n this.visibilityController = tdParent;\r\n }\r\n }\r\n }\r\n\r\n private async _attachRadioButtons(): Promise<void> {\r\n this.yesRadio = await createDOMNodeReference(`#${this.element.id}_1`);\r\n this.noRadio = await createDOMNodeReference(`#${this.element.id}_0`);\r\n }\r\n\r\n /**\r\n * Sets up an event listener based on the specified event type, executing the specified\r\n * event handler\r\n * @param {string} eventType - The DOM event to watch for\r\n * @param {(this: DOMNodeReference, e: Event) => void} eventHandler - The callback function that runs when the\r\n * specified event occurs\r\n * @returns - Instance of this\r\n */\r\n public on(\r\n eventType: string,\r\n eventHandler: (e: Event) => void\r\n ): DOMNodeReference {\r\n this.element.addEventListener(eventType, eventHandler.bind(this));\r\n return this;\r\n }\r\n\r\n /**\r\n * Hides the element by setting its display style to \"none\".\r\n * @returns - Instance of this\r\n */\r\n public hide(): DOMNodeReference {\r\n this.visibilityController.style.display = \"none\";\r\n return this;\r\n }\r\n\r\n /**\r\n * Shows the element by restoring its default display style.\r\n * @returns - Instance of this\r\n */\r\n public show(): DOMNodeReference {\r\n this.visibilityController.style.display = this.defaultDisplay;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param {function(this: DOMNodeReference): boolean | boolean} shouldShow - Either a function that returns true or false,\r\n * or a natural boolean to determine the visibility of this\r\n * @returns - Instance of this\r\n */\r\n public toggleVisibility(shouldShow: Function | boolean): DOMNodeReference {\r\n if (shouldShow instanceof Function) {\r\n shouldShow(this) ? this.show() : this.hide();\r\n } else {\r\n shouldShow ? this.show() : this.hide();\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the value of the HTML element.\r\n * @param {() => any} value - The value to set for the HTML element.\r\n * for parents of boolean radios, pass true or false as value, or\r\n * an expression returning a boolean\r\n * @returns - Instance of this\r\n */\r\n public setValue(value: any): DOMNodeReference {\r\n if (this.element.classList.contains(\"boolean-radio\")) {\r\n (\r\n (this.yesRadio as DOMNodeReference).element as HTMLInputElement\r\n ).checked = value;\r\n ((this.noRadio as DOMNodeReference).element as HTMLInputElement).checked =\r\n !value;\r\n } else {\r\n (this.element as HTMLInputElement).value = value;\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Disables the element so that users cannot input any data\r\n * @returns - Instance of this\r\n */\r\n public disable(): DOMNodeReference {\r\n try {\r\n (this.element as HTMLInputElement).disabled = true;\r\n } catch (e) {\r\n throw new Error(\r\n `There was an error trying to disable the target: ${this.target}`\r\n );\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Enables the element so that users can input data\r\n * @returns - Instance of this\r\n */\r\n public enable(): DOMNodeReference {\r\n try {\r\n (this.element as HTMLInputElement).disabled = false;\r\n } catch (e) {\r\n throw new Error(\r\n `There was an error trying to disable the target: ${this.target}`\r\n );\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param {...HTMLElement} elements - The elements to prepend to the element targeted by this.\r\n * @returns - Instance of this\r\n */\r\n public prepend(...elements: HTMLElement[]): DOMNodeReference {\r\n this.element.prepend(...elements);\r\n return this;\r\n }\r\n\r\n /**\r\n * Appends child elements to the HTML element.\r\n * @param {...HTMLElement} elements - The elements to append to the element targeted by this.\r\n * @returns - Instance of this\r\n */\r\n public append(...elements: HTMLElement[]): DOMNodeReference {\r\n this.element.append(...elements);\r\n return this;\r\n }\r\n\r\n /**\r\n * Inserts elements before the HTML element.\r\n * @param {...HTMLElement} elements - The elements to insert before the HTML element.\r\n * @returns - Instance of this\r\n */\r\n public before(...elements: HTMLElement[]): DOMNodeReference {\r\n this.element.before(...elements);\r\n return this;\r\n }\r\n\r\n /**\r\n * Inserts elements after the HTML element.\r\n * @param {...HTMLElement} elements - The elements to insert after the HTML element.\r\n * @returns - Instance of this\r\n */\r\n public after(...elements: HTMLElement[]): DOMNodeReference {\r\n this.element.after(...elements);\r\n return this;\r\n }\r\n\r\n /**\r\n * Retrieves the label associated with the HTML element.\r\n * @returns {HTMLElement} The label element associated with this element.\r\n */\r\n public getLabel(): HTMLElement | null {\r\n return document.querySelector(`#${this.element.id}_label`) || null;\r\n }\r\n\r\n /**\r\n * Appends child elements to the label associated with the HTML element.\r\n * @param {...HTMLElement} elements - The elements to append to the label.\r\n * @returns - Instance of this\r\n */\r\n public appendToLabel(...elements: HTMLElement[]): DOMNodeReference {\r\n const label = this.getLabel();\r\n if (label) {\r\n label.append(\" \", ...elements);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a tooltip with specified text to the label associated with the HTML element.\r\n * @param {string} text - The text to display in the tooltip.\r\n * @returns - Instance of this\r\n */\r\n public addLabelTooltip(text: string): DOMNodeReference {\r\n this.appendToLabel(createInfoEl(text));\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a tooltip with the specified text to the element\r\n * @param {string} text - The text to display in the tooltip\r\n * @returns - Instance of this\r\n */\r\n public addTooltip(text: string): DOMNodeReference {\r\n this.append(createInfoEl(text));\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the inner HTML content of the HTML element.\r\n * @param {string} string - The text to set as the inner HTML of the element.\r\n * @returns - Instance of this\r\n */\r\n setInnerHTML(string: string) {\r\n this.element.innerHTML = string;\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes this element from the DOM\r\n * @returns - Instance of this\r\n */\r\n remove() {\r\n this.element.remove();\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param {Partial<CSSStyleDeclaration} options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}\r\n * @returns - Instance of this\r\n */\r\n setStyle(options: Partial<CSSStyleDeclaration>) {\r\n if (Object.prototype.toString.call(options) !== \"[object Object]\") {\r\n throw new Error(\r\n `powerpagestoolkit: 'DOMNodeReference.setStyle' required options to be in the form of an object. Argument passed was of type: ${typeof options}`\r\n );\r\n }\r\n\r\n for (const key in options) {\r\n this.element.style[key as any] = options[key] as string;\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Unchecks both the yes and no radio buttons if they exist.\r\n * @returns - Instance of this\r\n */\r\n public uncheckRadios(): DOMNodeReference {\r\n if (this.yesRadio && this.noRadio) {\r\n (this.yesRadio.element as HTMLInputElement).checked = false;\r\n (this.noRadio.element as HTMLInputElement).checked = false;\r\n } else {\r\n console.error(\r\n \"[SYNACT] Attempted to uncheck radios for an element that has no radios\"\r\n );\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Configures conditional rendering for the target element based on a condition\r\n * and the visibility of one or more trigger elements.\r\n *\r\n * @param {(this: DOMNodeReference) => boolean} condition - A function that returns a boolean to determine\r\n * the visibility of the target element. If `condition()` returns true, the element is shown;\r\n * otherwise, it is hidden.\r\n * @param {Array<DOMNodeReference>} [dependencies] - An array of `DOMNodeReference` instances. Event listeners are\r\n * registered on each to toggle the visibility of the target element based on the `condition` and the visibility of\r\n * the target node.\r\n * @returns - Instance of this\r\n */\r\n public configureConditionalRendering(\r\n condition: () => boolean,\r\n dependencies: Array<DOMNodeReference>\r\n ): DOMNodeReference {\r\n try {\r\n this.toggleVisibility(condition());\r\n\r\n if (!dependencies) {\r\n console.warn(\r\n `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`\r\n );\r\n return this;\r\n }\r\n\r\n dependencies.forEach((node) => {\r\n node.on(\"change\", () => this.toggleVisibility(condition()));\r\n\r\n const observer = new MutationObserver(() => {\r\n const display = window.getComputedStyle(\r\n node.visibilityController\r\n ).display;\r\n this.toggleVisibility(display !== \"none\" && condition());\r\n });\r\n observer.observe(node.visibilityController, {\r\n attributes: true,\r\n attributeFilter: [\"style\"],\r\n });\r\n });\r\n\r\n return this;\r\n } catch (e) {\r\n throw new ConditionalRenderingError(this, e as string);\r\n }\r\n }\r\n\r\n /**\r\n * 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.\r\n *\r\n * @param {function(this: DOMNodeReference): boolean} isRequired - A function that determines whether the field should be required. Returns `true` if required, `false` otherwise.\r\n * @param {function(this: DOMNodeReference): boolean} isValid - A function that checks if the field's input is valid. Returns `true` if valid, `false` otherwise.\r\n * @param {string} fieldDisplayName - The name of the field, used in error messages if validation fails.\r\n * @param {Array<DOMNodeReference>} [dependencies] Other fields that this field\u2019s 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.\r\n * @returns - Instance of this\r\n */\r\n public configureValidationAndRequirements(\r\n isRequired: (instance: DOMNodeReference) => boolean,\r\n isValid: (instance: DOMNodeReference) => boolean,\r\n fieldDisplayName: string,\r\n dependencies: Array<DOMNodeReference>\r\n ): DOMNodeReference {\r\n if (typeof Page_Validators !== \"undefined\") {\r\n const newValidator = document.createElement(\"span\");\r\n newValidator.style.display = \"none\";\r\n newValidator.id = `${this.element.id}Validator`;\r\n (newValidator as any).controltovalidate = this.element.id;\r\n (\r\n newValidator as any\r\n ).errormessage = `<a href='#${this.element.id}_label'>${fieldDisplayName} is a required field</a>`;\r\n (newValidator as any).evaluationfunction = isValid.bind(this);\r\n //eslint-disable-next-line\r\n Page_Validators.push(newValidator);\r\n } else {\r\n throw new Error(\r\n \"Attempted to add to Validator where Page_Validators do not exist\"\r\n );\r\n }\r\n\r\n this.setRequiredLevel(isRequired(this));\r\n\r\n if (!dependencies) {\r\n console.warn(\r\n `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`\r\n );\r\n return this;\r\n }\r\n dependencies.forEach((dep) => {\r\n dep.element.addEventListener(\"change\", () =>\r\n this.setRequiredLevel(isRequired(this))\r\n );\r\n });\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the required level for the field by adding or removing the \"required-field\" class on the label.\r\n *\r\n * @param {boolean} isRequired - Determines whether the field should be marked as required.\r\n * If true, the \"required-field\" class is added to the label; if false, it is removed.\r\n * @returns - Instance of this\r\n */\r\n public setRequiredLevel(isRequired: Function | boolean): DOMNodeReference {\r\n if (isRequired instanceof Function) {\r\n isRequired()\r\n ? this.getLabel()?.classList.add(\"required-field\")\r\n : this.getLabel()?.classList.remove(\"required-field\");\r\n return this;\r\n } else {\r\n isRequired\r\n ? this.getLabel()?.classList.add(\"required-field\")\r\n : this.getLabel()?.classList.remove(\"required-field\");\r\n return this;\r\n }\r\n }\r\n\r\n /**\r\n * Executes a callback function once the element is fully loaded.\r\n * If the element is already loaded, the callback is called immediately.\r\n * Otherwise, a MutationObserver is used to detect when the element is added to the DOM.\r\n * @param {Function} callback - A callback function to execute once the element is loaded.\r\n */\r\n public onceLoaded(callback: (instance: DOMNodeReference) => any): any {\r\n if (this.isLoaded) {\r\n callback(this);\r\n return;\r\n }\r\n\r\n if (this.target instanceof HTMLElement) {\r\n callback(this);\r\n return;\r\n }\r\n const observer = new MutationObserver(() => {\r\n if (document.querySelector(this.target as string)) {\r\n observer.disconnect(); // Stop observing once loaded\r\n this.isLoaded = true;\r\n callback(this); // Call the provided callback\r\n }\r\n });\r\n\r\n observer.observe(document.body, {\r\n subtree: true,\r\n childList: true,\r\n });\r\n }\r\n}\r\n", "import DOMNodeReference, { _init } from \"./DOMNodeReference.js\";\r\n\r\n/**\r\n * Creates and initializes a DOMNodeReference instance.\r\n * @async\r\n * @param {string | HTMLElement} target - The CSS selector for the desired DOM element, or, optionally, the element itself for which to create a DOMNodeReference.\r\n * @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the initialized DOMNodeReference instance.\r\n */\r\nexport async function createDOMNodeReference(\r\n target: HTMLElement | string\r\n): Promise<DOMNodeReference> {\r\n try {\r\n const instance = new DOMNodeReference(target);\r\n await instance[_init]();\r\n\r\n return new Proxy(instance, {\r\n get: (target, prop) => {\r\n // do not proxy the initialization method\r\n // init() is only needed in this factory function\r\n if (prop.toString().startsWith(\"_\")) return undefined;\r\n\r\n // proxy the class to wrap all methods in the 'onceLoaded' method, to make sure the\r\n // element is always available before executing method\r\n const value = target[prop as keyof DOMNodeReference];\r\n if (typeof value === \"function\" && prop !== \"onceLoaded\") {\r\n return (...args: any[]) => {\r\n target.onceLoaded(() => value.apply(target, args));\r\n return target;\r\n };\r\n }\r\n return value;\r\n },\r\n });\r\n } catch (e) {\r\n throw new Error(e as string);\r\n }\r\n}\r\n\r\n/**\r\n * Creates and initializes multiple DOMNodeReference instances.\r\n * @async\r\n * @param {string} querySelector - The CSS selector for the desired DOM elements.\r\n * @returns {Promise<DOMNodeReference[]>} A promise that resolves to an array of Proxies of initialized DOMNodeReference instances.\r\n */\r\nexport async function createMultipleDOMNodeReferences(\r\n querySelector: string\r\n): Promise<DOMNodeReference[]> {\r\n try {\r\n const elements = Array.from(\r\n document.querySelectorAll(querySelector)\r\n ) as HTMLElement[];\r\n\r\n const initializedElements = await Promise.all(\r\n elements.map((element) => createDOMNodeReference(element))\r\n );\r\n\r\n const domNodeArray = initializedElements as DOMNodeReferenceArray;\r\n\r\n domNodeArray.hideAll = () =>\r\n domNodeArray.forEach((instance) => instance.hide());\r\n domNodeArray.showAll = () =>\r\n domNodeArray.forEach((instance) => instance.show());\r\n\r\n return domNodeArray;\r\n } catch (e) {\r\n console.error(\r\n `There was an error creating multiple DOMNodeReferences: ${e}`\r\n );\r\n throw new Error(e as string);\r\n }\r\n}\r\n", "import { createMultipleDOMNodeReferences } from \"./createDOMNodeReferences.js\";\r\nimport DOMNodeReference, { _init } from \"./DOMNodeReference.js\";\r\nimport ListItem from \"./ListItem.js\";\r\nexport const _listInit = Symbol(\"_listInit\");\r\n\r\n/******/ /******/ /******/ export default class List extends DOMNodeReference {\r\n /**\r\n * @property an array of List Items contained within this list\r\n */\r\n public declare listItems: ListItem[];\r\n\r\n constructor(target: HTMLElement | string) {\r\n super(target);\r\n this.listItems = [];\r\n }\r\n\r\n public async [_listInit](): Promise<void> {\r\n await super[_init]();\r\n const li = await createMultipleDOMNodeReferences(\r\n \"div.ms-DetailsRow-fields\"\r\n );\r\n console.log(li);\r\n setTimeout(() => {\r\n console.log(li);\r\n }, 1000);\r\n }\r\n}\r\n", "import List, { _listInit } from \"./List.js\";\r\n\r\nexport default async function (): Promise<List> {\r\n try {\r\n const instance = new List(\"div.ms-DetailsList\");\r\n await instance[_listInit]();\r\n\r\n return new Proxy(instance, {\r\n get: (target, prop) => {\r\n // do not proxy the initialization method\r\n // init() is only needed in this factory function\r\n if (prop.toString().startsWith(\"_\")) return undefined;\r\n\r\n // proxy the class to wrap all methods in the 'onceLoaded' method, to make sure the\r\n // element is always available before executing method\r\n const value = target[prop as keyof List];\r\n if (typeof value === \"function\" && prop !== \"onceLoaded\") {\r\n return (...args: any[]) => {\r\n target.onceLoaded(() => value.apply(target, args));\r\n return target;\r\n };\r\n }\r\n return value;\r\n },\r\n });\r\n } catch (e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;AAAA,UACT;AAAA,QACF;AACA,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAAA,EACH,SAAS,GAAG;AACV,UAAM,IAAI,MAAM,CAAW;AAAA,EAC7B;AACF;",
|
|
6
|
+
"names": ["target"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import DOMNodeReference, { _init } from "./DOMNodeReference.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates and initializes a DOMNodeReference instance.
|
|
4
|
+
* @async
|
|
5
|
+
* @param {string | HTMLElement} target - The CSS selector for the desired DOM element, or, optionally, the element itself for which to create a DOMNodeReference.
|
|
6
|
+
* @returns {Promise<DOMNodeReference>} A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
|
|
7
|
+
*/
|
|
8
|
+
export async function createDOMNodeReference(target) {
|
|
9
|
+
try {
|
|
10
|
+
const instance = new DOMNodeReference(target);
|
|
11
|
+
await instance[_init]();
|
|
12
|
+
return new Proxy(instance, {
|
|
13
|
+
get: (target, prop) => {
|
|
14
|
+
// do not proxy the initialization method
|
|
15
|
+
// init() is only needed in this factory function
|
|
16
|
+
if (prop.toString().startsWith("_"))
|
|
17
|
+
return undefined;
|
|
18
|
+
// proxy the class to wrap all methods in the 'onceLoaded' method, to make sure the
|
|
19
|
+
// element is always available before executing method
|
|
20
|
+
const value = target[prop];
|
|
21
|
+
if (typeof value === "function" && prop !== "onceLoaded") {
|
|
22
|
+
return (...args) => {
|
|
23
|
+
target.onceLoaded(() => value.apply(target, args));
|
|
24
|
+
return target;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
throw new Error(e);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates and initializes multiple DOMNodeReference instances.
|
|
37
|
+
* @async
|
|
38
|
+
* @param {string} querySelector - The CSS selector for the desired DOM elements.
|
|
39
|
+
* @returns {Promise<DOMNodeReference[]>} A promise that resolves to an array of Proxies of initialized DOMNodeReference instances.
|
|
40
|
+
*/
|
|
41
|
+
export async function createMultipleDOMNodeReferences(querySelector) {
|
|
42
|
+
try {
|
|
43
|
+
const elements = Array.from(document.querySelectorAll(querySelector));
|
|
44
|
+
const initializedElements = await Promise.all(elements.map((element) => createDOMNodeReference(element)));
|
|
45
|
+
const domNodeArray = initializedElements;
|
|
46
|
+
domNodeArray.hideAll = () => domNodeArray.forEach((instance) => instance.hide());
|
|
47
|
+
domNodeArray.showAll = () => domNodeArray.forEach((instance) => instance.show());
|
|
48
|
+
return domNodeArray;
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
console.error(`There was an error creating multiple DOMNodeReferences: ${e}`);
|
|
52
|
+
throw new Error(e);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=createDOMNodeReferences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDOMNodeReferences.js","sourceRoot":"","sources":["../src/createDOMNodeReferences.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,EAAE,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAA4B;IAE5B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAExB,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE;YACzB,GAAG,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;gBACpB,yCAAyC;gBACzC,iDAAiD;gBACjD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;oBAAE,OAAO,SAAS,CAAC;gBAEtD,mFAAmF;gBACnF,sDAAsD;gBACtD,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ACX,OAAO,CAAC,KAAK,CACX,2DAA2D,CAAC,EAAE,CAC/D,CAAC;QACF,MAAM,IAAI,KAAK,CAAC,CAAW,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export default function CreateInfoEl(titleString) {
|
|
2
|
+
const span = document.createElement("span");
|
|
3
|
+
span.classList.add("info-icon");
|
|
4
|
+
const icon = document.createElement("i");
|
|
5
|
+
icon.classList.add("fa", "fa-solid", "fa-info-circle");
|
|
6
|
+
icon.setAttribute("aria-label", "Info");
|
|
7
|
+
icon.style.cursor = "pointer";
|
|
8
|
+
const flyoutContent = document.createElement("div");
|
|
9
|
+
flyoutContent.innerHTML = titleString;
|
|
10
|
+
flyoutContent.classList.add("flyout-content");
|
|
11
|
+
span.appendChild(icon);
|
|
12
|
+
span.appendChild(flyoutContent);
|
|
13
|
+
// Function to position flyout content
|
|
14
|
+
const positionFlyout = () => {
|
|
15
|
+
flyoutContent.style.display = "block"; // Show the flyout to calculate dimensions
|
|
16
|
+
const flyoutRect = flyoutContent.getBoundingClientRect();
|
|
17
|
+
const viewportWidth = window.innerWidth;
|
|
18
|
+
// Position the flyout
|
|
19
|
+
// Adjust if flyout is too far to the right
|
|
20
|
+
if (flyoutRect.right > viewportWidth) {
|
|
21
|
+
const overflowAmount = flyoutRect.right - viewportWidth;
|
|
22
|
+
flyoutContent.style.left = `calc(50% - ${overflowAmount}px)`; // Shift left
|
|
23
|
+
}
|
|
24
|
+
// Adjust if flyout is too far to the left
|
|
25
|
+
if (flyoutRect.left < 0) {
|
|
26
|
+
const overflowAmount = Math.abs(flyoutRect.left);
|
|
27
|
+
flyoutContent.style.left = `calc(50% + ${overflowAmount}px)`; // Shift right
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
icon.addEventListener("mouseenter", positionFlyout);
|
|
31
|
+
icon.addEventListener("mouseleave", () => {
|
|
32
|
+
flyoutContent.style.display = "none"; // Hide on mouse leave
|
|
33
|
+
});
|
|
34
|
+
icon.addEventListener("touchstart", (event) => {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
// Toggle flyout visibility on touch
|
|
37
|
+
flyoutContent.style.display =
|
|
38
|
+
flyoutContent.style.display === "block" ? "none" : "block";
|
|
39
|
+
if (flyoutContent.style.display === "block") {
|
|
40
|
+
positionFlyout(); // Position the flyout when displayed
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
document.body.addEventListener("click", (event) => {
|
|
44
|
+
if (!span.contains(event.target)) {
|
|
45
|
+
flyoutContent.style.display = "none"; // Hide on body click
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
flyoutContent.style.display = "none";
|
|
49
|
+
return span;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=createInfoElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createInfoElement.js","sourceRoot":"","sources":["../src/createInfoElement.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,WAAmB;IACtD,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEhC,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACvD,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACxC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;IAE9B,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACpD,aAAa,CAAC,SAAS,GAAG,WAAW,CAAC;IACtC,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAE9C,IA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CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QAC7D,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;YAC5C,cAAc,EAAE,CAAC,CAAC,qCAAqC;QACzD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;QACvD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAO,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACvC,aAAa,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,qBAAqB;QAC7D,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,aAAa,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACrC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class DOMNodeInitializationError extends Error {
|
|
2
|
+
constructor(instance, error) {
|
|
3
|
+
super(`There was an error initializing a DOMNodeReference for target: ${instance.target}, :: ${error}`);
|
|
4
|
+
this.name = "DOMNodeInitializationError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export class DOMNodeNotFoundError extends Error {
|
|
8
|
+
constructor(instance) {
|
|
9
|
+
super(`The targeted DOM element was not found: ${instance.target}`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class ConditionalRenderingError extends Error {
|
|
13
|
+
constructor(instance, error) {
|
|
14
|
+
super(`There was an error condiguring conditional rendering for target: ${instance.target} :: ${error}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACnD,YAAY,QAA0B,EAAE,KAAa;QACnD,KAAK,CACH,kEAAkE,QAAQ,CAAC,MAAM,QAAQ,KAAK,EAAE,CACjG,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,QAA0B;QACpC,KAAK,CAAC,2CAA2C,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACtE,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAClD,YAAY,QAA0B,EAAE,KAAa;QACnD,KAAK,CACH,oEAAoE,QAAQ,CAAC,MAAM,OAAO,KAAK,EAAE,CAClG,CAAC;IACJ,CAAC;CACF"}
|
package/dist/getList.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import List, { _listInit } from "./List.js";
|
|
2
|
+
export default async function () {
|
|
3
|
+
try {
|
|
4
|
+
const instance = new List("div.ms-DetailsList");
|
|
5
|
+
await instance[_listInit]();
|
|
6
|
+
return new Proxy(instance, {
|
|
7
|
+
get: (target, prop) => {
|
|
8
|
+
// do not proxy the initialization method
|
|
9
|
+
// init() is only needed in this factory function
|
|
10
|
+
if (prop.toString().startsWith("_"))
|
|
11
|
+
return undefined;
|
|
12
|
+
// proxy the class to wrap all methods in the 'onceLoaded' method, to make sure the
|
|
13
|
+
// element is always available before executing method
|
|
14
|
+
const value = target[prop];
|
|
15
|
+
if (typeof value === "function" && prop !== "onceLoaded") {
|
|
16
|
+
return (...args) => {
|
|
17
|
+
target.onceLoaded(() => value.apply(target, args));
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
throw new Error(e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=getList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getList.js","sourceRoot":"","sources":["../src/getList.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,CAAC,OAAO,CAAC,KAAK;IAClB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAChD,MAAM,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAE5B,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE;YACzB,GAAG,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;gBACpB,yCAAyC;gBACzC,iDAAiD;gBACjD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;oBAAE,OAAO,SAAS,CAAC;gBAEtD,mFAAmF;gBACnF,sDAAsD;gBACtD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAkB,CAAC,CAAC;gBACzC,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;oBACzD,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;wBACxB,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;wBACnD,OAAO,MAAM,CAAC;oBAChB,CAAC,CAAC;gBACJ,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,CAAW,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference path="../@types/index.d.ts" />
|
|
2
|
+
import API from "./API.js";
|
|
3
|
+
import { createDOMNodeReference, createMultipleDOMNodeReferences, } from "./createDOMNodeReferences.js";
|
|
4
|
+
import getList from "./getList.js";
|
|
5
|
+
import "./style.css";
|
|
6
|
+
export { API, createDOMNodeReference, createMultipleDOMNodeReferences, getList, };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAE7C,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EACL,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,8BAA8B,CAAC;AACtC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,aAAa,CAAC;AAErB,OAAO,EACL,GAAG,EACH,sBAAsB,EACtB,+BAA+B,EAC/B,OAAO,GACR,CAAC"}
|
package/dist/safeAjax.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
export default function safeAjax(ajaxOptions) {
|
|
3
|
+
const deferredAjax = $.Deferred();
|
|
4
|
+
// shell is only available via runtime in a PowerPages portal
|
|
5
|
+
shell
|
|
6
|
+
.getTokenDeferred()
|
|
7
|
+
.done(function (token) {
|
|
8
|
+
// add headers for AJAX
|
|
9
|
+
if (!ajaxOptions.headers) {
|
|
10
|
+
$.extend(ajaxOptions, {
|
|
11
|
+
headers: {
|
|
12
|
+
__RequestVerificationToken: token,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
ajaxOptions.headers["__RequestVerificationToken"] = token;
|
|
18
|
+
}
|
|
19
|
+
$.ajax(ajaxOptions)
|
|
20
|
+
.done(function (data, textStatus, jqXHR) {
|
|
21
|
+
//eslint-disable-next-line
|
|
22
|
+
validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve);
|
|
23
|
+
})
|
|
24
|
+
.fail(deferredAjax.reject); //AJAX
|
|
25
|
+
})
|
|
26
|
+
.fail(function () {
|
|
27
|
+
deferredAjax.rejectWith(this, arguments); // on token failure pass the token AJAX and args
|
|
28
|
+
});
|
|
29
|
+
return deferredAjax.promise();
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=safeAjax.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safeAjax.js","sourceRoot":"","sources":["../src/safeAjax.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,WAAW;IAC1C,MAAM,YAAY,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IAElC,6DAA6D;IAE7D,KAAK;SACF,gBAAgB,EAAE;SAClB,IAAI,CAAC,UAAU,KAAK;QACnB,uBAAuB;QACvB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACzB,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE;gBACpB,OAAO,EAAE;oBACP,0BAA0B,EAAE,KAAK;iBAClC;aACF,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,OAAO,CAAC,4BAA4B,CAAC,GAAG,KAAK,CAAC;QAC5D,CAAC;QACD,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;aAChB,IAAI,CAAC,UAAU,IAAI,EAAE,UAAU,EAAE,KAAK;YACrC,0BAA0B;YAC1B,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QACtE,CAAC,CAAC;aACD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;IACtC,CAAC,CAAC;SACD,IAAI,CAAC;QACJ,YAAY,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,gDAAgD;IAC5F,CAAC,CAAC,CAAC;IAEL,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;AAChC,CAAC"}
|
package/dist/waitFor.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export default function waitFor(target) {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
// Create observer to watch for target in DOM
|
|
4
|
+
const observer = new MutationObserver(() => {
|
|
5
|
+
const observedElement = (document.querySelector(target));
|
|
6
|
+
if (observedElement) {
|
|
7
|
+
clearTimeout(timeout);
|
|
8
|
+
observer.disconnect();
|
|
9
|
+
resolve(observedElement);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const timeout = setTimeout(() => {
|
|
13
|
+
observer.disconnect();
|
|
14
|
+
reject(new Error(`Element not found: ${target} within 5 seconds`));
|
|
15
|
+
}, 5000);
|
|
16
|
+
// Check if target is already in DOM
|
|
17
|
+
if (target instanceof HTMLElement) {
|
|
18
|
+
clearTimeout(timeout);
|
|
19
|
+
return resolve(target);
|
|
20
|
+
}
|
|
21
|
+
const element = document.querySelector(target);
|
|
22
|
+
if (element) {
|
|
23
|
+
clearTimeout(timeout);
|
|
24
|
+
return resolve(element);
|
|
25
|
+
}
|
|
26
|
+
observer.observe(document.body, {
|
|
27
|
+
subtree: true,
|
|
28
|
+
attributes: true,
|
|
29
|
+
childList: true, // Detects added/removed child elements
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=waitFor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waitFor.js","sourceRoot":"","sources":["../src/waitFor.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,OAAO,CAC7B,MAA4B;IAE5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,6CAA6C;QAC7C,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE;YACzC,MAAM,eAAe,GAAgB,CACnC,QAAQ,CAAC,aAAa,CAAS,MAAM,CAAC,CACvC,CAAC;YACF,IAAI,eAAe,EAAE,CAAC;gBACpB,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtB,QAAQ,CAAC,UAAU,EAAE,CAAC;gBACtB,OAAO,CAAC,eAAe,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9B,QAAQ,CAAC,UAAU,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,MAAM,mBAAmB,CAAC,CAAC,CAAC;QACrE,CAAC,EAAE,IAAI,CAAC,CAAC;QAET,oCAAoC;QACpC,IAAI,MAAM,YAAY,WAAW,EAAE,CAAC;YAClC,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;QACD,MAAM,OAAO,GAAgB,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5D,IAAI,OAAO,EAAE,CAAC;YACZ,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;QAED,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE;YAC9B,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,IAAI,EAAE,uCAAuC;SACzD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ class DOMNodeReference {
|
|
|
8
8
|
*/
|
|
9
9
|
constructor(target: string): DOMNodeReference;
|
|
10
10
|
|
|
11
|
-
target: string;
|
|
12
11
|
/**
|
|
13
12
|
* The element targeted when instantiating DOMNodeReference.
|
|
14
13
|
* Made available in order to perform normal DOM traversal,
|
|
@@ -17,8 +16,6 @@ class DOMNodeReference {
|
|
|
17
16
|
*/
|
|
18
17
|
element: HTMLElement | null;
|
|
19
18
|
isLoaded: boolean;
|
|
20
|
-
visibilityController: HTMLElement | null;
|
|
21
|
-
defaultDisplay: string;
|
|
22
19
|
/**
|
|
23
20
|
* The value of the element that this node represents
|
|
24
21
|
* stays in syncs with the live DOM elements via event handler
|
|
@@ -50,55 +47,64 @@ class DOMNodeReference {
|
|
|
50
47
|
|
|
51
48
|
/**
|
|
52
49
|
* Hides the element by setting its display style to "none".
|
|
50
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
53
51
|
*/
|
|
54
|
-
hide():
|
|
52
|
+
hide(): DOMNodeReference;
|
|
55
53
|
|
|
56
54
|
/**
|
|
57
55
|
* Shows the element by restoring its default display style.
|
|
56
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
58
57
|
*/
|
|
59
|
-
show():
|
|
58
|
+
show(): DOMNodeReference;
|
|
60
59
|
|
|
61
60
|
/**
|
|
62
61
|
* Sets the value of the HTML element.
|
|
63
62
|
* @param {() => any} value - The value to set for the HTML element.
|
|
64
63
|
* for parents of boolean radios, pass true or false as value, or
|
|
65
64
|
* an expression returning a boolean
|
|
65
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
66
66
|
*/
|
|
67
|
-
setValue(value: string):
|
|
67
|
+
setValue(value: string): DOMNodeReference;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Disables the element so that users cannot input any data
|
|
71
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
71
72
|
*/
|
|
72
|
-
disable():
|
|
73
|
+
disable(): DOMNodeReference;
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* Enables the element so that users can input data
|
|
77
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
76
78
|
*/
|
|
77
|
-
enable():
|
|
79
|
+
enable(): DOMNodeReference;
|
|
78
80
|
|
|
79
81
|
/**
|
|
80
82
|
* Prepends elements to the target
|
|
81
|
-
* @param {
|
|
83
|
+
* @param {HTMLElement[] | DOMNodeReference[]} nodes - The elements to prepend to the HTML element
|
|
84
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
82
85
|
*/
|
|
83
|
-
prepend(...
|
|
86
|
+
prepend(...nodes: HTMLElement[] | DOMNodeReference[]): DOMNodeReference;
|
|
84
87
|
|
|
85
88
|
/**
|
|
86
89
|
* Appends child elements to the HTML element.
|
|
87
|
-
* @param {
|
|
90
|
+
* @param {HTMLElement[] | DOMNodeReference[]} nodes - The elements to append to the HTML element.
|
|
91
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
88
92
|
*/
|
|
89
|
-
append(...
|
|
93
|
+
append(...nodes: HTMLElement[] | DOMNodeReference[]): DOMNodeReference;
|
|
90
94
|
|
|
91
95
|
/**
|
|
92
96
|
* Inserts elements before the HTML element.
|
|
93
|
-
* @param {
|
|
97
|
+
* @param {HTMLElement[] | DOMNodeReference[]} nodes - The elements to insert before the HTML element.
|
|
98
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
94
99
|
*/
|
|
95
|
-
before(...
|
|
100
|
+
before(...nodes: HTMLElement[] | DOMNodeReference[]): DOMNodeReference;
|
|
96
101
|
|
|
97
102
|
/**
|
|
98
103
|
* Inserts elements after the HTML element.
|
|
99
|
-
* @param {
|
|
104
|
+
* @param {HTMLElement[] | DOMNodeReference[]} nodes - The elements to insert after the HTML element.
|
|
105
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
100
106
|
*/
|
|
101
|
-
after(...
|
|
107
|
+
after(...nodes: HTMLElement[] | DOMNodeReference[]): DOMNodeReference;
|
|
102
108
|
|
|
103
109
|
/**
|
|
104
110
|
* Retrieves the label associated with the HTML element.
|
|
@@ -110,8 +116,9 @@ class DOMNodeReference {
|
|
|
110
116
|
/**
|
|
111
117
|
* Appends child elements to the label associated with the HTML element.
|
|
112
118
|
* @param {...HTMLElement} elements - The elements to append to the label.
|
|
119
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
113
120
|
*/
|
|
114
|
-
appendToLabel(...elements: HTMLElement[]):
|
|
121
|
+
appendToLabel(...elements: HTMLElement[]): DOMNodeReference;
|
|
115
122
|
|
|
116
123
|
/**
|
|
117
124
|
* Sets up an event listener based on the specified event type, executing the specified
|
|
@@ -119,12 +126,15 @@ class DOMNodeReference {
|
|
|
119
126
|
* @param {string} eventType - The DOM event to watch for
|
|
120
127
|
* @param {(this: DOMNodeReference, e: Event) => void} eventHandler - The callback function that runs when the
|
|
121
128
|
* specified event occurs
|
|
129
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
122
130
|
*/
|
|
123
|
-
on(eventType: string, eventHandler: (event: Event) => void):
|
|
131
|
+
on(eventType: string, eventHandler: (event: Event) => void): DOMNodeReference;
|
|
132
|
+
|
|
124
133
|
/**
|
|
125
134
|
* Unchecks both the yes and no radio buttons if they exist.
|
|
135
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
126
136
|
*/
|
|
127
|
-
uncheckRadios():
|
|
137
|
+
uncheckRadios(): DOMNodeReference;
|
|
128
138
|
|
|
129
139
|
/**
|
|
130
140
|
* 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.
|
|
@@ -133,46 +143,66 @@ class DOMNodeReference {
|
|
|
133
143
|
* @param {function(this: DOMNodeReference): boolean} isValid - A function that checks if the field's input is valid. Returns `true` if valid, `false` otherwise.
|
|
134
144
|
* @param {string} fieldDisplayName - The name of the field, used in error messages if validation fails.
|
|
135
145
|
* @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.
|
|
146
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
136
147
|
*/
|
|
137
148
|
configureValidationAndRequirements(
|
|
138
149
|
isRequired: (this: this) => boolean,
|
|
139
150
|
isValid: (this: this) => boolean,
|
|
140
151
|
fieldDisplayName: string,
|
|
141
152
|
dependencies: Array<DOMNodeReference>
|
|
142
|
-
):
|
|
153
|
+
): DOMNodeReference;
|
|
143
154
|
|
|
144
155
|
/**
|
|
145
156
|
* Sets the required level for the field by adding or removing the "required-field" class on the label.
|
|
146
157
|
*
|
|
147
158
|
* @param {boolean} isRequired - Determines whether the field should be marked as required.
|
|
148
159
|
* If true, the "required-field" class is added to the label; if false, it is removed.
|
|
160
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
149
161
|
*/
|
|
150
|
-
setRequiredLevel(isRequired: boolean):
|
|
162
|
+
setRequiredLevel(isRequired: boolean): DOMNodeReference;
|
|
151
163
|
|
|
152
164
|
/**
|
|
153
165
|
* Adds a tooltip with specified text to the label associated with the HTML element.
|
|
154
166
|
* @param {string} text - The text to display in the tooltip.
|
|
167
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
155
168
|
*/
|
|
156
|
-
addLabelTooltip(text: string):
|
|
169
|
+
addLabelTooltip(text: string): DOMNodeReference;
|
|
157
170
|
|
|
158
171
|
/**
|
|
159
172
|
* Adds a tooltip with the specified text to the element
|
|
160
173
|
* @param {string} text - The text to display in the tooltip
|
|
174
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
161
175
|
*/
|
|
162
|
-
addTooltip(text: string):
|
|
176
|
+
addTooltip(text: string): DOMNodeReference;
|
|
163
177
|
|
|
164
178
|
/**
|
|
165
179
|
* Sets the inner HTML content of the HTML element.
|
|
166
180
|
* @param {string} text - The text to set as the inner HTML of the element.
|
|
181
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
182
|
+
*/
|
|
183
|
+
setInnerHTML(text: string): DOMNodeReference;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Removes the element from the DOM
|
|
187
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
188
|
+
*/
|
|
189
|
+
remove(): DOMNodeReference;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
*
|
|
193
|
+
* @param {Partial<CSSStyleDeclaration>} options - An object with the style properties (keys) and updated styles (values)
|
|
194
|
+
* to apply to the this. {"key": "value"}
|
|
195
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
167
196
|
*/
|
|
168
|
-
|
|
197
|
+
setStyle(options: Partial<CSSStyleDeclaration>): DOMNodeReference;
|
|
169
198
|
|
|
170
199
|
/**
|
|
171
200
|
*
|
|
172
201
|
* @param {boolean} shouldShow shows or hides the target
|
|
173
202
|
* if = true => show, if = false => hide
|
|
203
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
174
204
|
*/
|
|
175
|
-
toggleVisibility(shouldShow: boolean):
|
|
205
|
+
toggleVisibility(shouldShow: boolean): DOMNodeReference;
|
|
176
206
|
|
|
177
207
|
/**
|
|
178
208
|
* Configures conditional rendering for the target element based on a condition
|
|
@@ -181,14 +211,15 @@ class DOMNodeReference {
|
|
|
181
211
|
* @param {(this: DOMNodeReference) => boolean} condition - A function that returns a boolean to determine
|
|
182
212
|
* the visibility of the target element. If `condition()` returns true, the element is shown;
|
|
183
213
|
* otherwise, it is hidden.
|
|
184
|
-
* @param {DOMNodeReference
|
|
214
|
+
* @param {Array<DOMNodeReference>} dependencies - An array of `DOMNodeReference` instances. Event listeners are
|
|
185
215
|
* registered on each to toggle the visibility of the target element based on the `condition` and the visibility of
|
|
186
216
|
* the target node.
|
|
217
|
+
* @returns {DOMNodeReference} Returns 'this'
|
|
187
218
|
*/
|
|
188
219
|
configureConditionalRendering(
|
|
189
220
|
condition: (this: DOMNodeReference) => boolean,
|
|
190
|
-
|
|
191
|
-
):
|
|
221
|
+
dependencies: DOMNodeReference[]
|
|
222
|
+
): DOMNodeReference;
|
|
192
223
|
|
|
193
224
|
/**
|
|
194
225
|
* Executes a callback function once the element is fully loaded.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powerpagestoolkit",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
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/index.bundle.js",
|
|
6
6
|
"types": "index.d.ts",
|