@dreamlake/dockit 0.1.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.
Files changed (66) hide show
  1. package/dist/components/Callout.d.ts +11 -0
  2. package/dist/components/Callout.js +101 -0
  3. package/dist/components/ClientOnly.d.ts +4 -0
  4. package/dist/components/ClientOnly.js +11 -0
  5. package/dist/components/CodeBlock.d.ts +13 -0
  6. package/dist/components/CodeBlock.js +155 -0
  7. package/dist/components/DocFooter.d.ts +1 -0
  8. package/dist/components/DocFooter.js +63 -0
  9. package/dist/components/Preview.d.ts +16 -0
  10. package/dist/components/Preview.js +220 -0
  11. package/dist/components/SearchPalette.d.ts +8 -0
  12. package/dist/components/SearchPalette.js +678 -0
  13. package/dist/components/SearchResize.d.ts +11 -0
  14. package/dist/components/SearchResize.js +150 -0
  15. package/dist/components/Sidebar.d.ts +1 -0
  16. package/dist/components/Sidebar.js +134 -0
  17. package/dist/components/StatusTable.d.ts +19 -0
  18. package/dist/components/StatusTable.js +251 -0
  19. package/dist/components/TOC.d.ts +1 -0
  20. package/dist/components/TOC.js +674 -0
  21. package/dist/components/TabStrip.d.ts +8 -0
  22. package/dist/components/TabStrip.js +105 -0
  23. package/dist/components/ThemeProvider.d.ts +11 -0
  24. package/dist/components/ThemeProvider.js +40 -0
  25. package/dist/components/ThemeToggle.d.ts +2 -0
  26. package/dist/components/ThemeToggle.js +109 -0
  27. package/dist/components/Topbar.d.ts +9 -0
  28. package/dist/components/Topbar.js +818 -0
  29. package/dist/components/mdx-components.d.ts +30 -0
  30. package/dist/components/mdx-components.js +346 -0
  31. package/dist/index.d.ts +61 -0
  32. package/dist/index.js +81 -0
  33. package/dist/lib/navigation.d.ts +80 -0
  34. package/dist/lib/navigation.js +57 -0
  35. package/dist/lib/pagefind-search.d.ts +21 -0
  36. package/dist/lib/pagefind-search.js +201 -0
  37. package/dist/lib/search-index.d.ts +43 -0
  38. package/dist/lib/search-index.js +112 -0
  39. package/dist/lib/tabs.d.ts +23 -0
  40. package/dist/lib/tabs.js +30 -0
  41. package/dist/lib/use-hidden-toggle.d.ts +15 -0
  42. package/dist/lib/use-hidden-toggle.js +23 -0
  43. package/dist/lib/use-line-numbers.d.ts +9 -0
  44. package/dist/lib/use-line-numbers.js +7 -0
  45. package/dist/lib/use-local-storage.d.ts +15 -0
  46. package/dist/lib/use-local-storage.js +58 -0
  47. package/dist/lib/use-media-query.d.ts +5 -0
  48. package/dist/lib/use-media-query.js +16 -0
  49. package/dist/renderer/Layout.d.ts +5 -0
  50. package/dist/renderer/Layout.js +170 -0
  51. package/dist/renderer/onRenderClient.d.ts +1 -0
  52. package/dist/renderer/onRenderClient.js +23 -0
  53. package/dist/renderer/onRenderHtml.d.ts +5 -0
  54. package/dist/renderer/onRenderHtml.js +44 -0
  55. package/dist/site-config.d.ts +61 -0
  56. package/dist/site-config.js +21 -0
  57. package/dist/styles.css +310 -0
  58. package/dist/vike.d.ts +12 -0
  59. package/dist/vike.js +8 -0
  60. package/dist/vite.d.ts +2 -0
  61. package/dist/vite.js +80 -0
  62. package/package.json +82 -0
  63. package/templates/netlify.example.toml +33 -0
  64. package/templates/set-version.mjs +70 -0
  65. package/templates/version-branch.sh +16 -0
  66. package/templates/versions.example.json +15 -0
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ interface CalloutProps {
3
+ variant?: 'info' | 'warn';
4
+ /** Optional explicit title above the body. The body's leading
5
+ * `<strong>` is automatically styled as a title too — for GFM
6
+ * alerts, just lead with a `**bolded sentence.**` in the body. */
7
+ title?: ReactNode;
8
+ children: ReactNode;
9
+ }
10
+ export declare function Callout({ variant, title, children }: CalloutProps): import("react").JSX.Element;
11
+ export {};
@@ -0,0 +1,101 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ function InfoIcon() {
3
+ return /* @__PURE__ */ jsxs(
4
+ "svg",
5
+ {
6
+ viewBox: "0 0 24 24",
7
+ fill: "none",
8
+ stroke: "currentColor",
9
+ strokeWidth: "2",
10
+ strokeLinecap: "round",
11
+ strokeLinejoin: "round",
12
+ "aria-hidden": true,
13
+ style: { width: 18, height: 18, display: "block", marginTop: 2 },
14
+ children: [
15
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
16
+ /* @__PURE__ */ jsx("path", { d: "M12 16v-4" }),
17
+ /* @__PURE__ */ jsx("path", { d: "M12 8h.01" })
18
+ ]
19
+ }
20
+ );
21
+ }
22
+ function WarnIcon() {
23
+ return /* @__PURE__ */ jsxs(
24
+ "svg",
25
+ {
26
+ viewBox: "0 0 24 24",
27
+ fill: "none",
28
+ stroke: "currentColor",
29
+ strokeWidth: "2",
30
+ strokeLinecap: "round",
31
+ strokeLinejoin: "round",
32
+ "aria-hidden": true,
33
+ style: { width: 18, height: 18, display: "block", marginTop: 2 },
34
+ children: [
35
+ /* @__PURE__ */ jsx("path", { d: "M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" }),
36
+ /* @__PURE__ */ jsx("path", { d: "M12 9v4" }),
37
+ /* @__PURE__ */ jsx("path", { d: "M12 17h.01" })
38
+ ]
39
+ }
40
+ );
41
+ }
42
+ function Callout({ variant = "info", title, children }) {
43
+ const isWarn = variant === "warn";
44
+ return /* @__PURE__ */ jsxs(
45
+ "div",
46
+ {
47
+ className: "text-doc-template-ink",
48
+ style: {
49
+ display: "grid",
50
+ gridTemplateColumns: "18px 1fr",
51
+ gap: 12,
52
+ padding: "12px 14px",
53
+ borderRadius: "var(--radius-doc-template)",
54
+ border: "1px solid var(--color-doc-template-faint)",
55
+ background: isWarn ? "color-mix(in oklab, oklch(75% .16 80) 10%, var(--color-doc-template-bg))" : "color-mix(in srgb, var(--color-doc-template-accent) 5%, var(--color-doc-template-bg))",
56
+ margin: "18px 0 22px"
57
+ },
58
+ children: [
59
+ /* @__PURE__ */ jsx(
60
+ "span",
61
+ {
62
+ style: {
63
+ color: isWarn ? "oklch(58% .16 60)" : "var(--color-doc-template-accent)"
64
+ },
65
+ children: isWarn ? /* @__PURE__ */ jsx(WarnIcon, {}) : /* @__PURE__ */ jsx(InfoIcon, {})
66
+ }
67
+ ),
68
+ /* @__PURE__ */ jsxs(
69
+ "div",
70
+ {
71
+ style: {
72
+ fontFamily: "var(--font-doc-template-ui)",
73
+ fontSize: 13.5,
74
+ lineHeight: 1.55,
75
+ color: "var(--color-doc-template-ink)"
76
+ },
77
+ children: [
78
+ title && /* @__PURE__ */ jsx(
79
+ "div",
80
+ {
81
+ style: {
82
+ display: "block",
83
+ fontWeight: 600,
84
+ fontSize: 12,
85
+ letterSpacing: "-0.005em",
86
+ marginBottom: 2
87
+ },
88
+ children: title
89
+ }
90
+ ),
91
+ /* @__PURE__ */ jsx("div", { className: "doc-callout-body", children })
92
+ ]
93
+ }
94
+ )
95
+ ]
96
+ }
97
+ );
98
+ }
99
+ export {
100
+ Callout
101
+ };
@@ -0,0 +1,4 @@
1
+ import { ReactNode } from 'react';
2
+ export declare function ClientOnly({ children }: {
3
+ children: ReactNode;
4
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,11 @@
1
+ import { jsx, Fragment } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
3
+ function ClientOnly({ children }) {
4
+ const [mounted, setMounted] = useState(false);
5
+ useEffect(() => setMounted(true), []);
6
+ if (!mounted) return null;
7
+ return /* @__PURE__ */ jsx(Fragment, { children });
8
+ }
9
+ export {
10
+ ClientOnly
11
+ };
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ interface CodeBlockProps {
3
+ children: ReactNode;
4
+ filename?: string;
5
+ lang?: string;
6
+ }
7
+ /**
8
+ * Wraps a Shiki-rendered <pre><code> with the dreamlake header bar
9
+ * (lang label + filename + line-number toggle + Copy). Children come
10
+ * straight from MDX.
11
+ */
12
+ export declare function CodeBlock({ children, filename, lang }: CodeBlockProps): import("react").JSX.Element;
13
+ export {};
@@ -0,0 +1,155 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useRef, useState } from "react";
3
+ import { useLineNumbers } from "../lib/use-line-numbers.js";
4
+ const headerBtnStyle = (active) => ({
5
+ display: "inline-flex",
6
+ alignItems: "center",
7
+ gap: 4,
8
+ fontFamily: "var(--font-doc-template-mono)",
9
+ fontSize: 10,
10
+ letterSpacing: "0.04em",
11
+ textTransform: "uppercase",
12
+ color: active ? "var(--color-doc-template-accent)" : "var(--color-doc-template-muted)",
13
+ background: "transparent",
14
+ border: `1px solid ${active ? "var(--color-doc-template-accent)" : "var(--color-doc-template-faint)"}`,
15
+ borderRadius: 4,
16
+ padding: "2px 8px",
17
+ height: 22,
18
+ cursor: "pointer",
19
+ transition: "color 0.12s ease, border-color 0.12s ease"
20
+ });
21
+ function CodeBlock({ children, filename, lang }) {
22
+ const wrapRef = useRef(null);
23
+ const [copied, setCopied] = useState(false);
24
+ const [showLines, setShowLines] = useLineNumbers();
25
+ function copy() {
26
+ const el = wrapRef.current?.querySelector("pre code");
27
+ if (!el) return;
28
+ navigator.clipboard.writeText(el.innerText).then(
29
+ () => {
30
+ setCopied(true);
31
+ setTimeout(() => setCopied(false), 1400);
32
+ },
33
+ () => {
34
+ }
35
+ );
36
+ }
37
+ return /* @__PURE__ */ jsxs(
38
+ "div",
39
+ {
40
+ ref: wrapRef,
41
+ "data-line-numbers": showLines ? "on" : "off",
42
+ className: "group relative border border-doc-template-faint bg-doc-template-code",
43
+ style: {
44
+ margin: "18px 0 22px",
45
+ borderRadius: "var(--radius-doc-template)",
46
+ overflow: "hidden"
47
+ },
48
+ children: [
49
+ filename && /* @__PURE__ */ jsxs(
50
+ "div",
51
+ {
52
+ className: "flex items-center border-b border-doc-template-faint text-doc-template-muted",
53
+ style: {
54
+ gap: 12,
55
+ padding: "6px 10px 6px 14px",
56
+ fontFamily: "var(--font-doc-template-mono)",
57
+ fontSize: 10,
58
+ letterSpacing: "0.06em",
59
+ background: "color-mix(in srgb, var(--color-doc-template-ink) 3%, transparent)"
60
+ },
61
+ children: [
62
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 600, textTransform: "none", letterSpacing: 0 }, children: filename }),
63
+ lang && /* @__PURE__ */ jsx("span", { className: "uppercase", style: { fontWeight: 600, letterSpacing: "0.06em" }, children: lang }),
64
+ /* @__PURE__ */ jsx("span", { style: { flex: 1 } }),
65
+ /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center", style: { gap: 6 }, children: [
66
+ /* @__PURE__ */ jsx(
67
+ "button",
68
+ {
69
+ type: "button",
70
+ "aria-pressed": showLines,
71
+ title: showLines ? ":set nonu" : ":set nu",
72
+ onClick: () => setShowLines(!showLines),
73
+ style: headerBtnStyle(showLines),
74
+ children: /* @__PURE__ */ jsx(HashIcon, {})
75
+ }
76
+ ),
77
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: copy, style: headerBtnStyle(copied), children: copied ? "Copied" : "Copy" })
78
+ ] })
79
+ ]
80
+ }
81
+ ),
82
+ !filename && /* @__PURE__ */ jsxs(
83
+ "div",
84
+ {
85
+ className: "absolute top-0 right-0 z-10 flex items-center opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity duration-150",
86
+ style: { gap: 6, padding: "8px 8px" },
87
+ children: [
88
+ lang && /* @__PURE__ */ jsx(
89
+ "span",
90
+ {
91
+ className: "text-doc-template-muted uppercase",
92
+ style: {
93
+ fontFamily: "var(--font-doc-template-mono)",
94
+ fontSize: 10,
95
+ fontWeight: 600,
96
+ letterSpacing: "0.04em",
97
+ marginRight: 2
98
+ },
99
+ children: lang
100
+ }
101
+ ),
102
+ /* @__PURE__ */ jsx(
103
+ "button",
104
+ {
105
+ type: "button",
106
+ "aria-pressed": showLines,
107
+ title: showLines ? ":set nonu" : ":set nu",
108
+ onClick: () => setShowLines(!showLines),
109
+ style: headerBtnStyle(showLines),
110
+ children: /* @__PURE__ */ jsx(HashIcon, {})
111
+ }
112
+ ),
113
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: copy, style: headerBtnStyle(copied), children: copied ? "Copied" : "Copy" })
114
+ ]
115
+ }
116
+ ),
117
+ /* @__PURE__ */ jsx(
118
+ "div",
119
+ {
120
+ style: {
121
+ fontFamily: "var(--font-doc-template-mono)",
122
+ fontSize: 12.5,
123
+ lineHeight: 1.3
124
+ },
125
+ children
126
+ }
127
+ )
128
+ ]
129
+ }
130
+ );
131
+ }
132
+ function HashIcon() {
133
+ return /* @__PURE__ */ jsxs(
134
+ "svg",
135
+ {
136
+ viewBox: "0 0 24 24",
137
+ fill: "none",
138
+ stroke: "currentColor",
139
+ strokeWidth: "2",
140
+ strokeLinecap: "round",
141
+ strokeLinejoin: "round",
142
+ "aria-hidden": true,
143
+ style: { width: 10, height: 10, display: "block" },
144
+ children: [
145
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "9", x2: "20", y2: "9" }),
146
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "15", x2: "20", y2: "15" }),
147
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "3", x2: "8", y2: "21" }),
148
+ /* @__PURE__ */ jsx("line", { x1: "16", y1: "3", x2: "14", y2: "21" })
149
+ ]
150
+ }
151
+ );
152
+ }
153
+ export {
154
+ CodeBlock
155
+ };
@@ -0,0 +1 @@
1
+ export declare function DocFooter(): import("react").JSX.Element | null;
@@ -0,0 +1,63 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { usePageContext } from "vike-react/usePageContext";
3
+ import { getAdjacentPages } from "../lib/navigation.js";
4
+ import { useHiddenToggle } from "../lib/use-hidden-toggle.js";
5
+ const LINK = {
6
+ display: "flex",
7
+ flexDirection: "column",
8
+ gap: 4,
9
+ padding: "12px 14px",
10
+ border: "1px solid var(--color-doc-template-faint)",
11
+ borderRadius: "var(--radius-doc-template)",
12
+ textDecoration: "none",
13
+ background: "var(--color-doc-template-panel)",
14
+ transition: "border-color 0.15s ease"
15
+ };
16
+ const LABEL = {
17
+ fontFamily: "var(--font-doc-template-mono)",
18
+ fontSize: 10,
19
+ letterSpacing: "0.12em",
20
+ textTransform: "uppercase",
21
+ color: "var(--color-doc-template-muted)"
22
+ };
23
+ function DocFooter() {
24
+ const { urlPathname } = usePageContext();
25
+ const [showHidden] = useHiddenToggle();
26
+ const { prev, next } = getAdjacentPages(urlPathname, { includeHidden: showHidden });
27
+ if (!prev && !next) return null;
28
+ return /* @__PURE__ */ jsxs(
29
+ "nav",
30
+ {
31
+ "aria-label": "Page navigation",
32
+ style: {
33
+ display: "grid",
34
+ gridTemplateColumns: "1fr 1fr",
35
+ gap: 12,
36
+ marginTop: 64,
37
+ paddingTop: 24,
38
+ borderTop: "1px solid var(--color-doc-template-faint)"
39
+ },
40
+ children: [
41
+ prev ? /* @__PURE__ */ jsxs("a", { href: prev.path, style: LINK, className: "hover:[border-color:var(--color-doc-template-accent)]", children: [
42
+ /* @__PURE__ */ jsx("span", { style: LABEL, children: "← Prev" }),
43
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, fontWeight: 600 }, children: prev.title })
44
+ ] }) : /* @__PURE__ */ jsx("span", {}),
45
+ next ? /* @__PURE__ */ jsxs(
46
+ "a",
47
+ {
48
+ href: next.path,
49
+ style: { ...LINK, textAlign: "right" },
50
+ className: "hover:[border-color:var(--color-doc-template-accent)]",
51
+ children: [
52
+ /* @__PURE__ */ jsx("span", { style: LABEL, children: "Next →" }),
53
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, fontWeight: 600 }, children: next.title })
54
+ ]
55
+ }
56
+ ) : /* @__PURE__ */ jsx("span", {})
57
+ ]
58
+ }
59
+ );
60
+ }
61
+ export {
62
+ DocFooter
63
+ };
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from 'react';
2
+ export interface PreviewProps {
3
+ /** Live-rendered example. Pass a component or JSX. */
4
+ children: ReactNode;
5
+ /** Source code for the example (use `import src from './x.tsx?raw'`). */
6
+ source: string;
7
+ /** Optional matching dataIO source — surfaces a `Data` tab. */
8
+ dataSource?: string;
9
+ /** Filename shown in the tab header. */
10
+ filename?: string;
11
+ /** Default tab. */
12
+ defaultTab?: 'preview' | 'source' | 'data';
13
+ /** Force a height for the preview pane. */
14
+ height?: number | string;
15
+ }
16
+ export declare function Preview({ children, source, dataSource, filename, defaultTab, height, }: PreviewProps): import("react").JSX.Element;
@@ -0,0 +1,220 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
3
+ import { useLineNumbers } from "../lib/use-line-numbers.js";
4
+ function langFromFilename(name) {
5
+ if (!name) return "tsx";
6
+ const ext = name.split(".").pop()?.toLowerCase();
7
+ switch (ext) {
8
+ case "ts":
9
+ case "tsx":
10
+ case "js":
11
+ case "jsx":
12
+ case "json":
13
+ case "css":
14
+ case "html":
15
+ case "md":
16
+ case "mdx":
17
+ case "bash":
18
+ case "sh":
19
+ return ext;
20
+ default:
21
+ return "tsx";
22
+ }
23
+ }
24
+ function HighlightedSource({ code, filename }) {
25
+ const [html, setHtml] = useState(null);
26
+ useEffect(() => {
27
+ let alive = true;
28
+ setHtml(null);
29
+ (async () => {
30
+ try {
31
+ const { codeToHtml } = await import("shiki");
32
+ const out = await codeToHtml(code, {
33
+ lang: langFromFilename(filename),
34
+ themes: { light: "github-light", dark: "github-dark" },
35
+ defaultColor: false
36
+ });
37
+ if (alive) setHtml(out);
38
+ } catch {
39
+ if (alive) setHtml(null);
40
+ }
41
+ })();
42
+ return () => {
43
+ alive = false;
44
+ };
45
+ }, [code, filename]);
46
+ if (html) return /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: html } });
47
+ return /* @__PURE__ */ jsx(
48
+ "pre",
49
+ {
50
+ style: {
51
+ margin: 0,
52
+ padding: "14px 16px",
53
+ fontFamily: "var(--font-doc-template-mono)",
54
+ fontSize: 12.5,
55
+ lineHeight: 1.3,
56
+ overflowX: "auto",
57
+ background: "transparent"
58
+ },
59
+ children: /* @__PURE__ */ jsx("code", { children: code })
60
+ }
61
+ );
62
+ }
63
+ const TAB = {
64
+ fontFamily: "var(--font-doc-template-mono)",
65
+ fontSize: 10,
66
+ fontWeight: 600,
67
+ letterSpacing: "0.06em",
68
+ textTransform: "uppercase",
69
+ border: "1px solid transparent",
70
+ borderRadius: 4,
71
+ padding: "3px 8px",
72
+ height: 22,
73
+ background: "transparent",
74
+ cursor: "pointer",
75
+ transition: "color 0.12s ease, background 0.12s ease, border-color 0.12s ease"
76
+ };
77
+ const headerBtnStyle = (active) => ({
78
+ display: "inline-flex",
79
+ alignItems: "center",
80
+ gap: 4,
81
+ fontFamily: "var(--font-doc-template-mono)",
82
+ fontSize: 10,
83
+ letterSpacing: "0.04em",
84
+ textTransform: "uppercase",
85
+ color: active ? "var(--color-doc-template-accent)" : "var(--color-doc-template-muted)",
86
+ background: "transparent",
87
+ border: `1px solid ${active ? "var(--color-doc-template-accent)" : "var(--color-doc-template-faint)"}`,
88
+ borderRadius: 4,
89
+ padding: "2px 8px",
90
+ height: 22,
91
+ cursor: "pointer",
92
+ transition: "color 0.12s ease, border-color 0.12s ease"
93
+ });
94
+ function HashIcon() {
95
+ return /* @__PURE__ */ jsxs(
96
+ "svg",
97
+ {
98
+ viewBox: "0 0 24 24",
99
+ fill: "none",
100
+ stroke: "currentColor",
101
+ strokeWidth: "2",
102
+ strokeLinecap: "round",
103
+ strokeLinejoin: "round",
104
+ "aria-hidden": true,
105
+ style: { width: 10, height: 10, display: "block" },
106
+ children: [
107
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "9", x2: "20", y2: "9" }),
108
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "15", x2: "20", y2: "15" }),
109
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "3", x2: "8", y2: "21" }),
110
+ /* @__PURE__ */ jsx("line", { x1: "16", y1: "3", x2: "14", y2: "21" })
111
+ ]
112
+ }
113
+ );
114
+ }
115
+ function Preview({
116
+ children,
117
+ source,
118
+ dataSource,
119
+ filename,
120
+ defaultTab = "preview",
121
+ height
122
+ }) {
123
+ const [tab, setTab] = useState(defaultTab);
124
+ const [copied, setCopied] = useState(false);
125
+ const [showLines, setShowLines] = useLineNumbers();
126
+ const visibleSource = tab === "data" ? dataSource ?? "" : source;
127
+ function copy() {
128
+ navigator.clipboard.writeText(visibleSource).then(
129
+ () => {
130
+ setCopied(true);
131
+ setTimeout(() => setCopied(false), 1400);
132
+ },
133
+ () => {
134
+ }
135
+ );
136
+ }
137
+ return /* @__PURE__ */ jsxs(
138
+ "div",
139
+ {
140
+ "data-line-numbers": showLines ? "on" : "off",
141
+ className: "border border-doc-template-faint bg-doc-template-panel",
142
+ style: { margin: "18px 0 22px", borderRadius: "var(--radius-doc-template)", overflow: "hidden" },
143
+ children: [
144
+ /* @__PURE__ */ jsxs(
145
+ "div",
146
+ {
147
+ className: "flex items-center border-b border-doc-template-faint",
148
+ style: {
149
+ gap: 10,
150
+ padding: "6px 10px 6px 6px",
151
+ background: "color-mix(in srgb, var(--color-doc-template-ink) 3%, transparent)"
152
+ },
153
+ children: [
154
+ /* @__PURE__ */ jsx("div", { style: { display: "inline-flex", gap: 2 }, role: "tablist", children: ["preview", "source", ...dataSource ? ["data"] : []].map((t) => {
155
+ const active = t === tab;
156
+ return /* @__PURE__ */ jsx(
157
+ "button",
158
+ {
159
+ type: "button",
160
+ role: "tab",
161
+ "aria-selected": active,
162
+ onClick: () => setTab(t),
163
+ style: {
164
+ ...TAB,
165
+ color: active ? "var(--color-doc-template-ink)" : "var(--color-doc-template-muted)",
166
+ background: active ? "var(--color-doc-template-bg)" : "transparent",
167
+ borderColor: active ? "var(--color-doc-template-faint)" : "transparent"
168
+ },
169
+ children: t === "preview" ? "Preview" : t === "source" ? "Source" : "Data"
170
+ },
171
+ t
172
+ );
173
+ }) }),
174
+ filename && tab !== "preview" && /* @__PURE__ */ jsx(
175
+ "span",
176
+ {
177
+ className: "text-doc-template-muted",
178
+ style: { fontFamily: "var(--font-doc-template-mono)", fontSize: 10, marginLeft: 4 },
179
+ children: filename
180
+ }
181
+ ),
182
+ tab !== "preview" && /* @__PURE__ */ jsxs(Fragment, { children: [
183
+ /* @__PURE__ */ jsx("span", { style: { marginLeft: "auto" } }),
184
+ /* @__PURE__ */ jsxs(
185
+ "button",
186
+ {
187
+ type: "button",
188
+ "aria-pressed": showLines,
189
+ "aria-label": showLines ? "Hide line numbers" : "Show line numbers",
190
+ title: showLines ? ":set nonu" : ":set nu",
191
+ onClick: () => setShowLines(!showLines),
192
+ style: headerBtnStyle(showLines),
193
+ children: [
194
+ /* @__PURE__ */ jsx(HashIcon, {}),
195
+ /* @__PURE__ */ jsx("span", { children: showLines ? ":set nonu" : ":set nu" })
196
+ ]
197
+ }
198
+ ),
199
+ /* @__PURE__ */ jsx(
200
+ "button",
201
+ {
202
+ type: "button",
203
+ onClick: copy,
204
+ "aria-label": "Copy source",
205
+ style: headerBtnStyle(copied),
206
+ children: copied ? "Copied" : "Copy"
207
+ }
208
+ )
209
+ ] })
210
+ ]
211
+ }
212
+ ),
213
+ tab === "preview" ? /* @__PURE__ */ jsx("div", { style: { padding: 24, minHeight: 80, ...height ? { height } : null }, children }) : /* @__PURE__ */ jsx("div", { style: { background: "var(--color-doc-template-code)" }, children: /* @__PURE__ */ jsx(HighlightedSource, { code: visibleSource, filename }) })
214
+ ]
215
+ }
216
+ );
217
+ }
218
+ export {
219
+ Preview
220
+ };
@@ -0,0 +1,8 @@
1
+ import { JSX } from 'react';
2
+ interface SearchPaletteProps {
3
+ open: boolean;
4
+ onClose: () => void;
5
+ query: string;
6
+ }
7
+ export declare function SearchPalette({ open, onClose, query }: SearchPaletteProps): JSX.Element | null;
8
+ export {};