@ngrok/mantle 0.79.2 → 0.80.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/accordion.d.ts +169 -12
- package/dist/accordion.js +1 -1
- package/dist/agent.json +1 -1
- package/dist/alert-dialog.d.ts +496 -30
- package/dist/alert-dialog.js +1 -1
- package/dist/alert.d.ts +129 -9
- package/dist/alert.js +1 -1
- package/dist/anchor-_2meGDfj.js +1 -0
- package/dist/anchor.d.ts +2 -2
- package/dist/anchor.js +1 -1
- package/dist/as-child-D23mGo4f.d.ts +49 -0
- package/dist/badge.d.ts +44 -5
- package/dist/badge.js +1 -1
- package/dist/breadcrumb.d.ts +214 -14
- package/dist/breadcrumb.js +1 -1
- package/dist/button-5WsvzIQ6.js +1 -0
- package/dist/{button-DcXOWUYo.d.ts → button-BPMwa2jN.d.ts} +3 -3
- package/dist/button-D9n09xUg.js +1 -0
- package/dist/button.d.ts +3 -3
- package/dist/button.js +1 -1
- package/dist/calendar.d.ts +0 -3
- package/dist/calendar.js +1 -1
- package/dist/card.d.ts +146 -9
- package/dist/card.js +1 -1
- package/dist/centered-layout.d.ts +224 -8
- package/dist/centered-layout.js +1 -1
- package/dist/checkbox-Cq17y0-R.js +1 -0
- package/dist/checkbox.d.ts +12 -10
- package/dist/checkbox.js +1 -1
- package/dist/choice-Cc8dA5r8.js +1 -0
- package/dist/choice-Ct0KK8jw.d.ts +269 -0
- package/dist/choice.d.ts +1 -252
- package/dist/choice.js +1 -1
- package/dist/code-block.d.ts +270 -50
- package/dist/code-block.js +6 -6
- package/dist/code-block_highlight-utils.js +1 -1
- package/dist/code.d.ts +3 -2
- package/dist/code.js +1 -1
- package/dist/combobox.d.ts +190 -11
- package/dist/combobox.js +1 -1
- package/dist/command.d.ts +285 -81
- package/dist/command.js +1 -1
- package/dist/compose-refs-BdBMM9ga.js +1 -0
- package/dist/data-table.d.ts +33 -5
- package/dist/data-table.js +1 -1
- package/dist/description-list.d.ts +79 -6
- package/dist/description-list.js +1 -1
- package/dist/dialog-CQ2C6vkE.js +1 -0
- package/dist/dialog.d.ts +239 -18
- package/dist/dialog.js +1 -1
- package/dist/dropdown-menu-CSCDdA3K.js +1 -0
- package/dist/{dropdown-menu-DP_Ne9Mr.d.ts → dropdown-menu-CoyozLzy.d.ts} +170 -29
- package/dist/dropdown-menu.d.ts +2 -2
- package/dist/dropdown-menu.js +1 -1
- package/dist/empty.d.ts +1 -1
- package/dist/empty.js +1 -1
- package/dist/field.d.ts +596 -45
- package/dist/field.js +1 -1
- package/dist/flag.d.ts +0 -3
- package/dist/flag.js +1 -1
- package/dist/hooks.d.ts +3 -4
- package/dist/hooks.js +1 -1
- package/dist/hover-card.d.ts +54 -4
- package/dist/hover-card.js +1 -1
- package/dist/{icon-Cevjo93X.d.ts → icon-BDqpcZ-n.d.ts} +1 -1
- package/dist/icon-CGgMKpJg.js +1 -0
- package/dist/{icon-button-B7uEj1qq.d.ts → icon-button-C1AfGnQx.d.ts} +11 -60
- package/dist/icon-button-DiOhreJD.js +1 -0
- package/dist/icon.d.ts +2 -2
- package/dist/icon.js +1 -1
- package/dist/icons.d.ts +5 -13
- package/dist/icons.js +1 -1
- package/dist/{in-view-nkSOdED2.d.ts → in-view-DDEGUKDR.d.ts} +17 -9
- package/dist/index-B8mIWKIU.d.ts +211 -0
- package/dist/{index-Rv8RL7xy.d.ts → index-BtwKJTLq.d.ts} +1 -1
- package/dist/{index-BivvYYs-.d.ts → index-C2jj8U4a.d.ts} +8 -5
- package/dist/index-CdPXa9h1.d.ts +1 -0
- package/dist/{index-D47aqlpz.d.ts → index-DA4ig3gj.d.ts} +1 -1
- package/dist/input-CVyAVbim.js +1 -0
- package/dist/{types-C19IR7jf.d.ts → input-DV9M6K4v.d.ts} +42 -2
- package/dist/input.d.ts +4 -55
- package/dist/input.js +1 -1
- package/dist/{label-v2-bv98k.d.ts → label-C6YH9skg.d.ts} +8 -6
- package/dist/label-D-D11mlp.js +1 -0
- package/dist/label.d.ts +1 -1
- package/dist/label.js +1 -1
- package/dist/list.d.ts +150 -6
- package/dist/list.js +1 -1
- package/dist/llms.txt +1 -1
- package/dist/main.d.ts +20 -4
- package/dist/main.js +1 -1
- package/dist/mantle.css +21 -7
- package/dist/media-object.d.ts +27 -4
- package/dist/media-object.js +1 -1
- package/dist/multi-select.d.ts +312 -15
- package/dist/multi-select.js +1 -1
- package/dist/otp-input.d.ts +129 -5
- package/dist/otp-input.js +1 -1
- package/dist/pagination.d.ts +70 -6
- package/dist/pagination.js +1 -1
- package/dist/popover-CBMADtjV.js +1 -0
- package/dist/popover.d.ts +1 -181
- package/dist/popover.js +1 -1
- package/dist/primitive-CJRIlrLz.d.ts +31 -0
- package/dist/primitive-DCPHJsRs.js +1 -0
- package/dist/progress.js +1 -1
- package/dist/qr-code.d.ts +113 -5
- package/dist/qr-code.js +1 -1
- package/dist/radio-group.d.ts +128 -23
- package/dist/radio-group.js +1 -1
- package/dist/{resolve-pre-rendered-props-C3e5Auo3.js → resolve-pre-rendered-props-C9uaM9-V.js} +1 -1
- package/dist/sandboxed-on-click.d.ts +2 -2
- package/dist/sandboxed-on-click.js +1 -1
- package/dist/select-SR_9-bxA.js +1 -0
- package/dist/select-idm1jy7y.d.ts +600 -0
- package/dist/select.d.ts +1 -1
- package/dist/select.js +1 -1
- package/dist/selectable-list.d.ts +252 -298
- package/dist/selectable-list.js +1 -1
- package/dist/separator-B5UmkVRL.d.ts +75 -0
- package/dist/separator-bpE_kooz.js +1 -0
- package/dist/separator.d.ts +1 -52
- package/dist/separator.js +1 -1
- package/dist/sheet.d.ts +295 -21
- package/dist/sheet.js +1 -1
- package/dist/skeleton-CsbUHbBA.js +1 -0
- package/dist/skeleton.d.ts +4 -7
- package/dist/skeleton.js +1 -1
- package/dist/skip-to-main-link.d.ts +24 -4
- package/dist/skip-to-main-link.js +1 -1
- package/dist/slot-CDk0Bb9z.js +1 -0
- package/dist/slot.d.ts +1 -1
- package/dist/slot.js +1 -1
- package/dist/{sort-BPX2Fk9t.js → sort-B_DDQcVD.js} +1 -1
- package/dist/split-button.d.ts +28 -13
- package/dist/split-button.js +1 -1
- package/dist/{svg-only-BFeFS1aa.d.ts → svg-only-CdI_v82i.d.ts} +1 -1
- package/dist/svg-only-d-nMCfAI.js +1 -0
- package/dist/switch.d.ts +9 -6
- package/dist/switch.js +1 -1
- package/dist/table-DUSvU_Jw.d.ts +875 -0
- package/dist/table-GDkapNFi.js +1 -0
- package/dist/table.d.ts +1 -1
- package/dist/table.js +1 -1
- package/dist/tabs.d.ts +139 -12
- package/dist/tabs.js +1 -1
- package/dist/text-area.d.ts +1 -1
- package/dist/text-area.js +1 -1
- package/dist/theme-provider-BftkIiZn.js +1 -0
- package/dist/theme-switcher.d.ts +110 -29
- package/dist/theme-switcher.js +1 -1
- package/dist/theme-wVnzzx2F.js +1 -0
- package/dist/theme.d.ts +53 -14
- package/dist/theme.js +1 -1
- package/dist/toast-DKgMRv4F.js +1 -0
- package/dist/toast.d.ts +98 -10
- package/dist/toast.js +1 -1
- package/dist/tooltip.d.ts +28 -1
- package/dist/tooltip.js +1 -1
- package/dist/{traffic-policy-file-0g5RXFqu.js → traffic-policy-file-CF1lbWtp.js} +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/dist/virtual-UrzmaSQm.js +1 -0
- package/dist/well.d.ts +3 -3
- package/dist/well.js +1 -1
- package/package.json +5 -5
- package/dist/anchor-C_tjSVy6.js +0 -1
- package/dist/as-child-CYEVu1WY.d.ts +0 -23
- package/dist/button-5t6-JS_I.js +0 -1
- package/dist/button-ClC60Nzg.js +0 -1
- package/dist/checkbox-DJ2xl7Rc.js +0 -1
- package/dist/choice-DOdyNzFC.js +0 -1
- package/dist/compose-refs-Cjf2gfB8.js +0 -1
- package/dist/dialog-ZCgG41hx.js +0 -1
- package/dist/dropdown-menu-Bt1aKF1g.js +0 -1
- package/dist/icon-CDtYjF_H.js +0 -1
- package/dist/icon-button-DV2-GZHf.js +0 -1
- package/dist/index-g2rfwNCH.d.ts +0 -1
- package/dist/input-Ct1YOqSy.js +0 -1
- package/dist/label-BMlHW_2D.js +0 -1
- package/dist/popover-D5WxxnBY.js +0 -1
- package/dist/primitive-C64-m48O.d.ts +0 -13
- package/dist/primitive-M-kZdNIS.js +0 -1
- package/dist/select-Bwt2YduR.d.ts +0 -345
- package/dist/select-D-5u0Blc.js +0 -1
- package/dist/separator-kBnnv3Cw.js +0 -1
- package/dist/skeleton-Bu3tgNcW.js +0 -1
- package/dist/slot-DmPrjM7N.js +0 -1
- package/dist/svg-only-DDx6FtJd.js +0 -1
- package/dist/table-CPH2md2-.js +0 -1
- package/dist/table-CwFHXC-G.d.ts +0 -414
- package/dist/theme-D8kZCOzM.js +0 -1
- package/dist/theme-provider-Djj_jBo6.js +0 -1
- package/dist/toast-D3ntBmn4.js +0 -1
- package/dist/virtual-DZMBu7Ch.js +0 -1
package/dist/code-block.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as WithAsChild, t as SelfClosingWithAsChild } from "./as-child-D23mGo4f.js";
|
|
2
2
|
import { t as SvgAttributes } from "./types-D1RY5Tcj.js";
|
|
3
3
|
import { A as FoldStrategy, B as computeJsonFoldRanges, C as Indentation, D as FoldExplanation, E as ComputeFoldRangesInput, F as isSupportedLanguage, H as finalizeFoldRanges, I as parseLanguage, L as supportedLanguages, M as computeFoldRanges, N as foldStrategyFor, O as FoldLine, P as SupportedLanguage, S as normalizeIndentation, T as isIndentation, U as LineRange, V as FoldableRange, _ as MantleCodeBlockValue, a as Mode, c as ResolvedPreRenderedCodeBlockProps, d as parseMetastring, f as resolvePreRenderedCodeBlockProps, g as parseCodeBlockShowLineNumbers, h as parseCodeBlockLineNumberStart, i as MetaInput, j as FoldToken, k as FoldScope, l as defaultMeta, m as parseCodeBlockHighlightLines, n as DefaultMeta, o as ResolvePreRenderedCodeBlockPropsInput, p as tokenizeMetastring, r as Meta, s as ResolvePreRenderedCodeBlockPropsResult, t as CodeBlockPreElementInput, u as normalizeValue, v as MantleCodeOptions, w as inferIndentation, x as mantleCode, y as createMantleCodeBlockValue, z as decorateHighlightedHtml } from "./resolve-pre-rendered-props-B6OlZrSI.js";
|
|
4
|
-
import { ComponentProps,
|
|
4
|
+
import { ComponentProps, ReactNode } from "react";
|
|
5
5
|
import { Content, List, Trigger } from "@radix-ui/react-tabs";
|
|
6
6
|
//#region src/components/code-block/code-block.d.ts
|
|
7
7
|
type CodeBlockRootProps = Omit<ComponentProps<"div">, "align"> & WithAsChild & {
|
|
@@ -21,6 +21,55 @@ type CodeBlockRootProps = Omit<ComponentProps<"div">, "align"> & WithAsChild & {
|
|
|
21
21
|
*/
|
|
22
22
|
onActiveTabChange?: (value: string) => void;
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Shiki-powered code blocks with build-time syntax highlighting and zero browser bundle.
|
|
26
|
+
* This is the root component for all CodeBlock components.
|
|
27
|
+
*
|
|
28
|
+
* For tabbed code blocks, pass `defaultTab` (uncontrolled) or `activeTab` / `onActiveTabChange`
|
|
29
|
+
* (controlled) to enable tab switching with `CodeBlock.TabList` and `CodeBlock.TabContent`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <CodeBlock.Root>
|
|
34
|
+
* <CodeBlock.Header>
|
|
35
|
+
* <CodeBlock.Icon preset="file" />
|
|
36
|
+
* <CodeBlock.Title>example.ts</CodeBlock.Title>
|
|
37
|
+
* </CodeBlock.Header>
|
|
38
|
+
* <CodeBlock.Body>
|
|
39
|
+
* <CodeBlock.CopyButton />
|
|
40
|
+
* <CodeBlock.Code value={mantleCode("typescript")`const x = "hello";`} />
|
|
41
|
+
* </CodeBlock.Body>
|
|
42
|
+
* <CodeBlock.ExpanderButton />
|
|
43
|
+
* </CodeBlock.Root>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare const Root$1: {
|
|
47
|
+
({ asChild, className, defaultTab, activeTab, onActiveTabChange, ref, ...props }: CodeBlockRootProps): import("react").JSX.Element;
|
|
48
|
+
displayName: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The body of the `CodeBlock`. This is where `CodeBlock.Code` and
|
|
52
|
+
* the optional `CodeBlock.CopyButton` are rendered.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <CodeBlock.Root>
|
|
57
|
+
* <CodeBlock.Header>
|
|
58
|
+
* <CodeBlock.Icon preset="file" />
|
|
59
|
+
* <CodeBlock.Title>example.ts</CodeBlock.Title>
|
|
60
|
+
* </CodeBlock.Header>
|
|
61
|
+
* <CodeBlock.Body>
|
|
62
|
+
* <CodeBlock.CopyButton />
|
|
63
|
+
* <CodeBlock.Code value={mantleCode("typescript")`const x = "hello";`} />
|
|
64
|
+
* </CodeBlock.Body>
|
|
65
|
+
* <CodeBlock.ExpanderButton />
|
|
66
|
+
* </CodeBlock.Root>
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
declare const Body: {
|
|
70
|
+
({ asChild, className, ref, ...props }: ComponentProps<"div"> & WithAsChild): import("react").JSX.Element;
|
|
71
|
+
displayName: string;
|
|
72
|
+
};
|
|
24
73
|
type CodeBlockCodeProps = Omit<ComponentProps<"pre">, "children"> & {
|
|
25
74
|
/**
|
|
26
75
|
* The code value produced by `mantleCode("lang")` tagged template.
|
|
@@ -29,7 +78,142 @@ type CodeBlockCodeProps = Omit<ComponentProps<"pre">, "children"> & {
|
|
|
29
78
|
*/
|
|
30
79
|
value: MantleCodeBlockValue;
|
|
31
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* The `CodeBlock` content. Renders pre-highlighted code from `mantleCode()`.
|
|
83
|
+
*
|
|
84
|
+
* `value["~preHtml"]` must be provided by Mantle's Vite plugin or server highlighter.
|
|
85
|
+
* Runtime highlighting and runtime line decoration are intentionally unsupported.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```tsx
|
|
89
|
+
* <CodeBlock.Root>
|
|
90
|
+
* <CodeBlock.Header>
|
|
91
|
+
* <CodeBlock.Icon preset="file" />
|
|
92
|
+
* <CodeBlock.Title>example.ts</CodeBlock.Title>
|
|
93
|
+
* </CodeBlock.Header>
|
|
94
|
+
* <CodeBlock.Body>
|
|
95
|
+
* <CodeBlock.CopyButton />
|
|
96
|
+
* <CodeBlock.Code value={mantleCode("typescript")`const x = "hello";`} />
|
|
97
|
+
* </CodeBlock.Body>
|
|
98
|
+
* <CodeBlock.ExpanderButton />
|
|
99
|
+
* </CodeBlock.Root>
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare const Code: {
|
|
103
|
+
({ className, style, value, ref, ...props }: CodeBlockCodeProps): import("react").JSX.Element;
|
|
104
|
+
displayName: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The (optional) header slot of the `CodeBlock`. This is where
|
|
108
|
+
* `CodeBlock.Icon` and `CodeBlock.Title` are rendered.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```tsx
|
|
112
|
+
* <CodeBlock.Root>
|
|
113
|
+
* <CodeBlock.Header>
|
|
114
|
+
* <CodeBlock.Icon preset="file" />
|
|
115
|
+
* <CodeBlock.Title>example.ts</CodeBlock.Title>
|
|
116
|
+
* </CodeBlock.Header>
|
|
117
|
+
* <CodeBlock.Body>
|
|
118
|
+
* <CodeBlock.CopyButton />
|
|
119
|
+
* <CodeBlock.Code value={mantleCode("typescript")`const x = "hello";`} />
|
|
120
|
+
* </CodeBlock.Body>
|
|
121
|
+
* <CodeBlock.ExpanderButton />
|
|
122
|
+
* </CodeBlock.Root>
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
declare const Header: {
|
|
126
|
+
({ asChild, className, ref, ...props }: ComponentProps<"div"> & WithAsChild): import("react").JSX.Element;
|
|
127
|
+
displayName: string;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* The (optional) title of the `CodeBlock`. Renders as `h3` by default;
|
|
131
|
+
* use `asChild` to render a different element.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```tsx
|
|
135
|
+
* <CodeBlock.Root>
|
|
136
|
+
* <CodeBlock.Header>
|
|
137
|
+
* <CodeBlock.Icon preset="file" />
|
|
138
|
+
* <CodeBlock.Title>example.ts</CodeBlock.Title>
|
|
139
|
+
* </CodeBlock.Header>
|
|
140
|
+
* <CodeBlock.Body>
|
|
141
|
+
* <CodeBlock.CopyButton />
|
|
142
|
+
* <CodeBlock.Code value={mantleCode("typescript")`const x = "hello";`} />
|
|
143
|
+
* </CodeBlock.Body>
|
|
144
|
+
* <CodeBlock.ExpanderButton />
|
|
145
|
+
* </CodeBlock.Root>
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
declare const Title: {
|
|
149
|
+
({ asChild, className, ref, ...props }: ComponentProps<"h3"> & {
|
|
150
|
+
asChild?: boolean;
|
|
151
|
+
}): import("react").JSX.Element;
|
|
152
|
+
displayName: string;
|
|
153
|
+
};
|
|
154
|
+
type CodeBlockCopyButtonProps = Omit<ComponentProps<"button">, "children" | "type"> & SelfClosingWithAsChild & {
|
|
155
|
+
/**
|
|
156
|
+
* The accessible label for the copy button. This label will be visually hidden but announced to screen reader users, similar to alt text for img tags.
|
|
157
|
+
*
|
|
158
|
+
* @default "Copy code"
|
|
159
|
+
*/
|
|
160
|
+
label?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Callback fired when the copy button is clicked, passes the copied text as an argument.
|
|
163
|
+
*/
|
|
164
|
+
onCopy?: (value: string) => void;
|
|
165
|
+
/**
|
|
166
|
+
* Callback fired when an error occurs during copying.
|
|
167
|
+
*/
|
|
168
|
+
onCopyError?: (error: unknown) => void;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* The (optional) copy button of the `CodeBlock`. Copies the code content
|
|
172
|
+
* to the clipboard when clicked.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```tsx
|
|
176
|
+
* <CodeBlock.Root>
|
|
177
|
+
* <CodeBlock.Header>
|
|
178
|
+
* <CodeBlock.Icon preset="file" />
|
|
179
|
+
* <CodeBlock.Title>example.ts</CodeBlock.Title>
|
|
180
|
+
* </CodeBlock.Header>
|
|
181
|
+
* <CodeBlock.Body>
|
|
182
|
+
* <CodeBlock.CopyButton />
|
|
183
|
+
* <CodeBlock.Code value={mantleCode("typescript")`const x = "hello";`} />
|
|
184
|
+
* </CodeBlock.Body>
|
|
185
|
+
* <CodeBlock.ExpanderButton />
|
|
186
|
+
* </CodeBlock.Root>
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
declare const CopyButton: {
|
|
190
|
+
({ className, label, onCopy, onCopyError, onClick, ref, ...props }: CodeBlockCopyButtonProps): import("react").JSX.Element;
|
|
191
|
+
displayName: string;
|
|
192
|
+
};
|
|
32
193
|
type CodeBlockExpanderButtonProps = Omit<ComponentProps<"button">, "children" | "aria-controls" | "aria-expanded"> & WithAsChild;
|
|
194
|
+
/**
|
|
195
|
+
* The (optional) expander button of the `CodeBlock`. Toggles the expanded
|
|
196
|
+
* state of the code block. When present, the code block is collapsible.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```tsx
|
|
200
|
+
* <CodeBlock.Root>
|
|
201
|
+
* <CodeBlock.Header>
|
|
202
|
+
* <CodeBlock.Icon preset="file" />
|
|
203
|
+
* <CodeBlock.Title>example.ts</CodeBlock.Title>
|
|
204
|
+
* </CodeBlock.Header>
|
|
205
|
+
* <CodeBlock.Body>
|
|
206
|
+
* <CodeBlock.CopyButton />
|
|
207
|
+
* <CodeBlock.Code value={mantleCode("typescript")`const x = "hello";`} />
|
|
208
|
+
* </CodeBlock.Body>
|
|
209
|
+
* <CodeBlock.ExpanderButton />
|
|
210
|
+
* </CodeBlock.Root>
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
declare const ExpanderButton: {
|
|
214
|
+
({ asChild, className, onClick, ref, ...props }: CodeBlockExpanderButtonProps): import("react").JSX.Element;
|
|
215
|
+
displayName: string;
|
|
216
|
+
};
|
|
33
217
|
type CodeBlockIconProps = Omit<SvgAttributes, "children"> & ({
|
|
34
218
|
/**
|
|
35
219
|
* A custom icon SVG to display in the code block header.
|
|
@@ -74,8 +258,82 @@ type CodeBlockIconProps = Omit<SvgAttributes, "children"> & ({
|
|
|
74
258
|
*/
|
|
75
259
|
declare function CodeBlockIconComponent({ className, preset, svg: _svgProp, ...props }: CodeBlockIconProps): import("react").JSX.Element;
|
|
76
260
|
type CodeBlockTabListProps = Omit<ComponentProps<typeof List>, "asChild" | "loop">;
|
|
261
|
+
/**
|
|
262
|
+
* A tab list for the `CodeBlock` header. Renders pill-styled tab triggers
|
|
263
|
+
* that switch which code is displayed. Built on Radix Tabs primitives.
|
|
264
|
+
*
|
|
265
|
+
* Place this inside `CodeBlock.Header` and pair with `CodeBlock.TabContent`
|
|
266
|
+
* in `CodeBlock.Body` to conditionally render code based on the active tab.
|
|
267
|
+
* Tab state is managed by `CodeBlock.Root` via `defaultTab` / `activeTab` / `onActiveTabChange`.
|
|
268
|
+
*
|
|
269
|
+
* When the tabs exceed the available width they scroll horizontally with an edge
|
|
270
|
+
* fade (`scroll-fade-x`) instead of wrapping to a second row.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```tsx
|
|
274
|
+
* <CodeBlock.Root defaultTab="yml">
|
|
275
|
+
* <CodeBlock.Header>
|
|
276
|
+
* <CodeBlock.TabList>
|
|
277
|
+
* <CodeBlock.TabTrigger value="yml">policy.yml</CodeBlock.TabTrigger>
|
|
278
|
+
* <CodeBlock.TabTrigger value="json">policy.json</CodeBlock.TabTrigger>
|
|
279
|
+
* </CodeBlock.TabList>
|
|
280
|
+
* </CodeBlock.Header>
|
|
281
|
+
* <CodeBlock.Body>
|
|
282
|
+
* <CodeBlock.CopyButton />
|
|
283
|
+
* <CodeBlock.TabContent value="yml">
|
|
284
|
+
* <CodeBlock.Code value={ymlValue} />
|
|
285
|
+
* </CodeBlock.TabContent>
|
|
286
|
+
* <CodeBlock.TabContent value="json">
|
|
287
|
+
* <CodeBlock.Code value={jsonValue} />
|
|
288
|
+
* </CodeBlock.TabContent>
|
|
289
|
+
* </CodeBlock.Body>
|
|
290
|
+
* </CodeBlock.Root>
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
declare const TabList: {
|
|
294
|
+
({ className, ref, ...props }: CodeBlockTabListProps): import("react").JSX.Element;
|
|
295
|
+
displayName: string;
|
|
296
|
+
};
|
|
77
297
|
type CodeBlockTabTriggerProps = Omit<ComponentProps<typeof Trigger>, "asChild">;
|
|
298
|
+
/**
|
|
299
|
+
* A pill-styled tab trigger for the `CodeBlock` header.
|
|
300
|
+
* Must be rendered within a `CodeBlock.TabList`.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```tsx
|
|
304
|
+
* <CodeBlock.TabList>
|
|
305
|
+
* <CodeBlock.TabTrigger value="yml">policy.yml</CodeBlock.TabTrigger>
|
|
306
|
+
* <CodeBlock.TabTrigger value="json">policy.json</CodeBlock.TabTrigger>
|
|
307
|
+
* </CodeBlock.TabList>
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
declare const TabTrigger: {
|
|
311
|
+
({ className, ref, ...props }: CodeBlockTabTriggerProps): import("react").JSX.Element;
|
|
312
|
+
displayName: string;
|
|
313
|
+
};
|
|
78
314
|
type CodeBlockTabContentProps = Omit<ComponentProps<typeof Content>, "asChild" | "forceMount">;
|
|
315
|
+
/**
|
|
316
|
+
* Conditionally renders its children when the associated tab is active.
|
|
317
|
+
* Pair with `CodeBlock.TabList` and `CodeBlock.TabTrigger` in the header,
|
|
318
|
+
* and set `defaultTab` / `activeTab` on `CodeBlock.Root`.
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```tsx
|
|
322
|
+
* <CodeBlock.Body>
|
|
323
|
+
* <CodeBlock.CopyButton />
|
|
324
|
+
* <CodeBlock.TabContent value="yml">
|
|
325
|
+
* <CodeBlock.Code value={ymlValue} />
|
|
326
|
+
* </CodeBlock.TabContent>
|
|
327
|
+
* <CodeBlock.TabContent value="json">
|
|
328
|
+
* <CodeBlock.Code value={jsonValue} />
|
|
329
|
+
* </CodeBlock.TabContent>
|
|
330
|
+
* </CodeBlock.Body>
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
declare const TabContent: {
|
|
334
|
+
(props: CodeBlockTabContentProps): import("react").JSX.Element;
|
|
335
|
+
displayName: string;
|
|
336
|
+
};
|
|
79
337
|
/**
|
|
80
338
|
* Shiki-powered code blocks with build-time syntax highlighting and zero browser bundle.
|
|
81
339
|
*
|
|
@@ -158,7 +416,7 @@ declare const CodeBlock: {
|
|
|
158
416
|
* </CodeBlock.Root>
|
|
159
417
|
* ```
|
|
160
418
|
*/
|
|
161
|
-
readonly Root:
|
|
419
|
+
readonly Root: typeof Root$1;
|
|
162
420
|
/**
|
|
163
421
|
* The body of the `CodeBlock`. Contains `Code` and optional `CopyButton`.
|
|
164
422
|
*
|
|
@@ -177,7 +435,7 @@ declare const CodeBlock: {
|
|
|
177
435
|
* </CodeBlock.Root>
|
|
178
436
|
* ```
|
|
179
437
|
*/
|
|
180
|
-
readonly Body:
|
|
438
|
+
readonly Body: typeof Body;
|
|
181
439
|
/**
|
|
182
440
|
* The code content. Renders pre-highlighted Shiki HTML when the Vite plugin is active.
|
|
183
441
|
*
|
|
@@ -196,7 +454,7 @@ declare const CodeBlock: {
|
|
|
196
454
|
* </CodeBlock.Root>
|
|
197
455
|
* ```
|
|
198
456
|
*/
|
|
199
|
-
readonly Code:
|
|
457
|
+
readonly Code: typeof Code;
|
|
200
458
|
/**
|
|
201
459
|
* The optional copy button.
|
|
202
460
|
*
|
|
@@ -215,43 +473,7 @@ declare const CodeBlock: {
|
|
|
215
473
|
* </CodeBlock.Root>
|
|
216
474
|
* ```
|
|
217
475
|
*/
|
|
218
|
-
readonly CopyButton:
|
|
219
|
-
asChild: true;
|
|
220
|
-
children: ReactNode;
|
|
221
|
-
} & {
|
|
222
|
-
/**
|
|
223
|
-
* The accessible label for the copy button. This label will be visually hidden but announced to screen reader users, similar to alt text for img tags.
|
|
224
|
-
*
|
|
225
|
-
* @default "Copy code"
|
|
226
|
-
*/
|
|
227
|
-
label?: string;
|
|
228
|
-
/**
|
|
229
|
-
* Callback fired when the copy button is clicked, passes the copied text as an argument.
|
|
230
|
-
*/
|
|
231
|
-
onCopy?: (value: string) => void;
|
|
232
|
-
/**
|
|
233
|
-
* Callback fired when an error occurs during copying.
|
|
234
|
-
*/
|
|
235
|
-
onCopyError?: (error: unknown) => void;
|
|
236
|
-
}, "ref"> | Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "children" | "type"> & {
|
|
237
|
-
asChild?: false | undefined;
|
|
238
|
-
children?: undefined;
|
|
239
|
-
} & {
|
|
240
|
-
/**
|
|
241
|
-
* The accessible label for the copy button. This label will be visually hidden but announced to screen reader users, similar to alt text for img tags.
|
|
242
|
-
*
|
|
243
|
-
* @default "Copy code"
|
|
244
|
-
*/
|
|
245
|
-
label?: string;
|
|
246
|
-
/**
|
|
247
|
-
* Callback fired when the copy button is clicked, passes the copied text as an argument.
|
|
248
|
-
*/
|
|
249
|
-
onCopy?: (value: string) => void;
|
|
250
|
-
/**
|
|
251
|
-
* Callback fired when an error occurs during copying.
|
|
252
|
-
*/
|
|
253
|
-
onCopyError?: (error: unknown) => void;
|
|
254
|
-
}, "ref">) & import("react").RefAttributes<HTMLButtonElement>>;
|
|
476
|
+
readonly CopyButton: typeof CopyButton;
|
|
255
477
|
/**
|
|
256
478
|
* The optional expander button for collapsible code blocks.
|
|
257
479
|
*
|
|
@@ -270,7 +492,7 @@ declare const CodeBlock: {
|
|
|
270
492
|
* </CodeBlock.Root>
|
|
271
493
|
* ```
|
|
272
494
|
*/
|
|
273
|
-
readonly ExpanderButton:
|
|
495
|
+
readonly ExpanderButton: typeof ExpanderButton;
|
|
274
496
|
/**
|
|
275
497
|
* The optional header slot for icon and title.
|
|
276
498
|
*
|
|
@@ -289,7 +511,7 @@ declare const CodeBlock: {
|
|
|
289
511
|
* </CodeBlock.Root>
|
|
290
512
|
* ```
|
|
291
513
|
*/
|
|
292
|
-
readonly Header:
|
|
514
|
+
readonly Header: typeof Header;
|
|
293
515
|
/**
|
|
294
516
|
* A small icon for the code block header. Use `preset` or `svg`.
|
|
295
517
|
*
|
|
@@ -333,7 +555,7 @@ declare const CodeBlock: {
|
|
|
333
555
|
* </CodeBlock.Root>
|
|
334
556
|
* ```
|
|
335
557
|
*/
|
|
336
|
-
readonly TabContent:
|
|
558
|
+
readonly TabContent: typeof TabContent;
|
|
337
559
|
/**
|
|
338
560
|
* A tab list for the code block header. Renders pill-styled tabs for switching code.
|
|
339
561
|
*
|
|
@@ -358,7 +580,7 @@ declare const CodeBlock: {
|
|
|
358
580
|
* </CodeBlock.Root>
|
|
359
581
|
* ```
|
|
360
582
|
*/
|
|
361
|
-
readonly TabList:
|
|
583
|
+
readonly TabList: typeof TabList;
|
|
362
584
|
/**
|
|
363
585
|
* A pill-styled tab trigger for the code block header. Must be inside `TabList`.
|
|
364
586
|
*
|
|
@@ -383,7 +605,7 @@ declare const CodeBlock: {
|
|
|
383
605
|
* </CodeBlock.Root>
|
|
384
606
|
* ```
|
|
385
607
|
*/
|
|
386
|
-
readonly TabTrigger:
|
|
608
|
+
readonly TabTrigger: typeof TabTrigger;
|
|
387
609
|
/**
|
|
388
610
|
* The optional title rendered in the header.
|
|
389
611
|
*
|
|
@@ -402,9 +624,7 @@ declare const CodeBlock: {
|
|
|
402
624
|
* </CodeBlock.Root>
|
|
403
625
|
* ```
|
|
404
626
|
*/
|
|
405
|
-
readonly Title:
|
|
406
|
-
asChild?: boolean;
|
|
407
|
-
} & import("react").RefAttributes<HTMLHeadingElement>>;
|
|
627
|
+
readonly Title: typeof Title;
|
|
408
628
|
};
|
|
409
629
|
//#endregion
|
|
410
630
|
//#region src/components/code-block/json-highlight.d.ts
|
package/dist/code-block.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{t as e}from"./compose-refs-
|
|
2
|
-
`||e===`\r`||e===`{`||e===`}`||e===`[`||e===`]`||e===`:`||e===`,`||e===`"`}function
|
|
3
|
-
`||t===`\r`){s+=1;continue}break}let c=e[s]===`:`?`var(--shiki-token-keyword)`:`var(--shiki-token-string-expression)`;for(let e of i)n(e.text,e.isEscape?`var(--shiki-token-escape, var(--shiki-token-constant))`:c);return o}function
|
|
1
|
+
import{t as e}from"./compose-refs-BdBMM9ga.js";import{t}from"./cx-IiQEAKf5.js";import{t as n}from"./icon-CGgMKpJg.js";import{t as r}from"./slot-CDk0Bb9z.js";import{t as i}from"./icon-button-DiOhreJD.js";import{t as a}from"./use-copy-to-clipboard-DqQ0_N3E.js";import{t as o}from"./traffic-policy-file-CF1lbWtp.js";import{S as s,_ as c,a as l,b as u,c as d,d as f,f as p,g as m,h,i as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T,v as E,y as D}from"./resolve-pre-rendered-props-C9uaM9-V.js";import{CaretDownIcon as O}from"@phosphor-icons/react/CaretDown";import{createContext as k,useCallback as A,useContext as ee,useEffect as j,useId as te,useLayoutEffect as ne,useMemo as M,useRef as N,useState as P}from"react";import F from"tiny-invariant";import{jsx as I,jsxs as re}from"react/jsx-runtime";import{CheckIcon as ie}from"@phosphor-icons/react/Check";import{CopyIcon as ae}from"@phosphor-icons/react/Copy";import{FileTextIcon as oe}from"@phosphor-icons/react/FileText";import{TerminalIcon as se}from"@phosphor-icons/react/Terminal";import{Content as ce,List as le,Root as ue,Trigger as de}from"@radix-ui/react-tabs";function L(e){let t=-1;for(let n=0;n<e.length;n++){let r=e[n];if(r===`&`||r===`<`||r===`>`||r===`"`||r===`'`){t=n;break}}if(t===-1)return e;let n=e.slice(0,t);for(let r=t;r<e.length;r++){let t=e[r];switch(t){case`&`:n+=`&`;break;case`<`:n+=`<`;break;case`>`:n+=`>`;break;case`"`:n+=`"`;break;case`'`:n+=`'`;break;default:n+=t}}return n}const R=new WeakMap;function fe(e){let t=new Set;if(e==null||e===``)return t;for(let n of e.split(` `))n!==``&&t.add(n);return t}function pe(e){let t=R.get(e);if(t!=null&&ge(t))return t;let n=new Map,r=new WeakMap,i=e.querySelectorAll(`[data-fold-regions]`);for(let e=0;e<i.length;e+=1){let t=i[e];if(!(t instanceof HTMLElement))continue;let a=fe(t.dataset.foldRegions);if(a.size!==0){r.set(t,a);for(let e of a){let r=n.get(e);r??(r=[],n.set(e,r)),r.push(t)}}}let a={regionToLines:n,lineToRegions:r};return R.set(e,a),a}function me(e){R.delete(e)}function he(e){me(e),e.removeAttribute(`data-folded-regions`)}function ge(e){for(let t of e.regionToLines.values()){if(t.length===0)continue;let e=t[0];if(e!=null)return e.isConnected}return!0}function _e(e,t,n){let r=!1;for(let e of n)if(t.has(e)){r=!0;break}r?e.dataset.foldHidden=`true`:delete e.dataset.foldHidden}function ve(e){let t=e.dataset.foldLine;if(t==null||t===``)return!1;let n=e.closest(`[data-slot='code-block-code']`)?.querySelector(`code`);if(n==null)return!1;let r=fe(n.getAttribute(`data-folded-regions`)),i=!r.has(t);i?r.add(t):r.delete(t),r.size===0?n.removeAttribute(`data-folded-regions`):n.setAttribute(`data-folded-regions`,[...r].join(` `)),e.setAttribute(`aria-expanded`,i?`false`:`true`);let{regionToLines:a,lineToRegions:o}=pe(n),s=a.get(t);if(s!=null)for(let e of s){let t=o.get(e);t!=null&&_e(e,r,t)}return!0}function ye(e){let t=e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`.mantle-code-fold-toggle`);n instanceof HTMLButtonElement&&ve(n)};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}}const z=k(null);function B(){let e=ee(z);return F(e!=null,`CodeBlock subcomponents must be rendered within a <CodeBlock.Root>.`),e}const V=({asChild:e=!1,className:n,defaultTab:i,activeTab:a,onActiveTabChange:o,ref:s,...c})=>{let l=N(``),[u,d]=P(!1),[f,p]=P(!1),[m,h]=P(void 0),g=A(e=>{h(t=>(F(t==null,`You can only render a single CodeBlock.Code within a CodeBlock.`),e))},[]),_=A(e=>{h(t=>{F(t===e,`You can only render a single CodeBlock.Code within a CodeBlock.`)})},[]),v=M(()=>({codeId:m,copyTextRef:l,hasCodeExpander:u,isCodeExpanded:f,registerCodeId:g,setHasCodeExpander:d,setIsCodeExpanded:p,unregisterCodeId:_}),[m,u,f,g,_]),y=i!=null||a!=null,b=I(e?r:`div`,{"data-slot":`code-block`,className:t(`text-mono w-full overflow-hidden rounded-md border border-gray-300 bg-base font-mono`,`[&_svg]:shrink-0`,n),ref:s,...c});return I(z.Provider,{value:v,children:y?I(ue,{asChild:!0,defaultValue:i,value:a,onValueChange:o,children:b}):b})};V.displayName=`CodeBlock`;const H=({asChild:e=!1,className:n,ref:i,...a})=>I(e?r:`div`,{"data-slot":`code-block-body`,className:t(`relative`,n),ref:i,...a});H.displayName=`CodeBlockBody`;const be=/SHIKI_VAL_(\d+)/g;function xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}const U=new Map;function Se(e){if(e==null||e.length===0)return be;let t=U.get(e);return t??(U.size>=500&&U.clear(),t=RegExp(`${xe(e)}(\\d+)__`,`g`),U.set(e,t)),t}function W(e,t,n,r){if(n==null){if(!e.includes(`SHIKI_VAL_`))return e}else if(!e.includes(n))return e;return e.replaceAll(Se(n),(e,n)=>{let i=Number.parseInt(n,10);return Number.isNaN(i)||i<0||i>=t.length?e:r(t[i])})}function Ce(e,t,n){return W(e,t,n,e=>L(String(e)))}function we(e,t,n){return W(e,t,n,e=>String(e))}const G=({className:n,style:r,value:i,ref:a,...o})=>{let s=te(),c=N(null),{copyTextRef:l,hasCodeExpander:u,isCodeExpanded:d,registerCodeId:f,unregisterCodeId:p}=B(),{language:m,code:h,"~preValToken":g,"~preVals":_,"~highlightLines":v,"~lineNumberStart":y,"~preHtml":b,"~showLineNumbers":x}=i,S=v,C=y??1,w=x??!1,T=M(()=>_!=null&&_.length>0?we(h,_,g):h,[g,_,h]);ne(()=>{l.current=T},[l,T]),j(()=>(f(s),()=>{p(s)}),[s,f,p]);let E=M(()=>{if(b!=null)return _!=null&&_.length>0?Ce(b,_,g):b},[b,g,_]);j(()=>{let e=c.current;if(e==null)return;let t=e.querySelector(`code`);return t!=null&&he(t),ye(e)},[E]);let D=E!=null,O=E??L(T),k=M(()=>({__html:O}),[O]);return I(`pre`,{"data-slot":`code-block-code`,"aria-expanded":u?d:void 0,className:t(`scrollbar overflow-x-auto overflow-y-hidden py-4`,!D&&`pr-14`,`data-[mantle-line-numbers~='false']:pl-4`,`text-mono m-0 font-mono outline-hidden`,`aria-collapsed:max-h-[13.6rem]`,n),"data-highlighted":D?`true`:`false`,"data-lang":m,"data-mantle-highlight-lines":D&&S!=null&&S.length>0?S.join(`,`):void 0,"data-mantle-line-number-start":D&&w?String(C):`1`,"data-mantle-line-numbers":D&&w?`true`:`false`,id:s,ref:e(c,a),style:{...r,"--mantle-line-number-start":String(C),tabSize:2,MozTabSize:2},...o,children:I(`code`,{className:`text-size-inherit block min-w-full w-max`,dangerouslySetInnerHTML:k})})};G.displayName=`CodeBlockCode`;const K=({asChild:e=!1,className:n,ref:i,...a})=>I(e?r:`div`,{"data-slot":`code-block-header`,className:t(`flex items-center gap-1 border-b border-gray-300 bg-base px-4 py-2 text-gray-700`,n),ref:i,...a});K.displayName=`CodeBlockHeader`;const q=({asChild:e=!1,className:n,ref:i,...a})=>I(e?r:`h3`,{"data-slot":`code-block-title`,ref:i,className:t(`m-0 font-sans text-xs font-medium`,n),...a});q.displayName=`CodeBlockTitle`;const J=({className:e,label:n=`Copy code`,onCopy:r,onCopyError:o,onClick:s,ref:c,...l})=>{let{copyTextRef:u}=B(),d=a(),[f,p]=P(!1),m=N(void 0);return j(()=>()=>{m.current!=null&&clearTimeout(m.current)},[]),I(`span`,{"data-slot":`code-block-copy-button`,className:`absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-[var(--icon-button-border-radius,0.375rem)] bg-base`,children:I(i,{type:`button`,appearance:`ghost`,intent:`neutral`,size:`sm`,label:n,icon:I(f?ie:ae,{}),className:t(`bg-base not-disabled:hover:bg-neutral-500/15`,e),ref:c,onClick:async e=>{try{if(s?.(e),e.defaultPrevented){m.current!=null&&clearTimeout(m.current);return}let t=u.current;await d(t),r?.(t),p(!0),m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{p(!1)},2e3)}catch(e){o?.(e)}},...l})})};J.displayName=`CodeBlockCopyButton`;const Y=({asChild:e=!1,className:i,onClick:a,ref:o,...s})=>{let{codeId:c,isCodeExpanded:l,setIsCodeExpanded:u,setHasCodeExpander:d}=B();return j(()=>(d(!0),()=>{d(!1)}),[d]),re(e?r:`button`,{...s,"data-slot":`code-block-expander-button`,"aria-controls":c,"aria-expanded":l,className:t(`flex w-full items-center justify-center gap-0.5 border-t border-gray-300 bg-base px-4 py-2 font-sans text-gray-700 hover:bg-base-hover`,i),ref:o,type:`button`,onClick:e=>{u(e=>!e),a?.(e)},children:[l?`Show less`:`Show more`,` `,I(n,{svg:I(O,{weight:`bold`}),className:t(`size-4`,l&&`rotate-180`,`transition-all duration-150`)})]})};Y.displayName=`CodeBlockExpanderButton`;function X({className:e,preset:r,svg:i,...a}){let s=i;if(r!=null)switch(r){case`file`:s=I(oe,{weight:`fill`});break;case`cli`:s=I(se,{weight:`fill`});break;case`traffic-policy`:s=I(o,{});break}return I(n,{"data-slot":`code-block-icon`,className:t(`size-5`,e),svg:s,...a})}X.displayName=`CodeBlockIcon`;const Z=({className:e,ref:n,...r})=>I(le,{"data-slot":`code-block-tab-list`,className:t(`scroll-fade-x flex min-w-0 items-center gap-1 overflow-x-auto overscroll-x-none`,`-m-1 p-1`,e),ref:n,...r});Z.displayName=`CodeBlockTabList`;const Q=({className:e,ref:n,...r})=>I(de,{"data-slot":`code-block-tab-trigger`,className:t(`shrink-0 cursor-pointer rounded px-1.5 py-0.5 font-sans text-xs font-medium whitespace-nowrap`,`text-gray-600 outline-hidden`,`hover:text-gray-900`,`data-[state=active]:bg-neutral-500/15 data-[state=active]:text-strong`,`focus-visible:ring-focus-accent focus-visible:ring-4`,e),ref:n,...r});Q.displayName=`CodeBlockTabTrigger`;const $=e=>I(ce,{"data-slot":`code-block-tab-content`,...e});$.displayName=`CodeBlockTabContent`;const Te={Root:V,Body:H,Code:G,CopyButton:J,ExpanderButton:Y,Header:K,Icon:X,TabContent:$,TabList:Z,TabTrigger:Q,Title:q},Ee=`var(--shiki-foreground)`;function De(e){return e.replace(/[&<]/g,e=>e===`&`?`&`:`<`)}function Oe(e){return e===` `||e===` `||e===`
|
|
2
|
+
`||e===`\r`||e===`{`||e===`}`||e===`[`||e===`]`||e===`:`||e===`,`||e===`"`}function ke(e,t,n){let r=e.length,i=[],a=`"`,o=t+1;for(;o<r;){let t=e[o];if(t===`\\`){let t=e[o+1]===`u`&&/^[0-9a-fA-F]{4}$/.test(e.slice(o+2,o+6))?6:2;a!==``&&(i.push({text:a,isEscape:!1}),a=``),i.push({text:e.slice(o,o+t),isEscape:!0}),o+=t;continue}if(t===`"`){a+=`"`,o+=1;break}a+=t,o+=1}a!==``&&i.push({text:a,isEscape:!1});let s=o;for(;s<r;){let t=e[s];if(t===` `||t===` `||t===`
|
|
3
|
+
`||t===`\r`){s+=1;continue}break}let c=e[s]===`:`?`var(--shiki-token-keyword)`:`var(--shiki-token-string-expression)`;for(let e of i)n(e.text,e.isEscape?`var(--shiki-token-escape, var(--shiki-token-constant))`:c);return o}function Ae(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n!=null&&n.color==null){let r=Ee;for(let n=t+1;n<e.length;n+=1){let t=e[n];if(t!=null&&t.color!=null){r=t.color;break}}n.color=r}}let t=``,n=``,r=null,i=()=>{r!=null&&(t+=`<span style="color:${r}">${De(n)}</span>`),n=``,r=null};for(let t of e)t!=null&&(t.color===r?n+=t.text:(i(),n=t.text,r=t.color));return i(),`<span class="line">${t}</span>`}function je(e){let t=[[]],n=t[0]??[],r=e.length,i=0,a=(e,t)=>{n.push({text:e,color:t})};for(;i<r;){let o=e[i];if(o===`
|
|
4
4
|
`||o===`\r`){o===`\r`&&e[i+1]===`
|
|
5
|
-
`&&(i+=1);let r=[];t.push(r),n=r,i+=1;continue}if(o===` `||o===` `){let t=i+1;for(;t<r;){let n=e[t];if(n!==` `&&n!==` `)break;t+=1}a(e.slice(i,t),null),i=t;continue}if(o===`{`||o===`}`||o===`[`||o===`]`){a(o,
|
|
6
|
-
`)}function
|
|
7
|
-
`&&(n+=1,n>t))return!0;return!1}export{
|
|
5
|
+
`&&(i+=1);let r=[];t.push(r),n=r,i+=1;continue}if(o===` `||o===` `){let t=i+1;for(;t<r;){let n=e[t];if(n!==` `&&n!==` `)break;t+=1}a(e.slice(i,t),null),i=t;continue}if(o===`{`||o===`}`||o===`[`||o===`]`){a(o,Ee),i+=1;continue}if(o===`:`||o===`,`){a(o,`var(--shiki-token-punctuation)`),i+=1;continue}if(o===`"`){i=ke(e,i,a);continue}let s=i+1;for(;s<r&&!Oe(e[s]??``);)s+=1;a(e.slice(i,s),`var(--shiki-token-constant)`),i=s}return t.map(Ae).join(`
|
|
6
|
+
`)}function Me(e){let t=new WeakSet;try{return JSON.stringify(e,(e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n==`object`&&n){if(t.has(n))return`[Circular]`;t.add(n)}return n},2)??``}catch{try{return String(e)}catch{return``}}}function Ne(e,{showLineNumbers:t=!1,foldable:n=!0}={}){let r=Me(e);return u({language:`json`,code:r,preHtml:c({html:je(r),foldableRanges:n?E(r):void 0,showLineNumbers:t}),showLineNumbers:t})}function Pe(e,t){let n=1;if(n>t)return!0;for(let r=0;r<e.length;r++)if(e[r]===`
|
|
7
|
+
`&&(n+=1,n>t))return!0;return!1}export{Te as CodeBlock,h as computeFoldRanges,E as computeJsonFoldRanges,u as createMantleCodeBlockValue,c as decorateHighlightedHtml,w as defaultMeta,L as escapeHtml,D as finalizeFoldRanges,m as foldStrategyFor,Pe as hasMoreThanNLines,x as inferIndentation,v as isIndentation,_ as isSupportedLanguage,Ne as jsonCodeBlockValue,je as jsonToShikiHtml,s as mantleCode,p as normalizeIndentation,y as normalizeValue,b as parseCodeBlockHighlightLines,C as parseCodeBlockLineNumberStart,d as parseCodeBlockShowLineNumbers,T as parseLanguage,S as parseMetastring,g as resolvePreRenderedCodeBlockProps,f as supportedLanguages,l as tokenizeMetastring};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,l as s,m as c,n as l,o as u,p as d,s as f,u as p,v as m,x as h,y as g}from"./resolve-pre-rendered-props-
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,l as s,m as c,n as l,o as u,p as d,s as f,u as p,v as m,x as h,y as g}from"./resolve-pre-rendered-props-C9uaM9-V.js";export{o as computeFoldRanges,m as computeJsonFoldRanges,e as decorateHighlightedHtml,h as defaultShowLineNumbers,g as finalizeFoldRanges,a as foldStrategyFor,d as inferIndentation,c as isIndentation,s as isSupportedLanguage,i as normalizeIndentation,l as normalizeValue,u as parseCodeBlockHighlightLines,f as parseCodeBlockLineNumberStart,n as parseCodeBlockShowLineNumbers,p as parseLanguage,r as supportedLanguages,t as tokenizeMetastring};
|
package/dist/code.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as WithAsChild } from "./as-child-D23mGo4f.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
2
3
|
//#region src/components/code/code.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Marks a short fragment of inline computer code — a function name, a
|
|
@@ -33,6 +34,6 @@ import { t as WithAsChild } from "./as-child-CYEVu1WY.js";
|
|
|
33
34
|
* </Code>
|
|
34
35
|
* ```
|
|
35
36
|
*/
|
|
36
|
-
declare const Code:
|
|
37
|
+
declare const Code: ({ asChild, className, ref, ...props }: ComponentProps<"code"> & WithAsChild) => import("react").JSX.Element;
|
|
37
38
|
//#endregion
|
|
38
39
|
export { Code };
|
package/dist/code.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./cx-IiQEAKf5.js";import{t}from"./slot-
|
|
1
|
+
import{t as e}from"./cx-IiQEAKf5.js";import{t}from"./slot-CDk0Bb9z.js";import{jsx as n}from"react/jsx-runtime";const r=({asChild:r,className:i,ref:a,...o})=>n(r?t:`code`,{ref:a,"data-slot":`code`,className:e(`border-gray-500/15 rounded-md border bg-gray-500/5 px-1 font-mono text-[0.8em]`,i),...o});export{r as Code};
|