@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,168 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { selectAll } from 'unist-util-select';
|
|
3
|
+
import { visit } from 'unist-util-visit';
|
|
4
|
+
import { MyST } from 'myst-to-react';
|
|
5
|
+
import { Link } from 'react-router';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
import { useEffect, useState, useRef } from 'react';
|
|
8
|
+
// Transform function to remove links from header nodes using unist-util-visit
|
|
9
|
+
function transformHeaders(headers) {
|
|
10
|
+
return headers.map((header) => {
|
|
11
|
+
const transformedHeader = JSON.parse(JSON.stringify(header)); // Deep clone
|
|
12
|
+
// Use unist-util-visit to find and remove all link nodes
|
|
13
|
+
visit(transformedHeader, 'link', (node, index, parent) => {
|
|
14
|
+
if (parent && index !== null) {
|
|
15
|
+
// Replace the link node with its children
|
|
16
|
+
parent.children.splice(index, 1, ...(node.children || []));
|
|
17
|
+
// Return SKIP to continue visiting the same position
|
|
18
|
+
return [undefined, index];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return transformedHeader;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export function DocumentOutline({ mdast, maxdepth = 3, className }) {
|
|
25
|
+
const [activeId, setActiveId] = useState(null);
|
|
26
|
+
const timeoutRef = useRef(null);
|
|
27
|
+
const lastActiveIdRef = useRef(null);
|
|
28
|
+
const ulRef = useRef(null);
|
|
29
|
+
const [maxHeight, setMaxHeight] = useState(undefined);
|
|
30
|
+
const [isVisible, setIsVisible] = useState(true);
|
|
31
|
+
// Extract all headers from the MDAST and transform them
|
|
32
|
+
const rawHeaders = selectAll('heading', mdast);
|
|
33
|
+
const headers = transformHeaders(rawHeaders);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
// Set initial active header based on scroll position
|
|
36
|
+
const handleScroll = () => {
|
|
37
|
+
const scrollTop = window.scrollY;
|
|
38
|
+
const windowHeight = window.innerHeight;
|
|
39
|
+
const documentHeight = document.documentElement.scrollHeight;
|
|
40
|
+
const scrollBottom = scrollTop + windowHeight;
|
|
41
|
+
// If we're at the very top, activate the first header
|
|
42
|
+
if (scrollTop < windowHeight * 0.1) {
|
|
43
|
+
const firstHeader = headers.find((h) => h.html_id);
|
|
44
|
+
if (firstHeader?.html_id) {
|
|
45
|
+
setActiveId(firstHeader.html_id);
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
// If we're near the bottom of the page, activate the last header
|
|
50
|
+
if (scrollBottom > documentHeight - windowHeight * 0.2) {
|
|
51
|
+
const lastHeader = headers[headers.length - 1];
|
|
52
|
+
if (lastHeader?.html_id) {
|
|
53
|
+
setActiveId(lastHeader.html_id);
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// Find the header that's currently in view
|
|
58
|
+
for (let i = headers.length - 1; i >= 0; i--) {
|
|
59
|
+
const header = headers[i];
|
|
60
|
+
if (header.html_id) {
|
|
61
|
+
const element = document.getElementById(header.html_id);
|
|
62
|
+
if (element) {
|
|
63
|
+
const rect = element.getBoundingClientRect();
|
|
64
|
+
if (rect.top <= windowHeight * 0.2) {
|
|
65
|
+
setActiveId(header.html_id);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
// Set initial state
|
|
73
|
+
handleScroll();
|
|
74
|
+
// Add scroll listener as backup
|
|
75
|
+
window.addEventListener('scroll', handleScroll, { passive: true });
|
|
76
|
+
return () => {
|
|
77
|
+
window.removeEventListener('scroll', handleScroll);
|
|
78
|
+
if (timeoutRef.current) {
|
|
79
|
+
clearTimeout(timeoutRef.current);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}, [headers]);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
const ulElement = ulRef.current;
|
|
85
|
+
if (!ulElement)
|
|
86
|
+
return;
|
|
87
|
+
const updateMaxHeight = () => {
|
|
88
|
+
const rect = ulElement.getBoundingClientRect();
|
|
89
|
+
const viewportHeight = window.innerHeight;
|
|
90
|
+
const topOffset = rect.top;
|
|
91
|
+
// Check if bottom-of-article element exists and use it if above viewport bottom
|
|
92
|
+
const bottomOfArticle = document.getElementById('bottom-of-article');
|
|
93
|
+
let maxBottom;
|
|
94
|
+
if (bottomOfArticle) {
|
|
95
|
+
const articleRect = bottomOfArticle.getBoundingClientRect();
|
|
96
|
+
// Use the article bottom if it's above the viewport bottom
|
|
97
|
+
maxBottom = articleRect.top < viewportHeight ? articleRect.top : viewportHeight;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
maxBottom = viewportHeight;
|
|
101
|
+
}
|
|
102
|
+
// Calculate available height
|
|
103
|
+
const availableHeight = maxBottom - topOffset;
|
|
104
|
+
// Use scrollHeight (natural height) to check if we need to constrain
|
|
105
|
+
// This avoids feedback loops from checking rect.bottom which changes with maxHeight
|
|
106
|
+
const naturalHeight = ulElement.scrollHeight;
|
|
107
|
+
// Update visibility based on scrollHeight
|
|
108
|
+
setIsVisible((prev) => {
|
|
109
|
+
const newVisible = availableHeight >= 50;
|
|
110
|
+
return prev !== newVisible ? newVisible : prev;
|
|
111
|
+
});
|
|
112
|
+
// If the natural height exceeds available space, set max-height
|
|
113
|
+
if (naturalHeight > availableHeight) {
|
|
114
|
+
const newMaxHeight = `${availableHeight}px`;
|
|
115
|
+
// Only update if the value actually changed to prevent unnecessary re-renders
|
|
116
|
+
setMaxHeight((prev) => (prev !== newMaxHeight ? newMaxHeight : prev));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
setMaxHeight((prev) => (prev !== undefined ? undefined : prev));
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
// Create an intersection observer to watch the bottom of the ul
|
|
123
|
+
const observer = new IntersectionObserver(() => {
|
|
124
|
+
updateMaxHeight();
|
|
125
|
+
}, {
|
|
126
|
+
root: null, // viewport
|
|
127
|
+
rootMargin: '0px 0px -10px 0px', // Trigger when 10px from bottom
|
|
128
|
+
threshold: 0,
|
|
129
|
+
});
|
|
130
|
+
// Observe the ul element
|
|
131
|
+
observer.observe(ulElement);
|
|
132
|
+
// Also update on scroll and resize
|
|
133
|
+
window.addEventListener('scroll', updateMaxHeight, { passive: true });
|
|
134
|
+
window.addEventListener('resize', updateMaxHeight, { passive: true });
|
|
135
|
+
// Initial calculation
|
|
136
|
+
updateMaxHeight();
|
|
137
|
+
return () => {
|
|
138
|
+
observer.disconnect();
|
|
139
|
+
window.removeEventListener('scroll', updateMaxHeight);
|
|
140
|
+
window.removeEventListener('resize', updateMaxHeight);
|
|
141
|
+
};
|
|
142
|
+
}, []); // Empty dependency array - only run on mount/unmount
|
|
143
|
+
if (!headers || headers.length < 2) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
return (_jsxs("nav", { className: cn('relative space-y-2 font-sans not-prose transition-opacity', { 'opacity-100': isVisible, 'opacity-0 pointer-events-none': !isVisible }, className), children: [_jsx("h3", { className: "mb-4 text-sm font-normal text-muted-foreground", children: "On this page" }), _jsx("ul", { ref: ulRef, className: "space-y-1 border-l-1 overflow-y-auto", style: { maxHeight }, children: headers
|
|
147
|
+
.filter((header) => header.depth <= maxdepth)
|
|
148
|
+
.map((header, index) => {
|
|
149
|
+
const depth = header.depth;
|
|
150
|
+
const identifier = header.html_id;
|
|
151
|
+
const paddingLeft = `${Math.max(1, depth - 1) * 12}px`;
|
|
152
|
+
const isActive = activeId === identifier;
|
|
153
|
+
return (_jsx("li", { children: _jsx(Link, { to: `#${identifier}`, className: cn('block relative text-sm transition-colors', 'px-2 py-1 -ml-[2px]', isActive
|
|
154
|
+
? 'text-foreground border-primary border-l-3 bg-primary/2'
|
|
155
|
+
: 'text-muted-foreground border-border', 'hover:underline'), style: { paddingLeft }, onClick: (e) => {
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
const el = document.querySelector(`#${identifier}`);
|
|
158
|
+
if (!el)
|
|
159
|
+
return;
|
|
160
|
+
el.scrollIntoView({ behavior: 'smooth' });
|
|
161
|
+
history.replaceState(undefined, '', `#${identifier}`);
|
|
162
|
+
// Changes keyboard tab-index location
|
|
163
|
+
if (el.tabIndex === -1)
|
|
164
|
+
el.tabIndex = -1;
|
|
165
|
+
el.focus({ preventScroll: true });
|
|
166
|
+
}, children: _jsx(MyST, { ast: header.children }) }) }, index));
|
|
167
|
+
}) })] }));
|
|
168
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
|
+
declare function DropdownMenu({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function DropdownMenuPortal({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function DropdownMenuTrigger({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function DropdownMenuContent({ className, sideOffset, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare function DropdownMenuGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Group>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare function DropdownMenuItem({ className, inset, variant, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
9
|
+
inset?: boolean;
|
|
10
|
+
variant?: 'default' | 'destructive';
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare function DropdownMenuCheckboxItem({ className, children, checked, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare function DropdownMenuRadioGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare function DropdownMenuRadioItem({ className, children, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare function DropdownMenuLabel({ className, inset, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
|
16
|
+
inset?: boolean;
|
|
17
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
declare function DropdownMenuSeparator({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
declare function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<'span'>): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare function DropdownMenuSub({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
declare function DropdownMenuSubTrigger({ className, inset, children, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
22
|
+
inset?: boolean;
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
declare function DropdownMenuSubContent({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export { DropdownMenu, DropdownMenuPortal, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, };
|
|
26
|
+
//# sourceMappingURL=dropdown-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown-menu.d.ts","sourceRoot":"","sources":["../../../src/components/ui/dropdown-menu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,qBAAqB,MAAM,+BAA+B,CAAC;AAKvE,iBAAS,YAAY,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,IAAI,CAAC,2CAE1F;AAED,iBAAS,kBAAkB,CAAC,EAC1B,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,MAAM,CAAC,2CAE3D;AAED,iBAAS,mBAAmB,CAAC,EAC3B,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,OAAO,CAAC,2CAE5D;AAED,iBAAS,mBAAmB,CAAC,EAC3B,SAAS,EACT,UAAc,EACd,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,OAAO,CAAC,2CAc5D;AAED,iBAAS,iBAAiB,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,KAAK,CAAC,2CAEhG;AAED,iBAAS,gBAAgB,CAAC,EACxB,SAAS,EACT,KAAK,EACL,OAAmB,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,IAAI,CAAC,GAAG;IAC3D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;CACrC,2CAcA;AAED,iBAAS,wBAAwB,CAAC,EAChC,SAAS,EACT,QAAQ,EACR,OAAO,EACP,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,YAAY,CAAC,2CAmBjE;AAED,iBAAS,sBAAsB,CAAC,EAC9B,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,UAAU,CAAC,2CAE/D;AAED,iBAAS,qBAAqB,CAAC,EAC7B,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,SAAS,CAAC,2CAkB9D;AAED,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,KAAK,CAAC,GAAG;IAC5D,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,2CASA;AAED,iBAAS,qBAAqB,CAAC,EAC7B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,SAAS,CAAC,2CAQ9D;AAED,iBAAS,oBAAoB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,2CAQlF;AAED,iBAAS,eAAe,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,GAAG,CAAC,2CAE5F;AAED,iBAAS,sBAAsB,CAAC,EAC9B,SAAS,EACT,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,UAAU,CAAC,GAAG;IACjE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,2CAeA;AAED,iBAAS,sBAAsB,CAAC,EAC9B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,UAAU,CAAC,2CAW/D;AAED,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,GACvB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
4
|
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
function DropdownMenu({ ...props }) {
|
|
7
|
+
return _jsx(DropdownMenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props });
|
|
8
|
+
}
|
|
9
|
+
function DropdownMenuPortal({ ...props }) {
|
|
10
|
+
return _jsx(DropdownMenuPrimitive.Portal, { "data-slot": "dropdown-menu-portal", ...props });
|
|
11
|
+
}
|
|
12
|
+
function DropdownMenuTrigger({ ...props }) {
|
|
13
|
+
return _jsx(DropdownMenuPrimitive.Trigger, { "data-slot": "dropdown-menu-trigger", ...props });
|
|
14
|
+
}
|
|
15
|
+
function DropdownMenuContent({ className, sideOffset = 4, ...props }) {
|
|
16
|
+
return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { "data-slot": "dropdown-menu-content", sideOffset: sideOffset, className: cn('bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-sm border p-1 shadow-md', className), ...props }) }));
|
|
17
|
+
}
|
|
18
|
+
function DropdownMenuGroup({ ...props }) {
|
|
19
|
+
return _jsx(DropdownMenuPrimitive.Group, { "data-slot": "dropdown-menu-group", ...props });
|
|
20
|
+
}
|
|
21
|
+
function DropdownMenuItem({ className, inset, variant = 'default', ...props }) {
|
|
22
|
+
return (_jsx(DropdownMenuPrimitive.Item, { "data-slot": "dropdown-menu-item", "data-inset": inset, "data-variant": variant, className: cn("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", 'cursor-pointer', className), ...props }));
|
|
23
|
+
}
|
|
24
|
+
function DropdownMenuCheckboxItem({ className, children, checked, ...props }) {
|
|
25
|
+
return (_jsxs(DropdownMenuPrimitive.CheckboxItem, { "data-slot": "dropdown-menu-checkbox-item", className: cn("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), checked: checked, ...props, children: [_jsx("span", { className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(CheckIcon, { className: "size-4" }) }) }), children] }));
|
|
26
|
+
}
|
|
27
|
+
function DropdownMenuRadioGroup({ ...props }) {
|
|
28
|
+
return _jsx(DropdownMenuPrimitive.RadioGroup, { "data-slot": "dropdown-menu-radio-group", ...props });
|
|
29
|
+
}
|
|
30
|
+
function DropdownMenuRadioItem({ className, children, ...props }) {
|
|
31
|
+
return (_jsxs(DropdownMenuPrimitive.RadioItem, { "data-slot": "dropdown-menu-radio-item", className: cn("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), ...props, children: [_jsx("span", { className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(CircleIcon, { className: "fill-current size-2" }) }) }), children] }));
|
|
32
|
+
}
|
|
33
|
+
function DropdownMenuLabel({ className, inset, ...props }) {
|
|
34
|
+
return (_jsx(DropdownMenuPrimitive.Label, { "data-slot": "dropdown-menu-label", "data-inset": inset, className: cn('px-2 py-1.5 text-sm font-medium data-[inset]:pl-8', className), ...props }));
|
|
35
|
+
}
|
|
36
|
+
function DropdownMenuSeparator({ className, ...props }) {
|
|
37
|
+
return (_jsx(DropdownMenuPrimitive.Separator, { "data-slot": "dropdown-menu-separator", className: cn('-mx-1 my-1 h-px bg-border', className), ...props }));
|
|
38
|
+
}
|
|
39
|
+
function DropdownMenuShortcut({ className, ...props }) {
|
|
40
|
+
return (_jsx("span", { "data-slot": "dropdown-menu-shortcut", className: cn('ml-auto text-xs tracking-widest text-muted-foreground', className), ...props }));
|
|
41
|
+
}
|
|
42
|
+
function DropdownMenuSub({ ...props }) {
|
|
43
|
+
return _jsx(DropdownMenuPrimitive.Sub, { "data-slot": "dropdown-menu-sub", ...props });
|
|
44
|
+
}
|
|
45
|
+
function DropdownMenuSubTrigger({ className, inset, children, ...props }) {
|
|
46
|
+
return (_jsxs(DropdownMenuPrimitive.SubTrigger, { "data-slot": "dropdown-menu-sub-trigger", "data-inset": inset, className: cn('focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8', className), ...props, children: [children, _jsx(ChevronRightIcon, { className: "ml-auto size-4" })] }));
|
|
47
|
+
}
|
|
48
|
+
function DropdownMenuSubContent({ className, ...props }) {
|
|
49
|
+
return (_jsx(DropdownMenuPrimitive.SubContent, { "data-slot": "dropdown-menu-sub-content", className: cn('bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-sm border p-1 shadow-lg', className), ...props }));
|
|
50
|
+
}
|
|
51
|
+
export { DropdownMenu, DropdownMenuPortal, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface ErrorPageProps {
|
|
2
|
+
error: unknown;
|
|
3
|
+
title?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function ErrorPage({ error, title, description, className }: ErrorPageProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=error-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-page.d.ts","sourceRoot":"","sources":["../../../src/components/ui/error-page.tsx"],"names":[],"mappings":"AAGA,UAAU,cAAc;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,cAAc,2CAmCjF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isRouteErrorResponse } from 'react-router';
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
export function ErrorPage({ error, title, description, className }) {
|
|
5
|
+
let message = title || 'Oops!';
|
|
6
|
+
let details = description || 'An unexpected error occurred.';
|
|
7
|
+
let stack;
|
|
8
|
+
if (isRouteErrorResponse(error)) {
|
|
9
|
+
message = error.status === 404 ? '404' : title || 'Error';
|
|
10
|
+
details =
|
|
11
|
+
description ||
|
|
12
|
+
(error.status === 404
|
|
13
|
+
? 'The requested page could not be found.'
|
|
14
|
+
: error.statusText || 'An unexpected error occurred.');
|
|
15
|
+
}
|
|
16
|
+
else if (error && error instanceof Error) {
|
|
17
|
+
details = error.message;
|
|
18
|
+
stack = error.stack;
|
|
19
|
+
}
|
|
20
|
+
return (_jsx("div", { className: cn('flex flex-col items-center justify-center min-h-[75vh] px-4', className), children: _jsxs("div", { className: "text-center max-w-2xl space-y-4", children: [_jsx("h1", { className: "text-6xl font-bold text-foreground", children: message }), _jsx("p", { className: "text-lg text-muted-foreground", children: details }), stack && (_jsxs("details", { className: "mt-8 text-left", children: [_jsx("summary", { className: "cursor-pointer text-sm font-medium text-muted-foreground mb-2", children: "Error Details" }), _jsx("pre", { className: "overflow-x-auto p-4 bg-muted rounded-md text-xs", children: _jsx("code", { children: stack }) })] }))] }) }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface NavItem {
|
|
2
|
+
title: string;
|
|
3
|
+
short_title?: string;
|
|
4
|
+
url: string;
|
|
5
|
+
}
|
|
6
|
+
interface FooterLinksProps {
|
|
7
|
+
navigation?: {
|
|
8
|
+
prev?: NavItem;
|
|
9
|
+
next?: NavItem;
|
|
10
|
+
} | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function FooterLinks({ navigation }: FooterLinksProps): import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=footer-links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footer-links.d.ts","sourceRoot":"","sources":["../../../src/components/ui/footer-links.tsx"],"names":[],"mappings":"AAKA,UAAU,OAAO;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb;AAgCD,UAAU,gBAAgB;IACxB,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,GAAG,IAAI,CAAC;CACV;AAED,wBAAgB,WAAW,CAAC,EAAE,UAAU,EAAE,EAAE,gBAAgB,kDAqB3D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Link } from 'react-router';
|
|
3
|
+
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
4
|
+
import { useBaseurl, withBaseurl } from '@myst-theme/providers';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
function FooterLink({ item, align, label }) {
|
|
7
|
+
const baseUrl = useBaseurl();
|
|
8
|
+
const isLeft = align === 'left';
|
|
9
|
+
return (_jsxs(Link, { to: withBaseurl(item.url, baseUrl), className: `w-full block border border-muted rounded-sm p-4 hover:bg-accent transition-colors no-underline ${isLeft ? '' : 'text-right'}`, children: [_jsxs("div", { className: `text-muted-foreground flex items-center gap-1 text-sm font-light mb-1 ${isLeft ? '' : 'justify-end'}`, children: [isLeft && _jsx(ChevronLeft, { size: 16 }), _jsx("span", { children: label }), !isLeft && _jsx(ChevronRight, { size: 16 })] }), _jsx("div", { className: "text-sm font-normal", children: item.short_title || item.title })] }));
|
|
10
|
+
}
|
|
11
|
+
export function FooterLinks({ navigation }) {
|
|
12
|
+
if (!navigation)
|
|
13
|
+
return null;
|
|
14
|
+
const hasPrev = !!navigation.prev;
|
|
15
|
+
const hasNext = !!navigation.next;
|
|
16
|
+
const hasBoth = hasPrev && hasNext;
|
|
17
|
+
return (_jsxs("div", { className: "flex flex-col gap-4 mt-12 mb-4 sm:flex-row", children: [navigation.prev && (_jsx("div", { className: cn('flex w-full', { 'sm:w-1/2': hasBoth }), children: _jsx(FooterLink, { item: navigation.prev, align: "left", label: "Previous" }) })), navigation.next && (_jsx("div", { className: cn('flex w-full', { 'sm:w-1/2': hasBoth }), children: _jsx(FooterLink, { item: navigation.next, align: "right", label: "Next" }) }))] }));
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footnotes.d.ts","sourceRoot":"","sources":["../../../src/components/ui/footnotes.tsx"],"names":[],"mappings":"AAwBA,wBAAgB,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,kDA4C9D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFrontmatter, useReferences } from '@myst-theme/providers';
|
|
3
|
+
import { HashLink, MyST } from 'myst-to-react';
|
|
4
|
+
import { selectAll } from 'unist-util-select';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
function useFootnotes() {
|
|
7
|
+
// TODO: parts as well
|
|
8
|
+
const frontmatter = useFrontmatter();
|
|
9
|
+
const references = useReferences();
|
|
10
|
+
const page = references?.article;
|
|
11
|
+
const parts = Object.values(frontmatter?.parts ?? {})
|
|
12
|
+
.map((part) => part.mdast)
|
|
13
|
+
.filter(Boolean);
|
|
14
|
+
const fullTree = { type: 'page', children: [page, ...parts].filter(Boolean) };
|
|
15
|
+
const defs = selectAll('footnoteDefinition', fullTree);
|
|
16
|
+
const refs = selectAll('footnoteReference', fullTree);
|
|
17
|
+
if (defs.length === 0)
|
|
18
|
+
return null;
|
|
19
|
+
return { defs, refs };
|
|
20
|
+
}
|
|
21
|
+
export function Footnotes({ className }) {
|
|
22
|
+
const footnotes = useFootnotes();
|
|
23
|
+
if (!footnotes)
|
|
24
|
+
return null;
|
|
25
|
+
return (_jsxs("section", { id: "footnotes", 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: ["Footnotes", _jsx(HashLink, { id: "footnotes", title: "Link to Footnotes", hover: true, className: "ml-2" })] }), _jsx("div", { className: cn('pl-3 mb-8 text-xs text-stone-500 dark:text-stone-300'), children: _jsx("ol", { children: footnotes.defs.map((fn) => {
|
|
26
|
+
return (_jsx("li", { id: `fn-${fn.identifier}`, className: "group", children: _jsxs("div", { className: "flex flex-row", children: [_jsx("div", { className: "break-words grow", children: _jsx(MyST, { ast: fn.children }) }), _jsx("div", { className: "flex flex-col grow-0", children: footnotes.refs
|
|
27
|
+
.filter((ref) => ref.identifier === fn.identifier)
|
|
28
|
+
.map((ref) => (_jsx(HashLink, { id: `fnref-${ref.key}`, title: "Link to Content", hover: "desktop", className: "p-1", children: "\u21A9", scrollBehavior: "instant" }, ref.key))) })] }) }, fn.key));
|
|
29
|
+
}) }) })] }));
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare function DateString({ date, format, spacer, className, }: {
|
|
2
|
+
date?: string;
|
|
3
|
+
format?: Intl.DateTimeFormatOptions;
|
|
4
|
+
spacer?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
export declare function TwitterLink({ twitter: possibleLink }: {
|
|
8
|
+
twitter?: string;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
export declare function GitHubLink({ github: possibleLink }: {
|
|
11
|
+
github?: string;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
+
export declare function OpenAccessBadge({ open_access }: {
|
|
14
|
+
open_access?: boolean;
|
|
15
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
16
|
+
export declare function OrcidBadge({ orcid, className }: {
|
|
17
|
+
orcid?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
20
|
+
export declare function DoiLink({ doi: possibleLink, spacer }: {
|
|
21
|
+
doi?: string;
|
|
22
|
+
spacer?: boolean;
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
24
|
+
export declare function EmailLink({ email }: {
|
|
25
|
+
email?: string;
|
|
26
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
27
|
+
//# sourceMappingURL=frontmatter-badges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-badges.d.ts","sourceRoot":"","sources":["../../../src/components/ui/frontmatter-badges.tsx"],"names":[],"mappings":"AAOA,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,MAIC,EACD,MAAM,EACN,SAAS,GACV,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;IACpC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,kDAiBA;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,kDAkB1E;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,kDAkBvE;AACD,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,kDAiBzE;AAED,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,kDAmBtF;AAED,wBAAgB,OAAO,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,kDAgBxF;AAED,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,kDAYtD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { OpenAccessIcon, GithubIcon, XIcon, OrcidIcon } from '@scienceicons/react/24/solid';
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
import { SimpleTooltip } from './tooltip';
|
|
5
|
+
import { Mail } from 'lucide-react';
|
|
6
|
+
import { HashLink } from 'myst-to-react';
|
|
7
|
+
import { PART_IDS } from './types';
|
|
8
|
+
export function DateString({ date, format = {
|
|
9
|
+
year: 'numeric',
|
|
10
|
+
month: 'long',
|
|
11
|
+
day: 'numeric',
|
|
12
|
+
}, spacer, className, }) {
|
|
13
|
+
if (!date)
|
|
14
|
+
return null;
|
|
15
|
+
// Parse the date
|
|
16
|
+
// As this is a YYYY-MM-DD form, the parser interprets this as a UTC date
|
|
17
|
+
// (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#the_epoch_timestamps_and_invalid_date)
|
|
18
|
+
const utcDate = new Date(date);
|
|
19
|
+
// Now cast our UTC-date into the local timezone
|
|
20
|
+
const localDate = new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate());
|
|
21
|
+
// Then format as human-readable in the local timezone.
|
|
22
|
+
const dateString = localDate.toLocaleDateString('en-US', format);
|
|
23
|
+
return (_jsx("time", { dateTime: date, className: cn(className, { 'text-spacer': spacer }), children: dateString }));
|
|
24
|
+
}
|
|
25
|
+
export function TwitterLink({ twitter: possibleLink }) {
|
|
26
|
+
if (!possibleLink)
|
|
27
|
+
return null;
|
|
28
|
+
const twitter = possibleLink.replace(/^(https?:\/\/)?(?:twitter|x)\.com\//, '');
|
|
29
|
+
return (_jsx("a", { href: `https://x.com/${twitter}`, title: `X Account: ${twitter}`, target: "_blank", rel: "noopener noreferrer", className: "text-inherit hover:text-inherit", children: _jsx(XIcon, { width: "1.25rem", height: "1.25rem", className: "inline-block opacity-60 hover:opacity-100" }) }));
|
|
30
|
+
}
|
|
31
|
+
export function GitHubLink({ github: possibleLink }) {
|
|
32
|
+
if (!possibleLink)
|
|
33
|
+
return null;
|
|
34
|
+
const github = possibleLink.replace(/^(https?:\/\/)?github\.com\//, '');
|
|
35
|
+
return (_jsx("a", { href: `https://github.com/${github}`, title: `GitHub Repository: ${github}`, target: "_blank", rel: "noopener noreferrer", className: "text-inherit hover:text-inherit", children: _jsx(GithubIcon, { width: "1.25rem", height: "1.25rem", className: "inline-block opacity-60 hover:opacity-100" }) }));
|
|
36
|
+
}
|
|
37
|
+
export function OpenAccessBadge({ open_access }) {
|
|
38
|
+
if (!open_access)
|
|
39
|
+
return null;
|
|
40
|
+
return (_jsx(HashLink, { id: PART_IDS.license, title: "Open Access", hover: false, scrollBehavior: "instant", className: "text-inherit hover:text-inherit", children: _jsx(OpenAccessIcon, { width: "1.25rem", height: "1.25rem", className: "inline-block opacity-60 hover:opacity-100 hover:text-[#E18435]" }) }));
|
|
41
|
+
}
|
|
42
|
+
export function OrcidBadge({ orcid, className }) {
|
|
43
|
+
if (!orcid)
|
|
44
|
+
return null;
|
|
45
|
+
return (_jsx(SimpleTooltip, { title: "Open ORCID Profile", children: _jsx("a", { href: `https://orcid.org/${orcid}`, target: "_blank", rel: "noopener noreferrer", title: "ORCID", className: cn('text-inherit hover:text-inherit', className), children: _jsx(OrcidIcon, { width: "1.25rem", height: "1.25rem", className: "inline-block opacity-60 hover:opacity-100 hover:text-[#A6CE39]" }) }) }));
|
|
46
|
+
}
|
|
47
|
+
export function DoiLink({ doi: possibleLink, spacer }) {
|
|
48
|
+
if (!possibleLink)
|
|
49
|
+
return null;
|
|
50
|
+
const doi = possibleLink.replace(/^(https?:\/\/)?(dx\.)?doi\.org\//, '');
|
|
51
|
+
const url = `https://doi.org/${doi}`;
|
|
52
|
+
return (_jsx("a", { href: `https://doi.org/${doi}`, target: "_blank", rel: "noopener noreferrer", className: cn('font-light hover:underline text-muted-foreground hover:text-foreground', {
|
|
53
|
+
'text-spacer': spacer,
|
|
54
|
+
}), children: url }));
|
|
55
|
+
}
|
|
56
|
+
export function EmailLink({ email }) {
|
|
57
|
+
if (!email)
|
|
58
|
+
return null;
|
|
59
|
+
return (_jsx(SimpleTooltip, { title: "Email corresponding author", children: _jsx("a", { href: `mailto:${email}`, target: "_blank", rel: "noopener noreferrer", children: _jsx(Mail, { className: "inline-block ml-1 size-4 text-muted-foreground", "aria-label": "Corresponding author" }) }) }));
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../../src/components/ui/frontmatter.tsx"],"names":[],"mappings":"AAEA,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CAOhE;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../../lib/utils';
|
|
3
|
+
export function Frontmatter({ title, subtitle }) {
|
|
4
|
+
return (_jsxs("div", { children: [title && _jsx("h1", { className: cn({ 'mb-4': subtitle }), children: title }), subtitle && _jsx("div", { className: "text-muted-foreground text-lg mb-10", children: subtitle })] }));
|
|
5
|
+
}
|
|
6
|
+
export default Frontmatter;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { GenericParent } from 'myst-common';
|
|
3
|
+
interface ImageProps {
|
|
4
|
+
src: string;
|
|
5
|
+
srcOptimized?: string;
|
|
6
|
+
urlSource?: string;
|
|
7
|
+
alt?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
showLightbox?: boolean;
|
|
10
|
+
width?: string | number;
|
|
11
|
+
height?: string | number;
|
|
12
|
+
align?: 'left' | 'center' | 'right';
|
|
13
|
+
}
|
|
14
|
+
type Alignment = 'left' | 'center' | 'right';
|
|
15
|
+
export declare function Picture({ ref, className, src, srcOptimized, urlSource, align, alt, width, height, onClick, style, onLoad, onLoadedData, }: {
|
|
16
|
+
ref?: React.RefObject<HTMLImageElement | HTMLVideoElement | null>;
|
|
17
|
+
className?: string;
|
|
18
|
+
src: string;
|
|
19
|
+
srcOptimized?: string;
|
|
20
|
+
urlSource?: string;
|
|
21
|
+
alt?: string;
|
|
22
|
+
width?: string | number;
|
|
23
|
+
height?: string | number;
|
|
24
|
+
align?: Alignment;
|
|
25
|
+
onClick?: () => void;
|
|
26
|
+
style?: React.CSSProperties;
|
|
27
|
+
onLoad?: () => void;
|
|
28
|
+
onLoadedData?: () => void;
|
|
29
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare function Image({ src, srcOptimized, urlSource, alt, className, showLightbox, width, height, align, caption, }: ImageProps & {
|
|
31
|
+
caption?: string | GenericParent;
|
|
32
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/components/ui/image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAOjD,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACrC;AAED,KAAK,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAiF7C,wBAAgB,OAAO,CAAC,EACtB,GAAG,EACH,SAAS,EACT,GAAG,EACH,YAAY,EACZ,SAAS,EACT,KAAgB,EAChB,GAAG,EACH,KAAK,EACL,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,YAAY,GACb,EAAE;IACD,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B,2CA8CA;AAED,wBAAgB,KAAK,CAAC,EACpB,GAAG,EACH,YAAY,EACZ,SAAS,EACT,GAAG,EACH,SAAS,EACT,YAAmB,EACnB,KAAK,EACL,MAAM,EACN,KAAgB,EAChB,OAAO,GACR,EAAE,UAAU,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,2CAgDnD"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
import { useLightbox } from '../providers/lightbox-provider';
|
|
5
|
+
import { ZoomIn } from 'lucide-react';
|
|
6
|
+
import { SimpleTooltip } from './tooltip';
|
|
7
|
+
function getStyleValue(width) {
|
|
8
|
+
if (typeof width === 'number' && Number.isNaN(width)) {
|
|
9
|
+
// If it is nan, return undefined.
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
if (typeof width === 'string') {
|
|
13
|
+
if (width.endsWith('%')) {
|
|
14
|
+
return width;
|
|
15
|
+
}
|
|
16
|
+
else if (width.endsWith('px')) {
|
|
17
|
+
return Number(width.replace('px', ''));
|
|
18
|
+
}
|
|
19
|
+
else if (!Number.isNaN(Number(width))) {
|
|
20
|
+
return Number(width);
|
|
21
|
+
}
|
|
22
|
+
console.log(`Unknown width ${width} in getImageWidth`);
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return width;
|
|
26
|
+
}
|
|
27
|
+
function alignToMargin(align) {
|
|
28
|
+
switch (align) {
|
|
29
|
+
case 'left':
|
|
30
|
+
return { marginRight: 'auto' };
|
|
31
|
+
case 'right':
|
|
32
|
+
return { marginLeft: 'auto' };
|
|
33
|
+
case 'center':
|
|
34
|
+
return { margin: '0 auto' };
|
|
35
|
+
default:
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function Video({ ref, className, src, urlSource, align = 'center', width, height, onClick, style, onLoadedData, }) {
|
|
40
|
+
return (_jsx("video", { ref: ref, className: className, style: {
|
|
41
|
+
width: getStyleValue(width),
|
|
42
|
+
height: getStyleValue(height),
|
|
43
|
+
...alignToMargin(align),
|
|
44
|
+
...style,
|
|
45
|
+
}, src: src, "data-canonical-url": urlSource, autoPlay: true,
|
|
46
|
+
// For autoplay, the element needs to be muted to actually start!
|
|
47
|
+
muted: true, "webkit-playsinline": "true", playsInline: true, loop: true, onClick: onClick, onLoadedData: onLoadedData }));
|
|
48
|
+
}
|
|
49
|
+
export function Picture({ ref, className, src, srcOptimized, urlSource, align = 'center', alt, width, height, onClick, style, onLoad, onLoadedData, }) {
|
|
50
|
+
if (src.endsWith('.mp4') || urlSource?.endsWith('.mp4')) {
|
|
51
|
+
return (_jsx(Video, { ref: ref, className: className, width: width, height: height, align: align, src: src, urlSource: urlSource, onClick: onClick, style: style, onLoadedData: onLoadedData }));
|
|
52
|
+
}
|
|
53
|
+
const image = (_jsx("img", { ref: ref, style: {
|
|
54
|
+
width: getStyleValue(width),
|
|
55
|
+
height: getStyleValue(height),
|
|
56
|
+
...alignToMargin(align),
|
|
57
|
+
...style,
|
|
58
|
+
}, src: src, alt: alt, "data-canonical-url": urlSource,
|
|
59
|
+
// Don't set className if nested under picture
|
|
60
|
+
className: cn(srcOptimized ? undefined : className, 'bg-background'), onClick: onClick, draggable: false, onLoad: onLoad }));
|
|
61
|
+
if (!srcOptimized)
|
|
62
|
+
return image;
|
|
63
|
+
return (_jsxs("picture", { className: className, children: [_jsx("source", { srcSet: srcOptimized, type: "image/webp" }), image] }));
|
|
64
|
+
}
|
|
65
|
+
export function Image({ src, srcOptimized, urlSource, alt, className, showLightbox = true, width, height, align = 'center', caption, }) {
|
|
66
|
+
const { openLightbox } = useLightbox();
|
|
67
|
+
const handleClick = () => {
|
|
68
|
+
if (!showLightbox)
|
|
69
|
+
return;
|
|
70
|
+
const imageData = {
|
|
71
|
+
src,
|
|
72
|
+
srcOptimized,
|
|
73
|
+
urlSource,
|
|
74
|
+
alt,
|
|
75
|
+
caption,
|
|
76
|
+
};
|
|
77
|
+
openLightbox(imageData);
|
|
78
|
+
};
|
|
79
|
+
const isClickable = showLightbox;
|
|
80
|
+
return (_jsxs("div", { className: cn('overflow-hidden relative group/image', {
|
|
81
|
+
'transition-opacity cursor-pointer hover:opacity-90': isClickable,
|
|
82
|
+
}, className), onClick: isClickable ? handleClick : undefined, children: [_jsx(Picture, { src: src, srcOptimized: srcOptimized, urlSource: urlSource, alt: alt, width: width, height: height, align: align, onClick: isClickable ? handleClick : undefined }), isClickable && (_jsx(SimpleTooltip, { title: "Click to enlarge", children: _jsx(ZoomIn, { className: "absolute right-1 bottom-1 w-4 h-4 opacity-0 transition-opacity group-hover/image:opacity-100" }) }))] }));
|
|
83
|
+
}
|