@dxos/plugin-preview 0.8.4-main.406dc2a → 0.8.4-main.52d7546f51
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/chunk-XLN6KTHK.mjs +17 -0
- package/dist/lib/browser/chunk-XLN6KTHK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +26 -35
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/preview-popover-5YUZCO2D.mjs +82 -0
- package/dist/lib/browser/preview-popover-5YUZCO2D.mjs.map +7 -0
- package/dist/lib/browser/react-surface-W3FAIVY7.mjs +251 -0
- package/dist/lib/browser/react-surface-W3FAIVY7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-L3IZVX56.mjs → chunk-2G4FUGDA.mjs} +6 -1
- package/dist/lib/node-esm/chunk-2G4FUGDA.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +26 -35
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/preview-popover-7QRYVL73.mjs +84 -0
- package/dist/lib/node-esm/preview-popover-7QRYVL73.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-IO5DHYZB.mjs +252 -0
- package/dist/lib/node-esm/react-surface-IO5DHYZB.mjs.map +7 -0
- package/dist/types/src/PreviewPlugin.d.ts +2 -1
- package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/preview-popover/index.d.ts +3 -0
- package/dist/types/src/capabilities/preview-popover/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts +5 -0
- package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/cards/FormCard.d.ts +7 -0
- package/dist/types/src/cards/FormCard.d.ts.map +1 -0
- package/dist/types/src/cards/OrganizationCard.d.ts +5 -0
- package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -0
- package/dist/types/src/cards/PersonCard.d.ts +5 -0
- package/dist/types/src/cards/PersonCard.d.ts.map +1 -0
- package/dist/types/src/cards/ProjectCard.d.ts +5 -0
- package/dist/types/src/cards/ProjectCard.d.ts.map +1 -0
- package/dist/types/src/cards/TaskCard.d.ts +5 -0
- package/dist/types/src/cards/TaskCard.d.ts.map +1 -0
- package/dist/types/src/cards/index.d.ts +6 -0
- package/dist/types/src/cards/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/stories/Card.stories.d.ts +9 -7
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +14 -12
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +44 -33
- package/src/PreviewPlugin.tsx +12 -23
- package/src/capabilities/index.ts +2 -4
- package/src/capabilities/preview-popover/index.ts +7 -0
- package/src/capabilities/preview-popover/preview-popover.ts +90 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +97 -0
- package/src/cards/FormCard.tsx +56 -0
- package/src/cards/OrganizationCard.tsx +29 -0
- package/src/cards/PersonCard.tsx +47 -0
- package/src/cards/ProjectCard.tsx +22 -0
- package/src/{components → cards}/TaskCard.tsx +18 -24
- package/src/{components → cards}/index.ts +3 -1
- package/src/index.ts +0 -1
- package/src/meta.ts +7 -2
- package/src/stories/Card.stories.tsx +38 -21
- package/src/stories/testing.tsx +41 -71
- package/dist/lib/browser/chunk-XKCIQK3C.mjs +0 -12
- package/dist/lib/browser/chunk-XKCIQK3C.mjs.map +0 -7
- package/dist/lib/browser/preview-popover-RKHENTFP.mjs +0 -65
- package/dist/lib/browser/preview-popover-RKHENTFP.mjs.map +0 -7
- package/dist/lib/browser/react-surface-X56QWACK.mjs +0 -448
- package/dist/lib/browser/react-surface-X56QWACK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-L3IZVX56.mjs.map +0 -7
- package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs +0 -67
- package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-4P7UCMK7.mjs +0 -449
- package/dist/lib/node-esm/react-surface-4P7UCMK7.mjs.map +0 -7
- package/dist/types/src/capabilities/preview-popover.d.ts +0 -4
- package/dist/types/src/capabilities/preview-popover.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/CardSubjectMenu.d.ts +0 -12
- package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
- package/dist/types/src/components/ContactCard.d.ts +0 -7
- package/dist/types/src/components/ContactCard.d.ts.map +0 -1
- package/dist/types/src/components/OrganizationCard.d.ts +0 -5
- package/dist/types/src/components/OrganizationCard.d.ts.map +0 -1
- package/dist/types/src/components/ProjectCard.d.ts +0 -5
- package/dist/types/src/components/ProjectCard.d.ts.map +0 -1
- package/dist/types/src/components/TaskCard.d.ts +0 -5
- package/dist/types/src/components/TaskCard.d.ts.map +0 -1
- package/dist/types/src/components/index.d.ts +0 -4
- package/dist/types/src/components/index.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -9
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/preview-popover.ts +0 -69
- package/src/capabilities/react-surface.tsx +0 -134
- package/src/components/CardSubjectMenu.tsx +0 -82
- package/src/components/ContactCard.tsx +0 -78
- package/src/components/OrganizationCard.tsx +0 -44
- package/src/components/ProjectCard.tsx +0 -28
- package/src/types.ts +0 -14
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-preview",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.52d7546f51",
|
|
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,
|
|
@@ -24,43 +28,50 @@
|
|
|
24
28
|
"src"
|
|
25
29
|
],
|
|
26
30
|
"dependencies": {
|
|
27
|
-
"@effect-
|
|
28
|
-
"@
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
31
|
-
"@dxos/client": "0.8.4-main.
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/plugin-
|
|
40
|
-
"@dxos/plugin-
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/react-client": "0.8.4-main.
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/react-ui
|
|
45
|
-
"@dxos/react-ui-
|
|
46
|
-
"@dxos/react-ui-
|
|
47
|
-
"@dxos/react-ui-
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
31
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
32
|
+
"@dxos/app-graph": "0.8.4-main.52d7546f51",
|
|
33
|
+
"@dxos/app-toolkit": "0.8.4-main.52d7546f51",
|
|
34
|
+
"@dxos/app-framework": "0.8.4-main.52d7546f51",
|
|
35
|
+
"@dxos/client": "0.8.4-main.52d7546f51",
|
|
36
|
+
"@dxos/async": "0.8.4-main.52d7546f51",
|
|
37
|
+
"@dxos/echo": "0.8.4-main.52d7546f51",
|
|
38
|
+
"@dxos/effect": "0.8.4-main.52d7546f51",
|
|
39
|
+
"@dxos/lit-ui": "0.8.4-main.52d7546f51",
|
|
40
|
+
"@dxos/keys": "0.8.4-main.52d7546f51",
|
|
41
|
+
"@dxos/log": "0.8.4-main.52d7546f51",
|
|
42
|
+
"@dxos/operation": "0.8.4-main.52d7546f51",
|
|
43
|
+
"@dxos/plugin-attention": "0.8.4-main.52d7546f51",
|
|
44
|
+
"@dxos/plugin-client": "0.8.4-main.52d7546f51",
|
|
45
|
+
"@dxos/plugin-deck": "0.8.4-main.52d7546f51",
|
|
46
|
+
"@dxos/react-client": "0.8.4-main.52d7546f51",
|
|
47
|
+
"@dxos/plugin-space": "0.8.4-main.52d7546f51",
|
|
48
|
+
"@dxos/react-ui": "0.8.4-main.52d7546f51",
|
|
49
|
+
"@dxos/react-ui-form": "0.8.4-main.52d7546f51",
|
|
50
|
+
"@dxos/react-ui-editor": "0.8.4-main.52d7546f51",
|
|
51
|
+
"@dxos/react-ui-table": "0.8.4-main.52d7546f51",
|
|
52
|
+
"@dxos/react-ui-menu": "0.8.4-main.52d7546f51",
|
|
53
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.52d7546f51",
|
|
54
|
+
"@dxos/schema": "0.8.4-main.52d7546f51",
|
|
55
|
+
"@dxos/types": "0.8.4-main.52d7546f51",
|
|
56
|
+
"@dxos/ui-editor": "0.8.4-main.52d7546f51",
|
|
57
|
+
"@dxos/ui-theme": "0.8.4-main.52d7546f51",
|
|
58
|
+
"@dxos/util": "0.8.4-main.52d7546f51"
|
|
51
59
|
},
|
|
52
60
|
"devDependencies": {
|
|
53
|
-
"effect": "3.
|
|
54
|
-
"react": "~19.2.
|
|
55
|
-
"react-dom": "~19.2.
|
|
61
|
+
"effect": "3.19.16",
|
|
62
|
+
"react": "~19.2.3",
|
|
63
|
+
"react-dom": "~19.2.3",
|
|
56
64
|
"vite": "7.1.9",
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
65
|
+
"@dxos/echo-db": "0.8.4-main.52d7546f51",
|
|
66
|
+
"@dxos/plugin-testing": "0.8.4-main.52d7546f51",
|
|
67
|
+
"@dxos/random": "0.8.4-main.52d7546f51",
|
|
68
|
+
"@dxos/react-ui-components": "0.8.4-main.52d7546f51",
|
|
69
|
+
"@dxos/storybook-utils": "0.8.4-main.52d7546f51"
|
|
59
70
|
},
|
|
60
71
|
"peerDependencies": {
|
|
61
|
-
"effect": "
|
|
62
|
-
"react": "
|
|
63
|
-
"react-dom": "
|
|
72
|
+
"effect": "3.19.16",
|
|
73
|
+
"react": "~19.2.3",
|
|
74
|
+
"react-dom": "~19.2.3"
|
|
64
75
|
},
|
|
65
76
|
"publishConfig": {
|
|
66
77
|
"access": "public"
|
package/src/PreviewPlugin.tsx
CHANGED
|
@@ -2,33 +2,22 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
9
|
import { PreviewPopover, ReactSurface } from './capabilities';
|
|
10
10
|
import { meta } from './meta';
|
|
11
11
|
import { translations } from './translations';
|
|
12
12
|
|
|
13
|
-
export const PreviewPlugin =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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,
|
|
13
|
+
export const PreviewPlugin = Plugin.define(meta).pipe(
|
|
14
|
+
AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization], id: 'schema' }),
|
|
15
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
16
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
17
|
+
Plugin.addModule({
|
|
18
|
+
id: 'preview-popover',
|
|
19
|
+
activatesOn: ActivationEvents.Startup,
|
|
27
20
|
activate: PreviewPopover,
|
|
28
21
|
}),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
activatesOn: Events.SetupReactSurface,
|
|
32
|
-
activate: ReactSurface,
|
|
33
|
-
}),
|
|
34
|
-
]);
|
|
22
|
+
Plugin.make,
|
|
23
|
+
);
|
|
@@ -2,7 +2,5 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const PreviewPopover = lazy(() => import('./preview-popover'));
|
|
8
|
-
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
5
|
+
export * from './preview-popover';
|
|
6
|
+
export * from './react-surface';
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
+
import { addEventListener } from '@dxos/async';
|
|
10
|
+
import { type Client } from '@dxos/client';
|
|
11
|
+
import { type Space, parseId } from '@dxos/client/echo';
|
|
12
|
+
import { Obj } from '@dxos/echo';
|
|
13
|
+
import { DXN } from '@dxos/keys';
|
|
14
|
+
import { log } from '@dxos/log';
|
|
15
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
16
|
+
import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';
|
|
17
|
+
import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/ui-editor';
|
|
18
|
+
|
|
19
|
+
const customEventOptions = { capture: true, passive: false };
|
|
20
|
+
|
|
21
|
+
const handlePreviewLookup = async (
|
|
22
|
+
client: Client,
|
|
23
|
+
defaultSpace: Space,
|
|
24
|
+
{ dxn, label }: PreviewLinkRef,
|
|
25
|
+
): Promise<PreviewLinkTarget | null> => {
|
|
26
|
+
try {
|
|
27
|
+
const object = await defaultSpace.db.makeRef(DXN.parse(dxn)).load();
|
|
28
|
+
return { label, object };
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
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 } = parseId(layout.workspace);
|
|
55
|
+
const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
|
|
56
|
+
const result = await handlePreviewLookup(client, space, { dxn, label });
|
|
57
|
+
if (!result) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const title = titleProp ?? Obj.getLabel(result.object);
|
|
62
|
+
|
|
63
|
+
await invokePromise(LayoutOperation.UpdatePopover, {
|
|
64
|
+
subjectRef: dxn,
|
|
65
|
+
subject: result.object,
|
|
66
|
+
state: true,
|
|
67
|
+
variant: 'virtual',
|
|
68
|
+
anchor: trigger,
|
|
69
|
+
...(kind && { kind }),
|
|
70
|
+
...(title && { title }),
|
|
71
|
+
...(side && { side }),
|
|
72
|
+
...(props && { props }),
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
let cleanup: () => void;
|
|
77
|
+
if (document.defaultView) {
|
|
78
|
+
cleanup = addEventListener(
|
|
79
|
+
document.defaultView,
|
|
80
|
+
DX_ANCHOR_ACTIVATE as any,
|
|
81
|
+
handleAnchorActivate,
|
|
82
|
+
customEventOptions,
|
|
83
|
+
);
|
|
84
|
+
} else {
|
|
85
|
+
log.warn('no default view found');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => cleanup?.()));
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
@@ -0,0 +1,97 @@
|
|
|
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 { Obj } from '@dxos/echo';
|
|
11
|
+
import { Card } from '@dxos/react-ui-mosaic';
|
|
12
|
+
import { type ProjectionModel } from '@dxos/schema';
|
|
13
|
+
import { Organization, Person, Pipeline, Task } from '@dxos/types';
|
|
14
|
+
|
|
15
|
+
import { FormCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../../cards';
|
|
16
|
+
import { meta } from '../../meta';
|
|
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: `${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 <PersonCard role={role} subject={data.subject} />;
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
Surface.create({
|
|
36
|
+
id: `${meta.id}/schema-popover--organization`,
|
|
37
|
+
role: 'card--content',
|
|
38
|
+
position: 'hoist',
|
|
39
|
+
filter: (data): data is { subject: Organization.Organization } =>
|
|
40
|
+
Obj.instanceOf(Organization.Organization, data.subject),
|
|
41
|
+
component: ({ data, role }) => {
|
|
42
|
+
return <OrganizationCard role={role} subject={data.subject} />;
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
Surface.create({
|
|
46
|
+
id: `${meta.id}/schema-popover--project`,
|
|
47
|
+
role: 'card--content',
|
|
48
|
+
position: 'hoist',
|
|
49
|
+
filter: (data): data is { subject: Pipeline.Pipeline } => Obj.instanceOf(Pipeline.Pipeline, data.subject),
|
|
50
|
+
component: ({ data, role }) => {
|
|
51
|
+
return <ProjectCard role={role} subject={data.subject} />;
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
Surface.create({
|
|
55
|
+
id: `${meta.id}/schema-popover--task`,
|
|
56
|
+
role: 'card--content',
|
|
57
|
+
position: 'hoist',
|
|
58
|
+
filter: (data): data is { subject: Task.Task } => Obj.instanceOf(Task.Task, data.subject),
|
|
59
|
+
component: ({ data, role }) => {
|
|
60
|
+
return <TaskCard role={role} subject={data.subject} />;
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
|
|
64
|
+
//
|
|
65
|
+
// Fallback for any object.
|
|
66
|
+
//
|
|
67
|
+
|
|
68
|
+
Surface.create({
|
|
69
|
+
id: `${meta.id}/fallback-popover`,
|
|
70
|
+
role: 'card--content',
|
|
71
|
+
position: 'fallback',
|
|
72
|
+
filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
|
|
73
|
+
component: ({ data, role }) => {
|
|
74
|
+
return <FormCard role={role} subject={data.subject} projection={data.projection} />;
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
|
|
78
|
+
Surface.create({
|
|
79
|
+
id: `${meta.id}/section`,
|
|
80
|
+
role: ['section'],
|
|
81
|
+
position: 'fallback',
|
|
82
|
+
filter: (data): data is { subject: Obj.Unknown } => Obj.isObject(data.subject),
|
|
83
|
+
component: ({ data }) => {
|
|
84
|
+
return (
|
|
85
|
+
<div role='none' className='flex is-full justify-center'>
|
|
86
|
+
<div role='none' className='pbs-2 pbe-2 card-min-width card-max-width'>
|
|
87
|
+
<Card.Root>
|
|
88
|
+
<Surface.Surface role='card--content' data={data} limit={1} />
|
|
89
|
+
</Card.Root>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
}),
|
|
95
|
+
]),
|
|
96
|
+
),
|
|
97
|
+
);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
8
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
11
|
+
import { type JsonPath, splitJsonPath } from '@dxos/effect';
|
|
12
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
13
|
+
import { Form, omitId } from '@dxos/react-ui-form';
|
|
14
|
+
import { type ProjectionModel } from '@dxos/schema';
|
|
15
|
+
import { descriptionMessage, mx } from '@dxos/ui-theme';
|
|
16
|
+
|
|
17
|
+
import { meta } from '../meta';
|
|
18
|
+
|
|
19
|
+
export const FormCard = ({ subject, projection }: SurfaceComponentProps & { projection?: ProjectionModel }) => {
|
|
20
|
+
const { t } = useTranslation(meta.id);
|
|
21
|
+
const { invokePromise } = useOperationInvoker();
|
|
22
|
+
const schema = Obj.getSchema(subject);
|
|
23
|
+
const label = Obj.getLabel(subject) ?? Obj.getTypename(subject) ?? t('unable to create preview message');
|
|
24
|
+
|
|
25
|
+
const handleNavigate = useCallback(async () => {
|
|
26
|
+
await invokePromise(LayoutOperation.UpdatePopover, { state: false, anchorId: '' });
|
|
27
|
+
await invokePromise(LayoutOperation.Open, { subject: [Obj.getDXN(subject).toString()] });
|
|
28
|
+
}, [invokePromise, subject]);
|
|
29
|
+
|
|
30
|
+
const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
|
|
31
|
+
const paths = Object.keys(changed).filter((path) => changed[path]);
|
|
32
|
+
Obj.change(subject, () => {
|
|
33
|
+
for (const path of paths) {
|
|
34
|
+
const value = values[path];
|
|
35
|
+
const parts = splitJsonPath(path as JsonPath);
|
|
36
|
+
Obj.setValue(subject, parts, value);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
if (!schema) {
|
|
42
|
+
// TODO(burdon): Use Alert.
|
|
43
|
+
return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Form.Root schema={omitId(schema)} projection={projection} values={subject} autoSave onSave={handleSave}>
|
|
48
|
+
{/* TODO(burdon): Scrolling issue. Need fixed height. */}
|
|
49
|
+
<Form.Viewport>
|
|
50
|
+
<Form.Content>
|
|
51
|
+
<Form.FieldSet />
|
|
52
|
+
</Form.Content>
|
|
53
|
+
</Form.Viewport>
|
|
54
|
+
</Form.Root>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { Card } from '@dxos/react-ui-mosaic';
|
|
9
|
+
import { type Organization } from '@dxos/types';
|
|
10
|
+
|
|
11
|
+
export const OrganizationCard = ({ subject }: SurfaceComponentProps<Organization.Organization>) => {
|
|
12
|
+
const { 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
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { Avatar } from '@dxos/react-ui';
|
|
9
|
+
import { Card } from '@dxos/react-ui-mosaic';
|
|
10
|
+
import { type Person } from '@dxos/types';
|
|
11
|
+
|
|
12
|
+
export const PersonCard = ({ subject }: SurfaceComponentProps<Person.Person>) => {
|
|
13
|
+
const { image, organization: { target: organization } = {}, emails = [] } = subject;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Avatar.Root>
|
|
17
|
+
<Card.Content>
|
|
18
|
+
{image && (
|
|
19
|
+
<Card.Row className='plb-1'>
|
|
20
|
+
<Avatar.Content
|
|
21
|
+
imgSrc={image}
|
|
22
|
+
icon='ph--user--regular'
|
|
23
|
+
size={16}
|
|
24
|
+
classNames={!image && 'opacity-50'}
|
|
25
|
+
hue='neutral'
|
|
26
|
+
variant='square'
|
|
27
|
+
/>
|
|
28
|
+
</Card.Row>
|
|
29
|
+
)}
|
|
30
|
+
{organization?.name && (
|
|
31
|
+
<Card.Action
|
|
32
|
+
icon='ph--buildings--regular'
|
|
33
|
+
label={organization.name}
|
|
34
|
+
// onClick={onSelect ? () => onSelect(organization) : undefined}
|
|
35
|
+
/>
|
|
36
|
+
)}
|
|
37
|
+
{emails.map(({ value }) => (
|
|
38
|
+
<Card.Row key={value} icon='ph--at--regular'>
|
|
39
|
+
<Card.Text truncate className='text-primaryText'>
|
|
40
|
+
{value}
|
|
41
|
+
</Card.Text>
|
|
42
|
+
</Card.Row>
|
|
43
|
+
))}
|
|
44
|
+
</Card.Content>
|
|
45
|
+
</Avatar.Root>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
import { Card } from '@dxos/react-ui-mosaic';
|
|
10
|
+
import { type Pipeline } from '@dxos/types';
|
|
11
|
+
|
|
12
|
+
export const ProjectCard = ({ subject }: SurfaceComponentProps<Pipeline.Pipeline>) => {
|
|
13
|
+
const { name, image, description } = subject;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Card.Content>
|
|
17
|
+
{image && <Card.Poster image={image} alt={Obj.getLabel(subject) ?? ''} aspect='auto' />}
|
|
18
|
+
{/* <CardHeader label={name} subject={subject} db={db} /> */}
|
|
19
|
+
{description && <Card.Text variant='description'>{description}</Card.Text>}
|
|
20
|
+
</Card.Content>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -5,18 +5,30 @@
|
|
|
5
5
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
9
|
import { type PropertyMetaAnnotation, PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
9
|
-
import { Card
|
|
10
|
-
import {
|
|
11
|
-
import { DataType } from '@dxos/schema';
|
|
10
|
+
import { Card } from '@dxos/react-ui-mosaic';
|
|
11
|
+
import { Task } from '@dxos/types';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
export const TaskCard = ({ subject }: SurfaceComponentProps<Task.Task>) => {
|
|
14
|
+
const { title, status } = subject;
|
|
15
|
+
const statusOption = getActiveStatusOption(status);
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
return (
|
|
18
|
+
<Card.Content>
|
|
19
|
+
<Card.Heading classNames='min-is-0 flex-1 truncate'>{title}</Card.Heading>
|
|
20
|
+
{statusOption && (
|
|
21
|
+
<span className='dx-tag' data-hue={statusOption.color}>
|
|
22
|
+
{statusOption.title}
|
|
23
|
+
</span>
|
|
24
|
+
)}
|
|
25
|
+
</Card.Content>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
16
28
|
|
|
17
29
|
// TODO(thure): Should this move upstream as a helper? Is there an easier way to get options?
|
|
18
30
|
const getActiveStatusOption = (status?: string) => {
|
|
19
|
-
const properties = SchemaAST.getPropertySignatures(
|
|
31
|
+
const properties = SchemaAST.getPropertySignatures(Task.Task.ast);
|
|
20
32
|
const statusProperty = properties.find((p) => p.name === 'status');
|
|
21
33
|
const statusMeta = SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(
|
|
22
34
|
// TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
|
|
@@ -26,21 +38,3 @@ const getActiveStatusOption = (status?: string) => {
|
|
|
26
38
|
(statusMeta as any).value.singleSelect.options as { id: string; title: string; color: string }[];
|
|
27
39
|
return options.find(({ id }) => id === status);
|
|
28
40
|
};
|
|
29
|
-
|
|
30
|
-
export const TaskCard = ({ subject, role, activeSpace }: PreviewProps<DataType.Task>) => {
|
|
31
|
-
const { title, status } = subject;
|
|
32
|
-
const statusOption = getActiveStatusOption(status);
|
|
33
|
-
return (
|
|
34
|
-
<Card.SurfaceRoot role={role}>
|
|
35
|
-
<div role='none' className={mx('flex items-center gap-2', cardSpacing)}>
|
|
36
|
-
<Card.Heading classNames={[cardNoSpacing, 'min-is-0 flex-1 truncate']}>{title}</Card.Heading>
|
|
37
|
-
{statusOption && (
|
|
38
|
-
<span className='dx-tag' data-hue={statusOption.color}>
|
|
39
|
-
{statusOption.title}
|
|
40
|
-
</span>
|
|
41
|
-
)}
|
|
42
|
-
<CardSubjectMenu subject={subject} activeSpace={activeSpace} />
|
|
43
|
-
</div>
|
|
44
|
-
</Card.SurfaceRoot>
|
|
45
|
-
);
|
|
46
|
-
};
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const meta:
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
8
9
|
id: 'dxos.org/plugin/preview',
|
|
9
10
|
name: 'Preview',
|
|
11
|
+
description: trim`
|
|
12
|
+
Rich preview panel for viewing object content without opening full editors.
|
|
13
|
+
Quick peek at documents, images, and data with inline rendering.
|
|
14
|
+
`,
|
|
10
15
|
icon: 'ph--eye--regular',
|
|
11
16
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',
|
|
12
17
|
};
|