@dxos/plugin-preview 0.8.4-main.28f8d3d → 0.8.4-main.406dc2a
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-Z73ENKLE.mjs → chunk-XKCIQK3C.mjs} +2 -4
- package/dist/lib/browser/chunk-XKCIQK3C.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +11 -7
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{preview-popover-MAIBTJKJ.mjs → preview-popover-RKHENTFP.mjs} +9 -13
- package/dist/lib/browser/preview-popover-RKHENTFP.mjs.map +7 -0
- package/dist/lib/browser/react-surface-X56QWACK.mjs +448 -0
- package/dist/lib/browser/react-surface-X56QWACK.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2ORSL4GJ.mjs → chunk-L3IZVX56.mjs} +2 -4
- package/dist/lib/node-esm/chunk-L3IZVX56.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +11 -7
- package/dist/lib/node-esm/index.mjs.map +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{preview-popover-LZGHYW23.mjs → preview-popover-TZKX67EY.mjs} +9 -13
- package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-4P7UCMK7.mjs +449 -0
- package/dist/lib/node-esm/react-surface-4P7UCMK7.mjs.map +7 -0
- package/dist/types/src/PreviewPlugin.d.ts +1 -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.d.ts +1 -1
- package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/CardSubjectMenu.d.ts +12 -0
- package/dist/types/src/components/CardSubjectMenu.d.ts.map +1 -0
- package/dist/types/src/components/ContactCard.d.ts +1 -1
- package/dist/types/src/components/ContactCard.d.ts.map +1 -1
- package/dist/types/src/components/OrganizationCard.d.ts +1 -1
- package/dist/types/src/components/OrganizationCard.d.ts.map +1 -1
- package/dist/types/src/components/ProjectCard.d.ts +1 -1
- package/dist/types/src/components/ProjectCard.d.ts.map +1 -1
- package/dist/types/src/components/TaskCard.d.ts +5 -0
- package/dist/types/src/components/TaskCard.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/stories/Card.stories.d.ts +27 -47
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +2 -3
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +6 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +3 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -29
- package/src/PreviewPlugin.tsx +22 -23
- package/src/capabilities/preview-popover.ts +7 -12
- package/src/capabilities/react-surface.tsx +47 -76
- package/src/components/CardSubjectMenu.tsx +82 -0
- package/src/components/ContactCard.tsx +9 -3
- package/src/components/OrganizationCard.tsx +11 -8
- package/src/components/ProjectCard.tsx +12 -4
- package/src/components/TaskCard.tsx +46 -0
- package/src/meta.ts +1 -3
- package/src/stories/Card.stories.tsx +23 -17
- package/src/stories/testing.tsx +15 -4
- package/src/translations.ts +6 -0
- package/src/types.ts +4 -1
- package/dist/lib/browser/chunk-Z73ENKLE.mjs.map +0 -7
- package/dist/lib/browser/preview-popover-MAIBTJKJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SC522FSX.mjs +0 -303
- package/dist/lib/browser/react-surface-SC522FSX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs.map +0 -7
- package/dist/lib/node-esm/preview-popover-LZGHYW23.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-PDXF35OF.mjs +0 -304
- package/dist/lib/node-esm/react-surface-PDXF35OF.mjs.map +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.406dc2a",
|
|
4
4
|
"description": "Preview plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -24,40 +24,43 @@
|
|
|
24
24
|
"src"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"@effect-rx/rx-react": "0.42.4",
|
|
27
28
|
"@preact-signals/safe-react": "^0.9.0",
|
|
28
|
-
"@dxos/
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/client": "0.8.4-main.
|
|
31
|
-
"@dxos/echo": "0.8.4-main.
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/log": "0.8.4-main.
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/plugin-client": "0.8.4-main.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/react-
|
|
42
|
-
"@dxos/react-ui-
|
|
43
|
-
"@dxos/react-ui-
|
|
44
|
-
"@dxos/react-ui-
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/react-ui-
|
|
47
|
-
"@dxos/
|
|
29
|
+
"@dxos/async": "0.8.4-main.406dc2a",
|
|
30
|
+
"@dxos/app-framework": "0.8.4-main.406dc2a",
|
|
31
|
+
"@dxos/client": "0.8.4-main.406dc2a",
|
|
32
|
+
"@dxos/echo": "0.8.4-main.406dc2a",
|
|
33
|
+
"@dxos/app-graph": "0.8.4-main.406dc2a",
|
|
34
|
+
"@dxos/keys": "0.8.4-main.406dc2a",
|
|
35
|
+
"@dxos/log": "0.8.4-main.406dc2a",
|
|
36
|
+
"@dxos/plugin-attention": "0.8.4-main.406dc2a",
|
|
37
|
+
"@dxos/lit-ui": "0.8.4-main.406dc2a",
|
|
38
|
+
"@dxos/plugin-client": "0.8.4-main.406dc2a",
|
|
39
|
+
"@dxos/plugin-deck": "0.8.4-main.406dc2a",
|
|
40
|
+
"@dxos/plugin-space": "0.8.4-main.406dc2a",
|
|
41
|
+
"@dxos/react-ui": "0.8.4-main.406dc2a",
|
|
42
|
+
"@dxos/react-client": "0.8.4-main.406dc2a",
|
|
43
|
+
"@dxos/react-ui-editor": "0.8.4-main.406dc2a",
|
|
44
|
+
"@dxos/react-ui-form": "0.8.4-main.406dc2a",
|
|
45
|
+
"@dxos/react-ui-menu": "0.8.4-main.406dc2a",
|
|
46
|
+
"@dxos/react-ui-table": "0.8.4-main.406dc2a",
|
|
47
|
+
"@dxos/react-ui-theme": "0.8.4-main.406dc2a",
|
|
48
|
+
"@dxos/schema": "0.8.4-main.406dc2a",
|
|
49
|
+
"@dxos/util": "0.8.4-main.406dc2a",
|
|
50
|
+
"@dxos/react-ui-stack": "0.8.4-main.406dc2a"
|
|
48
51
|
},
|
|
49
52
|
"devDependencies": {
|
|
50
|
-
"effect": "3.
|
|
51
|
-
"react": "~
|
|
52
|
-
"react-dom": "~
|
|
53
|
-
"vite": "
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
53
|
+
"effect": "3.18.3",
|
|
54
|
+
"react": "~19.2.0",
|
|
55
|
+
"react-dom": "~19.2.0",
|
|
56
|
+
"vite": "7.1.9",
|
|
57
|
+
"@dxos/storybook-utils": "0.8.4-main.406dc2a",
|
|
58
|
+
"@dxos/random": "0.8.4-main.406dc2a"
|
|
56
59
|
},
|
|
57
60
|
"peerDependencies": {
|
|
58
61
|
"effect": "^3.13.3",
|
|
59
|
-
"react": "
|
|
60
|
-
"react-dom": "
|
|
62
|
+
"react": "^19.0.0",
|
|
63
|
+
"react-dom": "^19.0.0"
|
|
61
64
|
},
|
|
62
65
|
"publishConfig": {
|
|
63
66
|
"access": "public"
|
package/src/PreviewPlugin.tsx
CHANGED
|
@@ -10,26 +10,25 @@ 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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
]);
|
|
13
|
+
export const PreviewPlugin = definePlugin(meta, () => [
|
|
14
|
+
defineModule({
|
|
15
|
+
id: `${meta.id}/module/translations`,
|
|
16
|
+
activatesOn: Events.SetupTranslations,
|
|
17
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
18
|
+
}),
|
|
19
|
+
defineModule({
|
|
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,
|
|
27
|
+
activate: PreviewPopover,
|
|
28
|
+
}),
|
|
29
|
+
defineModule({
|
|
30
|
+
id: `${meta.id}/module/react-surface`,
|
|
31
|
+
activatesOn: Events.SetupReactSurface,
|
|
32
|
+
activate: ReactSurface,
|
|
33
|
+
}),
|
|
34
|
+
]);
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import { Capabilities, LayoutAction, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
|
|
6
6
|
import { addEventListener } from '@dxos/async';
|
|
7
|
-
import { type Client
|
|
7
|
+
import { type Client } from '@dxos/client';
|
|
8
8
|
import { type Space, parseId } from '@dxos/client/echo';
|
|
9
9
|
import { DXN } from '@dxos/keys';
|
|
10
|
-
import { type DxRefTagActivate } from '@dxos/lit-ui';
|
|
11
10
|
import { log } from '@dxos/log';
|
|
12
11
|
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
12
|
+
import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';
|
|
13
13
|
import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';
|
|
14
14
|
|
|
15
15
|
const customEventOptions = { capture: true, passive: false };
|
|
@@ -20,21 +20,16 @@ const handlePreviewLookup = async (
|
|
|
20
20
|
{ ref, label }: PreviewLinkRef,
|
|
21
21
|
): Promise<PreviewLinkTarget | null> => {
|
|
22
22
|
try {
|
|
23
|
-
const
|
|
24
|
-
if (!dxn) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const object = await resolveRef(client, dxn, defaultSpace);
|
|
23
|
+
const object = await defaultSpace.db.ref(DXN.parse(ref)).load();
|
|
29
24
|
return { label, object };
|
|
30
|
-
} catch
|
|
25
|
+
} catch {
|
|
31
26
|
return null;
|
|
32
27
|
}
|
|
33
28
|
};
|
|
34
29
|
|
|
35
30
|
export default (context: PluginContext) => {
|
|
36
31
|
// TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
|
|
37
|
-
const
|
|
32
|
+
const handleDxAnchorActivate = async ({ refId, label, trigger }: DxAnchorActivate) => {
|
|
38
33
|
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
39
34
|
const client = context.getCapability(ClientCapabilities.Client);
|
|
40
35
|
const [layout] = context.getCapabilities(Capabilities.Layout);
|
|
@@ -62,8 +57,8 @@ export default (context: PluginContext) => {
|
|
|
62
57
|
if (document.defaultView) {
|
|
63
58
|
cleanup = addEventListener(
|
|
64
59
|
document.defaultView,
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
DX_ANCHOR_ACTIVATE as any,
|
|
61
|
+
handleDxAnchorActivate,
|
|
67
62
|
customEventOptions,
|
|
68
63
|
);
|
|
69
64
|
} else {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Effect } from 'effect';
|
|
6
5
|
import React, { useCallback } from 'react';
|
|
7
6
|
|
|
8
7
|
import {
|
|
@@ -15,20 +14,18 @@ import {
|
|
|
15
14
|
useIntentDispatcher,
|
|
16
15
|
} from '@dxos/app-framework';
|
|
17
16
|
import { fullyQualifiedId, getSchema, getSpace } from '@dxos/client/echo';
|
|
18
|
-
import {
|
|
19
|
-
import { type JsonPath, setValue } from '@dxos/echo
|
|
20
|
-
import {
|
|
21
|
-
import { ATTENDABLE_PATH_SEPARATOR, DeckAction } from '@dxos/plugin-deck/types';
|
|
22
|
-
import { useQuery, useSpace } from '@dxos/react-client/echo';
|
|
17
|
+
import { Obj } from '@dxos/echo';
|
|
18
|
+
import { type JsonPath, setValue } from '@dxos/echo/internal';
|
|
19
|
+
import { useActiveSpace } from '@dxos/plugin-space';
|
|
23
20
|
import { useTranslation } from '@dxos/react-ui';
|
|
24
21
|
import { Form } from '@dxos/react-ui-form';
|
|
25
22
|
import { Card } from '@dxos/react-ui-stack';
|
|
26
|
-
import { TableView } from '@dxos/react-ui-table/types';
|
|
27
23
|
import { descriptionMessage, mx } from '@dxos/react-ui-theme';
|
|
28
|
-
import { DataType } from '@dxos/schema';
|
|
24
|
+
import { DataType, type ProjectionModel } from '@dxos/schema';
|
|
29
25
|
|
|
30
26
|
import { ContactCard, OrganizationCard, ProjectCard } from '../components';
|
|
31
|
-
import {
|
|
27
|
+
import { TaskCard } from '../components/TaskCard';
|
|
28
|
+
import { meta } from '../meta';
|
|
32
29
|
|
|
33
30
|
export default () =>
|
|
34
31
|
contributes(Capabilities.ReactSurface, [
|
|
@@ -36,103 +33,76 @@ export default () =>
|
|
|
36
33
|
// Specific schema types.
|
|
37
34
|
//
|
|
38
35
|
createSurface({
|
|
39
|
-
id: `${
|
|
36
|
+
id: `${meta.id}/schema-popover--contact`,
|
|
40
37
|
role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
|
|
41
38
|
filter: (data): data is { subject: DataType.Person } => Obj.instanceOf(DataType.Person, data.subject),
|
|
42
39
|
component: ({ data, role }) => {
|
|
43
|
-
const { dispatch } = useIntentDispatcher();
|
|
40
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
44
41
|
const space = getSpace(data.subject);
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const currentSpaceOrgs = useQuery(space, Filter.type(DataType.Organization));
|
|
48
|
-
const currentSpaceViews = useQuery(space, Filter.type(DataType.View));
|
|
49
|
-
const defaultSpaceViews = useQuery(defaultSpace, Filter.type(DataType.View));
|
|
50
|
-
const currentSpaceOrgTable = currentSpaceViews.find(
|
|
51
|
-
(view) =>
|
|
52
|
-
view.query.typename === DataType.Organization.typename &&
|
|
53
|
-
Obj.instanceOf(TableView, view.presentation.target),
|
|
54
|
-
);
|
|
55
|
-
const defaultSpaceOrgTable = defaultSpaceViews.find(
|
|
56
|
-
(view) =>
|
|
57
|
-
view.query.typename === DataType.Organization.typename &&
|
|
58
|
-
Obj.instanceOf(TableView, view.presentation.target),
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
// TODO(wittjosiah): Generalized way of handling related objects navigation.
|
|
42
|
+
const activeSpace = useActiveSpace();
|
|
62
43
|
const handleOrgClick = useCallback(
|
|
63
44
|
(org: DataType.Organization) =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
);
|
|
75
|
-
if (view) {
|
|
76
|
-
const id = fullyQualifiedId(view);
|
|
77
|
-
yield* dispatch(
|
|
78
|
-
createIntent(LayoutAction.Open, {
|
|
79
|
-
part: 'main',
|
|
80
|
-
subject: [id],
|
|
81
|
-
options: { workspace: space?.id },
|
|
82
|
-
}),
|
|
83
|
-
);
|
|
84
|
-
yield* dispatch(
|
|
85
|
-
createIntent(DeckAction.ChangeCompanion, {
|
|
86
|
-
primary: id,
|
|
87
|
-
companion: [id, 'selected-objects'].join(ATTENDABLE_PATH_SEPARATOR),
|
|
88
|
-
}),
|
|
89
|
-
);
|
|
90
|
-
yield* dispatch(
|
|
91
|
-
createIntent(AttentionAction.Select, {
|
|
92
|
-
contextId: id,
|
|
93
|
-
selection: { mode: 'multi', ids: [org.id] },
|
|
94
|
-
}),
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
}).pipe(Effect.runPromise),
|
|
98
|
-
[dispatch, currentSpaceOrgs, currentSpaceOrgTable, defaultSpaceOrgTable],
|
|
45
|
+
dispatch(
|
|
46
|
+
createIntent(LayoutAction.Open, {
|
|
47
|
+
part: 'main',
|
|
48
|
+
subject: [fullyQualifiedId(org)],
|
|
49
|
+
options: {
|
|
50
|
+
workspace: space?.id,
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
),
|
|
54
|
+
[dispatch],
|
|
99
55
|
);
|
|
100
56
|
|
|
101
57
|
return (
|
|
102
|
-
<ContactCard role={role} subject={data.subject} onOrgClick={handleOrgClick}>
|
|
58
|
+
<ContactCard role={role} subject={data.subject} activeSpace={activeSpace} onOrgClick={handleOrgClick}>
|
|
103
59
|
{role === 'card--popover' && <Surface role='related' data={data} />}
|
|
104
60
|
</ContactCard>
|
|
105
61
|
);
|
|
106
62
|
},
|
|
107
63
|
}),
|
|
108
64
|
createSurface({
|
|
109
|
-
id: `${
|
|
65
|
+
id: `${meta.id}/schema-popover--organization`,
|
|
110
66
|
role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
|
|
111
67
|
filter: (data): data is { subject: DataType.Organization } => Obj.instanceOf(DataType.Organization, data.subject),
|
|
112
|
-
component: ({ data, role }) =>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
68
|
+
component: ({ data, role }) => {
|
|
69
|
+
const activeSpace = useActiveSpace();
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<OrganizationCard role={role} subject={data.subject} activeSpace={activeSpace}>
|
|
73
|
+
{role === 'card--popover' && <Surface role='related' data={data} />}
|
|
74
|
+
</OrganizationCard>
|
|
75
|
+
);
|
|
76
|
+
},
|
|
117
77
|
}),
|
|
118
78
|
createSurface({
|
|
119
|
-
id: `${
|
|
79
|
+
id: `${meta.id}/schema-popover--project`,
|
|
120
80
|
role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
|
|
121
81
|
filter: (data): data is { subject: DataType.Project } => Obj.instanceOf(DataType.Project, data.subject),
|
|
122
|
-
component: ({ data, role }) =>
|
|
82
|
+
component: ({ data, role }) => {
|
|
83
|
+
const activeSpace = useActiveSpace();
|
|
84
|
+
|
|
85
|
+
return <ProjectCard subject={data.subject} role={role} activeSpace={activeSpace} />;
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
createSurface({
|
|
89
|
+
id: `${meta.id}/schema-popover--task`,
|
|
90
|
+
role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
|
|
91
|
+
filter: (data): data is { subject: DataType.Task } => Obj.instanceOf(DataType.Task, data.subject),
|
|
92
|
+
component: ({ data, role }) => <TaskCard subject={data.subject} role={role} />,
|
|
123
93
|
}),
|
|
124
94
|
|
|
125
95
|
//
|
|
126
96
|
// Fallback for any object.
|
|
127
97
|
//
|
|
128
98
|
createSurface({
|
|
129
|
-
id: `${
|
|
99
|
+
id: `${meta.id}/fallback-popover`,
|
|
130
100
|
role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
|
|
131
101
|
position: 'fallback',
|
|
132
|
-
filter: (data): data is { subject: Obj.Any } => Obj.isObject(data.subject),
|
|
102
|
+
filter: (data): data is { subject: Obj.Any; projection?: ProjectionModel } => Obj.isObject(data.subject),
|
|
133
103
|
component: ({ data, role }) => {
|
|
134
104
|
const schema = getSchema(data.subject);
|
|
135
|
-
const { t } = useTranslation(
|
|
105
|
+
const { t } = useTranslation(meta.id);
|
|
136
106
|
if (!schema) {
|
|
137
107
|
// TODO(burdon): Use Alert.
|
|
138
108
|
return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
|
|
@@ -150,8 +120,9 @@ export default () =>
|
|
|
150
120
|
<Card.SurfaceRoot role={role}>
|
|
151
121
|
<Form
|
|
152
122
|
schema={schema}
|
|
123
|
+
projection={data.projection}
|
|
153
124
|
values={data.subject}
|
|
154
|
-
readonly={role === 'card--popover'}
|
|
125
|
+
readonly={role === 'card--popover' ? 'static' : false}
|
|
155
126
|
onSave={handleSave}
|
|
156
127
|
autoSave
|
|
157
128
|
{...(role === 'card--intrinsic' && { outerSpacing: 'blockStart-0' })}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Rx } from '@effect-rx/rx-react';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { LayoutAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
+
import { ACTION_TYPE } from '@dxos/app-graph';
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
11
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
12
|
+
import { type Space, fullyQualifiedId } from '@dxos/react-client/echo';
|
|
13
|
+
import { IconButton, type IconButtonProps, useTranslation } from '@dxos/react-ui';
|
|
14
|
+
import { type ActionGraphProps, DropdownMenu, MenuProvider, useMenuActions } from '@dxos/react-ui-menu';
|
|
15
|
+
|
|
16
|
+
import { meta } from '../meta';
|
|
17
|
+
|
|
18
|
+
const useSubjectMenuGroupItems = (subject: Obj.Any, activeSpace?: Space) => {
|
|
19
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
20
|
+
const result: ActionGraphProps = { edges: [], nodes: [] };
|
|
21
|
+
|
|
22
|
+
result.nodes.push({
|
|
23
|
+
type: ACTION_TYPE,
|
|
24
|
+
id: `${subject.id}/open`,
|
|
25
|
+
data: () => dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [fullyQualifiedId(subject)] })),
|
|
26
|
+
properties: {
|
|
27
|
+
label: ['open object label', { ns: meta.id }],
|
|
28
|
+
icon: 'ph--arrow-right--regular',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (activeSpace && Obj.getDXN(subject).asQueueDXN()) {
|
|
33
|
+
result.nodes.push({
|
|
34
|
+
type: ACTION_TYPE,
|
|
35
|
+
id: `${subject.id}/add-to-space`,
|
|
36
|
+
// TODO(wittjosiah): Update reference to point to db object when adding?
|
|
37
|
+
data: () => dispatch(createIntent(SpaceAction.AddObject, { object: subject, target: activeSpace, hidden: true })),
|
|
38
|
+
properties: {
|
|
39
|
+
label: ['add object to space label', { ns: meta.id }],
|
|
40
|
+
icon: 'ph--file-plus--regular',
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
result.nodes.forEach(({ id: target }) => {
|
|
46
|
+
result.edges.push({ source: 'root', target });
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return useMenuActions(Rx.make(result));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* This is a generic menu for objects that tries to infer common actions.
|
|
54
|
+
*/
|
|
55
|
+
export const CardSubjectMenu = ({
|
|
56
|
+
subject,
|
|
57
|
+
activeSpace,
|
|
58
|
+
...props
|
|
59
|
+
}: Omit<IconButtonProps, 'icon' | 'label'> & { subject: Obj.Any; activeSpace?: Space }) => {
|
|
60
|
+
const { t } = useTranslation(meta.id);
|
|
61
|
+
const menuProps = useSubjectMenuGroupItems(subject, activeSpace);
|
|
62
|
+
|
|
63
|
+
if (!activeSpace) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<MenuProvider {...menuProps}>
|
|
69
|
+
<DropdownMenu.Root>
|
|
70
|
+
<DropdownMenu.Trigger asChild>
|
|
71
|
+
<IconButton
|
|
72
|
+
iconOnly
|
|
73
|
+
variant='ghost'
|
|
74
|
+
icon='ph--dots-three-vertical--bold'
|
|
75
|
+
label={t('more options label')}
|
|
76
|
+
{...props}
|
|
77
|
+
/>
|
|
78
|
+
</DropdownMenu.Trigger>
|
|
79
|
+
</DropdownMenu.Root>
|
|
80
|
+
</MenuProvider>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
@@ -11,22 +11,27 @@ import { type DataType } from '@dxos/schema';
|
|
|
11
11
|
|
|
12
12
|
import { type PreviewProps } from '../types';
|
|
13
13
|
|
|
14
|
+
import { CardSubjectMenu } from './CardSubjectMenu';
|
|
15
|
+
|
|
14
16
|
export const ContactCard = ({
|
|
15
17
|
children,
|
|
16
|
-
subject
|
|
18
|
+
subject,
|
|
19
|
+
activeSpace,
|
|
17
20
|
onOrgClick,
|
|
18
21
|
role,
|
|
19
22
|
}: PreviewProps<DataType.Person> & { onOrgClick?: (org: DataType.Organization) => void }) => {
|
|
23
|
+
const { fullName, image, organization, emails } = subject;
|
|
20
24
|
const organizationName = organization && typeof organization === 'object' ? organization.target?.name : organization;
|
|
21
25
|
return (
|
|
22
26
|
<Card.SurfaceRoot role={role}>
|
|
23
27
|
<Avatar.Root>
|
|
24
28
|
<Card.Text role='group' classNames='grid gap-3 grid-cols-[min-content_1fr]'>
|
|
25
29
|
<Avatar.Content imgSrc={image} icon='ph--user--regular' size={16} hue='neutral' />
|
|
26
|
-
<div role='none' className='bs-min self-center'>
|
|
30
|
+
<div role='none' className='bs-min self-center flex items-center'>
|
|
27
31
|
<Avatar.Label asChild>
|
|
28
|
-
<h2 className={cardHeading}>{fullName}</h2>
|
|
32
|
+
<h2 className={mx(cardHeading, 'grow')}>{fullName}</h2>
|
|
29
33
|
</Avatar.Label>
|
|
34
|
+
<CardSubjectMenu subject={subject} activeSpace={activeSpace} />
|
|
30
35
|
</div>
|
|
31
36
|
</Card.Text>
|
|
32
37
|
</Avatar.Root>
|
|
@@ -57,6 +62,7 @@ export const ContactCard = ({
|
|
|
57
62
|
emails.map(({ label, value }) => (
|
|
58
63
|
<Fragment key={value}>
|
|
59
64
|
<dt>
|
|
65
|
+
<span className='sr-only'>{label}</span>
|
|
60
66
|
<Icon icon='ph--at--regular' size={5} />
|
|
61
67
|
</dt>
|
|
62
68
|
<dd key={value} className='break-words'>
|
|
@@ -5,20 +5,23 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { Icon } from '@dxos/react-ui';
|
|
8
|
-
import { Card } from '@dxos/react-ui-stack';
|
|
8
|
+
import { Card, cardNoSpacing, cardSpacing } from '@dxos/react-ui-stack';
|
|
9
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
9
10
|
import { type DataType } from '@dxos/schema';
|
|
10
11
|
|
|
11
12
|
import { type PreviewProps } from '../types';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}: PreviewProps<DataType.Organization>) => {
|
|
14
|
+
import { CardSubjectMenu } from './CardSubjectMenu';
|
|
15
|
+
|
|
16
|
+
export const OrganizationCard = ({ children, subject, role, activeSpace }: PreviewProps<DataType.Organization>) => {
|
|
17
|
+
const { name, image, description, website } = subject;
|
|
18
18
|
return (
|
|
19
19
|
<Card.SurfaceRoot role={role}>
|
|
20
20
|
<Card.Poster alt={name!} {...(image ? { image } : { icon: 'ph--building-office--regular' })} />
|
|
21
|
-
<
|
|
21
|
+
<div role='none' className={mx('flex items-center gap-2', cardSpacing)}>
|
|
22
|
+
<Card.Heading classNames={cardNoSpacing}>{name}</Card.Heading>
|
|
23
|
+
<CardSubjectMenu subject={subject} activeSpace={activeSpace} />
|
|
24
|
+
</div>
|
|
22
25
|
{description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
|
|
23
26
|
{website && (
|
|
24
27
|
<Card.Chrome>
|
|
@@ -30,7 +33,7 @@ export const OrganizationCard = ({
|
|
|
30
33
|
rel='noreferrer'
|
|
31
34
|
>
|
|
32
35
|
<Icon icon='ph--link--regular' size={5} classNames='text-subdued' />
|
|
33
|
-
<span className='
|
|
36
|
+
<span className='min-is-0 flex-1 truncate'>{website}</span>
|
|
34
37
|
<Icon icon='ph--arrow-square-out--regular' />
|
|
35
38
|
</a>
|
|
36
39
|
</Card.Chrome>
|
|
@@ -4,16 +4,24 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Obj } from '@dxos/echo';
|
|
8
|
+
import { Card, cardNoSpacing, cardSpacing } from '@dxos/react-ui-stack';
|
|
9
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
8
10
|
import { type DataType } from '@dxos/schema';
|
|
9
11
|
|
|
10
12
|
import { type PreviewProps } from '../types';
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
import { CardSubjectMenu } from './CardSubjectMenu';
|
|
15
|
+
|
|
16
|
+
export const ProjectCard = ({ subject, role, activeSpace }: PreviewProps<DataType.Project>) => {
|
|
17
|
+
const { name, image, description } = subject;
|
|
13
18
|
return (
|
|
14
19
|
<Card.SurfaceRoot role={role}>
|
|
15
|
-
{image && <Card.Poster image={image} alt={
|
|
16
|
-
<
|
|
20
|
+
{image && <Card.Poster image={image} alt={Obj.getLabel(subject) ?? ''} aspect='auto' />}
|
|
21
|
+
<div role='none' className={mx('flex items-center gap-2', cardSpacing)}>
|
|
22
|
+
<Card.Heading classNames={cardNoSpacing}>{name}</Card.Heading>
|
|
23
|
+
<CardSubjectMenu subject={subject} activeSpace={activeSpace} />
|
|
24
|
+
</div>
|
|
17
25
|
{description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
|
|
18
26
|
</Card.SurfaceRoot>
|
|
19
27
|
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { type PropertyMetaAnnotation, PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
9
|
+
import { Card, cardNoSpacing, cardSpacing } from '@dxos/react-ui-stack';
|
|
10
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
11
|
+
import { DataType } from '@dxos/schema';
|
|
12
|
+
|
|
13
|
+
import { type PreviewProps } from '../types';
|
|
14
|
+
|
|
15
|
+
import { CardSubjectMenu } from './CardSubjectMenu';
|
|
16
|
+
|
|
17
|
+
// TODO(thure): Should this move upstream as a helper? Is there an easier way to get options?
|
|
18
|
+
const getActiveStatusOption = (status?: string) => {
|
|
19
|
+
const properties = SchemaAST.getPropertySignatures(DataType.Task.ast);
|
|
20
|
+
const statusProperty = properties.find((p) => p.name === 'status');
|
|
21
|
+
const statusMeta = SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(
|
|
22
|
+
// TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
|
|
23
|
+
(statusProperty!.type as any).types[0],
|
|
24
|
+
);
|
|
25
|
+
const options = // TODO(thure): Typescript asserts `statusMeta` doesn’t have `.value`, but in runtime it does.
|
|
26
|
+
(statusMeta as any).value.singleSelect.options as { id: string; title: string; color: string }[];
|
|
27
|
+
return options.find(({ id }) => id === status);
|
|
28
|
+
};
|
|
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/meta.ts
CHANGED
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
export const PREVIEW_PLUGIN = 'dxos.org/plugin/preview';
|
|
8
|
-
|
|
9
7
|
export const meta: PluginMeta = {
|
|
10
|
-
id:
|
|
8
|
+
id: 'dxos.org/plugin/preview',
|
|
11
9
|
name: 'Preview',
|
|
12
10
|
icon: 'ph--eye--regular',
|
|
13
11
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',
|