@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/LICENSE +21 -0
- package/README.md +118 -0
- package/dist/Card-L5O7G4xG.d.cts +33 -0
- package/dist/Card-L5O7G4xG.d.ts +33 -0
- package/dist/Image-DZPezRHi.d.cts +7 -0
- package/dist/Image-DZPezRHi.d.ts +7 -0
- package/dist/Stepper-B7xt0Dyr.d.cts +53 -0
- package/dist/Stepper-B7xt0Dyr.d.ts +53 -0
- package/dist/adapters/next/index.cjs +204 -0
- package/dist/adapters/next/index.d.cts +15 -0
- package/dist/adapters/next/index.d.ts +15 -0
- package/dist/adapters/next/index.js +166 -0
- package/dist/adapters/react-router/index.cjs +290 -0
- package/dist/adapters/react-router/index.d.cts +11 -0
- package/dist/adapters/react-router/index.d.ts +11 -0
- package/dist/adapters/react-router/index.js +252 -0
- package/dist/core/index.cjs +909 -0
- package/dist/core/index.d.cts +75 -0
- package/dist/core/index.d.ts +75 -0
- package/dist/core/index.js +896 -0
- package/dist/core/server.cjs +465 -0
- package/dist/core/server.d.cts +26 -0
- package/dist/core/server.d.ts +26 -0
- package/dist/core/server.js +428 -0
- package/dist/index.cjs +465 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +428 -0
- package/package.json +98 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// src/adapters/react-router/index.tsx
|
|
2
|
+
import { Link as RouterLink } from "react-router-dom";
|
|
3
|
+
|
|
4
|
+
// src/core/components/Button.tsx
|
|
5
|
+
import * as Icons from "lucide-react";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
function Button({
|
|
8
|
+
icon,
|
|
9
|
+
text,
|
|
10
|
+
href,
|
|
11
|
+
target,
|
|
12
|
+
size = "md",
|
|
13
|
+
variation = "primary",
|
|
14
|
+
LinkComponent
|
|
15
|
+
}) {
|
|
16
|
+
const baseStyles = "inline-flex items-center justify-center rounded font-medium focus:outline-none transition no-underline";
|
|
17
|
+
const sizeStyles = {
|
|
18
|
+
sm: "px-3 py-1 my-6 text-sm",
|
|
19
|
+
md: "px-4 py-2 my-6 text-base",
|
|
20
|
+
lg: "px-5 py-3 my-6 text-lg"
|
|
21
|
+
};
|
|
22
|
+
const variationStyles = {
|
|
23
|
+
primary: "bg-primary text-white hover:bg-primary/90",
|
|
24
|
+
accent: "bg-accent text-white hover:bg-accent/90",
|
|
25
|
+
outline: "border border-accent text-accent hover:bg-accent/10"
|
|
26
|
+
};
|
|
27
|
+
const Icon = icon ? Icons[icon] : null;
|
|
28
|
+
const className = `${baseStyles} ${sizeStyles[size]} ${variationStyles[variation]}`;
|
|
29
|
+
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
30
|
+
text && /* @__PURE__ */ jsx("span", { children: text }),
|
|
31
|
+
Icon && /* @__PURE__ */ jsx(Icon, { className: "mr-2 h-5 w-5" })
|
|
32
|
+
] });
|
|
33
|
+
if (LinkComponent) {
|
|
34
|
+
return /* @__PURE__ */ jsx(
|
|
35
|
+
LinkComponent,
|
|
36
|
+
{
|
|
37
|
+
href,
|
|
38
|
+
target,
|
|
39
|
+
rel: target === "_blank" ? "noopener noreferrer" : void 0,
|
|
40
|
+
className,
|
|
41
|
+
children: inner
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return /* @__PURE__ */ jsx(
|
|
46
|
+
"a",
|
|
47
|
+
{
|
|
48
|
+
href,
|
|
49
|
+
target,
|
|
50
|
+
rel: target === "_blank" ? "noopener noreferrer" : void 0,
|
|
51
|
+
className,
|
|
52
|
+
children: inner
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/core/components/Card.tsx
|
|
58
|
+
import * as Icons2 from "lucide-react";
|
|
59
|
+
import clsx from "clsx";
|
|
60
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
61
|
+
function Card({
|
|
62
|
+
title,
|
|
63
|
+
icon,
|
|
64
|
+
href,
|
|
65
|
+
horizontal,
|
|
66
|
+
children,
|
|
67
|
+
className,
|
|
68
|
+
LinkComponent
|
|
69
|
+
}) {
|
|
70
|
+
const Icon = icon ? Icons2[icon] : null;
|
|
71
|
+
const content = /* @__PURE__ */ jsxs2(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
className: clsx(
|
|
75
|
+
"border rounded-lg shadow-sm p-4 transition-all duration-200",
|
|
76
|
+
"bg-card text-card-foreground border-border",
|
|
77
|
+
"hover:bg-accent/5 hover:border-accent/30",
|
|
78
|
+
"flex gap-2",
|
|
79
|
+
horizontal ? "flex-row items-start gap-1" : "flex-col space-y-1",
|
|
80
|
+
className
|
|
81
|
+
),
|
|
82
|
+
children: [
|
|
83
|
+
Icon && /* @__PURE__ */ jsx2(Icon, { className: clsx("w-5 h-5 text-primary shrink-0", horizontal && "mt-0.5") }),
|
|
84
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex-1 min-w-0", children: [
|
|
85
|
+
/* @__PURE__ */ jsx2("div", { className: "text-base font-semibold text-foreground leading-6", children: title }),
|
|
86
|
+
/* @__PURE__ */ jsx2("div", { className: "text-sm text-muted-foreground -mt-3", children })
|
|
87
|
+
] })
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
if (!href) return content;
|
|
92
|
+
if (LinkComponent) {
|
|
93
|
+
return /* @__PURE__ */ jsx2(LinkComponent, { href, className: "no-underline block", children: content });
|
|
94
|
+
}
|
|
95
|
+
return /* @__PURE__ */ jsx2("a", { className: "no-underline block", href, children: content });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// src/core/components/Image.tsx
|
|
99
|
+
import { createPortal } from "react-dom";
|
|
100
|
+
import { X, ZoomIn } from "lucide-react";
|
|
101
|
+
import { useEffect, useRef, useState } from "react";
|
|
102
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
103
|
+
function Image({
|
|
104
|
+
src,
|
|
105
|
+
alt = "alt",
|
|
106
|
+
width = 800,
|
|
107
|
+
height = 350,
|
|
108
|
+
...props
|
|
109
|
+
}) {
|
|
110
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
111
|
+
const scrollYRef = useRef(0);
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
if (!isOpen) return;
|
|
114
|
+
scrollYRef.current = window.scrollY;
|
|
115
|
+
document.body.style.position = "fixed";
|
|
116
|
+
document.body.style.top = `-${scrollYRef.current}px`;
|
|
117
|
+
document.body.style.width = "100%";
|
|
118
|
+
const handleEsc = (e) => {
|
|
119
|
+
if (e.key === "Escape") setIsOpen(false);
|
|
120
|
+
};
|
|
121
|
+
window.addEventListener("keydown", handleEsc);
|
|
122
|
+
return () => {
|
|
123
|
+
document.body.style.position = "";
|
|
124
|
+
document.body.style.top = "";
|
|
125
|
+
document.body.style.width = "";
|
|
126
|
+
window.scrollTo(0, scrollYRef.current);
|
|
127
|
+
window.removeEventListener("keydown", handleEsc);
|
|
128
|
+
};
|
|
129
|
+
}, [isOpen]);
|
|
130
|
+
if (!src) return null;
|
|
131
|
+
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
132
|
+
/* @__PURE__ */ jsxs3(
|
|
133
|
+
"button",
|
|
134
|
+
{
|
|
135
|
+
type: "button",
|
|
136
|
+
className: "relative group cursor-zoom-in my-6 w-full flex justify-center rounded-lg",
|
|
137
|
+
onClick: () => setIsOpen(true),
|
|
138
|
+
"aria-label": "Zoom image",
|
|
139
|
+
children: [
|
|
140
|
+
/* @__PURE__ */ jsx3("span", { className: "absolute inset-0 bg-black/0 group-hover:bg-black/5 transition-colors z-10 flex items-center justify-center opacity-0 group-hover:opacity-100 rounded-lg", children: /* @__PURE__ */ jsx3(ZoomIn, { className: "w-8 h-8 text-white drop-shadow-md" }) }),
|
|
141
|
+
/* @__PURE__ */ jsx3(
|
|
142
|
+
"img",
|
|
143
|
+
{
|
|
144
|
+
src: typeof src === "string" ? src : "",
|
|
145
|
+
alt,
|
|
146
|
+
width,
|
|
147
|
+
height,
|
|
148
|
+
className: "w-full h-auto rounded-lg transition-transform duration-300 group-hover:scale-[1.01]",
|
|
149
|
+
...props
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
isOpen && /* @__PURE__ */ jsx3(Portal, { children: /* @__PURE__ */ jsxs3(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
className: "fixed inset-0 z-99999 flex items-center justify-center bg-black/90 backdrop-blur-md p-4 md:p-10 cursor-zoom-out",
|
|
159
|
+
onClick: () => setIsOpen(false),
|
|
160
|
+
children: [
|
|
161
|
+
/* @__PURE__ */ jsx3(
|
|
162
|
+
"button",
|
|
163
|
+
{
|
|
164
|
+
className: "absolute top-4 right-4 z-50 p-2 text-white/70 hover:text-white bg-black/20 hover:bg-white/10 rounded-full transition-colors",
|
|
165
|
+
onClick: (e) => {
|
|
166
|
+
e.stopPropagation();
|
|
167
|
+
setIsOpen(false);
|
|
168
|
+
},
|
|
169
|
+
children: /* @__PURE__ */ jsx3(X, { className: "w-6 h-6" })
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
/* @__PURE__ */ jsx3(
|
|
173
|
+
"div",
|
|
174
|
+
{
|
|
175
|
+
className: "relative max-w-7xl w-full h-full flex items-center justify-center",
|
|
176
|
+
onClick: (e) => e.stopPropagation(),
|
|
177
|
+
children: /* @__PURE__ */ jsx3(
|
|
178
|
+
"div",
|
|
179
|
+
{
|
|
180
|
+
className: "relative w-full h-full flex items-center justify-center",
|
|
181
|
+
onClick: () => setIsOpen(false),
|
|
182
|
+
children: /* @__PURE__ */ jsx3(
|
|
183
|
+
"img",
|
|
184
|
+
{
|
|
185
|
+
src: typeof src === "string" ? src : "",
|
|
186
|
+
alt,
|
|
187
|
+
width: 1920,
|
|
188
|
+
height: 1080,
|
|
189
|
+
className: "object-contain max-h-[90vh] w-auto h-auto rounded-md shadow-2xl"
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
alt && alt !== "alt" && /* @__PURE__ */ jsx3("div", { className: "absolute bottom-6 left-1/2 -translate-x-1/2 bg-black/60 text-white px-4 py-2 rounded-full text-sm font-medium backdrop-blur-md border border-white/10", children: alt })
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
) })
|
|
200
|
+
] });
|
|
201
|
+
}
|
|
202
|
+
function Portal({ children }) {
|
|
203
|
+
if (typeof window === "undefined") return null;
|
|
204
|
+
return createPortal(children, document.body);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// src/adapters/react-router/index.tsx
|
|
208
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
209
|
+
function isExternalHref(href) {
|
|
210
|
+
return /^(https?:|mailto:|tel:)/i.test(href);
|
|
211
|
+
}
|
|
212
|
+
function ReactRouterLinkMdx({ href, ...props }) {
|
|
213
|
+
if (!href) return null;
|
|
214
|
+
if (isExternalHref(href)) {
|
|
215
|
+
return /* @__PURE__ */ jsx4(
|
|
216
|
+
"a",
|
|
217
|
+
{
|
|
218
|
+
href,
|
|
219
|
+
...props,
|
|
220
|
+
target: props.target ?? "_blank",
|
|
221
|
+
rel: props.rel ?? "noopener noreferrer"
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
return /* @__PURE__ */ jsx4(RouterLink, { to: href, ...props });
|
|
226
|
+
}
|
|
227
|
+
var RouterLinkRenderer = ({ href, ...props }) => {
|
|
228
|
+
if (isExternalHref(href)) {
|
|
229
|
+
return /* @__PURE__ */ jsx4(
|
|
230
|
+
"a",
|
|
231
|
+
{
|
|
232
|
+
href,
|
|
233
|
+
...props,
|
|
234
|
+
target: props.target ?? "_blank",
|
|
235
|
+
rel: props.rel ?? "noopener noreferrer"
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
return /* @__PURE__ */ jsx4(RouterLink, { to: href, ...props });
|
|
240
|
+
};
|
|
241
|
+
function ReactRouterButtonMdx(props) {
|
|
242
|
+
return /* @__PURE__ */ jsx4(Button, { ...props, LinkComponent: RouterLinkRenderer });
|
|
243
|
+
}
|
|
244
|
+
function ReactRouterCardMdx(props) {
|
|
245
|
+
return /* @__PURE__ */ jsx4(Card, { ...props, LinkComponent: RouterLinkRenderer });
|
|
246
|
+
}
|
|
247
|
+
export {
|
|
248
|
+
ReactRouterButtonMdx,
|
|
249
|
+
ReactRouterCardMdx,
|
|
250
|
+
Image as ReactRouterImageMdx,
|
|
251
|
+
ReactRouterLinkMdx
|
|
252
|
+
};
|