wcz-layout 10.1.0 → 10.1.2

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.
Files changed (54) hide show
  1. package/dist/AggregatedCell-C7nAQyMO.mjs.map +1 -1
  2. package/dist/{Approval-C-hF4jbT.mjs → Approval-DoD-GRRH.mjs} +18 -14
  3. package/dist/Approval-DoD-GRRH.mjs.map +1 -0
  4. package/dist/{Employee-DbdStvU0.d.mts → Employee-N9fRSnIl.d.mts} +30 -14
  5. package/dist/FileMeta-DDqUju1Y.mjs.map +1 -1
  6. package/dist/{LayoutTable-BkrjgpW_.d.mts → LayoutTable-DX9IaO8V.d.mts} +196 -194
  7. package/dist/RouterListItemButton-ULMlaQh6.mjs.map +1 -1
  8. package/dist/{approval-BYryxFOW.mjs → approval-DiNOXd4B.mjs} +3 -3
  9. package/dist/approval-DiNOXd4B.mjs.map +1 -0
  10. package/dist/components.d.mts +1 -1
  11. package/dist/components.mjs.map +1 -1
  12. package/dist/data/client.d.mts +183 -28
  13. package/dist/data/client.mjs +2 -2
  14. package/dist/data/client.mjs.map +1 -1
  15. package/dist/data/server.d.mts +1 -1
  16. package/dist/data/server.mjs +1 -1
  17. package/dist/file-C5BOj1q8.mjs.map +1 -1
  18. package/dist/hooks.d.mts +1 -1
  19. package/dist/hooks.mjs +7 -7
  20. package/dist/hooks.mjs.map +1 -1
  21. package/dist/index.mjs +2 -2
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/middleware.mjs.map +1 -1
  24. package/dist/models.d.mts +22 -2
  25. package/dist/models.mjs +1 -1
  26. package/dist/{peoplesoft-BY_75WTS.d.mts → peoplesoft-BIdTNshE.d.mts} +2 -3
  27. package/dist/peoplesoft-BkJMCcHb.mjs.map +1 -1
  28. package/dist/providers-DrairEO2.mjs.map +1 -1
  29. package/dist/tokens-BLRreL1j.mjs.map +1 -1
  30. package/dist/utils-BUpDoqme.mjs.map +1 -1
  31. package/package.json +130 -130
  32. package/skills/ai/SKILL.md +59 -0
  33. package/skills/client-db/SKILL.md +47 -43
  34. package/skills/db-schema/SKILL.md +6 -0
  35. package/skills/dialogs/SKILL.md +8 -6
  36. package/skills/forms/SKILL.md +19 -1
  37. package/skills/general/SKILL.md +127 -122
  38. package/skills/general/references/exports.md +6 -3
  39. package/skills/migrations/versions/migrate-v10-to-v11.md +1 -0
  40. package/skills/migrations/versions/migrate-v9-to-v10.md +23 -23
  41. package/skills/routing/SKILL.md +7 -4
  42. package/skills/server-functions/SKILL.md +8 -5
  43. package/skills/services/SKILL.md +1 -1
  44. package/skills/services/docs/approval.md +258 -257
  45. package/skills/services/docs/peoplesoft.md +114 -114
  46. package/skills/start/SKILL.md +3 -2
  47. package/skills/start/steps/02-project-name-setup.md +1 -1
  48. package/skills/start/steps/07-vault-setup.md +5 -4
  49. package/skills/table/SKILL.md +2 -1
  50. package/dist/Approval-C-hF4jbT.mjs.map +0 -1
  51. package/dist/approval-BYryxFOW.mjs.map +0 -1
  52. package/skills/unslop/SKILL.md +0 -80
  53. /package/skills/start/steps/{10-gitlab-ci.md → 09-gitlab-ci.md} +0 -0
  54. /package/skills/start/steps/{09-commit.md → 10-commit.md} +0 -0
package/package.json CHANGED
@@ -1,130 +1,130 @@
1
- {
2
- "name": "wcz-layout",
3
- "version": "10.1.0",
4
- "private": false,
5
- "keywords": [
6
- "tanstack-intent"
7
- ],
8
- "repository": {
9
- "type": "git",
10
- "url": "https://gitlab.wistron.com/wcz/it-developers/layout/tanstack.git"
11
- },
12
- "files": [
13
- "dist",
14
- "skills",
15
- "!skills/_artifacts"
16
- ],
17
- "type": "module",
18
- "sideEffects": [
19
- "./dist/index.mjs"
20
- ],
21
- "exports": {
22
- "./package.json": "./package.json",
23
- ".": {
24
- "types": "./dist/index.d.mts",
25
- "import": "./dist/index.mjs"
26
- },
27
- "./components": {
28
- "types": "./dist/components.d.mts",
29
- "import": "./dist/components.mjs"
30
- },
31
- "./hooks": {
32
- "types": "./dist/hooks.d.mts",
33
- "import": "./dist/hooks.mjs"
34
- },
35
- "./middleware": {
36
- "types": "./dist/middleware.d.mts",
37
- "import": "./dist/middleware.mjs"
38
- },
39
- "./models": {
40
- "types": "./dist/models.d.mts",
41
- "import": "./dist/models.mjs"
42
- },
43
- "./data/client": {
44
- "types": "./dist/data/client.d.mts",
45
- "import": "./dist/data/client.mjs"
46
- },
47
- "./data/server": {
48
- "types": "./dist/data/server.d.mts",
49
- "import": "./dist/data/server.mjs"
50
- },
51
- "./utils": {
52
- "types": "./dist/utils.d.mts",
53
- "import": "./dist/utils.mjs"
54
- },
55
- "./auth": {
56
- "types": "./dist/auth.d.mts",
57
- "import": "./dist/auth.mjs"
58
- },
59
- "./vite": {
60
- "types": "./dist/vite.d.mts",
61
- "import": "./dist/vite.mjs"
62
- }
63
- },
64
- "scripts": {
65
- "dev": "vp dev",
66
- "typecheck": "tsc --noEmit --watch --preserveWatchOutput",
67
- "build": "vp pack",
68
- "prepublishOnly": "npm run build"
69
- },
70
- "dependencies": {
71
- "@t3-oss/env-core": "^0.13.11",
72
- "i18next": "^26.4.2",
73
- "i18next-browser-languagedetector": "^8.2.1",
74
- "jose": "^6.2.12",
75
- "react-dropzone": "^20.1.2",
76
- "react-i18next": "^17.0.14",
77
- "react-intersection-observer": "^11.0.1",
78
- "react-number-format": "^5.4.5",
79
- "tus-js-client": "^4.3.1",
80
- "uuidv7": "^1.2.1"
81
- },
82
- "devDependencies": {
83
- "@arethetypeswrong/core": "^0.18.5",
84
- "@rolldown/plugin-babel": "^0.2.4",
85
- "@tanstack/ai": "^0.55.0",
86
- "@tanstack/ai-client": "^0.32.1",
87
- "@tanstack/ai-openai": "^0.22.8",
88
- "@tanstack/highlight": "^0.1.0",
89
- "@tanstack/intent": "^0.4.0",
90
- "@tanstack/react-pacer": "^0.23.0",
91
- "@types/node": "^24.10.13",
92
- "@types/react": "^19.3.0",
93
- "@types/react-dom": "^19.3.0",
94
- "@vitejs/plugin-react": "^6.1.1",
95
- "babel-plugin-react-compiler": "^1.0.0",
96
- "nitro": "npm:nitro-nightly@latest",
97
- "publint": "^0.3.24",
98
- "typescript": "^7.0.2",
99
- "vite": "npm:@voidzero-dev/vite-plus-core@0.3.3",
100
- "vite-plus": "0.3.3"
101
- },
102
- "peerDependencies": {
103
- "@emotion/cache": "11.x",
104
- "@emotion/react": "11.x",
105
- "@emotion/styled": "11.x",
106
- "@mui/icons-material": "9.x",
107
- "@mui/material": "9.x",
108
- "@mui/x-date-pickers": "9.x",
109
- "@tanstack/query-db-collection": "1.x",
110
- "@tanstack/react-db": "0.x",
111
- "@tanstack/react-form": "1.x",
112
- "@tanstack/react-hotkeys": "0.x",
113
- "@tanstack/react-pacer": "0.x",
114
- "@tanstack/react-query": "5.x",
115
- "@tanstack/react-router": "1.x",
116
- "@tanstack/react-router-ssr-query": "1.x",
117
- "@tanstack/react-start": "1.x",
118
- "@tanstack/react-table": "9.x",
119
- "@tanstack/react-virtual": "3.x",
120
- "axios": "1.x",
121
- "dayjs": "1.x",
122
- "react": "19.x",
123
- "react-dom": "19.x",
124
- "zod": "4.x"
125
- },
126
- "overrides": {
127
- "vite": "npm:@voidzero-dev/vite-plus-core@0.3.3"
128
- },
129
- "packageManager": "npm@12.0.2"
130
- }
1
+ {
2
+ "name": "wcz-layout",
3
+ "version": "10.1.2",
4
+ "private": false,
5
+ "keywords": [
6
+ "tanstack-intent"
7
+ ],
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://gitlab.wistron.com/wcz/it-developers/layout/tanstack.git"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "skills",
15
+ "!skills/_artifacts"
16
+ ],
17
+ "type": "module",
18
+ "sideEffects": [
19
+ "./dist/index.mjs"
20
+ ],
21
+ "exports": {
22
+ "./package.json": "./package.json",
23
+ ".": {
24
+ "types": "./dist/index.d.mts",
25
+ "import": "./dist/index.mjs"
26
+ },
27
+ "./components": {
28
+ "types": "./dist/components.d.mts",
29
+ "import": "./dist/components.mjs"
30
+ },
31
+ "./hooks": {
32
+ "types": "./dist/hooks.d.mts",
33
+ "import": "./dist/hooks.mjs"
34
+ },
35
+ "./middleware": {
36
+ "types": "./dist/middleware.d.mts",
37
+ "import": "./dist/middleware.mjs"
38
+ },
39
+ "./models": {
40
+ "types": "./dist/models.d.mts",
41
+ "import": "./dist/models.mjs"
42
+ },
43
+ "./data/client": {
44
+ "types": "./dist/data/client.d.mts",
45
+ "import": "./dist/data/client.mjs"
46
+ },
47
+ "./data/server": {
48
+ "types": "./dist/data/server.d.mts",
49
+ "import": "./dist/data/server.mjs"
50
+ },
51
+ "./utils": {
52
+ "types": "./dist/utils.d.mts",
53
+ "import": "./dist/utils.mjs"
54
+ },
55
+ "./auth": {
56
+ "types": "./dist/auth.d.mts",
57
+ "import": "./dist/auth.mjs"
58
+ },
59
+ "./vite": {
60
+ "types": "./dist/vite.d.mts",
61
+ "import": "./dist/vite.mjs"
62
+ }
63
+ },
64
+ "scripts": {
65
+ "dev": "vp dev",
66
+ "typecheck": "tsc --noEmit --watch --preserveWatchOutput",
67
+ "build": "vp pack",
68
+ "prepublishOnly": "npm run build"
69
+ },
70
+ "dependencies": {
71
+ "@t3-oss/env-core": "^0.13.11",
72
+ "i18next": "^26.4.2",
73
+ "i18next-browser-languagedetector": "^8.2.1",
74
+ "jose": "^6.2.12",
75
+ "react-dropzone": "^20.1.2",
76
+ "react-i18next": "^17.0.16",
77
+ "react-intersection-observer": "^11.0.1",
78
+ "react-number-format": "^5.4.5",
79
+ "tus-js-client": "^4.3.1",
80
+ "uuidv7": "^1.2.1"
81
+ },
82
+ "devDependencies": {
83
+ "@arethetypeswrong/core": "^0.18.5",
84
+ "@rolldown/plugin-babel": "^0.2.4",
85
+ "@tanstack/ai": "^0.65.1",
86
+ "@tanstack/ai-client": "^0.38.0",
87
+ "@tanstack/ai-openai": "^0.27.0",
88
+ "@tanstack/highlight": "^1.0.0",
89
+ "@tanstack/intent": "^0.5.5",
90
+ "@tanstack/react-pacer": "^0.24.1",
91
+ "@types/node": "^24.10.13",
92
+ "@types/react": "^19.3.0",
93
+ "@types/react-dom": "^19.3.0",
94
+ "@vitejs/plugin-react": "^6.1.2",
95
+ "babel-plugin-react-compiler": "^1.0.0",
96
+ "nitro": "npm:nitro-nightly@latest",
97
+ "publint": "^0.3.25",
98
+ "typescript": "^7.0.2",
99
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.1.0",
100
+ "vite-plus": "1.1.0"
101
+ },
102
+ "peerDependencies": {
103
+ "@emotion/cache": "11.x",
104
+ "@emotion/react": "11.x",
105
+ "@emotion/styled": "11.x",
106
+ "@mui/icons-material": "9.x",
107
+ "@mui/material": "9.x",
108
+ "@mui/x-date-pickers": "9.x",
109
+ "@tanstack/query-db-collection": "1.x",
110
+ "@tanstack/react-db": "0.x",
111
+ "@tanstack/react-form": "1.x",
112
+ "@tanstack/react-hotkeys": "0.x",
113
+ "@tanstack/react-pacer": "0.x",
114
+ "@tanstack/react-query": "5.x",
115
+ "@tanstack/react-router": "1.x",
116
+ "@tanstack/react-router-ssr-query": "1.x",
117
+ "@tanstack/react-start": "1.x",
118
+ "@tanstack/react-table": "9.x",
119
+ "@tanstack/react-virtual": "3.x",
120
+ "axios": "1.x",
121
+ "dayjs": "1.x",
122
+ "react": "19.x",
123
+ "react-dom": "19.x",
124
+ "zod": "4.x"
125
+ },
126
+ "overrides": {
127
+ "vite": "$vite"
128
+ },
129
+ "packageManager": "npm@12.2.0"
130
+ }
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: ai
3
+ description: "Use when adding LLM features (chat, streamed text, structured output, tools, media generation)"
4
+ metadata:
5
+ type: convention
6
+ library: wcz-layout
7
+ ---
8
+
9
+ > Mechanics are covered by TanStack's own `@tanstack/ai` skills.
10
+ > This skill adds the wcz-layout conventions on top of that.
11
+
12
+ ## Rules
13
+
14
+ - The gateway needs three server-side inputs:
15
+ - Ensure that required env are present: `AI_BASE_URL` (`z.url()`) and `AI_SUBSCRIPTION_KEY` (`z.string()`) in `src/env.ts`.
16
+ - Ensure that `cognitiveServices: "https://cognitiveservices.azure.com/.default"` is added to
17
+ `src/lib/auth/scopes.ts` and pass `getAppToken("cognitiveServices")` as the API key.
18
+ - The subscription key sent as the `Ocp-Apim-Subscription-Key` header.
19
+ - Build the adapter in one place, `src/server/ai.ts`, and call it per request. `getAppToken`
20
+ caches and refreshes the token.
21
+ - Use server functions, not `/api/chat` routes (overrides the upstream examples). `useChat` and the
22
+ generation hooks take `fetcher` instead of `connection`; the server function returns
23
+ `toServerSentEventsResponse(...)`. Add an `api/` route only when a public API is required.
24
+ - Stream everything a user waits on. Use `useChat` for conversations and generation hooks for
25
+ media. For a typed result, combine `outputSchema` and `stream: true` with
26
+ `useChat({ fetcher, outputSchema })`, render `partial` as it fills in.
27
+ - Render chat text with `@tanstack/markdown` (install if missing): `<Markdown>` from
28
+ `@tanstack/markdown/react` with `extensions={[streamingMarkdownExtension()]}` from
29
+ `@tanstack/markdown/extensions/streaming`.
30
+
31
+ ## Example
32
+
33
+ ```ts
34
+ // src/server/ai.ts
35
+ import { createOpenaiChat } from "@tanstack/ai-openai";
36
+ import { getAppToken } from "wcz-layout/auth";
37
+ import { serverEnv } from "~/env";
38
+
39
+ export const aiText = async () =>
40
+ createOpenaiChat("gpt-5.5", await getAppToken("cognitiveServices"), {
41
+ baseURL: serverEnv.AI_BASE_URL,
42
+ defaultHeaders: { "Ocp-Apim-Subscription-Key": serverEnv.AI_SUBSCRIPTION_KEY },
43
+ });
44
+
45
+ // src/server/actions/chat.ts
46
+ export const chatFn = createServerFn({ method: "POST" })
47
+ .validator(z.object({ messages: z.array(z.custom<UIMessage>()) }))
48
+ .middleware([authMiddleware()])
49
+ .handler(async ({ data }) =>
50
+ toServerSentEventsResponse(
51
+ chat({ adapter: await aiText(), messages: data.messages, systemPrompts: [SYSTEM_PROMPT] }),
52
+ ),
53
+ );
54
+
55
+ // component
56
+ const { messages, sendMessage, isLoading, stop } = useChat({
57
+ fetcher: ({ messages }, { signal }) => chatFn({ data: { messages }, signal }),
58
+ });
59
+ ```
@@ -26,11 +26,15 @@ metadata:
26
26
  components.
27
27
  - Preload in the route loader and return the promise:
28
28
  `loader: ({ context }) => context.dbClient.preloadLiveQuery(<x>QueryOptions)`.
29
- This transports the query result. Explicit collection preload transports source rows
30
- and is a no-op for on-demand collections.
29
+ This transports the query result, so `useLiveQuery` has rows on the first render. Never
30
+ fire it with `void`: the server then renders an empty table and the browser fetches
31
+ again. Explicit collection preload transports source rows and is a no-op for on-demand
32
+ collections.
33
+ - A detail route awaits the preload, then throws `notFound()` when the row is missing,
34
+ and shows a skeleton `pendingComponent` meanwhile (see the example).
31
35
  - `useLiveQuery` for list pages, `useLiveSuspenseQuery` for detail components under
32
- suspense. Suspense data is initialized, but `.findOne()` still returns `T | undefined`;
33
- handle not-found explicitly.
36
+ suspense. `.findOne()` still returns `T | undefined` after the loader's check, so keep
37
+ an `if (!data) return null` guard.
34
38
  - Shape data in the query: filter, order, group and aggregate only the fields the
35
39
  consumer needs. Do not load broad results and transform them in component code.
36
40
  - Mutations go through `createOptimisticAction`: mirror the server write in `onMutate`,
@@ -39,24 +43,21 @@ metadata:
39
43
  Await `transaction.isPersisted.promise` at the call site and surface failures with
40
44
  `alert()`.
41
45
  - `syncMode: "eager"` for top-level collections, `"on-demand"` for child data and anything expected past ~10k rows.
42
- - Increment persisted `schemaVersion` whenever the row shape changes.
43
46
 
44
47
  ## Examples
45
48
 
46
49
  ```ts
47
50
  // src/db/collections/<table>.ts
48
- import { persistedCollectionOptions } from "@tanstack/browser-db-sqlite-persistence";
49
51
  import { queryCollectionOptions } from "@tanstack/query-db-collection";
50
52
  import { collectionOptions, useDbClient } from "@tanstack/react-db";
51
53
  import type { QueryClient } from "@tanstack/react-query";
52
- import { browserPersistence } from "../persistence";
53
54
  import { TodoSchema } from "~/lib/schemas/todo";
54
55
  import { selectTodos } from "~/server/actions/todo";
55
56
 
56
57
  const TODOS_ID = "todos";
57
58
 
58
- export const todoCollection = collectionOptions(TODOS_ID, (client) => {
59
- const options = queryCollectionOptions({
59
+ export const todoCollection = collectionOptions(TODOS_ID, (client) =>
60
+ queryCollectionOptions({
60
61
  id: TODOS_ID,
61
62
  queryKey: [TODOS_ID],
62
63
  queryFn: () => selectTodos(),
@@ -64,17 +65,8 @@ export const todoCollection = collectionOptions(TODOS_ID, (client) => {
64
65
  schema: TodoSchema,
65
66
  queryClient: client.requireDependency<QueryClient>("queryClient"),
66
67
  syncMode: "eager",
67
- });
68
-
69
- const persistence = browserPersistence();
70
- if (!persistence) return options;
71
-
72
- return persistedCollectionOptions({
73
- ...options,
74
- persistence,
75
- schemaVersion: 1, // Increment when the persisted row shape changes.
76
- }) as typeof options;
77
- });
68
+ }),
69
+ );
78
70
 
79
71
  export const useTodoCollection = () => useDbClient().collection(todoCollection);
80
72
  ```
@@ -100,33 +92,45 @@ export const todoByIdQueryOptions = (id: string) => ({
100
92
  ```
101
93
 
102
94
  ```tsx
103
- // route + component
95
+ // detail route: src/routes/todos/$id.tsx
104
96
  export const Route = createFileRoute("/todos/$id")({
97
+ component: RouteComponent,
98
+ pendingComponent: TodoSkeleton,
105
99
  beforeLoad: requireAuth("admin"),
106
- loader: ({ context, params }) =>
107
- context.dbClient.preloadLiveQuery(todoByIdQueryOptions(params.id)),
108
- });
109
-
110
- const { id } = Route.useParams();
111
- const todos = useTodoCollection();
112
- const { data } = useLiveSuspenseQuery(todoByIdQueryOptions(id));
113
-
114
- const handleOnDelete = createOptimisticAction<string>({
115
- onMutate: (id) => {
116
- todos.delete(id);
117
- },
118
- mutationFn: async (id) => {
119
- await deleteTodo({ data: { id } });
120
- await todos.utils.refetch({ throwOnError: true });
100
+ loader: async ({ context, params }) => {
101
+ await context.dbClient.preloadLiveQuery(todoByIdQueryOptions(params.id));
102
+ if (!context.dbClient.collection(todoCollection).has(params.id)) throw notFound();
121
103
  },
122
104
  });
123
105
 
124
- try {
125
- const transaction = handleOnDelete(id);
126
- await transaction.isPersisted.promise;
127
- } catch (error) {
128
- if (error instanceof Error) await alert(error.message);
129
- }
106
+ function RouteComponent() {
107
+ const { id } = Route.useParams();
108
+ const { alert } = useDialogs();
109
+ const navigate = useNavigate();
110
+ const todos = useTodoCollection();
111
+ const { data } = useLiveSuspenseQuery(todoByIdQueryOptions(id));
112
+
113
+ const handleOnDelete = createOptimisticAction<string>({
114
+ onMutate: (id) => {
115
+ todos.delete(id);
116
+ },
117
+ mutationFn: async (id) => {
118
+ await deleteTodos({ data: [id] });
119
+ await todos.utils.refetch({ throwOnError: true });
120
+ },
121
+ });
130
122
 
131
- if (!data) return null;
123
+ const handleDelete = async () => {
124
+ try {
125
+ const transaction = handleOnDelete(id);
126
+ await transaction.isPersisted.promise;
127
+ await navigate({ to: "/todos" });
128
+ } catch (error) {
129
+ if (error instanceof Error) await alert(error.message);
130
+ }
131
+ };
132
+
133
+ if (!data) return null;
134
+ // render data; call handleDelete from the delete button...
135
+ }
132
136
  ```
@@ -33,7 +33,9 @@ export const libraryTable = snakeCase.table("libraries", {
33
33
  id: uuid().primaryKey(),
34
34
  name: text().notNull(),
35
35
  });
36
+ ```
36
37
 
38
+ ```ts
37
39
  // src/server/db/schemas/book.ts
38
40
  import { index, pgEnum, snakeCase, text, timestamp, uuid } from "drizzle-orm/pg-core";
39
41
  import { libraryTable } from "./library";
@@ -53,7 +55,9 @@ export const bookTable = snakeCase.table(
53
55
  },
54
56
  (table) => [index().on(table.libraryId)],
55
57
  );
58
+ ```
56
59
 
60
+ ```ts
57
61
  // src/server/db/schemas/relations.ts
58
62
  import { defineRelations } from "drizzle-orm";
59
63
  import { bookTable } from "./book";
@@ -70,7 +74,9 @@ export const relations = defineRelations(
70
74
  },
71
75
  }),
72
76
  );
77
+ ```
73
78
 
79
+ ```ts
74
80
  // src/lib/schemas/<table>.ts
75
81
  import { createSelectSchema } from "drizzle-orm/zod";
76
82
  import { t } from "wcz-layout/utils";
@@ -22,14 +22,16 @@ metadata:
22
22
 
23
23
  ## Examples
24
24
 
25
- ```ts
25
+ ```tsx
26
26
  // confirmation dialog
27
27
  const { confirm } = useDialogs();
28
28
  const { t } = useTranslation();
29
29
 
30
30
  const confirmed = await confirm(t("DeleteConfirmation", { count: selectedIds.length }));
31
31
  if (confirmed) await deleteFeatures({ data: selectedIds });
32
+ ```
32
33
 
34
+ ```tsx
33
35
  // alert dialog
34
36
  const { alert } = useDialogs();
35
37
  const { t } = useTranslation();
@@ -39,23 +41,23 @@ try {
39
41
  } catch (error) {
40
42
  await alert(error instanceof Error ? error.message : t("UnknownError"));
41
43
  }
44
+ ```
42
45
 
46
+ ```tsx
43
47
  // custom dialog that returns a result
44
48
  const { open } = useDialogs();
45
49
 
46
50
  const saved = await open(EditFeatureDialog, { id });
47
51
  if (saved) await features.utils.refetch({ throwOnError: true });
52
+ ```
48
53
 
54
+ ```tsx
49
55
  // custom dialog component
50
56
  interface Payload {
51
57
  id: string;
52
58
  }
53
59
 
54
- export const EditFeatureDialog = ({
55
- payload,
56
- open,
57
- onClose,
58
- }: DialogProps<Payload, boolean>) => {
60
+ export const EditFeatureDialog = ({ payload, open, onClose }: DialogProps<Payload, boolean>) => {
59
61
  const { t } = useTranslation();
60
62
 
61
63
  return (
@@ -27,7 +27,8 @@ metadata:
27
27
  `dayjs(row.dueAt)` into `defaultValues`, `.toDate()` on the way out in `onSubmit`.
28
28
  - Use translation for labels, helper text, validation messages and submit.
29
29
  - Reset the form after a successful create, and let the submit handler reject on failure so
30
- a failed save keeps what the user typed.
30
+ a failed save keeps what the user typed: the route alerts, then rethrows (see the route
31
+ example). A handler that only alerts resolves, and the form resets anyway.
31
32
  - `SubmitButton` calls `form.handleSubmit()` and owns its loading and disabled state.
32
33
  - `reset()` restores the `defaultValues` captured when the form was constructed. If those
33
34
  contain a generated `uuidv7()` id, pass a fresh one to `reset({ ...defaults, id: uuidv7() })`
@@ -102,3 +103,20 @@ export const Form: FC<FormProps> = ({ defaultValues, onSubmit }) => {
102
103
  );
103
104
  };
104
105
  ```
106
+
107
+ ```tsx
108
+ // Route rendering the form: alert, then rethrow so a failed save keeps the input
109
+ <Form
110
+ defaultValues={{ id: uuidv7(), property1: "" }}
111
+ onSubmit={async (value) => {
112
+ try {
113
+ const transaction = handleOnSubmit(value);
114
+ await transaction.isPersisted.promise;
115
+ await navigate({ to: "/features" });
116
+ } catch (error) {
117
+ if (error instanceof Error) await alert(error.message);
118
+ throw error;
119
+ }
120
+ }}
121
+ />
122
+ ```