powerpagestoolkit 2.7.104 → 2.7.121-2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -35,7 +35,7 @@ createRef(
35
35
  options: {
36
36
  multiple: (() => boolean) | boolean = false,
37
37
  root: HTMLElement,
38
- timeout: number
38
+ timeoutMs:number
39
39
  }
40
40
  ): Promise<DOMNodeReference | DOMNodeReference[]>;
41
41
  ```
@@ -66,7 +66,7 @@ createRef takes two main arguments:
66
66
  <pre><code class="language-javascript">{
67
67
  multiple: () => boolean | boolean,
68
68
  root: HTMLElement,
69
- timeout: number
69
+ timeoutMs:number
70
70
  }</code></pre>
71
71
  </td>
72
72
  <td style="border: 1px solid #ddd; padding: 8px;">
@@ -98,7 +98,7 @@ const nodes = await createRef(".my-class", { multiple: true });
98
98
 
99
99
  // If the node you are targeting is not available at the initial execution
100
100
  // of the script, set a timeout for 2 seconds
101
- const node2 = await createRef("#target", { timeout: 2000 });
101
+ const node2 = await createRef("#target", { timeoutMs:2000 });
102
102
 
103
103
  // need to target a node within a specific node? use that node as the root
104
104
  const otherElement = document.getElementById("id");
@@ -107,7 +107,7 @@ const node3 = await createRef("#target", { root: otherElement });
107
107
  // implement all options:
108
108
  const nodes2 = await createRef("#target", {
109
109
  multiple: true,
110
- timeout: 4000,
110
+ timeoutMs:4000,
111
111
  root: otherElement,
112
112
  });
113
113
  ```
package/dist/bundle.js CHANGED
@@ -102,11 +102,11 @@ var API = {
102
102
  };
103
103
  var API_default = API;
104
104
 
105
- // src/utils/waitFor.ts
105
+ // src/core/waitFor.ts
106
106
  function waitFor(target, root = document, multiple = false, debounceTime2) {
107
107
  return new Promise((resolve, reject) => {
108
108
  if (multiple) {
109
- let timeout;
109
+ let timeoutMs;
110
110
  const observedElements = [];
111
111
  const observedSet = /* @__PURE__ */ new Set();
112
112
  if (debounceTime2 < 1) {
@@ -122,8 +122,8 @@ function waitFor(target, root = document, multiple = false, debounceTime2) {
122
122
  observedElements.push(element);
123
123
  }
124
124
  });
125
- clearTimeout(timeout);
126
- timeout = setTimeout(() => {
125
+ clearTimeout(timeoutMs);
126
+ timeoutMs = setTimeout(() => {
127
127
  if (observedElements.length > 0) {
128
128
  observer.disconnect();
129
129
  resolve(observedElements);
@@ -1,4 +1,31 @@
1
1
  import * as s from "@/constants/symbols.js";
2
+ declare type BusinessRule = {
3
+ /**
4
+ * @param condition A function that returns a boolean to determine
5
+ * the visibility of the target element. If `condition()` returns true, the element is shown;
6
+ * otherwise, it is hidden.
7
+
8
+ * @param clearValuesOnHide Should the values in the targeted field be cleared when hidden? Defaults to true
9
+ */
10
+ setVisibility?: [condition: () => boolean, clearValuesOnHide?: boolean];
11
+ /**
12
+ * @param isRequired Function determining if field is required
13
+ * @param isValid Function validating field input.
14
+ */
15
+ setRequired?: [isRequired: () => boolean, isValid: () => boolean];
16
+ /**
17
+ * @param condition A function to determine if the value provided should be applied to this field
18
+ * @param value The value to set for the HTML element.
19
+ * for parents of boolean radios, pass true or false as value, or
20
+ * an expression returning a boolean
21
+ */
22
+ setValue?: [condition: () => boolean, value: () => any | any];
23
+ /**
24
+ * @param condition A function to determine if this field
25
+ * should be enabled in a form, or disabled. True || 1 = disabled. False || 0 = enabled
26
+ */
27
+ setDisabled?: () => boolean;
28
+ };
2
29
  export default class DOMNodeReference {
3
30
  target: Element | string;
4
31
  logicalName?: string;
@@ -251,3 +278,4 @@ export default class DOMNodeReference {
251
278
  */
252
279
  onceLoaded(callback: (instance: DOMNodeReference) => any): any;
253
280
  }
281
+ export {};
@@ -1,11 +1,13 @@
1
1
  import DOMNodeReference from "./DOMNodeReference.js";
2
2
  import DOMNodeReferenceArray from "./DOMNodeReferenceArray.js";
3
+ declare type BoundForm = DOMNodeReferenceArray & Record<string, DOMNodeReference>;
3
4
  /**
4
- * @function
5
5
  * Get all controls related to the form for manipulating with the
6
6
  * DOMNodeReference class. Rather than having to instantiate each fields that you need manually,
7
7
  * you can call this method once with the form ID and gain access to all fields
8
8
  * @param formId The string GUID of the form you want to bind to
9
- * @returns An array of DOMNodeReferences
9
+ * @returns An array of DOMNodeReferences, accessible as properties of a Record<string, DOMNodeReference> i.e. formProp = form["some_logicalName"]
10
+ * @see {@link BoundForm}
10
11
  */
11
- export default function bindForm<T extends string>(formId: string): Promise<DOMNodeReferenceArray & Record<T, DOMNodeReference>>;
12
+ export default function bindForm(formId: string): Promise<BoundForm>;
13
+ export {};
@@ -1,5 +1,33 @@
1
1
  import DOMNodeReference from "./DOMNodeReference.js";
2
2
  import DOMNodeReferenceArray from "./DOMNodeReferenceArray.js";
3
+ /**
4
+ * Creates and initializes a DOMNodeReference instance.
5
+ * @see {@link CreationOptions}
6
+ * @param target The CSS selector for the desired DOM element, or, optionally, the element itself for which to create a DOMNodeReference.
7
+ * @param options Options for advanced retrieval of elements
8
+ * @param options.multiple - Should this call return an array of instantiated references, or just a single? Defaults to false, returning a single instance
9
+ * @param options.root - Optionally specify the element within to search for the element targeted by 'target'. Defaults to 'document.body'
10
+ * @param options.timeoutMs - Optionally specify the amount of time that should be waited to find the targeted element before throwing error - useful for async DOM loading. Relies on MutationObserver. WARNING: Implementing multiple references with timeout can results in infinite loading.
11
+ * @returns A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
12
+ */
13
+ export default function createDOMNodeReference(target: string | HTMLElement, options?: {
14
+ /**
15
+ * Should this call return an array of instantiated references, or just a single?
16
+ * Defaults to false, returning a single instance.
17
+ */
18
+ multiple?: (() => boolean) | boolean;
19
+ /**
20
+ * Optionally specify the element within which to search for the element targeted by 'target'.
21
+ * Defaults to 'document.body'.
22
+ */
23
+ root?: HTMLElement;
24
+ /**
25
+ * Optionally specify the amount of time that should be waited to find the targeted element before throwing an error.
26
+ * Useful for async DOM loading. Relies on MutationObserver.
27
+ * WARNING: Implementing multiple references with timeout can result in infinite loading.
28
+ */
29
+ timeoutMs?: number;
30
+ }): Promise<DOMNodeReference>;
3
31
  export default function createDOMNodeReference(target: string, options?: {
4
32
  /**
5
33
  * Should this call return an array of instantiated references, or just a single?
@@ -1,6 +1,6 @@
1
1
  import "./style.css";
2
2
  import API from "./core/API.js";
3
3
  import createRef from "./core/createDOMNodeReferences.js";
4
- import waitFor from "./utils/waitFor.js";
4
+ import waitFor from "./core/waitFor.js";
5
5
  import bindForm from "./core/bindForm.js";
6
6
  export { API, createRef, waitFor, bindForm };
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "powerpagestoolkit",
3
- "version": "2.7.104",
3
+ "version": "2.7.1212.001",
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
- "main": "./dist/index.js",
5
+ "main": "./dist/bundle.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "scripts": {
8
8
  "typecheck": "tsc",
9
9
  "node:build": "node build.js",
10
10
  "clean": "rimraf dist",
11
- "build:types": "tsc --emitDeclarationOnly --declaration",
12
- "build": "npm run clean && npm run typecheck && npm run node:build && npm run build:types",
11
+ "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir ./dist/types",
12
+ "build": "npm run clean && npm run build:types && npm run node:build",
13
13
  "dev": "tsc --watch"
14
14
  },
15
15
  "devDependencies": {
@@ -59,15 +59,14 @@
59
59
  ],
60
60
  "files": [
61
61
  "dist/bundle.js",
62
- "dist/index.js",
63
62
  "dist/bundle.css",
64
- "dist/**/*.d.ts",
63
+ "dist/types/**/*.d.ts",
65
64
  "assets/**"
66
65
  ],
67
66
  "exports": {
68
67
  ".": {
69
68
  "import": "./dist/bundle.js",
70
- "types": "./@types/index.d.ts"
69
+ "types": "./dist/types/index.d.ts"
71
70
  },
72
71
  "./createDOMNodeReference": {
73
72
  "import": "./dist/createDOMNodeReference.js",
package/dist/index.js DELETED
@@ -1,8 +0,0 @@
1
- /// <reference path="../@types/index.d.ts" />
2
- import "./style.css";
3
- import API from "./core/API.js";
4
- import createRef from "./core/createDOMNodeReferences.js";
5
- import waitFor from "./utils/waitFor.js";
6
- import bindForm from "./core/bindForm.js";
7
- export { API, createRef, waitFor, bindForm };
8
- //# sourceMappingURL=index.js.map
File without changes
File without changes
File without changes
File without changes
File without changes