wcz-layout 9.7.0 → 10.1.0

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 (93) hide show
  1. package/dist/AggregatedCell-C7nAQyMO.mjs +510 -0
  2. package/dist/AggregatedCell-C7nAQyMO.mjs.map +1 -0
  3. package/dist/Approval-C-hF4jbT.mjs.map +1 -1
  4. package/dist/DialogsContext-DLqA8RJ_.mjs.map +1 -1
  5. package/dist/Email-BzQQkbe9.mjs.map +1 -1
  6. package/dist/FileMeta-DDqUju1Y.mjs.map +1 -1
  7. package/dist/LayoutTable-BkrjgpW_.d.mts +758 -0
  8. package/dist/{QueryClientParam-Cbb0MIKg.d.mts → QueryClientParam-JcH0mJWl.d.mts} +2 -2
  9. package/dist/RouterListItemButton-ULMlaQh6.mjs.map +1 -1
  10. package/dist/{User-1gKoYJvW.d.mts → User-D4__w1I1.d.mts} +4 -2
  11. package/dist/approval-BYryxFOW.mjs +84 -0
  12. package/dist/approval-BYryxFOW.mjs.map +1 -0
  13. package/dist/auth.d.mts +21 -11
  14. package/dist/auth.mjs +43 -26
  15. package/dist/auth.mjs.map +1 -1
  16. package/dist/components.d.mts +22 -30
  17. package/dist/components.mjs +813 -140
  18. package/dist/components.mjs.map +1 -1
  19. package/dist/createApi-DGJJ4I_R.mjs +27 -0
  20. package/dist/createApi-DGJJ4I_R.mjs.map +1 -0
  21. package/dist/data/client.d.mts +690 -1176
  22. package/dist/data/client.mjs +4 -3
  23. package/dist/data/client.mjs.map +1 -1
  24. package/dist/data/server.d.mts +3 -3
  25. package/dist/data/server.mjs +4 -2
  26. package/dist/data/server.mjs.map +1 -1
  27. package/dist/{file-DimNsRly.mjs → file-C14fhUeg.mjs} +6 -7
  28. package/dist/file-C14fhUeg.mjs.map +1 -0
  29. package/dist/{file-BWcNzq55.mjs → file-C5BOj1q8.mjs} +5 -24
  30. package/dist/file-C5BOj1q8.mjs.map +1 -0
  31. package/dist/hooks.d.mts +7 -46
  32. package/dist/hooks.mjs +2587 -239
  33. package/dist/hooks.mjs.map +1 -1
  34. package/dist/index.d.mts +28 -9
  35. package/dist/index.mjs +1248 -500
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/middleware.d.mts +20 -19
  38. package/dist/middleware.mjs +47 -2
  39. package/dist/middleware.mjs.map +1 -1
  40. package/dist/models.d.mts +17 -10
  41. package/dist/models.mjs.map +1 -1
  42. package/dist/{peoplesoft-CskGsqd6.d.mts → peoplesoft-BY_75WTS.d.mts} +2 -2
  43. package/dist/{peoplesoft-DTPGpN2h.mjs → peoplesoft-BkJMCcHb.mjs} +24 -81
  44. package/dist/peoplesoft-BkJMCcHb.mjs.map +1 -0
  45. package/dist/providers-DrairEO2.mjs +74 -0
  46. package/dist/providers-DrairEO2.mjs.map +1 -0
  47. package/dist/tokens-BLRreL1j.mjs +143 -0
  48. package/dist/tokens-BLRreL1j.mjs.map +1 -0
  49. package/dist/{utils-DjdexspV.mjs → utils-BUpDoqme.mjs} +73 -51
  50. package/dist/utils-BUpDoqme.mjs.map +1 -0
  51. package/dist/{utils-5x4uNxsX.d.mts → utils-Bhi0KiBx.d.mts} +18 -6
  52. package/dist/utils.d.mts +2 -2
  53. package/dist/utils.mjs +2 -2
  54. package/dist/vite.d.mts +1 -2
  55. package/dist/vite.mjs +3 -3
  56. package/dist/vite.mjs.map +1 -1
  57. package/package.json +130 -128
  58. package/skills/client-db/SKILL.md +104 -96
  59. package/skills/db-schema/SKILL.md +46 -33
  60. package/skills/dialogs/SKILL.md +21 -27
  61. package/skills/forms/SKILL.md +60 -39
  62. package/skills/general/SKILL.md +122 -94
  63. package/skills/general/references/exports.md +106 -0
  64. package/skills/migrations/SKILL.md +53 -2
  65. package/skills/migrations/versions/migrate-v9-to-v10.md +582 -0
  66. package/skills/routing/SKILL.md +50 -60
  67. package/skills/server-functions/SKILL.md +36 -56
  68. package/skills/services/SKILL.md +7 -4
  69. package/skills/services/docs/approval.md +2 -2
  70. package/skills/services/docs/peoplesoft.md +114 -110
  71. package/skills/start/SKILL.md +9 -5
  72. package/skills/start/steps/05-database-setup.md +52 -52
  73. package/skills/start/steps/06-entra-setup.md +1 -1
  74. package/skills/start/steps/07-vault-setup.md +5 -12
  75. package/skills/table/SKILL.md +263 -0
  76. package/skills/unslop/SKILL.md +80 -0
  77. package/dist/NotificationContext-CgwUOeW0.mjs +0 -7
  78. package/dist/NotificationContext-CgwUOeW0.mjs.map +0 -1
  79. package/dist/authMiddleware-DPly0b_T.mjs +0 -48
  80. package/dist/authMiddleware-DPly0b_T.mjs.map +0 -1
  81. package/dist/entra-CJSyeQsx.mjs +0 -109
  82. package/dist/entra-CJSyeQsx.mjs.map +0 -1
  83. package/dist/file-BWcNzq55.mjs.map +0 -1
  84. package/dist/file-DimNsRly.mjs.map +0 -1
  85. package/dist/msalServer-DLwA7_ta.mjs +0 -30
  86. package/dist/msalServer-DLwA7_ta.mjs.map +0 -1
  87. package/dist/peoplesoft-DTPGpN2h.mjs.map +0 -1
  88. package/dist/useDialogs-BUzVrTSP.mjs +0 -248
  89. package/dist/useDialogs-BUzVrTSP.mjs.map +0 -1
  90. package/dist/user-Dzv0N9fj.d.mts +0 -16
  91. package/dist/utils-DjdexspV.mjs.map +0 -1
  92. package/skills/data-grid/SKILL.md +0 -142
  93. package/skills/migrations/versions/migrate-v9-to-v10.tsx +0 -9
@@ -1,52 +1,52 @@
1
- # Database Setup
2
-
3
- > Create `.env.local` if it does not exist.
4
- > The app pins `search_path` to the `DATABASE_URL` username, so a schema with that
5
- > exact name must exist. `public` cannot be a username — it is a reserved role.
6
-
7
- ## User Input
8
-
9
- Ask via **AskUserQuestion**: **"Do you already have a Postgres database created for this project?"** — options `Yes` / `No`.
10
-
11
- ## Branch A — Existing database
12
-
13
- 1. Ask: **"Please provide the database connection details"**.
14
-
15
- Fill the host in automatically — QAS is always `10.82.36.60:5432`, PRD is always `10.82.36.50:5432`.
16
-
17
- 2. Update `.env.local`:
18
- - Set `DATABASE_URL=postgres://<schema-username>:<password>@<server-address>:5432/<database-name>`.
19
-
20
- ## Branch B — No database
21
-
22
- Ask via **AskUserQuestion**: **"Would you like me to create a local Postgres database using Docker?"** — options `Yes` / `No`.
23
-
24
- - **No** → continue to next step.
25
- - **Yes** → execute the Docker flow below.
26
-
27
- ### Docker flow
28
-
29
- The container name is `<project-name>-postgres` where `<project-name>` is the kebab-case project name (read from the `name` field in `package.json`).
30
-
31
- 1. Ensure the Docker daemon is running. If not, start Docker Desktop via terminal automatically.
32
- 2. Auto-generate password.
33
- 3. Discover occupied ports by listing **all** containers (including stopped) and pick the first port in **5432 → 5450** that does **not** appear in the output. If all ports are occupied, stop and inform the user.
34
- 4. Run the container on the chosen port:
35
-
36
- ```powershell
37
- docker run --name <project-name>-postgres -e POSTGRES_PASSWORD=<password> -d -p <PORT>:5432 postgres
38
- ```
39
-
40
- - **Success** → continue.
41
- - **Error** → stop and show the full error to the user.
42
-
43
- 5. Create the schema matching the username:
44
-
45
- ```powershell
46
- docker exec <project-name>-postgres psql -U postgres -c "CREATE SCHEMA IF NOT EXISTS postgres AUTHORIZATION postgres;"
47
- ```
48
-
49
- 6. Update `.env.local`:
50
- - Set `DATABASE_URL=postgres://postgres:<password>@localhost:<PORT>/postgres`.
51
- 7. Output exactly:
52
- > ✅ Local Postgres database created successfully on port [PORT]
1
+ # Database Setup
2
+
3
+ > Create `.env.local` if it does not exist.
4
+ > The app pins `search_path` to the `DATABASE_URL` username, so a schema with that
5
+ > exact name must exist. `public` cannot be a username — it is a reserved role.
6
+
7
+ ## User Input
8
+
9
+ Ask via **AskUserQuestion**: **"Do you already have a Postgres database created for this project?"** — options `Yes` / `No`.
10
+
11
+ ## Branch A — Existing database
12
+
13
+ 1. Ask: **"Please provide the database connection details"**.
14
+
15
+ Fill the host in automatically — QAS is always `10.82.36.60:5432`, PRD is always `10.82.36.50:5432`.
16
+
17
+ 2. Update `.env.local`:
18
+ - Set `DATABASE_URL=postgres://<schema-username>:<password>@<server-address>:5432/<database-name>`.
19
+
20
+ ## Branch B — No database
21
+
22
+ Ask via **AskUserQuestion**: **"Would you like me to create a local Postgres database using Docker?"** — options `Yes` / `No`.
23
+
24
+ - **No** → continue to next step.
25
+ - **Yes** → execute the Docker flow below.
26
+
27
+ ### Docker flow
28
+
29
+ The container name is `<project-name>-postgres` where `<project-name>` is the kebab-case project name (read from the `name` field in `package.json`).
30
+
31
+ 1. Ensure the Docker daemon is running. If not, start Docker Desktop via terminal automatically.
32
+ 2. Auto-generate password.
33
+ 3. Discover occupied ports by listing **all** containers (including stopped) and pick the first port in **5432 → 5450** that does **not** appear in the output. If all ports are occupied, stop and inform the user.
34
+ 4. Run the container on the chosen port:
35
+
36
+ ```powershell
37
+ docker run --name <project-name>-postgres -e POSTGRES_PASSWORD=<password> -d -p <PORT>:5432 postgres
38
+ ```
39
+
40
+ - **Success** → continue.
41
+ - **Error** → stop and show the full error to the user.
42
+
43
+ 5. Create the schema matching the username:
44
+
45
+ ```powershell
46
+ docker exec <project-name>-postgres psql -U postgres -c "CREATE SCHEMA IF NOT EXISTS postgres AUTHORIZATION postgres;"
47
+ ```
48
+
49
+ 6. Update `.env.local`:
50
+ - Set `DATABASE_URL=postgres://postgres:<password>@localhost:<PORT>/postgres`.
51
+ 7. Output exactly:
52
+ > ✅ Local Postgres database created successfully on port [PORT]
@@ -74,7 +74,7 @@ SESSION_SECRET=<generated-64-char-hex>
74
74
 
75
75
  3. **Certificates & secrets:** open the **Client secrets** tab → **+ New client secret**. Leave **Description** empty and set **Expires** to `730 days (24 months)` — always these values, never ask the user — then click **Add**. **CRITICAL — one chance only:** the new row's **Value** column holds the secret and is shown _only_ immediately after creation; once you leave or reload the blade it is masked forever and the app must get a brand-new secret. Read that **Value** from the row's textbox in the page snapshot, and write it into `ENTRA_CLIENT_SECRET` in `.env.local` as your very next action, before any other click or navigation. The neighbouring **Secret ID** column is a plain GUID and is _not_ the secret — writing it there is a silent, unrecoverable mistake. The cell renders truncated with `…`, so take the textbox's full value from the snapshot, and never print it in chat or a commit.
76
76
  4. **Token configuration:** click **Add groups claim**. In the panel tick **Security groups** only, then expand each of **ID**, **Access**, and **SAML** in "Customize token properties by type" and switch the radio from `Group ID` to `sAMAccountName`. Click **Add**. The list should then show a `groups` claim with token type `ID, Access, SAML`.
77
- 5. **Expose an API:** next to **Application ID URI** click **Add** (or **Edit** if one exists). The portal prefills `api://<client-id>` — replace it with `api://wistron.com/<app-name>` (for `wh-fg-preparation`: `api://wistron.com/wh-fg-preparation`) and **Save**. Then **+ Add a scope** named `access_as_user`, set **Who can consent?** to `Admins and users`, and fill only the two required fields — **Admin consent display name** and **Admin consent description**. Leave the user consent fields empty (optional) and **State** on `Enabled`, then click **Add scope**. Do not navigate away or report progress as complete until the saved `api://wistron.com/<app-name>` URI and enabled `access_as_user` scope are both visible in the portal. Then set the `api` key in `src/lib/auth/scopes.ts` to `["api://wistron.com/<app-name>/access_as_user"]`, matching the scope exactly as the portal lists it; leave the other keys untouched.
77
+ 5. **Expose an API:** next to **Application ID URI** click **Add** (or **Edit** if one exists). The portal prefills `api://<client-id>` — replace it with `api://wistron.com/<app-name>` (for `wh-fg-preparation`: `api://wistron.com/wh-fg-preparation`) and **Save**. Then **+ Add a scope** named `access_as_user`, set **Who can consent?** to `Admins and users`, and fill only the two required fields — **Admin consent display name** and **Admin consent description**. Leave the user consent fields empty (optional) and **State** on `Enabled`, then click **Add scope**. Do not navigate away or report progress as complete until the saved `api://wistron.com/<app-name>` URI and enabled `access_as_user` scope are both visible in the portal. Then set the `api` key in `src/lib/auth/scopes.ts` to the plain string `"api://wistron.com/<app-name>/access_as_user"` (`Scope` is `string | Partial<Record<ProviderId, string>>` — an array fails `satisfies Scopes`), matching the scope exactly as the portal lists it; leave the other keys untouched.
78
78
  6. **Owners:** first read the current table once. Add only missing people from this fixed list: Radim Staworowski, Martin Husar, Dalibor Homola, Patrik Lorenc, Tien Thanh Tran, Sebastian Ondruska. In the picker, search each missing full name, wait for the exact name and Wistron UPN match, select it, then replace the search text with the next name without closing the picker. Submit the batch once and verify all six names in the refreshed table.
79
79
  7. **Manifest:** the page opens the **Microsoft Graph App Manifest (New)** JSON in a Monaco editor. Do not retype the JSON — click into the editor, press `Ctrl+H`, and run Replace All twice: `"acceptMappedClaims": null` → `"acceptMappedClaims": true`, then `"requestedAccessTokenVersion": null` → `"requestedAccessTokenVersion": 2` (both live in the `api` object, one match each). Verify both edited lines, then click **Save**.
80
80
 
@@ -1,7 +1,6 @@
1
1
  # Vault Setup
2
2
 
3
- Move the secrets that currently live in `.env.local` into Vault, then shrink
4
- `.env.local` down to the Vault connection only.
3
+ Move local-development secrets into Vault, then shrink `.env.local` to the Vault connection.
5
4
 
6
5
  Before starting, ask the user via **AskUserQuestion** which environment(s) to
7
6
  set up: **QAS**, **PRD** or **both**. Both environments follow the same steps —
@@ -17,17 +16,11 @@ expected state appears or ~5 minutes pass, then carry straight on. Never end
17
16
  your turn while waiting; announcing "I'll continue once you have signed in"
18
17
  and stopping ends the session, and nothing resumes it.
19
18
 
20
- Do not print secret values into chat, logs, or a commit — reference them by
21
- key name. Values move from `.env.local` into the browser and nowhere else.
22
-
23
19
  ## Part 1 — Collect the payload from `.env.local`
24
20
 
25
- 1. Read `.env.local`. Note: it is typically gitignored, so glob/searches may not
26
- find it — read it directly by path. If it does not exist, create it. Also
27
- check `.env`: in the template repo some keys (e.g. `*_BASE_URL`) live there
28
- instead — include them in the payload too.
29
- 2. If `SESSION_SECRET` is empty or missing, generate one.
30
- 3. Build the JSON payload from every key in `.env.local` (except `DATABASE_AUTOMIGRATE`). A typical payload that goes to Vault.
21
+ 1. Inspect key names and whether they are set without printing their values. Include keys from `.env` such as `*_BASE_URL`, etc.
22
+ 2. If `SESSION_SECRET` is empty or missing, generate it without writing it to command output.
23
+ 3. Build a JSON key skeleton from `.env.local`, excluding `DATABASE_AUTO_MIGRATE`.
31
24
 
32
25
  ```json
33
26
  {
@@ -113,7 +106,7 @@ VAULT_USERNAME=<from Part 2>
113
106
  VAULT_PASSWORD=<from Part 2>
114
107
 
115
108
  DATABASE_URL=<kept — local dev DB or QAS, per user choice>
116
- DATABASE_AUTOMIGRATE=<kept>
109
+ DATABASE_AUTO_MIGRATE=<kept>
117
110
  ```
118
111
 
119
112
  After writing, verify end-to-end: start the dev server (or replicate the
@@ -0,0 +1,263 @@
1
+ ---
2
+ name: table
3
+ description: "Use when building or changing a data table. Covers useLayoutTable, LayoutTable, createLayoutColumnHelper, column definitions and headers, cell formatters, filter variants, sorting, row selection and bulk actions, per-row actions, pagination, footer aggregation."
4
+ metadata:
5
+ type: convention
6
+ library: wcz-layout
7
+ ---
8
+
9
+ # Table patterns
10
+
11
+ > Mechanics (`createTableHook`, column helpers, row models, faceting, the state
12
+ > atoms) belong to TanStack Table v9 itself. List the skills shipped by
13
+ > `@tanstack/table-core` and `@tanstack/react-table` and load whichever cover the task at
14
+ > hand. This skill covers only the wcz-layout conventions on top of it.
15
+
16
+ ## Rules
17
+
18
+ - Build the instance with `useLayoutTable({ data, columns })` and pass it to
19
+ `<LayoutTable table={table} />`. Rows are keyed by `row.id`, so every row object
20
+ needs an `id`.
21
+ - For selection and actions display columns, always set `size: 50`,
22
+ `enableResizing: false`, and `enableCellSelection: false`. An actions column
23
+ that shows more than one button needs about 40px more per extra button.
24
+ - Render cells with the bound components off the render prop
25
+ (`cell.ValueCell`, `NumberCell`, `DateCell`, `DateTimeCell`, `BooleanCell`)
26
+ instead of raw JSX. They carry the alignment, the number and date locale, and
27
+ the noWrap behaviour. Write raw JSX only when the cell is a link or
28
+ another interactive element.
29
+ - Give `meta.label` to any column whose `header` is not a plain string. A string
30
+ header supplies the label automatically; a function or JSX header leaves the
31
+ header menu and column selector without a label; the filter picker falls back to
32
+ `column.id`. `meta` has five keys: `label`, `align`, `variant`, `options`, `flex`.
33
+ - `meta.flex` makes a column share the width left over from the sized columns, in
34
+ proportion like CSS `flex-grow`. `size` stays its minimum width. Resizing the column
35
+ pins it to a fixed width.
36
+ - Wrap the table in `Fullscreen` when it is the only content on the page.
37
+ - Props: `title`, `actions`, `showToolbar`,
38
+ `loading`, `pagination`, `pageSizeOptions`, `onRowClick`, `onRowDoubleClick`,
39
+ `sx`, and the `disableSearch` / `disableColumnFilter` / `disableColumnSelector` /
40
+ `disableColumnMenu` escape hatches.
41
+ - Rows and columns virtualize by default.
42
+ - Set `meta.variant` for non-text filters. Omission means `"text"`.
43
+ - Do not enumerate `meta.options` for a free-text column. `select` and
44
+ `multi-select` read their options from the faceted unique values, so the choices
45
+ track the data. Pass explicit string options when labels differ from stored values or
46
+ the UI needs a fixed list. Derive database-enum options from `enumValues`, never a
47
+ second hand-written list.
48
+
49
+ ## Example
50
+
51
+ ```tsx
52
+ import { Fullscreen, LayoutTable, RouterIconButton, RouterLink } from "wcz-layout/components";
53
+ import {
54
+ createLayoutColumnHelper,
55
+ useDialogs,
56
+ useLayoutTable,
57
+ useTranslation,
58
+ } from "wcz-layout/hooks";
59
+
60
+ const columnHelper = createLayoutColumnHelper<Todo>();
61
+
62
+ function RouteComponent() {
63
+ const { t } = useTranslation();
64
+ const { confirm, alert } = useDialogs();
65
+ const navigate = useNavigate();
66
+ const todos = useTodoCollection();
67
+ const { data, isLoading } = useLiveQuery(todosQueryOptions);
68
+
69
+ const columns = columnHelper.columns([
70
+ columnHelper.display({
71
+ id: "select",
72
+ header: ({ header }) => <header.SelectAllCell scope="all" />,
73
+ cell: ({ cell }) => <cell.SelectCell />,
74
+ size: 50,
75
+ enableResizing: false,
76
+ }),
77
+ columnHelper.accessor("name", {
78
+ header: t("Todo.Name"),
79
+ cell: ({ cell }) => (
80
+ <RouterLink
81
+ to="/todos/$id"
82
+ params={{ id: cell.row.original.id }}
83
+ underline="hover"
84
+ color="inherit"
85
+ >
86
+ {cell.getValue()}
87
+ </RouterLink>
88
+ ),
89
+ size: 260,
90
+ }),
91
+ columnHelper.accessor("assignee", {
92
+ header: t("Todo.Assignee"),
93
+ cell: ({ cell }) => <cell.ValueCell />,
94
+ // No options: the filter builds them from the faceted unique values.
95
+ meta: { variant: "multi-select" },
96
+ size: 180,
97
+ }),
98
+ columnHelper.accessor("priority", {
99
+ header: t("Todo.Priority"),
100
+ cell: ({ cell }) => <cell.NumberCell />,
101
+ footer: ({ header }) => <header.AggregationFooter options={{ maximumFractionDigits: 1 }} />,
102
+ aggregationFn: "mean",
103
+ meta: { variant: "number", align: "right" },
104
+ size: 120,
105
+ }),
106
+ columnHelper.accessor("starred", {
107
+ header: t("Todo.Starred"),
108
+ cell: ({ cell }) => <cell.BooleanCell />,
109
+ meta: { variant: "boolean", align: "center" },
110
+ size: 120,
111
+ }),
112
+ columnHelper.accessor("createdAt", {
113
+ header: t("Todo.CreatedAt"),
114
+ cell: ({ cell }) => <cell.DateTimeCell />,
115
+ meta: { variant: "date" },
116
+ size: 190,
117
+ }),
118
+ ]);
119
+
120
+ const table = useLayoutTable({ data, columns });
121
+ const selectedIds = table.getSelectedRowIds();
122
+
123
+ const handleOnDelete = createOptimisticAction<Array<string>>({
124
+ onMutate: (ids) => {
125
+ ids.forEach((id) => {
126
+ todos.delete(id);
127
+ });
128
+ },
129
+ mutationFn: async (ids) => {
130
+ await deleteTodos({ data: ids });
131
+ await todos.utils.refetch({ throwOnError: true });
132
+ },
133
+ });
134
+
135
+ return (
136
+ <Fullscreen>
137
+ <LayoutTable
138
+ table={table}
139
+ loading={isLoading}
140
+ showToolbar
141
+ title={t("Todo.Todos")}
142
+ onRowDoubleClick={(row) => navigate({ to: "/todos/$id", params: { id: row.id } })}
143
+ actions={
144
+ <>
145
+ <Tooltip title={t("Create")}>
146
+ <RouterIconButton to="/todos/create">
147
+ <Add fontSize="small" />
148
+ </RouterIconButton>
149
+ </Tooltip>
150
+
151
+ {selectedIds.length === 1 && (
152
+ <Tooltip title={t("Edit")}>
153
+ <RouterIconButton to="/todos/edit/$id" params={{ id: selectedIds[0] }}>
154
+ <Edit fontSize="small" />
155
+ </RouterIconButton>
156
+ </Tooltip>
157
+ )}
158
+
159
+ {selectedIds.length > 0 && (
160
+ <Tooltip title={t("Delete")}>
161
+ <IconButton
162
+ onClick={async () => {
163
+ const confirmed = await confirm(
164
+ t("DeleteConfirmation", { count: selectedIds.length }),
165
+ );
166
+ if (!confirmed) return;
167
+
168
+ try {
169
+ const transaction = handleOnDelete(selectedIds);
170
+ await transaction.isPersisted.promise;
171
+ table.resetRowSelection();
172
+ } catch (error) {
173
+ if (error instanceof Error) await alert(error.message);
174
+ }
175
+ }}
176
+ >
177
+ <Badge
178
+ badgeContent={selectedIds.length}
179
+ invisible={selectedIds.length <= 1}
180
+ color="error"
181
+ >
182
+ <Delete fontSize="small" />
183
+ </Badge>
184
+ </IconButton>
185
+ </Tooltip>
186
+ )}
187
+ </>
188
+ }
189
+ />
190
+ </Fullscreen>
191
+ );
192
+ }
193
+ ```
194
+
195
+ ### Per-row actions
196
+
197
+ ```tsx
198
+ columnHelper.display({
199
+ id: "actions",
200
+ cell: ({ cell }) => (
201
+ <cell.ActionsCell
202
+ actions={[
203
+ {
204
+ label: t("Edit"),
205
+ icon: <Edit fontSize="small" />,
206
+ onClick: (row) => navigate({ to: "/todos/edit/$id", params: { id: row.id } }),
207
+ },
208
+ {
209
+ label: t("Delete"),
210
+ icon: <Delete fontSize="small" />,
211
+ showInMenu: true,
212
+ onClick: (row) => remove(row.id),
213
+ },
214
+ ]}
215
+ />
216
+ ),
217
+ size: 50,
218
+ enableResizing: false,
219
+ enableCellSelection: false,
220
+ }),
221
+ ```
222
+
223
+ ### Other bound components
224
+
225
+ On the header render prop: `SelectAllCell`, `ExpandAllCell`, `AggregationFooter`,
226
+ `HeaderMenu`, `HeaderSortLabel`, `HeaderResizeHandle`. On the cell one:
227
+ `SelectCell`, `ExpandCell`, `GroupCell`, `PinRowCell`, `ActionsCell` and the
228
+ formatter cells. `LayoutTable` already places the menu, the sort label and the
229
+ resize handle, so reach for those three only when building a table by hand.
230
+
231
+ ### Custom cells and headers
232
+
233
+ The render prop only exposes the components registered in the library. To write your
234
+ own, read the context directly inside a plain component: `useCellContext<TValue>()`,
235
+ `useHeaderContext()` or `useTableContext()` from `wcz-layout/hooks`.
236
+ `layoutTableFeatures` and the `LayoutTableFeatures` type are the feature set
237
+ `useLayoutTable` installs — you need them only to type a hand-built table instance.
238
+
239
+ ## Common Mistakes
240
+
241
+ ### CRITICAL: Writing TanStack Table v8 column definitions
242
+
243
+ Wrong: `accessorKey: "name"`, `cell: (info) => info.getValue()`, `getCoreRowModel:
244
+ getCoreRowModel()`.
245
+
246
+ Correct: `columnHelper.accessor("name", { cell: ({ cell }) => <cell.ValueCell /> })`
247
+ inside `columnHelper.columns([...])`, and no row models at all.
248
+
249
+ This is v9. v8 column defs either type-error inside `columnHelper.columns()` or
250
+ silently no-op, and row models are gone.
251
+
252
+ ### HIGH: Adding your own virtualizer or pager
253
+
254
+ Wrong: wrapping rows in `useVirtualizer` from `@tanstack/react-virtual`, or bolting on
255
+ a `TablePagination`.
256
+
257
+ Correct: render `<LayoutTable table={table} />` and pass `pagination` if the user wants
258
+ a pager.
259
+
260
+ `LayoutTable` already virtualizes rows and columns. A second virtualizer fights the
261
+ first over scroll position.
262
+
263
+ Use only `LayoutTable`'s `pagination` prop for its pager.
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: unslop
3
+ description: Cut AI tells from any writing. Must always apply.
4
+ ---
5
+
6
+ # Unslop
7
+
8
+ Edit text to remove AI patterns and add human voice.
9
+
10
+ ## Process
11
+
12
+ 1. Scan for the patterns below.
13
+ 2. Rewrite. Preserve meaning, match intended tone.
14
+ 3. Add soul (see next section).
15
+ 4. Self-audit: "What makes this obviously AI generated?" Fix remaining tells.
16
+
17
+ ## Adding soul
18
+
19
+ Removing patterns is half the job. Sterile, voiceless writing is just as obvious.
20
+
21
+ - **Have opinions.** React to facts instead of neutrally listing pros and cons.
22
+ - **Vary rhythm.** Short sentences. Then longer ones that take their time. Mix it up.
23
+ - **Acknowledge complexity.** "Impressive but also kind of unsettling" beats "impressive."
24
+ - **Use "I" when it fits.** First person isn't unprofessional.
25
+ - **Let some mess in.** Perfect structure looks machine-made.
26
+ - **Be specific.** Not "this is concerning" but "there's something unsettling about agents churning away at 3am."
27
+
28
+ ## Patterns to detect and fix
29
+
30
+ ### Content
31
+
32
+ 1. **Puffery.** "pivotal moment", "testament to", "evolving landscape", "setting the stage for", "indelible mark", "deeply rooted". Cut puffery, state what happened.
33
+ 2. **Name-dropping.** Listing media outlets without context. Pick one, say what was said.
34
+ 3. **Superficial -ing phrases.** "highlighting...", "ensuring...", "reflecting...", "showcasing...", "fostering...". Delete or expand with real sources.
35
+ 4. **Promotional language.** "nestled", "vibrant", "breathtaking", "groundbreaking", "renowned", "stunning", "must-visit". Use neutral descriptions.
36
+ 5. **Vague attributions.** "Experts believe", "Industry reports suggest", "Some critics argue". Name the source or delete.
37
+ 6. **Formulaic challenges.** "Despite challenges... continues to thrive." Replace with specific facts.
38
+
39
+ ### Language
40
+
41
+ 7. **AI vocabulary.** Additionally, crucial, delve, enduring, enhance, fostering, garner, interplay, intricate, landscape (abstract), pivotal, showcase, tapestry (abstract), testament, underscore, vibrant. Replace with plain words.
42
+ 8. **Fancy ways to say "is".** "serves as", "stands as", "boasts", "features". Just say "is" or "has".
43
+ 9. **"Not just X, but Y."** State the point directly instead.
44
+ 10. **Rule of three.** Forcing ideas into groups of three. Use the natural number.
45
+ 11. **Synonym cycling.** Protagonist, main character, central figure, hero all in one paragraph. Pick one, repeat it.
46
+ 12. **False ranges.** "from X to Y" where X and Y aren't on a meaningful scale. List topics directly.
47
+
48
+ ### Style
49
+
50
+ 13. **Em dash overuse.** Avoid em dashes entirely. Use periods or commas only (no parentheses, no en dashes, no hyphen-as-dash substitutes). Em dashes are an AI tell, and reaching for parentheses instead just trades one tell for another. If a thought needs separation, end the sentence or use a comma.
51
+ 14. **Colon overuse.** Colons are fine before a list or example. Not as mid-sentence connectors. "If you're coming from traditional automation: instead of registering event handlers, you describe conditions" adds nothing with the colon. Rewrite to let the point stand on its own without comparison framing. "Describing when the scheduler should fire works best as plain English." Same meaning, no crutch punctuation.
52
+ 15. **Boldface overuse.** Don't bold every proper noun or acronym.
53
+ 16. **Inline-header lists.** The tell is a bold label and colon that restates the line: "**Performance:** Performance improved...". Convert those to prose. A bold lead-in that ends in a period, names the item, and is followed by genuinely new detail ("**Schema in TypeScript.** Tables live in one file.") is fine, not a tell.
54
+ 17. **Title case headings.** Use sentence case.
55
+ 18. **Decorative emojis.** Remove from headings and bullets.
56
+ 19. **Curly quotes.** Replace with straight quotes.
57
+
58
+ ### Communication artifacts
59
+
60
+ 20. **Chatbot phrases.** "I hope this helps!", "Let me know if...", "Of course!", "Certainly!", "Found the smoking gun!" Remove.
61
+ 21. **Cutoff disclaimers.** "While specific details are limited..." Find sources or remove.
62
+ 22. **Sycophantic tone.** "Great question! You're absolutely right!" Respond directly.
63
+
64
+ ### Filler
65
+
66
+ 23. **Filler phrases.** "In order to" becomes "To". "Due to the fact that" becomes "Because". "It is important to note that" gets deleted.
67
+ 24. **Excessive hedging.** "could potentially possibly be argued that it might" becomes "may".
68
+ 25. **Generic conclusions.** "The future looks bright." State specific plans or facts.
69
+
70
+ ### Jargon
71
+
72
+ 26. **Abstract metaphor nouns.** Substrate, wedge, vector, locus, vantage, nexus, primitive (as noun), harness (as metaphor), surface (as in "API surface"), bedrock, scaffolding (as metaphor), modality, paradigm, gold-plating, ratchet (as metaphor), evacuate (for moving code), endgame, north star, flywheel. These read as technical but usually have a plainer concrete word. "Substrate" becomes "base". "Wedge in" becomes "add". "Vector" becomes "way" or "method". "Gold-plating" becomes "more than the job needs". "Ratchet" becomes the mechanism's real name or "a limit that only tightens". "Evacuate" becomes "move out". "Endgame" becomes "the last phase". Pick the concrete word.
73
+
74
+ ### Plain speech
75
+
76
+ 27. **Say what it does, not how it feels.** "the database stays close at hand", "SQL you can read", "types that follow your schema" name a feeling. The fix names the mechanism or a number: "`.toSQL()` returns the exact string sent to the database", "a column rename fails the build". Ask what the sentence tells the reader to do or know, then write that. If you can't restate it as a concrete instruction, fact, or number, cut it. One more check: if the sentence could appear unchanged in another project's docs, it says nothing about this one. Cut it.
77
+ 28. **Shorten or split dense sentences.** If the reader has to backtrack to parse a sentence, break it in two or drop clauses. One idea per sentence.
78
+ 29. **Active voice.** Prefer it. Catch "is/are/was/were + past participle" and name the actor: "queries are validated" becomes "the compiler validates queries", "the file is parsed by the loader" becomes "the loader parses the file". Passive is fine only when the actor is unknown or genuinely doesn't matter.
79
+ 30. **Cut adverbs, or use a stronger verb.** "runs quickly" becomes "is fast" or the number. "significantly improves" becomes the measured delta. An adverb propping up a weak verb means the verb is wrong.
80
+ 31. **Prefer the plain word.** "utilize" becomes "use", "leverage" becomes "use", "facilitate" becomes "help", "numerous" becomes "many", "in the event that" becomes "if". The fancier synonym is rarely clearer.
@@ -1,7 +0,0 @@
1
- import { createContext } from "react";
2
- //#region src/contexts/NotificationContext.tsx
3
- const NotificationContext = createContext(null);
4
- //#endregion
5
- export { NotificationContext as t };
6
-
7
- //# sourceMappingURL=NotificationContext-CgwUOeW0.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NotificationContext-CgwUOeW0.mjs","names":[],"sources":["../src/contexts/NotificationContext.tsx"],"sourcesContent":["import { createContext } from \"react\";\nimport type { AlertColor } from \"@mui/material/Alert\";\n\nexport interface NotificationOptions {\n severity?: AlertColor;\n autoHideDuration?: number;\n}\n\nexport interface NotificationContextValue {\n notify: (message: string, options?: NotificationOptions) => void;\n}\n\nexport const NotificationContext = createContext<NotificationContextValue | null>(null);\n"],"mappings":";;AAYA,MAAa,sBAAsB,cAA+C,IAAI"}
@@ -1,48 +0,0 @@
1
- import { i as buildUser, m as serverEnv, o as hasPermission, u as getSessionUser } from "./utils-DjdexspV.mjs";
2
- import { createMiddleware } from "@tanstack/react-start";
3
- import * as jose from "jose";
4
- //#region src/middleware/authMiddleware.ts
5
- async function resolveUser(request) {
6
- const authHeader = request.headers.get("Authorization");
7
- if (authHeader?.startsWith("Bearer ")) {
8
- let payload;
9
- try {
10
- payload = await verifyToken(authHeader.substring(7));
11
- } catch (error) {
12
- throw Response.json({ message: error instanceof Error ? error.message : "Unauthorized: Invalid access token" }, { status: 401 });
13
- }
14
- return buildUser(payload);
15
- }
16
- return getSessionUser();
17
- }
18
- const requiredAuthenticationMiddleware = createMiddleware().server(async ({ next, request }) => {
19
- const user = await resolveUser(request);
20
- if (!user) throw Response.json({ message: "Unauthorized: User not signed in" }, { status: 401 });
21
- return next({ context: { user } });
22
- });
23
- const publicAuthenticationMiddleware = createMiddleware().server(async ({ next, request }) => {
24
- return next({ context: { user: await resolveUser(request) } });
25
- });
26
- function authenticationMiddleware(options) {
27
- return options?.optional ? publicAuthenticationMiddleware : requiredAuthenticationMiddleware;
28
- }
29
- const authorizationMiddleware = (permissionKey) => createMiddleware().middleware([authenticationMiddleware()]).server(async ({ next, context }) => {
30
- if (hasPermission(context.user, permissionKey)) return next();
31
- throw Response.json({ message: `Forbidden: User ${context.user.name} is not authorized to access this resource` }, { status: 403 });
32
- });
33
- async function verifyToken(token) {
34
- const { payload } = await jose.jwtVerify(token, getJWKS(), {
35
- issuer: `https://login.microsoftonline.com/${serverEnv.ENTRA_TENANT_ID}/v2.0`,
36
- audience: serverEnv.ENTRA_CLIENT_ID
37
- });
38
- return payload;
39
- }
40
- let jwksCache = null;
41
- function getJWKS() {
42
- jwksCache ??= jose.createRemoteJWKSet(new URL(`https://login.microsoftonline.com/${serverEnv.ENTRA_TENANT_ID}/discovery/v2.0/keys`));
43
- return jwksCache;
44
- }
45
- //#endregion
46
- export { authorizationMiddleware as n, authenticationMiddleware as t };
47
-
48
- //# sourceMappingURL=authMiddleware-DPly0b_T.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authMiddleware-DPly0b_T.mjs","names":[],"sources":["../src/middleware/authMiddleware.ts"],"sourcesContent":["import { createMiddleware } from \"@tanstack/react-start\";\nimport * as jose from \"jose\";\nimport type { permissions } from \"virtual:wcz-layout\";\nimport { serverEnv } from \"~/env\";\nimport { getSessionUser } from \"~/lib/auth/user\";\nimport { buildUser, hasPermission } from \"~/lib/utils\";\nimport type { TokenPayload } from \"~/models/TokenPayload\";\nimport type { User } from \"~/models/User\";\n\nasync function resolveUser(request: Request): Promise<User | null> {\n const authHeader = request.headers.get(\"Authorization\");\n\n if (authHeader?.startsWith(\"Bearer \")) {\n let payload: TokenPayload;\n try {\n payload = await verifyToken(authHeader.substring(\"Bearer \".length));\n } catch (error) {\n throw Response.json(\n { message: error instanceof Error ? error.message : \"Unauthorized: Invalid access token\" },\n { status: 401 },\n );\n }\n return buildUser(payload);\n }\n\n return getSessionUser();\n}\n\nconst requiredAuthenticationMiddleware = createMiddleware().server<{ user: User }>(\n async ({ next, request }) => {\n const user = await resolveUser(request);\n\n if (!user)\n throw Response.json({ message: \"Unauthorized: User not signed in\" }, { status: 401 });\n\n return next({ context: { user } });\n },\n);\n\nconst publicAuthenticationMiddleware = createMiddleware().server<{ user: User | null }>(\n async ({ next, request }) => {\n const user = await resolveUser(request);\n return next({ context: { user } });\n },\n);\n\nexport function authenticationMiddleware(options?: {\n optional?: false;\n}): typeof requiredAuthenticationMiddleware;\n\nexport function authenticationMiddleware(options: {\n optional: true;\n}): typeof publicAuthenticationMiddleware;\n\nexport function authenticationMiddleware(options: {\n optional: boolean;\n}): typeof requiredAuthenticationMiddleware | typeof publicAuthenticationMiddleware;\n\nexport function authenticationMiddleware(options?: { optional?: boolean }) {\n return options?.optional ? publicAuthenticationMiddleware : requiredAuthenticationMiddleware;\n}\n\nexport const authorizationMiddleware = (permissionKey: keyof typeof permissions) =>\n createMiddleware()\n .middleware([authenticationMiddleware()])\n .server(async ({ next, context }) => {\n if (hasPermission(context.user, permissionKey)) return next();\n throw Response.json(\n {\n message: `Forbidden: User ${context.user.name} is not authorized to access this resource`,\n },\n { status: 403 },\n );\n });\n\nasync function verifyToken(token: string): Promise<TokenPayload> {\n const { payload } = await jose.jwtVerify(token, getJWKS(), {\n issuer: `https://login.microsoftonline.com/${serverEnv.ENTRA_TENANT_ID}/v2.0`,\n audience: serverEnv.ENTRA_CLIENT_ID,\n });\n return payload as unknown as TokenPayload;\n}\n\nlet jwksCache: ReturnType<typeof jose.createRemoteJWKSet> | null = null;\n\nfunction getJWKS() {\n jwksCache ??= jose.createRemoteJWKSet(\n new URL(`https://login.microsoftonline.com/${serverEnv.ENTRA_TENANT_ID}/discovery/v2.0/keys`),\n );\n return jwksCache;\n}\n"],"mappings":";;;;AASA,eAAe,YAAY,SAAwC;CACjE,MAAM,aAAa,QAAQ,QAAQ,IAAI,eAAe;CAEtD,IAAI,YAAY,WAAW,SAAS,GAAG;EACrC,IAAI;EACJ,IAAI;GACF,UAAU,MAAM,YAAY,WAAW,UAAU,CAAgB,CAAC;EACpE,SAAS,OAAO;GACd,MAAM,SAAS,KACb,EAAE,SAAS,iBAAiB,QAAQ,MAAM,UAAU,qCAAqC,GACzF,EAAE,QAAQ,IAAI,CAChB;EACF;EACA,OAAO,UAAU,OAAO;CAC1B;CAEA,OAAO,eAAe;AACxB;AAEA,MAAM,mCAAmC,iBAAiB,CAAC,CAAC,OAC1D,OAAO,EAAE,MAAM,cAAc;CAC3B,MAAM,OAAO,MAAM,YAAY,OAAO;CAEtC,IAAI,CAAC,MACH,MAAM,SAAS,KAAK,EAAE,SAAS,mCAAmC,GAAG,EAAE,QAAQ,IAAI,CAAC;CAEtF,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACnC,CACF;AAEA,MAAM,iCAAiC,iBAAiB,CAAC,CAAC,OACxD,OAAO,EAAE,MAAM,cAAc;CAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAA,MADN,YAAY,OAAO,EACR,EAAE,CAAC;AACnC,CACF;AAcA,SAAgB,yBAAyB,SAAkC;CACzE,OAAO,SAAS,WAAW,iCAAiC;AAC9D;AAEA,MAAa,2BAA2B,kBACtC,iBAAiB,CAAC,CACf,WAAW,CAAC,yBAAyB,CAAC,CAAC,CAAC,CACxC,OAAO,OAAO,EAAE,MAAM,cAAc;CACnC,IAAI,cAAc,QAAQ,MAAM,aAAa,GAAG,OAAO,KAAK;CAC5D,MAAM,SAAS,KACb,EACE,SAAS,mBAAmB,QAAQ,KAAK,KAAI,4CAC/C,GACA,EAAE,QAAQ,IAAI,CAChB;AACF,CAAC;AAEL,eAAe,YAAY,OAAsC;CAC/D,MAAM,EAAE,YAAY,MAAM,KAAK,UAAU,OAAO,QAAQ,GAAG;EACzD,QAAQ,qCAAqC,UAAU,gBAAe;EACtE,UAAU,UAAU;CACtB,CAAC;CACD,OAAO;AACT;AAEA,IAAI,YAA+D;AAEnE,SAAS,UAAU;CACjB,cAAc,KAAK,mBACjB,IAAI,IAAI,qCAAqC,UAAU,gBAAe,qBAAsB,CAC9F;CACA,OAAO;AACT"}