@dxos/plugin-search 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/lib/browser/app-graph-builder-4C2ZPCED.mjs +41 -0
  2. package/dist/lib/browser/app-graph-builder-4C2ZPCED.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-4L4PWJYC.mjs → chunk-B532NWHM.mjs} +3 -3
  4. package/dist/lib/browser/chunk-B532NWHM.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-GGOOQO2C.mjs +133 -0
  6. package/dist/lib/browser/chunk-GGOOQO2C.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-Z745WIBH.mjs +21 -0
  8. package/dist/lib/browser/chunk-Z745WIBH.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +61 -557
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/intent-resolver-MKBD2LPH.mjs +22 -0
  12. package/dist/lib/browser/intent-resolver-MKBD2LPH.mjs.map +7 -0
  13. package/dist/lib/browser/meta.json +1 -1
  14. package/dist/lib/browser/react-surface-ZFFHKFME.mjs +343 -0
  15. package/dist/lib/browser/react-surface-ZFFHKFME.mjs.map +7 -0
  16. package/dist/types/src/SearchPlugin.d.ts +1 -3
  17. package/dist/types/src/SearchPlugin.d.ts.map +1 -1
  18. package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
  19. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  20. package/dist/types/src/capabilities/index.d.ts +180 -0
  21. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  22. package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
  23. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  24. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  25. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  26. package/dist/types/src/components/SearchDialog.d.ts +2 -4
  27. package/dist/types/src/components/SearchDialog.d.ts.map +1 -1
  28. package/dist/types/src/components/SearchResults/SearchResults.d.ts +4 -3
  29. package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +1 -1
  30. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts +1 -1
  31. package/dist/types/src/components/Searchbar/Searchbar.d.ts +1 -2
  32. package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +1 -1
  33. package/dist/types/src/context.d.ts +2 -2
  34. package/dist/types/src/context.d.ts.map +1 -1
  35. package/dist/types/src/index.d.ts +1 -2
  36. package/dist/types/src/index.d.ts.map +1 -1
  37. package/dist/types/src/meta.d.ts +1 -2
  38. package/dist/types/src/meta.d.ts.map +1 -1
  39. package/dist/types/src/types.d.ts +0 -2
  40. package/dist/types/src/types.d.ts.map +1 -1
  41. package/dist/types/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +20 -27
  43. package/src/SearchPlugin.tsx +35 -91
  44. package/src/capabilities/app-graph-builder.ts +36 -0
  45. package/src/capabilities/index.ts +9 -0
  46. package/src/capabilities/intent-resolver.ts +18 -0
  47. package/src/capabilities/react-surface.tsx +39 -0
  48. package/src/components/SearchDialog.tsx +20 -35
  49. package/src/components/SearchResults/SearchResults.tsx +30 -43
  50. package/src/index.ts +1 -4
  51. package/src/meta.ts +1 -1
  52. package/src/search-sync.ts +1 -1
  53. package/src/search.ts +1 -1
  54. package/src/types.tsx +0 -13
  55. package/dist/lib/browser/chunk-4L4PWJYC.mjs.map +0 -7
  56. package/dist/lib/browser/meta.mjs +0 -11
  57. package/dist/lib/browser/meta.mjs.map +0 -7
@@ -1,4 +1,3 @@
1
- import type { GraphBuilderProvides, IntentResolverProvides, MetadataRecordsProvides, SurfaceProvides, TranslationsProvides } from '@dxos/app-framework';
2
1
  import { S } from '@dxos/echo-schema';
3
2
  export declare namespace SearchAction {
4
3
  const OpenSearch_base: S.TaggedClass<OpenSearch, "dxos.org/plugin/search/action/open-search", {
@@ -11,5 +10,4 @@ export declare namespace SearchAction {
11
10
  }
12
11
  export {};
13
12
  }
14
- export type SearchPluginProvides = SurfaceProvides & IntentResolverProvides & GraphBuilderProvides & MetadataRecordsProvides & TranslationsProvides;
15
13
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAItC,yBAAiB,YAAY,CAAC;;;;;;;IAG5B,MAAM,OAAO,UAAW,SAAQ,eAG9B;KAAG;;CACN;AAED,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAChD,sBAAsB,GACtB,oBAAoB,GACpB,uBAAuB,GACvB,oBAAoB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAItC,yBAAiB,YAAY,CAAC;;;;;;;IAG5B,MAAM,OAAO,UAAW,SAAQ,eAG9B;KAAG;;CACN"}
@@ -1 +1 @@
1
- {"version":"5.7.2"}
1
+ {"version":"5.7.3"}
package/package.json CHANGED
@@ -1,29 +1,22 @@
1
1
  {
2
2
  "name": "@dxos/plugin-search",
3
- "version": "0.7.5-main.9d26e3a",
3
+ "version": "0.7.5-main.b19bfc8",
4
4
  "description": "Braneframe sketch plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
7
  "license": "MIT",
8
8
  "author": "DXOS.org",
9
9
  "sideEffects": true,
10
+ "type": "module",
10
11
  "exports": {
11
12
  ".": {
12
13
  "types": "./dist/types/src/index.d.ts",
13
14
  "browser": "./dist/lib/browser/index.mjs"
14
- },
15
- "./meta": {
16
- "types": "./dist/types/src/meta.d.ts",
17
- "browser": "./dist/lib/browser/meta.mjs"
18
15
  }
19
16
  },
20
17
  "types": "dist/types/src/index.d.ts",
21
18
  "typesVersions": {
22
- "*": {
23
- "meta": [
24
- "dist/types/src/meta.d.ts"
25
- ]
26
- }
19
+ "*": {}
27
20
  },
28
21
  "files": [
29
22
  "dist",
@@ -32,17 +25,17 @@
32
25
  "dependencies": {
33
26
  "@effect/schema": "^0.75.5",
34
27
  "main-thread-scheduling": "^14.1.1",
35
- "@dxos/live-object": "0.7.5-main.9d26e3a",
36
- "@dxos/app-framework": "0.7.5-main.9d26e3a",
37
- "@dxos/echo-schema": "0.7.5-main.9d26e3a",
38
- "@dxos/debug": "0.7.5-main.9d26e3a",
39
- "@dxos/plugin-graph": "0.7.5-main.9d26e3a",
40
- "@dxos/plugin-markdown": "0.7.5-main.9d26e3a",
41
- "@dxos/plugin-space": "0.7.5-main.9d26e3a",
42
- "@dxos/react-client": "0.7.5-main.9d26e3a",
43
- "@dxos/react-ui-mosaic": "0.7.5-main.9d26e3a",
44
- "@dxos/react-ui-searchlist": "0.7.5-main.9d26e3a",
45
- "@dxos/react-ui-card": "0.7.5-main.9d26e3a"
28
+ "@dxos/debug": "0.7.5-main.b19bfc8",
29
+ "@dxos/app-framework": "0.7.5-main.b19bfc8",
30
+ "@dxos/echo-schema": "0.7.5-main.b19bfc8",
31
+ "@dxos/live-object": "0.7.5-main.b19bfc8",
32
+ "@dxos/plugin-graph": "0.7.5-main.b19bfc8",
33
+ "@dxos/plugin-markdown": "0.7.5-main.b19bfc8",
34
+ "@dxos/plugin-space": "0.7.5-main.b19bfc8",
35
+ "@dxos/react-client": "0.7.5-main.b19bfc8",
36
+ "@dxos/react-ui-card": "0.7.5-main.b19bfc8",
37
+ "@dxos/react-ui-searchlist": "0.7.5-main.b19bfc8",
38
+ "@dxos/schema": "0.7.5-main.b19bfc8"
46
39
  },
47
40
  "devDependencies": {
48
41
  "@phosphor-icons/react": "^2.1.5",
@@ -51,17 +44,17 @@
51
44
  "react": "~18.2.0",
52
45
  "react-dom": "~18.2.0",
53
46
  "vite": "5.4.7",
54
- "@dxos/random": "0.7.5-main.9d26e3a",
55
- "@dxos/react-ui": "0.7.5-main.9d26e3a",
56
- "@dxos/react-ui-theme": "0.7.5-main.9d26e3a",
57
- "@dxos/storybook-utils": "0.7.5-main.9d26e3a"
47
+ "@dxos/random": "0.7.5-main.b19bfc8",
48
+ "@dxos/react-ui": "0.7.5-main.b19bfc8",
49
+ "@dxos/react-ui-theme": "0.7.5-main.b19bfc8",
50
+ "@dxos/storybook-utils": "0.7.5-main.b19bfc8"
58
51
  },
59
52
  "peerDependencies": {
60
53
  "@phosphor-icons/react": "^2.1.5",
61
54
  "react": "~18.2.0",
62
55
  "react-dom": "~18.2.0",
63
- "@dxos/react-ui": "0.7.5-main.9d26e3a",
64
- "@dxos/react-ui-theme": "0.7.5-main.9d26e3a"
56
+ "@dxos/react-ui-theme": "0.7.5-main.b19bfc8",
57
+ "@dxos/react-ui": "0.7.5-main.b19bfc8"
65
58
  },
66
59
  "publishConfig": {
67
60
  "access": "public"
@@ -2,38 +2,27 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import React from 'react';
5
+ import { contributes, Events, defineModule, definePlugin, Capabilities } from '@dxos/app-framework';
6
6
 
7
- import {
8
- type PluginDefinition,
9
- resolvePlugin,
10
- parseIntentPlugin,
11
- parseGraphPlugin,
12
- parseNavigationPlugin,
13
- LayoutAction,
14
- firstIdInPart,
15
- createSurface,
16
- createResolver,
17
- createIntent,
18
- } from '@dxos/app-framework';
19
- import { createExtension, type Node } from '@dxos/plugin-graph';
20
- import { getActiveSpace } from '@dxos/plugin-space';
21
-
22
- import { SEARCH_DIALOG, SearchDialog, type SearchDialogProps, SearchMain } from './components';
23
- import { SearchContextProvider } from './context';
24
- import meta, { SEARCH_PLUGIN, SEARCH_RESULT } from './meta';
7
+ import { AppGraphBuilder, IntentResolver, ReactSurface } from './capabilities';
8
+ import { meta, SEARCH_RESULT } from './meta';
25
9
  import type { SearchResult } from './search-sync';
26
10
  import translations from './translations';
27
- import { SearchAction, type SearchPluginProvides } from './types';
28
11
 
29
- export const SearchPlugin = (): PluginDefinition<SearchPluginProvides> => {
30
- return {
31
- meta,
32
- provides: {
33
- translations,
34
- metadata: {
35
- records: {
36
- [SEARCH_RESULT]: {
12
+ export const SearchPlugin = () =>
13
+ definePlugin(meta, [
14
+ defineModule({
15
+ id: `${meta.id}/module/translations`,
16
+ activatesOn: Events.SetupTranslations,
17
+ activate: () => contributes(Capabilities.Translations, translations),
18
+ }),
19
+ defineModule({
20
+ id: `${meta.id}/module/metadata`,
21
+ activatesOn: Events.SetupMetadata,
22
+ activate: () =>
23
+ contributes(Capabilities.Metadata, {
24
+ id: SEARCH_RESULT,
25
+ metadata: {
37
26
  parse: (item: SearchResult, type: string) => {
38
27
  switch (type) {
39
28
  case 'node':
@@ -45,66 +34,21 @@ export const SearchPlugin = (): PluginDefinition<SearchPluginProvides> => {
45
34
  }
46
35
  },
47
36
  },
48
- },
49
- },
50
- graph: {
51
- builder: (plugins) => {
52
- const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;
53
-
54
- return createExtension({
55
- id: SEARCH_PLUGIN,
56
- filter: (node): node is Node<null> => node.id === 'root',
57
- actions: () => [
58
- {
59
- id: SearchAction.OpenSearch._tag,
60
- data: async () => {
61
- await dispatch?.(createIntent(SearchAction.OpenSearch));
62
- },
63
- properties: {
64
- label: ['search action label', { ns: SEARCH_PLUGIN }],
65
- icon: 'ph--magnifying-glass--regular',
66
- keyBinding: {
67
- macos: 'shift+meta+f',
68
- windows: 'shift+alt+f',
69
- },
70
- testId: 'searchPlugin.search',
71
- },
72
- },
73
- ],
74
- });
75
- },
76
- },
77
- context: ({ children }) => <SearchContextProvider>{children}</SearchContextProvider>,
78
- surface: {
79
- definitions: ({ plugins }) => {
80
- const location = resolvePlugin(plugins, parseNavigationPlugin)?.provides.location;
81
- const graph = resolvePlugin(plugins, parseGraphPlugin)?.provides.graph;
82
-
83
- return [
84
- createSurface({
85
- id: SEARCH_DIALOG,
86
- role: 'dialog',
87
- filter: (data): data is { subject: SearchDialogProps } => data.component === SEARCH_DIALOG,
88
- component: ({ data }) => <SearchDialog {...data.subject} />,
89
- }),
90
- createSurface({
91
- id: 'search-input',
92
- role: 'search-input',
93
- component: () => {
94
- const space =
95
- graph && location ? getActiveSpace(graph, firstIdInPart(location.active, 'main')) : undefined;
96
- return space ? <SearchMain space={space} /> : null;
97
- },
98
- }),
99
- ];
100
- },
101
- },
102
- intent: {
103
- resolvers: () =>
104
- createResolver(SearchAction.OpenSearch, () => ({
105
- intents: [createIntent(LayoutAction.SetLayout, { element: 'complementary', state: true })],
106
- })),
107
- },
108
- },
109
- };
110
- };
37
+ }),
38
+ }),
39
+ defineModule({
40
+ id: `${meta.id}/module/react-surface`,
41
+ activatesOn: Events.SetupReactSurface,
42
+ activate: ReactSurface,
43
+ }),
44
+ defineModule({
45
+ id: `${meta.id}/module/intent-resolver`,
46
+ activatesOn: Events.SetupIntentResolver,
47
+ activate: IntentResolver,
48
+ }),
49
+ defineModule({
50
+ id: `${meta.id}/module/app-graph-builder`,
51
+ activatesOn: Events.SetupAppGraph,
52
+ activate: AppGraphBuilder,
53
+ }),
54
+ ]);
@@ -0,0 +1,36 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capabilities, contributes, createIntent, type PluginsContext } from '@dxos/app-framework';
6
+ import { createExtension, type Node } from '@dxos/plugin-graph';
7
+
8
+ import { SEARCH_PLUGIN } from '../meta';
9
+ import { SearchAction } from '../types';
10
+
11
+ export default (context: PluginsContext) =>
12
+ contributes(
13
+ Capabilities.AppGraphBuilder,
14
+ createExtension({
15
+ id: SEARCH_PLUGIN,
16
+ filter: (node): node is Node<null> => node.id === 'root',
17
+ actions: () => [
18
+ {
19
+ id: SearchAction.OpenSearch._tag,
20
+ data: async () => {
21
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
22
+ await dispatch(createIntent(SearchAction.OpenSearch));
23
+ },
24
+ properties: {
25
+ label: ['search action label', { ns: SEARCH_PLUGIN }],
26
+ icon: 'ph--magnifying-glass--regular',
27
+ keyBinding: {
28
+ macos: 'shift+meta+f',
29
+ windows: 'shift+alt+f',
30
+ },
31
+ testId: 'searchPlugin.search',
32
+ },
33
+ },
34
+ ],
35
+ }),
36
+ );
@@ -0,0 +1,9 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { lazy } from '@dxos/app-framework';
6
+
7
+ export const AppGraphBuilder = lazy(() => import('./app-graph-builder'));
8
+ export const IntentResolver = lazy(() => import('./intent-resolver'));
9
+ export const ReactSurface = lazy(() => import('./react-surface'));
@@ -0,0 +1,18 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { contributes, Capabilities, createResolver, LayoutAction, createIntent } from '@dxos/app-framework';
6
+
7
+ import { SearchAction } from '../types';
8
+
9
+ export default () =>
10
+ contributes(
11
+ Capabilities.IntentResolver,
12
+ createResolver({
13
+ intent: SearchAction.OpenSearch,
14
+ resolve: () => ({
15
+ intents: [createIntent(LayoutAction.UpdateComplementary, { part: 'complementary', subject: 'search' })],
16
+ }),
17
+ }),
18
+ );
@@ -0,0 +1,39 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { Capabilities, contributes, createSurface, useLayout, useAppGraph } from '@dxos/app-framework';
8
+ import { getActiveSpace } from '@dxos/plugin-space';
9
+
10
+ import { SEARCH_DIALOG, SearchDialog, type SearchDialogProps, SearchMain } from '../components';
11
+ import { SearchContextProvider } from '../context';
12
+
13
+ export default () =>
14
+ contributes(Capabilities.ReactSurface, [
15
+ createSurface({
16
+ id: SEARCH_DIALOG,
17
+ role: 'dialog',
18
+ filter: (data): data is { props: SearchDialogProps } => data.component === SEARCH_DIALOG,
19
+ component: ({ data }) => (
20
+ <SearchContextProvider>
21
+ <SearchDialog {...data.props} />
22
+ </SearchContextProvider>
23
+ ),
24
+ }),
25
+ createSurface({
26
+ id: 'search-input',
27
+ role: 'search-input',
28
+ component: () => {
29
+ const layout = useLayout();
30
+ const { graph } = useAppGraph();
31
+ const space = graph ? getActiveSpace(graph, layout.active[0]) : undefined;
32
+ return space ? (
33
+ <SearchContextProvider>
34
+ <SearchMain space={space} />
35
+ </SearchContextProvider>
36
+ ) : null;
37
+ },
38
+ }),
39
+ ]);
@@ -4,17 +4,7 @@
4
4
 
5
5
  import React, { forwardRef, useCallback, useState } from 'react';
6
6
 
7
- import {
8
- useResolvePlugin,
9
- parseNavigationPlugin,
10
- parseGraphPlugin,
11
- NavigationAction,
12
- LayoutAction,
13
- type LayoutCoordinate,
14
- isLayoutParts,
15
- useIntentDispatcher,
16
- createIntent,
17
- } from '@dxos/app-framework';
7
+ import { LayoutAction, createIntent, useAppGraph, useIntentDispatcher, useLayout } from '@dxos/app-framework';
18
8
  import { type Node } from '@dxos/plugin-graph';
19
9
  import { useClient } from '@dxos/react-client';
20
10
  import { Filter, fullyQualifiedId, useQuery } from '@dxos/react-client/echo';
@@ -49,19 +39,16 @@ const SearchListResult = forwardRef<HTMLDivElement, SearchListResultProps>(({ no
49
39
  });
50
40
 
51
41
  export type SearchDialogProps = {
52
- layoutCoordinate: LayoutCoordinate;
42
+ pivotId: string;
53
43
  };
54
44
 
55
- export const SearchDialog = ({ layoutCoordinate }: SearchDialogProps) => {
45
+ export const SearchDialog = ({ pivotId }: SearchDialogProps) => {
56
46
  const { t } = useTranslation(SEARCH_PLUGIN);
57
- const graphPlugin = useResolvePlugin(parseGraphPlugin);
58
- const graph = graphPlugin?.provides.graph;
59
- const navigationPlugin = useResolvePlugin(parseNavigationPlugin);
60
- const providedClosed = navigationPlugin?.provides.location.closed ?? [];
61
- const closed = (Array.isArray(providedClosed) ? providedClosed : [providedClosed])
47
+ const { graph } = useAppGraph();
48
+ const layout = useLayout();
49
+ const closed = (Array.isArray(layout.inactive) ? layout.inactive : [layout.inactive])
62
50
  .map((id) => graph?.findNode(id))
63
51
  .filter(Boolean);
64
- const active = navigationPlugin?.provides.location.active;
65
52
  const [queryString, setQueryString] = useState('');
66
53
  const client = useClient();
67
54
  const dangerouslyLoadAllObjects = useQuery(client.spaces, Filter.all());
@@ -71,28 +58,26 @@ export const SearchDialog = ({ layoutCoordinate }: SearchDialogProps) => {
71
58
 
72
59
  const handleSelect = useCallback(
73
60
  async (nodeId: string) => {
74
- if (active && isLayoutParts(active)) {
75
- // If node is already present in the active parts, scroll to it and close the dialog.
76
- const index = active?.main?.findIndex((entry) => entry.id === nodeId);
77
- if (index !== -1) {
78
- await dispatch(createIntent(LayoutAction.SetLayout, { element: 'dialog', state: false }));
79
- await dispatch(createIntent(LayoutAction.ScrollIntoView, { id: nodeId }));
80
- return;
81
- }
61
+ await dispatch(createIntent(LayoutAction.UpdateDialog, { part: 'dialog', options: { state: false } }));
82
62
 
63
+ // If node is already present in the active parts, scroll to it and close the dialog.
64
+ const index = layout.active.findIndex((id) => id === nodeId);
65
+ if (index !== -1) {
66
+ await dispatch(createIntent(LayoutAction.ScrollIntoView, { part: 'current', subject: nodeId }));
67
+ } else {
83
68
  await dispatch(
84
- createIntent(NavigationAction.AddToActive, {
85
- part: layoutCoordinate.part,
86
- id: nodeId,
87
- pivotId: layoutCoordinate.entryId,
88
- positioning: 'end',
69
+ createIntent(LayoutAction.Open, {
70
+ part: 'main',
71
+ subject: [nodeId],
72
+ options: {
73
+ pivotId,
74
+ positioning: 'end',
75
+ },
89
76
  }),
90
77
  );
91
- await dispatch(createIntent(LayoutAction.SetLayout, { element: 'dialog', state: false }));
92
- await dispatch(createIntent(LayoutAction.ScrollIntoView, { id: nodeId }));
93
78
  }
94
79
  },
95
- [layoutCoordinate, dispatch, active],
80
+ [pivotId, dispatch, layout],
96
81
  );
97
82
 
98
83
  return (
@@ -7,7 +7,6 @@ import React, { type FC, forwardRef } from 'react';
7
7
 
8
8
  import { ScrollArea } from '@dxos/react-ui';
9
9
  import { Card } from '@dxos/react-ui-card';
10
- import { type MosaicTileComponent, Mosaic } from '@dxos/react-ui-mosaic';
11
10
  import { ghostHover, mx } from '@dxos/react-ui-theme';
12
11
 
13
12
  import { SEARCH_RESULT } from '../../meta';
@@ -58,37 +57,28 @@ export const Snippet: FC<{ text: string; match?: RegExp }> = ({ text, match }) =
58
57
 
59
58
  export type SearchItemProps = SearchResult & { selected: boolean } & Pick<SearchResultsProps, 'onSelect'>;
60
59
 
61
- export const SearchItem: MosaicTileComponent<SearchItemProps> = forwardRef(
62
- ({ draggableStyle, draggableProps, item, debug = false }, forwardRef) => {
63
- const { id, type, label, snippet, match, selected, onSelect } = item;
64
- const Icon = type ? getIcon(type) : undefined;
60
+ export const SearchItem = forwardRef<HTMLDivElement, SearchItemProps>((item, forwardRef) => {
61
+ const { id, type, label, snippet, match, selected, onSelect } = item;
62
+ const Icon = type ? getIcon(type) : undefined;
65
63
 
66
- return (
67
- <Card.Root
68
- ref={forwardRef}
69
- style={draggableStyle}
70
- classNames={mx('mx-2 mt-2 cursor-pointer', ghostHover, selected && styles.selected)}
71
- onClick={() => onSelect?.(id)}
72
- >
73
- <Card.Header>
74
- <Card.DragHandle {...draggableProps} />
75
- <Card.Title title={label ?? 'Untitled'} />
76
- {Icon && <Card.Endcap Icon={Icon} />}
77
- </Card.Header>
78
- {snippet && (
79
- <Card.Body gutter>
80
- <Snippet text={snippet} match={match} />
81
- </Card.Body>
82
- )}
83
- {debug && (
84
- <Card.Body gutter>
85
- <pre className='text-xs whitespace-pre-line'>{JSON.stringify(item)}</pre>
86
- </Card.Body>
87
- )}
88
- </Card.Root>
89
- );
90
- },
91
- );
64
+ return (
65
+ <Card.Root
66
+ ref={forwardRef}
67
+ classNames={mx('mx-2 mt-2 cursor-pointer', ghostHover, selected && styles.selected)}
68
+ onClick={() => onSelect?.(id)}
69
+ >
70
+ <Card.Header>
71
+ <Card.Title title={label ?? 'Untitled'} />
72
+ {Icon && <Card.Endcap Icon={Icon} />}
73
+ </Card.Header>
74
+ {snippet && (
75
+ <Card.Body gutter>
76
+ <Snippet text={snippet} match={match} />
77
+ </Card.Body>
78
+ )}
79
+ </Card.Root>
80
+ );
81
+ });
92
82
 
93
83
  export type SearchResultsProps = {
94
84
  match?: RegExp;
@@ -99,21 +89,18 @@ export type SearchResultsProps = {
99
89
 
100
90
  // TODO(burdon): Key cursor up/down.
101
91
  export const SearchResults = ({ items, selected, onSelect }: SearchResultsProps) => {
102
- const path = 'search';
103
92
  return (
104
93
  <ScrollArea.Root classNames='grow'>
105
94
  <ScrollArea.Viewport>
106
- <Mosaic.Container id={path} Component={SearchItem}>
107
- {items.map((item) => (
108
- <Mosaic.DraggableTile
109
- key={item.id}
110
- path={path}
111
- type={SEARCH_RESULT}
112
- item={{ ...item, selected: selected === item.id, onSelect }}
113
- Component={SearchItem}
114
- />
115
- ))}
116
- </Mosaic.Container>
95
+ {items.map((item) => (
96
+ <SearchItem
97
+ key={item.id}
98
+ type={SEARCH_RESULT}
99
+ {...item}
100
+ onSelect={onSelect}
101
+ selected={selected === item.id}
102
+ />
103
+ ))}
117
104
  </ScrollArea.Viewport>
118
105
  <ScrollArea.Scrollbar orientation='vertical'>
119
106
  <ScrollArea.Thumb />
package/src/index.ts CHANGED
@@ -2,11 +2,8 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { SearchPlugin } from './SearchPlugin';
6
-
7
- export default SearchPlugin;
8
-
9
5
  export * from './context';
6
+ export * from './meta';
10
7
  export * from './search-sync';
11
8
 
12
9
  export * from './SearchPlugin';
package/src/meta.ts CHANGED
@@ -7,7 +7,7 @@ import { type PluginMeta } from '@dxos/app-framework';
7
7
  export const SEARCH_PLUGIN = 'dxos.org/plugin/search';
8
8
  export const SEARCH_RESULT = `${SEARCH_PLUGIN}/result`;
9
9
 
10
- export default {
10
+ export const meta = {
11
11
  id: SEARCH_PLUGIN,
12
12
  name: 'Search',
13
13
  description: 'Search ECHO spaces for content.',
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { AST, type S } from '@dxos/echo-schema';
6
6
  import { getSchema } from '@dxos/live-object';
7
- import { TextType } from '@dxos/plugin-markdown/types';
7
+ import { TextType } from '@dxos/schema';
8
8
 
9
9
  export const queryStringToMatch = (queryString?: string): RegExp | undefined => {
10
10
  const trimmed = queryString?.trim();
package/src/search.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  import { yieldOrContinue } from 'main-thread-scheduling';
6
6
  import { useEffect, useState } from 'react';
7
7
 
8
- import { TextType } from '@dxos/plugin-markdown/types';
8
+ import { TextType } from '@dxos/schema';
9
9
 
10
10
  // TODO(thure): Deprecate search-sync, move still-relevant utilities elsewhere (here, probably).
11
11
  import { mapObjectToTextFields, queryStringToMatch } from './search-sync';
package/src/types.tsx CHANGED
@@ -2,13 +2,6 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import type {
6
- GraphBuilderProvides,
7
- IntentResolverProvides,
8
- MetadataRecordsProvides,
9
- SurfaceProvides,
10
- TranslationsProvides,
11
- } from '@dxos/app-framework';
12
5
  import { S } from '@dxos/echo-schema';
13
6
 
14
7
  import { SEARCH_PLUGIN } from './meta';
@@ -21,9 +14,3 @@ export namespace SearchAction {
21
14
  output: S.Void,
22
15
  }) {}
23
16
  }
24
-
25
- export type SearchPluginProvides = SurfaceProvides &
26
- IntentResolverProvides &
27
- GraphBuilderProvides &
28
- MetadataRecordsProvides &
29
- TranslationsProvides;
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const SEARCH_PLUGIN = 'dxos.org/plugin/search';\nexport const SEARCH_RESULT = `${SEARCH_PLUGIN}/result`;\n\nexport default {\n id: SEARCH_PLUGIN,\n name: 'Search',\n description: 'Search ECHO spaces for content.',\n icon: 'ph--magnifying-glass--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-search',\n tags: ['experimental'],\n} satisfies PluginMeta;\n"],
5
- "mappings": ";AAMO,IAAMA,gBAAgB;AACtB,IAAMC,gBAAgB,GAAGD,aAAAA;AAEhC,IAAA,eAAe;EACbE,IAAIF;EACJG,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;AACT;",
6
- "names": ["SEARCH_PLUGIN", "SEARCH_RESULT", "id", "name", "description", "icon", "source", "tags"]
7
- }
@@ -1,11 +0,0 @@
1
- import {
2
- SEARCH_PLUGIN,
3
- SEARCH_RESULT,
4
- meta_default
5
- } from "./chunk-4L4PWJYC.mjs";
6
- export {
7
- SEARCH_PLUGIN,
8
- SEARCH_RESULT,
9
- meta_default as default
10
- };
11
- //# sourceMappingURL=meta.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }