@dxos/plugin-search 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae

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 (153) hide show
  1. package/README.md +0 -1
  2. package/dist/lib/browser/SearchDialog-E6336HCX.mjs +110 -0
  3. package/dist/lib/browser/SearchDialog-E6336HCX.mjs.map +7 -0
  4. package/dist/lib/browser/SearchMain-24ZNJB24.mjs +100 -0
  5. package/dist/lib/browser/SearchMain-24ZNJB24.mjs.map +7 -0
  6. package/dist/lib/browser/SpaceMain-IGCYHL7R.mjs +154 -0
  7. package/dist/lib/browser/SpaceMain-IGCYHL7R.mjs.map +7 -0
  8. package/dist/lib/browser/app-graph-builder-NUJ2FOVQ.mjs +82 -0
  9. package/dist/lib/browser/app-graph-builder-NUJ2FOVQ.mjs.map +7 -0
  10. package/dist/lib/browser/{chunk-5N6LDSFF.mjs → chunk-HRIWTRJV.mjs} +6 -2
  11. package/dist/lib/browser/chunk-HRIWTRJV.mjs.map +7 -0
  12. package/dist/lib/browser/chunk-I7YWQSUZ.mjs +26 -0
  13. package/dist/lib/browser/chunk-I7YWQSUZ.mjs.map +7 -0
  14. package/dist/lib/browser/chunk-NB4JZIOE.mjs +282 -0
  15. package/dist/lib/browser/chunk-NB4JZIOE.mjs.map +7 -0
  16. package/dist/lib/browser/index.mjs +52 -57
  17. package/dist/lib/browser/index.mjs.map +4 -4
  18. package/dist/lib/browser/meta.json +1 -1
  19. package/dist/lib/browser/operation-resolver-QEGN4ZKN.mjs +26 -0
  20. package/dist/lib/browser/operation-resolver-QEGN4ZKN.mjs.map +7 -0
  21. package/dist/lib/browser/react-surface-FLO4YTFP.mjs +73 -0
  22. package/dist/lib/browser/react-surface-FLO4YTFP.mjs.map +7 -0
  23. package/dist/types/src/SearchPlugin.d.ts +2 -1
  24. package/dist/types/src/SearchPlugin.d.ts.map +1 -1
  25. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  26. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  27. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  28. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  29. package/dist/types/src/capabilities/index.d.ts +3 -3
  30. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  31. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  32. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  33. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  34. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  35. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  36. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  37. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  38. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  39. package/dist/types/src/components/index.d.ts +0 -3
  40. package/dist/types/src/components/index.d.ts.map +1 -1
  41. package/dist/types/src/constants.d.ts +2 -0
  42. package/dist/types/src/constants.d.ts.map +1 -0
  43. package/dist/types/src/{components → containers/SearchDialog}/SearchDialog.d.ts +0 -1
  44. package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts.map +1 -0
  45. package/dist/types/src/containers/SearchDialog/index.d.ts +3 -0
  46. package/dist/types/src/containers/SearchDialog/index.d.ts.map +1 -0
  47. package/dist/types/src/containers/SearchMain/SearchMain.d.ts +6 -0
  48. package/dist/types/src/containers/SearchMain/SearchMain.d.ts.map +1 -0
  49. package/dist/types/src/containers/SearchMain/index.d.ts +3 -0
  50. package/dist/types/src/containers/SearchMain/index.d.ts.map +1 -0
  51. package/dist/types/src/containers/SpaceMain/SpaceMain.d.ts +6 -0
  52. package/dist/types/src/containers/SpaceMain/SpaceMain.d.ts.map +1 -0
  53. package/dist/types/src/containers/SpaceMain/index.d.ts +3 -0
  54. package/dist/types/src/containers/SpaceMain/index.d.ts.map +1 -0
  55. package/dist/types/src/containers/index.d.ts +6 -0
  56. package/dist/types/src/containers/index.d.ts.map +1 -0
  57. package/dist/types/src/hooks/index.d.ts +1 -0
  58. package/dist/types/src/hooks/index.d.ts.map +1 -1
  59. package/dist/types/src/hooks/sync.d.ts +3 -2
  60. package/dist/types/src/hooks/sync.d.ts.map +1 -1
  61. package/dist/types/src/hooks/useGlobalSearch.d.ts +7 -3
  62. package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
  63. package/dist/types/src/hooks/useSearchResults.d.ts +3 -2
  64. package/dist/types/src/hooks/useSearchResults.d.ts.map +1 -1
  65. package/dist/types/src/hooks/useWebSearch.d.ts +6 -3
  66. package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
  67. package/dist/types/src/meta.d.ts +2 -2
  68. package/dist/types/src/meta.d.ts.map +1 -1
  69. package/dist/types/src/search/exa.d.ts +3 -1
  70. package/dist/types/src/search/exa.d.ts.map +1 -1
  71. package/dist/types/src/translations.d.ts +1 -1
  72. package/dist/types/src/types/action.d.ts +13 -10
  73. package/dist/types/src/types/action.d.ts.map +1 -1
  74. package/dist/types/src/types/search.d.ts +3 -7
  75. package/dist/types/src/types/search.d.ts.map +1 -1
  76. package/dist/types/tsconfig.tsbuildinfo +1 -1
  77. package/package.json +56 -46
  78. package/src/SearchPlugin.tsx +25 -42
  79. package/src/capabilities/app-graph-builder/app-graph-builder.ts +71 -0
  80. package/src/capabilities/app-graph-builder/index.ts +7 -0
  81. package/src/capabilities/index.ts +3 -5
  82. package/src/capabilities/operation-resolver/index.ts +7 -0
  83. package/src/capabilities/operation-resolver/operation-resolver.ts +24 -0
  84. package/src/capabilities/react-surface/index.ts +7 -0
  85. package/src/capabilities/react-surface/react-surface.tsx +72 -0
  86. package/src/components/index.ts +0 -4
  87. package/src/constants.ts +7 -0
  88. package/src/containers/SearchDialog/SearchDialog.tsx +120 -0
  89. package/src/containers/SearchDialog/index.ts +7 -0
  90. package/src/containers/SearchMain/SearchMain.tsx +103 -0
  91. package/src/containers/SearchMain/index.ts +7 -0
  92. package/src/containers/SpaceMain/SpaceMain.tsx +180 -0
  93. package/src/containers/SpaceMain/index.ts +7 -0
  94. package/src/containers/index.ts +11 -0
  95. package/src/hooks/index.ts +2 -0
  96. package/src/hooks/sync.test.ts +6 -4
  97. package/src/hooks/sync.ts +25 -30
  98. package/src/hooks/useGlobalSearch.tsx +31 -12
  99. package/src/hooks/useSearchResults.ts +7 -4
  100. package/src/hooks/useWebSearch.ts +20 -9
  101. package/src/meta.ts +7 -3
  102. package/src/search/exa.test.ts +9 -11
  103. package/src/search/exa.ts +6 -5
  104. package/src/translations.ts +1 -1
  105. package/src/types/action.tsx +8 -6
  106. package/src/types/command-score.d.ts +16 -0
  107. package/src/types/search.ts +3 -9
  108. package/dist/lib/browser/app-graph-builder-YME7SN7O.mjs +0 -78
  109. package/dist/lib/browser/app-graph-builder-YME7SN7O.mjs.map +0 -7
  110. package/dist/lib/browser/chunk-5N6LDSFF.mjs.map +0 -7
  111. package/dist/lib/browser/chunk-WN3TVQLV.mjs +0 -190
  112. package/dist/lib/browser/chunk-WN3TVQLV.mjs.map +0 -7
  113. package/dist/lib/browser/chunk-YJGHPWUO.mjs +0 -21
  114. package/dist/lib/browser/chunk-YJGHPWUO.mjs.map +0 -7
  115. package/dist/lib/browser/intent-resolver-XNVR4XRX.mjs +0 -22
  116. package/dist/lib/browser/intent-resolver-XNVR4XRX.mjs.map +0 -7
  117. package/dist/lib/browser/react-surface-YOGLADC4.mjs +0 -470
  118. package/dist/lib/browser/react-surface-YOGLADC4.mjs.map +0 -7
  119. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  120. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  121. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  122. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  123. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  124. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  125. package/dist/types/src/components/Search.stories.d.ts +0 -19
  126. package/dist/types/src/components/Search.stories.d.ts.map +0 -1
  127. package/dist/types/src/components/SearchDialog.d.ts.map +0 -1
  128. package/dist/types/src/components/SearchMain.d.ts +0 -7
  129. package/dist/types/src/components/SearchMain.d.ts.map +0 -1
  130. package/dist/types/src/components/SearchResults/SearchResults.d.ts +0 -20
  131. package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +0 -1
  132. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts +0 -16
  133. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts.map +0 -1
  134. package/dist/types/src/components/SearchResults/index.d.ts +0 -2
  135. package/dist/types/src/components/SearchResults/index.d.ts.map +0 -1
  136. package/dist/types/src/components/Searchbar/Searchbar.d.ts +0 -14
  137. package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +0 -1
  138. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts +0 -13
  139. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts.map +0 -1
  140. package/dist/types/src/components/Searchbar/index.d.ts +0 -2
  141. package/dist/types/src/components/Searchbar/index.d.ts.map +0 -1
  142. package/src/capabilities/app-graph-builder.ts +0 -80
  143. package/src/capabilities/intent-resolver.ts +0 -18
  144. package/src/capabilities/react-surface.tsx +0 -59
  145. package/src/components/Search.stories.tsx +0 -67
  146. package/src/components/SearchDialog.tsx +0 -124
  147. package/src/components/SearchMain.tsx +0 -68
  148. package/src/components/SearchResults/SearchResults.stories.tsx +0 -58
  149. package/src/components/SearchResults/SearchResults.tsx +0 -86
  150. package/src/components/SearchResults/index.ts +0 -5
  151. package/src/components/Searchbar/Searchbar.stories.tsx +0 -28
  152. package/src/components/Searchbar/Searchbar.tsx +0 -67
  153. package/src/components/Searchbar/index.ts +0 -5
@@ -1 +0,0 @@
1
- {"version":3,"file":"SearchResults.d.ts","sourceRoot":"","sources":["../../../../../src/components/SearchResults/SearchResults.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,EAAc,MAAM,OAAO,CAAC;AAMnD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAyBxD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;AAE1G,eAAO,MAAM,UAAU;cAFkC,OAAO;+EAoB9D,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AAGF,eAAO,MAAM,aAAa,GAAI,+BAA+B,kBAAkB,sBAgB9E,CAAC"}
@@ -1,16 +0,0 @@
1
- import { type StoryObj } from '@storybook/react-vite';
2
- import React from 'react';
3
- import { type SearchResultsProps } from './SearchResults';
4
- declare const meta: {
5
- title: string;
6
- component: ({ items, selected, onSelect }: SearchResultsProps) => React.JSX.Element;
7
- render: (props: SearchResultsProps) => React.JSX.Element;
8
- decorators: import("@storybook/react").Decorator[];
9
- parameters: {
10
- layout: string;
11
- };
12
- };
13
- export default meta;
14
- type Story = StoryObj<typeof meta>;
15
- export declare const Default: Story;
16
- //# sourceMappingURL=SearchResults.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SearchResults.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/SearchResults/SearchResults.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAmB,MAAM,OAAO,CAAC;AAOxC,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AA0BzE,QAAA,MAAM,IAAI;;;oBAtBmB,kBAAkB;;;;;CA8BT,CAAC;AAEvC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './SearchResults';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/SearchResults/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC"}
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { type TextInputProps } from '@dxos/react-ui';
3
- export type SearchbarProps = Pick<TextInputProps, 'variant' | 'placeholder'> & {
4
- classes?: {
5
- root?: string;
6
- input?: string;
7
- };
8
- value?: string;
9
- onChange?: (text?: string) => void;
10
- onSubmit?: (text?: string) => void;
11
- delay?: number;
12
- };
13
- export declare const Searchbar: ({ classes, variant, placeholder, value, onChange, onSubmit }: SearchbarProps) => React.JSX.Element;
14
- //# sourceMappingURL=Searchbar.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Searchbar.d.ts","sourceRoot":"","sources":["../../../../../src/components/Searchbar/Searchbar.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA0D,MAAM,OAAO,CAAC;AAE/E,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAElE,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,aAAa,CAAC,GAAG;IAC7E,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,8DAA8D,cAAc,sBA+CrG,CAAC"}
@@ -1,13 +0,0 @@
1
- import { type StoryObj } from '@storybook/react-vite';
2
- declare const meta: {
3
- title: string;
4
- component: ({ classes, variant, placeholder, value, onChange, onSubmit }: import("./Searchbar").SearchbarProps) => import("react").JSX.Element;
5
- decorators: import("@storybook/react").Decorator[];
6
- parameters: {
7
- layout: string;
8
- };
9
- };
10
- export default meta;
11
- type Story = StoryObj<typeof meta>;
12
- export declare const Default: Story;
13
- //# sourceMappingURL=Searchbar.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Searchbar.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Searchbar/Searchbar.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAMjE,QAAA,MAAM,IAAI;;;;;;;CAOwB,CAAC;AAEnC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAIrB,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './Searchbar';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Searchbar/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC"}
@@ -1,80 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Rx } from '@effect-rx/rx-react';
6
- import * as Function from 'effect/Function';
7
- import * as Option from 'effect/Option';
8
-
9
- import { Capabilities, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
10
- import { ClientCapabilities } from '@dxos/plugin-client';
11
- import { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
12
- import { ROOT_ID, createExtension, rxFromSignal } from '@dxos/plugin-graph';
13
- import { parseId } from '@dxos/react-client/echo';
14
-
15
- import { meta } from '../meta';
16
- import { SearchAction } from '../types';
17
-
18
- export default (context: PluginContext) =>
19
- contributes(Capabilities.AppGraphBuilder, [
20
- createExtension({
21
- id: `${meta.id}/space-search`,
22
- connector: (node) =>
23
- Rx.make((get) =>
24
- Function.pipe(
25
- get(node),
26
- Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
27
- Option.map((node) => {
28
- const workspace = get(rxFromSignal(() => context.getCapability(Capabilities.Layout).workspace));
29
- const client = context.getCapability(ClientCapabilities.Client);
30
- const { spaceId } = parseId(workspace);
31
- const space = spaceId ? client.spaces.get(spaceId) : null;
32
-
33
- return [
34
- {
35
- id: [node.id, 'search'].join(ATTENDABLE_PATH_SEPARATOR),
36
- type: DECK_COMPANION_TYPE,
37
- data: space,
38
- properties: {
39
- label: ['search label', { ns: meta.id }],
40
- icon: 'ph--magnifying-glass--regular',
41
- disposition: 'hidden',
42
- },
43
- },
44
- ];
45
- }),
46
- Option.getOrElse(() => []),
47
- ),
48
- ),
49
- }),
50
- createExtension({
51
- id: meta.id,
52
- actions: (node) =>
53
- Rx.make((get) =>
54
- Function.pipe(
55
- get(node),
56
- Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
57
- Option.map(() => {
58
- return [
59
- {
60
- id: SearchAction.OpenSearch._tag,
61
- data: async () => {
62
- const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
63
- await dispatch(createIntent(SearchAction.OpenSearch));
64
- },
65
- properties: {
66
- label: ['search action label', { ns: meta.id }],
67
- icon: 'ph--magnifying-glass--regular',
68
- keyBinding: {
69
- macos: 'shift+meta+f',
70
- windows: 'shift+alt+f',
71
- },
72
- },
73
- },
74
- ];
75
- }),
76
- Option.getOrElse(() => []),
77
- ),
78
- ),
79
- }),
80
- ]);
@@ -1,18 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capabilities, LayoutAction, contributes, createIntent, createResolver } 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
- );
@@ -1,59 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
- import { useActiveSpace } from '@dxos/plugin-space';
9
- import { type Space, isSpace } from '@dxos/react-client/echo';
10
-
11
- import { SEARCH_DIALOG, SearchDialog, type SearchDialogProps, SearchMain } from '../components';
12
- import { SearchContextProvider } from '../hooks';
13
-
14
- export default () =>
15
- contributes(Capabilities.ReactSurface, [
16
- createSurface({
17
- id: SEARCH_DIALOG,
18
- role: 'dialog',
19
- filter: (data): data is { props: SearchDialogProps } => data.component === SEARCH_DIALOG,
20
- component: ({ data }) => (
21
- <SearchContextProvider>
22
- <SearchDialog {...data.props} />
23
- </SearchContextProvider>
24
- ),
25
- }),
26
- createSurface({
27
- id: `${SEARCH_DIALOG}/search-input`,
28
- role: 'search-input',
29
- component: () => {
30
- const space = useActiveSpace();
31
- if (!space) {
32
- return null;
33
- }
34
-
35
- return (
36
- <SearchContextProvider>
37
- <SearchMain space={space} />
38
- </SearchContextProvider>
39
- );
40
- },
41
- }),
42
- createSurface({
43
- id: `${SEARCH_DIALOG}/search`,
44
- role: 'deck-companion--search',
45
- filter: (data): data is { subject: Space } => isSpace(data.subject),
46
- component: ({ data }) => {
47
- const space = data.subject;
48
- if (!space) {
49
- return null;
50
- }
51
-
52
- return (
53
- <SearchContextProvider>
54
- <SearchMain space={space} />
55
- </SearchContextProvider>
56
- );
57
- },
58
- }),
59
- ]);
@@ -1,67 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { type Decorator, type Meta, type StoryObj } from '@storybook/react-vite';
6
- import React, { useState } from 'react';
7
-
8
- import { faker } from '@dxos/random';
9
- import { withTheme } from '@dxos/react-ui/testing';
10
-
11
- import { SearchContextProvider, useGlobalSearch, useGlobalSearchResults } from '../hooks';
12
-
13
- import { Searchbar, type SearchbarProps } from './Searchbar';
14
- import { SearchResults } from './SearchResults';
15
-
16
- faker.seed(1);
17
-
18
- type StoryProps = SearchbarProps & {
19
- objects?: any[];
20
- };
21
-
22
- const DefaultStory = ({ objects, ...props }: StoryProps) => {
23
- const [selected, setSelected] = useState<string>();
24
- const { setMatch } = useGlobalSearch();
25
- const filteredItems = useGlobalSearchResults(objects);
26
-
27
- return (
28
- <div className='flex grow justify-center overflow-hidden'>
29
- <div className='flex flex-col w-[300px] m-4 overflow-hidden'>
30
- <Searchbar variant='subdued' placeholder='Enter regular expression...' onChange={setMatch} {...props} />
31
- <SearchResults items={filteredItems} selected={selected} onSelect={setSelected} />
32
- </div>
33
- </div>
34
- );
35
- };
36
-
37
- const withSearchContext = (): Decorator => {
38
- return (Story) => (
39
- <SearchContextProvider>
40
- <Story />
41
- </SearchContextProvider>
42
- );
43
- };
44
-
45
- export const Default: Story = {
46
- args: {
47
- objects: Array.from({ length: 8 }).map(() => ({
48
- id: faker.string.uuid(),
49
- label: faker.lorem.sentence(4).replace(/\./g, ''),
50
- content: faker.lorem.sentences(3),
51
- })),
52
- },
53
- };
54
-
55
- const meta = {
56
- title: 'plugins/plugin-search/Search',
57
- component: Searchbar,
58
- render: DefaultStory,
59
- decorators: [withTheme, withSearchContext()],
60
- parameters: {
61
- layout: 'column',
62
- },
63
- } satisfies Meta<typeof Searchbar>;
64
-
65
- export default meta;
66
-
67
- type Story = StoryObj<typeof meta>;
@@ -1,124 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import * as Option from 'effect/Option';
6
- import React, { forwardRef, useCallback, useState } from 'react';
7
-
8
- import { LayoutAction, createIntent, useAppGraph, useIntentDispatcher, useLayout } from '@dxos/app-framework';
9
- import { type Node } from '@dxos/plugin-graph';
10
- import { useClient } from '@dxos/react-client';
11
- import { Filter, fullyQualifiedId, useQuery } from '@dxos/react-client/echo';
12
- import { Button, Dialog, Icon, toLocalizedString, useTranslation } from '@dxos/react-ui';
13
- import { SearchList, type SearchListItemProps } from '@dxos/react-ui-searchlist';
14
- import { descriptionText, mx } from '@dxos/react-ui-theme';
15
-
16
- import { useSearchResults } from '../hooks';
17
- import { meta } from '../meta';
18
-
19
- export const SEARCH_DIALOG = `${meta.id}/SearchDialog`;
20
-
21
- type SearchListResultProps = {
22
- node: Node;
23
- } & Pick<SearchListItemProps, 'onSelect'>;
24
-
25
- const SearchListResult = forwardRef<HTMLDivElement, SearchListResultProps>(({ node, onSelect }, forwardedRef) => {
26
- const { t } = useTranslation(meta.id);
27
- const label = toLocalizedString(node?.properties.label ?? 'never', t);
28
- return (
29
- <SearchList.Item
30
- value={label}
31
- key={node!.id}
32
- classNames='flex gap-2 items-center pli-2'
33
- onSelect={() => onSelect?.(node!.id)}
34
- ref={forwardedRef}
35
- >
36
- <Icon size={5} icon={node?.properties.icon} />
37
- <span className='is-0 grow truncate'>{label}</span>
38
- </SearchList.Item>
39
- );
40
- });
41
-
42
- export type SearchDialogProps = {
43
- pivotId: string;
44
- };
45
-
46
- export const SearchDialog = ({ pivotId }: SearchDialogProps) => {
47
- const { t } = useTranslation(meta.id);
48
- const { graph } = useAppGraph();
49
- const layout = useLayout();
50
- const closed = (Array.isArray(layout.inactive) ? layout.inactive : [layout.inactive])
51
- .map((id) => graph?.getNode(id))
52
- .filter(Boolean);
53
- const [queryString, setQueryString] = useState('');
54
- const client = useClient();
55
- const dangerouslyLoadAllObjects = useQuery(client.spaces, Filter.everything());
56
- const [pending, results] = useSearchResults(queryString, dangerouslyLoadAllObjects);
57
- const resultObjects = Array.from(results.keys());
58
- const { dispatchPromise: dispatch } = useIntentDispatcher();
59
-
60
- const handleSelect = useCallback(
61
- async (nodeId: string) => {
62
- await dispatch(createIntent(LayoutAction.UpdateDialog, { part: 'dialog', options: { state: false } }));
63
-
64
- // If node is already present in the active parts, scroll to it and close the dialog.
65
- const index = layout.active.findIndex((id) => id === nodeId);
66
- if (index !== -1) {
67
- await dispatch(createIntent(LayoutAction.ScrollIntoView, { part: 'current', subject: nodeId }));
68
- } else {
69
- await dispatch(
70
- createIntent(LayoutAction.Open, {
71
- part: 'main',
72
- subject: [nodeId],
73
- options: {
74
- pivotId,
75
- positioning: 'end',
76
- },
77
- }),
78
- );
79
- }
80
- },
81
- [pivotId, dispatch, layout],
82
- );
83
-
84
- return (
85
- <Dialog.Content classNames={['md:max-is-[24rem] overflow-hidden mbs-12']}>
86
- <Dialog.Title>{t('search dialog title')}</Dialog.Title>
87
- <SearchList.Root label={t('search placeholder')} classNames='flex flex-col grow overflow-hidden my-2'>
88
- <SearchList.Input
89
- value={queryString}
90
- onValueChange={(nextValue) => {
91
- setQueryString(nextValue);
92
- }}
93
- placeholder={t('search placeholder')}
94
- classNames='px-1 my-2'
95
- />
96
- <SearchList.Content classNames='max-bs-[24rem] overflow-auto'>
97
- {queryString.length > 0 ? (
98
- resultObjects.length > 0 ? (
99
- resultObjects
100
- .map((object) => graph.getNode(fullyQualifiedId(object)))
101
- .filter(Option.isSome)
102
- .map((node) => <SearchListResult key={node.value.id} node={node.value} onSelect={handleSelect} />)
103
- ) : (
104
- <p className='pli-1'>{t(pending ? 'pending results message' : 'empty results message')}</p>
105
- )
106
- ) : (
107
- <>
108
- {closed.length > 0 && <h2 className={mx('mlb-1', descriptionText)}>{t('recently closed heading')}</h2>}
109
- {closed.filter(Option.isSome).map((node) => (
110
- <SearchListResult key={node.value.id} node={node.value} onSelect={handleSelect} />
111
- ))}
112
- </>
113
- )}
114
- </SearchList.Content>
115
- </SearchList.Root>
116
-
117
- <Dialog.Close asChild>
118
- <Button variant='primary' classNames='mbs-2'>
119
- {t('close label', { ns: 'os' })}
120
- </Button>
121
- </Dialog.Close>
122
- </Dialog.Content>
123
- );
124
- };
@@ -1,68 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { type FC, useState } from 'react';
6
-
7
- import { log } from '@dxos/log';
8
- import { useClient } from '@dxos/react-client';
9
- import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
10
- import { type ThemedClassName, useTranslation } from '@dxos/react-ui';
11
- import { activeSurface, mx } from '@dxos/react-ui-theme';
12
-
13
- import { useGlobalSearch, useGlobalSearchResults } from '../hooks';
14
- import { useWebSearch } from '../hooks/useWebSearch';
15
- import { meta } from '../meta';
16
-
17
- import { Searchbar } from './Searchbar';
18
- import { SearchResults } from './SearchResults';
19
-
20
- export const SearchMain: FC<ThemedClassName<{ space: Space }>> = ({ classNames, space }) => {
21
- const { t } = useTranslation(meta.id);
22
- const client = useClient();
23
- const { setMatch } = useGlobalSearch();
24
- const [query, setQuery] = useState<string>();
25
- // TODO(burdon): UX to select all spaces.
26
- const allSpaces = false;
27
-
28
- // TODO(burdon): Returns ALL objects (e.g., incl. Text objects that are fields of parent objects).
29
- const objects = useQuery(allSpaces ? client.spaces : space, Filter.everything());
30
- const results = useGlobalSearchResults(objects);
31
-
32
- const {
33
- runSearch,
34
- results: webResults,
35
- isLoading,
36
- } = useWebSearch({
37
- query,
38
- });
39
-
40
- const [selected, setSelected] = useState<string>();
41
-
42
- // TODO(burdon): Activate and/or filter current main (set context).
43
- const handleSelect = (id: string) => {
44
- setSelected((selected) => (selected === id ? undefined : id));
45
- };
46
-
47
- const allResults = [...results, ...webResults];
48
- log.info('results', { results, webResults });
49
-
50
- return (
51
- <div className={mx('flex flex-col grow h-full overflow-hidden', classNames)}>
52
- <Searchbar
53
- placeholder={t('search placeholder')}
54
- onChange={(text) => {
55
- setQuery(text);
56
- setMatch?.(text);
57
- }}
58
- onSubmit={runSearch}
59
- />
60
- {isLoading && <div className={mx('flex flex-col grow overflow-hidden', activeSurface)}>Loading...</div>}
61
- {allResults.length > 0 && (
62
- <div className={mx('flex flex-col grow overflow-hidden', activeSurface)}>
63
- <SearchResults items={allResults} selected={selected} onSelect={handleSelect} />
64
- </div>
65
- )}
66
- </div>
67
- );
68
- };
@@ -1,58 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import React, { useState } from 'react';
7
-
8
- import { faker } from '@dxos/random';
9
- import { withTheme } from '@dxos/react-ui/testing';
10
-
11
- import { filterObjectsSync } from '../../hooks';
12
-
13
- import { SearchResults, type SearchResultsProps } from './SearchResults';
14
-
15
- faker.seed(1);
16
-
17
- const DefaultStory = (props: SearchResultsProps) => {
18
- const [selected, setSelected] = useState<string>();
19
-
20
- return (
21
- <div className='flex grow justify-center overflow-hidden'>
22
- <div className='flex w-[300px] m-4 overflow-hidden'>
23
- <SearchResults {...props} selected={selected} onSelect={setSelected} />
24
- </div>
25
- </div>
26
- );
27
- };
28
-
29
- const word = 'hello';
30
-
31
- const objects = Array.from({ length: 100 }).map((_, i) => ({
32
- id: faker.string.uuid(),
33
- name: faker.lorem.sentence(4),
34
- content: faker.lorem.sentence() + ` ${word} ` + faker.lorem.sentence(),
35
- }));
36
-
37
- const match = new RegExp(word, 'i');
38
-
39
- const meta = {
40
- title: 'plugins/plugin-search/SearchResults',
41
- component: SearchResults,
42
- render: DefaultStory,
43
- decorators: [withTheme],
44
- parameters: {
45
- layout: 'fullscreen',
46
- },
47
- } satisfies Meta<typeof SearchResults>;
48
-
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
- };
@@ -1,86 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { type FC, forwardRef } from 'react';
6
-
7
- import { Card } from '@dxos/react-ui-stack';
8
- import { ghostHover } from '@dxos/react-ui-theme';
9
-
10
- import { SEARCH_RESULT } from '../../meta';
11
- import { type SearchResult } from '../../types';
12
-
13
- export const Snippet: FC<{ text: string; match?: RegExp }> = ({ text, match }) => {
14
- let content = <>{text}</>;
15
- if (match) {
16
- const result = text.match(match);
17
- if (result?.index !== undefined) {
18
- // Break near to match.
19
- const maxOffset = 16;
20
- let before = text.slice(0, result.index);
21
- if (before.length > maxOffset) {
22
- const idx = before.indexOf(' ', result.index - maxOffset);
23
- before = '… ' + before.slice(idx);
24
- }
25
-
26
- const after = text.slice(result.index + result[0].length);
27
- content = (
28
- <>
29
- {before}
30
- <span className='text-blue-500'>{result[0]}</span>
31
- {after}
32
- </>
33
- );
34
- }
35
- }
36
-
37
- return <span className='text-xs mb-1 line-clamp-3 text-neutral-300'>{content}</span>;
38
- };
39
-
40
- export type SearchItemProps = SearchResult & { selected: boolean } & Pick<SearchResultsProps, 'onSelect'>;
41
-
42
- export const SearchItem = forwardRef<HTMLDivElement, SearchItemProps>((item, forwardRef) => {
43
- const { id, objectType, label, snippet, match, selected, onSelect } = item;
44
-
45
- return (
46
- <Card.StaticRoot
47
- ref={forwardRef}
48
- classNames={['mx-2 mt-2 cursor-pointer', selected && '!bg-activeSurface', ghostHover]}
49
- onClick={() => onSelect?.(id)}
50
- >
51
- {objectType && (
52
- <>
53
- <div className='text-xs text-neutral-400 ml-4'>{objectType}</div>
54
- </>
55
- )}
56
- <Card.Heading>{label ?? 'Untitled'}</Card.Heading>
57
- {snippet && <Snippet text={snippet} match={match} />}
58
- </Card.StaticRoot>
59
- );
60
- });
61
-
62
- export type SearchResultsProps = {
63
- match?: RegExp;
64
- items: SearchResult[];
65
- selected?: string;
66
- onSelect?: (id: string) => void;
67
- };
68
-
69
- // TODO(burdon): Key cursor up/down.
70
- export const SearchResults = ({ items, selected, onSelect }: SearchResultsProps) => {
71
- return (
72
- <div className='flex flex-col grow overflow-y-auto'>
73
- <div className='flex flex-col'>
74
- {items.map((item) => (
75
- <SearchItem
76
- key={item.id}
77
- type={SEARCH_RESULT}
78
- {...item}
79
- onSelect={onSelect}
80
- selected={selected === item.id}
81
- />
82
- ))}
83
- </div>
84
- </div>
85
- );
86
- };
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export * from './SearchResults';