@curvenote/theme-ui 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +3 -0
- package/dist/components/layout/app-layout.d.ts +8 -0
- package/dist/components/layout/app-layout.d.ts.map +1 -0
- package/dist/components/layout/app-layout.js +24 -0
- package/dist/components/layout/app-sidebar.d.ts +2 -0
- package/dist/components/layout/app-sidebar.d.ts.map +1 -0
- package/dist/components/layout/app-sidebar.js +125 -0
- package/dist/components/layout/article-layout.d.ts +8 -0
- package/dist/components/layout/article-layout.d.ts.map +1 -0
- package/dist/components/layout/article-layout.js +20 -0
- package/dist/components/layout/grid.d.ts +2 -0
- package/dist/components/layout/grid.d.ts.map +1 -0
- package/dist/components/layout/grid.js +4 -0
- package/dist/components/layout/header.d.ts +5 -0
- package/dist/components/layout/header.d.ts.map +1 -0
- package/dist/components/layout/header.js +5 -0
- package/dist/components/layout/index.d.ts +7 -0
- package/dist/components/layout/index.d.ts.map +1 -0
- package/dist/components/layout/index.js +7 -0
- package/dist/components/layout/loading-bar.d.ts +12 -0
- package/dist/components/layout/loading-bar.d.ts.map +1 -0
- package/dist/components/layout/loading-bar.js +53 -0
- package/dist/components/layout/site-header.d.ts +8 -0
- package/dist/components/layout/site-header.d.ts.map +1 -0
- package/dist/components/layout/site-header.js +55 -0
- package/dist/components/layout/types.d.ts +6 -0
- package/dist/components/layout/types.d.ts.map +1 -0
- package/dist/components/layout/types.js +1 -0
- package/dist/components/providers/compute.d.ts +5 -0
- package/dist/components/providers/compute.d.ts.map +1 -0
- package/dist/components/providers/compute.js +6 -0
- package/dist/components/providers/connect.d.ts +24 -0
- package/dist/components/providers/connect.d.ts.map +1 -0
- package/dist/components/providers/connect.js +208 -0
- package/dist/components/providers/curvenote-providers.d.ts +52 -0
- package/dist/components/providers/curvenote-providers.d.ts.map +1 -0
- package/dist/components/providers/curvenote-providers.js +199 -0
- package/dist/components/providers/design.d.ts +39 -0
- package/dist/components/providers/design.d.ts.map +1 -0
- package/dist/components/providers/design.js +50 -0
- package/dist/components/providers/index.d.ts +10 -0
- package/dist/components/providers/index.d.ts.map +1 -0
- package/dist/components/providers/index.js +12 -0
- package/dist/components/providers/lightbox-provider.d.ts +31 -0
- package/dist/components/providers/lightbox-provider.d.ts.map +1 -0
- package/dist/components/providers/lightbox-provider.js +109 -0
- package/dist/components/providers/myst-providers.d.ts +6 -0
- package/dist/components/providers/myst-providers.d.ts.map +1 -0
- package/dist/components/providers/myst-providers.js +29 -0
- package/dist/components/providers/page-providers.d.ts +15 -0
- package/dist/components/providers/page-providers.d.ts.map +1 -0
- package/dist/components/providers/page-providers.js +28 -0
- package/dist/components/providers/ping-boundary.d.ts +40 -0
- package/dist/components/providers/ping-boundary.d.ts.map +1 -0
- package/dist/components/providers/ping-boundary.js +115 -0
- package/dist/components/providers/platform-providers.d.ts +18 -0
- package/dist/components/providers/platform-providers.d.ts.map +1 -0
- package/dist/components/providers/platform-providers.js +29 -0
- package/dist/components/providers/types.d.ts +30 -0
- package/dist/components/providers/types.d.ts.map +1 -0
- package/dist/components/providers/types.js +1 -0
- package/dist/components/ui/Callout.d.ts +10 -0
- package/dist/components/ui/Callout.d.ts.map +1 -0
- package/dist/components/ui/Callout.js +7 -0
- package/dist/components/ui/PageCards.d.ts +2 -0
- package/dist/components/ui/PageCards.d.ts.map +1 -0
- package/dist/components/ui/PageCards.js +11 -0
- package/dist/components/ui/abbreviations.d.ts +5 -0
- package/dist/components/ui/abbreviations.d.ts.map +1 -0
- package/dist/components/ui/abbreviations.js +31 -0
- package/dist/components/ui/abstract.d.ts +8 -0
- package/dist/components/ui/abstract.d.ts.map +1 -0
- package/dist/components/ui/abstract.js +9 -0
- package/dist/components/ui/accessibility-skip-to.d.ts +15 -0
- package/dist/components/ui/accessibility-skip-to.d.ts.map +1 -0
- package/dist/components/ui/accessibility-skip-to.js +31 -0
- package/dist/components/ui/acknowledgements.d.ts +4 -0
- package/dist/components/ui/acknowledgements.d.ts.map +1 -0
- package/dist/components/ui/acknowledgements.js +20 -0
- package/dist/components/ui/article-actions-downloads.d.ts +26 -0
- package/dist/components/ui/article-actions-downloads.d.ts.map +1 -0
- package/dist/components/ui/article-actions-downloads.js +143 -0
- package/dist/components/ui/article-actions-dropdown.d.ts +5 -0
- package/dist/components/ui/article-actions-dropdown.d.ts.map +1 -0
- package/dist/components/ui/article-actions-dropdown.js +68 -0
- package/dist/components/ui/article-actions-share.d.ts +5 -0
- package/dist/components/ui/article-actions-share.d.ts.map +1 -0
- package/dist/components/ui/article-actions-share.js +52 -0
- package/dist/components/ui/article-actions.d.ts +2 -0
- package/dist/components/ui/article-actions.d.ts.map +1 -0
- package/dist/components/ui/article-actions.js +20 -0
- package/dist/components/ui/article-bar.d.ts +8 -0
- package/dist/components/ui/article-bar.d.ts.map +1 -0
- package/dist/components/ui/article-bar.js +32 -0
- package/dist/components/ui/article-card.d.ts +12 -0
- package/dist/components/ui/article-card.d.ts.map +1 -0
- package/dist/components/ui/article-card.js +22 -0
- package/dist/components/ui/article-footer.d.ts +2 -0
- package/dist/components/ui/article-footer.d.ts.map +1 -0
- package/dist/components/ui/article-footer.js +7 -0
- package/dist/components/ui/author-popover.d.ts +7 -0
- package/dist/components/ui/author-popover.d.ts.map +1 -0
- package/dist/components/ui/author-popover.js +36 -0
- package/dist/components/ui/backmatter.d.ts +9 -0
- package/dist/components/ui/backmatter.d.ts.map +1 -0
- package/dist/components/ui/backmatter.js +49 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +23 -0
- package/dist/components/ui/banner.d.ts +7 -0
- package/dist/components/ui/banner.d.ts.map +1 -0
- package/dist/components/ui/banner.js +44 -0
- package/dist/components/ui/bibliography.d.ts +6 -0
- package/dist/components/ui/bibliography.d.ts.map +1 -0
- package/dist/components/ui/bibliography.js +20 -0
- package/dist/components/ui/breadcrumb.d.ts +12 -0
- package/dist/components/ui/breadcrumb.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb.js +28 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +33 -0
- package/dist/components/ui/citation.d.ts +7 -0
- package/dist/components/ui/citation.d.ts.map +1 -0
- package/dist/components/ui/citation.js +99 -0
- package/dist/components/ui/collapsible.d.ts +6 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +12 -0
- package/dist/components/ui/cookie-banner.d.ts +8 -0
- package/dist/components/ui/cookie-banner.d.ts.map +1 -0
- package/dist/components/ui/cookie-banner.js +31 -0
- package/dist/components/ui/data-availability.d.ts +4 -0
- package/dist/components/ui/data-availability.d.ts.map +1 -0
- package/dist/components/ui/data-availability.js +20 -0
- package/dist/components/ui/dialog.d.ts +16 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +36 -0
- package/dist/components/ui/document-outline.d.ts +8 -0
- package/dist/components/ui/document-outline.d.ts.map +1 -0
- package/dist/components/ui/document-outline.js +168 -0
- package/dist/components/ui/dropdown-menu.d.ts +26 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +51 -0
- package/dist/components/ui/error-page.d.ts +9 -0
- package/dist/components/ui/error-page.d.ts.map +1 -0
- package/dist/components/ui/error-page.js +21 -0
- package/dist/components/ui/footer-links.d.ts +14 -0
- package/dist/components/ui/footer-links.d.ts.map +1 -0
- package/dist/components/ui/footer-links.js +18 -0
- package/dist/components/ui/footnotes.d.ts +4 -0
- package/dist/components/ui/footnotes.d.ts.map +1 -0
- package/dist/components/ui/footnotes.js +30 -0
- package/dist/components/ui/frontmatter-badges.d.ts +27 -0
- package/dist/components/ui/frontmatter-badges.d.ts.map +1 -0
- package/dist/components/ui/frontmatter-badges.js +60 -0
- package/dist/components/ui/frontmatter.d.ts +7 -0
- package/dist/components/ui/frontmatter.d.ts.map +1 -0
- package/dist/components/ui/frontmatter.js +6 -0
- package/dist/components/ui/image.d.ts +34 -0
- package/dist/components/ui/image.d.ts.map +1 -0
- package/dist/components/ui/image.js +83 -0
- package/dist/components/ui/index.d.ts +50 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +56 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +7 -0
- package/dist/components/ui/license-description.d.ts +4 -0
- package/dist/components/ui/license-description.d.ts.map +1 -0
- package/dist/components/ui/license-description.js +63 -0
- package/dist/components/ui/license-frontmatter.d.ts +22 -0
- package/dist/components/ui/license-frontmatter.d.ts.map +1 -0
- package/dist/components/ui/license-frontmatter.js +37 -0
- package/dist/components/ui/lightbox-container.d.ts +11 -0
- package/dist/components/ui/lightbox-container.d.ts.map +1 -0
- package/dist/components/ui/lightbox-container.js +13 -0
- package/dist/components/ui/lightbox.d.ts +17 -0
- package/dist/components/ui/lightbox.d.ts.map +1 -0
- package/dist/components/ui/lightbox.js +129 -0
- package/dist/components/ui/link-card.d.ts +15 -0
- package/dist/components/ui/link-card.d.ts.map +1 -0
- package/dist/components/ui/link-card.js +28 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +17 -0
- package/dist/components/ui/search.d.ts +9 -0
- package/dist/components/ui/search.d.ts.map +1 -0
- package/dist/components/ui/search.js +290 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +8 -0
- package/dist/components/ui/sheet.d.ts +14 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sheet.js +40 -0
- package/dist/components/ui/sidebar.d.ts +67 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +202 -0
- package/dist/components/ui/skeleton.d.ts +3 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +6 -0
- package/dist/components/ui/sonner.d.ts +5 -0
- package/dist/components/ui/sonner.d.ts.map +1 -0
- package/dist/components/ui/sonner.js +13 -0
- package/dist/components/ui/theme-button.d.ts +2 -0
- package/dist/components/ui/theme-button.d.ts.map +1 -0
- package/dist/components/ui/theme-button.js +9 -0
- package/dist/components/ui/tooltip.d.ts +13 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +20 -0
- package/dist/components/ui/types.d.ts +11 -0
- package/dist/components/ui/types.d.ts.map +1 -0
- package/dist/components/ui/types.js +10 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/use-hydrated.d.ts +2 -0
- package/dist/hooks/use-hydrated.d.ts.map +1 -0
- package/dist/hooks/use-hydrated.js +6 -0
- package/dist/hooks/use-image-load.d.ts +14 -0
- package/dist/hooks/use-image-load.d.ts.map +1 -0
- package/dist/hooks/use-image-load.js +41 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +15 -0
- package/dist/hooks/use-theme.d.ts +6 -0
- package/dist/hooks/use-theme.d.ts.map +1 -0
- package/dist/hooks/use-theme.js +23 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/lib/checkMecaExport.d.ts +5 -0
- package/dist/lib/checkMecaExport.d.ts.map +1 -0
- package/dist/lib/checkMecaExport.js +4 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +6 -0
- package/dist/lib/knownParts.d.ts +12 -0
- package/dist/lib/knownParts.d.ts.map +1 -0
- package/dist/lib/knownParts.js +14 -0
- package/dist/lib/links.d.ts +3 -0
- package/dist/lib/links.d.ts.map +1 -0
- package/dist/lib/links.js +7 -0
- package/dist/lib/parse-date.d.ts +2 -0
- package/dist/lib/parse-date.d.ts.map +1 -0
- package/dist/lib/parse-date.js +7 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +5 -0
- package/package.json +67 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useReferences } from '@myst-theme/providers';
|
|
4
|
+
import { SKIP, visit } from 'unist-util-visit';
|
|
5
|
+
import { select, selectAll } from 'unist-util-select';
|
|
6
|
+
export function useImages({ mdast }) {
|
|
7
|
+
const article = useReferences();
|
|
8
|
+
const content = mdast ?? article?.article;
|
|
9
|
+
if (!content)
|
|
10
|
+
return [];
|
|
11
|
+
const allImages = [];
|
|
12
|
+
visit(content, (node) => {
|
|
13
|
+
// Track container entry/exit
|
|
14
|
+
if (node.type === 'container') {
|
|
15
|
+
if ('kind' in node && node.kind === 'figure') {
|
|
16
|
+
const images = selectAll('image', node);
|
|
17
|
+
const caption = select('caption', node);
|
|
18
|
+
images.forEach((image) => {
|
|
19
|
+
allImages.push({
|
|
20
|
+
src: image.url,
|
|
21
|
+
srcOptimized: image.urlOptimized,
|
|
22
|
+
urlSource: image.urlSource,
|
|
23
|
+
alt: image.alt,
|
|
24
|
+
caption,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return SKIP;
|
|
29
|
+
}
|
|
30
|
+
// Process images
|
|
31
|
+
if (node.type === 'image') {
|
|
32
|
+
const imageNode = node;
|
|
33
|
+
allImages.push({
|
|
34
|
+
src: imageNode.url,
|
|
35
|
+
srcOptimized: imageNode.urlOptimized,
|
|
36
|
+
urlSource: imageNode.urlSource,
|
|
37
|
+
alt: imageNode.alt,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return allImages;
|
|
42
|
+
}
|
|
43
|
+
const LightboxContext = React.createContext(undefined);
|
|
44
|
+
export function LightboxProvider({ children, imageList: initialImageList = [], }) {
|
|
45
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
46
|
+
const [currentImage, setCurrentImage] = React.useState(null);
|
|
47
|
+
const [imageList, setImageList] = React.useState(initialImageList);
|
|
48
|
+
const [currentIndex, setCurrentIndex] = React.useState(0);
|
|
49
|
+
// Update imageList when initialImageList changes
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
setImageList(initialImageList);
|
|
52
|
+
}, [initialImageList]);
|
|
53
|
+
const openLightbox = React.useCallback((image) => {
|
|
54
|
+
// Find index by matching src
|
|
55
|
+
const index = imageList.findIndex((img) => img.src === image.src);
|
|
56
|
+
setCurrentImage(index >= 0 ? imageList[index] : image);
|
|
57
|
+
setCurrentIndex(index >= 0 ? index : 0);
|
|
58
|
+
setIsOpen(true);
|
|
59
|
+
}, [imageList]);
|
|
60
|
+
const closeLightbox = React.useCallback(() => {
|
|
61
|
+
setIsOpen(false);
|
|
62
|
+
setCurrentImage(null);
|
|
63
|
+
setCurrentIndex(0);
|
|
64
|
+
}, []);
|
|
65
|
+
const navigate = React.useCallback((direction) => {
|
|
66
|
+
if (imageList.length === 0)
|
|
67
|
+
return;
|
|
68
|
+
let newIndex;
|
|
69
|
+
if (direction === 'prev') {
|
|
70
|
+
newIndex = currentIndex > 0 ? currentIndex - 1 : imageList.length - 1;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
newIndex = currentIndex < imageList.length - 1 ? currentIndex + 1 : 0;
|
|
74
|
+
}
|
|
75
|
+
setCurrentIndex(newIndex);
|
|
76
|
+
setCurrentImage(imageList[newIndex]);
|
|
77
|
+
}, [currentIndex, imageList]);
|
|
78
|
+
const hasNext = imageList.length > 1;
|
|
79
|
+
const hasPrev = imageList.length > 1;
|
|
80
|
+
const value = React.useMemo(() => ({
|
|
81
|
+
isOpen,
|
|
82
|
+
currentImage,
|
|
83
|
+
imageList,
|
|
84
|
+
currentIndex,
|
|
85
|
+
openLightbox,
|
|
86
|
+
closeLightbox,
|
|
87
|
+
navigate,
|
|
88
|
+
hasNext,
|
|
89
|
+
hasPrev,
|
|
90
|
+
}), [
|
|
91
|
+
isOpen,
|
|
92
|
+
currentImage,
|
|
93
|
+
imageList,
|
|
94
|
+
currentIndex,
|
|
95
|
+
openLightbox,
|
|
96
|
+
closeLightbox,
|
|
97
|
+
navigate,
|
|
98
|
+
hasNext,
|
|
99
|
+
hasPrev,
|
|
100
|
+
]);
|
|
101
|
+
return _jsx(LightboxContext.Provider, { value: value, children: children });
|
|
102
|
+
}
|
|
103
|
+
export function useLightbox() {
|
|
104
|
+
const context = React.useContext(LightboxContext);
|
|
105
|
+
if (context === undefined) {
|
|
106
|
+
throw new Error('useLightbox must be used within a LightboxProvider');
|
|
107
|
+
}
|
|
108
|
+
return context;
|
|
109
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type NodeRenderers } from '@myst-theme/providers';
|
|
2
|
+
export declare function MystProviders({ children, renderers, }: {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
renderers: NodeRenderers;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=myst-providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"myst-providers.d.ts","sourceRoot":"","sources":["../../../src/components/providers/myst-providers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AA0B/B,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,EAAE,aAAa,CAAC;CAC1B,2CAkBA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SearchFactoryProvider, TabStateProvider, Theme, ThemeProvider, UiStateProvider, } from '@myst-theme/providers';
|
|
3
|
+
// import { curvenoteRenderers } from '@curvenote/renderers';
|
|
4
|
+
import { Link, NavLink } from 'react-router';
|
|
5
|
+
import { useTheme } from 'next-themes';
|
|
6
|
+
import { useCallback } from 'react';
|
|
7
|
+
import { SEARCH_ATTRIBUTES_ORDERED } from '@myst-theme/search';
|
|
8
|
+
import { createSearch as createMiniSearch } from '@myst-theme/search-minisearch';
|
|
9
|
+
const links = {
|
|
10
|
+
Link: (props) => _jsx(Link, { ...props, reloadDocument: true }),
|
|
11
|
+
NavLink: (props) => _jsx(NavLink, { ...props, reloadDocument: true }),
|
|
12
|
+
};
|
|
13
|
+
function createSearch(index) {
|
|
14
|
+
const options = {
|
|
15
|
+
fields: SEARCH_ATTRIBUTES_ORDERED,
|
|
16
|
+
storeFields: ['hierarchy', 'content', 'url', 'type', 'id', 'position'],
|
|
17
|
+
idField: 'id',
|
|
18
|
+
searchOptions: {
|
|
19
|
+
fuzzy: 0.1,
|
|
20
|
+
prefix: true,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
return createMiniSearch(index.records, options);
|
|
24
|
+
}
|
|
25
|
+
export function MystProviders({ children, renderers, }) {
|
|
26
|
+
const { theme } = useTheme();
|
|
27
|
+
const searchFactory = useCallback((index) => createSearch(index), []);
|
|
28
|
+
return (_jsx(SearchFactoryProvider, { factory: searchFactory, children: _jsx(ThemeProvider, { theme: theme === 'dark' ? Theme.dark : Theme.light, setTheme: () => { }, renderers: renderers, ...links, top: 60, children: _jsx(UiStateProvider, { children: _jsx(TabStateProvider, { children: children }) }) }) }));
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PageLoader } from '@myst-theme/common';
|
|
2
|
+
import type { SiteManifest } from 'myst-config';
|
|
3
|
+
export declare function PageProvider({ children, page }: {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
page: PageLoader;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function usePage(): PageLoader;
|
|
8
|
+
export declare function useIsIndexPage(): boolean;
|
|
9
|
+
export declare function PageProviders({ children, page, config, project, }: {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
page: PageLoader;
|
|
12
|
+
config?: SiteManifest;
|
|
13
|
+
project?: string | undefined;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=page-providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-providers.d.ts","sourceRoot":"","sources":["../../../src/components/providers/page-providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAOrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,2CAE/F;AAED,wBAAgB,OAAO,IAAI,UAAU,CAIpC;AAED,wBAAgB,cAAc,IAAI,OAAO,CAIxC;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,2CAqBA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ArticleProvider, ProjectProvider, SiteProvider, useProjectManifest, } from '@myst-theme/providers';
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
const PageContext = createContext(undefined);
|
|
5
|
+
export function PageProvider({ children, page }) {
|
|
6
|
+
return _jsx(PageContext.Provider, { value: page, children: children });
|
|
7
|
+
}
|
|
8
|
+
export function usePage() {
|
|
9
|
+
const page = useContext(PageContext);
|
|
10
|
+
if (!page)
|
|
11
|
+
throw new Error('usePage must be used within a PageProvider');
|
|
12
|
+
return page;
|
|
13
|
+
}
|
|
14
|
+
export function useIsIndexPage() {
|
|
15
|
+
const page = usePage();
|
|
16
|
+
const project = useProjectManifest();
|
|
17
|
+
return page.slug === project?.index;
|
|
18
|
+
}
|
|
19
|
+
export function PageProviders({ children, page, config, project, }) {
|
|
20
|
+
let projectManifest = config?.projects?.[0];
|
|
21
|
+
if (project) {
|
|
22
|
+
projectManifest = config?.projects?.find((p) => p.slug === project);
|
|
23
|
+
if (!projectManifest) {
|
|
24
|
+
throw new Error(`Project ${project} not found`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return (_jsx(PageProvider, { page: page, children: _jsx(ArticleProvider, { references: { ...page.references, article: page.mdast }, kind: page.kind, frontmatter: page.frontmatter, children: _jsx(SiteProvider, { config: config, children: _jsx(ProjectProvider, { project: projectManifest, children: children }) }) }) }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PingFn, PingPayload } from '@curvenote/bridge-jupyter';
|
|
2
|
+
/**
|
|
3
|
+
* A provider that provides a ping function to send ping events to the server.
|
|
4
|
+
*
|
|
5
|
+
* @param csrfToken The CSRF token to include in the ping requests
|
|
6
|
+
* @param children The children to render
|
|
7
|
+
* @example
|
|
8
|
+
* <PingBoundary csrfToken="csrf-token">
|
|
9
|
+
* <App />
|
|
10
|
+
* </PingBoundary>
|
|
11
|
+
* @see usePingFn
|
|
12
|
+
* @see usePingOnNavigate
|
|
13
|
+
* @see makePingFn
|
|
14
|
+
* @see PingFn
|
|
15
|
+
* @see LogBoundary
|
|
16
|
+
*/
|
|
17
|
+
export declare function PingBoundary({ csrfToken, children, }: React.PropsWithChildren<{
|
|
18
|
+
csrfToken: string;
|
|
19
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
/**
|
|
21
|
+
* A hook to get the ping function from the PingBoundary context.
|
|
22
|
+
* Is additionalPayload is provided, it will be merged with the payload of the ping event
|
|
23
|
+
* in a curried function.
|
|
24
|
+
*
|
|
25
|
+
* @returns The ping function
|
|
26
|
+
*/
|
|
27
|
+
export declare function usePingFn(additionalPayload?: Omit<PingPayload, 'event'>): PingFn;
|
|
28
|
+
/**
|
|
29
|
+
* A hook to send a ping event on every navigation event.
|
|
30
|
+
* It uses the useLocation hook from Remix to detect navigation events.
|
|
31
|
+
*
|
|
32
|
+
* @param payload The payload to send with the ping event
|
|
33
|
+
* @example
|
|
34
|
+
* usePingOnNavigate({ workVersionId: 'uuid-v7', slug: 'article-slug' });
|
|
35
|
+
* @see PingBoundary
|
|
36
|
+
* @see makePingFn
|
|
37
|
+
* @see PingPayload
|
|
38
|
+
*/
|
|
39
|
+
export declare function usePingOnNavigate(payload?: Omit<PingPayload, 'event'>, skip?: boolean): void;
|
|
40
|
+
//# sourceMappingURL=ping-boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping-boundary.d.ts","sourceRoot":"","sources":["../../../src/components/providers/ping-boundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAsDrE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC,2CAQD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,UAkBvE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE,IAAI,UAAQ,QAWnF"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useLocation } from 'react-router';
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useMemo } from 'react';
|
|
4
|
+
const PingBoundaryContext = createContext(undefined);
|
|
5
|
+
/**
|
|
6
|
+
* Make a ping function that sends a POST request to the ping service URL
|
|
7
|
+
* with the given payload.
|
|
8
|
+
* @param pingServiceUrl The URL of the ping service
|
|
9
|
+
* @param site The site configuration
|
|
10
|
+
* @param csrfToken The CSRF token to include in the request
|
|
11
|
+
* @returns A function that sends a ping request
|
|
12
|
+
* @example
|
|
13
|
+
* const ping = makePingFn('/api/ping', 'csrf-token');
|
|
14
|
+
* ping({ event: 'navigate' });
|
|
15
|
+
*/
|
|
16
|
+
function makePingFn(pingServiceUrl, csrfToken) {
|
|
17
|
+
return async function ping(payload) {
|
|
18
|
+
if (!pingServiceUrl) {
|
|
19
|
+
console.debug('No ping service URL provided');
|
|
20
|
+
console.log('ping', payload);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const response = await fetch(pingServiceUrl, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
body: JSON.stringify({
|
|
27
|
+
...payload,
|
|
28
|
+
title: document.title,
|
|
29
|
+
pathname: window.location.pathname,
|
|
30
|
+
search: window.location.search,
|
|
31
|
+
hash: window.location.hash,
|
|
32
|
+
url: window.location.href,
|
|
33
|
+
csrfToken,
|
|
34
|
+
}),
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
throw new Error(`HTTP error! status: ${response.status} ${response.statusText}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error(error);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A provider that provides a ping function to send ping events to the server.
|
|
50
|
+
*
|
|
51
|
+
* @param csrfToken The CSRF token to include in the ping requests
|
|
52
|
+
* @param children The children to render
|
|
53
|
+
* @example
|
|
54
|
+
* <PingBoundary csrfToken="csrf-token">
|
|
55
|
+
* <App />
|
|
56
|
+
* </PingBoundary>
|
|
57
|
+
* @see usePingFn
|
|
58
|
+
* @see usePingOnNavigate
|
|
59
|
+
* @see makePingFn
|
|
60
|
+
* @see PingFn
|
|
61
|
+
* @see LogBoundary
|
|
62
|
+
*/
|
|
63
|
+
export function PingBoundary({ csrfToken, children, }) {
|
|
64
|
+
const value = useMemo(() => {
|
|
65
|
+
return {
|
|
66
|
+
ping: makePingFn('/api/ping', csrfToken),
|
|
67
|
+
};
|
|
68
|
+
}, [csrfToken]);
|
|
69
|
+
return _jsx(PingBoundaryContext.Provider, { value: value, children: children });
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A hook to get the ping function from the PingBoundary context.
|
|
73
|
+
* Is additionalPayload is provided, it will be merged with the payload of the ping event
|
|
74
|
+
* in a curried function.
|
|
75
|
+
*
|
|
76
|
+
* @returns The ping function
|
|
77
|
+
*/
|
|
78
|
+
export function usePingFn(additionalPayload) {
|
|
79
|
+
const context = useContext(PingBoundaryContext);
|
|
80
|
+
const pingFn = useCallback((payload) => {
|
|
81
|
+
if (context) {
|
|
82
|
+
return context?.ping({
|
|
83
|
+
...payload,
|
|
84
|
+
...additionalPayload,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
console.warn('No ping service available');
|
|
88
|
+
return Promise.resolve();
|
|
89
|
+
}, [context, additionalPayload]);
|
|
90
|
+
return pingFn;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A hook to send a ping event on every navigation event.
|
|
94
|
+
* It uses the useLocation hook from Remix to detect navigation events.
|
|
95
|
+
*
|
|
96
|
+
* @param payload The payload to send with the ping event
|
|
97
|
+
* @example
|
|
98
|
+
* usePingOnNavigate({ workVersionId: 'uuid-v7', slug: 'article-slug' });
|
|
99
|
+
* @see PingBoundary
|
|
100
|
+
* @see makePingFn
|
|
101
|
+
* @see PingPayload
|
|
102
|
+
*/
|
|
103
|
+
export function usePingOnNavigate(payload, skip = false) {
|
|
104
|
+
const context = useContext(PingBoundaryContext);
|
|
105
|
+
const ping = context?.ping;
|
|
106
|
+
const location = useLocation();
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (!ping || skip)
|
|
109
|
+
return;
|
|
110
|
+
ping({
|
|
111
|
+
event: 'navigate',
|
|
112
|
+
...payload,
|
|
113
|
+
});
|
|
114
|
+
}, [location]);
|
|
115
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SiteManifest } from 'myst-config';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { Site } from '@curvenote/common';
|
|
4
|
+
import type { JournalTheme } from './types';
|
|
5
|
+
export declare const defaultTheme: JournalTheme;
|
|
6
|
+
export declare function PlatformSiteProvider({ site, config, children, }: {
|
|
7
|
+
site?: Site;
|
|
8
|
+
config?: SiteManifest;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function usePlatformSite(): Partial<Site>;
|
|
12
|
+
export declare function usePlatformConfig(): Partial<SiteManifest>;
|
|
13
|
+
export declare function PlatformThemeProvider({ theme, children, }: {
|
|
14
|
+
theme: JournalTheme;
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function usePlatformTheme(): JournalTheme;
|
|
18
|
+
//# sourceMappingURL=platform-providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-providers.d.ts","sourceRoot":"","sources":["../../../src/components/providers/platform-providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,eAAO,MAAM,YAAY,EAAE,YAI1B,CAAC;AASF,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,MAAM,EACN,QAAQ,GACT,EAAE;IACD,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CAMA;AAED,wBAAgB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAG/C;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,YAAY,CAAC,CAGzD;AAID,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CAEA;AAED,wBAAgB,gBAAgB,IAAI,YAAY,CAI/C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { createContext, useContext } from 'react';
|
|
3
|
+
import { SiteProvider } from '@myst-theme/providers';
|
|
4
|
+
export const defaultTheme = {
|
|
5
|
+
config: {
|
|
6
|
+
name: 'theme-one',
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
const PlatformSiteContext = createContext(undefined);
|
|
10
|
+
export function PlatformSiteProvider({ site, config, children, }) {
|
|
11
|
+
return (_jsx(PlatformSiteContext.Provider, { value: { site, config }, children: _jsx(SiteProvider, { config: config, children: children }) }));
|
|
12
|
+
}
|
|
13
|
+
export function usePlatformSite() {
|
|
14
|
+
const site = useContext(PlatformSiteContext)?.site ?? {};
|
|
15
|
+
return site;
|
|
16
|
+
}
|
|
17
|
+
export function usePlatformConfig() {
|
|
18
|
+
const config = useContext(PlatformSiteContext)?.config ?? {};
|
|
19
|
+
return config;
|
|
20
|
+
}
|
|
21
|
+
const PlatformThemeContext = createContext(undefined);
|
|
22
|
+
export function PlatformThemeProvider({ theme, children, }) {
|
|
23
|
+
return _jsx(PlatformThemeContext.Provider, { value: theme, children: children });
|
|
24
|
+
}
|
|
25
|
+
export function usePlatformTheme() {
|
|
26
|
+
// TODO need to watch out for the base theme to loaded theme transition causing flicker
|
|
27
|
+
const context = useContext(PlatformThemeContext) ?? defaultTheme;
|
|
28
|
+
return context;
|
|
29
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { JournalThemeConfig } from '@curvenote/common';
|
|
2
|
+
import type { PageFrontmatter } from 'myst-frontmatter';
|
|
3
|
+
export type BreadCrumbData = {
|
|
4
|
+
title: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
}[];
|
|
7
|
+
export interface JournalTheme {
|
|
8
|
+
config: JournalThemeConfig;
|
|
9
|
+
Footer?: React.FC;
|
|
10
|
+
Hero?: React.FC<{
|
|
11
|
+
title?: React.ReactNode;
|
|
12
|
+
description?: React.ReactNode;
|
|
13
|
+
}>;
|
|
14
|
+
ArticleHeader?: React.FC<{
|
|
15
|
+
frontmatter: PageFrontmatter;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
toggleTheme?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
}>;
|
|
20
|
+
BreadCrumbs?: React.FC<{
|
|
21
|
+
crumbs: BreadCrumbData;
|
|
22
|
+
}>;
|
|
23
|
+
TableOfContents?: React.FC<{
|
|
24
|
+
className?: string;
|
|
25
|
+
projectSlug?: string;
|
|
26
|
+
tocRef?: React.RefObject<HTMLElement>;
|
|
27
|
+
actionButton?: React.ReactNode;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/providers/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,EAAE,CAAC;AAEJ,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QAAC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAC;IAC5E,aAAa,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QACvB,WAAW,EAAE,eAAe,CAAC;QAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,CAAC,CAAC;IACnD,eAAe,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QACzB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACtC,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;KAChC,CAAC,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface CalloutProps {
|
|
3
|
+
title: React.ReactNode;
|
|
4
|
+
description?: React.ReactNode;
|
|
5
|
+
button?: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function Callout({ title, description, button, className }: CalloutProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=Callout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Callout.d.ts","sourceRoot":"","sources":["../../../src/components/ui/Callout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,UAAU,YAAY;IACpB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,YAAY,2CAkB9E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Info } from 'lucide-react';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
export function Callout({ title, description, button, className }) {
|
|
6
|
+
return (_jsxs("div", { className: cn('flex flex-col lg:flex-row items-center justify-between bg-muted/50 rounded p-4 my-4 gap-3', className), children: [_jsxs("div", { className: "flex items-start gap-2 grow self-start", children: [_jsx(Info, { className: "text-sky-500 mt-0.5", size: 18 }), _jsxs("div", { children: [_jsx("div", { className: "font-semibold text-sm", children: title }), description && _jsx("div", { className: "text-sm text-muted-foreground mt-0.5", children: description })] })] }), button && _jsx("div", { className: "ml-4 self-end lg:self-center", children: button })] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageCards.d.ts","sourceRoot":"","sources":["../../../src/components/ui/PageCards.tsx"],"names":[],"mappings":"AAIA,wBAAgB,SAAS,4CAyCxB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useProjectManifest } from '@myst-theme/providers';
|
|
4
|
+
import { Link } from 'react-router';
|
|
5
|
+
export function PageCards() {
|
|
6
|
+
const manifest = useProjectManifest();
|
|
7
|
+
const pages = manifest?.pages || [];
|
|
8
|
+
return (_jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 mt-8", children: pages
|
|
9
|
+
.filter((page) => !!page.slug)
|
|
10
|
+
.map((page) => (_jsxs(Link, { to: `/${page.slug}`, prefetch: "intent", className: "border border-muted rounded bg-white dark:bg-gray-900 p-4 flex flex-col justify-between hover:shadow-md transition-shadow gap-4 no-underline hover:underline", children: [_jsxs("div", { children: [_jsx("h3", { className: "text-lg font-semibold mt-0 mb-0 line-clamp-2", children: page.title }), page.description && (_jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300 mb-4 line-clamp-2", children: page.description }))] }), _jsxs("div", { className: "flex flex-col items-end", children: [page.thumbnail && (_jsx("img", { src: page.thumbnail, alt: page.title, className: "w-full h-20 object-cover mb-0 border rounded-xs mt-0" })), _jsx("div", { className: "flex justify-between mt-auto", children: _jsxs("div", { className: "text-xs text-gray-500 hover:text-blue-600 font-medium mt-2 inline-flex items-center gap-1", children: ["READ ", _jsx("span", { "aria-hidden": true, children: "\u2192" })] }) })] })] }, page.slug))) }));
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abbreviations.d.ts","sourceRoot":"","sources":["../../../src/components/ui/abbreviations.tsx"],"names":[],"mappings":"AAsBA,wBAAgB,aAAa,CAAC,EAC5B,MAAa,EACb,SAAS,GACV,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,kDAqCA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useFrontmatter, useReferences } from '@myst-theme/providers';
|
|
4
|
+
import { toText } from 'myst-common';
|
|
5
|
+
import { HashLink } from 'myst-to-react';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
import { selectAll } from 'unist-util-select';
|
|
8
|
+
import { PART_IDS } from './types';
|
|
9
|
+
function useAbbreviations() {
|
|
10
|
+
const frontmatter = useFrontmatter();
|
|
11
|
+
const references = useReferences();
|
|
12
|
+
const page = references?.article;
|
|
13
|
+
const parts = Object.values(frontmatter?.parts ?? {})
|
|
14
|
+
.map((part) => part.mdast)
|
|
15
|
+
.filter(Boolean);
|
|
16
|
+
const fullTree = { type: 'page', children: [page, ...parts].filter(Boolean) };
|
|
17
|
+
const inTextAbbreviations = selectAll('abbreviation', fullTree);
|
|
18
|
+
const abbr = Object.fromEntries(inTextAbbreviations.map((node) => [toText(node), node.title]));
|
|
19
|
+
if (Object.keys(abbr).length === 0)
|
|
20
|
+
return undefined;
|
|
21
|
+
return abbr;
|
|
22
|
+
}
|
|
23
|
+
export function Abbreviations({ sorted = true, className, }) {
|
|
24
|
+
const abbreviations = useAbbreviations();
|
|
25
|
+
if (!abbreviations)
|
|
26
|
+
return null;
|
|
27
|
+
const sortedAbbreviations = sorted
|
|
28
|
+
? Object.entries(abbreviations).sort(([a], [b]) => a.localeCompare(b))
|
|
29
|
+
: Object.entries(abbreviations);
|
|
30
|
+
return (_jsxs("section", { id: PART_IDS.abbreviations, className: cn('min-w-full prose dark:prose-invert prose-sm', className), children: [_jsxs("header", { className: "text-lg font-semibold text-stone-900 dark:text-white group", children: ["Abbreviations", _jsx(HashLink, { id: PART_IDS.abbreviations, title: "Link to Abbreviations", hover: true, className: "ml-2" })] }), _jsx("div", { className: cn('pl-3 mb-8 text-xs text-stone-500 dark:text-stone-300'), children: _jsx("dl", { className: "grid grid-cols-[auto_1fr] gap-x-6 gap-y-2", children: sortedAbbreviations.map(([abbreviation, description]) => (_jsxs(React.Fragment, { children: [_jsx("dt", { className: "py-1 pt-0 m-0 mt-0 font-medium text-stone-900 dark:text-white", children: abbreviation }), _jsx("dd", { className: "flex items-center py-1 pt-0 m-0 mt-0 text-center text-stone-600 dark:text-stone-400", children: description })] }, abbreviation))) }) })] }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GenericParent } from 'myst-common';
|
|
2
|
+
export declare function Abstract({ content, title, id, className, }: {
|
|
3
|
+
title?: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
content?: GenericParent;
|
|
6
|
+
className?: string;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
//# sourceMappingURL=abstract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract.d.ts","sourceRoot":"","sources":["../../../src/components/ui/abstract.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AAI9D,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EACP,KAAkB,EAClB,EAAe,EACf,SAAS,GACV,EAAE;IACD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,kDAcA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MyST, HashLink } from 'myst-to-react';
|
|
3
|
+
import { select } from 'unist-util-select';
|
|
4
|
+
export function Abstract({ content, title = 'Abstract', id = 'abstract', className, }) {
|
|
5
|
+
if (!content)
|
|
6
|
+
return null;
|
|
7
|
+
const block = select('block', content)?.children || content;
|
|
8
|
+
return (_jsxs("div", { className: className, children: [_jsxs("h2", { id: id, className: "mb-1 text-sm font-semibold group", children: [title, _jsx(HashLink, { id: id, title: `Link to ${title}`, hover: true, className: "ml-2" })] }), _jsx("div", { className: "mt-0 mb-3 text-base font-normal leading-relaxed text-justify text-muted-foreground", children: _jsx(MyST, { ast: block, className: "col-body first:mt-0" }) })] }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function createSkipToTargets(): {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
}[];
|
|
6
|
+
/**
|
|
7
|
+
* Add a skip navigation unit with links based on a list of targets
|
|
8
|
+
*/
|
|
9
|
+
export declare const SkipTo: React.MemoExoticComponent<({ targets }: {
|
|
10
|
+
targets: {
|
|
11
|
+
id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
}[];
|
|
14
|
+
}) => import("react/jsx-runtime").JSX.Element>;
|
|
15
|
+
//# sourceMappingURL=accessibility-skip-to.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessibility-skip-to.d.ts","sourceRoot":"","sources":["../../../src/components/ui/accessibility-skip-to.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAiB1B,wBAAgB,mBAAmB;;;IAMlC;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,0CAA4B;IAAE,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,6CAkBzF,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { PART_IDS } from './types';
|
|
4
|
+
function makeSkipClickHandler(hash) {
|
|
5
|
+
return (e) => {
|
|
6
|
+
e.preventDefault();
|
|
7
|
+
const el = document.querySelector(`#${hash}`);
|
|
8
|
+
if (!el)
|
|
9
|
+
return;
|
|
10
|
+
el.nextSibling.focus();
|
|
11
|
+
history.replaceState(undefined, '', `#${hash}`);
|
|
12
|
+
// Changes keyboard tab-index location
|
|
13
|
+
if (el.tabIndex === -1)
|
|
14
|
+
el.tabIndex = -1;
|
|
15
|
+
el.scrollIntoView({ behavior: 'instant' });
|
|
16
|
+
el.focus();
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function createSkipToTargets() {
|
|
20
|
+
return [
|
|
21
|
+
{ id: PART_IDS.skip_to_content, title: 'Skip to content' },
|
|
22
|
+
{ id: PART_IDS.skip_to_frontmatter, title: 'Skip to frontmatter' },
|
|
23
|
+
{ id: PART_IDS.skip_to_backmatter, title: 'Skip to Backmatter' },
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Add a skip navigation unit with links based on a list of targets
|
|
28
|
+
*/
|
|
29
|
+
export const SkipTo = React.memo(({ targets }) => {
|
|
30
|
+
return (_jsx("div", { className: "fixed top-1 left-1 h-[0px] w-[0px] focus-within:z-100 focus-within:h-auto focus-within:w-auto bg-white overflow-hidden focus-within:p-2 focus-within:ring-1 focus-within:ring-blue-500 focus-within:shadow-lg", "aria-label": "skip to content options", children: targets.map(({ id, title }) => (_jsx("a", { href: `#${id}`, className: "block px-2 py-1 text-black underline hover:text-blue-600 focus:text-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500", onClick: makeSkipClickHandler(id), children: title }, id))) }));
|
|
31
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acknowledgements.d.ts","sourceRoot":"","sources":["../../../src/components/ui/acknowledgements.tsx"],"names":[],"mappings":"AAeA,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,kDAuBrE"}
|