@nibapp/ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/LICENSE +21 -0
  3. package/README.md +124 -2
  4. package/TRADEMARKS.md +22 -0
  5. package/dist/_bundled/money/index.d.ts +98 -0
  6. package/dist/_bundled/money/index.js +152 -0
  7. package/dist/_bundled/tokens/index.d.ts +2 -0
  8. package/dist/_bundled/tokens/index.js +2 -0
  9. package/dist/_bundled/tokens/palette.gen.d.ts +51 -0
  10. package/dist/_bundled/tokens/palette.gen.js +206 -0
  11. package/dist/_bundled/tokens/spec.d.ts +291 -0
  12. package/dist/_bundled/tokens/spec.js +221 -0
  13. package/dist/components/accordion.d.ts +27 -0
  14. package/dist/components/accordion.js +66 -0
  15. package/dist/components/alert-dialog.d.ts +59 -0
  16. package/dist/components/alert-dialog.js +82 -0
  17. package/dist/components/alert.d.ts +141 -0
  18. package/dist/components/alert.js +55 -0
  19. package/dist/components/appear.d.ts +21 -0
  20. package/dist/components/appear.js +42 -0
  21. package/dist/components/avatar.d.ts +196 -0
  22. package/dist/components/avatar.js +135 -0
  23. package/dist/components/badge.d.ts +183 -0
  24. package/dist/components/badge.js +68 -0
  25. package/dist/components/block-stack.d.ts +33 -0
  26. package/dist/components/block-stack.js +197 -0
  27. package/dist/components/button.d.ts +327 -0
  28. package/dist/components/button.js +101 -0
  29. package/dist/components/card.d.ts +131 -0
  30. package/dist/components/card.js +100 -0
  31. package/dist/components/checkbox.d.ts +34 -0
  32. package/dist/components/checkbox.js +37 -0
  33. package/dist/components/choice-row.d.ts +104 -0
  34. package/dist/components/choice-row.js +56 -0
  35. package/dist/components/clamped-text.d.ts +17 -0
  36. package/dist/components/clamped-text.js +47 -0
  37. package/dist/components/code-block.d.ts +48 -0
  38. package/dist/components/code-block.js +124 -0
  39. package/dist/components/code-input.d.ts +49 -0
  40. package/dist/components/code-input.js +59 -0
  41. package/dist/components/combobox.d.ts +194 -0
  42. package/dist/components/combobox.js +176 -0
  43. package/dist/components/command-palette.d.ts +57 -0
  44. package/dist/components/command-palette.js +83 -0
  45. package/dist/components/context-menu.d.ts +24 -0
  46. package/dist/components/context-menu.js +30 -0
  47. package/dist/components/copy-button.d.ts +9 -0
  48. package/dist/components/copy-button.js +20 -0
  49. package/dist/components/copy-command.d.ts +18 -0
  50. package/dist/components/copy-command.js +19 -0
  51. package/dist/components/data-table.d.ts +240 -0
  52. package/dist/components/data-table.js +63 -0
  53. package/dist/components/dialog.d.ts +80 -0
  54. package/dist/components/dialog.js +85 -0
  55. package/dist/components/diff-lines.d.ts +20 -0
  56. package/dist/components/diff-lines.js +10 -0
  57. package/dist/components/diff-view.d.ts +128 -0
  58. package/dist/components/diff-view.js +675 -0
  59. package/dist/components/disclosure.d.ts +33 -0
  60. package/dist/components/disclosure.js +51 -0
  61. package/dist/components/drawn-check.d.ts +8 -0
  62. package/dist/components/drawn-check.js +16 -0
  63. package/dist/components/edge-resizer.d.ts +26 -0
  64. package/dist/components/edge-resizer.js +53 -0
  65. package/dist/components/empty-state.d.ts +112 -0
  66. package/dist/components/empty-state.js +56 -0
  67. package/dist/components/expand-toggle.d.ts +19 -0
  68. package/dist/components/expand-toggle.js +10 -0
  69. package/dist/components/field.d.ts +48 -0
  70. package/dist/components/field.js +60 -0
  71. package/dist/components/filter-chip.d.ts +47 -0
  72. package/dist/components/filter-chip.js +33 -0
  73. package/dist/components/group.d.ts +10 -0
  74. package/dist/components/group.js +9 -0
  75. package/dist/components/icon-text.d.ts +11 -0
  76. package/dist/components/icon-text.js +10 -0
  77. package/dist/components/image-sources.d.ts +57 -0
  78. package/dist/components/image-sources.js +58 -0
  79. package/dist/components/image-thumbnail.d.ts +34 -0
  80. package/dist/components/image-thumbnail.js +58 -0
  81. package/dist/components/image-viewer.d.ts +60 -0
  82. package/dist/components/image-viewer.js +411 -0
  83. package/dist/components/inline-edit.d.ts +22 -0
  84. package/dist/components/inline-edit.js +51 -0
  85. package/dist/components/input.d.ts +155 -0
  86. package/dist/components/input.js +109 -0
  87. package/dist/components/item-label.d.ts +11 -0
  88. package/dist/components/item-label.js +5 -0
  89. package/dist/components/item-row.d.ts +23 -0
  90. package/dist/components/item-row.js +19 -0
  91. package/dist/components/kbd.d.ts +55 -0
  92. package/dist/components/kbd.js +86 -0
  93. package/dist/components/link-policy.d.ts +24 -0
  94. package/dist/components/link-policy.js +32 -0
  95. package/dist/components/linked-text.d.ts +15 -0
  96. package/dist/components/linked-text.js +48 -0
  97. package/dist/components/loading-region.d.ts +18 -0
  98. package/dist/components/loading-region.js +17 -0
  99. package/dist/components/markdown.d.ts +34 -0
  100. package/dist/components/markdown.js +307 -0
  101. package/dist/components/menu.d.ts +132 -0
  102. package/dist/components/menu.js +102 -0
  103. package/dist/components/message-bubble.d.ts +57 -0
  104. package/dist/components/message-bubble.js +28 -0
  105. package/dist/components/meta-line.d.ts +28 -0
  106. package/dist/components/meta-line.js +36 -0
  107. package/dist/components/money-input.d.ts +23 -0
  108. package/dist/components/money-input.js +34 -0
  109. package/dist/components/native-select.d.ts +120 -0
  110. package/dist/components/native-select.js +85 -0
  111. package/dist/components/page-trail.d.ts +30 -0
  112. package/dist/components/page-trail.js +43 -0
  113. package/dist/components/page.d.ts +80 -0
  114. package/dist/components/page.js +60 -0
  115. package/dist/components/path-text.d.ts +8 -0
  116. package/dist/components/path-text.js +11 -0
  117. package/dist/components/percent-input.d.ts +20 -0
  118. package/dist/components/percent-input.js +32 -0
  119. package/dist/components/popover.d.ts +52 -0
  120. package/dist/components/popover.js +36 -0
  121. package/dist/components/progress.d.ts +389 -0
  122. package/dist/components/progress.js +142 -0
  123. package/dist/components/radio.d.ts +65 -0
  124. package/dist/components/radio.js +54 -0
  125. package/dist/components/remote-image-gate.d.ts +34 -0
  126. package/dist/components/remote-image-gate.js +60 -0
  127. package/dist/components/resizable.d.ts +23 -0
  128. package/dist/components/resizable.js +30 -0
  129. package/dist/components/rolling-number.d.ts +13 -0
  130. package/dist/components/rolling-number.js +69 -0
  131. package/dist/components/scroll-area.d.ts +17 -0
  132. package/dist/components/scroll-area.js +25 -0
  133. package/dist/components/section-label.d.ts +10 -0
  134. package/dist/components/section-label.js +21 -0
  135. package/dist/components/section-nav.d.ts +22 -0
  136. package/dist/components/section-nav.js +80 -0
  137. package/dist/components/segmented-control.d.ts +125 -0
  138. package/dist/components/segmented-control.js +101 -0
  139. package/dist/components/select.d.ts +120 -0
  140. package/dist/components/select.js +89 -0
  141. package/dist/components/separator.d.ts +10 -0
  142. package/dist/components/separator.js +12 -0
  143. package/dist/components/sheet.d.ts +101 -0
  144. package/dist/components/sheet.js +129 -0
  145. package/dist/components/shortcut-recorder.d.ts +31 -0
  146. package/dist/components/shortcut-recorder.js +67 -0
  147. package/dist/components/skeleton.d.ts +31 -0
  148. package/dist/components/skeleton.js +33 -0
  149. package/dist/components/slider.d.ts +138 -0
  150. package/dist/components/slider.js +98 -0
  151. package/dist/components/spinner.d.ts +37 -0
  152. package/dist/components/spinner.js +16 -0
  153. package/dist/components/switch.d.ts +59 -0
  154. package/dist/components/switch.js +56 -0
  155. package/dist/components/tab-strip.d.ts +29 -0
  156. package/dist/components/tab-strip.js +42 -0
  157. package/dist/components/tabs.d.ts +13 -0
  158. package/dist/components/tabs.js +68 -0
  159. package/dist/components/text-link.d.ts +54 -0
  160. package/dist/components/text-link.js +38 -0
  161. package/dist/components/textarea.d.ts +75 -0
  162. package/dist/components/textarea.js +90 -0
  163. package/dist/components/toast.d.ts +74 -0
  164. package/dist/components/toast.js +128 -0
  165. package/dist/components/tooltip.d.ts +50 -0
  166. package/dist/components/tooltip.js +46 -0
  167. package/dist/components/truncated-text.d.ts +15 -0
  168. package/dist/components/truncated-text.js +19 -0
  169. package/dist/i18n/defaults.d.ts +7 -0
  170. package/dist/i18n/defaults.js +7 -0
  171. package/dist/i18n/format.d.ts +84 -0
  172. package/dist/i18n/format.js +169 -0
  173. package/dist/i18n/index.d.ts +6 -0
  174. package/dist/i18n/index.js +8 -0
  175. package/dist/i18n/locales/ru-formatters.d.ts +3 -0
  176. package/dist/i18n/locales/ru-formatters.js +22 -0
  177. package/dist/i18n/locales/ru.d.ts +5 -0
  178. package/dist/i18n/locales/ru.js +185 -0
  179. package/dist/i18n/plural.d.ts +20 -0
  180. package/dist/i18n/plural.js +26 -0
  181. package/dist/i18n/provider.d.ts +36 -0
  182. package/dist/i18n/provider.js +39 -0
  183. package/dist/i18n/rich.d.ts +14 -0
  184. package/dist/i18n/rich.js +44 -0
  185. package/dist/i18n/ru-plural.d.ts +3 -0
  186. package/dist/i18n/ru-plural.js +4 -0
  187. package/dist/i18n/strings/alert-dialog.d.ts +5 -0
  188. package/dist/i18n/strings/alert-dialog.js +5 -0
  189. package/dist/i18n/strings/block-stack.d.ts +17 -0
  190. package/dist/i18n/strings/block-stack.js +11 -0
  191. package/dist/i18n/strings/code-block.d.ts +18 -0
  192. package/dist/i18n/strings/code-block.js +13 -0
  193. package/dist/i18n/strings/combobox.d.ts +12 -0
  194. package/dist/i18n/strings/combobox.js +10 -0
  195. package/dist/i18n/strings/command-palette.d.ts +17 -0
  196. package/dist/i18n/strings/command-palette.js +11 -0
  197. package/dist/i18n/strings/diff-view.d.ts +92 -0
  198. package/dist/i18n/strings/diff-view.js +68 -0
  199. package/dist/i18n/strings/image-viewer.d.ts +43 -0
  200. package/dist/i18n/strings/image-viewer.js +32 -0
  201. package/dist/i18n/strings/index.d.ts +314 -0
  202. package/dist/i18n/strings/index.js +43 -0
  203. package/dist/i18n/strings/kbd.d.ts +42 -0
  204. package/dist/i18n/strings/kbd.js +39 -0
  205. package/dist/i18n/strings/markdown.d.ts +23 -0
  206. package/dist/i18n/strings/markdown.js +18 -0
  207. package/dist/i18n/strings/money.d.ts +7 -0
  208. package/dist/i18n/strings/money.js +5 -0
  209. package/dist/i18n/strings/primitives.d.ts +25 -0
  210. package/dist/i18n/strings/primitives.js +18 -0
  211. package/dist/i18n/strings/progress.d.ts +4 -0
  212. package/dist/i18n/strings/progress.js +4 -0
  213. package/dist/i18n/strings/shortcut-recorder.d.ts +15 -0
  214. package/dist/i18n/strings/shortcut-recorder.js +11 -0
  215. package/dist/i18n/strings/time.d.ts +41 -0
  216. package/dist/i18n/strings/time.js +20 -0
  217. package/dist/i18n/strings/toast.d.ts +6 -0
  218. package/dist/i18n/strings/toast.js +6 -0
  219. package/dist/i18n/time-zones.d.ts +20 -0
  220. package/dist/i18n/time-zones.js +64 -0
  221. package/dist/index.d.ts +84 -0
  222. package/dist/index.js +88 -0
  223. package/dist/lib/ansi.d.ts +55 -0
  224. package/dist/lib/ansi.js +438 -0
  225. package/dist/lib/clock.d.ts +32 -0
  226. package/dist/lib/clock.js +106 -0
  227. package/dist/lib/cn.d.ts +12 -0
  228. package/dist/lib/cn.js +28 -0
  229. package/dist/lib/control-props.d.ts +21 -0
  230. package/dist/lib/control-props.js +14 -0
  231. package/dist/lib/direction.d.ts +13 -0
  232. package/dist/lib/direction.js +25 -0
  233. package/dist/lib/image-size.d.ts +12 -0
  234. package/dist/lib/image-size.js +66 -0
  235. package/dist/lib/keycaps.d.ts +21 -0
  236. package/dist/lib/keycaps.js +62 -0
  237. package/dist/lib/keyed.d.ts +9 -0
  238. package/dist/lib/keyed.js +14 -0
  239. package/dist/lib/keys.d.ts +49 -0
  240. package/dist/lib/keys.js +159 -0
  241. package/dist/lib/kit-motion.d.ts +9 -0
  242. package/dist/lib/kit-motion.js +12 -0
  243. package/dist/lib/link-check-dialog.d.ts +11 -0
  244. package/dist/lib/link-check-dialog.js +18 -0
  245. package/dist/lib/motion-features.d.ts +1 -0
  246. package/dist/lib/motion-features.js +4 -0
  247. package/dist/lib/motion-provider.d.ts +5 -0
  248. package/dist/lib/motion-provider.js +8 -0
  249. package/dist/lib/motion.d.ts +39 -0
  250. package/dist/lib/motion.js +49 -0
  251. package/dist/lib/number-format.d.ts +114 -0
  252. package/dist/lib/number-format.js +313 -0
  253. package/dist/lib/patch.d.ts +72 -0
  254. package/dist/lib/patch.js +344 -0
  255. package/dist/lib/path.d.ts +34 -0
  256. package/dist/lib/path.js +85 -0
  257. package/dist/lib/search.d.ts +10 -0
  258. package/dist/lib/search.js +20 -0
  259. package/dist/lib/shiki-themes.d.ts +7 -0
  260. package/dist/lib/shiki-themes.js +115 -0
  261. package/dist/lib/shiki.d.ts +101 -0
  262. package/dist/lib/shiki.js +353 -0
  263. package/dist/lib/shortcut-context.d.ts +23 -0
  264. package/dist/lib/shortcut-context.js +29 -0
  265. package/dist/lib/text.d.ts +56 -0
  266. package/dist/lib/text.js +149 -0
  267. package/dist/lib/theme-scope.d.ts +18 -0
  268. package/dist/lib/theme-scope.js +24 -0
  269. package/dist/lib/theme.d.ts +40 -0
  270. package/dist/lib/theme.js +96 -0
  271. package/dist/lib/tree-keys.d.ts +72 -0
  272. package/dist/lib/tree-keys.js +126 -0
  273. package/dist/lib/url.d.ts +17 -0
  274. package/dist/lib/url.js +38 -0
  275. package/dist/lib/use-copy-to-clipboard.d.ts +13 -0
  276. package/dist/lib/use-copy-to-clipboard.js +40 -0
  277. package/dist/lib/use-delayed-loading.d.ts +11 -0
  278. package/dist/lib/use-delayed-loading.js +31 -0
  279. package/dist/lib/use-file-picker.d.ts +26 -0
  280. package/dist/lib/use-file-picker.js +43 -0
  281. package/dist/lib/use-hydrated.d.ts +6 -0
  282. package/dist/lib/use-hydrated.js +11 -0
  283. package/dist/lib/use-latest.d.ts +12 -0
  284. package/dist/lib/use-latest.js +22 -0
  285. package/dist/lib/use-resolved-theme.d.ts +12 -0
  286. package/dist/lib/use-resolved-theme.js +25 -0
  287. package/dist/styles/base.css +393 -0
  288. package/dist/styles/code.css +35 -0
  289. package/dist/styles/fonts.css +12 -0
  290. package/dist/styles/index.css +13 -0
  291. package/dist/styles/tokens.gen.css +494 -0
  292. package/package.json +208 -4
@@ -0,0 +1,80 @@
1
+ import { Dialog as BaseDialog } from "@base-ui/react/dialog";
2
+ import type { ComponentProps, ReactElement, ReactNode } from "react";
3
+ import { type VariantProps } from "../lib/cn.js";
4
+ /** Dimmed, lightly blurred scrim. */
5
+ export declare const dialogBackdropClass = "fixed inset-0 z-(--z-overlay) min-h-dvh bg-scrim backdrop-blur-[2px] backdrop-motion supports-[-webkit-touch-callout:none]:absolute";
6
+ /** Full-screen layer; the popup centers with `my-auto` so tall dialogs scroll instead of clipping. */
7
+ export declare const dialogViewportClass = "fixed inset-0 z-(--z-overlay) flex justify-center overflow-y-auto overscroll-contain p-4 outline-none sm:p-6";
8
+ export declare const dialogPopupStyles: import("tailwind-variants").TVReturnType<{
9
+ size: {
10
+ sm: "max-w-[400px]";
11
+ md: "max-w-[520px]";
12
+ lg: "max-w-[680px]";
13
+ xl: "max-w-[880px]";
14
+ /** A page of its own in a dialog (Settings): wide, and as tall as the window allows up to 760 px. */
15
+ window: "h-[min(760px,100%)] max-w-[1040px]";
16
+ };
17
+ }, undefined, string[], {
18
+ size: {
19
+ sm: "max-w-[400px]";
20
+ md: "max-w-[520px]";
21
+ lg: "max-w-[680px]";
22
+ xl: "max-w-[880px]";
23
+ /** A page of its own in a dialog (Settings): wide, and as tall as the window allows up to 760 px. */
24
+ window: "h-[min(760px,100%)] max-w-[1040px]";
25
+ };
26
+ }, undefined, import("tailwind-variants").TVReturnTypeLike<{
27
+ size: {
28
+ sm: "max-w-[400px]";
29
+ md: "max-w-[520px]";
30
+ lg: "max-w-[680px]";
31
+ xl: "max-w-[880px]";
32
+ /** A page of its own in a dialog (Settings): wide, and as tall as the window allows up to 760 px. */
33
+ window: "h-[min(760px,100%)] max-w-[1040px]";
34
+ };
35
+ }, undefined>>;
36
+ export type DialogPopupVariants = VariantProps<typeof dialogPopupStyles>;
37
+ export declare const dialogTitleClass = "text-md font-semibold leading-tight tracking-tight text-fg";
38
+ export declare const dialogDescriptionClass = "text-base text-fg-muted";
39
+ export declare const dialogHeaderClass = "flex flex-col gap-1.5 px-6 pt-6 pb-4";
40
+ export declare const dialogBodyClass = "px-6 pb-4";
41
+ export declare const dialogFooterClass = "flex flex-col-reverse gap-2 px-6 pt-2 pb-6 sm:flex-row sm:items-center sm:justify-end";
42
+ export declare const DialogRoot: <Payload>(props: BaseDialog.Root.Props<Payload>) => React.JSX.Element;
43
+ export declare const DialogTrigger: BaseDialog.Trigger;
44
+ export declare const DialogPortal: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").DialogPortalProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
45
+ export declare const DialogClose: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").DialogCloseProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
46
+ /** The unstyled popup, for full-screen surfaces that bring their own look (the account gate). */
47
+ export declare const DialogPopup: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").DialogPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
48
+ export declare function DialogBackdrop({ className, ...props }: ComponentProps<typeof BaseDialog.Backdrop>): import("react").JSX.Element;
49
+ export interface DialogContentProps extends ComponentProps<typeof BaseDialog.Popup>, DialogPopupVariants {
50
+ /** Render the corner close button. */
51
+ closable?: boolean;
52
+ /** Extra classes for the centering viewport (e.g. vertical alignment). */
53
+ viewportClassName?: string;
54
+ }
55
+ /** Portal + backdrop + viewport + popup. */
56
+ export declare function DialogContent({ size, closable, viewportClassName, className, children, ...props }: DialogContentProps): import("react").JSX.Element;
57
+ export declare function DialogHeader({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
58
+ export declare function DialogBody({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
59
+ export declare function DialogFooter({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
60
+ export declare function DialogTitle({ className, ...props }: ComponentProps<typeof BaseDialog.Title>): import("react").JSX.Element;
61
+ export declare function DialogDescription({ className, ...props }: ComponentProps<typeof BaseDialog.Description>): import("react").JSX.Element;
62
+ /** Icon-only close pinned to the top-right corner. */
63
+ export declare function DialogCloseButton({ className, "aria-label": ariaLabel, ...props }: ComponentProps<typeof BaseDialog.Close>): import("react").JSX.Element;
64
+ export interface DialogProps extends DialogPopupVariants {
65
+ /** Optional trigger element; must accept a ref and DOM props (e.g. <Button>). */
66
+ trigger?: ReactElement;
67
+ title: ReactNode;
68
+ description?: ReactNode;
69
+ /** Body content. */
70
+ children?: ReactNode;
71
+ /** Footer actions (buttons). Wrap a cancel button in `<DialogClose render={<Button/>}/>`. */
72
+ footer?: ReactNode;
73
+ open?: boolean;
74
+ defaultOpen?: boolean;
75
+ onOpenChange?: ComponentProps<typeof BaseDialog.Root>["onOpenChange"];
76
+ closable?: boolean;
77
+ className?: string;
78
+ }
79
+ /** Convenience wrapper with a standard header/body/footer layout. */
80
+ export declare function Dialog({ trigger, title, description, children, footer, size, open, defaultOpen, onOpenChange, closable, className, }: DialogProps): import("react").JSX.Element;
@@ -0,0 +1,85 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Dialog as BaseDialog } from "@base-ui/react/dialog";
4
+ import { X } from "lucide-react";
5
+ import { useUiStrings } from "../i18n/provider.js";
6
+ import { cn, tv, withBase } from "../lib/cn.js";
7
+ import { usePortalContainer } from "../lib/theme-scope.js";
8
+ import { iconButtonStyles } from "./button.js";
9
+ /* ------------------------------------------------------------------------------------------ */
10
+ /* Shared modal styles — also used by AlertDialog, Sheet and CommandPalette. */
11
+ /* ------------------------------------------------------------------------------------------ */
12
+ /** Dimmed, lightly blurred scrim. */
13
+ export const dialogBackdropClass = "fixed inset-0 z-(--z-overlay) min-h-dvh bg-scrim backdrop-blur-[2px] backdrop-motion supports-[-webkit-touch-callout:none]:absolute";
14
+ /** Full-screen layer; the popup centers with `my-auto` so tall dialogs scroll instead of clipping. */
15
+ export const dialogViewportClass = "fixed inset-0 z-(--z-overlay) flex justify-center overflow-y-auto overscroll-contain p-4 outline-none sm:p-6";
16
+ export const dialogPopupStyles = tv({
17
+ base: [
18
+ "relative my-auto flex w-full flex-col rounded-2xl border border-border-subtle bg-surface-overlay text-fg outline-none",
19
+ "[box-shadow:var(--shadow-xl),var(--shadow-inset-edge)]",
20
+ // 180 ms scale-in from slightly below, no blur; quick ease-in fade out.
21
+ "origin-top transition-[opacity,scale,translate] duration-(--duration-base) ease-(--ease-out)",
22
+ "data-starting-style:translate-y-2 data-starting-style:scale-[0.96] data-starting-style:opacity-0",
23
+ "data-ending-style:scale-[0.98] data-ending-style:opacity-0 data-ending-style:duration-(--duration-fast) data-ending-style:ease-(--ease-in)",
24
+ "motion-reduce:data-starting-style:translate-y-0 motion-reduce:data-starting-style:scale-100 motion-reduce:data-ending-style:scale-100",
25
+ // Nested dialogs: recede the parent a touch.
26
+ "data-nested-dialog-open:scale-[0.98] data-nested-dialog-open:opacity-80",
27
+ ],
28
+ variants: {
29
+ size: {
30
+ sm: "max-w-[400px]",
31
+ md: "max-w-[520px]",
32
+ lg: "max-w-[680px]",
33
+ xl: "max-w-[880px]",
34
+ /** A page of its own in a dialog (Settings): wide, and as tall as the window allows up to 760 px. */
35
+ window: "h-[min(760px,100%)] max-w-[1040px]",
36
+ },
37
+ },
38
+ defaultVariants: { size: "md" },
39
+ });
40
+ export const dialogTitleClass = "text-md font-semibold leading-tight tracking-tight text-fg";
41
+ export const dialogDescriptionClass = "text-base text-fg-muted";
42
+ export const dialogHeaderClass = "flex flex-col gap-1.5 px-6 pt-6 pb-4";
43
+ export const dialogBodyClass = "px-6 pb-4";
44
+ export const dialogFooterClass = "flex flex-col-reverse gap-2 px-6 pt-2 pb-6 sm:flex-row sm:items-center sm:justify-end";
45
+ /* ------------------------------------------------------------------------------------------ */
46
+ /* Dialog */
47
+ /* ------------------------------------------------------------------------------------------ */
48
+ export const DialogRoot = BaseDialog.Root;
49
+ export const DialogTrigger = BaseDialog.Trigger;
50
+ export const DialogPortal = BaseDialog.Portal;
51
+ export const DialogClose = BaseDialog.Close;
52
+ /** The unstyled popup, for full-screen surfaces that bring their own look (the account gate). */
53
+ export const DialogPopup = BaseDialog.Popup;
54
+ export function DialogBackdrop({ className, ...props }) {
55
+ return (_jsx(BaseDialog.Backdrop, { "data-slot": "dialog-backdrop", className: withBase(dialogBackdropClass, className), ...props }));
56
+ }
57
+ /** Portal + backdrop + viewport + popup. */
58
+ export function DialogContent({ size, closable = true, viewportClassName, className, children, ...props }) {
59
+ const container = usePortalContainer();
60
+ return (_jsxs(BaseDialog.Portal, { container: container, children: [_jsx(DialogBackdrop, {}), _jsx(BaseDialog.Viewport, { "data-slot": "dialog-viewport", className: cn(dialogViewportClass, viewportClassName), children: _jsxs(BaseDialog.Popup, { "data-slot": "dialog", className: withBase(dialogPopupStyles({ size }), className), ...props, children: [children, closable && _jsx(DialogCloseButton, {})] }) })] }));
61
+ }
62
+ export function DialogHeader({ className, ...props }) {
63
+ return _jsx("div", { "data-slot": "dialog-header", className: cn(dialogHeaderClass, "pe-12", className), ...props });
64
+ }
65
+ export function DialogBody({ className, ...props }) {
66
+ return _jsx("div", { "data-slot": "dialog-body", className: cn(dialogBodyClass, className), ...props });
67
+ }
68
+ export function DialogFooter({ className, ...props }) {
69
+ return _jsx("div", { "data-slot": "dialog-footer", className: cn(dialogFooterClass, className), ...props });
70
+ }
71
+ export function DialogTitle({ className, ...props }) {
72
+ return (_jsx(BaseDialog.Title, { "data-slot": "dialog-title", className: withBase(dialogTitleClass, className), ...props }));
73
+ }
74
+ export function DialogDescription({ className, ...props }) {
75
+ return (_jsx(BaseDialog.Description, { "data-slot": "dialog-description", className: withBase(dialogDescriptionClass, className), ...props }));
76
+ }
77
+ /** Icon-only close pinned to the top-right corner. */
78
+ export function DialogCloseButton({ className, "aria-label": ariaLabel, ...props }) {
79
+ const t = useUiStrings().primitives;
80
+ return (_jsx(BaseDialog.Close, { "data-slot": "dialog-close", "aria-label": ariaLabel ?? t.close, className: withBase(cn(iconButtonStyles({ variant: "ghost", size: "sm" }), "absolute top-4 end-4"), className), ...props, children: _jsx(X, { "aria-hidden": true }) }));
81
+ }
82
+ /** Convenience wrapper with a standard header/body/footer layout. */
83
+ export function Dialog({ trigger, title, description, children, footer, size, open, defaultOpen, onOpenChange, closable, className, }) {
84
+ return (_jsxs(BaseDialog.Root, { ...(open !== undefined && { open }), ...(defaultOpen !== undefined && { defaultOpen }), ...(onOpenChange && { onOpenChange }), children: [trigger && _jsx(BaseDialog.Trigger, { render: trigger }), _jsxs(DialogContent, { size: size, ...(closable !== undefined && { closable }), className: className, children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: title }), description !== undefined && _jsx(DialogDescription, { children: description })] }), children !== undefined && _jsx(DialogBody, { children: children }), footer !== undefined && _jsx(DialogFooter, { children: footer })] })] }));
85
+ }
@@ -0,0 +1,20 @@
1
+ import type { ReactNode } from "react";
2
+ /** One line of a small diff: added, removed or unchanged context. */
3
+ export interface DiffLine {
4
+ readonly kind: "add" | "remove" | "context";
5
+ /**
6
+ * The line's text. A span inside it can mark a changed word: `bg-diff-add-word` (or `-remove-`) in
7
+ * ink (`text-fg`), since the line's green or red on the word band falls under 4.5:1.
8
+ */
9
+ readonly text: ReactNode;
10
+ /** Unique among the lines (the text, when it is a string and unique). */
11
+ readonly key: string;
12
+ }
13
+ /**
14
+ * A few lines of a change on the diff tokens, each with its sign: a preview or a demo, where the
15
+ * full `DiffView` (files, hunks, highlighting) is more than the place needs.
16
+ */
17
+ export declare function DiffLines({ lines, className, }: {
18
+ readonly lines: readonly DiffLine[];
19
+ readonly className?: string;
20
+ }): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../lib/cn.js";
3
+ const SIGN = { add: "+", remove: "−", context: " " };
4
+ /**
5
+ * A few lines of a change on the diff tokens, each with its sign: a preview or a demo, where the
6
+ * full `DiffView` (files, hunks, highlighting) is more than the place needs.
7
+ */
8
+ export function DiffLines({ lines, className, }) {
9
+ return (_jsx("div", { "data-slot": "diff-lines", className: cn("overflow-hidden rounded-lg border border-border-subtle bg-bg-inset font-mono text-xs leading-5", className), children: lines.map((line) => (_jsxs("p", { className: cn("flex gap-2 truncate px-3", line.kind === "add" && "bg-diff-add-bg text-diff-add-fg", line.kind === "remove" && "bg-diff-remove-bg text-diff-remove-fg", line.kind === "context" && "text-fg-subtle"), children: [_jsx("span", { "aria-hidden": true, className: "w-2 shrink-0 select-none", children: SIGN[line.kind] }), _jsx("span", { className: "truncate", children: line.text })] }, line.key))) }));
10
+ }
@@ -0,0 +1,128 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ import { type DiffStats } from "../lib/patch.js";
3
+ export interface DiffHighlighterProviderProps {
4
+ /**
5
+ * Creates one @pierre/diffs highlight worker. The bundler has to see the worker entry, so the host
6
+ * supplies it (Vite, webpack, Rspack): `() => new Worker(new URL(
7
+ * "@pierre/diffs/worker/worker-portable.js", import.meta.url), { type: "module" })`. Read once, on
8
+ * mount.
9
+ *
10
+ * The portable entry, not `worker.js`: in @pierre/diffs 1.6.0 `worker.js` is also the chunk its own
11
+ * lazily loaded highlighter chunks import back (`./worker.js`). A dev server that loads a worker
12
+ * entry under another URL (Vite's `?worker_file`) then runs it twice in each worker. The second
13
+ * copy never gets `initialize`, keeps the library's default themes, and fails every request with
14
+ * `Theme "pierre-dark" has not been resolved`. The portable entry is one self-contained file.
15
+ */
16
+ workerFactory: () => Worker;
17
+ children: ReactNode;
18
+ }
19
+ /**
20
+ * Moves every descendant <DiffView>'s syntax highlighting into @pierre/diffs' worker pool: a diff
21
+ * first paints as plain text (same rows, same height), then swaps in its highlighted lines when
22
+ * the worker answers, and a content-keyed LRU makes remounts (a virtualized row scrolling back
23
+ * into view) highlighted on their first paint. Without this provider diffs highlight on the main
24
+ * thread while mounting. Mount it once, near the root; it owns the pool's lifetime. The workers
25
+ * start when the first diff mounts, so pages without diffs never download the highlighter.
26
+ */
27
+ export declare function DiffHighlighterProvider({ workerFactory, children }: DiffHighlighterProviderProps): import("react").JSX.Element;
28
+ /**
29
+ * Content-derived `cacheKey` (two 53-bit hashes + length) for the pool's highlight cache, so equal
30
+ * diffs share one highlight across mounts and changed content never reuses a stale one.
31
+ */
32
+ export declare function diffCacheKey(...parts: ReadonlyArray<string | undefined>): string;
33
+ export interface DiffFile {
34
+ /** Path shown in the header; its extension picks the grammar. */
35
+ name: string;
36
+ contents: string;
37
+ /** Override the inferred language. */
38
+ lang?: string;
39
+ }
40
+ export type DiffMode = "split" | "unified";
41
+ type DiffSource = {
42
+ oldFile: DiffFile | null;
43
+ newFile: DiffFile | null;
44
+ patch?: never;
45
+ } | {
46
+ patch: string;
47
+ oldFile?: never;
48
+ newFile?: never;
49
+ };
50
+ /** A review comment pinned to one line of one side of the diff. */
51
+ export interface DiffComment {
52
+ id: string;
53
+ /** `old` = the left / deleted side, `new` = the right / added side. */
54
+ side: "old" | "new";
55
+ line: number;
56
+ text: string;
57
+ /** Shown with an avatar initial; defaults to `diffView.comment.you` ("You"). */
58
+ author?: string;
59
+ }
60
+ /**
61
+ * Host-rendered content pinned under one line (e.g. a review finding marker). Rendered above that
62
+ * line's comments, inside the same width-pinned annotation row.
63
+ */
64
+ export interface DiffLineNote {
65
+ id: string;
66
+ /** `old` = the left / deleted side, `new` = the right / added side. */
67
+ side: "old" | "new";
68
+ line: number;
69
+ content: ReactNode;
70
+ }
71
+ /** What `onAddComment` receives; the host assigns the id. */
72
+ export type NewDiffComment = Pick<DiffComment, "side" | "line" | "text">;
73
+ /** Outcome of a per-hunk action, shown in that hunk's toolbar. */
74
+ export type HunkState = "accepted" | "reverted";
75
+ /**
76
+ * `+12 −3`: lines added and removed, in the diff's colours with glyphs (never colour alone), the
77
+ * figures in the reader's digits, spoken as words so they are never read as arithmetic.
78
+ */
79
+ export declare function DiffStat({ additions, deletions, className }: DiffStats & {
80
+ className?: string;
81
+ }): import("react").JSX.Element;
82
+ export type DiffViewProps = DiffSource & Omit<ComponentProps<"div">, "children"> & {
83
+ /** Controlled layout. */
84
+ mode?: DiffMode;
85
+ defaultMode?: DiffMode;
86
+ onModeChange?: (mode: DiffMode) => void;
87
+ /**
88
+ * Below this container width (px) an uncontrolled split view shows unified instead, until the
89
+ * user picks a layout with the toggle. Default 900; 0 disables the fallback.
90
+ */
91
+ splitMinWidth?: number;
92
+ /** Controlled collapse. */
93
+ collapsed?: boolean;
94
+ defaultCollapsed?: boolean;
95
+ onCollapsedChange?: (collapsed: boolean) => void;
96
+ /** Header path; defaults to the new (or old) file name, or the patch's. */
97
+ filename?: string;
98
+ /** Soft-wrap long lines (controlled). */
99
+ wrap?: boolean;
100
+ defaultWrap?: boolean;
101
+ onWrapChange?: (wrap: boolean) => void;
102
+ /** Show the soft-wrap toggle (default true). */
103
+ showWrapToggle?: boolean;
104
+ /** Scroll the body beyond this height. */
105
+ maxHeight?: number | string;
106
+ /** Show the split/unified toggle (default true). */
107
+ showModeToggle?: boolean;
108
+ /** Extra header controls (e.g. accept / reject), rendered before the built-ins. */
109
+ actions?: ReactNode;
110
+ /** Per-hunk toolbar actions; each receives the hunk's index in the parsed diff. */
111
+ onAcceptHunk?: (hunkIndex: number) => void;
112
+ onRevertHunk?: (hunkIndex: number) => void;
113
+ /** "Ask about this hunk"; also receives the hunk as unified-diff text to quote. */
114
+ onAskAboutHunk?: (hunkIndex: number, excerpt: string) => void;
115
+ /** Settled hunks by index: labelled in their toolbar, with the matching action disabled. */
116
+ hunkStates?: Readonly<Partial<Record<number, HunkState>>>;
117
+ /** Comments rendered inline under their line. */
118
+ comments?: readonly DiffComment[];
119
+ /** Enables commenting: click a line number (or the gutter "+") to open an inline comment field. */
120
+ onAddComment?: (comment: NewDiffComment) => void;
121
+ onRemoveComment?: (id: string) => void;
122
+ /** The inline comment field's placeholder, when the host says where comments go; "Leave a comment…" by default. */
123
+ commentPlaceholder?: string | undefined;
124
+ /** Host content pinned under specific lines (review finding markers, lint notes…). */
125
+ lineNotes?: readonly DiffLineNote[];
126
+ };
127
+ export declare function DiffView(props: DiffViewProps): import("react").JSX.Element;
128
+ export {};