fumadocs-core 15.8.5 → 16.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/breadcrumb.d.ts +1 -1
- package/dist/breadcrumb.js +3 -3
- package/dist/{builder-5BHIAfCi.d.ts → builder-feW_xVjc.d.ts} +12 -99
- package/dist/{chunk-2IYQ7QMS.js → chunk-IZPLHEX4.js} +22 -6
- package/dist/{chunk-HN2NUUD2.js → chunk-XN2LKXFZ.js} +16 -27
- package/dist/{chunk-LMRZFODA.js → chunk-XZSI7AHE.js} +0 -16
- package/dist/content/github.js +39 -3
- package/dist/content/toc.d.ts +1 -0
- package/dist/content/toc.js +16 -3
- package/dist/{definitions-Q95-psoo.d.ts → definitions-BRsJlZ6m.d.ts} +1 -10
- package/dist/hide-if-empty.js +1 -19
- package/dist/highlight/client.d.ts +2 -13
- package/dist/highlight/client.js +2 -7
- package/dist/highlight/index.d.ts +13 -7
- package/dist/highlight/index.js +3 -1
- package/dist/i18n/index.js +5 -3
- package/dist/mdx-plugins/index.d.ts +6 -6
- package/dist/mdx-plugins/index.js +10 -13
- package/dist/{orama-cloud-74FM25SB.js → orama-cloud-WEGQE5A6.js} +8 -5
- package/dist/page-tree/index.d.ts +3 -3
- package/dist/page-tree/index.js +1 -1
- package/dist/search/algolia.d.ts +0 -6
- package/dist/search/algolia.js +1 -1
- package/dist/search/client.d.ts +4 -24
- package/dist/search/client.js +11 -18
- package/dist/search/orama-cloud.d.ts +3 -3
- package/dist/search/orama-cloud.js +16 -9
- package/dist/search/server.d.ts +2 -10
- package/dist/search/server.js +7 -12
- package/dist/source/index.d.ts +35 -5
- package/dist/source/index.js +15 -78
- package/dist/source/plugins/lucide-icons.d.ts +2 -2
- package/dist/toc.d.ts +4 -3
- package/dist/toc.js +1 -1
- package/dist/utils/use-media-query.js +19 -3
- package/package.json +21 -31
- package/dist/chunk-CX7IQ5Z6.js +0 -21
- package/dist/chunk-EP5LHGDZ.js +0 -22
- package/dist/chunk-HSBNG7QC.js +0 -42
- package/dist/chunk-HUTQC33E.js +0 -8
- package/dist/i18n/legacy.d.ts +0 -15
- package/dist/i18n/legacy.js +0 -19
- package/dist/server/index.d.ts +0 -66
- package/dist/server/index.js +0 -84
- package/dist/sidebar.d.ts +0 -33
- package/dist/sidebar.js +0 -79
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "The library for building a documentation website in any React.js framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fumadocs",
|
|
@@ -12,10 +12,6 @@
|
|
|
12
12
|
"author": "Fuma Nama",
|
|
13
13
|
"type": "module",
|
|
14
14
|
"exports": {
|
|
15
|
-
"./sidebar": {
|
|
16
|
-
"import": "./dist/sidebar.js",
|
|
17
|
-
"types": "./dist/sidebar.d.ts"
|
|
18
|
-
},
|
|
19
15
|
"./breadcrumb": {
|
|
20
16
|
"import": "./dist/breadcrumb.js",
|
|
21
17
|
"types": "./dist/breadcrumb.d.ts"
|
|
@@ -52,10 +48,6 @@
|
|
|
52
48
|
"import": "./dist/search/*.js",
|
|
53
49
|
"types": "./dist/search/*.d.ts"
|
|
54
50
|
},
|
|
55
|
-
"./server": {
|
|
56
|
-
"import": "./dist/server/index.js",
|
|
57
|
-
"types": "./dist/server/index.d.ts"
|
|
58
|
-
},
|
|
59
51
|
"./source": {
|
|
60
52
|
"import": "./dist/source/index.js",
|
|
61
53
|
"types": "./dist/source/index.d.ts"
|
|
@@ -81,9 +73,8 @@
|
|
|
81
73
|
"types": "./dist/mdx-plugins/index.d.ts"
|
|
82
74
|
},
|
|
83
75
|
"./i18n": {
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"types": "./dist/i18n/legacy.d.ts"
|
|
76
|
+
"import": "./dist/i18n/index.js",
|
|
77
|
+
"types": "./dist/i18n/index.d.ts"
|
|
87
78
|
},
|
|
88
79
|
"./i18n/middleware": {
|
|
89
80
|
"import": "./dist/i18n/middleware.js",
|
|
@@ -111,7 +102,7 @@
|
|
|
111
102
|
],
|
|
112
103
|
"dependencies": {
|
|
113
104
|
"@formatjs/intl-localematcher": "^0.6.2",
|
|
114
|
-
"@orama/orama": "^3.1.
|
|
105
|
+
"@orama/orama": "^3.1.16",
|
|
115
106
|
"@shikijs/rehype": "^3.13.0",
|
|
116
107
|
"@shikijs/transformers": "^3.13.0",
|
|
117
108
|
"github-slugger": "^2.0.0",
|
|
@@ -121,7 +112,6 @@
|
|
|
121
112
|
"negotiator": "^1.0.0",
|
|
122
113
|
"npm-to-yarn": "^3.0.1",
|
|
123
114
|
"path-to-regexp": "^8.3.0",
|
|
124
|
-
"react-remove-scroll": "^2.7.1",
|
|
125
115
|
"remark": "^15.0.1",
|
|
126
116
|
"remark-gfm": "^4.0.1",
|
|
127
117
|
"remark-rehype": "^11.1.2",
|
|
@@ -131,41 +121,41 @@
|
|
|
131
121
|
},
|
|
132
122
|
"devDependencies": {
|
|
133
123
|
"@mdx-js/mdx": "^3.1.1",
|
|
134
|
-
"@mixedbread/sdk": "^0.
|
|
135
|
-
"@
|
|
136
|
-
"@tanstack/react-router": "^1.
|
|
124
|
+
"@mixedbread/sdk": "^0.35.1",
|
|
125
|
+
"@orama/core": "^1.2.13",
|
|
126
|
+
"@tanstack/react-router": "^1.133.21",
|
|
137
127
|
"@types/estree-jsx": "^1.0.5",
|
|
138
128
|
"@types/hast": "^3.0.4",
|
|
139
129
|
"@types/mdast": "^4.0.4",
|
|
140
130
|
"@types/negotiator": "^0.6.4",
|
|
141
|
-
"@types/node": "24.
|
|
142
|
-
"@types/react": "^19.2.
|
|
143
|
-
"@types/react-dom": "^19.2.
|
|
144
|
-
"algoliasearch": "5.
|
|
145
|
-
"lucide-react": "^0.
|
|
131
|
+
"@types/node": "24.9.1",
|
|
132
|
+
"@types/react": "^19.2.2",
|
|
133
|
+
"@types/react-dom": "^19.2.2",
|
|
134
|
+
"algoliasearch": "5.40.1",
|
|
135
|
+
"lucide-react": "^0.546.0",
|
|
146
136
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
147
137
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
148
|
-
"next": "
|
|
149
|
-
"react-router": "^7.9.
|
|
138
|
+
"next": "16.0.0",
|
|
139
|
+
"react-router": "^7.9.4",
|
|
150
140
|
"remark-mdx": "^3.1.1",
|
|
151
141
|
"remove-markdown": "^0.6.2",
|
|
152
142
|
"typescript": "^5.9.3",
|
|
153
143
|
"unified": "^11.0.5",
|
|
154
144
|
"vfile": "^6.0.3",
|
|
155
145
|
"waku": "^0.26.1",
|
|
156
|
-
"
|
|
157
|
-
"
|
|
146
|
+
"eslint-config-custom": "0.0.0",
|
|
147
|
+
"tsconfig": "0.0.0"
|
|
158
148
|
},
|
|
159
149
|
"peerDependencies": {
|
|
160
150
|
"@mixedbread/sdk": "^0.19.0",
|
|
161
|
-
"@
|
|
151
|
+
"@orama/core": "1.x.x",
|
|
162
152
|
"@tanstack/react-router": "1.x.x",
|
|
163
153
|
"@types/react": "*",
|
|
164
154
|
"algoliasearch": "5.x.x",
|
|
165
155
|
"lucide-react": "*",
|
|
166
|
-
"next": "
|
|
167
|
-
"react": "
|
|
168
|
-
"react-dom": "
|
|
156
|
+
"next": "16.x.x",
|
|
157
|
+
"react": "^19.2.0",
|
|
158
|
+
"react-dom": "^19.2.0",
|
|
169
159
|
"react-router": "7.x.x",
|
|
170
160
|
"waku": "^0.26.0"
|
|
171
161
|
},
|
|
@@ -176,7 +166,7 @@
|
|
|
176
166
|
"@types/react": {
|
|
177
167
|
"optional": true
|
|
178
168
|
},
|
|
179
|
-
"@
|
|
169
|
+
"@orama/core": {
|
|
180
170
|
"optional": true
|
|
181
171
|
},
|
|
182
172
|
"algoliasearch": {
|
package/dist/chunk-CX7IQ5Z6.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
remarkHeading
|
|
3
|
-
} from "./chunk-QMATWJ5F.js";
|
|
4
|
-
|
|
5
|
-
// src/content/toc.ts
|
|
6
|
-
import { remark } from "remark";
|
|
7
|
-
function getTableOfContents(content, remarkPlugins) {
|
|
8
|
-
if (remarkPlugins) {
|
|
9
|
-
return remark().use(remarkPlugins).use(remarkHeading).process(content).then((result2) => {
|
|
10
|
-
if ("toc" in result2.data) return result2.data.toc;
|
|
11
|
-
return [];
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
const result = remark().use(remarkHeading).processSync(content);
|
|
15
|
-
if ("toc" in result.data) return result.data.toc;
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
getTableOfContents
|
|
21
|
-
};
|
package/dist/chunk-EP5LHGDZ.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// src/utils/use-media-query.ts
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
function useMediaQuery(query, disabled = false) {
|
|
4
|
-
const [isMatch, setMatch] = useState(null);
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
if (disabled) return;
|
|
7
|
-
const mediaQueryList = window.matchMedia(query);
|
|
8
|
-
const handleChange = () => {
|
|
9
|
-
setMatch(mediaQueryList.matches);
|
|
10
|
-
};
|
|
11
|
-
handleChange();
|
|
12
|
-
mediaQueryList.addEventListener("change", handleChange);
|
|
13
|
-
return () => {
|
|
14
|
-
mediaQueryList.removeEventListener("change", handleChange);
|
|
15
|
-
};
|
|
16
|
-
}, [disabled, query]);
|
|
17
|
-
return isMatch;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
useMediaQuery
|
|
22
|
-
};
|
package/dist/chunk-HSBNG7QC.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// src/content/github.ts
|
|
2
|
-
async function getGithubLastEdit({
|
|
3
|
-
repo,
|
|
4
|
-
token,
|
|
5
|
-
owner,
|
|
6
|
-
path,
|
|
7
|
-
sha,
|
|
8
|
-
options = {},
|
|
9
|
-
params: customParams = {}
|
|
10
|
-
}) {
|
|
11
|
-
const headers = new Headers(options.headers);
|
|
12
|
-
const params = new URLSearchParams();
|
|
13
|
-
params.set("path", path);
|
|
14
|
-
params.set("page", "1");
|
|
15
|
-
params.set("per_page", "1");
|
|
16
|
-
if (sha) params.set("sha", sha);
|
|
17
|
-
for (const [key, value] of Object.entries(customParams)) {
|
|
18
|
-
params.set(key, value);
|
|
19
|
-
}
|
|
20
|
-
if (token) {
|
|
21
|
-
headers.append("authorization", token);
|
|
22
|
-
}
|
|
23
|
-
const res = await fetch(
|
|
24
|
-
`https://api.github.com/repos/${owner}/${repo}/commits?${params.toString()}`,
|
|
25
|
-
{
|
|
26
|
-
cache: "force-cache",
|
|
27
|
-
...options,
|
|
28
|
-
headers
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
if (!res.ok)
|
|
32
|
-
throw new Error(
|
|
33
|
-
`Failed to fetch last edit time from Git ${await res.text()}`
|
|
34
|
-
);
|
|
35
|
-
const data = await res.json();
|
|
36
|
-
if (data.length === 0) return null;
|
|
37
|
-
return new Date(data[0].commit.committer.date);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
getGithubLastEdit
|
|
42
|
-
};
|
package/dist/chunk-HUTQC33E.js
DELETED
package/dist/i18n/legacy.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createI18nMiddleware as createI18nMiddleware$1 } from './middleware.js';
|
|
2
|
-
export { I18nConfig, defineI18n } from './index.js';
|
|
3
|
-
import 'next/dist/server/web/types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* From what I observed, Next.js will somehow pick "browser" export instead of "import" in middleware.
|
|
7
|
-
* Hence, `createI18nMiddleware` is not available from `fumadocs-core/i18n`, even with compatibility layer.
|
|
8
|
-
*
|
|
9
|
-
* I hope Next.js will fix it in the future, before old projects bump deps and face errors.
|
|
10
|
-
*
|
|
11
|
-
* @deprecated Import from `fumadocs-core/i18n/middleware` instead
|
|
12
|
-
*/
|
|
13
|
-
declare const createI18nMiddleware: typeof createI18nMiddleware$1;
|
|
14
|
-
|
|
15
|
-
export { createI18nMiddleware };
|
package/dist/i18n/legacy.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineI18n
|
|
3
|
-
} from "../chunk-HUTQC33E.js";
|
|
4
|
-
import "../chunk-U67V476Y.js";
|
|
5
|
-
|
|
6
|
-
// src/i18n/legacy.ts
|
|
7
|
-
var createI18nMiddleware = (...args) => {
|
|
8
|
-
console.warn(
|
|
9
|
-
"[Fumadocs Core] Please import i18n middleware from `fumadocs-core/i18n/middleware` instead, this export will soon be removed."
|
|
10
|
-
);
|
|
11
|
-
const middleware = import("./middleware.js").then(
|
|
12
|
-
(res) => res.createI18nMiddleware(...args)
|
|
13
|
-
);
|
|
14
|
-
return async (...args2) => (await middleware)(...args2);
|
|
15
|
-
};
|
|
16
|
-
export {
|
|
17
|
-
createI18nMiddleware,
|
|
18
|
-
defineI18n
|
|
19
|
-
};
|
package/dist/server/index.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export { GetGithubLastCommitOptions, getGithubLastEdit } from '../content/github.js';
|
|
2
|
-
import { Metadata } from 'next';
|
|
3
|
-
import { NextRequest } from 'next/server';
|
|
4
|
-
import { L as LoaderOutput, a as LoaderConfig, I as InferPageType } from '../builder-5BHIAfCi.js';
|
|
5
|
-
export { getTableOfContents } from '../content/toc.js';
|
|
6
|
-
export { TOCItemType, TableOfContents } from '../toc.js';
|
|
7
|
-
export { SortedResult } from '../search/index.js';
|
|
8
|
-
export { findNeighbour, findPath, flattenTree, getPageTreePeers, getPageTreeRoots } from '../page-tree/index.js';
|
|
9
|
-
export { d as PageTree } from '../definitions-Q95-psoo.js';
|
|
10
|
-
import '../i18n/index.js';
|
|
11
|
-
import 'react';
|
|
12
|
-
import 'unified';
|
|
13
|
-
import 'vfile';
|
|
14
|
-
|
|
15
|
-
interface ImageMeta {
|
|
16
|
-
alt: string;
|
|
17
|
-
url: string;
|
|
18
|
-
width: number;
|
|
19
|
-
height: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @deprecated Use the SEO features of your own React.js framework instead
|
|
23
|
-
*/
|
|
24
|
-
declare function createMetadataImage<S extends LoaderOutput<LoaderConfig>>(options: {
|
|
25
|
-
source: S;
|
|
26
|
-
/**
|
|
27
|
-
* the route of your OG image generator.
|
|
28
|
-
*
|
|
29
|
-
* @example '/docs-og'
|
|
30
|
-
* @defaultValue '/docs-og'
|
|
31
|
-
*/
|
|
32
|
-
imageRoute?: string;
|
|
33
|
-
/**
|
|
34
|
-
* The filename of generated OG Image
|
|
35
|
-
*
|
|
36
|
-
* @defaultValue 'image.png'
|
|
37
|
-
*/
|
|
38
|
-
filename?: string;
|
|
39
|
-
}): {
|
|
40
|
-
getImageMeta: (slugs: string[]) => ImageMeta;
|
|
41
|
-
/**
|
|
42
|
-
* Add image meta tags to metadata
|
|
43
|
-
*/
|
|
44
|
-
withImage: (slugs: string[], metadata?: Metadata) => Metadata;
|
|
45
|
-
/**
|
|
46
|
-
* Generate static params for OG Image Generator
|
|
47
|
-
*/
|
|
48
|
-
generateParams: () => {
|
|
49
|
-
slug: string[];
|
|
50
|
-
lang?: string;
|
|
51
|
-
}[];
|
|
52
|
-
/**
|
|
53
|
-
* create route handler for OG Image Generator
|
|
54
|
-
*/
|
|
55
|
-
createAPI: (handler: (page: InferPageType<S>, request: NextRequest, options: {
|
|
56
|
-
params: {
|
|
57
|
-
slug: string[];
|
|
58
|
-
lang?: string;
|
|
59
|
-
} | Promise<{
|
|
60
|
-
slug: string[];
|
|
61
|
-
lang?: string;
|
|
62
|
-
}>;
|
|
63
|
-
}) => Response | Promise<Response>) => (request: NextRequest, options: any) => Response | Promise<Response>;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export { createMetadataImage };
|
package/dist/server/index.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getTableOfContents
|
|
3
|
-
} from "../chunk-CX7IQ5Z6.js";
|
|
4
|
-
import "../chunk-QMATWJ5F.js";
|
|
5
|
-
import {
|
|
6
|
-
findNeighbour,
|
|
7
|
-
findPath,
|
|
8
|
-
flattenTree,
|
|
9
|
-
getPageTreePeers,
|
|
10
|
-
getPageTreeRoots
|
|
11
|
-
} from "../chunk-2IYQ7QMS.js";
|
|
12
|
-
import {
|
|
13
|
-
getGithubLastEdit
|
|
14
|
-
} from "../chunk-HSBNG7QC.js";
|
|
15
|
-
import "../chunk-U67V476Y.js";
|
|
16
|
-
|
|
17
|
-
// src/server/metadata.ts
|
|
18
|
-
function createMetadataImage(options) {
|
|
19
|
-
const { filename = "image.png", imageRoute = "/docs-og" } = options;
|
|
20
|
-
function getImageMeta(slugs) {
|
|
21
|
-
return {
|
|
22
|
-
alt: "Banner",
|
|
23
|
-
url: `/${[...imageRoute.split("/"), ...slugs, filename].filter((v) => v.length > 0).join("/")}`,
|
|
24
|
-
width: 1200,
|
|
25
|
-
height: 630
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
getImageMeta,
|
|
30
|
-
withImage(slugs, data) {
|
|
31
|
-
const imageData = getImageMeta(slugs);
|
|
32
|
-
return {
|
|
33
|
-
...data,
|
|
34
|
-
openGraph: {
|
|
35
|
-
images: imageData,
|
|
36
|
-
...data?.openGraph
|
|
37
|
-
},
|
|
38
|
-
twitter: {
|
|
39
|
-
images: imageData,
|
|
40
|
-
card: "summary_large_image",
|
|
41
|
-
...data?.twitter
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
generateParams() {
|
|
46
|
-
return options.source.generateParams().map((params) => ({
|
|
47
|
-
...params,
|
|
48
|
-
slug: [...params.slug, filename]
|
|
49
|
-
}));
|
|
50
|
-
},
|
|
51
|
-
createAPI(handler) {
|
|
52
|
-
return async (req, args) => {
|
|
53
|
-
const params = await args.params;
|
|
54
|
-
if (!params || !("slug" in params) || params.slug === void 0)
|
|
55
|
-
throw new Error(`Invalid params: ${JSON.stringify(params)}`);
|
|
56
|
-
const lang = "lang" in params && typeof params.lang === "string" ? params.lang : void 0;
|
|
57
|
-
const input = {
|
|
58
|
-
slug: Array.isArray(params.slug) ? params.slug : [params.slug],
|
|
59
|
-
lang
|
|
60
|
-
};
|
|
61
|
-
const page = options.source.getPage(
|
|
62
|
-
input.slug.slice(0, -1),
|
|
63
|
-
//remove filename
|
|
64
|
-
lang
|
|
65
|
-
);
|
|
66
|
-
if (!page)
|
|
67
|
-
return new Response(null, {
|
|
68
|
-
status: 404
|
|
69
|
-
});
|
|
70
|
-
return handler(page, req, { params: input });
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
export {
|
|
76
|
-
createMetadataImage,
|
|
77
|
-
findNeighbour,
|
|
78
|
-
findPath,
|
|
79
|
-
flattenTree,
|
|
80
|
-
getGithubLastEdit,
|
|
81
|
-
getPageTreePeers,
|
|
82
|
-
getPageTreeRoots,
|
|
83
|
-
getTableOfContents
|
|
84
|
-
};
|
package/dist/sidebar.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode, ElementType, ComponentPropsWithoutRef, ReactElement } from 'react';
|
|
3
|
-
|
|
4
|
-
interface SidebarProviderProps {
|
|
5
|
-
open?: boolean;
|
|
6
|
-
onOpenChange?: (v: boolean) => void;
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
declare function SidebarProvider(props: SidebarProviderProps): react_jsx_runtime.JSX.Element;
|
|
10
|
-
type AsProps<T extends ElementType> = Omit<ComponentPropsWithoutRef<T>, 'as'> & {
|
|
11
|
-
as?: T;
|
|
12
|
-
};
|
|
13
|
-
type SidebarTriggerProps<T extends ElementType> = AsProps<T>;
|
|
14
|
-
declare function SidebarTrigger<T extends ElementType = 'button'>({ as, ...props }: SidebarTriggerProps<T>): ReactElement;
|
|
15
|
-
type SidebarContentProps<T extends ElementType> = AsProps<T> & {
|
|
16
|
-
/**
|
|
17
|
-
* Disable scroll blocking when the viewport width is larger than a certain number (in pixels)
|
|
18
|
-
*
|
|
19
|
-
* @deprecated use `removeScrollOn`
|
|
20
|
-
*/
|
|
21
|
-
blockScrollingWidth?: number;
|
|
22
|
-
/**
|
|
23
|
-
* A media query.
|
|
24
|
-
*
|
|
25
|
-
* When the sidebar is opening and media query is matched, scrolling outside the sidebar will be blocked.
|
|
26
|
-
*
|
|
27
|
-
* @example (max-width: 1000px)
|
|
28
|
-
*/
|
|
29
|
-
removeScrollOn?: string;
|
|
30
|
-
};
|
|
31
|
-
declare function SidebarList<T extends ElementType = 'aside'>({ as, blockScrollingWidth, removeScrollOn, ...props }: SidebarContentProps<T>): ReactElement;
|
|
32
|
-
|
|
33
|
-
export { type SidebarContentProps, SidebarList, SidebarProvider, type SidebarProviderProps, SidebarTrigger, type SidebarTriggerProps };
|
package/dist/sidebar.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
useMediaQuery
|
|
4
|
-
} from "./chunk-EP5LHGDZ.js";
|
|
5
|
-
import "./chunk-U67V476Y.js";
|
|
6
|
-
|
|
7
|
-
// src/sidebar.tsx
|
|
8
|
-
import {
|
|
9
|
-
createContext,
|
|
10
|
-
useContext,
|
|
11
|
-
useMemo,
|
|
12
|
-
useState
|
|
13
|
-
} from "react";
|
|
14
|
-
import { RemoveScroll } from "react-remove-scroll";
|
|
15
|
-
import { jsx } from "react/jsx-runtime";
|
|
16
|
-
var SidebarContext = createContext(null);
|
|
17
|
-
function useSidebarContext() {
|
|
18
|
-
const ctx = useContext(SidebarContext);
|
|
19
|
-
if (!ctx) throw new Error("Missing sidebar provider");
|
|
20
|
-
return ctx;
|
|
21
|
-
}
|
|
22
|
-
function SidebarProvider(props) {
|
|
23
|
-
const [open, setOpen] = props.open === void 0 ? (
|
|
24
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
25
|
-
useState(false)
|
|
26
|
-
) : [props.open, props.onOpenChange];
|
|
27
|
-
return /* @__PURE__ */ jsx(
|
|
28
|
-
SidebarContext.Provider,
|
|
29
|
-
{
|
|
30
|
-
value: useMemo(
|
|
31
|
-
() => ({ open, setOpen: setOpen ?? (() => void 0) }),
|
|
32
|
-
[open, setOpen]
|
|
33
|
-
),
|
|
34
|
-
children: props.children
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
function SidebarTrigger({
|
|
39
|
-
as,
|
|
40
|
-
...props
|
|
41
|
-
}) {
|
|
42
|
-
const { open, setOpen } = useSidebarContext();
|
|
43
|
-
const As = as ?? "button";
|
|
44
|
-
return /* @__PURE__ */ jsx(
|
|
45
|
-
As,
|
|
46
|
-
{
|
|
47
|
-
"aria-label": "Toggle Sidebar",
|
|
48
|
-
"data-open": open,
|
|
49
|
-
onClick: () => {
|
|
50
|
-
setOpen(!open);
|
|
51
|
-
},
|
|
52
|
-
...props
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
function SidebarList({
|
|
57
|
-
as,
|
|
58
|
-
blockScrollingWidth,
|
|
59
|
-
removeScrollOn = blockScrollingWidth ? `(width < ${blockScrollingWidth}px)` : void 0,
|
|
60
|
-
...props
|
|
61
|
-
}) {
|
|
62
|
-
const { open } = useSidebarContext();
|
|
63
|
-
const isBlocking = useMediaQuery(removeScrollOn ?? "", !removeScrollOn) ?? false;
|
|
64
|
-
return /* @__PURE__ */ jsx(
|
|
65
|
-
RemoveScroll,
|
|
66
|
-
{
|
|
67
|
-
as: as ?? "aside",
|
|
68
|
-
"data-open": open,
|
|
69
|
-
enabled: isBlocking && open,
|
|
70
|
-
...props,
|
|
71
|
-
children: props.children
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
export {
|
|
76
|
-
SidebarList,
|
|
77
|
-
SidebarProvider,
|
|
78
|
-
SidebarTrigger
|
|
79
|
-
};
|