@paragrav/rhf-utils 0.0.88 → 0.0.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,23 @@
1
- import o from "./FormNonFieldErrorMarkerHtmlAttribute.mjs";
2
- const t = (r) => `[role="alert"][${o}="${r}"]`, i = (r, e) => !!e.querySelector(t(r));
1
+ import l from "./FormNonFieldErrorMarkerHtmlAttribute.mjs";
2
+ const m = (r, e) => (
3
+ // list of selector variants
4
+ [
5
+ // equals
6
+ // e.g., attr="path"
7
+ ["", ""],
8
+ [
9
+ // @see https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors#attrvalue_4
10
+ "^",
11
+ // only match nested (avoid match 'field' with 'field1`)
12
+ "."
13
+ ]
14
+ ].map(
15
+ ([o, t]) => n(
16
+ l + o,
17
+ r + t
18
+ )
19
+ ).join(", ")
20
+ ), n = (r, e) => `[role="alert"][${r}="${e}"]`;
3
21
  export {
4
- t as getFormNonFieldErrorMarkerQuerySelector,
5
- i as isNonFieldErrorMarkerInDOM
22
+ m as getFormNonFieldErrorMarkerQuerySelector
6
23
  };
@@ -0,0 +1,5 @@
1
+ import { getFormNonFieldErrorMarkerQuerySelector as o } from "./FormNonFieldErrorMarker.utils.mjs";
2
+ const i = (r, e) => !!e.querySelector(o(r));
3
+ export {
4
+ i as isNonFieldErrorMarkerInDOM
5
+ };
@@ -1,10 +1,10 @@
1
1
  import m from "../isFieldErrorRefd.mjs";
2
- import { isNonFieldErrorMarkerInDOM as t } from "../nonfield/FormNonFieldErrorMarker.utils.mjs";
2
+ import { isNonFieldErrorMarkerInDOM as t } from "../nonfield/isNonFieldErrorMarkerInDOM.mjs";
3
3
  import e from "../root/isFormErrorPathRoot.mjs";
4
4
  const d = (r, o, i) => (
5
5
  // not root path
6
6
  !e(r) && // non-field
7
- !m(o) && // does not have marker
7
+ !m(o) && // not marked in DOM
8
8
  !t(r, i)
9
9
  );
10
10
  export {
@@ -1,2 +1,16 @@
1
- export declare const getFormNonFieldErrorMarkerQuerySelector: (path: string) => string;
2
- export declare const isNonFieldErrorMarkerInDOM: (path: string, parentElement: Pick<HTMLElement, 'querySelector'>) => boolean;
1
+ /**
2
+ * Returns query selector for matching non-field error marker.
3
+ * By default includes nested field matching. (See `options.excludeNested`.)
4
+ *
5
+ * @returns One or more selectors in a comma-separated list.
6
+ */
7
+ export declare const getFormNonFieldErrorMarkerQuerySelector: (path: string, options?: {
8
+ /**
9
+ * Do not look for match as nested field.
10
+ *
11
+ * By default this is enabled to facilitate looking for fields that may be nested inside objects.
12
+ * For example, field arrays require objects as items, so actual field may be `field.value`.
13
+ * This should be safe, as fields are by definition leaf nodes, so will not have nested fields.
14
+ */
15
+ excludeNested?: boolean;
16
+ }) => string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Determine if a non-field error marker is in the DOM.
3
+ * Note: this will also look for nested markers to accommodate field arrays
4
+ */
5
+ export declare const isNonFieldErrorMarkerInDOM: (path: string, parentElement: Pick<HTMLElement, 'querySelector'>) => boolean;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@paragrav/rhf-utils",
3
3
  "author": "paragrav.dev",
4
4
  "license": "MIT",
5
- "version": "0.0.88",
5
+ "version": "0.0.90",
6
6
  "description": "Integration utilities for react-hook-form.",
7
7
  "type": "module",
8
8
  "sideEffects": false,
@@ -34,39 +34,6 @@
34
34
  "react-hook-form": "7",
35
35
  "zod": "3"
36
36
  },
37
- "devDependencies": {
38
- "@playwright/experimental-ct-react": "^1.44.0",
39
- "@playwright/test": "^1.44.0",
40
- "@rollup/plugin-typescript": "^11.1.6",
41
- "@types/node": "^20.12.11",
42
- "@types/react": "^18.3.1",
43
- "@types/react-dom": "^18.3.0",
44
- "@typescript-eslint/eslint-plugin": "^7.8.0",
45
- "@typescript-eslint/parser": "^7.8.0",
46
- "@vitejs/plugin-react": "^4.2.1",
47
- "cross-env": "^7.0.3",
48
- "eslint": "^8.57.0",
49
- "eslint-config-prettier": "^9.1.0",
50
- "eslint-import-resolver-typescript": "^3.6.1",
51
- "eslint-plugin-import": "^2.29.1",
52
- "eslint-plugin-react": "^7.34.1",
53
- "eslint-plugin-react-hooks": "^4.6.2",
54
- "eslint-plugin-simple-import-sort": "^12.1.0",
55
- "happy-dom": "^14.10.1",
56
- "husky": "^9.0.11",
57
- "lint-staged": "^15.2.2",
58
- "prettier": "^3.2.5",
59
- "rollup": "^4.17.2",
60
- "typescript": "^5.4.5",
61
- "vite": "^5.2.11",
62
- "vite-plugin-dts": "^3.9.1",
63
- "vite-tsconfig-paths": "^4.3.2",
64
- "vitest": "^1.6.0"
65
- },
66
- "engines": {
67
- "node": ">=20.12",
68
- "pnpm": ">=9.0.6"
69
- },
70
37
  "repository": {
71
38
  "type": "git",
72
39
  "url": "git+https://github.com/paragrav/rhf-utils.git"
@@ -84,18 +51,5 @@
84
51
  "utilities",
85
52
  "utils",
86
53
  "zod"
87
- ],
88
- "scripts": {
89
- "build": "vite build",
90
- "build:dev": "vite build --config vite.config.dev.ts",
91
- "dev": "vite --config vite.config.dev.ts",
92
- "lint": "eslint --ignore-path ./.gitignore --ext ts,tsx --report-unused-disable-directives --max-warnings 0 .",
93
- "preinstall": "npx only-allow pnpm",
94
- "preview": "vite preview --config vite.config.dev.ts",
95
- "test": "vitest run",
96
- "test:ct": "playwright test -c playwright-ct.config.ts",
97
- "test:ct:ui": "playwright test -c playwright-ct.config.ts --ui",
98
- "tsc": "tsc",
99
- "validate": "cross-env CI=1 pnpm install && pnpm tsc & pnpm lint & pnpm test && pnpm test:ct"
100
- }
54
+ ]
101
55
  }