@unterberg/nivel 0.0.1
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/assets/nivel/brands/bluesky.svg +4 -0
- package/assets/nivel/brands/discord.svg +3 -0
- package/assets/nivel/brands/github.svg +2 -0
- package/assets/nivel/brands/linkedin.svg +3 -0
- package/assets/nivel/brands/typescript.svg +26 -0
- package/assets/nivel/brands/x.svg +4 -0
- package/assets/nivel/decorators/pattern-light.png +0 -0
- package/assets/nivel/decorators/pattern.png +0 -0
- package/assets/nivel/fonts/fonts-inter.css +26 -0
- package/assets/nivel/fonts/inter-v20-latin-600.woff2 +0 -0
- package/assets/nivel/fonts/inter-v20-latin-800.woff2 +0 -0
- package/assets/nivel/fonts/inter-v20-latin-regular.woff2 +0 -0
- package/dist/chunk-3JJ6TYWL.js +614 -0
- package/dist/chunk-3JJ6TYWL.js.map +1 -0
- package/dist/chunk-45CLUNJW.js +657 -0
- package/dist/chunk-45CLUNJW.js.map +1 -0
- package/dist/chunk-4WTEOEV2.js +36 -0
- package/dist/chunk-4WTEOEV2.js.map +1 -0
- package/dist/chunk-62MBEYU7.js +1091 -0
- package/dist/chunk-62MBEYU7.js.map +1 -0
- package/dist/chunk-73NPVCDQ.js +353 -0
- package/dist/chunk-73NPVCDQ.js.map +1 -0
- package/dist/chunk-FLO5CJZH.js +42 -0
- package/dist/chunk-FLO5CJZH.js.map +1 -0
- package/dist/chunk-PHHK2BAF.js +350 -0
- package/dist/chunk-PHHK2BAF.js.map +1 -0
- package/dist/client.d.ts +70 -0
- package/dist/client.js +26 -0
- package/dist/client.js.map +1 -0
- package/dist/code-blocks.d.ts +35 -0
- package/dist/code-blocks.js +21 -0
- package/dist/code-blocks.js.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.js +101 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +143 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/mdx.d.ts +6 -0
- package/dist/mdx.js +35 -0
- package/dist/mdx.js.map +1 -0
- package/dist/runtime/client.d.ts +7 -0
- package/dist/runtime/client.js +26 -0
- package/dist/runtime/client.js.map +1 -0
- package/dist/runtime/index.d.ts +15 -0
- package/dist/runtime/index.js +18 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/types-mvLNHHrf.d.ts +177 -0
- package/package.json +90 -0
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderInlineMarkdown,
|
|
3
|
+
useUniversalMdxRuntime
|
|
4
|
+
} from "./chunk-4WTEOEV2.js";
|
|
5
|
+
import {
|
|
6
|
+
withSiteBaseUrl
|
|
7
|
+
} from "./chunk-FLO5CJZH.js";
|
|
8
|
+
|
|
9
|
+
// src/components/Alert.tsx
|
|
10
|
+
import cm, { cmMerge } from "@classmatejs/react";
|
|
11
|
+
import { Check, CircleX, Info, TriangleAlert } from "lucide-react";
|
|
12
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
var alertIconMap = {
|
|
14
|
+
info: Info,
|
|
15
|
+
warning: TriangleAlert,
|
|
16
|
+
error: CircleX,
|
|
17
|
+
success: Check
|
|
18
|
+
};
|
|
19
|
+
var Alert = ({
|
|
20
|
+
type = "info",
|
|
21
|
+
heading,
|
|
22
|
+
children,
|
|
23
|
+
icon = true
|
|
24
|
+
}) => {
|
|
25
|
+
const AlertIcon = icon === true ? alertIconMap[type] : typeof icon === "object" ? () => /* @__PURE__ */ jsx(Fragment, { children: icon }) : null;
|
|
26
|
+
const alertIconTextColorClass = {
|
|
27
|
+
info: "text-info",
|
|
28
|
+
warning: "text-warning",
|
|
29
|
+
error: "text-error",
|
|
30
|
+
success: "text-success"
|
|
31
|
+
}[type];
|
|
32
|
+
return /* @__PURE__ */ jsxs(AlertOuter, { $variant: type, children: [
|
|
33
|
+
!!heading && AlertIcon && /* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center gap-2", children: [
|
|
34
|
+
/* @__PURE__ */ jsx(AlertIcon, { className: cmMerge(alertIconTextColorClass, "float-left h-5 w-5") }),
|
|
35
|
+
/* @__PURE__ */ jsx(AlertHeading, { children: heading })
|
|
36
|
+
] }),
|
|
37
|
+
!(!!heading && AlertIcon) && !!heading && /* @__PURE__ */ jsx(AlertHeading, { children: heading }),
|
|
38
|
+
!(!!heading && AlertIcon) && AlertIcon && /* @__PURE__ */ jsx("div", { className: cmMerge(alertIconTextColorClass, "float-left mr-2"), children: /* @__PURE__ */ jsx(AlertIcon, { className: "mt-1 h-5 w-5" }) }),
|
|
39
|
+
children
|
|
40
|
+
] });
|
|
41
|
+
};
|
|
42
|
+
var AlertOuter = cm.section.variants({
|
|
43
|
+
base: `
|
|
44
|
+
p-4
|
|
45
|
+
mt-5
|
|
46
|
+
mb-5
|
|
47
|
+
border
|
|
48
|
+
rounded-lg
|
|
49
|
+
prose-p:last:mb-0
|
|
50
|
+
prose-p:mt-0
|
|
51
|
+
prose-headings:first:mt-0
|
|
52
|
+
prose-headings:last:mb-0
|
|
53
|
+
prose-ul:first:mt-0
|
|
54
|
+
prose-ul:last:mb-0
|
|
55
|
+
text-sm
|
|
56
|
+
`,
|
|
57
|
+
variants: {
|
|
58
|
+
$variant: {
|
|
59
|
+
info: "bg-info/10 border-info/30",
|
|
60
|
+
warning: "bg-warning/10 border-warning/30",
|
|
61
|
+
error: "bg-error/10 border-error/25",
|
|
62
|
+
success: "bg-success/10 border-success/35"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
defaultVariants: {
|
|
66
|
+
$variant: "info"
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
var AlertHeading = cm.header`
|
|
70
|
+
font-bold
|
|
71
|
+
text-base
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
// src/components/code-blocks/ChoiceGroup.tsx
|
|
75
|
+
import { Children, isValidElement, useRef as useRef2 } from "react";
|
|
76
|
+
|
|
77
|
+
// src/components/code-blocks/CopyButton.tsx
|
|
78
|
+
import { cmMerge as cmMerge2 } from "@classmatejs/react";
|
|
79
|
+
import { Check as Check2, Copy } from "lucide-react";
|
|
80
|
+
import { useState } from "react";
|
|
81
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
82
|
+
var trimTrailingWhitespace = (text) => {
|
|
83
|
+
return text.split("\n").map((line) => line.trimEnd()).join("\n");
|
|
84
|
+
};
|
|
85
|
+
var CodeBlockCopyButton = ({
|
|
86
|
+
onCopy,
|
|
87
|
+
className = ""
|
|
88
|
+
}) => {
|
|
89
|
+
const [copyState, setCopyState] = useState("idle");
|
|
90
|
+
return /* @__PURE__ */ jsx2(
|
|
91
|
+
"button",
|
|
92
|
+
{
|
|
93
|
+
type: "button",
|
|
94
|
+
className: cmMerge2("btn btn-ghost btn-xs h-8 min-h-8 px-2 text-base-muted hover:text-base-content", className),
|
|
95
|
+
onClick: async () => {
|
|
96
|
+
const success = await onCopy();
|
|
97
|
+
setCopyState(success ? "success" : "error");
|
|
98
|
+
window.setTimeout(() => setCopyState("idle"), 900);
|
|
99
|
+
},
|
|
100
|
+
"aria-label": copyState === "idle" ? "Copy to clipboard" : copyState === "success" ? "Copied" : "Copy failed",
|
|
101
|
+
children: copyState === "success" ? /* @__PURE__ */ jsx2(Check2, { size: 14 }) : /* @__PURE__ */ jsx2(Copy, { size: 14 })
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// src/components/code-blocks/context.tsx
|
|
107
|
+
import { createContext, useContext } from "react";
|
|
108
|
+
var CodeBlockGroupContext = createContext(false);
|
|
109
|
+
var CodeBlockGroupProvider = CodeBlockGroupContext.Provider;
|
|
110
|
+
var useIsInCodeBlockGroup = () => useContext(CodeBlockGroupContext);
|
|
111
|
+
|
|
112
|
+
// src/components/code-blocks/useRestoreScroll.ts
|
|
113
|
+
import { useEffect, useRef } from "react";
|
|
114
|
+
var useRestoreScroll = (deps) => {
|
|
115
|
+
const previousPositionRef = useRef(null);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (!previousPositionRef.current) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const { top, element } = previousPositionRef.current;
|
|
121
|
+
const delta = element.getBoundingClientRect().top - top;
|
|
122
|
+
if (delta !== 0) {
|
|
123
|
+
window.scrollBy(0, delta);
|
|
124
|
+
}
|
|
125
|
+
previousPositionRef.current = null;
|
|
126
|
+
}, deps);
|
|
127
|
+
return previousPositionRef;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// src/components/code-blocks/useSelectedChoice.ts
|
|
131
|
+
import { useEffect as useEffect2, useState as useState2, useSyncExternalStore } from "react";
|
|
132
|
+
var subscribeNoop = () => () => {
|
|
133
|
+
};
|
|
134
|
+
var getServerSnapshot = () => null;
|
|
135
|
+
var useSelectedChoice = (choiceGroupName, defaultValue) => {
|
|
136
|
+
const runtime = useUniversalMdxRuntime();
|
|
137
|
+
const choiceStore = runtime?.codeBlockChoices;
|
|
138
|
+
const storedChoice = useSyncExternalStore(
|
|
139
|
+
choiceStore?.subscribe ?? subscribeNoop,
|
|
140
|
+
() => choiceStore?.getChoice(choiceGroupName) ?? null,
|
|
141
|
+
getServerSnapshot
|
|
142
|
+
);
|
|
143
|
+
const [localChoice, setLocalChoice] = useState2(defaultValue);
|
|
144
|
+
useEffect2(() => {
|
|
145
|
+
if (!choiceStore || storedChoice) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const legacyChoice = choiceStore.getLegacyChoice?.(choiceGroupName);
|
|
149
|
+
if (legacyChoice) {
|
|
150
|
+
choiceStore.setChoice(choiceGroupName, legacyChoice);
|
|
151
|
+
}
|
|
152
|
+
}, [choiceGroupName, choiceStore, storedChoice]);
|
|
153
|
+
if (choiceStore) {
|
|
154
|
+
return [storedChoice ?? defaultValue, (value) => choiceStore.setChoice(choiceGroupName, value)];
|
|
155
|
+
}
|
|
156
|
+
return [localChoice, setLocalChoice];
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// src/components/code-blocks/ChoiceGroup.tsx
|
|
160
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
161
|
+
var isChoiceElement = (node) => {
|
|
162
|
+
return isValidElement(node) && typeof node.props?.["data-choice-value"] === "string";
|
|
163
|
+
};
|
|
164
|
+
var asTrimmedString = (value) => {
|
|
165
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
166
|
+
};
|
|
167
|
+
var getActiveCodeBlockMeta = (node) => {
|
|
168
|
+
for (const child of Children.toArray(node)) {
|
|
169
|
+
if (!isValidElement(child)) {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const props = child.props;
|
|
173
|
+
const title = asTrimmedString(props["data-code-title"]);
|
|
174
|
+
const hideCopy = props["hide-menu"] === "true";
|
|
175
|
+
if (title || hideCopy) {
|
|
176
|
+
return { hideCopy, title };
|
|
177
|
+
}
|
|
178
|
+
const nestedMeta = getActiveCodeBlockMeta(props.children);
|
|
179
|
+
if (nestedMeta.title || nestedMeta.hideCopy) {
|
|
180
|
+
return nestedMeta;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return { hideCopy: false, title: null };
|
|
184
|
+
};
|
|
185
|
+
var ChoiceGroup = ({
|
|
186
|
+
children,
|
|
187
|
+
choiceGroup,
|
|
188
|
+
hide = false
|
|
189
|
+
}) => {
|
|
190
|
+
const [selectedChoice, setSelectedChoice] = useSelectedChoice(choiceGroup.name, choiceGroup.default);
|
|
191
|
+
const bodyRef = useRef2(null);
|
|
192
|
+
const previousPositionRef = useRestoreScroll([selectedChoice]);
|
|
193
|
+
const choiceElements = Children.toArray(children).filter(isChoiceElement);
|
|
194
|
+
const activeChoiceElement = choiceElements.find((choiceElement) => choiceElement.props["data-choice-value"] === selectedChoice) ?? choiceElements[0];
|
|
195
|
+
if (!activeChoiceElement) {
|
|
196
|
+
return /* @__PURE__ */ jsx3(Fragment2, { children });
|
|
197
|
+
}
|
|
198
|
+
const activeCodeBlockMeta = getActiveCodeBlockMeta(activeChoiceElement.props.children);
|
|
199
|
+
const headerLabel = activeCodeBlockMeta.title ?? activeChoiceElement.props["data-choice-value"];
|
|
200
|
+
if (hide) {
|
|
201
|
+
return /* @__PURE__ */ jsx3(Fragment2, { children: activeChoiceElement.props.children });
|
|
202
|
+
}
|
|
203
|
+
return /* @__PURE__ */ jsxs2(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
"data-choice-group-outer": true,
|
|
207
|
+
className: "mt-5 mb-5 flex h-full flex-col overflow-hidden rounded-box border border-base-muted-light",
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ jsxs2(
|
|
210
|
+
"div",
|
|
211
|
+
{
|
|
212
|
+
className: "not-prose flex min-h-10 items-center justify-between gap-3 border-b border-base-muted-light bg-base-muted-superlight px-4",
|
|
213
|
+
"data-choice-group-header": true,
|
|
214
|
+
children: [
|
|
215
|
+
/* @__PURE__ */ jsx3("div", { className: "font-mono text-xs font-semibold tracking-[0.08em] text-base-muted", children: headerLabel }),
|
|
216
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-1", children: [
|
|
217
|
+
/* @__PURE__ */ jsx3("label", { className: "select select-xs min-w-28 w-fit", children: /* @__PURE__ */ jsx3(
|
|
218
|
+
"select",
|
|
219
|
+
{
|
|
220
|
+
name: `choicesFor-${choiceGroup.name}`,
|
|
221
|
+
value: activeChoiceElement.props["data-choice-value"],
|
|
222
|
+
onChange: (event) => {
|
|
223
|
+
previousPositionRef.current = {
|
|
224
|
+
top: event.currentTarget.getBoundingClientRect().top,
|
|
225
|
+
element: event.currentTarget
|
|
226
|
+
};
|
|
227
|
+
setSelectedChoice(event.currentTarget.value);
|
|
228
|
+
},
|
|
229
|
+
children: choiceGroup.choices.map((choice) => /* @__PURE__ */ jsx3("option", { value: choice, disabled: choiceGroup.disabled.includes(choice), children: choice }, choice))
|
|
230
|
+
}
|
|
231
|
+
) }),
|
|
232
|
+
!activeCodeBlockMeta.hideCopy && /* @__PURE__ */ jsx3(
|
|
233
|
+
CodeBlockCopyButton,
|
|
234
|
+
{
|
|
235
|
+
onCopy: async () => {
|
|
236
|
+
const text = trimTrailingWhitespace(bodyRef.current?.textContent ?? "");
|
|
237
|
+
try {
|
|
238
|
+
await navigator.clipboard.writeText(text);
|
|
239
|
+
return true;
|
|
240
|
+
} catch {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
] })
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
/* @__PURE__ */ jsx3("div", { ref: bodyRef, className: "h-full flex-1 bg-base-200! [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", children: /* @__PURE__ */ jsx3(CodeBlockGroupProvider, { value: true, children: activeChoiceElement.props.children }) })
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// src/components/code-blocks/CodeBlockTransformer.tsx
|
|
257
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
258
|
+
var CodeBlockTransformer = ({ children, lineBreak }) => {
|
|
259
|
+
const className = `with-line-break_${lineBreak}`;
|
|
260
|
+
return /* @__PURE__ */ jsx4("div", { className, children });
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// src/components/code-blocks/FileState.tsx
|
|
264
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
265
|
+
var FileAdded = ({ children }) => {
|
|
266
|
+
return /* @__PURE__ */ jsx5("div", { className: "doc-code-file-state doc-code-file-added", children });
|
|
267
|
+
};
|
|
268
|
+
var FileRemoved = ({ children }) => {
|
|
269
|
+
return /* @__PURE__ */ jsx5("div", { className: "doc-code-file-state doc-code-file-removed", children });
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// src/components/code-blocks/Pre.tsx
|
|
273
|
+
import { cmMerge as cmMerge3 } from "@classmatejs/react";
|
|
274
|
+
import {
|
|
275
|
+
Children as Children2,
|
|
276
|
+
isValidElement as isValidElement2,
|
|
277
|
+
useRef as useRef3
|
|
278
|
+
} from "react";
|
|
279
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
280
|
+
var asTrimmedString2 = (value) => {
|
|
281
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
282
|
+
};
|
|
283
|
+
var getLanguageFromChildren = (children) => {
|
|
284
|
+
const firstChild = Children2.toArray(children)[0];
|
|
285
|
+
if (!isValidElement2(firstChild)) {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
const props = firstChild.props;
|
|
289
|
+
const explicitLanguage = asTrimmedString2(props["data-language"]);
|
|
290
|
+
if (explicitLanguage) {
|
|
291
|
+
return explicitLanguage;
|
|
292
|
+
}
|
|
293
|
+
const classNames = typeof props.className === "string" ? props.className.split(/\s+/) : [];
|
|
294
|
+
const languageClassName = classNames.find((className) => className.startsWith("language-"));
|
|
295
|
+
return languageClassName ? languageClassName.slice("language-".length) : null;
|
|
296
|
+
};
|
|
297
|
+
var getLanguageLabel = (props) => {
|
|
298
|
+
const explicitLabel = asTrimmedString2(props["data-language-label"]);
|
|
299
|
+
if (explicitLabel) {
|
|
300
|
+
return explicitLabel;
|
|
301
|
+
}
|
|
302
|
+
const explicitLanguage = asTrimmedString2(props["data-language"]) ?? getLanguageFromChildren(props.children);
|
|
303
|
+
return explicitLanguage ? explicitLanguage.toUpperCase() : "CODE";
|
|
304
|
+
};
|
|
305
|
+
var Pre = ({ children, className, ...props }) => {
|
|
306
|
+
const preRef = useRef3(null);
|
|
307
|
+
const isInChoiceGroup = useIsInCodeBlockGroup();
|
|
308
|
+
const label = asTrimmedString2(props["data-code-title"]) ?? getLanguageLabel(props);
|
|
309
|
+
const fileState = props["file-added"] ? "added" : props["file-removed"] ? "removed" : null;
|
|
310
|
+
const hideMenu = props["hide-menu"] === "true";
|
|
311
|
+
const copyButton = hideMenu || isInChoiceGroup ? null : /* @__PURE__ */ jsx6(
|
|
312
|
+
CodeBlockCopyButton,
|
|
313
|
+
{
|
|
314
|
+
onCopy: async () => {
|
|
315
|
+
const text = trimTrailingWhitespace(preRef.current?.textContent ?? "");
|
|
316
|
+
try {
|
|
317
|
+
await navigator.clipboard.writeText(text);
|
|
318
|
+
return true;
|
|
319
|
+
} catch {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
);
|
|
325
|
+
return /* @__PURE__ */ jsxs3(
|
|
326
|
+
"div",
|
|
327
|
+
{
|
|
328
|
+
className: cmMerge3(
|
|
329
|
+
"group relative h-full not-prose overflow-hidden",
|
|
330
|
+
isInChoiceGroup ? "" : "mb-6 rounded-box border border-base-muted-light bg-base-100/60",
|
|
331
|
+
className
|
|
332
|
+
),
|
|
333
|
+
"data-code-block-frame": "",
|
|
334
|
+
"data-file-state": fileState ?? void 0,
|
|
335
|
+
children: [
|
|
336
|
+
!isInChoiceGroup && /* @__PURE__ */ jsxs3(
|
|
337
|
+
"div",
|
|
338
|
+
{
|
|
339
|
+
className: "flex min-h-10 items-center justify-between gap-3 border-b border-base-muted-light bg-base-muted-superlight! px-4",
|
|
340
|
+
"data-code-block-header": "",
|
|
341
|
+
children: [
|
|
342
|
+
/* @__PURE__ */ jsx6("div", { className: "font-mono text-xs font-semibold tracking-[0.08em] text-base-muted", children: label }),
|
|
343
|
+
copyButton
|
|
344
|
+
]
|
|
345
|
+
}
|
|
346
|
+
),
|
|
347
|
+
/* @__PURE__ */ jsx6(
|
|
348
|
+
"pre",
|
|
349
|
+
{
|
|
350
|
+
...props,
|
|
351
|
+
ref: preRef,
|
|
352
|
+
className: cmMerge3("doc-code-pre m-0 h-full overflow-x-auto bg-base-200! p-4 text-sm", className),
|
|
353
|
+
"data-code-block-content": "",
|
|
354
|
+
children
|
|
355
|
+
}
|
|
356
|
+
)
|
|
357
|
+
]
|
|
358
|
+
}
|
|
359
|
+
);
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
// src/components/Link.tsx
|
|
363
|
+
import { cmMerge as cmMerge4 } from "@classmatejs/react";
|
|
364
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
365
|
+
function assertUsage(condition, message) {
|
|
366
|
+
if (!condition) {
|
|
367
|
+
throw new Error(`[UniversalMdxMods][Wrong Usage] ${message}`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
var assertWarning = (condition, message) => {
|
|
371
|
+
const isDev = import.meta.env?.DEV === true;
|
|
372
|
+
if (condition || !isDev) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
console.warn(`[UniversalMdxMods][Warning] ${message}`);
|
|
376
|
+
};
|
|
377
|
+
var parseMarkdownMini = (markdown) => {
|
|
378
|
+
const parts = [];
|
|
379
|
+
let current;
|
|
380
|
+
for (const letter of markdown.split("")) {
|
|
381
|
+
if (letter === "`") {
|
|
382
|
+
if (current?.nodeType === "code") {
|
|
383
|
+
parts.push(current);
|
|
384
|
+
current = void 0;
|
|
385
|
+
} else {
|
|
386
|
+
if (current) {
|
|
387
|
+
parts.push(current);
|
|
388
|
+
}
|
|
389
|
+
current = { nodeType: "code", content: "" };
|
|
390
|
+
}
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
current ??= { nodeType: "text", content: "" };
|
|
394
|
+
current.content += letter;
|
|
395
|
+
}
|
|
396
|
+
if (current) {
|
|
397
|
+
parts.push(current);
|
|
398
|
+
}
|
|
399
|
+
return /* @__PURE__ */ jsx7(Fragment3, { children: parts.map(
|
|
400
|
+
(part, index) => part.nodeType === "code" ? /* @__PURE__ */ jsx7("code", { children: part.content }, index) : /* @__PURE__ */ jsx7("span", { children: part.content }, index)
|
|
401
|
+
) });
|
|
402
|
+
};
|
|
403
|
+
var determineSectionTitle = (href) => {
|
|
404
|
+
const hash = href.split("#")[1];
|
|
405
|
+
if (!hash) {
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
return hash.split(":~:text")[0]?.split("-").map((word, index) => index === 0 ? `${word[0]?.toUpperCase() ?? ""}${word.slice(1)}` : word).join(" ");
|
|
409
|
+
};
|
|
410
|
+
var isExternalHref = (href) => {
|
|
411
|
+
return /^(?:[a-z]+:)?\/\//i.test(href) || href.startsWith("mailto:") || href.startsWith("tel:");
|
|
412
|
+
};
|
|
413
|
+
var renderLabelPart = (value) => {
|
|
414
|
+
return typeof value === "string" ? parseMarkdownMini(value) : value;
|
|
415
|
+
};
|
|
416
|
+
var getLinkText = ({
|
|
417
|
+
isCurrentPage,
|
|
418
|
+
breadcrumb,
|
|
419
|
+
noBreadcrumb,
|
|
420
|
+
sectionTitle,
|
|
421
|
+
title
|
|
422
|
+
}) => {
|
|
423
|
+
const breadcrumbParts = [];
|
|
424
|
+
if (breadcrumb) {
|
|
425
|
+
breadcrumbParts.push(...breadcrumb.map((item) => renderLabelPart(item)));
|
|
426
|
+
}
|
|
427
|
+
if (title) {
|
|
428
|
+
breadcrumbParts.push(renderLabelPart(title));
|
|
429
|
+
}
|
|
430
|
+
if (sectionTitle) {
|
|
431
|
+
breadcrumbParts.push(renderLabelPart(sectionTitle));
|
|
432
|
+
}
|
|
433
|
+
if (noBreadcrumb || isCurrentPage) {
|
|
434
|
+
return breadcrumbParts[breadcrumbParts.length - 1] ?? null;
|
|
435
|
+
}
|
|
436
|
+
return /* @__PURE__ */ jsx7(Fragment3, { children: breadcrumbParts.map((part, index) => /* @__PURE__ */ jsxs4("span", { children: [
|
|
437
|
+
index > 0 ? " > " : null,
|
|
438
|
+
part
|
|
439
|
+
] }, index)) });
|
|
440
|
+
};
|
|
441
|
+
var Link = ({
|
|
442
|
+
href,
|
|
443
|
+
text,
|
|
444
|
+
noBreadcrumb,
|
|
445
|
+
doNotInferSectionTitle,
|
|
446
|
+
noWarning,
|
|
447
|
+
children,
|
|
448
|
+
className,
|
|
449
|
+
...props
|
|
450
|
+
}) => {
|
|
451
|
+
const runtime = useUniversalMdxRuntime();
|
|
452
|
+
if (typeof href !== "string" || href === "") {
|
|
453
|
+
assertWarning(false, "<Link /> is missing `href`.");
|
|
454
|
+
return /* @__PURE__ */ jsx7("a", { className: cmMerge4(className, "inline-flex gap-1 items-center"), ...props, children: text ?? children ?? "LINK-TARGET-NOT-FOUND" });
|
|
455
|
+
}
|
|
456
|
+
assertUsage(
|
|
457
|
+
href.startsWith("/") || href.startsWith("#") || isExternalHref(href),
|
|
458
|
+
`<Link href /> prop \`href==='${href}'\` but should be external or start with '/' or '#'`
|
|
459
|
+
);
|
|
460
|
+
assertUsage(!text || !children, "Cannot use both `text` or `children`");
|
|
461
|
+
const content = text ?? children;
|
|
462
|
+
const resolvedDocLink = runtime?.resolveDocLink?.({
|
|
463
|
+
href,
|
|
464
|
+
doNotInferSectionTitle,
|
|
465
|
+
noWarning
|
|
466
|
+
});
|
|
467
|
+
const localizedHref = resolvedDocLink?.href ?? runtime?.localizeHref?.(href) ?? withSiteBaseUrl(href);
|
|
468
|
+
const inferredSectionTitle = resolvedDocLink?.sectionTitle ?? (!doNotInferSectionTitle ? determineSectionTitle(href) : null);
|
|
469
|
+
const inferredText = content ?? (resolvedDocLink ? getLinkText({
|
|
470
|
+
breadcrumb: resolvedDocLink.breadcrumb,
|
|
471
|
+
isCurrentPage: resolvedDocLink.isCurrentPage,
|
|
472
|
+
noBreadcrumb,
|
|
473
|
+
sectionTitle: inferredSectionTitle ?? void 0,
|
|
474
|
+
title: resolvedDocLink.title
|
|
475
|
+
}) : isExternalHref(href) ? href : inferredSectionTitle ?? "LINK-TARGET-NOT-FOUND");
|
|
476
|
+
return /* @__PURE__ */ jsx7("a", { href: localizedHref, className: cmMerge4(className, ""), ...props, children: inferredText });
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
// src/components/Overview.tsx
|
|
480
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
481
|
+
import { createElement } from "react";
|
|
482
|
+
var isOverviewDividerItem = (item) => typeof item === "object" && item !== null && "dividerText" in item;
|
|
483
|
+
function assertUsage2(condition, message) {
|
|
484
|
+
if (!condition) {
|
|
485
|
+
throw new Error(`[UniversalMdxMods][Wrong Usage] ${message}`);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
var groupOverviewItems = (items) => {
|
|
489
|
+
const groups = [];
|
|
490
|
+
let currentGroup = {
|
|
491
|
+
items: []
|
|
492
|
+
};
|
|
493
|
+
const commitCurrentGroup = () => {
|
|
494
|
+
if (currentGroup.items.length > 0) {
|
|
495
|
+
groups.push(currentGroup);
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
for (const item of items) {
|
|
499
|
+
if (isOverviewDividerItem(item)) {
|
|
500
|
+
commitCurrentGroup();
|
|
501
|
+
currentGroup = {
|
|
502
|
+
dividerText: item.dividerText,
|
|
503
|
+
items: []
|
|
504
|
+
};
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
currentGroup.items.push(item);
|
|
508
|
+
}
|
|
509
|
+
commitCurrentGroup();
|
|
510
|
+
return groups;
|
|
511
|
+
};
|
|
512
|
+
var OverviewCard = ({ excerpt, href, title }) => {
|
|
513
|
+
return /* @__PURE__ */ jsxs5(
|
|
514
|
+
"a",
|
|
515
|
+
{
|
|
516
|
+
href: withSiteBaseUrl(href),
|
|
517
|
+
className: "group flex h-full flex-col gap-3 rounded-box border border-base-muted-light bg-base-muted-superlight p-5 no-underline hover:border-primary-muted-medium hover:bg-base-muted-superlight/50",
|
|
518
|
+
children: [
|
|
519
|
+
/* @__PURE__ */ jsx8("h3", { className: "text-lg font-semibold text-base-content", children: renderInlineMarkdown(title) }),
|
|
520
|
+
excerpt ? /* @__PURE__ */ jsx8("p", { className: "text-sm leading-relaxed text-base-muted", children: renderInlineMarkdown(excerpt) }) : null
|
|
521
|
+
]
|
|
522
|
+
}
|
|
523
|
+
);
|
|
524
|
+
};
|
|
525
|
+
var normalizeOverviewItems = (items, resolveOverviewItem) => {
|
|
526
|
+
return items.map((item) => {
|
|
527
|
+
if (typeof item !== "string") {
|
|
528
|
+
return item;
|
|
529
|
+
}
|
|
530
|
+
const resolvedItem = resolveOverviewItem?.(item);
|
|
531
|
+
assertUsage2(
|
|
532
|
+
resolvedItem,
|
|
533
|
+
`Overview item "${item}" requires runtime.resolveOverviewItem(). Pass { title, href, excerpt } manually when no resolver is available.`
|
|
534
|
+
);
|
|
535
|
+
return resolvedItem;
|
|
536
|
+
});
|
|
537
|
+
};
|
|
538
|
+
var Overview = ({ items }) => {
|
|
539
|
+
const runtime = useUniversalMdxRuntime();
|
|
540
|
+
const groups = groupOverviewItems(normalizeOverviewItems(items, runtime?.resolveOverviewItem));
|
|
541
|
+
if (groups.length === 0) {
|
|
542
|
+
return null;
|
|
543
|
+
}
|
|
544
|
+
return /* @__PURE__ */ jsx8("div", { className: "prose-headings:my-0 prose-p:my-0 my-5 flex flex-col gap-8", children: groups.map((group, groupIndex) => /* @__PURE__ */ jsxs5("section", { className: "flex flex-col gap-4", children: [
|
|
545
|
+
group.dividerText ? /* @__PURE__ */ jsx8("p", { className: "text-sm font-semibold uppercase tracking-wide", children: renderInlineMarkdown(group.dividerText) }) : null,
|
|
546
|
+
/* @__PURE__ */ jsx8("div", { className: "grid gap-4 sm:grid-cols-2", children: group.items.map((item, itemIndex) => /* @__PURE__ */ createElement(OverviewCard, { ...item, key: item.href || itemIndex })) })
|
|
547
|
+
] }, groupIndex)) });
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
// src/components/RepoLink.tsx
|
|
551
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
552
|
+
var RepoLink = ({ repo, timestamp }) => {
|
|
553
|
+
if (!repo || repo.split("/").length !== 2) {
|
|
554
|
+
throw new Error("Invalid repo");
|
|
555
|
+
}
|
|
556
|
+
return /* @__PURE__ */ jsxs6("span", { className: "inline-flex items-center gap-1", children: [
|
|
557
|
+
/* @__PURE__ */ jsx9("span", { className: "bg-white font-mono font-bold h-fit px-1 text-sm!", children: timestamp }),
|
|
558
|
+
/* @__PURE__ */ jsxs6("a", { href: `https://github.com/${repo}`, target: "_blank", rel: "noopener", children: [
|
|
559
|
+
"GitHub > ",
|
|
560
|
+
/* @__PURE__ */ jsx9("code", { children: repo })
|
|
561
|
+
] })
|
|
562
|
+
] });
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
// src/components/Table.tsx
|
|
566
|
+
import cm2 from "@classmatejs/react";
|
|
567
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
568
|
+
var Table = ({ size = "md", data }) => {
|
|
569
|
+
return /* @__PURE__ */ jsxs7(StyledTable, { $size: size, children: [
|
|
570
|
+
/* @__PURE__ */ jsx10("thead", { className: "overflow-hidden rounded-t-box bg-base-200", children: /* @__PURE__ */ jsx10("tr", { children: data.headers.map((header, index) => /* @__PURE__ */ jsx10("th", { children: header }, index)) }) }),
|
|
571
|
+
/* @__PURE__ */ jsx10("tbody", { children: data.rows.map((row, rowIndex) => /* @__PURE__ */ jsx10("tr", { children: row.map((cell, cellIndex) => /* @__PURE__ */ jsx10("td", { children: cell }, cellIndex)) }, rowIndex)) })
|
|
572
|
+
] });
|
|
573
|
+
};
|
|
574
|
+
var StyledTable = cm2.table.variants({
|
|
575
|
+
base: `
|
|
576
|
+
not-prose
|
|
577
|
+
table
|
|
578
|
+
w-full
|
|
579
|
+
table-zebra
|
|
580
|
+
mb-6
|
|
581
|
+
`,
|
|
582
|
+
variants: {
|
|
583
|
+
$size: {
|
|
584
|
+
sm: "table-sm",
|
|
585
|
+
md: "table-md",
|
|
586
|
+
lg: "table-lg"
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
defaultVariants: {
|
|
590
|
+
$size: "md"
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
// src/defineDocsConfig.ts
|
|
595
|
+
var defineDocsConfig = (config) => config;
|
|
596
|
+
|
|
597
|
+
// src/defineDocsGraph.ts
|
|
598
|
+
var defineDocsGraph = (graph) => graph;
|
|
599
|
+
|
|
600
|
+
export {
|
|
601
|
+
Alert,
|
|
602
|
+
ChoiceGroup,
|
|
603
|
+
CodeBlockTransformer,
|
|
604
|
+
FileAdded,
|
|
605
|
+
FileRemoved,
|
|
606
|
+
Pre,
|
|
607
|
+
Link,
|
|
608
|
+
Overview,
|
|
609
|
+
RepoLink,
|
|
610
|
+
Table,
|
|
611
|
+
defineDocsConfig,
|
|
612
|
+
defineDocsGraph
|
|
613
|
+
};
|
|
614
|
+
//# sourceMappingURL=chunk-3JJ6TYWL.js.map
|