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