fumadocs-ui 15.3.2 → 15.3.4
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/preset.css +26 -5
- package/css/vitepress.css +1 -4
- package/dist/components/dialog/search-algolia.d.ts.map +1 -1
- package/dist/components/dialog/search-algolia.js +3 -3
- package/dist/components/dialog/search-default.d.ts.map +1 -1
- package/dist/components/dialog/search-default.js +2 -2
- package/dist/components/dialog/search-orama.d.ts.map +1 -1
- package/dist/components/dialog/search-orama.js +3 -3
- package/dist/components/dialog/search.d.ts +10 -9
- package/dist/components/dialog/search.d.ts.map +1 -1
- package/dist/components/dialog/search.js +30 -27
- package/dist/components/layout/root-toggle.js +1 -1
- package/dist/components/layout/search-toggle.js +2 -2
- package/dist/components/layout/sidebar.d.ts +1 -1
- package/dist/components/layout/sidebar.d.ts.map +1 -1
- package/dist/components/layout/sidebar.js +28 -23
- package/dist/components/tabs.d.ts +18 -9
- package/dist/components/tabs.d.ts.map +1 -1
- package/dist/components/tabs.js +22 -18
- package/dist/components/ui/hide-if-empty.d.ts.map +1 -1
- package/dist/components/ui/hide-if-empty.js +30 -18
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.js +1 -1
- package/dist/components/ui/tabs.js +2 -2
- package/dist/layouts/docs-client.d.ts +3 -3
- package/dist/layouts/docs-client.d.ts.map +1 -1
- package/dist/layouts/docs-client.js +5 -4
- package/dist/layouts/docs.d.ts.map +1 -1
- package/dist/layouts/docs.js +6 -6
- package/dist/layouts/home/navbar.js +1 -1
- package/dist/layouts/home.js +1 -1
- package/dist/layouts/notebook-client.js +1 -1
- package/dist/layouts/notebook.d.ts.map +1 -1
- package/dist/layouts/notebook.js +9 -9
- package/dist/page-client.js +1 -1
- package/dist/style.css +107 -60
- package/package.json +11 -11
package/css/preset.css
CHANGED
|
@@ -20,14 +20,16 @@
|
|
|
20
20
|
--animate-fd-fade-in: fd-fade-in 300ms ease;
|
|
21
21
|
--animate-fd-fade-out: fd-fade-out 300ms ease;
|
|
22
22
|
|
|
23
|
-
--animate-fd-dialog-in: fd-dialog-in
|
|
24
|
-
--animate-fd-dialog-out: fd-dialog-out
|
|
23
|
+
--animate-fd-dialog-in: fd-dialog-in 240ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
24
|
+
--animate-fd-dialog-out: fd-dialog-out 240ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
25
25
|
|
|
26
26
|
--animate-fd-popover-in: fd-popover-in 150ms ease;
|
|
27
27
|
--animate-fd-popover-out: fd-popover-out 150ms ease;
|
|
28
28
|
|
|
29
|
-
--animate-fd-collapsible-down: fd-collapsible-down 150ms
|
|
30
|
-
|
|
29
|
+
--animate-fd-collapsible-down: fd-collapsible-down 150ms
|
|
30
|
+
cubic-bezier(0.45, 0, 0.55, 1);
|
|
31
|
+
--animate-fd-collapsible-up: fd-collapsible-up 150ms
|
|
32
|
+
cubic-bezier(0.45, 0, 0.55, 1);
|
|
31
33
|
|
|
32
34
|
--animate-fd-accordion-down: fd-accordion-down 200ms ease-out;
|
|
33
35
|
--animate-fd-accordion-up: fd-accordion-up 200ms ease-out;
|
|
@@ -38,6 +40,9 @@
|
|
|
38
40
|
--animate-fd-enterFromLeft: fd-enterFromLeft 250ms ease;
|
|
39
41
|
--animate-fd-enterFromRight: fd-enterFromRight 250ms ease;
|
|
40
42
|
|
|
43
|
+
--animate-fd-sidebar-in: fd-sidebar-in 250ms ease;
|
|
44
|
+
--animate-fd-sidebar-out: fd-sidebar-out 250ms ease;
|
|
45
|
+
|
|
41
46
|
--animate-fd-exitToLeft: fd-exitToLeft 250ms ease;
|
|
42
47
|
--animate-fd-exitToRight: fd-exitToRight 250ms ease;
|
|
43
48
|
|
|
@@ -96,7 +101,7 @@
|
|
|
96
101
|
transform: scale(1);
|
|
97
102
|
}
|
|
98
103
|
to {
|
|
99
|
-
transform: scale(1.
|
|
104
|
+
transform: scale(1.04);
|
|
100
105
|
opacity: 0;
|
|
101
106
|
}
|
|
102
107
|
}
|
|
@@ -185,6 +190,18 @@
|
|
|
185
190
|
}
|
|
186
191
|
}
|
|
187
192
|
|
|
193
|
+
@keyframes fd-sidebar-in {
|
|
194
|
+
from {
|
|
195
|
+
transform: translateX(-100%);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@keyframes fd-sidebar-out {
|
|
200
|
+
to {
|
|
201
|
+
transform: translateX(-100%);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
188
205
|
@keyframes fd-nav-menu-in {
|
|
189
206
|
from {
|
|
190
207
|
opacity: 0;
|
|
@@ -241,6 +258,10 @@
|
|
|
241
258
|
&::-webkit-scrollbar-track {
|
|
242
259
|
background: transparent;
|
|
243
260
|
}
|
|
261
|
+
|
|
262
|
+
&::-webkit-scrollbar-corner {
|
|
263
|
+
display: none;
|
|
264
|
+
}
|
|
244
265
|
}
|
|
245
266
|
|
|
246
267
|
@utility fd-steps {
|
package/css/vitepress.css
CHANGED
|
@@ -63,16 +63,13 @@
|
|
|
63
63
|
|
|
64
64
|
#nd-sidebar {
|
|
65
65
|
background-color: hsl(240, 6%, 97%);
|
|
66
|
+
border-color: transparent;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
.dark #nd-sidebar {
|
|
69
70
|
background-color: hsl(240, 4%, 9%);
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
#nd-sidebar > div {
|
|
73
|
-
border-color: transparent;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
73
|
button[data-search-full] {
|
|
77
74
|
background-color: var(--color-fd-background);
|
|
78
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-algolia.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search-algolia.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"search-algolia.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search-algolia.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAEjD,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,OAAO,EAGb,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IAEjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,KAAK,EACL,aAAa,EACb,IAAI,EACJ,UAAU,EACV,WAAmB,EACnB,UAAkB,EAClB,GAAG,KAAK,EACT,EAAE,wBAAwB,GAAG,SAAS,CA0CtC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useDocsSearch, } from 'fumadocs-core/search/client';
|
|
4
4
|
import { useState } from 'react';
|
|
5
5
|
import { useOnChange } from 'fumadocs-core/utils/use-on-change';
|
|
6
|
-
import { SearchDialog, TagsList, } from './search.js';
|
|
6
|
+
import { SearchDialog, TagsList, TagsListItem, } from './search.js';
|
|
7
7
|
export default function AlgoliaSearchDialog({ index, searchOptions, tags, defaultTag, showAlgolia = false, allowClear = false, ...props }) {
|
|
8
8
|
const [tag, setTag] = useState(defaultTag);
|
|
9
9
|
const { search, setSearch, query } = useDocsSearch({
|
|
@@ -14,7 +14,7 @@ export default function AlgoliaSearchDialog({ index, searchOptions, tags, defaul
|
|
|
14
14
|
useOnChange(defaultTag, (v) => {
|
|
15
15
|
setTag(v);
|
|
16
16
|
});
|
|
17
|
-
return (_jsx(SearchDialog, { search: search, onSearchChange: setSearch, results: query.data ?? [], isLoading: query.isLoading, ...props, footer:
|
|
17
|
+
return (_jsx(SearchDialog, { search: search, onSearchChange: setSearch, results: query.data ?? [], isLoading: query.isLoading, ...props, footer: _jsxs(_Fragment, { children: [tags ? (_jsxs(TagsList, { tag: tag, onTagChange: setTag, allowClear: allowClear, children: [tags.map((tag) => (_jsx(TagsListItem, { value: tag.value, children: tag.name }, tag.value))), showAlgolia && _jsx(AlgoliaTitle, {})] })) : (showAlgolia && _jsx(AlgoliaTitle, {})), props.footer] }) }));
|
|
18
18
|
}
|
|
19
19
|
function AlgoliaTitle() {
|
|
20
20
|
return (_jsx("a", { href: "https://algolia.com", rel: "noreferrer noopener", className: "ms-auto text-xs text-fd-muted-foreground", children: "Search powered by Algolia" }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-default.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search-default.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAGjD,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"search-default.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search-default.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAGjD,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,OAAO,EAGb,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAE1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IAEjB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,UAAU,EACV,IAAI,EACJ,GAAG,EACH,OAAO,EACP,IAAc,EACd,UAAkB,EAClB,GAAG,KAAK,EACT,EAAE,wBAAwB,GAAG,SAAS,CA6CtC"}
|
|
@@ -4,7 +4,7 @@ import { useDocsSearch } from 'fumadocs-core/search/client';
|
|
|
4
4
|
import { useState } from 'react';
|
|
5
5
|
import { useOnChange } from 'fumadocs-core/utils/use-on-change';
|
|
6
6
|
import { useI18n } from '../../contexts/i18n.js';
|
|
7
|
-
import { SearchDialog, TagsList, } from './search.js';
|
|
7
|
+
import { SearchDialog, TagsList, TagsListItem, } from './search.js';
|
|
8
8
|
export default function DefaultSearchDialog({ defaultTag, tags, api, delayMs, type = 'fetch', allowClear = false, ...props }) {
|
|
9
9
|
const { locale } = useI18n();
|
|
10
10
|
const [tag, setTag] = useState(defaultTag);
|
|
@@ -20,5 +20,5 @@ export default function DefaultSearchDialog({ defaultTag, tags, api, delayMs, ty
|
|
|
20
20
|
useOnChange(defaultTag, (v) => {
|
|
21
21
|
setTag(v);
|
|
22
22
|
});
|
|
23
|
-
return (_jsx(SearchDialog, { search: search, onSearchChange: setSearch, isLoading: query.isLoading, results: query.data ?? [], ...props, footer:
|
|
23
|
+
return (_jsx(SearchDialog, { search: search, onSearchChange: setSearch, isLoading: query.isLoading, results: query.data ?? [], ...props, footer: _jsxs(_Fragment, { children: [tags && (_jsx(TagsList, { tag: tag, onTagChange: setTag, allowClear: allowClear, children: tags.map((tag) => (_jsx(TagsListItem, { value: tag.value, children: tag.name }, tag.value))) })), props.footer] }) }));
|
|
24
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-orama.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search-orama.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"search-orama.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search-orama.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAEjD,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,OAAO,EAGb,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACpC,aAAa,CAAC,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAEnC,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IAEjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,MAAM,EACN,aAAa,EACb,IAAI,EACJ,UAAU,EACV,SAAiB,EACjB,UAAkB,EAClB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,sBAAsB,GAAG,SAAS,CA2CpC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useDocsSearch, } from 'fumadocs-core/search/client';
|
|
4
4
|
import { useState } from 'react';
|
|
5
5
|
import { useOnChange } from 'fumadocs-core/utils/use-on-change';
|
|
6
|
-
import { SearchDialog, TagsList, } from './search.js';
|
|
6
|
+
import { SearchDialog, TagsList, TagsListItem, } from './search.js';
|
|
7
7
|
/**
|
|
8
8
|
* Orama Cloud integration
|
|
9
9
|
*/
|
|
@@ -18,7 +18,7 @@ export default function OramaSearchDialog({ client, searchOptions, tags, default
|
|
|
18
18
|
useOnChange(defaultTag, (v) => {
|
|
19
19
|
setTag(v);
|
|
20
20
|
});
|
|
21
|
-
return (_jsx(SearchDialog, { search: search, onSearchChange: setSearch, results: query.data ?? [], isLoading: query.isLoading, ...props, footer:
|
|
21
|
+
return (_jsx(SearchDialog, { search: search, onSearchChange: setSearch, results: query.data ?? [], isLoading: query.isLoading, ...props, footer: _jsxs(_Fragment, { children: [tags ? (_jsxs(TagsList, { tag: tag, onTagChange: setTag, allowClear: allowClear, children: [tags.map((tag) => (_jsx(TagsListItem, { value: tag.value, children: tag.name }, tag.value))), showOrama && _jsx(Label, {})] })) : (showOrama && _jsx(Label, {})), props.footer] }) }));
|
|
22
22
|
}
|
|
23
23
|
function Label() {
|
|
24
24
|
return (_jsx("a", { href: "https://orama.com", rel: "noreferrer noopener", className: "ms-auto text-xs text-fd-muted-foreground", children: "Search powered by Orama" }));
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
2
|
import type { SortedResult } from 'fumadocs-core/server';
|
|
3
3
|
export type SearchLink = [name: string, href: string];
|
|
4
4
|
type ReactSortedResult = Omit<SortedResult, 'content'> & {
|
|
5
5
|
external?: boolean;
|
|
6
6
|
content: ReactNode;
|
|
7
7
|
};
|
|
8
|
+
export interface TagItem {
|
|
9
|
+
name: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
8
12
|
export interface SharedProps {
|
|
9
13
|
open: boolean;
|
|
10
14
|
onOpenChange: (open: boolean) => void;
|
|
@@ -22,17 +26,14 @@ interface SearchDialogProps extends SharedProps {
|
|
|
22
26
|
footer?: ReactNode;
|
|
23
27
|
}
|
|
24
28
|
export declare function SearchDialog({ open, onOpenChange, footer, links, search, onSearchChange, isLoading, ...props }: SearchDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
export interface
|
|
26
|
-
name: string;
|
|
27
|
-
value: string | undefined;
|
|
28
|
-
props?: HTMLAttributes<HTMLButtonElement>;
|
|
29
|
-
}
|
|
30
|
-
export interface TagsListProps extends HTMLAttributes<HTMLDivElement> {
|
|
29
|
+
export interface TagsListProps extends ComponentProps<'div'> {
|
|
31
30
|
tag?: string;
|
|
32
31
|
onTagChange: (tag: string | undefined) => void;
|
|
33
32
|
allowClear?: boolean;
|
|
34
|
-
items: TagItem[];
|
|
35
33
|
}
|
|
36
|
-
export declare function TagsList({ tag, onTagChange,
|
|
34
|
+
export declare function TagsList({ tag, onTagChange, allowClear, ...props }: TagsListProps): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare function TagsListItem({ value, className, ...props }: ComponentProps<'button'> & {
|
|
36
|
+
value: string;
|
|
37
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
37
38
|
export {};
|
|
38
39
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search.tsx"],"names":[],"mappings":"AASA,OAAO,
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search.tsx"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAWf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKzD,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEtD,KAAK,iBAAiB,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,GAAG;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAEtC;;OAEG;IACH,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,UAAU,iBAAkB,SAAQ,WAAW;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;IAEvC,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,KAAU,EACV,MAAM,EACN,cAAc,EACd,SAAS,EACT,GAAG,KAAK,EACT,EAAE,iBAAiB,2CA6DnB;AAoJD,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,KAAK,CAAC;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAmBD,wBAAgB,QAAQ,CAAC,EACvB,GAAG,EACH,WAAW,EACX,UAAkB,EAClB,GAAG,KAAK,EACT,EAAE,aAAa,2CAoBf;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf,2CAmBA"}
|
|
@@ -9,9 +9,10 @@ import { buttonVariants } from '../../components/ui/button.js';
|
|
|
9
9
|
import { Dialog, DialogContent, DialogOverlay, DialogTitle, } from '@radix-ui/react-dialog';
|
|
10
10
|
import { cva } from 'class-variance-authority';
|
|
11
11
|
import { useEffectEvent } from 'fumadocs-core/utils/use-effect-event';
|
|
12
|
-
import { useRouter } from 'fumadocs-core/framework';
|
|
12
|
+
import { createContext, useRouter } from 'fumadocs-core/framework';
|
|
13
13
|
export function SearchDialog({ open, onOpenChange, footer, links = [], search, onSearchChange, isLoading, ...props }) {
|
|
14
14
|
const { text } = useI18n();
|
|
15
|
+
const [active, setActive] = useState();
|
|
15
16
|
const defaultItems = useMemo(() => links.map(([name, link]) => ({
|
|
16
17
|
type: 'page',
|
|
17
18
|
id: name,
|
|
@@ -20,25 +21,21 @@ export function SearchDialog({ open, onOpenChange, footer, links = [], search, o
|
|
|
20
21
|
})), [links]);
|
|
21
22
|
return (_jsxs(Dialog, { open: open, onOpenChange: onOpenChange, children: [_jsx(DialogOverlay, { className: "fixed inset-0 z-50 bg-black/30 backdrop-blur-sm data-[state=closed]:animate-fd-fade-out data-[state=open]:animate-fd-fade-in" }), _jsxs(DialogContent, { "aria-describedby": undefined, className: "fixed left-1/2 top-[10vh] z-50 w-[98vw] max-w-screen-sm -translate-x-1/2 rounded-lg border bg-fd-popover text-fd-popover-foreground shadow-lg data-[state=closed]:animate-fd-dialog-out data-[state=open]:animate-fd-dialog-in", children: [_jsx(DialogTitle, { className: "hidden", children: text.search }), _jsxs("div", { className: "flex flex-row items-center gap-2 px-3", children: [_jsx(LoadingIndicator, { isLoading: isLoading ?? false }), _jsx("input", { value: search, onChange: (e) => {
|
|
22
23
|
onSearchChange(e.target.value);
|
|
24
|
+
setActive(undefined);
|
|
23
25
|
}, placeholder: text.search, className: "w-0 flex-1 bg-transparent py-3 text-base placeholder:text-fd-muted-foreground focus-visible:outline-none" }), _jsx("button", { type: "button", "aria-label": "Close Search", onClick: () => onOpenChange(false), className: cn(buttonVariants({
|
|
24
26
|
color: 'outline',
|
|
25
27
|
className: 'text-xs p-1.5',
|
|
26
|
-
})), children: "Esc" })] }), props.results !== 'empty' || defaultItems.length > 0 ? (_jsx(SearchResults, { items: props.results === 'empty' ? defaultItems : props.results, onSelect: () => onOpenChange(false) })) : null,
|
|
28
|
+
})), children: "Esc" })] }), props.results !== 'empty' || defaultItems.length > 0 ? (_jsx(SearchResults, { active: active, onActiveChange: setActive, items: props.results === 'empty' ? defaultItems : props.results, onSelect: () => onOpenChange(false) })) : null, _jsx("div", { className: "mt-auto flex flex-col border-t p-3 empty:hidden", children: footer })] })] }));
|
|
27
29
|
}
|
|
28
30
|
const icons = {
|
|
29
31
|
text: _jsx(Text, { className: "size-4 text-fd-muted-foreground" }),
|
|
30
32
|
heading: _jsx(Hash, { className: "size-4 text-fd-muted-foreground" }),
|
|
31
33
|
page: _jsx(FileText, { className: "size-4 text-fd-muted-foreground" }),
|
|
32
34
|
};
|
|
33
|
-
function SearchResults({ items, onSelect, ...props }) {
|
|
34
|
-
const [active, setActive] = useState();
|
|
35
|
+
function SearchResults({ items, active = items.at(0)?.id, onActiveChange, onSelect, ...props }) {
|
|
35
36
|
const { text } = useI18n();
|
|
36
37
|
const router = useRouter();
|
|
37
38
|
const sidebar = useSidebar();
|
|
38
|
-
if (items.length > 0 &&
|
|
39
|
-
(!active || items.every((item) => item.id !== active))) {
|
|
40
|
-
setActive(items[0].id);
|
|
41
|
-
}
|
|
42
39
|
const onOpen = ({ external, url }) => {
|
|
43
40
|
if (external)
|
|
44
41
|
window.open(url, '_blank')?.focus();
|
|
@@ -49,12 +46,14 @@ function SearchResults({ items, onSelect, ...props }) {
|
|
|
49
46
|
};
|
|
50
47
|
const onKey = useEffectEvent((e) => {
|
|
51
48
|
if (e.key === 'ArrowDown' || e.key == 'ArrowUp') {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
const idx = items.findIndex((item) => item.id === active);
|
|
50
|
+
if (idx === -1) {
|
|
51
|
+
onActiveChange(items.at(0)?.id);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
onActiveChange(items.at((e.key === 'ArrowDown' ? idx + 1 : idx - 1) % items.length)
|
|
55
|
+
?.id);
|
|
56
|
+
}
|
|
58
57
|
e.preventDefault();
|
|
59
58
|
}
|
|
60
59
|
if (e.key === 'Enter') {
|
|
@@ -70,21 +69,21 @@ function SearchResults({ items, onSelect, ...props }) {
|
|
|
70
69
|
window.removeEventListener('keydown', onKey);
|
|
71
70
|
};
|
|
72
71
|
}, [onKey]);
|
|
73
|
-
return (_jsxs("div", { ...props, className: cn('flex max-h-[460px] flex-col overflow-y-auto border-t p-2', props.className), children: [items.length === 0 ? (_jsx("div", { className: "py-12 text-center text-sm", children: text.searchNoResult })) : null, items.map((item) => (_jsxs(CommandItem, {
|
|
72
|
+
return (_jsxs("div", { ...props, className: cn('flex max-h-[460px] flex-col overflow-y-auto border-t p-2', props.className), children: [items.length === 0 ? (_jsx("div", { className: "py-12 text-center text-sm", children: text.searchNoResult })) : null, items.map((item) => (_jsxs(CommandItem, { active: active === item.id, onPointerMove: () => onActiveChange(item.id), onClick: () => {
|
|
74
73
|
onOpen(item);
|
|
75
74
|
}, children: [item.type !== 'page' ? (_jsx("div", { role: "none", className: "ms-2 h-full min-h-10 w-px bg-fd-border" })) : null, icons[item.type], _jsx("p", { className: "w-0 flex-1 truncate", children: item.content })] }, item.id)))] }));
|
|
76
75
|
}
|
|
77
76
|
function LoadingIndicator({ isLoading }) {
|
|
78
77
|
return (_jsxs("div", { className: "relative size-4", children: [_jsx(LoaderCircle, { className: cn('absolute size-full animate-spin text-fd-primary transition-opacity', !isLoading && 'opacity-0') }), _jsx(SearchIcon, { className: cn('absolute size-full text-fd-muted-foreground transition-opacity', isLoading && 'opacity-0') })] }));
|
|
79
78
|
}
|
|
80
|
-
function CommandItem({ active
|
|
79
|
+
function CommandItem({ active = false, ...props }) {
|
|
81
80
|
return (_jsx("button", { ref: useCallback((element) => {
|
|
82
|
-
if (active
|
|
81
|
+
if (active && element) {
|
|
83
82
|
element.scrollIntoView({
|
|
84
83
|
block: 'nearest',
|
|
85
84
|
});
|
|
86
85
|
}
|
|
87
|
-
}, [active
|
|
86
|
+
}, [active]), type: "button", "aria-selected": active, ...props, className: cn('flex min-h-10 select-none flex-row items-center gap-2.5 rounded-lg px-2 text-start text-sm', active && 'bg-fd-accent text-fd-accent-foreground', props.className), children: props.children }));
|
|
88
87
|
}
|
|
89
88
|
const itemVariants = cva('rounded-md border px-2 py-0.5 text-xs font-medium text-fd-muted-foreground transition-colors', {
|
|
90
89
|
variants: {
|
|
@@ -93,13 +92,17 @@ const itemVariants = cva('rounded-md border px-2 py-0.5 text-xs font-medium text
|
|
|
93
92
|
},
|
|
94
93
|
},
|
|
95
94
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
const TagsListContext = createContext('TagsList');
|
|
96
|
+
export function TagsList({ tag, onTagChange, allowClear = false, ...props }) {
|
|
97
|
+
return (_jsx("div", { ...props, className: cn('flex items-center gap-1 flex-wrap', props.className), children: _jsx(TagsListContext.Provider, { value: useMemo(() => ({
|
|
98
|
+
value: tag,
|
|
99
|
+
onValueChange: onTagChange,
|
|
100
|
+
allowClear,
|
|
101
|
+
}), [allowClear, onTagChange, tag]), children: props.children }) }));
|
|
102
|
+
}
|
|
103
|
+
export function TagsListItem({ value, className, ...props }) {
|
|
104
|
+
const ctx = TagsListContext.use();
|
|
105
|
+
return (_jsx("button", { type: "button", "data-active": value === ctx.value, className: cn(itemVariants({ active: value === ctx.value, className })), onClick: () => {
|
|
106
|
+
ctx.onValueChange(ctx.value === value && ctx.allowClear ? undefined : value);
|
|
107
|
+
}, tabIndex: -1, ...props, children: props.children }));
|
|
105
108
|
}
|
|
@@ -22,7 +22,7 @@ export function RootToggle({ options, placeholder, ...props }) {
|
|
|
22
22
|
setOpen(false);
|
|
23
23
|
};
|
|
24
24
|
const item = selected ? _jsx(Item, { ...selected }) : placeholder;
|
|
25
|
-
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [item ? (_jsxs(PopoverTrigger, { ...props, className: cn('flex items-center gap-2
|
|
25
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [item ? (_jsxs(PopoverTrigger, { ...props, className: cn('flex items-center gap-2 rounded-lg pe-2 hover:text-fd-accent-foreground', props.className), children: [item, _jsx(ChevronsUpDown, { className: "size-4 text-fd-muted-foreground" })] })) : null, _jsx(PopoverContent, { className: "w-(--radix-popover-trigger-width) overflow-hidden p-0", children: options.map((item) => (_jsx(Link, { href: item.url, onClick: onClick, ...item.props, className: cn('flex w-full flex-row items-center gap-2 px-2 py-1.5', selected === item
|
|
26
26
|
? 'bg-fd-accent text-fd-accent-foreground'
|
|
27
27
|
: 'hover:bg-fd-accent/50', item.props?.className), children: _jsx(Item, { ...item }) }, item.url))) })] }));
|
|
28
28
|
}
|
|
@@ -21,7 +21,7 @@ export function LargeSearchToggle({ hideIfDisabled, ...props }) {
|
|
|
21
21
|
const { text } = useI18n();
|
|
22
22
|
if (hideIfDisabled && !enabled)
|
|
23
23
|
return null;
|
|
24
|
-
return (_jsxs("button", { type: "button", "data-search-full": "", ...props, className: cn('inline-flex items-center gap-2 rounded-
|
|
24
|
+
return (_jsxs("button", { type: "button", "data-search-full": "", ...props, className: cn('inline-flex items-center gap-2 rounded-lg border bg-fd-secondary/50 p-1.5 ps-2 text-sm text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground', props.className), onClick: () => {
|
|
25
25
|
setOpenSearch(true);
|
|
26
|
-
}, children: [_jsx(Search, { className: "
|
|
26
|
+
}, children: [_jsx(Search, { className: "size-4" }), text.search, _jsx("div", { className: "ms-auto inline-flex gap-0.5", children: hotKey.map((k, i) => (_jsx("kbd", { className: "rounded-md border bg-fd-background px-1.5", children: k.display }, i))) })] }));
|
|
27
27
|
}
|
|
@@ -35,7 +35,7 @@ export declare function SidebarItem({ icon, ...props }: LinkProps & {
|
|
|
35
35
|
export declare function SidebarFolder({ defaultOpen, ...props }: ComponentProps<'div'> & {
|
|
36
36
|
defaultOpen?: boolean;
|
|
37
37
|
}): import("react/jsx-runtime").JSX.Element;
|
|
38
|
-
export declare function SidebarFolderTrigger(props: CollapsibleTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export declare function SidebarFolderTrigger({ className, ...props }: CollapsibleTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
39
39
|
export declare function SidebarFolderLink(props: LinkProps): import("react/jsx-runtime").JSX.Element;
|
|
40
40
|
export declare function SidebarFolderContent(props: CollapsibleContentProps): import("react/jsx-runtime").JSX.Element;
|
|
41
41
|
export declare function SidebarCollapseTrigger(props: ComponentProps<'button'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../../src/components/layout/sidebar.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../../src/components/layout/sidebar.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,EAAE,EAEP,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AACf,OAAa,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAU1D,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGnE,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAMrD,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,OAAO,CAAC;IAC3D;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AA2BD,wBAAgB,OAAO,CAAC,EACtB,gBAAoB,EACpB,QAAe,EACf,WAAkB,EAClB,GAAG,KAAK,EACT,EAAE,YAAY,2CAmHd;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,2CASzD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,2CASzD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,2CAcrD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,2CAkB1D;AAED,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,SAAS,GAAG;IACb,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,2CAsBA;AAED,wBAAgB,aAAa,CAAC,EAC5B,WAAmB,EACnB,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,2CAgBA;AAED,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,GAAG,KAAK,EACT,EAAE,uBAAuB,2CAqBzB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,2CAsCjD;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,uBAAuB,2CAqBlE;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,CAAC,QAAQ,CAAC,2CAgBrE;AAgBD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,EAAE,CAAC;QAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAA;KAAE,CAAC,CAAC;IAClC,MAAM,EAAE,EAAE,CAAC;QAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IAC1E,SAAS,EAAE,EAAE,CAAC;QAAE,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAA;KAAE,CAAC,CAAC;CAC7C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACzC,2CAuDA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { ChevronDown, ExternalLink } from '../../icons.js';
|
|
4
4
|
import { usePathname } from 'fumadocs-core/framework';
|
|
5
5
|
import { createContext, Fragment, useContext, useMemo, useRef, useState, } from 'react';
|
|
@@ -45,18 +45,22 @@ export function Sidebar({ defaultOpenLevel = 0, prefetch = true, collapsible = t
|
|
|
45
45
|
});
|
|
46
46
|
if (isMobile) {
|
|
47
47
|
const state = open ? 'open' : 'closed';
|
|
48
|
-
return (_jsxs(
|
|
48
|
+
return (_jsxs(Context.Provider, { value: context, children: [_jsx(Presence, { present: open, children: _jsx("div", { "data-state": state, className: "fixed z-40 inset-0 bg-black/30 backdrop-blur-sm data-[state=open]:animate-fd-fade-in data-[state=closed]:animate-fd-fade-out", onClick: () => setOpen(false) }) }), _jsx(Presence, { present: open, children: ({ present }) => (_jsx(RemoveScroll, { as: "aside", enabled: present, id: "nd-sidebar-mobile", ...props, "data-state": state, className: cn('fixed text-[15px] flex flex-col py-2 rounded-e-2xl border-e start-0 inset-y-0 w-[85%] max-w-[380px] z-40 bg-fd-background data-[state=open]:animate-fd-sidebar-in data-[state=closed]:animate-fd-sidebar-out', !present && 'invisible', props.className), children: props.children })) })] }));
|
|
49
49
|
}
|
|
50
|
-
return (_jsx("aside", { id: "nd-sidebar", ...props, "data-collapsed": collapsed, className: cn('sticky top-(--fd-sidebar-top) z-20 bg-fd-card text-sm h-(--fd-sidebar-height) max-md:hidden',
|
|
51
|
-
'
|
|
52
|
-
|
|
53
|
-
'-
|
|
54
|
-
|
|
55
|
-
collapsed && !hover && 'opacity-0',
|
|
50
|
+
return (_jsx("aside", { id: "nd-sidebar", ...props, "data-collapsed": collapsed, className: cn('sticky shrink-0 flex flex-col items-end top-(--fd-sidebar-top) z-20 bg-fd-card text-sm h-(--fd-sidebar-height) w-(--fd-sidebar-width) *:w-(--fd-sidebar-width) border-e max-md:hidden', collapsed && [
|
|
51
|
+
'rounded-xl border',
|
|
52
|
+
hover
|
|
53
|
+
? 'z-50 translate-x-2 shadow-lg'
|
|
54
|
+
: 'opacity-0 -translate-x-(--fd-sidebar-offset) rtl:translate-x-(--fd-sidebar-offset)',
|
|
56
55
|
], props.className), style: {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
transition: [
|
|
57
|
+
...['border', 'height', 'top'].map((v) => collapsed ? `${v} step-end 200ms` : `${v} step-start 200ms`),
|
|
58
|
+
...['opacity', 'margin', 'translate'].map((v) => `${v} ease 200ms`),
|
|
59
|
+
].join(', '),
|
|
60
|
+
'--fd-sidebar-offset': 'calc(100% - 16px)',
|
|
61
|
+
'--fd-sidebar-margin': collapsed ? '0.5rem' : '0px',
|
|
62
|
+
'--fd-sidebar-top': `calc(var(--fd-banner-height) + var(--fd-nav-height) + var(--fd-sidebar-margin))`,
|
|
63
|
+
'--fd-sidebar-height': 'calc(100dvh - var(--fd-sidebar-top) - var(--fd-sidebar-margin))',
|
|
60
64
|
...props.style,
|
|
61
65
|
}, onPointerEnter: (e) => {
|
|
62
66
|
if (!collapsible ||
|
|
@@ -76,22 +80,22 @@ export function Sidebar({ defaultOpenLevel = 0, prefetch = true, collapsible = t
|
|
|
76
80
|
}, Math.min(e.clientX, document.body.clientWidth - e.clientX) > 100
|
|
77
81
|
? 0
|
|
78
82
|
: 500);
|
|
79
|
-
}, children: _jsx(
|
|
83
|
+
}, children: _jsx(Context.Provider, { value: context, children: props.children }) }));
|
|
80
84
|
}
|
|
81
85
|
export function SidebarHeader(props) {
|
|
82
|
-
return (_jsx("div", { ...props, className: cn('flex flex-col gap-3
|
|
86
|
+
return (_jsx("div", { ...props, className: cn('flex flex-col gap-3 p-4 pb-2', props.className), children: props.children }));
|
|
83
87
|
}
|
|
84
88
|
export function SidebarFooter(props) {
|
|
85
89
|
return (_jsx("div", { ...props, className: cn('flex flex-col border-t px-4 py-3', props.className), children: props.children }));
|
|
86
90
|
}
|
|
87
91
|
export function SidebarViewport(props) {
|
|
88
92
|
return (_jsx(ScrollArea, { ...props, className: cn('h-full', props.className), children: _jsx(ScrollViewport, { className: "p-4", style: {
|
|
89
|
-
maskImage: 'linear-gradient(to bottom, transparent, white 12px)',
|
|
93
|
+
maskImage: 'linear-gradient(to bottom, transparent, white 12px, white calc(100% - 12px), transparent)',
|
|
90
94
|
}, children: props.children }) }));
|
|
91
95
|
}
|
|
92
96
|
export function SidebarSeparator(props) {
|
|
93
97
|
const { level } = useInternalContext();
|
|
94
|
-
return (_jsx("p", { ...props, className: cn('inline-flex items-center gap-2 mb-
|
|
98
|
+
return (_jsx("p", { ...props, className: cn('inline-flex items-center gap-2 mb-1.5 px-2 font-medium empty:mb-0 [&_svg]:size-4 [&_svg]:shrink-0', props.className), style: {
|
|
95
99
|
paddingInlineStart: getOffset(level),
|
|
96
100
|
...props.style,
|
|
97
101
|
}, children: props.children }));
|
|
@@ -113,10 +117,10 @@ export function SidebarFolder({ defaultOpen = false, ...props }) {
|
|
|
113
117
|
});
|
|
114
118
|
return (_jsx(Collapsible, { open: open, onOpenChange: setOpen, ...props, children: _jsx(FolderContext.Provider, { value: useMemo(() => ({ open, setOpen }), [open]), children: props.children }) }));
|
|
115
119
|
}
|
|
116
|
-
export function SidebarFolderTrigger(props) {
|
|
120
|
+
export function SidebarFolderTrigger({ className, ...props }) {
|
|
117
121
|
const { level } = useInternalContext();
|
|
118
122
|
const { open } = useFolderContext();
|
|
119
|
-
return (_jsxs(CollapsibleTrigger, {
|
|
123
|
+
return (_jsxs(CollapsibleTrigger, { className: cn(itemVariants({ active: false }), 'w-full', className), ...props, style: {
|
|
120
124
|
paddingInlineStart: getOffset(level),
|
|
121
125
|
...props.style,
|
|
122
126
|
}, children: [_jsx(Border, { level: level }), props.children, _jsx(ChevronDown, { "data-icon": true, className: cn('ms-auto transition-transform', !open && '-rotate-90') })] }));
|
|
@@ -127,12 +131,13 @@ export function SidebarFolderLink(props) {
|
|
|
127
131
|
const pathname = usePathname();
|
|
128
132
|
const active = props.href !== undefined && isActive(props.href, pathname, false);
|
|
129
133
|
return (_jsxs(Link, { ...props, "data-active": active, className: cn(itemVariants({ active }), 'w-full', props.className), onClick: (e) => {
|
|
130
|
-
if (e.target
|
|
131
|
-
|
|
134
|
+
if (e.target instanceof HTMLElement &&
|
|
135
|
+
e.target.hasAttribute('data-icon')) {
|
|
136
|
+
setOpen(!open);
|
|
132
137
|
e.preventDefault();
|
|
133
138
|
}
|
|
134
139
|
else {
|
|
135
|
-
setOpen(
|
|
140
|
+
setOpen(active ? !open : true);
|
|
136
141
|
}
|
|
137
142
|
}, prefetch: prefetch, style: {
|
|
138
143
|
paddingInlineStart: getOffset(level),
|
|
@@ -144,7 +149,7 @@ export function SidebarFolderContent(props) {
|
|
|
144
149
|
return (_jsx(CollapsibleContent, { ...props, className: cn('relative', props.className), children: _jsxs(Context.Provider, { value: useMemo(() => ({
|
|
145
150
|
...ctx,
|
|
146
151
|
level: ctx.level + 1,
|
|
147
|
-
}), [ctx]), children: [ctx.level === 1 && (_jsx("div", { className: "absolute w-px inset-y-
|
|
152
|
+
}), [ctx]), children: [ctx.level === 1 && (_jsx("div", { className: "absolute w-px inset-y-1 bg-fd-border start-2.5" })), props.children] }) }));
|
|
148
153
|
}
|
|
149
154
|
export function SidebarCollapseTrigger(props) {
|
|
150
155
|
const { collapsed, setCollapsed } = useSidebar();
|
|
@@ -198,10 +203,10 @@ function PageTreeFolder({ item, ...props }) {
|
|
|
198
203
|
return (_jsxs(SidebarFolder, { defaultOpen: (item.defaultOpen ?? defaultOpenLevel >= level) || path.includes(item), children: [item.index ? (_jsxs(SidebarFolderLink, { href: item.index.url, external: item.index.external, ...props, children: [item.icon, item.name] })) : (_jsxs(SidebarFolderTrigger, { ...props, children: [item.icon, item.name] })), _jsx(SidebarFolderContent, { children: props.children })] }));
|
|
199
204
|
}
|
|
200
205
|
function getOffset(level) {
|
|
201
|
-
return `calc(var(--spacing) * ${level > 1 ?
|
|
206
|
+
return `calc(var(--spacing) * ${level > 1 ? level * 3 : 2})`;
|
|
202
207
|
}
|
|
203
208
|
function Border({ level, active }) {
|
|
204
209
|
if (level <= 1)
|
|
205
210
|
return null;
|
|
206
|
-
return (_jsx("div", { className: cn('absolute w-px inset-y-3 z-[2] start-
|
|
211
|
+
return (_jsx("div", { className: cn('absolute w-px inset-y-3 z-[2] start-2.5 md:inset-y-2', active && 'bg-fd-primary') }));
|
|
207
212
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { TabsContentProps, TabsProps as BaseProps } from '@radix-ui/react-tabs';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
|
-
import * as Primitive from './ui/tabs.js';
|
|
4
|
-
export { Primitive };
|
|
5
3
|
export interface TabsProps extends BaseProps {
|
|
6
|
-
label?: ReactNode;
|
|
7
4
|
/**
|
|
8
5
|
* Identifier for Sharing value of tabs
|
|
9
6
|
*/
|
|
@@ -13,21 +10,33 @@ export interface TabsProps extends BaseProps {
|
|
|
13
10
|
*/
|
|
14
11
|
persist?: boolean;
|
|
15
12
|
/**
|
|
13
|
+
* If true, updates the URL hash based on the tab's id
|
|
14
|
+
*/
|
|
15
|
+
updateAnchor?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Use simple mode instead of advanced usage as documented in https://radix-ui.com/primitives/docs/components/tabs.
|
|
18
|
+
*/
|
|
19
|
+
items?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Shortcut for `defaultValue` when `items` is provided.
|
|
22
|
+
*
|
|
16
23
|
* @defaultValue 0
|
|
17
24
|
*/
|
|
18
25
|
defaultIndex?: number;
|
|
19
|
-
items?: string[];
|
|
20
26
|
/**
|
|
21
|
-
*
|
|
27
|
+
* Additional label in tabs list when `items` is provided.
|
|
22
28
|
*/
|
|
23
|
-
|
|
29
|
+
label?: ReactNode;
|
|
24
30
|
}
|
|
25
|
-
export declare
|
|
31
|
+
export declare const TabsList: import("react").ForwardRefExoticComponent<Omit<import("@radix-ui/react-tabs").TabsListProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
|
+
export declare const TabsTrigger: import("react").ForwardRefExoticComponent<Omit<import("@radix-ui/react-tabs").TabsTriggerProps & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
33
|
+
export declare function Tabs({ groupId, items, persist, label, defaultIndex, updateAnchor, defaultValue, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
26
34
|
export type TabProps = Omit<TabsContentProps, 'value'> & {
|
|
27
35
|
/**
|
|
28
36
|
* Value of tab, detect from index if unspecified.
|
|
29
37
|
*/
|
|
30
|
-
value?:
|
|
38
|
+
value?: string;
|
|
31
39
|
};
|
|
32
|
-
export declare function Tab({ value,
|
|
40
|
+
export declare function Tab({ value, ...props }: TabProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export declare function TabsContent({ value, className, ...props }: TabsContentProps): import("react/jsx-runtime").JSX.Element;
|
|
33
42
|
//# sourceMappingURL=tabs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/components/tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,IAAI,SAAS,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,SAAS,EAOf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/components/tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,IAAI,SAAS,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,SAAS,EAOf,MAAM,OAAO,CAAC;AAuBf,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAcD,eAAO,MAAM,QAAQ,sMAAqB,CAAC;AAC3C,eAAO,MAAM,WAAW,+MAAwB,CAAC;AAEjD,wBAAgB,IAAI,CAAC,EACnB,OAAO,EACP,KAAK,EACL,OAAe,EACf,KAAK,EACL,YAAgB,EAChB,YAAoB,EACpB,YAAmE,EACnE,GAAG,KAAK,EACT,EAAE,SAAS,2CAmFX;AAED,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG;IACvD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,QAAQ,2CAgBhD;AAED,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,2CAoB3E"}
|