@dxos/plugin-search 0.8.4-main.3f58842 → 0.8.4-main.548089c
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-FLW7KDC5.mjs → app-graph-builder-LCC2D3GZ.mjs} +16 -15
- package/dist/lib/browser/app-graph-builder-LCC2D3GZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-GN2FSWTM.mjs +22 -0
- package/dist/lib/browser/chunk-GN2FSWTM.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JVMYGOKS.mjs → chunk-TCVYYI44.mjs} +5 -5
- package/dist/lib/browser/chunk-TCVYYI44.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BXSF7IAU.mjs → chunk-YJBPTYJZ.mjs} +9 -9
- package/dist/lib/browser/chunk-YJBPTYJZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +8 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-UYQA6UUQ.mjs +22 -0
- package/dist/lib/browser/{intent-resolver-JPBGEKFT.mjs.map → intent-resolver-UYQA6UUQ.mjs.map} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-MPPIWDBF.mjs → react-surface-6IIORPNH.mjs} +111 -290
- package/dist/lib/browser/react-surface-6IIORPNH.mjs.map +7 -0
- package/dist/types/src/SearchPlugin.d.ts +1 -1
- package/dist/types/src/SearchPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +3 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/components/Search.stories.d.ts +13 -12
- package/dist/types/src/components/Search.stories.d.ts.map +1 -1
- package/dist/types/src/components/SearchDialog.d.ts +1 -1
- package/dist/types/src/components/SearchDialog.d.ts.map +1 -1
- package/dist/types/src/components/SearchMain.d.ts.map +1 -1
- package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts +12 -8
- package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts.map +1 -1
- package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +1 -1
- package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts +10 -8
- package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/sync.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
- package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/search/exa.d.ts +1 -3
- package/dist/types/src/search/exa.d.ts.map +1 -1
- package/dist/types/src/types/action.d.ts +3 -3
- package/dist/types/src/types/action.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -39
- package/src/SearchPlugin.tsx +43 -44
- package/src/capabilities/app-graph-builder.ts +14 -13
- package/src/capabilities/intent-resolver.ts +1 -1
- package/src/capabilities/react-surface.tsx +1 -1
- package/src/components/Search.stories.tsx +13 -15
- package/src/components/SearchDialog.tsx +23 -11
- package/src/components/SearchMain.tsx +7 -6
- package/src/components/SearchResults/SearchResults.stories.tsx +18 -17
- package/src/components/Searchbar/Searchbar.stories.tsx +8 -8
- package/src/components/Searchbar/Searchbar.tsx +2 -2
- package/src/hooks/sync.test.ts +1 -1
- package/src/hooks/sync.ts +5 -4
- package/src/hooks/useGlobalSearch.tsx +3 -2
- package/src/hooks/useSearchResults.ts +4 -4
- package/src/hooks/useWebSearch.ts +4 -9
- package/src/meta.ts +8 -5
- package/src/search/exa.test.ts +8 -31
- package/src/search/exa.ts +131 -151
- package/src/types/action.tsx +3 -3
- package/dist/lib/browser/app-graph-builder-FLW7KDC5.mjs.map +0 -7
- package/dist/lib/browser/chunk-BXSF7IAU.mjs.map +0 -7
- package/dist/lib/browser/chunk-JVMYGOKS.mjs.map +0 -7
- package/dist/lib/browser/chunk-KNS62YL2.mjs +0 -20
- package/dist/lib/browser/chunk-KNS62YL2.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JPBGEKFT.mjs +0 -22
- package/dist/lib/browser/react-surface-MPPIWDBF.mjs.map +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-search",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.548089c",
|
|
4
4
|
"description": "Braneframe sketch plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"source": "./src/index.ts",
|
|
13
14
|
"types": "./dist/types/src/index.d.ts",
|
|
14
15
|
"browser": "./dist/lib/browser/index.mjs"
|
|
15
16
|
}
|
|
@@ -26,50 +27,50 @@
|
|
|
26
27
|
"@preact-signals/safe-react": "^0.9.0",
|
|
27
28
|
"exa-js": "^1.5.12",
|
|
28
29
|
"main-thread-scheduling": "^14.1.1",
|
|
29
|
-
"@dxos/ai": "0.8.4-main.
|
|
30
|
-
"@dxos/assistant": "0.8.4-main.
|
|
31
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
32
|
-
"@dxos/blueprints": "0.8.4-main.
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/echo-protocol": "0.8.4-main.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/log": "0.8.4-main.
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/plugin-
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/plugin-graph": "0.8.4-main.
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/react-
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
30
|
+
"@dxos/ai": "0.8.4-main.548089c",
|
|
31
|
+
"@dxos/assistant": "0.8.4-main.548089c",
|
|
32
|
+
"@dxos/app-framework": "0.8.4-main.548089c",
|
|
33
|
+
"@dxos/blueprints": "0.8.4-main.548089c",
|
|
34
|
+
"@dxos/debug": "0.8.4-main.548089c",
|
|
35
|
+
"@dxos/echo": "0.8.4-main.548089c",
|
|
36
|
+
"@dxos/echo-protocol": "0.8.4-main.548089c",
|
|
37
|
+
"@dxos/effect": "0.8.4-main.548089c",
|
|
38
|
+
"@dxos/invariant": "0.8.4-main.548089c",
|
|
39
|
+
"@dxos/live-object": "0.8.4-main.548089c",
|
|
40
|
+
"@dxos/log": "0.8.4-main.548089c",
|
|
41
|
+
"@dxos/plugin-space": "0.8.4-main.548089c",
|
|
42
|
+
"@dxos/plugin-deck": "0.8.4-main.548089c",
|
|
43
|
+
"@dxos/react-client": "0.8.4-main.548089c",
|
|
44
|
+
"@dxos/plugin-graph": "0.8.4-main.548089c",
|
|
45
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.548089c",
|
|
46
|
+
"@dxos/react-ui-stack": "0.8.4-main.548089c",
|
|
47
|
+
"@dxos/schema": "0.8.4-main.548089c",
|
|
48
|
+
"@dxos/plugin-client": "0.8.4-main.548089c",
|
|
49
|
+
"@dxos/util": "0.8.4-main.548089c",
|
|
50
|
+
"@dxos/types": "0.8.4-main.548089c"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@effect-
|
|
53
|
-
"@effect/platform": "0.
|
|
54
|
-
"@types/react": "~
|
|
55
|
-
"@types/react-dom": "~
|
|
56
|
-
"effect": "3.
|
|
57
|
-
"react": "~
|
|
58
|
-
"react-dom": "~
|
|
59
|
-
"vite": "
|
|
60
|
-
"@dxos/random": "0.8.4-main.
|
|
61
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
62
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
63
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
53
|
+
"@effect-atom/atom-react": "^0.3.4",
|
|
54
|
+
"@effect/platform": "0.92.1",
|
|
55
|
+
"@types/react": "~19.2.2",
|
|
56
|
+
"@types/react-dom": "~19.2.2",
|
|
57
|
+
"effect": "3.18.3",
|
|
58
|
+
"react": "~19.2.0",
|
|
59
|
+
"react-dom": "~19.2.0",
|
|
60
|
+
"vite": "7.1.9",
|
|
61
|
+
"@dxos/random": "0.8.4-main.548089c",
|
|
62
|
+
"@dxos/react-ui": "0.8.4-main.548089c",
|
|
63
|
+
"@dxos/react-ui-theme": "0.8.4-main.548089c",
|
|
64
|
+
"@dxos/storybook-utils": "0.8.4-main.548089c"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
66
|
-
"@effect-
|
|
67
|
+
"@effect-atom/atom-react": "^0.3.4",
|
|
67
68
|
"@effect/platform": "^0.80.12",
|
|
68
69
|
"effect": "^3.13.3",
|
|
69
|
-
"react": "
|
|
70
|
-
"react-dom": "
|
|
71
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
72
|
-
"@dxos/react-ui
|
|
70
|
+
"react": "^19.0.0",
|
|
71
|
+
"react-dom": "^19.0.0",
|
|
72
|
+
"@dxos/react-ui-theme": "0.8.4-main.548089c",
|
|
73
|
+
"@dxos/react-ui": "0.8.4-main.548089c"
|
|
73
74
|
},
|
|
74
75
|
"publishConfig": {
|
|
75
76
|
"access": "public"
|
package/src/SearchPlugin.tsx
CHANGED
|
@@ -2,53 +2,52 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
7
|
import { AppGraphBuilder, IntentResolver, ReactSurface } from './capabilities';
|
|
8
|
-
import {
|
|
8
|
+
import { SEARCH_RESULT, meta } from './meta';
|
|
9
9
|
import { translations } from './translations';
|
|
10
10
|
import { type SearchResult } from './types';
|
|
11
11
|
|
|
12
|
-
export const SearchPlugin = () =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
},
|
|
12
|
+
export const SearchPlugin = definePlugin(meta, () => [
|
|
13
|
+
defineModule({
|
|
14
|
+
id: `${meta.id}/module/translations`,
|
|
15
|
+
activatesOn: Events.SetupTranslations,
|
|
16
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
17
|
+
}),
|
|
18
|
+
defineModule({
|
|
19
|
+
id: `${meta.id}/module/metadata`,
|
|
20
|
+
activatesOn: Events.SetupMetadata,
|
|
21
|
+
activate: () =>
|
|
22
|
+
contributes(Capabilities.Metadata, {
|
|
23
|
+
id: SEARCH_RESULT,
|
|
24
|
+
metadata: {
|
|
25
|
+
parse: (item: SearchResult, type: string) => {
|
|
26
|
+
switch (type) {
|
|
27
|
+
case 'node':
|
|
28
|
+
return { id: item.id, label: item.label, data: item.object };
|
|
29
|
+
case 'object':
|
|
30
|
+
return item.object;
|
|
31
|
+
case 'view-object':
|
|
32
|
+
return item;
|
|
33
|
+
}
|
|
36
34
|
},
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
}),
|
|
38
|
+
defineModule({
|
|
39
|
+
id: `${meta.id}/module/app-graph-builder`,
|
|
40
|
+
activatesOn: Events.SetupAppGraph,
|
|
41
|
+
activate: AppGraphBuilder,
|
|
42
|
+
}),
|
|
43
|
+
defineModule({
|
|
44
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
45
|
+
activatesOn: Events.SetupIntentResolver,
|
|
46
|
+
activate: IntentResolver,
|
|
47
|
+
}),
|
|
48
|
+
defineModule({
|
|
49
|
+
id: `${meta.id}/module/react-surface`,
|
|
50
|
+
activatesOn: Events.SetupReactSurface,
|
|
51
|
+
activate: ReactSurface,
|
|
52
|
+
}),
|
|
53
|
+
]);
|
|
@@ -2,25 +2,26 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Function from 'effect/Function';
|
|
7
|
+
import * as Option from 'effect/Option';
|
|
7
8
|
|
|
8
|
-
import { Capabilities, contributes, createIntent
|
|
9
|
+
import { Capabilities, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
|
|
9
10
|
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
10
11
|
import { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
|
|
11
|
-
import {
|
|
12
|
+
import { ROOT_ID, createExtension, rxFromSignal } from '@dxos/plugin-graph';
|
|
12
13
|
import { parseId } from '@dxos/react-client/echo';
|
|
13
14
|
|
|
14
|
-
import {
|
|
15
|
+
import { meta } from '../meta';
|
|
15
16
|
import { SearchAction } from '../types';
|
|
16
17
|
|
|
17
18
|
export default (context: PluginContext) =>
|
|
18
19
|
contributes(Capabilities.AppGraphBuilder, [
|
|
19
20
|
createExtension({
|
|
20
|
-
id: `${
|
|
21
|
+
id: `${meta.id}/space-search`,
|
|
21
22
|
connector: (node) =>
|
|
22
|
-
|
|
23
|
-
pipe(
|
|
23
|
+
Atom.make((get) =>
|
|
24
|
+
Function.pipe(
|
|
24
25
|
get(node),
|
|
25
26
|
Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
|
|
26
27
|
Option.map((node) => {
|
|
@@ -35,7 +36,7 @@ export default (context: PluginContext) =>
|
|
|
35
36
|
type: DECK_COMPANION_TYPE,
|
|
36
37
|
data: space,
|
|
37
38
|
properties: {
|
|
38
|
-
label: ['search label', { ns:
|
|
39
|
+
label: ['search label', { ns: meta.id }],
|
|
39
40
|
icon: 'ph--magnifying-glass--regular',
|
|
40
41
|
disposition: 'hidden',
|
|
41
42
|
},
|
|
@@ -47,10 +48,10 @@ export default (context: PluginContext) =>
|
|
|
47
48
|
),
|
|
48
49
|
}),
|
|
49
50
|
createExtension({
|
|
50
|
-
id:
|
|
51
|
+
id: meta.id,
|
|
51
52
|
actions: (node) =>
|
|
52
|
-
|
|
53
|
-
pipe(
|
|
53
|
+
Atom.make((get) =>
|
|
54
|
+
Function.pipe(
|
|
54
55
|
get(node),
|
|
55
56
|
Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
|
|
56
57
|
Option.map(() => {
|
|
@@ -62,7 +63,7 @@ export default (context: PluginContext) =>
|
|
|
62
63
|
await dispatch(createIntent(SearchAction.OpenSearch));
|
|
63
64
|
},
|
|
64
65
|
properties: {
|
|
65
|
-
label: ['search action label', { ns:
|
|
66
|
+
label: ['search action label', { ns: meta.id }],
|
|
66
67
|
icon: 'ph--magnifying-glass--regular',
|
|
67
68
|
keyBinding: {
|
|
68
69
|
macos: 'shift+meta+f',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capabilities, LayoutAction, contributes, createIntent, createResolver } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
7
|
import { SearchAction } from '../types';
|
|
8
8
|
|
|
@@ -6,7 +6,7 @@ import React from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
8
8
|
import { useActiveSpace } from '@dxos/plugin-space';
|
|
9
|
-
import {
|
|
9
|
+
import { type Space, isSpace } from '@dxos/react-client/echo';
|
|
10
10
|
|
|
11
11
|
import { SEARCH_DIALOG, SearchDialog, type SearchDialogProps, SearchMain } from '../components';
|
|
12
12
|
import { SearchContextProvider } from '../hooks';
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta, type Decorator, type StoryFn } from '@storybook/react-vite';
|
|
5
|
+
import { type Decorator, type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { faker } from '@dxos/random';
|
|
11
|
-
import { withLayout, withTheme } from '@dxos/
|
|
9
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
10
|
|
|
13
|
-
import { SearchResults } from './SearchResults';
|
|
14
|
-
import { Searchbar, type SearchbarProps } from './Searchbar';
|
|
15
11
|
import { SearchContextProvider, useGlobalSearch, useGlobalSearchResults } from '../hooks';
|
|
16
12
|
|
|
13
|
+
import { Searchbar, type SearchbarProps } from './Searchbar';
|
|
14
|
+
import { SearchResults } from './SearchResults';
|
|
15
|
+
|
|
17
16
|
faker.seed(1);
|
|
18
17
|
|
|
19
18
|
type StoryProps = SearchbarProps & {
|
|
@@ -35,15 +34,15 @@ const DefaultStory = ({ objects, ...props }: StoryProps) => {
|
|
|
35
34
|
);
|
|
36
35
|
};
|
|
37
36
|
|
|
38
|
-
const
|
|
39
|
-
return (Story
|
|
37
|
+
const withSearchContext = (): Decorator => {
|
|
38
|
+
return (Story) => (
|
|
40
39
|
<SearchContextProvider>
|
|
41
40
|
<Story />
|
|
42
41
|
</SearchContextProvider>
|
|
43
42
|
);
|
|
44
43
|
};
|
|
45
44
|
|
|
46
|
-
export const Default = {
|
|
45
|
+
export const Default: Story = {
|
|
47
46
|
args: {
|
|
48
47
|
objects: Array.from({ length: 8 }).map(() => ({
|
|
49
48
|
id: faker.string.uuid(),
|
|
@@ -53,14 +52,13 @@ export const Default = {
|
|
|
53
52
|
},
|
|
54
53
|
};
|
|
55
54
|
|
|
56
|
-
const meta
|
|
55
|
+
const meta = {
|
|
57
56
|
title: 'plugins/plugin-search/Search',
|
|
58
57
|
component: Searchbar,
|
|
59
58
|
render: DefaultStory,
|
|
60
|
-
decorators: [withTheme, withLayout({
|
|
61
|
-
|
|
62
|
-
layout: 'fullscreen',
|
|
63
|
-
},
|
|
64
|
-
};
|
|
59
|
+
decorators: [withTheme, withLayout({ container: 'column' }), withSearchContext()],
|
|
60
|
+
} satisfies Meta<typeof Searchbar>;
|
|
65
61
|
|
|
66
62
|
export default meta;
|
|
63
|
+
|
|
64
|
+
type Story = StoryObj<typeof meta>;
|
|
@@ -2,28 +2,30 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Option from 'effect/Option';
|
|
6
6
|
import React, { forwardRef, useCallback, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { LayoutAction, createIntent
|
|
8
|
+
import { LayoutAction, createIntent } from '@dxos/app-framework';
|
|
9
|
+
import { useAppGraph, useIntentDispatcher, useLayout } from '@dxos/app-framework/react';
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
9
11
|
import { type Node } from '@dxos/plugin-graph';
|
|
10
12
|
import { useClient } from '@dxos/react-client';
|
|
11
|
-
import { Filter,
|
|
13
|
+
import { Filter, useQuery } from '@dxos/react-client/echo';
|
|
12
14
|
import { Button, Dialog, Icon, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
13
15
|
import { SearchList, type SearchListItemProps } from '@dxos/react-ui-searchlist';
|
|
14
16
|
import { descriptionText, mx } from '@dxos/react-ui-theme';
|
|
15
17
|
|
|
16
18
|
import { useSearchResults } from '../hooks';
|
|
17
|
-
import {
|
|
19
|
+
import { meta } from '../meta';
|
|
18
20
|
|
|
19
|
-
export const SEARCH_DIALOG = `${
|
|
21
|
+
export const SEARCH_DIALOG = `${meta.id}/SearchDialog`;
|
|
20
22
|
|
|
21
23
|
type SearchListResultProps = {
|
|
22
24
|
node: Node;
|
|
23
25
|
} & Pick<SearchListItemProps, 'onSelect'>;
|
|
24
26
|
|
|
25
27
|
const SearchListResult = forwardRef<HTMLDivElement, SearchListResultProps>(({ node, onSelect }, forwardedRef) => {
|
|
26
|
-
const { t } = useTranslation(
|
|
28
|
+
const { t } = useTranslation(meta.id);
|
|
27
29
|
const label = toLocalizedString(node?.properties.label ?? 'never', t);
|
|
28
30
|
return (
|
|
29
31
|
<SearchList.Item
|
|
@@ -44,7 +46,7 @@ export type SearchDialogProps = {
|
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
export const SearchDialog = ({ pivotId }: SearchDialogProps) => {
|
|
47
|
-
const { t } = useTranslation(
|
|
49
|
+
const { t } = useTranslation(meta.id);
|
|
48
50
|
const { graph } = useAppGraph();
|
|
49
51
|
const layout = useLayout();
|
|
50
52
|
const closed = (Array.isArray(layout.inactive) ? layout.inactive : [layout.inactive])
|
|
@@ -59,12 +61,22 @@ export const SearchDialog = ({ pivotId }: SearchDialogProps) => {
|
|
|
59
61
|
|
|
60
62
|
const handleSelect = useCallback(
|
|
61
63
|
async (nodeId: string) => {
|
|
62
|
-
await dispatch(
|
|
64
|
+
await dispatch(
|
|
65
|
+
createIntent(LayoutAction.UpdateDialog, {
|
|
66
|
+
part: 'dialog',
|
|
67
|
+
options: { state: false },
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
63
70
|
|
|
64
71
|
// If node is already present in the active parts, scroll to it and close the dialog.
|
|
65
72
|
const index = layout.active.findIndex((id) => id === nodeId);
|
|
66
73
|
if (index !== -1) {
|
|
67
|
-
await dispatch(
|
|
74
|
+
await dispatch(
|
|
75
|
+
createIntent(LayoutAction.ScrollIntoView, {
|
|
76
|
+
part: 'current',
|
|
77
|
+
subject: nodeId,
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
68
80
|
} else {
|
|
69
81
|
await dispatch(
|
|
70
82
|
createIntent(LayoutAction.Open, {
|
|
@@ -91,13 +103,13 @@ export const SearchDialog = ({ pivotId }: SearchDialogProps) => {
|
|
|
91
103
|
setQueryString(nextValue);
|
|
92
104
|
}}
|
|
93
105
|
placeholder={t('search placeholder')}
|
|
94
|
-
classNames='
|
|
106
|
+
classNames='pli-1 my-2'
|
|
95
107
|
/>
|
|
96
108
|
<SearchList.Content classNames='max-bs-[24rem] overflow-auto'>
|
|
97
109
|
{queryString.length > 0 ? (
|
|
98
110
|
resultObjects.length > 0 ? (
|
|
99
111
|
resultObjects
|
|
100
|
-
.map((object) => graph.getNode(
|
|
112
|
+
.map((object) => graph.getNode(Obj.getDXN(object).toString()))
|
|
101
113
|
.filter(Option.isSome)
|
|
102
114
|
.map((node) => <SearchListResult key={node.value.id} node={node.value} onSelect={handleSelect} />)
|
|
103
115
|
) : (
|
|
@@ -6,18 +6,19 @@ import React, { type FC, useState } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { log } from '@dxos/log';
|
|
8
8
|
import { useClient } from '@dxos/react-client';
|
|
9
|
-
import { Filter,
|
|
9
|
+
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
|
10
10
|
import { type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
11
11
|
import { activeSurface, mx } from '@dxos/react-ui-theme';
|
|
12
12
|
|
|
13
|
-
import { SearchResults } from './SearchResults';
|
|
14
|
-
import { Searchbar } from './Searchbar';
|
|
15
13
|
import { useGlobalSearch, useGlobalSearchResults } from '../hooks';
|
|
16
14
|
import { useWebSearch } from '../hooks/useWebSearch';
|
|
17
|
-
import {
|
|
15
|
+
import { meta } from '../meta';
|
|
16
|
+
|
|
17
|
+
import { Searchbar } from './Searchbar';
|
|
18
|
+
import { SearchResults } from './SearchResults';
|
|
18
19
|
|
|
19
20
|
export const SearchMain: FC<ThemedClassName<{ space: Space }>> = ({ classNames, space }) => {
|
|
20
|
-
const { t } = useTranslation(
|
|
21
|
+
const { t } = useTranslation(meta.id);
|
|
21
22
|
const client = useClient();
|
|
22
23
|
const { setMatch } = useGlobalSearch();
|
|
23
24
|
const [query, setQuery] = useState<string>();
|
|
@@ -47,7 +48,7 @@ export const SearchMain: FC<ThemedClassName<{ space: Space }>> = ({ classNames,
|
|
|
47
48
|
log.info('results', { results, webResults });
|
|
48
49
|
|
|
49
50
|
return (
|
|
50
|
-
<div className={mx('flex flex-col grow
|
|
51
|
+
<div className={mx('flex flex-col grow bs-full overflow-hidden', classNames)}>
|
|
51
52
|
<Searchbar
|
|
52
53
|
placeholder={t('search placeholder')}
|
|
53
54
|
onChange={(text) => {
|
|
@@ -2,26 +2,25 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { faker } from '@dxos/random';
|
|
11
|
-
import {
|
|
9
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
12
10
|
|
|
13
|
-
import { SearchResults, type SearchResultsProps } from './SearchResults';
|
|
14
11
|
import { filterObjectsSync } from '../../hooks';
|
|
15
12
|
|
|
13
|
+
import { SearchResults, type SearchResultsProps } from './SearchResults';
|
|
14
|
+
|
|
16
15
|
faker.seed(1);
|
|
17
16
|
|
|
18
|
-
const DefaultStory = (
|
|
17
|
+
const DefaultStory = (props: SearchResultsProps) => {
|
|
19
18
|
const [selected, setSelected] = useState<string>();
|
|
20
19
|
|
|
21
20
|
return (
|
|
22
21
|
<div className='flex grow justify-center overflow-hidden'>
|
|
23
22
|
<div className='flex w-[300px] m-4 overflow-hidden'>
|
|
24
|
-
<SearchResults {...
|
|
23
|
+
<SearchResults {...props} selected={selected} onSelect={setSelected} />
|
|
25
24
|
</div>
|
|
26
25
|
</div>
|
|
27
26
|
);
|
|
@@ -37,21 +36,23 @@ const objects = Array.from({ length: 100 }).map((_, i) => ({
|
|
|
37
36
|
|
|
38
37
|
const match = new RegExp(word, 'i');
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
args: {
|
|
42
|
-
items: filterObjectsSync(objects, match),
|
|
43
|
-
match,
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const meta: Meta<typeof SearchResults> = {
|
|
39
|
+
const meta = {
|
|
48
40
|
title: 'plugins/plugin-search/SearchResults',
|
|
49
41
|
component: SearchResults,
|
|
50
42
|
render: DefaultStory,
|
|
51
|
-
decorators: [withTheme
|
|
43
|
+
decorators: [withTheme],
|
|
52
44
|
parameters: {
|
|
53
45
|
layout: 'fullscreen',
|
|
54
46
|
},
|
|
55
|
-
}
|
|
47
|
+
} satisfies Meta<typeof SearchResults>;
|
|
56
48
|
|
|
57
49
|
export default meta;
|
|
50
|
+
|
|
51
|
+
type Story = StoryObj<typeof meta>;
|
|
52
|
+
|
|
53
|
+
export const Default: Story = {
|
|
54
|
+
args: {
|
|
55
|
+
items: filterObjectsSync(objects, match),
|
|
56
|
+
match,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { Searchbar } from './Searchbar';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const meta: Meta<SearchbarProps> = {
|
|
11
|
+
const meta = {
|
|
14
12
|
title: 'plugins/plugin-search/Searchbar',
|
|
15
13
|
component: Searchbar,
|
|
16
14
|
decorators: [withTheme],
|
|
17
15
|
parameters: {
|
|
18
16
|
layout: 'centered',
|
|
19
17
|
},
|
|
20
|
-
}
|
|
18
|
+
} satisfies Meta<typeof Searchbar>;
|
|
21
19
|
|
|
22
20
|
export default meta;
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
type Story = StoryObj<typeof meta>;
|
|
23
|
+
|
|
24
|
+
export const Default: Story = {
|
|
25
25
|
args: {
|
|
26
26
|
placeholder: 'Search...',
|
|
27
27
|
},
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type KeyboardEvent, useEffect, useRef, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Input, type TextInputProps
|
|
7
|
+
import { Icon, Input, type TextInputProps } from '@dxos/react-ui';
|
|
8
8
|
|
|
9
9
|
export type SearchbarProps = Pick<TextInputProps, 'variant' | 'placeholder'> & {
|
|
10
10
|
classes?: {
|
|
@@ -45,7 +45,7 @@ export const Searchbar = ({ classes, variant, placeholder, value, onChange, onSu
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
|
-
<div className='flex shrink-
|
|
48
|
+
<div className='flex shrink-0is-full items-center pli-1 pbs-1'>
|
|
49
49
|
<Input.Root>
|
|
50
50
|
<Input.TextInput
|
|
51
51
|
ref={inputRef}
|
package/src/hooks/sync.test.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Client } from '@dxos/client';
|
|
8
|
-
import {
|
|
8
|
+
import { Filter, Obj, Type } from '@dxos/echo';
|
|
9
9
|
import { faker } from '@dxos/random';
|
|
10
10
|
|
|
11
11
|
import { filterObjectsSync } from './sync';
|
package/src/hooks/sync.ts
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
6
7
|
|
|
7
8
|
import { Obj } from '@dxos/echo';
|
|
8
|
-
import {
|
|
9
|
+
import { Text } from '@dxos/schema';
|
|
9
10
|
|
|
10
11
|
import { type SearchResult } from '../types';
|
|
11
12
|
|
|
@@ -45,7 +46,7 @@ export const filterObjectsSync = <T extends Record<string, any>>(objects: T[], m
|
|
|
45
46
|
|
|
46
47
|
return objects.reduce<SearchResult[]>((results, object) => {
|
|
47
48
|
// TODO(burdon): Hack to ignore Text objects.
|
|
48
|
-
if (object instanceof
|
|
49
|
+
if (object instanceof Text.Text) {
|
|
49
50
|
return results;
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -111,7 +112,7 @@ const getKeys = (object: Record<string, unknown>): string[] => {
|
|
|
111
112
|
export const mapObjectToTextFields = <T extends Record<string, unknown>>(object: T): TextFields => {
|
|
112
113
|
return getKeys(object).reduce<TextFields>((fields, key) => {
|
|
113
114
|
const value = object[key] as any;
|
|
114
|
-
if (typeof value === 'string' || value instanceof
|
|
115
|
+
if (typeof value === 'string' || value instanceof Text.Text) {
|
|
115
116
|
try {
|
|
116
117
|
fields[key] = String(value);
|
|
117
118
|
} catch (err) {
|