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

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 (43) hide show
  1. package/dist/lib/browser/{SearchDialog-E6336HCX.mjs → SearchDialog-KJL6C2OF.mjs} +4 -6
  2. package/dist/lib/browser/{SearchDialog-E6336HCX.mjs.map → SearchDialog-KJL6C2OF.mjs.map} +4 -4
  3. package/dist/lib/browser/{SearchMain-24ZNJB24.mjs → SearchMain-JCNONOF3.mjs} +3 -3
  4. package/dist/lib/browser/{SearchMain-24ZNJB24.mjs.map → SearchMain-JCNONOF3.mjs.map} +1 -1
  5. package/dist/lib/browser/{app-graph-builder-NUJ2FOVQ.mjs → app-graph-builder-FHVM5QV7.mjs} +8 -12
  6. package/dist/lib/browser/app-graph-builder-FHVM5QV7.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-I7YWQSUZ.mjs → chunk-I3633KKK.mjs} +4 -4
  8. package/dist/lib/browser/{chunk-I7YWQSUZ.mjs.map → chunk-I3633KKK.mjs.map} +1 -1
  9. package/dist/lib/browser/{chunk-HRIWTRJV.mjs → chunk-PZ67KFRU.mjs} +3 -3
  10. package/dist/lib/browser/{chunk-HRIWTRJV.mjs.map → chunk-PZ67KFRU.mjs.map} +1 -1
  11. package/dist/lib/browser/index.mjs +5 -5
  12. package/dist/lib/browser/meta.json +1 -1
  13. package/dist/lib/browser/{operation-resolver-QEGN4ZKN.mjs → operation-resolver-H4X6BNWR.mjs} +3 -3
  14. package/dist/lib/browser/{react-surface-FLO4YTFP.mjs → react-surface-IPH2UPKO.mjs} +8 -21
  15. package/dist/lib/browser/react-surface-IPH2UPKO.mjs.map +7 -0
  16. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -1
  17. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
  18. package/dist/types/src/containers/SearchDialog/index.d.ts +2 -2
  19. package/dist/types/src/containers/SearchDialog/index.d.ts.map +1 -1
  20. package/dist/types/src/containers/index.d.ts +1 -2
  21. package/dist/types/src/containers/index.d.ts.map +1 -1
  22. package/dist/types/src/types/action.d.ts +1 -1
  23. package/dist/types/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +36 -36
  25. package/src/capabilities/app-graph-builder/app-graph-builder.ts +5 -6
  26. package/src/capabilities/react-surface/react-surface.tsx +4 -14
  27. package/src/constants.ts +1 -1
  28. package/src/containers/SearchDialog/index.ts +2 -3
  29. package/src/containers/SearchMain/SearchMain.tsx +1 -1
  30. package/src/containers/index.ts +1 -2
  31. package/src/meta.ts +2 -2
  32. package/src/types/action.tsx +2 -2
  33. package/dist/lib/browser/SpaceMain-IGCYHL7R.mjs +0 -154
  34. package/dist/lib/browser/SpaceMain-IGCYHL7R.mjs.map +0 -7
  35. package/dist/lib/browser/app-graph-builder-NUJ2FOVQ.mjs.map +0 -7
  36. package/dist/lib/browser/react-surface-FLO4YTFP.mjs.map +0 -7
  37. package/dist/types/src/containers/SpaceMain/SpaceMain.d.ts +0 -6
  38. package/dist/types/src/containers/SpaceMain/SpaceMain.d.ts.map +0 -1
  39. package/dist/types/src/containers/SpaceMain/index.d.ts +0 -3
  40. package/dist/types/src/containers/SpaceMain/index.d.ts.map +0 -1
  41. package/src/containers/SpaceMain/SpaceMain.tsx +0 -180
  42. package/src/containers/SpaceMain/index.ts +0 -7
  43. /package/dist/lib/browser/{operation-resolver-QEGN4ZKN.mjs.map → operation-resolver-H4X6BNWR.mjs.map} +0 -0
@@ -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
- };
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { SpaceMain } from './SpaceMain';
6
-
7
- export default SpaceMain;