fumadocs-ui 15.3.0 → 15.3.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/css/shiki.css CHANGED
@@ -3,9 +3,30 @@
3
3
  color: var(--shiki-light);
4
4
  }
5
5
 
6
+ code .line {
7
+ min-height: 1em;
8
+ @apply relative inline-block w-full;
9
+ }
10
+
11
+ &[data-line-numbers] code .twoslash-meta-line {
12
+ @apply ml-7;
13
+ }
14
+
15
+ &[data-line-numbers] code .line {
16
+ width: calc(100% - 7 * var(--spacing));
17
+ counter-increment: line;
18
+ @apply ml-7;
19
+
20
+ &::after {
21
+ position: absolute;
22
+ content: counter(line);
23
+ @apply top-0 -left-5 text-fd-muted-foreground/60;
24
+ }
25
+ }
26
+
6
27
  code .diff::before {
7
28
  position: absolute;
8
- left: 6px;
29
+ left: var(--spacing);
9
30
  }
10
31
 
11
32
  code .diff.remove {
@@ -28,15 +49,11 @@
28
49
  }
29
50
 
30
51
  code .diff {
31
- width: calc(100% + 8 * var(--spacing));
32
-
33
- @apply relative inline-block -mx-4 px-4;
52
+ @apply relative;
34
53
  }
35
54
 
36
55
  .highlighted {
37
- width: calc(100% + 8 * var(--spacing));
38
-
39
- @apply inline-block -mx-4 px-4 bg-fd-primary/10;
56
+ @apply bg-fd-primary/10;
40
57
  }
41
58
 
42
59
  .highlighted-word {
@@ -20,6 +20,14 @@ export type CodeBlockProps = HTMLAttributes<HTMLElement> & {
20
20
  */
21
21
  keepBackground?: boolean;
22
22
  viewportProps?: ScrollAreaViewportProps;
23
+ /**
24
+ * show line numbers
25
+ */
26
+ 'data-line-numbers'?: boolean;
27
+ /**
28
+ * @defaultValue 1
29
+ */
30
+ 'data-line-numbers-start'?: number;
23
31
  };
24
32
  export declare const Pre: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLPreElement> & import("react").RefAttributes<HTMLPreElement>>;
25
33
  export declare const CodeBlock: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & {
@@ -42,5 +50,13 @@ export declare const CodeBlock: import("react").ForwardRefExoticComponent<HTMLAt
42
50
  */
43
51
  keepBackground?: boolean;
44
52
  viewportProps?: ScrollAreaViewportProps;
53
+ /**
54
+ * show line numbers
55
+ */
56
+ 'data-line-numbers'?: boolean;
57
+ /**
58
+ * @defaultValue 1
59
+ */
60
+ 'data-line-numbers-start'?: number;
45
61
  } & import("react").RefAttributes<HTMLElement>>;
46
62
  //# sourceMappingURL=codeblock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codeblock.d.ts","sourceRoot":"","sources":["../../src/components/codeblock.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,WAAW,CAAC,GAAG;IACzD;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IAEjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,GAAG,2HAYf,CAAC;AAIF,eAAO,MAAM,SAAS;IAxCpB;;;;OAIG;WACI,SAAS;IAEhB;;;;OAIG;gBACS,OAAO;IAEnB;;;;OAIG;qBACc,OAAO;oBAER,uBAAuB;+CAiGxC,CAAC"}
1
+ {"version":3,"file":"codeblock.d.ts","sourceRoot":"","sources":["../../src/components/codeblock.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,WAAW,CAAC,GAAG;IACzD;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IAEjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,aAAa,CAAC,EAAE,uBAAuB,CAAC;IAExC;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,GAAG,2HAYf,CAAC;AAIF,eAAO,MAAM,SAAS;IAlDpB;;;;OAIG;WACI,SAAS;IAEhB;;;;OAIG;gBACS,OAAO;IAEnB;;;;OAIG;qBACc,OAAO;oBAER,uBAAuB;IAEvC;;OAEG;0BACmB,OAAO;IAE7B;;OAEG;gCACyB,MAAM;+CA4GnC,CAAC"}
@@ -7,10 +7,10 @@ import { ScrollArea, ScrollBar, ScrollViewport, } from '../components/ui/scroll-
7
7
  import { useCopyButton } from '../utils/use-copy-button.js';
8
8
  import { buttonVariants } from '../components/ui/button.js';
9
9
  export const Pre = forwardRef(({ className, ...props }, ref) => {
10
- return (_jsx("pre", { ref: ref, className: cn('text-[13px] p-4 *:block *:w-full', className), ...props, children: props.children }));
10
+ return (_jsx("pre", { ref: ref, className: cn('size-full *:block *:w-full', className), ...props, children: props.children }));
11
11
  });
12
12
  Pre.displayName = 'Pre';
13
- export const CodeBlock = forwardRef(({ title, allowCopy = true, keepBackground = false, icon, viewportProps, ...props }, ref) => {
13
+ export const CodeBlock = forwardRef(({ title, allowCopy = true, keepBackground = false, icon, viewportProps, children, ...props }, ref) => {
14
14
  const areaRef = useRef(null);
15
15
  const onCopy = () => {
16
16
  const pre = areaRef.current?.getElementsByTagName('pre').item(0);
@@ -26,7 +26,12 @@ export const CodeBlock = forwardRef(({ title, allowCopy = true, keepBackground =
26
26
  ? {
27
27
  __html: icon,
28
28
  }
29
- : undefined, children: typeof icon !== 'string' ? icon : null })) : null, _jsx("figcaption", { className: "flex-1 truncate text-fd-muted-foreground", children: title }), allowCopy ? (_jsx(CopyButton, { className: "-me-2", onCopy: onCopy })) : null] })) : (allowCopy && (_jsx(CopyButton, { className: "absolute right-2 top-2 z-[2] backdrop-blur-md", onCopy: onCopy }))), _jsxs(ScrollArea, { ref: areaRef, dir: "ltr", children: [_jsx(ScrollViewport, { ...viewportProps, className: cn('max-h-[600px]', viewportProps?.className), children: props.children }), _jsx(ScrollBar, { orientation: "horizontal" })] })] }));
29
+ : undefined, children: typeof icon !== 'string' ? icon : null })) : null, _jsx("figcaption", { className: "flex-1 truncate text-fd-muted-foreground", children: title }), allowCopy ? (_jsx(CopyButton, { className: "-me-2", onCopy: onCopy })) : null] })) : (allowCopy && (_jsx(CopyButton, { className: "absolute right-2 top-2 z-[2] backdrop-blur-md", onCopy: onCopy }))), _jsxs(ScrollArea, { ref: areaRef, dir: "ltr", children: [_jsx(ScrollViewport, { ...viewportProps, className: cn('text-[13px] py-3.5 [&_.line]:px-4 max-h-[600px]', props['data-line-numbers'] && '[&_.line]:pl-3', viewportProps?.className), style: {
30
+ counterSet: props['data-line-numbers']
31
+ ? `line ${Number(props['data-line-numbers-start'] ?? 1) - 1}`
32
+ : undefined,
33
+ ...viewportProps?.style,
34
+ }, children: children }), _jsx(ScrollBar, { orientation: "horizontal" })] })] }));
30
35
  });
31
36
  CodeBlock.displayName = 'CodeBlock';
32
37
  function CopyButton({ className, onCopy, ...props }) {
@@ -79,7 +79,7 @@ export function Sidebar({ defaultOpenLevel = 0, prefetch = true, collapsible = t
79
79
  }, children: _jsx("div", { className: "flex w-(--fd-sidebar-width) h-full max-w-full flex-col ms-auto border-e", children: _jsx(Context.Provider, { value: context, children: props.children }) }) }));
80
80
  }
81
81
  export function SidebarHeader(props) {
82
- return (_jsx("div", { ...props, className: cn('flex flex-col gap-3 px-4 pt-4 max-md:pt-6 max-md:pb-4 empty:hidden', props.className), children: props.children }));
82
+ return (_jsx("div", { ...props, className: cn('flex flex-col gap-3 px-4 pt-4 max-md:pt-6 empty:hidden', props.className), children: props.children }));
83
83
  }
84
84
  export function SidebarFooter(props) {
85
85
  return (_jsx("div", { ...props, className: cn('flex flex-col border-t px-4 py-3 empty:hidden max-md:pb-6', props.className), children: props.children }));
@@ -41,5 +41,5 @@ export function MenuTrigger({ enableHover = false, ...props }) {
41
41
  }), props.className), children: props.children }));
42
42
  }
43
43
  export function MenuContent(props) {
44
- return (_jsx(NavigationMenuContent, { ...props, className: cn('flex flex-col p-4', props.className), children: props.children }));
44
+ return (_jsx(NavigationMenuContent, { ...props, className: cn('flex flex-col px-4 pb-4', props.className), children: props.children }));
45
45
  }
@@ -38,7 +38,7 @@ export function DocsLayout(props) {
38
38
  color: 'ghost',
39
39
  size: 'icon-sm',
40
40
  className: 'text-fd-muted-foreground mb-auto',
41
- })), children: _jsx(SidebarIcon, {}) }))] })), nav.children, sidebarBanner, tabMode === 'sidebar' && tabs.length > 0 ? (_jsx(RootToggle, { options: tabs })) : null] }), _jsxs(SidebarViewport, { children: [tabMode === 'navbar' &&
41
+ })), children: _jsx(SidebarIcon, {}) }))] })), nav.children, sidebarBanner, tabMode === 'sidebar' && tabs.length > 0 ? (_jsx(RootToggle, { className: "mb-2", options: tabs })) : null] }), _jsxs(SidebarViewport, { children: [tabMode === 'navbar' &&
42
42
  tabs.map((tab, i) => (_jsx(SidebarLayoutTab, { item: tab, className: cn('lg:hidden', i === tabs.length - 1 && 'mb-4') }, tab.url))), links.map((item, i) => (_jsx(SidebarLinkItem, { item: item, className: cn('lg:hidden', i === links.length - 1 && 'mb-4') }, i))), _jsx(SidebarPageTree, { components: sidebarComponents })] }), _jsxs(SidebarFooter, { className: cn('flex flex-row items-center', !sidebarFooter && 'md:hidden'), children: [i18n ? (_jsx(LanguageToggle, { className: "me-auto md:hidden", children: _jsx(Languages, { className: "size-5 text-fd-muted-foreground" }) })) : null, slot(themeSwitch, _jsx(ThemeToggle, { className: "md:hidden", mode: themeSwitch?.mode ?? 'light-dark-system' })), sidebarFooter] })] }), _jsx(DocsNavbar, { ...props, links: links, tabs: tabMode == 'navbar' ? tabs : [] }), _jsx(StylesProvider, { ...pageStyles, children: props.children })] }) }) }));
43
43
  }
44
44
  function DocsNavbar({ links, tabs, ...props }) {
@@ -21,7 +21,7 @@ export function TocPopoverTrigger({ items, ...props }) {
21
21
  const selected = useMemo(() => items.findIndex((item) => active === item.url.slice(1)), [items, active]);
22
22
  const path = useTreePath().at(-1);
23
23
  const showItem = selected !== -1 && !open;
24
- return (_jsxs(CollapsibleTrigger, { ...props, className: cn('flex flex-row items-center text-sm text-fd-muted-foreground gap-2.5 px-4 py-2.5 text-start focus-visible:outline-none [&_svg]:shrink-0 [&_svg]:size-4 md:px-6', props.className), children: [_jsx(ProgressCircle, { value: (selected + 1) / items.length, max: 1, className: cn(open && 'text-fd-primary') }), _jsxs("span", { className: "grid flex-1 *:row-start-1 *:col-start-1", children: [_jsx("span", { className: cn('truncate transition-all', open && 'text-fd-foreground', showItem && 'opacity-0 -translate-y-full pointer-events-none'), children: path?.name ?? text.toc }), _jsx("span", { className: cn('truncate transition-all', !showItem && 'opacity-0 translate-y-full pointer-events-none'), children: items[selected]?.title })] }), _jsx(ChevronDown, { className: cn('opacity-50 transition-transform', open && 'rotate-180') })] }));
24
+ return (_jsxs(CollapsibleTrigger, { ...props, className: cn('flex flex-row items-center text-sm text-fd-muted-foreground gap-2.5 px-4 py-2.5 text-start focus-visible:outline-none [&_svg]:shrink-0 [&_svg]:size-4 md:px-6', props.className), children: [_jsx(ProgressCircle, { value: (selected + 1) / items.length, max: 1, className: cn(open && 'text-fd-primary') }), _jsxs("span", { className: "grid flex-1 *:row-start-1 *:col-start-1", children: [_jsx("span", { className: cn('truncate transition-all', open && 'text-fd-foreground', showItem && 'opacity-0 -translate-y-full pointer-events-none'), children: path?.name ?? text.toc }), _jsx("span", { className: cn('truncate transition-all', !showItem && 'opacity-0 translate-y-full pointer-events-none'), children: items[selected]?.title })] }), _jsx(ChevronDown, { className: cn('transition-transform', open && 'rotate-180') })] }));
25
25
  }
26
26
  function clamp(input, min, max) {
27
27
  if (input < min)
package/dist/style.css CHANGED
@@ -1421,6 +1421,9 @@
1421
1421
  .py-3 {
1422
1422
  padding-block: calc(var(--spacing) * 3);
1423
1423
  }
1424
+ .py-3\.5 {
1425
+ padding-block: calc(var(--spacing) * 3.5);
1426
+ }
1424
1427
  .py-8 {
1425
1428
  padding-block: calc(var(--spacing) * 8);
1426
1429
  }
@@ -1472,6 +1475,9 @@
1472
1475
  .pb-2 {
1473
1476
  padding-bottom: calc(var(--spacing) * 2);
1474
1477
  }
1478
+ .pb-4 {
1479
+ padding-bottom: calc(var(--spacing) * 4);
1480
+ }
1475
1481
  .pb-6 {
1476
1482
  padding-bottom: calc(var(--spacing) * 6);
1477
1483
  }
@@ -1587,9 +1593,6 @@
1587
1593
  .opacity-0 {
1588
1594
  opacity: 0%;
1589
1595
  }
1590
- .opacity-50 {
1591
- opacity: 50%;
1592
- }
1593
1596
  .shadow-lg {
1594
1597
  --tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 4px 6px -4px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
1595
1598
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
@@ -2030,11 +2033,6 @@
2030
2033
  padding-top: calc(var(--spacing) * 6);
2031
2034
  }
2032
2035
  }
2033
- .max-md\:pb-4 {
2034
- @media (width < 48rem) {
2035
- padding-bottom: calc(var(--spacing) * 4);
2036
- }
2037
- }
2038
2036
  .max-md\:pb-6 {
2039
2037
  @media (width < 48rem) {
2040
2038
  padding-bottom: calc(var(--spacing) * 6);
@@ -2270,6 +2268,16 @@
2270
2268
  background-color: var(--shiki-dark-bg);
2271
2269
  }
2272
2270
  }
2271
+ .\[\&_\.line\]\:px-4 {
2272
+ & .line {
2273
+ padding-inline: calc(var(--spacing) * 4);
2274
+ }
2275
+ }
2276
+ .\[\&_\.line\]\:pl-3 {
2277
+ & .line {
2278
+ padding-left: calc(var(--spacing) * 3);
2279
+ }
2280
+ }
2273
2281
  .\[\&_svg\]\:\!size-4\.5 {
2274
2282
  & svg {
2275
2283
  width: calc(var(--spacing) * 4.5) !important;
@@ -2357,9 +2365,33 @@
2357
2365
  code span {
2358
2366
  color: var(--shiki-light);
2359
2367
  }
2368
+ code .line {
2369
+ min-height: 1em;
2370
+ position: relative;
2371
+ display: inline-block;
2372
+ width: 100%;
2373
+ }
2374
+ &[data-line-numbers] code .twoslash-meta-line {
2375
+ margin-left: calc(var(--spacing) * 7);
2376
+ }
2377
+ &[data-line-numbers] code .line {
2378
+ width: calc(100% - 7 * var(--spacing));
2379
+ counter-increment: line;
2380
+ margin-left: calc(var(--spacing) * 7);
2381
+ &::after {
2382
+ position: absolute;
2383
+ content: counter(line);
2384
+ top: calc(var(--spacing) * 0);
2385
+ left: calc(var(--spacing) * -5);
2386
+ color: color-mix(in srgb, hsl(0, 0%, 45.1%) 60%, transparent);
2387
+ @supports (color: color-mix(in lab, red, red)) {
2388
+ color: color-mix(in oklab, var(--color-fd-muted-foreground) 60%, transparent);
2389
+ }
2390
+ }
2391
+ }
2360
2392
  code .diff::before {
2361
2393
  position: absolute;
2362
- left: 6px;
2394
+ left: var(--spacing);
2363
2395
  }
2364
2396
  code .diff.remove {
2365
2397
  opacity: 0.7;
@@ -2377,21 +2409,13 @@
2377
2409
  color: var(--color-fd-diff-add-symbol);
2378
2410
  }
2379
2411
  code .diff {
2380
- width: calc(100% + 8 * var(--spacing));
2381
2412
  position: relative;
2382
- margin-inline: calc(var(--spacing) * -4);
2383
- display: inline-block;
2384
- padding-inline: calc(var(--spacing) * 4);
2385
2413
  }
2386
2414
  .highlighted {
2387
- width: calc(100% + 8 * var(--spacing));
2388
- margin-inline: calc(var(--spacing) * -4);
2389
- display: inline-block;
2390
2415
  background-color: color-mix(in srgb, hsl(0, 0%, 9%) 10%, transparent);
2391
2416
  @supports (color: color-mix(in lab, red, red)) {
2392
2417
  background-color: color-mix(in oklab, var(--color-fd-primary) 10%, transparent);
2393
2418
  }
2394
- padding-inline: calc(var(--spacing) * 4);
2395
2419
  }
2396
2420
  .highlighted-word {
2397
2421
  padding: 1px 2px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-ui",
3
- "version": "15.3.0",
3
+ "version": "15.3.1",
4
4
  "description": "The framework for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -89,7 +89,7 @@
89
89
  "react-medium-image-zoom": "^5.2.14",
90
90
  "react-remove-scroll": "^2.6.3",
91
91
  "tailwind-merge": "^3.2.0",
92
- "fumadocs-core": "15.3.0"
92
+ "fumadocs-core": "15.3.1"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@next/eslint-plugin-next": "^15.3.1",
@@ -102,7 +102,7 @@
102
102
  "tsc-alias": "^1.8.16",
103
103
  "@fumadocs/cli": "0.1.1",
104
104
  "eslint-config-custom": "0.0.0",
105
- "fumadocs-core": "15.3.0",
105
+ "fumadocs-core": "15.3.1",
106
106
  "tsconfig": "0.0.0"
107
107
  },
108
108
  "peerDependencies": {