@dxos/plugin-search 0.8.4-main.c1de068 → 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 (154) 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-HRIWTRJV.mjs +22 -0
  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 -59
  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 +3 -4
  68. package/dist/types/src/meta.d.ts.map +1 -1
  69. package/dist/types/src/search/exa.d.ts +4 -4
  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 +14 -11
  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 +57 -47
  78. package/src/SearchPlugin.tsx +28 -46
  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 +27 -31
  98. package/src/hooks/useGlobalSearch.tsx +33 -13
  99. package/src/hooks/useSearchResults.ts +9 -6
  100. package/src/hooks/useWebSearch.ts +21 -11
  101. package/src/meta.ts +10 -7
  102. package/src/search/exa.test.ts +8 -19
  103. package/src/search/exa.ts +135 -154
  104. package/src/translations.ts +1 -1
  105. package/src/types/action.tsx +10 -8
  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-FLW7KDC5.mjs +0 -77
  109. package/dist/lib/browser/app-graph-builder-FLW7KDC5.mjs.map +0 -7
  110. package/dist/lib/browser/chunk-BXSF7IAU.mjs +0 -190
  111. package/dist/lib/browser/chunk-BXSF7IAU.mjs.map +0 -7
  112. package/dist/lib/browser/chunk-JVMYGOKS.mjs +0 -21
  113. package/dist/lib/browser/chunk-JVMYGOKS.mjs.map +0 -7
  114. package/dist/lib/browser/chunk-KNS62YL2.mjs +0 -20
  115. package/dist/lib/browser/chunk-KNS62YL2.mjs.map +0 -7
  116. package/dist/lib/browser/intent-resolver-JPBGEKFT.mjs +0 -22
  117. package/dist/lib/browser/intent-resolver-JPBGEKFT.mjs.map +0 -7
  118. package/dist/lib/browser/react-surface-ETKK5YS3.mjs +0 -648
  119. package/dist/lib/browser/react-surface-ETKK5YS3.mjs.map +0 -7
  120. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  121. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  122. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  123. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  124. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  125. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  126. package/dist/types/src/components/Search.stories.d.ts +0 -15
  127. package/dist/types/src/components/Search.stories.d.ts.map +0 -1
  128. package/dist/types/src/components/SearchDialog.d.ts.map +0 -1
  129. package/dist/types/src/components/SearchMain.d.ts +0 -7
  130. package/dist/types/src/components/SearchMain.d.ts.map +0 -1
  131. package/dist/types/src/components/SearchResults/SearchResults.d.ts +0 -20
  132. package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +0 -1
  133. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts +0 -12
  134. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts.map +0 -1
  135. package/dist/types/src/components/SearchResults/index.d.ts +0 -2
  136. package/dist/types/src/components/SearchResults/index.d.ts.map +0 -1
  137. package/dist/types/src/components/Searchbar/Searchbar.d.ts +0 -14
  138. package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +0 -1
  139. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts +0 -11
  140. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts.map +0 -1
  141. package/dist/types/src/components/Searchbar/index.d.ts +0 -2
  142. package/dist/types/src/components/Searchbar/index.d.ts.map +0 -1
  143. package/src/capabilities/app-graph-builder.ts +0 -79
  144. package/src/capabilities/intent-resolver.ts +0 -18
  145. package/src/capabilities/react-surface.tsx +0 -59
  146. package/src/components/Search.stories.tsx +0 -66
  147. package/src/components/SearchDialog.tsx +0 -124
  148. package/src/components/SearchMain.tsx +0 -67
  149. package/src/components/SearchResults/SearchResults.stories.tsx +0 -57
  150. package/src/components/SearchResults/SearchResults.tsx +0 -86
  151. package/src/components/SearchResults/index.ts +0 -5
  152. package/src/components/Searchbar/Searchbar.stories.tsx +0 -28
  153. package/src/components/Searchbar/Searchbar.tsx +0 -67
  154. package/src/components/Searchbar/index.ts +0 -5
@@ -1,67 +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, useQuery, type Space } 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 { SearchResults } from './SearchResults';
14
- import { Searchbar } from './Searchbar';
15
- import { useGlobalSearch, useGlobalSearchResults } from '../hooks';
16
- import { useWebSearch } from '../hooks/useWebSearch';
17
- import { SEARCH_PLUGIN } from '../meta';
18
-
19
- export const SearchMain: FC<ThemedClassName<{ space: Space }>> = ({ classNames, space }) => {
20
- const { t } = useTranslation(SEARCH_PLUGIN);
21
- const client = useClient();
22
- const { setMatch } = useGlobalSearch();
23
- const [query, setQuery] = useState<string>();
24
- // TODO(burdon): UX to select all spaces.
25
- const allSpaces = false;
26
-
27
- // TODO(burdon): Returns ALL objects (e.g., incl. Text objects that are fields of parent objects).
28
- const objects = useQuery(allSpaces ? client.spaces : space, Filter.everything());
29
- const results = useGlobalSearchResults(objects);
30
-
31
- const {
32
- runSearch,
33
- results: webResults,
34
- isLoading,
35
- } = useWebSearch({
36
- query,
37
- });
38
-
39
- const [selected, setSelected] = useState<string>();
40
-
41
- // TODO(burdon): Activate and/or filter current main (set context).
42
- const handleSelect = (id: string) => {
43
- setSelected((selected) => (selected === id ? undefined : id));
44
- };
45
-
46
- const allResults = [...results, ...webResults];
47
- log.info('results', { results, webResults });
48
-
49
- return (
50
- <div className={mx('flex flex-col grow h-full overflow-hidden', classNames)}>
51
- <Searchbar
52
- placeholder={t('search placeholder')}
53
- onChange={(text) => {
54
- setQuery(text);
55
- setMatch?.(text);
56
- }}
57
- onSubmit={runSearch}
58
- />
59
- {isLoading && <div className={mx('flex flex-col grow overflow-hidden', activeSurface)}>Loading...</div>}
60
- {allResults.length > 0 && (
61
- <div className={mx('flex flex-col grow overflow-hidden', activeSurface)}>
62
- <SearchResults items={allResults} selected={selected} onSelect={handleSelect} />
63
- </div>
64
- )}
65
- </div>
66
- );
67
- };
@@ -1,57 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { type Meta } from '@storybook/react-vite';
8
- import React, { useState } from 'react';
9
-
10
- import { faker } from '@dxos/random';
11
- import { withLayout, withTheme } from '@dxos/storybook-utils';
12
-
13
- import { SearchResults, type SearchResultsProps } from './SearchResults';
14
- import { filterObjectsSync } from '../../hooks';
15
-
16
- faker.seed(1);
17
-
18
- const DefaultStory = (args: SearchResultsProps) => {
19
- const [selected, setSelected] = useState<string>();
20
-
21
- return (
22
- <div className='flex grow justify-center overflow-hidden'>
23
- <div className='flex w-[300px] m-4 overflow-hidden'>
24
- <SearchResults {...args} selected={selected} onSelect={setSelected} />
25
- </div>
26
- </div>
27
- );
28
- };
29
-
30
- const word = 'hello';
31
-
32
- const objects = Array.from({ length: 100 }).map((_, i) => ({
33
- id: faker.string.uuid(),
34
- name: faker.lorem.sentence(4),
35
- content: faker.lorem.sentence() + ` ${word} ` + faker.lorem.sentence(),
36
- }));
37
-
38
- const match = new RegExp(word, 'i');
39
-
40
- export const Default = {
41
- args: {
42
- items: filterObjectsSync(objects, match),
43
- match,
44
- },
45
- };
46
-
47
- const meta: Meta<typeof SearchResults> = {
48
- title: 'plugins/plugin-search/SearchResults',
49
- component: SearchResults,
50
- render: DefaultStory,
51
- decorators: [withTheme, withLayout({ fullscreen: true })],
52
- parameters: {
53
- layout: 'fullscreen',
54
- },
55
- };
56
-
57
- export default meta;
@@ -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';
@@ -1,28 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { type Meta } from '@storybook/react-vite';
8
-
9
- import { withTheme } from '@dxos/storybook-utils';
10
-
11
- import { Searchbar, type SearchbarProps } from './Searchbar';
12
-
13
- const meta: Meta<SearchbarProps> = {
14
- title: 'plugins/plugin-search/Searchbar',
15
- component: Searchbar,
16
- decorators: [withTheme],
17
- parameters: {
18
- layout: 'centered',
19
- },
20
- };
21
-
22
- export default meta;
23
-
24
- export const Default = {
25
- args: {
26
- placeholder: 'Search...',
27
- },
28
- };
@@ -1,67 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { type KeyboardEvent, useEffect, useRef, useState } from 'react';
6
-
7
- import { Input, type TextInputProps, Icon } from '@dxos/react-ui';
8
-
9
- export type SearchbarProps = Pick<TextInputProps, 'variant' | 'placeholder'> & {
10
- classes?: {
11
- root?: string;
12
- input?: string;
13
- };
14
- value?: string;
15
- onChange?: (text?: string) => void;
16
- onSubmit?: (text?: string) => void;
17
- delay?: number;
18
- };
19
-
20
- export const Searchbar = ({ classes, variant, placeholder, value, onChange, onSubmit }: SearchbarProps) => {
21
- const inputRef = useRef<HTMLInputElement>(null);
22
- const [text, setText] = useState(value);
23
- useEffect(() => {
24
- setText(value);
25
- }, [value]);
26
- const handleChange = (text?: string) => {
27
- setText(text);
28
- onChange?.(text);
29
- };
30
-
31
- const handleReset = () => {
32
- handleChange(undefined);
33
- inputRef.current?.focus();
34
- };
35
-
36
- const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
37
- switch (event.key) {
38
- case 'Enter':
39
- onSubmit?.(text);
40
- break;
41
- case 'Escape':
42
- handleReset();
43
- break;
44
- }
45
- };
46
-
47
- return (
48
- <div className='flex shrink-0w-full items-center pli-1 pbs-1'>
49
- <Input.Root>
50
- <Input.TextInput
51
- ref={inputRef}
52
- placeholder={placeholder}
53
- variant={variant}
54
- value={text ?? ''}
55
- classNames={['pl-3 pr-10', classes?.input]}
56
- onChange={({ target }) => handleChange(target.value)}
57
- onKeyDown={handleKeyDown}
58
- />
59
-
60
- {/* TODO(burdon): Margin should be density specific. */}
61
- <div role='button' className='-ml-7 p-0 cursor-pointer' onClick={handleReset}>
62
- <Icon icon='ph--magnifying-glass--regular' size={5} />
63
- </div>
64
- </Input.Root>
65
- </div>
66
- );
67
- };
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export * from './Searchbar';