create-tigra 5.0.0 → 5.0.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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  A generated project never changes after it is created: these notes say what new projects get. To bring an older
4
4
  project along, port the changes you need; the guides in [docs/](docs/) cover the ones that need care.
5
5
 
6
+ ## 5.0.2 (2026-11-18)
7
+
8
+ - Give new apps a shared 1px inset focus outline. Keyboard navigation shows the outline from the first frame, and text fields also show it after a click or tap. Adjust the width and style in `client/src/app/globals.css`.
9
+
10
+ ## 5.0.1 (2026-11-17)
11
+
12
+ - Pin Next.js and eslint-config-next to 16.4.6 in new projects. This includes the [security fixes released in Next.js 16.4.5](https://github.com/vercel/next.js/releases/tag/v16.4.5).
13
+
6
14
  ## 5.0.0 (2026-11-17)
7
15
 
8
16
  ### Compatibility
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-tigra",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "type": "module",
5
5
  "description": "Create a production-ready full-stack app with Next.js 16 + Fastify 5 + Prisma + Redis",
6
6
  "bin": {
@@ -14,6 +14,8 @@
14
14
  - `src/lib/constants/routes.ts` and `api-endpoints.ts` own application and API paths. `PROTECTED_PATHS` and `AUTH_PATHS` there are the one list each that the proxy and `AuthInitializer` use, matched by whole path segments (`src/lib/utils/paths.ts`): add your protected areas there.
15
15
  - The start-up "who am I" check runs only when the browser holds the server's `auth_session` marker (`src/lib/utils/session-marker.ts`), so anonymous visitors make no API calls.
16
16
  - `src/styles/themes/default.css` owns color values. Components use semantic Tailwind tokens; do not hardcode palette values or create competing theme variables.
17
+ - Components inherit the inset focus outline from `src/app/globals.css`. Adjust its shared width and style there and keep individual components free of custom focus rings, shadows, and widths. Preserve keyboard focus when adding interactive controls.
18
+ - For a compound control with one visible surface, add `data-focus-surface` to the wrapper and `data-focus-delegate` to its existing focusable direct child. The wrapper draws the outline while the child keeps its normal tab stop. Menu and option rows use their own focus highlight.
17
19
  - If a `next/font` CSS variable is referenced by a token declared on `:root`, apply that font's generated variable class to `<html>`. Never attach it only to `<body>`, where it cannot resolve the root-scoped token.
18
20
  - `src/proxy.ts` (Next 16's name for middleware) is the single source of truth for security headers and nonce-based CSP. Do not add a second CSP in `next.config.ts`.
19
21
 
@@ -16,7 +16,7 @@
16
16
  "class-variance-authority": "^0.7.1",
17
17
  "clsx": "^2.1.1",
18
18
  "lucide-react": "^0.563.0",
19
- "next": "16.3.8",
19
+ "next": "16.4.6",
20
20
  "next-themes": "^0.4.6",
21
21
  "radix-ui": "^1.4.3",
22
22
  "react": "19.2.3",
@@ -34,7 +34,7 @@
34
34
  "@types/react-dom": "^19",
35
35
  "@vitest/coverage-v8": "^4.1.11",
36
36
  "eslint": "^9",
37
- "eslint-config-next": "16.3.8",
37
+ "eslint-config-next": "16.4.6",
38
38
  "jsdom": "^29.1.1",
39
39
  "shadcn": "^3.8.4",
40
40
  "tailwindcss": "^4",
@@ -2097,15 +2097,15 @@
2097
2097
  }
2098
2098
  },
2099
2099
  "node_modules/@next/env": {
2100
- "version": "16.3.8",
2101
- "resolved": "https://registry.npmjs.org/@next/env/-/env-16.3.8.tgz",
2102
- "integrity": "sha512-Al9zqHVV7TJv0eFuOU4U7Lvv74PTih4Ch63sk2xCIpSTkE3udFnaOcnzP2lQVymiL7yS9Cj2iClUXlR3EQ5sEw==",
2100
+ "version": "16.4.6",
2101
+ "resolved": "https://registry.npmjs.org/@next/env/-/env-16.4.6.tgz",
2102
+ "integrity": "sha512-SunBjJ6t+oBtecS3dTjdVuMhUogP5wD/vrGL5EVuQYM1iS4O5ilL51HkiJ3sPjMzRHiCChvr4dbaSJbR7F3lxA==",
2103
2103
  "license": "MIT"
2104
2104
  },
2105
2105
  "node_modules/@next/eslint-plugin-next": {
2106
- "version": "16.3.8",
2107
- "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.3.8.tgz",
2108
- "integrity": "sha512-eCR9RcLTZrVS+K3+VOhi0xMdUUGNuriCHHhU1ZoABC/QQ/Gp0OWbLKQxV2/9DkmihYdYRcQWFmZXW8M1AMUXYw==",
2106
+ "version": "16.4.6",
2107
+ "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.4.6.tgz",
2108
+ "integrity": "sha512-HdqERVOafOD8JaUSAkwf9aSu/1rsHlkN8C5GcXYBH3C/z1MxBhZFxB5rz/xqMMRiIj7r9tIv8OCLQ9JWUxCvWA==",
2109
2109
  "dev": true,
2110
2110
  "license": "MIT",
2111
2111
  "dependencies": {
@@ -2114,9 +2114,9 @@
2114
2114
  }
2115
2115
  },
2116
2116
  "node_modules/@next/swc-darwin-arm64": {
2117
- "version": "16.3.8",
2118
- "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.3.8.tgz",
2119
- "integrity": "sha512-2JPRMh2nmQG5CiL7cXGL9AGwnPWJQ//cTtAUCT+w511QHk79SYz3LGv/pc5X643B/WEO0rvu3Yww0hqwt3kgeA==",
2117
+ "version": "16.4.6",
2118
+ "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.4.6.tgz",
2119
+ "integrity": "sha512-kJ4VVZkley17xKaJx72QN2IBqjrj7zenCQZaUF0l9ShS/1Mt2kW4+Z5KGG6vgr3L/J562xTOizVyM1iA/u5nlg==",
2120
2120
  "cpu": [
2121
2121
  "arm64"
2122
2122
  ],
@@ -2130,9 +2130,9 @@
2130
2130
  }
2131
2131
  },
2132
2132
  "node_modules/@next/swc-darwin-x64": {
2133
- "version": "16.3.8",
2134
- "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.3.8.tgz",
2135
- "integrity": "sha512-GZtCCOBKJ4leVIT/Th0llWKhD1ca92lzbQiS5R5ON9QkoiFnilFsebDae1JU2a3HWoKMEmEZWGs1AGLavVM72Q==",
2133
+ "version": "16.4.6",
2134
+ "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.4.6.tgz",
2135
+ "integrity": "sha512-eIPGZIqC+8JKaeZmvnCANJQF4xWkkHqSnAAajtFxgwDMAOnCgxNvP52SeWZ41PyVwoe+Le/NQuZSaQ8j7YshSA==",
2136
2136
  "cpu": [
2137
2137
  "x64"
2138
2138
  ],
@@ -2146,9 +2146,9 @@
2146
2146
  }
2147
2147
  },
2148
2148
  "node_modules/@next/swc-linux-arm64-gnu": {
2149
- "version": "16.3.8",
2150
- "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.3.8.tgz",
2151
- "integrity": "sha512-O659ygeQYqneJ1fBKMpFxIFqYkYswu8IAS1OCKK/4f3ZgJJm1dRz4fVJZRi/kLLWjnBKnebOePA4WNv+sV1pVA==",
2149
+ "version": "16.4.6",
2150
+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.4.6.tgz",
2151
+ "integrity": "sha512-9nI6O8vvczH2D9ZNdMGqb/3NuT15T9ksOZnAmx9/gjF2cOi74+xxyf1Hk96uIMfm14c9y6wHeBq6SH8g6udvcA==",
2152
2152
  "cpu": [
2153
2153
  "arm64"
2154
2154
  ],
@@ -2165,9 +2165,9 @@
2165
2165
  }
2166
2166
  },
2167
2167
  "node_modules/@next/swc-linux-arm64-musl": {
2168
- "version": "16.3.8",
2169
- "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.3.8.tgz",
2170
- "integrity": "sha512-dSjKSyWpzxoO1d3DIZZcP4XJcNaKeLmxQMFOiYl5vuBRMmweIqnAhty8tAmRsvTss779cK1FtYnDMj40e4TQlg==",
2168
+ "version": "16.4.6",
2169
+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.4.6.tgz",
2170
+ "integrity": "sha512-7/qPhTxDp2ScluOJOhLuhWmlA17o1yZ0SIgpISBCpBxXgtnK4+KGywBpFkfLPiU1rnSM1faFGzYkH6i7JdTrqA==",
2171
2171
  "cpu": [
2172
2172
  "arm64"
2173
2173
  ],
@@ -2184,9 +2184,9 @@
2184
2184
  }
2185
2185
  },
2186
2186
  "node_modules/@next/swc-linux-x64-gnu": {
2187
- "version": "16.3.8",
2188
- "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.3.8.tgz",
2189
- "integrity": "sha512-lbqOuz3RPRcv+o9msNsJw5x4+Y1ZwPTs6vmL6DCf7i0fZfvng/F59wyeDwqHIvV0mK//RBy/jJkZ+nCKsSMXjQ==",
2187
+ "version": "16.4.6",
2188
+ "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.4.6.tgz",
2189
+ "integrity": "sha512-oOpbNa8XOW1qCGd9VvzC4fbkkRxEls7/WI6tz+YHC0xRA7KpV1U7DrAnCPjzVyOk/karzWEepCOcTIDmwK8FwQ==",
2190
2190
  "cpu": [
2191
2191
  "x64"
2192
2192
  ],
@@ -2203,9 +2203,9 @@
2203
2203
  }
2204
2204
  },
2205
2205
  "node_modules/@next/swc-linux-x64-musl": {
2206
- "version": "16.3.8",
2207
- "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.3.8.tgz",
2208
- "integrity": "sha512-+316WswI8ScVgZeUd+1KGaXkHhaYQzCjvH/05TZSpJ8zBizb1a4G7DtO7F12jcBIqMOtsz9ji1t48fmKtzqsGA==",
2206
+ "version": "16.4.6",
2207
+ "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.4.6.tgz",
2208
+ "integrity": "sha512-aM8CZ+OR2EwXaAYw7KGkW2GDmNDsLBIRe1MMRZCJPTdw/xhTD0IMUVO4sf3KqrzuRouGzwwLZn34+gFeVXiUQA==",
2209
2209
  "cpu": [
2210
2210
  "x64"
2211
2211
  ],
@@ -2222,9 +2222,9 @@
2222
2222
  }
2223
2223
  },
2224
2224
  "node_modules/@next/swc-win32-arm64-msvc": {
2225
- "version": "16.3.8",
2226
- "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.3.8.tgz",
2227
- "integrity": "sha512-ji0gd4kMYUxO+1fJBIbiBVRCjzG/lloiyCccnlebvb1ZJ5qXCPZqYg4Jl1DrrixnWNMKylzgpmMWx0yNDYXlzw==",
2225
+ "version": "16.4.6",
2226
+ "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.4.6.tgz",
2227
+ "integrity": "sha512-U0p7/tEtqvHX2crhd841CDwKtp5CFkKXVjOhmfccR3Pvp64sj8KBwRqsvltqLOwVBbj0NtkxwXSDpEHYGbxeXQ==",
2228
2228
  "cpu": [
2229
2229
  "arm64"
2230
2230
  ],
@@ -2238,9 +2238,9 @@
2238
2238
  }
2239
2239
  },
2240
2240
  "node_modules/@next/swc-win32-x64-msvc": {
2241
- "version": "16.3.8",
2242
- "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.3.8.tgz",
2243
- "integrity": "sha512-WcTlaKt/TWkh5kUjdJcUmB1XgZ+1c6fz4Y9fDHL73YNSdGaUWjceeWrrlwF0nv19iABYWC4iAq1oX1w4Bn0vfg==",
2241
+ "version": "16.4.6",
2242
+ "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.4.6.tgz",
2243
+ "integrity": "sha512-3ZG15/5WIdlTQsIEvc9sPTTSL5XFrlLklIKmfF4fwsDnoAhu6NcBDXsk3mbGxNyo6aVLEGex+fHCv2MahY7a9g==",
2244
2244
  "cpu": [
2245
2245
  "x64"
2246
2246
  ],
@@ -8486,21 +8486,21 @@
8486
8486
  }
8487
8487
  },
8488
8488
  "node_modules/eslint-config-next": {
8489
- "version": "16.3.8",
8490
- "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.3.8.tgz",
8491
- "integrity": "sha512-81vovwMe6NGnoFsl0KUJWzlS+y239i3fdsxs49gSEX3pDQW2cuKy+fxUPXNkQqqx6OCPheYPtBlSufc9aZ0k+w==",
8489
+ "version": "16.4.6",
8490
+ "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.4.6.tgz",
8491
+ "integrity": "sha512-IBGGrVf9E6pL0NGL0hmeicVGeSyv1VEzIWq6IecDqkw+YFByhEtDJS9u1r6s6a1VxK6rssh69KyNFQUgfaacqw==",
8492
8492
  "dev": true,
8493
8493
  "license": "MIT",
8494
8494
  "dependencies": {
8495
- "@next/eslint-plugin-next": "16.3.8",
8495
+ "@next/eslint-plugin-next": "16.4.6",
8496
8496
  "eslint-import-resolver-node": "^0.3.6",
8497
8497
  "eslint-import-resolver-typescript": "^3.5.2",
8498
8498
  "eslint-plugin-import": "^2.32.0",
8499
8499
  "eslint-plugin-jsx-a11y": "^6.10.0",
8500
8500
  "eslint-plugin-react": "^7.37.0",
8501
- "eslint-plugin-react-hooks": "^7.0.0",
8501
+ "eslint-plugin-react-hooks": "^7.1.0",
8502
8502
  "globals": "16.4.0",
8503
- "typescript-eslint": "^8.46.0"
8503
+ "typescript-eslint": "^8.56.0"
8504
8504
  },
8505
8505
  "peerDependencies": {
8506
8506
  "eslint": ">=9.0.0",
@@ -11753,12 +11753,12 @@
11753
11753
  "peer": true
11754
11754
  },
11755
11755
  "node_modules/next": {
11756
- "version": "16.3.8",
11757
- "resolved": "https://registry.npmjs.org/next/-/next-16.3.8.tgz",
11758
- "integrity": "sha512-U7QEZaTini6wKrb8A8hqLLqYQyCetegKjCpJOyxk642vWoMoU1x5PyZCJFvgYgiptA8xc5j/9xYlZFO7w9Sjmw==",
11756
+ "version": "16.4.6",
11757
+ "resolved": "https://registry.npmjs.org/next/-/next-16.4.6.tgz",
11758
+ "integrity": "sha512-QZJiYhaZLJMo2KpkQGQIwvmd79WVsAWeYIU554a8d7zArS3si/IRy3lBNV/rtYhE70oLwdLYhPAXLPx8HwcwtA==",
11759
11759
  "license": "MIT",
11760
11760
  "dependencies": {
11761
- "@next/env": "16.3.8",
11761
+ "@next/env": "16.4.6",
11762
11762
  "@swc/helpers": "0.5.23",
11763
11763
  "baseline-browser-mapping": "^2.9.19",
11764
11764
  "caniuse-lite": "^1.0.30001579",
@@ -11772,15 +11772,15 @@
11772
11772
  "node": ">=20.9.0"
11773
11773
  },
11774
11774
  "optionalDependencies": {
11775
- "@next/swc-darwin-arm64": "16.3.8",
11776
- "@next/swc-darwin-x64": "16.3.8",
11777
- "@next/swc-linux-arm64-gnu": "16.3.8",
11778
- "@next/swc-linux-arm64-musl": "16.3.8",
11779
- "@next/swc-linux-x64-gnu": "16.3.8",
11780
- "@next/swc-linux-x64-musl": "16.3.8",
11781
- "@next/swc-win32-arm64-msvc": "16.3.8",
11782
- "@next/swc-win32-x64-msvc": "16.3.8",
11783
- "sharp": "^0.35.4"
11775
+ "@next/swc-darwin-arm64": "16.4.6",
11776
+ "@next/swc-darwin-x64": "16.4.6",
11777
+ "@next/swc-linux-arm64-gnu": "16.4.6",
11778
+ "@next/swc-linux-arm64-musl": "16.4.6",
11779
+ "@next/swc-linux-x64-gnu": "16.4.6",
11780
+ "@next/swc-linux-x64-musl": "16.4.6",
11781
+ "@next/swc-win32-arm64-msvc": "16.4.6",
11782
+ "@next/swc-win32-x64-msvc": "16.4.6",
11783
+ "sharp": "^0.35.5"
11784
11784
  },
11785
11785
  "peerDependencies": {
11786
11786
  "@opentelemetry/api": "^1.1.0",
@@ -26,7 +26,7 @@
26
26
  "class-variance-authority": "^0.7.1",
27
27
  "clsx": "^2.1.1",
28
28
  "lucide-react": "^0.563.0",
29
- "next": "16.3.8",
29
+ "next": "16.4.6",
30
30
  "next-themes": "^0.4.6",
31
31
  "radix-ui": "^1.4.3",
32
32
  "react": "19.2.3",
@@ -47,7 +47,7 @@
47
47
  "@types/react-dom": "^19",
48
48
  "@vitest/coverage-v8": "^4.1.11",
49
49
  "eslint": "^9",
50
- "eslint-config-next": "16.3.8",
50
+ "eslint-config-next": "16.4.6",
51
51
  "jsdom": "^29.1.1",
52
52
  "shadcn": "^3.8.4",
53
53
  "tailwindcss": "^4",
@@ -2,87 +2,28 @@ import { readdirSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { describe, expect, it } from 'vitest';
4
4
 
5
- /**
6
- * Guard: focus rings show only for keyboard users. jsdom cannot evaluate `:focus-visible` or cascade layers, so this
7
- * pins the wiring and the CSS (proven in a real browser on iAI, 2026-10-25); lib/input-modality.test.ts covers the
8
- * mode switching itself.
9
- */
10
5
  const src = join(__dirname, '..');
11
- const read = (path: string): string => readFileSync(join(src, path), 'utf8').replace(/\r\n/g, '\n');
12
- const globals = read('app/globals.css');
6
+ const read = (path: string): string => readFileSync(join(src, path), 'utf8');
13
7
 
14
- describe('focus rings are keyboard-only', () => {
15
- it('the root layout starts in pointer mode and mounts the tracker', () => {
8
+ /** Guard the scaffold wiring and keep the primitives from reintroducing a second focus indicator.
9
+ * Computed outlines, geometry, and transitions are checked in Chromium because jsdom cannot render them. */
10
+ describe('shared inset focus outline', () => {
11
+ it('starts in pointer mode and mounts the input modality tracker', () => {
16
12
  const layout = read('app/layout.tsx');
17
13
  expect(layout).toMatch(/<html[^>]*data-input="pointer"/u);
18
14
  expect(layout).toMatch(/<InputModalityTracker\s*\/>/u);
19
15
  });
20
16
 
21
- it('Tailwind focus-visible utilities never fire in pointer mode, except on text fields', () => {
22
- const variant = globals.match(/@custom-variant focus-visible \(([^\n]+)\);/u)?.[1] ?? '';
23
- expect(variant).toContain('&:focus-visible');
24
- expect(variant).toContain(":not([data-input='pointer'] *)");
25
- for (const field of ['textarea', 'select', "[contenteditable]:not([contenteditable='false'])", 'input:not(']) {
26
- expect(variant).toContain(field);
27
- }
17
+ it('keeps the default outline width and style together on the root', () => {
18
+ const globals = read('app/globals.css');
19
+ expect(globals).toMatch(/:root[ \t]*\{[ \t]*--tigra-focus-width:[^;\r\n]+;[ \t]*--tigra-focus-style:[^;\r\n]+;[ \t]*\}/u);
28
20
  });
29
21
 
30
- it('a global rule outside every cascade layer drops plain-CSS focus outlines in pointer mode', () => {
31
- const rule = globals.match(/\nhtml\[data-input='pointer'\] :focus:not\([^{]+\{\s*outline: none !important;\s*\}/u);
32
- expect(rule).not.toBeNull();
33
- const before = globals.slice(0, rule!.index);
34
- expect((before.match(/\{/gu) ?? []).length).toBe((before.match(/\}/gu) ?? []).length);
35
- });
36
-
37
- it('keyboard focus is one style everywhere: a 1px accent edge on the element and a faint tint, never outside it', () => {
38
- const rule = globals.match(/\nhtml\[data-input='keyboard'\] :focus-visible:not\(([^{]+)\) \{([^}]+)\}/u);
39
- expect(rule).not.toBeNull();
40
- const [, excluded, body] = rule!;
41
- expect(body).toContain('outline: 1px solid var(--ring) !important;');
42
- expect(body).toContain('outline-offset: -1px !important;');
43
- // `transparent` first: Tailwind's build copies the FIRST colour of a color-mix() into a fallback for browsers
44
- // without it; `var(--ring)` first would fill the whole control with the accent there.
45
- expect(body).toMatch(/box-shadow: inset 0 0 0 100vmax color-mix\(in srgb, transparent \d+%, var\(--ring\)\) !important;/u);
46
- // Menus and select options keep their highlight only; programmatic focus targets are not tab stops.
47
- for (const part of ["[role='menuitem']", "[role='option']", "[tabindex='-1']", 'textarea']) expect(excluded).toContain(part);
48
- const before = globals.slice(0, rule!.index);
49
- expect((before.match(/\{/gu) ?? []).length).toBe((before.match(/\}/gu) ?? []).length);
50
- });
51
-
52
- it('filled controls add a page-coloured line inside the edge instead of the tint', () => {
53
- // The primary fill equals --ring here, so the accent edge alone would vanish on a primary button.
54
- const filled = globals.match(/\nhtml\[data-input='keyboard'\] :is\(([^{]+)\):focus-visible \{([^}]+)\}/u);
55
- expect(filled).not.toBeNull();
56
- // Hand-styled fills count too (the welcome page's links are `bg-primary` anchors, not the UI kit's Button).
57
- for (const part of ["[data-slot='button'][data-variant='default']", "[data-slot='button'][data-variant='destructive']",
58
- '.bg-primary', '.bg-destructive']) {
59
- expect(filled![1]).toContain(part);
60
- }
61
- expect(filled![2].trim()).toBe('box-shadow: inset 0 0 0 2px var(--background) !important;');
62
- // Same specificity as the general rule, so it must come after it to win.
63
- expect(filled!.index).toBeGreaterThan(globals.indexOf("\nhtml[data-input='keyboard'] :focus-visible:not("));
64
- });
65
-
66
- it('text fields show focus by their border turning accent, never a glow outside the field', () => {
67
- // Text fields keep a focus look for mouse users too (you need to see where you type), so it follows the same
68
- // "nothing outside the element" rule: accent border on focus, red border when invalid, no ring.
69
- const input = read('components/ui/input.tsx');
70
- expect(input).toContain('focus-visible:border-ring');
71
- expect(input).toContain('aria-invalid:border-destructive');
72
- expect(input).not.toMatch(/focus-visible:ring|aria-invalid:ring/u);
73
- });
74
-
75
- it('a focused invalid field keeps its red border and gets a faint red tint, so focus stays visible', () => {
76
- // The red border is the same with or without focus; without the old red glow, the tint is what marks focus.
77
- const rule = globals.match(/\n:is\(([^{]+)\)\[aria-invalid='true'\]:focus-visible \{([^}]+)\}/u);
78
- expect(rule).not.toBeNull();
79
- for (const field of ['textarea', 'select', 'input:not(']) expect(rule![1]).toContain(field);
80
- expect(rule![2]).toMatch(/box-shadow: inset 0 0 0 100vmax color-mix\(in srgb, transparent \d+%, var\(--destructive\)\) !important;/u);
81
- });
82
-
83
- it('no UI kit component draws a ring on plain :focus (it would show on every mouse click)', () => {
84
- const offenders = readdirSync(join(src, 'components/ui')).filter((file) => file.endsWith('.tsx'))
85
- .filter((file) => /(^|[\s"'`])focus:(ring|outline-(?!hidden|none))/u.test(read(`components/ui/${file}`)));
22
+ it('keeps competing focus rings, outlines and shadows out of the UI primitives', () => {
23
+ const directory = 'components/ui';
24
+ const focusPaint = /(?:^|[\s"'`])(?:[\w-]+:)*(?:focus|focus-visible|focus-within|aria-invalid):(?:ring|outline|shadow)(?=[-\s"'`])/u;
25
+ const offenders = readdirSync(join(src, directory))
26
+ .filter(file => file.endsWith('.tsx') && focusPaint.test(read(directory + '/' + file)));
86
27
  expect(offenders).toEqual([]);
87
28
  });
88
- });
29
+ });
@@ -29,11 +29,8 @@
29
29
 
30
30
  @custom-variant dark (&:is(.dark *));
31
31
 
32
- /* Focus rings are for keyboard users. Tailwind's own focus-visible variant is replaced so that every `focus-visible:`
33
- * utility (rings, borders) stays off while the page is in pointer mode (`<html data-input>`, set by
34
- * lib/input-modality.ts). Text fields keep their focus look in every mode: it shows where the visitor is typing.
35
- * Static selection rings (a plain `ring-2`) are untouched; see "Focus rings" at the end of this file for plain-CSS
36
- * outlines. */
32
+ /* Keep the modality distinction for Tailwind focus utilities that change other affordances, such as text or
33
+ * backgrounds. The focus outline itself is shared below. */
37
34
  @custom-variant focus-visible (&:focus-visible:where(:not([data-input='pointer'] *), textarea, select, [contenteditable]:not([contenteditable='false']), input:not([type='button'], [type='submit'], [type='reset'], [type='checkbox'], [type='radio'], [type='range'], [type='file'], [type='color'], [type='image'])));
38
35
 
39
36
  @theme inline {
@@ -113,41 +110,67 @@
113
110
  }
114
111
  }
115
112
 
116
- /* Focus rings. Radix menus and selects move focus by script after a mouse click, and Chrome then reports
117
- * `:focus-visible`, so keyboard-only rings appeared for mouse users. In pointer mode (lib/input-modality.ts) no focused
118
- * element draws an outline, except text fields. Unlayered and !important on purpose: it must beat Tailwind's layered
119
- * utilities and any CSS module's `:focus-visible { outline }`. Keyboard mode always shows focus (WCAG 2.4.7), in the
120
- * one style defined below. */
121
- html[data-input='pointer'] :focus:not(textarea, select, [contenteditable]:not([contenteditable='false']), input:not([type='button'], [type='submit'], [type='reset'], [type='checkbox'], [type='radio'], [type='range'], [type='file'], [type='color'], [type='image'])) {
122
- outline: none !important;
113
+ /* Focus outline. Adjust its width and style here. The inset follows the width. */
114
+ :root { --tigra-focus-width: 1px; --tigra-focus-style: solid; }
115
+
116
+ /* Set geometry and ink before focus so transition-all cannot interpolate from the browser's outside outline.
117
+ * Focus changes only outline-style. Keep these rules outside Tailwind's layers to own the browser outline. */
118
+ :where(a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex='-1']), [contenteditable], [data-focus-surface]) {
119
+ --tigra-focus-ink: var(--ring, currentColor);
120
+ --tigra-focus-clearance: 0px;
121
+ outline-width: var(--tigra-focus-width) !important;
122
+ outline-offset: calc(0px - var(--tigra-focus-width) - var(--tigra-focus-clearance)) !important;
123
+ outline-color: var(--tigra-focus-ink) !important;
124
+ outline-style: none !important;
125
+
126
+ @media (forced-colors: active) {
127
+ outline-color: Highlight !important;
128
+ }
123
129
  }
124
130
 
125
- /* Keyboard focus: one style everywhere. A 1px accent line drawn exactly on the element's edge (it covers a 1px border,
126
- * or hugs a borderless edge) and a faint accent tint painted under the content (an inset shadow, so backgrounds and
127
- * images stay). Nothing grows outside the element. Replaces the browser's default ring and the UI kit's
128
- * `focus-visible:ring-*` rings while the keyboard is in use.
129
- * Not here: text fields (their border turns accent, components/ui/input.tsx), menu items and select options (their highlight is the focus), and
130
- * focus targets that are not tab stops (tabindex -1: a main region after a skip link, menus, dialogs).
131
- * `transparent` comes first in the color-mix() on purpose: Tailwind's build copies the first colour into a fallback for
132
- * browsers without color-mix(), so those get no tint (just the edge) instead of a control filled with the accent. */
133
- html[data-input='keyboard'] :focus-visible:not(textarea, select, [contenteditable]:not([contenteditable='false']), input:not([type='button'], [type='submit'], [type='reset'], [type='checkbox'], [type='radio'], [type='range'], [type='file'], [type='color'], [type='image']), [role='menuitem'], [role='menuitemcheckbox'], [role='menuitemradio'], [role='option'], [tabindex='-1']) {
134
- outline: 1px solid var(--ring) !important;
135
- outline-offset: -1px !important;
136
- box-shadow: inset 0 0 0 100vmax color-mix(in srgb, transparent 92%, var(--ring)) !important;
131
+ /* Use the ink that already contrasts with a filled surface. Error fields reserve a pixel so their border still
132
+ * shows when the outline appears. On a compound field, the designated direct child supplies the error state. */
133
+ :where(a[href], button, [tabindex]):where(.bg-primary, .bg-destructive) {
134
+ --tigra-focus-ink: currentColor;
137
135
  }
138
136
 
139
- /* Filled controls (primary and destructive buttons, hand-styled `bg-primary` / `bg-destructive` links and buttons;
140
- * shadcn checkboxes and switches once added): the primary fill is the ring colour, so the edge alone would vanish, and
141
- * a tint does not show on a strong fill. They keep the edge above and get a 1px page-coloured line just inside it,
142
- * which reads on any fill. Same specificity as the rule above, so it must stay after it. */
143
- html[data-input='keyboard'] :is([data-slot='button'][data-variant='default'], [data-slot='button'][data-variant='destructive'], .bg-primary, .bg-destructive, [data-slot='checkbox'][data-state='checked'], [data-slot='switch'][data-state='checked']):focus-visible {
144
- box-shadow: inset 0 0 0 2px var(--background) !important;
137
+ :where([data-slot='checkbox'], [data-slot='switch']):where([data-state='checked']) {
138
+ --tigra-focus-ink: var(--primary-foreground, currentColor);
145
139
  }
146
140
 
147
- /* Text fields show focus on their own border (accent, components/ui/input.tsx), for mouse and keyboard alike. An
148
- * invalid field's border stays red with or without focus, so a focused one also gets a faint red tint inside;
149
- * otherwise a keyboard user could not see which field with an error they are in. `transparent` first for the same
150
- * fallback reason as above. */
151
- :is(textarea, select, input:not([type='button'], [type='submit'], [type='reset'], [type='checkbox'], [type='radio'], [type='range'], [type='file'], [type='color'], [type='image']))[aria-invalid='true']:focus-visible {
152
- box-shadow: inset 0 0 0 100vmax color-mix(in srgb, transparent 92%, var(--destructive)) !important;
141
+ :where([aria-invalid='true'], [data-focus-surface]:has(> [data-focus-delegate][aria-invalid='true'])) {
142
+ --tigra-focus-ink: var(--foreground, currentColor);
143
+ --tigra-focus-clearance: 1px;
153
144
  }
145
+
146
+ /* Keep text entry visible after a pointer press. Other controls use the tracker because Radix can move pointer
147
+ * focus by script and still match :focus-visible. Menu and option rows keep their own highlight. */
148
+ :is(
149
+ :focus:where(textarea, select, [contenteditable]:not([contenteditable='false']),
150
+ input:not([type='button'], [type='submit'], [type='reset'], [type='checkbox'], [type='radio'], [type='range'], [type='file'], [type='color'], [type='image'])),
151
+ html:not([data-input='pointer']) :focus-visible:where(a[href], button, input, select, textarea, summary,
152
+ [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']))
153
+ ):not(:where([data-focus-surface] > [data-focus-delegate], [role='menuitem'], [role='menuitemcheckbox'], [role='menuitemradio'], [role='option'])) {
154
+ outline-style: var(--tigra-focus-style) !important;
155
+ }
156
+
157
+ /* Radix options are programmatic tab stops. Their highlight replaces the browser outline. */
158
+ :where([role='menuitem'], [role='menuitemcheckbox'], [role='menuitemradio'], [role='option']):focus {
159
+ outline-style: none !important;
160
+ }
161
+
162
+ /* A direct child delegates the outline to its visible surface while keeping its original tab stop. */
163
+ [data-focus-surface]:has(> [data-focus-delegate]:focus:where(textarea, select, [contenteditable]:not([contenteditable='false']),
164
+ input:not([type='button'], [type='submit'], [type='reset'], [type='checkbox'], [type='radio'], [type='range'], [type='file'], [type='color'], [type='image']))),
165
+ html:not([data-input='pointer']) [data-focus-surface]:has(> [data-focus-delegate]:focus-visible) {
166
+ outline-style: var(--tigra-focus-style) !important;
167
+ }
168
+
169
+ /* Forced colors replace custom backgrounds. Give the existing row highlight the system selection colors. */
170
+ @media (forced-colors: active) {
171
+ :where([role='menuitem'], [role='menuitemcheckbox'], [role='menuitemradio'], [role='option']):is(:focus, [data-highlighted]) {
172
+ forced-color-adjust: none;
173
+ background-color: Highlight;
174
+ color: HighlightText;
175
+ }
176
+ }
@@ -5,7 +5,7 @@ import { Slot } from "radix-ui"
5
5
  import { cn } from "@/lib/utils"
6
6
 
7
7
  const badgeVariants = cva(
8
- "inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
8
+ "inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
9
9
  {
10
10
  variants: {
11
11
  variant: {
@@ -13,7 +13,7 @@ const badgeVariants = cva(
13
13
  secondary:
14
14
  "bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
15
15
  destructive:
16
- "bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
16
+ "bg-destructive text-white [a&]:hover:bg-destructive/90 dark:bg-destructive/60",
17
17
  outline:
18
18
  "border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
19
19
  ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
@@ -5,13 +5,13 @@ import { Slot } from "radix-ui"
5
5
  import { cn } from "@/lib/utils"
6
6
 
7
7
  const buttonVariants = cva(
8
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
8
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 aria-invalid:border-destructive",
9
9
  {
10
10
  variants: {
11
11
  variant: {
12
12
  default: "bg-primary text-primary-foreground hover:bg-primary/90",
13
13
  destructive:
14
- "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
14
+ "bg-destructive text-white hover:bg-destructive/90 dark:bg-destructive/60",
15
15
  outline:
16
16
  "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
17
17
  secondary:
@@ -8,9 +8,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
8
8
  type={type}
9
9
  data-slot="input"
10
10
  className={cn(
11
- "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
12
- // Focus and errors show on the field's own border, never as a glow outside it (globals.css "Focus rings").
13
- "focus-visible:border-ring",
11
+ "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
14
12
  "aria-invalid:border-destructive",
15
13
  className
16
14
  )}
@@ -37,7 +37,7 @@ function SelectTrigger({
37
37
  data-slot="select-trigger"
38
38
  data-size={size}
39
39
  className={cn(
40
- "border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
40
+ "border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
41
41
  className
42
42
  )}
43
43
  {...props}
@@ -109,7 +109,7 @@ function SelectItem({
109
109
  <SelectPrimitive.Item
110
110
  data-slot="select-item"
111
111
  className={cn(
112
- "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
112
+ "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
113
113
  className
114
114
  )}
115
115
  {...props}
@@ -1,6 +1,6 @@
1
1
  /**
2
- * How the visitor last interacted with the page, kept on `<html data-input="pointer" | "keyboard">`, so focus rings
3
- * show only for keyboard users (globals.css "Focus rings").
2
+ * How the visitor last interacted with the page, kept on `<html data-input="pointer" | "keyboard">`.
3
+ * The shared focus policy uses this for navigation controls. Text entry keeps its outline in either mode.
4
4
  *
5
5
  * Why the browser's own `:focus-visible` is not enough: Radix menus and selects cancel the default of the mouse press
6
6
  * on their trigger and then move focus by script (into the menu, then to the item under the pointer). Chrome then has