@dxos/plugin-search 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850
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/lib/browser/{app-graph-builder-N6QQA637.mjs → app-graph-builder-NZN3MIDZ.mjs} +3 -3
- package/dist/lib/browser/{chunk-J6YWSQTW.mjs → chunk-ARZYMSFF.mjs} +3 -3
- package/dist/lib/browser/{chunk-J6YWSQTW.mjs.map → chunk-ARZYMSFF.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-SNU4XR5T.mjs → chunk-CKQAVN5U.mjs} +15 -9
- package/dist/lib/browser/{chunk-SNU4XR5T.mjs.map → chunk-CKQAVN5U.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-4KPMT56H.mjs → chunk-VMEXQBHE.mjs} +3 -3
- package/dist/lib/browser/{chunk-4KPMT56H.mjs.map → chunk-VMEXQBHE.mjs.map} +1 -1
- package/dist/lib/browser/index.mjs +6 -6
- package/dist/lib/browser/{intent-resolver-QKBYLREY.mjs → intent-resolver-RWC63UGI.mjs} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-MG2K2YZ3.mjs → react-surface-UJOSZGP5.mjs} +272 -235
- package/dist/lib/browser/react-surface-UJOSZGP5.mjs.map +7 -0
- package/dist/types/src/hooks/useWebSearch.d.ts +1 -1
- package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
- package/dist/types/src/search/exa.d.ts +1 -1
- package/dist/types/src/search/exa.d.ts.map +1 -1
- package/package.json +29 -27
- package/src/components/SearchMain.tsx +3 -3
- package/src/components/SearchResults/SearchResults.tsx +1 -1
- package/src/hooks/sync.test.ts +2 -2
- package/src/hooks/useWebSearch.ts +5 -7
- package/src/meta.ts +2 -2
- package/src/search/exa.test.ts +2 -3
- package/src/search/exa.ts +9 -3
- package/dist/lib/browser/react-surface-MG2K2YZ3.mjs.map +0 -7
- /package/dist/lib/browser/{app-graph-builder-N6QQA637.mjs.map → app-graph-builder-NZN3MIDZ.mjs.map} +0 -0
- /package/dist/lib/browser/{intent-resolver-QKBYLREY.mjs.map → intent-resolver-RWC63UGI.mjs.map} +0 -0
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
useGlobalSearch,
|
|
5
5
|
useGlobalSearchResults,
|
|
6
6
|
useSearchResults
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-CKQAVN5U.mjs";
|
|
8
8
|
import {
|
|
9
9
|
SEARCH_PLUGIN,
|
|
10
10
|
SEARCH_RESULT
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ARZYMSFF.mjs";
|
|
12
12
|
|
|
13
13
|
// packages/plugins/plugin-search/src/capabilities/react-surface.tsx
|
|
14
14
|
import React5 from "react";
|
|
@@ -17,126 +17,149 @@ import { useActiveSpace } from "@dxos/plugin-space";
|
|
|
17
17
|
import { isSpace } from "@dxos/react-client/echo";
|
|
18
18
|
|
|
19
19
|
// packages/plugins/plugin-search/src/components/Searchbar/Searchbar.tsx
|
|
20
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
20
21
|
import { MagnifyingGlass } from "@phosphor-icons/react";
|
|
21
22
|
import React, { useEffect, useRef, useState } from "react";
|
|
22
23
|
import { Input } from "@dxos/react-ui";
|
|
23
24
|
import { getSize, mx } from "@dxos/react-ui-theme";
|
|
24
25
|
var Searchbar = ({ classes, variant, placeholder, value, onChange, onSubmit }) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
setText(value);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
26
|
+
var _effect = _useSignals();
|
|
27
|
+
try {
|
|
28
|
+
const inputRef = useRef(null);
|
|
29
|
+
const [text, setText] = useState(value);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setText(value);
|
|
32
|
+
}, [
|
|
33
|
+
value
|
|
34
|
+
]);
|
|
35
|
+
const handleChange = (text2) => {
|
|
36
|
+
setText(text2);
|
|
37
|
+
onChange?.(text2);
|
|
38
|
+
};
|
|
39
|
+
const handleReset = () => {
|
|
40
|
+
handleChange(void 0);
|
|
41
|
+
inputRef.current?.focus();
|
|
42
|
+
};
|
|
43
|
+
const handleKeyDown = (event) => {
|
|
44
|
+
switch (event.key) {
|
|
45
|
+
case "Enter":
|
|
46
|
+
onSubmit?.(text);
|
|
47
|
+
break;
|
|
48
|
+
case "Escape":
|
|
49
|
+
handleReset();
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
54
|
+
className: "flex shrink-0w-full items-center pli-1 pbs-1"
|
|
55
|
+
}, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.TextInput, {
|
|
56
|
+
ref: inputRef,
|
|
57
|
+
placeholder,
|
|
58
|
+
variant,
|
|
59
|
+
value: text ?? "",
|
|
60
|
+
classNames: mx("pl-3 pr-10", classes?.input),
|
|
61
|
+
onChange: ({ target }) => handleChange(target.value),
|
|
62
|
+
onKeyDown: handleKeyDown
|
|
63
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
64
|
+
role: "button",
|
|
65
|
+
className: "-ml-7 p-0 cursor-pointer",
|
|
66
|
+
onClick: handleReset
|
|
67
|
+
}, /* @__PURE__ */ React.createElement(MagnifyingGlass, {
|
|
68
|
+
className: getSize(5)
|
|
69
|
+
}))));
|
|
70
|
+
} finally {
|
|
71
|
+
_effect.f();
|
|
72
|
+
}
|
|
67
73
|
};
|
|
68
74
|
|
|
69
75
|
// packages/plugins/plugin-search/src/components/SearchMain.tsx
|
|
76
|
+
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
70
77
|
import React3, { useState as useState3 } from "react";
|
|
71
78
|
import { log as log3 } from "@dxos/log";
|
|
72
79
|
import { useClient } from "@dxos/react-client";
|
|
73
80
|
import { Filter, useQuery } from "@dxos/react-client/echo";
|
|
74
81
|
import { useTranslation } from "@dxos/react-ui";
|
|
75
|
-
import {
|
|
82
|
+
import { activeSurface, mx as mx3 } from "@dxos/react-ui-theme";
|
|
76
83
|
|
|
77
84
|
// packages/plugins/plugin-search/src/components/SearchResults/SearchResults.tsx
|
|
85
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
78
86
|
import React2, { forwardRef } from "react";
|
|
79
87
|
import { Card } from "@dxos/react-ui-card";
|
|
80
88
|
import { ghostHover, mx as mx2 } from "@dxos/react-ui-theme";
|
|
81
89
|
var Snippet = ({ text, match }) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
before
|
|
90
|
+
var _effect = _useSignals2();
|
|
91
|
+
try {
|
|
92
|
+
let content = /* @__PURE__ */ React2.createElement(React2.Fragment, null, text);
|
|
93
|
+
if (match) {
|
|
94
|
+
const result = text.match(match);
|
|
95
|
+
if (result?.index !== void 0) {
|
|
96
|
+
const maxOffset = 16;
|
|
97
|
+
let before = text.slice(0, result.index);
|
|
98
|
+
if (before.length > maxOffset) {
|
|
99
|
+
const idx = before.indexOf(" ", result.index - maxOffset);
|
|
100
|
+
before = "\u2026 " + before.slice(idx);
|
|
101
|
+
}
|
|
102
|
+
const after = text.slice(result.index + result[0].length);
|
|
103
|
+
content = /* @__PURE__ */ React2.createElement(React2.Fragment, null, before, /* @__PURE__ */ React2.createElement("span", {
|
|
104
|
+
className: "text-blue-500"
|
|
105
|
+
}, result[0]), after);
|
|
91
106
|
}
|
|
92
|
-
const after = text.slice(result.index + result[0].length);
|
|
93
|
-
content = /* @__PURE__ */ React2.createElement(React2.Fragment, null, before, /* @__PURE__ */ React2.createElement("span", {
|
|
94
|
-
className: "text-blue-500"
|
|
95
|
-
}, result[0]), after);
|
|
96
107
|
}
|
|
108
|
+
return /* @__PURE__ */ React2.createElement("span", {
|
|
109
|
+
className: "text-xs mb-1 line-clamp-3 text-neutral-300"
|
|
110
|
+
}, content);
|
|
111
|
+
} finally {
|
|
112
|
+
_effect.f();
|
|
97
113
|
}
|
|
98
|
-
return /* @__PURE__ */ React2.createElement("span", {
|
|
99
|
-
className: "text-xs mb-1 line-clamp-3 text-neutral-300"
|
|
100
|
-
}, content);
|
|
101
114
|
};
|
|
102
115
|
var SearchItem = /* @__PURE__ */ forwardRef((item, forwardRef3) => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
var _effect = _useSignals2();
|
|
117
|
+
try {
|
|
118
|
+
const { id, objectType, label, snippet, match, selected, onSelect } = item;
|
|
119
|
+
const Icon2 = void 0;
|
|
120
|
+
return /* @__PURE__ */ React2.createElement(Card.Root, {
|
|
121
|
+
ref: forwardRef3,
|
|
122
|
+
classNames: mx2("mx-2 mt-2 cursor-pointer", selected && "!bg-activeSurface", ghostHover),
|
|
123
|
+
onClick: () => onSelect?.(id)
|
|
124
|
+
}, objectType && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", {
|
|
125
|
+
className: "text-xs text-neutral-400 ml-4"
|
|
126
|
+
}, objectType)), /* @__PURE__ */ React2.createElement(Card.Header, null, /* @__PURE__ */ React2.createElement(Card.Title, {
|
|
127
|
+
title: label ?? "Untitled"
|
|
128
|
+
}), Icon2 && /* @__PURE__ */ React2.createElement(Card.Endcap, {
|
|
129
|
+
Icon: Icon2
|
|
130
|
+
})), snippet && /* @__PURE__ */ React2.createElement(Card.Body, {
|
|
131
|
+
gutter: true
|
|
132
|
+
}, /* @__PURE__ */ React2.createElement(Snippet, {
|
|
133
|
+
text: snippet,
|
|
134
|
+
match
|
|
135
|
+
})));
|
|
136
|
+
} finally {
|
|
137
|
+
_effect.f();
|
|
138
|
+
}
|
|
121
139
|
});
|
|
122
140
|
var SearchResults = ({ items, selected, onSelect }) => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
141
|
+
var _effect = _useSignals2();
|
|
142
|
+
try {
|
|
143
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
144
|
+
className: "flex flex-col grow overflow-y-auto"
|
|
145
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
146
|
+
className: "flex flex-col"
|
|
147
|
+
}, items.map((item) => /* @__PURE__ */ React2.createElement(SearchItem, {
|
|
148
|
+
key: item.id,
|
|
149
|
+
type: SEARCH_RESULT,
|
|
150
|
+
...item,
|
|
151
|
+
onSelect,
|
|
152
|
+
selected: selected === item.id
|
|
153
|
+
}))));
|
|
154
|
+
} finally {
|
|
155
|
+
_effect.f();
|
|
156
|
+
}
|
|
134
157
|
};
|
|
135
158
|
|
|
136
159
|
// packages/plugins/plugin-search/src/hooks/useWebSearch.ts
|
|
137
160
|
import { useState as useState2 } from "react";
|
|
138
|
-
import { AIServiceEdgeClient } from "@dxos/
|
|
139
|
-
import { AI_SERVICE_ENDPOINT } from "@dxos/
|
|
161
|
+
import { AIServiceEdgeClient } from "@dxos/ai";
|
|
162
|
+
import { AI_SERVICE_ENDPOINT, EXA_API_KEY } from "@dxos/ai/testing";
|
|
140
163
|
import { getSchema, getTypename } from "@dxos/echo-schema";
|
|
141
164
|
import { log as log2 } from "@dxos/log";
|
|
142
165
|
import { getIconAnnotation } from "@dxos/schema";
|
|
@@ -145,8 +168,7 @@ import { Testing } from "@dxos/schema/testing";
|
|
|
145
168
|
// packages/plugins/plugin-search/src/search/exa.ts
|
|
146
169
|
import { Option, Schema, SchemaAST } from "effect";
|
|
147
170
|
import Exa from "exa-js";
|
|
148
|
-
import {
|
|
149
|
-
import { MixedStreamParser } from "@dxos/assistant";
|
|
171
|
+
import { Message, MixedStreamParser, createTool } from "@dxos/ai";
|
|
150
172
|
import { isEncodedReference } from "@dxos/echo-protocol";
|
|
151
173
|
import { create, getTypeAnnotation, ObjectId, ReferenceAnnotationId } from "@dxos/echo-schema";
|
|
152
174
|
import { mapAst } from "@dxos/effect";
|
|
@@ -163,7 +185,7 @@ var search = async (options) => {
|
|
|
163
185
|
additionalSearchTerms: contextSearchTerms
|
|
164
186
|
}, {
|
|
165
187
|
F: __dxlog_file,
|
|
166
|
-
L:
|
|
188
|
+
L: 53,
|
|
167
189
|
S: void 0,
|
|
168
190
|
C: (f, a) => f(...a)
|
|
169
191
|
});
|
|
@@ -182,7 +204,7 @@ var search = async (options) => {
|
|
|
182
204
|
context
|
|
183
205
|
}, {
|
|
184
206
|
F: __dxlog_file,
|
|
185
|
-
L:
|
|
207
|
+
L: 69,
|
|
186
208
|
S: void 0,
|
|
187
209
|
C: (f, a) => f(...a)
|
|
188
210
|
});
|
|
@@ -225,7 +247,7 @@ ${r.text}`
|
|
|
225
247
|
result
|
|
226
248
|
}, {
|
|
227
249
|
F: __dxlog_file,
|
|
228
|
-
L:
|
|
250
|
+
L: 113,
|
|
229
251
|
S: void 0,
|
|
230
252
|
C: (f, a) => f(...a)
|
|
231
253
|
});
|
|
@@ -264,7 +286,7 @@ var getStructuredOutput = async (aiService, request) => {
|
|
|
264
286
|
...request,
|
|
265
287
|
systemPrompt: request.systemPrompt + "\nDo not output anything other then the tool call. Call the submit_result tool with the result.",
|
|
266
288
|
tools: [
|
|
267
|
-
|
|
289
|
+
createTool("submit_result", {
|
|
268
290
|
name: "submit_result",
|
|
269
291
|
description: "Submit the result",
|
|
270
292
|
schema: request.schema,
|
|
@@ -346,7 +368,6 @@ var mapSchemaRefs = (schema) => {
|
|
|
346
368
|
|
|
347
369
|
// packages/plugins/plugin-search/src/hooks/useWebSearch.ts
|
|
348
370
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-search/src/hooks/useWebSearch.ts";
|
|
349
|
-
var EXA_API_KEY = "9c7e17ff-0c85-4cd5-827a-8b489f139e03";
|
|
350
371
|
var useWebSearch = ({ query, context }) => {
|
|
351
372
|
const aiService = new AIServiceEdgeClient({
|
|
352
373
|
endpoint: AI_SERVICE_ENDPOINT.REMOTE
|
|
@@ -361,7 +382,7 @@ var useWebSearch = ({ query, context }) => {
|
|
|
361
382
|
context
|
|
362
383
|
}, {
|
|
363
384
|
F: __dxlog_file2,
|
|
364
|
-
L:
|
|
385
|
+
L: 30,
|
|
365
386
|
S: void 0,
|
|
366
387
|
C: (f, a) => f(...a)
|
|
367
388
|
});
|
|
@@ -411,54 +432,60 @@ var useWebSearch = ({ query, context }) => {
|
|
|
411
432
|
// packages/plugins/plugin-search/src/components/SearchMain.tsx
|
|
412
433
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-search/src/components/SearchMain.tsx";
|
|
413
434
|
var SearchMain = ({ classNames, space }) => {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
435
|
+
var _effect = _useSignals3();
|
|
436
|
+
try {
|
|
437
|
+
const { t } = useTranslation(SEARCH_PLUGIN);
|
|
438
|
+
const client = useClient();
|
|
439
|
+
const { setMatch } = useGlobalSearch();
|
|
440
|
+
const [query, setQuery] = useState3();
|
|
441
|
+
const allSpaces = false;
|
|
442
|
+
const objects = useQuery(allSpaces ? client.spaces : space, Filter.everything());
|
|
443
|
+
const results = useGlobalSearchResults(objects);
|
|
444
|
+
const { runSearch, results: webResults, isLoading } = useWebSearch({
|
|
445
|
+
query
|
|
446
|
+
});
|
|
447
|
+
const [selected, setSelected] = useState3();
|
|
448
|
+
const handleSelect = (id) => {
|
|
449
|
+
setSelected((selected2) => selected2 === id ? void 0 : id);
|
|
450
|
+
};
|
|
451
|
+
const allResults = [
|
|
452
|
+
...results,
|
|
453
|
+
...webResults
|
|
454
|
+
];
|
|
455
|
+
log3.info("results", {
|
|
456
|
+
results,
|
|
457
|
+
webResults
|
|
458
|
+
}, {
|
|
459
|
+
F: __dxlog_file3,
|
|
460
|
+
L: 47,
|
|
461
|
+
S: void 0,
|
|
462
|
+
C: (f, a) => f(...a)
|
|
463
|
+
});
|
|
464
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
465
|
+
className: mx3("flex flex-col grow h-full overflow-hidden", classNames)
|
|
466
|
+
}, /* @__PURE__ */ React3.createElement(Searchbar, {
|
|
467
|
+
placeholder: t("search placeholder"),
|
|
468
|
+
onChange: (text) => {
|
|
469
|
+
setQuery(text);
|
|
470
|
+
setMatch?.(text);
|
|
471
|
+
},
|
|
472
|
+
onSubmit: runSearch
|
|
473
|
+
}), isLoading && /* @__PURE__ */ React3.createElement("div", {
|
|
474
|
+
className: mx3("flex flex-col grow overflow-hidden", activeSurface)
|
|
475
|
+
}, "Loading..."), allResults.length > 0 && /* @__PURE__ */ React3.createElement("div", {
|
|
476
|
+
className: mx3("flex flex-col grow overflow-hidden", activeSurface)
|
|
477
|
+
}, /* @__PURE__ */ React3.createElement(SearchResults, {
|
|
478
|
+
items: allResults,
|
|
479
|
+
selected,
|
|
480
|
+
onSelect: handleSelect
|
|
481
|
+
})));
|
|
482
|
+
} finally {
|
|
483
|
+
_effect.f();
|
|
484
|
+
}
|
|
459
485
|
};
|
|
460
486
|
|
|
461
487
|
// packages/plugins/plugin-search/src/components/SearchDialog.tsx
|
|
488
|
+
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
462
489
|
import { Option as Option2 } from "effect";
|
|
463
490
|
import React4, { forwardRef as forwardRef2, useCallback, useState as useState4 } from "react";
|
|
464
491
|
import { LayoutAction, createIntent, useAppGraph, useIntentDispatcher, useLayout } from "@dxos/app-framework";
|
|
@@ -469,100 +496,110 @@ import { SearchList } from "@dxos/react-ui-searchlist";
|
|
|
469
496
|
import { descriptionText, mx as mx4 } from "@dxos/react-ui-theme";
|
|
470
497
|
var SEARCH_DIALOG = `${SEARCH_PLUGIN}/SearchDialog`;
|
|
471
498
|
var SearchListResult = /* @__PURE__ */ forwardRef2(({ node, onSelect }, forwardedRef) => {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
499
|
+
var _effect = _useSignals4();
|
|
500
|
+
try {
|
|
501
|
+
const { t } = useTranslation2(SEARCH_PLUGIN);
|
|
502
|
+
const label = toLocalizedString(node?.properties.label ?? "never", t);
|
|
503
|
+
return /* @__PURE__ */ React4.createElement(SearchList.Item, {
|
|
504
|
+
value: label,
|
|
505
|
+
key: node.id,
|
|
506
|
+
classNames: "flex gap-2 items-center pli-2",
|
|
507
|
+
onSelect: () => onSelect?.(node.id),
|
|
508
|
+
ref: forwardedRef
|
|
509
|
+
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
510
|
+
size: 5,
|
|
511
|
+
icon: node?.properties.icon
|
|
512
|
+
}), /* @__PURE__ */ React4.createElement("span", {
|
|
513
|
+
className: "is-0 grow truncate"
|
|
514
|
+
}, label));
|
|
515
|
+
} finally {
|
|
516
|
+
_effect.f();
|
|
517
|
+
}
|
|
486
518
|
});
|
|
487
519
|
var SearchDialog = ({ pivotId }) => {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
layout
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
}));
|
|
507
|
-
const index = layout.active.findIndex((id) => id === nodeId);
|
|
508
|
-
if (index !== -1) {
|
|
509
|
-
await dispatch(createIntent(LayoutAction.ScrollIntoView, {
|
|
510
|
-
part: "current",
|
|
511
|
-
subject: nodeId
|
|
512
|
-
}));
|
|
513
|
-
} else {
|
|
514
|
-
await dispatch(createIntent(LayoutAction.Open, {
|
|
515
|
-
part: "main",
|
|
516
|
-
subject: [
|
|
517
|
-
nodeId
|
|
518
|
-
],
|
|
520
|
+
var _effect = _useSignals4();
|
|
521
|
+
try {
|
|
522
|
+
const { t } = useTranslation2(SEARCH_PLUGIN);
|
|
523
|
+
const { graph } = useAppGraph();
|
|
524
|
+
const layout = useLayout();
|
|
525
|
+
const closed = (Array.isArray(layout.inactive) ? layout.inactive : [
|
|
526
|
+
layout.inactive
|
|
527
|
+
]).map((id) => graph?.getNode(id)).filter(Boolean);
|
|
528
|
+
const [queryString, setQueryString] = useState4("");
|
|
529
|
+
const client = useClient2();
|
|
530
|
+
const dangerouslyLoadAllObjects = useQuery2(client.spaces, Filter2.everything());
|
|
531
|
+
const [pending, results] = useSearchResults(queryString, dangerouslyLoadAllObjects);
|
|
532
|
+
const resultObjects = Array.from(results.keys());
|
|
533
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
534
|
+
const handleSelect = useCallback(async (nodeId) => {
|
|
535
|
+
await dispatch(createIntent(LayoutAction.UpdateDialog, {
|
|
536
|
+
part: "dialog",
|
|
519
537
|
options: {
|
|
520
|
-
|
|
521
|
-
positioning: "end"
|
|
538
|
+
state: false
|
|
522
539
|
}
|
|
523
540
|
}));
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
541
|
+
const index = layout.active.findIndex((id) => id === nodeId);
|
|
542
|
+
if (index !== -1) {
|
|
543
|
+
await dispatch(createIntent(LayoutAction.ScrollIntoView, {
|
|
544
|
+
part: "current",
|
|
545
|
+
subject: nodeId
|
|
546
|
+
}));
|
|
547
|
+
} else {
|
|
548
|
+
await dispatch(createIntent(LayoutAction.Open, {
|
|
549
|
+
part: "main",
|
|
550
|
+
subject: [
|
|
551
|
+
nodeId
|
|
552
|
+
],
|
|
553
|
+
options: {
|
|
554
|
+
pivotId,
|
|
555
|
+
positioning: "end"
|
|
556
|
+
}
|
|
557
|
+
}));
|
|
558
|
+
}
|
|
559
|
+
}, [
|
|
560
|
+
pivotId,
|
|
561
|
+
dispatch,
|
|
562
|
+
layout
|
|
563
|
+
]);
|
|
564
|
+
return /* @__PURE__ */ React4.createElement(Dialog.Content, {
|
|
565
|
+
classNames: [
|
|
566
|
+
"md:max-is-[24rem] overflow-hidden mbs-12"
|
|
567
|
+
]
|
|
568
|
+
}, /* @__PURE__ */ React4.createElement(Dialog.Title, null, t("search dialog title")), /* @__PURE__ */ React4.createElement(SearchList.Root, {
|
|
569
|
+
label: t("search placeholder"),
|
|
570
|
+
classNames: "flex flex-col grow overflow-hidden my-2"
|
|
571
|
+
}, /* @__PURE__ */ React4.createElement(SearchList.Input, {
|
|
572
|
+
value: queryString,
|
|
573
|
+
onValueChange: (nextValue) => {
|
|
574
|
+
setQueryString(nextValue);
|
|
575
|
+
},
|
|
576
|
+
placeholder: t("search placeholder"),
|
|
577
|
+
classNames: "px-1 my-2"
|
|
578
|
+
}), /* @__PURE__ */ React4.createElement(SearchList.Content, {
|
|
579
|
+
classNames: "max-bs-[24rem] overflow-auto"
|
|
580
|
+
}, queryString.length > 0 ? resultObjects.length > 0 ? resultObjects.map((object) => graph.getNode(fullyQualifiedId(object))).filter(Option2.isSome).map((node) => /* @__PURE__ */ React4.createElement(SearchListResult, {
|
|
581
|
+
key: node.value.id,
|
|
582
|
+
node: node.value,
|
|
583
|
+
onSelect: handleSelect
|
|
584
|
+
})) : /* @__PURE__ */ React4.createElement("p", {
|
|
585
|
+
className: "pli-1"
|
|
586
|
+
}, t(pending ? "pending results message" : "empty results message")) : /* @__PURE__ */ React4.createElement(React4.Fragment, null, closed.length > 0 && /* @__PURE__ */ React4.createElement("h2", {
|
|
587
|
+
className: mx4("mlb-1", descriptionText)
|
|
588
|
+
}, t("recently closed heading")), closed.filter(Option2.isSome).map((node) => /* @__PURE__ */ React4.createElement(SearchListResult, {
|
|
589
|
+
key: node.value.id,
|
|
590
|
+
node: node.value,
|
|
591
|
+
onSelect: handleSelect
|
|
592
|
+
}))))), /* @__PURE__ */ React4.createElement(Dialog.Close, {
|
|
593
|
+
asChild: true
|
|
594
|
+
}, /* @__PURE__ */ React4.createElement(Button, {
|
|
595
|
+
variant: "primary",
|
|
596
|
+
classNames: "mbs-2"
|
|
597
|
+
}, t("close label", {
|
|
598
|
+
ns: "os"
|
|
599
|
+
}))));
|
|
600
|
+
} finally {
|
|
601
|
+
_effect.f();
|
|
602
|
+
}
|
|
566
603
|
};
|
|
567
604
|
|
|
568
605
|
// packages/plugins/plugin-search/src/capabilities/react-surface.tsx
|
|
@@ -604,4 +641,4 @@ var react_surface_default = () => contributes(Capabilities.ReactSurface, [
|
|
|
604
641
|
export {
|
|
605
642
|
react_surface_default as default
|
|
606
643
|
};
|
|
607
|
-
//# sourceMappingURL=react-surface-
|
|
644
|
+
//# sourceMappingURL=react-surface-UJOSZGP5.mjs.map
|