@platned/ui 0.10.3 → 1.0.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 (63) hide show
  1. package/README.md +42 -98
  2. package/dist/blocks-charts.cjs +459 -0
  3. package/dist/blocks-charts.cjs.map +1 -0
  4. package/dist/blocks-charts.d.cts +64 -0
  5. package/dist/blocks-charts.d.ts +64 -0
  6. package/dist/blocks-charts.js +440 -0
  7. package/dist/blocks-charts.js.map +1 -0
  8. package/dist/blocks.cjs +8007 -0
  9. package/dist/blocks.cjs.map +1 -0
  10. package/dist/blocks.d.cts +3082 -0
  11. package/dist/blocks.d.ts +3082 -0
  12. package/dist/blocks.js +8223 -0
  13. package/dist/blocks.js.map +1 -0
  14. package/dist/chart.cjs +226 -0
  15. package/dist/chart.cjs.map +1 -0
  16. package/dist/chart.d.ts +66 -0
  17. package/dist/chart.js +183 -0
  18. package/dist/chart.js.map +1 -0
  19. package/dist/chunk-2L5XAYNK.js +11 -0
  20. package/dist/chunk-2L5XAYNK.js.map +1 -0
  21. package/dist/chunk-327NSKZW.js +3176 -0
  22. package/dist/chunk-327NSKZW.js.map +1 -0
  23. package/dist/chunk-GJJWRZ4B.js +200 -0
  24. package/dist/chunk-GJJWRZ4B.js.map +1 -0
  25. package/dist/chunk-WGCAQEZ4.js +178 -0
  26. package/dist/chunk-WGCAQEZ4.js.map +1 -0
  27. package/dist/code-block-BgEiLXpO.d.ts +111 -0
  28. package/dist/code-block-highlight.cjs +489 -0
  29. package/dist/code-block-highlight.cjs.map +1 -0
  30. package/dist/code-block-highlight.d.ts +28 -0
  31. package/dist/code-block-highlight.js +120 -0
  32. package/dist/code-block-highlight.js.map +1 -0
  33. package/dist/data-table-Dec6t8NO.d.ts +729 -0
  34. package/dist/data-table.cjs +3506 -2219
  35. package/dist/data-table.cjs.map +1 -1
  36. package/dist/data-table.d.ts +2 -1
  37. package/dist/data-table.js +1396 -246
  38. package/dist/data-table.js.map +1 -1
  39. package/dist/index.cjs +8932 -11975
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.ts +2524 -5312
  42. package/dist/index.js +4681 -9560
  43. package/dist/index.js.map +1 -1
  44. package/dist/map.cjs +432 -0
  45. package/dist/map.cjs.map +1 -0
  46. package/dist/map.d.cts +294 -0
  47. package/dist/map.d.ts +294 -0
  48. package/dist/map.js +422 -0
  49. package/dist/map.js.map +1 -0
  50. package/dist/theme.css +1897 -0
  51. package/package.json +65 -24
  52. package/dist/chunk-OVIRTNT4.js +0 -2787
  53. package/dist/chunk-OVIRTNT4.js.map +0 -1
  54. package/dist/data-table-JX-vnL0F.d.ts +0 -464
  55. package/dist/sidebar.cjs +0 -108
  56. package/dist/sidebar.cjs.map +0 -1
  57. package/dist/sidebar.d.cts +0 -257
  58. package/dist/sidebar.d.ts +0 -257
  59. package/dist/sidebar.js +0 -70
  60. package/dist/sidebar.js.map +0 -1
  61. package/dist/styles.css +0 -1
  62. package/dist/tokens.css +0 -1
  63. package/tailwind-preset.cjs +0 -446
@@ -0,0 +1,489 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/code-block-highlight.tsx
31
+ var code_block_highlight_exports = {};
32
+ __export(code_block_highlight_exports, {
33
+ HighlightedCodeBlock: () => HighlightedCodeBlock,
34
+ highlightCode: () => highlightCode,
35
+ loadHighlighter: () => loadHighlighter,
36
+ useHighlightedCode: () => useHighlightedCode
37
+ });
38
+ module.exports = __toCommonJS(code_block_highlight_exports);
39
+ var import_react5 = require("react");
40
+ var import_core = require("shiki/core");
41
+ var import_javascript = require("shiki/engine/javascript");
42
+
43
+ // src/components/ai/code-block.tsx
44
+ var import_react4 = require("react");
45
+ var import_lucide_react2 = require("lucide-react");
46
+
47
+ // src/lib/cn.ts
48
+ var import_clsx = require("clsx");
49
+ var import_tailwind_merge = require("tailwind-merge");
50
+ function cn(...inputs) {
51
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
52
+ }
53
+
54
+ // src/components/forms/button.tsx
55
+ var import_react3 = require("react");
56
+
57
+ // src/lib/slot.tsx
58
+ var import_react = require("react");
59
+ var import_clsx2 = __toESM(require("clsx"), 1);
60
+ var Slot = (0, import_react.forwardRef)(function Slot2({ children, wrapChildren, ...slotProps }, forwardedRef) {
61
+ if (!(0, import_react.isValidElement)(children)) return null;
62
+ const child = children;
63
+ const merged = {
64
+ ...mergeProps(slotProps, child.props),
65
+ ref: composeRefs(forwardedRef, getElementRef(child))
66
+ };
67
+ return wrapChildren ? (0, import_react.cloneElement)(child, merged, wrapChildren(child.props.children)) : (0, import_react.cloneElement)(child, merged);
68
+ });
69
+ function mergeProps(slotProps, childProps) {
70
+ const merged = { ...slotProps };
71
+ for (const key in childProps) {
72
+ const slotValue = slotProps[key];
73
+ const childValue = childProps[key];
74
+ if (/^on[A-Z]/.test(key)) {
75
+ if (typeof slotValue === "function" && typeof childValue === "function") {
76
+ merged[key] = (...args) => {
77
+ slotValue(...args);
78
+ childValue(...args);
79
+ };
80
+ } else {
81
+ merged[key] = childValue ?? slotValue;
82
+ }
83
+ } else if (key === "className") {
84
+ merged[key] = (0, import_clsx2.default)(slotValue, childValue);
85
+ } else if (key === "style") {
86
+ merged[key] = { ...slotValue, ...childValue };
87
+ } else {
88
+ merged[key] = childValue;
89
+ }
90
+ }
91
+ return merged;
92
+ }
93
+ function getElementRef(element) {
94
+ const asRecord = element;
95
+ return asRecord.props?.ref ?? asRecord.ref;
96
+ }
97
+ function composeRefs(...refs) {
98
+ return (node) => {
99
+ for (const ref of refs) {
100
+ if (!ref) continue;
101
+ if (typeof ref === "function") {
102
+ ref(node);
103
+ } else {
104
+ ref.current = node;
105
+ }
106
+ }
107
+ };
108
+ }
109
+
110
+ // src/components/feedback/spinner.tsx
111
+ var import_react2 = require("react");
112
+ var import_lucide_react = require("lucide-react");
113
+ var import_jsx_runtime = require("react/jsx-runtime");
114
+ var Spinner = (0, import_react2.forwardRef)(function Spinner2({ className, ...props }, ref) {
115
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
116
+ import_lucide_react.Loader2Icon,
117
+ {
118
+ ref,
119
+ "data-slot": "spinner",
120
+ role: "status",
121
+ "aria-label": "Loading",
122
+ className: cn("size-4 animate-spin", className),
123
+ ...props
124
+ }
125
+ );
126
+ });
127
+
128
+ // src/components/forms/button.tsx
129
+ var import_jsx_runtime2 = require("react/jsx-runtime");
130
+ var BASE = "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4";
131
+ var VARIANT = {
132
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
133
+ outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
134
+ secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
135
+ ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
136
+ destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
137
+ link: "text-primary underline-offset-4 hover:underline"
138
+ };
139
+ var SIZE = {
140
+ default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",
141
+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",
142
+ sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",
143
+ lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",
144
+ icon: "size-8",
145
+ "icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
146
+ "icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
147
+ "icon-lg": "size-9"
148
+ };
149
+ function withDataIcon(icon, side) {
150
+ if ((0, import_react3.isValidElement)(icon)) {
151
+ return (0, import_react3.cloneElement)(icon, { "data-icon": side, "aria-hidden": true });
152
+ }
153
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-icon": side, "aria-hidden": true, className: "inline-flex shrink-0", children: icon });
154
+ }
155
+ var Button = (0, import_react3.forwardRef)(function Button2({
156
+ variant = "default",
157
+ size = "default",
158
+ asChild = false,
159
+ leadingIcon,
160
+ trailingIcon,
161
+ loading = false,
162
+ loadingLabel,
163
+ disabled,
164
+ type,
165
+ children,
166
+ className,
167
+ onClick,
168
+ ...props
169
+ }, ref) {
170
+ const softDisabled = loading || asChild && Boolean(disabled);
171
+ const handleClick = (event) => {
172
+ if (softDisabled) {
173
+ event.preventDefault();
174
+ event.stopPropagation();
175
+ return;
176
+ }
177
+ onClick?.(event);
178
+ };
179
+ const small = size === "xs" || size === "icon-xs";
180
+ const decorate = (content) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
181
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
182
+ Spinner,
183
+ {
184
+ "data-icon": "inline-start",
185
+ className: small ? "size-3" : void 0,
186
+ ...loadingLabel ? { "aria-label": loadingLabel } : { role: void 0, "aria-label": void 0, "aria-hidden": true }
187
+ }
188
+ ) : leadingIcon !== void 0 && leadingIcon !== null ? withDataIcon(leadingIcon, "inline-start") : null,
189
+ content,
190
+ trailingIcon !== void 0 && trailingIcon !== null ? withDataIcon(trailingIcon, "inline-end") : null
191
+ ] });
192
+ const rootProps = {
193
+ className: cn(BASE, VARIANT[variant], SIZE[size], className),
194
+ "data-slot": "button",
195
+ "data-variant": variant,
196
+ "data-size": size,
197
+ "aria-busy": loading || void 0,
198
+ "aria-disabled": softDisabled || void 0,
199
+ onClick: handleClick,
200
+ ...props
201
+ };
202
+ if (asChild) {
203
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Slot, { ref, wrapChildren: decorate, tabIndex: disabled ? -1 : void 0, ...rootProps, children });
204
+ }
205
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { ref, type: type ?? "button", disabled, ...rootProps, children: decorate(children) });
206
+ });
207
+
208
+ // src/components/ai/code-block.tsx
209
+ var import_jsx_runtime3 = require("react/jsx-runtime");
210
+ var VARIANT2 = {
211
+ default: "bg-muted text-foreground ring-1 ring-foreground/5 dark:ring-foreground/10",
212
+ destructive: "bg-destructive/5 text-destructive ring-1 ring-destructive/15 dark:bg-destructive/10 dark:ring-destructive/20"
213
+ };
214
+ var LINE_VARIANT = {
215
+ default: "",
216
+ highlighted: "bg-foreground/5",
217
+ added: "bg-foreground/5 after:content-['+']",
218
+ removed: "bg-destructive/10 after:text-destructive after:content-['\u2212']"
219
+ };
220
+ var CodeBlock = (0, import_react4.forwardRef)(function CodeBlock2({
221
+ variant = "default",
222
+ size = "default",
223
+ code,
224
+ lines,
225
+ title,
226
+ copyable = false,
227
+ lineNumbers = false,
228
+ wrap = false,
229
+ startLine = 1,
230
+ highlightLines,
231
+ language,
232
+ className,
233
+ children,
234
+ ...props
235
+ }, ref) {
236
+ const shorthand = code != null || lines != null;
237
+ const source = code ?? "";
238
+ const rows = lines ?? source.replace(/\n$/, "").split("\n");
239
+ const copy = copyable ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CodeBlockCopyButton, { value: source }) : null;
240
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
241
+ "div",
242
+ {
243
+ ref,
244
+ "data-slot": "code-block",
245
+ "data-variant": variant,
246
+ "data-size": size,
247
+ "data-language": language,
248
+ className: cn(
249
+ "group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-2xl text-sm has-[>[data-slot=code-block-content]:focus-visible]:ring-3 has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/30 data-[size=sm]:rounded-xl data-[size=sm]:text-xs",
250
+ VARIANT2[variant],
251
+ className
252
+ ),
253
+ ...props,
254
+ children: shorthand ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
255
+ title != null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(CodeBlockHeader, { children: [
256
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CodeBlockTitle, { children: title }),
257
+ copy && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CodeBlockActions, { children: copy })
258
+ ] }) : copy && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CodeBlockActions, { children: copy }),
259
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CodeBlockContent, { lineNumbers, wrap, startLine, children: rows.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CodeBlockLine, { variant: highlightLines?.includes(startLine + index) ? "highlighted" : "default", children: line }, index)) }),
260
+ children
261
+ ] }) : children
262
+ }
263
+ );
264
+ });
265
+ function CodeBlockHeader({ className, ...props }) {
266
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
267
+ "div",
268
+ {
269
+ "data-slot": "code-block-header",
270
+ className: cn(
271
+ "flex min-w-0 shrink-0 items-center gap-2 px-4 pt-4 text-muted-foreground group-data-[size=sm]/code-block:px-3 group-data-[size=sm]/code-block:pt-3 group-data-[variant=destructive]/code-block:text-destructive *:has-[>[data-slot=code-block-title]]:min-w-0",
272
+ className
273
+ ),
274
+ ...props
275
+ }
276
+ );
277
+ }
278
+ function CodeBlockTitle({ className, ...props }) {
279
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
280
+ "div",
281
+ {
282
+ "data-slot": "code-block-title",
283
+ className: cn(
284
+ "min-w-0 truncate font-sans text-sm font-medium text-foreground group-data-[size=sm]/code-block:text-xs group-data-[variant=destructive]/code-block:text-destructive *:[svg]:me-1.5 [&_svg]:pointer-events-none [&_svg]:inline-block [&_svg]:align-middle [&_svg:not([class*='size-'])]:size-4 group-data-[size=sm]/code-block:[&_svg:not([class*='size-'])]:size-3.5",
285
+ className
286
+ ),
287
+ ...props
288
+ }
289
+ );
290
+ }
291
+ function CodeBlockActions({ className, ...props }) {
292
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
293
+ "div",
294
+ {
295
+ "data-slot": "code-block-actions",
296
+ className: cn(
297
+ "-my-1 -me-1.5 ms-auto flex shrink-0 items-center gap-1 *:data-[slot=button]:hover:bg-foreground/5 dark:*:data-[slot=button]:hover:bg-foreground/10",
298
+ "[[data-slot=code-block]>&]:absolute [[data-slot=code-block]>&]:end-3 [[data-slot=code-block]>&]:top-3 [[data-slot=code-block]>&]:z-10 [[data-slot=code-block]>&]:m-0 [[data-slot=code-block]>&]:opacity-0 [[data-slot=code-block]>&]:transition-opacity [[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100 [[data-slot=code-block]>&]:group-hover/code-block:opacity-100 [[data-slot=code-block]>&]:pointer-coarse:opacity-100 [[data-slot=code-block]>&]:*:[button]:bg-background [[data-slot=code-block]>&]:*:[button]:ring-1 [[data-slot=code-block]>&]:*:[button]:ring-foreground/10 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-2 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-2",
299
+ className
300
+ ),
301
+ ...props
302
+ }
303
+ );
304
+ }
305
+ function CodeBlockCopyButton({ value, variant = "ghost", size = "icon-xs", className, onClick, ...props }) {
306
+ const [copied, setCopied] = (0, import_react4.useState)(false);
307
+ (0, import_react4.useEffect)(() => {
308
+ if (!copied) return;
309
+ const timeout = setTimeout(() => setCopied(false), 2e3);
310
+ return () => clearTimeout(timeout);
311
+ }, [copied]);
312
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
313
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
314
+ Button,
315
+ {
316
+ "data-slot": "code-block-copy-button",
317
+ "data-copied": copied || void 0,
318
+ variant,
319
+ size,
320
+ "aria-label": copied ? "Copied" : "Copy",
321
+ className: cn("hover:bg-foreground/5 dark:hover:bg-foreground/10", className),
322
+ onClick: (event) => {
323
+ onClick?.(event);
324
+ navigator.clipboard?.writeText(value).then(() => setCopied(true)).catch(() => {
325
+ });
326
+ },
327
+ ...props,
328
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.CheckIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.CopyIcon, {})
329
+ }
330
+ ),
331
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-live": "polite", className: "sr-only", children: copied ? "Copied" : "" })
332
+ ] });
333
+ }
334
+ function CodeBlockContent({ className, children, style, wrap = false, lineNumbers = false, startLine = 1, ...props }) {
335
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
336
+ "pre",
337
+ {
338
+ "data-slot": "code-block-content",
339
+ "data-wrap": wrap || void 0,
340
+ "data-numbered": lineNumbers || void 0,
341
+ dir: "ltr",
342
+ tabIndex: 0,
343
+ style: { counterReset: `line ${startLine - 1}`, ...style },
344
+ className: cn(
345
+ "min-h-0 min-w-0 overflow-auto px-4 py-4 text-start font-mono leading-relaxed outline-none scrollbar-thin scroll-fade-x group-has-data-[slot=code-block-footer]/code-block:pb-2 group-has-data-[slot=code-block-header]/code-block:pt-2 group-data-[size=sm]/code-block:px-3 group-data-[size=sm]/code-block:py-3 group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5 data-wrap:scroll-fade-y data-wrap:whitespace-pre-wrap data-wrap:wrap-break-word",
346
+ className
347
+ ),
348
+ ...props,
349
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
350
+ "code",
351
+ {
352
+ "data-slot": "code-block-code",
353
+ className: "grid min-h-lh min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0",
354
+ children: lineNumbers && typeof children === "string" ? children.replace(/\n$/, "").split("\n").map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CodeBlockLine, { children: line }, index)) : children
355
+ }
356
+ )
357
+ }
358
+ );
359
+ }
360
+ function CodeBlockLine({ className, variant = "default", children, ...props }) {
361
+ const empty = children === void 0 || children === null || children === "" || Array.isArray(children) && children.length === 0;
362
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
363
+ "span",
364
+ {
365
+ "data-slot": "code-block-line",
366
+ "data-variant": variant,
367
+ className: cn(
368
+ "relative -mx-4 block min-h-lh px-4 group-data-[size=sm]/code-block:-mx-3 group-data-[size=sm]/code-block:px-3 before:min-w-6 before:text-end before:text-muted-foreground after:absolute after:start-1 after:top-0 after:text-muted-foreground after:select-none in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3 in-data-numbered:[counter-increment:line] in-data-numbered:before:content-[counter(line)] in-data-numbered:before:select-none in-data-numbered:supports-[content:counter(line)_/_'']:before:content-[counter(line)_/_'']",
369
+ LINE_VARIANT[variant],
370
+ className
371
+ ),
372
+ ...props,
373
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-slot": "code-block-line-content", className: "min-w-0", children: empty ? "\n" : children })
374
+ }
375
+ );
376
+ }
377
+
378
+ // src/code-block-highlight.tsx
379
+ var import_jsx_runtime4 = require("react/jsx-runtime");
380
+ var languages = {
381
+ bash: () => import("shiki/langs/shellscript.mjs"),
382
+ css: () => import("shiki/langs/css.mjs"),
383
+ diff: () => import("shiki/langs/diff.mjs"),
384
+ html: () => import("shiki/langs/html.mjs"),
385
+ javascript: () => import("shiki/langs/javascript.mjs"),
386
+ json: () => import("shiki/langs/json.mjs"),
387
+ jsx: () => import("shiki/langs/jsx.mjs"),
388
+ markdown: () => import("shiki/langs/markdown.mjs"),
389
+ python: () => import("shiki/langs/python.mjs"),
390
+ sql: () => import("shiki/langs/sql.mjs"),
391
+ tsx: () => import("shiki/langs/tsx.mjs"),
392
+ typescript: () => import("shiki/langs/typescript.mjs"),
393
+ yaml: () => import("shiki/langs/yaml.mjs")
394
+ };
395
+ var aliases = {
396
+ js: "javascript",
397
+ md: "markdown",
398
+ py: "python",
399
+ sh: "bash",
400
+ shell: "bash",
401
+ shellscript: "bash",
402
+ ts: "typescript",
403
+ yml: "yaml",
404
+ zsh: "bash"
405
+ };
406
+ var highlighter;
407
+ function getHighlighter() {
408
+ highlighter ?? (highlighter = (0, import_core.createHighlighterCore)({
409
+ themes: [import("shiki/themes/github-light.mjs"), import("shiki/themes/github-dark.mjs")],
410
+ langs: [],
411
+ engine: (0, import_javascript.createJavaScriptRegexEngine)({ forgiving: true })
412
+ }));
413
+ return highlighter;
414
+ }
415
+ function getLanguage(language) {
416
+ const name = language.toLowerCase();
417
+ if (name === "ansi") return name;
418
+ if (name in languages) return name;
419
+ return aliases[name] ?? null;
420
+ }
421
+ async function loadHighlighter(language) {
422
+ const lang = getLanguage(language);
423
+ if (!lang) return null;
424
+ const shiki = await getHighlighter();
425
+ if (lang !== "ansi" && !shiki.getLoadedLanguages().includes(lang)) await shiki.loadLanguage(languages[lang]);
426
+ return {
427
+ /** One React node per line, and the grammar state after the last line (pass it back to continue). */
428
+ highlight(code, state) {
429
+ const tokenize = (text) => shiki.codeToTokens(text, {
430
+ lang,
431
+ themes: { light: "github-light", dark: "github-dark" },
432
+ defaultColor: false,
433
+ grammarState: state
434
+ }).tokens;
435
+ const tokens = lang === "ansi" ? code.split("\n").flatMap((line) => tokenize(line)) : tokenize(code);
436
+ return {
437
+ lines: tokens.map(
438
+ (line) => line.map((token, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: token.htmlStyle, className: "text-(--shiki-light) dark:text-(--shiki-dark)", children: token.content }, index))
439
+ ),
440
+ state: shiki.getLastGrammarState(tokens)
441
+ };
442
+ }
443
+ };
444
+ }
445
+ async function highlightCode(code, language) {
446
+ const loaded = await loadHighlighter(language);
447
+ return loaded ? loaded.highlight(code).lines : null;
448
+ }
449
+ function useHighlightedCode(value, language) {
450
+ const code = value.endsWith("\n") ? value.slice(0, -1) : value;
451
+ const [loaded, setLoaded] = (0, import_react5.useState)(null);
452
+ const current = loaded?.language === language ? loaded.highlighter : null;
453
+ (0, import_react5.useEffect)(() => {
454
+ let cancelled = false;
455
+ loadHighlighter(language).then((next2) => {
456
+ if (!cancelled) setLoaded({ language, highlighter: next2 });
457
+ }).catch(() => {
458
+ });
459
+ return () => {
460
+ cancelled = true;
461
+ };
462
+ }, [language]);
463
+ const [done, setDone] = (0, import_react5.useState)({ highlighter: null, text: "", lines: [] });
464
+ let next = done;
465
+ if (next.highlighter !== current || !code.startsWith(next.text)) next = { highlighter: current, text: "", lines: [] };
466
+ const end = code.lastIndexOf("\n") + 1;
467
+ if (current && end > next.text.length) {
468
+ const result = current.highlight(code.slice(next.text.length, end - 1), next.state);
469
+ next = { highlighter: current, text: code.slice(0, end), lines: [...next.lines, ...result.lines], state: result.state };
470
+ }
471
+ if (next !== done) setDone(next);
472
+ const tail = code.slice(end);
473
+ return (0, import_react5.useMemo)(() => {
474
+ if (!current) return code.split("\n");
475
+ return [...next.lines, current.highlight(tail, next.state).lines[0]];
476
+ }, [code, current, next, tail]);
477
+ }
478
+ var HighlightedCodeBlock = (0, import_react5.forwardRef)(function HighlightedCodeBlock2({ code, language, ...props }, ref) {
479
+ const lines = useHighlightedCode(code, language);
480
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CodeBlock, { ref, code, lines, language, ...props });
481
+ });
482
+ // Annotate the CommonJS export names for ESM import in node:
483
+ 0 && (module.exports = {
484
+ HighlightedCodeBlock,
485
+ highlightCode,
486
+ loadHighlighter,
487
+ useHighlightedCode
488
+ });
489
+ //# sourceMappingURL=code-block-highlight.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/code-block-highlight.tsx","../src/components/ai/code-block.tsx","../src/lib/cn.ts","../src/components/forms/button.tsx","../src/lib/slot.tsx","../src/components/feedback/spinner.tsx"],"sourcesContent":["/**\n * `@platned/ui/code-block-highlight`: syntax colours for CodeBlock, with Shiki. New in 0.11.\n *\n * Its own entry because `shiki` is an optional peer dependency: an app that shows no highlighted\n * code does not install it. Shiki runs on its JavaScript regex engine (no WASM), and each language\n * loads the first time it is used: bash, css, diff, html, javascript, json, jsx, markdown, python,\n * sql, tsx, typescript, yaml (aliases ts, js, sh, yml, md, py…), plus \"ansi\" for terminal output.\n * Another language renders as plain text.\n */\nimport { forwardRef, useEffect, useMemo, useState, type CSSProperties, type ReactNode } from 'react';\nimport { createHighlighterCore, type GrammarState, type HighlighterCore } from 'shiki/core';\nimport { createJavaScriptRegexEngine } from 'shiki/engine/javascript';\nimport { CodeBlock, type CodeBlockProps } from './components/ai/code-block';\n\nconst languages = {\n bash: () => import('shiki/langs/shellscript.mjs'),\n css: () => import('shiki/langs/css.mjs'),\n diff: () => import('shiki/langs/diff.mjs'),\n html: () => import('shiki/langs/html.mjs'),\n javascript: () => import('shiki/langs/javascript.mjs'),\n json: () => import('shiki/langs/json.mjs'),\n jsx: () => import('shiki/langs/jsx.mjs'),\n markdown: () => import('shiki/langs/markdown.mjs'),\n python: () => import('shiki/langs/python.mjs'),\n sql: () => import('shiki/langs/sql.mjs'),\n tsx: () => import('shiki/langs/tsx.mjs'),\n typescript: () => import('shiki/langs/typescript.mjs'),\n yaml: () => import('shiki/langs/yaml.mjs'),\n};\n\nconst aliases: Record<string, keyof typeof languages> = {\n js: 'javascript',\n md: 'markdown',\n py: 'python',\n sh: 'bash',\n shell: 'bash',\n shellscript: 'bash',\n ts: 'typescript',\n yml: 'yaml',\n zsh: 'bash',\n};\n\nlet highlighter: Promise<HighlighterCore> | undefined;\n\nfunction getHighlighter() {\n highlighter ??= createHighlighterCore({\n themes: [import('shiki/themes/github-light.mjs'), import('shiki/themes/github-dark.mjs')],\n langs: [],\n engine: createJavaScriptRegexEngine({ forgiving: true }),\n });\n return highlighter;\n}\n\nfunction getLanguage(language: string) {\n const name = language.toLowerCase();\n if (name === 'ansi') return name;\n if (name in languages) return name as keyof typeof languages;\n return aliases[name] ?? null;\n}\n\n/** Loads a language and returns a highlighter for it, or null for a language that is not listed. */\nexport async function loadHighlighter(language: string) {\n const lang = getLanguage(language);\n if (!lang) return null;\n const shiki = await getHighlighter();\n if (lang !== 'ansi' && !shiki.getLoadedLanguages().includes(lang)) await shiki.loadLanguage(languages[lang]);\n\n return {\n /** One React node per line, and the grammar state after the last line (pass it back to continue). */\n highlight(code: string, state?: GrammarState) {\n const tokenize = (text: string) =>\n shiki.codeToTokens(text, {\n lang,\n themes: { light: 'github-light', dark: 'github-dark' },\n defaultColor: false,\n grammarState: state,\n }).tokens;\n // ANSI has no grammar state, so each line is tokenized on its own.\n const tokens = lang === 'ansi' ? code.split('\\n').flatMap((line) => tokenize(line)) : tokenize(code);\n return {\n lines: tokens.map((line) =>\n line.map((token, index) => (\n <span key={index} style={token.htmlStyle as CSSProperties} className=\"text-(--shiki-light) dark:text-(--shiki-dark)\">\n {token.content}\n </span>\n )),\n ),\n state: shiki.getLastGrammarState(tokens),\n };\n },\n };\n}\n\n/** One React node per line, or null for a language that is not listed. Works on the server. */\nexport async function highlightCode(code: string, language: string) {\n const loaded = await loadHighlighter(language);\n return loaded ? loaded.highlight(code).lines : null;\n}\n\n/**\n * Highlights `value` in `language` and returns one node per line for `CodeBlockLine`. Plain lines\n * until the language has loaded. While the code streams, only the new lines are tokenized.\n */\nexport function useHighlightedCode(value: string, language: string) {\n // A trailing newline would render as an extra empty line.\n const code = value.endsWith('\\n') ? value.slice(0, -1) : value;\n const [loaded, setLoaded] = useState<{ language: string; highlighter: Awaited<ReturnType<typeof loadHighlighter>> } | null>(null);\n const current = loaded?.language === language ? loaded.highlighter : null;\n\n useEffect(() => {\n let cancelled = false;\n loadHighlighter(language)\n .then((next) => {\n if (!cancelled) setLoaded({ language, highlighter: next });\n })\n .catch(() => {});\n return () => {\n cancelled = true;\n };\n }, [language]);\n\n const [done, setDone] = useState<{\n highlighter: typeof current;\n text: string;\n lines: ReactNode[];\n state?: GrammarState;\n }>({ highlighter: null, text: '', lines: [] });\n\n let next = done;\n if (next.highlighter !== current || !code.startsWith(next.text)) next = { highlighter: current, text: '', lines: [] };\n\n const end = code.lastIndexOf('\\n') + 1;\n if (current && end > next.text.length) {\n const result = current.highlight(code.slice(next.text.length, end - 1), next.state);\n next = { highlighter: current, text: code.slice(0, end), lines: [...next.lines, ...result.lines], state: result.state };\n }\n if (next !== done) setDone(next);\n\n // The last line is still being written, so it is tokenized on every render.\n const tail = code.slice(end);\n return useMemo<ReactNode[]>(() => {\n if (!current) return code.split('\\n');\n return [...next.lines, current.highlight(tail, next.state).lines[0]];\n }, [code, current, next, tail]);\n}\n\nexport interface HighlightedCodeBlockProps extends Omit<CodeBlockProps, 'lines' | 'code' | 'language'> {\n code: string;\n language: string;\n}\n\n/** The CodeBlock shorthand with syntax colours: `<HighlightedCodeBlock code language title copyable />`. */\nexport const HighlightedCodeBlock = forwardRef<HTMLDivElement, HighlightedCodeBlockProps>(function HighlightedCodeBlock(\n { code, language, ...props },\n ref,\n) {\n const lines = useHighlightedCode(code, language);\n return <CodeBlock ref={ref} code={code} lines={lines} language={language} {...props} />;\n});\n","import { forwardRef, useEffect, useState, type ComponentProps, type HTMLAttributes, type ReactNode } from 'react';\nimport { CheckIcon, CopyIcon } from 'lucide-react';\nimport { cn } from '../../lib/cn';\nimport { Button, type ButtonProps } from '../forms/button';\n\n/**\n * CodeBlock: displays code with an optional header, line numbers, diff and highlighted lines.\n *\n * Composition: `CodeBlockHeader` (`CodeBlockTitle`, `CodeBlockActions` with a\n * `CodeBlockCopyButton`), `CodeBlockContent` (a `pre` > `code`; `lineNumbers`, `wrap`,\n * `startLine`) holding `CodeBlockLine`s (`variant` `default` / `added` / `removed` /\n * `highlighted`), and `CodeBlockFooter`. `CodeBlockActions` placed directly in the block floats in\n * the corner and shows on hover or focus.\n *\n * Shorthand: `code` (with `title`, `copyable`, `lineNumbers`, `wrap`, `startLine`,\n * `highlightLines`) renders all of that. Syntax colours come from `@platned/ui/code-block-highlight`\n * (Shiki, an optional peer): pass its lines as `lines`, or use its `HighlightedCodeBlock`.\n */\n\nexport type CodeBlockVariant = 'default' | 'destructive';\nexport type CodeBlockSize = 'default' | 'sm';\nexport type CodeBlockLineVariant = 'default' | 'added' | 'removed' | 'highlighted';\n\nconst VARIANT: Record<CodeBlockVariant, string> = {\n default: 'bg-muted text-foreground ring-1 ring-foreground/5 dark:ring-foreground/10',\n destructive: 'bg-destructive/5 text-destructive ring-1 ring-destructive/15 dark:bg-destructive/10 dark:ring-destructive/20',\n};\n\nconst LINE_VARIANT: Record<CodeBlockLineVariant, string> = {\n default: '',\n highlighted: 'bg-foreground/5',\n added: \"bg-foreground/5 after:content-['+']\",\n removed: \"bg-destructive/10 after:text-destructive after:content-['−']\",\n};\n\nexport interface CodeBlockProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** Default `default`. */\n variant?: CodeBlockVariant;\n /** `sm` has tighter padding and `text-xs` code, for tool output. Default `default`. */\n size?: CodeBlockSize;\n /** Shorthand: the code. Renders the header (with `title` / `copyable`) and the content. */\n code?: string;\n /** Shorthand: one node per line (e.g. from `useHighlightedCode`); defaults to `code` split by line. */\n lines?: readonly ReactNode[];\n /** Shorthand: the header title, e.g. a file name. */\n title?: ReactNode;\n /** Shorthand: a copy button in the header (or floating, without a title). */\n copyable?: boolean;\n /** Shorthand: number the lines. */\n lineNumbers?: boolean;\n /** Shorthand: wrap long lines instead of scrolling. */\n wrap?: boolean;\n /** Shorthand: the first line number. Default 1. */\n startLine?: number;\n /** Shorthand: 1-based line numbers to highlight. */\n highlightLines?: readonly number[];\n /** Shorthand: the language, as a `data-language` attribute (colours come from the highlight entry). */\n language?: string;\n}\n\nexport const CodeBlock = forwardRef<HTMLDivElement, CodeBlockProps>(function CodeBlock(\n {\n variant = 'default',\n size = 'default',\n code,\n lines,\n title,\n copyable = false,\n lineNumbers = false,\n wrap = false,\n startLine = 1,\n highlightLines,\n language,\n className,\n children,\n ...props\n },\n ref,\n) {\n const shorthand = code != null || lines != null;\n const source = code ?? '';\n const rows = lines ?? source.replace(/\\n$/, '').split('\\n');\n const copy = copyable ? <CodeBlockCopyButton value={source} /> : null;\n return (\n <div\n ref={ref}\n data-slot=\"code-block\"\n data-variant={variant}\n data-size={size}\n data-language={language}\n className={cn(\n 'group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-2xl text-sm has-[>[data-slot=code-block-content]:focus-visible]:ring-3 has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/30 data-[size=sm]:rounded-xl data-[size=sm]:text-xs',\n VARIANT[variant],\n className,\n )}\n {...props}\n >\n {shorthand ? (\n <>\n {title != null ? (\n <CodeBlockHeader>\n <CodeBlockTitle>{title}</CodeBlockTitle>\n {copy && <CodeBlockActions>{copy}</CodeBlockActions>}\n </CodeBlockHeader>\n ) : (\n copy && <CodeBlockActions>{copy}</CodeBlockActions>\n )}\n <CodeBlockContent lineNumbers={lineNumbers} wrap={wrap} startLine={startLine}>\n {rows.map((line, index) => (\n <CodeBlockLine key={index} variant={highlightLines?.includes(startLine + index) ? 'highlighted' : 'default'}>\n {line}\n </CodeBlockLine>\n ))}\n </CodeBlockContent>\n {children}\n </>\n ) : (\n children\n )}\n </div>\n );\n});\n\n/** A row above the content for a title and actions. */\nexport function CodeBlockHeader({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n data-slot=\"code-block-header\"\n className={cn(\n 'flex min-w-0 shrink-0 items-center gap-2 px-4 pt-4 text-muted-foreground group-data-[size=sm]/code-block:px-3 group-data-[size=sm]/code-block:pt-3 group-data-[variant=destructive]/code-block:text-destructive *:has-[>[data-slot=code-block-title]]:min-w-0',\n className,\n )}\n {...props}\n />\n );\n}\n\n/** The header title, e.g. a file name. Icons sit inline before the text. */\nexport function CodeBlockTitle({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n data-slot=\"code-block-title\"\n className={cn(\n \"min-w-0 truncate font-sans text-sm font-medium text-foreground group-data-[size=sm]/code-block:text-xs group-data-[variant=destructive]/code-block:text-destructive *:[svg]:me-1.5 [&_svg]:pointer-events-none [&_svg]:inline-block [&_svg]:align-middle [&_svg:not([class*='size-'])]:size-4 group-data-[size=sm]/code-block:[&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/** Buttons for the block. In the header they sit at the end; directly in the block they float. */\nexport function CodeBlockActions({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n data-slot=\"code-block-actions\"\n className={cn(\n '-my-1 -me-1.5 ms-auto flex shrink-0 items-center gap-1 *:data-[slot=button]:hover:bg-foreground/5 dark:*:data-[slot=button]:hover:bg-foreground/10',\n '[[data-slot=code-block]>&]:absolute [[data-slot=code-block]>&]:end-3 [[data-slot=code-block]>&]:top-3 [[data-slot=code-block]>&]:z-10 [[data-slot=code-block]>&]:m-0 [[data-slot=code-block]>&]:opacity-0 [[data-slot=code-block]>&]:transition-opacity [[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100 [[data-slot=code-block]>&]:group-hover/code-block:opacity-100 [[data-slot=code-block]>&]:pointer-coarse:opacity-100 [[data-slot=code-block]>&]:*:[button]:bg-background [[data-slot=code-block]>&]:*:[button]:ring-1 [[data-slot=code-block]>&]:*:[button]:ring-foreground/10 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-2 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-2',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport interface CodeBlockCopyButtonProps extends ButtonProps {\n /** The text to copy. */\n value: string;\n}\n\n/** Copies `value`; shows a check for two seconds and announces \"Copied\". */\nexport function CodeBlockCopyButton({ value, variant = 'ghost', size = 'icon-xs', className, onClick, ...props }: CodeBlockCopyButtonProps) {\n const [copied, setCopied] = useState(false);\n useEffect(() => {\n if (!copied) return;\n const timeout = setTimeout(() => setCopied(false), 2000);\n return () => clearTimeout(timeout);\n }, [copied]);\n\n return (\n <>\n <Button\n data-slot=\"code-block-copy-button\"\n data-copied={copied || undefined}\n variant={variant}\n size={size}\n aria-label={copied ? 'Copied' : 'Copy'}\n className={cn('hover:bg-foreground/5 dark:hover:bg-foreground/10', className)}\n onClick={(event) => {\n onClick?.(event);\n navigator.clipboard\n ?.writeText(value)\n .then(() => setCopied(true))\n .catch(() => {});\n }}\n {...props}\n >\n {copied ? <CheckIcon /> : <CopyIcon />}\n </Button>\n <span aria-live=\"polite\" className=\"sr-only\">\n {copied ? 'Copied' : ''}\n </span>\n </>\n );\n}\n\nexport interface CodeBlockContentProps extends ComponentProps<'pre'> {\n /** Wrap long lines instead of scrolling. */\n wrap?: boolean;\n /** Number the lines (CodeBlockLine children, or a string split into lines). */\n lineNumbers?: boolean;\n /** The first line number. Default 1. */\n startLine?: number;\n}\n\n/** The scrolling `pre` > `code`. Always left to right; focusable so the keyboard can scroll it. */\nexport function CodeBlockContent({ className, children, style, wrap = false, lineNumbers = false, startLine = 1, ...props }: CodeBlockContentProps) {\n return (\n <pre\n data-slot=\"code-block-content\"\n data-wrap={wrap || undefined}\n data-numbered={lineNumbers || undefined}\n dir=\"ltr\"\n // A scroll container: keyboard users focus it to scroll long code (WCAG 2.1.1). Pass\n // tabIndex={-1} to drop the tab stop.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n style={{ counterReset: `line ${startLine - 1}`, ...style }}\n className={cn(\n 'min-h-0 min-w-0 overflow-auto px-4 py-4 text-start font-mono leading-relaxed outline-none scrollbar-thin scroll-fade-x group-has-data-[slot=code-block-footer]/code-block:pb-2 group-has-data-[slot=code-block-header]/code-block:pt-2 group-data-[size=sm]/code-block:px-3 group-data-[size=sm]/code-block:py-3 group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5 data-wrap:scroll-fade-y data-wrap:whitespace-pre-wrap data-wrap:wrap-break-word',\n className,\n )}\n {...props}\n >\n <code\n data-slot=\"code-block-code\"\n className=\"grid min-h-lh min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0\"\n >\n {lineNumbers && typeof children === 'string'\n ? children\n .replace(/\\n$/, '')\n .split('\\n')\n .map((line, index) => <CodeBlockLine key={index}>{line}</CodeBlockLine>)\n : children}\n </code>\n </pre>\n );\n}\n\nexport interface CodeBlockLineProps extends HTMLAttributes<HTMLSpanElement> {\n /** Default `default`. `added` / `removed` also carry a `+` / `−` marker. */\n variant?: CodeBlockLineVariant;\n}\n\n/** One line. Numbered by CSS when the content has `lineNumbers`; the number is hidden from readers. */\nexport function CodeBlockLine({ className, variant = 'default', children, ...props }: CodeBlockLineProps) {\n // An empty line holds a newline so copying a selection keeps blank lines.\n const empty = children === undefined || children === null || children === '' || (Array.isArray(children) && children.length === 0);\n return (\n <span\n data-slot=\"code-block-line\"\n data-variant={variant}\n className={cn(\n \"relative -mx-4 block min-h-lh px-4 group-data-[size=sm]/code-block:-mx-3 group-data-[size=sm]/code-block:px-3 before:min-w-6 before:text-end before:text-muted-foreground after:absolute after:start-1 after:top-0 after:text-muted-foreground after:select-none in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3 in-data-numbered:[counter-increment:line] in-data-numbered:before:content-[counter(line)] in-data-numbered:before:select-none in-data-numbered:supports-[content:counter(line)_/_'']:before:content-[counter(line)_/_'']\",\n LINE_VARIANT[variant],\n className,\n )}\n {...props}\n >\n <span data-slot=\"code-block-line-content\" className=\"min-w-0\">\n {empty ? '\\n' : children}\n </span>\n </span>\n );\n}\n\n/** A row under the content, e.g. a language label or a Show more button. */\nexport function CodeBlockFooter({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n data-slot=\"code-block-footer\"\n className={cn('flex min-w-0 shrink-0 items-center gap-2 px-4 pb-4 text-muted-foreground group-data-[size=sm]/code-block:px-3 group-data-[size=sm]/code-block:pb-3', className)}\n {...props}\n />\n );\n}\n","import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/**\n * `clsx` + `tailwind-merge`.\n *\n * The type scale is Tailwind's stock one (0.11), so `tailwind-merge` recognises every size as a\n * size. Until 0.11 the preset had word-named sizes (`text-body-sm`), which twMerge filed under\n * colour and dropped when a colour followed; the build now rejects any custom `fontSize` key\n * in the preset so that cannot come back.\n *\n * Use this instead of bare `clsx` in any component whose `className` prop is meant to\n * *override* a base utility — the composable `Card*` and `Dialog*` parts, and anything\n * else built to be reshaped by its caller.\n *\n * Why it is necessary: `clsx` only concatenates. When two conflicting Tailwind\n * utilities both end up in the attribute, the winner is decided by *stylesheet order*,\n * not attribute order. Tailwind emits `flex-row` before `flex-col` and `gap-3` before\n * `gap-4`, so under plain `clsx`:\n *\n * <Part className=\"flex-row gap-3\" /> // base is 'flex flex-col gap-4'\n *\n * silently stays a column with a 4-unit gap. `twMerge` drops the losing class instead,\n * so the caller's intent wins.\n *\n * Everywhere else in the library `className` is purely additive, and plain `clsx`\n * remains correct — and cheaper. Do not sweep it out of those files.\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import {\n cloneElement,\n forwardRef,\n isValidElement,\n type ButtonHTMLAttributes,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { cn } from '../../lib/cn';\nimport { Slot } from '../../lib/slot';\nimport { Spinner } from '../feedback/spinner';\n\n/**\n * Button: displays a button or a component that looks like a button.\n *\n * Variants `default`, `outline`, `secondary`, `ghost`, `destructive`, `link`; sizes `xs` (24px),\n * `sm` (28px), `default` (32px), `lg` (36px), and the square `icon-xs`, `icon-sm`, `icon`,\n * `icon-lg` for icon-only buttons (name them with `aria-label`). Icons are children with\n * `data-icon=\"inline-start\"` / `\"inline-end\"`, which tighten the padding on that side.\n *\n * Shorthand: `leadingIcon` / `trailingIcon` render the same as those icon children, and\n * `loading` swaps the leading icon for a spinner, sets `aria-busy` and ignores presses while\n * keeping focus (`aria-disabled`, not `disabled`).\n */\n\nexport type ButtonVariant = 'default' | 'outline' | 'secondary' | 'ghost' | 'destructive' | 'link';\nexport type ButtonSize = 'default' | 'xs' | 'sm' | 'lg' | 'icon' | 'icon-xs' | 'icon-sm' | 'icon-lg';\n\nexport interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /** Default `default`. */\n variant?: ButtonVariant;\n /** Default `default`. */\n size?: ButtonSize;\n /** Render the single child element instead of a `<button>`, e.g. a router `Link`. */\n asChild?: boolean;\n /** Shorthand: a leading icon (as `data-icon=\"inline-start\"`). */\n leadingIcon?: ReactNode;\n /** Shorthand: a trailing icon (as `data-icon=\"inline-end\"`). */\n trailingIcon?: ReactNode;\n /**\n * A request is in flight: a spinner replaces the leading icon, `aria-busy` is set, and\n * presses are ignored. The button keeps focus (`aria-disabled`, not `disabled`).\n */\n loading?: boolean;\n /** Announced while `loading`. Default: the button's own content. */\n loadingLabel?: string;\n}\n\nconst BASE =\n \"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\";\n\nconst VARIANT: Record<ButtonVariant, string> = {\n default: 'bg-primary text-primary-foreground hover:bg-primary/80',\n outline:\n 'border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50',\n secondary:\n 'bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground',\n ghost:\n 'hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50',\n destructive:\n 'bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40',\n link: 'text-primary underline-offset-4 hover:underline',\n};\n\nconst SIZE: Record<ButtonSize, string> = {\n default: 'h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2',\n xs: \"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3\",\n sm: \"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5\",\n lg: 'h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2',\n icon: 'size-8',\n 'icon-xs':\n \"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3\",\n 'icon-sm': 'size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg',\n 'icon-lg': 'size-9',\n};\n\n/** The classes of a Button, for an element another library renders (e.g. Calendar's nav). */\nexport function buttonVariants({\n variant = 'default',\n size = 'default',\n}: { variant?: ButtonVariant; size?: ButtonSize } = {}) {\n return cn(BASE, VARIANT[variant], SIZE[size]);\n}\n\n/** An icon shorthand, rendered exactly as an icon child with `data-icon`. */\nfunction withDataIcon(icon: ReactNode, side: 'inline-start' | 'inline-end') {\n if (isValidElement(icon)) {\n return cloneElement(icon as ReactElement<Record<string, unknown>>, { 'data-icon': side, 'aria-hidden': true });\n }\n return (\n <span data-icon={side} aria-hidden className=\"inline-flex shrink-0\">\n {icon}\n </span>\n );\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = 'default',\n size = 'default',\n asChild = false,\n leadingIcon,\n trailingIcon,\n loading = false,\n loadingLabel,\n disabled,\n type,\n children,\n className,\n onClick,\n ...props\n },\n ref,\n) {\n // Inert to a press but still focusable: a loading button, or any disabled `asChild`\n // element (an `<a>` has no `disabled` attribute to fall back on).\n const softDisabled = loading || (asChild && Boolean(disabled));\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n if (softDisabled) {\n // Stops a router `<Link>` too: it skips navigation when the event is prevented.\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n onClick?.(event);\n };\n\n const small = size === 'xs' || size === 'icon-xs';\n const decorate = (content: ReactNode) => (\n <>\n {loading ? (\n <Spinner\n data-icon=\"inline-start\"\n className={small ? 'size-3' : undefined}\n // Named by loadingLabel; otherwise the busy button announces its own content.\n {...(loadingLabel\n ? { 'aria-label': loadingLabel }\n : { role: undefined, 'aria-label': undefined, 'aria-hidden': true })}\n />\n ) : leadingIcon !== undefined && leadingIcon !== null ? (\n withDataIcon(leadingIcon, 'inline-start')\n ) : null}\n {content}\n {trailingIcon !== undefined && trailingIcon !== null ? withDataIcon(trailingIcon, 'inline-end') : null}\n </>\n );\n\n const rootProps = {\n className: cn(BASE, VARIANT[variant], SIZE[size], className),\n 'data-slot': 'button',\n 'data-variant': variant,\n 'data-size': size,\n 'aria-busy': loading || undefined,\n 'aria-disabled': softDisabled || undefined,\n onClick: handleClick,\n ...props,\n };\n\n if (asChild) {\n // `aria-disabled`, not `disabled`: the child may be an `<a>`, which has no disabled\n // attribute. A disabled link also leaves the tab order, as a disabled `<button>` does.\n return (\n <Slot ref={ref} wrapChildren={decorate} tabIndex={disabled ? -1 : undefined} {...rootProps}>\n {children}\n </Slot>\n );\n }\n\n return (\n <button ref={ref} type={type ?? 'button'} disabled={disabled} {...rootProps}>\n {decorate(children)}\n </button>\n );\n});\n","import {\n cloneElement,\n forwardRef,\n isValidElement,\n type CSSProperties,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react';\nimport clsx from 'clsx';\n\n/**\n * `Slot` renders its own props onto its single child element instead of emitting a\n * wrapper of its own. It is what makes `asChild` work.\n *\n * Why the library needs it: before 0.4.0 there was no way to render a `Button` as a\n * router `<Link>`, or to use any component as a tooltip/popover anchor, because every\n * component hardcoded its host element. The usual workaround — a `component`/`as` prop —\n * multiplies generics across the whole surface and still cannot forward a ref through\n * two levels. Delegating to the child instead keeps the type surface flat.\n *\n * <Button asChild><Link to=\"/x\">Go</Link></Button>\n *\n * Merge rules, in order of who wins:\n * - `className` — concatenated, slot first, so the child's classes come last\n * - `style` — shallow-merged, child wins on conflicting keys\n * - `on*` — both run, slot's handler first; the child's runs even if the slot's\n * called `preventDefault`, matching normal DOM listener behaviour\n * - everything else — child wins, so a child's explicit `type` or `role` is never\n * clobbered by a default the slot happens to carry\n */\nexport interface SlotProps extends HTMLAttributes<HTMLElement> {\n /** The single element to merge into. */\n children?: ReactNode;\n /**\n * Rebuilds the child's children, so a component that decorates its content can keep\n * doing so through `asChild`.\n *\n * `Button` renders `leadingIcon`, a padded label span and `trailingIcon` around whatever\n * it is given. Without this, `<Button asChild><Link>Go</Link></Button>` would either drop\n * the icons (cloning the Link untouched) or drop \"Go\" (replacing the Link's children\n * outright). It receives the child's own children — \"Go\" — and returns the decorated\n * tree to place inside the child.\n */\n wrapChildren?: (childChildren: ReactNode) => ReactNode;\n}\n\nexport const Slot = forwardRef<HTMLElement, SlotProps>(function Slot(\n { children, wrapChildren, ...slotProps },\n forwardedRef,\n) {\n // A bare string, an array, or nothing at all — there is no element to merge into.\n // Rendering the children plain would silently drop every prop the slot carries\n // (including the ref and the ARIA wiring a trigger depends on), so this renders\n // nothing rather than something subtly broken.\n if (!isValidElement(children)) return null;\n\n const child = children as ReactElement<{ children?: ReactNode }>;\n\n const merged = {\n ...mergeProps(slotProps, child.props as Record<string, unknown>),\n ref: composeRefs(forwardedRef, getElementRef(child)),\n } as Record<string, unknown>;\n\n return wrapChildren\n ? cloneElement(child, merged, wrapChildren(child.props.children))\n : cloneElement(child, merged);\n});\n\nfunction mergeProps(\n slotProps: Record<string, unknown>,\n childProps: Record<string, unknown>,\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...slotProps };\n\n for (const key in childProps) {\n const slotValue = slotProps[key];\n const childValue = childProps[key];\n\n if (/^on[A-Z]/.test(key)) {\n // Both handlers run. The slot's fires first so a component can set up state\n // before the consumer's own handler observes it.\n if (typeof slotValue === 'function' && typeof childValue === 'function') {\n merged[key] = (...args: unknown[]) => {\n (slotValue as (...a: unknown[]) => void)(...args);\n (childValue as (...a: unknown[]) => void)(...args);\n };\n } else {\n merged[key] = childValue ?? slotValue;\n }\n } else if (key === 'className') {\n merged[key] = clsx(slotValue as string, childValue as string);\n } else if (key === 'style') {\n merged[key] = { ...(slotValue as CSSProperties), ...(childValue as CSSProperties) };\n } else {\n merged[key] = childValue;\n }\n }\n\n return merged;\n}\n\n/**\n * React 19 exposes a `ref` on `props`; React 18 kept it on the element. The peer range is\n * `>=19` from 0.11; the element fallback stays for elements created by older copies of React.\n */\nfunction getElementRef(element: ReactElement): Ref<unknown> | undefined {\n const asRecord = element as unknown as {\n ref?: Ref<unknown>;\n props?: { ref?: Ref<unknown> };\n };\n return asRecord.props?.ref ?? asRecord.ref;\n}\n\n/** Fan one node out to several refs, callback or object. */\nexport function composeRefs<T>(...refs: (Ref<T> | undefined)[]) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (!ref) continue;\n if (typeof ref === 'function') {\n ref(node);\n } else {\n (ref as { current: T | null }).current = node;\n }\n }\n };\n}\n","import { forwardRef, type SVGProps } from 'react';\nimport { Loader2Icon } from 'lucide-react';\n\nimport { cn } from '../../lib/cn';\n\nexport type SpinnerProps = SVGProps<SVGSVGElement>;\n\n/**\n * Spinner: an indicator that can be used to show a loading state. `Progress` is the determinate\n * counterpart.\n *\n * A spinning `role=\"status\"` icon named \"Loading\" (pass `aria-label` for another name). Size it\n * with `className` (`size-6`); it takes the text colour.\n */\nexport const Spinner = forwardRef<SVGSVGElement, SpinnerProps>(function Spinner({ className, ...props }, ref) {\n return (\n <Loader2Icon\n ref={ref}\n data-slot=\"spinner\"\n role=\"status\"\n aria-label=\"Loading\"\n className={cn('size-4 animate-spin', className)}\n {...props}\n />\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAAA,gBAA6F;AAC7F,kBAA+E;AAC/E,wBAA4C;;;ACX5C,IAAAC,gBAA0G;AAC1G,IAAAC,uBAAoC;;;ACDpC,kBAAsC;AACtC,4BAAwB;AA2BjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;AC9BC,IAAAC,gBAQM;;;ACRP,mBASO;AACP,IAAAC,eAAiB;AAsCV,IAAM,WAAO,yBAAmC,SAASC,MAC9D,EAAE,UAAU,cAAc,GAAG,UAAU,GACvC,cACA;AAKA,MAAI,KAAC,6BAAe,QAAQ,EAAG,QAAO;AAEtC,QAAM,QAAQ;AAEd,QAAM,SAAS;AAAA,IACb,GAAG,WAAW,WAAW,MAAM,KAAgC;AAAA,IAC/D,KAAK,YAAY,cAAc,cAAc,KAAK,CAAC;AAAA,EACrD;AAEA,SAAO,mBACH,2BAAa,OAAO,QAAQ,aAAa,MAAM,MAAM,QAAQ,CAAC,QAC9D,2BAAa,OAAO,MAAM;AAChC,CAAC;AAED,SAAS,WACP,WACA,YACyB;AACzB,QAAM,SAAk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,QAAM,OAAO,KAAK,MAAM,GAAG;AAC3B,aAAO,uBAAqB,MAAM;AAChC,QAAI,CAAC,QAAS,QAAO,KAAK,MAAM,IAAI;AACpC,WAAO,CAAC,GAAG,KAAK,OAAO,QAAQ,UAAU,MAAM,KAAK,KAAK,EAAE,MAAM,CAAC,CAAC;AAAA,EACrE,GAAG,CAAC,MAAM,SAAS,MAAM,IAAI,CAAC;AAChC;AAQO,IAAM,2BAAuB,0BAAsD,SAASC,sBACjG,EAAE,MAAM,UAAU,GAAG,MAAM,GAC3B,KACA;AACA,QAAM,QAAQ,mBAAmB,MAAM,QAAQ;AAC/C,SAAO,6CAAC,aAAU,KAAU,MAAY,OAAc,UAAqB,GAAG,OAAO;AACvF,CAAC;","names":["import_react","import_react","import_lucide_react","import_react","import_clsx","Slot","clsx","import_react","Spinner","import_jsx_runtime","Button","import_jsx_runtime","VARIANT","CodeBlock","import_jsx_runtime","next","HighlightedCodeBlock"]}
@@ -0,0 +1,28 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { GrammarState } from 'shiki/core';
4
+ import { C as CodeBlockProps } from './code-block-BgEiLXpO.js';
5
+
6
+ /** Loads a language and returns a highlighter for it, or null for a language that is not listed. */
7
+ declare function loadHighlighter(language: string): Promise<{
8
+ /** One React node per line, and the grammar state after the last line (pass it back to continue). */
9
+ highlight(code: string, state?: GrammarState): {
10
+ lines: react.JSX.Element[][];
11
+ state: GrammarState | undefined;
12
+ };
13
+ } | null>;
14
+ /** One React node per line, or null for a language that is not listed. Works on the server. */
15
+ declare function highlightCode(code: string, language: string): Promise<react.JSX.Element[][] | null>;
16
+ /**
17
+ * Highlights `value` in `language` and returns one node per line for `CodeBlockLine`. Plain lines
18
+ * until the language has loaded. While the code streams, only the new lines are tokenized.
19
+ */
20
+ declare function useHighlightedCode(value: string, language: string): ReactNode[];
21
+ interface HighlightedCodeBlockProps extends Omit<CodeBlockProps, 'lines' | 'code' | 'language'> {
22
+ code: string;
23
+ language: string;
24
+ }
25
+ /** The CodeBlock shorthand with syntax colours: `<HighlightedCodeBlock code language title copyable />`. */
26
+ declare const HighlightedCodeBlock: react.ForwardRefExoticComponent<HighlightedCodeBlockProps & react.RefAttributes<HTMLDivElement>>;
27
+
28
+ export { HighlightedCodeBlock, type HighlightedCodeBlockProps, highlightCode, loadHighlighter, useHighlightedCode };