@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.
- package/dist/components/Callout.d.ts +11 -0
- package/dist/components/Callout.js +101 -0
- package/dist/components/ClientOnly.d.ts +4 -0
- package/dist/components/ClientOnly.js +11 -0
- package/dist/components/CodeBlock.d.ts +13 -0
- package/dist/components/CodeBlock.js +155 -0
- package/dist/components/DocFooter.d.ts +1 -0
- package/dist/components/DocFooter.js +63 -0
- package/dist/components/Preview.d.ts +16 -0
- package/dist/components/Preview.js +220 -0
- package/dist/components/SearchPalette.d.ts +8 -0
- package/dist/components/SearchPalette.js +678 -0
- package/dist/components/SearchResize.d.ts +11 -0
- package/dist/components/SearchResize.js +150 -0
- package/dist/components/Sidebar.d.ts +1 -0
- package/dist/components/Sidebar.js +134 -0
- package/dist/components/StatusTable.d.ts +19 -0
- package/dist/components/StatusTable.js +251 -0
- package/dist/components/TOC.d.ts +1 -0
- package/dist/components/TOC.js +674 -0
- package/dist/components/TabStrip.d.ts +8 -0
- package/dist/components/TabStrip.js +105 -0
- package/dist/components/ThemeProvider.d.ts +11 -0
- package/dist/components/ThemeProvider.js +40 -0
- package/dist/components/ThemeToggle.d.ts +2 -0
- package/dist/components/ThemeToggle.js +109 -0
- package/dist/components/Topbar.d.ts +9 -0
- package/dist/components/Topbar.js +818 -0
- package/dist/components/mdx-components.d.ts +30 -0
- package/dist/components/mdx-components.js +346 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +81 -0
- package/dist/lib/navigation.d.ts +80 -0
- package/dist/lib/navigation.js +57 -0
- package/dist/lib/pagefind-search.d.ts +21 -0
- package/dist/lib/pagefind-search.js +201 -0
- package/dist/lib/search-index.d.ts +43 -0
- package/dist/lib/search-index.js +112 -0
- package/dist/lib/tabs.d.ts +23 -0
- package/dist/lib/tabs.js +30 -0
- package/dist/lib/use-hidden-toggle.d.ts +15 -0
- package/dist/lib/use-hidden-toggle.js +23 -0
- package/dist/lib/use-line-numbers.d.ts +9 -0
- package/dist/lib/use-line-numbers.js +7 -0
- package/dist/lib/use-local-storage.d.ts +15 -0
- package/dist/lib/use-local-storage.js +58 -0
- package/dist/lib/use-media-query.d.ts +5 -0
- package/dist/lib/use-media-query.js +16 -0
- package/dist/renderer/Layout.d.ts +5 -0
- package/dist/renderer/Layout.js +170 -0
- package/dist/renderer/onRenderClient.d.ts +1 -0
- package/dist/renderer/onRenderClient.js +23 -0
- package/dist/renderer/onRenderHtml.d.ts +5 -0
- package/dist/renderer/onRenderHtml.js +44 -0
- package/dist/site-config.d.ts +61 -0
- package/dist/site-config.js +21 -0
- package/dist/styles.css +310 -0
- package/dist/vike.d.ts +12 -0
- package/dist/vike.js +8 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.js +80 -0
- package/package.json +82 -0
- package/templates/netlify.example.toml +33 -0
- package/templates/set-version.mjs +70 -0
- package/templates/version-branch.sh +16 -0
- package/templates/versions.example.json +15 -0
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect } from "react";
|
|
3
|
+
import { defaultResults, searchPages } from "../lib/pagefind-search.js";
|
|
4
|
+
import { useMediaQuery } from "../lib/use-media-query.js";
|
|
5
|
+
import { useSearchResize, SearchResizeHandles } from "./SearchResize.js";
|
|
6
|
+
import { useHiddenToggle } from "../lib/use-hidden-toggle.js";
|
|
7
|
+
const PAL_MAX_W = 860;
|
|
8
|
+
const PAL_GUTTER = 24;
|
|
9
|
+
const PAL_INSET = `max(${PAL_GUTTER}px, calc((100vw - ${PAL_MAX_W}px) / 2))`;
|
|
10
|
+
const PAL_EASE = "cubic-bezier(0.16, 1, 0.3, 1)";
|
|
11
|
+
const PAL_MS = 280;
|
|
12
|
+
function SearchPalette({ open, onClose, query }) {
|
|
13
|
+
const [showHidden] = useHiddenToggle();
|
|
14
|
+
const [active, setActive] = useState(0);
|
|
15
|
+
const [splitPx, setSplitPx] = useState(() => {
|
|
16
|
+
if (typeof window === "undefined") return 360;
|
|
17
|
+
const stored = Number(localStorage.getItem("palette-split"));
|
|
18
|
+
return Number.isFinite(stored) && stored > 0 ? stored : 360;
|
|
19
|
+
});
|
|
20
|
+
const draggingRef = useRef(false);
|
|
21
|
+
const [gripY, setGripY] = useState(null);
|
|
22
|
+
const isNarrowInset = useMediaQuery("(max-width: 767px)");
|
|
23
|
+
const isSingleCol = useMediaQuery("(max-width: 639px)");
|
|
24
|
+
const [hits, setHits] = useState(defaultResults);
|
|
25
|
+
const totalChars = hits.reduce((sum, h) => sum + h.title.length + (h.snippet?.length || 0) + (h.description?.length || 0), 0);
|
|
26
|
+
const { panelH, effectiveH, isResizing, startResize, resetHeight } = useSearchResize(hits.length, totalChars);
|
|
27
|
+
const prevQueryRef = useRef("");
|
|
28
|
+
const prevOrderRef = useRef([]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
let cancelled = false;
|
|
31
|
+
searchPages(query, 30, showHidden).then((results) => {
|
|
32
|
+
if (cancelled) return;
|
|
33
|
+
const prevQ = prevQueryRef.current;
|
|
34
|
+
const isExtending = query.length > prevQ.length && query.toLowerCase().startsWith(prevQ.toLowerCase()) && prevQ.length > 0;
|
|
35
|
+
if (isExtending && prevOrderRef.current.length > 0) {
|
|
36
|
+
const resultMap = new Map(results.map((r) => [r.path, r]));
|
|
37
|
+
const stable = [];
|
|
38
|
+
for (const path of prevOrderRef.current) {
|
|
39
|
+
const r = resultMap.get(path);
|
|
40
|
+
if (r) {
|
|
41
|
+
stable.push(r);
|
|
42
|
+
resultMap.delete(path);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const fresh = [...resultMap.values()].sort((a, b) => b.score - a.score);
|
|
46
|
+
for (const r of fresh) {
|
|
47
|
+
const insertIdx = stable.findIndex((s) => r.score > s.score);
|
|
48
|
+
if (insertIdx >= 0) stable.splice(insertIdx, 0, r);
|
|
49
|
+
else stable.push(r);
|
|
50
|
+
}
|
|
51
|
+
prevOrderRef.current = stable.map((r) => r.path);
|
|
52
|
+
prevQueryRef.current = query;
|
|
53
|
+
setHits(stable);
|
|
54
|
+
} else {
|
|
55
|
+
prevOrderRef.current = results.map((r) => r.path);
|
|
56
|
+
prevQueryRef.current = query;
|
|
57
|
+
setHits(results);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return () => {
|
|
61
|
+
cancelled = true;
|
|
62
|
+
};
|
|
63
|
+
}, [query, showHidden]);
|
|
64
|
+
const previewBodyRef = useRef(null);
|
|
65
|
+
const [pageHtml, setPageHtml] = useState("");
|
|
66
|
+
const pageCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
67
|
+
const activePath = hits[active]?.path;
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (!activePath || isSingleCol) {
|
|
70
|
+
setPageHtml("");
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const cached = pageCacheRef.current.get(activePath);
|
|
74
|
+
if (cached !== void 0) {
|
|
75
|
+
setPageHtml(cached);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
setPageHtml("");
|
|
79
|
+
let cancelled = false;
|
|
80
|
+
fetch(activePath).then((r) => r.ok ? r.text() : "").then((html) => {
|
|
81
|
+
if (cancelled) return;
|
|
82
|
+
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
83
|
+
const main = doc.querySelector("[data-pagefind-body]");
|
|
84
|
+
main?.querySelectorAll("[data-pagefind-ignore], script, style").forEach((el) => el.remove());
|
|
85
|
+
const h1 = main?.querySelector("h1");
|
|
86
|
+
h1?.remove();
|
|
87
|
+
main?.querySelectorAll("h2, h3").forEach((el) => {
|
|
88
|
+
el.removeAttribute("style");
|
|
89
|
+
el.removeAttribute("class");
|
|
90
|
+
});
|
|
91
|
+
const content = main?.innerHTML ?? "";
|
|
92
|
+
pageCacheRef.current.set(activePath, content);
|
|
93
|
+
setPageHtml(content);
|
|
94
|
+
}).catch(() => {
|
|
95
|
+
if (!cancelled) setPageHtml("");
|
|
96
|
+
});
|
|
97
|
+
return () => {
|
|
98
|
+
cancelled = true;
|
|
99
|
+
};
|
|
100
|
+
}, [active, activePath, isSingleCol]);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (!open) return;
|
|
103
|
+
setActive(0);
|
|
104
|
+
}, [open]);
|
|
105
|
+
useEffect(() => setActive(0), [query]);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
const el = previewBodyRef.current;
|
|
108
|
+
if (!el) return;
|
|
109
|
+
requestAnimationFrame(() => {
|
|
110
|
+
const mark = el.querySelector("mark");
|
|
111
|
+
if (mark) mark.scrollIntoView({ block: "center", behavior: "instant" });
|
|
112
|
+
else el.scrollTop = 0;
|
|
113
|
+
});
|
|
114
|
+
}, [activePath, query]);
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
if (!open) return;
|
|
117
|
+
function onKey(e) {
|
|
118
|
+
if (e.key === "Escape") onClose();
|
|
119
|
+
else if (e.key === "ArrowDown") {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
setActive((a) => Math.min(a + 1, Math.max(hits.length - 1, 0)));
|
|
122
|
+
} else if (e.key === "ArrowUp") {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
setActive((a) => Math.max(a - 1, 0));
|
|
125
|
+
} else if (e.key === "Enter") {
|
|
126
|
+
const hit = hits[active];
|
|
127
|
+
if (hit) window.location.href = hit.path;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
window.addEventListener("keydown", onKey);
|
|
131
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
132
|
+
}, [open, onClose, hits, active]);
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
function onMove(e) {
|
|
135
|
+
if (!draggingRef.current) return;
|
|
136
|
+
const dlg = document.querySelector("[data-palette-panel]");
|
|
137
|
+
if (!dlg) return;
|
|
138
|
+
const rect = dlg.getBoundingClientRect();
|
|
139
|
+
const x = Math.max(200, Math.min(e.clientX - rect.left, rect.width - 200));
|
|
140
|
+
setSplitPx(x);
|
|
141
|
+
setGripY(Math.max(0, Math.min(e.clientY - rect.top, rect.height)));
|
|
142
|
+
}
|
|
143
|
+
function onUp() {
|
|
144
|
+
if (draggingRef.current) {
|
|
145
|
+
draggingRef.current = false;
|
|
146
|
+
setGripY(null);
|
|
147
|
+
localStorage.setItem("palette-split", String(splitPx));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
window.addEventListener("mousemove", onMove);
|
|
151
|
+
window.addEventListener("mouseup", onUp);
|
|
152
|
+
return () => {
|
|
153
|
+
window.removeEventListener("mousemove", onMove);
|
|
154
|
+
window.removeEventListener("mouseup", onUp);
|
|
155
|
+
};
|
|
156
|
+
}, [splitPx]);
|
|
157
|
+
const [mounted, setMounted] = useState(open);
|
|
158
|
+
const [visible, setVisible] = useState(false);
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (open) {
|
|
161
|
+
setMounted(true);
|
|
162
|
+
let raf2 = 0;
|
|
163
|
+
const raf1 = requestAnimationFrame(() => {
|
|
164
|
+
raf2 = requestAnimationFrame(() => setVisible(true));
|
|
165
|
+
});
|
|
166
|
+
return () => {
|
|
167
|
+
cancelAnimationFrame(raf1);
|
|
168
|
+
if (raf2) cancelAnimationFrame(raf2);
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
setVisible(false);
|
|
172
|
+
const t = window.setTimeout(() => setMounted(false), PAL_MS + 40);
|
|
173
|
+
return () => window.clearTimeout(t);
|
|
174
|
+
}, [open]);
|
|
175
|
+
if (!mounted) return null;
|
|
176
|
+
const previewHit = hits[active];
|
|
177
|
+
function highlight(text, q) {
|
|
178
|
+
if (!q) return text;
|
|
179
|
+
const lc = text.toLowerCase();
|
|
180
|
+
const lq = q.toLowerCase();
|
|
181
|
+
const out = [];
|
|
182
|
+
let from = 0;
|
|
183
|
+
let key = 0;
|
|
184
|
+
while (true) {
|
|
185
|
+
const idx = lc.indexOf(lq, from);
|
|
186
|
+
if (idx < 0) {
|
|
187
|
+
out.push(text.slice(from));
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
if (idx > from) out.push(text.slice(from, idx));
|
|
191
|
+
out.push(
|
|
192
|
+
/* @__PURE__ */ jsx(
|
|
193
|
+
"mark",
|
|
194
|
+
{
|
|
195
|
+
style: {
|
|
196
|
+
background: "color-mix(in srgb, var(--color-doc-template-accent) 18%, transparent)",
|
|
197
|
+
color: "var(--color-doc-template-ink)",
|
|
198
|
+
opacity: 1,
|
|
199
|
+
fontWeight: 600,
|
|
200
|
+
borderRadius: 2,
|
|
201
|
+
padding: "0 1px"
|
|
202
|
+
},
|
|
203
|
+
children: text.slice(idx, idx + q.length)
|
|
204
|
+
},
|
|
205
|
+
`m${key++}`
|
|
206
|
+
)
|
|
207
|
+
);
|
|
208
|
+
from = idx + q.length;
|
|
209
|
+
}
|
|
210
|
+
return out;
|
|
211
|
+
}
|
|
212
|
+
function highlightHtml(html, q) {
|
|
213
|
+
if (!q.trim()) return html;
|
|
214
|
+
const ql = q.trim().toLowerCase();
|
|
215
|
+
return html.split(/(<[^>]*>)/g).map((part, i) => {
|
|
216
|
+
if (i % 2 === 1) return part;
|
|
217
|
+
const lc = part.toLowerCase();
|
|
218
|
+
if (!lc.includes(ql)) return part;
|
|
219
|
+
let result = "";
|
|
220
|
+
let last = 0;
|
|
221
|
+
while (true) {
|
|
222
|
+
const idx = lc.indexOf(ql, last);
|
|
223
|
+
if (idx < 0) break;
|
|
224
|
+
result += part.slice(last, idx);
|
|
225
|
+
result += `<mark>${part.slice(idx, idx + q.trim().length)}</mark>`;
|
|
226
|
+
last = idx + q.trim().length;
|
|
227
|
+
}
|
|
228
|
+
return result + part.slice(last);
|
|
229
|
+
}).join("");
|
|
230
|
+
}
|
|
231
|
+
const backdropStyle = {
|
|
232
|
+
position: "fixed",
|
|
233
|
+
inset: 0,
|
|
234
|
+
zIndex: 40,
|
|
235
|
+
background: "color-mix(in srgb, #000 28%, transparent)",
|
|
236
|
+
backdropFilter: "blur(6px) saturate(105%)",
|
|
237
|
+
WebkitBackdropFilter: "blur(6px) saturate(105%)",
|
|
238
|
+
opacity: visible ? 1 : 0,
|
|
239
|
+
pointerEvents: visible ? "auto" : "none",
|
|
240
|
+
transition: `opacity ${PAL_MS}ms ease`
|
|
241
|
+
};
|
|
242
|
+
const panelStyle = {
|
|
243
|
+
position: "fixed",
|
|
244
|
+
top: 40,
|
|
245
|
+
left: isNarrowInset ? 12 : PAL_INSET,
|
|
246
|
+
right: isNarrowInset ? 12 : PAL_INSET,
|
|
247
|
+
zIndex: 49,
|
|
248
|
+
background: "var(--color-doc-template-bg)",
|
|
249
|
+
border: "1px solid var(--color-doc-template-faint)",
|
|
250
|
+
borderRadius: 16,
|
|
251
|
+
boxShadow: "0 24px 60px rgb(0 0 0 / 0.18), 0 6px 18px rgb(0 0 0 / 0.06)",
|
|
252
|
+
display: "flex",
|
|
253
|
+
flexDirection: "column",
|
|
254
|
+
overflow: "hidden",
|
|
255
|
+
opacity: visible ? 1 : 0,
|
|
256
|
+
pointerEvents: visible ? "auto" : "none",
|
|
257
|
+
transform: visible ? "translateY(0)" : "translateY(-8px)",
|
|
258
|
+
...panelH != null ? { height: visible ? panelH : 0 } : {},
|
|
259
|
+
maxHeight: visible ? effectiveH : 0,
|
|
260
|
+
transformOrigin: "top center",
|
|
261
|
+
transition: isResizing ? "none" : `opacity ${PAL_MS}ms ${PAL_EASE}, transform ${PAL_MS}ms ${PAL_EASE}, max-height ${PAL_MS}ms ${PAL_EASE}${panelH != null ? `, height ${PAL_MS}ms ${PAL_EASE}` : ""}`
|
|
262
|
+
};
|
|
263
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
264
|
+
/* @__PURE__ */ jsx("div", { style: backdropStyle, onClick: onClose }),
|
|
265
|
+
/* @__PURE__ */ jsxs("div", { "data-palette-panel": true, role: "dialog", "aria-modal": "true", "aria-label": "Search", style: panelStyle, children: [
|
|
266
|
+
/* @__PURE__ */ jsxs(
|
|
267
|
+
"div",
|
|
268
|
+
{
|
|
269
|
+
className: "grid flex-1",
|
|
270
|
+
style: {
|
|
271
|
+
gridTemplateColumns: isSingleCol ? "1fr" : `${splitPx}px 1fr`,
|
|
272
|
+
minHeight: 0,
|
|
273
|
+
position: "relative"
|
|
274
|
+
},
|
|
275
|
+
children: [
|
|
276
|
+
/* @__PURE__ */ jsxs(
|
|
277
|
+
"ul",
|
|
278
|
+
{
|
|
279
|
+
className: "m-0 overflow-y-auto list-none select-none",
|
|
280
|
+
style: {
|
|
281
|
+
padding: 6,
|
|
282
|
+
borderRight: isSingleCol ? "0" : "1px solid var(--color-doc-template-faint)",
|
|
283
|
+
background: "color-mix(in srgb, var(--color-doc-template-panel) 35%, var(--color-doc-template-bg))"
|
|
284
|
+
},
|
|
285
|
+
children: [
|
|
286
|
+
hits.length === 0 && /* @__PURE__ */ jsx("li", { className: "text-doc-template-muted", style: { padding: "8px 10px", fontSize: 13 }, children: "No matches." }),
|
|
287
|
+
hits.map((hit, i) => /* @__PURE__ */ jsxs(
|
|
288
|
+
"li",
|
|
289
|
+
{
|
|
290
|
+
onMouseEnter: () => setActive(i),
|
|
291
|
+
onClick: () => {
|
|
292
|
+
window.location.href = hit.path;
|
|
293
|
+
},
|
|
294
|
+
className: i === active ? "flex items-center gap-2.5 cursor-pointer bg-doc-template-selected text-doc-template-ink" : "flex items-center gap-2.5 cursor-pointer text-doc-template-ink",
|
|
295
|
+
style: {
|
|
296
|
+
padding: "4px 10px",
|
|
297
|
+
borderRadius: 10,
|
|
298
|
+
fontFamily: "var(--font-doc-template-ui)",
|
|
299
|
+
fontSize: 13,
|
|
300
|
+
transition: "background 0.1s ease"
|
|
301
|
+
},
|
|
302
|
+
children: [
|
|
303
|
+
/* @__PURE__ */ jsx(
|
|
304
|
+
"span",
|
|
305
|
+
{
|
|
306
|
+
className: i === active ? "inline-flex items-center justify-center text-doc-template-accent shrink-0" : "inline-flex items-center justify-center text-doc-template-muted shrink-0",
|
|
307
|
+
style: {
|
|
308
|
+
width: 24,
|
|
309
|
+
height: 24,
|
|
310
|
+
borderRadius: 5,
|
|
311
|
+
background: i === active ? "var(--color-doc-template-accent-soft)" : "var(--color-doc-template-chip)"
|
|
312
|
+
},
|
|
313
|
+
children: /* @__PURE__ */ jsxs(
|
|
314
|
+
"svg",
|
|
315
|
+
{
|
|
316
|
+
viewBox: "0 0 24 24",
|
|
317
|
+
fill: "none",
|
|
318
|
+
stroke: "currentColor",
|
|
319
|
+
strokeWidth: "2",
|
|
320
|
+
strokeLinecap: "round",
|
|
321
|
+
strokeLinejoin: "round",
|
|
322
|
+
"aria-hidden": true,
|
|
323
|
+
style: { width: 13, height: 13 },
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ jsx("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
|
|
326
|
+
/* @__PURE__ */ jsx("path", { d: "M14 2v6h6" })
|
|
327
|
+
]
|
|
328
|
+
}
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
),
|
|
332
|
+
/* @__PURE__ */ jsx("span", { className: "flex flex-col min-w-0 flex-1", style: { gap: isSingleCol ? 1 : 2 }, children: isSingleCol ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
333
|
+
/* @__PURE__ */ jsxs(
|
|
334
|
+
"span",
|
|
335
|
+
{
|
|
336
|
+
className: "text-doc-template-ink",
|
|
337
|
+
style: {
|
|
338
|
+
fontWeight: 500,
|
|
339
|
+
whiteSpace: "nowrap",
|
|
340
|
+
overflow: "hidden",
|
|
341
|
+
textOverflow: "ellipsis"
|
|
342
|
+
},
|
|
343
|
+
children: [
|
|
344
|
+
hit.section && /* @__PURE__ */ jsxs(
|
|
345
|
+
"span",
|
|
346
|
+
{
|
|
347
|
+
className: "text-doc-template-muted uppercase",
|
|
348
|
+
style: {
|
|
349
|
+
fontFamily: "var(--font-doc-template-mono)",
|
|
350
|
+
fontSize: 9.5,
|
|
351
|
+
fontWeight: 500,
|
|
352
|
+
letterSpacing: "0.04em"
|
|
353
|
+
},
|
|
354
|
+
children: [
|
|
355
|
+
hit.section,
|
|
356
|
+
/* @__PURE__ */ jsx("span", { style: { margin: "0 3px", opacity: 0.5 }, children: "/" })
|
|
357
|
+
]
|
|
358
|
+
}
|
|
359
|
+
),
|
|
360
|
+
highlight(hit.title, query)
|
|
361
|
+
]
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
hit.snippet && /* @__PURE__ */ jsx(
|
|
365
|
+
"span",
|
|
366
|
+
{
|
|
367
|
+
style: {
|
|
368
|
+
fontFamily: "var(--font-doc-template-ui)",
|
|
369
|
+
fontSize: 12,
|
|
370
|
+
lineHeight: 1.45,
|
|
371
|
+
color: "color-mix(in srgb, var(--color-doc-template-ink) 55%, transparent)",
|
|
372
|
+
overflow: "hidden",
|
|
373
|
+
textOverflow: "ellipsis",
|
|
374
|
+
display: "-webkit-box",
|
|
375
|
+
WebkitLineClamp: 2,
|
|
376
|
+
WebkitBoxOrient: "vertical"
|
|
377
|
+
},
|
|
378
|
+
children: highlight(hit.snippet, query)
|
|
379
|
+
}
|
|
380
|
+
)
|
|
381
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
382
|
+
/* @__PURE__ */ jsx(
|
|
383
|
+
"span",
|
|
384
|
+
{
|
|
385
|
+
className: "text-doc-template-ink",
|
|
386
|
+
style: {
|
|
387
|
+
fontWeight: 500,
|
|
388
|
+
whiteSpace: "nowrap",
|
|
389
|
+
overflow: "hidden",
|
|
390
|
+
textOverflow: "ellipsis"
|
|
391
|
+
},
|
|
392
|
+
children: highlight(hit.title, query)
|
|
393
|
+
}
|
|
394
|
+
),
|
|
395
|
+
hit.section && /* @__PURE__ */ jsx(
|
|
396
|
+
"span",
|
|
397
|
+
{
|
|
398
|
+
className: "text-doc-template-muted uppercase",
|
|
399
|
+
style: {
|
|
400
|
+
fontFamily: "var(--font-doc-template-mono)",
|
|
401
|
+
fontSize: 9.5,
|
|
402
|
+
fontWeight: 500,
|
|
403
|
+
letterSpacing: "0.04em",
|
|
404
|
+
whiteSpace: "nowrap",
|
|
405
|
+
overflow: "hidden",
|
|
406
|
+
textOverflow: "ellipsis"
|
|
407
|
+
},
|
|
408
|
+
children: hit.section
|
|
409
|
+
}
|
|
410
|
+
),
|
|
411
|
+
query.trim() && (hit.excerptHtml || hit.snippet) && /* @__PURE__ */ jsx(
|
|
412
|
+
"span",
|
|
413
|
+
{
|
|
414
|
+
className: "pagefind-excerpt",
|
|
415
|
+
style: {
|
|
416
|
+
fontFamily: "var(--font-doc-template-ui)",
|
|
417
|
+
fontSize: 11.5,
|
|
418
|
+
lineHeight: 1.4,
|
|
419
|
+
color: "color-mix(in srgb, var(--color-doc-template-ink) 55%, transparent)",
|
|
420
|
+
overflow: "hidden",
|
|
421
|
+
textOverflow: "ellipsis",
|
|
422
|
+
display: "-webkit-box",
|
|
423
|
+
WebkitLineClamp: 2,
|
|
424
|
+
WebkitBoxOrient: "vertical"
|
|
425
|
+
},
|
|
426
|
+
...hit.excerptHtml ? { dangerouslySetInnerHTML: { __html: hit.excerptHtml } } : { children: highlight(hit.snippet, query) }
|
|
427
|
+
}
|
|
428
|
+
)
|
|
429
|
+
] }) })
|
|
430
|
+
]
|
|
431
|
+
},
|
|
432
|
+
hit.path
|
|
433
|
+
))
|
|
434
|
+
]
|
|
435
|
+
}
|
|
436
|
+
),
|
|
437
|
+
!isSingleCol && /* @__PURE__ */ jsx(
|
|
438
|
+
"div",
|
|
439
|
+
{
|
|
440
|
+
"aria-hidden": true,
|
|
441
|
+
onMouseDown: (e) => {
|
|
442
|
+
draggingRef.current = true;
|
|
443
|
+
const dlg = e.currentTarget.closest("[data-palette-panel]");
|
|
444
|
+
if (dlg) {
|
|
445
|
+
const rect = dlg.getBoundingClientRect();
|
|
446
|
+
setGripY(Math.max(0, Math.min(e.clientY - rect.top, rect.height)));
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
onDoubleClick: () => {
|
|
450
|
+
setSplitPx(360);
|
|
451
|
+
localStorage.setItem("palette-split", "360");
|
|
452
|
+
},
|
|
453
|
+
style: {
|
|
454
|
+
position: "absolute",
|
|
455
|
+
top: 0,
|
|
456
|
+
bottom: 0,
|
|
457
|
+
left: `calc(${splitPx}px - 4px)`,
|
|
458
|
+
width: 8,
|
|
459
|
+
cursor: "col-resize",
|
|
460
|
+
zIndex: 2
|
|
461
|
+
},
|
|
462
|
+
children: gripY != null && /* @__PURE__ */ jsx(
|
|
463
|
+
"div",
|
|
464
|
+
{
|
|
465
|
+
style: {
|
|
466
|
+
position: "absolute",
|
|
467
|
+
left: "50%",
|
|
468
|
+
top: gripY,
|
|
469
|
+
transform: "translate(-50%, -50%)",
|
|
470
|
+
width: 3,
|
|
471
|
+
height: 28,
|
|
472
|
+
borderRadius: 2,
|
|
473
|
+
background: "var(--color-doc-template-muted)"
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
)
|
|
477
|
+
}
|
|
478
|
+
),
|
|
479
|
+
!isSingleCol && /* @__PURE__ */ jsx(
|
|
480
|
+
"aside",
|
|
481
|
+
{
|
|
482
|
+
className: "overflow-y-auto flex flex-col",
|
|
483
|
+
style: {
|
|
484
|
+
background: "color-mix(in srgb, var(--color-doc-template-panel) 60%, transparent)",
|
|
485
|
+
minHeight: 280
|
|
486
|
+
},
|
|
487
|
+
children: previewHit ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
488
|
+
/* @__PURE__ */ jsxs("div", { style: { padding: "14px 18px 0" }, children: [
|
|
489
|
+
/* @__PURE__ */ jsx(
|
|
490
|
+
"div",
|
|
491
|
+
{
|
|
492
|
+
className: "text-doc-template-muted uppercase",
|
|
493
|
+
style: {
|
|
494
|
+
fontFamily: "var(--font-doc-template-mono)",
|
|
495
|
+
fontSize: 9.5,
|
|
496
|
+
fontWeight: 500,
|
|
497
|
+
letterSpacing: "0.05em",
|
|
498
|
+
marginBottom: 6
|
|
499
|
+
},
|
|
500
|
+
children: previewHit.section || "—"
|
|
501
|
+
}
|
|
502
|
+
),
|
|
503
|
+
/* @__PURE__ */ jsx(
|
|
504
|
+
"h3",
|
|
505
|
+
{
|
|
506
|
+
className: "text-doc-template-ink",
|
|
507
|
+
style: {
|
|
508
|
+
margin: "0 0 12px",
|
|
509
|
+
fontFamily: "var(--font-doc-template-ui)",
|
|
510
|
+
fontSize: 16,
|
|
511
|
+
fontWeight: 600,
|
|
512
|
+
letterSpacing: "-0.012em",
|
|
513
|
+
lineHeight: 1.25
|
|
514
|
+
},
|
|
515
|
+
children: highlight(previewHit.title, query)
|
|
516
|
+
}
|
|
517
|
+
)
|
|
518
|
+
] }),
|
|
519
|
+
query.trim() && previewHit.subResults.length > 0 ? /* @__PURE__ */ jsx("div", { ref: previewBodyRef, className: "flex-1 overflow-y-auto pagefind-excerpt", style: { padding: "0 18px 14px" }, children: previewHit.subResults.map((sr, idx) => {
|
|
520
|
+
const multi = previewHit.subResults.length > 1;
|
|
521
|
+
return /* @__PURE__ */ jsxs(
|
|
522
|
+
"div",
|
|
523
|
+
{
|
|
524
|
+
style: {
|
|
525
|
+
padding: "10px 0",
|
|
526
|
+
borderTop: idx > 0 ? "1px solid var(--color-doc-template-faint)" : "none"
|
|
527
|
+
},
|
|
528
|
+
children: [
|
|
529
|
+
sr.title && sr.title !== previewHit.title && /* @__PURE__ */ jsxs(
|
|
530
|
+
"div",
|
|
531
|
+
{
|
|
532
|
+
className: "text-doc-template-muted",
|
|
533
|
+
style: {
|
|
534
|
+
fontFamily: "var(--font-doc-template-mono)",
|
|
535
|
+
fontSize: 10,
|
|
536
|
+
fontWeight: 600,
|
|
537
|
+
letterSpacing: "0.02em",
|
|
538
|
+
marginBottom: 6,
|
|
539
|
+
opacity: 0.7
|
|
540
|
+
},
|
|
541
|
+
children: [
|
|
542
|
+
"# ",
|
|
543
|
+
sr.title
|
|
544
|
+
]
|
|
545
|
+
}
|
|
546
|
+
),
|
|
547
|
+
/* @__PURE__ */ jsx(
|
|
548
|
+
"div",
|
|
549
|
+
{
|
|
550
|
+
style: {
|
|
551
|
+
fontFamily: "var(--font-doc-template-ui)",
|
|
552
|
+
fontSize: 12.5,
|
|
553
|
+
lineHeight: 1.6,
|
|
554
|
+
color: "color-mix(in srgb, var(--color-doc-template-ink) 70%, transparent)",
|
|
555
|
+
...multi ? {
|
|
556
|
+
overflow: "hidden",
|
|
557
|
+
display: "-webkit-box",
|
|
558
|
+
WebkitLineClamp: 5,
|
|
559
|
+
WebkitBoxOrient: "vertical"
|
|
560
|
+
} : {}
|
|
561
|
+
},
|
|
562
|
+
dangerouslySetInnerHTML: { __html: sr.excerptHtml }
|
|
563
|
+
}
|
|
564
|
+
)
|
|
565
|
+
]
|
|
566
|
+
},
|
|
567
|
+
idx
|
|
568
|
+
);
|
|
569
|
+
}) }) : pageHtml ? /* @__PURE__ */ jsx(
|
|
570
|
+
"div",
|
|
571
|
+
{
|
|
572
|
+
ref: previewBodyRef,
|
|
573
|
+
className: "flex-1 overflow-y-auto preview-body pagefind-excerpt",
|
|
574
|
+
style: { padding: "0 18px 14px" },
|
|
575
|
+
dangerouslySetInnerHTML: {
|
|
576
|
+
__html: query.trim() ? highlightHtml(pageHtml, query) : pageHtml
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
) : /* @__PURE__ */ jsx(
|
|
580
|
+
"div",
|
|
581
|
+
{
|
|
582
|
+
ref: previewBodyRef,
|
|
583
|
+
className: "flex-1 overflow-y-auto",
|
|
584
|
+
style: {
|
|
585
|
+
padding: "0 18px 14px",
|
|
586
|
+
fontFamily: "var(--font-doc-template-ui)",
|
|
587
|
+
fontSize: 12.5,
|
|
588
|
+
lineHeight: 1.6,
|
|
589
|
+
color: "color-mix(in srgb, var(--color-doc-template-ink) 70%, transparent)"
|
|
590
|
+
},
|
|
591
|
+
children: query.trim() && previewHit.snippet ? highlight(previewHit.snippet, query) : previewHit.description || ""
|
|
592
|
+
}
|
|
593
|
+
),
|
|
594
|
+
/* @__PURE__ */ jsx(
|
|
595
|
+
"div",
|
|
596
|
+
{
|
|
597
|
+
className: "text-doc-template-muted",
|
|
598
|
+
style: {
|
|
599
|
+
fontFamily: "var(--font-doc-template-mono)",
|
|
600
|
+
fontSize: 10,
|
|
601
|
+
fontWeight: 500,
|
|
602
|
+
padding: "10px 18px",
|
|
603
|
+
marginTop: "auto",
|
|
604
|
+
opacity: 0.7,
|
|
605
|
+
overflow: "hidden",
|
|
606
|
+
textOverflow: "ellipsis",
|
|
607
|
+
whiteSpace: "nowrap"
|
|
608
|
+
},
|
|
609
|
+
children: previewHit.path
|
|
610
|
+
}
|
|
611
|
+
)
|
|
612
|
+
] }) : /* @__PURE__ */ jsx("p", { className: "text-doc-template-muted", style: { padding: "18px", fontSize: 13 }, children: "Select a result to preview." })
|
|
613
|
+
}
|
|
614
|
+
)
|
|
615
|
+
]
|
|
616
|
+
}
|
|
617
|
+
),
|
|
618
|
+
/* @__PURE__ */ jsxs(
|
|
619
|
+
"div",
|
|
620
|
+
{
|
|
621
|
+
className: "flex items-center text-doc-template-muted",
|
|
622
|
+
style: {
|
|
623
|
+
gap: 14,
|
|
624
|
+
padding: "9px 14px",
|
|
625
|
+
borderTop: "1px solid var(--color-doc-template-faint)",
|
|
626
|
+
fontFamily: "var(--font-doc-template-mono)",
|
|
627
|
+
fontSize: 10,
|
|
628
|
+
fontWeight: 500,
|
|
629
|
+
background: "color-mix(in srgb, var(--color-doc-template-panel) 50%, transparent)"
|
|
630
|
+
},
|
|
631
|
+
children: [
|
|
632
|
+
/* @__PURE__ */ jsxs(FootKey, { children: [
|
|
633
|
+
/* @__PURE__ */ jsx(FootKbd, { children: "↑" }),
|
|
634
|
+
/* @__PURE__ */ jsx(FootKbd, { children: "↓" }),
|
|
635
|
+
/* @__PURE__ */ jsx("span", { children: "navigate" })
|
|
636
|
+
] }),
|
|
637
|
+
/* @__PURE__ */ jsxs(FootKey, { children: [
|
|
638
|
+
/* @__PURE__ */ jsx(FootKbd, { children: "↵" }),
|
|
639
|
+
/* @__PURE__ */ jsx("span", { children: "open" })
|
|
640
|
+
] }),
|
|
641
|
+
/* @__PURE__ */ jsxs(FootKey, { children: [
|
|
642
|
+
/* @__PURE__ */ jsx(FootKbd, { children: "esc" }),
|
|
643
|
+
/* @__PURE__ */ jsx("span", { children: "close" })
|
|
644
|
+
] }),
|
|
645
|
+
/* @__PURE__ */ jsx("span", { style: { flex: 1 } }),
|
|
646
|
+
/* @__PURE__ */ jsx("span", { style: { opacity: 0.8 }, children: "Search · Dreamlake docs" })
|
|
647
|
+
]
|
|
648
|
+
}
|
|
649
|
+
),
|
|
650
|
+
!isNarrowInset && /* @__PURE__ */ jsx(SearchResizeHandles, { startResize, resetHeight })
|
|
651
|
+
] })
|
|
652
|
+
] });
|
|
653
|
+
}
|
|
654
|
+
function FootKey({ children }) {
|
|
655
|
+
return /* @__PURE__ */ jsx("span", { className: "inline-flex items-center", style: { gap: 5 }, children });
|
|
656
|
+
}
|
|
657
|
+
function FootKbd({ children }) {
|
|
658
|
+
return /* @__PURE__ */ jsx(
|
|
659
|
+
"kbd",
|
|
660
|
+
{
|
|
661
|
+
style: {
|
|
662
|
+
fontFamily: "var(--font-doc-template-mono)",
|
|
663
|
+
fontSize: 9.5,
|
|
664
|
+
background: "var(--color-doc-template-bg)",
|
|
665
|
+
border: "1px solid var(--color-doc-template-faint)",
|
|
666
|
+
borderRadius: 3,
|
|
667
|
+
padding: "1px 4px",
|
|
668
|
+
color: "var(--color-doc-template-ink)",
|
|
669
|
+
minWidth: 14,
|
|
670
|
+
textAlign: "center"
|
|
671
|
+
},
|
|
672
|
+
children
|
|
673
|
+
}
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
export {
|
|
677
|
+
SearchPalette
|
|
678
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function useSearchResize(hitCount: number, totalChars: number): {
|
|
2
|
+
panelH: number | null;
|
|
3
|
+
effectiveH: number;
|
|
4
|
+
isResizing: boolean;
|
|
5
|
+
startResize: (edge: "bottom" | "corner", e: React.MouseEvent) => void;
|
|
6
|
+
resetHeight: () => void;
|
|
7
|
+
};
|
|
8
|
+
export declare function SearchResizeHandles({ startResize, resetHeight }: {
|
|
9
|
+
startResize: (edge: 'bottom' | 'corner', e: React.MouseEvent) => void;
|
|
10
|
+
resetHeight: () => void;
|
|
11
|
+
}): import("react").JSX.Element;
|