powerpagestoolkit 2.7.1211 → 2.7.1401

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);
@@ -613,10 +613,15 @@ var DOMNodeReference = class _DOMNodeReference {
613
613
  }
614
614
  const eventType = this.determineEventType();
615
615
  this.element.dispatchEvent(new Event(eventType, { bubbles: false }));
616
- if (this.element.classList.contains("boolean-radio") && this.yesRadio instanceof _DOMNodeReference && this.noRadio instanceof _DOMNodeReference) {
616
+ if (this.yesRadio instanceof _DOMNodeReference && this.noRadio instanceof _DOMNodeReference) {
617
617
  this.yesRadio.element.checked = value;
618
618
  this.noRadio.element.checked = !value;
619
619
  this.value = value;
620
+ this.checked = value;
621
+ this.element.checked = value;
622
+ } else if (this.isRadio || this.element.type === "radio") {
623
+ this.checked = value;
624
+ this.element.checked = value;
620
625
  } else {
621
626
  this.element.value = value;
622
627
  }
@@ -892,7 +897,7 @@ var DOMNodeReference = class _DOMNodeReference {
892
897
  evaluationfunction: () => {
893
898
  const isFieldRequired = isRequired.bind(this)();
894
899
  const isFieldVisible = window.getComputedStyle(this.visibilityController).display !== "none";
895
- return !isFieldRequired || !isFieldVisible || isValid.bind(this)();
900
+ return !isFieldRequired || !isFieldVisible || isValid.bind(this)(isFieldRequired);
896
901
  }
897
902
  });
898
903
  Page_Validators.push(newValidator);
@@ -1330,10 +1335,15 @@ function createReferenceString(tagName, datafieldname) {
1330
1335
  return `[data-name="${datafieldname}"]`;
1331
1336
  return null;
1332
1337
  }
1338
+
1339
+ // src/index.ts
1340
+ var toolkit = { API: API_default, createRef: createDOMNodeReference, waitFor, bindForm };
1341
+ var src_default = toolkit;
1333
1342
  export {
1334
1343
  API_default as API,
1335
1344
  bindForm,
1336
1345
  createDOMNodeReference as createRef,
1346
+ src_default as default,
1337
1347
  waitFor
1338
1348
  };
1339
1349
 
@@ -1,4 +1,34 @@
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?: [
16
+ isRequired: () => boolean,
17
+ isValid: (isRequired: boolean) => boolean
18
+ ];
19
+ /**
20
+ * @param condition A function to determine if the value provided should be applied to this field
21
+ * @param value The value to set for the HTML element.
22
+ * for parents of boolean radios, pass true or false as value, or
23
+ * an expression returning a boolean
24
+ */
25
+ setValue?: [condition: () => boolean, value: () => any | any];
26
+ /**
27
+ * @param condition A function to determine if this field
28
+ * should be enabled in a form, or disabled. True || 1 = disabled. False || 0 = enabled
29
+ */
30
+ setDisabled?: () => boolean;
31
+ };
2
32
  export default class DOMNodeReference {
3
33
  target: Element | string;
4
34
  logicalName?: string;
@@ -251,3 +281,4 @@ export default class DOMNodeReference {
251
281
  */
252
282
  onceLoaded(callback: (instance: DOMNodeReference) => any): any;
253
283
  }
284
+ export {};
@@ -7,7 +7,7 @@ import DOMNodeReferenceArray from "./DOMNodeReferenceArray.js";
7
7
  * @param options Options for advanced retrieval of elements
8
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
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.
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 result in infinite loading.
11
11
  * @returns A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
12
12
  */
13
13
  export default function createDOMNodeReference(target: string | HTMLElement, options?: {
@@ -1,6 +1,18 @@
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 };
7
+ declare const toolkit: {
8
+ API: {
9
+ createRecord(tableSetName: string, data: object): Promise<string>;
10
+ getRecord<T>(tableSetName: string, recordID: string, selectColumns?: string): Promise<T>;
11
+ getMultiple(tableSetName: string, queryParameters?: string): Promise<Array<object>>;
12
+ updateRecord(tableSetName: string, recordId: string, data: object): Promise<any>;
13
+ };
14
+ createRef: typeof createRef;
15
+ waitFor: typeof waitFor;
16
+ bindForm: typeof bindForm;
17
+ };
18
+ export default toolkit;
package/package.json CHANGED
@@ -1,9 +1,46 @@
1
1
  {
2
2
  "name": "powerpagestoolkit",
3
- "version": "2.7.1211",
3
+ "version": "2.7.1401",
4
4
  "description": "Reference, manipulate, and engage with Power Pages sites through the nodes in the DOM; use a variety of custom methods that allow customizing your power pages site quicker and easier. ",
5
5
  "main": "./dist/bundle.js",
6
- "types": "./dist/index.d.ts",
6
+ "module": "./dist/bundle.js",
7
+ "types": "./dist/types/index.d.ts",
8
+ "typesVersions": {
9
+ "*": {
10
+ "*": [
11
+ "./dist/types/*"
12
+ ]
13
+ }
14
+ },
15
+ "unpkg": "./dist/bundle.js",
16
+ "jsdelivr": "./dist/bundle.js",
17
+ "browser": "./dist/bundle.js",
18
+ "author": "KeatonBrewster",
19
+ "license": "AGPL-3.0-only",
20
+ "type": "module",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/Keaton-Brewster/PowerPagesToolKit"
24
+ },
25
+ "files": [
26
+ "dist/bundle.js",
27
+ "dist/bundle.css",
28
+ "dist/types/**/*.d.ts",
29
+ "assets/**"
30
+ ],
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/types/index.d.ts",
34
+ "import": "./dist/bundle.js"
35
+ },
36
+ "./createDOMNodeReference": {
37
+ "import": "./dist/createDOMNodeReference.js",
38
+ "types": "./dist/createDOMNodeReference.d.ts"
39
+ },
40
+ "./style.css": {
41
+ "import": "./dist/bundle.css"
42
+ }
43
+ },
7
44
  "scripts": {
8
45
  "typecheck": "tsc",
9
46
  "node:build": "node build.js",
@@ -17,7 +54,7 @@
17
54
  "@types/node": "^22.8.6",
18
55
  "@typescript-eslint/parser": "^8.20.0",
19
56
  "css-loader": "^7.1.2",
20
- "esbuild": "^0.24.0",
57
+ "esbuild": "^0.24.2",
21
58
  "esbuild-css-modules-plugin": "^3.1.2",
22
59
  "eslint": "^8.57.1",
23
60
  "eslint-plugin-import": "^2.31.0",
@@ -27,13 +64,6 @@
27
64
  "typescript": "^5.6.3",
28
65
  "typescript-eslint": "^8.12.2"
29
66
  },
30
- "author": "KeatonBrewster",
31
- "license": "AGPL-3.0-only",
32
- "type": "module",
33
- "repository": {
34
- "type": "git",
35
- "url": "https://github.com/Keaton-Brewster/PowerPagesToolKit"
36
- },
37
67
  "keywords": [
38
68
  "powerpages",
39
69
  "power pages",
@@ -56,24 +86,5 @@
56
86
  "form-management",
57
87
  "frontend",
58
88
  "web-development"
59
- ],
60
- "files": [
61
- "dist/bundle.js",
62
- "dist/bundle.css",
63
- "dist/types/**/*.d.ts",
64
- "assets/**"
65
- ],
66
- "exports": {
67
- ".": {
68
- "import": "./dist/bundle.js",
69
- "types": "./dist/types/index.d.ts"
70
- },
71
- "./createDOMNodeReference": {
72
- "import": "./dist/createDOMNodeReference.js",
73
- "types": "./dist/createDOMNodeReference.d.ts"
74
- },
75
- "./style.css": {
76
- "import": "./dist/bundle.css"
77
- }
78
- }
89
+ ]
79
90
  }
File without changes