@dxos/plugin-search 0.8.4-main.c85a9c8dae → 0.8.4-main.d9fc60f731
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/LICENSE +102 -5
- package/PLUGIN.mdl +291 -0
- package/dist/lib/neutral/SearchArticle-CQMZ46ZS.mjs +51 -0
- package/dist/lib/neutral/SearchArticle-CQMZ46ZS.mjs.map +7 -0
- package/dist/lib/neutral/SearchDialog-IFMA5UP5.mjs +76 -0
- package/dist/lib/neutral/SearchDialog-IFMA5UP5.mjs.map +7 -0
- package/dist/lib/neutral/SearchPlugin.mjs +10 -0
- package/dist/lib/neutral/SearchPlugin.mjs.map +7 -0
- package/dist/lib/{browser/app-graph-builder-NUJ2FOVQ.mjs → neutral/app-graph-builder-ADB5LBS5.mjs} +23 -34
- package/dist/lib/neutral/app-graph-builder-ADB5LBS5.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +13 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-2XHA22US.mjs +9 -0
- package/dist/lib/neutral/chunk-2XHA22US.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BST37VRI.mjs +34 -0
- package/dist/lib/neutral/chunk-BST37VRI.mjs.map +7 -0
- package/dist/lib/{browser/chunk-NB4JZIOE.mjs → neutral/chunk-CZU523NP.mjs} +22 -22
- package/dist/lib/neutral/chunk-CZU523NP.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GT3AGVU6.mjs +28 -0
- package/dist/lib/neutral/chunk-GT3AGVU6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Q2F6YOOZ.mjs +41 -0
- package/dist/lib/neutral/chunk-Q2F6YOOZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-TN4G3MZZ.mjs +8 -0
- package/dist/lib/neutral/chunk-TN4G3MZZ.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +97 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +11 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +30 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +40 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +10 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/open-search-Y6OUELN3.mjs +23 -0
- package/dist/lib/neutral/open-search-Y6OUELN3.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-DY624P2R.mjs +13 -0
- package/dist/lib/neutral/operation-handler-DY624P2R.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-3IXL3EOJ.mjs +61 -0
- package/dist/lib/neutral/react-surface-3IXL3EOJ.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +8 -0
- package/dist/lib/neutral/testing.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +25 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +8 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/SearchPlugin.d.ts +1 -0
- package/dist/types/src/SearchPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/SearchResultStack/SearchResultStack.d.ts +9 -0
- package/dist/types/src/components/SearchResultStack/SearchResultStack.d.ts.map +1 -0
- package/dist/types/src/components/SearchResultStack/index.d.ts +2 -0
- package/dist/types/src/components/SearchResultStack/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +2 -1
- package/dist/types/src/constants.d.ts.map +1 -1
- package/dist/types/src/containers/SearchArticle/SearchArticle.d.ts +4 -0
- package/dist/types/src/containers/SearchArticle/SearchArticle.d.ts.map +1 -0
- package/dist/types/src/containers/SearchArticle/SearchArticle.stories.d.ts +14 -0
- package/dist/types/src/containers/SearchArticle/SearchArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/SearchArticle/index.d.ts +2 -0
- package/dist/types/src/containers/SearchArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts +5 -4
- package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts.map +1 -1
- package/dist/types/src/containers/SearchDialog/SearchDialog.stories.d.ts +16 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.stories.d.ts.map +1 -0
- package/dist/types/src/containers/SearchDialog/index.d.ts +1 -2
- package/dist/types/src/containers/SearchDialog/index.d.ts.map +1 -1
- package/dist/types/src/containers/index.d.ts +1 -3
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/hooks/sync.d.ts +2 -2
- package/dist/types/src/hooks/sync.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobalSearch.d.ts +2 -2
- package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
- package/dist/types/src/hooks/useSearchResults.d.ts.map +1 -1
- 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/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open-search.d.ts +5 -0
- package/dist/types/src/operations/open-search.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/search/exa.d.ts +4 -5
- package/dist/types/src/search/exa.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +15 -10
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/SearchOperation.d.ts +3 -0
- package/dist/types/src/types/SearchOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/search.d.ts +1 -16
- package/dist/types/src/types/search.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +102 -46
- package/src/SearchPlugin.tsx +12 -22
- package/src/capabilities/{app-graph-builder/app-graph-builder.ts → app-graph-builder.ts} +14 -19
- package/src/capabilities/index.ts +9 -3
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +72 -0
- package/src/components/SearchResultStack/SearchResultStack.tsx +118 -0
- package/src/components/SearchResultStack/index.ts +5 -0
- package/src/components/index.ts +2 -0
- package/src/constants.ts +4 -2
- package/src/containers/SearchArticle/SearchArticle.stories.tsx +79 -0
- package/src/containers/SearchArticle/SearchArticle.tsx +60 -0
- package/src/containers/SearchArticle/index.ts +5 -0
- package/src/containers/SearchDialog/SearchDialog.stories.tsx +108 -0
- package/src/containers/SearchDialog/SearchDialog.tsx +67 -94
- package/src/containers/SearchDialog/index.ts +1 -3
- package/src/containers/index.ts +1 -4
- package/src/hooks/sync.test.ts +4 -4
- package/src/hooks/sync.ts +11 -8
- package/src/hooks/useGlobalSearch.tsx +3 -3
- package/src/hooks/useSearchResults.ts +2 -2
- package/src/hooks/useWebSearch.ts +6 -6
- package/src/index.ts +2 -2
- package/src/meta.ts +25 -7
- package/src/operations/index.ts +7 -0
- package/src/operations/open-search.ts +24 -0
- package/src/plugin.ts +11 -0
- package/src/search/exa.test.ts +6 -6
- package/src/search/exa.ts +6 -6
- package/src/testing.ts +7 -0
- package/src/translations.ts +10 -9
- package/src/types/SearchOperation.ts +20 -0
- package/src/types/index.ts +2 -1
- package/src/types/search.ts +1 -19
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/SearchDialog-E6336HCX.mjs +0 -110
- package/dist/lib/browser/SearchDialog-E6336HCX.mjs.map +0 -7
- package/dist/lib/browser/SearchMain-24ZNJB24.mjs +0 -100
- package/dist/lib/browser/SearchMain-24ZNJB24.mjs.map +0 -7
- package/dist/lib/browser/SpaceMain-IGCYHL7R.mjs +0 -154
- package/dist/lib/browser/SpaceMain-IGCYHL7R.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-NUJ2FOVQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-HRIWTRJV.mjs +0 -22
- package/dist/lib/browser/chunk-HRIWTRJV.mjs.map +0 -7
- package/dist/lib/browser/chunk-I7YWQSUZ.mjs +0 -26
- package/dist/lib/browser/chunk-I7YWQSUZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-NB4JZIOE.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -105
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/operation-resolver-QEGN4ZKN.mjs +0 -26
- package/dist/lib/browser/operation-resolver-QEGN4ZKN.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FLO4YTFP.mjs +0 -73
- package/dist/lib/browser/react-surface-FLO4YTFP.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/containers/SearchMain/SearchMain.d.ts +0 -6
- package/dist/types/src/containers/SearchMain/SearchMain.d.ts.map +0 -1
- package/dist/types/src/containers/SearchMain/index.d.ts +0 -3
- package/dist/types/src/containers/SearchMain/index.d.ts.map +0 -1
- package/dist/types/src/containers/SpaceMain/SpaceMain.d.ts +0 -6
- package/dist/types/src/containers/SpaceMain/SpaceMain.d.ts.map +0 -1
- package/dist/types/src/containers/SpaceMain/index.d.ts +0 -3
- package/dist/types/src/containers/SpaceMain/index.d.ts.map +0 -1
- package/dist/types/src/types/action.d.ts +0 -16
- package/dist/types/src/types/action.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -24
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -72
- package/src/containers/SearchMain/SearchMain.tsx +0 -103
- package/src/containers/SearchMain/index.ts +0 -7
- package/src/containers/SpaceMain/SpaceMain.tsx +0 -180
- package/src/containers/SpaceMain/index.ts +0 -7
- package/src/types/action.tsx +0 -18
- /package/dist/types/src/capabilities/{app-graph-builder/app-graph-builder.d.ts → app-graph-builder.d.ts} +0 -0
- /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SearchMain.d.ts","sourceRoot":"","sources":["../../../../../src/containers/SearchMain/SearchMain.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAK9D,OAAO,EAAU,KAAK,KAAK,EAAY,MAAM,yBAAyB,CAAC;AAWvE,eAAO,MAAM,UAAU,GAAI,WAAW;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,sBAwDtD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/containers/SearchMain/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,eAAe,UAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpaceMain.d.ts","sourceRoot":"","sources":["../../../../../src/containers/SpaceMain/SpaceMain.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAOzE,OAAO,EAAE,KAAK,KAAK,EAAY,MAAM,yBAAyB,CAAC;AAU/D,eAAO,MAAM,SAAS,GAAI,WAAW;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,sBA0BpD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/containers/SpaceMain/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,eAAe,SAAS,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as Schema from 'effect/Schema';
|
|
2
|
-
export declare namespace SearchOperation {
|
|
3
|
-
const OpenSearch: Omit<{
|
|
4
|
-
readonly meta: {
|
|
5
|
-
readonly key: `${string}/open-search`;
|
|
6
|
-
readonly name: "Open Search";
|
|
7
|
-
};
|
|
8
|
-
readonly schema: {
|
|
9
|
-
readonly input: typeof Schema.Void;
|
|
10
|
-
readonly output: typeof Schema.Void;
|
|
11
|
-
};
|
|
12
|
-
}, "executionMode"> & import("effect/Pipeable").Pipeable & {
|
|
13
|
-
readonly executionMode: "sync" | "async";
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=action.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../src/types/action.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAQxC,yBAAiB,eAAe,CAAC;IACxB,MAAM,UAAU;;;;;;;;;;;KAGrB,CAAC;CACJ"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Effect from 'effect/Effect';
|
|
6
|
-
|
|
7
|
-
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
-
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
-
import { Operation, OperationResolver } from '@dxos/operation';
|
|
10
|
-
|
|
11
|
-
import { SearchOperation } from '../../types';
|
|
12
|
-
|
|
13
|
-
export default Capability.makeModule(
|
|
14
|
-
Effect.fnUntraced(function* () {
|
|
15
|
-
return Capability.contributes(Capabilities.OperationResolver, [
|
|
16
|
-
OperationResolver.make({
|
|
17
|
-
operation: SearchOperation.OpenSearch,
|
|
18
|
-
handler: Effect.fnUntraced(function* () {
|
|
19
|
-
yield* Operation.invoke(LayoutOperation.UpdateComplementary, { subject: 'search' });
|
|
20
|
-
}),
|
|
21
|
-
}),
|
|
22
|
-
]);
|
|
23
|
-
}),
|
|
24
|
-
);
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Effect from 'effect/Effect';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
|
|
8
|
-
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
-
import { Surface } from '@dxos/app-framework/ui';
|
|
10
|
-
import { useActiveSpace } from '@dxos/plugin-space';
|
|
11
|
-
import { type Space, SpaceState, isSpace } from '@dxos/react-client/echo';
|
|
12
|
-
|
|
13
|
-
import { SEARCH_DIALOG } from '../../constants';
|
|
14
|
-
import { SearchDialog, type SearchDialogProps, SearchMain, SpaceMain } from '../../containers';
|
|
15
|
-
import { SearchContextProvider } from '../../hooks';
|
|
16
|
-
import { meta } from '../../meta';
|
|
17
|
-
|
|
18
|
-
export default Capability.makeModule(() =>
|
|
19
|
-
Effect.succeed(
|
|
20
|
-
Capability.contributes(Capabilities.ReactSurface, [
|
|
21
|
-
Surface.create({
|
|
22
|
-
id: SEARCH_DIALOG,
|
|
23
|
-
role: 'dialog',
|
|
24
|
-
filter: (data): data is { props: SearchDialogProps } => data.component === SEARCH_DIALOG,
|
|
25
|
-
component: ({ data }) => (
|
|
26
|
-
<SearchContextProvider>
|
|
27
|
-
<SearchDialog {...data.props} />
|
|
28
|
-
</SearchContextProvider>
|
|
29
|
-
),
|
|
30
|
-
}),
|
|
31
|
-
Surface.create({
|
|
32
|
-
id: `${SEARCH_DIALOG}/search-input`,
|
|
33
|
-
role: 'search-input',
|
|
34
|
-
component: () => {
|
|
35
|
-
const space = useActiveSpace();
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<SearchContextProvider>
|
|
39
|
-
<SearchMain space={space} />
|
|
40
|
-
</SearchContextProvider>
|
|
41
|
-
);
|
|
42
|
-
},
|
|
43
|
-
}),
|
|
44
|
-
Surface.create({
|
|
45
|
-
id: `${SEARCH_DIALOG}/search`,
|
|
46
|
-
role: 'deck-companion--search',
|
|
47
|
-
filter: (data): data is { subject: Space } => isSpace(data.subject),
|
|
48
|
-
component: ({ data }) => {
|
|
49
|
-
const space = data.subject;
|
|
50
|
-
if (!space) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<SearchContextProvider>
|
|
56
|
-
<SearchMain space={space} />
|
|
57
|
-
</SearchContextProvider>
|
|
58
|
-
);
|
|
59
|
-
},
|
|
60
|
-
}),
|
|
61
|
-
Surface.create({
|
|
62
|
-
id: `${meta.id}/space-article`,
|
|
63
|
-
role: 'article',
|
|
64
|
-
position: 'hoist',
|
|
65
|
-
filter: (data): data is { subject: Space } =>
|
|
66
|
-
// TODO(wittjosiah): Need to avoid shotgun parsing space state everywhere.
|
|
67
|
-
isSpace(data.subject) && data.subject.state.get() === SpaceState.SPACE_READY,
|
|
68
|
-
component: ({ data }) => <SpaceMain space={data.subject} />,
|
|
69
|
-
}),
|
|
70
|
-
]),
|
|
71
|
-
),
|
|
72
|
-
);
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useCallback, useMemo, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
-
import { useObjectMenuItems, useObjectNavigate } from '@dxos/app-toolkit/ui';
|
|
9
|
-
import { Entity, Query } from '@dxos/echo';
|
|
10
|
-
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
|
11
|
-
import { Card, Panel, ScrollArea, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
12
|
-
import { Menu } from '@dxos/react-ui-menu';
|
|
13
|
-
import { Mosaic, type MosaicStackTileComponent } from '@dxos/react-ui-mosaic';
|
|
14
|
-
import { SearchList } from '@dxos/react-ui-searchlist';
|
|
15
|
-
import { Text } from '@dxos/schema';
|
|
16
|
-
|
|
17
|
-
import { useGlobalSearch, useGlobalSearchResults, useWebSearch } from '../../hooks';
|
|
18
|
-
import { meta } from '../../meta';
|
|
19
|
-
import { type SearchResult } from '../../types';
|
|
20
|
-
|
|
21
|
-
export const SearchMain = ({ space }: { space?: Space }) => {
|
|
22
|
-
const { t } = useTranslation(meta.id);
|
|
23
|
-
const { setMatch } = useGlobalSearch();
|
|
24
|
-
const [query, setQuery] = useState<string>();
|
|
25
|
-
// TODO(burdon): Option to search across spaces.
|
|
26
|
-
const objects = useQuery(
|
|
27
|
-
space?.db,
|
|
28
|
-
query === undefined
|
|
29
|
-
? Query.select(Filter.nothing())
|
|
30
|
-
: // TODO(dmaretskyi): Final version would walk the ancestry of the object until we find a non-system type.
|
|
31
|
-
Query.all(
|
|
32
|
-
Query.select(Filter.text(query, { type: 'full-text' })).select(Filter.not(Filter.type(Text.Text))),
|
|
33
|
-
Query.select(Filter.text(query, { type: 'full-text' }))
|
|
34
|
-
.select(Filter.type(Text.Text))
|
|
35
|
-
.referencedBy('dxos.org/type/Document', 'content'),
|
|
36
|
-
),
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
const results = useGlobalSearchResults(objects);
|
|
40
|
-
const { results: webResults } = useWebSearch({ query });
|
|
41
|
-
const allResults = useMemo(
|
|
42
|
-
() => [...results, ...webResults].filter(({ object }) => object && Entity.getLabel(object)),
|
|
43
|
-
[results, webResults],
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const handleSearch = useCallback(
|
|
47
|
-
(text: string) => {
|
|
48
|
-
setQuery(text);
|
|
49
|
-
setMatch?.(text);
|
|
50
|
-
},
|
|
51
|
-
[setMatch],
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<SearchList.Root onSearch={handleSearch}>
|
|
56
|
-
<Panel.Root className='dx-article'>
|
|
57
|
-
<Panel.Toolbar asChild>
|
|
58
|
-
<Toolbar.Root>
|
|
59
|
-
<SearchList.Input placeholder={t('search placeholder')} />
|
|
60
|
-
</Toolbar.Root>
|
|
61
|
-
</Panel.Toolbar>
|
|
62
|
-
<Panel.Content asChild>
|
|
63
|
-
<SearchList.Content>
|
|
64
|
-
<Mosaic.Container asChild>
|
|
65
|
-
<ScrollArea.Root orientation='vertical'>
|
|
66
|
-
<ScrollArea.Viewport>
|
|
67
|
-
<Mosaic.Stack items={allResults} getId={(result) => result.object!.id} Tile={SearchResultTile} />
|
|
68
|
-
</ScrollArea.Viewport>
|
|
69
|
-
</ScrollArea.Root>
|
|
70
|
-
</Mosaic.Container>
|
|
71
|
-
{allResults.length === 0 && <SearchList.Empty>{t('empty results message')}</SearchList.Empty>}
|
|
72
|
-
</SearchList.Content>
|
|
73
|
-
</Panel.Content>
|
|
74
|
-
</Panel.Root>
|
|
75
|
-
</SearchList.Root>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const SearchResultTile: MosaicStackTileComponent<SearchResult> = (props) => {
|
|
80
|
-
const data = props.data;
|
|
81
|
-
const object = data.object!;
|
|
82
|
-
const objectMenuItems = useObjectMenuItems(object);
|
|
83
|
-
const handleNavigate = useObjectNavigate(object);
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<Menu.Root>
|
|
87
|
-
<Card.Root key={data.id}>
|
|
88
|
-
<Card.Toolbar>
|
|
89
|
-
<Card.DragHandle />
|
|
90
|
-
<Card.Title onClick={handleNavigate}>
|
|
91
|
-
{data.label ?? (data.object && Entity.getLabel(data.object))}
|
|
92
|
-
</Card.Title>
|
|
93
|
-
{/* TODO(wittjosiah): Reconcile with Card.Menu. */}
|
|
94
|
-
<Menu.Trigger asChild disabled={!objectMenuItems?.length}>
|
|
95
|
-
<Toolbar.IconButton iconOnly variant='ghost' icon='ph--dots-three-vertical--regular' label='Actions' />
|
|
96
|
-
</Menu.Trigger>
|
|
97
|
-
<Menu.Content items={objectMenuItems} />
|
|
98
|
-
</Card.Toolbar>
|
|
99
|
-
<Surface.Surface role='card--content' data={{ subject: data.object }} limit={1} />
|
|
100
|
-
</Card.Root>
|
|
101
|
-
</Menu.Root>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { useCapabilities, useOperationInvoker } from '@dxos/app-framework/ui';
|
|
8
|
-
import { AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
-
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
10
|
-
import { Filter, Obj, Query } from '@dxos/echo';
|
|
11
|
-
import { Graph, Node, useActionRunner, useConnections } from '@dxos/plugin-graph';
|
|
12
|
-
import { type Space, useQuery } from '@dxos/react-client/echo';
|
|
13
|
-
import { ScrollArea, Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
14
|
-
import { Card, Panel } from '@dxos/react-ui';
|
|
15
|
-
import { Mosaic, type MosaicStackTileComponent } from '@dxos/react-ui-mosaic';
|
|
16
|
-
import { SearchList } from '@dxos/react-ui-searchlist';
|
|
17
|
-
import { Text } from '@dxos/schema';
|
|
18
|
-
import { getStyles } from '@dxos/ui-theme';
|
|
19
|
-
|
|
20
|
-
import { meta } from '../../meta';
|
|
21
|
-
|
|
22
|
-
export const SpaceMain = ({ space }: { space: Space }) => {
|
|
23
|
-
const { t } = useTranslation(meta.id);
|
|
24
|
-
const { items, handleSearch } = useSpaceItems(space);
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<SearchList.Root onSearch={handleSearch}>
|
|
28
|
-
<Panel.Root className='dx-article'>
|
|
29
|
-
<Panel.Toolbar asChild>
|
|
30
|
-
<Toolbar.Root>
|
|
31
|
-
<SearchList.Input placeholder={t('search placeholder')} />
|
|
32
|
-
</Toolbar.Root>
|
|
33
|
-
</Panel.Toolbar>
|
|
34
|
-
<Panel.Content asChild>
|
|
35
|
-
<SearchList.Content>
|
|
36
|
-
<Mosaic.Container asChild>
|
|
37
|
-
<ScrollArea.Root orientation='vertical'>
|
|
38
|
-
<ScrollArea.Viewport classNames='p-2'>
|
|
39
|
-
<Mosaic.Stack items={items} getId={(node) => node.id} Tile={NodeTile} />
|
|
40
|
-
</ScrollArea.Viewport>
|
|
41
|
-
</ScrollArea.Root>
|
|
42
|
-
</Mosaic.Container>
|
|
43
|
-
</SearchList.Content>
|
|
44
|
-
</Panel.Content>
|
|
45
|
-
</Panel.Root>
|
|
46
|
-
</SearchList.Root>
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const NodeTile: MosaicStackTileComponent<Node.Node> = (props) => {
|
|
51
|
-
const node = props.data;
|
|
52
|
-
const { t } = useTranslation(meta.id);
|
|
53
|
-
const { graph } = useAppGraph();
|
|
54
|
-
const { invokeSync } = useOperationInvoker();
|
|
55
|
-
const runAction = useActionRunner();
|
|
56
|
-
|
|
57
|
-
const label = toLocalizedString(node.properties.label, t);
|
|
58
|
-
const icon = node.properties.icon ?? 'ph--placeholder--regular';
|
|
59
|
-
const iconHue = node.properties.iconHue;
|
|
60
|
-
const styles = iconHue ? getStyles(iconHue) : undefined;
|
|
61
|
-
|
|
62
|
-
const handleClick = () => {
|
|
63
|
-
if (Node.isAction(node)) {
|
|
64
|
-
// Run action if this is an action node.
|
|
65
|
-
const [parent] = Graph.getConnections(graph, node.id, Node.childRelation('inbound'));
|
|
66
|
-
if (parent) {
|
|
67
|
-
void runAction(node, { parent });
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
// Navigate to the node.
|
|
71
|
-
invokeSync(LayoutOperation.Open, { subject: [node.id] });
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<Card.Root fullWidth>
|
|
77
|
-
<Card.Toolbar>
|
|
78
|
-
<Card.ToolbarIconButton
|
|
79
|
-
variant='ghost'
|
|
80
|
-
label={label}
|
|
81
|
-
icon={icon}
|
|
82
|
-
iconOnly
|
|
83
|
-
iconClassNames={styles?.surfaceText}
|
|
84
|
-
/>
|
|
85
|
-
<Card.Title onClick={handleClick}>{label}</Card.Title>
|
|
86
|
-
<Card.Menu />
|
|
87
|
-
</Card.Toolbar>
|
|
88
|
-
</Card.Root>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Hook to resolve metadata (icon, iconHue, etc.) for objects based on their typename.
|
|
94
|
-
*/
|
|
95
|
-
// TODO(wittjosiah): Factor out.
|
|
96
|
-
const useMetadataResolver = () => {
|
|
97
|
-
const allMetadata = useCapabilities(AppCapabilities.Metadata);
|
|
98
|
-
return useCallback((typename: string) => allMetadata.find((m) => m.id === typename)?.metadata ?? {}, [allMetadata]);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Hook to get space items with search/filter support.
|
|
103
|
-
* Returns direct children when no query, or full-text search results when searching.
|
|
104
|
-
*/
|
|
105
|
-
const useSpaceItems = (space: Space) => {
|
|
106
|
-
const { graph } = useAppGraph();
|
|
107
|
-
const [query, setQuery] = useState<string>();
|
|
108
|
-
const resolveMetadata = useMetadataResolver();
|
|
109
|
-
|
|
110
|
-
// Expand the space node to load its children (needed when navigating directly to a space URL).
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
const frame = requestAnimationFrame(() => {
|
|
113
|
-
Graph.expand(graph, space.id, 'child');
|
|
114
|
-
});
|
|
115
|
-
return () => cancelAnimationFrame(frame);
|
|
116
|
-
}, [graph, space.id]);
|
|
117
|
-
|
|
118
|
-
// Get direct children of the space node for the default view.
|
|
119
|
-
const children = useConnections(graph, space.id, 'child');
|
|
120
|
-
|
|
121
|
-
const handleSearch = useCallback((text: string) => {
|
|
122
|
-
setQuery(text);
|
|
123
|
-
}, []);
|
|
124
|
-
|
|
125
|
-
// TODO(dmaretskyi): Switch back to QueryEditor once query builder is ready for production.
|
|
126
|
-
// Query results using full-text search.
|
|
127
|
-
const results = useQuery(
|
|
128
|
-
space.db,
|
|
129
|
-
query === undefined
|
|
130
|
-
? Query.select(Filter.nothing())
|
|
131
|
-
: Query.all(
|
|
132
|
-
Query.select(Filter.text(query, { type: 'full-text' })).select(Filter.not(Filter.type(Text.Text))),
|
|
133
|
-
Query.select(Filter.text(query, { type: 'full-text' }))
|
|
134
|
-
.select(Filter.type(Text.Text))
|
|
135
|
-
.referencedBy('dxos.org/type/Document', 'content'),
|
|
136
|
-
),
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
// Determine if query is empty (show default view).
|
|
140
|
-
const isQueryEmpty = !query?.trim();
|
|
141
|
-
|
|
142
|
-
// Filter children to those which are objects, actions with disposition 'item', or alternate-tree nodes.
|
|
143
|
-
const filteredChildren = useMemo(
|
|
144
|
-
() =>
|
|
145
|
-
children.filter((node) => {
|
|
146
|
-
// Include regular objects.
|
|
147
|
-
if (Obj.isObject(node.data)) {
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
// Include actions with disposition 'item'.
|
|
151
|
-
return Node.isAction(node) && node.properties.disposition === 'item';
|
|
152
|
-
}),
|
|
153
|
-
[children],
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
// When showing default view, use nodes (which may include actions).
|
|
157
|
-
// When showing search results, wrap objects in a compatible shape with resolved metadata.
|
|
158
|
-
const items = useMemo(() => {
|
|
159
|
-
if (isQueryEmpty) {
|
|
160
|
-
return filteredChildren;
|
|
161
|
-
}
|
|
162
|
-
// Wrap query results as pseudo-nodes for consistent rendering.
|
|
163
|
-
return results.map((obj) => {
|
|
164
|
-
const typename = Obj.getTypename(obj);
|
|
165
|
-
const metadata = typename ? resolveMetadata(typename) : {};
|
|
166
|
-
return {
|
|
167
|
-
id: obj.id,
|
|
168
|
-
type: 'search-result',
|
|
169
|
-
data: obj,
|
|
170
|
-
properties: {
|
|
171
|
-
label: Obj.getLabel(obj) ?? obj.id,
|
|
172
|
-
icon: metadata.icon ?? 'ph--placeholder--regular',
|
|
173
|
-
iconHue: metadata.iconHue,
|
|
174
|
-
},
|
|
175
|
-
} as Node.Node;
|
|
176
|
-
});
|
|
177
|
-
}, [isQueryEmpty, filteredChildren, results, resolveMetadata]);
|
|
178
|
-
|
|
179
|
-
return { items, handleSearch };
|
|
180
|
-
};
|
package/src/types/action.tsx
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
|
-
|
|
7
|
-
import { Operation } from '@dxos/operation';
|
|
8
|
-
|
|
9
|
-
import { meta } from '../meta';
|
|
10
|
-
|
|
11
|
-
const SEARCH_OPERATION = `${meta.id}/operation`;
|
|
12
|
-
|
|
13
|
-
export namespace SearchOperation {
|
|
14
|
-
export const OpenSearch = Operation.make({
|
|
15
|
-
meta: { key: `${SEARCH_OPERATION}/open-search`, name: 'Open Search' },
|
|
16
|
-
schema: { input: Schema.Void, output: Schema.Void },
|
|
17
|
-
});
|
|
18
|
-
}
|
|
File without changes
|
/package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts}
RENAMED
|
File without changes
|