react-docs-ui 0.6.11 → 0.6.13
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/AISettingsPanel-KzfonkeY.js +1171 -0
- package/dist/{index-DOSBzyKY.js → DocsApp-DTFpyBOl.js} +12860 -16794
- package/dist/{GlobalContextMenu-B8XZ1MXh.js → GlobalContextMenu-hGNTKw3S.js} +19 -18
- package/dist/MdxContent-B664V_Hk.js +812 -0
- package/dist/MdxContent.lazy-DsQt7MZQ.js +1512 -0
- package/dist/SearchDialog-Cfam5kUW.js +406 -0
- package/dist/SearchRuntime-Dk265vam.js +31 -0
- package/dist/context-menu-CBGG4zJl.js +140 -0
- package/dist/docs-app.es.js +10 -0
- package/dist/index-ByXnCzVt.js +12 -0
- package/dist/react-docs-ui.css +1 -1
- package/dist/react-docs-ui.es.js +193 -122
- package/dist/types/components/FontProvider.d.ts.map +1 -1
- package/dist/types/components/HeaderNav.d.ts.map +1 -1
- package/dist/types/components/MdxContent.d.ts.map +1 -1
- package/dist/types/components/MdxContent.lazy.d.ts.map +1 -1
- package/dist/types/components/SearchLauncher.d.ts +15 -0
- package/dist/types/components/SearchLauncher.d.ts.map +1 -0
- package/dist/types/components/search/SearchProvider.d.ts +2 -1
- package/dist/types/components/search/SearchProvider.d.ts.map +1 -1
- package/dist/types/components/search/SearchRuntime.d.ts +9 -0
- package/dist/types/components/search/SearchRuntime.d.ts.map +1 -0
- package/dist/types/docs-app.d.ts +5 -0
- package/dist/types/docs-app.d.ts.map +1 -0
- package/dist/types/lib/component-scanner.d.ts +1 -0
- package/dist/types/lib/component-scanner.d.ts.map +1 -1
- package/dist/types/lib/shiki-highlighter.d.ts +2 -0
- package/dist/types/lib/shiki-highlighter.d.ts.map +1 -1
- package/dist/types/react-docs-ui.d.ts +2 -0
- package/package.json +5 -1
- package/dist/MdxContent.lazy-B15Pt0p4.js +0 -4
- package/dist/fonts/02c687e7ed17b3df.woff2 +0 -0
- package/dist/fonts/09d4de25241bfe76.woff +0 -0
- package/dist/fonts/09dfac589fa421e8.woff2 +0 -0
- package/dist/fonts/0d29b2b1f8303138.ttf +0 -0
- package/dist/fonts/0e9f19247ab3bbab.ttf +0 -0
- package/dist/fonts/1969dbe1bc0fb3ba.woff +0 -0
- package/dist/fonts/1f89d2fedc85c386.woff +0 -0
- package/dist/fonts/20b388d1a51f5745.ttf +0 -0
- package/dist/fonts/21851da450182870.ttf +0 -0
- package/dist/fonts/22d5c4e6cd1e9474.woff2 +0 -0
- package/dist/fonts/22e83d374a2e6691.woff +0 -0
- package/dist/fonts/2f36d9db5ff365d4.woff +0 -0
- package/dist/fonts/314032aa9f107304.woff2 +0 -0
- package/dist/fonts/3533cc38c9cdc602.ttf +0 -0
- package/dist/fonts/3d0f44e32f2e74f2.ttf +0 -0
- package/dist/fonts/4124e542a1b58f9d.woff +0 -0
- package/dist/fonts/46d68807665c21f9.ttf +0 -0
- package/dist/fonts/4e1eaced156586d3.ttf +0 -0
- package/dist/fonts/4fc7ad74569941de.woff +0 -0
- package/dist/fonts/552292117efd3f42.ttf +0 -0
- package/dist/fonts/552f66ef43fc7522.woff +0 -0
- package/dist/fonts/5600e0919751e982.woff +0 -0
- package/dist/fonts/58d42913cac4cb53.woff2 +0 -0
- package/dist/fonts/5cff588fceb2856c.ttf +0 -0
- package/dist/fonts/5d09426707f9d063.ttf +0 -0
- package/dist/fonts/607b70ee0da7b15f.woff2 +0 -0
- package/dist/fonts/6652f5c5affcddc6.ttf +0 -0
- package/dist/fonts/69732d145fb77d46.ttf +0 -0
- package/dist/fonts/69ed18356e7517f2.woff2 +0 -0
- package/dist/fonts/705a1783b9c1d57b.ttf +0 -0
- package/dist/fonts/72bb9b68fd978fda.woff +0 -0
- package/dist/fonts/745939d4e3f4755f.woff2 +0 -0
- package/dist/fonts/7591411ae35bc580.woff +0 -0
- package/dist/fonts/786e88705bcced94.woff2 +0 -0
- package/dist/fonts/79d8b432f0a85a07.woff +0 -0
- package/dist/fonts/83b99a8c57312e6e.woff2 +0 -0
- package/dist/fonts/83fb1a9d8474dd56.woff2 +0 -0
- package/dist/fonts/8cfd3def12a3c5ef.ttf +0 -0
- package/dist/fonts/90b626c33ef816d4.ttf +0 -0
- package/dist/fonts/96bbd8e3dc776eb1.woff +0 -0
- package/dist/fonts/99d6d1362d7b9b12.woff2 +0 -0
- package/dist/fonts/a27661173f0a7433.woff2 +0 -0
- package/dist/fonts/abe35a8c78edf887.woff +0 -0
- package/dist/fonts/ad9576beef3f1d4e.woff2 +0 -0
- package/dist/fonts/adbfefebea65cf02.ttf +0 -0
- package/dist/fonts/b4aab29b79f992e3.woff2 +0 -0
- package/dist/fonts/b9b897e4301ad703.woff2 +0 -0
- package/dist/fonts/be03438595f83d0f.ttf +0 -0
- package/dist/fonts/c2b56591519e9293.woff2 +0 -0
- package/dist/fonts/c505bdad51c9abfa.ttf +0 -0
- package/dist/fonts/c811e89c187ceac5.woff +0 -0
- package/dist/fonts/ce2290c5c835ea00.woff +0 -0
- package/dist/fonts/ce4cb83d70539101.woff2 +0 -0
- package/dist/fonts/d601cb8345d82ba5.ttf +0 -0
- package/dist/fonts/d6f6ac428c874555.woff +0 -0
- package/dist/fonts/debedc918129c66f.woff2 +0 -0
- package/dist/fonts/e079035466b8f120.woff +0 -0
- package/dist/fonts/e618042c847fd3b9.woff2 +0 -0
- package/dist/fonts/e71ae6d3e7debcfd.woff +0 -0
- package/dist/fonts/f61879e5a60b36a0.woff +0 -0
- package/dist/index-DQPDmZq9.js +0 -11
- package/dist/index-Dkm4IQwC.js +0 -11
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { j as s, c as z, d as P, h as K, aF as V, aG as $ } from "./DocsApp-DTFpyBOl.js";
|
|
2
|
+
import { useState as y, useRef as j, useEffect as p, useCallback as E, createContext as q, useContext as H, forwardRef as M } from "react";
|
|
3
|
+
import { useNavigate as Q } from "react-router-dom";
|
|
4
|
+
import R from "flexsearch";
|
|
5
|
+
import { Search as U, X as G, FileText as X, Loader2 as J } from "lucide-react";
|
|
6
|
+
const W = 20;
|
|
7
|
+
class O {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
index;
|
|
10
|
+
sections = /* @__PURE__ */ new Map();
|
|
11
|
+
initialized = !1;
|
|
12
|
+
constructor() {
|
|
13
|
+
this.index = new R.Index({
|
|
14
|
+
tokenize: "full",
|
|
15
|
+
resolution: 9,
|
|
16
|
+
cache: 100
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
init(t) {
|
|
20
|
+
this.clear();
|
|
21
|
+
for (const r of t.sections)
|
|
22
|
+
this.sections.set(r.id, r), this.index.add(r.id, r.tokens.join(" "));
|
|
23
|
+
this.initialized = !0;
|
|
24
|
+
}
|
|
25
|
+
clear() {
|
|
26
|
+
this.sections.clear(), this.index = new R.Index({
|
|
27
|
+
tokenize: "full",
|
|
28
|
+
resolution: 9,
|
|
29
|
+
cache: 100
|
|
30
|
+
}), this.initialized = !1;
|
|
31
|
+
}
|
|
32
|
+
search(t) {
|
|
33
|
+
if (!this.initialized)
|
|
34
|
+
return [];
|
|
35
|
+
const { query: r, limit: n = W } = t, i = r.toLowerCase().trim();
|
|
36
|
+
return i ? this.index.search(i, { limit: n }).map((c) => {
|
|
37
|
+
const a = this.sections.get(c);
|
|
38
|
+
return a ? {
|
|
39
|
+
id: a.id,
|
|
40
|
+
pageTitle: a.pageTitle,
|
|
41
|
+
sectionTitle: a.sectionTitle,
|
|
42
|
+
snippet: this.generateSnippet(a.content, i),
|
|
43
|
+
url: a.url,
|
|
44
|
+
score: 1
|
|
45
|
+
} : null;
|
|
46
|
+
}).filter((c) => c !== null) : [];
|
|
47
|
+
}
|
|
48
|
+
generateSnippet(t, r) {
|
|
49
|
+
if (!t) return "";
|
|
50
|
+
const n = 150, i = t.toLowerCase(), d = r.split(/\s+/).filter(Boolean);
|
|
51
|
+
let c = 0;
|
|
52
|
+
for (const u of d) {
|
|
53
|
+
const f = i.indexOf(u);
|
|
54
|
+
if (f !== -1) {
|
|
55
|
+
c = f;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const a = Math.max(0, c - 30), o = Math.min(t.length, a + n);
|
|
60
|
+
let l = t.slice(a, o);
|
|
61
|
+
return a > 0 && (l = "..." + l), o < t.length && (l = l + "..."), l;
|
|
62
|
+
}
|
|
63
|
+
isInitialized() {
|
|
64
|
+
return this.initialized;
|
|
65
|
+
}
|
|
66
|
+
getSectionCount() {
|
|
67
|
+
return this.sections.size;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const le = new O();
|
|
71
|
+
function Y(e, t, r = "mark") {
|
|
72
|
+
if (!e || t.length === 0)
|
|
73
|
+
return e;
|
|
74
|
+
const n = e.toLowerCase(), i = [];
|
|
75
|
+
for (const o of t) {
|
|
76
|
+
const l = o.toLowerCase();
|
|
77
|
+
let u = 0;
|
|
78
|
+
for (; ; ) {
|
|
79
|
+
const f = n.indexOf(l, u);
|
|
80
|
+
if (f === -1) break;
|
|
81
|
+
i.push({ start: f, end: f + o.length }), u = f + 1;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (i.length === 0)
|
|
85
|
+
return e;
|
|
86
|
+
const d = Z(i);
|
|
87
|
+
let c = "", a = 0;
|
|
88
|
+
for (const o of d)
|
|
89
|
+
c += e.slice(a, o.start), c += `<${r}>`, c += e.slice(o.start, o.end), c += `</${r}>`, a = o.end;
|
|
90
|
+
return c += e.slice(a), c;
|
|
91
|
+
}
|
|
92
|
+
function Z(e) {
|
|
93
|
+
if (e.length === 0) return [];
|
|
94
|
+
const t = [...e].sort((n, i) => n.start - i.start), r = [t[0]];
|
|
95
|
+
for (let n = 1; n < t.length; n++) {
|
|
96
|
+
const i = t[n], d = r[r.length - 1];
|
|
97
|
+
i.start <= d.end ? d.end = Math.max(d.end, i.end) : r.push(i);
|
|
98
|
+
}
|
|
99
|
+
return r;
|
|
100
|
+
}
|
|
101
|
+
function ee(e, t, r = {}) {
|
|
102
|
+
const {
|
|
103
|
+
maxLength: n = 120,
|
|
104
|
+
contextBefore: i = 30,
|
|
105
|
+
contextAfter: d = 80
|
|
106
|
+
} = r;
|
|
107
|
+
if (!e) return "";
|
|
108
|
+
if (t.length === 0)
|
|
109
|
+
return e.slice(0, n) + (e.length > n ? "..." : "");
|
|
110
|
+
const c = e.toLowerCase();
|
|
111
|
+
let a = -1, o = "";
|
|
112
|
+
for (const g of t) {
|
|
113
|
+
const h = c.indexOf(g.toLowerCase());
|
|
114
|
+
h !== -1 && (a === -1 || h < a) && (a = h, o = g);
|
|
115
|
+
}
|
|
116
|
+
if (a === -1)
|
|
117
|
+
return e.slice(0, n) + (e.length > n ? "..." : "");
|
|
118
|
+
const l = Math.max(0, a - i), u = Math.min(e.length, a + o.length + d);
|
|
119
|
+
let f = e.slice(l, u);
|
|
120
|
+
return l > 0 && (f = "..." + f), u < e.length && (f = f + "..."), f;
|
|
121
|
+
}
|
|
122
|
+
function D(e, t, r = {}) {
|
|
123
|
+
const n = ee(e, t, r);
|
|
124
|
+
return Y(n, t, r.tag || "mark");
|
|
125
|
+
}
|
|
126
|
+
function te(e) {
|
|
127
|
+
return e.toLowerCase().split(/[\s\-_]+/).filter((t) => t.length > 0);
|
|
128
|
+
}
|
|
129
|
+
const B = q(null);
|
|
130
|
+
function ne() {
|
|
131
|
+
const e = H(B);
|
|
132
|
+
if (!e)
|
|
133
|
+
throw new Error("useSearch must be used within a SearchProvider");
|
|
134
|
+
return e;
|
|
135
|
+
}
|
|
136
|
+
function de({
|
|
137
|
+
children: e,
|
|
138
|
+
lang: t = "zh-cn",
|
|
139
|
+
enabled: r = !0,
|
|
140
|
+
maxResults: n = 20,
|
|
141
|
+
enableHotkeys: i = !0
|
|
142
|
+
}) {
|
|
143
|
+
const [d, c] = y(!1), [a, o] = y(!1), [l, u] = y(null), [f, g] = y([]), [h, I] = y(""), [v, S] = y(!1), x = j(null), b = j(null), N = j(null), L = j(!1);
|
|
144
|
+
p(() => (x.current = new O(), () => {
|
|
145
|
+
x.current && (x.current.clear(), x.current = null);
|
|
146
|
+
}), []), p(() => {
|
|
147
|
+
N.current && N.current !== t && (c(!1), N.current = null, g([]), I(""), x.current && x.current.clear());
|
|
148
|
+
}, [t]);
|
|
149
|
+
const k = E(async () => {
|
|
150
|
+
if (!(d && N.current === t || L.current || !r)) {
|
|
151
|
+
L.current = !0, o(!0), u(null);
|
|
152
|
+
try {
|
|
153
|
+
const m = await fetch(`/search-index-${t}.json`);
|
|
154
|
+
if (!m.ok)
|
|
155
|
+
throw new Error(`Failed to load search index: ${m.status}`);
|
|
156
|
+
const w = await m.json();
|
|
157
|
+
x.current && x.current.init(w), N.current = t, c(!0);
|
|
158
|
+
} catch (m) {
|
|
159
|
+
u(m instanceof Error ? m.message : "Failed to load search index");
|
|
160
|
+
} finally {
|
|
161
|
+
o(!1), L.current = !1;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}, [t, d, r]), T = E(async (m) => {
|
|
165
|
+
if (!m.trim())
|
|
166
|
+
return g([]), [];
|
|
167
|
+
x.current?.isInitialized() || await k();
|
|
168
|
+
const w = {
|
|
169
|
+
query: m,
|
|
170
|
+
lang: t,
|
|
171
|
+
limit: n
|
|
172
|
+
};
|
|
173
|
+
if (x.current) {
|
|
174
|
+
const C = x.current.search(w);
|
|
175
|
+
return g(C), C;
|
|
176
|
+
}
|
|
177
|
+
return [];
|
|
178
|
+
}, [t, k, n]);
|
|
179
|
+
p(() => {
|
|
180
|
+
if (!h.trim()) {
|
|
181
|
+
g([]);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
return b.current && clearTimeout(b.current), b.current = setTimeout(() => {
|
|
185
|
+
T(h);
|
|
186
|
+
}, 150), () => {
|
|
187
|
+
b.current && clearTimeout(b.current);
|
|
188
|
+
};
|
|
189
|
+
}, [h, T]), p(() => {
|
|
190
|
+
v && !d && !L.current && k();
|
|
191
|
+
}, [v, d, k]), p(() => {
|
|
192
|
+
if (!i) return;
|
|
193
|
+
const m = (w) => {
|
|
194
|
+
(w.metaKey || w.ctrlKey) && w.key.toLowerCase() === "k" && (w.preventDefault(), S((C) => !C)), w.key === "Escape" && v && S(!1);
|
|
195
|
+
};
|
|
196
|
+
return document.addEventListener("keydown", m), () => document.removeEventListener("keydown", m);
|
|
197
|
+
}, [i, v]);
|
|
198
|
+
const A = {
|
|
199
|
+
isLoaded: d,
|
|
200
|
+
isLoading: a,
|
|
201
|
+
error: l,
|
|
202
|
+
search: T,
|
|
203
|
+
results: f,
|
|
204
|
+
query: h,
|
|
205
|
+
setQuery: I,
|
|
206
|
+
open: v,
|
|
207
|
+
setOpen: S,
|
|
208
|
+
loadIndex: k
|
|
209
|
+
};
|
|
210
|
+
return /* @__PURE__ */ s.jsx(B.Provider, { value: A, children: e });
|
|
211
|
+
}
|
|
212
|
+
const F = M(
|
|
213
|
+
({ value: e, onChange: t, onClear: r, className: n, placeholder: i, ...d }, c) => /* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-3 px-4 py-3 border-b", children: [
|
|
214
|
+
/* @__PURE__ */ s.jsx(U, { className: "h-5 w-5 shrink-0 text-muted-foreground" }),
|
|
215
|
+
/* @__PURE__ */ s.jsx(
|
|
216
|
+
"input",
|
|
217
|
+
{
|
|
218
|
+
ref: c,
|
|
219
|
+
type: "text",
|
|
220
|
+
value: e,
|
|
221
|
+
onChange: (a) => t(a.target.value),
|
|
222
|
+
placeholder: i || "搜索文档...",
|
|
223
|
+
className: z(
|
|
224
|
+
"flex-1 bg-transparent text-base outline-none placeholder:text-muted-foreground",
|
|
225
|
+
n
|
|
226
|
+
),
|
|
227
|
+
...d
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
e && r && /* @__PURE__ */ s.jsx(
|
|
231
|
+
"button",
|
|
232
|
+
{
|
|
233
|
+
type: "button",
|
|
234
|
+
onClick: r,
|
|
235
|
+
className: "p-1 rounded hover:bg-muted transition-colors",
|
|
236
|
+
children: /* @__PURE__ */ s.jsx(G, { className: "h-4 w-4 text-muted-foreground" })
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
] })
|
|
240
|
+
);
|
|
241
|
+
F.displayName = "SearchInput";
|
|
242
|
+
const _ = M(
|
|
243
|
+
({ result: e, query: t, isSelected: r, onClick: n, onMouseEnter: i }, d) => {
|
|
244
|
+
const c = te(t), a = D(
|
|
245
|
+
e.sectionTitle,
|
|
246
|
+
c,
|
|
247
|
+
{ maxLength: 100, contextBefore: 0, contextAfter: 0 }
|
|
248
|
+
), o = D(
|
|
249
|
+
e.snippet,
|
|
250
|
+
c,
|
|
251
|
+
{ maxLength: 150 }
|
|
252
|
+
);
|
|
253
|
+
return /* @__PURE__ */ s.jsxs(
|
|
254
|
+
"div",
|
|
255
|
+
{
|
|
256
|
+
ref: d,
|
|
257
|
+
onClick: n,
|
|
258
|
+
onMouseEnter: i,
|
|
259
|
+
className: z(
|
|
260
|
+
"flex items-start gap-3 px-4 py-3 cursor-pointer transition-all duration-200 border-l-2 rounded-r-md mx-2",
|
|
261
|
+
"hover:shadow-sm hover:translate-x-0.5",
|
|
262
|
+
r ? "bg-accent/80 border-l-primary shadow-md scale-[1.02] translate-x-1" : "hover:bg-muted/50 border-l-transparent"
|
|
263
|
+
),
|
|
264
|
+
children: [
|
|
265
|
+
/* @__PURE__ */ s.jsx(X, { className: "h-4 w-4 mt-0.5 shrink-0 text-muted-foreground" }),
|
|
266
|
+
/* @__PURE__ */ s.jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
267
|
+
/* @__PURE__ */ s.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ s.jsx(
|
|
268
|
+
"span",
|
|
269
|
+
{
|
|
270
|
+
className: "font-medium text-sm truncate",
|
|
271
|
+
dangerouslySetInnerHTML: { __html: a }
|
|
272
|
+
}
|
|
273
|
+
) }),
|
|
274
|
+
e.pageTitle !== e.sectionTitle && /* @__PURE__ */ s.jsx("div", { className: "text-xs text-muted-foreground truncate mt-0.5", children: e.pageTitle }),
|
|
275
|
+
o && /* @__PURE__ */ s.jsx(
|
|
276
|
+
"div",
|
|
277
|
+
{
|
|
278
|
+
className: "text-xs text-muted-foreground mt-1 line-clamp-2",
|
|
279
|
+
dangerouslySetInnerHTML: { __html: o }
|
|
280
|
+
}
|
|
281
|
+
)
|
|
282
|
+
] })
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
_.displayName = "SearchItem";
|
|
289
|
+
function re({ results: e, query: t, onSelect: r }) {
|
|
290
|
+
const [n, i] = y(0), d = j(null), c = j(null);
|
|
291
|
+
p(() => {
|
|
292
|
+
i(0);
|
|
293
|
+
}, [e]), p(() => {
|
|
294
|
+
if (c.current && d.current) {
|
|
295
|
+
const o = d.current, l = c.current, u = o.getBoundingClientRect(), f = l.getBoundingClientRect();
|
|
296
|
+
f.bottom > u.bottom ? l.scrollIntoView({ block: "nearest" }) : f.top < u.top && l.scrollIntoView({ block: "nearest" });
|
|
297
|
+
}
|
|
298
|
+
}, [n]), p(() => {
|
|
299
|
+
const o = (l) => {
|
|
300
|
+
if (l.key === "ArrowDown")
|
|
301
|
+
l.preventDefault(), i((u) => Math.min(u + 1, e.length - 1));
|
|
302
|
+
else if (l.key === "ArrowUp")
|
|
303
|
+
l.preventDefault(), i((u) => Math.max(u - 1, 0));
|
|
304
|
+
else if (l.key === "Enter") {
|
|
305
|
+
l.preventDefault();
|
|
306
|
+
const u = e[n];
|
|
307
|
+
u && r(u.url);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
|
|
311
|
+
}, [e, n, r]);
|
|
312
|
+
const a = (o) => {
|
|
313
|
+
r(o.url);
|
|
314
|
+
};
|
|
315
|
+
return /* @__PURE__ */ s.jsx("div", { ref: d, className: "py-2", children: e.map((o, l) => /* @__PURE__ */ s.jsx(
|
|
316
|
+
_,
|
|
317
|
+
{
|
|
318
|
+
result: o,
|
|
319
|
+
query: t,
|
|
320
|
+
isSelected: l === n,
|
|
321
|
+
ref: l === n ? c : null,
|
|
322
|
+
onClick: () => a(o),
|
|
323
|
+
onMouseEnter: () => i(l)
|
|
324
|
+
},
|
|
325
|
+
o.id
|
|
326
|
+
)) });
|
|
327
|
+
}
|
|
328
|
+
function ue({ placeholder: e }) {
|
|
329
|
+
const {
|
|
330
|
+
open: t,
|
|
331
|
+
setOpen: r,
|
|
332
|
+
query: n,
|
|
333
|
+
setQuery: i,
|
|
334
|
+
results: d,
|
|
335
|
+
isLoading: c,
|
|
336
|
+
error: a,
|
|
337
|
+
isLoaded: o
|
|
338
|
+
} = ne(), l = Q(), u = j(null);
|
|
339
|
+
p(() => {
|
|
340
|
+
t && u.current && setTimeout(() => u.current?.focus(), 0);
|
|
341
|
+
}, [t]), p(() => {
|
|
342
|
+
t || i("");
|
|
343
|
+
}, [t, i]);
|
|
344
|
+
const f = (h) => {
|
|
345
|
+
l(h), r(!1);
|
|
346
|
+
}, g = (h) => {
|
|
347
|
+
r(h);
|
|
348
|
+
};
|
|
349
|
+
return /* @__PURE__ */ s.jsx(P, { open: t, onOpenChange: g, children: /* @__PURE__ */ s.jsxs(K, { className: "overflow-hidden p-0 shadow-lg max-w-xl top-[15%] translate-y-0", showCloseButton: !1, children: [
|
|
350
|
+
/* @__PURE__ */ s.jsx(V, { children: "搜索文档" }),
|
|
351
|
+
/* @__PURE__ */ s.jsx($, { children: "搜索文档内容" }),
|
|
352
|
+
/* @__PURE__ */ s.jsxs("div", { className: "flex flex-col", children: [
|
|
353
|
+
/* @__PURE__ */ s.jsx(
|
|
354
|
+
F,
|
|
355
|
+
{
|
|
356
|
+
ref: u,
|
|
357
|
+
value: n,
|
|
358
|
+
onChange: i,
|
|
359
|
+
placeholder: e,
|
|
360
|
+
onClear: () => i("")
|
|
361
|
+
}
|
|
362
|
+
),
|
|
363
|
+
/* @__PURE__ */ s.jsxs("div", { className: "max-h-[60vh] overflow-y-auto border-t", children: [
|
|
364
|
+
c && !o && /* @__PURE__ */ s.jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ s.jsx(J, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }),
|
|
365
|
+
a && /* @__PURE__ */ s.jsx("div", { className: "px-4 py-8 text-center text-sm text-muted-foreground", children: a }),
|
|
366
|
+
o && !c && !n && /* @__PURE__ */ s.jsx("div", { className: "px-4 py-8 text-center text-sm text-muted-foreground", children: "输入关键词搜索文档" }),
|
|
367
|
+
o && n && d.length === 0 && !c && /* @__PURE__ */ s.jsxs("div", { className: "px-4 py-8 text-center text-sm text-muted-foreground", children: [
|
|
368
|
+
'未找到 "',
|
|
369
|
+
n,
|
|
370
|
+
'" 相关结果'
|
|
371
|
+
] }),
|
|
372
|
+
d.length > 0 && /* @__PURE__ */ s.jsx(re, { results: d, query: n, onSelect: f })
|
|
373
|
+
] }),
|
|
374
|
+
/* @__PURE__ */ s.jsxs("div", { className: "flex items-center justify-between border-t px-4 py-2 text-xs text-muted-foreground bg-muted/30", children: [
|
|
375
|
+
/* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
376
|
+
/* @__PURE__ */ s.jsxs("span", { className: "flex items-center gap-1", children: [
|
|
377
|
+
/* @__PURE__ */ s.jsx("kbd", { className: "px-1.5 py-0.5 rounded bg-muted border text-[10px]", children: "↵" }),
|
|
378
|
+
"选择"
|
|
379
|
+
] }),
|
|
380
|
+
/* @__PURE__ */ s.jsxs("span", { className: "flex items-center gap-1", children: [
|
|
381
|
+
/* @__PURE__ */ s.jsx("kbd", { className: "px-1.5 py-0.5 rounded bg-muted border text-[10px]", children: "↑↓" }),
|
|
382
|
+
"导航"
|
|
383
|
+
] })
|
|
384
|
+
] }),
|
|
385
|
+
/* @__PURE__ */ s.jsxs("span", { className: "flex items-center gap-1", children: [
|
|
386
|
+
/* @__PURE__ */ s.jsx("kbd", { className: "px-1.5 py-0.5 rounded bg-muted border text-[10px]", children: "esc" }),
|
|
387
|
+
"关闭"
|
|
388
|
+
] })
|
|
389
|
+
] })
|
|
390
|
+
] })
|
|
391
|
+
] }) });
|
|
392
|
+
}
|
|
393
|
+
export {
|
|
394
|
+
de as S,
|
|
395
|
+
ue as a,
|
|
396
|
+
O as b,
|
|
397
|
+
F as c,
|
|
398
|
+
_ as d,
|
|
399
|
+
re as e,
|
|
400
|
+
Y as f,
|
|
401
|
+
ee as g,
|
|
402
|
+
D as h,
|
|
403
|
+
le as s,
|
|
404
|
+
te as t,
|
|
405
|
+
ne as u
|
|
406
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { j as s } from "./DocsApp-DTFpyBOl.js";
|
|
2
|
+
import { useEffect as o } from "react";
|
|
3
|
+
import { S as i, u, a as n } from "./SearchDialog-Cfam5kUW.js";
|
|
4
|
+
function c({
|
|
5
|
+
openSignal: e,
|
|
6
|
+
placeholder: t
|
|
7
|
+
}) {
|
|
8
|
+
const { setOpen: r } = u();
|
|
9
|
+
return o(() => {
|
|
10
|
+
e > 0 && r(!0);
|
|
11
|
+
}, [e, r]), /* @__PURE__ */ s.jsx(n, { placeholder: t });
|
|
12
|
+
}
|
|
13
|
+
function x({
|
|
14
|
+
lang: e,
|
|
15
|
+
maxResults: t,
|
|
16
|
+
placeholder: r,
|
|
17
|
+
openSignal: a
|
|
18
|
+
}) {
|
|
19
|
+
return /* @__PURE__ */ s.jsx(
|
|
20
|
+
i,
|
|
21
|
+
{
|
|
22
|
+
lang: e,
|
|
23
|
+
maxResults: t,
|
|
24
|
+
enableHotkeys: !1,
|
|
25
|
+
children: /* @__PURE__ */ s.jsx(c, { openSignal: a, placeholder: r })
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
x as default
|
|
31
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { j as o, c as d } from "./DocsApp-DTFpyBOl.js";
|
|
2
|
+
import * as r from "react";
|
|
3
|
+
import * as e from "@radix-ui/react-context-menu";
|
|
4
|
+
import { ChevronRightIcon as l, CheckIcon as c, CircleIcon as m } from "lucide-react";
|
|
5
|
+
const w = e.Root, R = e.Trigger, I = e.Group, M = e.Sub, v = e.RadioGroup, u = r.forwardRef(({ className: t, inset: a, children: s, ...n }, i) => /* @__PURE__ */ o.jsxs(
|
|
6
|
+
e.SubTrigger,
|
|
7
|
+
{
|
|
8
|
+
ref: i,
|
|
9
|
+
className: d(
|
|
10
|
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
|
|
11
|
+
a && "pl-8",
|
|
12
|
+
t
|
|
13
|
+
),
|
|
14
|
+
...n,
|
|
15
|
+
children: [
|
|
16
|
+
s,
|
|
17
|
+
/* @__PURE__ */ o.jsx(l, { className: "ml-auto h-4 w-4" })
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
));
|
|
21
|
+
u.displayName = e.SubTrigger.displayName;
|
|
22
|
+
const p = r.forwardRef(({ className: t, ...a }, s) => /* @__PURE__ */ o.jsx(
|
|
23
|
+
e.SubContent,
|
|
24
|
+
{
|
|
25
|
+
ref: s,
|
|
26
|
+
className: d(
|
|
27
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",
|
|
28
|
+
t
|
|
29
|
+
),
|
|
30
|
+
...a
|
|
31
|
+
}
|
|
32
|
+
));
|
|
33
|
+
p.displayName = e.SubContent.displayName;
|
|
34
|
+
const f = r.forwardRef(({ className: t, ...a }, s) => /* @__PURE__ */ o.jsx(e.Portal, { children: /* @__PURE__ */ o.jsx(
|
|
35
|
+
e.Content,
|
|
36
|
+
{
|
|
37
|
+
ref: s,
|
|
38
|
+
className: d(
|
|
39
|
+
"z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",
|
|
40
|
+
t
|
|
41
|
+
),
|
|
42
|
+
...a
|
|
43
|
+
}
|
|
44
|
+
) }));
|
|
45
|
+
f.displayName = e.Content.displayName;
|
|
46
|
+
const x = r.forwardRef(({ className: t, inset: a, ...s }, n) => /* @__PURE__ */ o.jsx(
|
|
47
|
+
e.Item,
|
|
48
|
+
{
|
|
49
|
+
ref: n,
|
|
50
|
+
className: d(
|
|
51
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
52
|
+
a && "pl-8",
|
|
53
|
+
t
|
|
54
|
+
),
|
|
55
|
+
...s
|
|
56
|
+
}
|
|
57
|
+
));
|
|
58
|
+
x.displayName = e.Item.displayName;
|
|
59
|
+
const b = r.forwardRef(({ className: t, children: a, checked: s, ...n }, i) => /* @__PURE__ */ o.jsxs(
|
|
60
|
+
e.CheckboxItem,
|
|
61
|
+
{
|
|
62
|
+
ref: i,
|
|
63
|
+
className: d(
|
|
64
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
65
|
+
t
|
|
66
|
+
),
|
|
67
|
+
checked: s,
|
|
68
|
+
...n,
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ o.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ o.jsx(e.ItemIndicator, { children: /* @__PURE__ */ o.jsx(c, { className: "h-4 w-4" }) }) }),
|
|
71
|
+
a
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
));
|
|
75
|
+
b.displayName = e.CheckboxItem.displayName;
|
|
76
|
+
const g = r.forwardRef(({ className: t, children: a, ...s }, n) => /* @__PURE__ */ o.jsxs(
|
|
77
|
+
e.RadioItem,
|
|
78
|
+
{
|
|
79
|
+
ref: n,
|
|
80
|
+
className: d(
|
|
81
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
82
|
+
t
|
|
83
|
+
),
|
|
84
|
+
...s,
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ o.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ o.jsx(e.ItemIndicator, { children: /* @__PURE__ */ o.jsx(m, { className: "h-2 w-2 fill-current" }) }) }),
|
|
87
|
+
a
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
));
|
|
91
|
+
g.displayName = e.RadioItem.displayName;
|
|
92
|
+
const h = r.forwardRef(({ className: t, inset: a, ...s }, n) => /* @__PURE__ */ o.jsx(
|
|
93
|
+
e.Label,
|
|
94
|
+
{
|
|
95
|
+
ref: n,
|
|
96
|
+
className: d(
|
|
97
|
+
"px-2 py-1.5 text-xs font-semibold text-muted-foreground",
|
|
98
|
+
a && "pl-8",
|
|
99
|
+
t
|
|
100
|
+
),
|
|
101
|
+
...s
|
|
102
|
+
}
|
|
103
|
+
));
|
|
104
|
+
h.displayName = e.Label.displayName;
|
|
105
|
+
const N = r.forwardRef(({ className: t, ...a }, s) => /* @__PURE__ */ o.jsx(
|
|
106
|
+
e.Separator,
|
|
107
|
+
{
|
|
108
|
+
ref: s,
|
|
109
|
+
className: d("-mx-1 my-1 h-px bg-muted", t),
|
|
110
|
+
...a
|
|
111
|
+
}
|
|
112
|
+
));
|
|
113
|
+
N.displayName = e.Separator.displayName;
|
|
114
|
+
const y = ({
|
|
115
|
+
className: t,
|
|
116
|
+
...a
|
|
117
|
+
}) => /* @__PURE__ */ o.jsx(
|
|
118
|
+
"span",
|
|
119
|
+
{
|
|
120
|
+
className: d("ml-auto text-xs tracking-widest opacity-60", t),
|
|
121
|
+
...a
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
y.displayName = "ContextMenuShortcut";
|
|
125
|
+
export {
|
|
126
|
+
w as C,
|
|
127
|
+
R as a,
|
|
128
|
+
f as b,
|
|
129
|
+
h as c,
|
|
130
|
+
I as d,
|
|
131
|
+
x as e,
|
|
132
|
+
N as f,
|
|
133
|
+
M as g,
|
|
134
|
+
u as h,
|
|
135
|
+
p as i,
|
|
136
|
+
v as j,
|
|
137
|
+
g as k,
|
|
138
|
+
b as l,
|
|
139
|
+
y as m
|
|
140
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { A, u as I } from "./DocsApp-DTFpyBOl.js";
|
|
2
|
+
import { A as e, a as r, b as s } from "./AISettingsPanel-KzfonkeY.js";
|
|
3
|
+
import { c as g, d as p } from "./AISettingsPanel-KzfonkeY.js";
|
|
4
|
+
export {
|
|
5
|
+
r as AIChatDialog,
|
|
6
|
+
g as AIChatInput,
|
|
7
|
+
p as AIChatMessage,
|
|
8
|
+
A as AIProvider,
|
|
9
|
+
e as AISelectionTrigger,
|
|
10
|
+
s as AISettingsPanel,
|
|
11
|
+
I as useAI
|
|
12
|
+
};
|