@dxos/plugin-preview 0.8.4-main.3eb6e50203 → 0.8.4-main.422d1c7879
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +24 -20
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +25 -20
- 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 +2 -2
- 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 +13 -9
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +2 -2
- 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 +40 -39
- package/src/PreviewPlugin.tsx +3 -2
- package/src/capabilities/index.ts +4 -2
- package/src/capabilities/{preview-popover/preview-popover.ts → preview-popover.ts} +12 -6
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +39 -25
- package/src/cards/FormCard.tsx +17 -25
- 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 +4 -4
- 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 +40 -9
- package/src/stories/testing.tsx +36 -29
- 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-5YUZCO2D.mjs +0 -82
- package/dist/lib/browser/preview-popover-5YUZCO2D.mjs.map +0 -7
- package/dist/lib/browser/react-surface-W3FAIVY7.mjs +0 -251
- package/dist/lib/browser/react-surface-W3FAIVY7.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-7QRYVL73.mjs +0 -84
- package/dist/lib/node-esm/preview-popover-7QRYVL73.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-IO5DHYZB.mjs +0 -252
- package/dist/lib/node-esm/react-surface-IO5DHYZB.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/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.422d1c7879",
|
|
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",
|
|
@@ -20,56 +24,53 @@
|
|
|
20
24
|
}
|
|
21
25
|
},
|
|
22
26
|
"types": "dist/types/src/index.d.ts",
|
|
23
|
-
"typesVersions": {
|
|
24
|
-
"*": {}
|
|
25
|
-
},
|
|
26
27
|
"files": [
|
|
27
28
|
"dist",
|
|
28
29
|
"src"
|
|
29
30
|
],
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"@effect-atom/atom-react": "^0.5.0",
|
|
32
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/app-toolkit": "0.8.4-main.
|
|
35
|
-
"@dxos/client": "0.8.4-main.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/effect": "0.8.4-main.
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/plugin-attention": "0.8.4-main.
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
47
|
-
"@dxos/react-
|
|
48
|
-
"@dxos/react-ui-
|
|
49
|
-
"@dxos/react-ui-
|
|
50
|
-
"@dxos/react-ui-
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/ui-
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
33
|
+
"@dxos/app-framework": "0.8.4-main.422d1c7879",
|
|
34
|
+
"@dxos/async": "0.8.4-main.422d1c7879",
|
|
35
|
+
"@dxos/app-toolkit": "0.8.4-main.422d1c7879",
|
|
36
|
+
"@dxos/client": "0.8.4-main.422d1c7879",
|
|
37
|
+
"@dxos/echo": "0.8.4-main.422d1c7879",
|
|
38
|
+
"@dxos/lit-ui": "0.8.4-main.422d1c7879",
|
|
39
|
+
"@dxos/log": "0.8.4-main.422d1c7879",
|
|
40
|
+
"@dxos/effect": "0.8.4-main.422d1c7879",
|
|
41
|
+
"@dxos/keys": "0.8.4-main.422d1c7879",
|
|
42
|
+
"@dxos/operation": "0.8.4-main.422d1c7879",
|
|
43
|
+
"@dxos/plugin-attention": "0.8.4-main.422d1c7879",
|
|
44
|
+
"@dxos/plugin-client": "0.8.4-main.422d1c7879",
|
|
45
|
+
"@dxos/react-client": "0.8.4-main.422d1c7879",
|
|
46
|
+
"@dxos/react-ui": "0.8.4-main.422d1c7879",
|
|
47
|
+
"@dxos/react-ui-editor": "0.8.4-main.422d1c7879",
|
|
48
|
+
"@dxos/react-ui-form": "0.8.4-main.422d1c7879",
|
|
49
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.422d1c7879",
|
|
50
|
+
"@dxos/react-ui-table": "0.8.4-main.422d1c7879",
|
|
51
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.422d1c7879",
|
|
52
|
+
"@dxos/schema": "0.8.4-main.422d1c7879",
|
|
53
|
+
"@dxos/types": "0.8.4-main.422d1c7879",
|
|
54
|
+
"@dxos/react-ui-menu": "0.8.4-main.422d1c7879",
|
|
55
|
+
"@dxos/ui-editor": "0.8.4-main.422d1c7879",
|
|
56
|
+
"@dxos/ui-theme": "0.8.4-main.422d1c7879",
|
|
57
|
+
"@dxos/util": "0.8.4-main.422d1c7879",
|
|
58
|
+
"@dxos/plugin-deck": "0.8.4-main.422d1c7879",
|
|
59
|
+
"@dxos/app-graph": "0.8.4-main.422d1c7879"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
|
-
"effect": "3.
|
|
62
|
+
"effect": "3.20.0",
|
|
62
63
|
"react": "~19.2.3",
|
|
63
64
|
"react-dom": "~19.2.3",
|
|
64
|
-
"vite": "7.1.
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/random": "0.8.4-main.
|
|
68
|
-
"@dxos/react-ui-components": "0.8.4-main.
|
|
69
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
65
|
+
"vite": "^7.1.11",
|
|
66
|
+
"@dxos/echo-db": "0.8.4-main.422d1c7879",
|
|
67
|
+
"@dxos/plugin-testing": "0.8.4-main.422d1c7879",
|
|
68
|
+
"@dxos/random": "0.8.4-main.422d1c7879",
|
|
69
|
+
"@dxos/react-ui-components": "0.8.4-main.422d1c7879",
|
|
70
|
+
"@dxos/storybook-utils": "0.8.4-main.422d1c7879"
|
|
70
71
|
},
|
|
71
72
|
"peerDependencies": {
|
|
72
|
-
"effect": "3.
|
|
73
|
+
"effect": "3.20.0",
|
|
73
74
|
"react": "~19.2.3",
|
|
74
75
|
"react-dom": "~19.2.3"
|
|
75
76
|
},
|
package/src/PreviewPlugin.tsx
CHANGED
|
@@ -6,8 +6,9 @@ import { ActivationEvents, Plugin } from '@dxos/app-framework';
|
|
|
6
6
|
import { AppPlugin } from '@dxos/app-toolkit';
|
|
7
7
|
import { Organization, Person } from '@dxos/types';
|
|
8
8
|
|
|
9
|
-
import { PreviewPopover, ReactSurface } from '
|
|
10
|
-
import { meta } from '
|
|
9
|
+
import { PreviewPopover, ReactSurface } from '#capabilities';
|
|
10
|
+
import { meta } from '#meta';
|
|
11
|
+
|
|
11
12
|
import { translations } from './translations';
|
|
12
13
|
|
|
13
14
|
export const PreviewPlugin = Plugin.define(meta).pipe(
|
|
@@ -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'));
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
7
|
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
-
import { AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';
|
|
8
|
+
import { AppCapabilities, LayoutOperation, getPersonalSpace, getSpaceIdFromPath } from '@dxos/app-toolkit';
|
|
9
9
|
import { addEventListener } from '@dxos/async';
|
|
10
10
|
import { type Client } from '@dxos/client';
|
|
11
|
-
import { type Space
|
|
11
|
+
import { type Space } from '@dxos/client/echo';
|
|
12
12
|
import { Obj } from '@dxos/echo';
|
|
13
13
|
import { DXN } from '@dxos/keys';
|
|
14
14
|
import { log } from '@dxos/log';
|
|
15
|
-
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
15
|
+
import { ClientCapabilities } from '@dxos/plugin-client/types';
|
|
16
16
|
import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';
|
|
17
17
|
import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/ui-editor';
|
|
18
18
|
|
|
@@ -49,10 +49,16 @@ export default Capability.makeModule(
|
|
|
49
49
|
const { invokePromise } = capabilities.get(Capabilities.OperationInvoker);
|
|
50
50
|
const client = capabilities.get(ClientCapabilities.Client);
|
|
51
51
|
const registry = capabilities.get(Capabilities.AtomRegistry);
|
|
52
|
+
// Layout is optional: in standalone harnesses (Storybook, tests) no plugin contributes
|
|
53
|
+
// `AppCapabilities.Layout`, and `getAll` returns an empty array. Reading `registry.get(undefined)`
|
|
54
|
+
// would crash inside Atom's identity check (`'~atom/Serializable' in undefined`). When layout
|
|
55
|
+
// isn't available, fall through to the personal-space default.
|
|
52
56
|
const [layoutAtom] = capabilities.getAll(AppCapabilities.Layout);
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
57
|
+
const spaceId = layoutAtom && getSpaceIdFromPath(registry.get(layoutAtom).workspace);
|
|
58
|
+
const space = (spaceId && client.spaces.get(spaceId)) ?? getPersonalSpace(client);
|
|
59
|
+
if (!space) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
56
62
|
const result = await handlePreviewLookup(client, space, { dxn, label });
|
|
57
63
|
if (!result) {
|
|
58
64
|
return;
|
|
@@ -7,13 +7,13 @@ import React from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
9
|
import { Surface } from '@dxos/app-framework/ui';
|
|
10
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
10
11
|
import { Obj } from '@dxos/echo';
|
|
11
|
-
import { Card } from '@dxos/react-ui
|
|
12
|
+
import { Card } from '@dxos/react-ui';
|
|
12
13
|
import { type ProjectionModel } from '@dxos/schema';
|
|
13
14
|
import { Organization, Person, Pipeline, Task } from '@dxos/types';
|
|
14
15
|
|
|
15
|
-
import { FormCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '
|
|
16
|
-
import { meta } from '../../meta';
|
|
16
|
+
import { FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
17
17
|
|
|
18
18
|
export default Capability.makeModule(() =>
|
|
19
19
|
Effect.succeed(
|
|
@@ -24,38 +24,43 @@ export default Capability.makeModule(() =>
|
|
|
24
24
|
//
|
|
25
25
|
|
|
26
26
|
Surface.create<{ subject: Person.Person }>({
|
|
27
|
-
id:
|
|
28
|
-
role: 'card--content',
|
|
27
|
+
id: 'schema-popover--contact',
|
|
29
28
|
position: 'hoist',
|
|
30
|
-
filter: (
|
|
29
|
+
filter: AppSurface.object(AppSurface.Card, Person.Person),
|
|
31
30
|
component: ({ data, role }) => {
|
|
32
|
-
return
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<PersonCard role={role} subject={data.subject} />
|
|
34
|
+
<Surface.Surface type={AppSurface.Related} data={data} limit={1} />
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
33
37
|
},
|
|
34
38
|
}),
|
|
35
39
|
Surface.create({
|
|
36
|
-
id:
|
|
37
|
-
role: 'card--content',
|
|
40
|
+
id: 'schema-popover--organization',
|
|
38
41
|
position: 'hoist',
|
|
39
|
-
filter: (
|
|
40
|
-
Obj.instanceOf(Organization.Organization, data.subject),
|
|
42
|
+
filter: AppSurface.object(AppSurface.Card, Organization.Organization),
|
|
41
43
|
component: ({ data, role }) => {
|
|
42
|
-
return
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<OrganizationCard role={role} subject={data.subject} />
|
|
47
|
+
<Surface.Surface type={AppSurface.Related} data={data} limit={1} />
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
43
50
|
},
|
|
44
51
|
}),
|
|
45
52
|
Surface.create({
|
|
46
|
-
id:
|
|
47
|
-
role: 'card--content',
|
|
53
|
+
id: 'schema-popover--project',
|
|
48
54
|
position: 'hoist',
|
|
49
|
-
filter: (
|
|
55
|
+
filter: AppSurface.object(AppSurface.Card, Pipeline.Pipeline),
|
|
50
56
|
component: ({ data, role }) => {
|
|
51
57
|
return <ProjectCard role={role} subject={data.subject} />;
|
|
52
58
|
},
|
|
53
59
|
}),
|
|
54
60
|
Surface.create({
|
|
55
|
-
id:
|
|
56
|
-
role: 'card--content',
|
|
61
|
+
id: 'schema-popover--task',
|
|
57
62
|
position: 'hoist',
|
|
58
|
-
filter: (
|
|
63
|
+
filter: AppSurface.object(AppSurface.Card, Task.Task),
|
|
59
64
|
component: ({ data, role }) => {
|
|
60
65
|
return <TaskCard role={role} subject={data.subject} />;
|
|
61
66
|
},
|
|
@@ -66,7 +71,7 @@ export default Capability.makeModule(() =>
|
|
|
66
71
|
//
|
|
67
72
|
|
|
68
73
|
Surface.create({
|
|
69
|
-
id:
|
|
74
|
+
id: 'fallback-popover',
|
|
70
75
|
role: 'card--content',
|
|
71
76
|
position: 'fallback',
|
|
72
77
|
filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
|
|
@@ -76,16 +81,25 @@ export default Capability.makeModule(() =>
|
|
|
76
81
|
}),
|
|
77
82
|
|
|
78
83
|
Surface.create({
|
|
79
|
-
id:
|
|
80
|
-
role:
|
|
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
|
+
}),
|
|
92
|
+
|
|
93
|
+
Surface.create({
|
|
94
|
+
id: 'section',
|
|
81
95
|
position: 'fallback',
|
|
82
|
-
filter: (
|
|
96
|
+
filter: AppSurface.subject(AppSurface.Section, Obj.isObject),
|
|
83
97
|
component: ({ data }) => {
|
|
84
98
|
return (
|
|
85
|
-
<div role='none' className='flex
|
|
86
|
-
<div role='none' className='
|
|
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'>
|
|
87
101
|
<Card.Root>
|
|
88
|
-
<Surface.Surface
|
|
102
|
+
<Surface.Surface type={AppSurface.Card} data={data} limit={1} />
|
|
89
103
|
</Card.Root>
|
|
90
104
|
</div>
|
|
91
105
|
</div>
|
package/src/cards/FormCard.tsx
CHANGED
|
@@ -2,30 +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 { LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
-
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
10
8
|
import { Obj } from '@dxos/echo';
|
|
11
9
|
import { type JsonPath, splitJsonPath } from '@dxos/effect';
|
|
12
|
-
import { useTranslation } from '@dxos/react-ui';
|
|
10
|
+
import { Card, useTranslation } from '@dxos/react-ui';
|
|
13
11
|
import { Form, omitId } from '@dxos/react-ui-form';
|
|
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 }:
|
|
17
|
+
export const FormCard = ({ subject, projection }: AppSurface.ObjectCardProps & { projection?: ProjectionModel }) => {
|
|
20
18
|
const { t } = useTranslation(meta.id);
|
|
21
|
-
const
|
|
22
|
-
const schema =
|
|
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]);
|
|
19
|
+
const echoSchema = Obj.getSchema(subject);
|
|
20
|
+
const schema = useMemo(() => echoSchema && omitId(echoSchema), [echoSchema]);
|
|
29
21
|
|
|
30
22
|
const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
|
|
31
23
|
const paths = Object.keys(changed).filter((path) => changed[path]);
|
|
@@ -39,18 +31,18 @@ export const FormCard = ({ subject, projection }: SurfaceComponentProps & { proj
|
|
|
39
31
|
}, []);
|
|
40
32
|
|
|
41
33
|
if (!schema) {
|
|
42
|
-
|
|
43
|
-
return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
|
|
34
|
+
return <p className={mx(descriptionMessage)}>{t('unable-to-create-preview.message')}</p>;
|
|
44
35
|
}
|
|
45
36
|
|
|
46
37
|
return (
|
|
47
|
-
<
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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>
|
|
55
47
|
);
|
|
56
48
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Card } from '@dxos/react-ui';
|
|
8
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
9
|
+
|
|
10
|
+
export const JsonCard = ({ data }: { data: unknown }) => {
|
|
11
|
+
return (
|
|
12
|
+
<Card.Content>
|
|
13
|
+
<JsonHighlighter data={data} />
|
|
14
|
+
</Card.Content>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
@@ -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
|
|
9
|
+
import { Card } from '@dxos/react-ui';
|
|
10
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.
|
|
@@ -3,32 +3,32 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React from 'react';
|
|
6
7
|
|
|
7
8
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
8
9
|
import { corePlugins } from '@dxos/plugin-testing';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
10
|
+
import { random } from '@dxos/random';
|
|
11
|
+
import { Card } from '@dxos/react-ui';
|
|
12
|
+
import { withLayout } from '@dxos/react-ui/testing';
|
|
11
13
|
import { type Organization, type Person, type Pipeline, type Task } from '@dxos/types';
|
|
12
14
|
|
|
13
|
-
import { FormCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
15
|
+
import { FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
14
16
|
import { translations } from '../translations';
|
|
15
|
-
|
|
16
17
|
import { DefaultStory, createOrganization, createPerson, createProject, createTask } from './testing';
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
random.seed(999);
|
|
19
20
|
|
|
20
21
|
const meta = {
|
|
21
|
-
title: 'plugins/plugin-preview/Card',
|
|
22
|
+
title: 'plugins/plugin-preview/cards/Card',
|
|
22
23
|
render: DefaultStory,
|
|
23
24
|
decorators: [
|
|
24
|
-
|
|
25
|
-
withLayout({ layout: 'column', scroll: true }),
|
|
25
|
+
withLayout({ layout: 'fullscreen' }),
|
|
26
26
|
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
27
27
|
withPluginManager({ plugins: corePlugins() }),
|
|
28
28
|
],
|
|
29
29
|
parameters: {
|
|
30
|
-
translations,
|
|
31
30
|
layout: 'fullscreen',
|
|
31
|
+
translations,
|
|
32
32
|
},
|
|
33
33
|
tags: ['cards'],
|
|
34
34
|
} satisfies Meta<typeof DefaultStory>;
|
|
@@ -74,3 +74,34 @@ export const _Task: StoryObj<typeof DefaultStory<Task.Task>> = {
|
|
|
74
74
|
image: true,
|
|
75
75
|
},
|
|
76
76
|
};
|
|
77
|
+
|
|
78
|
+
export const _Json = {
|
|
79
|
+
render: () => {
|
|
80
|
+
const data = {
|
|
81
|
+
subject: {
|
|
82
|
+
id: random.string.uuid(),
|
|
83
|
+
name: random.person.fullName(),
|
|
84
|
+
email: random.internet.email(),
|
|
85
|
+
tags: [random.lorem.word(), random.lorem.word(), random.lorem.word()],
|
|
86
|
+
nested: {
|
|
87
|
+
count: random.number.int({ max: 100 }),
|
|
88
|
+
active: random.datatype.boolean(),
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div className='flex justify-center p-16'>
|
|
95
|
+
<div className='dx-card-min-width dx-card-max-width'>
|
|
96
|
+
<Card.Root>
|
|
97
|
+
<Card.Toolbar>
|
|
98
|
+
<Card.IconBlock />
|
|
99
|
+
<Card.Title>JSON</Card.Title>
|
|
100
|
+
</Card.Toolbar>
|
|
101
|
+
<JsonCard data={data} />
|
|
102
|
+
</Card.Root>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
};
|