@docubook/mdx 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,465 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Button: () => Button,
34
+ Card: () => Card,
35
+ CardGroup: () => CardGroup,
36
+ Changes: () => Changes,
37
+ Kbd: () => Kbd,
38
+ Link: () => Link,
39
+ Note: () => Note,
40
+ Release: () => Release,
41
+ Stepper: () => Stepper,
42
+ StepperItem: () => StepperItem,
43
+ Youtube: () => Youtube,
44
+ createCoreServerMdxComponents: () => createCoreServerMdxComponents
45
+ });
46
+ module.exports = __toCommonJS(index_exports);
47
+
48
+ // src/core/components/Button.tsx
49
+ var Icons = __toESM(require("lucide-react"), 1);
50
+ var import_jsx_runtime = require("react/jsx-runtime");
51
+ function Button({
52
+ icon,
53
+ text,
54
+ href,
55
+ target,
56
+ size = "md",
57
+ variation = "primary",
58
+ LinkComponent
59
+ }) {
60
+ const baseStyles = "inline-flex items-center justify-center rounded font-medium focus:outline-none transition no-underline";
61
+ const sizeStyles = {
62
+ sm: "px-3 py-1 my-6 text-sm",
63
+ md: "px-4 py-2 my-6 text-base",
64
+ lg: "px-5 py-3 my-6 text-lg"
65
+ };
66
+ const variationStyles = {
67
+ primary: "bg-primary text-white hover:bg-primary/90",
68
+ accent: "bg-accent text-white hover:bg-accent/90",
69
+ outline: "border border-accent text-accent hover:bg-accent/10"
70
+ };
71
+ const Icon = icon ? Icons[icon] : null;
72
+ const className = `${baseStyles} ${sizeStyles[size]} ${variationStyles[variation]}`;
73
+ const inner = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
74
+ text && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: text }),
75
+ Icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { className: "mr-2 h-5 w-5" })
76
+ ] });
77
+ if (LinkComponent) {
78
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
79
+ LinkComponent,
80
+ {
81
+ href,
82
+ target,
83
+ rel: target === "_blank" ? "noopener noreferrer" : void 0,
84
+ className,
85
+ children: inner
86
+ }
87
+ );
88
+ }
89
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
90
+ "a",
91
+ {
92
+ href,
93
+ target,
94
+ rel: target === "_blank" ? "noopener noreferrer" : void 0,
95
+ className,
96
+ children: inner
97
+ }
98
+ );
99
+ }
100
+
101
+ // src/core/components/Card.tsx
102
+ var Icons2 = __toESM(require("lucide-react"), 1);
103
+ var import_clsx = __toESM(require("clsx"), 1);
104
+ var import_jsx_runtime2 = require("react/jsx-runtime");
105
+ function Card({
106
+ title,
107
+ icon,
108
+ href,
109
+ horizontal,
110
+ children,
111
+ className,
112
+ LinkComponent
113
+ }) {
114
+ const Icon = icon ? Icons2[icon] : null;
115
+ const content = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
116
+ "div",
117
+ {
118
+ className: (0, import_clsx.default)(
119
+ "border rounded-lg shadow-sm p-4 transition-all duration-200",
120
+ "bg-card text-card-foreground border-border",
121
+ "hover:bg-accent/5 hover:border-accent/30",
122
+ "flex gap-2",
123
+ horizontal ? "flex-row items-start gap-1" : "flex-col space-y-1",
124
+ className
125
+ ),
126
+ children: [
127
+ Icon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { className: (0, import_clsx.default)("w-5 h-5 text-primary shrink-0", horizontal && "mt-0.5") }),
128
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex-1 min-w-0", children: [
129
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "text-base font-semibold text-foreground leading-6", children: title }),
130
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "text-sm text-muted-foreground -mt-3", children })
131
+ ] })
132
+ ]
133
+ }
134
+ );
135
+ if (!href) return content;
136
+ if (LinkComponent) {
137
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LinkComponent, { href, className: "no-underline block", children: content });
138
+ }
139
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { className: "no-underline block", href, children: content });
140
+ }
141
+
142
+ // src/core/components/CardGroup.tsx
143
+ var import_react = __toESM(require("react"), 1);
144
+ var import_clsx2 = __toESM(require("clsx"), 1);
145
+ var import_jsx_runtime3 = require("react/jsx-runtime");
146
+ function CardGroup({ children, cols = 2, className }) {
147
+ const cardsArray = import_react.default.Children.toArray(children);
148
+ const gridColsClass = {
149
+ 1: "grid-cols-1",
150
+ 2: "grid-cols-1 sm:grid-cols-2",
151
+ 3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
152
+ 4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4"
153
+ }[cols] || "grid-cols-1 sm:grid-cols-2";
154
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: (0, import_clsx2.default)("grid gap-4 text-foreground", gridColsClass, className), children: cardsArray.map((card, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: card }, index)) });
155
+ }
156
+
157
+ // src/core/components/Keyboard.tsx
158
+ var import_jsx_runtime4 = require("react/jsx-runtime");
159
+ var macKeyMap = {
160
+ command: "\u2318",
161
+ cmd: "\u2318",
162
+ option: "\u2325",
163
+ alt: "\u2325",
164
+ shift: "\u21E7",
165
+ ctrl: "\u2303",
166
+ control: "\u2303",
167
+ tab: "\u21E5",
168
+ caps: "\u21EA",
169
+ enter: "\u23CE",
170
+ return: "\u23CE",
171
+ delete: "\u232B",
172
+ escape: "\u238B",
173
+ esc: "\u238B",
174
+ up: "\u2191",
175
+ down: "\u2193",
176
+ left: "\u2190",
177
+ right: "\u2192",
178
+ space: "\u2423"
179
+ };
180
+ var windowsKeyMap = {
181
+ command: "Win",
182
+ cmd: "Win",
183
+ option: "Alt",
184
+ alt: "Alt",
185
+ ctrl: "Ctrl",
186
+ control: "Ctrl",
187
+ delete: "Del",
188
+ escape: "Esc",
189
+ esc: "Esc",
190
+ enter: "Enter",
191
+ return: "Enter",
192
+ tab: "Tab",
193
+ caps: "Caps",
194
+ shift: "Shift",
195
+ space: "Space",
196
+ up: "\u2191",
197
+ down: "\u2193",
198
+ left: "\u2190",
199
+ right: "\u2192"
200
+ };
201
+ function Kbd({
202
+ show: keyProp,
203
+ type = "window",
204
+ children,
205
+ ...props
206
+ }) {
207
+ const getKeyDisplay = () => {
208
+ if (!keyProp || typeof keyProp !== "string") return null;
209
+ const lowerKey = keyProp.toLowerCase();
210
+ if (type === "mac") {
211
+ return macKeyMap[lowerKey] || keyProp;
212
+ }
213
+ return windowsKeyMap[lowerKey] || keyProp.charAt(0).toUpperCase() + keyProp.slice(1);
214
+ };
215
+ const renderContent = () => {
216
+ if (children !== void 0 && children !== null && children !== "") {
217
+ return children;
218
+ }
219
+ return getKeyDisplay() || keyProp || "";
220
+ };
221
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
222
+ "kbd",
223
+ {
224
+ className: "inline-flex items-center justify-center px-2 py-1 mx-0.5 text-xs font-mono font-medium text-foreground bg-secondary/70 border rounded-md",
225
+ ...props,
226
+ children: renderContent()
227
+ }
228
+ );
229
+ }
230
+
231
+ // src/core/components/Link.tsx
232
+ var import_jsx_runtime5 = require("react/jsx-runtime");
233
+ function isUnsafeHref(href) {
234
+ const normalized = href.trim().toLowerCase();
235
+ return normalized.startsWith("javascript:") || normalized.startsWith("data:") || normalized.startsWith("vbscript:");
236
+ }
237
+ function Link({ href, target, rel, ...props }) {
238
+ if (!href) return null;
239
+ if (isUnsafeHref(href)) return null;
240
+ const isExternal = /^https?:\/\//.test(href);
241
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
242
+ "a",
243
+ {
244
+ href,
245
+ ...props,
246
+ target: target ?? (isExternal ? "_blank" : void 0),
247
+ rel: rel ?? (isExternal ? "noopener noreferrer" : void 0)
248
+ }
249
+ );
250
+ }
251
+
252
+ // src/core/components/Note.tsx
253
+ var import_class_variance_authority = require("class-variance-authority");
254
+ var import_lucide_react = require("lucide-react");
255
+
256
+ // src/core/utils/cn.ts
257
+ var import_clsx3 = require("clsx");
258
+ var import_tailwind_merge = require("tailwind-merge");
259
+ function cn(...inputs) {
260
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx3.clsx)(inputs));
261
+ }
262
+
263
+ // src/core/components/Note.tsx
264
+ var import_jsx_runtime6 = require("react/jsx-runtime");
265
+ var noteVariants = (0, import_class_variance_authority.cva)(
266
+ "relative w-full rounded-lg border border-l-4 p-4 mb-4 [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",
267
+ {
268
+ variants: {
269
+ variant: {
270
+ note: "bg-muted/30 border-border border-l-primary/50 text-foreground [&>svg]:text-primary",
271
+ danger: "border-destructive/20 border-l-destructive/60 bg-destructive/5 text-destructive [&>svg]:text-destructive dark:border-destructive/30",
272
+ warning: "border-orange-500/20 border-l-orange-500/60 bg-orange-500/5 text-orange-600 dark:text-orange-400 [&>svg]:text-orange-600 dark:[&>svg]:text-orange-400",
273
+ success: "border-emerald-500/20 border-l-emerald-500/60 bg-emerald-500/5 text-emerald-600 dark:text-emerald-400 [&>svg]:text-emerald-600 dark:[&>svg]:text-emerald-400"
274
+ }
275
+ },
276
+ defaultVariants: {
277
+ variant: "note"
278
+ }
279
+ }
280
+ );
281
+ var iconMap = {
282
+ note: import_lucide_react.Info,
283
+ danger: import_lucide_react.ShieldAlert,
284
+ warning: import_lucide_react.AlertTriangle,
285
+ success: import_lucide_react.CheckCircle2
286
+ };
287
+ function Note({
288
+ className,
289
+ title = "Note",
290
+ type = "note",
291
+ children,
292
+ ...props
293
+ }) {
294
+ const Icon = iconMap[type] || import_lucide_react.Info;
295
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: cn(noteVariants({ variant: type }), className), ...props, children: [
296
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { className: "h-5 w-5" }),
297
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "pl-8", children: [
298
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h5", { className: "mb-1 font-medium leading-none tracking-tight", children: title }),
299
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-sm [&_p]:leading-relaxed opacity-90", children })
300
+ ] })
301
+ ] });
302
+ }
303
+
304
+ // src/core/components/Release.tsx
305
+ var import_react2 = require("react");
306
+ var import_lucide_react2 = require("lucide-react");
307
+ var import_jsx_runtime7 = require("react/jsx-runtime");
308
+ function Release({ version, title, date, children }) {
309
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "mb-16 group", children: [
310
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-3 mt-6 mb-2", children: [
311
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
312
+ "div",
313
+ {
314
+ id: version,
315
+ className: "inline-flex items-center rounded-full border border-primary/20 bg-primary/10 px-3 py-1 text-sm font-semibold text-primary transition-colors hover:bg-primary/15 scroll-m-20 backdrop-blur-sm",
316
+ children: [
317
+ "v",
318
+ version
319
+ ]
320
+ }
321
+ ),
322
+ date && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-3 text-sm font-medium text-muted-foreground", children: [
323
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "h-1 w-1 rounded-full bg-muted-foreground/30" }),
324
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { dateTime: date, children: new Date(date).toLocaleDateString("en-US", {
325
+ year: "numeric",
326
+ month: "long",
327
+ day: "numeric"
328
+ }) })
329
+ ] })
330
+ ] }),
331
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { className: "text-2xl font-bold text-foreground/90 mb-6 mt-0!", children: title }),
332
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "space-y-8", children })
333
+ ] });
334
+ }
335
+ var typeConfig = {
336
+ added: {
337
+ label: "Added",
338
+ className: "bg-green-100 dark:bg-green-900/50 text-green-700 dark:text-green-300",
339
+ icon: import_lucide_react2.PlusCircle
340
+ },
341
+ fixed: {
342
+ label: "Fixed",
343
+ className: "bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-300",
344
+ icon: import_lucide_react2.Wrench
345
+ },
346
+ improved: {
347
+ label: "Improved",
348
+ className: "bg-cyan-100 dark:bg-cyan-900/50 text-cyan-700 dark:text-cyan-300",
349
+ icon: import_lucide_react2.Zap
350
+ },
351
+ deprecated: {
352
+ label: "Deprecated",
353
+ className: "bg-orange-100 dark:bg-orange-900/50 text-orange-700 dark:text-orange-300",
354
+ icon: import_lucide_react2.AlertTriangle
355
+ },
356
+ removed: {
357
+ label: "Removed",
358
+ className: "bg-pink-100 dark:bg-pink-900/50 text-pink-700 dark:text-pink-300",
359
+ icon: import_lucide_react2.XCircle
360
+ }
361
+ };
362
+ function Changes({ type, children }) {
363
+ const config = typeConfig[type] || typeConfig.added;
364
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-3 mb-8", children: [
365
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
366
+ "div",
367
+ {
368
+ className: cn(
369
+ "px-3 py-1 rounded-full text-sm font-medium flex items-center gap-1.5",
370
+ config.className
371
+ ),
372
+ children: [
373
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(config.icon, { className: "h-3.5 w-3.5" }),
374
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: config.label })
375
+ ]
376
+ }
377
+ ) }),
378
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "list-none pl-0 space-y-2 text-foreground/80", children: import_react2.Children.map(children, (child, index) => {
379
+ const processedChild = typeof child === "string" ? child.trim().replace(/^[-*]\s+/, "") : child;
380
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { className: "leading-relaxed", children: processedChild }, index);
381
+ }) })
382
+ ] });
383
+ }
384
+
385
+ // src/core/components/Stepper.tsx
386
+ var import_clsx4 = __toESM(require("clsx"), 1);
387
+ var import_react3 = require("react");
388
+ var import_jsx_runtime8 = require("react/jsx-runtime");
389
+ function Stepper({ children }) {
390
+ const length = import_react3.Children.count(children);
391
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex flex-col", children: import_react3.Children.map(children, (child, index) => {
392
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
393
+ "div",
394
+ {
395
+ className: cn(
396
+ "border-l border-muted pl-9 ml-3 relative",
397
+ (0, import_clsx4.default)({
398
+ "pb-5 ": index < length - 1
399
+ })
400
+ ),
401
+ children: [
402
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "bg-muted text-muted-foreground w-8 h-8 text-xs font-medium rounded-md border border-border/50 flex items-center justify-center absolute -left-4 font-code", children: index + 1 }),
403
+ child
404
+ ]
405
+ }
406
+ );
407
+ }) });
408
+ }
409
+ function StepperItem({
410
+ children,
411
+ title
412
+ }) {
413
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "pt-0.5", children: [
414
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h4", { className: "mt-0", children: title }),
415
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children })
416
+ ] });
417
+ }
418
+
419
+ // src/core/components/Youtube.tsx
420
+ var import_jsx_runtime9 = require("react/jsx-runtime");
421
+ var Youtube = ({ videoId, className }) => {
422
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `youtube ${className || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
423
+ "iframe",
424
+ {
425
+ src: `https://www.youtube.com/embed/${videoId}?rel=0&modestbranding=1&showinfo=0&autohide=1&controls=1`,
426
+ title: "YouTube video player",
427
+ frameBorder: "0",
428
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
429
+ allowFullScreen: true
430
+ }
431
+ ) });
432
+ };
433
+
434
+ // src/core/server.ts
435
+ function createCoreServerMdxComponents() {
436
+ return {
437
+ Button,
438
+ Card,
439
+ CardGroup,
440
+ Kbd,
441
+ kbd: Kbd,
442
+ Note,
443
+ Stepper,
444
+ StepperItem,
445
+ Youtube,
446
+ Release,
447
+ Changes,
448
+ a: Link
449
+ };
450
+ }
451
+ // Annotate the CommonJS export names for ESM import in node:
452
+ 0 && (module.exports = {
453
+ Button,
454
+ Card,
455
+ CardGroup,
456
+ Changes,
457
+ Kbd,
458
+ Link,
459
+ Note,
460
+ Release,
461
+ Stepper,
462
+ StepperItem,
463
+ Youtube,
464
+ createCoreServerMdxComponents
465
+ });
@@ -0,0 +1,8 @@
1
+ export { createCoreServerMdxComponents } from './core/server.cjs';
2
+ export { B as Button, C as Card, L as LinkLikeProps, a as LinkRenderer } from './Card-L5O7G4xG.cjs';
3
+ export { C as CardGroup, b as Changes, K as Kbd, L as Link, N as Note, R as Release, S as Stepper, a as StepperItem, c as Youtube } from './Stepper-B7xt0Dyr.cjs';
4
+ import 'react';
5
+ import 'react/jsx-runtime';
6
+ import 'class-variance-authority/types';
7
+ import 'class-variance-authority';
8
+ import 'lucide-react';
@@ -0,0 +1,8 @@
1
+ export { createCoreServerMdxComponents } from './core/server.js';
2
+ export { B as Button, C as Card, L as LinkLikeProps, a as LinkRenderer } from './Card-L5O7G4xG.js';
3
+ export { C as CardGroup, b as Changes, K as Kbd, L as Link, N as Note, R as Release, S as Stepper, a as StepperItem, c as Youtube } from './Stepper-B7xt0Dyr.js';
4
+ import 'react';
5
+ import 'react/jsx-runtime';
6
+ import 'class-variance-authority/types';
7
+ import 'class-variance-authority';
8
+ import 'lucide-react';