@krizaka/ui 3.76.1 → 3.77.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 (46) hide show
  1. package/dist/blocks.css +14 -0
  2. package/dist/chunk-NM2DEHFZ.js +25 -0
  3. package/dist/chunk-NM2DEHFZ.js.map +1 -0
  4. package/dist/document-viewer.d.ts +23 -6
  5. package/dist/document-viewer.js +21 -5
  6. package/dist/document-viewer.js.map +1 -1
  7. package/dist/filter-bar.d.ts +3 -3
  8. package/dist/map/cards.d.ts +145 -0
  9. package/dist/map/cards.js +74 -0
  10. package/dist/map/cards.js.map +1 -0
  11. package/dist/map/pin.d.ts +57 -0
  12. package/dist/map/pin.js +53 -0
  13. package/dist/map/pin.js.map +1 -0
  14. package/dist/map/sheet.d.ts +80 -0
  15. package/dist/map/sheet.js +61 -0
  16. package/dist/map/sheet.js.map +1 -0
  17. package/dist/map.d.ts +41 -14
  18. package/dist/map.js +85 -112
  19. package/dist/map.js.map +1 -1
  20. package/dist/native/map.d.ts +29 -10
  21. package/dist/native/map.js +81 -107
  22. package/dist/native/map.js.map +1 -1
  23. package/dist/wall.d.ts +10 -5
  24. package/dist/wall.js +10 -4
  25. package/dist/wall.js.map +1 -1
  26. package/package.json +51 -6
  27. package/registry/app-frame.json +1 -1
  28. package/registry/document-viewer.json +9 -8
  29. package/registry/examples/document-viewer/highlights.js +2 -1
  30. package/registry/examples/document-viewer/highlights.tsx +3 -0
  31. package/registry/examples/map/pins.d.ts +4 -0
  32. package/registry/examples/map/pins.js +20 -0
  33. package/registry/examples/map/pins.tsx +27 -0
  34. package/registry/examples/map/place-sheet.d.ts +4 -0
  35. package/registry/examples/map/place-sheet.js +34 -0
  36. package/registry/examples/map/place-sheet.tsx +35 -0
  37. package/registry/examples/wall/tidy.d.ts +4 -0
  38. package/registry/examples/wall/tidy.js +27 -0
  39. package/registry/examples/wall/tidy.tsx +19 -0
  40. package/registry/index.json +9 -9
  41. package/registry/map.json +81 -13
  42. package/registry/nav-bar.json +1 -1
  43. package/registry/rail-nav.json +1 -1
  44. package/registry/shop.json +1 -1
  45. package/registry/site-footer.json +1 -1
  46. package/registry/wall.json +24 -2
package/dist/wall.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cahier-seed.ts","../src/stuck/stuck.tsx","../src/wall/pinned-note.tsx","../src/wall/polaroid.tsx","../src/wall/attachment.tsx","../src/wall/shop-sign.tsx","../src/wall/wall.tsx"],"sourcesContent":["// The Cahier's small deterministic randomness: a string (an id, a slug, a title) becomes a number in [-1, 1], always the\n// same one, so a tilt or a wobble drawn \"by hand\" is the same on the server, on the client and in every screenshot.\nexport function seedUnit(seed: string): number {\n let h = 2166136261;\n for (let i = 0; i < seed.length; i++) h = Math.imul(h ^ seed.charCodeAt(i), 16777619);\n return ((h >>> 0) % 2001) / 1000 - 1;\n}\n","// Server-safe. A block stuck into the notebook (ADR-004, blocks.css): a figure, a specimen tag, a card, a print — held by\n// tape, a pin, photo corners or a lifted edge, slightly tilted (from data, never random), on the Cahier's hard paper\n// shadow. The tape is TapedPhoto's own (the same rule in blocks.css). The tilt is a transform: nothing shifts.\nimport type * as React from \"react\";\n\nimport { seedUnit } from \"../cahier-seed\";\nimport { cn } from \"../cn\";\n\nexport type StuckHold = \"tape\" | \"tape-corners\" | \"pin\" | \"corner\" | \"glue\";\n\nexport type StuckProps = Omit<React.HTMLAttributes<HTMLElement>, \"children\"> & {\n /** What is stuck: a figure, a `SpecimenTag`, a card, a `TapedPhoto`. */\n children: React.ReactNode;\n /**\n * How it is held: `tape` (one strip), `tape-corners` (two opposite corners), `pin` (a drawing pin), `corner` (photo\n * corners) or `glue` (a slightly lifted edge).\n * @default \"tape\"\n */\n hold?: StuckHold;\n /** The tilt in degrees (negative leans left). Without it, the tilt comes from `seed`. */\n tilt?: number;\n /** Where the tilt comes from when `tilt` is not given: the same string always leans the same way (±2°). @default \"\" */\n seed?: string;\n /** Margin doodles (`Doodle`) drawn beside the block; they leave with the margin on a narrow screen. */\n doodle?: React.ReactNode;\n /** The element of the wrapper. A `figure` goes inside, never here. @default \"div\" */\n as?: \"div\" | \"li\" | \"aside\";\n};\n\n/** The tilt of a stuck block: `tilt` when given, otherwise a steady lean (−2° to 2°) read from `seed`, rounded to a tenth. */\nexport function stuckTilt(seed: string, tilt?: number): number {\n return tilt ?? Math.round(seedUnit(seed) * 20) / 10;\n}\n\n/** A block stuck into the notebook: held by tape, a pin, photo corners or glue; tilted from data; a hard paper shadow. */\nexport function Stuck({ children, hold = \"tape\", tilt, seed = \"\", doodle, as: Tag = \"div\", className, style, ...props }: StuckProps) {\n return (\n <Tag className={cn(\"kz-stuck\", className)} style={style} {...props}>\n <div className=\"kz-stuck-body\" data-hold={hold} style={{ [\"--kz-stuck-tilt\" as string]: `${stuckTilt(seed, tilt)}deg` }}>\n {hold === \"pin\" ? <span className=\"kz-stuck-pin\" aria-hidden /> : null}\n {children}\n </div>\n {doodle}\n </Tag>\n );\n}\n","import type * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { Stuck } from \"../stuck\";\nimport type { WallObjectProps } from \"./attachment\";\n\nexport interface PinnedNoteProps extends Omit<React.ComponentProps<\"article\">, \"children\" | \"style\">, WallObjectProps {\n /** The short message; capped at 140 Unicode code points without an ellipsis. */\n text: string;\n /** The optional author's signature, written in the handwriting role. */\n signature?: string;\n /** The ink of the pen: blue ink, the margin's red, or the page's hue. @default \"blue\" */\n ink?: \"blue\" | \"margin\" | \"hue\";\n /** How the note is held, through `Stuck`: a strip of tape or a pin. Takes over `attachment`. @default \"tape\" */\n hold?: \"tape\" | \"pin\";\n /** The colour of the paper: the page's own, or a real post-it (butter, rose, mint, sky), pale in both themes with the pen dark on it. @default \"plain\" */\n paper?: \"plain\" | \"butter\" | \"rose\" | \"mint\" | \"sky\";\n /** A small action under the words (a link, a button) kept inside the note and reachable by keyboard; it is never part of the capped text. */\n action?: React.ReactNode;\n /** How many Unicode code points of `text` are kept (a flyer longer than a word is read whole). @default 140 */\n limit?: number;\n /** The lines of the text box, fixed so a late font never shifts the page (the text is read in full by assistive technology). @default 4 */\n lines?: number;\n}\n\n/** A short word on a cut-corner card, stuck into the notebook. */\nexport function PinnedNote({ text, signature, rotation = 0, attachment, attachmentRotation: _attachmentRotation, ink = \"blue\", paper = \"plain\", action, limit = 140, hold, lines = 4, className, ...props }: PinnedNoteProps) {\n const rows = Math.max(1, Math.round(Number.isFinite(lines) ? lines : 4));\n return (\n <Stuck hold={hold ?? attachment ?? \"tape\"} tilt={Number.isFinite(rotation) ? rotation : 0} className=\"kz-wall-object kz-pinned-stuck\">\n <article {...props} className={cn(\"kz-pinned-note\", className)} data-shape=\"cut\" data-ink={ink} data-paper={paper === \"plain\" ? undefined : paper} style={{ \"--kz-note-lines\": rows } as React.CSSProperties}>\n <div className=\"kz-pinned-note-paper\">\n <p className=\"kz-pinned-note-text\">{Array.from(text).slice(0, Number.isFinite(limit) ? Math.max(0, Math.floor(limit)) : 140).join(\"\")}</p>\n {signature && <p className=\"kz-pinned-note-signature\">{signature}</p>}\n {action && <div className=\"kz-pinned-note-action\">{action}</div>}\n </div>\n </article>\n </Stuck>\n );\n}\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { TapedPhoto } from \"../taped-photo\";\nimport { Attachment, finite, type WallObjectProps } from \"./attachment\";\n\nexport interface PolaroidProps extends Omit<React.ComponentProps<\"figure\">, \"children\" | \"style\">, WallObjectProps {\n /** The photo slot: an img or next/image, including fill inside this positioned frame. Supply its alt text. */\n img: React.ReactNode;\n /** A short handwritten caption, using the --kz-font-cahier role. */\n caption?: React.ReactNode;\n /** Enable the first-view develop effect; defaults to true, never runs under reduced motion. */\n develop?: boolean;\n}\n\n/** A photo held to the wall by tape or a pin, with a handwritten caption. */\nexport function Polaroid({ img, caption, rotation = 0, attachment = \"tape\", attachmentRotation = 0, develop = true, className, ...props }: PolaroidProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const [state, setState] = React.useState<\"waiting\" | \"ready\" | undefined>();\n React.useEffect(() => {\n if (!develop || !ref.current || typeof IntersectionObserver === \"undefined\" || typeof matchMedia === \"undefined\") return;\n const preference = matchMedia(\"(prefers-reduced-motion: reduce)\");\n let seen = false;\n let observer: IntersectionObserver | undefined;\n const sync = () => {\n observer?.disconnect();\n if (preference.matches) {\n seen = true;\n setState(undefined);\n } else if (!seen) {\n setState(\"waiting\");\n observer = new IntersectionObserver((entries) => {\n if (seen || !entries.some((entry) => entry.isIntersecting)) return;\n seen = true;\n setState(\"ready\");\n observer?.disconnect();\n }, { threshold: 0.15 });\n observer.observe(ref.current!);\n }\n };\n sync();\n preference.addEventListener(\"change\", sync);\n return () => { observer?.disconnect(); preference.removeEventListener(\"change\", sync); };\n }, [develop]);\n return (\n <TapedPhoto {...props} className={cn(\"kz-polaroid\", className)} tilt={finite(rotation)} tape={attachment === \"pin\" ? \"none\" : \"top\"} caption={caption}\n style={{ \"--kz-wall-attachment-rotation\": `${finite(attachmentRotation)}deg` } as React.CSSProperties} data-develop={develop ? state : undefined}>\n {attachment === \"pin\" && <Attachment attachment=\"pin\" attachmentRotation={attachmentRotation} />}\n <div ref={ref} className=\"kz-polaroid-photo\">{img}</div>\n </TapedPhoto>\n );\n}\n","import type { CSSProperties } from \"react\";\n\nimport { cn } from \"../cn\";\n\nexport interface WallObjectProps {\n /** Tilt in degrees, deterministic; defaults to zero. */\n rotation?: number;\n /** A tape strip or a pin; defaults to tape. */\n attachment?: \"tape\" | \"pin\";\n /** The tape or pin's tilt in degrees; defaults to zero. */\n attachmentRotation?: number;\n}\n\nexport const finite = (value: number) => Number.isFinite(value) ? value : 0;\nexport const rotationStyle = (rotation: number): CSSProperties =>\n ({ \"--kz-wall-rotation\": `${finite(rotation)}deg` }) as CSSProperties;\n\nexport function Attachment({ attachment = \"tape\", attachmentRotation = 0 }: WallObjectProps) {\n return <span aria-hidden=\"true\" className={cn(\"kz-wall-attachment\", attachment === \"pin\" ? \"kz-wall-pin\" : \"kz-wall-tape\")} style={{ transform: `rotate(${finite(attachmentRotation)}deg)` }} />;\n}\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { rotationStyle } from \"./attachment\";\n\nexport interface ShopSignProps extends Omit<React.ComponentProps<\"div\">, \"style\"> {\n /** The shop's name as live text, in the sign's lettering: the page's heading (`as`). Prefer it to an image of the name. */\n children?: React.ReactNode;\n /** The element of the name: the page's `h1` by default, `h2`/`h3` for a second sign, `p` for none. A sign on a `Wall` is a `p` unless told otherwise. */\n as?: \"h1\" | \"h2\" | \"h3\" | \"p\";\n /** The owner's logo or wordmark, optional beside the name. Name an SVG/image accessibly, or use readable text. */\n logo?: React.ReactNode;\n /** Enamel plate and screws, softly glowing neon, a time-worn painted sign, or `none` (the name alone on paper). */\n variant?: \"enamel\" | \"neon\" | \"painted\" | \"none\";\n /** Deterministic tilt in degrees; defaults to zero. */\n rotation?: number;\n /** Allow one soft neon flicker the first time the sign is seen; defaults to true, never loops, respects reduced motion. */\n animated?: boolean;\n}\n\n/** The neon's first view: `waiting` until it is on screen, then `ready` once. Nothing under reduced motion or without observers. */\nfunction useFirstView(enabled: boolean) {\n const ref = React.useRef<HTMLDivElement>(null);\n const [state, setState] = React.useState<\"waiting\" | \"ready\" | undefined>();\n React.useEffect(() => {\n if (!enabled || !ref.current || typeof IntersectionObserver === \"undefined\" || typeof matchMedia === \"undefined\") return;\n const preference = matchMedia(\"(prefers-reduced-motion: reduce)\");\n let seen = false;\n let observer: IntersectionObserver | undefined;\n const sync = () => {\n observer?.disconnect();\n if (preference.matches) {\n setState(undefined);\n } else if (!seen) {\n setState(\"waiting\");\n observer = new IntersectionObserver((entries) => {\n if (seen || !entries.some((entry) => entry.isIntersecting)) return;\n seen = true;\n setState(\"ready\");\n observer?.disconnect();\n }, { threshold: 0.3 });\n observer.observe(ref.current!);\n }\n };\n sync();\n preference.addEventListener(\"change\", sync);\n return () => { observer?.disconnect(); preference.removeEventListener(\"change\", sync); };\n }, [enabled]);\n return [ref, state] as const;\n}\n\n/** A shop's own mark, as a plate, a neon, a painted sign, or the name alone. */\nexport function ShopSign({ children, as: Name = \"h1\", logo, variant = \"enamel\", rotation = 0, animated = true, className, ...props }: ShopSignProps) {\n const [ref, lit] = useFirstView(variant === \"neon\" && animated);\n return (\n <div {...props} ref={ref} className={cn(\"kz-shop-sign kz-wall-object\", className)} style={rotationStyle(rotation)} data-variant={variant} data-animated={animated ? \"\" : undefined} data-lit={lit}>\n {variant === \"enamel\" && [0, 1, 2, 3].map((corner) => <span key={corner} aria-hidden=\"true\" className=\"kz-shop-sign-screw\" data-corner={corner} />)}\n {logo && <div className=\"kz-shop-sign-logo\">{logo}</div>}\n {children && <Name className=\"kz-shop-sign-name\">{children}</Name>}\n </div>\n );\n}\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { finite } from \"./attachment\";\nimport { PinnedNote, type PinnedNoteProps } from \"./pinned-note\";\nimport { Polaroid, type PolaroidProps } from \"./polaroid\";\nimport { ShopSign, type ShopSignProps } from \"./shop-sign\";\n\nexport interface WallPosition {\n /** Stable identity for this object. */\n id: string;\n /** Horizontal placement as a percentage (0–100); clamped to the wall. */\n x: number;\n /** Vertical placement as a percentage (0–100); clamped to the wall. */\n y: number;\n /** Tilt in degrees; defaults to zero. */\n rotation?: number;\n /** Stacking and reading order, ascending; ties preserve input order. */\n z: number;\n}\n\n/** The item's kind chooses its component; its remaining fields are that component's props. */\nexport type WallItem = WallPosition & (\n | ({ /** A framed photo. */ kind: \"polaroid\" } & PolaroidProps)\n | ({ /** A short pinned message. */ kind: \"note\" } & PinnedNoteProps)\n | ({ /** The owner's sign. */ kind: \"sign\" } & ShopSignProps)\n);\n\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;\n\nexport interface WallProps extends Omit<React.ComponentProps<\"ul\">, \"children\" | \"style\" | \"role\"> {\n /** The read-only objects; never mutated. Sorted by z for reading, keyboard and phone order. */\n items: readonly WallItem[];\n /** CSS/SVG texture; no image download. Defaults to plaster. */\n texture?: \"brick\" | \"zellige\" | \"ridge\" | \"plaster\";\n /** Draws at most this many items (the first in z order); defaults to 12. The rest belongs to the host's « see the whole wall ». */\n max?: number;\n /** A fixed desktop surface height in pixels (minimum 320). Absent, the surface is a fixed 16:9 box. Phones grow with content. */\n height?: number;\n /** Desktop object width in pixels (minimum 120); defaults to 240 and never exceeds the surface. */\n itemWidth?: number;\n}\n\n/** The object of one item, straight: the wall places and tilts it. A sign on a wall is a paragraph, not a second h1. */\nfunction WallObject({ item }: { readonly item: DistributiveOmit<WallItem, keyof WallPosition> }) {\n if (item.kind === \"polaroid\") return <Polaroid {...item} rotation={0} />;\n if (item.kind === \"note\") return <PinnedNote {...item} rotation={0} />;\n return <ShopSign {...item} as={item.as ?? \"p\"} rotation={0} />;\n}\n\n/** A decorative textured surface over a real keyboard-reachable list; never an editor. */\nexport function Wall({ items, texture = \"plaster\", max = 12, height, itemWidth = 240, className, ...props }: WallProps) {\n const patternId = React.useId().replace(/:/g, \"\");\n const drawn = Math.max(0, Math.floor(finite(max)));\n return (\n <ul {...props} role=\"list\" className={cn(\"kz-wall\", className)} data-texture={texture} data-count={Math.min(items.length, drawn)} data-fixed-height={height === undefined ? undefined : \"\"} style={{ ...(height === undefined ? null : { \"--kz-wall-height\": `${Math.max(320, finite(height))}px` }), \"--kz-wall-item-width\": `${Math.max(120, finite(itemWidth))}px` } as React.CSSProperties}>\n {[...items].sort((a, b) => finite(a.z) - finite(b.z)).slice(0, drawn).map(({ id, x, y, rotation = 0, z: _z, ...item }, rank) => (\n <li key={id} className=\"kz-wall-item\" tabIndex={0} style={{\n \"--kz-wall-x\": `${Math.min(100, Math.max(0, finite(x)))}%`,\n \"--kz-wall-y\": `${Math.min(100, Math.max(0, finite(y)))}%`,\n \"--kz-wall-rotation\": `${finite(rotation)}deg`,\n zIndex: rank,\n } as React.CSSProperties}>\n <WallObject item={item} />\n </li>\n ))}\n {texture === \"brick\" && <li className=\"kz-wall-decoration\" aria-hidden=\"true\" role=\"presentation\"><svg width=\"100%\" height=\"100%\" aria-hidden=\"true\">\n <defs><pattern id={patternId} width=\"96\" height=\"48\" patternUnits=\"userSpaceOnUse\">\n <path d=\"M0 0H96M0 24H96M0 48H96M48 0V24M0 24V48M96 24V48\" fill=\"none\" stroke=\"var(--kz-border-default)\" strokeWidth=\"2\" />\n </pattern></defs><rect width=\"100%\" height=\"100%\" fill={`url(#${patternId})`} />\n </svg></li>}\n {texture === \"zellige\" && <li className=\"kz-wall-decoration\" aria-hidden=\"true\" role=\"presentation\"><svg width=\"100%\" height=\"100%\" aria-hidden=\"true\">\n <defs><pattern id={patternId} width=\"64\" height=\"64\" patternUnits=\"userSpaceOnUse\">\n <path d=\"M32 3 39 15 52 12 49 25 61 32 49 39 52 52 39 49 32 61 25 49 12 52 15 39 3 32 15 25 12 12 25 15Z\" fill=\"var(--kz-accent-soft)\" stroke=\"var(--kz-border-default)\" />\n <path d=\"m32 18 14 14-14 14-14-14Z\" fill=\"var(--kz-surface-2)\" stroke=\"var(--kz-accent-2)\" />\n </pattern></defs><rect width=\"100%\" height=\"100%\" fill={`url(#${patternId})`} />\n </svg></li>}\n {texture === \"ridge\" && <li className=\"kz-wall-decoration\" aria-hidden=\"true\" role=\"presentation\"><svg viewBox=\"0 0 1000 600\" preserveAspectRatio=\"none\" width=\"100%\" height=\"100%\" aria-hidden=\"true\">\n <path d=\"M0 380 170 100 290 300 450 70 620 330 790 120 1000 350V600H0Z\" fill=\"var(--kz-accent-soft)\" />\n <path d=\"M0 470 200 280 370 440 600 190 760 400 920 260 1000 390V600H0Z\" fill=\"var(--kz-surface-2)\" />\n <path d=\"M0 540 180 430 360 520 540 390 760 520 900 410 1000 480V600H0Z\" fill=\"var(--kz-surface-3)\" />\n </svg></li>}\n </ul>\n );\n}\n"],"mappings":";;;;;;;;;;AAEO,SAAS,SAAS,MAAsB;AAC7C,MAAI,IAAI;AACR,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S,KAAK;AAAA,OAChF,GAAM;AAAA,IACL,YAAY,WAAW,gBAAAA,KAAC,QAAG,WAAU,sBAAqB,eAAY,QAAO,MAAK,gBAAe,0BAAAC,MAAC,SAAI,SAAQ,gBAAe,qBAAoB,QAAO,OAAM,QAAO,QAAO,QAAO,eAAY,QAC9L;AAAA,sBAAAD,KAAC,UAAK,GAAE,iEAAgE,MAAK,yBAAwB;AAAA,MACrG,gBAAAA,KAAC,UAAK,GAAE,kEAAiE,MAAK,uBAAsB;AAAA,MACpG,gBAAAA,KAAC,UAAK,GAAE,kEAAiE,MAAK,uBAAsB;AAAA,OACtG,GAAM;AAAA,KACR;AAEJ;","names":["jsx","jsxs","jsx","jsx","jsxs","React","jsx","jsxs","React","jsx","jsxs"]}
1
+ {"version":3,"sources":["../src/cahier-seed.ts","../src/stuck/stuck.tsx","../src/wall/pinned-note.tsx","../src/wall/polaroid.tsx","../src/wall/attachment.tsx","../src/wall/shop-sign.tsx","../src/wall/wall.tsx"],"sourcesContent":["// The Cahier's small deterministic randomness: a string (an id, a slug, a title) becomes a number in [-1, 1], always the\n// same one, so a tilt or a wobble drawn \"by hand\" is the same on the server, on the client and in every screenshot.\nexport function seedUnit(seed: string): number {\n let h = 2166136261;\n for (let i = 0; i < seed.length; i++) h = Math.imul(h ^ seed.charCodeAt(i), 16777619);\n return ((h >>> 0) % 2001) / 1000 - 1;\n}\n","// Server-safe. A block stuck into the notebook (ADR-004, blocks.css): a figure, a specimen tag, a card, a print — held by\n// tape, a pin, photo corners or a lifted edge, slightly tilted (from data, never random), on the Cahier's hard paper\n// shadow. The tape is TapedPhoto's own (the same rule in blocks.css). The tilt is a transform: nothing shifts.\nimport type * as React from \"react\";\n\nimport { seedUnit } from \"../cahier-seed\";\nimport { cn } from \"../cn\";\n\nexport type StuckHold = \"tape\" | \"tape-corners\" | \"pin\" | \"corner\" | \"glue\";\n\nexport type StuckProps = Omit<React.HTMLAttributes<HTMLElement>, \"children\"> & {\n /** What is stuck: a figure, a `SpecimenTag`, a card, a `TapedPhoto`. */\n children: React.ReactNode;\n /**\n * How it is held: `tape` (one strip), `tape-corners` (two opposite corners), `pin` (a drawing pin), `corner` (photo\n * corners) or `glue` (a slightly lifted edge).\n * @default \"tape\"\n */\n hold?: StuckHold;\n /** The tilt in degrees (negative leans left). Without it, the tilt comes from `seed`. */\n tilt?: number;\n /** Where the tilt comes from when `tilt` is not given: the same string always leans the same way (±2°). @default \"\" */\n seed?: string;\n /** Margin doodles (`Doodle`) drawn beside the block; they leave with the margin on a narrow screen. */\n doodle?: React.ReactNode;\n /** The element of the wrapper. A `figure` goes inside, never here. @default \"div\" */\n as?: \"div\" | \"li\" | \"aside\";\n};\n\n/** The tilt of a stuck block: `tilt` when given, otherwise a steady lean (−2° to 2°) read from `seed`, rounded to a tenth. */\nexport function stuckTilt(seed: string, tilt?: number): number {\n return tilt ?? Math.round(seedUnit(seed) * 20) / 10;\n}\n\n/** A block stuck into the notebook: held by tape, a pin, photo corners or glue; tilted from data; a hard paper shadow. */\nexport function Stuck({ children, hold = \"tape\", tilt, seed = \"\", doodle, as: Tag = \"div\", className, style, ...props }: StuckProps) {\n return (\n <Tag className={cn(\"kz-stuck\", className)} style={style} {...props}>\n <div className=\"kz-stuck-body\" data-hold={hold} style={{ [\"--kz-stuck-tilt\" as string]: `${stuckTilt(seed, tilt)}deg` }}>\n {hold === \"pin\" ? <span className=\"kz-stuck-pin\" aria-hidden /> : null}\n {children}\n </div>\n {doodle}\n </Tag>\n );\n}\n","import type * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { Stuck } from \"../stuck\";\nimport type { WallObjectProps } from \"./attachment\";\n\nexport interface PinnedNoteProps extends Omit<React.ComponentProps<\"article\">, \"children\" | \"style\">, WallObjectProps {\n /** The short message; capped at 140 Unicode code points without an ellipsis. */\n text: string;\n /** The optional author's signature, written in the handwriting role. */\n signature?: string;\n /** The ink of the pen: blue ink, the margin's red, or the page's hue. @default \"blue\" */\n ink?: \"blue\" | \"margin\" | \"hue\";\n /** How the note is held, through `Stuck`: a strip of tape or a pin. Takes over `attachment`. @default \"tape\" */\n hold?: \"tape\" | \"pin\";\n /** The colour of the paper: the page's own, or a real post-it (butter, rose, mint, sky), pale in both themes with the pen dark on it. @default \"plain\" */\n paper?: \"plain\" | \"butter\" | \"rose\" | \"mint\" | \"sky\";\n /** A small action under the words (a link, a button) kept inside the note and reachable by keyboard; it is never part of the capped text. */\n action?: React.ReactNode;\n /** How many Unicode code points of `text` are kept (a flyer longer than a word is read whole). @default 140 */\n limit?: number;\n /** The lines of the text box, fixed so a late font never shifts the page (the text is read in full by assistive technology). @default 4 */\n lines?: number;\n}\n\n/** A short word on a cut-corner card, stuck into the notebook. */\nexport function PinnedNote({ text, signature, rotation = 0, attachment, attachmentRotation: _attachmentRotation, ink = \"blue\", paper = \"plain\", action, limit = 140, hold, lines = 4, className, ...props }: PinnedNoteProps) {\n const rows = Math.max(1, Math.round(Number.isFinite(lines) ? lines : 4));\n return (\n <Stuck hold={hold ?? attachment ?? \"tape\"} tilt={Number.isFinite(rotation) ? rotation : 0} className=\"kz-wall-object kz-pinned-stuck\">\n <article {...props} className={cn(\"kz-pinned-note\", className)} data-shape=\"cut\" data-ink={ink} data-paper={paper === \"plain\" ? undefined : paper} style={{ \"--kz-note-lines\": rows } as React.CSSProperties}>\n <div className=\"kz-pinned-note-paper\">\n <p className=\"kz-pinned-note-text\">{Array.from(text).slice(0, Number.isFinite(limit) ? Math.max(0, Math.floor(limit)) : 140).join(\"\")}</p>\n {signature && <p className=\"kz-pinned-note-signature\">{signature}</p>}\n {action && <div className=\"kz-pinned-note-action\">{action}</div>}\n </div>\n </article>\n </Stuck>\n );\n}\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { TapedPhoto } from \"../taped-photo\";\nimport { Attachment, finite, type WallObjectProps } from \"./attachment\";\n\nexport interface PolaroidProps extends Omit<React.ComponentProps<\"figure\">, \"children\" | \"style\">, WallObjectProps {\n /** The photo slot: an img or next/image, including fill inside this positioned frame. Supply its alt text. */\n img: React.ReactNode;\n /** A short handwritten caption, using the --kz-font-cahier role. */\n caption?: React.ReactNode;\n /** Enable the first-view develop effect; defaults to true, never runs under reduced motion. */\n develop?: boolean;\n}\n\n/** A photo held to the wall by tape or a pin, with a handwritten caption. */\nexport function Polaroid({ img, caption, rotation = 0, attachment = \"tape\", attachmentRotation = 0, develop = true, className, ...props }: PolaroidProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const [state, setState] = React.useState<\"waiting\" | \"ready\" | undefined>();\n React.useEffect(() => {\n if (!develop || !ref.current || typeof IntersectionObserver === \"undefined\" || typeof matchMedia === \"undefined\") return;\n const preference = matchMedia(\"(prefers-reduced-motion: reduce)\");\n let seen = false;\n let observer: IntersectionObserver | undefined;\n const sync = () => {\n observer?.disconnect();\n if (preference.matches) {\n seen = true;\n setState(undefined);\n } else if (!seen) {\n setState(\"waiting\");\n observer = new IntersectionObserver((entries) => {\n if (seen || !entries.some((entry) => entry.isIntersecting)) return;\n seen = true;\n setState(\"ready\");\n observer?.disconnect();\n }, { threshold: 0.15 });\n observer.observe(ref.current!);\n }\n };\n sync();\n preference.addEventListener(\"change\", sync);\n return () => { observer?.disconnect(); preference.removeEventListener(\"change\", sync); };\n }, [develop]);\n return (\n <TapedPhoto {...props} className={cn(\"kz-polaroid\", className)} tilt={finite(rotation)} tape={attachment === \"pin\" ? \"none\" : \"top\"} caption={caption}\n style={{ \"--kz-wall-attachment-rotation\": `${finite(attachmentRotation)}deg` } as React.CSSProperties} data-develop={develop ? state : undefined}>\n {attachment === \"pin\" && <Attachment attachment=\"pin\" attachmentRotation={attachmentRotation} />}\n <div ref={ref} className=\"kz-polaroid-photo\">{img}</div>\n </TapedPhoto>\n );\n}\n","import type { CSSProperties } from \"react\";\n\nimport { cn } from \"../cn\";\n\nexport interface WallObjectProps {\n /** Tilt in degrees, deterministic; defaults to zero. */\n rotation?: number;\n /** A tape strip or a pin; defaults to tape. */\n attachment?: \"tape\" | \"pin\";\n /** The tape or pin's tilt in degrees; defaults to zero. */\n attachmentRotation?: number;\n}\n\nexport const finite = (value: number) => Number.isFinite(value) ? value : 0;\nexport const rotationStyle = (rotation: number): CSSProperties =>\n ({ \"--kz-wall-rotation\": `${finite(rotation)}deg` }) as CSSProperties;\n\nexport function Attachment({ attachment = \"tape\", attachmentRotation = 0 }: WallObjectProps) {\n return <span aria-hidden=\"true\" className={cn(\"kz-wall-attachment\", attachment === \"pin\" ? \"kz-wall-pin\" : \"kz-wall-tape\")} style={{ transform: `rotate(${finite(attachmentRotation)}deg)` }} />;\n}\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { rotationStyle } from \"./attachment\";\n\nexport interface ShopSignProps extends Omit<React.ComponentProps<\"div\">, \"style\"> {\n /** The shop's name as live text, in the sign's lettering: the page's heading (`as`). Prefer it to an image of the name. */\n children?: React.ReactNode;\n /** The element of the name: the page's `h1` by default, `h2`/`h3` for a second sign, `p` for none. A sign on a `Wall` is a `p` unless told otherwise. */\n as?: \"h1\" | \"h2\" | \"h3\" | \"p\";\n /** The owner's logo or wordmark, optional beside the name. Name an SVG/image accessibly, or use readable text. */\n logo?: React.ReactNode;\n /** Enamel plate and screws, softly glowing neon, a time-worn painted sign, or `none` (the name alone on paper). */\n variant?: \"enamel\" | \"neon\" | \"painted\" | \"none\";\n /** Deterministic tilt in degrees; defaults to zero. */\n rotation?: number;\n /** Allow one soft neon flicker the first time the sign is seen; defaults to true, never loops, respects reduced motion. */\n animated?: boolean;\n}\n\n/** The neon's first view: `waiting` until it is on screen, then `ready` once. Nothing under reduced motion or without observers. */\nfunction useFirstView(enabled: boolean) {\n const ref = React.useRef<HTMLDivElement>(null);\n const [state, setState] = React.useState<\"waiting\" | \"ready\" | undefined>();\n React.useEffect(() => {\n if (!enabled || !ref.current || typeof IntersectionObserver === \"undefined\" || typeof matchMedia === \"undefined\") return;\n const preference = matchMedia(\"(prefers-reduced-motion: reduce)\");\n let seen = false;\n let observer: IntersectionObserver | undefined;\n const sync = () => {\n observer?.disconnect();\n if (preference.matches) {\n setState(undefined);\n } else if (!seen) {\n setState(\"waiting\");\n observer = new IntersectionObserver((entries) => {\n if (seen || !entries.some((entry) => entry.isIntersecting)) return;\n seen = true;\n setState(\"ready\");\n observer?.disconnect();\n }, { threshold: 0.3 });\n observer.observe(ref.current!);\n }\n };\n sync();\n preference.addEventListener(\"change\", sync);\n return () => { observer?.disconnect(); preference.removeEventListener(\"change\", sync); };\n }, [enabled]);\n return [ref, state] as const;\n}\n\n/** A shop's own mark, as a plate, a neon, a painted sign, or the name alone. */\nexport function ShopSign({ children, as: Name = \"h1\", logo, variant = \"enamel\", rotation = 0, animated = true, className, ...props }: ShopSignProps) {\n const [ref, lit] = useFirstView(variant === \"neon\" && animated);\n return (\n <div {...props} ref={ref} className={cn(\"kz-shop-sign kz-wall-object\", className)} style={rotationStyle(rotation)} data-variant={variant} data-animated={animated ? \"\" : undefined} data-lit={lit}>\n {variant === \"enamel\" && [0, 1, 2, 3].map((corner) => <span key={corner} aria-hidden=\"true\" className=\"kz-shop-sign-screw\" data-corner={corner} />)}\n {logo && <div className=\"kz-shop-sign-logo\">{logo}</div>}\n {children && <Name className=\"kz-shop-sign-name\">{children}</Name>}\n </div>\n );\n}\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { finite } from \"./attachment\";\nimport { PinnedNote, type PinnedNoteProps } from \"./pinned-note\";\nimport { Polaroid, type PolaroidProps } from \"./polaroid\";\nimport { ShopSign, type ShopSignProps } from \"./shop-sign\";\n\nexport interface WallPosition {\n /** Stable identity for this object. */\n id: string;\n /** Horizontal placement as a percentage (0–100); clamped to the wall. Unused by the tidy layout. */\n x?: number;\n /** Vertical placement as a percentage (0–100); clamped to the wall. Unused by the tidy layout. */\n y?: number;\n /** Tilt in degrees; defaults to zero. */\n rotation?: number;\n /** Stacking and reading order, ascending; ties preserve input order. */\n z: number;\n}\n\n/** The item's kind chooses its component; its remaining fields are that component's props. */\nexport type WallItem = WallPosition & (\n | ({ /** A framed photo. */ kind: \"polaroid\" } & PolaroidProps)\n | ({ /** A short pinned message. */ kind: \"note\" } & PinnedNoteProps)\n | ({ /** The owner's sign. */ kind: \"sign\" } & ShopSignProps)\n);\n\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;\n\nexport interface WallProps extends Omit<React.ComponentProps<\"ul\">, \"children\" | \"style\" | \"role\"> {\n /** The read-only objects; never mutated. Sorted by z for reading, keyboard and phone order. */\n items: readonly WallItem[];\n /** CSS/SVG texture; no image download. Defaults to plaster. */\n texture?: \"brick\" | \"zellige\" | \"ridge\" | \"plaster\";\n /** Draws at most this many items (the first in z order); defaults to 12. The rest belongs to the host's « see the whole wall ». */\n max?: number;\n /** A fixed desktop surface height in pixels (minimum 320). Absent, the surface is a fixed 16:9 box. Phones grow with content. */\n height?: number;\n /** Desktop object width in pixels (minimum 120); defaults to 240 and never exceeds the surface. */\n itemWidth?: number;\n /**\n * `pinned` (default): objects placed at x / y on a fixed surface. `tidy`: the Cahier pinboard — a dense CSS grid (3 columns,\n * 2 on a phone, 1 on a very small one), a note may span two, each tilted 1–2° by its id (no random position), no JS layout.\n */\n layout?: \"pinned\" | \"tidy\";\n}\n\n/** A tilt of 1 to 2 degrees, either way, derived from the id: the same wall draws the same everywhere (server and client). */\nexport function tidyTilt(id: string): number {\n let h = 2166136261;\n for (let i = 0; i < id.length; i += 1) h = Math.imul(h ^ id.charCodeAt(i), 16777619);\n const n = (h >>> 0) % 4; // 0..3\n return [-2, -1, 1, 2][n]!;\n}\n\n/** The object of one item, straight: the wall places and tilts it. A sign on a wall is a paragraph, not a second h1. */\nfunction WallObject({ item }: { readonly item: DistributiveOmit<WallItem, keyof WallPosition> }) {\n if (item.kind === \"polaroid\") return <Polaroid {...item} rotation={0} />;\n if (item.kind === \"note\") return <PinnedNote {...item} rotation={0} />;\n return <ShopSign {...item} as={item.as ?? \"p\"} rotation={0} />;\n}\n\n/** A decorative textured surface over a real keyboard-reachable list; never an editor. */\nexport function Wall({ items, texture = \"plaster\", max = 12, height, itemWidth = 240, layout = \"pinned\", className, ...props }: WallProps) {\n const patternId = React.useId().replace(/:/g, \"\");\n const drawn = Math.max(0, Math.floor(finite(max)));\n return (\n <ul {...props} role=\"list\" className={cn(\"kz-wall\", className)} data-texture={texture} data-layout={layout === \"tidy\" ? \"tidy\" : undefined} data-count={Math.min(items.length, drawn)} data-fixed-height={height === undefined ? undefined : \"\"} style={{ ...(height === undefined ? null : { \"--kz-wall-height\": `${Math.max(320, finite(height))}px` }), \"--kz-wall-item-width\": `${Math.max(120, finite(itemWidth))}px` } as React.CSSProperties}>\n {[...items].sort((a, b) => finite(a.z) - finite(b.z)).slice(0, drawn).map(({ id, x = 0, y = 0, rotation, z: _z, ...item }, rank) => (\n <li key={id} className=\"kz-wall-item\" tabIndex={0} data-span={layout === \"tidy\" && item.kind === \"note\" ? \"2\" : undefined} style={{\n \"--kz-wall-x\": `${Math.min(100, Math.max(0, finite(x)))}%`,\n \"--kz-wall-y\": `${Math.min(100, Math.max(0, finite(y)))}%`,\n \"--kz-wall-rotation\": `${layout === \"tidy\" ? tidyTilt(id) : finite(rotation ?? 0)}deg`,\n zIndex: rank,\n } as React.CSSProperties}>\n <WallObject item={item} />\n </li>\n ))}\n {texture === \"brick\" && <li className=\"kz-wall-decoration\" aria-hidden=\"true\" role=\"presentation\"><svg width=\"100%\" height=\"100%\" aria-hidden=\"true\">\n <defs><pattern id={patternId} width=\"96\" height=\"48\" patternUnits=\"userSpaceOnUse\">\n <path d=\"M0 0H96M0 24H96M0 48H96M48 0V24M0 24V48M96 24V48\" fill=\"none\" stroke=\"var(--kz-border-default)\" strokeWidth=\"2\" />\n </pattern></defs><rect width=\"100%\" height=\"100%\" fill={`url(#${patternId})`} />\n </svg></li>}\n {texture === \"zellige\" && <li className=\"kz-wall-decoration\" aria-hidden=\"true\" role=\"presentation\"><svg width=\"100%\" height=\"100%\" aria-hidden=\"true\">\n <defs><pattern id={patternId} width=\"64\" height=\"64\" patternUnits=\"userSpaceOnUse\">\n <path d=\"M32 3 39 15 52 12 49 25 61 32 49 39 52 52 39 49 32 61 25 49 12 52 15 39 3 32 15 25 12 12 25 15Z\" fill=\"var(--kz-accent-soft)\" stroke=\"var(--kz-border-default)\" />\n <path d=\"m32 18 14 14-14 14-14-14Z\" fill=\"var(--kz-surface-2)\" stroke=\"var(--kz-accent-2)\" />\n </pattern></defs><rect width=\"100%\" height=\"100%\" fill={`url(#${patternId})`} />\n </svg></li>}\n {texture === \"ridge\" && <li className=\"kz-wall-decoration\" aria-hidden=\"true\" role=\"presentation\"><svg viewBox=\"0 0 1000 600\" preserveAspectRatio=\"none\" width=\"100%\" height=\"100%\" aria-hidden=\"true\">\n <path d=\"M0 380 170 100 290 300 450 70 620 330 790 120 1000 350V600H0Z\" fill=\"var(--kz-accent-soft)\" />\n <path d=\"M0 470 200 280 370 440 600 190 760 400 920 260 1000 390V600H0Z\" fill=\"var(--kz-surface-2)\" />\n <path d=\"M0 540 180 430 360 520 540 390 760 520 900 410 1000 480V600H0Z\" fill=\"var(--kz-surface-3)\" />\n </svg></li>}\n </ul>\n );\n}\n"],"mappings":";;;;;;;;;;AAEO,SAAS,SAAS,MAAsB;AAC7C,MAAI,IAAI;AACR,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,IAAK,KAAI,KAAK,KAAK,IAAI,KAAK,WAAW,CAAC,GAAG,QAAQ;AACpF,UAAS,MAAM,KAAK,OAAQ,MAAO;AACrC;;;ACgCM,SACoB,KADpB;AARC,SAAS,UAAU,MAAc,MAAuB;AAC7D,SAAO,QAAQ,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE,IAAI;AACnD;AAGO,SAAS,MAAM,EAAE,UAAU,OAAO,QAAQ,MAAM,OAAO,IAAI,QAAQ,IAAI,MAAM,OAAO,WAAW,OAAO,GAAG,MAAM,GAAe;AACnI,SACE,qBAAC,O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AAM;AAAA,IACL,YAAY,WAAW,gBAAAA,KAAC,QAAG,WAAU,sBAAqB,eAAY,QAAO,MAAK,gBAAe,0BAAAC,MAAC,SAAI,SAAQ,gBAAe,qBAAoB,QAAO,OAAM,QAAO,QAAO,QAAO,eAAY,QAC9L;AAAA,sBAAAD,KAAC,UAAK,GAAE,iEAAgE,MAAK,yBAAwB;AAAA,MACrG,gBAAAA,KAAC,UAAK,GAAE,kEAAiE,MAAK,uBAAsB;AAAA,MACpG,gBAAAA,KAAC,UAAK,GAAE,kEAAiE,MAAK,uBAAsB;AAAA,OACtG,GAAM;AAAA,KACR;AAEJ;","names":["jsx","jsxs","jsx","jsx","jsxs","React","jsx","jsxs","React","jsx","jsxs"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krizaka/ui",
3
- "version": "3.76.1",
3
+ "version": "3.77.0",
4
4
  "description": "The Krizaka front-end platform's components: the primitives (button, card, dialog, toast, menu, field, tabs, chip, switch, slider, command palette, theme, countdown…) on the semantic --kz-* tokens, the animated marks (Krizaka, Orazaka, Yomizaka, Akinaza) and the motion signature — web and /native.",
5
5
  "keywords": [
6
6
  "krizaka",
@@ -413,6 +413,18 @@
413
413
  "types": "./dist/map.d.ts",
414
414
  "import": "./dist/map.js"
415
415
  },
416
+ "./map/sheet": {
417
+ "types": "./dist/map/sheet.d.ts",
418
+ "import": "./dist/map/sheet.js"
419
+ },
420
+ "./map/pin": {
421
+ "types": "./dist/map/pin.d.ts",
422
+ "import": "./dist/map/pin.js"
423
+ },
424
+ "./map/cards": {
425
+ "types": "./dist/map/cards.d.ts",
426
+ "import": "./dist/map/cards.js"
427
+ },
416
428
  "./search-field": {
417
429
  "types": "./dist/search-field.d.ts",
418
430
  "import": "./dist/search-field.js"
@@ -977,7 +989,7 @@
977
989
  ],
978
990
  "peerDependencies": {
979
991
  "@krizaka/query": ">=0.3.0",
980
- "@krizaka/tailwind": ">=3.76.1",
992
+ "@krizaka/tailwind": ">=3.77.0",
981
993
  "@maplibre/maplibre-react-native": ">=11",
982
994
  "@shopify/flash-list": ">=2",
983
995
  "expo-camera": ">=16",
@@ -2934,10 +2946,43 @@
2934
2946
  "@krizaka/ui"
2935
2947
  ]
2936
2948
  },
2949
+ {
2950
+ "name": "./map/sheet",
2951
+ "path": "dist/map/sheet.js",
2952
+ "limit": "1.1 kB",
2953
+ "gzip": true,
2954
+ "ignore": [
2955
+ "tailwind-variants",
2956
+ "clsx",
2957
+ "react-dom"
2958
+ ]
2959
+ },
2960
+ {
2961
+ "name": "./map/pin",
2962
+ "path": "dist/map/pin.js",
2963
+ "limit": "1.2 kB",
2964
+ "gzip": true,
2965
+ "ignore": [
2966
+ "tailwind-variants",
2967
+ "clsx",
2968
+ "react-dom"
2969
+ ]
2970
+ },
2971
+ {
2972
+ "name": "./map/cards",
2973
+ "path": "dist/map/cards.js",
2974
+ "limit": "1.4 kB",
2975
+ "gzip": true,
2976
+ "ignore": [
2977
+ "tailwind-variants",
2978
+ "clsx",
2979
+ "react-dom"
2980
+ ]
2981
+ },
2937
2982
  {
2938
2983
  "name": "./map",
2939
2984
  "path": "dist/map.js",
2940
- "limit": "18 kB",
2985
+ "limit": "17.2 kB",
2941
2986
  "gzip": true,
2942
2987
  "ignore": [
2943
2988
  "tailwind-variants",
@@ -2950,7 +2995,7 @@
2950
2995
  {
2951
2996
  "name": "./native/map",
2952
2997
  "path": "dist/native/map.js",
2953
- "limit": "13.5 kB",
2998
+ "limit": "13.2 kB",
2954
2999
  "gzip": true,
2955
3000
  "ignore": [
2956
3001
  "react-native",
@@ -3367,8 +3412,8 @@
3367
3412
  "tailwind-variants": "^3.3.1",
3368
3413
  "zod": "^4.6.7",
3369
3414
  "@krizaka/intl": "^0.4.1",
3370
- "@krizaka/pacer": "^0.1.0",
3371
- "@krizaka/tokens": "^3.76.1"
3415
+ "@krizaka/tokens": "^3.77.0",
3416
+ "@krizaka/pacer": "^0.1.0"
3372
3417
  },
3373
3418
  "scripts": {
3374
3419
  "build": "node -e \"const fs=require('node:fs');fs.rmSync('dist',{recursive:true,force:true});for(const f of fs.readdirSync('registry/examples',{recursive:true}))if(/\\.(js|d\\.ts)$/.test(f))fs.rmSync('registry/examples/'+f)\" && tsup && node -e \"require('node:fs').copyFileSync('src/motion.css','dist/motion.css');require('node:fs').copyFileSync('src/blocks.css','dist/blocks.css');require('node:fs').copyFileSync('src/story.css','dist/story.css')\" && node scripts/build-registry.mjs",
@@ -350,7 +350,7 @@
350
350
  }
351
351
  ],
352
352
  "dependencies": [
353
- "@krizaka/tokens@^3.76.1"
353
+ "@krizaka/tokens@^3.77.0"
354
354
  ],
355
355
  "registryDependencies": [
356
356
  "account-menu",
@@ -42,6 +42,7 @@
42
42
  ],
43
43
  "bestPractices": [
44
44
  "Keep the list of passages in the page, next to the viewer: the viewer is not a keyboard route to each box, your list is (`activeId` / `onActiveChange`).",
45
+ "Light a region instead of a quote when the app already knows where the evidence sits (`region: { page, x, y, width, height }`, fractions of the page): no text layer needed, and a region outside the page is never drawn.",
45
46
  "Pass the quote as the text layer reads it and, when you know it, the page: a quote the layout cut is still placed by its opening words, and a page alone still scrolls.",
46
47
  "Use `onLocate` to tell the person what was placed and what was not (« page 3 », « not found in the text layer ») — a passage is never drawn at a guessed place.",
47
48
  "Load pdf.js with `() => import(\"pdfjs-dist\")` and give it a same-origin worker (`workerSrc`): the engine only reaches pages that show a document."
@@ -67,7 +68,7 @@
67
68
  ],
68
69
  "web": {
69
70
  "entry": "@krizaka/ui/document-viewer",
70
- "import": "import { DocumentViewer, locateQuote } from \"@krizaka/ui/document-viewer\";",
71
+ "import": "import { DocumentViewer, locateQuote, locateRegion } from \"@krizaka/ui/document-viewer\";",
71
72
  "props": [
72
73
  {
73
74
  "component": "DocumentViewer",
@@ -136,10 +137,10 @@
136
137
  {
137
138
  "name": "highlights",
138
139
  "title": "Findings in the file",
139
- "description": "A one-page lease and two passages; pick one and the page scrolls to it and lights it.",
140
+ "description": "A one-page lease, two passages told by their quote and one by a region; pick one and the page scrolls to it and lights it.",
140
141
  "path": "examples/document-viewer/highlights.tsx",
141
142
  "module": "@krizaka/ui/registry/examples/document-viewer/highlights",
142
- "code": "\"use client\";\n\nimport { DocumentViewer } from \"@krizaka/ui/document-viewer\";\nimport * as React from \"react\";\n\nconst PDF = \"JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA2MTIgNzkyXSAvQ29udGVudHMgNCAwIFIgL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNSAwIFIgPj4gPj4gPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCAyMDkgPj4Kc3RyZWFtCkJUIC9GMSAxNCBUZiA3MiA3MDAgVGQgKEJBSUwgUkVTSURFTlRJRUwpIFRqIEVUCkJUIC9GMSAxMSBUZiA3MiA2NzAgVGQgKExlIGxvY2F0ZXVyIHBldXQgYXVnbWVudGVyIGxlIGxveWVyIGEgdG91dCBtb21lbnQuKSBUaiBFVApCVCAvRjEgMTEgVGYgNzIgNjUwIFRkIChMZSBkZXBvdCBkZSBnYXJhbnRpZSBlc3QgZGUgZGV1eCBtb2lzIGRlIGxveWVyLikgVGogRVQKZW5kc3RyZWFtCmVuZG9iago1IDAgb2JqCjw8IC9UeXBlIC9Gb250IC9TdWJ0eXBlIC9UeXBlMSAvQmFzZUZvbnQgL0hlbHZldGljYSA+PgplbmRvYmoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDExNSAwMDAwMCBuIAowMDAwMDAwMjQxIDAwMDAwIG4gCjAwMDAwMDA1MDAgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA2IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgo1NzAKJSVFT0YK\";\nconst quotes = [\n { id: \"r1\", quote: \"Le locateur peut augmenter le loyer à tout moment.\", label: \"Rent increase\" },\n { id: \"r2\", quote: \"Le dépôt de garantie est de deux mois de loyer.\", label: \"Deposit\" },\n];\n// pdf.js is the app's: `loadPdfjs={() => import(\"pdfjs-dist\")}` and a worker served from its own origin. Here, from a CDN.\nconst CDN = \"https://cdn.jsdelivr.net/npm/pdfjs-dist@5.4.149/build/\";\nconst loadPdfjs = () => import(/* webpackIgnore: true */ /* turbopackIgnore: true */ `${CDN}pdf.min.mjs`) as never;\n\n// Pick a passage in your own list: the viewer scrolls to it and lights it where it sits in the page.\nexport default function DocumentViewerHighlights() {\n const [active, setActive] = React.useState<string | null>(\"r1\");\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex gap-2\">\n {quotes.map((q) => (\n <button key={q.id} type=\"button\" aria-pressed={active === q.id} className=\"rounded-md border border-border-default px-3 py-1 text-sm aria-pressed:bg-surface-3\" onClick={() => setActive(q.id)}>\n {q.label}\n </button>\n ))}\n </div>\n <DocumentViewer src={Uint8Array.from(atob(PDF), (c) => c.charCodeAt(0))} loadPdfjs={loadPdfjs} workerSrc={`${CDN}pdf.worker.min.mjs`} highlights={quotes} activeId={active} onActiveChange={setActive} />\n </div>\n );\n}\n"
143
+ "code": "\"use client\";\n\nimport { DocumentViewer } from \"@krizaka/ui/document-viewer\";\nimport * as React from \"react\";\n\nconst PDF = \"JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA2MTIgNzkyXSAvQ29udGVudHMgNCAwIFIgL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNSAwIFIgPj4gPj4gPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCAyMDkgPj4Kc3RyZWFtCkJUIC9GMSAxNCBUZiA3MiA3MDAgVGQgKEJBSUwgUkVTSURFTlRJRUwpIFRqIEVUCkJUIC9GMSAxMSBUZiA3MiA2NzAgVGQgKExlIGxvY2F0ZXVyIHBldXQgYXVnbWVudGVyIGxlIGxveWVyIGEgdG91dCBtb21lbnQuKSBUaiBFVApCVCAvRjEgMTEgVGYgNzIgNjUwIFRkIChMZSBkZXBvdCBkZSBnYXJhbnRpZSBlc3QgZGUgZGV1eCBtb2lzIGRlIGxveWVyLikgVGogRVQKZW5kc3RyZWFtCmVuZG9iago1IDAgb2JqCjw8IC9UeXBlIC9Gb250IC9TdWJ0eXBlIC9UeXBlMSAvQmFzZUZvbnQgL0hlbHZldGljYSA+PgplbmRvYmoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDExNSAwMDAwMCBuIAowMDAwMDAwMjQxIDAwMDAwIG4gCjAwMDAwMDA1MDAgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA2IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgo1NzAKJSVFT0YK\";\n// Two passages told by their quote, and one told by a region of the page (fractions, origin top-left): an app that already\n// knows where a stamp or a mismatch sits lights it without any text to match.\nconst quotes = [\n { id: \"r1\", quote: \"Le locateur peut augmenter le loyer à tout moment.\", label: \"Rent increase\" },\n { id: \"r2\", quote: \"Le dépôt de garantie est de deux mois de loyer.\", label: \"Deposit\" },\n { id: \"r3\", region: { page: 1, x: 0.1, y: 0.1, width: 0.3, height: 0.05 }, label: \"Title block\" },\n];\n// pdf.js is the app's: `loadPdfjs={() => import(\"pdfjs-dist\")}` and a worker served from its own origin. Here, from a CDN.\nconst CDN = \"https://cdn.jsdelivr.net/npm/pdfjs-dist@5.4.149/build/\";\nconst loadPdfjs = () => import(/* webpackIgnore: true */ /* turbopackIgnore: true */ `${CDN}pdf.min.mjs`) as never;\n\n// Pick a passage in your own list: the viewer scrolls to it and lights it where it sits in the page.\nexport default function DocumentViewerHighlights() {\n const [active, setActive] = React.useState<string | null>(\"r1\");\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex gap-2\">\n {quotes.map((q) => (\n <button key={q.id} type=\"button\" aria-pressed={active === q.id} className=\"rounded-md border border-border-default px-3 py-1 text-sm aria-pressed:bg-surface-3\" onClick={() => setActive(q.id)}>\n {q.label}\n </button>\n ))}\n </div>\n <DocumentViewer src={Uint8Array.from(atob(PDF), (c) => c.charCodeAt(0))} loadPdfjs={loadPdfjs} workerSrc={`${CDN}pdf.worker.min.mjs`} highlights={quotes} activeId={active} onActiveChange={setActive} />\n </div>\n );\n}\n"
143
144
  }
144
145
  ]
145
146
  },
@@ -147,19 +148,19 @@
147
148
  "files": [
148
149
  {
149
150
  "path": "document-viewer/document-viewer.tsx",
150
- "content": "// Client. A PDF drawn page by page (pdf.js), and passages of it lit where they sit. The app hands over the engine\n// (`loadPdfjs={() => import(\"pdfjs-dist\")}` — an optional peer, loaded only on a page that shows a document) and the\n// worker's address; it hands over the passages as quotes (`highlights`), and the viewer finds their place from the\n// PDF's own text positions (`locateQuote`): one box per line, in fractions of the page, so they follow any zoom.\n// `activeId` (controlled) scrolls to a passage and strengthens it; a click on a box calls `onActiveChange`. A passage\n// the text layer cannot place is never drawn at a guessed place: the viewer goes to its page when it is known and shows\n// the quote in a bar — and tells the app (`onLocate`) so its list can say \"page 3\" or \"not found\".\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { useLatest, usePrefersReducedMotion } from \"../media\";\nimport { type Located, locateQuote, type PageText } from \"./locate\";\n\nexport const documentViewer = tv({\n slots: {\n root: \"relative flex min-w-0 flex-col gap-3\",\n pages: \"flex max-h-(--kz-document-viewer-height,70vh) flex-col gap-3 overflow-auto rounded-lg border border-border-default bg-surface-2 p-3 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent\",\n page: \"relative mx-auto w-full max-w-(--kz-document-viewer-page,56rem) shrink-0 overflow-hidden rounded-sm bg-white shadow-sm\",\n canvas: \"block h-auto w-full\",\n caption: \"absolute top-1 left-1 rounded-sm bg-surface-1/90 px-1.5 py-0.5 text-xs text-fg-secondary\",\n box: \"absolute cursor-pointer rounded-xs border border-warning/70 bg-warning/25 mix-blend-multiply transition-colors data-[active=true]:border-2 data-[active=true]:border-danger data-[active=true]:bg-danger/25 motion-reduce:transition-none\",\n bar: \"rounded-lg border border-border-default bg-surface-1 px-3 py-2 text-sm text-fg-secondary\",\n status: \"p-6 text-center text-sm text-fg-secondary\",\n },\n});\n\n/** The words of the viewer, passed translated. `{page}` and `{total}` are replaced. */\nexport type DocumentViewerLabels = {\n /** The accessible name of the pages' region. */\n region: string;\n loading: string;\n failed: string;\n /** A page's caption and accessible name: \"Page {page} of {total}\". */\n page: string;\n /** The bar above the pages when the active passage could only be placed on a page: \"Passage on page {page}:\". */\n onPage: string;\n /** The bar when the active passage is not in the text layer. */\n notFound: string;\n};\n\nexport const documentViewerLabels: DocumentViewerLabels = {\n region: \"Document pages\",\n loading: \"Loading the document…\",\n failed: \"The document could not be displayed.\",\n page: \"Page {page} of {total}\",\n onPage: \"Passage on page {page}:\",\n notFound: \"This passage is not in the document's text layer:\",\n};\n\n/** A passage to light: its quote (as the text layer reads it), the page if the app knows it, a name for screen readers. */\nexport type DocumentHighlight = { id: string; quote: string; page?: number; label?: string };\n\n/** What the viewer found for a passage. */\nexport type { Located };\n\n/** The members of pdf.js the viewer uses (`pdfjs-dist` ≥ 5), typed here so the package does not depend on it. */\nexport type PdfjsModule = {\n GlobalWorkerOptions: { workerSrc: string };\n getDocument(source: { url?: string; data?: Uint8Array }): { promise: Promise<PdfDocument>; destroy?: () => Promise<void> | void };\n};\nexport type PdfDocument = { numPages: number; getPage(n: number): Promise<PdfPage>; destroy?: () => Promise<void> | void };\nexport type PdfPage = {\n rotate: number;\n view: number[];\n getViewport(options: { scale: number }): { width: number; height: number };\n getTextContent(): Promise<{ items: readonly unknown[] }>;\n render(options: { canvas: HTMLCanvasElement; canvasContext: CanvasRenderingContext2D; viewport: { width: number; height: number } }): { promise: Promise<void>; cancel?: () => void };\n cleanup?: () => void;\n};\n\nexport type DocumentViewerProps = Omit<React.ComponentProps<\"div\">, \"children\" | \"onChange\"> & {\n /** The PDF: an address (same origin or CORS) or its bytes. */\n src: string | Uint8Array;\n /** Loads pdf.js: `() => import(\"pdfjs-dist\")`. An optional peer, never in a bundle without a document. */\n loadPdfjs: () => Promise<PdfjsModule>;\n /** The address of pdf.js's worker (`new URL(\"pdfjs-dist/build/pdf.worker.min.mjs\", import.meta.url).toString()`). */\n workerSrc: string;\n /** The passages to light. */\n highlights?: readonly DocumentHighlight[];\n /** The passage in focus: the viewer scrolls to it. */\n activeId?: string | null;\n /** A box was clicked (the id) or the focus was released (`null`). */\n onActiveChange?: (id: string | null) => void;\n /** Where each passage was found (`null`: nowhere) — once the text layer is read, and again if `highlights` change. */\n onLocate?: (found: Record<string, Located | null>) => void;\n /** Called when the document is open, with its page count. */\n onLoad?: (info: { pages: number }) => void;\n /** The words of the viewer, translated (English by default). */\n labels?: Partial<DocumentViewerLabels>;\n};\n\nconst fill = (template: string, vars: Record<string, string | number>) => template.replace(/\\{(\\w+)\\}/g, (m, k: string) => (k in vars ? String(vars[k]) : m));\n\ntype Loaded = { doc: PdfDocument; texts: PageText[]; sizes: { width: number; height: number }[] };\ntype Phase = { state: \"loading\" } | { state: \"error\"; key: string } | ({ state: \"ready\"; key: string } & Loaded);\n\nconst isItem = (x: unknown): x is PageText[\"items\"][number] => typeof x === \"object\" && x !== null && typeof (x as { str?: unknown }).str === \"string\" && Array.isArray((x as { transform?: unknown }).transform);\n\nfunction PageCanvas({ page, doc, caption, onReady, className }: { page: number; doc: PdfDocument; caption: string; onReady?: () => void; className: string }) {\n const ref = React.useRef<HTMLCanvasElement>(null);\n const wrapper = React.useRef<HTMLDivElement>(null);\n const [visible, setVisible] = React.useState(() => typeof IntersectionObserver === \"undefined\");\n const ready = useLatest(onReady);\n React.useEffect(() => {\n const node = wrapper.current?.parentElement;\n if (!node) return;\n if (typeof IntersectionObserver === \"undefined\") return;\n const observer = new IntersectionObserver((entries) => entries.some((e) => e.isIntersecting) && setVisible(true), { rootMargin: \"600px 0px\" });\n observer.observe(node);\n return () => observer.disconnect();\n }, []);\n React.useEffect(() => {\n if (!visible) return;\n let task: { promise: Promise<void>; cancel?: () => void } | undefined;\n let cancelled = false;\n void (async () => {\n const p = await doc.getPage(page);\n const canvas = ref.current;\n const ctx = canvas?.getContext(\"2d\");\n if (cancelled || !canvas || !ctx) return;\n const base = p.getViewport({ scale: 1 });\n const dpr = typeof window === \"undefined\" ? 1 : Math.min(2, window.devicePixelRatio || 1);\n const scale = Math.min(2.5, Math.max(1, (canvas.parentElement?.clientWidth || base.width) / base.width)) * dpr;\n const viewport = p.getViewport({ scale });\n canvas.width = Math.floor(viewport.width);\n canvas.height = Math.floor(viewport.height);\n task = p.render({ canvas, canvasContext: ctx, viewport });\n await task.promise.catch(() => undefined);\n if (!cancelled) ready.current?.();\n })().catch(() => undefined);\n return () => {\n cancelled = true;\n task?.cancel?.();\n };\n }, [visible, doc, page, ready]);\n return (\n <div ref={wrapper} className=\"contents\">\n <canvas ref={ref} aria-hidden=\"true\" className={className} />\n <span className=\"sr-only\">{caption}</span>\n </div>\n );\n}\n\n/** A PDF with its passages lit — see the file's header. Client. */\nexport function DocumentViewer({ src, loadPdfjs, workerSrc, highlights = [], activeId = null, onActiveChange, onLocate, onLoad, labels, className, ...props }: DocumentViewerProps) {\n const words = { ...documentViewerLabels, ...labels };\n const s = documentViewer();\n const reduce = usePrefersReducedMotion();\n const [loaded, setPhase] = React.useState<Phase>({ state: \"loading\" });\n const callbacks = useLatest({ onLoad, onLocate });\n const containerRef = React.useRef<HTMLDivElement>(null);\n const bytes = typeof src === \"string\" ? src : src.byteLength + \":\" + src[0] + \":\" + src[src.length - 1];\n // A result belongs to the document it was read from: another `src` is loading again, with no reset inside the effect.\n const phase: Phase = loaded.state !== \"loading\" && loaded.key !== bytes ? { state: \"loading\" } : loaded;\n\n // Open the document and read every page's text layer (positions only; nothing is sent anywhere).\n React.useEffect(() => {\n let cancelled = false;\n let opened: { destroy?: () => Promise<void> | void } | undefined;\n void (async () => {\n const pdfjs = await loadPdfjs();\n pdfjs.GlobalWorkerOptions.workerSrc = workerSrc;\n const loading = pdfjs.getDocument(typeof src === \"string\" ? { url: src } : { data: src.slice() });\n opened = loading;\n const doc = await loading.promise;\n const texts: PageText[] = [];\n const sizes: Loaded[\"sizes\"] = [];\n for (let n = 1; n <= doc.numPages; n++) {\n const page = await doc.getPage(n);\n const vp = page.getViewport({ scale: 1 });\n sizes.push({ width: vp.width, height: vp.height });\n const content = await page.getTextContent();\n // A rotated page has no reliable boxes: it keeps its size and an empty text layer (the app's page hint still works).\n texts.push({ page: n, width: vp.width, height: vp.height, items: page.rotate % 360 === 0 ? content.items.filter(isItem) : [] });\n page.cleanup?.();\n }\n if (cancelled) return;\n setPhase({ state: \"ready\", key: bytes, doc, texts, sizes });\n callbacks.current.onLoad?.({ pages: doc.numPages });\n })().catch(() => !cancelled && setPhase({ state: \"error\", key: bytes }));\n return () => {\n cancelled = true;\n void opened?.destroy?.();\n };\n // `src` is compared by content (`bytes`) so a re-render with the same bytes does not reopen the file.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [bytes, loadPdfjs, workerSrc, callbacks]);\n\n const key = highlights.map((h) => `${h.id}\\u0000${h.page ?? \"\"}\\u0000${h.quote}`).join(\"\\u0001\");\n const found = React.useMemo(() => {\n const out: Record<string, Located | null> = {};\n if (phase.state === \"ready\") for (const h of highlights) out[h.id] = locateQuote(phase.texts, h.quote, h.page);\n return out;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [phase, key]);\n React.useEffect(() => {\n if (phase.state === \"ready\") callbacks.current.onLocate?.(found);\n }, [found, phase.state, callbacks]);\n\n // Go to the active passage.\n const active = activeId ? highlights.find((h) => h.id === activeId) : undefined;\n const where = activeId ? found[activeId] : undefined;\n React.useEffect(() => {\n if (phase.state !== \"ready\" || !where) return;\n const root = containerRef.current;\n const target = root?.querySelector<HTMLElement>(where.boxes.length > 0 ? `[data-highlight=\"${CSS.escape(activeId!)}\"]` : `[data-page=\"${where.page}\"]`) ?? null;\n target?.scrollIntoView?.({ block: where.boxes.length > 0 ? \"center\" : \"start\", behavior: reduce ? \"auto\" : \"smooth\" });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeId, where, phase.state]);\n\n return (\n <div className={s.root({ className })} {...props}>\n {active && where !== undefined && where?.match !== \"exact\" && where?.match !== \"start\" ? (\n <p className={s.bar()} data-testid=\"document-viewer-bar\">\n {where?.match === \"page\" ? fill(words.onPage, { page: where.page }) : words.notFound} <q>{active.quote}</q>\n </p>\n ) : null}\n <div ref={containerRef} className={s.pages()} role=\"region\" aria-label={words.region} tabIndex={0}>\n {phase.state === \"loading\" ? <p className={s.status()}>{words.loading}</p> : null}\n {phase.state === \"error\" ? <p role=\"alert\" className={s.status()}>{words.failed}</p> : null}\n {phase.state === \"ready\"\n ? phase.texts.map((t, i) => {\n const size = phase.sizes[i]!;\n const caption = fill(words.page, { page: t.page, total: phase.doc.numPages });\n return (\n <div key={t.page} className={s.page()} data-page={t.page} style={{ aspectRatio: `${size.width} / ${size.height}` }}>\n <PageCanvas page={t.page} doc={phase.doc} caption={caption} className={s.canvas()} />\n <span className={s.caption()} aria-hidden=\"true\">{caption}</span>\n {highlights.flatMap((h) => {\n const f = found[h.id];\n if (!f || f.page !== t.page) return [];\n return f.boxes.map((b, k) => (\n <div\n key={`${h.id}:${k}`}\n aria-hidden=\"true\"\n data-highlight={h.id}\n data-active={h.id === activeId}\n className={s.box()}\n style={{ left: `${b.x * 100}%`, top: `${b.y * 100}%`, width: `${b.width * 100}%`, height: `${b.height * 100}%` }}\n onClick={() => onActiveChange?.(h.id === activeId ? null : h.id)}\n />\n ));\n })}\n </div>\n );\n })\n : null}\n </div>\n </div>\n );\n}\n"
151
+ "content": "// Client. A PDF drawn page by page (pdf.js), and passages of it lit where they sit. The app hands over the engine\n// (`loadPdfjs={() => import(\"pdfjs-dist\")}` — an optional peer, loaded only on a page that shows a document) and the\n// worker's address; it hands over the passages as quotes (`highlights`), and the viewer finds their place from the\n// PDF's own text positions (`locateQuote`): one box per line, in fractions of the page, so they follow any zoom.\n// `activeId` (controlled) scrolls to a passage and strengthens it; a click on a box calls `onActiveChange`. A passage\n// the text layer cannot place is never drawn at a guessed place: the viewer goes to its page when it is known and shows\n// the quote in a bar — and tells the app (`onLocate`) so its list can say \"page 3\" or \"not found\".\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { useLatest, usePrefersReducedMotion } from \"../media\";\nimport { type Located, type PageText, type Region, resolveHighlight } from \"./locate\";\n\nexport const documentViewer = tv({\n slots: {\n root: \"relative flex min-w-0 flex-col gap-3\",\n pages: \"flex max-h-(--kz-document-viewer-height,70vh) flex-col gap-3 overflow-auto rounded-lg border border-border-default bg-surface-2 p-3 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent\",\n page: \"relative mx-auto w-full max-w-(--kz-document-viewer-page,56rem) shrink-0 overflow-hidden rounded-sm bg-white shadow-sm\",\n canvas: \"block h-auto w-full\",\n caption: \"absolute top-1 left-1 rounded-sm bg-surface-1/90 px-1.5 py-0.5 text-xs text-fg-secondary\",\n box: \"absolute cursor-pointer rounded-xs border border-warning/70 bg-warning/25 mix-blend-multiply transition-colors data-[active=true]:border-2 data-[active=true]:border-danger data-[active=true]:bg-danger/25 motion-reduce:transition-none\",\n bar: \"rounded-lg border border-border-default bg-surface-1 px-3 py-2 text-sm text-fg-secondary\",\n status: \"p-6 text-center text-sm text-fg-secondary\",\n },\n});\n\n/** The words of the viewer, passed translated. `{page}` and `{total}` are replaced. */\nexport type DocumentViewerLabels = {\n /** The accessible name of the pages' region. */\n region: string;\n loading: string;\n failed: string;\n /** A page's caption and accessible name: \"Page {page} of {total}\". */\n page: string;\n /** The bar above the pages when the active passage could only be placed on a page: \"Passage on page {page}:\". */\n onPage: string;\n /** The bar when the active passage is not in the text layer. */\n notFound: string;\n};\n\nexport const documentViewerLabels: DocumentViewerLabels = {\n region: \"Document pages\",\n loading: \"Loading the document…\",\n failed: \"The document could not be displayed.\",\n page: \"Page {page} of {total}\",\n onPage: \"Passage on page {page}:\",\n notFound: \"This passage is not in the document's text layer:\",\n};\n\n/** A passage to light: its quote (as the text layer reads it) and/or a `region` of a page the app already knows (a stamp, a\n mismatch — fractions of the page, origin top-left); the page if known, a name for screen readers. A valid region wins. */\nexport type DocumentHighlight = { id: string; quote?: string; region?: Region; page?: number; label?: string };\n\n/** What the viewer found for a passage. */\nexport type { Located };\n\n/** The members of pdf.js the viewer uses (`pdfjs-dist` ≥ 5), typed here so the package does not depend on it. */\nexport type PdfjsModule = {\n GlobalWorkerOptions: { workerSrc: string };\n getDocument(source: { url?: string; data?: Uint8Array }): { promise: Promise<PdfDocument>; destroy?: () => Promise<void> | void };\n};\nexport type PdfDocument = { numPages: number; getPage(n: number): Promise<PdfPage>; destroy?: () => Promise<void> | void };\nexport type PdfPage = {\n rotate: number;\n view: number[];\n getViewport(options: { scale: number }): { width: number; height: number };\n getTextContent(): Promise<{ items: readonly unknown[] }>;\n render(options: { canvas: HTMLCanvasElement; canvasContext: CanvasRenderingContext2D; viewport: { width: number; height: number } }): { promise: Promise<void>; cancel?: () => void };\n cleanup?: () => void;\n};\n\nexport type DocumentViewerProps = Omit<React.ComponentProps<\"div\">, \"children\" | \"onChange\"> & {\n /** The PDF: an address (same origin or CORS) or its bytes. */\n src: string | Uint8Array;\n /** Loads pdf.js: `() => import(\"pdfjs-dist\")`. An optional peer, never in a bundle without a document. */\n loadPdfjs: () => Promise<PdfjsModule>;\n /** The address of pdf.js's worker (`new URL(\"pdfjs-dist/build/pdf.worker.min.mjs\", import.meta.url).toString()`). */\n workerSrc: string;\n /** The passages to light. */\n highlights?: readonly DocumentHighlight[];\n /** The passage in focus: the viewer scrolls to it. */\n activeId?: string | null;\n /** A box was clicked (the id) or the focus was released (`null`). */\n onActiveChange?: (id: string | null) => void;\n /** Where each passage was found (`null`: nowhere) — once the text layer is read, and again if `highlights` change. */\n onLocate?: (found: Record<string, Located | null>) => void;\n /** Called when the document is open, with its page count. */\n onLoad?: (info: { pages: number }) => void;\n /** The words of the viewer, translated (English by default). */\n labels?: Partial<DocumentViewerLabels>;\n};\n\nconst regionKey = (r: Region | undefined) => (r ? [r.page, r.x, r.y, r.width, r.height].join(\",\") : \"\");\nconst fill = (template: string, vars: Record<string, string | number>) => template.replace(/\\{(\\w+)\\}/g, (m, k: string) => (k in vars ? String(vars[k]) : m));\n\ntype Loaded = { doc: PdfDocument; texts: PageText[]; sizes: { width: number; height: number }[] };\ntype Phase = { state: \"loading\" } | { state: \"error\"; key: string } | ({ state: \"ready\"; key: string } & Loaded);\n\nconst isItem = (x: unknown): x is PageText[\"items\"][number] => typeof x === \"object\" && x !== null && typeof (x as { str?: unknown }).str === \"string\" && Array.isArray((x as { transform?: unknown }).transform);\n\nfunction PageCanvas({ page, doc, caption, onReady, className }: { page: number; doc: PdfDocument; caption: string; onReady?: () => void; className: string }) {\n const ref = React.useRef<HTMLCanvasElement>(null);\n const wrapper = React.useRef<HTMLDivElement>(null);\n const [visible, setVisible] = React.useState(() => typeof IntersectionObserver === \"undefined\");\n const ready = useLatest(onReady);\n React.useEffect(() => {\n const node = wrapper.current?.parentElement;\n if (!node) return;\n if (typeof IntersectionObserver === \"undefined\") return;\n const observer = new IntersectionObserver((entries) => entries.some((e) => e.isIntersecting) && setVisible(true), { rootMargin: \"600px 0px\" });\n observer.observe(node);\n return () => observer.disconnect();\n }, []);\n React.useEffect(() => {\n if (!visible) return;\n let task: { promise: Promise<void>; cancel?: () => void } | undefined;\n let cancelled = false;\n void (async () => {\n const p = await doc.getPage(page);\n const canvas = ref.current;\n const ctx = canvas?.getContext(\"2d\");\n if (cancelled || !canvas || !ctx) return;\n const base = p.getViewport({ scale: 1 });\n const dpr = typeof window === \"undefined\" ? 1 : Math.min(2, window.devicePixelRatio || 1);\n const scale = Math.min(2.5, Math.max(1, (canvas.parentElement?.clientWidth || base.width) / base.width)) * dpr;\n const viewport = p.getViewport({ scale });\n canvas.width = Math.floor(viewport.width);\n canvas.height = Math.floor(viewport.height);\n task = p.render({ canvas, canvasContext: ctx, viewport });\n await task.promise.catch(() => undefined);\n if (!cancelled) ready.current?.();\n })().catch(() => undefined);\n return () => {\n cancelled = true;\n task?.cancel?.();\n };\n }, [visible, doc, page, ready]);\n return (\n <div ref={wrapper} className=\"contents\">\n <canvas ref={ref} aria-hidden=\"true\" className={className} />\n <span className=\"sr-only\">{caption}</span>\n </div>\n );\n}\n\n/** A PDF with its passages lit — see the file's header. Client. */\nexport function DocumentViewer({ src, loadPdfjs, workerSrc, highlights = [], activeId = null, onActiveChange, onLocate, onLoad, labels, className, ...props }: DocumentViewerProps) {\n const words = { ...documentViewerLabels, ...labels };\n const s = documentViewer();\n const reduce = usePrefersReducedMotion();\n const [loaded, setPhase] = React.useState<Phase>({ state: \"loading\" });\n const callbacks = useLatest({ onLoad, onLocate });\n const containerRef = React.useRef<HTMLDivElement>(null);\n const bytes = typeof src === \"string\" ? src : src.byteLength + \":\" + src[0] + \":\" + src[src.length - 1];\n // A result belongs to the document it was read from: another `src` is loading again, with no reset inside the effect.\n const phase: Phase = loaded.state !== \"loading\" && loaded.key !== bytes ? { state: \"loading\" } : loaded;\n\n // Open the document and read every page's text layer (positions only; nothing is sent anywhere).\n React.useEffect(() => {\n let cancelled = false;\n let opened: { destroy?: () => Promise<void> | void } | undefined;\n void (async () => {\n const pdfjs = await loadPdfjs();\n pdfjs.GlobalWorkerOptions.workerSrc = workerSrc;\n const loading = pdfjs.getDocument(typeof src === \"string\" ? { url: src } : { data: src.slice() });\n opened = loading;\n const doc = await loading.promise;\n const texts: PageText[] = [];\n const sizes: Loaded[\"sizes\"] = [];\n for (let n = 1; n <= doc.numPages; n++) {\n const page = await doc.getPage(n);\n const vp = page.getViewport({ scale: 1 });\n sizes.push({ width: vp.width, height: vp.height });\n const content = await page.getTextContent();\n // A rotated page has no reliable boxes: it keeps its size and an empty text layer (the app's page hint still works).\n texts.push({ page: n, width: vp.width, height: vp.height, items: page.rotate % 360 === 0 ? content.items.filter(isItem) : [] });\n page.cleanup?.();\n }\n if (cancelled) return;\n setPhase({ state: \"ready\", key: bytes, doc, texts, sizes });\n callbacks.current.onLoad?.({ pages: doc.numPages });\n })().catch(() => !cancelled && setPhase({ state: \"error\", key: bytes }));\n return () => {\n cancelled = true;\n void opened?.destroy?.();\n };\n // `src` is compared by content (`bytes`) so a re-render with the same bytes does not reopen the file.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [bytes, loadPdfjs, workerSrc, callbacks]);\n\n const key = highlights.map((h) => `${h.id}\\u0000${h.page ?? \"\"}\\u0000${h.quote ?? \"\"}\\u0000${regionKey(h.region)}`).join(\"\\u0001\");\n const found = React.useMemo(() => {\n const out: Record<string, Located | null> = {};\n if (phase.state === \"ready\") for (const h of highlights) out[h.id] = resolveHighlight(phase.texts, h);\n return out;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [phase, key]);\n React.useEffect(() => {\n if (phase.state === \"ready\") callbacks.current.onLocate?.(found);\n }, [found, phase.state, callbacks]);\n\n // Go to the active passage.\n const active = activeId ? highlights.find((h) => h.id === activeId) : undefined;\n const where = activeId ? found[activeId] : undefined;\n React.useEffect(() => {\n if (phase.state !== \"ready\" || !where) return;\n const root = containerRef.current;\n const target = root?.querySelector<HTMLElement>(where.boxes.length > 0 ? `[data-highlight=\"${CSS.escape(activeId!)}\"]` : `[data-page=\"${where.page}\"]`) ?? null;\n target?.scrollIntoView?.({ block: where.boxes.length > 0 ? \"center\" : \"start\", behavior: reduce ? \"auto\" : \"smooth\" });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeId, where, phase.state]);\n\n return (\n <div className={s.root({ className })} {...props}>\n {active && where !== undefined && where?.match !== \"exact\" && where?.match !== \"start\" && where?.match !== \"region\" ? (\n <p className={s.bar()} data-testid=\"document-viewer-bar\">\n {where?.match === \"page\" ? fill(words.onPage, { page: where.page }) : words.notFound} {active.quote ? <q>{active.quote}</q> : null}\n </p>\n ) : null}\n <div ref={containerRef} className={s.pages()} role=\"region\" aria-label={words.region} tabIndex={0}>\n {phase.state === \"loading\" ? <p className={s.status()}>{words.loading}</p> : null}\n {phase.state === \"error\" ? <p role=\"alert\" className={s.status()}>{words.failed}</p> : null}\n {phase.state === \"ready\"\n ? phase.texts.map((t, i) => {\n const size = phase.sizes[i]!;\n const caption = fill(words.page, { page: t.page, total: phase.doc.numPages });\n return (\n <div key={t.page} className={s.page()} data-page={t.page} style={{ aspectRatio: `${size.width} / ${size.height}` }}>\n <PageCanvas page={t.page} doc={phase.doc} caption={caption} className={s.canvas()} />\n <span className={s.caption()} aria-hidden=\"true\">{caption}</span>\n {highlights.flatMap((h) => {\n const f = found[h.id];\n if (!f || f.page !== t.page) return [];\n return f.boxes.map((b, k) => (\n <div\n key={`${h.id}:${k}`}\n aria-hidden=\"true\"\n data-highlight={h.id}\n data-active={h.id === activeId}\n className={s.box()}\n style={{ left: `${b.x * 100}%`, top: `${b.y * 100}%`, width: `${b.width * 100}%`, height: `${b.height * 100}%` }}\n onClick={() => onActiveChange?.(h.id === activeId ? null : h.id)}\n />\n ));\n })}\n </div>\n );\n })\n : null}\n </div>\n </div>\n );\n}\n"
151
152
  },
152
153
  {
153
154
  "path": "document-viewer/index.ts",
154
- "content": "/** @krizaka/ui/document-viewer — `DocumentViewer` (a PDF drawn by pdf.js, its passages lit where they sit), `locateQuote` (a quote → boxes, pure). Client (\"use client\"). */\nexport { type DocumentHighlight, DocumentViewer, documentViewer, type DocumentViewerLabels, documentViewerLabels, type DocumentViewerProps, type Located, type PdfDocument, type PdfjsModule, type PdfPage } from \"./document-viewer\";\nexport { type Box, fold, locateQuote, type PageText, type TextItem } from \"./locate\";\n"
155
+ "content": "/** @krizaka/ui/document-viewer — `DocumentViewer` (a PDF drawn by pdf.js, its passages lit where they sit), `locateQuote` (a quote → boxes, pure), `locateRegion` (a box of a page, checked). Client (\"use client\"). */\nexport { type DocumentHighlight, DocumentViewer, documentViewer, type DocumentViewerLabels, documentViewerLabels, type DocumentViewerProps, type Located, type PdfDocument, type PdfjsModule, type PdfPage } from \"./document-viewer\";\nexport { type Box, fold, locateQuote, locateRegion, type PageText, type Region, resolveHighlight, type TextItem } from \"./locate\";\n"
155
156
  },
156
157
  {
157
158
  "path": "document-viewer/locate.ts",
158
- "content": "// Pure: where a quoted passage sits on the pages of a PDF, from pdf.js's text positions. No DOM, no pdf.js import —\n// the viewer feeds it what `page.getTextContent()` returned, a test feeds it a fixture.\n\n/** A text item as pdf.js returns it (`TextItem`): the string, its matrix (`[a, b, c, d, x, baseline]`) and its size. */\nexport type TextItem = { str: string; transform: number[]; width: number; height: number };\n\n/** A rectangle in fractions of the page (0–1), origin top-left — independent of the zoom the page is drawn at. */\nexport type Box = { x: number; y: number; width: number; height: number };\n\n/** The text layer of one page: its size in PDF units (rotation 0) and its items in reading order. */\nexport type PageText = { page: number; width: number; height: number; items: readonly TextItem[] };\n\nexport type Located = {\n /** 1-based page where the passage starts. */\n page: number;\n /** One box per line of the passage (merged along a line); empty when only the page is known. */\n boxes: Box[];\n /** `exact`: the whole quote was found; `start`: only its opening words were (a quote cut by a different layout). */\n match: \"exact\" | \"start\" | \"page\";\n};\n\nconst FOLD: Record<string, string> = { \"’\": \"'\", \"‘\": \"'\", \"“\": '\"', \"”\": '\"', \"«\": '\"', \"»\": '\"', \"–\": \"-\", \"—\": \"-\", \" \": \" \", \" \": \" \", \"fi\": \"fi\", \"fl\": \"fl\" };\n\n/** The comparable form of a text: no whitespace, no soft hyphen, straight quotes, case and accents folded. */\nexport function fold(text: string): string {\n let out = \"\";\n for (const ch of text.normalize(\"NFKD\")) {\n if (/\\p{M}/u.test(ch) || /\\s/u.test(ch) || ch === \"­\" || ch === \"​\") continue;\n out += (FOLD[ch] ?? ch).toLowerCase();\n }\n return out;\n}\n\ntype Index = { text: string; at: { item: number; char: number }[] };\n\nfunction indexPage(items: readonly TextItem[]): Index {\n let text = \"\";\n const at: Index[\"at\"] = [];\n items.forEach((item, i) => {\n for (let c = 0; c < item.str.length; c++) {\n const piece = fold(item.str[c]!);\n for (let k = 0; k < piece.length; k++) {\n text += piece[k];\n at.push({ item: i, char: c });\n }\n }\n });\n return { text, at };\n}\n\n// Proportional faces: \"locataire\" is not as wide as nine capitals. pdf.js gives one width per item, so a position inside an\n// item is shared out by the Helvetica advance widths (per 1000 em) — close for any sans text, far better than a flat share.\nconst ADVANCE =\n \"278 278 355 556 556 889 667 191 333 333 389 584 278 333 278 278 556 556 556 556 556 556 556 556 556 556 278 278 584 584 584 556 1015 \" +\n \"667 667 722 722 667 611 778 722 278 500 667 556 833 722 778 667 778 722 667 611 722 667 944 667 667 611 278 278 278 469 556 333 \" +\n \"556 556 500 556 556 278 556 556 222 222 500 222 833 556 556 556 556 333 500 278 556 500 722 500 500 500\";\nconst ADVANCES = ADVANCE.split(\" \").map(Number);\nfunction advance(ch: string): number {\n const base = ch.normalize(\"NFD\")[0] ?? ch;\n const code = base.charCodeAt(0);\n return code >= 32 && code <= 126 ? (ADVANCES[code - 32] ?? 556) : 556;\n}\n/** The share (0–1) of an item's width that lies before character `n` of `text`. */\nfunction shareBefore(text: string, n: number): number {\n let before = 0;\n let total = 0;\n for (let i = 0; i < text.length; i++) {\n const a = advance(text[i]!);\n if (i < n) before += a;\n total += a;\n }\n return total > 0 ? before / total : n / Math.max(1, text.length);\n}\n\nfunction boxesOf(page: PageText, index: Index, from: number, to: number): Box[] {\n const spans = new Map<number, [number, number]>();\n for (let k = from; k < to; k++) {\n const { item, char } = index.at[k]!;\n const s = spans.get(item);\n spans.set(item, s ? [Math.min(s[0], char), Math.max(s[1], char + 1)] : [char, char + 1]);\n }\n const raw: Box[] = [];\n for (const [i, [c0, c1]] of [...spans].sort((a, b) => a[0] - b[0])) {\n const item = page.items[i]!;\n const size = item.height || Math.abs(item.transform[3] ?? 0) || 10;\n const x = (item.transform[4] ?? 0) + item.width * shareBefore(item.str, c0);\n const w = item.width * (shareBefore(item.str, c1) - shareBefore(item.str, c0));\n const top = page.height - ((item.transform[5] ?? 0) + size * 0.9);\n raw.push({ x: x / page.width, y: top / page.height, width: w / page.width, height: (size * 1.15) / page.height });\n }\n // Merge the pieces that sit on one line and touch (several items of one sentence) into one rectangle.\n const merged: Box[] = [];\n for (const b of raw) {\n const last = merged[merged.length - 1];\n const sameLine = last && Math.abs(last.y - b.y) < last.height * 0.5 && b.x - (last.x + last.width) < last.height * 1.5 && b.x >= last.x - 1e-9;\n if (last && sameLine) {\n const right = Math.max(last.x + last.width, b.x + b.width);\n last.y = Math.min(last.y, b.y);\n last.height = Math.max(last.height, b.height);\n last.width = right - last.x;\n } else merged.push({ ...b });\n }\n return merged.map((b) => ({ x: clamp01(b.x), y: clamp01(b.y), width: Math.min(b.width, 1 - clamp01(b.x)), height: Math.min(b.height, 1 - clamp01(b.y)) }));\n}\n\nconst clamp01 = (n: number) => Math.min(1, Math.max(0, n));\n\n/** The shortest opening worth highlighting alone: a few words, not a stray letter. */\nconst MIN_START = 24;\n\n/**\n * Where `quote` sits in the pages: the first page (starting with `hintPage`, if any) whose text contains it, and the\n * boxes of its lines. A quote that a different layout cut (a column break, a hyphen) is looked for by its opening\n * words (`match: \"start\"`); one that is nowhere gives `null`, or the hinted page alone (`match: \"page\"`). Never a guess:\n * a rotated page has no boxes, only its page.\n */\nexport function locateQuote(pages: readonly PageText[], quote: string, hintPage?: number): Located | null {\n const needle = fold(quote);\n const ordered = hintPage ? [...pages].sort((a, b) => Number(b.page === hintPage) - Number(a.page === hintPage)) : pages;\n if (needle.length > 0) {\n for (const mode of [\"exact\", \"start\"] as const) {\n const wanted = mode === \"exact\" ? needle : needle.slice(0, Math.max(MIN_START, Math.min(40, Math.floor(needle.length * 0.6))));\n if (mode === \"start\" && (needle.length <= wanted.length || wanted.length < MIN_START)) break;\n for (const page of ordered) {\n const index = indexPage(page.items);\n const found = index.text.indexOf(wanted);\n if (found < 0) continue;\n return { page: page.page, boxes: boxesOf(page, index, found, found + wanted.length), match: mode };\n }\n }\n }\n return hintPage && pages.some((p) => p.page === hintPage) ? { page: hintPage, boxes: [], match: \"page\" } : null;\n}\n"
159
+ "content": "// Pure: where a quoted passage sits on the pages of a PDF, from pdf.js's text positions. No DOM, no pdf.js import —\n// the viewer feeds it what `page.getTextContent()` returned, a test feeds it a fixture.\n\n/** A text item as pdf.js returns it (`TextItem`): the string, its matrix (`[a, b, c, d, x, baseline]`) and its size. */\nexport type TextItem = { str: string; transform: number[]; width: number; height: number };\n\n/** A rectangle in fractions of the page (0–1), origin top-left — independent of the zoom the page is drawn at. */\nexport type Box = { x: number; y: number; width: number; height: number };\n\n/** The text layer of one page: its size in PDF units (rotation 0) and its items in reading order. */\nexport type PageText = { page: number; width: number; height: number; items: readonly TextItem[] };\n\nexport type Located = {\n /** 1-based page where the passage starts. */\n page: number;\n /** One box per line of the passage (merged along a line); empty when only the page is known. */\n boxes: Box[];\n /** `region`: the box the app gave, as it is; `exact`: the whole quote was found; `start`: only its opening words were (a quote cut by a different layout). */\n match: \"exact\" | \"start\" | \"page\" | \"region\";\n};\n\n/** A region of a page the app already knows (a stamp, a font mismatch, a metadata area): its page and a box in fractions. */\nexport type Region = Box & { page: number };\n\nconst FOLD: Record<string, string> = { \"’\": \"'\", \"‘\": \"'\", \"“\": '\"', \"”\": '\"', \"«\": '\"', \"»\": '\"', \"–\": \"-\", \"—\": \"-\", \" \": \" \", \" \": \" \", \"fi\": \"fi\", \"fl\": \"fl\" };\n\n/** The comparable form of a text: no whitespace, no soft hyphen, straight quotes, case and accents folded. */\nexport function fold(text: string): string {\n let out = \"\";\n for (const ch of text.normalize(\"NFKD\")) {\n if (/\\p{M}/u.test(ch) || /\\s/u.test(ch) || ch === \"­\" || ch === \"​\") continue;\n out += (FOLD[ch] ?? ch).toLowerCase();\n }\n return out;\n}\n\ntype Index = { text: string; at: { item: number; char: number }[] };\n\nfunction indexPage(items: readonly TextItem[]): Index {\n let text = \"\";\n const at: Index[\"at\"] = [];\n items.forEach((item, i) => {\n for (let c = 0; c < item.str.length; c++) {\n const piece = fold(item.str[c]!);\n for (let k = 0; k < piece.length; k++) {\n text += piece[k];\n at.push({ item: i, char: c });\n }\n }\n });\n return { text, at };\n}\n\n// Proportional faces: \"locataire\" is not as wide as nine capitals. pdf.js gives one width per item, so a position inside an\n// item is shared out by the Helvetica advance widths (per 1000 em) — close for any sans text, far better than a flat share.\nconst ADVANCE =\n \"278 278 355 556 556 889 667 191 333 333 389 584 278 333 278 278 556 556 556 556 556 556 556 556 556 556 278 278 584 584 584 556 1015 \" +\n \"667 667 722 722 667 611 778 722 278 500 667 556 833 722 778 667 778 722 667 611 722 667 944 667 667 611 278 278 278 469 556 333 \" +\n \"556 556 500 556 556 278 556 556 222 222 500 222 833 556 556 556 556 333 500 278 556 500 722 500 500 500\";\nconst ADVANCES = ADVANCE.split(\" \").map(Number);\nfunction advance(ch: string): number {\n const base = ch.normalize(\"NFD\")[0] ?? ch;\n const code = base.charCodeAt(0);\n return code >= 32 && code <= 126 ? (ADVANCES[code - 32] ?? 556) : 556;\n}\n/** The share (0–1) of an item's width that lies before character `n` of `text`. */\nfunction shareBefore(text: string, n: number): number {\n let before = 0;\n let total = 0;\n for (let i = 0; i < text.length; i++) {\n const a = advance(text[i]!);\n if (i < n) before += a;\n total += a;\n }\n return total > 0 ? before / total : n / Math.max(1, text.length);\n}\n\nfunction boxesOf(page: PageText, index: Index, from: number, to: number): Box[] {\n const spans = new Map<number, [number, number]>();\n for (let k = from; k < to; k++) {\n const { item, char } = index.at[k]!;\n const s = spans.get(item);\n spans.set(item, s ? [Math.min(s[0], char), Math.max(s[1], char + 1)] : [char, char + 1]);\n }\n const raw: Box[] = [];\n for (const [i, [c0, c1]] of [...spans].sort((a, b) => a[0] - b[0])) {\n const item = page.items[i]!;\n const size = item.height || Math.abs(item.transform[3] ?? 0) || 10;\n const x = (item.transform[4] ?? 0) + item.width * shareBefore(item.str, c0);\n const w = item.width * (shareBefore(item.str, c1) - shareBefore(item.str, c0));\n const top = page.height - ((item.transform[5] ?? 0) + size * 0.9);\n raw.push({ x: x / page.width, y: top / page.height, width: w / page.width, height: (size * 1.15) / page.height });\n }\n // Merge the pieces that sit on one line and touch (several items of one sentence) into one rectangle.\n const merged: Box[] = [];\n for (const b of raw) {\n const last = merged[merged.length - 1];\n const sameLine = last && Math.abs(last.y - b.y) < last.height * 0.5 && b.x - (last.x + last.width) < last.height * 1.5 && b.x >= last.x - 1e-9;\n if (last && sameLine) {\n const right = Math.max(last.x + last.width, b.x + b.width);\n last.y = Math.min(last.y, b.y);\n last.height = Math.max(last.height, b.height);\n last.width = right - last.x;\n } else merged.push({ ...b });\n }\n return merged.map((b) => ({ x: clamp01(b.x), y: clamp01(b.y), width: Math.min(b.width, 1 - clamp01(b.x)), height: Math.min(b.height, 1 - clamp01(b.y)) }));\n}\n\nconst clamp01 = (n: number) => Math.min(1, Math.max(0, n));\n\n/** The shortest opening worth highlighting alone: a few words, not a stray letter. */\nconst MIN_START = 24;\n\n/**\n * Where `quote` sits in the pages: the first page (starting with `hintPage`, if any) whose text contains it, and the\n * boxes of its lines. A quote that a different layout cut (a column break, a hyphen) is looked for by its opening\n * words (`match: \"start\"`); one that is nowhere gives `null`, or the hinted page alone (`match: \"page\"`). Never a guess:\n * a rotated page has no boxes, only its page.\n */\nexport function locateQuote(pages: readonly PageText[], quote: string, hintPage?: number): Located | null {\n const needle = fold(quote);\n const ordered = hintPage ? [...pages].sort((a, b) => Number(b.page === hintPage) - Number(a.page === hintPage)) : pages;\n if (needle.length > 0) {\n for (const mode of [\"exact\", \"start\"] as const) {\n const wanted = mode === \"exact\" ? needle : needle.slice(0, Math.max(MIN_START, Math.min(40, Math.floor(needle.length * 0.6))));\n if (mode === \"start\" && (needle.length <= wanted.length || wanted.length < MIN_START)) break;\n for (const page of ordered) {\n const index = indexPage(page.items);\n const found = index.text.indexOf(wanted);\n if (found < 0) continue;\n return { page: page.page, boxes: boxesOf(page, index, found, found + wanted.length), match: mode };\n }\n }\n }\n return hintPage && pages.some((p) => p.page === hintPage) ? { page: hintPage, boxes: [], match: \"page\" } : null;\n}\n\nconst inUnit = (n: number) => Number.isFinite(n) && n >= 0 && n <= 1;\n\n/**\n * A region of a page, as it is: one box, no text needed. Never drawn when it is not on the pages — an unknown page, a box\n * outside 0–1 or empty, a value that is not a number — so a wrong box is `null`, not a guess.\n */\nexport function locateRegion(pages: readonly PageText[], region: Region): Located | null {\n const { page, x, y, width, height } = region;\n const valid = pages.some((p) => p.page === page) && inUnit(x) && inUnit(y) && width > 0 && height > 0 && inUnit(x + width) && inUnit(y + height);\n return valid ? { page, boxes: [{ x, y, width, height }], match: \"region\" } : null;\n}\n\n/** What to light for a highlight: its region when it has a valid one, otherwise its quote (if any). */\nexport function resolveHighlight(pages: readonly PageText[], h: { quote?: string; page?: number; region?: Region }): Located | null {\n const byRegion = h.region ? locateRegion(pages, h.region) : null;\n if (byRegion) return byRegion;\n if (h.quote) return locateQuote(pages, h.quote, h.page ?? h.region?.page);\n const hinted = h.page !== undefined && pages.some((p) => p.page === h.page);\n return hinted ? { page: h.page!, boxes: [], match: \"page\" } : null;\n}\n"
159
160
  },
160
161
  {
161
162
  "path": "document-viewer/meta.ts",
162
- "content": "import type { ComponentMeta } from \"../meta\";\n\nexport const meta = {\n title: \"Document viewer\",\n summary: \"A PDF drawn page by page with pdf.js, and the passages of a report lit where they sit — found from the PDF's own text positions, one box per line; the page and the quote when the text layer cannot place them.\",\n status: \"beta\",\n category: \"media\",\n domain: \"media\",\n platforms: \"web\",\n parity: { native: { status: \"gap\", issue: \"krizaka/krizaka-ui#278\", reason: \"Needs a PDF module; Yomizaka has no phone app yet.\" }, desktop: \"web\" },\n whenToUse: [\n \"To read a document beside what was said about it: findings, comments, extracted fields.\",\n \"To make a quoted passage visible in the original file instead of in a copy of its text.\",\n ],\n whenNotToUse: [\n { when: \"To play a video or a recording.\", use: \"video-player\" },\n { when: \"To show an image to crop.\" },\n { when: \"To let the browser open the file as it is: a link to the file is enough.\", use: \"button\" },\n ],\n bestPractices: [\n \"Keep the list of passages in the page, next to the viewer: the viewer is not a keyboard route to each box, your list is (`activeId` / `onActiveChange`).\",\n \"Pass the quote as the text layer reads it and, when you know it, the page: a quote the layout cut is still placed by its opening words, and a page alone still scrolls.\",\n \"Use `onLocate` to tell the person what was placed and what was not (« page 3 », « not found in the text layer ») — a passage is never drawn at a guessed place.\",\n \"Load pdf.js with `() => import(\\\"pdfjs-dist\\\")` and give it a same-origin worker (`workerSrc`): the engine only reaches pages that show a document.\",\n ],\n accessibility: {\n keyboard: [{ keys: \"Tab, arrows, Page Up / Down\", action: \"The pages' region is focusable and scrolls like any scrollable area.\" }],\n notes: [\n \"The region is named by `labels.region`; each page is announced by its caption (« Page 2 of 5 »).\",\n \"The highlight boxes are decorative (`aria-hidden`): the passages are reached through your list, whose entries scroll to them.\",\n \"A scanned PDF has no text layer: nothing is lit, and the pages stay readable as images — offer the text alternative yourself.\",\n \"A passage that cannot be placed is announced in a bar with its quote.\",\n ],\n },\n related: [\"tabs\", \"split-view\", \"video-player\"],\n web: {\n imports: [\"DocumentViewer\", \"locateQuote\"],\n examples: [\n { name: \"highlights\", title: \"Findings in the file\", description: \"A one-page lease and two passages; pick one and the page scrolls to it and lights it.\" },\n ],\n },\n} satisfies ComponentMeta;\n"
163
+ "content": "import type { ComponentMeta } from \"../meta\";\n\nexport const meta = {\n title: \"Document viewer\",\n summary: \"A PDF drawn page by page with pdf.js, and the passages of a report lit where they sit — found from the PDF's own text positions, one box per line; the page and the quote when the text layer cannot place them.\",\n status: \"beta\",\n category: \"media\",\n domain: \"media\",\n platforms: \"web\",\n parity: { native: { status: \"gap\", issue: \"krizaka/krizaka-ui#278\", reason: \"Needs a PDF module; Yomizaka has no phone app yet.\" }, desktop: \"web\" },\n whenToUse: [\n \"To read a document beside what was said about it: findings, comments, extracted fields.\",\n \"To make a quoted passage visible in the original file instead of in a copy of its text.\",\n ],\n whenNotToUse: [\n { when: \"To play a video or a recording.\", use: \"video-player\" },\n { when: \"To show an image to crop.\" },\n { when: \"To let the browser open the file as it is: a link to the file is enough.\", use: \"button\" },\n ],\n bestPractices: [\n \"Keep the list of passages in the page, next to the viewer: the viewer is not a keyboard route to each box, your list is (`activeId` / `onActiveChange`).\",\n \"Light a region instead of a quote when the app already knows where the evidence sits (`region: { page, x, y, width, height }`, fractions of the page): no text layer needed, and a region outside the page is never drawn.\",\n \"Pass the quote as the text layer reads it and, when you know it, the page: a quote the layout cut is still placed by its opening words, and a page alone still scrolls.\",\n \"Use `onLocate` to tell the person what was placed and what was not (« page 3 », « not found in the text layer ») — a passage is never drawn at a guessed place.\",\n \"Load pdf.js with `() => import(\\\"pdfjs-dist\\\")` and give it a same-origin worker (`workerSrc`): the engine only reaches pages that show a document.\",\n ],\n accessibility: {\n keyboard: [{ keys: \"Tab, arrows, Page Up / Down\", action: \"The pages' region is focusable and scrolls like any scrollable area.\" }],\n notes: [\n \"The region is named by `labels.region`; each page is announced by its caption (« Page 2 of 5 »).\",\n \"The highlight boxes are decorative (`aria-hidden`): the passages are reached through your list, whose entries scroll to them.\",\n \"A scanned PDF has no text layer: nothing is lit, and the pages stay readable as images — offer the text alternative yourself.\",\n \"A passage that cannot be placed is announced in a bar with its quote.\",\n ],\n },\n related: [\"tabs\", \"split-view\", \"video-player\"],\n web: {\n imports: [\"DocumentViewer\", \"locateQuote\", \"locateRegion\"],\n examples: [\n { name: \"highlights\", title: \"Findings in the file\", description: \"A one-page lease, two passages told by their quote and one by a region; pick one and the page scrolls to it and lights it.\" },\n ],\n },\n} satisfies ComponentMeta;\n"
163
164
  },
164
165
  {
165
166
  "path": "media.ts",
@@ -176,7 +177,7 @@
176
177
  "registryDependencies": [],
177
178
  "demo": {
178
179
  "path": "examples/document-viewer/highlights.tsx",
179
- "content": "\"use client\";\n\nimport { DocumentViewer } from \"@krizaka/ui/document-viewer\";\nimport * as React from \"react\";\n\nconst PDF = \"JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA2MTIgNzkyXSAvQ29udGVudHMgNCAwIFIgL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNSAwIFIgPj4gPj4gPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCAyMDkgPj4Kc3RyZWFtCkJUIC9GMSAxNCBUZiA3MiA3MDAgVGQgKEJBSUwgUkVTSURFTlRJRUwpIFRqIEVUCkJUIC9GMSAxMSBUZiA3MiA2NzAgVGQgKExlIGxvY2F0ZXVyIHBldXQgYXVnbWVudGVyIGxlIGxveWVyIGEgdG91dCBtb21lbnQuKSBUaiBFVApCVCAvRjEgMTEgVGYgNzIgNjUwIFRkIChMZSBkZXBvdCBkZSBnYXJhbnRpZSBlc3QgZGUgZGV1eCBtb2lzIGRlIGxveWVyLikgVGogRVQKZW5kc3RyZWFtCmVuZG9iago1IDAgb2JqCjw8IC9UeXBlIC9Gb250IC9TdWJ0eXBlIC9UeXBlMSAvQmFzZUZvbnQgL0hlbHZldGljYSA+PgplbmRvYmoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDExNSAwMDAwMCBuIAowMDAwMDAwMjQxIDAwMDAwIG4gCjAwMDAwMDA1MDAgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA2IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgo1NzAKJSVFT0YK\";\nconst quotes = [\n { id: \"r1\", quote: \"Le locateur peut augmenter le loyer à tout moment.\", label: \"Rent increase\" },\n { id: \"r2\", quote: \"Le dépôt de garantie est de deux mois de loyer.\", label: \"Deposit\" },\n];\n// pdf.js is the app's: `loadPdfjs={() => import(\"pdfjs-dist\")}` and a worker served from its own origin. Here, from a CDN.\nconst CDN = \"https://cdn.jsdelivr.net/npm/pdfjs-dist@5.4.149/build/\";\nconst loadPdfjs = () => import(/* webpackIgnore: true */ /* turbopackIgnore: true */ `${CDN}pdf.min.mjs`) as never;\n\n// Pick a passage in your own list: the viewer scrolls to it and lights it where it sits in the page.\nexport default function DocumentViewerHighlights() {\n const [active, setActive] = React.useState<string | null>(\"r1\");\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex gap-2\">\n {quotes.map((q) => (\n <button key={q.id} type=\"button\" aria-pressed={active === q.id} className=\"rounded-md border border-border-default px-3 py-1 text-sm aria-pressed:bg-surface-3\" onClick={() => setActive(q.id)}>\n {q.label}\n </button>\n ))}\n </div>\n <DocumentViewer src={Uint8Array.from(atob(PDF), (c) => c.charCodeAt(0))} loadPdfjs={loadPdfjs} workerSrc={`${CDN}pdf.worker.min.mjs`} highlights={quotes} activeId={active} onActiveChange={setActive} />\n </div>\n );\n}\n"
180
+ "content": "\"use client\";\n\nimport { DocumentViewer } from \"@krizaka/ui/document-viewer\";\nimport * as React from \"react\";\n\nconst PDF = \"JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA2MTIgNzkyXSAvQ29udGVudHMgNCAwIFIgL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNSAwIFIgPj4gPj4gPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCAyMDkgPj4Kc3RyZWFtCkJUIC9GMSAxNCBUZiA3MiA3MDAgVGQgKEJBSUwgUkVTSURFTlRJRUwpIFRqIEVUCkJUIC9GMSAxMSBUZiA3MiA2NzAgVGQgKExlIGxvY2F0ZXVyIHBldXQgYXVnbWVudGVyIGxlIGxveWVyIGEgdG91dCBtb21lbnQuKSBUaiBFVApCVCAvRjEgMTEgVGYgNzIgNjUwIFRkIChMZSBkZXBvdCBkZSBnYXJhbnRpZSBlc3QgZGUgZGV1eCBtb2lzIGRlIGxveWVyLikgVGogRVQKZW5kc3RyZWFtCmVuZG9iago1IDAgb2JqCjw8IC9UeXBlIC9Gb250IC9TdWJ0eXBlIC9UeXBlMSAvQmFzZUZvbnQgL0hlbHZldGljYSA+PgplbmRvYmoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDExNSAwMDAwMCBuIAowMDAwMDAwMjQxIDAwMDAwIG4gCjAwMDAwMDA1MDAgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA2IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgo1NzAKJSVFT0YK\";\n// Two passages told by their quote, and one told by a region of the page (fractions, origin top-left): an app that already\n// knows where a stamp or a mismatch sits lights it without any text to match.\nconst quotes = [\n { id: \"r1\", quote: \"Le locateur peut augmenter le loyer à tout moment.\", label: \"Rent increase\" },\n { id: \"r2\", quote: \"Le dépôt de garantie est de deux mois de loyer.\", label: \"Deposit\" },\n { id: \"r3\", region: { page: 1, x: 0.1, y: 0.1, width: 0.3, height: 0.05 }, label: \"Title block\" },\n];\n// pdf.js is the app's: `loadPdfjs={() => import(\"pdfjs-dist\")}` and a worker served from its own origin. Here, from a CDN.\nconst CDN = \"https://cdn.jsdelivr.net/npm/pdfjs-dist@5.4.149/build/\";\nconst loadPdfjs = () => import(/* webpackIgnore: true */ /* turbopackIgnore: true */ `${CDN}pdf.min.mjs`) as never;\n\n// Pick a passage in your own list: the viewer scrolls to it and lights it where it sits in the page.\nexport default function DocumentViewerHighlights() {\n const [active, setActive] = React.useState<string | null>(\"r1\");\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex gap-2\">\n {quotes.map((q) => (\n <button key={q.id} type=\"button\" aria-pressed={active === q.id} className=\"rounded-md border border-border-default px-3 py-1 text-sm aria-pressed:bg-surface-3\" onClick={() => setActive(q.id)}>\n {q.label}\n </button>\n ))}\n </div>\n <DocumentViewer src={Uint8Array.from(atob(PDF), (c) => c.charCodeAt(0))} loadPdfjs={loadPdfjs} workerSrc={`${CDN}pdf.worker.min.mjs`} highlights={quotes} activeId={active} onActiveChange={setActive} />\n </div>\n );\n}\n"
180
181
  },
181
182
  "props": [
182
183
  {
@@ -7,7 +7,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
7
7
  var PDF = "JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA2MTIgNzkyXSAvQ29udGVudHMgNCAwIFIgL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNSAwIFIgPj4gPj4gPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCAyMDkgPj4Kc3RyZWFtCkJUIC9GMSAxNCBUZiA3MiA3MDAgVGQgKEJBSUwgUkVTSURFTlRJRUwpIFRqIEVUCkJUIC9GMSAxMSBUZiA3MiA2NzAgVGQgKExlIGxvY2F0ZXVyIHBldXQgYXVnbWVudGVyIGxlIGxveWVyIGEgdG91dCBtb21lbnQuKSBUaiBFVApCVCAvRjEgMTEgVGYgNzIgNjUwIFRkIChMZSBkZXBvdCBkZSBnYXJhbnRpZSBlc3QgZGUgZGV1eCBtb2lzIGRlIGxveWVyLikgVGogRVQKZW5kc3RyZWFtCmVuZG9iago1IDAgb2JqCjw8IC9UeXBlIC9Gb250IC9TdWJ0eXBlIC9UeXBlMSAvQmFzZUZvbnQgL0hlbHZldGljYSA+PgplbmRvYmoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDExNSAwMDAwMCBuIAowMDAwMDAwMjQxIDAwMDAwIG4gCjAwMDAwMDA1MDAgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA2IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgo1NzAKJSVFT0YK";
8
8
  var quotes = [
9
9
  { id: "r1", quote: "Le locateur peut augmenter le loyer \xE0 tout moment.", label: "Rent increase" },
10
- { id: "r2", quote: "Le d\xE9p\xF4t de garantie est de deux mois de loyer.", label: "Deposit" }
10
+ { id: "r2", quote: "Le d\xE9p\xF4t de garantie est de deux mois de loyer.", label: "Deposit" },
11
+ { id: "r3", region: { page: 1, x: 0.1, y: 0.1, width: 0.3, height: 0.05 }, label: "Title block" }
11
12
  ];
12
13
  var CDN = "https://cdn.jsdelivr.net/npm/pdfjs-dist@5.4.149/build/";
13
14
  var loadPdfjs = () => import(
@@ -4,9 +4,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lZgo1NzAKJSVFT0YK";
7
+ // Two passages told by their quote, and one told by a region of the page (fractions, origin top-left): an app that already
8
+ // knows where a stamp or a mismatch sits lights it without any text to match.
7
9
  const quotes = [
8
10
  { id: "r1", quote: "Le locateur peut augmenter le loyer à tout moment.", label: "Rent increase" },
9
11
  { id: "r2", quote: "Le dépôt de garantie est de deux mois de loyer.", label: "Deposit" },
12
+ { id: "r3", region: { page: 1, x: 0.1, y: 0.1, width: 0.3, height: 0.05 }, label: "Title block" },
10
13
  ];
11
14
  // pdf.js is the app's: `loadPdfjs={() => import("pdfjs-dist")}` and a worker served from its own origin. Here, from a CDN.
12
15
  const CDN = "https://cdn.jsdelivr.net/npm/pdfjs-dist@5.4.149/build/";
@@ -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,20 @@
1
+ "use client";
2
+
3
+ // registry/examples/map/pins.tsx
4
+ import { MapPin } from "@krizaka/ui/map/pin";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ var SHAPES = ["drop", "disc", "tag"];
7
+ var STATES = ["default", "selected", "visited", "closed"];
8
+ function MapPins() {
9
+ return /* @__PURE__ */ jsxs("div", { className: "grid w-full max-w-xl grid-cols-[auto_repeat(4,1fr)] items-end gap-x-6 gap-y-5 rounded-xl border border-border-subtle bg-surface-1 p-5 text-xs text-fg-secondary", children: [
10
+ /* @__PURE__ */ jsx("span", {}),
11
+ STATES.map((state) => /* @__PURE__ */ jsx("span", { children: state }, state)),
12
+ SHAPES.map((shape) => /* @__PURE__ */ jsxs("div", { className: "contents", children: [
13
+ /* @__PURE__ */ jsx("span", { children: shape }),
14
+ STATES.map((state) => /* @__PURE__ */ jsx("span", { className: "flex h-12 items-end", children: /* @__PURE__ */ jsx(MapPin, { shape, state, size: 26 }) }, state))
15
+ ] }, shape))
16
+ ] });
17
+ }
18
+ export {
19
+ MapPins as default
20
+ };
@@ -0,0 +1,27 @@
1
+ import { MapPin, type MapPinShape, type MapPinState } from "@krizaka/ui/map/pin";
2
+
3
+ const SHAPES: MapPinShape[] = ["drop", "disc", "tag"];
4
+ const STATES: MapPinState[] = ["default", "selected", "visited", "closed"];
5
+
6
+ // The pins of a map, in their three shapes and four states: the state is said by shape too (hollow = visited,
7
+ // dashed = closed, larger = selected), so it never rests on colour alone.
8
+ export default function MapPins() {
9
+ return (
10
+ <div className="grid w-full max-w-xl grid-cols-[auto_repeat(4,1fr)] items-end gap-x-6 gap-y-5 rounded-xl border border-border-subtle bg-surface-1 p-5 text-xs text-fg-secondary">
11
+ <span />
12
+ {STATES.map((state) => (
13
+ <span key={state}>{state}</span>
14
+ ))}
15
+ {SHAPES.map((shape) => (
16
+ <div key={shape} className="contents">
17
+ <span>{shape}</span>
18
+ {STATES.map((state) => (
19
+ <span key={state} className="flex h-12 items-end">
20
+ <MapPin shape={shape} state={state} size={26} />
21
+ </span>
22
+ ))}
23
+ </div>
24
+ ))}
25
+ </div>
26
+ );
27
+ }
@@ -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,34 @@
1
+ "use client";
2
+
3
+ // registry/examples/map/place-sheet.tsx
4
+ import { Button } from "@krizaka/ui/button";
5
+ import { StaticMap } from "@krizaka/ui/map";
6
+ import { MapInfoCard, RouteCard } from "@krizaka/ui/map/cards";
7
+ import { MapSheet } from "@krizaka/ui/map/sheet";
8
+ import * as React from "react";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ var SHOP = [-73.5673, 45.5017];
11
+ var ME = [-73.58, 45.51];
12
+ function MapPlaceSheet() {
13
+ const [snap, setSnap] = React.useState("half");
14
+ return /* @__PURE__ */ jsxs("div", { className: "relative h-[34rem] w-full max-w-3xl overflow-hidden rounded-xl border border-border-subtle", children: [
15
+ /* @__PURE__ */ jsx(StaticMap, { label: "Atelier Rose, Montr\xE9al", center: [-73.575, 45.505], zoom: 13, places: [{ position: SHOP, label: "Atelier Rose" }] }),
16
+ /* @__PURE__ */ jsx(MapSheet, { label: "Atelier Rose", handleLabel: "Resize the panel", snap, onSnapChange: setSnap, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5", children: [
17
+ /* @__PURE__ */ jsx(MapInfoCard, { title: "Atelier Rose", meta: "Hair salon \xB7 1.4 km", status: "Open until 18:00", action: /* @__PURE__ */ jsx(Button, { size: "sm", children: "See the shop" }) }),
18
+ /* @__PURE__ */ jsx(
19
+ RouteCard,
20
+ {
21
+ destination: "Directions to Atelier Rose",
22
+ position: SHOP,
23
+ origin: ME,
24
+ directionsLabel: "Open in",
25
+ appLabels: { apple: "Apple Maps", google: "Google Maps", osm: "OpenStreetMap", waze: "Waze", transit: "Transit" },
26
+ times: [{ label: "On foot", value: "18 min" }, { label: "By bike", value: "7 min" }]
27
+ }
28
+ )
29
+ ] }) })
30
+ ] });
31
+ }
32
+ export {
33
+ MapPlaceSheet as default
34
+ };