@dxos/plugin-search 0.8.4-main.f9ba587 → 0.8.4-main.fcc0d83b33
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/index.mjs +309 -89
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +23 -0
- package/dist/lib/browser/translations.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.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- 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 +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- 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 -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/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 +7 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts.map +1 -0
- 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 +2 -0
- package/dist/types/src/containers/SearchDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/sync.d.ts +4 -3
- package/dist/types/src/hooks/sync.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobalSearch.d.ts +8 -4
- 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 +7 -4
- package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +3 -4
- 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 +4 -4
- package/dist/types/src/search/exa.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +15 -10
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/search.d.ts +1 -20
- package/dist/types/src/types/search.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +73 -49
- package/src/SearchPlugin.tsx +30 -48
- package/src/capabilities/app-graph-builder.ts +56 -69
- package/src/capabilities/index.ts +8 -4
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +68 -55
- package/src/components/SearchResultStack/SearchResultStack.tsx +118 -0
- package/src/components/SearchResultStack/index.ts +5 -0
- package/src/components/index.ts +1 -3
- package/src/constants.ts +7 -0
- 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 +93 -0
- package/src/containers/SearchDialog/index.ts +5 -0
- package/src/containers/index.ts +8 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/sync.test.ts +9 -7
- package/src/hooks/sync.ts +28 -32
- package/src/hooks/useGlobalSearch.tsx +33 -13
- package/src/hooks/useSearchResults.ts +9 -6
- package/src/hooks/useWebSearch.ts +25 -19
- package/src/meta.ts +10 -7
- package/src/operations/definitions.ts +17 -0
- package/src/operations/index.ts +9 -0
- package/src/operations/open-search.ts +24 -0
- package/src/search/exa.test.ts +9 -32
- package/src/search/exa.ts +140 -168
- package/src/translations.ts +10 -9
- package/src/types/command-score.d.ts +16 -0
- package/src/types/index.ts +1 -2
- package/src/types/search.ts +1 -25
- package/dist/lib/browser/app-graph-builder-V667YGDS.mjs +0 -77
- package/dist/lib/browser/app-graph-builder-V667YGDS.mjs.map +0 -7
- package/dist/lib/browser/chunk-2QKDUXCH.mjs +0 -21
- package/dist/lib/browser/chunk-2QKDUXCH.mjs.map +0 -7
- package/dist/lib/browser/chunk-KNS62YL2.mjs +0 -20
- package/dist/lib/browser/chunk-KNS62YL2.mjs.map +0 -7
- package/dist/lib/browser/chunk-LPB2XRYL.mjs +0 -190
- package/dist/lib/browser/chunk-LPB2XRYL.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-SPX5JVY7.mjs +0 -22
- package/dist/lib/browser/intent-resolver-SPX5JVY7.mjs.map +0 -7
- package/dist/lib/browser/react-surface-HMXHJSLE.mjs +0 -642
- package/dist/lib/browser/react-surface-HMXHJSLE.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-IZHM72QQ.mjs +0 -78
- package/dist/lib/node-esm/app-graph-builder-IZHM72QQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-L7BUHKLC.mjs +0 -192
- package/dist/lib/node-esm/chunk-L7BUHKLC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-N5SNYFMK.mjs +0 -22
- package/dist/lib/node-esm/chunk-N5SNYFMK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y7BGRQH5.mjs +0 -22
- package/dist/lib/node-esm/chunk-Y7BGRQH5.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -113
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-MFPFD3XC.mjs +0 -23
- package/dist/lib/node-esm/intent-resolver-MFPFD3XC.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-WHU5EEAQ.mjs +0 -643
- package/dist/lib/node-esm/react-surface-WHU5EEAQ.mjs.map +0 -7
- 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/components/Search.stories.d.ts +0 -15
- 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 +0 -7
- 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 -12
- 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 -14
- package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +0 -1
- package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts +0 -11
- 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/intent-resolver.ts +0 -18
- package/src/components/Search.stories.tsx +0 -66
- package/src/components/SearchDialog.tsx +0 -124
- package/src/components/SearchMain.tsx +0 -67
- package/src/components/SearchResults/SearchResults.stories.tsx +0 -57
- package/src/components/SearchResults/SearchResults.tsx +0 -86
- package/src/components/SearchResults/index.ts +0 -5
- package/src/components/Searchbar/Searchbar.stories.tsx +0 -28
- package/src/components/Searchbar/Searchbar.tsx +0 -69
- package/src/components/Searchbar/index.ts +0 -5
- package/src/types/action.tsx +0 -16
|
@@ -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,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,69 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { MagnifyingGlass } from '@phosphor-icons/react';
|
|
6
|
-
import React, { type KeyboardEvent, useEffect, useRef, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
import { Input, type TextInputProps } from '@dxos/react-ui';
|
|
9
|
-
import { getSize, mx } from '@dxos/react-ui-theme';
|
|
10
|
-
|
|
11
|
-
export type SearchbarProps = Pick<TextInputProps, 'variant' | 'placeholder'> & {
|
|
12
|
-
classes?: {
|
|
13
|
-
root?: string;
|
|
14
|
-
input?: string;
|
|
15
|
-
};
|
|
16
|
-
value?: string;
|
|
17
|
-
onChange?: (text?: string) => void;
|
|
18
|
-
onSubmit?: (text?: string) => void;
|
|
19
|
-
delay?: number;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const Searchbar = ({ classes, variant, placeholder, value, onChange, onSubmit }: SearchbarProps) => {
|
|
23
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
24
|
-
const [text, setText] = useState(value);
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
setText(value);
|
|
27
|
-
}, [value]);
|
|
28
|
-
const handleChange = (text?: string) => {
|
|
29
|
-
setText(text);
|
|
30
|
-
onChange?.(text);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const handleReset = () => {
|
|
34
|
-
handleChange(undefined);
|
|
35
|
-
inputRef.current?.focus();
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
|
|
39
|
-
switch (event.key) {
|
|
40
|
-
case 'Enter':
|
|
41
|
-
onSubmit?.(text);
|
|
42
|
-
break;
|
|
43
|
-
case 'Escape':
|
|
44
|
-
handleReset();
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<div className='flex shrink-0w-full items-center pli-1 pbs-1'>
|
|
51
|
-
<Input.Root>
|
|
52
|
-
<Input.TextInput
|
|
53
|
-
ref={inputRef}
|
|
54
|
-
placeholder={placeholder}
|
|
55
|
-
variant={variant}
|
|
56
|
-
value={text ?? ''}
|
|
57
|
-
classNames={mx('pl-3 pr-10', classes?.input)}
|
|
58
|
-
onChange={({ target }) => handleChange(target.value)}
|
|
59
|
-
onKeyDown={handleKeyDown}
|
|
60
|
-
/>
|
|
61
|
-
|
|
62
|
-
{/* TODO(burdon): Margin should be density specific. */}
|
|
63
|
-
<div role='button' className='-ml-7 p-0 cursor-pointer' onClick={handleReset}>
|
|
64
|
-
<MagnifyingGlass className={getSize(5)} />
|
|
65
|
-
</div>
|
|
66
|
-
</Input.Root>
|
|
67
|
-
</div>
|
|
68
|
-
);
|
|
69
|
-
};
|
package/src/types/action.tsx
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { SEARCH_PLUGIN } from '../meta';
|
|
8
|
-
|
|
9
|
-
export namespace SearchAction {
|
|
10
|
-
const SEARCH_ACTION = `${SEARCH_PLUGIN}/action`;
|
|
11
|
-
|
|
12
|
-
export class OpenSearch extends Schema.TaggedClass<OpenSearch>()(`${SEARCH_ACTION}/open-search`, {
|
|
13
|
-
input: Schema.Void,
|
|
14
|
-
output: Schema.Void,
|
|
15
|
-
}) {}
|
|
16
|
-
}
|