@dxos/plugin-preview 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef

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 (90) hide show
  1. package/dist/lib/browser/index.mjs +16 -47
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/translations.mjs +21 -0
  5. package/dist/lib/browser/translations.mjs.map +7 -0
  6. package/dist/lib/node-esm/index.mjs +16 -46
  7. package/dist/lib/node-esm/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/meta.json +1 -1
  9. package/dist/lib/node-esm/translations.mjs +23 -0
  10. package/dist/lib/node-esm/translations.mjs.map +7 -0
  11. package/dist/types/src/PreviewPlugin.d.ts +1 -0
  12. package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
  13. package/dist/types/src/PreviewPlugin.node.d.ts +4 -0
  14. package/dist/types/src/PreviewPlugin.node.d.ts.map +1 -0
  15. package/dist/types/src/PreviewPlugin.test.d.ts +2 -0
  16. package/dist/types/src/PreviewPlugin.test.d.ts.map +1 -0
  17. package/dist/types/src/capabilities/index.d.ts +3 -2
  18. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  19. package/dist/types/src/capabilities/preview-popover.d.ts +5 -0
  20. package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -0
  21. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  22. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  23. package/dist/types/src/cards/ExpandoCard.d.ts +4 -0
  24. package/dist/types/src/cards/ExpandoCard.d.ts.map +1 -0
  25. package/dist/types/src/cards/FormCard.d.ts +2 -2
  26. package/dist/types/src/cards/FormCard.d.ts.map +1 -1
  27. package/dist/types/src/cards/JsonCard.d.ts +5 -0
  28. package/dist/types/src/cards/JsonCard.d.ts.map +1 -0
  29. package/dist/types/src/cards/OrganizationCard.d.ts +2 -2
  30. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
  31. package/dist/types/src/cards/PersonCard.d.ts +2 -2
  32. package/dist/types/src/cards/PersonCard.d.ts.map +1 -1
  33. package/dist/types/src/cards/ProjectCard.d.ts +3 -3
  34. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
  35. package/dist/types/src/cards/TaskCard.d.ts +2 -2
  36. package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
  37. package/dist/types/src/cards/index.d.ts +2 -0
  38. package/dist/types/src/cards/index.d.ts.map +1 -1
  39. package/dist/types/src/index.d.ts +2 -1
  40. package/dist/types/src/index.d.ts.map +1 -1
  41. package/dist/types/src/stories/Card.stories.d.ts +19 -12
  42. package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
  43. package/dist/types/src/stories/testing.d.ts +6 -4
  44. package/dist/types/src/stories/testing.d.ts.map +1 -1
  45. package/dist/types/src/translations.d.ts +8 -9
  46. package/dist/types/src/translations.d.ts.map +1 -1
  47. package/dist/types/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +53 -39
  49. package/src/PreviewPlugin.node.ts +16 -0
  50. package/src/PreviewPlugin.test.ts +25 -0
  51. package/src/PreviewPlugin.tsx +11 -8
  52. package/src/capabilities/index.ts +4 -2
  53. package/src/capabilities/{preview-popover/preview-popover.ts → preview-popover.ts} +35 -16
  54. package/src/capabilities/react-surface.tsx +118 -0
  55. package/src/cards/ExpandoCard.tsx +76 -0
  56. package/src/cards/FormCard.tsx +14 -29
  57. package/src/cards/JsonCard.tsx +19 -0
  58. package/src/cards/OrganizationCard.tsx +4 -4
  59. package/src/cards/PersonCard.tsx +34 -16
  60. package/src/cards/ProjectCard.tsx +5 -5
  61. package/src/cards/TaskCard.tsx +16 -12
  62. package/src/cards/index.ts +2 -0
  63. package/src/index.ts +6 -2
  64. package/src/meta.ts +1 -1
  65. package/src/stories/Card.stories.tsx +64 -11
  66. package/src/stories/testing.tsx +48 -31
  67. package/src/translations.ts +8 -8
  68. package/dist/lib/browser/chunk-XLN6KTHK.mjs +0 -17
  69. package/dist/lib/browser/chunk-XLN6KTHK.mjs.map +0 -7
  70. package/dist/lib/browser/preview-popover-Y67LE6TV.mjs +0 -78
  71. package/dist/lib/browser/preview-popover-Y67LE6TV.mjs.map +0 -7
  72. package/dist/lib/browser/react-surface-YCDD5VZC.mjs +0 -263
  73. package/dist/lib/browser/react-surface-YCDD5VZC.mjs.map +0 -7
  74. package/dist/lib/node-esm/chunk-2G4FUGDA.mjs +0 -19
  75. package/dist/lib/node-esm/chunk-2G4FUGDA.mjs.map +0 -7
  76. package/dist/lib/node-esm/preview-popover-BGV2P6UX.mjs +0 -80
  77. package/dist/lib/node-esm/preview-popover-BGV2P6UX.mjs.map +0 -7
  78. package/dist/lib/node-esm/react-surface-MYZZR7AQ.mjs +0 -264
  79. package/dist/lib/node-esm/react-surface-MYZZR7AQ.mjs.map +0 -7
  80. package/dist/types/src/capabilities/preview-popover/index.d.ts +0 -3
  81. package/dist/types/src/capabilities/preview-popover/index.d.ts.map +0 -1
  82. package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts +0 -5
  83. package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts.map +0 -1
  84. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  85. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  86. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  87. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  88. package/src/capabilities/preview-popover/index.ts +0 -7
  89. package/src/capabilities/react-surface/index.ts +0 -7
  90. 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.9735255",
3
+ "version": "0.8.4-main.abd8ff62ef",
4
4
  "description": "Preview plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -12,63 +12,77 @@
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
+ "#plugin": {
19
+ "browser": "./src/PreviewPlugin.tsx",
20
+ "node": "./src/PreviewPlugin.node.ts",
21
+ "default": "./src/PreviewPlugin.tsx"
22
+ },
23
+ "#translations": "./src/translations.ts"
24
+ },
15
25
  "exports": {
16
26
  ".": {
17
27
  "source": "./src/index.ts",
18
28
  "types": "./dist/types/src/index.d.ts",
19
29
  "browser": "./dist/lib/browser/index.mjs"
30
+ },
31
+ "./translations": {
32
+ "source": "./src/translations.ts",
33
+ "types": "./dist/types/src/translations.d.ts",
34
+ "browser": "./dist/lib/browser/translations.mjs",
35
+ "node": "./dist/lib/node-esm/translations.mjs"
20
36
  }
21
37
  },
22
38
  "types": "dist/types/src/index.d.ts",
23
- "typesVersions": {
24
- "*": {}
25
- },
26
39
  "files": [
27
40
  "dist",
28
41
  "src"
29
42
  ],
30
43
  "dependencies": {
31
- "@effect-atom/atom-react": "^0.4.6",
32
- "@dxos/app-graph": "0.8.4-main.9735255",
33
- "@dxos/app-framework": "0.8.4-main.9735255",
34
- "@dxos/async": "0.8.4-main.9735255",
35
- "@dxos/echo": "0.8.4-main.9735255",
36
- "@dxos/client": "0.8.4-main.9735255",
37
- "@dxos/effect": "0.8.4-main.9735255",
38
- "@dxos/lit-ui": "0.8.4-main.9735255",
39
- "@dxos/keys": "0.8.4-main.9735255",
40
- "@dxos/log": "0.8.4-main.9735255",
41
- "@dxos/operation": "0.8.4-main.9735255",
42
- "@dxos/plugin-attention": "0.8.4-main.9735255",
43
- "@dxos/plugin-client": "0.8.4-main.9735255",
44
- "@dxos/plugin-space": "0.8.4-main.9735255",
45
- "@dxos/plugin-deck": "0.8.4-main.9735255",
46
- "@dxos/react-client": "0.8.4-main.9735255",
47
- "@dxos/react-ui": "0.8.4-main.9735255",
48
- "@dxos/react-ui-form": "0.8.4-main.9735255",
49
- "@dxos/react-ui-editor": "0.8.4-main.9735255",
50
- "@dxos/react-ui-menu": "0.8.4-main.9735255",
51
- "@dxos/react-ui-table": "0.8.4-main.9735255",
52
- "@dxos/react-ui-mosaic": "0.8.4-main.9735255",
53
- "@dxos/schema": "0.8.4-main.9735255",
54
- "@dxos/types": "0.8.4-main.9735255",
55
- "@dxos/ui-theme": "0.8.4-main.9735255",
56
- "@dxos/util": "0.8.4-main.9735255",
57
- "@dxos/ui-editor": "0.8.4-main.9735255"
44
+ "@effect-atom/atom-react": "^0.5.0",
45
+ "@dxos/app-framework": "0.8.4-main.abd8ff62ef",
46
+ "@dxos/app-graph": "0.8.4-main.abd8ff62ef",
47
+ "@dxos/app-toolkit": "0.8.4-main.abd8ff62ef",
48
+ "@dxos/async": "0.8.4-main.abd8ff62ef",
49
+ "@dxos/echo": "0.8.4-main.abd8ff62ef",
50
+ "@dxos/effect": "0.8.4-main.abd8ff62ef",
51
+ "@dxos/keys": "0.8.4-main.abd8ff62ef",
52
+ "@dxos/client": "0.8.4-main.abd8ff62ef",
53
+ "@dxos/lit-ui": "0.8.4-main.abd8ff62ef",
54
+ "@dxos/operation": "0.8.4-main.abd8ff62ef",
55
+ "@dxos/log": "0.8.4-main.abd8ff62ef",
56
+ "@dxos/plugin-attention": "0.8.4-main.abd8ff62ef",
57
+ "@dxos/plugin-client": "0.8.4-main.abd8ff62ef",
58
+ "@dxos/plugin-deck": "0.8.4-main.abd8ff62ef",
59
+ "@dxos/react-client": "0.8.4-main.abd8ff62ef",
60
+ "@dxos/react-ui": "0.8.4-main.abd8ff62ef",
61
+ "@dxos/react-ui-editor": "0.8.4-main.abd8ff62ef",
62
+ "@dxos/react-ui-mosaic": "0.8.4-main.abd8ff62ef",
63
+ "@dxos/react-ui-menu": "0.8.4-main.abd8ff62ef",
64
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.abd8ff62ef",
65
+ "@dxos/schema": "0.8.4-main.abd8ff62ef",
66
+ "@dxos/react-ui-table": "0.8.4-main.abd8ff62ef",
67
+ "@dxos/types": "0.8.4-main.abd8ff62ef",
68
+ "@dxos/util": "0.8.4-main.abd8ff62ef",
69
+ "@dxos/ui-theme": "0.8.4-main.abd8ff62ef",
70
+ "@dxos/ui-editor": "0.8.4-main.abd8ff62ef",
71
+ "@dxos/react-ui-form": "0.8.4-main.abd8ff62ef"
58
72
  },
59
73
  "devDependencies": {
60
- "effect": "3.19.11",
74
+ "effect": "3.20.0",
61
75
  "react": "~19.2.3",
62
76
  "react-dom": "~19.2.3",
63
- "vite": "7.1.9",
64
- "@dxos/plugin-testing": "0.8.4-main.9735255",
65
- "@dxos/echo-db": "0.8.4-main.9735255",
66
- "@dxos/random": "0.8.4-main.9735255",
67
- "@dxos/storybook-utils": "0.8.4-main.9735255",
68
- "@dxos/react-ui-components": "0.8.4-main.9735255"
77
+ "vite": "^8.0.10",
78
+ "@dxos/plugin-testing": "0.8.4-main.abd8ff62ef",
79
+ "@dxos/echo-db": "0.8.4-main.abd8ff62ef",
80
+ "@dxos/random": "0.8.4-main.abd8ff62ef",
81
+ "@dxos/react-ui-components": "0.8.4-main.abd8ff62ef",
82
+ "@dxos/storybook-utils": "0.8.4-main.abd8ff62ef"
69
83
  },
70
84
  "peerDependencies": {
71
- "effect": "3.19.11",
85
+ "effect": "3.20.0",
72
86
  "react": "~19.2.3",
73
87
  "react-dom": "~19.2.3"
74
88
  },
@@ -0,0 +1,16 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
7
+ import { Organization, Person } from '@dxos/types';
8
+
9
+ import { meta } from '#meta';
10
+
11
+ export const PreviewPlugin = Plugin.define(meta).pipe(
12
+ AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization] }),
13
+ Plugin.make,
14
+ );
15
+
16
+ export default PreviewPlugin;
@@ -0,0 +1,25 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import { describe, test } from 'vitest';
6
+
7
+ import { ClientPlugin } from '@dxos/plugin-client';
8
+ import { createComposerTestApp } from '@dxos/plugin-testing/harness';
9
+
10
+ import { PreviewPlugin } from '#plugin';
11
+
12
+ import { meta } from './meta';
13
+
14
+ const moduleId = (name: string) => `${meta.id}.module.${name}`;
15
+
16
+ describe('PreviewPlugin', () => {
17
+ test('modules activate on the expected events', async ({ expect }) => {
18
+ await using harness = await createComposerTestApp({
19
+ plugins: [ClientPlugin({}), PreviewPlugin()],
20
+ });
21
+
22
+ // After autoStart: schema auto-cascades from ClientPlugin.
23
+ expect(harness.manager.getActive()).toContain(moduleId('schema'));
24
+ });
25
+ });
@@ -2,21 +2,24 @@
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';
10
- import { translations } from './translations';
9
+ import { PreviewPopover, ReactSurface } from '#capabilities';
10
+ import { meta } from '#meta';
11
+ import { translations } from '#translations';
11
12
 
12
13
  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 }),
14
+ AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization] }),
15
+ AppPlugin.addSurfaceModule({ activate: ReactSurface }),
16
+ AppPlugin.addTranslationsModule({ translations }),
16
17
  Plugin.addModule({
17
18
  id: 'preview-popover',
18
- activatesOn: Common.ActivationEvent.Startup,
19
+ activatesOn: ActivationEvents.Startup,
19
20
  activate: PreviewPopover,
20
21
  }),
21
22
  Plugin.make,
22
23
  );
24
+
25
+ export default PreviewPlugin;
@@ -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,37 @@ 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);
43
- 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 });
51
+ const registry = capabilities.get(Capabilities.AtomRegistry);
52
+ // Layout is optional: in standalone harnesses (Storybook, tests) no plugin contributes
53
+ // `AppCapabilities.Layout`, and `getAll` returns an empty array. Reading `registry.get(undefined)`
54
+ // would crash inside Atom's identity check (`'~atom/Serializable' in undefined`). When layout
55
+ // isn't available, fall through to the personal-space default.
56
+ const [layoutAtom] = capabilities.getAll(AppCapabilities.Layout);
57
+ const spaceId = layoutAtom && getSpaceIdFromPath(registry.get(layoutAtom).workspace);
58
+ const space = (spaceId && client.spaces.get(spaceId)) ?? getPersonalSpace(client);
59
+ if (!space) {
60
+ return;
61
+ }
62
+ const result = await handlePreviewLookup(client, space, { dxn, label });
47
63
  if (!result) {
48
64
  return;
49
65
  }
50
66
 
51
- await invokePromise(Common.LayoutOperation.UpdatePopover, {
67
+ const title = titleProp ?? Obj.getLabel(result.object);
68
+
69
+ await invokePromise(LayoutOperation.UpdatePopover, {
70
+ subjectRef: dxn,
52
71
  subject: result.object,
53
72
  state: true,
54
73
  variant: 'virtual',
@@ -69,9 +88,9 @@ export default Capability.makeModule(
69
88
  customEventOptions,
70
89
  );
71
90
  } else {
72
- log.warn('No default view found');
91
+ log.warn('no default view found');
73
92
  }
74
93
 
75
- return Capability.contributes(Common.Capability.Null, null, () => Effect.sync(() => cleanup?.()));
94
+ return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => cleanup?.()));
76
95
  }),
77
96
  );
@@ -0,0 +1,118 @@
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 { Expando, type ProjectionModel } from '@dxos/schema';
14
+ import { Organization, Person, Pipeline, Task } from '@dxos/types';
15
+
16
+ import { ExpandoCard, 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
+ position: 'hoist',
29
+ filter: AppSurface.object(AppSurface.Card, Person.Person),
30
+ component: ({ data, role }) => {
31
+ return (
32
+ <>
33
+ <PersonCard role={role} subject={data.subject} />
34
+ <Surface.Surface type={AppSurface.Related} data={data} limit={1} />
35
+ </>
36
+ );
37
+ },
38
+ }),
39
+ Surface.create({
40
+ id: 'schema-popover--organization',
41
+ position: 'hoist',
42
+ filter: AppSurface.object(AppSurface.Card, Organization.Organization),
43
+ component: ({ data, role }) => {
44
+ return (
45
+ <>
46
+ <OrganizationCard role={role} subject={data.subject} />
47
+ <Surface.Surface type={AppSurface.Related} data={data} limit={1} />
48
+ </>
49
+ );
50
+ },
51
+ }),
52
+ Surface.create({
53
+ id: 'schema-popover--project',
54
+ position: 'hoist',
55
+ filter: AppSurface.object(AppSurface.Card, Pipeline.Pipeline),
56
+ component: ({ data, role }) => {
57
+ return <ProjectCard role={role} subject={data.subject} />;
58
+ },
59
+ }),
60
+ Surface.create({
61
+ id: 'schema-popover--task',
62
+ position: 'hoist',
63
+ filter: AppSurface.object(AppSurface.Card, Task.Task),
64
+ component: ({ data, role }) => {
65
+ return <TaskCard role={role} subject={data.subject} />;
66
+ },
67
+ }),
68
+ Surface.create<AppSurface.ObjectCardData<Expando.Expando>>({
69
+ id: 'schema-popover--expando',
70
+ filter: AppSurface.object(AppSurface.Card, Expando.Expando),
71
+ component: ({ data, role }) => {
72
+ return <ExpandoCard role={role} subject={data.subject} ignorePaths={data.ignorePaths} />;
73
+ },
74
+ }),
75
+
76
+ //
77
+ // Fallback for any object.
78
+ //
79
+
80
+ Surface.create({
81
+ id: 'fallback-popover',
82
+ role: 'card--content',
83
+ position: 'fallback',
84
+ filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
85
+ component: ({ data, role }) => {
86
+ return <FormCard role={role} subject={data.subject} projection={data.projection} />;
87
+ },
88
+ }),
89
+
90
+ Surface.create({
91
+ id: 'fallback-json',
92
+ role: 'card--content',
93
+ position: 'fallback',
94
+ filter: (data): data is Record<string, unknown> => true,
95
+ component: ({ data }) => {
96
+ return <JsonCard data={data} />;
97
+ },
98
+ }),
99
+
100
+ Surface.create({
101
+ id: 'section',
102
+ position: 'fallback',
103
+ filter: AppSurface.subject(AppSurface.Section, Obj.isObject),
104
+ component: ({ data }) => {
105
+ return (
106
+ <div role='none' className='flex w-full justify-center'>
107
+ <div role='none' className='py-2 dx-card-min-width dx-card-max-width'>
108
+ <Card.Root>
109
+ <Surface.Surface type={AppSurface.Card} data={data} limit={1} />
110
+ </Card.Root>
111
+ </div>
112
+ </div>
113
+ );
114
+ },
115
+ }),
116
+ ]),
117
+ ),
118
+ );
@@ -0,0 +1,76 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+ import React, { useCallback, useMemo } from 'react';
7
+
8
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
9
+ import { Obj } from '@dxos/echo';
10
+ import { type JsonPath, splitJsonPath } from '@dxos/effect';
11
+ import { Card } from '@dxos/react-ui';
12
+ import { Form } from '@dxos/react-ui-form';
13
+
14
+ const schemaForValue = (value: unknown): Schema.Schema.AnyNoContext | undefined => {
15
+ switch (typeof value) {
16
+ case 'string':
17
+ return Schema.String;
18
+ case 'number':
19
+ return Schema.Number;
20
+ case 'boolean':
21
+ return Schema.Boolean;
22
+ default:
23
+ return undefined;
24
+ }
25
+ };
26
+
27
+ /**
28
+ * Reserved keys: `id`, plus any `~`-prefixed key (ECHO uses `~`-prefixed
29
+ * string keys to brand entity instances and schemas — KindId,
30
+ * SchemaKindId, SnapshotKindId, etc. — and the `~` namespace is reserved
31
+ * for that purpose). They show up in `Object.keys` but aren't user data.
32
+ */
33
+ const isInternalKey = (key: string) => key === 'id' || key.startsWith('~');
34
+
35
+ export const ExpandoCard = ({ subject, ignorePaths }: AppSurface.ObjectCardProps) => {
36
+ const schema = useMemo(() => {
37
+ const ignored = new Set(ignorePaths ?? []);
38
+ const fields: Record<string, Schema.Schema.AnyNoContext> = {};
39
+ for (const key of Object.keys(subject)) {
40
+ if (isInternalKey(key) || ignored.has(key)) {
41
+ continue;
42
+ }
43
+ const fieldSchema = schemaForValue((subject as any)[key]);
44
+ if (fieldSchema) {
45
+ fields[key] = fieldSchema;
46
+ }
47
+ }
48
+ return Schema.Struct(fields);
49
+ }, [subject, ignorePaths]);
50
+
51
+ const handleSave = useCallback(
52
+ (values: any, { changed }: { changed: Record<string, boolean> }) => {
53
+ const paths = Object.keys(changed).filter((path) => changed[path]);
54
+ Obj.update(subject, () => {
55
+ for (const path of paths) {
56
+ const value = values[path];
57
+ const parts = splitJsonPath(path as JsonPath);
58
+ Obj.setValue(subject, parts, value);
59
+ }
60
+ });
61
+ },
62
+ [subject],
63
+ );
64
+
65
+ return (
66
+ <Card.Content>
67
+ <Form.Root schema={schema} values={subject} autoSave onSave={handleSave}>
68
+ <Form.Viewport>
69
+ <Form.Content>
70
+ <Form.FieldSet />
71
+ </Form.Content>
72
+ </Form.Viewport>
73
+ </Form.Root>
74
+ </Card.Content>
75
+ );
76
+ };
@@ -2,38 +2,26 @@
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]);
36
- Obj.change(subject, () => {
24
+ Obj.update(subject, () => {
37
25
  for (const path of paths) {
38
26
  const value = values[path];
39
27
  const parts = splitJsonPath(path as JsonPath);
@@ -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,19 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { Card } from '@dxos/react-ui';
8
+ import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
9
+
10
+ export const JsonCard = ({ data }: { data: unknown }) => {
11
+ return (
12
+ <Card.Content>
13
+ <span />
14
+ {/* TODO(wittjosiah): Span whole row. */}
15
+ <JsonHighlighter data={data} />
16
+ <span />
17
+ </Card.Content>
18
+ );
19
+ };
@@ -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>