@dxos/plugin-preview 0.8.4-main.406dc2a → 0.8.4-main.422d1c7879

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 (89) hide show
  1. package/dist/lib/browser/index.mjs +41 -46
  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 +42 -46
  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 +2 -1
  8. package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
  9. package/dist/types/src/capabilities/index.d.ts +3 -2
  10. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  11. package/dist/types/src/capabilities/preview-popover.d.ts +3 -2
  12. package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -1
  13. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  14. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  15. package/dist/types/src/cards/FormCard.d.ts +7 -0
  16. package/dist/types/src/cards/FormCard.d.ts.map +1 -0
  17. package/dist/types/src/cards/JsonCard.d.ts +5 -0
  18. package/dist/types/src/cards/JsonCard.d.ts.map +1 -0
  19. package/dist/types/src/cards/OrganizationCard.d.ts +5 -0
  20. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -0
  21. package/dist/types/src/cards/PersonCard.d.ts +5 -0
  22. package/dist/types/src/cards/PersonCard.d.ts.map +1 -0
  23. package/dist/types/src/cards/ProjectCard.d.ts +5 -0
  24. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -0
  25. package/dist/types/src/cards/TaskCard.d.ts +5 -0
  26. package/dist/types/src/cards/TaskCard.d.ts.map +1 -0
  27. package/dist/types/src/cards/index.d.ts +7 -0
  28. package/dist/types/src/cards/index.d.ts.map +1 -0
  29. package/dist/types/src/index.d.ts +0 -1
  30. package/dist/types/src/index.d.ts.map +1 -1
  31. package/dist/types/src/meta.d.ts +2 -2
  32. package/dist/types/src/meta.d.ts.map +1 -1
  33. package/dist/types/src/stories/Card.stories.d.ts +19 -13
  34. package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
  35. package/dist/types/src/stories/testing.d.ts +14 -12
  36. package/dist/types/src/stories/testing.d.ts.map +1 -1
  37. package/dist/types/src/translations.d.ts +8 -8
  38. package/dist/types/src/translations.d.ts.map +1 -1
  39. package/dist/types/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +49 -37
  41. package/src/PreviewPlugin.tsx +15 -25
  42. package/src/capabilities/index.ts +3 -3
  43. package/src/capabilities/preview-popover.ts +69 -42
  44. package/src/capabilities/react-surface.tsx +98 -121
  45. package/src/cards/FormCard.tsx +48 -0
  46. package/src/cards/JsonCard.tsx +16 -0
  47. package/src/cards/OrganizationCard.tsx +29 -0
  48. package/src/cards/PersonCard.tsx +65 -0
  49. package/src/cards/ProjectCard.tsx +22 -0
  50. package/src/cards/TaskCard.tsx +44 -0
  51. package/src/cards/index.ts +10 -0
  52. package/src/index.ts +0 -1
  53. package/src/meta.ts +8 -3
  54. package/src/stories/Card.stories.tsx +70 -22
  55. package/src/stories/testing.tsx +55 -78
  56. package/src/translations.ts +8 -8
  57. package/dist/lib/browser/chunk-XKCIQK3C.mjs +0 -12
  58. package/dist/lib/browser/chunk-XKCIQK3C.mjs.map +0 -7
  59. package/dist/lib/browser/preview-popover-RKHENTFP.mjs +0 -65
  60. package/dist/lib/browser/preview-popover-RKHENTFP.mjs.map +0 -7
  61. package/dist/lib/browser/react-surface-X56QWACK.mjs +0 -448
  62. package/dist/lib/browser/react-surface-X56QWACK.mjs.map +0 -7
  63. package/dist/lib/node-esm/chunk-L3IZVX56.mjs +0 -14
  64. package/dist/lib/node-esm/chunk-L3IZVX56.mjs.map +0 -7
  65. package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs +0 -67
  66. package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs.map +0 -7
  67. package/dist/lib/node-esm/react-surface-4P7UCMK7.mjs +0 -449
  68. package/dist/lib/node-esm/react-surface-4P7UCMK7.mjs.map +0 -7
  69. package/dist/types/src/components/CardSubjectMenu.d.ts +0 -12
  70. package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
  71. package/dist/types/src/components/ContactCard.d.ts +0 -7
  72. package/dist/types/src/components/ContactCard.d.ts.map +0 -1
  73. package/dist/types/src/components/OrganizationCard.d.ts +0 -5
  74. package/dist/types/src/components/OrganizationCard.d.ts.map +0 -1
  75. package/dist/types/src/components/ProjectCard.d.ts +0 -5
  76. package/dist/types/src/components/ProjectCard.d.ts.map +0 -1
  77. package/dist/types/src/components/TaskCard.d.ts +0 -5
  78. package/dist/types/src/components/TaskCard.d.ts.map +0 -1
  79. package/dist/types/src/components/index.d.ts +0 -4
  80. package/dist/types/src/components/index.d.ts.map +0 -1
  81. package/dist/types/src/types.d.ts +0 -9
  82. package/dist/types/src/types.d.ts.map +0 -1
  83. package/src/components/CardSubjectMenu.tsx +0 -82
  84. package/src/components/ContactCard.tsx +0 -78
  85. package/src/components/OrganizationCard.tsx +0 -44
  86. package/src/components/ProjectCard.tsx +0 -28
  87. package/src/components/TaskCard.tsx +0 -46
  88. package/src/components/index.ts +0 -7
  89. package/src/types.ts +0 -14
package/package.json CHANGED
@@ -1,13 +1,21 @@
1
1
  {
2
2
  "name": "@dxos/plugin-preview",
3
- "version": "0.8.4-main.406dc2a",
3
+ "version": "0.8.4-main.422d1c7879",
4
4
  "description": "Preview plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
13
  "sideEffects": true,
10
14
  "type": "module",
15
+ "imports": {
16
+ "#capabilities": "./src/capabilities/index.ts",
17
+ "#meta": "./src/meta.ts"
18
+ },
11
19
  "exports": {
12
20
  ".": {
13
21
  "source": "./src/index.ts",
@@ -16,51 +24,55 @@
16
24
  }
17
25
  },
18
26
  "types": "dist/types/src/index.d.ts",
19
- "typesVersions": {
20
- "*": {}
21
- },
22
27
  "files": [
23
28
  "dist",
24
29
  "src"
25
30
  ],
26
31
  "dependencies": {
27
- "@effect-rx/rx-react": "0.42.4",
28
- "@preact-signals/safe-react": "^0.9.0",
29
- "@dxos/async": "0.8.4-main.406dc2a",
30
- "@dxos/app-framework": "0.8.4-main.406dc2a",
31
- "@dxos/client": "0.8.4-main.406dc2a",
32
- "@dxos/echo": "0.8.4-main.406dc2a",
33
- "@dxos/app-graph": "0.8.4-main.406dc2a",
34
- "@dxos/keys": "0.8.4-main.406dc2a",
35
- "@dxos/log": "0.8.4-main.406dc2a",
36
- "@dxos/plugin-attention": "0.8.4-main.406dc2a",
37
- "@dxos/lit-ui": "0.8.4-main.406dc2a",
38
- "@dxos/plugin-client": "0.8.4-main.406dc2a",
39
- "@dxos/plugin-deck": "0.8.4-main.406dc2a",
40
- "@dxos/plugin-space": "0.8.4-main.406dc2a",
41
- "@dxos/react-ui": "0.8.4-main.406dc2a",
42
- "@dxos/react-client": "0.8.4-main.406dc2a",
43
- "@dxos/react-ui-editor": "0.8.4-main.406dc2a",
44
- "@dxos/react-ui-form": "0.8.4-main.406dc2a",
45
- "@dxos/react-ui-menu": "0.8.4-main.406dc2a",
46
- "@dxos/react-ui-table": "0.8.4-main.406dc2a",
47
- "@dxos/react-ui-theme": "0.8.4-main.406dc2a",
48
- "@dxos/schema": "0.8.4-main.406dc2a",
49
- "@dxos/util": "0.8.4-main.406dc2a",
50
- "@dxos/react-ui-stack": "0.8.4-main.406dc2a"
32
+ "@effect-atom/atom-react": "^0.5.0",
33
+ "@dxos/app-framework": "0.8.4-main.422d1c7879",
34
+ "@dxos/async": "0.8.4-main.422d1c7879",
35
+ "@dxos/app-toolkit": "0.8.4-main.422d1c7879",
36
+ "@dxos/client": "0.8.4-main.422d1c7879",
37
+ "@dxos/echo": "0.8.4-main.422d1c7879",
38
+ "@dxos/lit-ui": "0.8.4-main.422d1c7879",
39
+ "@dxos/log": "0.8.4-main.422d1c7879",
40
+ "@dxos/effect": "0.8.4-main.422d1c7879",
41
+ "@dxos/keys": "0.8.4-main.422d1c7879",
42
+ "@dxos/operation": "0.8.4-main.422d1c7879",
43
+ "@dxos/plugin-attention": "0.8.4-main.422d1c7879",
44
+ "@dxos/plugin-client": "0.8.4-main.422d1c7879",
45
+ "@dxos/react-client": "0.8.4-main.422d1c7879",
46
+ "@dxos/react-ui": "0.8.4-main.422d1c7879",
47
+ "@dxos/react-ui-editor": "0.8.4-main.422d1c7879",
48
+ "@dxos/react-ui-form": "0.8.4-main.422d1c7879",
49
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.422d1c7879",
50
+ "@dxos/react-ui-table": "0.8.4-main.422d1c7879",
51
+ "@dxos/react-ui-mosaic": "0.8.4-main.422d1c7879",
52
+ "@dxos/schema": "0.8.4-main.422d1c7879",
53
+ "@dxos/types": "0.8.4-main.422d1c7879",
54
+ "@dxos/react-ui-menu": "0.8.4-main.422d1c7879",
55
+ "@dxos/ui-editor": "0.8.4-main.422d1c7879",
56
+ "@dxos/ui-theme": "0.8.4-main.422d1c7879",
57
+ "@dxos/util": "0.8.4-main.422d1c7879",
58
+ "@dxos/plugin-deck": "0.8.4-main.422d1c7879",
59
+ "@dxos/app-graph": "0.8.4-main.422d1c7879"
51
60
  },
52
61
  "devDependencies": {
53
- "effect": "3.18.3",
54
- "react": "~19.2.0",
55
- "react-dom": "~19.2.0",
56
- "vite": "7.1.9",
57
- "@dxos/storybook-utils": "0.8.4-main.406dc2a",
58
- "@dxos/random": "0.8.4-main.406dc2a"
62
+ "effect": "3.20.0",
63
+ "react": "~19.2.3",
64
+ "react-dom": "~19.2.3",
65
+ "vite": "^7.1.11",
66
+ "@dxos/echo-db": "0.8.4-main.422d1c7879",
67
+ "@dxos/plugin-testing": "0.8.4-main.422d1c7879",
68
+ "@dxos/random": "0.8.4-main.422d1c7879",
69
+ "@dxos/react-ui-components": "0.8.4-main.422d1c7879",
70
+ "@dxos/storybook-utils": "0.8.4-main.422d1c7879"
59
71
  },
60
72
  "peerDependencies": {
61
- "effect": "^3.13.3",
62
- "react": "^19.0.0",
63
- "react-dom": "^19.0.0"
73
+ "effect": "3.20.0",
74
+ "react": "~19.2.3",
75
+ "react-dom": "~19.2.3"
64
76
  },
65
77
  "publishConfig": {
66
78
  "access": "public"
@@ -2,33 +2,23 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
6
- import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
7
- import { DataType } from '@dxos/schema';
5
+ import { ActivationEvents, Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
7
+ import { Organization, Person } from '@dxos/types';
8
+
9
+ import { PreviewPopover, ReactSurface } from '#capabilities';
10
+ import { meta } from '#meta';
8
11
 
9
- import { PreviewPopover, ReactSurface } from './capabilities';
10
- import { meta } from './meta';
11
12
  import { translations } from './translations';
12
13
 
13
- export const PreviewPlugin = definePlugin(meta, () => [
14
- defineModule({
15
- id: `${meta.id}/module/translations`,
16
- activatesOn: Events.SetupTranslations,
17
- activate: () => contributes(Capabilities.Translations, translations),
18
- }),
19
- defineModule({
20
- id: `${meta.id}/module/schema`,
21
- activatesOn: ClientEvents.SetupSchema,
22
- activate: () => [contributes(ClientCapabilities.Schema, [DataType.Person, DataType.Organization])],
23
- }),
24
- defineModule({
25
- id: `${meta.id}/module/preview-popover`,
26
- activatesOn: Events.Startup,
14
+ export const PreviewPlugin = Plugin.define(meta).pipe(
15
+ AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization], id: 'schema' }),
16
+ AppPlugin.addSurfaceModule({ activate: ReactSurface }),
17
+ AppPlugin.addTranslationsModule({ translations }),
18
+ Plugin.addModule({
19
+ id: 'preview-popover',
20
+ activatesOn: ActivationEvents.Startup,
27
21
  activate: PreviewPopover,
28
22
  }),
29
- defineModule({
30
- id: `${meta.id}/module/react-surface`,
31
- activatesOn: Events.SetupReactSurface,
32
- activate: ReactSurface,
33
- }),
34
- ]);
23
+ Plugin.make,
24
+ );
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { lazy } from '@dxos/app-framework';
5
+ import { Capability } from '@dxos/app-framework';
6
6
 
7
- export const PreviewPopover = lazy(() => import('./preview-popover'));
8
- export const ReactSurface = lazy(() => import('./react-surface'));
7
+ export const PreviewPopover = Capability.lazy('PreviewPopover', () => import('./preview-popover'));
8
+ export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -2,68 +2,95 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, LayoutAction, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capabilities, Capability } from '@dxos/app-framework';
8
+ import { AppCapabilities, LayoutOperation, getPersonalSpace, getSpaceIdFromPath } from '@dxos/app-toolkit';
6
9
  import { addEventListener } from '@dxos/async';
7
10
  import { type Client } from '@dxos/client';
8
- import { type Space, parseId } from '@dxos/client/echo';
11
+ import { type Space } from '@dxos/client/echo';
12
+ import { Obj } from '@dxos/echo';
9
13
  import { DXN } from '@dxos/keys';
10
14
  import { log } from '@dxos/log';
11
- import { ClientCapabilities } from '@dxos/plugin-client';
15
+ import { ClientCapabilities } from '@dxos/plugin-client/types';
12
16
  import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';
13
- import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';
17
+ import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/ui-editor';
14
18
 
15
19
  const customEventOptions = { capture: true, passive: false };
16
20
 
17
21
  const handlePreviewLookup = async (
18
22
  client: Client,
19
23
  defaultSpace: Space,
20
- { ref, label }: PreviewLinkRef,
24
+ { dxn, label }: PreviewLinkRef,
21
25
  ): Promise<PreviewLinkTarget | null> => {
22
26
  try {
23
- const object = await defaultSpace.db.ref(DXN.parse(ref)).load();
27
+ const object = await defaultSpace.db.makeRef(DXN.parse(dxn)).load();
24
28
  return { label, object };
25
29
  } catch {
26
30
  return null;
27
31
  }
28
32
  };
29
33
 
30
- export default (context: PluginContext) => {
31
- // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
32
- const handleDxAnchorActivate = async ({ refId, label, trigger }: DxAnchorActivate) => {
33
- const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
34
- const client = context.getCapability(ClientCapabilities.Client);
35
- const [layout] = context.getCapabilities(Capabilities.Layout);
36
- const { spaceId } = parseId(layout.workspace);
37
- const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
38
- const result = await handlePreviewLookup(client, space, { ref: refId, label });
39
- if (!result) {
40
- return;
41
- }
34
+ export default Capability.makeModule(
35
+ Effect.fnUntraced(function* () {
36
+ // Get context for lazy capability access in callbacks.
37
+ const capabilities = yield* Capability.Service;
38
+
39
+ // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
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);
50
+ const client = capabilities.get(ClientCapabilities.Client);
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 });
63
+ if (!result) {
64
+ return;
65
+ }
66
+
67
+ const title = titleProp ?? Obj.getLabel(result.object);
42
68
 
43
- await dispatch(
44
- createIntent(LayoutAction.UpdatePopover, {
45
- part: 'popover',
69
+ await invokePromise(LayoutOperation.UpdatePopover, {
70
+ subjectRef: dxn,
46
71
  subject: result.object,
47
- options: {
48
- state: true,
49
- variant: 'virtual',
50
- anchor: trigger,
51
- },
52
- }),
53
- );
54
- };
72
+ state: true,
73
+ variant: 'virtual',
74
+ anchor: trigger,
75
+ ...(kind && { kind }),
76
+ ...(title && { title }),
77
+ ...(side && { side }),
78
+ ...(props && { props }),
79
+ });
80
+ };
55
81
 
56
- let cleanup: () => void;
57
- if (document.defaultView) {
58
- cleanup = addEventListener(
59
- document.defaultView,
60
- DX_ANCHOR_ACTIVATE as any,
61
- handleDxAnchorActivate,
62
- customEventOptions,
63
- );
64
- } else {
65
- log.warn('No default view found');
66
- }
82
+ let cleanup: () => void;
83
+ if (document.defaultView) {
84
+ cleanup = addEventListener(
85
+ document.defaultView,
86
+ DX_ANCHOR_ACTIVATE as any,
87
+ handleAnchorActivate,
88
+ customEventOptions,
89
+ );
90
+ } else {
91
+ log.warn('no default view found');
92
+ }
67
93
 
68
- return contributes(Capabilities.Null, null, () => cleanup());
69
- };
94
+ return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => cleanup?.()));
95
+ }),
96
+ );
@@ -2,133 +2,110 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React, { useCallback } from 'react';
5
+ import * as Effect from 'effect/Effect';
6
+ import React from 'react';
6
7
 
7
- import {
8
- Capabilities,
9
- LayoutAction,
10
- Surface,
11
- contributes,
12
- createIntent,
13
- createSurface,
14
- useIntentDispatcher,
15
- } from '@dxos/app-framework';
16
- import { fullyQualifiedId, getSchema, getSpace } from '@dxos/client/echo';
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { Surface } from '@dxos/app-framework/ui';
10
+ import { AppSurface } from '@dxos/app-toolkit/ui';
17
11
  import { Obj } from '@dxos/echo';
18
- import { type JsonPath, setValue } from '@dxos/echo/internal';
19
- import { useActiveSpace } from '@dxos/plugin-space';
20
- import { useTranslation } from '@dxos/react-ui';
21
- import { Form } from '@dxos/react-ui-form';
22
- import { Card } from '@dxos/react-ui-stack';
23
- import { descriptionMessage, mx } from '@dxos/react-ui-theme';
24
- import { DataType, type ProjectionModel } from '@dxos/schema';
12
+ import { Card } from '@dxos/react-ui';
13
+ import { type ProjectionModel } from '@dxos/schema';
14
+ import { Organization, Person, Pipeline, Task } from '@dxos/types';
25
15
 
26
- import { ContactCard, OrganizationCard, ProjectCard } from '../components';
27
- import { TaskCard } from '../components/TaskCard';
28
- import { meta } from '../meta';
16
+ import { FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
29
17
 
30
- export default () =>
31
- contributes(Capabilities.ReactSurface, [
32
- //
33
- // Specific schema types.
34
- //
35
- createSurface({
36
- id: `${meta.id}/schema-popover--contact`,
37
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
38
- filter: (data): data is { subject: DataType.Person } => Obj.instanceOf(DataType.Person, data.subject),
39
- component: ({ data, role }) => {
40
- const { dispatchPromise: dispatch } = useIntentDispatcher();
41
- const space = getSpace(data.subject);
42
- const activeSpace = useActiveSpace();
43
- const handleOrgClick = useCallback(
44
- (org: DataType.Organization) =>
45
- dispatch(
46
- createIntent(LayoutAction.Open, {
47
- part: 'main',
48
- subject: [fullyQualifiedId(org)],
49
- options: {
50
- workspace: space?.id,
51
- },
52
- }),
53
- ),
54
- [dispatch],
55
- );
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
+ //
56
25
 
57
- return (
58
- <ContactCard role={role} subject={data.subject} activeSpace={activeSpace} onOrgClick={handleOrgClick}>
59
- {role === 'card--popover' && <Surface role='related' data={data} />}
60
- </ContactCard>
61
- );
62
- },
63
- }),
64
- createSurface({
65
- id: `${meta.id}/schema-popover--organization`,
66
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
67
- filter: (data): data is { subject: DataType.Organization } => Obj.instanceOf(DataType.Organization, data.subject),
68
- component: ({ data, role }) => {
69
- const activeSpace = useActiveSpace();
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
+ }),
70
68
 
71
- return (
72
- <OrganizationCard role={role} subject={data.subject} activeSpace={activeSpace}>
73
- {role === 'card--popover' && <Surface role='related' data={data} />}
74
- </OrganizationCard>
75
- );
76
- },
77
- }),
78
- createSurface({
79
- id: `${meta.id}/schema-popover--project`,
80
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
81
- filter: (data): data is { subject: DataType.Project } => Obj.instanceOf(DataType.Project, data.subject),
82
- component: ({ data, role }) => {
83
- const activeSpace = useActiveSpace();
69
+ //
70
+ // Fallback for any object.
71
+ //
84
72
 
85
- return <ProjectCard subject={data.subject} role={role} activeSpace={activeSpace} />;
86
- },
87
- }),
88
- createSurface({
89
- id: `${meta.id}/schema-popover--task`,
90
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
91
- filter: (data): data is { subject: DataType.Task } => Obj.instanceOf(DataType.Task, data.subject),
92
- component: ({ data, role }) => <TaskCard subject={data.subject} role={role} />,
93
- }),
73
+ Surface.create({
74
+ id: 'fallback-popover',
75
+ role: 'card--content',
76
+ position: 'fallback',
77
+ filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
78
+ component: ({ data, role }) => {
79
+ return <FormCard role={role} subject={data.subject} projection={data.projection} />;
80
+ },
81
+ }),
94
82
 
95
- //
96
- // Fallback for any object.
97
- //
98
- createSurface({
99
- id: `${meta.id}/fallback-popover`,
100
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
101
- position: 'fallback',
102
- filter: (data): data is { subject: Obj.Any; projection?: ProjectionModel } => Obj.isObject(data.subject),
103
- component: ({ data, role }) => {
104
- const schema = getSchema(data.subject);
105
- const { t } = useTranslation(meta.id);
106
- if (!schema) {
107
- // TODO(burdon): Use Alert.
108
- return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
109
- }
83
+ Surface.create({
84
+ id: 'fallback-json',
85
+ role: 'card--content',
86
+ position: 'fallback',
87
+ filter: (data): data is Record<string, unknown> => true,
88
+ component: ({ data }) => {
89
+ return <JsonCard data={data} />;
90
+ },
91
+ }),
110
92
 
111
- const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
112
- const changedPaths = Object.keys(changed).filter((path) => changed[path]);
113
- for (const path of changedPaths) {
114
- const value = values[path];
115
- setValue(data.subject, path as JsonPath, value);
116
- }
117
- }, []);
118
-
119
- return (
120
- <Card.SurfaceRoot role={role}>
121
- <Form
122
- schema={schema}
123
- projection={data.projection}
124
- values={data.subject}
125
- readonly={role === 'card--popover' ? 'static' : false}
126
- onSave={handleSave}
127
- autoSave
128
- {...(role === 'card--intrinsic' && { outerSpacing: 'blockStart-0' })}
129
- />
130
- </Card.SurfaceRoot>
131
- );
132
- },
133
- }),
134
- ]);
93
+ Surface.create({
94
+ id: 'section',
95
+ position: 'fallback',
96
+ filter: AppSurface.subject(AppSurface.Section, Obj.isObject),
97
+ component: ({ data }) => {
98
+ return (
99
+ <div role='none' className='flex w-full justify-center'>
100
+ <div role='none' className='pt-2 pb-2 dx-card-min-width dx-card-max-width'>
101
+ <Card.Root>
102
+ <Surface.Surface type={AppSurface.Card} data={data} limit={1} />
103
+ </Card.Root>
104
+ </div>
105
+ </div>
106
+ );
107
+ },
108
+ }),
109
+ ]),
110
+ ),
111
+ );
@@ -0,0 +1,48 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback, useMemo } from 'react';
6
+
7
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
8
+ import { Obj } from '@dxos/echo';
9
+ import { type JsonPath, splitJsonPath } from '@dxos/effect';
10
+ import { Card, useTranslation } from '@dxos/react-ui';
11
+ import { Form, omitId } from '@dxos/react-ui-form';
12
+ import { type ProjectionModel } from '@dxos/schema';
13
+ import { descriptionMessage, mx } from '@dxos/ui-theme';
14
+
15
+ import { meta } from '#meta';
16
+
17
+ export const FormCard = ({ subject, projection }: AppSurface.ObjectCardProps & { projection?: ProjectionModel }) => {
18
+ const { t } = useTranslation(meta.id);
19
+ const echoSchema = Obj.getSchema(subject);
20
+ const schema = useMemo(() => echoSchema && omitId(echoSchema), [echoSchema]);
21
+
22
+ const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
23
+ const paths = Object.keys(changed).filter((path) => changed[path]);
24
+ Obj.change(subject, () => {
25
+ for (const path of paths) {
26
+ const value = values[path];
27
+ const parts = splitJsonPath(path as JsonPath);
28
+ Obj.setValue(subject, parts, value);
29
+ }
30
+ });
31
+ }, []);
32
+
33
+ if (!schema) {
34
+ return <p className={mx(descriptionMessage)}>{t('unable-to-create-preview.message')}</p>;
35
+ }
36
+
37
+ return (
38
+ <Card.Content>
39
+ <Form.Root schema={schema} projection={projection} values={subject} autoSave onSave={handleSave}>
40
+ <Form.Viewport>
41
+ <Form.Content>
42
+ <Form.FieldSet />
43
+ </Form.Content>
44
+ </Form.Viewport>
45
+ </Form.Root>
46
+ </Card.Content>
47
+ );
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 { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
9
+
10
+ export const JsonCard = ({ data }: { data: unknown }) => {
11
+ return (
12
+ <Card.Content>
13
+ <JsonHighlighter data={data} />
14
+ </Card.Content>
15
+ );
16
+ };
@@ -0,0 +1,29 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
8
+ import { Card } from '@dxos/react-ui';
9
+ import { type Organization } from '@dxos/types';
10
+
11
+ export const OrganizationCard = ({ subject }: AppSurface.ObjectCardProps<Organization.Organization>) => {
12
+ const { name, image, description, website } = subject;
13
+
14
+ return (
15
+ <Card.Content>
16
+ <Card.Poster
17
+ alt={name ?? ''}
18
+ {...(image ? { image } : { icon: 'ph--building-office--regular' })}
19
+ classNames={!image && 'opacity-50'}
20
+ />
21
+ {description && (
22
+ <Card.Row>
23
+ <Card.Text variant='description'>{description}</Card.Text>
24
+ </Card.Row>
25
+ )}
26
+ {website && <Card.Link label={website} href={website} />}
27
+ </Card.Content>
28
+ );
29
+ };