@nomos-ui/tanstack-router-adapter 0.0.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 ADDED
@@ -0,0 +1,5 @@
1
+ # Nomos UI Layout
2
+
3
+ > **νόμος** (nomos) - Greek: law, order, principle
4
+
5
+ Beautiful, validated form components that integrate seamlessly with React Hook Form. Built on the principle that forms should enforce order and validation effortlessly.
@@ -0,0 +1,3 @@
1
+ import { TanstackRouterAdapter } from "..";
2
+ export { TanstackRouterAdapter };
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,IAAI,CAAC;AAE3C,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TanstackRouterAdapter = void 0;
4
+ const __1 = require("..");
5
+ Object.defineProperty(exports, "TanstackRouterAdapter", { enumerable: true, get: function () { return __1.TanstackRouterAdapter; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":";;;AAAA,0BAA2C;AAElC,sGAFA,yBAAqB,OAEA"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Returns a function to update search params while preserving existing ones.
3
+ * Wraps TanStack Router's `useNavigate` to match the `RouterAdapter` contract.
4
+ *
5
+ * @returns A function that accepts an array of `{ name, value }` pairs to set
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const updateSearchParams = useUpdateSearchParams();
10
+ * updateSearchParams([{ name: "page", value: "2" }]);
11
+ * ```
12
+ */
13
+ export declare function useUpdateSearchParams(): (fields: {
14
+ name: string;
15
+ value: string;
16
+ }[]) => void;
17
+ //# sourceMappingURL=use-update-search-params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-update-search-params.d.ts","sourceRoot":"","sources":["../../src/hooks/use-update-search-params.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,KAElB,QAAQ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,UAS3D"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useUpdateSearchParams = useUpdateSearchParams;
4
+ const react_router_1 = require("@tanstack/react-router");
5
+ /**
6
+ * Returns a function to update search params while preserving existing ones.
7
+ * Wraps TanStack Router's `useNavigate` to match the `RouterAdapter` contract.
8
+ *
9
+ * @returns A function that accepts an array of `{ name, value }` pairs to set
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const updateSearchParams = useUpdateSearchParams();
14
+ * updateSearchParams([{ name: "page", value: "2" }]);
15
+ * ```
16
+ */
17
+ function useUpdateSearchParams() {
18
+ const navigate = (0, react_router_1.useNavigate)();
19
+ return function (fields) {
20
+ navigate({
21
+ search: (prev) => {
22
+ const next = { ...prev };
23
+ fields.forEach((field) => (next[field.name] = field.value));
24
+ return next;
25
+ },
26
+ });
27
+ };
28
+ }
29
+ //# sourceMappingURL=use-update-search-params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-update-search-params.js","sourceRoot":"","sources":["../../src/hooks/use-update-search-params.ts"],"names":[],"mappings":";;AAcA,sDAWC;AAzBD,yDAAqD;AAErD;;;;;;;;;;;GAWG;AACH,SAAgB,qBAAqB;IACnC,MAAM,QAAQ,GAAG,IAAA,0BAAW,GAAE,CAAC;IAC/B,OAAO,UAAU,MAAyC;QACxD,QAAQ,CAAC;YACP,MAAM,EAAE,CAAC,IAAyB,EAAE,EAAE;gBACpC,MAAM,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;gBACzB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC5D,OAAO,IAAI,CAAC;YACd,CAAC;SACK,CAAC,CAAC;IACZ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { RouterAdapter } from "@nomos-ui/core";
2
+ /**
3
+ * TanStack Router adapter for `@nomos-ui/core` Provider.
4
+ * Implements the `RouterAdapter` contract using TanStack Router hooks and components.
5
+ *
6
+ * Pass this to the `adapter` prop of the Provider to enable routing support
7
+ * in all `@nomos-ui` components when using TanStack Router.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * import { TanstackRouterAdapter } from "@nomos-ui/tanstack-router-adapter";
12
+ *
13
+ * <Provider queryLibrary="tanstack-query" adapters={{ core: TanstackRouterAdapter }}>
14
+ * <App />
15
+ * </Provider>
16
+ * ```
17
+ */
18
+ export declare const TanstackRouterAdapter: RouterAdapter;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAyC/C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAOnC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TanstackRouterAdapter = void 0;
4
+ const react_router_1 = require("@tanstack/react-router");
5
+ const use_update_search_params_1 = require("./hooks/use-update-search-params");
6
+ /**
7
+ * Returns a normalized search params object with a `.get()` interface.
8
+ * Wraps TanStack Router's `useSearch` to match the `RouterAdapter` contract.
9
+ *
10
+ * @returns An object with a `get` method to read search params by key
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const searchParams = useSearchParams();
15
+ * searchParams.get("page"); // "1"
16
+ * ```
17
+ */
18
+ function useSearchParams() {
19
+ const search = (0, react_router_1.useSearch)({ strict: false });
20
+ return {
21
+ get: (key) => search[key] ?? null,
22
+ };
23
+ }
24
+ /**
25
+ * Returns a normalized route params object with a `.get()` interface.
26
+ * Wraps TanStack Router's `useParams` to match the `RouterAdapter` contract.
27
+ *
28
+ * @returns An object with a `get` method to read route params by key
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const params = useParams();
33
+ * params.get("id"); // "648339adsf043c8ed"
34
+ * ```
35
+ */
36
+ function useParams() {
37
+ const params = (0, react_router_1.useParams)({ strict: false });
38
+ return {
39
+ get: (key) => params[key] ?? null,
40
+ };
41
+ }
42
+ /**
43
+ * TanStack Router adapter for `@nomos-ui/core` Provider.
44
+ * Implements the `RouterAdapter` contract using TanStack Router hooks and components.
45
+ *
46
+ * Pass this to the `adapter` prop of the Provider to enable routing support
47
+ * in all `@nomos-ui` components when using TanStack Router.
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * import { TanstackRouterAdapter } from "@nomos-ui/tanstack-router-adapter";
52
+ *
53
+ * <Provider queryLibrary="tanstack-query" adapters={{ core: TanstackRouterAdapter }}>
54
+ * <App />
55
+ * </Provider>
56
+ * ```
57
+ */
58
+ exports.TanstackRouterAdapter = {
59
+ useSearchParams,
60
+ useUpdateSearchParams: use_update_search_params_1.useUpdateSearchParams,
61
+ useParams,
62
+ components: {
63
+ Link: { component: react_router_1.Link, hrefKey: "to" },
64
+ },
65
+ };
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yDAIgC;AAEhC,+EAAyE;AAEzE;;;;;;;;;;;GAWG;AACH,SAAS,eAAe;IACtB,MAAM,MAAM,GAAG,IAAA,wBAAS,EAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAwB,CAAC;IACnE,OAAO;QACL,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI;KAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,SAAS;IAChB,MAAM,MAAM,GAAG,IAAA,wBAAiB,EAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAwB,CAAC;IAC3E,OAAO;QACL,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI;KAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACU,QAAA,qBAAqB,GAAkB;IAClD,eAAe;IACf,qBAAqB,EAArB,gDAAqB;IACrB,SAAS;IACT,UAAU,EAAE;QACV,IAAI,EAAE,EAAE,SAAS,EAAE,mBAAI,EAAE,OAAO,EAAE,IAAI,EAAE;KACzC;CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,110 @@
1
+ {
2
+ "name": "@nomos-ui/tanstack-router-adapter",
3
+ "version": "0.0.1",
4
+ "description": "The Shadcn library for building robust React layouts",
5
+ "main": "dist/index.js",
6
+ "module": "dist/exports/index.js",
7
+ "types": "dist/exports/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/exports/index.d.ts",
11
+ "import": "./dist/exports/index.js",
12
+ "require": "./dist/exports/index.js"
13
+ }
14
+ },
15
+ "typesVersions": {
16
+ "*": {
17
+ "types": [
18
+ "./dist/exports/index.d.ts"
19
+ ]
20
+ }
21
+ },
22
+ "scripts": {
23
+ "build": "trash dist && tsc",
24
+ "dev": "tsc --watch",
25
+ "clean": "rm -rf dist",
26
+ "lint": "eslint src --ext .ts,.tsx",
27
+ "type-check": "tsc --noEmit",
28
+ "test": "vitest",
29
+ "test:watch": "vitest --watch",
30
+ "test:ui": "vitest --ui",
31
+ "test:coverage": "vitest --coverage",
32
+ "prepublishOnly": "pnpm run build"
33
+ },
34
+ "keywords": [
35
+ "react",
36
+ "react-hook-form",
37
+ "form",
38
+ "forms",
39
+ "validation",
40
+ "components",
41
+ "ui",
42
+ "input",
43
+ "select",
44
+ "checkbox",
45
+ "accessible",
46
+ "a11y",
47
+ "tailwind",
48
+ "typescript",
49
+ "nomos"
50
+ ],
51
+ "author": "Uanela Como",
52
+ "license": "MIT",
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/uanela/nomos-ui.git",
56
+ "directory": "packages/layout"
57
+ },
58
+ "bugs": {
59
+ "url": "https://github.com/uanela/nomos-ui/issues"
60
+ },
61
+ "homepage": "https://github.com/uanela/nomos-ui",
62
+ "files": [
63
+ "dist",
64
+ "README.md",
65
+ "LICENSE"
66
+ ],
67
+ "sideEffects": false,
68
+ "packageManager": "pnpm@10.13.1",
69
+ "dependencies": {
70
+ "@nomos-ui/core": "^0.2.0",
71
+ "@tanstack/react-router": "^1.163.3"
72
+ },
73
+ "devDependencies": {
74
+ "@types/node": "^24.9.1",
75
+ "@types/react": "^19.2.2",
76
+ "@types/react-dom": "^19.2.0",
77
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
78
+ "@typescript-eslint/parser": "^6.0.0",
79
+ "eslint": "^8.56.0",
80
+ "eslint-plugin-react": "^7.33.2",
81
+ "eslint-plugin-react-hooks": "^4.6.0",
82
+ "tailwindcss": "^4.1.16",
83
+ "trash-cli": "^7.0.0",
84
+ "tsx": "^4.20.3",
85
+ "typescript": "^5.9.3",
86
+ "vitest": "^4.0.3"
87
+ },
88
+ "peerDependencies": {
89
+ "next": "^15.5.12 || ^16.1.6",
90
+ "react": "^18.0.0 || ^19.0.0",
91
+ "react-dom": "^18.0.0 || ^19.0.0"
92
+ },
93
+ "peerDependenciesMeta": {
94
+ "react": {
95
+ "optional": false
96
+ },
97
+ "react-dom": {
98
+ "optional": false
99
+ },
100
+ "react-hook-form": {
101
+ "optional": false
102
+ }
103
+ },
104
+ "engines": {
105
+ "node": ">=18.0.0"
106
+ },
107
+ "publishConfig": {
108
+ "access": "public"
109
+ }
110
+ }