@farming-labs/next 0.1.64 → 0.1.65

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.
@@ -3,6 +3,7 @@ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
3
3
  import { join, relative } from "node:path";
4
4
  import { ApiReference } from "@scalar/nextjs-api-reference";
5
5
  import { buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, resolveApiReferenceConfig, resolveApiReferenceRenderer } from "@farming-labs/docs/server";
6
+ import { SidebarTabsDropdown } from "fumadocs-ui/components/sidebar/tabs/dropdown";
6
7
  import Link from "next/link";
7
8
  import { notFound } from "next/navigation";
8
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -262,24 +263,13 @@ function buildNextOpenApiDocument(config) {
262
263
  paths: buildOpenApiPaths(routes)
263
264
  };
264
265
  }
265
- function SwitcherGlyph({ kind, radius, active }) {
266
+ function SwitcherGlyph({ kind }) {
266
267
  const isApi = kind === "api";
267
268
  return /* @__PURE__ */ jsx("span", {
268
269
  className: "fd-api-reference-switcher-glyph",
269
- "data-active": active ? "true" : "false",
270
+ "data-kind": kind,
270
271
  "aria-hidden": "true",
271
- style: {
272
- display: "inline-flex",
273
- width: 22,
274
- height: 22,
275
- alignItems: "center",
276
- justifyContent: "center",
277
- color: active ? "var(--color-fd-primary, currentColor)" : "var(--fd-api-switcher-muted, var(--color-fd-muted-foreground, rgba(255,255,255,0.72)))",
278
- borderRadius: radius
279
- },
280
272
  children: isApi ? /* @__PURE__ */ jsx("svg", {
281
- width: "13",
282
- height: "13",
283
273
  viewBox: "0 0 24 24",
284
274
  fill: "none",
285
275
  children: /* @__PURE__ */ jsx("path", {
@@ -290,8 +280,6 @@ function SwitcherGlyph({ kind, radius, active }) {
290
280
  strokeLinejoin: "round"
291
281
  })
292
282
  }) : /* @__PURE__ */ jsx("svg", {
293
- width: "13",
294
- height: "13",
295
283
  viewBox: "0 0 24 24",
296
284
  fill: "none",
297
285
  children: /* @__PURE__ */ jsx("path", {
@@ -303,66 +291,6 @@ function SwitcherGlyph({ kind, radius, active }) {
303
291
  })
304
292
  });
305
293
  }
306
- function ChevronStack() {
307
- return /* @__PURE__ */ jsxs("span", {
308
- className: "fd-api-reference-switcher-chevron",
309
- "aria-hidden": "true",
310
- style: {
311
- display: "inline-flex",
312
- flexDirection: "column",
313
- gap: 2
314
- },
315
- children: [/* @__PURE__ */ jsx("svg", {
316
- width: "11",
317
- height: "7",
318
- viewBox: "0 0 10 6",
319
- fill: "none",
320
- children: /* @__PURE__ */ jsx("path", {
321
- d: "M1 5L5 1L9 5",
322
- stroke: "currentColor",
323
- strokeWidth: "1.5",
324
- strokeLinecap: "round"
325
- })
326
- }), /* @__PURE__ */ jsx("svg", {
327
- width: "11",
328
- height: "7",
329
- viewBox: "0 0 10 6",
330
- fill: "none",
331
- children: /* @__PURE__ */ jsx("path", {
332
- d: "M1 1L5 5L9 1",
333
- stroke: "currentColor",
334
- strokeWidth: "1.5",
335
- strokeLinecap: "round"
336
- })
337
- })]
338
- });
339
- }
340
- function getApiReferenceSwitcherTheme(config) {
341
- const themeName = config.theme?.name?.toLowerCase() ?? "";
342
- const isPixelBorder = themeName.includes("pixel-border");
343
- const isDarksharp = themeName.includes("darksharp");
344
- const isShiny = themeName.includes("shiny");
345
- const radius = config.theme?.ui?.radius ?? (isPixelBorder || isDarksharp ? "0px" : "var(--radius, 0.75rem)");
346
- return {
347
- cardRadius: radius,
348
- iconRadius: radius,
349
- backgroundImage: isPixelBorder ? "repeating-linear-gradient(-45deg, color-mix(in srgb, var(--color-fd-border) 10%, transparent), color-mix(in srgb, var(--color-fd-border) 10%, transparent) 1px, transparent 1px, transparent 6px)" : void 0,
350
- boxShadow: isPixelBorder || isDarksharp ? "none" : isShiny ? "0 14px 40px color-mix(in srgb, var(--color-fd-border, #2a2a2a) 18%, transparent)" : "0 0 0 1px color-mix(in srgb, var(--color-fd-border, #2a2a2a) 32%, transparent)",
351
- titleStyle: {
352
- fontFamily: isPixelBorder ? "var(--fd-font-mono, var(--font-geist-mono, ui-monospace, monospace))" : "var(--fd-font-sans, var(--font-geist-sans, system-ui, sans-serif))",
353
- textTransform: isPixelBorder ? "uppercase" : void 0,
354
- letterSpacing: isPixelBorder ? "0.08em" : void 0,
355
- fontSize: isPixelBorder ? 12 : 13
356
- },
357
- descriptionStyle: {
358
- fontFamily: isPixelBorder ? "var(--fd-font-mono, var(--font-geist-mono, ui-monospace, monospace))" : "var(--fd-font-sans, var(--font-geist-sans, system-ui, sans-serif))",
359
- textTransform: isPixelBorder ? "uppercase" : void 0,
360
- letterSpacing: isPixelBorder ? "0.04em" : void 0,
361
- fontSize: isPixelBorder ? 11 : 11,
362
- opacity: isPixelBorder ? .74 : .72
363
- }
364
- };
365
- }
366
294
  const API_REFERENCE_COLOR_MAP = {
367
295
  primary: "--color-fd-primary",
368
296
  primaryForeground: "--color-fd-primary-foreground",
@@ -515,131 +443,20 @@ function ApiReferenceServerUrlPatchScript({ serverUrl }) {
515
443
  })();` }
516
444
  });
517
445
  }
518
- function SwitcherOption({ href, kind, title, description, current, config }) {
519
- const theme = getApiReferenceSwitcherTheme(config);
520
- return /* @__PURE__ */ jsxs(Link, {
521
- className: "fd-api-reference-switcher-option",
522
- "data-current": current ? "true" : "false",
523
- href,
524
- prefetch: true,
525
- style: {
526
- display: "grid",
527
- gridTemplateColumns: "22px minmax(0, 1fr)",
528
- gap: 12,
529
- alignItems: "start",
530
- padding: "11px 12px",
531
- borderRadius: "0.625rem",
532
- textDecoration: "none",
533
- color: "inherit",
534
- backgroundImage: current ? theme.backgroundImage : void 0
535
- },
536
- children: [/* @__PURE__ */ jsx("span", {
537
- style: {
538
- display: "inline-flex",
539
- alignSelf: "start",
540
- paddingTop: 1
541
- },
542
- children: /* @__PURE__ */ jsx(SwitcherGlyph, {
543
- kind,
544
- radius: theme.iconRadius,
545
- active: current
546
- })
547
- }), /* @__PURE__ */ jsxs("span", {
548
- style: {
549
- display: "flex",
550
- minWidth: 0,
551
- flexDirection: "column",
552
- gap: 3
553
- },
554
- children: [/* @__PURE__ */ jsx("span", {
555
- style: {
556
- fontWeight: 600,
557
- lineHeight: 1.2,
558
- ...theme.titleStyle
559
- },
560
- children: title
561
- }), /* @__PURE__ */ jsx("span", {
562
- style: {
563
- lineHeight: 1.4,
564
- ...theme.descriptionStyle
565
- },
566
- children: description
567
- })]
568
- })]
569
- });
570
- }
571
- function ApiReferenceSwitcher({ docsUrl, apiUrl, current, config }) {
572
- const currentLabel = current === "api" ? "API Reference" : "Documentation";
573
- const theme = getApiReferenceSwitcherTheme(config);
574
- const themeStyle = resolveApiReferenceThemeStyle(config);
575
- const switcherStyle = {
576
- position: "relative",
577
- marginBottom: 16,
578
- overflow: "hidden",
579
- backgroundImage: theme.backgroundImage,
580
- boxShadow: theme.boxShadow,
581
- ["--fd-api-switcher-card-radius"]: theme.cardRadius,
582
- ["--fd-api-switcher-icon-radius"]: theme.iconRadius,
583
- ["--fd-api-switcher-shadow"]: theme.boxShadow
584
- };
585
- return /* @__PURE__ */ jsxs("details", {
586
- className: "fd-api-reference-switcher",
587
- "data-theme-style": themeStyle,
588
- style: switcherStyle,
589
- children: [/* @__PURE__ */ jsxs("summary", {
590
- className: "fd-api-reference-switcher-summary",
591
- style: {
592
- display: "flex",
593
- alignItems: "center",
594
- justifyContent: "space-between",
595
- gap: 10,
596
- cursor: "pointer",
597
- padding: "10px 13px"
598
- },
599
- children: [/* @__PURE__ */ jsxs("span", {
600
- style: {
601
- display: "flex",
602
- minWidth: 0,
603
- alignItems: "center",
604
- gap: 10
605
- },
606
- children: [/* @__PURE__ */ jsx(SwitcherGlyph, {
607
- kind: current,
608
- radius: theme.iconRadius,
609
- active: true
610
- }), /* @__PURE__ */ jsx("span", {
611
- style: {
612
- fontWeight: 600,
613
- lineHeight: 1.2,
614
- ...theme.titleStyle
615
- },
616
- children: currentLabel
617
- })]
618
- }), /* @__PURE__ */ jsx(ChevronStack, {})]
619
- }), /* @__PURE__ */ jsxs("div", {
620
- className: "fd-api-reference-switcher-options",
621
- style: {
622
- display: "flex",
623
- flexDirection: "column",
624
- gap: 2,
625
- padding: "8px 8px 9px"
626
- },
627
- children: [/* @__PURE__ */ jsx(SwitcherOption, {
628
- href: docsUrl,
629
- kind: "docs",
630
- title: "Documentation",
631
- description: "Guides & concepts",
632
- current: current === "docs",
633
- config
634
- }), /* @__PURE__ */ jsx(SwitcherOption, {
635
- href: apiUrl,
636
- kind: "api",
637
- title: "API Reference",
638
- description: "Endpoints & examples",
639
- current: current === "api",
640
- config
641
- })]
642
- })]
446
+ function ApiReferenceSwitcher({ docsUrl, apiUrl }) {
447
+ return /* @__PURE__ */ jsx(SidebarTabsDropdown, {
448
+ className: "fd-api-reference-switcher w-full mb-4",
449
+ options: [{
450
+ url: docsUrl,
451
+ title: "Documentation",
452
+ description: "Guides & concepts",
453
+ icon: /* @__PURE__ */ jsx(SwitcherGlyph, { kind: "docs" })
454
+ }, {
455
+ url: apiUrl,
456
+ title: "API Reference",
457
+ description: "Endpoints & examples",
458
+ icon: /* @__PURE__ */ jsx(SwitcherGlyph, { kind: "api" })
459
+ }]
643
460
  });
644
461
  }
645
462
  function getExistingSidebarBanner(config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/next",
3
- "version": "0.1.64",
3
+ "version": "0.1.65",
4
4
  "description": "Next.js adapter for @farming-labs/docs — MDX config wrapper",
5
5
  "keywords": [
6
6
  "docs",
@@ -95,8 +95,8 @@
95
95
  "tsdown": "^0.20.3",
96
96
  "typescript": "^5.9.3",
97
97
  "vitest": "^3.2.4",
98
- "@farming-labs/docs": "0.1.64",
99
- "@farming-labs/theme": "0.1.64"
98
+ "@farming-labs/docs": "0.1.65",
99
+ "@farming-labs/theme": "0.1.65"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "@farming-labs/docs": ">=0.0.1",
@@ -39,126 +39,33 @@
39
39
  --color-fd-overlay: hsla(0, 0%, 0%, 0.2);
40
40
  }
41
41
 
42
- .fd-api-reference-switcher {
43
- --fd-api-switcher-card-radius: var(--radius, 0.75rem);
44
- --fd-api-switcher-icon-radius: var(--radius, 0.75rem);
45
- --fd-api-switcher-shadow: none;
46
- --fd-api-switcher-surface: var(--color-fd-card);
47
- --fd-api-switcher-summary-surface: color-mix(
48
- in srgb,
49
- var(--color-fd-secondary) 72%,
50
- var(--color-fd-card) 28%
51
- );
52
- --fd-api-switcher-border: color-mix(in srgb, var(--color-fd-border) 92%, transparent);
53
- --fd-api-switcher-muted: rgb(71 85 105 / 0.84);
54
- --fd-api-switcher-current-surface: color-mix(
55
- in srgb,
56
- var(--color-fd-primary, rgb(214 145 0)) 12%,
57
- var(--color-fd-card) 88%
58
- );
59
- --fd-api-switcher-current-border: color-mix(
60
- in srgb,
61
- var(--color-fd-primary, rgb(214 145 0)) 22%,
62
- transparent
63
- );
64
- --fd-api-switcher-glyph-surface: color-mix(
65
- in srgb,
66
- var(--color-fd-secondary) 64%,
67
- var(--color-fd-card) 36%
68
- );
69
- }
70
-
71
- .dark .fd-api-reference-switcher {
72
- --fd-api-switcher-shadow: 0 0 0 1px rgb(255 255 255 / 0.06);
73
- --fd-api-switcher-surface: color-mix(in srgb, rgb(20 20 20) 94%, transparent);
74
- --fd-api-switcher-summary-surface: color-mix(in srgb, rgb(28 28 28) 96%, transparent);
75
- --fd-api-switcher-border: rgb(255 255 255 / 0.08);
76
- --fd-api-switcher-muted: rgb(255 255 255 / 0.68);
77
- --fd-api-switcher-current-surface: color-mix(
78
- in srgb,
79
- var(--color-fd-primary, rgb(250 204 21)) 18%,
80
- transparent
81
- );
82
- --fd-api-switcher-current-border: color-mix(
83
- in srgb,
84
- var(--color-fd-primary, rgb(250 204 21)) 22%,
85
- rgb(255 255 255 / 0.08)
86
- );
87
- --fd-api-switcher-glyph-surface: color-mix(in srgb, rgb(28 28 28) 94%, transparent);
88
- }
89
-
90
- .fd-api-reference-switcher {
91
- border: 1px solid var(--fd-api-switcher-border);
92
- border-radius: var(--fd-api-switcher-card-radius);
93
- background: var(--fd-api-switcher-surface);
94
- box-shadow: var(--fd-api-switcher-shadow);
95
- }
96
-
97
- .fd-api-reference-switcher-summary {
98
- list-style: none;
99
- background: var(--fd-api-switcher-summary-surface);
100
- border-radius: calc(var(--fd-api-switcher-card-radius) - 1px);
101
- color: inherit;
102
- border-bottom: 1px solid color-mix(in srgb, var(--fd-api-switcher-border) 72%, transparent);
103
- }
104
-
105
- .fd-api-reference-switcher-summary::-webkit-details-marker {
106
- display: none;
107
- }
108
-
109
- .fd-api-reference-switcher-options {
110
- background: var(--fd-api-switcher-surface);
111
- }
112
-
113
- .fd-api-reference-switcher-option {
114
- border: 1px solid transparent;
115
- transition:
116
- background-color 150ms ease,
117
- border-color 150ms ease,
118
- color 150ms ease;
119
- }
120
-
121
- .fd-api-reference-switcher-option:hover {
122
- background: color-mix(in srgb, var(--color-fd-accent) 55%, transparent);
42
+ button.fd-api-reference-switcher {
43
+ width: 100%;
44
+ margin-bottom: 1rem;
45
+ border: 1px solid var(--color-fd-border) !important;
123
46
  }
124
47
 
125
- .fd-api-reference-switcher-option[data-current="true"] {
126
- background: var(--fd-api-switcher-current-surface);
127
- border-color: var(--fd-api-switcher-current-border);
48
+ button.fd-api-reference-switcher:hover,
49
+ button.fd-api-reference-switcher[data-state="open"] {
50
+ border-color: var(--color-fd-border) !important;
128
51
  }
129
52
 
130
53
  .fd-api-reference-switcher-glyph {
131
- border: 1px solid var(--fd-api-switcher-border);
132
- border-radius: var(--fd-api-switcher-icon-radius);
133
- background: var(--fd-api-switcher-glyph-surface);
134
- box-shadow: var(--fd-api-switcher-shadow);
135
- }
136
-
137
- .fd-api-reference-switcher-glyph[data-active="false"] {
138
- color: var(--fd-api-switcher-muted);
54
+ display: inline-flex;
55
+ width: 1.25rem;
56
+ height: 1.25rem;
57
+ align-items: center;
58
+ justify-content: center;
59
+ color: color-mix(in srgb, var(--color-fd-primary) 82%, var(--color-fd-foreground));
139
60
  }
140
61
 
141
- .fd-api-reference-switcher-chevron {
142
- color: var(--fd-api-switcher-muted);
62
+ .fd-api-reference-switcher-glyph[data-kind="api"] {
63
+ color: color-mix(in srgb, var(--color-fd-primary) 64%, var(--color-fd-muted-foreground));
143
64
  }
144
65
 
145
- .light .fd-api-reference-switcher {
146
- --fd-api-switcher-surface: var(--color-fd-card);
147
- --fd-api-switcher-summary-surface: color-mix(
148
- in srgb,
149
- var(--color-fd-primary) 12%,
150
- var(--color-fd-card) 88%
151
- );
152
- --fd-api-switcher-current-surface: color-mix(
153
- in srgb,
154
- var(--color-fd-primary) 14%,
155
- var(--color-fd-card) 86%
156
- );
157
- --fd-api-switcher-glyph-surface: color-mix(
158
- in srgb,
159
- var(--color-fd-primary) 10%,
160
- var(--color-fd-card) 90%
161
- );
66
+ .fd-api-reference-switcher-glyph svg {
67
+ width: 100%;
68
+ height: 100%;
162
69
  }
163
70
 
164
71
  .light .fd-api-reference-route article .border,
@@ -183,44 +90,6 @@
183
90
  color: rgb(71 85 105 / 0.9);
184
91
  }
185
92
 
186
- .light .fd-api-reference-switcher[data-theme-style="colorful"] .fd-api-reference-switcher-summary {
187
- background: color-mix(in srgb, var(--color-fd-primary) 18%, white 82%);
188
- color: var(--color-fd-primary);
189
- }
190
-
191
- .light .fd-api-reference-switcher[data-theme-style="colorful"] {
192
- border-color: color-mix(in srgb, var(--color-fd-primary) 28%, var(--color-fd-border));
193
- background: var(--color-fd-card);
194
- box-shadow: none;
195
- }
196
-
197
- .light
198
- .fd-api-reference-switcher[data-theme-style="colorful"]
199
- .fd-api-reference-switcher-summary
200
- .fd-api-reference-switcher-chevron {
201
- color: color-mix(in srgb, var(--color-fd-primary) 78%, black 22%);
202
- }
203
-
204
- .light
205
- .fd-api-reference-switcher[data-theme-style="colorful"]
206
- .fd-api-reference-switcher-summary
207
- .fd-api-reference-switcher-glyph {
208
- background: color-mix(in srgb, var(--color-fd-primary) 24%, white 76%);
209
- border-color: color-mix(in srgb, var(--color-fd-primary) 38%, var(--color-fd-border));
210
- color: var(--color-fd-primary);
211
- }
212
-
213
- .light .fd-api-reference-switcher[data-theme-style="colorful"] .fd-api-reference-switcher-options {
214
- background: var(--color-fd-card);
215
- }
216
-
217
- .light
218
- .fd-api-reference-switcher[data-theme-style="colorful"]
219
- .fd-api-reference-switcher-option[data-current="true"] {
220
- background: color-mix(in srgb, var(--color-fd-primary) 18%, white 82%);
221
- border-color: color-mix(in srgb, var(--color-fd-primary) 32%, var(--color-fd-border));
222
- }
223
-
224
93
  .light
225
94
  .fd-api-reference-route[data-theme-style="colorful"]
226
95
  .fd-api-reference-pagination-item:hover {