@dxos/plugin-preview 0.8.4-main.4a85c3132b → 0.8.4-main.51f1e5ca51
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 +16 -31
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +21 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +17 -31
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +23 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- 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.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/cards/ExpandoCard.d.ts +4 -0
- package/dist/types/src/cards/ExpandoCard.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 +2 -0
- package/dist/types/src/cards/index.d.ts.map +1 -1
- package/dist/types/src/stories/Card.stories.d.ts +15 -9
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +4 -2
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -9
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +47 -39
- package/src/PreviewPlugin.tsx +3 -3
- 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} +45 -24
- package/src/cards/ExpandoCard.tsx +76 -0
- package/src/cards/FormCard.tsx +9 -8
- package/src/cards/JsonCard.tsx +19 -0
- package/src/cards/OrganizationCard.tsx +3 -3
- package/src/cards/PersonCard.tsx +27 -9
- package/src/cards/ProjectCard.tsx +2 -2
- package/src/cards/TaskCard.tsx +15 -11
- package/src/cards/index.ts +2 -0
- package/src/meta.ts +1 -1
- package/src/stories/Card.stories.tsx +50 -5
- package/src/stories/testing.tsx +26 -16
- 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-O25YV7AH.mjs +0 -233
- package/dist/lib/browser/react-surface-O25YV7AH.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-YA3XXW7A.mjs +0 -234
- package/dist/lib/node-esm/react-surface-YA3XXW7A.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.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.map +0 -1
- package/src/capabilities/preview-popover/index.ts +0 -7
- package/src/capabilities/react-surface/index.ts +0 -7
- /package/dist/types/src/capabilities/{preview-popover/preview-popover.d.ts → preview-popover.d.ts} +0 -0
- /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
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.51f1e5ca51",
|
|
4
4
|
"description": "Preview plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -12,64 +12,72 @@
|
|
|
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
|
+
"#translations": "./src/translations.ts"
|
|
19
|
+
},
|
|
15
20
|
"exports": {
|
|
16
21
|
".": {
|
|
17
22
|
"source": "./src/index.ts",
|
|
18
23
|
"types": "./dist/types/src/index.d.ts",
|
|
19
24
|
"browser": "./dist/lib/browser/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./translations": {
|
|
27
|
+
"source": "./src/translations.ts",
|
|
28
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
29
|
+
"browser": "./dist/lib/browser/translations.mjs",
|
|
30
|
+
"node": "./dist/lib/node-esm/translations.mjs"
|
|
20
31
|
}
|
|
21
32
|
},
|
|
22
33
|
"types": "dist/types/src/index.d.ts",
|
|
23
|
-
"typesVersions": {
|
|
24
|
-
"*": {}
|
|
25
|
-
},
|
|
26
34
|
"files": [
|
|
27
35
|
"dist",
|
|
28
36
|
"src"
|
|
29
37
|
],
|
|
30
38
|
"dependencies": {
|
|
31
39
|
"@effect-atom/atom-react": "^0.5.0",
|
|
32
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
33
|
-
"@dxos/app-toolkit": "0.8.4-main.
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/echo": "0.8.4-main.
|
|
37
|
-
"@dxos/effect": "0.8.4-main.
|
|
38
|
-
"@dxos/keys": "0.8.4-main.
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/plugin-
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/react-client": "0.8.4-main.
|
|
47
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
48
|
-
"@dxos/react-ui-
|
|
49
|
-
"@dxos/react-ui-
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/react-ui-
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/ui-
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/ui-
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
40
|
+
"@dxos/app-framework": "0.8.4-main.51f1e5ca51",
|
|
41
|
+
"@dxos/app-toolkit": "0.8.4-main.51f1e5ca51",
|
|
42
|
+
"@dxos/async": "0.8.4-main.51f1e5ca51",
|
|
43
|
+
"@dxos/app-graph": "0.8.4-main.51f1e5ca51",
|
|
44
|
+
"@dxos/echo": "0.8.4-main.51f1e5ca51",
|
|
45
|
+
"@dxos/effect": "0.8.4-main.51f1e5ca51",
|
|
46
|
+
"@dxos/keys": "0.8.4-main.51f1e5ca51",
|
|
47
|
+
"@dxos/log": "0.8.4-main.51f1e5ca51",
|
|
48
|
+
"@dxos/lit-ui": "0.8.4-main.51f1e5ca51",
|
|
49
|
+
"@dxos/operation": "0.8.4-main.51f1e5ca51",
|
|
50
|
+
"@dxos/plugin-attention": "0.8.4-main.51f1e5ca51",
|
|
51
|
+
"@dxos/plugin-client": "0.8.4-main.51f1e5ca51",
|
|
52
|
+
"@dxos/plugin-deck": "0.8.4-main.51f1e5ca51",
|
|
53
|
+
"@dxos/client": "0.8.4-main.51f1e5ca51",
|
|
54
|
+
"@dxos/react-client": "0.8.4-main.51f1e5ca51",
|
|
55
|
+
"@dxos/react-ui": "0.8.4-main.51f1e5ca51",
|
|
56
|
+
"@dxos/react-ui-form": "0.8.4-main.51f1e5ca51",
|
|
57
|
+
"@dxos/react-ui-editor": "0.8.4-main.51f1e5ca51",
|
|
58
|
+
"@dxos/react-ui-menu": "0.8.4-main.51f1e5ca51",
|
|
59
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.51f1e5ca51",
|
|
60
|
+
"@dxos/react-ui-table": "0.8.4-main.51f1e5ca51",
|
|
61
|
+
"@dxos/schema": "0.8.4-main.51f1e5ca51",
|
|
62
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.51f1e5ca51",
|
|
63
|
+
"@dxos/types": "0.8.4-main.51f1e5ca51",
|
|
64
|
+
"@dxos/ui-editor": "0.8.4-main.51f1e5ca51",
|
|
65
|
+
"@dxos/ui-theme": "0.8.4-main.51f1e5ca51",
|
|
66
|
+
"@dxos/util": "0.8.4-main.51f1e5ca51"
|
|
59
67
|
},
|
|
60
68
|
"devDependencies": {
|
|
61
|
-
"effect": "3.
|
|
69
|
+
"effect": "3.20.0",
|
|
62
70
|
"react": "~19.2.3",
|
|
63
71
|
"react-dom": "~19.2.3",
|
|
64
|
-
"vite": "^
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/react-ui-components": "0.8.4-main.
|
|
69
|
-
"@dxos/
|
|
72
|
+
"vite": "^8.0.10",
|
|
73
|
+
"@dxos/plugin-testing": "0.8.4-main.51f1e5ca51",
|
|
74
|
+
"@dxos/echo-db": "0.8.4-main.51f1e5ca51",
|
|
75
|
+
"@dxos/storybook-utils": "0.8.4-main.51f1e5ca51",
|
|
76
|
+
"@dxos/react-ui-components": "0.8.4-main.51f1e5ca51",
|
|
77
|
+
"@dxos/random": "0.8.4-main.51f1e5ca51"
|
|
70
78
|
},
|
|
71
79
|
"peerDependencies": {
|
|
72
|
-
"effect": "3.
|
|
80
|
+
"effect": "3.20.0",
|
|
73
81
|
"react": "~19.2.3",
|
|
74
82
|
"react-dom": "~19.2.3"
|
|
75
83
|
},
|
package/src/PreviewPlugin.tsx
CHANGED
|
@@ -6,9 +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 '
|
|
11
|
-
import { translations } from '
|
|
9
|
+
import { PreviewPopover, ReactSurface } from '#capabilities';
|
|
10
|
+
import { meta } from '#meta';
|
|
11
|
+
import { translations } from '#translations';
|
|
12
12
|
|
|
13
13
|
export const PreviewPlugin = Plugin.define(meta).pipe(
|
|
14
14
|
AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization], id: 'schema' }),
|
|
@@ -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
12
|
import { Card } from '@dxos/react-ui';
|
|
12
|
-
import { type ProjectionModel } from '@dxos/schema';
|
|
13
|
+
import { Expando, 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 { ExpandoCard, FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
17
17
|
|
|
18
18
|
export default Capability.makeModule(() =>
|
|
19
19
|
Effect.succeed(
|
|
@@ -24,49 +24,61 @@ 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
|
},
|
|
62
67
|
}),
|
|
68
|
+
Surface.create<AppSurface.ObjectCardData<Expando.Expando>>({
|
|
69
|
+
id: 'schema-popover--expando',
|
|
70
|
+
filter: AppSurface.object(AppSurface.Card, Expando.Expando),
|
|
71
|
+
component: ({ data, role }) => {
|
|
72
|
+
return <ExpandoCard role={role} subject={data.subject} ignorePaths={data.ignorePaths} />;
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
63
75
|
|
|
64
76
|
//
|
|
65
77
|
// Fallback for any object.
|
|
66
78
|
//
|
|
67
79
|
|
|
68
80
|
Surface.create({
|
|
69
|
-
id:
|
|
81
|
+
id: 'fallback-popover',
|
|
70
82
|
role: 'card--content',
|
|
71
83
|
position: 'fallback',
|
|
72
84
|
filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
|
|
@@ -76,16 +88,25 @@ export default Capability.makeModule(() =>
|
|
|
76
88
|
}),
|
|
77
89
|
|
|
78
90
|
Surface.create({
|
|
79
|
-
id:
|
|
80
|
-
role:
|
|
91
|
+
id: 'fallback-json',
|
|
92
|
+
role: 'card--content',
|
|
93
|
+
position: 'fallback',
|
|
94
|
+
filter: (data): data is Record<string, unknown> => true,
|
|
95
|
+
component: ({ data }) => {
|
|
96
|
+
return <JsonCard data={data} />;
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
|
|
100
|
+
Surface.create({
|
|
101
|
+
id: 'section',
|
|
81
102
|
position: 'fallback',
|
|
82
|
-
filter: (
|
|
103
|
+
filter: AppSurface.subject(AppSurface.Section, Obj.isObject),
|
|
83
104
|
component: ({ data }) => {
|
|
84
105
|
return (
|
|
85
106
|
<div role='none' className='flex w-full justify-center'>
|
|
86
|
-
<div role='none' className='
|
|
107
|
+
<div role='none' className='py-2 dx-card-min-width dx-card-max-width'>
|
|
87
108
|
<Card.Root>
|
|
88
|
-
<Surface.Surface
|
|
109
|
+
<Surface.Surface type={AppSurface.Card} data={data} limit={1} />
|
|
89
110
|
</Card.Root>
|
|
90
111
|
</div>
|
|
91
112
|
</div>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import React, { useCallback, useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { type JsonPath, splitJsonPath } from '@dxos/effect';
|
|
11
|
+
import { Card } from '@dxos/react-ui';
|
|
12
|
+
import { Form } from '@dxos/react-ui-form';
|
|
13
|
+
|
|
14
|
+
const schemaForValue = (value: unknown): Schema.Schema.AnyNoContext | undefined => {
|
|
15
|
+
switch (typeof value) {
|
|
16
|
+
case 'string':
|
|
17
|
+
return Schema.String;
|
|
18
|
+
case 'number':
|
|
19
|
+
return Schema.Number;
|
|
20
|
+
case 'boolean':
|
|
21
|
+
return Schema.Boolean;
|
|
22
|
+
default:
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Reserved keys: `id`, plus any `~`-prefixed key (ECHO uses `~`-prefixed
|
|
29
|
+
* string keys to brand entity instances and schemas — KindId,
|
|
30
|
+
* SchemaKindId, SnapshotKindId, etc. — and the `~` namespace is reserved
|
|
31
|
+
* for that purpose). They show up in `Object.keys` but aren't user data.
|
|
32
|
+
*/
|
|
33
|
+
const isInternalKey = (key: string) => key === 'id' || key.startsWith('~');
|
|
34
|
+
|
|
35
|
+
export const ExpandoCard = ({ subject, ignorePaths }: AppSurface.ObjectCardProps) => {
|
|
36
|
+
const schema = useMemo(() => {
|
|
37
|
+
const ignored = new Set(ignorePaths ?? []);
|
|
38
|
+
const fields: Record<string, Schema.Schema.AnyNoContext> = {};
|
|
39
|
+
for (const key of Object.keys(subject)) {
|
|
40
|
+
if (isInternalKey(key) || ignored.has(key)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const fieldSchema = schemaForValue((subject as any)[key]);
|
|
44
|
+
if (fieldSchema) {
|
|
45
|
+
fields[key] = fieldSchema;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return Schema.Struct(fields);
|
|
49
|
+
}, [subject, ignorePaths]);
|
|
50
|
+
|
|
51
|
+
const handleSave = useCallback(
|
|
52
|
+
(values: any, { changed }: { changed: Record<string, boolean> }) => {
|
|
53
|
+
const paths = Object.keys(changed).filter((path) => changed[path]);
|
|
54
|
+
Obj.update(subject, () => {
|
|
55
|
+
for (const path of paths) {
|
|
56
|
+
const value = values[path];
|
|
57
|
+
const parts = splitJsonPath(path as JsonPath);
|
|
58
|
+
Obj.setValue(subject, parts, value);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
[subject],
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Card.Content>
|
|
67
|
+
<Form.Root schema={schema} values={subject} autoSave onSave={handleSave}>
|
|
68
|
+
<Form.Viewport>
|
|
69
|
+
<Form.Content>
|
|
70
|
+
<Form.FieldSet />
|
|
71
|
+
</Form.Content>
|
|
72
|
+
</Form.Viewport>
|
|
73
|
+
</Form.Root>
|
|
74
|
+
</Card.Content>
|
|
75
|
+
);
|
|
76
|
+
};
|
package/src/cards/FormCard.tsx
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
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 { type
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { Obj } from '@dxos/echo';
|
|
9
9
|
import { type JsonPath, splitJsonPath } from '@dxos/effect';
|
|
10
10
|
import { Card, useTranslation } from '@dxos/react-ui';
|
|
@@ -12,15 +12,16 @@ import { Form, omitId } from '@dxos/react-ui-form';
|
|
|
12
12
|
import { type ProjectionModel } from '@dxos/schema';
|
|
13
13
|
import { descriptionMessage, mx } from '@dxos/ui-theme';
|
|
14
14
|
|
|
15
|
-
import { meta } from '
|
|
15
|
+
import { meta } from '#meta';
|
|
16
16
|
|
|
17
|
-
export const FormCard = ({ subject, projection }:
|
|
17
|
+
export const FormCard = ({ subject, projection }: AppSurface.ObjectCardProps & { projection?: ProjectionModel }) => {
|
|
18
18
|
const { t } = useTranslation(meta.id);
|
|
19
|
-
const
|
|
19
|
+
const echoSchema = Obj.getSchema(subject);
|
|
20
|
+
const schema = useMemo(() => echoSchema && omitId(echoSchema), [echoSchema]);
|
|
20
21
|
|
|
21
22
|
const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
|
|
22
23
|
const paths = Object.keys(changed).filter((path) => changed[path]);
|
|
23
|
-
Obj.
|
|
24
|
+
Obj.update(subject, () => {
|
|
24
25
|
for (const path of paths) {
|
|
25
26
|
const value = values[path];
|
|
26
27
|
const parts = splitJsonPath(path as JsonPath);
|
|
@@ -30,12 +31,12 @@ export const FormCard = ({ subject, projection }: SurfaceComponentProps & { proj
|
|
|
30
31
|
}, []);
|
|
31
32
|
|
|
32
33
|
if (!schema) {
|
|
33
|
-
return <p className={mx(descriptionMessage)}>{t('unable
|
|
34
|
+
return <p className={mx(descriptionMessage)}>{t('unable-to-create-preview.message')}</p>;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
return (
|
|
37
38
|
<Card.Content>
|
|
38
|
-
<Form.Root schema={
|
|
39
|
+
<Form.Root schema={schema} projection={projection} values={subject} autoSave onSave={handleSave}>
|
|
39
40
|
<Form.Viewport>
|
|
40
41
|
<Form.Content>
|
|
41
42
|
<Form.FieldSet />
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
<span />
|
|
14
|
+
{/* TODO(wittjosiah): Span whole row. */}
|
|
15
|
+
<JsonHighlighter data={data} />
|
|
16
|
+
<span />
|
|
17
|
+
</Card.Content>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -4,12 +4,12 @@
|
|
|
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 { 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,16 +2,38 @@
|
|
|
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
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
38
|
<Card.Content>
|
|
17
39
|
<Avatar.Root>
|
|
@@ -20,7 +42,7 @@ export const PersonCard = ({ subject }: SurfaceComponentProps<Person.Person>) =>
|
|
|
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,11 +50,7 @@ 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'>
|
|
@@ -4,12 +4,12 @@
|
|
|
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
9
|
import { Card } from '@dxos/react-ui';
|
|
10
10
|
import { type Pipeline } from '@dxos/types';
|
|
11
11
|
|
|
12
|
-
export const ProjectCard = ({ subject }:
|
|
12
|
+
export const ProjectCard = ({ subject }: AppSurface.ObjectCardProps<Pipeline.Pipeline>) => {
|
|
13
13
|
const { image, description } = subject;
|
|
14
14
|
|
|
15
15
|
return (
|
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
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.
|