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