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.
- package/dist/AggregatedCell-C7nAQyMO.mjs.map +1 -1
- package/dist/{Approval-C-hF4jbT.mjs → Approval-DoD-GRRH.mjs} +18 -14
- package/dist/Approval-DoD-GRRH.mjs.map +1 -0
- package/dist/{Employee-DbdStvU0.d.mts → Employee-N9fRSnIl.d.mts} +30 -14
- package/dist/FileMeta-DDqUju1Y.mjs.map +1 -1
- package/dist/{LayoutTable-BkrjgpW_.d.mts → LayoutTable-DX9IaO8V.d.mts} +196 -194
- package/dist/RouterListItemButton-ULMlaQh6.mjs.map +1 -1
- package/dist/{approval-BYryxFOW.mjs → approval-DiNOXd4B.mjs} +3 -3
- package/dist/approval-DiNOXd4B.mjs.map +1 -0
- package/dist/components.d.mts +1 -1
- package/dist/components.mjs.map +1 -1
- package/dist/data/client.d.mts +183 -28
- package/dist/data/client.mjs +2 -2
- package/dist/data/client.mjs.map +1 -1
- package/dist/data/server.d.mts +1 -1
- package/dist/data/server.mjs +1 -1
- package/dist/file-C5BOj1q8.mjs.map +1 -1
- package/dist/hooks.d.mts +1 -1
- package/dist/hooks.mjs +7 -7
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.mjs.map +1 -1
- package/dist/models.d.mts +22 -2
- package/dist/models.mjs +1 -1
- package/dist/{peoplesoft-BY_75WTS.d.mts → peoplesoft-BIdTNshE.d.mts} +2 -3
- package/dist/peoplesoft-BkJMCcHb.mjs.map +1 -1
- package/dist/providers-DrairEO2.mjs.map +1 -1
- package/dist/tokens-BLRreL1j.mjs.map +1 -1
- package/dist/utils-BUpDoqme.mjs.map +1 -1
- package/package.json +130 -130
- package/skills/ai/SKILL.md +59 -0
- package/skills/client-db/SKILL.md +47 -43
- package/skills/db-schema/SKILL.md +6 -0
- package/skills/dialogs/SKILL.md +8 -6
- package/skills/forms/SKILL.md +19 -1
- package/skills/general/SKILL.md +127 -122
- package/skills/general/references/exports.md +6 -3
- package/skills/migrations/versions/migrate-v10-to-v11.md +1 -0
- package/skills/migrations/versions/migrate-v9-to-v10.md +23 -23
- package/skills/routing/SKILL.md +7 -4
- package/skills/server-functions/SKILL.md +8 -5
- package/skills/services/SKILL.md +1 -1
- package/skills/services/docs/approval.md +258 -257
- package/skills/services/docs/peoplesoft.md +114 -114
- package/skills/start/SKILL.md +3 -2
- package/skills/start/steps/02-project-name-setup.md +1 -1
- package/skills/start/steps/07-vault-setup.md +5 -4
- package/skills/table/SKILL.md +2 -1
- package/dist/Approval-C-hF4jbT.mjs.map +0 -1
- package/dist/approval-BYryxFOW.mjs.map +0 -1
- package/skills/unslop/SKILL.md +0 -80
- /package/skills/start/steps/{10-gitlab-ci.md → 09-gitlab-ci.md} +0 -0
- /package/skills/start/steps/{09-commit.md → 10-commit.md} +0 -0
package/skills/general/SKILL.md
CHANGED
|
@@ -1,122 +1,127 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: general
|
|
3
|
-
description: "Use ALWAYS, before any other skill here, for every code change in this project. Defines the approved stack (TanStack, Vite+, MUI), TypeScript and naming conventions, date formatting, light/dark theming, testing and the validation command, and the src/ and tests/ folder layout that decides where each new file goes."
|
|
4
|
-
metadata:
|
|
5
|
-
type: convention
|
|
6
|
-
library: wcz-layout
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
> This is the default skill. Reference it in combination with more specific skills (e.g., `forms`, `table`, `dialogs`, etc.) for targeted tasks. For the full catalogue of every `wcz-layout` import subpath and what it exports, read [references/exports.md](references/exports.md).
|
|
10
|
-
|
|
11
|
-
## Preferred Technology Stack
|
|
12
|
-
|
|
13
|
-
Favor the established platform before introducing custom code or a new dependency:
|
|
14
|
-
|
|
15
|
-
- **TanStack ecosystem:** Reach for the TanStack library that owns the problem instead of hand-rolling it — Start for the full-stack app and server functions, Router for routing and route-level data loading, DB for client-side collections and live queries, AI for LLM-backed chat and streaming, Form for form state and validation, Hotkeys for keyboard shortcuts, Virtual for long lists and grids, Pacer for debouncing, throttling, rate limiting and queueing.
|
|
16
|
-
- **Vite+:** Use Vite+ for the development server, formatting, linting and testing.
|
|
17
|
-
- **Material UI:** Use Material UI for interface components and icons.
|
|
18
|
-
|
|
19
|
-
When the requirement is not covered above, look for an existing library before writing any logic. Prefer a well-maintained, widely adopted, typed library over custom implementations, even for seemingly simple functionality where a library can reduce edge cases and bugs. If a suitable library exists, install it and use it. Only implement the functionality yourself when it takes a few lines or no suitable library exists.
|
|
20
|
-
|
|
21
|
-
## Coding Conventions
|
|
22
|
-
|
|
23
|
-
- Write strict ES2023 TypeScript. Preserve local inference, type public boundaries and never use explicit `any`.
|
|
24
|
-
- Stick to double quotes, semicolons, and the `~/` alias for `src/` imports.
|
|
25
|
-
- Avoid `useMemo` / `useCallback`; the React Compiler handles memoization.
|
|
26
|
-
- Keep code self-documenting; only add comments to clarify non-obvious intent.
|
|
27
|
-
- Run the narrow relevant test, then `vp check --fix`. It formats, lints and type-checks.
|
|
28
|
-
|
|
29
|
-
## User Interface
|
|
30
|
-
|
|
31
|
-
- Translate every user-facing string via `useTranslation` (or `t` outside components).
|
|
32
|
-
- Format all client-side dates with `"L LT"` or `"L"`.
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
│
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
│
|
|
57
|
-
├──
|
|
58
|
-
|
|
59
|
-
│
|
|
60
|
-
|
|
61
|
-
│ ├──
|
|
62
|
-
│ │ ├──
|
|
63
|
-
│ │ └──
|
|
64
|
-
│
|
|
65
|
-
│
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
│
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
│ ├──
|
|
72
|
-
│
|
|
73
|
-
│
|
|
74
|
-
│
|
|
75
|
-
│ ├──
|
|
76
|
-
│ │
|
|
77
|
-
│ │
|
|
78
|
-
│ │
|
|
79
|
-
│
|
|
80
|
-
│
|
|
81
|
-
│ ├──
|
|
82
|
-
│
|
|
83
|
-
│
|
|
84
|
-
│ ├──
|
|
85
|
-
│
|
|
86
|
-
├──
|
|
87
|
-
│
|
|
88
|
-
│
|
|
89
|
-
│
|
|
90
|
-
|
|
91
|
-
│
|
|
92
|
-
│ │
|
|
93
|
-
│
|
|
94
|
-
│ │
|
|
95
|
-
│
|
|
96
|
-
│
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
│
|
|
100
|
-
│
|
|
101
|
-
|
|
102
|
-
├──
|
|
103
|
-
│
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
│ ├──
|
|
107
|
-
│ │ └──
|
|
108
|
-
│ └──
|
|
109
|
-
│
|
|
110
|
-
│
|
|
111
|
-
│
|
|
112
|
-
|
|
113
|
-
│
|
|
114
|
-
│
|
|
115
|
-
|
|
116
|
-
│
|
|
117
|
-
│
|
|
118
|
-
│
|
|
119
|
-
└──
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
1
|
+
---
|
|
2
|
+
name: general
|
|
3
|
+
description: "Use ALWAYS, before any other skill here, for every code change in this project. Defines the approved stack (TanStack, Vite+, MUI), TypeScript and naming conventions, date formatting, light/dark theming, testing and the validation command, and the src/ and tests/ folder layout that decides where each new file goes."
|
|
4
|
+
metadata:
|
|
5
|
+
type: convention
|
|
6
|
+
library: wcz-layout
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
> This is the default skill. Reference it in combination with more specific skills (e.g., `forms`, `table`, `dialogs`, etc.) for targeted tasks. For the full catalogue of every `wcz-layout` import subpath and what it exports, read [references/exports.md](references/exports.md).
|
|
10
|
+
|
|
11
|
+
## Preferred Technology Stack
|
|
12
|
+
|
|
13
|
+
Favor the established platform before introducing custom code or a new dependency:
|
|
14
|
+
|
|
15
|
+
- **TanStack ecosystem:** Reach for the TanStack library that owns the problem instead of hand-rolling it — Start for the full-stack app and server functions, Router for routing and route-level data loading, DB for client-side collections and live queries, AI for LLM-backed chat and streaming, Form for form state and validation, Hotkeys for keyboard shortcuts, Virtual for long lists and grids, Pacer for debouncing, throttling, rate limiting and queueing or Charts for data visualization.
|
|
16
|
+
- **Vite+:** Use Vite+ for the development server, formatting, linting and testing.
|
|
17
|
+
- **Material UI:** Use Material UI for interface components and icons.
|
|
18
|
+
|
|
19
|
+
When the requirement is not covered above, look for an existing library before writing any logic. Prefer a well-maintained, widely adopted, typed library over custom implementations, even for seemingly simple functionality where a library can reduce edge cases and bugs. If a suitable library exists, install it and use it. Only implement the functionality yourself when it takes a few lines or no suitable library exists.
|
|
20
|
+
|
|
21
|
+
## Coding Conventions
|
|
22
|
+
|
|
23
|
+
- Write strict ES2023 TypeScript. Preserve local inference, type public boundaries and never use explicit `any`.
|
|
24
|
+
- Stick to double quotes, semicolons, and the `~/` alias for `src/` imports.
|
|
25
|
+
- Avoid `useMemo` / `useCallback`; the React Compiler handles memoization.
|
|
26
|
+
- Keep code self-documenting; only add comments to clarify non-obvious intent.
|
|
27
|
+
- Run the narrow relevant test, then `vp check --fix`. It formats, lints and type-checks.
|
|
28
|
+
|
|
29
|
+
## User Interface
|
|
30
|
+
|
|
31
|
+
- Translate every user-facing string via `useTranslation` (or `t` outside components).
|
|
32
|
+
- Format all client-side dates with `"L LT"` or `"L"`.
|
|
33
|
+
- When building UI, always design for both light and dark mode; this app uses `colorSchemeSelector: "data-mui-color-scheme"`, so prefer `theme.applyStyles("dark", ...)` for mode-specific styling.
|
|
34
|
+
- Always design for desktop and mobile, using responsive layouts and breakpoints to keep the UI usable on any screen.
|
|
35
|
+
- Build skeletons for loading states.
|
|
36
|
+
- Success has no message. Animate the changed item where it lives: created enters, deleted collapses out, edited briefly tints. If the change isn't visible (e.g. before navigating), morph the trigger button to a check for ~400ms.
|
|
37
|
+
|
|
38
|
+
## Testing
|
|
39
|
+
|
|
40
|
+
- `vp test` runs `tests/unit` and `tests/integration`; import the test API from `vite-plus/test`.
|
|
41
|
+
- Server functions need a request context to run, so integration tests cover what they build on: the schema and constraints against the `DATABASE_URL` Postgres, and collections with the server function mocked.
|
|
42
|
+
- `npm run test:e2e` runs Playwright against the dev server, signed in as admin by `tests/e2e/auth.setup.ts`.
|
|
43
|
+
- Add or update tests for any new functionality or bug fixes where it matters, don't write tests just for the sake of having them.
|
|
44
|
+
|
|
45
|
+
## File Organization
|
|
46
|
+
|
|
47
|
+
Use this ownership model for new application code. Keep feature-specific code close to its route; promote it to a root directory only when it is shared across multiple features.
|
|
48
|
+
|
|
49
|
+
```txt
|
|
50
|
+
src/ # client-first architecture
|
|
51
|
+
├── components/ # shared components across multiple routes
|
|
52
|
+
├── db/ # TanStack DB
|
|
53
|
+
│ ├── collections/ # collection descriptors
|
|
54
|
+
│ │ └── <table>.ts
|
|
55
|
+
│ └── queries/ # live query option objects
|
|
56
|
+
│ └── <table>.ts
|
|
57
|
+
├── env.ts # clientEnv + serverEnv via createEnv
|
|
58
|
+
├── hooks/ # shared hooks across multiple routes
|
|
59
|
+
│ └── useTheme.ts # MUI theme + color schemes
|
|
60
|
+
├── lib/ # isomorphic/shared logic usable by client and server
|
|
61
|
+
│ ├── auth/
|
|
62
|
+
│ │ ├── permissions.ts # as const satisfies Permissions
|
|
63
|
+
│ │ └── scopes.ts # as const satisfies Scopes
|
|
64
|
+
│ ├── locales/
|
|
65
|
+
│ │ ├── cs.json
|
|
66
|
+
│ │ └── en.json
|
|
67
|
+
│ └── schemas/ # shared Zod schemas
|
|
68
|
+
│ └── <table>.ts
|
|
69
|
+
├── router.tsx # QueryClient, DbClient, router options
|
|
70
|
+
├── routes/ # TanStack Router file-based routing
|
|
71
|
+
│ ├── __root.tsx
|
|
72
|
+
│ ├── index.tsx
|
|
73
|
+
│ ├── login.tsx # required by requireAuth
|
|
74
|
+
│ ├── health.ts # Docker HEALTHCHECK, pings the database
|
|
75
|
+
│ ├── auth/ # OAuth handlers
|
|
76
|
+
│ │ ├── login.ts
|
|
77
|
+
│ │ ├── callback.ts
|
|
78
|
+
│ │ └── logout.ts
|
|
79
|
+
│ ├── api/ # REST API routes (only when a public API is required)
|
|
80
|
+
│ │ └── features/
|
|
81
|
+
│ │ ├── index.ts
|
|
82
|
+
│ │ └── $id.ts
|
|
83
|
+
│ └── features/ # feature folder with multiple routes (kebab-case, plural)
|
|
84
|
+
│ ├── -components/ # route-specific components
|
|
85
|
+
│ ├── -hooks/ # route-specific hooks
|
|
86
|
+
│ ├── index.tsx
|
|
87
|
+
│ ├── create.tsx
|
|
88
|
+
│ ├── $id.tsx
|
|
89
|
+
│ └── edit.$id.tsx
|
|
90
|
+
├── server/ # server-only code, never imported from a component
|
|
91
|
+
│ ├── actions/
|
|
92
|
+
│ │ └── <table>.ts
|
|
93
|
+
│ ├── db/
|
|
94
|
+
│ │ ├── migrations/
|
|
95
|
+
│ │ ├── schemas/ # Drizzle schemas
|
|
96
|
+
│ │ │ ├── <table>.ts
|
|
97
|
+
│ │ │ └── relations.ts
|
|
98
|
+
│ │ └── index.ts # pool, search_path, auto-migrate
|
|
99
|
+
│ └── middleware/
|
|
100
|
+
│ └── databaseMiddleware.ts # app-local, not a library export
|
|
101
|
+
├── types/
|
|
102
|
+
│ ├── i18next.d.ts # types t() against en.json
|
|
103
|
+
│ └── wcz-layout.d.ts # declares virtual:wcz-layout
|
|
104
|
+
tests/
|
|
105
|
+
├── unit/
|
|
106
|
+
│ ├── lib/
|
|
107
|
+
│ │ └── schemas/
|
|
108
|
+
│ │ └── <table>.test.ts
|
|
109
|
+
│ ├── hooks/
|
|
110
|
+
│ │ └── useX.test.ts
|
|
111
|
+
│ └── routes/
|
|
112
|
+
│ └── features/
|
|
113
|
+
│ └── -components/
|
|
114
|
+
│ └── XCard.test.tsx
|
|
115
|
+
├── integration/
|
|
116
|
+
│ ├── server/
|
|
117
|
+
│ │ └── db/ # real Postgres from DATABASE_URL
|
|
118
|
+
│ │ └── <table>.test.ts
|
|
119
|
+
│ └── db/
|
|
120
|
+
│ └── collections/ # server function mocked
|
|
121
|
+
│ └── <table>.test.ts
|
|
122
|
+
└── e2e/ # Playwright
|
|
123
|
+
├── auth.setup.ts # signs in as admin, no Microsoft login
|
|
124
|
+
├── utils.ts # gotoHydrated
|
|
125
|
+
└── features/
|
|
126
|
+
└── crud.spec.ts
|
|
127
|
+
```
|
|
@@ -70,9 +70,12 @@ The root subpath. Everything the application shell needs.
|
|
|
70
70
|
- `userMiddleware` — attaches the user without requiring one, as `User | null`
|
|
71
71
|
- `validationMiddleware` — validates API route input against a Zod schema. REST routes
|
|
72
72
|
only; server functions use `.validator()`.
|
|
73
|
-
- `csrfMiddleware` — CSRF protection
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
- `csrfMiddleware` — CSRF protection for server functions. Without a `src/start.ts`, Start
|
|
74
|
+
applies the same check by default, so the template has none. If the app adds
|
|
75
|
+
`src/start.ts` for its own request middleware, list `csrfMiddleware` there too —
|
|
76
|
+
`createStart(() => ({ requestMiddleware: [csrfMiddleware, ...] }))` — because a start
|
|
77
|
+
instance replaces that default. It is a **request** middleware, never part of a
|
|
78
|
+
`.middleware([])` array.
|
|
76
79
|
|
|
77
80
|
`databaseMiddleware` is **not** here. It is app-local; every app writes its own. See the
|
|
78
81
|
`server-functions` skill.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
https://mui.com/material-ui/react-number-field/
|
|
@@ -172,7 +172,7 @@ Check what the v9 middleware composed before touching any call site:
|
|
|
172
172
|
now serves anonymous callers unless you add `authMiddleware()` yourself.
|
|
173
173
|
|
|
174
174
|
| v9 call site | v9 meaning | v10 |
|
|
175
|
-
| ---------------------------------------------------------- | ------------------- |
|
|
175
|
+
| ---------------------------------------------------------- | ------------------- | ------------------------------------------------- |
|
|
176
176
|
| `databaseMiddleware({ optional: true })` | anonymous allowed | `[databaseMiddleware()]` |
|
|
177
177
|
| `databaseMiddleware()` over `authenticationMiddleware()` | user required | `[databaseMiddleware(), authMiddleware()]` |
|
|
178
178
|
| `[authorizationMiddleware("admin"), databaseMiddleware()]` | permission required | `[databaseMiddleware(), authMiddleware("admin")]` |
|
|
@@ -231,7 +231,7 @@ locale files is the library's.
|
|
|
231
231
|
|
|
232
232
|
**Merge it into the app's `Layout`, do not replace the block.** Apps add their own
|
|
233
233
|
keys inside that namespace (`Layout.Loading`, `Layout.NotProvided` in one app), and a
|
|
234
|
-
wholesale replace silently deletes them — which
|
|
234
|
+
wholesale replace silently deletes them — which _does_ break the build, because
|
|
235
235
|
`src/types/i18next.d.ts` types `t()` from `en.json` and the app's own
|
|
236
236
|
`t("Layout.Loading")` calls stop compiling. So: overlay the library's keys on top of
|
|
237
237
|
the app's, then look at what is left over. A leftover key the app's own code
|
|
@@ -286,25 +286,25 @@ Delete `src/components/DataGridToolbar.tsx`; `LayoutTable` renders the toolbar,
|
|
|
286
286
|
quick filter, columns panel and filter panel itself. In `useTheme.ts`, drop
|
|
287
287
|
`import { csCZ, enUS } from "@mui/x-data-grid/locales"` and its two entries.
|
|
288
288
|
|
|
289
|
-
| DataGridPremium | LayoutTable
|
|
290
|
-
| --------------------------------------------------- |
|
|
291
|
-
| `Array<GridColDef<Row>>` | `columnHelper.columns([...])` from `createLayoutColumnHelper`
|
|
292
|
-
| `field` / `headerName` | the accessor key / `header`
|
|
293
|
-
| `width`, `flex`, `minWidth` | `size`
|
|
294
|
-
| `renderCell` | `cell: ({ cell }) => <cell.ValueCell />`
|
|
295
|
-
| `valueGetter: (_v, row) => row.x.y` | `columnHelper.accessor((row) => row.x.y, { id: "..." })`
|
|
296
|
-
| `align` / `headerAlign` | `meta: { align }`
|
|
297
|
-
| `initialState.pinnedColumns.left` / `.right` | `initialState.columnPinning.start` / `.end`
|
|
298
|
-
| `initialState.sorting.sortModel` `{field, sort}` | `initialState.sorting` `[{ id, desc }]`
|
|
299
|
-
| `valueFormatter` on a date column | `cell.DateCell` or `cell.DateTimeCell`
|
|
300
|
-
| `valueFormatter` with an `Intl.NumberFormat` | `cell.NumberCell options={...}`, same options object
|
|
301
|
-
| `type: "singleSelect"` with `valueOptions` | `meta: { variant: "select", options }`
|
|
302
|
-
| `type: "number"` / `"date"` / `"boolean"` | `meta: { variant: "number" \| "date" \| "boolean" }`
|
|
303
|
-
| `rows` and `columns` props | `useLayoutTable({ data, columns })`, then `table={table}`
|
|
304
|
-
| `showToolbar` with `slots.toolbar` | `showToolbar` with `title` and `actions` on `LayoutTable`
|
|
305
|
-
| `ignoreDiacritics` | always on
|
|
306
|
-
| `rowSelectionModel` state | `table.getSelectedRowIds()`, `table.resetRowSelection()`
|
|
307
|
-
| `cellSelection` | always on, `Mod+C` copies the range as TSV
|
|
289
|
+
| DataGridPremium | LayoutTable |
|
|
290
|
+
| --------------------------------------------------- | ------------------------------------------------------------------ |
|
|
291
|
+
| `Array<GridColDef<Row>>` | `columnHelper.columns([...])` from `createLayoutColumnHelper` |
|
|
292
|
+
| `field` / `headerName` | the accessor key / `header` |
|
|
293
|
+
| `width`, `flex`, `minWidth` | `size` |
|
|
294
|
+
| `renderCell` | `cell: ({ cell }) => <cell.ValueCell />` |
|
|
295
|
+
| `valueGetter: (_v, row) => row.x.y` | `columnHelper.accessor((row) => row.x.y, { id: "..." })` |
|
|
296
|
+
| `align` / `headerAlign` | `meta: { align }` |
|
|
297
|
+
| `initialState.pinnedColumns.left` / `.right` | `initialState.columnPinning.start` / `.end` |
|
|
298
|
+
| `initialState.sorting.sortModel` `{field, sort}` | `initialState.sorting` `[{ id, desc }]` |
|
|
299
|
+
| `valueFormatter` on a date column | `cell.DateCell` or `cell.DateTimeCell` |
|
|
300
|
+
| `valueFormatter` with an `Intl.NumberFormat` | `cell.NumberCell options={...}`, same options object |
|
|
301
|
+
| `type: "singleSelect"` with `valueOptions` | `meta: { variant: "select", options }` |
|
|
302
|
+
| `type: "number"` / `"date"` / `"boolean"` | `meta: { variant: "number" \| "date" \| "boolean" }` |
|
|
303
|
+
| `rows` and `columns` props | `useLayoutTable({ data, columns })`, then `table={table}` |
|
|
304
|
+
| `showToolbar` with `slots.toolbar` | `showToolbar` with `title` and `actions` on `LayoutTable` |
|
|
305
|
+
| `ignoreDiacritics` | always on |
|
|
306
|
+
| `rowSelectionModel` state | `table.getSelectedRowIds()`, `table.resetRowSelection()` |
|
|
307
|
+
| `cellSelection` | always on, `Mod+C` copies the range as TSV |
|
|
308
308
|
| `GridActionsCellItem` in a `type: "actions"` column | a `display` column rendering `cell.ActionsCell`, `showInMenu` kept |
|
|
309
309
|
|
|
310
310
|
**Every row needs an `id`.** `getRowId` is not an option — the library hardcodes
|
|
@@ -326,7 +326,7 @@ with one effect on `table.state`. There is no `onStateChange` option.
|
|
|
326
326
|
**Shared generic column factories do not port.** A v9 helper like
|
|
327
327
|
`actionColumn<T>(): GridColDef<T>` reused across pages cannot be rewritten as
|
|
328
328
|
`(helper: ColumnHelper<T>) => ...` — `createLayoutColumnHelper` is invariant in its row
|
|
329
|
-
type, so a concrete helper will not satisfy a generic parameter. Share the
|
|
329
|
+
type, so a concrete helper will not satisfy a generic parameter. Share the _contents_
|
|
330
330
|
instead: a function returning `Array<RowAction<T>>` (that type is generic-friendly) or
|
|
331
331
|
a plain predicate, and let each page write its own five-line `display` column.
|
|
332
332
|
|
|
@@ -340,7 +340,7 @@ field errors itself.
|
|
|
340
340
|
|
|
341
341
|
**Bulk actions need a selection column.** A v9 page driving actions off
|
|
342
342
|
`Object.keys(cellSelectionModel)` has nothing to map onto: cell selection is always on
|
|
343
|
-
in v10 but exists for `Mod+C`. `table.getSelectedRowIds()` reads
|
|
343
|
+
in v10 but exists for `Mod+C`. `table.getSelectedRowIds()` reads _row_ selection,
|
|
344
344
|
which renders only if the columns start with a `select` display column
|
|
345
345
|
(`header.SelectAllCell` / `cell.SelectCell`, `size: 50`, `enableResizing: false`,
|
|
346
346
|
`enableCellSelection: false`). Ids come back as plain strings, so the `id.toString()`
|
package/skills/routing/SKILL.md
CHANGED
|
@@ -22,7 +22,8 @@ metadata:
|
|
|
22
22
|
- Use `Route.useRouteContext()` to access the authenticated user. `user` can be `null` if
|
|
23
23
|
the route doesn't include `requireAuth`.
|
|
24
24
|
- Preload the route's live queries in the loader and return the promise:
|
|
25
|
-
`loader: ({ context }) => context.dbClient.preloadLiveQuery(<x>QueryOptions)`.
|
|
25
|
+
`loader: ({ context }) => context.dbClient.preloadLiveQuery(<x>QueryOptions)`. Detail
|
|
26
|
+
routes await it and throw `notFound()` for a missing row; see the `client-db` skill.
|
|
26
27
|
- Literal URL segments and feature folders use kebab-case. Entity feature names are plural;
|
|
27
28
|
TanStack special route tokens retain their required syntax.
|
|
28
29
|
- If a feature contains only one route, create a single file route: `src/routes/<feature>s.tsx`
|
|
@@ -33,6 +34,8 @@ metadata:
|
|
|
33
34
|
- Root-level `components/` and `hooks/` are only for code shared across multiple routes.
|
|
34
35
|
- After creating a new route, add a navigation item with a unique icon from
|
|
35
36
|
`@mui/icons-material` in `src/routes/__root.tsx`.
|
|
37
|
+
- Hide a navigation entry from users who cannot open it: `hidden: !hasPermission(user, <key>)`
|
|
38
|
+
with the same key as its route's `requireAuth(<key>)`.
|
|
36
39
|
- For user-clickable in-app navigation, use the type-safe router components from
|
|
37
40
|
`wcz-layout/components` (`RouterButton`, `RouterIconButton`, `RouterLink`, `RouterFab`,
|
|
38
41
|
`RouterTab`, `RouterListItemButton`) rather than raw MUI with a manual `href` — they wrap
|
|
@@ -40,14 +43,13 @@ metadata:
|
|
|
40
43
|
|
|
41
44
|
## Examples
|
|
42
45
|
|
|
43
|
-
```
|
|
46
|
+
```tsx
|
|
44
47
|
// imports
|
|
45
48
|
import AccountTree from "@mui/icons-material/AccountTree";
|
|
46
49
|
import Code from "@mui/icons-material/Code";
|
|
47
50
|
import Home from "@mui/icons-material/Home";
|
|
48
51
|
import Widgets from "@mui/icons-material/Widgets";
|
|
49
52
|
import { createFileRoute } from "@tanstack/react-router";
|
|
50
|
-
import { z } from "zod";
|
|
51
53
|
import type { Navigation } from "wcz-layout";
|
|
52
54
|
import { useDialogs, useTranslation } from "wcz-layout/hooks";
|
|
53
55
|
import { hasPermission, requireAuth } from "wcz-layout/utils";
|
|
@@ -68,12 +70,13 @@ function RouteComponent() {
|
|
|
68
70
|
|
|
69
71
|
// __root.tsx navigation
|
|
70
72
|
const navigation: Navigation = [
|
|
71
|
-
{ kind: "item", to: "/", title: t("Home"), icon: <Home
|
|
73
|
+
{ kind: "item", to: "/", title: t("Home"), icon: <Home /> },
|
|
72
74
|
{ kind: "header", title: t("Documentation") },
|
|
73
75
|
{
|
|
74
76
|
kind: "group",
|
|
75
77
|
title: t("Components"),
|
|
76
78
|
icon: <Widgets />,
|
|
79
|
+
hidden: !hasPermission(user, "admin"),
|
|
77
80
|
children: [
|
|
78
81
|
{ kind: "item", to: "/components/navigation", title: t("Navigation"), icon: <AccountTree /> },
|
|
79
82
|
{ kind: "divider" },
|
|
@@ -26,7 +26,7 @@ metadata:
|
|
|
26
26
|
// src/server/actions/<table>.ts
|
|
27
27
|
import { createFileRoute } from "@tanstack/react-router";
|
|
28
28
|
import { createServerFn } from "@tanstack/react-start";
|
|
29
|
-
import { eq } from "drizzle-orm";
|
|
29
|
+
import { eq, inArray } from "drizzle-orm";
|
|
30
30
|
import { authMiddleware, validationMiddleware } from "wcz-layout/middleware";
|
|
31
31
|
import z from "zod";
|
|
32
32
|
import { FeatureSchema } from "~/lib/schemas/feature";
|
|
@@ -43,7 +43,10 @@ export const insertFeature = createServerFn({ method: "POST" })
|
|
|
43
43
|
.validator(FeatureSchema)
|
|
44
44
|
.middleware([databaseMiddleware(), authMiddleware("admin")])
|
|
45
45
|
.handler(async ({ data, context }) => {
|
|
46
|
-
await context.db
|
|
46
|
+
await context.db
|
|
47
|
+
.insert(featureTable)
|
|
48
|
+
.values(data)
|
|
49
|
+
.onConflictDoNothing({ target: featureTable.id });
|
|
47
50
|
});
|
|
48
51
|
|
|
49
52
|
export const updateFeature = createServerFn({ method: "POST" })
|
|
@@ -53,11 +56,11 @@ export const updateFeature = createServerFn({ method: "POST" })
|
|
|
53
56
|
await context.db.update(featureTable).set(data).where(eq(featureTable.id, data.id));
|
|
54
57
|
});
|
|
55
58
|
|
|
56
|
-
export const
|
|
57
|
-
.validator(z.uuid())
|
|
59
|
+
export const deleteFeatures = createServerFn({ method: "POST" })
|
|
60
|
+
.validator(z.array(z.uuid()))
|
|
58
61
|
.middleware([databaseMiddleware(), authMiddleware("admin")])
|
|
59
62
|
.handler(async ({ data, context }) => {
|
|
60
|
-
await context.db.delete(featureTable).where(
|
|
63
|
+
await context.db.delete(featureTable).where(inArray(featureTable.id, data));
|
|
61
64
|
});
|
|
62
65
|
|
|
63
66
|
// src/routes/api/<feature>s/index.ts
|
package/skills/services/SKILL.md
CHANGED
|
@@ -11,7 +11,7 @@ metadata:
|
|
|
11
11
|
You can read about each service in the links below. Services are categorized as either client or server exports, depending on their intended usage.
|
|
12
12
|
|
|
13
13
|
- **Client exports** — React Query option factories from `wcz-layout/data/client`.
|
|
14
|
-
- **Server exports** — Direct service operations from `wcz-layout/data/server`; import
|
|
14
|
+
- **Server exports** — Direct service operations from `wcz-layout/data/server`; import them only in server code.
|
|
15
15
|
- Invalidating mutation factories take `{ queryClient }`.
|
|
16
16
|
- Access `queryClient` with `Route.useRouteContext()` in a route file, or `useRouteContext({ from: "path" })` in a component.
|
|
17
17
|
- To read about a service, open the linked file in the **File** column directly.
|