fumadocs-ui 15.5.0 → 15.5.2
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 +6 -14
- package/dist/components/dialog/search-algolia.d.ts +3 -2
- package/dist/components/dialog/search-algolia.d.ts.map +1 -1
- package/dist/components/dialog/search-algolia.js +21 -6
- package/dist/components/dialog/search-default.d.ts +3 -2
- package/dist/components/dialog/search-default.d.ts.map +1 -1
- package/dist/components/dialog/search-default.js +22 -6
- package/dist/components/dialog/search-orama.d.ts +3 -2
- package/dist/components/dialog/search-orama.d.ts.map +1 -1
- package/dist/components/dialog/search-orama.js +21 -6
- package/dist/components/dialog/search.d.ts +46 -19
- package/dist/components/dialog/search.d.ts.map +1 -1
- package/dist/components/dialog/search.js +113 -43
- package/dist/components/tabs.d.ts +7 -7
- package/dist/components/tabs.d.ts.map +1 -1
- package/dist/components/tabs.js +7 -4
- package/dist/components/ui/popover.js +1 -1
- package/dist/contexts/search.d.ts +10 -2
- package/dist/contexts/search.d.ts.map +1 -1
- package/dist/contexts/search.js +3 -1
- package/dist/layouts/docs.d.ts +2 -11
- package/dist/layouts/docs.d.ts.map +1 -1
- package/dist/layouts/docs.js +15 -14
- package/dist/layouts/home.d.ts +1 -2
- package/dist/layouts/home.d.ts.map +1 -1
- package/dist/layouts/home.js +8 -6
- package/dist/layouts/notebook.d.ts.map +1 -1
- package/dist/layouts/notebook.js +13 -9
- package/dist/layouts/shared.d.ts +0 -9
- package/dist/layouts/shared.d.ts.map +1 -1
- package/dist/layouts/shared.js +0 -21
- package/dist/mdx.server.d.ts.map +1 -1
- package/dist/mdx.server.js +2 -1
- package/dist/page.d.ts +1 -1
- package/dist/page.d.ts.map +1 -1
- package/dist/page.js +6 -3
- package/dist/page.server.d.ts.map +1 -1
- package/dist/page.server.js +3 -2
- package/dist/provider/base.d.ts +1 -1
- package/dist/provider/base.d.ts.map +1 -1
- package/dist/style.css +43 -31
- package/package.json +20 -13
- package/dist/components/ui/hide-if-empty.d.ts +0 -10
- package/dist/components/ui/hide-if-empty.d.ts.map +0 -1
- package/dist/components/ui/hide-if-empty.js +0 -66
package/css/preset.css
CHANGED
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
--animate-fd-fade-in: fd-fade-in 300ms ease;
|
|
22
22
|
--animate-fd-fade-out: fd-fade-out 300ms ease;
|
|
23
23
|
|
|
24
|
-
--animate-fd-dialog-in: fd-dialog-in
|
|
25
|
-
--animate-fd-dialog-out: fd-dialog-out
|
|
24
|
+
--animate-fd-dialog-in: fd-dialog-in 300ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
25
|
+
--animate-fd-dialog-out: fd-dialog-out 300ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
26
26
|
|
|
27
|
-
--animate-fd-popover-in: fd-popover-in
|
|
28
|
-
--animate-fd-popover-out: fd-popover-out
|
|
27
|
+
--animate-fd-popover-in: fd-popover-in 130ms ease;
|
|
28
|
+
--animate-fd-popover-out: fd-popover-out 130ms ease;
|
|
29
29
|
|
|
30
30
|
--animate-fd-collapsible-down: fd-collapsible-down 150ms
|
|
31
31
|
cubic-bezier(0.45, 0, 0.55, 1);
|
|
@@ -110,22 +110,14 @@
|
|
|
110
110
|
@keyframes fd-popover-in {
|
|
111
111
|
from {
|
|
112
112
|
opacity: 0;
|
|
113
|
-
transform: translateY(-12px);
|
|
114
|
-
}
|
|
115
|
-
to {
|
|
116
|
-
opacity: 1;
|
|
117
|
-
transform: translateY(0);
|
|
113
|
+
transform: translateY(-12px) scale(0.9);
|
|
118
114
|
}
|
|
119
115
|
}
|
|
120
116
|
|
|
121
117
|
@keyframes fd-popover-out {
|
|
122
|
-
from {
|
|
123
|
-
opacity: 1;
|
|
124
|
-
transform: translateY(0);
|
|
125
|
-
}
|
|
126
118
|
to {
|
|
127
119
|
opacity: 0;
|
|
128
|
-
transform: translateY(-12px);
|
|
120
|
+
transform: translateY(-12px) scale(0.9);
|
|
129
121
|
}
|
|
130
122
|
}
|
|
131
123
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type AlgoliaOptions } from 'fumadocs-core/search/client';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import type { SearchLink, SharedProps, TagItem } from '../../contexts/search.js';
|
|
4
4
|
export interface AlgoliaSearchDialogProps extends SharedProps {
|
|
5
5
|
searchOptions: AlgoliaOptions;
|
|
6
|
+
links?: SearchLink[];
|
|
6
7
|
footer?: ReactNode;
|
|
7
8
|
defaultTag?: string;
|
|
8
9
|
tags?: TagItem[];
|
|
@@ -19,5 +20,5 @@ export interface AlgoliaSearchDialogProps extends SharedProps {
|
|
|
19
20
|
*/
|
|
20
21
|
allowClear?: boolean;
|
|
21
22
|
}
|
|
22
|
-
export default function AlgoliaSearchDialog({ searchOptions, tags, defaultTag, showAlgolia, allowClear, ...props }: AlgoliaSearchDialogProps):
|
|
23
|
+
export default function AlgoliaSearchDialog({ searchOptions, tags, defaultTag, showAlgolia, allowClear, links, footer, ...props }: AlgoliaSearchDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
23
24
|
//# sourceMappingURL=search-algolia.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAAqB,MAAM,OAAO,CAAC;AAgB1D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG1E,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,aAAa,EAAE,cAAc,CAAC;IAC9B,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IAErB,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,aAAa,EACb,IAAS,EACT,UAAU,EACV,WAAmB,EACnB,UAAkB,EAClB,KAAU,EACV,MAAM,EACN,GAAG,KAAK,EACT,EAAE,wBAAwB,2CA4D1B"}
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useDocsSearch, } from 'fumadocs-core/search/client';
|
|
4
|
-
import { useState } from 'react';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
5
|
import { useOnChange } from 'fumadocs-core/utils/use-on-change';
|
|
6
|
-
import { SearchDialog, TagsList, TagsListItem, } from './search.js';
|
|
7
|
-
|
|
6
|
+
import { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogOverlay, TagsList, TagsListItem, } from './search.js';
|
|
7
|
+
import { useI18n } from '../../contexts/i18n.js';
|
|
8
|
+
export default function AlgoliaSearchDialog({ searchOptions, tags = [], defaultTag, showAlgolia = false, allowClear = false, links = [], footer, ...props }) {
|
|
8
9
|
const [tag, setTag] = useState(defaultTag);
|
|
10
|
+
const { locale } = useI18n();
|
|
9
11
|
const { search, setSearch, query } = useDocsSearch({
|
|
10
12
|
type: 'algolia',
|
|
13
|
+
tag,
|
|
14
|
+
locale,
|
|
11
15
|
...searchOptions,
|
|
12
|
-
}
|
|
16
|
+
});
|
|
17
|
+
const defaultItems = useMemo(() => {
|
|
18
|
+
if (links.length === 0)
|
|
19
|
+
return null;
|
|
20
|
+
return links.map(([name, link]) => ({
|
|
21
|
+
type: 'page',
|
|
22
|
+
id: name,
|
|
23
|
+
content: name,
|
|
24
|
+
url: link,
|
|
25
|
+
}));
|
|
26
|
+
}, [links]);
|
|
13
27
|
useOnChange(defaultTag, (v) => {
|
|
14
28
|
setTag(v);
|
|
15
29
|
});
|
|
16
|
-
|
|
30
|
+
const label = showAlgolia && _jsx(AlgoliaTitle, {});
|
|
31
|
+
return (_jsxs(SearchDialog, { search: search, onSearchChange: setSearch, isLoading: query.isLoading, ...props, children: [_jsx(SearchDialogOverlay, {}), _jsxs(SearchDialogContent, { children: [_jsxs(SearchDialogHeader, { children: [_jsx(SearchDialogIcon, {}), _jsx(SearchDialogInput, {}), _jsx(SearchDialogClose, {})] }), _jsx(SearchDialogList, { items: query.data !== 'empty' ? query.data : defaultItems })] }), _jsxs(SearchDialogFooter, { children: [tags.length > 0 ? (_jsxs(TagsList, { tag: tag, onTagChange: setTag, allowClear: allowClear, children: [tags.map((tag) => (_jsx(TagsListItem, { value: tag.value, children: tag.name }, tag.value))), label] })) : (label), footer] })] }));
|
|
17
32
|
}
|
|
18
33
|
function AlgoliaTitle() {
|
|
19
34
|
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,6 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { SearchLink, SharedProps, TagItem } from '../../contexts/search.js';
|
|
3
3
|
export interface DefaultSearchDialogProps extends SharedProps {
|
|
4
|
+
links?: SearchLink[];
|
|
4
5
|
/**
|
|
5
6
|
* @defaultValue 'fetch'
|
|
6
7
|
*/
|
|
@@ -23,5 +24,5 @@ export interface DefaultSearchDialogProps extends SharedProps {
|
|
|
23
24
|
*/
|
|
24
25
|
allowClear?: boolean;
|
|
25
26
|
}
|
|
26
|
-
export default function DefaultSearchDialog({ defaultTag, tags, api, delayMs, type, allowClear, ...props }: DefaultSearchDialogProps):
|
|
27
|
+
export default function DefaultSearchDialog({ defaultTag, tags, api, delayMs, type, allowClear, links, footer, ...props }: DefaultSearchDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
27
28
|
//# sourceMappingURL=search-default.d.ts.map
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"search-default.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search-default.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAC;AAiB1D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE1E,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IAErB;;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,IAAS,EACT,GAAG,EACH,OAAO,EACP,IAAc,EACd,UAAkB,EAClB,KAAU,EACV,MAAM,EACN,GAAG,KAAK,EACT,EAAE,wBAAwB,2CAkE1B"}
|
|
@@ -1,24 +1,40 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useDocsSearch } from 'fumadocs-core/search/client';
|
|
4
|
-
import { useState } from 'react';
|
|
4
|
+
import { useMemo, 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, TagsListItem, } from './search.js';
|
|
8
|
-
export default function DefaultSearchDialog({ defaultTag, tags, api, delayMs, type = 'fetch', allowClear = false, ...props }) {
|
|
7
|
+
import { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogOverlay, TagsList, TagsListItem, } from './search.js';
|
|
8
|
+
export default function DefaultSearchDialog({ defaultTag, tags = [], api, delayMs, type = 'fetch', allowClear = false, links = [], footer, ...props }) {
|
|
9
9
|
const { locale } = useI18n();
|
|
10
10
|
const [tag, setTag] = useState(defaultTag);
|
|
11
11
|
const { search, setSearch, query } = useDocsSearch(type === 'fetch'
|
|
12
12
|
? {
|
|
13
13
|
type: 'fetch',
|
|
14
14
|
api,
|
|
15
|
+
locale,
|
|
16
|
+
tag,
|
|
17
|
+
delayMs,
|
|
15
18
|
}
|
|
16
19
|
: {
|
|
17
20
|
type: 'static',
|
|
18
21
|
from: api,
|
|
19
|
-
|
|
22
|
+
locale,
|
|
23
|
+
tag,
|
|
24
|
+
delayMs,
|
|
25
|
+
});
|
|
26
|
+
const defaultItems = useMemo(() => {
|
|
27
|
+
if (links.length === 0)
|
|
28
|
+
return null;
|
|
29
|
+
return links.map(([name, link]) => ({
|
|
30
|
+
type: 'page',
|
|
31
|
+
id: name,
|
|
32
|
+
content: name,
|
|
33
|
+
url: link,
|
|
34
|
+
}));
|
|
35
|
+
}, [links]);
|
|
20
36
|
useOnChange(defaultTag, (v) => {
|
|
21
37
|
setTag(v);
|
|
22
38
|
});
|
|
23
|
-
return (
|
|
39
|
+
return (_jsxs(SearchDialog, { search: search, onSearchChange: setSearch, isLoading: query.isLoading, ...props, children: [_jsx(SearchDialogOverlay, {}), _jsxs(SearchDialogContent, { children: [_jsxs(SearchDialogHeader, { children: [_jsx(SearchDialogIcon, {}), _jsx(SearchDialogInput, {}), _jsx(SearchDialogClose, {})] }), _jsx(SearchDialogList, { items: query.data !== 'empty' ? query.data : defaultItems })] }), _jsxs(SearchDialogFooter, { children: [tags.length > 0 && (_jsx(TagsList, { tag: tag, onTagChange: setTag, allowClear: allowClear, children: tags.map((tag) => (_jsx(TagsListItem, { value: tag.value, children: tag.name }, tag.value))) })), footer] })] }));
|
|
24
40
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type OramaCloudOptions } from 'fumadocs-core/search/client';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import type { SearchLink, SharedProps, TagItem } from '../../contexts/search.js';
|
|
4
4
|
export interface OramaSearchDialogProps extends SharedProps {
|
|
5
|
+
links?: SearchLink[];
|
|
5
6
|
client: OramaCloudOptions['client'];
|
|
6
7
|
searchOptions?: OramaCloudOptions['params'];
|
|
7
8
|
index?: OramaCloudOptions['index'];
|
|
@@ -24,5 +25,5 @@ export interface OramaSearchDialogProps extends SharedProps {
|
|
|
24
25
|
/**
|
|
25
26
|
* Orama Cloud integration
|
|
26
27
|
*/
|
|
27
|
-
export default function OramaSearchDialog({ client, searchOptions, tags, defaultTag, showOrama, allowClear, index, ...props }: OramaSearchDialogProps):
|
|
28
|
+
export default function OramaSearchDialog({ client, searchOptions, tags, defaultTag, showOrama, allowClear, index, footer, links, ...props }: OramaSearchDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
28
29
|
//# sourceMappingURL=search-orama.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAAqB,MAAM,OAAO,CAAC;AAgB1D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG1E,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,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,IAAS,EACT,UAAU,EACV,SAAiB,EACjB,UAAkB,EAClB,KAAK,EACL,MAAM,EACN,KAAU,EACV,GAAG,KAAK,EACT,EAAE,sBAAsB,2CAgExB"}
|
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useDocsSearch, } from 'fumadocs-core/search/client';
|
|
4
|
-
import { useState } from 'react';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
5
|
import { useOnChange } from 'fumadocs-core/utils/use-on-change';
|
|
6
|
-
import { SearchDialog, TagsList, TagsListItem, } from './search.js';
|
|
6
|
+
import { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogOverlay, TagsList, TagsListItem, } from './search.js';
|
|
7
|
+
import { useI18n } from '../../contexts/i18n.js';
|
|
7
8
|
/**
|
|
8
9
|
* Orama Cloud integration
|
|
9
10
|
*/
|
|
10
|
-
export default function OramaSearchDialog({ client, searchOptions, tags, defaultTag, showOrama = false, allowClear = false, index, ...props }) {
|
|
11
|
+
export default function OramaSearchDialog({ client, searchOptions, tags = [], defaultTag, showOrama = false, allowClear = false, index, footer, links = [], ...props }) {
|
|
12
|
+
const { locale } = useI18n();
|
|
11
13
|
const [tag, setTag] = useState(defaultTag);
|
|
12
14
|
const { search, setSearch, query } = useDocsSearch({
|
|
13
15
|
type: 'orama-cloud',
|
|
14
16
|
client,
|
|
15
17
|
index,
|
|
16
18
|
params: searchOptions,
|
|
17
|
-
|
|
19
|
+
locale,
|
|
20
|
+
tag,
|
|
21
|
+
});
|
|
22
|
+
const defaultItems = useMemo(() => {
|
|
23
|
+
if (links.length === 0)
|
|
24
|
+
return null;
|
|
25
|
+
return links.map(([name, link]) => ({
|
|
26
|
+
type: 'page',
|
|
27
|
+
id: name,
|
|
28
|
+
content: name,
|
|
29
|
+
url: link,
|
|
30
|
+
}));
|
|
31
|
+
}, [links]);
|
|
18
32
|
useOnChange(defaultTag, (v) => {
|
|
19
33
|
setTag(v);
|
|
20
34
|
});
|
|
21
|
-
|
|
35
|
+
const label = showOrama && _jsx(Label, {});
|
|
36
|
+
return (_jsxs(SearchDialog, { search: search, onSearchChange: setSearch, isLoading: query.isLoading, ...props, children: [_jsx(SearchDialogOverlay, {}), _jsxs(SearchDialogContent, { children: [_jsxs(SearchDialogHeader, { children: [_jsx(SearchDialogIcon, {}), _jsx(SearchDialogInput, {}), _jsx(SearchDialogClose, {})] }), _jsx(SearchDialogList, { items: query.data !== 'empty' ? query.data : defaultItems }), _jsxs(SearchDialogFooter, { children: [tags.length > 0 ? (_jsxs(TagsList, { tag: tag, onTagChange: setTag, allowClear: allowClear, children: [tags.map((tag) => (_jsx(TagsListItem, { value: tag.value, children: tag.name }, tag.value))), label] })) : (label), footer] })] })] }));
|
|
22
37
|
}
|
|
23
38
|
function Label() {
|
|
24
39
|
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,31 +1,43 @@
|
|
|
1
1
|
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
import { DialogContent, DialogOverlay } from '@radix-ui/react-dialog';
|
|
2
3
|
import type { SortedResult } from 'fumadocs-core/server';
|
|
3
|
-
|
|
4
|
+
import type { SharedProps } from '../../contexts/search.js';
|
|
4
5
|
type ReactSortedResult = Omit<SortedResult, 'content'> & {
|
|
5
6
|
external?: boolean;
|
|
6
7
|
content: ReactNode;
|
|
7
8
|
};
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
value: string;
|
|
11
|
-
}
|
|
12
|
-
export interface SharedProps {
|
|
13
|
-
open: boolean;
|
|
14
|
-
onOpenChange: (open: boolean) => void;
|
|
15
|
-
/**
|
|
16
|
-
* Custom links to be displayed if search is empty
|
|
17
|
-
*/
|
|
18
|
-
links?: SearchLink[];
|
|
19
|
-
}
|
|
20
|
-
interface SearchDialogProps extends SharedProps {
|
|
9
|
+
export type { SharedProps };
|
|
10
|
+
export interface SearchDialogProps extends SharedProps {
|
|
21
11
|
search: string;
|
|
22
12
|
onSearchChange: (v: string) => void;
|
|
23
13
|
isLoading?: boolean;
|
|
24
|
-
|
|
25
|
-
results: ReactSortedResult[] | 'empty';
|
|
26
|
-
footer?: ReactNode;
|
|
14
|
+
children: ReactNode;
|
|
27
15
|
}
|
|
28
|
-
export declare function SearchDialog({ open, onOpenChange,
|
|
16
|
+
export declare function SearchDialog({ open, onOpenChange, search, onSearchChange, isLoading, children, }: SearchDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function SearchDialogHeader(props: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function SearchDialogInput(props: ComponentProps<'input'>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function SearchDialogClose({ children, className, ...props }: ComponentProps<'button'>): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function SearchDialogFooter(props: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function SearchDialogOverlay(props: ComponentProps<typeof DialogOverlay>): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function SearchDialogContent({ children, ...props }: ComponentProps<typeof DialogContent>): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function SearchDialogList({ items, Empty, Item, ...props }: Omit<ComponentProps<'div'>, 'children'> & {
|
|
24
|
+
items: ReactSortedResult[] | null | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Renderer for empty list UI
|
|
27
|
+
*/
|
|
28
|
+
Empty?: () => ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Renderer for items
|
|
31
|
+
*/
|
|
32
|
+
Item?: (props: {
|
|
33
|
+
item: ReactSortedResult;
|
|
34
|
+
onClick: () => void;
|
|
35
|
+
}) => ReactNode;
|
|
36
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export declare function SearchDialogListItem({ item, className, children, ...props }: ComponentProps<'button'> & {
|
|
38
|
+
item: ReactSortedResult;
|
|
39
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
export declare function SearchDialogIcon(props: ComponentProps<'svg'>): import("react/jsx-runtime").JSX.Element;
|
|
29
41
|
export interface TagsListProps extends ComponentProps<'div'> {
|
|
30
42
|
tag?: string;
|
|
31
43
|
onTagChange: (tag: string | undefined) => void;
|
|
@@ -35,5 +47,20 @@ export declare function TagsList({ tag, onTagChange, allowClear, ...props }: Tag
|
|
|
35
47
|
export declare function TagsListItem({ value, className, ...props }: ComponentProps<'button'> & {
|
|
36
48
|
value: string;
|
|
37
49
|
}): import("react/jsx-runtime").JSX.Element;
|
|
38
|
-
export {
|
|
50
|
+
export declare function useSearch(): {
|
|
51
|
+
open: boolean;
|
|
52
|
+
onOpenChange: (open: boolean) => void;
|
|
53
|
+
search: string;
|
|
54
|
+
onSearchChange: (v: string) => void;
|
|
55
|
+
isLoading: boolean;
|
|
56
|
+
};
|
|
57
|
+
export declare function useTagsList(): {
|
|
58
|
+
value?: string;
|
|
59
|
+
onValueChange: (value: string | undefined) => void;
|
|
60
|
+
allowClear: boolean;
|
|
61
|
+
};
|
|
62
|
+
export declare function useSearchList(): {
|
|
63
|
+
active: string | null;
|
|
64
|
+
setActive: (v: string | null) => void;
|
|
65
|
+
};
|
|
39
66
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,SAAS,EAOf,MAAM,OAAO,CAAC;AAIf,OAAO,EAEL,aAAa,EACb,aAAa,EAEd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIzD,OAAO,KAAK,EAA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OAAO;EAmZpB;AAED,wBAAgB,aAAa;YA5ZnB,MAAM,GAAG,IAAI;eACV,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI;EA+ZtC"}
|
|
@@ -1,56 +1,85 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { FileText, Hash,
|
|
4
|
-
import { useCallback, useEffect, useMemo, useState, } from 'react';
|
|
5
|
-
import { useI18n } from '../../contexts/i18n.js';
|
|
3
|
+
import { FileText, Hash, Search as SearchIcon, Text, X } from '../../icons.js';
|
|
4
|
+
import { createContext, Fragment, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
5
|
+
import { I18nLabel, useI18n } from '../../contexts/i18n.js';
|
|
6
6
|
import { cn } from '../../utils/cn.js';
|
|
7
7
|
import { buttonVariants } from '../../components/ui/button.js';
|
|
8
8
|
import { Dialog, DialogContent, DialogOverlay, DialogTitle, } from '@radix-ui/react-dialog';
|
|
9
9
|
import { cva } from 'class-variance-authority';
|
|
10
10
|
import { useEffectEvent } from 'fumadocs-core/utils/use-effect-event';
|
|
11
|
-
import {
|
|
12
|
-
|
|
11
|
+
import { useRouter } from 'fumadocs-core/framework';
|
|
12
|
+
import { useOnChange } from 'fumadocs-core/utils/use-on-change';
|
|
13
|
+
const Context = createContext(null);
|
|
14
|
+
const ListContext = createContext(null);
|
|
15
|
+
const TagsListContext = createContext(null);
|
|
16
|
+
export function SearchDialog({ open, onOpenChange, search, onSearchChange, isLoading = false, children, }) {
|
|
17
|
+
const [active, setActive] = useState(null);
|
|
18
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsx(Context.Provider, { value: useMemo(() => ({
|
|
19
|
+
open,
|
|
20
|
+
onOpenChange,
|
|
21
|
+
search,
|
|
22
|
+
onSearchChange,
|
|
23
|
+
active,
|
|
24
|
+
setActive,
|
|
25
|
+
isLoading,
|
|
26
|
+
}), [active, isLoading, onOpenChange, onSearchChange, open, search]), children: children }) }));
|
|
27
|
+
}
|
|
28
|
+
export function SearchDialogHeader(props) {
|
|
29
|
+
return (_jsx("div", { ...props, className: cn('flex flex-row items-center gap-2 px-3', props.className) }));
|
|
30
|
+
}
|
|
31
|
+
export function SearchDialogInput(props) {
|
|
13
32
|
const { text } = useI18n();
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
const { search, onSearchChange } = useSearch();
|
|
34
|
+
return (_jsx("input", { ...props, value: search, onChange: (e) => onSearchChange(e.target.value), placeholder: text.search, className: "w-0 flex-1 bg-transparent py-3 text-base placeholder:text-fd-muted-foreground focus-visible:outline-none" }));
|
|
35
|
+
}
|
|
36
|
+
export function SearchDialogClose({ children = _jsx(X, {}), className, ...props }) {
|
|
37
|
+
const { onOpenChange } = useSearch();
|
|
38
|
+
return (_jsx("button", { type: "button", "aria-label": "Close", onClick: () => onOpenChange(false), className: cn(buttonVariants({
|
|
39
|
+
color: 'ghost',
|
|
40
|
+
size: 'icon-sm',
|
|
41
|
+
className: 'text-fd-muted-foreground -me-2',
|
|
42
|
+
}), className), ...props, children: children }));
|
|
43
|
+
}
|
|
44
|
+
export function SearchDialogFooter(props) {
|
|
45
|
+
return (_jsx("div", { ...props, className: cn('border-t bg-fd-secondary/50 p-3 empty:hidden', props.className) }));
|
|
46
|
+
}
|
|
47
|
+
export function SearchDialogOverlay(props) {
|
|
48
|
+
return (_jsx(DialogOverlay, { ...props, className: cn('fixed inset-0 z-50 data-[state=open]:animate-fd-fade-in data-[state=closed]:animate-fd-fade-out', props.className) }));
|
|
49
|
+
}
|
|
50
|
+
export function SearchDialogContent({ children, ...props }) {
|
|
51
|
+
const { text } = useI18n();
|
|
52
|
+
return (_jsxs(DialogContent, { "aria-describedby": undefined, ...props, className: cn('fixed left-1/2 top-[10vh] z-50 w-[98vw] max-w-screen-sm -translate-x-1/2 rounded-xl border bg-fd-popover/60 backdrop-blur-sm text-fd-popover-foreground shadow-2xl overflow-hidden shadow-black/20 data-[state=closed]:animate-fd-dialog-out data-[state=open]:animate-fd-dialog-in', props.className), children: [_jsx(DialogTitle, { className: "hidden", children: text.search }), children] }));
|
|
28
53
|
}
|
|
29
54
|
const icons = {
|
|
30
55
|
text: _jsx(Text, { className: "size-4 text-fd-muted-foreground" }),
|
|
31
56
|
heading: _jsx(Hash, { className: "size-4 text-fd-muted-foreground" }),
|
|
32
57
|
page: _jsx(FileText, { className: "size-4 text-fd-muted-foreground" }),
|
|
33
58
|
};
|
|
34
|
-
function
|
|
35
|
-
const
|
|
59
|
+
export function SearchDialogList({ items = null, Empty = () => (_jsx("div", { className: "py-12 text-center text-sm text-fd-muted-foreground", children: _jsx(I18nLabel, { label: "searchNoResult" }) })), Item = (props) => _jsx(SearchDialogListItem, { ...props }), ...props }) {
|
|
60
|
+
const ref = useRef(null);
|
|
61
|
+
const [active, setActive] = useState(() => items && items.length > 0 ? items[0].id : null);
|
|
62
|
+
const { onOpenChange } = useSearch();
|
|
36
63
|
const router = useRouter();
|
|
37
64
|
const onOpen = ({ external, url }) => {
|
|
38
65
|
if (external)
|
|
39
66
|
window.open(url, '_blank')?.focus();
|
|
40
67
|
else
|
|
41
68
|
router.push(url);
|
|
42
|
-
|
|
69
|
+
onOpenChange(false);
|
|
43
70
|
};
|
|
44
71
|
const onKey = useEffectEvent((e) => {
|
|
72
|
+
if (!items)
|
|
73
|
+
return;
|
|
45
74
|
if (e.key === 'ArrowDown' || e.key == 'ArrowUp') {
|
|
46
|
-
|
|
47
|
-
if (idx === -1)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
75
|
+
let idx = items.findIndex((item) => item.id === active);
|
|
76
|
+
if (idx === -1)
|
|
77
|
+
idx = 0;
|
|
78
|
+
else if (e.key === 'ArrowDown')
|
|
79
|
+
idx++;
|
|
80
|
+
else
|
|
81
|
+
idx--;
|
|
82
|
+
setActive(items.at(idx % items.length)?.id ?? null);
|
|
54
83
|
e.preventDefault();
|
|
55
84
|
}
|
|
56
85
|
if (e.key === 'Enter') {
|
|
@@ -61,26 +90,49 @@ function SearchResults({ items, active = items.at(0)?.id, onActiveChange, onSele
|
|
|
61
90
|
}
|
|
62
91
|
});
|
|
63
92
|
useEffect(() => {
|
|
93
|
+
const element = ref.current;
|
|
94
|
+
if (!element)
|
|
95
|
+
return;
|
|
96
|
+
const observer = new ResizeObserver(() => {
|
|
97
|
+
const viewport = element.firstElementChild;
|
|
98
|
+
element.style.setProperty('--fd-animated-height', `${viewport.clientHeight}px`);
|
|
99
|
+
});
|
|
100
|
+
const viewport = element.firstElementChild;
|
|
101
|
+
if (viewport)
|
|
102
|
+
observer.observe(viewport);
|
|
64
103
|
window.addEventListener('keydown', onKey);
|
|
65
104
|
return () => {
|
|
105
|
+
observer.disconnect();
|
|
66
106
|
window.removeEventListener('keydown', onKey);
|
|
67
107
|
};
|
|
68
108
|
}, [onKey]);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return (
|
|
109
|
+
useOnChange(items, () => {
|
|
110
|
+
if (items && items.length > 0) {
|
|
111
|
+
setActive(items[0].id);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return (_jsx("div", { ...props, ref: ref, className: cn('overflow-hidden h-(--fd-animated-height) transition-[height]', items && 'border-t', props.className), style: {
|
|
115
|
+
...props.style,
|
|
116
|
+
'--fd-animated-height': '0px',
|
|
117
|
+
}, children: _jsx("div", { className: cn('w-full flex flex-col overflow-y-auto max-h-[460px]', !items && 'hidden'), children: _jsxs(ListContext.Provider, { value: useMemo(() => ({
|
|
118
|
+
active,
|
|
119
|
+
setActive,
|
|
120
|
+
}), [active]), children: [items?.length === 0 && Empty(), items?.map((item) => (_jsx(Fragment, { children: Item({ item, onClick: () => onOpen(item) }) }, item.id)))] }) }) }));
|
|
75
121
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
122
|
+
export function SearchDialogListItem({ item, className, children, ...props }) {
|
|
123
|
+
const { active: activeId, setActive } = useSearchList();
|
|
124
|
+
const active = item.id === activeId;
|
|
125
|
+
return (_jsxs("button", { type: "button", ref: useCallback((element) => {
|
|
78
126
|
if (active && element) {
|
|
79
127
|
element.scrollIntoView({
|
|
80
128
|
block: 'nearest',
|
|
81
129
|
});
|
|
82
130
|
}
|
|
83
|
-
}, [active]),
|
|
131
|
+
}, [active]), "aria-selected": active, className: cn('flex min-h-10 select-none flex-row items-center gap-2.5 px-3 text-start text-sm', active && 'bg-fd-accent text-fd-accent-foreground', className), onPointerMove: () => setActive(item.id), ...props, children: [item.type !== 'page' && (_jsx("div", { role: "none", className: "ms-2 h-full min-h-10 w-px bg-fd-border" })), icons[item.type], _jsx("p", { className: "w-0 flex-1 truncate", children: children ?? item.content })] }));
|
|
132
|
+
}
|
|
133
|
+
export function SearchDialogIcon(props) {
|
|
134
|
+
const { isLoading } = useSearch();
|
|
135
|
+
return (_jsx(SearchIcon, { ...props, className: cn('size-4.5 text-fd-muted-foreground', isLoading && 'animate-pulse duration-400', props.className) }));
|
|
84
136
|
}
|
|
85
137
|
const itemVariants = cva('rounded-md border px-2 py-0.5 text-xs font-medium text-fd-muted-foreground transition-colors', {
|
|
86
138
|
variants: {
|
|
@@ -89,7 +141,6 @@ const itemVariants = cva('rounded-md border px-2 py-0.5 text-xs font-medium text
|
|
|
89
141
|
},
|
|
90
142
|
},
|
|
91
143
|
});
|
|
92
|
-
const TagsListContext = createContext('TagsList');
|
|
93
144
|
export function TagsList({ tag, onTagChange, allowClear = false, ...props }) {
|
|
94
145
|
return (_jsx("div", { ...props, className: cn('flex items-center gap-1 flex-wrap', props.className), children: _jsx(TagsListContext.Provider, { value: useMemo(() => ({
|
|
95
146
|
value: tag,
|
|
@@ -98,8 +149,27 @@ export function TagsList({ tag, onTagChange, allowClear = false, ...props }) {
|
|
|
98
149
|
}), [allowClear, onTagChange, tag]), children: props.children }) }));
|
|
99
150
|
}
|
|
100
151
|
export function TagsListItem({ value, className, ...props }) {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
152
|
+
const { onValueChange, value: selectedValue, allowClear } = useTagsList();
|
|
153
|
+
const selected = value === selectedValue;
|
|
154
|
+
return (_jsx("button", { type: "button", "data-active": selected, className: cn(itemVariants({ active: selected, className })), onClick: () => {
|
|
155
|
+
onValueChange(selected && allowClear ? undefined : value);
|
|
104
156
|
}, tabIndex: -1, ...props, children: props.children }));
|
|
105
157
|
}
|
|
158
|
+
export function useSearch() {
|
|
159
|
+
const ctx = useContext(Context);
|
|
160
|
+
if (!ctx)
|
|
161
|
+
throw new Error('Missing <SearchDialog />');
|
|
162
|
+
return ctx;
|
|
163
|
+
}
|
|
164
|
+
export function useTagsList() {
|
|
165
|
+
const ctx = useContext(TagsListContext);
|
|
166
|
+
if (!ctx)
|
|
167
|
+
throw new Error('Missing <TagsList />');
|
|
168
|
+
return ctx;
|
|
169
|
+
}
|
|
170
|
+
export function useSearchList() {
|
|
171
|
+
const ctx = useContext(ListContext);
|
|
172
|
+
if (!ctx)
|
|
173
|
+
throw new Error('Missing <SearchDialogList />');
|
|
174
|
+
return ctx;
|
|
175
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import
|
|
3
|
-
export interface TabsProps extends
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
import * as Primitive from './ui/tabs.js';
|
|
3
|
+
export interface TabsProps extends ComponentProps<typeof Primitive.Tabs> {
|
|
4
4
|
/**
|
|
5
5
|
* Identifier for Sharing value of tabs
|
|
6
6
|
*/
|
|
@@ -30,13 +30,13 @@ export interface TabsProps extends BaseProps {
|
|
|
30
30
|
}
|
|
31
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
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;
|
|
34
|
-
export
|
|
33
|
+
export declare function Tabs({ ref, className, groupId, items, persist, label, defaultIndex, updateAnchor, defaultValue, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export interface TabProps extends Omit<ComponentProps<typeof Primitive.TabsContent>, 'value'> {
|
|
35
35
|
/**
|
|
36
36
|
* Value of tab, detect from index if unspecified.
|
|
37
37
|
*/
|
|
38
38
|
value?: string;
|
|
39
|
-
}
|
|
39
|
+
}
|
|
40
40
|
export declare function Tab({ value, ...props }: TabProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
-
export declare function TabsContent({ value, className, ...props }:
|
|
41
|
+
export declare function TabsContent({ value, className, ...props }: ComponentProps<typeof Primitive.TabsContent>): import("react/jsx-runtime").JSX.Element;
|
|
42
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,
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/components/tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,SAAS,EAQf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AAsBvC,MAAM,WAAW,SAAU,SAA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