@dxos/plugin-preview 0.8.4-main.ae835ea → 0.8.4-main.bcb3aa67d6

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 (83) 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 +3 -3
  20. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
  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 +3 -3
  24. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
  25. package/dist/types/src/cards/TaskCard.d.ts +3 -3
  26. package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
  27. package/dist/types/src/cards/index.d.ts +3 -1
  28. package/dist/types/src/cards/index.d.ts.map +1 -1
  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 +13 -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 -34
  41. package/src/PreviewPlugin.tsx +15 -25
  42. package/src/capabilities/index.ts +3 -3
  43. package/src/capabilities/preview-popover.ts +66 -42
  44. package/src/capabilities/react-surface.tsx +103 -135
  45. package/src/cards/FormCard.tsx +48 -0
  46. package/src/cards/JsonCard.tsx +16 -0
  47. package/src/cards/OrganizationCard.tsx +17 -13
  48. package/src/cards/PersonCard.tsx +65 -0
  49. package/src/cards/ProjectCard.tsx +9 -11
  50. package/src/cards/TaskCard.tsx +26 -28
  51. package/src/cards/index.ts +3 -1
  52. package/src/index.ts +0 -1
  53. package/src/meta.ts +3 -3
  54. package/src/stories/Card.stories.tsx +67 -21
  55. package/src/stories/testing.tsx +47 -69
  56. package/src/translations.ts +8 -8
  57. package/dist/lib/browser/chunk-CEWM5LJG.mjs +0 -17
  58. package/dist/lib/browser/chunk-CEWM5LJG.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-3AR3BFLF.mjs +0 -515
  62. package/dist/lib/browser/react-surface-3AR3BFLF.mjs.map +0 -7
  63. package/dist/lib/node-esm/chunk-Q5MUNELK.mjs +0 -19
  64. package/dist/lib/node-esm/chunk-Q5MUNELK.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-L37JR7U2.mjs +0 -516
  68. package/dist/lib/node-esm/react-surface-L37JR7U2.mjs.map +0 -7
  69. package/dist/types/src/cards/ContactCard.d.ts +0 -5
  70. package/dist/types/src/cards/ContactCard.d.ts.map +0 -1
  71. package/dist/types/src/components/CardComponents.d.ts +0 -16
  72. package/dist/types/src/components/CardComponents.d.ts.map +0 -1
  73. package/dist/types/src/components/CardSubjectMenu.d.ts +0 -8
  74. package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
  75. package/dist/types/src/components/index.d.ts +0 -3
  76. package/dist/types/src/components/index.d.ts.map +0 -1
  77. package/dist/types/src/types.d.ts +0 -10
  78. package/dist/types/src/types.d.ts.map +0 -1
  79. package/src/cards/ContactCard.tsx +0 -65
  80. package/src/components/CardComponents.tsx +0 -67
  81. package/src/components/CardSubjectMenu.tsx +0 -91
  82. package/src/components/index.ts +0 -6
  83. package/src/types.ts +0 -15
package/package.json CHANGED
@@ -1,13 +1,21 @@
1
1
  {
2
2
  "name": "@dxos/plugin-preview",
3
- "version": "0.8.4-main.ae835ea",
3
+ "version": "0.8.4-main.bcb3aa67d6",
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",
@@ -24,43 +32,50 @@
24
32
  "src"
25
33
  ],
26
34
  "dependencies": {
27
- "@effect-rx/rx-react": "0.42.4",
28
- "@preact-signals/safe-react": "^0.9.0",
29
- "@dxos/app-graph": "0.8.4-main.ae835ea",
30
- "@dxos/app-framework": "0.8.4-main.ae835ea",
31
- "@dxos/async": "0.8.4-main.ae835ea",
32
- "@dxos/echo": "0.8.4-main.ae835ea",
33
- "@dxos/keys": "0.8.4-main.ae835ea",
34
- "@dxos/lit-ui": "0.8.4-main.ae835ea",
35
- "@dxos/plugin-attention": "0.8.4-main.ae835ea",
36
- "@dxos/client": "0.8.4-main.ae835ea",
37
- "@dxos/plugin-client": "0.8.4-main.ae835ea",
38
- "@dxos/plugin-deck": "0.8.4-main.ae835ea",
39
- "@dxos/log": "0.8.4-main.ae835ea",
40
- "@dxos/react-client": "0.8.4-main.ae835ea",
41
- "@dxos/react-ui": "0.8.4-main.ae835ea",
42
- "@dxos/plugin-space": "0.8.4-main.ae835ea",
43
- "@dxos/react-ui-editor": "0.8.4-main.ae835ea",
44
- "@dxos/react-ui-menu": "0.8.4-main.ae835ea",
45
- "@dxos/react-ui-table": "0.8.4-main.ae835ea",
46
- "@dxos/react-ui-stack": "0.8.4-main.ae835ea",
47
- "@dxos/react-ui-theme": "0.8.4-main.ae835ea",
48
- "@dxos/schema": "0.8.4-main.ae835ea",
49
- "@dxos/util": "0.8.4-main.ae835ea",
50
- "@dxos/react-ui-form": "0.8.4-main.ae835ea"
35
+ "@effect-atom/atom-react": "^0.5.0",
36
+ "@dxos/app-framework": "0.8.4-main.bcb3aa67d6",
37
+ "@dxos/app-graph": "0.8.4-main.bcb3aa67d6",
38
+ "@dxos/async": "0.8.4-main.bcb3aa67d6",
39
+ "@dxos/app-toolkit": "0.8.4-main.bcb3aa67d6",
40
+ "@dxos/client": "0.8.4-main.bcb3aa67d6",
41
+ "@dxos/echo": "0.8.4-main.bcb3aa67d6",
42
+ "@dxos/effect": "0.8.4-main.bcb3aa67d6",
43
+ "@dxos/keys": "0.8.4-main.bcb3aa67d6",
44
+ "@dxos/lit-ui": "0.8.4-main.bcb3aa67d6",
45
+ "@dxos/plugin-attention": "0.8.4-main.bcb3aa67d6",
46
+ "@dxos/log": "0.8.4-main.bcb3aa67d6",
47
+ "@dxos/plugin-client": "0.8.4-main.bcb3aa67d6",
48
+ "@dxos/operation": "0.8.4-main.bcb3aa67d6",
49
+ "@dxos/plugin-deck": "0.8.4-main.bcb3aa67d6",
50
+ "@dxos/react-client": "0.8.4-main.bcb3aa67d6",
51
+ "@dxos/react-ui": "0.8.4-main.bcb3aa67d6",
52
+ "@dxos/react-ui-form": "0.8.4-main.bcb3aa67d6",
53
+ "@dxos/react-ui-editor": "0.8.4-main.bcb3aa67d6",
54
+ "@dxos/react-ui-menu": "0.8.4-main.bcb3aa67d6",
55
+ "@dxos/react-ui-mosaic": "0.8.4-main.bcb3aa67d6",
56
+ "@dxos/react-ui-table": "0.8.4-main.bcb3aa67d6",
57
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.bcb3aa67d6",
58
+ "@dxos/schema": "0.8.4-main.bcb3aa67d6",
59
+ "@dxos/types": "0.8.4-main.bcb3aa67d6",
60
+ "@dxos/ui-editor": "0.8.4-main.bcb3aa67d6",
61
+ "@dxos/util": "0.8.4-main.bcb3aa67d6",
62
+ "@dxos/ui-theme": "0.8.4-main.bcb3aa67d6"
51
63
  },
52
64
  "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.ae835ea",
58
- "@dxos/random": "0.8.4-main.ae835ea"
65
+ "effect": "3.20.0",
66
+ "react": "~19.2.3",
67
+ "react-dom": "~19.2.3",
68
+ "vite": "^7.1.11",
69
+ "@dxos/echo-db": "0.8.4-main.bcb3aa67d6",
70
+ "@dxos/random": "0.8.4-main.bcb3aa67d6",
71
+ "@dxos/react-ui-components": "0.8.4-main.bcb3aa67d6",
72
+ "@dxos/plugin-testing": "0.8.4-main.bcb3aa67d6",
73
+ "@dxos/storybook-utils": "0.8.4-main.bcb3aa67d6"
59
74
  },
60
75
  "peerDependencies": {
61
- "effect": "^3.13.3",
62
- "react": "^19.0.0",
63
- "react-dom": "^19.0.0"
76
+ "effect": "3.20.0",
77
+ "react": "~19.2.3",
78
+ "react-dom": "~19.2.3"
64
79
  },
65
80
  "publishConfig": {
66
81
  "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
8
 
9
- import { PreviewPopover, ReactSurface } from './capabilities';
10
- import { meta } from './meta';
9
+ import { meta } from '#meta';
11
10
  import { translations } from './translations';
12
11
 
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,
12
+ import { PreviewPopover, ReactSurface } from '#capabilities';
13
+
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,92 @@
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
+ const [layoutAtom] = capabilities.getAll(AppCapabilities.Layout);
53
+ const layout = registry.get(layoutAtom);
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 });
60
+ if (!result) {
61
+ return;
62
+ }
63
+
64
+ const title = titleProp ?? Obj.getLabel(result.object);
42
65
 
43
- await dispatch(
44
- createIntent(LayoutAction.UpdatePopover, {
45
- part: 'popover',
66
+ await invokePromise(LayoutOperation.UpdatePopover, {
67
+ subjectRef: dxn,
46
68
  subject: result.object,
47
- options: {
48
- state: true,
49
- variant: 'virtual',
50
- anchor: trigger,
51
- },
52
- }),
53
- );
54
- };
69
+ state: true,
70
+ variant: 'virtual',
71
+ anchor: trigger,
72
+ ...(kind && { kind }),
73
+ ...(title && { title }),
74
+ ...(side && { side }),
75
+ ...(props && { props }),
76
+ });
77
+ };
55
78
 
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
- }
79
+ let cleanup: () => void;
80
+ if (document.defaultView) {
81
+ cleanup = addEventListener(
82
+ document.defaultView,
83
+ DX_ANCHOR_ACTIVATE as any,
84
+ handleAnchorActivate,
85
+ customEventOptions,
86
+ );
87
+ } else {
88
+ log.warn('no default view found');
89
+ }
67
90
 
68
- return contributes(Capabilities.Null, null, () => cleanup());
69
- };
91
+ return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => cleanup?.()));
92
+ }),
93
+ );
@@ -2,148 +2,116 @@
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';
17
10
  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';
11
+ import { Card } from '@dxos/react-ui';
12
+ import { type ProjectionModel } from '@dxos/schema';
13
+ import { Organization, Person, Pipeline, Task } from '@dxos/types';
25
14
 
26
- import { ContactCard, OrganizationCard, ProjectCard, TaskCard } from '../cards';
27
- import { meta } from '../meta';
15
+ import { FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
16
+ import { meta } from '#meta';
28
17
 
29
- export default () =>
30
- contributes(Capabilities.ReactSurface, [
31
- //
32
- // Specific schema types.
33
- //
34
- createSurface({
35
- id: `${meta.id}/schema-popover--contact`,
36
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
37
- filter: (data): data is { subject: DataType.Person } => Obj.instanceOf(DataType.Person, data.subject),
38
- component: ({ data, role }) => {
39
- const { dispatchPromise: dispatch } = useIntentDispatcher();
40
- const space = getSpace(data.subject);
41
- const activeSpace = useActiveSpace();
42
- const handleSelect = useCallback(
43
- (org: Obj.Any) =>
44
- dispatch(
45
- createIntent(LayoutAction.Open, {
46
- part: 'main',
47
- subject: [fullyQualifiedId(org)],
48
- options: {
49
- workspace: space?.id,
50
- },
51
- }),
52
- ),
53
- [dispatch],
54
- );
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
+ //
55
25
 
56
- return (
57
- <ContactCard role={role} subject={data.subject} activeSpace={activeSpace} onSelect={handleSelect}>
58
- {role === 'card--popover' && <Surface role='related' data={data} />}
59
- </ContactCard>
60
- );
61
- },
62
- }),
63
- createSurface({
64
- id: `${meta.id}/schema-popover--organization`,
65
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
66
- filter: (data): data is { subject: DataType.Organization } => Obj.instanceOf(DataType.Organization, data.subject),
67
- component: ({ data, role }) => {
68
- const activeSpace = useActiveSpace();
26
+ Surface.create<{ subject: Person.Person }>({
27
+ id: `${meta.id}.schema-popover--contact`,
28
+ role: 'card--content',
29
+ position: 'hoist',
30
+ filter: (data): data is { subject: Person.Person } => Obj.instanceOf(Person.Person, data.subject),
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: `${meta.id}.schema-popover--organization`,
42
+ role: 'card--content',
43
+ position: 'hoist',
44
+ filter: (data): data is { subject: Organization.Organization } =>
45
+ Obj.instanceOf(Organization.Organization, data.subject),
46
+ component: ({ data, role }) => {
47
+ return (
48
+ <>
49
+ <OrganizationCard role={role} subject={data.subject} />
50
+ <Surface.Surface role='related' data={data} limit={1} />
51
+ </>
52
+ );
53
+ },
54
+ }),
55
+ Surface.create({
56
+ id: `${meta.id}.schema-popover--project`,
57
+ role: 'card--content',
58
+ position: 'hoist',
59
+ filter: (data): data is { subject: Pipeline.Pipeline } => Obj.instanceOf(Pipeline.Pipeline, data.subject),
60
+ component: ({ data, role }) => {
61
+ return <ProjectCard role={role} subject={data.subject} />;
62
+ },
63
+ }),
64
+ Surface.create({
65
+ id: `${meta.id}.schema-popover--task`,
66
+ role: 'card--content',
67
+ position: 'hoist',
68
+ filter: (data): data is { subject: Task.Task } => Obj.instanceOf(Task.Task, data.subject),
69
+ component: ({ data, role }) => {
70
+ return <TaskCard role={role} subject={data.subject} />;
71
+ },
72
+ }),
69
73
 
70
- return (
71
- <OrganizationCard role={role} subject={data.subject} activeSpace={activeSpace}>
72
- {role === 'card--popover' && <Surface role='related' data={data} />}
73
- </OrganizationCard>
74
- );
75
- },
76
- }),
77
- createSurface({
78
- id: `${meta.id}/schema-popover--project`,
79
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
80
- filter: (data): data is { subject: DataType.Project } => Obj.instanceOf(DataType.Project, data.subject),
81
- component: ({ data, role }) => {
82
- const activeSpace = useActiveSpace();
74
+ //
75
+ // Fallback for any object.
76
+ //
83
77
 
84
- return <ProjectCard subject={data.subject} role={role} activeSpace={activeSpace} />;
85
- },
86
- }),
87
- createSurface({
88
- id: `${meta.id}/schema-popover--task`,
89
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
90
- filter: (data): data is { subject: DataType.Task } => Obj.instanceOf(DataType.Task, data.subject),
91
- component: ({ data, role }) => <TaskCard subject={data.subject} role={role} />,
92
- }),
78
+ Surface.create({
79
+ id: `${meta.id}.fallback-popover`,
80
+ role: 'card--content',
81
+ position: 'fallback',
82
+ filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
83
+ component: ({ data, role }) => {
84
+ return <FormCard role={role} subject={data.subject} projection={data.projection} />;
85
+ },
86
+ }),
93
87
 
94
- //
95
- // Fallback for any object.
96
- //
97
- createSurface({
98
- id: `${meta.id}/fallback-popover`,
99
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
100
- position: 'fallback',
101
- filter: (data): data is { subject: Obj.Any; projection?: ProjectionModel } => Obj.isObject(data.subject),
102
- component: ({ data, role }) => {
103
- const schema = getSchema(data.subject);
104
- const { t } = useTranslation(meta.id);
105
- if (!schema) {
106
- // TODO(burdon): Use Alert.
107
- return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
108
- }
88
+ Surface.create({
89
+ id: `${meta.id}.fallback-json`,
90
+ role: 'card--content',
91
+ position: 'fallback',
92
+ filter: (data): data is Record<string, unknown> => true,
93
+ component: ({ data }) => {
94
+ return <JsonCard data={data} />;
95
+ },
96
+ }),
109
97
 
110
- const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
111
- const changedPaths = Object.keys(changed).filter((path) => changed[path]);
112
- for (const path of changedPaths) {
113
- const value = values[path];
114
- setValue(data.subject, path as JsonPath, value);
115
- }
116
- }, []);
117
-
118
- return (
119
- <Card.SurfaceRoot role={role}>
120
- <Form
121
- schema={schema}
122
- projection={data.projection}
123
- values={data.subject}
124
- readonly={role === 'card--popover' ? 'static' : false}
125
- onSave={handleSave}
126
- autoSave
127
- {...(role === 'card--intrinsic' && { outerSpacing: 'blockStart-0' })}
128
- />
129
- </Card.SurfaceRoot>
130
- );
131
- },
132
- }),
133
-
134
- createSurface({
135
- id: `${meta.id}/section`,
136
- role: ['section'],
137
- position: 'fallback',
138
- filter: (data): data is { subject: Obj.Any } => Obj.isObject(data.subject),
139
- component: ({ data }) => {
140
- return (
141
- <div role='none' className='flex justify-center'>
142
- <div role='none' className='card-max-width'>
143
- <Surface role='card' data={data} limit={1} />
98
+ Surface.create({
99
+ id: `${meta.id}.section`,
100
+ role: ['section'],
101
+ position: 'fallback',
102
+ filter: (data): data is { subject: Obj.Unknown } => Obj.isObject(data.subject),
103
+ component: ({ data }) => {
104
+ return (
105
+ <div role='none' className='flex w-full justify-center'>
106
+ <div role='none' className='pt-2 pb-2 dx-card-min-width dx-card-max-width'>
107
+ <Card.Root>
108
+ <Surface.Surface role='card--content' data={data} limit={1} />
109
+ </Card.Root>
110
+ </div>
144
111
  </div>
145
- </div>
146
- );
147
- },
148
- }),
149
- ]);
112
+ );
113
+ },
114
+ }),
115
+ ]),
116
+ ),
117
+ );
@@ -0,0 +1,48 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback, useMemo } from 'react';
6
+
7
+ import { type ObjectSurfaceProps } 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 }: ObjectSurfaceProps & { 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 { 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
+ };