@ngrok/mantle 0.24.1 → 0.25.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.
- package/dist/code-block.d.ts +223 -30
- package/dist/code-block.js +3 -3
- package/dist/code-block.js.map +1 -1
- package/package.json +11 -11
package/dist/code-block.d.ts
CHANGED
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { HTMLAttributes, ComponentProps, ReactNode } from 'react';
|
|
4
|
+
import { W as WithAsChild } from './as-child-DJ7x3JFV.js';
|
|
4
5
|
import { S as SvgAttributes } from './types-BuKAGhC-.js';
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* List of supported languages for syntax highlighting.
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
declare const supportedLanguages: readonly ["bash", "cs", "csharp", "css", "dotnet", "go", "html", "java", "javascript", "js", "json", "jsx", "markup", "plain", "plaintext", "py", "python", "rb", "ruby", "rust", "sh", "shell", "text", "ts", "tsx", "txt", "typescript", "xml", "yaml", "yml"];
|
|
13
|
+
/**
|
|
14
|
+
* Supported languages for syntax highlighting.
|
|
15
|
+
*/
|
|
16
|
+
type SupportedLanguage = (typeof supportedLanguages)[number];
|
|
17
|
+
/**
|
|
18
|
+
* Parses a markdown code block (```) language class into a SupportedLanguage.
|
|
19
|
+
* Defaults to "sh" if no supported language is found.
|
|
20
|
+
*/
|
|
21
|
+
declare function parseLanguage(value: `language-${string}` | `lang-${string}` | (string & {}) | undefined): SupportedLanguage;
|
|
22
|
+
/**
|
|
23
|
+
* Type Predicate: checks if an arbitrary value is a supported syntax highlighting language.
|
|
24
|
+
*/
|
|
25
|
+
declare const isSupportedLanguage: (value: unknown) => value is SupportedLanguage;
|
|
26
|
+
/**
|
|
27
|
+
* Formats a language name into a class name that Prism.js can understand.
|
|
28
|
+
* @default "language-sh"
|
|
29
|
+
*/
|
|
30
|
+
declare function formatLanguageClassName(language?: SupportedLanguage | undefined): "language-html" | "language-ruby" | "language-text" | "language-plaintext" | "language-bash" | "language-cs" | "language-csharp" | "language-css" | "language-dotnet" | "language-go" | "language-java" | "language-javascript" | "language-js" | "language-json" | "language-jsx" | "language-markup" | "language-plain" | "language-py" | "language-python" | "language-rb" | "language-rust" | "language-sh" | "language-shell" | "language-ts" | "language-tsx" | "language-txt" | "language-typescript" | "language-xml" | "language-yaml" | "language-yml";
|
|
31
|
+
|
|
32
|
+
declare const indentations: readonly ["tabs", "spaces"];
|
|
33
|
+
type Indentation = (typeof indentations)[number];
|
|
34
|
+
|
|
7
35
|
/**
|
|
8
36
|
* A line range is a string in the format of `start-end` where `start` and `end` are line numbers.
|
|
9
37
|
*/
|
|
@@ -16,14 +44,17 @@ declare const metaSchema: z.ZodObject<{
|
|
|
16
44
|
disableCopy: z.ZodDefault<z.ZodBoolean>;
|
|
17
45
|
mode: z.ZodOptional<z.ZodEnum<["cli", "file", "traffic-policy"]>>;
|
|
18
46
|
title: z.ZodOptional<z.ZodString>;
|
|
47
|
+
indentation: z.ZodOptional<z.ZodEnum<["tabs", "spaces"]>>;
|
|
19
48
|
}, "strip", z.ZodTypeAny, {
|
|
20
49
|
collapsible: boolean;
|
|
21
50
|
disableCopy: boolean;
|
|
22
51
|
title?: string | undefined;
|
|
23
52
|
mode?: "cli" | "file" | "traffic-policy" | undefined;
|
|
53
|
+
indentation?: "spaces" | "tabs" | undefined;
|
|
24
54
|
}, {
|
|
25
55
|
title?: string | undefined;
|
|
26
56
|
mode?: "cli" | "file" | "traffic-policy" | undefined;
|
|
57
|
+
indentation?: "spaces" | "tabs" | undefined;
|
|
27
58
|
collapsible?: boolean | undefined;
|
|
28
59
|
disableCopy?: boolean | undefined;
|
|
29
60
|
}>;
|
|
@@ -34,6 +65,7 @@ declare const defaultMeta: {
|
|
|
34
65
|
readonly disableCopy: false;
|
|
35
66
|
readonly mode: undefined;
|
|
36
67
|
readonly title: undefined;
|
|
68
|
+
readonly indentation: undefined;
|
|
37
69
|
};
|
|
38
70
|
type DefaultMeta = typeof defaultMeta;
|
|
39
71
|
/**
|
|
@@ -45,31 +77,49 @@ type DefaultMeta = typeof defaultMeta;
|
|
|
45
77
|
declare function parseMetastring(value: string | undefined): Meta;
|
|
46
78
|
|
|
47
79
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
*
|
|
80
|
+
* Code blocks render and apply syntax highlighting to blocks of code.
|
|
81
|
+
* This is the root component for all code block components.
|
|
82
|
+
*
|
|
83
|
+
* @see https://mantle.ngrok.com/components/code-block#api-code-block
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* <CodeBlock>
|
|
88
|
+
* <CodeBlockHeader>
|
|
89
|
+
* <CodeBlockIcon preset="file" />
|
|
90
|
+
* <CodeBlockTitle>…</CodeBlockTitle>
|
|
91
|
+
* </CodeBlockHeader>
|
|
92
|
+
* <CodeBlockBody>
|
|
93
|
+
* <CodeBlockCopyButton />
|
|
94
|
+
* <CodeBlockCode language="…" value={fmtCode\`…\`} />
|
|
95
|
+
* </CodeBlockBody>
|
|
96
|
+
* <CodeBlockExpanderButton />
|
|
97
|
+
* </CodeBlock>
|
|
98
|
+
* ```
|
|
59
99
|
*/
|
|
60
|
-
declare
|
|
100
|
+
declare const CodeBlock: react.ForwardRefExoticComponent<Omit<react.ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & WithAsChild, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
61
101
|
/**
|
|
62
|
-
*
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*
|
|
67
|
-
* @
|
|
102
|
+
* The body of the `CodeBlock`. This is where the `CodeBlockCode` and optional
|
|
103
|
+
* `CodeBlockCopyButton` is rendered.
|
|
104
|
+
*
|
|
105
|
+
* @see https://mantle.ngrok.com/components/code-block#api-code-block-body
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```tsx
|
|
109
|
+
* <CodeBlock>
|
|
110
|
+
* <CodeBlockHeader>
|
|
111
|
+
* <CodeBlockIcon preset="file" />
|
|
112
|
+
* <CodeBlockTitle>…</CodeBlockTitle>
|
|
113
|
+
* </CodeBlockHeader>
|
|
114
|
+
* <CodeBlockBody>
|
|
115
|
+
* <CodeBlockCopyButton />
|
|
116
|
+
* <CodeBlockCode language="…" value={fmtCode\`…\`} />
|
|
117
|
+
* </CodeBlockBody>
|
|
118
|
+
* <CodeBlockExpanderButton />
|
|
119
|
+
* </CodeBlock>
|
|
120
|
+
* ```
|
|
68
121
|
*/
|
|
69
|
-
declare
|
|
70
|
-
|
|
71
|
-
declare const CodeBlock: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
72
|
-
declare const CodeBlockBody: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & react.RefAttributes<HTMLDivElement>>;
|
|
122
|
+
declare const CodeBlockBody: react.ForwardRefExoticComponent<Omit<react.ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & WithAsChild, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
73
123
|
type CodeBlockCodeProps = Omit<ComponentProps<"pre">, "children"> & {
|
|
74
124
|
/**
|
|
75
125
|
* The code to display in the code block. Should be code formatted as a string. This code will be passed to our syntax highlighter.
|
|
@@ -80,7 +130,13 @@ type CodeBlockCodeProps = Omit<ComponentProps<"pre">, "children"> & {
|
|
|
80
130
|
*/
|
|
81
131
|
highlightLines?: (LineRange | number)[];
|
|
82
132
|
/**
|
|
83
|
-
* The
|
|
133
|
+
* The type of indentation to use. Can be either "tabs" or "spaces".
|
|
134
|
+
* @default inferred from the given language, fallback to `spaces`
|
|
135
|
+
*/
|
|
136
|
+
indentation?: Indentation;
|
|
137
|
+
/**
|
|
138
|
+
* The language of the code block. This will be used to determine how to syntax highlight the code.
|
|
139
|
+
* @default `"text"`.
|
|
84
140
|
*/
|
|
85
141
|
language?: SupportedLanguage;
|
|
86
142
|
/**
|
|
@@ -88,12 +144,77 @@ type CodeBlockCodeProps = Omit<ComponentProps<"pre">, "children"> & {
|
|
|
88
144
|
*/
|
|
89
145
|
showLineNumbers?: boolean;
|
|
90
146
|
};
|
|
147
|
+
/**
|
|
148
|
+
* The `CodeBlock` content. This is where the code is rendered and syntax highlighted.
|
|
149
|
+
*
|
|
150
|
+
* @see https://mantle.ngrok.com/components/code-block#api-code-block-code
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```tsx
|
|
154
|
+
* <CodeBlock>
|
|
155
|
+
* <CodeBlockHeader>
|
|
156
|
+
* <CodeBlockIcon preset="file" />
|
|
157
|
+
* <CodeBlockTitle>…</CodeBlockTitle>
|
|
158
|
+
* </CodeBlockHeader>
|
|
159
|
+
* <CodeBlockBody>
|
|
160
|
+
* <CodeBlockCopyButton />
|
|
161
|
+
* <CodeBlockCode
|
|
162
|
+
* language="sh"
|
|
163
|
+
* value={fmtCode`ffmpeg -i multichannel.mxf -map 0:v:0 -map 0:a:0 -map 0:a:0 -c:a:0 ac3 -b:a:0 640k -ac:a:1 2 -c:a:1 aac -b:2 128k out.mp4`}
|
|
164
|
+
* />
|
|
165
|
+
* </CodeBlockBody>
|
|
166
|
+
* <CodeBlockExpanderButton />
|
|
167
|
+
* </CodeBlock>
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
91
170
|
declare const CodeBlockCode: react.ForwardRefExoticComponent<Omit<CodeBlockCodeProps, "ref"> & react.RefAttributes<HTMLPreElement>>;
|
|
92
|
-
|
|
171
|
+
/**
|
|
172
|
+
* The (optional) header slot of the `CodeBlock`. This is where things like the
|
|
173
|
+
* `CodeBlockIcon` and `CodeBlockTitle` are rendered.
|
|
174
|
+
*
|
|
175
|
+
* @see https://mantle.ngrok.com/components/code-block#api-code-block-header
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```tsx
|
|
179
|
+
* <CodeBlock>
|
|
180
|
+
* <CodeBlockHeader>
|
|
181
|
+
* <CodeBlockIcon preset="file" />
|
|
182
|
+
* <CodeBlockTitle>…</CodeBlockTitle>
|
|
183
|
+
* </CodeBlockHeader>
|
|
184
|
+
* <CodeBlockBody>
|
|
185
|
+
* <CodeBlockCopyButton />
|
|
186
|
+
* <CodeBlockCode language="…" value={fmtCode\`…\`} />
|
|
187
|
+
* </CodeBlockBody>
|
|
188
|
+
* <CodeBlockExpanderButton />
|
|
189
|
+
* </CodeBlock>
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
declare const CodeBlockHeader: react.ForwardRefExoticComponent<Omit<react.ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & WithAsChild, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
193
|
+
/**
|
|
194
|
+
* The (optional) title of the `CodeBlock`. Default renders as an h3 element,
|
|
195
|
+
* use asChild to render something else.
|
|
196
|
+
*
|
|
197
|
+
* @see https://mantle.ngrok.com/components/code-block#api-code-block-title
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```tsx
|
|
201
|
+
* <CodeBlock>
|
|
202
|
+
* <CodeBlockHeader>
|
|
203
|
+
* <CodeBlockIcon preset="file" />
|
|
204
|
+
* <CodeBlockTitle>…</CodeBlockTitle>
|
|
205
|
+
* </CodeBlockHeader>
|
|
206
|
+
* <CodeBlockBody>
|
|
207
|
+
* <CodeBlockCopyButton />
|
|
208
|
+
* <CodeBlockCode language="…" value={fmtCode\`…\`} />
|
|
209
|
+
* </CodeBlockBody>
|
|
210
|
+
* <CodeBlockExpanderButton />
|
|
211
|
+
* </CodeBlock>
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
93
214
|
declare const CodeBlockTitle: react.ForwardRefExoticComponent<HTMLAttributes<HTMLHeadingElement> & {
|
|
94
215
|
asChild?: boolean;
|
|
95
216
|
} & react.RefAttributes<HTMLHeadingElement>>;
|
|
96
|
-
type CodeBlockCopyButtonProps = Omit<ComponentProps<"button">, "children" | "type"> & {
|
|
217
|
+
type CodeBlockCopyButtonProps = Omit<ComponentProps<"button">, "children" | "type"> & WithAsChild & {
|
|
97
218
|
/**
|
|
98
219
|
* Callback fired when the copy button is clicked, passes the copied text as an argument.
|
|
99
220
|
*/
|
|
@@ -103,9 +224,56 @@ type CodeBlockCopyButtonProps = Omit<ComponentProps<"button">, "children" | "typ
|
|
|
103
224
|
*/
|
|
104
225
|
onCopyError?: (error: unknown) => void;
|
|
105
226
|
};
|
|
227
|
+
/**
|
|
228
|
+
* The (optional) copy button of the `CodeBlock`. Render this as a child of the
|
|
229
|
+
* `CodeBlockBody` to allow users to copy the code block contents to their
|
|
230
|
+
* clipboard.
|
|
231
|
+
*
|
|
232
|
+
* @see https://mantle.ngrok.com/components/code-block#api-code-block-copy-button
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```tsx
|
|
236
|
+
* <CodeBlock>
|
|
237
|
+
* <CodeBlockHeader>
|
|
238
|
+
* <CodeBlockIcon preset="file" />
|
|
239
|
+
* <CodeBlockTitle>…</CodeBlockTitle>
|
|
240
|
+
* </CodeBlockHeader>
|
|
241
|
+
* <CodeBlockBody>
|
|
242
|
+
* <CodeBlockCopyButton />
|
|
243
|
+
* <CodeBlockCode language="…" value={fmtCode\`…\`} />
|
|
244
|
+
* </CodeBlockBody>
|
|
245
|
+
* <CodeBlockExpanderButton />
|
|
246
|
+
* </CodeBlock>
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
106
249
|
declare const CodeBlockCopyButton: react.ForwardRefExoticComponent<Omit<CodeBlockCopyButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
107
|
-
type CodeBlockExpanderButtonProps = Omit<
|
|
108
|
-
|
|
250
|
+
type CodeBlockExpanderButtonProps = Omit<ComponentProps<"button">, "children" | "aria-controls" | "aria-expanded"> & WithAsChild;
|
|
251
|
+
/**
|
|
252
|
+
* The (optional) expander button of the `CodeBlock`. Render this as a child of the
|
|
253
|
+
* `CodeBlockBody` to allow users to expand/collapse the code block contents.
|
|
254
|
+
*
|
|
255
|
+
* @note If this component is preset, the `CodeBlock` will automatically know
|
|
256
|
+
* that it should be collapsible. Don't use this component if you don't want
|
|
257
|
+
* the code block to be collapsible.
|
|
258
|
+
*
|
|
259
|
+
* @see https://mantle.ngrok.com/components/code-block#api-code-block-expander-button
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```tsx
|
|
263
|
+
* <CodeBlock>
|
|
264
|
+
* <CodeBlockHeader>
|
|
265
|
+
* <CodeBlockIcon preset="file" />
|
|
266
|
+
* <CodeBlockTitle>…</CodeBlockTitle>
|
|
267
|
+
* </CodeBlockHeader>
|
|
268
|
+
* <CodeBlockBody>
|
|
269
|
+
* <CodeBlockCopyButton />
|
|
270
|
+
* <CodeBlockCode language="…" value={fmtCode\`…\`} />
|
|
271
|
+
* </CodeBlockBody>
|
|
272
|
+
* <CodeBlockExpanderButton />
|
|
273
|
+
* </CodeBlock>
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
declare const CodeBlockExpanderButton: react.ForwardRefExoticComponent<Omit<CodeBlockExpanderButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
109
277
|
type CodeBlockIconProps = Omit<SvgAttributes, "children"> & ({
|
|
110
278
|
/**
|
|
111
279
|
* A custom icon to display in the code block header.
|
|
@@ -135,8 +303,25 @@ type CodeBlockIconProps = Omit<SvgAttributes, "children"> & ({
|
|
|
135
303
|
*
|
|
136
304
|
* You can pass in a custom SVG component or use one of the presets
|
|
137
305
|
* (pass only one of `svg` or `preset`).
|
|
306
|
+
*
|
|
307
|
+
* @see https://mantle.ngrok.com/components/code-block#api-code-block-icon
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```tsx
|
|
311
|
+
* <CodeBlock>
|
|
312
|
+
* <CodeBlockHeader>
|
|
313
|
+
* <CodeBlockIcon preset="file" />
|
|
314
|
+
* <CodeBlockTitle>…</CodeBlockTitle>
|
|
315
|
+
* </CodeBlockHeader>
|
|
316
|
+
* <CodeBlockBody>
|
|
317
|
+
* <CodeBlockCopyButton />
|
|
318
|
+
* <CodeBlockCode language="…" value={fmtCode\`…\`} />
|
|
319
|
+
* </CodeBlockBody>
|
|
320
|
+
* <CodeBlockExpanderButton />
|
|
321
|
+
* </CodeBlock>
|
|
322
|
+
* ```
|
|
138
323
|
*/
|
|
139
|
-
declare function CodeBlockIcon({ className
|
|
324
|
+
declare function CodeBlockIcon({ className, preset, svg: _svgProp, ...props }: CodeBlockIconProps): react_jsx_runtime.JSX.Element;
|
|
140
325
|
|
|
141
326
|
/**
|
|
142
327
|
* Escapes special HTML characters in a string to their corresponding
|
|
@@ -165,9 +350,17 @@ type Primitive = string | number | boolean | undefined | null;
|
|
|
165
350
|
*/
|
|
166
351
|
declare function fmtCode(strings: TemplateStringsArray, ...values: Primitive[]): string;
|
|
167
352
|
|
|
353
|
+
type Options = {
|
|
354
|
+
/**
|
|
355
|
+
* The indentation type to use. Can be either "tabs" or "spaces".
|
|
356
|
+
* @default "spaces"
|
|
357
|
+
*/
|
|
358
|
+
indentation?: Indentation;
|
|
359
|
+
};
|
|
168
360
|
/**
|
|
169
|
-
* Trim any leading and trailing whitespace/empty lines, convert leading
|
|
361
|
+
* Trim any leading and trailing whitespace/empty lines, convert leading
|
|
362
|
+
* indentation to the given options.indentation
|
|
170
363
|
*/
|
|
171
|
-
declare function normalizeIndentation(value: string): string;
|
|
364
|
+
declare function normalizeIndentation(value: string, options?: Options): string;
|
|
172
365
|
|
|
173
366
|
export { CodeBlock, CodeBlockBody, CodeBlockCode, CodeBlockCopyButton, CodeBlockExpanderButton, CodeBlockHeader, CodeBlockIcon, CodeBlockTitle, type DefaultMeta, type Meta, type MetaInput, type Mode, type SupportedLanguage, defaultMeta, escapeHtml, fmtCode, formatLanguageClassName, isSupportedLanguage, normalizeIndentation, parseLanguage, parseMetastring, supportedLanguages };
|
package/dist/code-block.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
`).map(
|
|
3
|
-
`)
|
|
1
|
+
import{a as _}from"./chunk-IWKI4XHM.js";import{a as R}from"./chunk-7O36LG52.js";import"./chunk-HDPLH5HC.js";import{a as u}from"./chunk-AZ56JGNY.js";import{CaretDown as re}from"@phosphor-icons/react/CaretDown";import{Check as se}from"@phosphor-icons/react/Check";import{Copy as ae}from"@phosphor-icons/react/Copy";import{FileText as ie}from"@phosphor-icons/react/FileText";import{Terminal as de}from"@phosphor-icons/react/Terminal";import{Slot as b}from"@radix-ui/react-slot";import pe from"clsx";import{createContext as ce,forwardRef as C,useContext as j,useEffect as B,useId as le,useMemo as D,useRef as ue,useState as y}from"react";import z from"tiny-invariant";function E(e){let t="";for(let n of e)switch(n){case"&":t+="&";break;case"<":t+="<";break;case">":t+=">";break;case'"':t+=""";break;case"'":t+="'";break;default:t+=n}return t}import N from"prismjs";import"prismjs/components/prism-bash.js";import"prismjs/components/prism-csharp.js";import"prismjs/components/prism-css.js";import"prismjs/components/prism-go.js";import"prismjs/components/prism-java.js";import"prismjs/components/prism-javascript.js";import"prismjs/components/prism-json.js";import"prismjs/components/prism-jsx.js";import"prismjs/components/prism-markup.js";import"prismjs/components/prism-python.js";import"prismjs/components/prism-ruby.js";import"prismjs/components/prism-rust.js";import"prismjs/components/prism-tsx.js";import"prismjs/components/prism-typescript.js";import"prismjs/components/prism-yaml.js";var O=["tabs","spaces"];function W(e,t){return t||(te(e)?"tabs":(oe(e),"spaces"))}var Z=["csharp","css","go","html","java","javascript","js","jsx","ts","tsx","typescript","xml"],ee=["python","py","yaml","yml","ruby","rb"];function te(e){return Z.includes(e)}function oe(e){return ee.includes(e)}function I(e,t){let{indentation:n="spaces"}=t||{};return e.trim().replace(/^[ \t]*(?=\S)/gm,o=>n==="spaces"?o.replace(/\t/g," "):o.replace(/ {2}/g," "))}var L=["bash","cs","csharp","css","dotnet","go","html","java","javascript","js","json","jsx","markup","plain","plaintext","py","python","rb","ruby","rust","sh","shell","text","ts","tsx","txt","typescript","xml","yaml","yml"];function ne(e){if(!e)return"sh";let t=e.trim().slice(e.indexOf("-")+1);return $(t)?t:"sh"}var $=e=>typeof e=="string"&&L.includes(e);function H(e="sh"){return`language-${e??"sh"}`}import{Fragment as fe,jsx as a,jsxs as w}from"react/jsx-runtime";var S=ce({codeId:void 0,copyText:"",hasCodeExpander:!1,isCodeExpanded:!1,registerCodeId:()=>{},setCopyText:()=>{},setHasCodeExpander:()=>{},setIsCodeExpanded:()=>{},unregisterCodeId:()=>{}}),V=C(({asChild:e=!1,className:t,...n},o)=>{let[r,s]=y(""),[i,d]=y(!1),[c,g]=y(!1),[p,l]=y(void 0),v=D(()=>({codeId:p,copyText:r,hasCodeExpander:i,isCodeExpanded:c,registerCodeId:m=>{l(h=>(z(h==null,"You can only render a single CodeBlockCode within a CodeBlock."),m))},setCopyText:s,setHasCodeExpander:d,setIsCodeExpanded:g,unregisterCodeId:m=>{l(h=>{z(h===m,"You can only render a single CodeBlockCode within a CodeBlock.")})}}),[p,r,i,c]),f=e?b:"div";return a(S.Provider,{value:v,children:a(f,{className:u("text-mono overflow-hidden rounded-md border border-gray-300 bg-gray-50 font-mono","[&_svg]:shrink-0",t),ref:o,...n})})});V.displayName="CodeBlock";var F=C(({asChild:e=!1,className:t,...n},o)=>a(e?b:"div",{className:u("relative",t),ref:o,...n}));F.displayName="CodeBlockBody";var Y=C(({className:e,highlightLines:t,indentation:n,language:o="text",showLineNumbers:r,style:s,tabIndex:i,value:d,...c},g)=>{let p=le(),{hasCodeExpander:l,isCodeExpanded:v,registerCodeId:f,setCopyText:m,unregisterCodeId:h}=j(S),M=W(o,n),k=D(()=>I(d,{indentation:M}),[d,M]),[K,U]=y(E(I(d,{indentation:M})));B(()=>{let A=N.languages[o];z(A,`CodeBlock does not support the language "${o}". The syntax highlighter does not have a grammar for this language. The supported languages are: ${L.join(", ")}.`);let X=N.highlight(k,A,o);U(X)},[k,o]),B(()=>{m(k)},[k,m]),B(()=>(f(p),()=>{h(p)}),[p,f,h]);let P=H(o);return a("pre",{"aria-expanded":l?v:void 0,className:u("scrollbar firefox:after:mr-[3.375rem] firefox:after:inline-block firefox:after:content-[''] overflow-x-auto overflow-y-hidden p-4 pr-14","text-size-inherit text-mono m-0 font-mono","aria-collapsed:max-h-[13.6rem]",P,e),"data-lang":o,id:p,ref:g,style:{...s,tabSize:2,MozTabSize:2},tabIndex:i??-1,...c,children:a("code",{className:pe("text-size-inherit",P),dangerouslySetInnerHTML:{__html:K},suppressHydrationWarning:!0})})});Y.displayName="CodeBlockCode";var q=C(({asChild:e=!1,className:t,...n},o)=>a(e?b:"div",{className:u("flex items-center gap-1 border-b border-gray-300 bg-gray-100 px-4 py-2 text-gray-700",t),ref:o,...n}));q.displayName="CodeBlockHeader";var J=C(({asChild:e=!1,className:t,...n},o)=>a(e?b:"h3",{ref:o,className:u("text-mono m-0 font-mono font-normal",t),...n}));J.displayName="CodeBlockTitle";var Q=C(({asChild:e=!1,className:t,onCopy:n,onCopyError:o,onClick:r,...s},i)=>{let{copyText:d}=j(S),[,c]=_(),[g,p]=y(!1),l=ue(0);return w(e?b:"button",{type:"button",className:u("focus-visible:border-accent-600 focus-visible:ring-focus-accent absolute right-2.5 top-2.5 z-10 flex size-7 items-center justify-center rounded border border-gray-300 bg-gray-50 shadow-[-1rem_0_0.75rem_-0.375rem_hsl(var(--gray-50)),1rem_0_0_-0.25rem_hsl(var(--gray-50))] hover:border-gray-400 hover:bg-gray-200 focus-visible:outline-none focus-visible:ring-4",g&&"bg-filled-success text-on-filled hover:bg-filled-success focus:bg-filled-success focus-visible:border-success-600 focus-visible:ring-focus-success w-auto gap-1 border-transparent pl-2 pr-1.5 hover:border-transparent",t),ref:i,onClick:async f=>{try{if(r?.(f),f.defaultPrevented){window.clearTimeout(l.current);return}await c(d),n?.(d),p(!0),window.clearTimeout(l.current),l.current=window.setTimeout(()=>{p(!1)},2e3)}catch(m){o?.(m)}},...s,children:[a("span",{className:"sr-only",children:"Copy code"}),g?w(fe,{children:["Copied",a(se,{className:"size-4 shrink-0",weight:"bold"})]}):a(ae,{className:"-ml-px size-5 shrink-0"})]})});Q.displayName="CodeBlockCopyButton";var G=C(({asChild:e=!1,className:t,onClick:n,...o},r)=>{let{codeId:s,isCodeExpanded:i,setIsCodeExpanded:d,setHasCodeExpander:c}=j(S);return B(()=>(c(!0),()=>{c(!1)}),[c]),w(e?b:"button",{...o,"aria-controls":s,"aria-expanded":i,className:u("flex w-full items-center justify-center gap-0.5 border-t border-gray-300 bg-gray-50 px-4 py-2 font-sans text-gray-700 hover:bg-gray-100",t),ref:r,type:"button",onClick:p=>{d(l=>!l),n?.(p)},children:[i?"Show less":"Show more"," ",a(re,{className:u("size-4 shrink-0",i&&"rotate-180","transition-all duration-150"),weight:"bold"})]})});G.displayName="CodeBlockExpanderButton";function me({className:e,preset:t,svg:n,...o}){let r=n;if(t!=null)switch(t){case"file":r=a(ie,{weight:"fill"});break;case"cli":r=a(de,{weight:"fill"});break;case"traffic-policy":r=a(ge,{});break}return a(R,{className:e,svg:r,...o})}function ge(e){return w("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 256 256",...e,children:[a("path",{fill:"none",d:"M0 0h256v256H0z"}),a("path",{d:"m213.7 82.3-56-56c-1.5-1.5-3.5-2.3-5.7-2.3H56c-8.8 0-16 7.2-16 16v88c0 4.4 3.6 8 8 8s8-3.6 8-8V40h88v48c0 4.4 3.6 8 8 8h48v120h-40c-4.4 0-8 3.6-8 8s3.6 8 8 8h40c8.8 0 16-7.2 16-16V88c0-2.1-.8-4.2-2.3-5.7zm-53.7-31L188.7 80H160V51.3z"}),a("path",{d:"M124.6 194.5h-6.8v-27.3h6.8c1.9 0 3.4-1.5 3.4-3.4s-1.5-3.4-3.4-3.4h-6.8v-10.2c0-3.8-3.1-6.8-6.8-6.8H63.3c-3.8 0-6.8 3.1-6.8 6.8v10.2h-6.8c-1.9 0-3.4 1.5-3.4 3.4s1.5 3.4 3.4 3.4h6.8v27.3h-6.8c-1.9 0-3.4 1.5-3.4 3.4s1.5 3.4 3.4 3.4h6.8v23.9c0 3.8 3.1 6.8 6.8 6.8H111c3.8 0 6.8-3.1 6.8-6.8v-23.9h6.8c1.9 0 3.4-1.5 3.4-3.4s-1.5-3.4-3.4-3.4zm-37.5-11.9c-6.6 0-11.9-5.3-11.9-11.9s5.3-11.9 11.9-11.9S99 164.1 99 170.7s-5.3 11.9-11.9 11.9zm0 10.2c6.6 0 11.9 5.3 11.9 11.9s-5.3 11.9-11.9 11.9-11.9-5.3-11.9-11.9 5.3-11.9 11.9-11.9z"})]})}function Ce(e,...t){if(!ye(e)||!Array.isArray(t))throw new Error("It looks like you tried to call `fmtCode` as a function. Make sure to use it as a tagged template.\n Example: fmtCode`SELECT * FROM users`, not fmtCode('SELECT * FROM users')");let n=String.raw({raw:e},...t),o=he(n);return n.trim().split(`
|
|
2
|
+
`).map(s=>/^\S+/.test(s)?s:s.slice(o)).join(`
|
|
3
|
+
`)}function he(e){let t=e.match(/^[ \t]*(?=\S)/gm);return t?t.reduce((n,o)=>Math.min(n,o.length),Number.POSITIVE_INFINITY):0}function ye(e){return Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw)}import{z as x}from"zod";var be=["cli","file","traffic-policy"],xe=x.object({collapsible:x.boolean().default(!1),disableCopy:x.boolean().default(!1),mode:x.enum(be).optional(),title:x.string().trim().optional(),indentation:x.enum(O).optional()}),T={collapsible:!1,disableCopy:!1,mode:void 0,title:void 0,indentation:void 0};function ve(e){let t=e?.trim()??"";if(!t)return T;let n=Ie(t).reduce((o,r)=>{let[s,i]=r.split("=");if(!s)return o;let d=ke(i);return o[s]=d??!0,o},{});try{let o=xe.parse(n);return{...T,...o}}catch{return T}}function ke(e){return e?.trim().replace(/^"(.*)"$/,"$1")}function Ie(e){let t=e?.trim()??"",n=[],o="",r=!1;for(let s of t)s===" "&&!r?o&&(n.push(o),o=""):(s==='"'&&(r=!r),o+=s);return o&&n.push(o),n}export{V as CodeBlock,F as CodeBlockBody,Y as CodeBlockCode,Q as CodeBlockCopyButton,G as CodeBlockExpanderButton,q as CodeBlockHeader,me as CodeBlockIcon,J as CodeBlockTitle,T as defaultMeta,E as escapeHtml,Ce as fmtCode,H as formatLanguageClassName,$ as isSupportedLanguage,I as normalizeIndentation,ne as parseLanguage,ve as parseMetastring,L as supportedLanguages};
|
|
4
4
|
//# sourceMappingURL=code-block.js.map
|
package/dist/code-block.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/code-block/code-block.tsx","../src/components/code-block/escape-html.ts","../src/components/code-block/highlighter.ts","../src/components/code-block/normalize.ts","../src/components/code-block/supported-languages.ts","../src/components/code-block/fmt-code.ts","../src/components/code-block/parse-metastring.ts"],"sourcesContent":["import { CaretDown } from \"@phosphor-icons/react/CaretDown\";\nimport { Check } from \"@phosphor-icons/react/Check\";\nimport { Copy } from \"@phosphor-icons/react/Copy\";\nimport { FileText } from \"@phosphor-icons/react/FileText\";\nimport { Terminal } from \"@phosphor-icons/react/Terminal\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport clsx from \"clsx\";\nimport type {\n\tComponentProps,\n\tDispatch,\n\tHTMLAttributes,\n\tReactNode,\n\tSetStateAction,\n} from \"react\";\nimport {\n\tcreateContext,\n\tforwardRef,\n\tuseContext,\n\tuseEffect,\n\tuseId,\n\tuseMemo,\n\tuseState,\n} from \"react\";\nimport assert from \"tiny-invariant\";\nimport { useCopyToClipboard } from \"../../hooks/use-copy-to-clipboard.js\";\nimport { cx } from \"../../utils/cx/cx.js\";\nimport { Icon } from \"../icon/icon.js\";\nimport type { SvgAttributes } from \"../icon/types.js\";\nimport { escapeHtml } from \"./escape-html.js\";\nimport { Highlighter } from \"./highlighter.js\";\nimport type { LineRange } from \"./line-numbers.js\";\nimport { normalizeIndentation } from \"./normalize.js\";\nimport type { Mode } from \"./parse-metastring.js\";\nimport type { SupportedLanguage } from \"./supported-languages.js\";\nimport {\n\tformatLanguageClassName,\n\tsupportedLanguages,\n} from \"./supported-languages.js\";\n\n/**\n * TODO(cody):\n * - fix line numbers, maybe try grid instead of :before and flex?\n * - fix line hightlighting\n * - fix line wrapping? horizontal scrolling has problems w/ line highlighting :(\n */\n\ntype CodeBlockContextType = {\n\tcodeId: string | undefined;\n\tcopyText: string;\n\thasCodeExpander: boolean;\n\tisCodeExpanded: boolean;\n\tregisterCodeId: (id: string) => void;\n\tsetCopyText: (newCopyText: string) => void;\n\tsetHasCodeExpander: (value: boolean) => void;\n\tsetIsCodeExpanded: Dispatch<SetStateAction<boolean>>;\n\tunregisterCodeId: (id: string) => void;\n};\n\nconst CodeBlockContext = createContext<CodeBlockContextType>({\n\tcodeId: undefined,\n\tcopyText: \"\",\n\thasCodeExpander: false,\n\tisCodeExpanded: false,\n\tregisterCodeId: () => {},\n\tsetCopyText: () => {},\n\tsetHasCodeExpander: () => {},\n\tsetIsCodeExpanded: () => {},\n\tunregisterCodeId: () => {},\n});\n\nconst CodeBlock = forwardRef<HTMLDivElement, ComponentProps<\"div\">>(\n\t({ className, ...props }, ref) => {\n\t\tconst [copyText, setCopyText] = useState(\"\");\n\t\tconst [hasCodeExpander, setHasCodeExpander] = useState(false);\n\t\tconst [isCodeExpanded, setIsCodeExpanded] = useState(false);\n\t\tconst [codeId, setCodeId] = useState<string | undefined>(undefined);\n\n\t\tconst context: CodeBlockContextType = useMemo(\n\t\t\t() =>\n\t\t\t\t({\n\t\t\t\t\tcodeId,\n\t\t\t\t\tcopyText,\n\t\t\t\t\thasCodeExpander,\n\t\t\t\t\tisCodeExpanded,\n\t\t\t\t\tregisterCodeId: (id) => {\n\t\t\t\t\t\tsetCodeId((old) => {\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\told == null,\n\t\t\t\t\t\t\t\t\"You can only render a single CodeBlockCode within a CodeBlock.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn id;\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tsetCopyText,\n\t\t\t\t\tsetHasCodeExpander,\n\t\t\t\t\tsetIsCodeExpanded,\n\t\t\t\t\tunregisterCodeId: (id) => {\n\t\t\t\t\t\tsetCodeId((old) => {\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\told === id,\n\t\t\t\t\t\t\t\t\"You can only render a single CodeBlockCode within a CodeBlock.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t}) as const,\n\t\t\t[codeId, copyText, hasCodeExpander, isCodeExpanded],\n\t\t);\n\n\t\treturn (\n\t\t\t<CodeBlockContext.Provider value={context}>\n\t\t\t\t<div\n\t\t\t\t\tclassName={cx(\n\t\t\t\t\t\t\"text-mono overflow-hidden rounded-md border border-gray-300 bg-gray-50 font-mono\",\n\t\t\t\t\t\t\"[&_svg]:shrink-0\",\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t)}\n\t\t\t\t\tref={ref}\n\t\t\t\t\t{...props}\n\t\t\t\t/>\n\t\t\t</CodeBlockContext.Provider>\n\t\t);\n\t},\n);\nCodeBlock.displayName = \"CodeBlock\";\n\nconst CodeBlockBody = forwardRef<\n\tHTMLDivElement,\n\tHTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n\t<div className={cx(\"relative\", className)} ref={ref} {...props} />\n));\nCodeBlockBody.displayName = \"CodeBlockBody\";\n\ntype CodeBlockCodeProps = Omit<ComponentProps<\"pre\">, \"children\"> & {\n\t/**\n\t * The code to display in the code block. Should be code formatted as a string. This code will be passed to our syntax highlighter.\n\t */\n\tvalue: string;\n\t/**\n\t * @todo not implemented yet\n\t */\n\thighlightLines?: (LineRange | number)[];\n\t/**\n\t * The language of the code block. This will be used to determine how to syntax highlight the code. @default `\"text\"`.\n\t */\n\tlanguage?: SupportedLanguage;\n\t/**\n\t * @todo not implemented yet\n\t */\n\tshowLineNumbers?: boolean;\n};\n\nconst CodeBlockCode = forwardRef<HTMLPreElement, CodeBlockCodeProps>(\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\tlanguage = \"text\",\n\t\t\tstyle,\n\t\t\tvalue,\n\t\t\thighlightLines: _unusedHighlightLines, // not implemented yet\n\t\t\tshowLineNumbers: _unusedShowLineNumbers, // not implemented yet\n\t\t\ttabIndex,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst id = useId();\n\t\tconst {\n\t\t\thasCodeExpander,\n\t\t\tisCodeExpanded,\n\t\t\tregisterCodeId,\n\t\t\tsetCopyText,\n\t\t\tunregisterCodeId,\n\t\t} = useContext(CodeBlockContext);\n\n\t\t// trim any leading and trailing whitespace/empty lines, convert leading tabs to spaces\n\t\tconst normalizedAndTrimmedValue = useMemo(\n\t\t\t() => normalizeIndentation(value),\n\t\t\t[value],\n\t\t);\n\t\tconst [highlightedCodeInnerHtml, setHighlightedCodeInnerHtml] = useState(\n\t\t\t// initialize the <code> inner html with escaped HTML since we are using\n\t\t\t// dangerouslySetInnerHTML to set the inner html of the <code> element\n\t\t\t// and use Prism.js to \"highlight\" the code in a useEffect (client-side only)\n\t\t\tescapeHtml(normalizeIndentation(value)),\n\t\t);\n\n\t\tuseEffect(() => {\n\t\t\tconst grammar = Highlighter.languages[language];\n\t\t\tassert(\n\t\t\t\tgrammar,\n\t\t\t\t`CodeBlock does not support the language \"${language}\". The syntax highlighter does not have a grammar for this language. The supported languages are: ${supportedLanguages.join(\", \")}.`,\n\t\t\t);\n\t\t\tconst newHighlightedCodeInnerHtml = Highlighter.highlight(\n\t\t\t\tnormalizedAndTrimmedValue,\n\t\t\t\tgrammar,\n\t\t\t\tlanguage,\n\t\t\t);\n\t\t\tsetHighlightedCodeInnerHtml(newHighlightedCodeInnerHtml);\n\t\t}, [normalizedAndTrimmedValue, language]);\n\n\t\tuseEffect(() => {\n\t\t\tsetCopyText(normalizedAndTrimmedValue);\n\t\t}, [normalizedAndTrimmedValue, setCopyText]);\n\n\t\tuseEffect(() => {\n\t\t\tregisterCodeId(id);\n\n\t\t\treturn () => {\n\t\t\t\tunregisterCodeId(id);\n\t\t\t};\n\t\t}, [id, registerCodeId, unregisterCodeId]);\n\n\t\tconst languageClassName = formatLanguageClassName(language);\n\n\t\treturn (\n\t\t\t<pre\n\t\t\t\taria-expanded={hasCodeExpander ? isCodeExpanded : undefined}\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"scrollbar firefox:after:mr-[3.375rem] firefox:after:inline-block firefox:after:content-[''] overflow-x-auto overflow-y-hidden p-4 pr-14\",\n\t\t\t\t\t\"text-size-inherit text-mono m-0 font-mono\",\n\t\t\t\t\t\"aria-collapsed:max-h-[13.6rem]\",\n\t\t\t\t\tlanguageClassName, // place it last because prism does weird stuff client side, causes hydration mismatches\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tdata-lang={language}\n\t\t\t\tid={id}\n\t\t\t\tref={ref}\n\t\t\t\tstyle={{\n\t\t\t\t\t...style,\n\t\t\t\t\ttabSize: 2,\n\t\t\t\t\tMozTabSize: 2,\n\t\t\t\t}}\n\t\t\t\t// prism.js adds a tabindex of 0 to the pre element by default (unless it's set)\n\t\t\t\t// this is unnecessary, we do not want this automatic behavior!\n\t\t\t\ttabIndex={tabIndex ?? -1}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<code\n\t\t\t\t\tclassName={clsx(\"text-size-inherit\", languageClassName)}\n\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t__html: highlightedCodeInnerHtml,\n\t\t\t\t\t}}\n\t\t\t\t\t// we need to suppress the hydration warning because we are setting the innerHTML of the code block\n\t\t\t\t\t// and using Prism.js to \"highlight\" the code in a useEffect (client-side only), which does different things on the client and server\n\t\t\t\t\tsuppressHydrationWarning\n\t\t\t\t/>\n\t\t\t</pre>\n\t\t);\n\t},\n);\nCodeBlockCode.displayName = \"CodeBlockCode\";\n\nconst CodeBlockHeader = forwardRef<HTMLDivElement, ComponentProps<\"div\">>(\n\t({ className, ...props }, ref) => (\n\t\t<div\n\t\t\tclassName={cx(\n\t\t\t\t\"flex items-center gap-1 border-b border-gray-300 bg-gray-100 px-4 py-2 text-gray-700\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\tref={ref}\n\t\t\t{...props}\n\t\t/>\n\t),\n);\nCodeBlockHeader.displayName = \"CodeBlockHeader\";\n\nconst CodeBlockTitle = forwardRef<\n\tHTMLHeadingElement,\n\tHTMLAttributes<HTMLHeadingElement> & { asChild?: boolean }\n>(({ asChild = false, className, ...props }, ref) => {\n\tconst Comp = asChild ? Slot : \"h3\";\n\treturn (\n\t\t<Comp\n\t\t\tref={ref}\n\t\t\tclassName={cx(\"text-mono m-0 font-mono font-normal\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n});\nCodeBlockTitle.displayName = \"CodeBlockTitle\";\n\ntype CodeBlockCopyButtonProps = Omit<\n\tComponentProps<\"button\">,\n\t\"children\" | \"type\"\n> & {\n\t/**\n\t * Callback fired when the copy button is clicked, passes the copied text as an argument.\n\t */\n\tonCopy?: (value: string) => void;\n\t/**\n\t * Callback fired when an error occurs during copying.\n\t */\n\tonCopyError?: (error: unknown) => void;\n};\n\nconst CodeBlockCopyButton = forwardRef<\n\tHTMLButtonElement,\n\tCodeBlockCopyButtonProps\n>(({ className, onCopy, onCopyError, onClick, ...props }, ref) => {\n\tconst { copyText } = useContext(CodeBlockContext);\n\tconst [, copyToClipboard] = useCopyToClipboard();\n\tconst [copied, setCopied] = useState(false);\n\n\tuseEffect(() => {\n\t\tif (copied) {\n\t\t\tconst timeoutId = window.setTimeout(() => {\n\t\t\t\tsetCopied(false);\n\t\t\t}, 2000);\n\n\t\t\treturn () => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t};\n\t\t}\n\t}, [copied]);\n\n\treturn (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclassName={cx(\n\t\t\t\t\"focus-visible:border-accent-600 focus-visible:ring-focus-accent absolute right-2.5 top-2.5 z-10 flex size-7 items-center justify-center rounded border border-gray-300 bg-gray-50 shadow-[-1rem_0_0.75rem_-0.375rem_hsl(var(--gray-50)),1rem_0_0_-0.25rem_hsl(var(--gray-50))] hover:border-gray-400 hover:bg-gray-200 focus-visible:outline-none focus-visible:ring-4\",\n\t\t\t\tcopied &&\n\t\t\t\t\t\"bg-filled-success text-on-filled hover:bg-filled-success focus:bg-filled-success focus-visible:border-success-600 focus-visible:ring-focus-success w-auto gap-1 border-transparent pl-2 pr-1.5 hover:border-transparent\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\tref={ref}\n\t\t\tonClick={async (event) => {\n\t\t\t\ttry {\n\t\t\t\t\tonClick?.(event);\n\t\t\t\t\tawait copyToClipboard(copyText);\n\t\t\t\t\tonCopy?.(copyText);\n\t\t\t\t\tsetCopied(true);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tonCopyError?.(error);\n\t\t\t\t}\n\t\t\t}}\n\t\t\t{...props}\n\t\t>\n\t\t\t<span className=\"sr-only\">Copy code</span>\n\t\t\t{copied ? (\n\t\t\t\t<>\n\t\t\t\t\tCopied\n\t\t\t\t\t<Check className=\"size-4 shrink-0\" weight=\"bold\" />\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<Copy className=\"-ml-px size-5 shrink-0\" />\n\t\t\t)}\n\t\t</button>\n\t);\n});\nCodeBlockCopyButton.displayName = \"CodeBlockCopyButton\";\n\ntype CodeBlockExpanderButtonProps = Omit<\n\tHTMLAttributes<HTMLButtonElement>,\n\t\"children\" | \"aria-controls\" | \"aria-expanded\"\n>;\n\nconst CodeBlockExpanderButton = forwardRef<\n\tHTMLButtonElement,\n\tCodeBlockExpanderButtonProps\n>(({ className, onClick, ...props }, ref) => {\n\tconst { codeId, isCodeExpanded, setIsCodeExpanded, setHasCodeExpander } =\n\t\tuseContext(CodeBlockContext);\n\n\tuseEffect(() => {\n\t\tsetHasCodeExpander(true);\n\n\t\treturn () => {\n\t\t\tsetHasCodeExpander(false);\n\t\t};\n\t}, [setHasCodeExpander]);\n\n\treturn (\n\t\t<button\n\t\t\t{...props}\n\t\t\taria-controls={codeId}\n\t\t\taria-expanded={isCodeExpanded}\n\t\t\tclassName={cx(\n\t\t\t\t\"flex w-full items-center justify-center gap-0.5 border-t border-gray-300 bg-gray-50 px-4 py-2 font-sans text-gray-700 hover:bg-gray-100\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\tref={ref}\n\t\t\ttype=\"button\"\n\t\t\tonClick={(event) => {\n\t\t\t\tsetIsCodeExpanded((prev) => !prev);\n\t\t\t\tonClick?.(event);\n\t\t\t}}\n\t\t>\n\t\t\t{isCodeExpanded ? \"Show less\" : \"Show more\"}{\" \"}\n\t\t\t<CaretDown\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"size-4 shrink-0\",\n\t\t\t\t\tisCodeExpanded && \"rotate-180\",\n\t\t\t\t\t\"transition-all duration-150\",\n\t\t\t\t)}\n\t\t\t\tweight=\"bold\"\n\t\t\t/>\n\t\t</button>\n\t);\n});\nCodeBlockExpanderButton.displayName = \"CodeBlockExpanderButton\";\n\ntype CodeBlockIconProps = Omit<SvgAttributes, \"children\"> &\n\t(\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * A custom icon to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tsvg: ReactNode;\n\t\t\t\t/**\n\t\t\t\t * A preset icon to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tpreset?: undefined | never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * A custom icon to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tsvg?: undefined | never;\n\t\t\t\t/**\n\t\t\t\t * A preset icon to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tpreset: Mode;\n\t\t }\n\t);\n\n/**\n * A small icon that represents the type of code block being displayed,\n * rendered as an SVG next to the code block title in the code block header.\n *\n * You can pass in a custom SVG component or use one of the presets\n * (pass only one of `svg` or `preset`).\n */\nfunction CodeBlockIcon({\n\tclassName: _className,\n\tpreset,\n\tsvg,\n\t...props\n}: CodeBlockIconProps) {\n\tconst className = cx(\"size-5 shrink-0\", _className);\n\n\tif (preset != null) {\n\t\tswitch (preset) {\n\t\t\tcase \"file\":\n\t\t\t\treturn <FileText className={className} weight=\"fill\" {...props} />;\n\t\t\tcase \"cli\":\n\t\t\t\treturn <Terminal className={className} weight=\"fill\" {...props} />;\n\t\t\tcase \"traffic-policy\":\n\t\t\t\treturn <TrafficPolicyFileIcon className={className} {...props} />;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t}\n\n\treturn <Icon className={className} svg={svg} {...props} />;\n}\n\nconst TrafficPolicyFileIcon = (props: SvgAttributes) => (\n\t<svg\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\twidth=\"1em\"\n\t\theight=\"1em\"\n\t\tfill=\"currentColor\"\n\t\tviewBox=\"0 0 256 256\"\n\t\t{...props}\n\t>\n\t\t<path fill=\"none\" d=\"M0 0h256v256H0z\" />\n\t\t<path d=\"m213.7 82.3-56-56c-1.5-1.5-3.5-2.3-5.7-2.3H56c-8.8 0-16 7.2-16 16v88c0 4.4 3.6 8 8 8s8-3.6 8-8V40h88v48c0 4.4 3.6 8 8 8h48v120h-40c-4.4 0-8 3.6-8 8s3.6 8 8 8h40c8.8 0 16-7.2 16-16V88c0-2.1-.8-4.2-2.3-5.7zm-53.7-31L188.7 80H160V51.3z\" />\n\t\t<path d=\"M124.6 194.5h-6.8v-27.3h6.8c1.9 0 3.4-1.5 3.4-3.4s-1.5-3.4-3.4-3.4h-6.8v-10.2c0-3.8-3.1-6.8-6.8-6.8H63.3c-3.8 0-6.8 3.1-6.8 6.8v10.2h-6.8c-1.9 0-3.4 1.5-3.4 3.4s1.5 3.4 3.4 3.4h6.8v27.3h-6.8c-1.9 0-3.4 1.5-3.4 3.4s1.5 3.4 3.4 3.4h6.8v23.9c0 3.8 3.1 6.8 6.8 6.8H111c3.8 0 6.8-3.1 6.8-6.8v-23.9h6.8c1.9 0 3.4-1.5 3.4-3.4s-1.5-3.4-3.4-3.4zm-37.5-11.9c-6.6 0-11.9-5.3-11.9-11.9s5.3-11.9 11.9-11.9S99 164.1 99 170.7s-5.3 11.9-11.9 11.9zm0 10.2c6.6 0 11.9 5.3 11.9 11.9s-5.3 11.9-11.9 11.9-11.9-5.3-11.9-11.9 5.3-11.9 11.9-11.9z\" />\n\t</svg>\n);\n\nexport {\n\tCodeBlock,\n\tCodeBlockBody,\n\tCodeBlockCode,\n\tCodeBlockCopyButton,\n\tCodeBlockExpanderButton,\n\tCodeBlockHeader,\n\tCodeBlockIcon,\n\tCodeBlockTitle,\n};\n","/**\n * Escapes special HTML characters in a string to their corresponding\n * HTML entities, preventing issues like unintended HTML rendering or\n * cross-site scripting (XSS) when injecting raw strings into the DOM\n * using `dangerouslySetInnerHTML`.\n *\n * Characters escaped:\n * - \\& => `&`;\n * - \\< => `<`;\n * - \\> => `>`;\n * - \\\" => `"`;\n * - \\' => `'`;\n *\n * @param {string} value The raw string to be escaped.\n *\n * @example\n * escapeHtml('<div>Hello & \"world\"</div>');\n * // Returns: '<div>Hello & "world"</div>'\n */\nfunction escapeHtml(value: string): string {\n\tlet escaped = \"\";\n\tfor (const character of value) {\n\t\tswitch (character) {\n\t\t\tcase \"&\":\n\t\t\t\tescaped += \"&\";\n\t\t\t\tbreak;\n\t\t\tcase \"<\":\n\t\t\t\tescaped += \"<\";\n\t\t\t\tbreak;\n\t\t\tcase \">\":\n\t\t\t\tescaped += \">\";\n\t\t\t\tbreak;\n\t\t\tcase '\"':\n\t\t\t\tescaped += \""\";\n\t\t\t\tbreak;\n\t\t\tcase \"'\":\n\t\t\t\tescaped += \"'\";\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tescaped += character;\n\t\t}\n\t}\n\treturn escaped;\n}\n\nexport {\n\t//,\n\tescapeHtml,\n};\n","import Prism from \"prismjs\";\nimport \"prismjs/components/prism-bash.js\";\nimport \"prismjs/components/prism-csharp.js\";\nimport \"prismjs/components/prism-css.js\";\nimport \"prismjs/components/prism-go.js\";\nimport \"prismjs/components/prism-java.js\";\nimport \"prismjs/components/prism-javascript.js\";\nimport \"prismjs/components/prism-json.js\";\nimport \"prismjs/components/prism-jsx.js\";\nimport \"prismjs/components/prism-markup.js\";\nimport \"prismjs/components/prism-python.js\";\nimport \"prismjs/components/prism-ruby.js\";\nimport \"prismjs/components/prism-rust.js\";\nimport \"prismjs/components/prism-tsx.js\";\nimport \"prismjs/components/prism-typescript.js\";\nimport \"prismjs/components/prism-yaml.js\";\n\nexport {\n\t//,\n\tPrism as Highlighter,\n};\n","/**\n * Trim any leading and trailing whitespace/empty lines, convert leading tabs to spaces\n */\nfunction normalizeIndentation(value: string) {\n\treturn value\n\t\t.trim()\n\t\t.replace(/^\\t+/gm, (match) => \" \".repeat(match.length * 2));\n}\n\nexport {\n\t//,\n\tnormalizeIndentation,\n};\n","/**\n * List of supported languages for syntax highlighting.\n * @private\n */\nexport const supportedLanguages = [\n\t\"bash\",\n\t\"cs\",\n\t\"csharp\",\n\t\"css\",\n\t\"dotnet\",\n\t\"go\",\n\t\"html\",\n\t\"java\",\n\t\"javascript\",\n\t\"js\",\n\t\"json\",\n\t\"jsx\",\n\t\"markup\",\n\t\"plain\",\n\t\"plaintext\",\n\t\"py\",\n\t\"python\",\n\t\"rb\",\n\t\"ruby\",\n\t\"rust\",\n\t\"sh\",\n\t\"shell\",\n\t\"text\",\n\t\"ts\",\n\t\"tsx\",\n\t\"txt\",\n\t\"typescript\",\n\t\"xml\",\n\t\"yaml\",\n\t\"yml\",\n] as const;\n\n/**\n * Supported languages for syntax highlighting.\n */\ntype SupportedLanguage = (typeof supportedLanguages)[number];\n\n/**\n * Parses a markdown code block (```) language class into a SupportedLanguage.\n * Defaults to \"sh\" if no supported language is found.\n */\nfunction parseLanguage(\n\tvalue: `language-${string}` | `lang-${string}` | (string & {}) | undefined,\n): SupportedLanguage {\n\tif (!value) {\n\t\treturn \"sh\";\n\t}\n\n\t// remove leading \"language-\" and \"lang-\" prefixes\n\t// find first '-' and slice from there\n\tconst maybeLanguage = value.trim().slice(value.indexOf(\"-\") + 1);\n\n\treturn isSupportedLanguage(maybeLanguage) ? maybeLanguage : \"sh\";\n}\n\n/**\n * Type Predicate: checks if an arbitrary value is a supported syntax highlighting language.\n */\nconst isSupportedLanguage = (value: unknown): value is SupportedLanguage => {\n\treturn (\n\t\ttypeof value === \"string\" &&\n\t\tsupportedLanguages.includes(value as SupportedLanguage)\n\t);\n};\n\n/**\n * A class name for a language that Prism.js can understand.\n */\ntype LanguageClass = `language-${SupportedLanguage}`;\n\n/**\n * Formats a language name into a class name that Prism.js can understand.\n * @default \"language-sh\"\n */\nfunction formatLanguageClassName(\n\tlanguage: SupportedLanguage | undefined = \"sh\",\n) {\n\tconst lang = language ?? \"sh\";\n\tconst className: LanguageClass = `language-${lang}`;\n\treturn className;\n}\n\nexport { isSupportedLanguage, parseLanguage, formatLanguageClassName };\nexport type { SupportedLanguage };\n","type Primitive = string | number | boolean | undefined | null;\n\n/**\n * Tagged template literal to format code blocks and normalize leading indentation\n */\nexport function fmtCode(\n\tstrings: TemplateStringsArray,\n\t...values: Primitive[]\n): string {\n\tif (!isTemplateStringsArray(strings) || !Array.isArray(values)) {\n\t\tthrow new Error(\n\t\t\t\"It looks like you tried to call `fmtCode` as a function. Make sure to use it as a tagged template.\\n\\tExample: fmtCode`SELECT * FROM users`, not fmtCode('SELECT * FROM users')\",\n\t\t);\n\t}\n\n\tconst text = String.raw({ raw: strings }, ...values);\n\n\t// fine the minimum indentation of the code block\n\tconst minIndent = findMinIndent(text);\n\tconst lines = text.trim().split(\"\\n\");\n\n\treturn lines\n\t\t.map((line) => {\n\t\t\t// remove nothing if the line doesn't start with indentation\n\t\t\tif (/^\\S+/.test(line)) {\n\t\t\t\treturn line;\n\t\t\t}\n\t\t\treturn line.slice(minIndent);\n\t\t})\n\t\t.join(\"\\n\")\n\t\t.replace(/\\t/g, \" \"); // replace all tabs with 2 spaces\n}\n\n/**\n * Find the shortest indentation of a multiline string\n */\nfunction findMinIndent(value: string): number {\n\tconst match = value.match(/^[ \\t]*(?=\\S)/gm);\n\n\tif (!match) {\n\t\treturn 0;\n\t}\n\n\treturn match.reduce(\n\t\t(acc, curr) => Math.min(acc, curr.length),\n\t\tNumber.POSITIVE_INFINITY,\n\t);\n}\n\n/**\n * Type guard to check if a value is a `TemplateStringsArray`\n */\nfunction isTemplateStringsArray(\n\tstrings: unknown,\n): strings is TemplateStringsArray {\n\treturn (\n\t\tArray.isArray(strings) && \"raw\" in strings && Array.isArray(strings.raw)\n\t);\n}\n","import { z } from \"zod\";\n\nconst modes = [\n\t//,\n\t\"cli\",\n\t\"file\",\n\t\"traffic-policy\",\n] as const;\ntype Mode = (typeof modes)[number];\n\nconst metaSchema = z.object({\n\tcollapsible: z.boolean().default(false),\n\tdisableCopy: z.boolean().default(false),\n\tmode: z.enum(modes).optional(),\n\ttitle: z.string().trim().optional(),\n});\n\ntype MetaInput = z.input<typeof metaSchema>;\n\ntype Meta = z.infer<typeof metaSchema>;\n\nconst defaultMeta = {\n\tcollapsible: false,\n\tdisableCopy: false,\n\tmode: undefined,\n\ttitle: undefined,\n} as const satisfies Meta;\n\ntype DefaultMeta = typeof defaultMeta;\n\n/**\n * Parses a markdown code block (```) metastring into a meta object.\n * Defaults to DefaultMeta if no metastring given or if metastring is invalid.\n * Useful for parsing the metastring from a markdown code block to pass into the\n * CodeBlock components as props.\n */\nfunction parseMetastring(value: string | undefined): Meta {\n\tconst metastring = value?.trim() ?? \"\";\n\tif (!metastring) {\n\t\treturn defaultMeta;\n\t}\n\n\tconst metaJson = tokenizeMetastring(metastring).reduce<\n\t\tRecord<string, unknown>\n\t>((acc, token) => {\n\t\tconst [key, _value] = token.split(\"=\");\n\t\tif (!key) {\n\t\t\treturn acc;\n\t\t}\n\t\tconst value = normalizeValue(_value);\n\t\tacc[key] = value ?? true;\n\t\treturn acc;\n\t}, {});\n\n\ttry {\n\t\tconst parsed = metaSchema.parse(metaJson);\n\n\t\t// return the parsed meta object, with default values filled in\n\t\treturn {\n\t\t\t...defaultMeta,\n\t\t\t...parsed,\n\t\t};\n\t} catch (_) {\n\t\treturn defaultMeta;\n\t}\n}\n\nexport {\n\t//,\n\tdefaultMeta,\n\tparseMetastring,\n};\nexport type {\n\t//,\n\tMeta,\n\tMetaInput,\n\tMode,\n\tDefaultMeta,\n};\n\n/**\n * Remove leading and trailing `\"` quotes around value\n * @private\n */\nexport function normalizeValue(value: string | undefined) {\n\treturn value?.trim().replace(/^\"(.*)\"$/, \"$1\");\n}\n\n/**\n * Splits a metastring into an array of tokens that can be parsed into a meta object.\n * Should allow for quotes and spaces in tokens\n * @private\n */\nexport function tokenizeMetastring(value: string | undefined): string[] {\n\tconst input = value?.trim() ?? \"\";\n\tconst result: string[] = [];\n\n\tlet currentString = \"\";\n\tlet inQuotes = false;\n\n\tfor (const char of input) {\n\t\tif (char === \" \" && !inQuotes) {\n\t\t\tif (currentString) {\n\t\t\t\tresult.push(currentString);\n\t\t\t\tcurrentString = \"\";\n\t\t\t}\n\t\t} else if (char === '\"') {\n\t\t\tinQuotes = !inQuotes;\n\t\t\tcurrentString += char;\n\t\t} else {\n\t\t\tcurrentString += char;\n\t\t}\n\t}\n\n\tif (currentString) {\n\t\tresult.push(currentString);\n\t}\n\n\treturn result;\n}\n"],"mappings":"oJAAA,OAAS,aAAAA,MAAiB,kCAC1B,OAAS,SAAAC,MAAa,8BACtB,OAAS,QAAAC,MAAY,6BACrB,OAAS,YAAAC,MAAgB,iCACzB,OAAS,YAAAC,MAAgB,iCACzB,OAAS,QAAAC,OAAY,uBACrB,OAAOC,OAAU,OAQjB,OACC,iBAAAC,GACA,cAAAC,EACA,cAAAC,EACA,aAAAC,EACA,SAAAC,GACA,WAAAC,EACA,YAAAC,MACM,QACP,OAAOC,MAAY,iBCJnB,SAASC,EAAWC,EAAuB,CAC1C,IAAIC,EAAU,GACd,QAAWC,KAAaF,EACvB,OAAQE,EAAW,CAClB,IAAK,IACJD,GAAW,QACX,MACD,IAAK,IACJA,GAAW,OACX,MACD,IAAK,IACJA,GAAW,OACX,MACD,IAAK,IACJA,GAAW,SACX,MACD,IAAK,IACJA,GAAW,QACX,MACD,QACCA,GAAWC,CACb,CAED,OAAOD,CACR,CC3CA,OAAOE,MAAW,UAClB,MAAO,mCACP,MAAO,qCACP,MAAO,kCACP,MAAO,iCACP,MAAO,mCACP,MAAO,yCACP,MAAO,mCACP,MAAO,kCACP,MAAO,qCACP,MAAO,qCACP,MAAO,mCACP,MAAO,mCACP,MAAO,kCACP,MAAO,yCACP,MAAO,mCCZP,SAASC,EAAqBC,EAAe,CAC5C,OAAOA,EACL,KAAK,EACL,QAAQ,SAAWC,GAAU,IAAI,OAAOA,EAAM,OAAS,CAAC,CAAC,CAC5D,CCHO,IAAMC,EAAqB,CACjC,OACA,KACA,SACA,MACA,SACA,KACA,OACA,OACA,aACA,KACA,OACA,MACA,SACA,QACA,YACA,KACA,SACA,KACA,OACA,OACA,KACA,QACA,OACA,KACA,MACA,MACA,aACA,MACA,OACA,KACD,EAWA,SAASC,EACRC,EACoB,CACpB,GAAI,CAACA,EACJ,MAAO,KAKR,IAAMC,EAAgBD,EAAM,KAAK,EAAE,MAAMA,EAAM,QAAQ,GAAG,EAAI,CAAC,E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,OAAIF,GACHD,EAAO,KAAKC,CAAa,EAGnBD,CACR","names":["CaretDown","Check","Copy","FileText","Terminal","Slot","clsx","createContext","forwardRef","useContext","useEffect","useId","useMemo","useState","assert","escapeHtml","value","escaped","character","Prism","normalizeIndentation","value","match","supportedLanguages","parseLanguage","value","maybeLanguage","isSupportedLanguage","formatLanguageClassName","language","Fragment","jsx","jsxs","CodeBlockContext","createContext","CodeBlock","forwardRef","className","props","ref","copyText","setCopyText","useState","hasCodeExpander","setHasCodeExpander","isCodeExpanded","setIsCodeExpanded","codeId","setCodeId","context","useMemo","id","old","assert","cx","CodeBlockBody","CodeBlockCode","language","style","value","_unusedHighlightLines","_unusedShowLineNumbers","tabIndex","useId","registerCodeId","unregisterCodeId","useContext","normalizedAndTrimmedValue","normalizeIndentation","highlightedCodeInnerHtml","setHighlightedCodeInnerHtml","escapeHtml","useEffect","grammar","Prism","supportedLanguages","newHighlightedCodeInnerHtml","languageClassName","formatLanguageClassName","clsx","CodeBlockHeader","CodeBlockTitle","asChild","Slot","CodeBlockCopyButton","onCopy","onCopyError","onClick","copyToClipboard","useCopyToClipboard","copied","setCopied","timeoutId","event","error","Check","Copy","CodeBlockExpanderButton","prev","CaretDown","CodeBlockIcon","_className","preset","svg","FileText","Terminal","TrafficPolicyFileIcon","Icon","fmtCode","strings","values","isTemplateStringsArray","text","minIndent","findMinIndent","line","value","match","acc","curr","z","modes","metaSchema","defaultMeta","parseMetastring","value","metastring","metaJson","tokenizeMetastring","acc","token","key","_value","normalizeValue","parsed","normalizeValue","value","tokenizeMetastring","input","result","currentString","inQuotes","char"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/code-block/code-block.tsx","../src/components/code-block/escape-html.ts","../src/components/code-block/highlighter.ts","../src/components/code-block/indentation.ts","../src/components/code-block/normalize.ts","../src/components/code-block/supported-languages.ts","../src/components/code-block/fmt-code.ts","../src/components/code-block/parse-metastring.ts"],"sourcesContent":["import { CaretDown } from \"@phosphor-icons/react/CaretDown\";\nimport { Check } from \"@phosphor-icons/react/Check\";\nimport { Copy } from \"@phosphor-icons/react/Copy\";\nimport { FileText } from \"@phosphor-icons/react/FileText\";\nimport { Terminal } from \"@phosphor-icons/react/Terminal\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport clsx from \"clsx\";\nimport type {\n\tComponentProps,\n\tComponentRef,\n\tDispatch,\n\tHTMLAttributes,\n\tReactNode,\n\tSetStateAction,\n} from \"react\";\nimport {\n\tcreateContext,\n\tforwardRef,\n\tuseContext,\n\tuseEffect,\n\tuseId,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport assert from \"tiny-invariant\";\nimport { useCopyToClipboard } from \"../../hooks/use-copy-to-clipboard.js\";\nimport type { WithAsChild } from \"../../types/as-child.js\";\nimport { cx } from \"../../utils/cx/cx.js\";\nimport { Icon } from \"../icon/icon.js\";\nimport type { SvgAttributes } from \"../icon/types.js\";\nimport { escapeHtml } from \"./escape-html.js\";\nimport { Highlighter } from \"./highlighter.js\";\nimport { type Indentation, inferIndentation } from \"./indentation.js\";\nimport type { LineRange } from \"./line-numbers.js\";\nimport { normalizeIndentation } from \"./normalize.js\";\nimport type { Mode } from \"./parse-metastring.js\";\nimport type { SupportedLanguage } from \"./supported-languages.js\";\nimport {\n\tformatLanguageClassName,\n\tsupportedLanguages,\n} from \"./supported-languages.js\";\n\n/**\n * TODO(cody):\n * - fix line numbers, maybe try grid instead of :before and flex?\n * - fix line hightlighting\n * - fix line wrapping? horizontal scrolling has problems w/ line highlighting :(\n */\n\ntype CodeBlockContextType = {\n\tcodeId: string | undefined;\n\tcopyText: string;\n\thasCodeExpander: boolean;\n\tisCodeExpanded: boolean;\n\tregisterCodeId: (id: string) => void;\n\tsetCopyText: (newCopyText: string) => void;\n\tsetHasCodeExpander: (value: boolean) => void;\n\tsetIsCodeExpanded: Dispatch<SetStateAction<boolean>>;\n\tunregisterCodeId: (id: string) => void;\n};\n\nconst CodeBlockContext = createContext<CodeBlockContextType>({\n\tcodeId: undefined,\n\tcopyText: \"\",\n\thasCodeExpander: false,\n\tisCodeExpanded: false,\n\tregisterCodeId: () => {},\n\tsetCopyText: () => {},\n\tsetHasCodeExpander: () => {},\n\tsetIsCodeExpanded: () => {},\n\tunregisterCodeId: () => {},\n});\n\n/**\n * Code blocks render and apply syntax highlighting to blocks of code.\n * This is the root component for all code block components.\n *\n * @see https://mantle.ngrok.com/components/code-block#api-code-block\n *\n * @example\n * ```tsx\n * <CodeBlock>\n * <CodeBlockHeader>\n * <CodeBlockIcon preset=\"file\" />\n * <CodeBlockTitle>…</CodeBlockTitle>\n * </CodeBlockHeader>\n * <CodeBlockBody>\n * <CodeBlockCopyButton />\n * <CodeBlockCode language=\"…\" value={fmtCode\\`…\\`} />\n * </CodeBlockBody>\n * <CodeBlockExpanderButton />\n * </CodeBlock>\n * ```\n */\nconst CodeBlock = forwardRef<\n\tComponentRef<\"div\">,\n\tComponentProps<\"div\"> & WithAsChild\n>(({ asChild = false, className, ...props }, ref) => {\n\tconst [copyText, setCopyText] = useState(\"\");\n\tconst [hasCodeExpander, setHasCodeExpander] = useState(false);\n\tconst [isCodeExpanded, setIsCodeExpanded] = useState(false);\n\tconst [codeId, setCodeId] = useState<string | undefined>(undefined);\n\n\tconst context: CodeBlockContextType = useMemo(\n\t\t() =>\n\t\t\t({\n\t\t\t\tcodeId,\n\t\t\t\tcopyText,\n\t\t\t\thasCodeExpander,\n\t\t\t\tisCodeExpanded,\n\t\t\t\tregisterCodeId: (id) => {\n\t\t\t\t\tsetCodeId((old) => {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\told == null,\n\t\t\t\t\t\t\t\"You can only render a single CodeBlockCode within a CodeBlock.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn id;\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tsetCopyText,\n\t\t\t\tsetHasCodeExpander,\n\t\t\t\tsetIsCodeExpanded,\n\t\t\t\tunregisterCodeId: (id) => {\n\t\t\t\t\tsetCodeId((old) => {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\told === id,\n\t\t\t\t\t\t\t\"You can only render a single CodeBlockCode within a CodeBlock.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}) as const,\n\t\t[codeId, copyText, hasCodeExpander, isCodeExpanded],\n\t);\n\n\tconst Component = asChild ? Slot : \"div\";\n\n\treturn (\n\t\t<CodeBlockContext.Provider value={context}>\n\t\t\t<Component\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"text-mono overflow-hidden rounded-md border border-gray-300 bg-gray-50 font-mono\",\n\t\t\t\t\t\"[&_svg]:shrink-0\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t</CodeBlockContext.Provider>\n\t);\n});\nCodeBlock.displayName = \"CodeBlock\";\n\n/**\n * The body of the `CodeBlock`. This is where the `CodeBlockCode` and optional\n * `CodeBlockCopyButton` is rendered.\n *\n * @see https://mantle.ngrok.com/components/code-block#api-code-block-body\n *\n * @example\n * ```tsx\n * <CodeBlock>\n * <CodeBlockHeader>\n * <CodeBlockIcon preset=\"file\" />\n * <CodeBlockTitle>…</CodeBlockTitle>\n * </CodeBlockHeader>\n * <CodeBlockBody>\n * <CodeBlockCopyButton />\n * <CodeBlockCode language=\"…\" value={fmtCode\\`…\\`} />\n * </CodeBlockBody>\n * <CodeBlockExpanderButton />\n * </CodeBlock>\n * ```\n */\nconst CodeBlockBody = forwardRef<\n\tComponentRef<\"div\">,\n\tComponentProps<\"div\"> & WithAsChild\n>(({ asChild = false, className, ...props }, ref) => {\n\tconst Component = asChild ? Slot : \"div\";\n\n\treturn (\n\t\t<Component className={cx(\"relative\", className)} ref={ref} {...props} />\n\t);\n});\nCodeBlockBody.displayName = \"CodeBlockBody\";\n\ntype CodeBlockCodeProps = Omit<ComponentProps<\"pre\">, \"children\"> & {\n\t/**\n\t * The code to display in the code block. Should be code formatted as a string. This code will be passed to our syntax highlighter.\n\t */\n\tvalue: string;\n\t/**\n\t * @todo not implemented yet\n\t */\n\thighlightLines?: (LineRange | number)[];\n\t/**\n\t * The type of indentation to use. Can be either \"tabs\" or \"spaces\".\n\t * @default inferred from the given language, fallback to `spaces`\n\t */\n\tindentation?: Indentation;\n\t/**\n\t * The language of the code block. This will be used to determine how to syntax highlight the code.\n\t * @default `\"text\"`.\n\t */\n\tlanguage?: SupportedLanguage;\n\t/**\n\t * @todo not implemented yet\n\t */\n\tshowLineNumbers?: boolean;\n};\n\n/**\n * The `CodeBlock` content. This is where the code is rendered and syntax highlighted.\n *\n * @see https://mantle.ngrok.com/components/code-block#api-code-block-code\n *\n * @example\n * ```tsx\n * <CodeBlock>\n * <CodeBlockHeader>\n * <CodeBlockIcon preset=\"file\" />\n * <CodeBlockTitle>…</CodeBlockTitle>\n * </CodeBlockHeader>\n * <CodeBlockBody>\n * <CodeBlockCopyButton />\n * <CodeBlockCode\n * language=\"sh\"\n * value={fmtCode`ffmpeg -i multichannel.mxf -map 0:v:0 -map 0:a:0 -map 0:a:0 -c:a:0 ac3 -b:a:0 640k -ac:a:1 2 -c:a:1 aac -b:2 128k out.mp4`}\n * />\n * </CodeBlockBody>\n * <CodeBlockExpanderButton />\n * </CodeBlock>\n * ```\n */\nconst CodeBlockCode = forwardRef<ComponentRef<\"pre\">, CodeBlockCodeProps>(\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\thighlightLines: _unusedHighlightLines, // not implemented yet\n\t\t\tindentation: propIndentation,\n\t\t\tlanguage = \"text\",\n\t\t\tshowLineNumbers: _unusedShowLineNumbers, // not implemented yet\n\t\t\tstyle,\n\t\t\ttabIndex,\n\t\t\tvalue,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst id = useId();\n\t\tconst {\n\t\t\thasCodeExpander,\n\t\t\tisCodeExpanded,\n\t\t\tregisterCodeId,\n\t\t\tsetCopyText,\n\t\t\tunregisterCodeId,\n\t\t} = useContext(CodeBlockContext);\n\t\tconst indentation = inferIndentation(language, propIndentation);\n\n\t\t// trim any leading and trailing whitespace/empty lines, convert leading tabs to spaces\n\t\tconst normalizedAndTrimmedValue = useMemo(\n\t\t\t() => normalizeIndentation(value, { indentation }),\n\t\t\t[value, indentation],\n\t\t);\n\t\tconst [highlightedCodeInnerHtml, setHighlightedCodeInnerHtml] = useState(\n\t\t\t// initialize the <code> inner html with escaped HTML since we are using\n\t\t\t// dangerouslySetInnerHTML to set the inner html of the <code> element\n\t\t\t// and use Prism.js to \"highlight\" the code in a useEffect (client-side only)\n\t\t\tescapeHtml(normalizeIndentation(value, { indentation })),\n\t\t);\n\n\t\tuseEffect(() => {\n\t\t\tconst grammar = Highlighter.languages[language];\n\t\t\tassert(\n\t\t\t\tgrammar,\n\t\t\t\t`CodeBlock does not support the language \"${language}\". The syntax highlighter does not have a grammar for this language. The supported languages are: ${supportedLanguages.join(\", \")}.`,\n\t\t\t);\n\t\t\tconst newHighlightedCodeInnerHtml = Highlighter.highlight(\n\t\t\t\tnormalizedAndTrimmedValue,\n\t\t\t\tgrammar,\n\t\t\t\tlanguage,\n\t\t\t);\n\t\t\tsetHighlightedCodeInnerHtml(newHighlightedCodeInnerHtml);\n\t\t}, [normalizedAndTrimmedValue, language]);\n\n\t\tuseEffect(() => {\n\t\t\tsetCopyText(normalizedAndTrimmedValue);\n\t\t}, [normalizedAndTrimmedValue, setCopyText]);\n\n\t\tuseEffect(() => {\n\t\t\tregisterCodeId(id);\n\n\t\t\treturn () => {\n\t\t\t\tunregisterCodeId(id);\n\t\t\t};\n\t\t}, [id, registerCodeId, unregisterCodeId]);\n\n\t\tconst languageClassName = formatLanguageClassName(language);\n\n\t\treturn (\n\t\t\t<pre\n\t\t\t\taria-expanded={hasCodeExpander ? isCodeExpanded : undefined}\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"scrollbar firefox:after:mr-[3.375rem] firefox:after:inline-block firefox:after:content-[''] overflow-x-auto overflow-y-hidden p-4 pr-14\",\n\t\t\t\t\t\"text-size-inherit text-mono m-0 font-mono\",\n\t\t\t\t\t\"aria-collapsed:max-h-[13.6rem]\",\n\t\t\t\t\tlanguageClassName, // place it last because prism does weird stuff client side, causes hydration mismatches\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tdata-lang={language}\n\t\t\t\tid={id}\n\t\t\t\tref={ref}\n\t\t\t\tstyle={{\n\t\t\t\t\t...style,\n\t\t\t\t\ttabSize: 2,\n\t\t\t\t\tMozTabSize: 2,\n\t\t\t\t}}\n\t\t\t\t// prism.js adds a tabindex of 0 to the pre element by default (unless it's set)\n\t\t\t\t// this is unnecessary, we do not want this automatic behavior!\n\t\t\t\ttabIndex={tabIndex ?? -1}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<code\n\t\t\t\t\tclassName={clsx(\"text-size-inherit\", languageClassName)}\n\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t__html: highlightedCodeInnerHtml,\n\t\t\t\t\t}}\n\t\t\t\t\t// we need to suppress the hydration warning because we are setting the innerHTML of the code block\n\t\t\t\t\t// and using Prism.js to \"highlight\" the code in a useEffect (client-side only), which does different things on the client and server\n\t\t\t\t\tsuppressHydrationWarning\n\t\t\t\t/>\n\t\t\t</pre>\n\t\t);\n\t},\n);\nCodeBlockCode.displayName = \"CodeBlockCode\";\n\n/**\n * The (optional) header slot of the `CodeBlock`. This is where things like the\n * `CodeBlockIcon` and `CodeBlockTitle` are rendered.\n *\n * @see https://mantle.ngrok.com/components/code-block#api-code-block-header\n *\n * @example\n * ```tsx\n * <CodeBlock>\n * <CodeBlockHeader>\n * <CodeBlockIcon preset=\"file\" />\n * <CodeBlockTitle>…</CodeBlockTitle>\n * </CodeBlockHeader>\n * <CodeBlockBody>\n * <CodeBlockCopyButton />\n * <CodeBlockCode language=\"…\" value={fmtCode\\`…\\`} />\n * </CodeBlockBody>\n * <CodeBlockExpanderButton />\n * </CodeBlock>\n * ```\n */\nconst CodeBlockHeader = forwardRef<\n\tComponentRef<\"div\">,\n\tComponentProps<\"div\"> & WithAsChild\n>(({ asChild = false, className, ...props }, ref) => {\n\tconst Component = asChild ? Slot : \"div\";\n\n\treturn (\n\t\t<Component\n\t\t\tclassName={cx(\n\t\t\t\t\"flex items-center gap-1 border-b border-gray-300 bg-gray-100 px-4 py-2 text-gray-700\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\tref={ref}\n\t\t\t{...props}\n\t\t/>\n\t);\n});\nCodeBlockHeader.displayName = \"CodeBlockHeader\";\n\n/**\n * The (optional) title of the `CodeBlock`. Default renders as an h3 element,\n * use asChild to render something else.\n *\n * @see https://mantle.ngrok.com/components/code-block#api-code-block-title\n *\n * @example\n * ```tsx\n * <CodeBlock>\n * <CodeBlockHeader>\n * <CodeBlockIcon preset=\"file\" />\n * <CodeBlockTitle>…</CodeBlockTitle>\n * </CodeBlockHeader>\n * <CodeBlockBody>\n * <CodeBlockCopyButton />\n * <CodeBlockCode language=\"…\" value={fmtCode\\`…\\`} />\n * </CodeBlockBody>\n * <CodeBlockExpanderButton />\n * </CodeBlock>\n * ```\n */\nconst CodeBlockTitle = forwardRef<\n\tHTMLHeadingElement,\n\tHTMLAttributes<HTMLHeadingElement> & { asChild?: boolean }\n>(({ asChild = false, className, ...props }, ref) => {\n\tconst Component = asChild ? Slot : \"h3\";\n\n\treturn (\n\t\t<Component\n\t\t\tref={ref}\n\t\t\tclassName={cx(\"text-mono m-0 font-mono font-normal\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n});\nCodeBlockTitle.displayName = \"CodeBlockTitle\";\n\ntype CodeBlockCopyButtonProps = Omit<\n\tComponentProps<\"button\">,\n\t\"children\" | \"type\"\n> &\n\tWithAsChild & {\n\t\t/**\n\t\t * Callback fired when the copy button is clicked, passes the copied text as an argument.\n\t\t */\n\t\tonCopy?: (value: string) => void;\n\t\t/**\n\t\t * Callback fired when an error occurs during copying.\n\t\t */\n\t\tonCopyError?: (error: unknown) => void;\n\t};\n\n/**\n * The (optional) copy button of the `CodeBlock`. Render this as a child of the\n * `CodeBlockBody` to allow users to copy the code block contents to their\n * clipboard.\n *\n * @see https://mantle.ngrok.com/components/code-block#api-code-block-copy-button\n *\n * @example\n * ```tsx\n * <CodeBlock>\n * <CodeBlockHeader>\n * <CodeBlockIcon preset=\"file\" />\n * <CodeBlockTitle>…</CodeBlockTitle>\n * </CodeBlockHeader>\n * <CodeBlockBody>\n * <CodeBlockCopyButton />\n * <CodeBlockCode language=\"…\" value={fmtCode\\`…\\`} />\n * </CodeBlockBody>\n * <CodeBlockExpanderButton />\n * </CodeBlock>\n * ```\n */\nconst CodeBlockCopyButton = forwardRef<\n\tComponentRef<\"button\">,\n\tCodeBlockCopyButtonProps\n>(\n\t(\n\t\t{ asChild = false, className, onCopy, onCopyError, onClick, ...props },\n\t\tref,\n\t) => {\n\t\tconst { copyText } = useContext(CodeBlockContext);\n\t\tconst [, copyToClipboard] = useCopyToClipboard();\n\t\tconst [wasCopied, setWasCopied] = useState(false);\n\t\tconst timeoutHandle = useRef<number>(0);\n\n\t\tconst Component = asChild ? Slot : \"button\";\n\n\t\treturn (\n\t\t\t<Component\n\t\t\t\ttype=\"button\"\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"focus-visible:border-accent-600 focus-visible:ring-focus-accent absolute right-2.5 top-2.5 z-10 flex size-7 items-center justify-center rounded border border-gray-300 bg-gray-50 shadow-[-1rem_0_0.75rem_-0.375rem_hsl(var(--gray-50)),1rem_0_0_-0.25rem_hsl(var(--gray-50))] hover:border-gray-400 hover:bg-gray-200 focus-visible:outline-none focus-visible:ring-4\",\n\t\t\t\t\twasCopied &&\n\t\t\t\t\t\t\"bg-filled-success text-on-filled hover:bg-filled-success focus:bg-filled-success focus-visible:border-success-600 focus-visible:ring-focus-success w-auto gap-1 border-transparent pl-2 pr-1.5 hover:border-transparent\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\tonClick={async (event) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tonClick?.(event);\n\t\t\t\t\t\tif (event.defaultPrevented) {\n\t\t\t\t\t\t\t// Clear any existing timeout\n\t\t\t\t\t\t\twindow.clearTimeout(timeoutHandle.current);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tawait copyToClipboard(copyText);\n\t\t\t\t\t\tonCopy?.(copyText);\n\t\t\t\t\t\tsetWasCopied(true);\n\n\t\t\t\t\t\t// Clear any existing timeout\n\t\t\t\t\t\twindow.clearTimeout(timeoutHandle.current);\n\n\t\t\t\t\t\t// Reset the copied state after a short delay\n\t\t\t\t\t\ttimeoutHandle.current = window.setTimeout(() => {\n\t\t\t\t\t\t\tsetWasCopied(false);\n\t\t\t\t\t\t}, 2000);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tonCopyError?.(error);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<span className=\"sr-only\">Copy code</span>\n\t\t\t\t{wasCopied ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\tCopied\n\t\t\t\t\t\t<Check className=\"size-4 shrink-0\" weight=\"bold\" />\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<Copy className=\"-ml-px size-5 shrink-0\" />\n\t\t\t\t)}\n\t\t\t</Component>\n\t\t);\n\t},\n);\nCodeBlockCopyButton.displayName = \"CodeBlockCopyButton\";\n\ntype CodeBlockExpanderButtonProps = Omit<\n\tComponentProps<\"button\">,\n\t\"children\" | \"aria-controls\" | \"aria-expanded\"\n> &\n\tWithAsChild;\n\n/**\n * The (optional) expander button of the `CodeBlock`. Render this as a child of the\n * `CodeBlockBody` to allow users to expand/collapse the code block contents.\n *\n * @note If this component is preset, the `CodeBlock` will automatically know\n * that it should be collapsible. Don't use this component if you don't want\n * the code block to be collapsible.\n *\n * @see https://mantle.ngrok.com/components/code-block#api-code-block-expander-button\n *\n * @example\n * ```tsx\n * <CodeBlock>\n * <CodeBlockHeader>\n * <CodeBlockIcon preset=\"file\" />\n * <CodeBlockTitle>…</CodeBlockTitle>\n * </CodeBlockHeader>\n * <CodeBlockBody>\n * <CodeBlockCopyButton />\n * <CodeBlockCode language=\"…\" value={fmtCode\\`…\\`} />\n * </CodeBlockBody>\n * <CodeBlockExpanderButton />\n * </CodeBlock>\n * ```\n */\nconst CodeBlockExpanderButton = forwardRef<\n\tComponentRef<\"button\">,\n\tCodeBlockExpanderButtonProps\n>(({ asChild = false, className, onClick, ...props }, ref) => {\n\tconst { codeId, isCodeExpanded, setIsCodeExpanded, setHasCodeExpander } =\n\t\tuseContext(CodeBlockContext);\n\n\tuseEffect(() => {\n\t\tsetHasCodeExpander(true);\n\n\t\treturn () => {\n\t\t\tsetHasCodeExpander(false);\n\t\t};\n\t}, [setHasCodeExpander]);\n\n\tconst Component = asChild ? Slot : \"button\";\n\n\treturn (\n\t\t<Component\n\t\t\t{...props}\n\t\t\taria-controls={codeId}\n\t\t\taria-expanded={isCodeExpanded}\n\t\t\tclassName={cx(\n\t\t\t\t\"flex w-full items-center justify-center gap-0.5 border-t border-gray-300 bg-gray-50 px-4 py-2 font-sans text-gray-700 hover:bg-gray-100\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\tref={ref}\n\t\t\ttype=\"button\"\n\t\t\tonClick={(event) => {\n\t\t\t\tsetIsCodeExpanded((prev) => !prev);\n\t\t\t\tonClick?.(event);\n\t\t\t}}\n\t\t>\n\t\t\t{isCodeExpanded ? \"Show less\" : \"Show more\"}{\" \"}\n\t\t\t<CaretDown\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"size-4 shrink-0\",\n\t\t\t\t\tisCodeExpanded && \"rotate-180\",\n\t\t\t\t\t\"transition-all duration-150\",\n\t\t\t\t)}\n\t\t\t\tweight=\"bold\"\n\t\t\t/>\n\t\t</Component>\n\t);\n});\nCodeBlockExpanderButton.displayName = \"CodeBlockExpanderButton\";\n\ntype CodeBlockIconProps = Omit<SvgAttributes, \"children\"> &\n\t(\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * A custom icon to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tsvg: ReactNode;\n\t\t\t\t/**\n\t\t\t\t * A preset icon to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tpreset?: undefined | never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * A custom icon to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tsvg?: undefined | never;\n\t\t\t\t/**\n\t\t\t\t * A preset icon to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tpreset: Mode;\n\t\t }\n\t);\n\n/**\n * A small icon that represents the type of code block being displayed,\n * rendered as an SVG next to the code block title in the code block header.\n *\n * You can pass in a custom SVG component or use one of the presets\n * (pass only one of `svg` or `preset`).\n *\n * @see https://mantle.ngrok.com/components/code-block#api-code-block-icon\n *\n * @example\n * ```tsx\n * <CodeBlock>\n * <CodeBlockHeader>\n * <CodeBlockIcon preset=\"file\" />\n * <CodeBlockTitle>…</CodeBlockTitle>\n * </CodeBlockHeader>\n * <CodeBlockBody>\n * <CodeBlockCopyButton />\n * <CodeBlockCode language=\"…\" value={fmtCode\\`…\\`} />\n * </CodeBlockBody>\n * <CodeBlockExpanderButton />\n * </CodeBlock>\n * ```\n */\nfunction CodeBlockIcon({\n\tclassName,\n\tpreset,\n\tsvg: _svgProp,\n\t...props\n}: CodeBlockIconProps) {\n\tlet svg = _svgProp;\n\tif (preset != null) {\n\t\tswitch (preset) {\n\t\t\tcase \"file\":\n\t\t\t\tsvg = <FileText weight=\"fill\" />;\n\t\t\t\tbreak;\n\t\t\tcase \"cli\":\n\t\t\t\tsvg = <Terminal weight=\"fill\" />;\n\t\t\t\tbreak;\n\t\t\tcase \"traffic-policy\":\n\t\t\t\tsvg = <TrafficPolicyFileIcon />;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn <Icon className={className} svg={svg} {...props} />;\n}\n\nexport {\n\tCodeBlock,\n\tCodeBlockBody,\n\tCodeBlockCode,\n\tCodeBlockCopyButton,\n\tCodeBlockExpanderButton,\n\tCodeBlockHeader,\n\tCodeBlockIcon,\n\tCodeBlockTitle,\n};\n\nfunction TrafficPolicyFileIcon(props: SvgAttributes) {\n\treturn (\n\t\t<svg\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\twidth=\"1em\"\n\t\t\theight=\"1em\"\n\t\t\tfill=\"currentColor\"\n\t\t\tviewBox=\"0 0 256 256\"\n\t\t\t{...props}\n\t\t>\n\t\t\t<path fill=\"none\" d=\"M0 0h256v256H0z\" />\n\t\t\t<path d=\"m213.7 82.3-56-56c-1.5-1.5-3.5-2.3-5.7-2.3H56c-8.8 0-16 7.2-16 16v88c0 4.4 3.6 8 8 8s8-3.6 8-8V40h88v48c0 4.4 3.6 8 8 8h48v120h-40c-4.4 0-8 3.6-8 8s3.6 8 8 8h40c8.8 0 16-7.2 16-16V88c0-2.1-.8-4.2-2.3-5.7zm-53.7-31L188.7 80H160V51.3z\" />\n\t\t\t<path d=\"M124.6 194.5h-6.8v-27.3h6.8c1.9 0 3.4-1.5 3.4-3.4s-1.5-3.4-3.4-3.4h-6.8v-10.2c0-3.8-3.1-6.8-6.8-6.8H63.3c-3.8 0-6.8 3.1-6.8 6.8v10.2h-6.8c-1.9 0-3.4 1.5-3.4 3.4s1.5 3.4 3.4 3.4h6.8v27.3h-6.8c-1.9 0-3.4 1.5-3.4 3.4s1.5 3.4 3.4 3.4h6.8v23.9c0 3.8 3.1 6.8 6.8 6.8H111c3.8 0 6.8-3.1 6.8-6.8v-23.9h6.8c1.9 0 3.4-1.5 3.4-3.4s-1.5-3.4-3.4-3.4zm-37.5-11.9c-6.6 0-11.9-5.3-11.9-11.9s5.3-11.9 11.9-11.9S99 164.1 99 170.7s-5.3 11.9-11.9 11.9zm0 10.2c6.6 0 11.9 5.3 11.9 11.9s-5.3 11.9-11.9 11.9-11.9-5.3-11.9-11.9 5.3-11.9 11.9-11.9z\" />\n\t\t</svg>\n\t);\n}\n","/**\n * Escapes special HTML characters in a string to their corresponding\n * HTML entities, preventing issues like unintended HTML rendering or\n * cross-site scripting (XSS) when injecting raw strings into the DOM\n * using `dangerouslySetInnerHTML`.\n *\n * Characters escaped:\n * - \\& => `&`;\n * - \\< => `<`;\n * - \\> => `>`;\n * - \\\" => `"`;\n * - \\' => `'`;\n *\n * @param {string} value The raw string to be escaped.\n *\n * @example\n * escapeHtml('<div>Hello & \"world\"</div>');\n * // Returns: '<div>Hello & "world"</div>'\n */\nfunction escapeHtml(value: string): string {\n\tlet escaped = \"\";\n\tfor (const character of value) {\n\t\tswitch (character) {\n\t\t\tcase \"&\":\n\t\t\t\tescaped += \"&\";\n\t\t\t\tbreak;\n\t\t\tcase \"<\":\n\t\t\t\tescaped += \"<\";\n\t\t\t\tbreak;\n\t\t\tcase \">\":\n\t\t\t\tescaped += \">\";\n\t\t\t\tbreak;\n\t\t\tcase '\"':\n\t\t\t\tescaped += \""\";\n\t\t\t\tbreak;\n\t\t\tcase \"'\":\n\t\t\t\tescaped += \"'\";\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tescaped += character;\n\t\t}\n\t}\n\treturn escaped;\n}\n\nexport {\n\t//,\n\tescapeHtml,\n};\n","import Prism from \"prismjs\";\nimport \"prismjs/components/prism-bash.js\";\nimport \"prismjs/components/prism-csharp.js\";\nimport \"prismjs/components/prism-css.js\";\nimport \"prismjs/components/prism-go.js\";\nimport \"prismjs/components/prism-java.js\";\nimport \"prismjs/components/prism-javascript.js\";\nimport \"prismjs/components/prism-json.js\";\nimport \"prismjs/components/prism-jsx.js\";\nimport \"prismjs/components/prism-markup.js\";\nimport \"prismjs/components/prism-python.js\";\nimport \"prismjs/components/prism-ruby.js\";\nimport \"prismjs/components/prism-rust.js\";\nimport \"prismjs/components/prism-tsx.js\";\nimport \"prismjs/components/prism-typescript.js\";\nimport \"prismjs/components/prism-yaml.js\";\n\nexport {\n\t//,\n\tPrism as Highlighter,\n};\n","import type { SupportedLanguage } from \"./supported-languages.js\";\n\nconst indentations = [\"tabs\", \"spaces\"] as const;\ntype Indentation = (typeof indentations)[number];\n\n/**\n * Infers the indentation type based on the language and preferred indentation.\n *\n * @param language - The language to check.\n * @param preferredIndentation - The preferred indentation type (overrides what is detected).\n */\nfunction inferIndentation(\n\tlanguage: SupportedLanguage,\n\tpreferredIndentation: Indentation | undefined,\n) {\n\t// if the user has a preferred indentation, use that regardless of the language\n\tif (preferredIndentation) {\n\t\treturn preferredIndentation;\n\t}\n\n\tif (isTabIndentedLanguage(language)) {\n\t\treturn \"tabs\";\n\t}\n\n\tif (isSpaceIndentedLanguage(language)) {\n\t\treturn \"spaces\";\n\t}\n\n\treturn \"spaces\";\n}\n\nexport {\n\t//,\n\tindentations,\n\tinferIndentation,\n};\n\nexport type {\n\t//,\n\tIndentation,\n};\n\n/**\n * Languages that require or strongly prefer tabs\n */\nconst tabIndentedLanguages = [\n\t\"csharp\",\n\t\"css\",\n\t\"go\",\n\t\"html\",\n\t\"java\",\n\t\"javascript\",\n\t\"js\",\n\t\"jsx\",\n\t\"ts\",\n\t\"tsx\",\n\t\"typescript\",\n\t\"xml\",\n] as const satisfies SupportedLanguage[];\n\n/**\n * Languages that require or strongly prefer spaces\n */\nconst spaceIndentedLanguages = [\n\t\"python\",\n\t\"py\",\n\t\"yaml\",\n\t\"yml\",\n\t\"ruby\",\n\t\"rb\",\n] as const satisfies SupportedLanguage[];\n\ntype TabIndentedLanguage = (typeof tabIndentedLanguages)[number];\ntype SpaceIndentedLanguage = (typeof spaceIndentedLanguages)[number];\n\n/**\n * Type Predicate: checks if the given value is a required/preferred tab-indented language.\n */\nfunction isTabIndentedLanguage(\n\tvalue: SupportedLanguage,\n): value is TabIndentedLanguage {\n\treturn tabIndentedLanguages.includes(value as TabIndentedLanguage);\n}\n\n/**\n * Type Predicate: checks if the given value is a required/preferred space-indented language.\n */\nfunction isSpaceIndentedLanguage(\n\tvalue: SupportedLanguage,\n): value is SpaceIndentedLanguage {\n\treturn spaceIndentedLanguages.includes(value as SpaceIndentedLanguage);\n}\n","import type { Indentation } from \"./indentation.js\";\n\ntype Options = {\n\t/**\n\t * The indentation type to use. Can be either \"tabs\" or \"spaces\".\n\t * @default \"spaces\"\n\t */\n\tindentation?: Indentation;\n};\n\n/**\n * Trim any leading and trailing whitespace/empty lines, convert leading\n * indentation to the given options.indentation\n */\nfunction normalizeIndentation(value: string, options?: Options): string {\n\tconst { indentation = \"spaces\" } = options || {};\n\n\treturn value.trim().replace(/^[ \\t]*(?=\\S)/gm, (match) => {\n\t\t// 1 tab === 2 spaces\n\t\t// convert tabs to spaces and spaces to tabs\n\t\tif (indentation === \"spaces\") {\n\t\t\treturn match.replace(/\\t/g, \" \");\n\t\t}\n\t\treturn match.replace(/ {2}/g, \"\\t\");\n\t});\n}\n\nexport {\n\t//,\n\tnormalizeIndentation,\n};\n","/**\n * List of supported languages for syntax highlighting.\n * @private\n */\nexport const supportedLanguages = [\n\t\"bash\",\n\t\"cs\",\n\t\"csharp\",\n\t\"css\",\n\t\"dotnet\",\n\t\"go\",\n\t\"html\",\n\t\"java\",\n\t\"javascript\",\n\t\"js\",\n\t\"json\",\n\t\"jsx\",\n\t\"markup\",\n\t\"plain\",\n\t\"plaintext\",\n\t\"py\",\n\t\"python\",\n\t\"rb\",\n\t\"ruby\",\n\t\"rust\",\n\t\"sh\",\n\t\"shell\",\n\t\"text\",\n\t\"ts\",\n\t\"tsx\",\n\t\"txt\",\n\t\"typescript\",\n\t\"xml\",\n\t\"yaml\",\n\t\"yml\",\n] as const;\n\n/**\n * Supported languages for syntax highlighting.\n */\ntype SupportedLanguage = (typeof supportedLanguages)[number];\n\n/**\n * Parses a markdown code block (```) language class into a SupportedLanguage.\n * Defaults to \"sh\" if no supported language is found.\n */\nfunction parseLanguage(\n\tvalue: `language-${string}` | `lang-${string}` | (string & {}) | undefined,\n): SupportedLanguage {\n\tif (!value) {\n\t\treturn \"sh\";\n\t}\n\n\t// remove leading \"language-\" and \"lang-\" prefixes\n\t// find first '-' and slice from there\n\tconst maybeLanguage = value.trim().slice(value.indexOf(\"-\") + 1);\n\n\treturn isSupportedLanguage(maybeLanguage) ? maybeLanguage : \"sh\";\n}\n\n/**\n * Type Predicate: checks if an arbitrary value is a supported syntax highlighting language.\n */\nconst isSupportedLanguage = (value: unknown): value is SupportedLanguage => {\n\treturn (\n\t\ttypeof value === \"string\" &&\n\t\tsupportedLanguages.includes(value as SupportedLanguage)\n\t);\n};\n\n/**\n * A class name for a language that Prism.js can understand.\n */\ntype LanguageClass = `language-${SupportedLanguage}`;\n\n/**\n * Formats a language name into a class name that Prism.js can understand.\n * @default \"language-sh\"\n */\nfunction formatLanguageClassName(\n\tlanguage: SupportedLanguage | undefined = \"sh\",\n) {\n\tconst lang = language ?? \"sh\";\n\tconst className: LanguageClass = `language-${lang}`;\n\treturn className;\n}\n\nexport { isSupportedLanguage, parseLanguage, formatLanguageClassName };\nexport type { SupportedLanguage };\n","type Primitive = string | number | boolean | undefined | null;\n\n/**\n * Tagged template literal to format code blocks and normalize leading indentation\n */\nfunction fmtCode(\n\tstrings: TemplateStringsArray,\n\t...values: Primitive[]\n): string {\n\tif (!isTemplateStringsArray(strings) || !Array.isArray(values)) {\n\t\tthrow new Error(\n\t\t\t\"It looks like you tried to call `fmtCode` as a function. Make sure to use it as a tagged template.\\n\\tExample: fmtCode`SELECT * FROM users`, not fmtCode('SELECT * FROM users')\",\n\t\t);\n\t}\n\n\tconst text = String.raw({ raw: strings }, ...values);\n\n\t// fine the minimum indentation of the code block\n\tconst minIndent = findMinIndent(text);\n\tconst lines = text.trim().split(\"\\n\");\n\n\treturn lines\n\t\t.map((line) => {\n\t\t\t// remove nothing if the line doesn't start with indentation\n\t\t\tif (/^\\S+/.test(line)) {\n\t\t\t\treturn line;\n\t\t\t}\n\t\t\treturn line.slice(minIndent);\n\t\t})\n\t\t.join(\"\\n\");\n}\n\nexport {\n\t//,\n\tfmtCode,\n};\n\n/**\n * Find the shortest indentation of a multiline string\n */\nfunction findMinIndent(value: string): number {\n\tconst match = value.match(/^[ \\t]*(?=\\S)/gm);\n\n\tif (!match) {\n\t\treturn 0;\n\t}\n\n\treturn match.reduce(\n\t\t(acc, curr) => Math.min(acc, curr.length),\n\t\tNumber.POSITIVE_INFINITY,\n\t);\n}\n\n/**\n * Type guard to check if a value is a `TemplateStringsArray`\n */\nfunction isTemplateStringsArray(\n\tstrings: unknown,\n): strings is TemplateStringsArray {\n\treturn (\n\t\tArray.isArray(strings) && \"raw\" in strings && Array.isArray(strings.raw)\n\t);\n}\n","import { z } from \"zod\";\nimport { indentations } from \"./indentation.js\";\n\nconst modes = [\n\t//,\n\t\"cli\",\n\t\"file\",\n\t\"traffic-policy\",\n] as const;\ntype Mode = (typeof modes)[number];\n\nconst metaSchema = z.object({\n\tcollapsible: z.boolean().default(false),\n\tdisableCopy: z.boolean().default(false),\n\tmode: z.enum(modes).optional(),\n\ttitle: z.string().trim().optional(),\n\tindentation: z.enum(indentations).optional(),\n});\n\ntype MetaInput = z.input<typeof metaSchema>;\n\ntype Meta = z.infer<typeof metaSchema>;\n\nconst defaultMeta = {\n\tcollapsible: false,\n\tdisableCopy: false,\n\tmode: undefined,\n\ttitle: undefined,\n\tindentation: undefined,\n} as const satisfies Meta;\n\ntype DefaultMeta = typeof defaultMeta;\n\n/**\n * Parses a markdown code block (```) metastring into a meta object.\n * Defaults to DefaultMeta if no metastring given or if metastring is invalid.\n * Useful for parsing the metastring from a markdown code block to pass into the\n * CodeBlock components as props.\n */\nfunction parseMetastring(value: string | undefined): Meta {\n\tconst metastring = value?.trim() ?? \"\";\n\tif (!metastring) {\n\t\treturn defaultMeta;\n\t}\n\n\tconst metaJson = tokenizeMetastring(metastring).reduce<\n\t\tRecord<string, unknown>\n\t>((acc, token) => {\n\t\tconst [key, _value] = token.split(\"=\");\n\t\tif (!key) {\n\t\t\treturn acc;\n\t\t}\n\t\tconst value = normalizeValue(_value);\n\t\tacc[key] = value ?? true;\n\t\treturn acc;\n\t}, {});\n\n\ttry {\n\t\tconst parsed = metaSchema.parse(metaJson);\n\n\t\t// return the parsed meta object, with default values filled in\n\t\treturn {\n\t\t\t...defaultMeta,\n\t\t\t...parsed,\n\t\t};\n\t} catch (_) {\n\t\treturn defaultMeta;\n\t}\n}\n\nexport {\n\t//,\n\tdefaultMeta,\n\tparseMetastring,\n};\nexport type {\n\t//,\n\tMeta,\n\tMetaInput,\n\tMode,\n\tDefaultMeta,\n};\n\n/**\n * Remove leading and trailing `\"` quotes around value\n * @private\n */\nexport function normalizeValue(value: string | undefined) {\n\treturn value?.trim().replace(/^\"(.*)\"$/, \"$1\");\n}\n\n/**\n * Splits a metastring into an array of tokens that can be parsed into a meta object.\n * Should allow for quotes and spaces in tokens\n * @private\n */\nexport function tokenizeMetastring(value: string | undefined): string[] {\n\tconst input = value?.trim() ?? \"\";\n\tconst result: string[] = [];\n\n\tlet currentString = \"\";\n\tlet inQuotes = false;\n\n\tfor (const char of input) {\n\t\tif (char === \" \" && !inQuotes) {\n\t\t\tif (currentString) {\n\t\t\t\tresult.push(currentString);\n\t\t\t\tcurrentString = \"\";\n\t\t\t}\n\t\t} else if (char === '\"') {\n\t\t\tinQuotes = !inQuotes;\n\t\t\tcurrentString += char;\n\t\t} else {\n\t\t\tcurrentString += char;\n\t\t}\n\t}\n\n\tif (currentString) {\n\t\tresult.push(currentString);\n\t}\n\n\treturn result;\n}\n"],"mappings":"oJAAA,OAAS,aAAAA,OAAiB,kCAC1B,OAAS,SAAAC,OAAa,8BACtB,OAAS,QAAAC,OAAY,6BACrB,OAAS,YAAAC,OAAgB,iCACzB,OAAS,YAAAC,OAAgB,iCACzB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B,GAAM,CAACC,EAAKC,CAAM,EAAIF,EAAM,MAAM,GAAG,EACrC,GAAI,CAACC,EACJ,OAAOF,EAER,IAAMJ,EAAQQ,GAAeD,CAAM,EACnC,OAAAH,EAAIE,CAAG,EAAIN,GAAS,GACbI,CACR,EAAG,CAAC,CAAC,EAEL,GAAI,CACH,IAAMK,EAASd,GAAW,MAAMO,CAAQ,EAGxC,MAAO,CACN,GAAGJ,EACH,GAAGW,CACJ,CACD,MAAY,CACX,OAAOX,CACR,CACD,CAmBO,SAASY,GAAeC,EAA2B,CACzD,OAAOA,GAAO,KAAK,EAAE,QAAQ,WAAY,IAAI,CAC9C,CAOO,SAASC,GAAmBD,EAAqC,CACvE,IAAME,EAAQF,GAAO,KAAK,GAAK,GACzBG,EAAmB,CAAC,EAEtBC,EAAgB,GAChBC,EAAW,GAEf,QAAWC,KAAQJ,EACdI,IAAS,KAAO,CAACD,EAChBD,IACHD,EAAO,KAAKC,CAAa,EACzBA,EAAgB,KAEPE,IAAS,MACnBD,EAAW,CAACA,GACZD,GAAiBE,GAMnB,OAAIF,GACHD,EAAO,KAAKC,CAAa,EAGnBD,CACR","names":["CaretDown","Check","Copy","FileText","Terminal","Slot","clsx","createContext","forwardRef","useContext","useEffect","useId","useMemo","useRef","useState","assert","escapeHtml","value","escaped","character","Prism","indentations","inferIndentation","language","preferredIndentation","isTabIndentedLanguage","isSpaceIndentedLanguage","tabIndentedLanguages","spaceIndentedLanguages","isTabIndentedLanguage","value","isSpaceIndentedLanguage","normalizeIndentation","value","options","indentation","match","supportedLanguages","parseLanguage","value","maybeLanguage","isSupportedLanguage","formatLanguageClassName","language","Fragment","jsx","jsxs","CodeBlockContext","createContext","CodeBlock","forwardRef","asChild","className","props","ref","copyText","setCopyText","useState","hasCodeExpander","setHasCodeExpander","isCodeExpanded","setIsCodeExpanded","codeId","setCodeId","context","useMemo","id","old","assert","Component","Slot","cx","CodeBlockBody","CodeBlockCode","_unusedHighlightLines","propIndentation","language","_unusedShowLineNumbers","style","tabIndex","value","useId","registerCodeId","unregisterCodeId","useContext","indentation","inferIndentation","normalizedAndTrimmedValue","normalizeIndentation","highlightedCodeInnerHtml","setHighlightedCodeInnerHtml","escapeHtml","useEffect","grammar","Prism","supportedLanguages","newHighlightedCodeInnerHtml","languageClassName","formatLanguageClassName","clsx","CodeBlockHeader","CodeBlockTitle","CodeBlockCopyButton","onCopy","onCopyError","onClick","copyToClipboard","useCopyToClipboard","wasCopied","setWasCopied","timeoutHandle","useRef","event","error","Check","Copy","CodeBlockExpanderButton","prev","CaretDown","CodeBlockIcon","preset","_svgProp","svg","FileText","Terminal","TrafficPolicyFileIcon","Icon","TrafficPolicyFileIcon","props","jsxs","jsx","fmtCode","strings","values","isTemplateStringsArray","text","minIndent","findMinIndent","line","findMinIndent","value","match","acc","curr","isTemplateStringsArray","strings","z","modes","metaSchema","z","indentations","defaultMeta","parseMetastring","value","metastring","metaJson","tokenizeMetastring","acc","token","key","_value","normalizeValue","parsed","normalizeValue","value","tokenizeMetastring","input","result","currentString","inQuotes","char"]}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "mantle is ngrok's UI library and design system.",
|
|
4
4
|
"author": "ngrok",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.25.0",
|
|
7
7
|
"homepage": "https://mantle.ngrok.com",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@ariakit/react": "0.4.16",
|
|
29
29
|
"@headlessui/react": "2.2.1",
|
|
30
|
-
"@radix-ui/react-accordion": "1.2.
|
|
31
|
-
"@radix-ui/react-dialog": "1.1.
|
|
32
|
-
"@radix-ui/react-dropdown-menu": "2.1.
|
|
33
|
-
"@radix-ui/react-hover-card": "1.1.
|
|
34
|
-
"@radix-ui/react-popover": "1.1.
|
|
35
|
-
"@radix-ui/react-select": "2.1.
|
|
36
|
-
"@radix-ui/react-slot": "1.
|
|
37
|
-
"@radix-ui/react-switch": "1.1.
|
|
38
|
-
"@radix-ui/react-tabs": "1.1.
|
|
39
|
-
"@radix-ui/react-tooltip": "1.
|
|
30
|
+
"@radix-ui/react-accordion": "1.2.4",
|
|
31
|
+
"@radix-ui/react-dialog": "1.1.7",
|
|
32
|
+
"@radix-ui/react-dropdown-menu": "2.1.7",
|
|
33
|
+
"@radix-ui/react-hover-card": "1.1.7",
|
|
34
|
+
"@radix-ui/react-popover": "1.1.7",
|
|
35
|
+
"@radix-ui/react-select": "2.1.7",
|
|
36
|
+
"@radix-ui/react-slot": "1.2.0",
|
|
37
|
+
"@radix-ui/react-switch": "1.1.4",
|
|
38
|
+
"@radix-ui/react-tabs": "1.1.4",
|
|
39
|
+
"@radix-ui/react-tooltip": "1.2.0",
|
|
40
40
|
"@tanstack/react-table": "8.21.2",
|
|
41
41
|
"@uidotdev/usehooks": "2.4.1",
|
|
42
42
|
"class-variance-authority": "0.7.1",
|