@dxos/plugin-preview 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe

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 (73) hide show
  1. package/dist/lib/browser/index.mjs +30 -25
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +31 -25
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
  8. package/dist/types/src/capabilities/index.d.ts +3 -2
  9. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  10. package/dist/types/src/capabilities/preview-popover.d.ts +5 -0
  11. package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -0
  12. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  13. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  14. package/dist/types/src/cards/FormCard.d.ts +2 -2
  15. package/dist/types/src/cards/FormCard.d.ts.map +1 -1
  16. package/dist/types/src/cards/JsonCard.d.ts +5 -0
  17. package/dist/types/src/cards/JsonCard.d.ts.map +1 -0
  18. package/dist/types/src/cards/OrganizationCard.d.ts +2 -2
  19. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
  20. package/dist/types/src/cards/PersonCard.d.ts +2 -2
  21. package/dist/types/src/cards/PersonCard.d.ts.map +1 -1
  22. package/dist/types/src/cards/ProjectCard.d.ts +3 -3
  23. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
  24. package/dist/types/src/cards/TaskCard.d.ts +2 -2
  25. package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
  26. package/dist/types/src/cards/index.d.ts +1 -0
  27. package/dist/types/src/cards/index.d.ts.map +1 -1
  28. package/dist/types/src/stories/Card.stories.d.ts +16 -11
  29. package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
  30. package/dist/types/src/stories/testing.d.ts +4 -4
  31. package/dist/types/src/stories/testing.d.ts.map +1 -1
  32. package/dist/types/src/translations.d.ts +8 -8
  33. package/dist/types/src/translations.d.ts.map +1 -1
  34. package/dist/types/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +41 -36
  36. package/src/PreviewPlugin.tsx +9 -7
  37. package/src/capabilities/index.ts +4 -2
  38. package/src/capabilities/{preview-popover/preview-popover.ts → preview-popover.ts} +31 -15
  39. package/src/capabilities/react-surface.tsx +116 -0
  40. package/src/cards/FormCard.tsx +13 -28
  41. package/src/cards/JsonCard.tsx +16 -0
  42. package/src/cards/OrganizationCard.tsx +4 -4
  43. package/src/cards/PersonCard.tsx +34 -16
  44. package/src/cards/ProjectCard.tsx +5 -5
  45. package/src/cards/TaskCard.tsx +25 -21
  46. package/src/cards/index.ts +1 -0
  47. package/src/meta.ts +1 -1
  48. package/src/stories/Card.stories.tsx +50 -11
  49. package/src/stories/testing.tsx +38 -31
  50. package/src/translations.ts +8 -8
  51. package/dist/lib/browser/chunk-XLN6KTHK.mjs +0 -17
  52. package/dist/lib/browser/chunk-XLN6KTHK.mjs.map +0 -7
  53. package/dist/lib/browser/preview-popover-Y67LE6TV.mjs +0 -78
  54. package/dist/lib/browser/preview-popover-Y67LE6TV.mjs.map +0 -7
  55. package/dist/lib/browser/react-surface-XYEFQ6NI.mjs +0 -263
  56. package/dist/lib/browser/react-surface-XYEFQ6NI.mjs.map +0 -7
  57. package/dist/lib/node-esm/chunk-2G4FUGDA.mjs +0 -19
  58. package/dist/lib/node-esm/chunk-2G4FUGDA.mjs.map +0 -7
  59. package/dist/lib/node-esm/preview-popover-BGV2P6UX.mjs +0 -80
  60. package/dist/lib/node-esm/preview-popover-BGV2P6UX.mjs.map +0 -7
  61. package/dist/lib/node-esm/react-surface-PSUCURVT.mjs +0 -264
  62. package/dist/lib/node-esm/react-surface-PSUCURVT.mjs.map +0 -7
  63. package/dist/types/src/capabilities/preview-popover/index.d.ts +0 -3
  64. package/dist/types/src/capabilities/preview-popover/index.d.ts.map +0 -1
  65. package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts +0 -5
  66. package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts.map +0 -1
  67. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  68. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  69. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  70. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  71. package/src/capabilities/preview-popover/index.ts +0 -7
  72. package/src/capabilities/react-surface/index.ts +0 -7
  73. package/src/capabilities/react-surface/react-surface.tsx +0 -97
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-preview",
3
- "version": "0.8.4-main.937b3ca",
3
+ "version": "0.8.4-main.9be5663bfe",
4
4
  "description": "Preview plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -12,6 +12,10 @@
12
12
  "author": "DXOS.org",
13
13
  "sideEffects": true,
14
14
  "type": "module",
15
+ "imports": {
16
+ "#capabilities": "./src/capabilities/index.ts",
17
+ "#meta": "./src/meta.ts"
18
+ },
15
19
  "exports": {
16
20
  ".": {
17
21
  "source": "./src/index.ts",
@@ -28,47 +32,48 @@
28
32
  "src"
29
33
  ],
30
34
  "dependencies": {
31
- "@effect-atom/atom-react": "^0.4.6",
32
- "@dxos/app-framework": "0.8.4-main.937b3ca",
33
- "@dxos/async": "0.8.4-main.937b3ca",
34
- "@dxos/effect": "0.8.4-main.937b3ca",
35
- "@dxos/client": "0.8.4-main.937b3ca",
36
- "@dxos/keys": "0.8.4-main.937b3ca",
37
- "@dxos/lit-ui": "0.8.4-main.937b3ca",
38
- "@dxos/app-graph": "0.8.4-main.937b3ca",
39
- "@dxos/echo": "0.8.4-main.937b3ca",
40
- "@dxos/log": "0.8.4-main.937b3ca",
41
- "@dxos/plugin-client": "0.8.4-main.937b3ca",
42
- "@dxos/plugin-attention": "0.8.4-main.937b3ca",
43
- "@dxos/plugin-deck": "0.8.4-main.937b3ca",
44
- "@dxos/operation": "0.8.4-main.937b3ca",
45
- "@dxos/plugin-space": "0.8.4-main.937b3ca",
46
- "@dxos/react-client": "0.8.4-main.937b3ca",
47
- "@dxos/react-ui": "0.8.4-main.937b3ca",
48
- "@dxos/react-ui-editor": "0.8.4-main.937b3ca",
49
- "@dxos/react-ui-form": "0.8.4-main.937b3ca",
50
- "@dxos/react-ui-menu": "0.8.4-main.937b3ca",
51
- "@dxos/react-ui-mosaic": "0.8.4-main.937b3ca",
52
- "@dxos/react-ui-table": "0.8.4-main.937b3ca",
53
- "@dxos/types": "0.8.4-main.937b3ca",
54
- "@dxos/schema": "0.8.4-main.937b3ca",
55
- "@dxos/ui-editor": "0.8.4-main.937b3ca",
56
- "@dxos/ui-theme": "0.8.4-main.937b3ca",
57
- "@dxos/util": "0.8.4-main.937b3ca"
35
+ "@effect-atom/atom-react": "^0.5.0",
36
+ "@dxos/app-framework": "0.8.4-main.9be5663bfe",
37
+ "@dxos/app-toolkit": "0.8.4-main.9be5663bfe",
38
+ "@dxos/async": "0.8.4-main.9be5663bfe",
39
+ "@dxos/app-graph": "0.8.4-main.9be5663bfe",
40
+ "@dxos/client": "0.8.4-main.9be5663bfe",
41
+ "@dxos/effect": "0.8.4-main.9be5663bfe",
42
+ "@dxos/echo": "0.8.4-main.9be5663bfe",
43
+ "@dxos/keys": "0.8.4-main.9be5663bfe",
44
+ "@dxos/lit-ui": "0.8.4-main.9be5663bfe",
45
+ "@dxos/operation": "0.8.4-main.9be5663bfe",
46
+ "@dxos/plugin-client": "0.8.4-main.9be5663bfe",
47
+ "@dxos/plugin-attention": "0.8.4-main.9be5663bfe",
48
+ "@dxos/plugin-deck": "0.8.4-main.9be5663bfe",
49
+ "@dxos/react-client": "0.8.4-main.9be5663bfe",
50
+ "@dxos/react-ui": "0.8.4-main.9be5663bfe",
51
+ "@dxos/react-ui-editor": "0.8.4-main.9be5663bfe",
52
+ "@dxos/react-ui-form": "0.8.4-main.9be5663bfe",
53
+ "@dxos/react-ui-menu": "0.8.4-main.9be5663bfe",
54
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.9be5663bfe",
55
+ "@dxos/react-ui-table": "0.8.4-main.9be5663bfe",
56
+ "@dxos/react-ui-mosaic": "0.8.4-main.9be5663bfe",
57
+ "@dxos/schema": "0.8.4-main.9be5663bfe",
58
+ "@dxos/ui-editor": "0.8.4-main.9be5663bfe",
59
+ "@dxos/ui-theme": "0.8.4-main.9be5663bfe",
60
+ "@dxos/types": "0.8.4-main.9be5663bfe",
61
+ "@dxos/util": "0.8.4-main.9be5663bfe",
62
+ "@dxos/log": "0.8.4-main.9be5663bfe"
58
63
  },
59
64
  "devDependencies": {
60
- "effect": "3.19.11",
65
+ "effect": "3.20.0",
61
66
  "react": "~19.2.3",
62
67
  "react-dom": "~19.2.3",
63
- "vite": "7.1.9",
64
- "@dxos/echo-db": "0.8.4-main.937b3ca",
65
- "@dxos/plugin-testing": "0.8.4-main.937b3ca",
66
- "@dxos/react-ui-components": "0.8.4-main.937b3ca",
67
- "@dxos/random": "0.8.4-main.937b3ca",
68
- "@dxos/storybook-utils": "0.8.4-main.937b3ca"
68
+ "vite": "^7.1.11",
69
+ "@dxos/echo-db": "0.8.4-main.9be5663bfe",
70
+ "@dxos/plugin-testing": "0.8.4-main.9be5663bfe",
71
+ "@dxos/react-ui-components": "0.8.4-main.9be5663bfe",
72
+ "@dxos/random": "0.8.4-main.9be5663bfe",
73
+ "@dxos/storybook-utils": "0.8.4-main.9be5663bfe"
69
74
  },
70
75
  "peerDependencies": {
71
- "effect": "3.19.11",
76
+ "effect": "3.20.0",
72
77
  "react": "~19.2.3",
73
78
  "react-dom": "~19.2.3"
74
79
  },
@@ -2,20 +2,22 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { Common, Plugin } from '@dxos/app-framework';
5
+ import { ActivationEvents, Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
6
7
  import { Organization, Person } from '@dxos/types';
7
8
 
8
- import { PreviewPopover, ReactSurface } from './capabilities';
9
- import { meta } from './meta';
9
+ import { PreviewPopover, ReactSurface } from '#capabilities';
10
+ import { meta } from '#meta';
11
+
10
12
  import { translations } from './translations';
11
13
 
12
14
  export const PreviewPlugin = Plugin.define(meta).pipe(
13
- Common.Plugin.addTranslationsModule({ translations }),
14
- Common.Plugin.addSchemaModule({ schema: [Person.Person, Organization.Organization], id: 'schema' }),
15
- Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
15
+ AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization], id: 'schema' }),
16
+ AppPlugin.addSurfaceModule({ activate: ReactSurface }),
17
+ AppPlugin.addTranslationsModule({ translations }),
16
18
  Plugin.addModule({
17
19
  id: 'preview-popover',
18
- activatesOn: Common.ActivationEvent.Startup,
20
+ activatesOn: ActivationEvents.Startup,
19
21
  activate: PreviewPopover,
20
22
  }),
21
23
  Plugin.make,
@@ -2,5 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './preview-popover';
6
- export * from './react-surface';
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ export const PreviewPopover = Capability.lazy('PreviewPopover', () => import('./preview-popover'));
8
+ export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -4,13 +4,15 @@
4
4
 
5
5
  import * as Effect from 'effect/Effect';
6
6
 
7
- import { Capability, Common } from '@dxos/app-framework';
7
+ import { Capabilities, Capability } from '@dxos/app-framework';
8
+ import { AppCapabilities, LayoutOperation, getPersonalSpace, getSpaceIdFromPath } from '@dxos/app-toolkit';
8
9
  import { addEventListener } from '@dxos/async';
9
10
  import { type Client } from '@dxos/client';
10
- import { type Space, parseId } from '@dxos/client/echo';
11
+ import { type Space } from '@dxos/client/echo';
12
+ import { Obj } from '@dxos/echo';
11
13
  import { DXN } from '@dxos/keys';
12
14
  import { log } from '@dxos/log';
13
- import { ClientCapabilities } from '@dxos/plugin-client';
15
+ import { ClientCapabilities } from '@dxos/plugin-client/types';
14
16
  import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';
15
17
  import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/ui-editor';
16
18
 
@@ -19,10 +21,10 @@ const customEventOptions = { capture: true, passive: false };
19
21
  const handlePreviewLookup = async (
20
22
  client: Client,
21
23
  defaultSpace: Space,
22
- { ref, label }: PreviewLinkRef,
24
+ { dxn, label }: PreviewLinkRef,
23
25
  ): Promise<PreviewLinkTarget | null> => {
24
26
  try {
25
- const object = await defaultSpace.db.makeRef(DXN.parse(ref)).load();
27
+ const object = await defaultSpace.db.makeRef(DXN.parse(dxn)).load();
26
28
  return { label, object };
27
29
  } catch {
28
30
  return null;
@@ -35,20 +37,34 @@ export default Capability.makeModule(
35
37
  const capabilities = yield* Capability.Service;
36
38
 
37
39
  // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
38
- const handleAnchorActivate = async ({ refId, label, trigger, kind, title, side, props }: DxAnchorActivate) => {
39
- const { invokePromise } = capabilities.get(Common.Capability.OperationInvoker);
40
+ const handleAnchorActivate = async ({
41
+ dxn,
42
+ label,
43
+ trigger,
44
+ kind = 'card',
45
+ title: titleProp,
46
+ side,
47
+ props,
48
+ }: DxAnchorActivate) => {
49
+ const { invokePromise } = capabilities.get(Capabilities.OperationInvoker);
40
50
  const client = capabilities.get(ClientCapabilities.Client);
41
- const registry = capabilities.get(Common.Capability.AtomRegistry);
42
- const [layoutAtom] = capabilities.getAll(Common.Capability.Layout);
51
+ const registry = capabilities.get(Capabilities.AtomRegistry);
52
+ const [layoutAtom] = capabilities.getAll(AppCapabilities.Layout);
43
53
  const layout = registry.get(layoutAtom);
44
- const { spaceId } = parseId(layout.workspace);
45
- const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
46
- const result = await handlePreviewLookup(client, space, { ref: refId, label });
54
+ const spaceId = getSpaceIdFromPath(layout.workspace);
55
+ const space = (spaceId && client.spaces.get(spaceId)) ?? getPersonalSpace(client);
56
+ if (!space) {
57
+ return;
58
+ }
59
+ const result = await handlePreviewLookup(client, space, { dxn, label });
47
60
  if (!result) {
48
61
  return;
49
62
  }
50
63
 
51
- await invokePromise(Common.LayoutOperation.UpdatePopover, {
64
+ const title = titleProp ?? Obj.getLabel(result.object);
65
+
66
+ await invokePromise(LayoutOperation.UpdatePopover, {
67
+ subjectRef: dxn,
52
68
  subject: result.object,
53
69
  state: true,
54
70
  variant: 'virtual',
@@ -69,9 +85,9 @@ export default Capability.makeModule(
69
85
  customEventOptions,
70
86
  );
71
87
  } else {
72
- log.warn('No default view found');
88
+ log.warn('no default view found');
73
89
  }
74
90
 
75
- return Capability.contributes(Common.Capability.Null, null, () => Effect.sync(() => cleanup?.()));
91
+ return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => cleanup?.()));
76
92
  }),
77
93
  );
@@ -0,0 +1,116 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+ import React from 'react';
7
+
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { Surface } from '@dxos/app-framework/ui';
10
+ import { AppSurface } from '@dxos/app-toolkit/ui';
11
+ import { Obj } from '@dxos/echo';
12
+ import { Card } from '@dxos/react-ui';
13
+ import { type ProjectionModel } from '@dxos/schema';
14
+ import { Organization, Person, Pipeline, Task } from '@dxos/types';
15
+
16
+ import { FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
17
+
18
+ export default Capability.makeModule(() =>
19
+ Effect.succeed(
20
+ Capability.contributes(Capabilities.ReactSurface, [
21
+ //
22
+ // Specific schema types.
23
+ // TODO(burdon): Create helpers and factor out.
24
+ //
25
+
26
+ Surface.create<{ subject: Person.Person }>({
27
+ id: 'schema-popover--contact',
28
+ role: 'card--content',
29
+ position: 'hoist',
30
+ filter: AppSurface.objectCard(Person.Person),
31
+ component: ({ data, role }) => {
32
+ return (
33
+ <>
34
+ <PersonCard role={role} subject={data.subject} />
35
+ <Surface.Surface role='related' data={data} limit={1} />
36
+ </>
37
+ );
38
+ },
39
+ }),
40
+ Surface.create({
41
+ id: 'schema-popover--organization',
42
+ role: 'card--content',
43
+ position: 'hoist',
44
+ filter: AppSurface.objectCard(Organization.Organization),
45
+ component: ({ data, role }) => {
46
+ return (
47
+ <>
48
+ <OrganizationCard role={role} subject={data.subject} />
49
+ <Surface.Surface role='related' data={data} limit={1} />
50
+ </>
51
+ );
52
+ },
53
+ }),
54
+ Surface.create({
55
+ id: 'schema-popover--project',
56
+ role: 'card--content',
57
+ position: 'hoist',
58
+ filter: AppSurface.objectCard(Pipeline.Pipeline),
59
+ component: ({ data, role }) => {
60
+ return <ProjectCard role={role} subject={data.subject} />;
61
+ },
62
+ }),
63
+ Surface.create({
64
+ id: 'schema-popover--task',
65
+ role: 'card--content',
66
+ position: 'hoist',
67
+ filter: AppSurface.objectCard(Task.Task),
68
+ component: ({ data, role }) => {
69
+ return <TaskCard role={role} subject={data.subject} />;
70
+ },
71
+ }),
72
+
73
+ //
74
+ // Fallback for any object.
75
+ //
76
+
77
+ Surface.create({
78
+ id: 'fallback-popover',
79
+ role: 'card--content',
80
+ position: 'fallback',
81
+ filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
82
+ component: ({ data, role }) => {
83
+ return <FormCard role={role} subject={data.subject} projection={data.projection} />;
84
+ },
85
+ }),
86
+
87
+ Surface.create({
88
+ id: 'fallback-json',
89
+ role: 'card--content',
90
+ position: 'fallback',
91
+ filter: (data): data is Record<string, unknown> => true,
92
+ component: ({ data }) => {
93
+ return <JsonCard data={data} />;
94
+ },
95
+ }),
96
+
97
+ Surface.create({
98
+ id: 'section',
99
+ role: ['section'],
100
+ position: 'fallback',
101
+ filter: AppSurface.anyObjectSection(),
102
+ component: ({ data }) => {
103
+ return (
104
+ <div role='none' className='flex w-full justify-center'>
105
+ <div role='none' className='pt-2 pb-2 dx-card-min-width dx-card-max-width'>
106
+ <Card.Root>
107
+ <Surface.Surface role='card--content' data={data} limit={1} />
108
+ </Card.Root>
109
+ </div>
110
+ </div>
111
+ );
112
+ },
113
+ }),
114
+ ]),
115
+ ),
116
+ );
@@ -2,34 +2,22 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React, { useCallback } from 'react';
5
+ import React, { useCallback, useMemo } from 'react';
6
6
 
7
- import { Common } from '@dxos/app-framework';
8
- import { type SurfaceComponentProps, useOperationInvoker } from '@dxos/app-framework/react';
7
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
9
8
  import { Obj } from '@dxos/echo';
10
9
  import { type JsonPath, splitJsonPath } from '@dxos/effect';
11
- import { IconButton, useTranslation } from '@dxos/react-ui';
10
+ import { Card, useTranslation } from '@dxos/react-ui';
12
11
  import { Form, omitId } from '@dxos/react-ui-form';
13
- import { Card } from '@dxos/react-ui-mosaic';
14
12
  import { type ProjectionModel } from '@dxos/schema';
15
13
  import { descriptionMessage, mx } from '@dxos/ui-theme';
16
14
 
17
- import { meta } from '../meta';
15
+ import { meta } from '#meta';
18
16
 
19
- export const FormCard = ({ subject, projection }: SurfaceComponentProps & { projection?: ProjectionModel }) => {
20
- const { invokePromise } = useOperationInvoker();
21
- const schema = Obj.getSchema(subject);
17
+ export const FormCard = ({ subject, projection }: AppSurface.ObjectCardProps & { projection?: ProjectionModel }) => {
22
18
  const { t } = useTranslation(meta.id);
23
-
24
- const handleNavigate = useCallback(async () => {
25
- await invokePromise(Common.LayoutOperation.UpdatePopover, { state: false, anchorId: '' });
26
- await invokePromise(Common.LayoutOperation.Open, { subject: [Obj.getDXN(subject).toString()] });
27
- }, [invokePromise, subject]);
28
-
29
- if (!schema) {
30
- // TODO(burdon): Use Alert.
31
- return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
32
- }
19
+ const echoSchema = Obj.getSchema(subject);
20
+ const schema = useMemo(() => echoSchema && omitId(echoSchema), [echoSchema]);
33
21
 
34
22
  const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
35
23
  const paths = Object.keys(changed).filter((path) => changed[path]);
@@ -42,22 +30,19 @@ export const FormCard = ({ subject, projection }: SurfaceComponentProps & { proj
42
30
  });
43
31
  }, []);
44
32
 
45
- const label = Obj.getLabel(subject) ?? Obj.getTypename(subject) ?? t('unable to create preview message');
33
+ if (!schema) {
34
+ return <p className={mx(descriptionMessage)}>{t('unable-to-create-preview.message')}</p>;
35
+ }
46
36
 
47
37
  return (
48
- <Card.Root id={subject.id}>
49
- <Card.Heading classNames='flex items-center'>
50
- {label}
51
- <span className='grow' />
52
- <IconButton iconOnly icon='ph--arrow-right--regular' label={t('open object label')} onClick={handleNavigate} />
53
- </Card.Heading>
54
- <Form.Root schema={omitId(schema)} projection={projection} values={subject} autoSave onSave={handleSave}>
38
+ <Card.Content>
39
+ <Form.Root schema={schema} projection={projection} values={subject} autoSave onSave={handleSave}>
55
40
  <Form.Viewport>
56
41
  <Form.Content>
57
42
  <Form.FieldSet />
58
43
  </Form.Content>
59
44
  </Form.Viewport>
60
45
  </Form.Root>
61
- </Card.Root>
46
+ </Card.Content>
62
47
  );
63
48
  };
@@ -0,0 +1,16 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { Card } from '@dxos/react-ui';
8
+ import { Json } from '@dxos/react-ui-syntax-highlighter';
9
+
10
+ export const JsonCard = ({ data }: { data: unknown }) => {
11
+ return (
12
+ <Card.Content>
13
+ <Json.Data data={data} />
14
+ </Card.Content>
15
+ );
16
+ };
@@ -4,12 +4,12 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { type SurfaceComponentProps } from '@dxos/app-framework/react';
8
- import { Card } from '@dxos/react-ui-mosaic';
7
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
8
+ import { Card } from '@dxos/react-ui';
9
9
  import { type Organization } from '@dxos/types';
10
10
 
11
- export const OrganizationCard = ({ subject }: SurfaceComponentProps<Organization.Organization>) => {
12
- const { image, description, website } = subject;
11
+ export const OrganizationCard = ({ subject }: AppSurface.ObjectCardProps<Organization.Organization>) => {
12
+ const { name, image, description, website } = subject;
13
13
 
14
14
  return (
15
15
  <Card.Content>
@@ -2,25 +2,47 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React from 'react';
5
+ import * as Effect from 'effect/Effect';
6
+ import React, { useCallback } from 'react';
6
7
 
7
- import { type SurfaceComponentProps } from '@dxos/app-framework/react';
8
+ import { useOperationInvoker } from '@dxos/app-framework/ui';
9
+ import { LayoutOperation, getObjectPathFromObject, getSpacePath } from '@dxos/app-toolkit';
10
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
11
+ import { Obj } from '@dxos/echo';
12
+ import { runAndForwardErrors } from '@dxos/effect';
8
13
  import { Avatar } from '@dxos/react-ui';
9
- import { Card } from '@dxos/react-ui-mosaic';
14
+ import { Card } from '@dxos/react-ui';
10
15
  import { type Person } from '@dxos/types';
11
16
 
12
- export const PersonCard = ({ subject }: SurfaceComponentProps<Person.Person>) => {
17
+ export const PersonCard = ({ subject }: AppSurface.ObjectCardProps<Person.Person>) => {
18
+ const { invoke } = useOperationInvoker();
13
19
  const { image, organization: { target: organization } = {}, emails = [] } = subject;
14
20
 
21
+ const handleOrganizationClick = useCallback(() => {
22
+ if (!organization) {
23
+ return;
24
+ }
25
+
26
+ return Effect.gen(function* () {
27
+ const organizationPath = getObjectPathFromObject(organization);
28
+ const db = Obj.getDatabase(organization);
29
+ yield* invoke(LayoutOperation.UpdatePopover, { state: false, anchorId: '' });
30
+ yield* invoke(LayoutOperation.Open, {
31
+ subject: [organizationPath],
32
+ workspace: db ? getSpacePath(db.spaceId) : undefined,
33
+ });
34
+ }).pipe(runAndForwardErrors);
35
+ }, [invoke, organization]);
36
+
15
37
  return (
16
- <Avatar.Root>
17
- <Card.Content>
38
+ <Card.Content>
39
+ <Avatar.Root>
18
40
  {image && (
19
- <Card.Row className='plb-1'>
41
+ <Card.Row className='py-1'>
20
42
  <Avatar.Content
21
43
  imgSrc={image}
22
44
  icon='ph--user--regular'
23
- size={16}
45
+ size={20}
24
46
  classNames={!image && 'opacity-50'}
25
47
  hue='neutral'
26
48
  variant='square'
@@ -28,20 +50,16 @@ export const PersonCard = ({ subject }: SurfaceComponentProps<Person.Person>) =>
28
50
  </Card.Row>
29
51
  )}
30
52
  {organization?.name && (
31
- <Card.Action
32
- icon='ph--buildings--regular'
33
- label={organization.name}
34
- // onClick={onSelect ? () => onSelect(organization) : undefined}
35
- />
53
+ <Card.Action icon='ph--buildings--regular' label={organization.name} onClick={handleOrganizationClick} />
36
54
  )}
37
55
  {emails.map(({ value }) => (
38
56
  <Card.Row key={value} icon='ph--at--regular'>
39
- <Card.Text truncate className='text-primaryText'>
57
+ <Card.Text truncate className='text-primary-text'>
40
58
  {value}
41
59
  </Card.Text>
42
60
  </Card.Row>
43
61
  ))}
44
- </Card.Content>
45
- </Avatar.Root>
62
+ </Avatar.Root>
63
+ </Card.Content>
46
64
  );
47
65
  };
@@ -4,13 +4,13 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { type SurfaceComponentProps } from '@dxos/app-framework/react';
7
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
8
8
  import { Obj } from '@dxos/echo';
9
- import { Card } from '@dxos/react-ui-mosaic';
10
- import { type Project } from '@dxos/types';
9
+ import { Card } from '@dxos/react-ui';
10
+ import { type Pipeline } from '@dxos/types';
11
11
 
12
- export const ProjectCard = ({ subject }: SurfaceComponentProps<Project.Project>) => {
13
- const { name, image, description } = subject;
12
+ export const ProjectCard = ({ subject }: AppSurface.ObjectCardProps<Pipeline.Pipeline>) => {
13
+ const { image, description } = subject;
14
14
 
15
15
  return (
16
16
  <Card.Content>
@@ -5,36 +5,40 @@
5
5
  import * as SchemaAST from 'effect/SchemaAST';
6
6
  import React from 'react';
7
7
 
8
- import { type SurfaceComponentProps } from '@dxos/app-framework/react';
8
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
9
9
  import { type PropertyMetaAnnotation, PropertyMetaAnnotationId } from '@dxos/echo/internal';
10
- import { Card } from '@dxos/react-ui-mosaic';
10
+ import { Card } from '@dxos/react-ui';
11
11
  import { Task } from '@dxos/types';
12
12
 
13
+ export const TaskCard = ({ subject }: AppSurface.ObjectCardProps<Task.Task>) => {
14
+ const { title, status } = subject;
15
+ const statusOption = getActiveStatusOption(status);
16
+
17
+ return (
18
+ <Card.Content>
19
+ <Card.Row>
20
+ {statusOption && (
21
+ <div>
22
+ <span className='dx-tag' data-hue={statusOption.color}>
23
+ {statusOption.title}
24
+ </span>
25
+ </div>
26
+ )}
27
+ </Card.Row>
28
+ </Card.Content>
29
+ );
30
+ };
31
+
13
32
  // TODO(thure): Should this move upstream as a helper? Is there an easier way to get options?
14
33
  const getActiveStatusOption = (status?: string) => {
15
34
  const properties = SchemaAST.getPropertySignatures(Task.Task.ast);
16
35
  const statusProperty = properties.find((p) => p.name === 'status');
36
+ // TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
17
37
  const statusMeta = SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(
18
- // TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
19
38
  (statusProperty!.type as any).types[0],
20
39
  );
21
- const options = // TODO(thure): Typescript asserts `statusMeta` doesn’t have `.value`, but in runtime it does.
22
- (statusMeta as any).value.singleSelect.options as { id: string; title: string; color: string }[];
23
- return options.find(({ id }) => id === status);
24
- };
25
40
 
26
- export const TaskCard = ({ subject }: SurfaceComponentProps<Task.Task>) => {
27
- const { title, status } = subject;
28
- const statusOption = getActiveStatusOption(status);
29
-
30
- return (
31
- <Card.Content>
32
- <Card.Heading classNames='min-is-0 flex-1 truncate'>{title}</Card.Heading>
33
- {statusOption && (
34
- <span className='dx-tag' data-hue={statusOption.color}>
35
- {statusOption.title}
36
- </span>
37
- )}
38
- </Card.Content>
39
- );
41
+ // TODO(thure): Typescript asserts `statusMeta` doesn’t have `.value`, but in runtime it does.
42
+ const options = (statusMeta as any).value.singleSelect.options as { id: string; title: string; color: string }[];
43
+ return options.find(({ id }) => id === status);
40
44
  };
@@ -3,6 +3,7 @@
3
3
  //
4
4
 
5
5
  export * from './FormCard';
6
+ export * from './JsonCard';
6
7
  export * from './OrganizationCard';
7
8
  export * from './PersonCard';
8
9
  export * from './ProjectCard';
package/src/meta.ts CHANGED
@@ -6,7 +6,7 @@ import { type Plugin } from '@dxos/app-framework';
6
6
  import { trim } from '@dxos/util';
7
7
 
8
8
  export const meta: Plugin.Meta = {
9
- id: 'dxos.org/plugin/preview',
9
+ id: 'org.dxos.plugin.preview',
10
10
  name: 'Preview',
11
11
  description: trim`
12
12
  Rich preview panel for viewing object content without opening full editors.