* feat(inbox): skip AI extraction for multi-page PDFs (#553) Bedrock churns for minutes on multi-page PDFs (sales reports, bank statements, contracts) and returns nothing useful. Above 3 pages we now skip extraction entirely and mark the row with extraction_skipped=true; the document still lands in the inbox and can be attached or converted manually. Same gate applies to the /items/:id/attach path. Client can also opt out via skip_extraction=true (skip_reason=client_opt_out). The InvoiceInboxWorkspace renders an "Inte AI-tolkad" badge for skipped rows, distinct from the "Felaktig" failure state (status='error'). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(ui): introduce DataList + DropdownMenu primitives, roll out across list pages DataList replaces the per-row Card pattern across Granskning, Transactions, Invoices, Supplier invoices, and Pending. One bordered container with hairline rows matches the flat-with-hairlines aesthetic in CLAUDE.md — no shadows, no state-tinted borders, secondary token for selected/hover. DropdownMenu fills the gap for row-level action menus on TransactionInboxCard, TransactionHistoryList, and the page-level action menus on /transactions and /pending. Replaces ad-hoc Popover + buttons constructions. Migrates list pages and the transaction inbox/history components onto the new primitives. No behavior change beyond the visual unification. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: add agent skills + gnubok domain skills, gitignore compliance reports .agents/skills/ + skills-lock.json + symlinks under .claude/skills/ check in the vercel-labs/agent-skills set pinned by the local skill manager (deploy-to-vercel, vercel-cli-with-tokens, react-best-practices, composition-patterns, react-native-skills, react-view-transitions, web-design-guidelines). Keeps the team on the same versions. .claude/skills/industry/ + .claude/skills/modifier/ are hand-authored vertical and entity-modifier skills for the specialized accountant agent — industries (konsult-it, e-handel, bygg-hantverk, reklambyra, saas-ai) and entity overlays (holding-ab, single-shareholder-ab-fmb, mixed- verksamhet). Project-owned content; lives in the repo by design. Also gitignores .compliance-reports/ — those are large generated SARIF/dossier artifacts from the compliance scanner. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(transactions): unify inbox/history chrome, drop swipe flow The transactions page mixed two-tier filtering, a swipe-view detour, and per-row Card chrome that didn't carry its weight. This pass collapses those into a single editorial-list surface and removes the unused swipe path entirely. User-visible changes: - Mode toggle (Att bokföra / Alla transaktioner) moved from a Tabs row under the header into a dropdown to the right of a unified search bar. Search now persists when switching modes. - Removed the swipe categorization view ("Gå igenom alla") and its trigger button. The 800-line SwipeCategorizationView component is deleted; suggestion-fetching shrinks to what the template picker still consumes. - Inbox rows now show one primary action: invoice/supplier-invoice match shortcut when auto-detected, else "Bokför". A new visible Link2 icon button opens the customer or supplier invoice picker manually (chosen by amount sign). Delete becomes a plain trash button — no overflow menu since it only ever held one item. - Bulk action bar swaps "Markera som privat" for "Ta bort" with a single combined confirmation. - Built SupplierInvoicePicker mirroring InvoicePicker so expense transactions can be matched to supplier invoices from the inbox. Wired through /api/transactions/{id}/match-supplier-invoice. - Template picker dialog renamed to "Bokför transaktion"; "Bokför manuellt…" and "Matcha med faktura…" promoted from muted ghost buttons at the bottom to outline buttons at the top, above the template list. - Breathing room: row padding py-3 → py-4, primary text text-sm → text-base, amount text-base, button heights h-8 → h-9, trailing gap-2 → gap-3 (in the DataList primitive itself, so every list benefits slightly). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: align package-lock.json with merged package.json The merge resolution took origin/main's package-lock.json (which dropped pdf-lib) but kept our package.json (which still requires pdf-lib for the invoice-inbox extension's PDFDocument import). `npm ci` rejected the mismatch. Regenerate the lock from the merged package.json so both files agree. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: regenerate package-lock.json with npm@10 for CI compat Local npm@11 produced a lock that npm@10 (CI) rejected with "Missing: @swc/helpers@0.5.21". Regenerated with npm@10 --package-lock-only so CI can install. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(transactions): supplier-invoice status-leak guard + drop dead prop Two follow-ups from the merge-risk audit: - SupplierInvoicePicker now mirrors InvoicePicker's status-leak guard: if a supplier invoice is still 'approved'/'overdue' but already has a payment voucher attached (journal_entry_id on supplier_invoice_payments), hide it. Closes a UX race window between payment and status flip. Partially-paid invoices still pass through. - Drop the unused onMarkPrivate prop on TransactionInboxCard and the matching handleMarkPrivate wrapper in the parent. Both became dead when the swipe-categorisation flow was removed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
177 lines
5.7 KiB
Markdown
177 lines
5.7 KiB
Markdown
# View Transitions in Next.js
|
|
|
|
## Setup
|
|
|
|
`<ViewTransition>` works out of the box for `startTransition`/`Suspense` updates. To also animate `<Link>` navigations:
|
|
|
|
```js
|
|
// next.config.js
|
|
const nextConfig = {
|
|
experimental: { viewTransition: true },
|
|
};
|
|
module.exports = nextConfig;
|
|
```
|
|
|
|
This wraps every `<Link>` navigation in `document.startViewTransition`. Any VT with `default="auto"` fires on **every** link click — use `default="none"` to prevent competing animations.
|
|
|
|
Do **not** install `react@canary` — see SKILL.md "Availability" for details.
|
|
|
|
---
|
|
|
|
## Next.js Implementation Additions
|
|
|
|
When following `implementation.md`, apply these additions:
|
|
|
|
**After Step 2:** Enable the experimental flag above.
|
|
|
|
**Step 4:** Use `transitionTypes` on `<Link>` — see "The `transitionTypes` Prop" section below for usage and availability.
|
|
|
|
**After Step 6:** For same-route dynamic segments (e.g., `/collection/[slug]`), use the `key` + `name` + `share` pattern — see Same-Route Dynamic Segment Transitions below.
|
|
|
|
---
|
|
|
|
## Layout-Level ViewTransition
|
|
|
|
**Do NOT add a layout-level VT wrapping `{children}` if pages have their own VTs.** Nested VTs never fire enter/exit when inside a parent VT — page-level enter/exit will silently not work. Remove the layout VT entirely.
|
|
|
|
A bare `<ViewTransition>` in layout works only if pages have **no** VTs of their own.
|
|
|
|
**Layouts persist across navigations** — `enter`/`exit` only fire on initial mount, not on route changes. Don't use type-keyed maps in layouts.
|
|
|
|
---
|
|
|
|
## The `transitionTypes` Prop on `next/link`
|
|
|
|
No wrapper component needed, works in Server Components:
|
|
|
|
```tsx
|
|
<Link href="/products/1" transitionTypes={['transition-to-detail']}>View Product</Link>
|
|
```
|
|
|
|
Replaces the manual pattern of `onNavigate` + `startTransition` + `addTransitionType` + `router.push()`. Reserve manual `startTransition` for non-link interactions (buttons, forms).
|
|
|
|
**Availability:** `transitionTypes` requires `experimental.viewTransition: true` and is available in Next.js 15+ canary builds and Next.js 16+. If unavailable, use `startTransition` + `addTransitionType` + `router.push()` (see Programmatic Navigation below). To check: `grep -r "transitionTypes" node_modules/next/dist/` — if no results, fall back to programmatic navigation.
|
|
|
|
---
|
|
|
|
## Programmatic Navigation
|
|
|
|
```tsx
|
|
'use client';
|
|
|
|
import { useRouter } from 'next/navigation';
|
|
import { startTransition, addTransitionType } from 'react';
|
|
|
|
function handleNavigate(href: string) {
|
|
const router = useRouter();
|
|
startTransition(() => {
|
|
addTransitionType('nav-forward');
|
|
router.push(href);
|
|
});
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Server-Side Filtering with `router.replace`
|
|
|
|
For search/sort/filter that re-renders on the server (via URL params), use `startTransition` + `router.replace`. VTs activate because the state update is inside `startTransition`:
|
|
|
|
```tsx
|
|
'use client';
|
|
|
|
import { useRouter } from 'next/navigation';
|
|
import { startTransition } from 'react';
|
|
|
|
function handleSort(sort: string) {
|
|
const router = useRouter();
|
|
startTransition(() => {
|
|
router.replace(`?sort=${sort}`);
|
|
});
|
|
}
|
|
```
|
|
|
|
List items wrapped in `<ViewTransition key={item.id}>` will animate reorder. This is the server-component alternative to the client-side `useDeferredValue` pattern in `patterns.md`.
|
|
|
|
---
|
|
|
|
## Two-Layer Pattern (Directional + Suspense)
|
|
|
|
Directional slides + Suspense reveals coexist because they fire at different moments. Place the directional VT in the **page component** (not layout):
|
|
|
|
```tsx
|
|
<ViewTransition
|
|
enter={{ "nav-forward": "slide-from-right", default: "none" }}
|
|
exit={{ "nav-forward": "slide-to-left", default: "none" }}
|
|
default="none"
|
|
>
|
|
<div>
|
|
<Suspense fallback={<ViewTransition exit="slide-down"><Skeleton /></ViewTransition>}>
|
|
<ViewTransition enter="slide-up" default="none"><Content /></ViewTransition>
|
|
</Suspense>
|
|
</div>
|
|
</ViewTransition>
|
|
```
|
|
|
|
---
|
|
|
|
## `loading.tsx` as Suspense Boundary
|
|
|
|
Next.js `loading.tsx` is an implicit `<Suspense>` boundary. Wrap the skeleton in `<ViewTransition exit="...">` in `loading.tsx`, and the content in `<ViewTransition enter="..." default="none">` in the page:
|
|
|
|
```tsx
|
|
// loading.tsx
|
|
<ViewTransition exit="slide-down"><PhotoGridSkeleton /></ViewTransition>
|
|
|
|
// page.tsx
|
|
<ViewTransition enter="slide-up" default="none"><PhotoGrid photos={photos} /></ViewTransition>
|
|
```
|
|
|
|
Same rules as explicit `<Suspense>`: use simple string props (not type maps) since Suspense reveals fire without transition types.
|
|
|
|
---
|
|
|
|
## Shared Elements Across Routes
|
|
|
|
```tsx
|
|
// List page
|
|
{products.map((product) => (
|
|
<Link key={product.id} href={`/products/${product.id}`} transitionTypes={['nav-forward']}>
|
|
<ViewTransition name={`product-${product.id}`}>
|
|
<Image src={product.image} alt={product.name} width={400} height={300} />
|
|
</ViewTransition>
|
|
</Link>
|
|
))}
|
|
|
|
// Detail page — same name
|
|
<ViewTransition name={`product-${product.id}`}>
|
|
<Image src={product.image} alt={product.name} width={800} height={600} />
|
|
</ViewTransition>
|
|
```
|
|
|
|
---
|
|
|
|
## Same-Route Dynamic Segment Transitions
|
|
|
|
When navigating between dynamic segments of the same route (e.g., `/collection/[slug]`), the page stays mounted — enter/exit never fire. Use `key` + `name` + `share`:
|
|
|
|
```tsx
|
|
<Suspense fallback={<Skeleton />}>
|
|
<ViewTransition key={slug} name={`collection-${slug}`} share="auto" default="none">
|
|
<Content slug={slug} />
|
|
</ViewTransition>
|
|
</Suspense>
|
|
```
|
|
|
|
- `key={slug}` forces unmount/remount on change
|
|
- `name` + `share="auto"` creates a shared element crossfade
|
|
- VT inside `<Suspense>` (without keying Suspense) keeps old content visible during loading
|
|
|
|
---
|
|
|
|
## Server Components
|
|
|
|
- `<ViewTransition>` works in both Server and Client Components
|
|
- `<Link transitionTypes>` works in Server Components — no `'use client'` needed
|
|
- `addTransitionType` and `startTransition` for programmatic nav require Client Components
|