@krizaka/ui 4.5.0 → 4.6.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 (45) hide show
  1. package/dist/account-settings.js +56 -43
  2. package/dist/account-settings.js.map +1 -1
  3. package/dist/{chunk-CZHPWLNW.js → chunk-WKQ5CB3I.js} +18 -5
  4. package/dist/chunk-WKQ5CB3I.js.map +1 -0
  5. package/dist/columns.js +3 -1
  6. package/dist/columns.js.map +1 -1
  7. package/dist/comparison-table.js +3 -3
  8. package/dist/comparison-table.js.map +1 -1
  9. package/dist/filter-bar.d.ts +3 -3
  10. package/dist/kind-config-editor.js +1 -1
  11. package/dist/nav-bar.d.ts +1 -1
  12. package/dist/notification-preferences.js +1 -1
  13. package/dist/router.js +2 -2
  14. package/dist/router.js.map +1 -1
  15. package/dist/schema-form.js +1 -1
  16. package/dist/shop-composer.d.ts +2 -2
  17. package/dist/site-cahier.d.ts +2 -0
  18. package/dist/site-cahier.js +2 -1
  19. package/dist/site-cahier.js.map +1 -1
  20. package/dist/site-footer.d.ts +52 -6
  21. package/dist/site-footer.js +98 -60
  22. package/dist/site-footer.js.map +1 -1
  23. package/dist/{sites-iJkCPeiH.d.ts → sites-BPshUouf.d.ts} +2 -2
  24. package/dist/switch.d.ts +25 -3
  25. package/dist/switch.js +1 -1
  26. package/dist/virtual.d.ts +3 -3
  27. package/package.json +11 -11
  28. package/registry/app-frame.json +1 -1
  29. package/registry/columns.json +1 -1
  30. package/registry/comparison-table.json +1 -1
  31. package/registry/examples/site-footer/family.d.ts +4 -0
  32. package/registry/examples/site-footer/family.js +25 -0
  33. package/registry/examples/site-footer/family.tsx +28 -0
  34. package/registry/examples/switch/row.d.ts +4 -0
  35. package/registry/examples/switch/row.js +14 -0
  36. package/registry/examples/switch/row.tsx +13 -0
  37. package/registry/index.json +9 -9
  38. package/registry/map.json +1 -1
  39. package/registry/nav-bar.json +1 -1
  40. package/registry/rail-nav.json +1 -1
  41. package/registry/router.json +1 -1
  42. package/registry/shop.json +1 -1
  43. package/registry/site-footer.json +306 -5
  44. package/registry/switch.json +43 -6
  45. package/dist/chunk-CZHPWLNW.js.map +0 -1
@@ -195,7 +195,7 @@
195
195
  "files": [
196
196
  {
197
197
  "path": "columns/columns.tsx",
198
- "content": "// Server-safe. Layouts that decide on the width of the room they sit in — their container, never the viewport or a device —\n// like the native `Grid` and `Columns` (src/native/grid.tsx), with the same props and the same size classes\n// (compact < 600 px, regular < 840 px, expanded from there). No JS measures anything: `Grid` is a CSS container\n// (`@container`) whose columns come from the size class of that container, and `Columns` stacks by container-relative\n// sizing (a `flex-basis` that is huge below the width the columns need and zero above it). Every width is in `rem`, so a\n// larger text size grows the room an item needs: at 200 % a card that held two per row stacks into one. The order is the\n// reading order and it mirrors in `rtl`: no physical edge is used.\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\n/** The size class of a container: where each one begins, in px of the room (Material's window size classes, as on native). */\nexport const SIZE_CLASS_FROM = { regular: 600, expanded: 840 } as const;\n\n/** The gap tokens, in px — the spacing scale (`gap-1` … `gap-6`), the same numbers as native. */\nexport const GRID_GAPS = { none: 0, xs: 4, sm: 8, md: 12, lg: 16, xl: 24 } as const;\nexport type GridGap = keyof typeof GRID_GAPS;\n\n/** How many columns per size class, or one number for all. A size class left out takes the one before it (compact → regular → expanded). */\nexport type GridColumns = number | Partial<Record<\"compact\" | \"regular\" | \"expanded\", number>>;\n\n/** One column on a compact room, two on a regular one, three on an expanded one. */\nexport const DEFAULT_COLUMNS = { compact: 1, regular: 2, expanded: 3 } as const;\n\nconst PX_PER_REM = 16;\nconst rem = (px: number) => `${px / PX_PER_REM}rem`;\n\nexport const columnsLayout = tv({\n slots: {\n // `@container`: the grid reads the width of this element. The track inside switches its columns at its widths.\n grid: \"@container w-full min-w-0\",\n track:\n \"grid [--kz-grid-cols:var(--kz-grid-compact)] @min-[600px]:[--kz-grid-cols:var(--kz-grid-regular)] @min-[840px]:[--kz-grid-cols:var(--kz-grid-expanded)]\",\n cell: \"flex min-w-0 flex-col\",\n columns: \"flex w-full min-w-0 flex-wrap\",\n column: \"min-w-0\",\n },\n variants: {\n gap: Object.fromEntries(\n Object.entries({ none: \"gap-0\", xs: \"gap-1\", sm: \"gap-2\", md: \"gap-3\", lg: \"gap-4\", xl: \"gap-6\" }).map(([name, cls]) => [name, { track: cls, columns: cls }]),\n ) as Record<GridGap, { track: string; columns: string }>,\n equalHeight: { true: { track: \"items-stretch\", cell: \"*:flex-1\" }, false: { track: \"items-start\" } },\n },\n});\n\n/** The columns of a size class: a size class left out takes the one before it. */\nexport function columnsFor(columns: GridColumns | undefined, sizeClass: keyof typeof DEFAULT_COLUMNS): number {\n const asked = columns ?? DEFAULT_COLUMNS;\n if (typeof asked === \"number\") return Math.max(1, Math.floor(asked));\n const order = [\"compact\", \"regular\", \"expanded\"] as const;\n for (let i = order.indexOf(sizeClass); i >= 0; i--) {\n const value = asked[order[i] as (typeof order)[number]];\n if (value) return Math.max(1, Math.floor(value));\n }\n return 1;\n}\n\nexport type GridProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** The items. Each is one cell. */\n children: React.ReactNode;\n /** Columns per size class of the container the grid is in (default 1 · 2 · 3), or one number. A ceiling: it drops when `minItemWidth` does not fit. */\n columns?: GridColumns;\n /** No cell is narrower than this, in px (default 160); it grows with the text scale. */\n minItemWidth?: number;\n /** The space between cells (default `md`). */\n gap?: GridGap;\n /** The most columns, whatever the container (default 6). */\n maxColumns?: number;\n /** The cells of a row are as tall as the tallest (default true); `false` lets each keep its own height. */\n equalHeight?: boolean;\n /** The text scale to lay out for, on top of the browser's (widths are in `rem`, so a larger text size is followed already). Pass 2 to see 200 % text. */\n fontScale?: number;\n};\n\n/**\n * A grid that fits its container: the columns come from the size class of the container's width, and no cell is narrower\n * than `minItemWidth`, so nothing overflows in a page, a side panel or a split. The order mirrors in right-to-left.\n */\nexport function Grid({ children, columns, minItemWidth = 160, gap = \"md\", maxColumns = 6, equalHeight = true, fontScale = 1, \"aria-label\": label, className, style, ...props }: GridProps) {\n const s = columnsLayout({ gap, equalHeight });\n const items = React.Children.toArray(children);\n const cap = Math.max(1, Math.floor(maxColumns));\n const at = (sizeClass: keyof typeof DEFAULT_COLUMNS) => Math.min(columnsFor(columns, sizeClass), cap);\n const vars = {\n \"--kz-grid-compact\": at(\"compact\"),\n \"--kz-grid-regular\": at(\"regular\"),\n \"--kz-grid-expanded\": at(\"expanded\"),\n \"--kz-grid-min\": rem(minItemWidth * Math.max(1, fontScale)),\n \"--kz-grid-gap\": rem(GRID_GAPS[gap]),\n // As many tracks as `--kz-grid-cols` allows, none narrower than the minimum: the ceiling drops on its own.\n gridTemplateColumns:\n \"repeat(auto-fill, minmax(max(var(--kz-grid-min), calc((100% - (var(--kz-grid-cols) - 1) * var(--kz-grid-gap)) / var(--kz-grid-cols))), 1fr))\",\n } as React.CSSProperties;\n return (\n <div className={s.grid({ className })} style={style} {...props}>\n <div className={s.track()} style={vars} role={label ? \"list\" : undefined} aria-label={label}>\n {items.map((child, index) => (\n <div key={React.isValidElement(child) && child.key != null ? child.key : index} className={s.cell()} role={label ? \"listitem\" : undefined}>\n {child}\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nexport type ColumnsProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** The columns, in reading order (the first is at the start edge, on the right in right-to-left). */\n children: React.ReactNode;\n /** The share of each column (default equal); `[1, 2]` is a third and two thirds. */\n weights?: readonly number[];\n /** Below this width per column, in px, the columns stack top to bottom (default 280); it grows with the text scale. */\n minColumnWidth?: number;\n /** The space between columns, and between stacked ones (default `lg`). */\n gap?: GridGap;\n /** The text scale to lay out for, on top of the browser's. Pass 2 to see 200 % text. */\n fontScale?: number;\n};\n\n/** The width, in px, that `count` columns need to sit side by side. */\nexport function columnsNeed(count: number, minColumnWidth: number, gapPx: number, fontScale = 1): number {\n return count * minColumnWidth * Math.max(1, fontScale) + gapPx * (count - 1);\n}\n\n/**\n * A few columns that sit side by side when their container holds them and stack when it does not — the master and the\n * detail, a form and its summary. Stacked, they keep their order and each takes the full width.\n */\nexport function Columns({ children, weights, minColumnWidth = 280, gap = \"lg\", fontScale = 1, className, style, ...props }: ColumnsProps) {\n const s = columnsLayout({ gap });\n const items = React.Children.toArray(children);\n const need = columnsNeed(items.length, minColumnWidth, GRID_GAPS[gap], fontScale);\n const side = items.length > 1;\n return (\n <div\n className={s.columns({ className })}\n style={{ \"--kz-columns-need\": rem(need), ...style } as React.CSSProperties}\n data-layout=\"columns\"\n {...props}\n >\n {items.map((child, index) => (\n <div\n key={React.isValidElement(child) && child.key != null ? child.key : index}\n className={s.column()}\n // Container-relative: a basis above the row's width wraps the column onto its own line (stacked, full width);\n // below it the basis is 0 and the free space is shared by weight.\n style={{ flexGrow: weights?.[index] ?? 1, flexBasis: side ? \"calc((var(--kz-columns-need) - 100%) * 999)\" : \"100%\" }}\n >\n {child}\n </div>\n ))}\n </div>\n );\n}\n"
198
+ "content": "// Server-safe. Layouts that decide on the width of the room they sit in — their container, never the viewport or a device —\n// like the native `Grid` and `Columns` (src/native/grid.tsx), with the same props and the same size classes\n// (compact < 600 px, regular < 840 px, expanded from there). No JS measures anything: `Grid` is a CSS container\n// (`@container`) whose columns come from the size class of that container, and `Columns` stacks by container-relative\n// sizing (a `flex-basis` that is huge below the width the columns need and zero above it). Every width is in `rem`, so a\n// larger text size grows the room an item needs: at 200 % a card that held two per row stacks into one. The order is the\n// reading order and it mirrors in `rtl`: no physical edge is used.\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\n/** The size class of a container: where each one begins, in px of the room (Material's window size classes, as on native). */\nexport const SIZE_CLASS_FROM = { regular: 600, expanded: 840 } as const;\n\n/** The gap tokens, in px — the spacing scale (`gap-1` … `gap-6`), the same numbers as native. */\nexport const GRID_GAPS = { none: 0, xs: 4, sm: 8, md: 12, lg: 16, xl: 24 } as const;\nexport type GridGap = keyof typeof GRID_GAPS;\n\n/** How many columns per size class, or one number for all. A size class left out takes the one before it (compact → regular → expanded). */\nexport type GridColumns = number | Partial<Record<\"compact\" | \"regular\" | \"expanded\", number>>;\n\n/** One column on a compact room, two on a regular one, three on an expanded one. */\nexport const DEFAULT_COLUMNS = { compact: 1, regular: 2, expanded: 3 } as const;\n\nconst PX_PER_REM = 16;\nconst rem = (px: number) => `${px / PX_PER_REM}rem`;\n\nexport const columnsLayout = tv({\n slots: {\n // `@container`: the grid reads the width of this element. The track inside switches its columns at its widths.\n grid: \"@container w-full min-w-0\",\n track:\n \"grid [--kz-grid-cols:var(--kz-grid-compact)] @min-[600px]:[--kz-grid-cols:var(--kz-grid-regular)] @min-[840px]:[--kz-grid-cols:var(--kz-grid-expanded)]\",\n cell: \"flex min-w-0 flex-col\",\n columns: \"flex w-full min-w-0 flex-wrap\",\n column: \"min-w-0\",\n },\n variants: {\n gap: Object.fromEntries(\n Object.entries({ none: \"gap-0\", xs: \"gap-1\", sm: \"gap-2\", md: \"gap-3\", lg: \"gap-4\", xl: \"gap-6\" }).map(([name, cls]) => [name, { track: cls, columns: cls }]),\n ) as Record<GridGap, { track: string; columns: string }>,\n equalHeight: { true: { track: \"items-stretch\", cell: \"*:flex-1\" }, false: { track: \"items-start\" } },\n },\n});\n\n/** The columns of a size class: a size class left out takes the one before it. */\nexport function columnsFor(columns: GridColumns | undefined, sizeClass: keyof typeof DEFAULT_COLUMNS): number {\n const asked = columns ?? DEFAULT_COLUMNS;\n if (typeof asked === \"number\") return Math.max(1, Math.floor(asked));\n const order = [\"compact\", \"regular\", \"expanded\"] as const;\n for (let i = order.indexOf(sizeClass); i >= 0; i--) {\n const value = asked[order[i] as (typeof order)[number]];\n if (value) return Math.max(1, Math.floor(value));\n }\n return 1;\n}\n\nexport type GridProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** The items. Each is one cell. */\n children: React.ReactNode;\n /** Columns per size class of the container the grid is in (default 1 · 2 · 3), or one number. A ceiling: it drops when `minItemWidth` does not fit. */\n columns?: GridColumns;\n /** No cell is narrower than this, in px (default 160); it grows with the text scale. */\n minItemWidth?: number;\n /** The space between cells (default `md`). */\n gap?: GridGap;\n /** The most columns, whatever the container (default 6). */\n maxColumns?: number;\n /** The cells of a row are as tall as the tallest (default true); `false` lets each keep its own height. */\n equalHeight?: boolean;\n /** The text scale to lay out for, on top of the browser's (widths are in `rem`, so a larger text size is followed already). Pass 2 to see 200 % text. */\n fontScale?: number;\n};\n\n/**\n * A grid that fits its container: the columns come from the size class of the container's width, and no cell is narrower\n * than `minItemWidth`, so nothing overflows in a page, a side panel or a split. The order mirrors in right-to-left.\n */\nexport function Grid({ children, columns, minItemWidth = 160, gap = \"md\", maxColumns = 6, equalHeight = true, fontScale = 1, \"aria-label\": label, className, style, ...props }: GridProps) {\n const s = columnsLayout({ gap, equalHeight });\n const items = React.Children.toArray(children);\n const cap = Math.max(1, Math.floor(maxColumns));\n const at = (sizeClass: keyof typeof DEFAULT_COLUMNS) => Math.min(columnsFor(columns, sizeClass), cap);\n const vars = {\n \"--kz-grid-compact\": at(\"compact\"),\n \"--kz-grid-regular\": at(\"regular\"),\n \"--kz-grid-expanded\": at(\"expanded\"),\n \"--kz-grid-min\": rem(minItemWidth * Math.max(1, fontScale)),\n \"--kz-grid-gap\": rem(GRID_GAPS[gap]),\n // As many tracks as `--kz-grid-cols` allows, none narrower than the minimum: the ceiling drops on its own.\n gridTemplateColumns:\n \"repeat(auto-fill, minmax(max(var(--kz-grid-min), calc((100% - (var(--kz-grid-cols) - 1) * var(--kz-grid-gap)) / var(--kz-grid-cols))), 1fr))\",\n } as React.CSSProperties;\n // A labelled grid is a list: real <ul>/<li> (native semantics on every device), never a div with an ARIA role.\n const Track = label ? \"ul\" : \"div\";\n const Cell = label ? \"li\" : \"div\";\n return (\n <div className={s.grid({ className })} style={style} {...props}>\n <Track className={s.track({ className: label ? \"m-0 list-none p-0\" : undefined })} style={vars} aria-label={label}>\n {items.map((child, index) => (\n <Cell key={React.isValidElement(child) && child.key != null ? child.key : index} className={s.cell()}>\n {child}\n </Cell>\n ))}\n </Track>\n </div>\n );\n}\n\nexport type ColumnsProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** The columns, in reading order (the first is at the start edge, on the right in right-to-left). */\n children: React.ReactNode;\n /** The share of each column (default equal); `[1, 2]` is a third and two thirds. */\n weights?: readonly number[];\n /** Below this width per column, in px, the columns stack top to bottom (default 280); it grows with the text scale. */\n minColumnWidth?: number;\n /** The space between columns, and between stacked ones (default `lg`). */\n gap?: GridGap;\n /** The text scale to lay out for, on top of the browser's. Pass 2 to see 200 % text. */\n fontScale?: number;\n};\n\n/** The width, in px, that `count` columns need to sit side by side. */\nexport function columnsNeed(count: number, minColumnWidth: number, gapPx: number, fontScale = 1): number {\n return count * minColumnWidth * Math.max(1, fontScale) + gapPx * (count - 1);\n}\n\n/**\n * A few columns that sit side by side when their container holds them and stack when it does not — the master and the\n * detail, a form and its summary. Stacked, they keep their order and each takes the full width.\n */\nexport function Columns({ children, weights, minColumnWidth = 280, gap = \"lg\", fontScale = 1, className, style, ...props }: ColumnsProps) {\n const s = columnsLayout({ gap });\n const items = React.Children.toArray(children);\n const need = columnsNeed(items.length, minColumnWidth, GRID_GAPS[gap], fontScale);\n const side = items.length > 1;\n return (\n <div\n className={s.columns({ className })}\n style={{ \"--kz-columns-need\": rem(need), ...style } as React.CSSProperties}\n data-layout=\"columns\"\n {...props}\n >\n {items.map((child, index) => (\n <div\n key={React.isValidElement(child) && child.key != null ? child.key : index}\n className={s.column()}\n // Container-relative: a basis above the row's width wraps the column onto its own line (stacked, full width);\n // below it the basis is 0 and the free space is shared by weight.\n style={{ flexGrow: weights?.[index] ?? 1, flexBasis: side ? \"calc((var(--kz-columns-need) - 100%) * 999)\" : \"100%\" }}\n >\n {child}\n </div>\n ))}\n </div>\n );\n}\n"
199
199
  },
200
200
  {
201
201
  "path": "columns/index.ts",
@@ -133,7 +133,7 @@
133
133
  "files": [
134
134
  {
135
135
  "path": "comparison-table/comparison-table.tsx",
136
- "content": "// Server-safe (no state). A fair \"versus\" block: one grid where every row lines up across the columns, the column you\n// argue for drawn AS a column of the grid (a tinted band with the brand's light, its header part of the band), a small icon per question, each answer as its key phrase in bold then its detail. The other columns stay\n// neutral — never crossed out. Below `md` each question is a card: the question, then the answers stacked, the\n// highlighted one tinted. Rows arrive one after the other (`[data-reveal]`, staggered) when a MotionObserver runs.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\n\nexport interface ComparisonColumn {\n /** A stable id: the key of the rows' `answers`. */\n id: string;\n /** The column's name (“A cloud assistant”), passed translated. */\n label: string;\n /** A small icon beside the name. */\n icon?: React.ReactNode;\n}\n\nexport interface ComparisonAnswer {\n /** The key phrase, in bold (“On your machines.”). */\n key: string;\n /** The detail after it (“A cloud model only if you connect one.”). */\n detail?: string;\n}\n\nexport interface ComparisonRow {\n /** A stable key. */\n id: string;\n /** The question (“Where do your prompts go?”). */\n topic: string;\n /** A small icon for the question. */\n icon?: React.ReactNode;\n /** One answer per column id. */\n answers: Readonly<Record<string, ComparisonAnswer>>;\n}\n\nexport interface ComparisonTableProps extends Omit<React.ComponentProps<\"div\">, \"children\"> {\n /** The table's accessible name (the section's title), passed translated. */\n label: string;\n /** The first column's header (“Question”). */\n topicLabel: string;\n /** The answer columns, in order. */\n columns: readonly ComparisonColumn[];\n /** The column drawn as the highlighted band (yours). */\n highlight: string;\n /** The questions, in order (three to six). */\n rows: readonly ComparisonRow[];\n /** Stagger the rows' entrance with `[data-reveal]` (needs MotionObserver). @default true */\n reveal?: boolean;\n}\n\nfunction Answer({ answer }: { answer?: ComparisonAnswer }) {\n if (!answer) return null;\n return (\n <>\n <strong className=\"font-semibold text-fg\">{answer.key}</strong>\n {answer.detail && <span className=\"text-fg-secondary\"> {answer.detail}</span>}\n </>\n );\n}\n\n/** The rows' stagger: 70 ms apart, through the motion system's `--kz-delay` (reduced motion: no movement at all). */\nconst stagger = (i: number): React.CSSProperties => ({ \"--kz-delay\": `${i * 70}ms` }) as React.CSSProperties;\n\n/** A comparison where your column is a highlighted band of the same grid — aligned rows, fair neutral answers, cards on a phone. */\nexport function ComparisonTable({ label, topicLabel, columns, highlight, rows, reveal = true, className, ...props }: ComparisonTableProps) {\n const at = Math.max(columns.findIndex((c) => c.id === highlight), 0);\n const grid = { gridTemplateColumns: `minmax(10rem, 0.9fr) repeat(${columns.length}, minmax(0, 1fr))` };\n const band = (i: number) => i === at;\n return (\n <div data-kz-comparison className={cn(\"w-full\", className)} {...props}>\n {/* Wide: one grid, the band is a grid item spanning every row of its column — the rows cannot drift. */}\n <div role=\"table\" aria-label={label} className=\"relative hidden md:grid\" style={grid}>\n <div\n aria-hidden\n data-band\n className=\"pointer-events-none rounded-2xl border border-accent/35 bg-accent-soft shadow-[0_0_48px_-16px_var(--kz-accent)]\"\n style={{ gridColumn: at + 2, gridRow: `1 / span ${rows.length + 1}` }}\n />\n <div role=\"row\" className=\"contents\">\n <span role=\"columnheader\" className=\"row-start-1 self-end px-4 pb-4 pt-5 font-mono text-xs font-semibold text-fg-secondary\" style={{ gridColumn: 1 }}>\n {topicLabel}\n </span>\n {columns.map((c, i) => (\n <span\n key={c.id}\n role=\"columnheader\"\n data-highlight={band(i) ? \"\" : undefined}\n className={cn(\"row-start-1 flex items-center gap-2 self-stretch px-5 pb-4 pt-5 text-sm font-semibold\", band(i) ? \"text-fg [&_svg]:text-fg-accent\" : \"text-fg-secondary\")}\n style={{ gridColumn: i + 2 }}\n >\n {c.icon}\n {c.label}\n </span>\n ))}\n </div>\n {rows.map((row, r) => (\n <div key={row.id} role=\"row\" className=\"contents\">\n <span role=\"rowheader\" data-reveal={reveal ? \"soft\" : undefined} style={{ ...stagger(r), gridColumn: 1, gridRow: r + 2 }} className=\"flex items-start gap-3 border-t border-border-subtle px-4 py-5 text-base font-semibold text-fg\">\n {row.icon && <span className=\"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border-default bg-surface-2 text-fg-accent [&>svg]:h-4 [&>svg]:w-4\">{row.icon}</span>}\n {row.topic}\n </span>\n {columns.map((c, i) => (\n <span\n key={c.id}\n role=\"cell\"\n data-reveal={reveal ? \"soft\" : undefined}\n style={{ ...stagger(r), gridColumn: i + 2, gridRow: r + 2 }}\n className={cn(\"border-t px-5 py-5 text-sm leading-relaxed\", band(i) ? \"border-accent/20\" : \"border-border-subtle\")}\n >\n <Answer answer={row.answers[c.id]} />\n </span>\n ))}\n </div>\n ))}\n </div>\n\n {/* Phone: one card per question, the answers stacked, the highlighted one tinted. */}\n <ul aria-label={label} className=\"grid gap-4 md:hidden\">\n {rows.map((row, r) => (\n <li key={row.id} data-reveal={reveal ? \"soft\" : undefined} style={stagger(r)} className=\"rounded-2xl border border-border-subtle bg-surface-1/80 p-4\">\n <p className=\"flex items-center gap-3 text-base font-semibold text-fg\">\n {row.icon && <span className=\"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border-default bg-surface-2 text-fg-accent [&>svg]:h-4 [&>svg]:w-4\">{row.icon}</span>}\n {row.topic}\n </p>\n <dl className=\"mt-3 grid gap-2\">\n {columns.map((c, i) => (\n <div key={c.id} data-highlight={band(i) ? \"\" : undefined} className={cn(\"rounded-xl p-3 text-sm leading-relaxed\", band(i) ? \"border border-accent/35 bg-accent-soft\" : \"bg-surface-2/60\")}>\n <dt className={cn(\"mb-1 flex items-center gap-1.5 font-mono text-[11px] \", band(i) ? \"text-fg-accent\" : \"text-fg-secondary\")}>\n {c.label}\n </dt>\n <dd>\n <Answer answer={row.answers[c.id]} />\n </dd>\n </div>\n ))}\n </dl>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"
136
+ "content": "// Server-safe (no state). A fair \"versus\" block: one grid where every row lines up across the columns, the column you\n// argue for drawn AS a column of the grid (a tinted band with the brand's light, its header part of the band), a small icon per question, each answer as its key phrase in bold then its detail. The other columns stay\n// neutral — never crossed out. Below `md` each question is a card: the question, then the answers stacked, the\n// highlighted one tinted. Rows arrive one after the other (`[data-reveal]`, staggered) when a MotionObserver runs.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\n\nexport interface ComparisonColumn {\n /** A stable id: the key of the rows' `answers`. */\n id: string;\n /** The column's name (“A cloud assistant”), passed translated. */\n label: string;\n /** A small icon beside the name. */\n icon?: React.ReactNode;\n}\n\nexport interface ComparisonAnswer {\n /** The key phrase, in bold (“On your machines.”). */\n key: string;\n /** The detail after it (“A cloud model only if you connect one.”). */\n detail?: string;\n}\n\nexport interface ComparisonRow {\n /** A stable key. */\n id: string;\n /** The question (“Where do your prompts go?”). */\n topic: string;\n /** A small icon for the question. */\n icon?: React.ReactNode;\n /** One answer per column id. */\n answers: Readonly<Record<string, ComparisonAnswer>>;\n}\n\nexport interface ComparisonTableProps extends Omit<React.ComponentProps<\"div\">, \"children\"> {\n /** The table's accessible name (the section's title), passed translated. */\n label: string;\n /** The first column's header (“Question”). */\n topicLabel: string;\n /** The answer columns, in order. */\n columns: readonly ComparisonColumn[];\n /** The column drawn as the highlighted band (yours). */\n highlight: string;\n /** The questions, in order (three to six). */\n rows: readonly ComparisonRow[];\n /** Stagger the rows' entrance with `[data-reveal]` (needs MotionObserver). @default true */\n reveal?: boolean;\n}\n\nfunction Answer({ answer }: { answer?: ComparisonAnswer }) {\n if (!answer) return null;\n return (\n <>\n <strong className=\"font-semibold text-fg\">{answer.key}</strong>\n {answer.detail && <span className=\"text-fg-secondary\"> {answer.detail}</span>}\n </>\n );\n}\n\n/** The rows' stagger: 70 ms apart, through the motion system's `--kz-delay` (reduced motion: no movement at all). */\nconst stagger = (i: number): React.CSSProperties => ({ \"--kz-delay\": `${i * 70}ms` }) as React.CSSProperties;\n\n/** A comparison where your column is a highlighted band of the same grid — aligned rows, fair neutral answers, cards on a phone. */\nexport function ComparisonTable({ label, topicLabel, columns, highlight, rows, reveal = true, className, ...props }: ComparisonTableProps) {\n const at = Math.max(columns.findIndex((c) => c.id === highlight), 0);\n const grid = { gridTemplateColumns: `minmax(10rem, 0.9fr) repeat(${columns.length}, minmax(0, 1fr))` };\n const band = (i: number) => i === at;\n return (\n <div data-kz-comparison className={cn(\"w-full\", className)} {...props}>\n {/* Wide: one grid, the band is a grid item spanning every row of its column — the rows cannot drift. */}\n <div role=\"table\" aria-label={label} className=\"relative hidden md:grid\" style={grid}>\n <div\n aria-hidden\n data-band\n className=\"pointer-events-none rounded-none border border-accent bg-accent-soft\"\n style={{ gridColumn: at + 2, gridRow: `1 / span ${rows.length + 1}` }}\n />\n <div role=\"row\" className=\"contents\">\n <span role=\"columnheader\" className=\"row-start-1 self-end px-4 pb-4 pt-5 font-mono text-xs font-semibold text-fg-secondary\" style={{ gridColumn: 1 }}>\n {topicLabel}\n </span>\n {columns.map((c, i) => (\n <span\n key={c.id}\n role=\"columnheader\"\n data-highlight={band(i) ? \"\" : undefined}\n className={cn(\"row-start-1 flex items-center gap-2 self-stretch px-5 pb-4 pt-5 text-sm font-semibold\", band(i) ? \"text-fg [&_svg]:text-fg-accent\" : \"text-fg-secondary\")}\n style={{ gridColumn: i + 2 }}\n >\n {c.icon}\n {c.label}\n </span>\n ))}\n </div>\n {rows.map((row, r) => (\n <div key={row.id} role=\"row\" className=\"contents\">\n <span role=\"rowheader\" data-reveal={reveal ? \"soft\" : undefined} style={{ ...stagger(r), gridColumn: 1, gridRow: r + 2 }} className=\"flex items-start gap-3 border-t border-border-subtle px-4 py-5 text-base font-semibold text-fg\">\n {row.icon && <span className=\"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border-default bg-surface-2 text-fg-accent [&>svg]:h-4 [&>svg]:w-4\">{row.icon}</span>}\n {row.topic}\n </span>\n {columns.map((c, i) => (\n <span\n key={c.id}\n role=\"cell\"\n data-reveal={reveal ? \"soft\" : undefined}\n style={{ ...stagger(r), gridColumn: i + 2, gridRow: r + 2 }}\n className={cn(\"border-t px-5 py-5 text-sm leading-relaxed\", band(i) ? \"border-accent/20\" : \"border-border-subtle\")}\n >\n <Answer answer={row.answers[c.id]} />\n </span>\n ))}\n </div>\n ))}\n </div>\n\n {/* Phone: one card per question, the answers stacked, the highlighted one tinted. */}\n <ul aria-label={label} className=\"grid gap-4 md:hidden\">\n {rows.map((row, r) => (\n <li key={row.id} data-reveal={reveal ? \"soft\" : undefined} style={stagger(r)} className=\"rounded-none border border-border-subtle bg-surface-1/80 p-4\">\n <p className=\"flex items-center gap-3 text-base font-semibold text-fg\">\n {row.icon && <span className=\"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border-default bg-surface-2 text-fg-accent [&>svg]:h-4 [&>svg]:w-4\">{row.icon}</span>}\n {row.topic}\n </p>\n <dl className=\"mt-3 grid gap-2\">\n {columns.map((c, i) => (\n <div key={c.id} data-highlight={band(i) ? \"\" : undefined} className={cn(\"rounded-none p-3 text-sm leading-relaxed\", band(i) ? \"border border-accent bg-accent-soft\" : \"bg-surface-2/60\")}>\n <dt className={cn(\"mb-1 flex items-center gap-1.5 font-mono text-[11px] \", band(i) ? \"text-fg-accent\" : \"text-fg-secondary\")}>\n {c.label}\n </dt>\n <dd>\n <Answer answer={row.answers[c.id]} />\n </dd>\n </div>\n ))}\n </dl>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"
137
137
  },
138
138
  {
139
139
  "path": "comparison-table/index.ts",
@@ -0,0 +1,4 @@
1
+ import type { ComponentType } from "react";
2
+ /** A named example of the @krizaka/ui registry; `defaultOpen` opens what it opens (a dialog, a menu, toasts) at load. */
3
+ declare const Example: ComponentType<{ defaultOpen?: boolean }>;
4
+ export default Example;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+
3
+ // registry/examples/site-footer/family.tsx
4
+ import { FamilyFooter } from "@krizaka/ui/site-footer";
5
+ import { familyLabels } from "@krizaka/ui/sites";
6
+ import { jsx } from "react/jsx-runtime";
7
+ var footer = {
8
+ id: "ui",
9
+ groups: [
10
+ { group: "products", entries: [{ id: "verikora", name: "Verikora", group: "products", status: "released", url: "https://www.verikora.com" }] },
11
+ { group: "open-source", entries: [{ id: "ui", name: "Krizaka UI", group: "open-source", status: "released", url: "https://ui.krizaka.com" }] }
12
+ ],
13
+ social: [{ id: "instagram", label: "Instagram", url: "https://www.instagram.com/krizakahq" }],
14
+ source: "https://github.com/krizaka/krizaka-ui",
15
+ license: "Apache-2.0",
16
+ legal: [{ id: "privacy", label: { fr: "Confidentialit\xE9", en: "Privacy" }, url: { fr: "#privacy", en: "#privacy" } }],
17
+ line: { fr: "Une entreprise de Technologies Krizaka \xB7 Fait \xE0 Montr\xE9al", en: "A Technologies Krizaka company \xB7 Made in Montr\xE9al" },
18
+ version: true
19
+ };
20
+ function SiteFooterFamily() {
21
+ return /* @__PURE__ */ jsx(FamilyFooter, { footer, current: "ui", labels: familyLabels.en, sourceLabel: "Source code", version: "2.0.0", children: /* @__PURE__ */ jsx(FamilyFooter.Column, { title: "Docs", children: /* @__PURE__ */ jsx(FamilyFooter.Link, { href: "#components", children: "Components" }) }) });
22
+ }
23
+ export {
24
+ SiteFooterFamily as default
25
+ };
@@ -0,0 +1,28 @@
1
+ import { FamilyFooter, type FamilyFooterData } from "@krizaka/ui/site-footer";
2
+ import { familyLabels } from "@krizaka/ui/sites";
3
+
4
+ // A developer site (ui.krizaka.com): the footer is what `footerFor("ui")` of `@krizaka/org` returns — pass it as is.
5
+ // The block places the family, the source code, the licence, the legal links, the accounts and the version; the site adds its own links.
6
+ const footer: FamilyFooterData = {
7
+ id: "ui",
8
+ groups: [
9
+ { group: "products", entries: [{ id: "verikora", name: "Verikora", group: "products", status: "released", url: "https://www.verikora.com" }] },
10
+ { group: "open-source", entries: [{ id: "ui", name: "Krizaka UI", group: "open-source", status: "released", url: "https://ui.krizaka.com" }] },
11
+ ],
12
+ social: [{ id: "instagram", label: "Instagram", url: "https://www.instagram.com/krizakahq" }],
13
+ source: "https://github.com/krizaka/krizaka-ui",
14
+ license: "Apache-2.0",
15
+ legal: [{ id: "privacy", label: { fr: "Confidentialité", en: "Privacy" }, url: { fr: "#privacy", en: "#privacy" } }],
16
+ line: { fr: "Une entreprise de Technologies Krizaka · Fait à Montréal", en: "A Technologies Krizaka company · Made in Montréal" },
17
+ version: true,
18
+ };
19
+
20
+ export default function SiteFooterFamily() {
21
+ return (
22
+ <FamilyFooter footer={footer} current="ui" labels={familyLabels.en} sourceLabel="Source code" version="2.0.0">
23
+ <FamilyFooter.Column title="Docs">
24
+ <FamilyFooter.Link href="#components">Components</FamilyFooter.Link>
25
+ </FamilyFooter.Column>
26
+ </FamilyFooter>
27
+ );
28
+ }
@@ -0,0 +1,4 @@
1
+ import type { ComponentType } from "react";
2
+ /** A named example of the @krizaka/ui registry; `defaultOpen` opens what it opens (a dialog, a menu, toasts) at load. */
3
+ declare const Example: ComponentType<{ defaultOpen?: boolean }>;
4
+ export default Example;
@@ -0,0 +1,14 @@
1
+ "use client";
2
+
3
+ // registry/examples/switch/row.tsx
4
+ import { Switch } from "@krizaka/ui/switch";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ function SwitchRow() {
7
+ return /* @__PURE__ */ jsxs("div", { className: "flex w-80 flex-col", children: [
8
+ /* @__PURE__ */ jsx(Switch, { defaultChecked: true, description: "One email on Monday with what you missed.", children: "Weekly digest" }),
9
+ /* @__PURE__ */ jsx(Switch, { description: "Plays the next video when this one ends.", children: "Autoplay" })
10
+ ] });
11
+ }
12
+ export {
13
+ SwitchRow as default
14
+ };
@@ -0,0 +1,13 @@
1
+ import { Switch } from "@krizaka/ui/switch";
2
+
3
+ // A settings row: `children` and `description` at the start, the switch at the end, the whole row clickable.
4
+ export default function SwitchRow() {
5
+ return (
6
+ <div className="flex w-80 flex-col">
7
+ <Switch defaultChecked description="One email on Monday with what you missed.">
8
+ Weekly digest
9
+ </Switch>
10
+ <Switch description="Plays the next video when this one ends.">Autoplay</Switch>
11
+ </div>
12
+ );
13
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krizaka/ui",
3
- "version": "4.5.0",
3
+ "version": "4.6.0",
4
4
  "templatePurposes": {
5
5
  "convince": {
6
6
  "title": "Convince",
@@ -1013,7 +1013,7 @@
1013
1013
  "native": 0
1014
1014
  },
1015
1015
  "dependencies": [
1016
- "@krizaka/tokens@^4.5.0"
1016
+ "@krizaka/tokens@^4.6.0"
1017
1017
  ],
1018
1018
  "registryDependencies": [
1019
1019
  "account-menu",
@@ -4048,7 +4048,7 @@
4048
4048
  "native": 2
4049
4049
  },
4050
4050
  "dependencies": [
4051
- "@krizaka/tokens@^4.5.0",
4051
+ "@krizaka/tokens@^4.6.0",
4052
4052
  "@protomaps/basemaps@5.7.2",
4053
4053
  "tailwind-variants@^3.3.1"
4054
4054
  ],
@@ -4461,7 +4461,7 @@
4461
4461
  "native": 0
4462
4462
  },
4463
4463
  "dependencies": [
4464
- "@krizaka/tokens@^4.5.0",
4464
+ "@krizaka/tokens@^4.6.0",
4465
4465
  "radix-ui@^1.8.1",
4466
4466
  "tailwind-variants@^3.3.1"
4467
4467
  ],
@@ -5329,7 +5329,7 @@
5329
5329
  "native": 0
5330
5330
  },
5331
5331
  "dependencies": [
5332
- "@krizaka/tokens@^4.5.0",
5332
+ "@krizaka/tokens@^4.6.0",
5333
5333
  "radix-ui@^1.8.1",
5334
5334
  "tailwind-variants@^3.3.1"
5335
5335
  ],
@@ -5776,7 +5776,7 @@
5776
5776
  "native": 0
5777
5777
  },
5778
5778
  "dependencies": [
5779
- "@krizaka/tokens@^4.5.0",
5779
+ "@krizaka/tokens@^4.6.0",
5780
5780
  "zod@^4.6.7"
5781
5781
  ],
5782
5782
  "registryDependencies": [
@@ -5992,12 +5992,12 @@
5992
5992
  }
5993
5993
  },
5994
5994
  "examples": {
5995
- "web": 7,
5995
+ "web": 8,
5996
5996
  "native": 0
5997
5997
  },
5998
5998
  "dependencies": [
5999
5999
  "@krizaka/icons@^0.10.0",
6000
- "@krizaka/tokens@^4.5.0",
6000
+ "@krizaka/tokens@^4.6.0",
6001
6001
  "radix-ui@^1.8.1",
6002
6002
  "tailwind-variants@^3.3.1"
6003
6003
  ],
@@ -6731,7 +6731,7 @@
6731
6731
  }
6732
6732
  },
6733
6733
  "examples": {
6734
- "web": 5,
6734
+ "web": 6,
6735
6735
  "native": 2
6736
6736
  },
6737
6737
  "dependencies": [
package/registry/map.json CHANGED
@@ -1158,7 +1158,7 @@
1158
1158
  }
1159
1159
  ],
1160
1160
  "dependencies": [
1161
- "@krizaka/tokens@^4.5.0",
1161
+ "@krizaka/tokens@^4.6.0",
1162
1162
  "@protomaps/basemaps@5.7.2",
1163
1163
  "tailwind-variants@^3.3.1"
1164
1164
  ],
@@ -719,7 +719,7 @@
719
719
  }
720
720
  ],
721
721
  "dependencies": [
722
- "@krizaka/tokens@^4.5.0",
722
+ "@krizaka/tokens@^4.6.0",
723
723
  "radix-ui@^1.8.1",
724
724
  "tailwind-variants@^3.3.1"
725
725
  ],
@@ -344,7 +344,7 @@
344
344
  }
345
345
  ],
346
346
  "dependencies": [
347
- "@krizaka/tokens@^4.5.0",
347
+ "@krizaka/tokens@^4.6.0",
348
348
  "radix-ui@^1.8.1",
349
349
  "tailwind-variants@^3.3.1"
350
350
  ],
@@ -98,7 +98,7 @@
98
98
  },
99
99
  {
100
100
  "path": "router/route-state.tsx",
101
- "content": "// Client. The URL is the state: a selection the user would want to share, reload or come back to (a tab, a type, a\n// filter) lives in a search parameter, never in `useState` (Oussama, 2026-10-22: « changer les tabs doit changer les routes »).\n// One primitive reads and writes it: `useRouteState`. The selection components take `routeKey` and bind to it.\nimport * as React from \"react\";\n\n/** How a router moves and reads the address: the browser's by default, your framework's through `RouteStateProvider`. */\nexport interface RouteAdapter {\n /** The current query string, with or without `?` (`\"\"` on the server). */\n search: () => string;\n /** Go to `search` (`?type=bail`, or `\"\"`), keeping the path and the hash; `replace` keeps the history as it is. */\n navigate: (search: string, options: { replace: boolean }) => void;\n /** Calls `onChange` when the address changes under you (back, forward, another navigation); returns the unsubscribe. */\n subscribe: (onChange: () => void) => () => void;\n}\n\nconst CHANGE = \"kz-route-state\";\n\n/** The History API: any web app (Vite, a static site). Next.js apps pass their router's adapter once, in the layout. */\nexport const browserAdapter: RouteAdapter = {\n search: () => (globalThis.window === undefined ? \"\" : globalThis.location.search),\n navigate: (search, { replace }) => {\n const url = `${globalThis.location.pathname}${search}${globalThis.location.hash}`;\n globalThis.history[replace ? \"replaceState\" : \"pushState\"](globalThis.history.state, \"\", url);\n globalThis.dispatchEvent(new Event(CHANGE));\n },\n subscribe: (onChange) => {\n globalThis.addEventListener(\"popstate\", onChange);\n globalThis.addEventListener(CHANGE, onChange);\n return () => {\n globalThis.removeEventListener(\"popstate\", onChange);\n globalThis.removeEventListener(CHANGE, onChange);\n };\n },\n};\n\nconst AdapterContext = React.createContext<RouteAdapter>(browserAdapter);\n\nexport interface RouteStateProviderProps {\n /** How your router reads the query string, navigates and tells about changes. */\n adapter: RouteAdapter;\n children: React.ReactNode;\n}\n\n/** Gives `useRouteState` your router: `<RouteStateProvider adapter={nextAdapter}>` once, in the root layout. */\nexport function RouteStateProvider({ adapter, children }: Readonly<RouteStateProviderProps>) {\n return <AdapterContext.Provider value={adapter}>{children}</AdapterContext.Provider>;\n}\n\nexport interface RouteStateOptions<V extends string> {\n /** The values the parameter may hold, as a const list: anything else in the address reads as the default. Omit for free text. */\n values?: readonly V[];\n /** The value when the parameter is absent. It is never written to the address (a clean URL). */\n default: V;\n /** `push` (the default) keeps each change in the history, `replace` overwrites it: use `replace` for a filter typed or toggled in passing. */\n history?: \"push\" | \"replace\";\n}\n\n/** The value a query string holds for `key`, checked against `values`. Pure: the hook and the tests share it. */\nexport function readRouteValue<V extends string>(search: string, key: string, { values, default: fallback }: Pick<RouteStateOptions<V>, \"values\" | \"default\">): V {\n const raw = new URLSearchParams(search).get(key);\n if (raw === null) return fallback;\n return !values || (values as readonly string[]).includes(raw) ? (raw as V) : fallback;\n}\n\n/** The query string with `key` set to `value` (removed when it is the default); every other parameter is kept. Pure. */\nexport function writeRouteValue(search: string, key: string, value: string, fallback: string): string {\n const params = new URLSearchParams(search);\n if (value === fallback) params.delete(key);\n else params.set(key, value);\n const text = params.toString();\n return text ? `?${text}` : \"\";\n}\n\n/**\n * A value kept in the URL's search parameter `key`: `const [type, setType] = useRouteState(\"type\", { values: TYPES, default: \"auto\" })`\n * with `const TYPES = [\"auto\", \"lease\", \"contract\", \"invoice\", \"other\"] as const`. The value is typed from the list, an\n * unknown one in the address reads as the default, the default is not written, other parameters are kept.\n * `key` undefined makes the hook inert (it returns the default) so a component can call it unconditionally.\n */\nexport function useRouteState<V extends string>(key: string | undefined, { values, default: fallback, history = \"push\" }: RouteStateOptions<V>): readonly [V, (next: V) => void] {\n const adapter = React.useContext(AdapterContext);\n const search = React.useSyncExternalStore(adapter.subscribe, adapter.search, () => \"\");\n const value = key === undefined ? fallback : readRouteValue(search, key, { values, default: fallback });\n const set = React.useCallback(\n (next: V) => {\n if (key === undefined) return;\n navigateFrom(adapter, (search) => writeRouteValue(search, key, next, fallback), { replace: history === \"replace\" });\n },\n [adapter, key, fallback, history],\n );\n return [value, set] as const;\n}\n\n// What was written but not yet read back: a router may apply a navigation later (Next.js), so every writer — two tables,\n// a table and a tab — builds on the last write, not on an address that has not caught up. Cleared at the router's next\n// change (the write landing, back, forward), one subscription per adapter.\nconst pending = new WeakMap<RouteAdapter, string>();\nconst watched = new WeakSet<RouteAdapter>();\n\n/** Navigate to `update(the latest address)`: writes in the same tick, from any hook, compose instead of overwriting each other. */\nexport function navigateFrom(adapter: RouteAdapter, update: (search: string) => string, { replace }: { replace: boolean }) {\n if (!watched.has(adapter)) {\n watched.add(adapter);\n adapter.subscribe(() => pending.delete(adapter));\n }\n const next = update(pending.get(adapter) ?? adapter.search());\n pending.set(adapter, next);\n adapter.navigate(next, { replace });\n}\n\n/**\n * The query string and a way to change several parameters in one navigation (a sort and the page it resets). Writes made\n * in the same tick build on each other — across every hook of the same router — so a router that applies them later never\n * loses one.\n */\nexport function useRouteSearch(): { search: string; write: (update: (search: string) => string, options?: { replace?: boolean }) => void } {\n const adapter = React.useContext(AdapterContext);\n const search = React.useSyncExternalStore(adapter.subscribe, adapter.search, () => \"\");\n const write = React.useCallback(\n (update: (search: string) => string, { replace = false }: { replace?: boolean } = {}) => navigateFrom(adapter, update, { replace }),\n [adapter],\n );\n return { search, write };\n}\n\n/** What a selection component spreads on its root: `value` and `onValueChange` bound to the URL when `routeKey` is set. */\nexport interface RouteBindable {\n value?: string | null;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n}\n\n/** The props of a selection component bound to the URL (`routeKey`), or its own, unchanged, when there is no `routeKey`. */\nexport function useRouteBinding<P extends RouteBindable>(routeKey: string | undefined, routeValues: readonly string[] | undefined, props: P): P {\n const initial = props.defaultValue ?? props.value ?? routeValues?.[0] ?? \"\";\n const [value, set] = useRouteState<string>(routeKey, { values: routeValues, default: initial });\n if (routeKey === undefined) return props;\n return {\n ...props,\n value,\n defaultValue: undefined,\n onValueChange: (next: string) => {\n set(next);\n props.onValueChange?.(next);\n },\n };\n}\n"
101
+ "content": "// Client. The URL is the state: a selection the user would want to share, reload or come back to (a tab, a type, a\n// filter) lives in a search parameter, never in `useState` (Oussama, 2026-10-22: « changer les tabs doit changer les routes »).\n// One primitive reads and writes it: `useRouteState`. The selection components take `routeKey` and bind to it.\nimport * as React from \"react\";\n\n/** How a router moves and reads the address: the browser's by default, your framework's through `RouteStateProvider`. */\nexport interface RouteAdapter {\n /** The current query string, with or without `?` (`\"\"` on the server). */\n search: () => string;\n /** Go to `search` (`?type=bail`, or `\"\"`), keeping the path and the hash; `replace` keeps the history as it is. */\n navigate: (search: string, options: { replace: boolean }) => void;\n /** Calls `onChange` when the address changes under you (back, forward, another navigation); returns the unsubscribe. */\n subscribe: (onChange: () => void) => () => void;\n}\n\nconst CHANGE = \"kz-route-state\";\n\n/** The History API: any web app (Vite, a static site). Next.js apps pass their router's adapter once, in the layout. */\nexport const browserAdapter: RouteAdapter = {\n search: () => (globalThis.window === undefined ? \"\" : globalThis.location.search),\n navigate: (search, { replace }) => {\n const where = globalThis.location;\n // The address already shown adds no entry (a tab fires twice on one click: mousedown, then focus).\n // A null state, never the current one: Next.js keeps its own mark in the state, and an entry that carries it is taken\n // as Next's own and never synced (`useSearchParams` would keep the old value). Without a state, Next adopts the entry.\n if (search !== where.search) globalThis.history[replace ? \"replaceState\" : \"pushState\"](null, \"\", where.pathname + search + where.hash);\n // The change event always fires: it settles what `navigateFrom` kept as pending.\n globalThis.dispatchEvent(new Event(CHANGE));\n },\n subscribe: (onChange) => {\n globalThis.addEventListener(\"popstate\", onChange);\n globalThis.addEventListener(CHANGE, onChange);\n return () => {\n globalThis.removeEventListener(\"popstate\", onChange);\n globalThis.removeEventListener(CHANGE, onChange);\n };\n },\n};\n\nconst AdapterContext = React.createContext<RouteAdapter>(browserAdapter);\n\nexport interface RouteStateProviderProps {\n /** How your router reads the query string, navigates and tells about changes. */\n adapter: RouteAdapter;\n children: React.ReactNode;\n}\n\n/** Gives `useRouteState` your router: `<RouteStateProvider adapter={nextAdapter}>` once, in the root layout. */\nexport function RouteStateProvider({ adapter, children }: Readonly<RouteStateProviderProps>) {\n return <AdapterContext.Provider value={adapter}>{children}</AdapterContext.Provider>;\n}\n\nexport interface RouteStateOptions<V extends string> {\n /** The values the parameter may hold, as a const list: anything else in the address reads as the default. Omit for free text. */\n values?: readonly V[];\n /** The value when the parameter is absent. It is never written to the address (a clean URL). */\n default: V;\n /** `push` (the default) keeps each change in the history, `replace` overwrites it: use `replace` for a filter typed or toggled in passing. */\n history?: \"push\" | \"replace\";\n}\n\n/** The value a query string holds for `key`, checked against `values`. Pure: the hook and the tests share it. */\nexport function readRouteValue<V extends string>(search: string, key: string, { values, default: fallback }: Pick<RouteStateOptions<V>, \"values\" | \"default\">): V {\n const raw = new URLSearchParams(search).get(key);\n if (raw === null) return fallback;\n return !values || (values as readonly string[]).includes(raw) ? (raw as V) : fallback;\n}\n\n/** The query string with `key` set to `value` (removed when it is the default); every other parameter is kept. Pure. */\nexport function writeRouteValue(search: string, key: string, value: string, fallback: string): string {\n const params = new URLSearchParams(search);\n if (value === fallback) params.delete(key);\n else params.set(key, value);\n const text = params.toString();\n return text ? `?${text}` : \"\";\n}\n\n/**\n * A value kept in the URL's search parameter `key`: `const [type, setType] = useRouteState(\"type\", { values: TYPES, default: \"auto\" })`\n * with `const TYPES = [\"auto\", \"lease\", \"contract\", \"invoice\", \"other\"] as const`. The value is typed from the list, an\n * unknown one in the address reads as the default, the default is not written, other parameters are kept.\n * `key` undefined makes the hook inert (it returns the default) so a component can call it unconditionally.\n */\nexport function useRouteState<V extends string>(key: string | undefined, { values, default: fallback, history = \"push\" }: RouteStateOptions<V>): readonly [V, (next: V) => void] {\n const adapter = React.useContext(AdapterContext);\n const search = React.useSyncExternalStore(adapter.subscribe, adapter.search, () => \"\");\n const value = key === undefined ? fallback : readRouteValue(search, key, { values, default: fallback });\n const set = React.useCallback(\n (next: V) => {\n if (key === undefined) return;\n navigateFrom(adapter, (search) => writeRouteValue(search, key, next, fallback), { replace: history === \"replace\" });\n },\n [adapter, key, fallback, history],\n );\n return [value, set] as const;\n}\n\n// What was written but not yet read back: a router may apply a navigation later (Next.js), so every writer — two tables,\n// a table and a tab — builds on the last write, not on an address that has not caught up. Cleared at the router's next\n// change (the write landing, back, forward), one subscription per adapter.\nconst pending = new WeakMap<RouteAdapter, string>();\nconst watched = new WeakSet<RouteAdapter>();\n\n/** Navigate to `update(the latest address)`: writes in the same tick, from any hook, compose instead of overwriting each other. */\nexport function navigateFrom(adapter: RouteAdapter, update: (search: string) => string, { replace }: { replace: boolean }) {\n if (!watched.has(adapter)) {\n watched.add(adapter);\n adapter.subscribe(() => pending.delete(adapter));\n }\n const next = update(pending.get(adapter) ?? adapter.search());\n pending.set(adapter, next);\n adapter.navigate(next, { replace });\n}\n\n/**\n * The query string and a way to change several parameters in one navigation (a sort and the page it resets). Writes made\n * in the same tick build on each other — across every hook of the same router — so a router that applies them later never\n * loses one.\n */\nexport function useRouteSearch(): { search: string; write: (update: (search: string) => string, options?: { replace?: boolean }) => void } {\n const adapter = React.useContext(AdapterContext);\n const search = React.useSyncExternalStore(adapter.subscribe, adapter.search, () => \"\");\n const write = React.useCallback(\n (update: (search: string) => string, { replace = false }: { replace?: boolean } = {}) => navigateFrom(adapter, update, { replace }),\n [adapter],\n );\n return { search, write };\n}\n\n/** What a selection component spreads on its root: `value` and `onValueChange` bound to the URL when `routeKey` is set. */\nexport interface RouteBindable {\n value?: string | null;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n}\n\n/** The props of a selection component bound to the URL (`routeKey`), or its own, unchanged, when there is no `routeKey`. */\nexport function useRouteBinding<P extends RouteBindable>(routeKey: string | undefined, routeValues: readonly string[] | undefined, props: P): P {\n const initial = props.defaultValue ?? props.value ?? routeValues?.[0] ?? \"\";\n const [value, set] = useRouteState<string>(routeKey, { values: routeValues, default: initial });\n if (routeKey === undefined) return props;\n return {\n ...props,\n value,\n defaultValue: undefined,\n onValueChange: (next: string) => {\n set(next);\n props.onValueChange?.(next);\n },\n };\n}\n"
102
102
  }
103
103
  ],
104
104
  "dependencies": [],
@@ -700,7 +700,7 @@
700
700
  }
701
701
  ],
702
702
  "dependencies": [
703
- "@krizaka/tokens@^4.5.0",
703
+ "@krizaka/tokens@^4.6.0",
704
704
  "zod@^4.6.7"
705
705
  ],
706
706
  "registryDependencies": [