@dxos/plugin-search 0.8.4-main.72ec0f3 → 0.8.4-main.7996785055
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/README.md +0 -1
- package/dist/lib/browser/SearchDialog-DVLB2VC2.mjs +84 -0
- package/dist/lib/browser/SearchDialog-DVLB2VC2.mjs.map +7 -0
- package/dist/lib/browser/SearchMain-25GWFGDM.mjs +92 -0
- package/dist/lib/browser/SearchMain-25GWFGDM.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-GTD4XFXW.mjs +79 -0
- package/dist/lib/browser/app-graph-builder-GTD4XFXW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ZEP4O5SU.mjs → chunk-CMFZ7CJK.mjs} +49 -58
- package/dist/lib/browser/chunk-CMFZ7CJK.mjs.map +7 -0
- package/dist/lib/browser/chunk-OGXI46DO.mjs +27 -0
- package/dist/lib/browser/chunk-OGXI46DO.mjs.map +7 -0
- package/dist/lib/browser/chunk-RX3VHGKJ.mjs +8 -0
- package/dist/lib/browser/chunk-RX3VHGKJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GN2FSWTM.mjs → chunk-VZK2I4SR.mjs} +10 -3
- package/dist/lib/browser/chunk-VZK2I4SR.mjs.map +7 -0
- package/dist/lib/browser/chunk-W4E6FT6J.mjs +11 -0
- package/dist/lib/browser/chunk-W4E6FT6J.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +47 -56
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/open-search-HJI2ZI7N.mjs +23 -0
- package/dist/lib/browser/open-search-HJI2ZI7N.mjs.map +7 -0
- package/dist/lib/browser/operation-handler-GY2ZUYKH.mjs +16 -0
- package/dist/lib/browser/operation-handler-GY2ZUYKH.mjs.map +7 -0
- package/dist/lib/browser/react-surface-Y5BHTAJX.mjs +58 -0
- package/dist/lib/browser/react-surface-Y5BHTAJX.mjs.map +7 -0
- package/dist/types/src/SearchPlugin.d.ts +2 -1
- package/dist/types/src/SearchPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +3 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler/index.d.ts +4 -0
- package/dist/types/src/capabilities/operation-handler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +2 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts +6 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts.map +1 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.stories.d.ts +35 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.stories.d.ts.map +1 -0
- package/dist/types/src/containers/SearchDialog/index.d.ts +3 -0
- package/dist/types/src/containers/SearchDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/SearchMain/SearchMain.d.ts.map +1 -0
- package/dist/types/src/containers/SearchMain/index.d.ts +3 -0
- package/dist/types/src/containers/SearchMain/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +5 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/sync.d.ts +3 -2
- package/dist/types/src/hooks/sync.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobalSearch.d.ts +7 -3
- package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
- package/dist/types/src/hooks/useSearchResults.d.ts +3 -2
- package/dist/types/src/hooks/useSearchResults.d.ts.map +1 -1
- package/dist/types/src/hooks/useWebSearch.d.ts +6 -3
- package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +3 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -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/search/exa.d.ts +3 -1
- package/dist/types/src/search/exa.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +7 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +0 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/search.d.ts +3 -7
- package/dist/types/src/types/search.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +56 -47
- package/src/SearchPlugin.tsx +25 -42
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +70 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/index.ts +3 -5
- package/src/capabilities/operation-handler/index.ts +11 -0
- package/src/capabilities/operation-handler/operation-handler.ts +16 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +62 -0
- package/src/components/index.ts +0 -4
- package/src/constants.ts +7 -0
- package/src/containers/SearchDialog/SearchDialog.stories.tsx +53 -0
- package/src/containers/SearchDialog/SearchDialog.tsx +104 -0
- package/src/containers/SearchDialog/index.ts +6 -0
- package/src/containers/SearchMain/SearchMain.tsx +92 -0
- package/src/containers/SearchMain/index.ts +7 -0
- package/src/containers/index.ts +10 -0
- package/src/hooks/sync.test.ts +6 -4
- package/src/hooks/sync.ts +22 -27
- package/src/hooks/useGlobalSearch.tsx +31 -12
- package/src/hooks/useSearchResults.ts +5 -2
- package/src/hooks/useWebSearch.ts +20 -9
- package/src/meta.ts +4 -4
- package/src/operations/definitions.ts +17 -0
- package/src/operations/index.ts +9 -0
- package/src/operations/open-search.ts +25 -0
- package/src/search/exa.test.ts +7 -7
- package/src/search/exa.ts +4 -3
- package/src/translations.ts +3 -1
- package/src/types/command-score.d.ts +16 -0
- package/src/types/index.ts +0 -1
- package/src/types/search.ts +3 -9
- package/dist/lib/browser/app-graph-builder-HQR6P4C7.mjs +0 -78
- package/dist/lib/browser/app-graph-builder-HQR6P4C7.mjs.map +0 -7
- package/dist/lib/browser/chunk-GN2FSWTM.mjs.map +0 -7
- package/dist/lib/browser/chunk-TCVYYI44.mjs +0 -21
- package/dist/lib/browser/chunk-TCVYYI44.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZEP4O5SU.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-UYQA6UUQ.mjs +0 -22
- package/dist/lib/browser/intent-resolver-UYQA6UUQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-H5CKQVII.mjs +0 -307
- package/dist/lib/browser/react-surface-H5CKQVII.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/Search.stories.d.ts +0 -16
- package/dist/types/src/components/Search.stories.d.ts.map +0 -1
- package/dist/types/src/components/SearchDialog.d.ts +0 -7
- package/dist/types/src/components/SearchDialog.d.ts.map +0 -1
- package/dist/types/src/components/SearchMain.d.ts.map +0 -1
- package/dist/types/src/components/SearchResults/SearchResults.d.ts +0 -20
- package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +0 -1
- package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts +0 -16
- package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts.map +0 -1
- package/dist/types/src/components/SearchResults/index.d.ts +0 -2
- package/dist/types/src/components/SearchResults/index.d.ts.map +0 -1
- package/dist/types/src/components/Searchbar/Searchbar.d.ts +0 -10
- package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +0 -1
- package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts +0 -13
- package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts.map +0 -1
- package/dist/types/src/components/Searchbar/index.d.ts +0 -2
- package/dist/types/src/components/Searchbar/index.d.ts.map +0 -1
- package/dist/types/src/types/action.d.ts +0 -13
- package/dist/types/src/types/action.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -80
- package/src/capabilities/intent-resolver.ts +0 -18
- package/src/capabilities/react-surface.tsx +0 -56
- package/src/components/Search.stories.tsx +0 -64
- package/src/components/SearchDialog.tsx +0 -136
- package/src/components/SearchMain.tsx +0 -62
- package/src/components/SearchResults/SearchResults.stories.tsx +0 -59
- package/src/components/SearchResults/SearchResults.tsx +0 -83
- package/src/components/SearchResults/index.ts +0 -5
- package/src/components/Searchbar/Searchbar.stories.tsx +0 -28
- package/src/components/Searchbar/Searchbar.tsx +0 -48
- package/src/components/Searchbar/index.ts +0 -5
- package/src/types/action.tsx +0 -16
- /package/dist/types/src/{components → containers/SearchMain}/SearchMain.d.ts +0 -0
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type FC, forwardRef } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Surface } from '@dxos/app-framework/react';
|
|
8
|
-
import { Obj } from '@dxos/echo';
|
|
9
|
-
import { Card } from '@dxos/react-ui-stack';
|
|
10
|
-
import { ghostHover } from '@dxos/react-ui-theme';
|
|
11
|
-
|
|
12
|
-
import { type SearchResult } from '../../types';
|
|
13
|
-
|
|
14
|
-
export type SearchResultsProps = {
|
|
15
|
-
items: SearchResult[];
|
|
16
|
-
match?: RegExp;
|
|
17
|
-
selected?: string;
|
|
18
|
-
onSelect?: (id: string) => void;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// TODO(burdon): Key cursor up/down.
|
|
22
|
-
// TODO(burdon): Use stack (should be virtualized).
|
|
23
|
-
export const SearchResults = ({ items }: SearchResultsProps) => {
|
|
24
|
-
return (
|
|
25
|
-
<div className='overflow-y-auto'>
|
|
26
|
-
<div className='flex flex-col'>
|
|
27
|
-
{items
|
|
28
|
-
// TODO(burdon): Hack to reduce noise from system objects.
|
|
29
|
-
.filter((item) => Obj.getLabel(item.object))
|
|
30
|
-
.map((item) => (
|
|
31
|
-
<div key={item.id} role='none' className='pli-2 first:pbs-2 pbe-2'>
|
|
32
|
-
<Surface role='card' data={{ subject: item.object }} limit={1} />
|
|
33
|
-
</div>
|
|
34
|
-
))}
|
|
35
|
-
</div>
|
|
36
|
-
</div>
|
|
37
|
-
);
|
|
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 && <div className='text-xs text-neutral-400 ml-4'>{objectType}</div>}
|
|
52
|
-
<Card.Heading>{label ?? 'Untitled'}</Card.Heading>
|
|
53
|
-
{snippet && <Snippet text={snippet} match={match} />}
|
|
54
|
-
</Card.StaticRoot>
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
export const Snippet: FC<{ text: string; match?: RegExp }> = ({ text, match }) => {
|
|
59
|
-
let content = <>{text}</>;
|
|
60
|
-
if (match) {
|
|
61
|
-
const result = text.match(match);
|
|
62
|
-
if (result?.index !== undefined) {
|
|
63
|
-
// Break near to match.
|
|
64
|
-
const maxOffset = 16;
|
|
65
|
-
let before = text.slice(0, result.index);
|
|
66
|
-
if (before.length > maxOffset) {
|
|
67
|
-
const idx = before.indexOf(' ', result.index - maxOffset);
|
|
68
|
-
before = '… ' + before.slice(idx);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const after = text.slice(result.index + result[0].length);
|
|
72
|
-
content = (
|
|
73
|
-
<>
|
|
74
|
-
{before}
|
|
75
|
-
<span className='text-blue-500'>{result[0]}</span>
|
|
76
|
-
{after}
|
|
77
|
-
</>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return <span className='text-xs mb-1 line-clamp-3 text-neutral-300'>{content}</span>;
|
|
83
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
-
|
|
7
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
8
|
-
|
|
9
|
-
import { Searchbar } from './Searchbar';
|
|
10
|
-
|
|
11
|
-
const meta = {
|
|
12
|
-
title: 'plugins/plugin-search/Searchbar',
|
|
13
|
-
component: Searchbar,
|
|
14
|
-
decorators: [withTheme],
|
|
15
|
-
parameters: {
|
|
16
|
-
layout: 'centered',
|
|
17
|
-
},
|
|
18
|
-
} satisfies Meta<typeof Searchbar>;
|
|
19
|
-
|
|
20
|
-
export default meta;
|
|
21
|
-
|
|
22
|
-
type Story = StoryObj<typeof meta>;
|
|
23
|
-
|
|
24
|
-
export const Default: Story = {
|
|
25
|
-
args: {
|
|
26
|
-
placeholder: 'Search...',
|
|
27
|
-
},
|
|
28
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type KeyboardEvent, useCallback, useRef } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Input, type TextInputProps, type ThemedClassName, Toolbar, useControlledState } from '@dxos/react-ui';
|
|
8
|
-
|
|
9
|
-
export type SearchbarProps = ThemedClassName<
|
|
10
|
-
Pick<TextInputProps, 'variant' | 'placeholder'> & {
|
|
11
|
-
delay?: number;
|
|
12
|
-
value?: string;
|
|
13
|
-
onChange?: (text?: string) => void;
|
|
14
|
-
onSubmit?: (text?: string) => void;
|
|
15
|
-
}
|
|
16
|
-
>;
|
|
17
|
-
|
|
18
|
-
export const Searchbar = ({ classNames, variant, placeholder, value, onChange, onSubmit }: SearchbarProps) => {
|
|
19
|
-
const [text, setText] = useControlledState(value, onChange);
|
|
20
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
21
|
-
|
|
22
|
-
const handleKeyDown = useCallback(
|
|
23
|
-
(event: KeyboardEvent<HTMLInputElement>) => {
|
|
24
|
-
switch (event.key) {
|
|
25
|
-
case 'Enter':
|
|
26
|
-
onSubmit?.(text);
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
[text, onSubmit],
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<Toolbar.Root classNames={classNames}>
|
|
35
|
-
<Input.Root>
|
|
36
|
-
<Input.TextInput
|
|
37
|
-
ref={inputRef}
|
|
38
|
-
placeholder={placeholder}
|
|
39
|
-
autoFocus
|
|
40
|
-
variant={variant}
|
|
41
|
-
value={text ?? ''}
|
|
42
|
-
onChange={({ target }) => setText(target.value)}
|
|
43
|
-
onKeyDown={handleKeyDown}
|
|
44
|
-
/>
|
|
45
|
-
</Input.Root>
|
|
46
|
-
</Toolbar.Root>
|
|
47
|
-
);
|
|
48
|
-
};
|
package/src/types/action.tsx
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
|
-
|
|
7
|
-
import { meta } from '../meta';
|
|
8
|
-
|
|
9
|
-
export namespace SearchAction {
|
|
10
|
-
const SEARCH_ACTION = `${meta.id}/action`;
|
|
11
|
-
|
|
12
|
-
export class OpenSearch extends Schema.TaggedClass<OpenSearch>()(`${SEARCH_ACTION}/open-search`, {
|
|
13
|
-
input: Schema.Void,
|
|
14
|
-
output: Schema.Void,
|
|
15
|
-
}) {}
|
|
16
|
-
}
|
|
File without changes
|