@dxos/plugin-preview 0.8.4-main.f5c0578 → 0.8.4-main.fcfe5033a5

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 (86) hide show
  1. package/dist/lib/browser/index.mjs +41 -42
  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 -42
  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 -3
  32. package/dist/types/src/meta.d.ts.map +1 -1
  33. package/dist/types/src/stories/Card.stories.d.ts +32 -46
  34. package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
  35. package/dist/types/src/stories/testing.d.ts +15 -14
  36. package/dist/types/src/stories/testing.d.ts.map +1 -1
  37. package/dist/types/src/translations.d.ts +8 -2
  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 +17 -28
  42. package/src/capabilities/index.ts +3 -3
  43. package/src/capabilities/preview-popover.ts +69 -50
  44. package/src/capabilities/react-surface.tsx +99 -151
  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 -5
  54. package/src/stories/Card.stories.tsx +81 -27
  55. package/src/stories/testing.tsx +56 -68
  56. package/src/translations.ts +8 -2
  57. package/dist/lib/browser/chunk-Z73ENKLE.mjs +0 -14
  58. package/dist/lib/browser/chunk-Z73ENKLE.mjs.map +0 -7
  59. package/dist/lib/browser/preview-popover-MAIBTJKJ.mjs +0 -69
  60. package/dist/lib/browser/preview-popover-MAIBTJKJ.mjs.map +0 -7
  61. package/dist/lib/browser/react-surface-H4RYYXVQ.mjs +0 -379
  62. package/dist/lib/browser/react-surface-H4RYYXVQ.mjs.map +0 -7
  63. package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs +0 -16
  64. package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs.map +0 -7
  65. package/dist/lib/node-esm/preview-popover-LZGHYW23.mjs +0 -71
  66. package/dist/lib/node-esm/preview-popover-LZGHYW23.mjs.map +0 -7
  67. package/dist/lib/node-esm/react-surface-4C44XCLH.mjs +0 -380
  68. package/dist/lib/node-esm/react-surface-4C44XCLH.mjs.map +0 -7
  69. package/dist/types/src/components/CardSubjectMenu.d.ts +0 -10
  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/index.d.ts +0 -4
  78. package/dist/types/src/components/index.d.ts.map +0 -1
  79. package/dist/types/src/types.d.ts +0 -7
  80. package/dist/types/src/types.d.ts.map +0 -1
  81. package/src/components/CardSubjectMenu.tsx +0 -56
  82. package/src/components/ContactCard.tsx +0 -76
  83. package/src/components/OrganizationCard.tsx +0 -44
  84. package/src/components/ProjectCard.tsx +0 -27
  85. package/src/components/index.ts +0 -7
  86. package/src/types.ts +0 -11
package/package.json CHANGED
@@ -1,13 +1,21 @@
1
1
  {
2
2
  "name": "@dxos/plugin-preview",
3
- "version": "0.8.4-main.f5c0578",
3
+ "version": "0.8.4-main.fcfe5033a5",
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.38.0",
28
- "@preact-signals/safe-react": "^0.9.0",
29
- "@dxos/app-framework": "0.8.4-main.f5c0578",
30
- "@dxos/app-graph": "0.8.4-main.f5c0578",
31
- "@dxos/async": "0.8.4-main.f5c0578",
32
- "@dxos/client": "0.8.4-main.f5c0578",
33
- "@dxos/keys": "0.8.4-main.f5c0578",
34
- "@dxos/lit-ui": "0.8.4-main.f5c0578",
35
- "@dxos/echo": "0.8.4-main.f5c0578",
36
- "@dxos/log": "0.8.4-main.f5c0578",
37
- "@dxos/plugin-attention": "0.8.4-main.f5c0578",
38
- "@dxos/plugin-client": "0.8.4-main.f5c0578",
39
- "@dxos/echo-schema": "0.8.4-main.f5c0578",
40
- "@dxos/plugin-deck": "0.8.4-main.f5c0578",
41
- "@dxos/react-client": "0.8.4-main.f5c0578",
42
- "@dxos/react-ui": "0.8.4-main.f5c0578",
43
- "@dxos/react-ui-editor": "0.8.4-main.f5c0578",
44
- "@dxos/react-ui-form": "0.8.4-main.f5c0578",
45
- "@dxos/react-ui-stack": "0.8.4-main.f5c0578",
46
- "@dxos/react-ui-theme": "0.8.4-main.f5c0578",
47
- "@dxos/react-ui-table": "0.8.4-main.f5c0578",
48
- "@dxos/react-ui-menu": "0.8.4-main.f5c0578",
49
- "@dxos/schema": "0.8.4-main.f5c0578",
50
- "@dxos/util": "0.8.4-main.f5c0578"
35
+ "@effect-atom/atom-react": "^0.5.0",
36
+ "@dxos/app-toolkit": "0.8.4-main.fcfe5033a5",
37
+ "@dxos/app-graph": "0.8.4-main.fcfe5033a5",
38
+ "@dxos/app-framework": "0.8.4-main.fcfe5033a5",
39
+ "@dxos/async": "0.8.4-main.fcfe5033a5",
40
+ "@dxos/echo": "0.8.4-main.fcfe5033a5",
41
+ "@dxos/client": "0.8.4-main.fcfe5033a5",
42
+ "@dxos/effect": "0.8.4-main.fcfe5033a5",
43
+ "@dxos/lit-ui": "0.8.4-main.fcfe5033a5",
44
+ "@dxos/log": "0.8.4-main.fcfe5033a5",
45
+ "@dxos/keys": "0.8.4-main.fcfe5033a5",
46
+ "@dxos/plugin-attention": "0.8.4-main.fcfe5033a5",
47
+ "@dxos/plugin-client": "0.8.4-main.fcfe5033a5",
48
+ "@dxos/react-client": "0.8.4-main.fcfe5033a5",
49
+ "@dxos/plugin-deck": "0.8.4-main.fcfe5033a5",
50
+ "@dxos/operation": "0.8.4-main.fcfe5033a5",
51
+ "@dxos/react-ui": "0.8.4-main.fcfe5033a5",
52
+ "@dxos/react-ui-editor": "0.8.4-main.fcfe5033a5",
53
+ "@dxos/react-ui-form": "0.8.4-main.fcfe5033a5",
54
+ "@dxos/react-ui-mosaic": "0.8.4-main.fcfe5033a5",
55
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.fcfe5033a5",
56
+ "@dxos/react-ui-menu": "0.8.4-main.fcfe5033a5",
57
+ "@dxos/react-ui-table": "0.8.4-main.fcfe5033a5",
58
+ "@dxos/schema": "0.8.4-main.fcfe5033a5",
59
+ "@dxos/types": "0.8.4-main.fcfe5033a5",
60
+ "@dxos/ui-editor": "0.8.4-main.fcfe5033a5",
61
+ "@dxos/util": "0.8.4-main.fcfe5033a5",
62
+ "@dxos/ui-theme": "0.8.4-main.fcfe5033a5"
51
63
  },
52
64
  "devDependencies": {
53
- "effect": "3.17.7",
54
- "react": "~18.2.0",
55
- "react-dom": "~18.2.0",
56
- "vite": "5.4.7",
57
- "@dxos/random": "0.8.4-main.f5c0578",
58
- "@dxos/storybook-utils": "0.8.4-main.f5c0578"
65
+ "effect": "3.20.0",
66
+ "react": "~19.2.3",
67
+ "react-dom": "~19.2.3",
68
+ "vite": "^7.1.11",
69
+ "@dxos/plugin-testing": "0.8.4-main.fcfe5033a5",
70
+ "@dxos/storybook-utils": "0.8.4-main.fcfe5033a5",
71
+ "@dxos/react-ui-components": "0.8.4-main.fcfe5033a5",
72
+ "@dxos/random": "0.8.4-main.fcfe5033a5",
73
+ "@dxos/echo-db": "0.8.4-main.fcfe5033a5"
59
74
  },
60
75
  "peerDependencies": {
61
- "effect": "^3.13.3",
62
- "react": "~18.2.0",
63
- "react-dom": "~18.2.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,34 +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 = () =>
14
- definePlugin(meta, [
15
- defineModule({
16
- id: `${meta.id}/module/translations`,
17
- activatesOn: Events.SetupTranslations,
18
- activate: () => contributes(Capabilities.Translations, translations),
19
- }),
20
- defineModule({
21
- id: `${meta.id}/module/schema`,
22
- activatesOn: ClientEvents.SetupSchema,
23
- activate: () => [contributes(ClientCapabilities.Schema, [DataType.Person, DataType.Organization])],
24
- }),
25
- defineModule({
26
- id: `${meta.id}/module/preview-popover`,
27
- activatesOn: Events.Startup,
28
- activate: PreviewPopover,
29
- }),
30
- defineModule({
31
- id: `${meta.id}/module/react-surface`,
32
- activatesOn: Events.SetupReactSurface,
33
- activate: ReactSurface,
34
- }),
35
- ]);
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,
21
+ activate: PreviewPopover,
22
+ }),
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,73 +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
- import { type Client, resolveRef } from '@dxos/client';
8
- import { type Space, parseId } from '@dxos/client/echo';
10
+ import { type Client } from '@dxos/client';
11
+ import { type Space } from '@dxos/client/echo';
12
+ import { Obj } from '@dxos/echo';
9
13
  import { DXN } from '@dxos/keys';
10
- import { type DxRefTagActivate } from '@dxos/lit-ui';
11
14
  import { log } from '@dxos/log';
12
- import { ClientCapabilities } from '@dxos/plugin-client';
13
- import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';
15
+ import { ClientCapabilities } from '@dxos/plugin-client/types';
16
+ import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';
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 dxn = DXN.parse(ref);
24
- if (!dxn) {
25
- return null;
26
- }
27
-
28
- const object = await resolveRef(client, dxn, defaultSpace);
27
+ const object = await defaultSpace.db.makeRef(DXN.parse(dxn)).load();
29
28
  return { label, object };
30
- } catch (err) {
29
+ } catch {
31
30
  return null;
32
31
  }
33
32
  };
34
33
 
35
- export default (context: PluginContext) => {
36
- // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
37
- const handleDxRefTagActivate = async ({ refId, label, trigger }: DxRefTagActivate) => {
38
- const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
39
- const client = context.getCapability(ClientCapabilities.Client);
40
- const [layout] = context.getCapabilities(Capabilities.Layout);
41
- const { spaceId } = parseId(layout.workspace);
42
- const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
43
- const result = await handlePreviewLookup(client, space, { ref: refId, label });
44
- if (!result) {
45
- return;
46
- }
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
+ }
47
63
 
48
- await dispatch(
49
- createIntent(LayoutAction.UpdatePopover, {
50
- part: 'popover',
64
+ const title = titleProp ?? Obj.getLabel(result.object);
65
+
66
+ await invokePromise(LayoutOperation.UpdatePopover, {
67
+ subjectRef: dxn,
51
68
  subject: result.object,
52
- options: {
53
- state: true,
54
- variant: 'virtual',
55
- anchor: trigger,
56
- },
57
- }),
58
- );
59
- };
69
+ state: true,
70
+ variant: 'virtual',
71
+ anchor: trigger,
72
+ ...(kind && { kind }),
73
+ ...(title && { title }),
74
+ ...(side && { side }),
75
+ ...(props && { props }),
76
+ });
77
+ };
60
78
 
61
- let cleanup: () => void;
62
- if (document.defaultView) {
63
- cleanup = addEventListener(
64
- document.defaultView,
65
- 'dx-ref-tag-activate' as any,
66
- handleDxRefTagActivate,
67
- customEventOptions,
68
- );
69
- } else {
70
- log.warn('No default view found');
71
- }
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
+ }
72
90
 
73
- return contributes(Capabilities.Null, null, () => cleanup());
74
- };
91
+ return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => cleanup?.()));
92
+ }),
93
+ );
@@ -2,162 +2,110 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Effect } from 'effect';
6
- import React, { useCallback } from 'react';
5
+ import * as Effect from 'effect/Effect';
6
+ import React from 'react';
7
7
 
8
- import {
9
- Capabilities,
10
- LayoutAction,
11
- Surface,
12
- contributes,
13
- createIntent,
14
- createSurface,
15
- useIntentDispatcher,
16
- } from '@dxos/app-framework';
17
- import { fullyQualifiedId, getSchema, getSpace } from '@dxos/client/echo';
18
- import { Filter, Obj } from '@dxos/echo';
19
- import { type JsonPath, setValue } from '@dxos/echo-schema';
20
- import { AttentionAction } from '@dxos/plugin-attention/types';
21
- import { ATTENDABLE_PATH_SEPARATOR, DeckAction } from '@dxos/plugin-deck/types';
22
- import { useQuery, useSpace } from '@dxos/react-client/echo';
23
- import { useTranslation } from '@dxos/react-ui';
24
- import { Form } from '@dxos/react-ui-form';
25
- import { Card } from '@dxos/react-ui-stack';
26
- import { TableView } from '@dxos/react-ui-table/types';
27
- import { descriptionMessage, mx } from '@dxos/react-ui-theme';
28
- import { DataType } from '@dxos/schema';
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';
29
15
 
30
- import { ContactCard, OrganizationCard, ProjectCard } from '../components';
31
- import { PREVIEW_PLUGIN } from '../meta';
16
+ import { FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
32
17
 
33
- export default () =>
34
- contributes(Capabilities.ReactSurface, [
35
- //
36
- // Specific schema types.
37
- //
38
- createSurface({
39
- id: `${PREVIEW_PLUGIN}/schema-popover--contact`,
40
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
41
- filter: (data): data is { subject: DataType.Person } => Obj.instanceOf(DataType.Person, data.subject),
42
- component: ({ data, role }) => {
43
- const { dispatch } = useIntentDispatcher();
44
- const space = getSpace(data.subject);
45
- const defaultSpace = useSpace();
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
+ //
46
25
 
47
- const currentSpaceOrgs = useQuery(space, Filter.type(DataType.Organization));
48
- const currentSpaceViews = useQuery(space, Filter.type(DataType.View));
49
- const defaultSpaceViews = useQuery(defaultSpace, Filter.type(DataType.View));
50
- const currentSpaceOrgTable = currentSpaceViews.find(
51
- (view) =>
52
- view.query.typename === DataType.Organization.typename &&
53
- Obj.instanceOf(TableView, view.presentation.target),
54
- );
55
- const defaultSpaceOrgTable = defaultSpaceViews.find(
56
- (view) =>
57
- view.query.typename === DataType.Organization.typename &&
58
- Obj.instanceOf(TableView, view.presentation.target),
59
- );
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
+ }),
60
68
 
61
- // TODO(wittjosiah): Generalized way of handling related objects navigation.
62
- const handleOrgClick = useCallback(
63
- (org: DataType.Organization) =>
64
- Effect.gen(function* () {
65
- const view = currentSpaceOrgs.includes(org) ? currentSpaceOrgTable : defaultSpaceOrgTable;
66
- yield* dispatch(
67
- createIntent(LayoutAction.UpdatePopover, {
68
- part: 'popover',
69
- options: {
70
- state: false,
71
- anchorId: '',
72
- },
73
- }),
74
- );
75
- if (view) {
76
- const id = fullyQualifiedId(view);
77
- yield* dispatch(
78
- createIntent(LayoutAction.Open, {
79
- part: 'main',
80
- subject: [id],
81
- options: { workspace: space?.id },
82
- }),
83
- );
84
- yield* dispatch(
85
- createIntent(DeckAction.ChangeCompanion, {
86
- primary: id,
87
- companion: [id, 'selected-objects'].join(ATTENDABLE_PATH_SEPARATOR),
88
- }),
89
- );
90
- yield* dispatch(
91
- createIntent(AttentionAction.Select, {
92
- contextId: id,
93
- selection: { mode: 'multi', ids: [org.id] },
94
- }),
95
- );
96
- }
97
- }).pipe(Effect.runPromise),
98
- [dispatch, currentSpaceOrgs, currentSpaceOrgTable, defaultSpaceOrgTable],
99
- );
69
+ //
70
+ // Fallback for any object.
71
+ //
100
72
 
101
- return (
102
- <ContactCard role={role} subject={data.subject} onOrgClick={handleOrgClick}>
103
- {role === 'card--popover' && <Surface role='related' data={data} />}
104
- </ContactCard>
105
- );
106
- },
107
- }),
108
- createSurface({
109
- id: `${PREVIEW_PLUGIN}/schema-popover--organization`,
110
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
111
- filter: (data): data is { subject: DataType.Organization } => Obj.instanceOf(DataType.Organization, data.subject),
112
- component: ({ data, role }) => (
113
- <OrganizationCard role={role} subject={data.subject}>
114
- {role === 'card--popover' && <Surface role='related' data={data} />}
115
- </OrganizationCard>
116
- ),
117
- }),
118
- createSurface({
119
- id: `${PREVIEW_PLUGIN}/schema-popover--project`,
120
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
121
- filter: (data): data is { subject: DataType.Project } => Obj.instanceOf(DataType.Project, data.subject),
122
- component: ({ data, role }) => <ProjectCard subject={data.subject} role={role} />,
123
- }),
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
+ }),
124
82
 
125
- //
126
- // Fallback for any object.
127
- //
128
- createSurface({
129
- id: `${PREVIEW_PLUGIN}/fallback-popover`,
130
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
131
- position: 'fallback',
132
- filter: (data): data is { subject: Obj.Any } => Obj.isObject(data.subject),
133
- component: ({ data, role }) => {
134
- const schema = getSchema(data.subject);
135
- const { t } = useTranslation(PREVIEW_PLUGIN);
136
- if (!schema) {
137
- // TODO(burdon): Use Alert.
138
- return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
139
- }
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
+ }),
140
92
 
141
- const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
142
- const changedPaths = Object.keys(changed).filter((path) => changed[path]);
143
- for (const path of changedPaths) {
144
- const value = values[path];
145
- setValue(data.subject, path as JsonPath, value);
146
- }
147
- }, []);
148
-
149
- return (
150
- <Card.SurfaceRoot role={role}>
151
- <Form
152
- schema={schema}
153
- values={data.subject}
154
- readonly={role === 'card--popover'}
155
- onSave={handleSave}
156
- autoSave
157
- {...(role === 'card--intrinsic' && { outerSpacing: 'blockStart-0' })}
158
- />
159
- </Card.SurfaceRoot>
160
- );
161
- },
162
- }),
163
- ]);
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 { 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
+ };