@dxos/plugin-preview 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7
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 → chunk-KLQDOIFV.mjs} +2 -2
- package/dist/lib/browser/{chunk-XLN6KTHK.mjs.map → chunk-KLQDOIFV.mjs.map} +1 -1
- package/dist/lib/browser/index.mjs +10 -9
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{preview-popover-Y67LE6TV.mjs → preview-popover-X2ZJM5MK.mjs} +18 -15
- package/dist/lib/browser/preview-popover-X2ZJM5MK.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-XYEFQ6NI.mjs → react-surface-ZXZXNERQ.mjs} +49 -79
- package/dist/lib/browser/react-surface-ZXZXNERQ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2G4FUGDA.mjs → chunk-GFWHEHC5.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-2G4FUGDA.mjs.map → chunk-GFWHEHC5.mjs.map} +1 -1
- package/dist/lib/node-esm/index.mjs +10 -9
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{preview-popover-BGV2P6UX.mjs → preview-popover-6FLDJHHB.mjs} +18 -15
- package/dist/lib/node-esm/preview-popover-6FLDJHHB.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-PSUCURVT.mjs → react-surface-UVSIV3HW.mjs} +49 -79
- package/dist/lib/node-esm/react-surface-UVSIV3HW.mjs.map +7 -0
- package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts +1 -1
- package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
- package/dist/types/src/cards/FormCard.d.ts +1 -1
- package/dist/types/src/cards/FormCard.d.ts.map +1 -1
- package/dist/types/src/cards/OrganizationCard.d.ts +1 -1
- package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
- package/dist/types/src/cards/PersonCard.d.ts +1 -1
- package/dist/types/src/cards/PersonCard.d.ts.map +1 -1
- package/dist/types/src/cards/ProjectCard.d.ts +3 -3
- package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
- package/dist/types/src/cards/TaskCard.d.ts +1 -1
- package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
- package/dist/types/src/stories/Card.stories.d.ts +4 -3
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +3 -3
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -36
- package/src/PreviewPlugin.tsx +6 -5
- package/src/capabilities/preview-popover/preview-popover.ts +26 -13
- package/src/capabilities/react-surface/react-surface.tsx +21 -21
- package/src/cards/FormCard.tsx +8 -24
- package/src/cards/OrganizationCard.tsx +2 -2
- package/src/cards/PersonCard.tsx +8 -8
- package/src/cards/ProjectCard.tsx +5 -5
- package/src/cards/TaskCard.tsx +16 -16
- package/src/meta.ts +1 -1
- package/src/stories/Card.stories.tsx +15 -7
- package/src/stories/testing.tsx +24 -17
- package/dist/lib/browser/preview-popover-Y67LE6TV.mjs.map +0 -7
- package/dist/lib/browser/react-surface-XYEFQ6NI.mjs.map +0 -7
- package/dist/lib/node-esm/preview-popover-BGV2P6UX.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-PSUCURVT.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.6fa680abb7",
|
|
4
4
|
"description": "Preview plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -28,47 +28,48 @@
|
|
|
28
28
|
"src"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@effect-atom/atom-react": "^0.
|
|
32
|
-
"@dxos/app-
|
|
33
|
-
"@dxos/app-
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/plugin-
|
|
44
|
-
"@dxos/plugin-
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/plugin-deck": "0.8.4-main.
|
|
47
|
-
"@dxos/react-
|
|
48
|
-
"@dxos/react-ui
|
|
49
|
-
"@dxos/react-ui-
|
|
50
|
-
"@dxos/react-ui-
|
|
51
|
-
"@dxos/react-ui-
|
|
52
|
-
"@dxos/react-ui-
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/ui-
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
31
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
32
|
+
"@dxos/app-framework": "0.8.4-main.6fa680abb7",
|
|
33
|
+
"@dxos/app-toolkit": "0.8.4-main.6fa680abb7",
|
|
34
|
+
"@dxos/app-graph": "0.8.4-main.6fa680abb7",
|
|
35
|
+
"@dxos/echo": "0.8.4-main.6fa680abb7",
|
|
36
|
+
"@dxos/client": "0.8.4-main.6fa680abb7",
|
|
37
|
+
"@dxos/effect": "0.8.4-main.6fa680abb7",
|
|
38
|
+
"@dxos/keys": "0.8.4-main.6fa680abb7",
|
|
39
|
+
"@dxos/lit-ui": "0.8.4-main.6fa680abb7",
|
|
40
|
+
"@dxos/async": "0.8.4-main.6fa680abb7",
|
|
41
|
+
"@dxos/log": "0.8.4-main.6fa680abb7",
|
|
42
|
+
"@dxos/operation": "0.8.4-main.6fa680abb7",
|
|
43
|
+
"@dxos/plugin-attention": "0.8.4-main.6fa680abb7",
|
|
44
|
+
"@dxos/plugin-client": "0.8.4-main.6fa680abb7",
|
|
45
|
+
"@dxos/plugin-space": "0.8.4-main.6fa680abb7",
|
|
46
|
+
"@dxos/plugin-deck": "0.8.4-main.6fa680abb7",
|
|
47
|
+
"@dxos/react-client": "0.8.4-main.6fa680abb7",
|
|
48
|
+
"@dxos/react-ui": "0.8.4-main.6fa680abb7",
|
|
49
|
+
"@dxos/react-ui-form": "0.8.4-main.6fa680abb7",
|
|
50
|
+
"@dxos/react-ui-editor": "0.8.4-main.6fa680abb7",
|
|
51
|
+
"@dxos/react-ui-menu": "0.8.4-main.6fa680abb7",
|
|
52
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.6fa680abb7",
|
|
53
|
+
"@dxos/react-ui-table": "0.8.4-main.6fa680abb7",
|
|
54
|
+
"@dxos/ui-editor": "0.8.4-main.6fa680abb7",
|
|
55
|
+
"@dxos/ui-theme": "0.8.4-main.6fa680abb7",
|
|
56
|
+
"@dxos/util": "0.8.4-main.6fa680abb7",
|
|
57
|
+
"@dxos/types": "0.8.4-main.6fa680abb7",
|
|
58
|
+
"@dxos/schema": "0.8.4-main.6fa680abb7"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"effect": "3.19.
|
|
61
|
+
"effect": "3.19.16",
|
|
61
62
|
"react": "~19.2.3",
|
|
62
63
|
"react-dom": "~19.2.3",
|
|
63
|
-
"vite": "7.1.
|
|
64
|
-
"@dxos/echo-db": "0.8.4-main.
|
|
65
|
-
"@dxos/plugin-testing": "0.8.4-main.
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/react-ui-components": "0.8.4-main.
|
|
68
|
-
"@dxos/
|
|
64
|
+
"vite": "^7.1.11",
|
|
65
|
+
"@dxos/echo-db": "0.8.4-main.6fa680abb7",
|
|
66
|
+
"@dxos/plugin-testing": "0.8.4-main.6fa680abb7",
|
|
67
|
+
"@dxos/storybook-utils": "0.8.4-main.6fa680abb7",
|
|
68
|
+
"@dxos/react-ui-components": "0.8.4-main.6fa680abb7",
|
|
69
|
+
"@dxos/random": "0.8.4-main.6fa680abb7"
|
|
69
70
|
},
|
|
70
71
|
"peerDependencies": {
|
|
71
|
-
"effect": "3.19.
|
|
72
|
+
"effect": "3.19.16",
|
|
72
73
|
"react": "~19.2.3",
|
|
73
74
|
"react-dom": "~19.2.3"
|
|
74
75
|
},
|
package/src/PreviewPlugin.tsx
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { ActivationEvents, Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
6
7
|
import { Organization, Person } from '@dxos/types';
|
|
7
8
|
|
|
8
9
|
import { PreviewPopover, ReactSurface } from './capabilities';
|
|
@@ -10,12 +11,12 @@ import { meta } from './meta';
|
|
|
10
11
|
import { translations } from './translations';
|
|
11
12
|
|
|
12
13
|
export const PreviewPlugin = Plugin.define(meta).pipe(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization], id: 'schema' }),
|
|
15
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
16
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
16
17
|
Plugin.addModule({
|
|
17
18
|
id: 'preview-popover',
|
|
18
|
-
activatesOn:
|
|
19
|
+
activatesOn: ActivationEvents.Startup,
|
|
19
20
|
activate: PreviewPopover,
|
|
20
21
|
}),
|
|
21
22
|
Plugin.make,
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities, LayoutOperation, getSpaceIdFromPath } from '@dxos/app-toolkit';
|
|
8
9
|
import { addEventListener } from '@dxos/async';
|
|
9
10
|
import { type Client } from '@dxos/client';
|
|
10
|
-
import { type Space
|
|
11
|
+
import { type Space } from '@dxos/client/echo';
|
|
12
|
+
import { Obj } from '@dxos/echo';
|
|
11
13
|
import { DXN } from '@dxos/keys';
|
|
12
14
|
import { log } from '@dxos/log';
|
|
13
15
|
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
@@ -19,10 +21,10 @@ const customEventOptions = { capture: true, passive: false };
|
|
|
19
21
|
const handlePreviewLookup = async (
|
|
20
22
|
client: Client,
|
|
21
23
|
defaultSpace: Space,
|
|
22
|
-
{
|
|
24
|
+
{ dxn, label }: PreviewLinkRef,
|
|
23
25
|
): Promise<PreviewLinkTarget | null> => {
|
|
24
26
|
try {
|
|
25
|
-
const object = await defaultSpace.db.makeRef(DXN.parse(
|
|
27
|
+
const object = await defaultSpace.db.makeRef(DXN.parse(dxn)).load();
|
|
26
28
|
return { label, object };
|
|
27
29
|
} catch {
|
|
28
30
|
return null;
|
|
@@ -35,20 +37,31 @@ export default Capability.makeModule(
|
|
|
35
37
|
const capabilities = yield* Capability.Service;
|
|
36
38
|
|
|
37
39
|
// TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
|
|
38
|
-
const handleAnchorActivate = async ({
|
|
39
|
-
|
|
40
|
+
const handleAnchorActivate = async ({
|
|
41
|
+
dxn,
|
|
42
|
+
label,
|
|
43
|
+
trigger,
|
|
44
|
+
kind = 'card',
|
|
45
|
+
title: titleProp,
|
|
46
|
+
side,
|
|
47
|
+
props,
|
|
48
|
+
}: DxAnchorActivate) => {
|
|
49
|
+
const { invokePromise } = capabilities.get(Capabilities.OperationInvoker);
|
|
40
50
|
const client = capabilities.get(ClientCapabilities.Client);
|
|
41
|
-
const registry = capabilities.get(
|
|
42
|
-
const [layoutAtom] = capabilities.getAll(
|
|
51
|
+
const registry = capabilities.get(Capabilities.AtomRegistry);
|
|
52
|
+
const [layoutAtom] = capabilities.getAll(AppCapabilities.Layout);
|
|
43
53
|
const layout = registry.get(layoutAtom);
|
|
44
|
-
const
|
|
54
|
+
const spaceId = getSpaceIdFromPath(layout.workspace);
|
|
45
55
|
const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
|
|
46
|
-
const result = await handlePreviewLookup(client, space, {
|
|
56
|
+
const result = await handlePreviewLookup(client, space, { dxn, label });
|
|
47
57
|
if (!result) {
|
|
48
58
|
return;
|
|
49
59
|
}
|
|
50
60
|
|
|
51
|
-
|
|
61
|
+
const title = titleProp ?? Obj.getLabel(result.object);
|
|
62
|
+
|
|
63
|
+
await invokePromise(LayoutOperation.UpdatePopover, {
|
|
64
|
+
subjectRef: dxn,
|
|
52
65
|
subject: result.object,
|
|
53
66
|
state: true,
|
|
54
67
|
variant: 'virtual',
|
|
@@ -69,9 +82,9 @@ export default Capability.makeModule(
|
|
|
69
82
|
customEventOptions,
|
|
70
83
|
);
|
|
71
84
|
} else {
|
|
72
|
-
log.warn('
|
|
85
|
+
log.warn('no default view found');
|
|
73
86
|
}
|
|
74
87
|
|
|
75
|
-
return Capability.contributes(
|
|
88
|
+
return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => cleanup?.()));
|
|
76
89
|
}),
|
|
77
90
|
);
|
|
@@ -5,26 +5,26 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import { Surface } from '@dxos/app-framework/
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
10
10
|
import { Obj } from '@dxos/echo';
|
|
11
|
-
import { Card } from '@dxos/react-ui
|
|
11
|
+
import { Card } from '@dxos/react-ui';
|
|
12
12
|
import { type ProjectionModel } from '@dxos/schema';
|
|
13
|
-
import { Organization, Person,
|
|
13
|
+
import { Organization, Person, Pipeline, Task } from '@dxos/types';
|
|
14
14
|
|
|
15
15
|
import { FormCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../../cards';
|
|
16
16
|
import { meta } from '../../meta';
|
|
17
17
|
|
|
18
18
|
export default Capability.makeModule(() =>
|
|
19
19
|
Effect.succeed(
|
|
20
|
-
Capability.contributes(
|
|
20
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
21
21
|
//
|
|
22
22
|
// Specific schema types.
|
|
23
23
|
// TODO(burdon): Create helpers and factor out.
|
|
24
24
|
//
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
id: `${meta.id}
|
|
26
|
+
Surface.create<{ subject: Person.Person }>({
|
|
27
|
+
id: `${meta.id}.schema-popover--contact`,
|
|
28
28
|
role: 'card--content',
|
|
29
29
|
position: 'hoist',
|
|
30
30
|
filter: (data): data is { subject: Person.Person } => Obj.instanceOf(Person.Person, data.subject),
|
|
@@ -32,8 +32,8 @@ export default Capability.makeModule(() =>
|
|
|
32
32
|
return <PersonCard role={role} subject={data.subject} />;
|
|
33
33
|
},
|
|
34
34
|
}),
|
|
35
|
-
|
|
36
|
-
id: `${meta.id}
|
|
35
|
+
Surface.create({
|
|
36
|
+
id: `${meta.id}.schema-popover--organization`,
|
|
37
37
|
role: 'card--content',
|
|
38
38
|
position: 'hoist',
|
|
39
39
|
filter: (data): data is { subject: Organization.Organization } =>
|
|
@@ -42,17 +42,17 @@ export default Capability.makeModule(() =>
|
|
|
42
42
|
return <OrganizationCard role={role} subject={data.subject} />;
|
|
43
43
|
},
|
|
44
44
|
}),
|
|
45
|
-
|
|
46
|
-
id: `${meta.id}
|
|
45
|
+
Surface.create({
|
|
46
|
+
id: `${meta.id}.schema-popover--project`,
|
|
47
47
|
role: 'card--content',
|
|
48
48
|
position: 'hoist',
|
|
49
|
-
filter: (data): data is { subject:
|
|
49
|
+
filter: (data): data is { subject: Pipeline.Pipeline } => Obj.instanceOf(Pipeline.Pipeline, data.subject),
|
|
50
50
|
component: ({ data, role }) => {
|
|
51
51
|
return <ProjectCard role={role} subject={data.subject} />;
|
|
52
52
|
},
|
|
53
53
|
}),
|
|
54
|
-
|
|
55
|
-
id: `${meta.id}
|
|
54
|
+
Surface.create({
|
|
55
|
+
id: `${meta.id}.schema-popover--task`,
|
|
56
56
|
role: 'card--content',
|
|
57
57
|
position: 'hoist',
|
|
58
58
|
filter: (data): data is { subject: Task.Task } => Obj.instanceOf(Task.Task, data.subject),
|
|
@@ -65,8 +65,8 @@ export default Capability.makeModule(() =>
|
|
|
65
65
|
// Fallback for any object.
|
|
66
66
|
//
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
id: `${meta.id}
|
|
68
|
+
Surface.create({
|
|
69
|
+
id: `${meta.id}.fallback-popover`,
|
|
70
70
|
role: 'card--content',
|
|
71
71
|
position: 'fallback',
|
|
72
72
|
filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
|
|
@@ -75,17 +75,17 @@ export default Capability.makeModule(() =>
|
|
|
75
75
|
},
|
|
76
76
|
}),
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
id: `${meta.id}
|
|
78
|
+
Surface.create({
|
|
79
|
+
id: `${meta.id}.section`,
|
|
80
80
|
role: ['section'],
|
|
81
81
|
position: 'fallback',
|
|
82
82
|
filter: (data): data is { subject: Obj.Unknown } => Obj.isObject(data.subject),
|
|
83
83
|
component: ({ data }) => {
|
|
84
84
|
return (
|
|
85
|
-
<div role='none' className='flex
|
|
86
|
-
<div role='none' className='
|
|
85
|
+
<div role='none' className='flex w-full justify-center'>
|
|
86
|
+
<div role='none' className='pt-2 pb-2 dx-card-min-width dx-card-max-width'>
|
|
87
87
|
<Card.Root>
|
|
88
|
-
<Surface role='card--content' data={data} limit={1} />
|
|
88
|
+
<Surface.Surface role='card--content' data={data} limit={1} />
|
|
89
89
|
</Card.Root>
|
|
90
90
|
</div>
|
|
91
91
|
</div>
|
package/src/cards/FormCard.tsx
CHANGED
|
@@ -4,32 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { type SurfaceComponentProps, useOperationInvoker } from '@dxos/app-framework/react';
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
9
8
|
import { Obj } from '@dxos/echo';
|
|
10
9
|
import { type JsonPath, splitJsonPath } from '@dxos/effect';
|
|
11
|
-
import {
|
|
10
|
+
import { Card, useTranslation } from '@dxos/react-ui';
|
|
12
11
|
import { Form, omitId } from '@dxos/react-ui-form';
|
|
13
|
-
import { Card } from '@dxos/react-ui-mosaic';
|
|
14
12
|
import { type ProjectionModel } from '@dxos/schema';
|
|
15
13
|
import { descriptionMessage, mx } from '@dxos/ui-theme';
|
|
16
14
|
|
|
17
15
|
import { meta } from '../meta';
|
|
18
16
|
|
|
19
17
|
export const FormCard = ({ subject, projection }: SurfaceComponentProps & { projection?: ProjectionModel }) => {
|
|
20
|
-
const { invokePromise } = useOperationInvoker();
|
|
21
|
-
const schema = Obj.getSchema(subject);
|
|
22
18
|
const { t } = useTranslation(meta.id);
|
|
23
|
-
|
|
24
|
-
const handleNavigate = useCallback(async () => {
|
|
25
|
-
await invokePromise(Common.LayoutOperation.UpdatePopover, { state: false, anchorId: '' });
|
|
26
|
-
await invokePromise(Common.LayoutOperation.Open, { subject: [Obj.getDXN(subject).toString()] });
|
|
27
|
-
}, [invokePromise, subject]);
|
|
28
|
-
|
|
29
|
-
if (!schema) {
|
|
30
|
-
// TODO(burdon): Use Alert.
|
|
31
|
-
return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
|
|
32
|
-
}
|
|
19
|
+
const schema = Obj.getSchema(subject);
|
|
33
20
|
|
|
34
21
|
const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
|
|
35
22
|
const paths = Object.keys(changed).filter((path) => changed[path]);
|
|
@@ -42,15 +29,12 @@ export const FormCard = ({ subject, projection }: SurfaceComponentProps & { proj
|
|
|
42
29
|
});
|
|
43
30
|
}, []);
|
|
44
31
|
|
|
45
|
-
|
|
32
|
+
if (!schema) {
|
|
33
|
+
return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
|
|
34
|
+
}
|
|
46
35
|
|
|
47
36
|
return (
|
|
48
|
-
<Card.
|
|
49
|
-
<Card.Heading classNames='flex items-center'>
|
|
50
|
-
{label}
|
|
51
|
-
<span className='grow' />
|
|
52
|
-
<IconButton iconOnly icon='ph--arrow-right--regular' label={t('open object label')} onClick={handleNavigate} />
|
|
53
|
-
</Card.Heading>
|
|
37
|
+
<Card.Content>
|
|
54
38
|
<Form.Root schema={omitId(schema)} projection={projection} values={subject} autoSave onSave={handleSave}>
|
|
55
39
|
<Form.Viewport>
|
|
56
40
|
<Form.Content>
|
|
@@ -58,6 +42,6 @@ export const FormCard = ({ subject, projection }: SurfaceComponentProps & { proj
|
|
|
58
42
|
</Form.Content>
|
|
59
43
|
</Form.Viewport>
|
|
60
44
|
</Form.Root>
|
|
61
|
-
</Card.
|
|
45
|
+
</Card.Content>
|
|
62
46
|
);
|
|
63
47
|
};
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type SurfaceComponentProps } from '@dxos/app-
|
|
8
|
-
import { Card } from '@dxos/react-ui
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { Card } from '@dxos/react-ui';
|
|
9
9
|
import { type Organization } from '@dxos/types';
|
|
10
10
|
|
|
11
11
|
export const OrganizationCard = ({ subject }: SurfaceComponentProps<Organization.Organization>) => {
|
package/src/cards/PersonCard.tsx
CHANGED
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type SurfaceComponentProps } from '@dxos/app-
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { Avatar } from '@dxos/react-ui';
|
|
9
|
-
import { Card } from '@dxos/react-ui
|
|
9
|
+
import { Card } from '@dxos/react-ui';
|
|
10
10
|
import { type Person } from '@dxos/types';
|
|
11
11
|
|
|
12
12
|
export const PersonCard = ({ subject }: SurfaceComponentProps<Person.Person>) => {
|
|
13
13
|
const { image, organization: { target: organization } = {}, emails = [] } = subject;
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
|
-
<
|
|
17
|
-
<
|
|
16
|
+
<Card.Content>
|
|
17
|
+
<Avatar.Root>
|
|
18
18
|
{image && (
|
|
19
|
-
<Card.Row className='
|
|
19
|
+
<Card.Row className='py-1'>
|
|
20
20
|
<Avatar.Content
|
|
21
21
|
imgSrc={image}
|
|
22
22
|
icon='ph--user--regular'
|
|
@@ -36,12 +36,12 @@ export const PersonCard = ({ subject }: SurfaceComponentProps<Person.Person>) =>
|
|
|
36
36
|
)}
|
|
37
37
|
{emails.map(({ value }) => (
|
|
38
38
|
<Card.Row key={value} icon='ph--at--regular'>
|
|
39
|
-
<Card.Text truncate className='text-
|
|
39
|
+
<Card.Text truncate className='text-primary-text'>
|
|
40
40
|
{value}
|
|
41
41
|
</Card.Text>
|
|
42
42
|
</Card.Row>
|
|
43
43
|
))}
|
|
44
|
-
</
|
|
45
|
-
</
|
|
44
|
+
</Avatar.Root>
|
|
45
|
+
</Card.Content>
|
|
46
46
|
);
|
|
47
47
|
};
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type SurfaceComponentProps } from '@dxos/app-
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { Obj } from '@dxos/echo';
|
|
9
|
-
import { Card } from '@dxos/react-ui
|
|
10
|
-
import { type
|
|
9
|
+
import { Card } from '@dxos/react-ui';
|
|
10
|
+
import { type Pipeline } from '@dxos/types';
|
|
11
11
|
|
|
12
|
-
export const ProjectCard = ({ subject }: SurfaceComponentProps<
|
|
13
|
-
const {
|
|
12
|
+
export const ProjectCard = ({ subject }: SurfaceComponentProps<Pipeline.Pipeline>) => {
|
|
13
|
+
const { image, description } = subject;
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<Card.Content>
|
package/src/cards/TaskCard.tsx
CHANGED
|
@@ -5,31 +5,18 @@
|
|
|
5
5
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { type SurfaceComponentProps } from '@dxos/app-
|
|
8
|
+
import { type SurfaceComponentProps } 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
|
-
// TODO(thure): Should this move upstream as a helper? Is there an easier way to get options?
|
|
14
|
-
const getActiveStatusOption = (status?: string) => {
|
|
15
|
-
const properties = SchemaAST.getPropertySignatures(Task.Task.ast);
|
|
16
|
-
const statusProperty = properties.find((p) => p.name === 'status');
|
|
17
|
-
const statusMeta = SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(
|
|
18
|
-
// TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
|
|
19
|
-
(statusProperty!.type as any).types[0],
|
|
20
|
-
);
|
|
21
|
-
const options = // TODO(thure): Typescript asserts `statusMeta` doesn’t have `.value`, but in runtime it does.
|
|
22
|
-
(statusMeta as any).value.singleSelect.options as { id: string; title: string; color: string }[];
|
|
23
|
-
return options.find(({ id }) => id === status);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
13
|
export const TaskCard = ({ subject }: SurfaceComponentProps<Task.Task>) => {
|
|
27
14
|
const { title, status } = subject;
|
|
28
15
|
const statusOption = getActiveStatusOption(status);
|
|
29
16
|
|
|
30
17
|
return (
|
|
31
18
|
<Card.Content>
|
|
32
|
-
<Card.Heading classNames='min-
|
|
19
|
+
<Card.Heading classNames='min-w-0 flex-1 truncate'>{title}</Card.Heading>
|
|
33
20
|
{statusOption && (
|
|
34
21
|
<span className='dx-tag' data-hue={statusOption.color}>
|
|
35
22
|
{statusOption.title}
|
|
@@ -38,3 +25,16 @@ export const TaskCard = ({ subject }: SurfaceComponentProps<Task.Task>) => {
|
|
|
38
25
|
</Card.Content>
|
|
39
26
|
);
|
|
40
27
|
};
|
|
28
|
+
|
|
29
|
+
// TODO(thure): Should this move upstream as a helper? Is there an easier way to get options?
|
|
30
|
+
const getActiveStatusOption = (status?: string) => {
|
|
31
|
+
const properties = SchemaAST.getPropertySignatures(Task.Task.ast);
|
|
32
|
+
const statusProperty = properties.find((p) => p.name === 'status');
|
|
33
|
+
const statusMeta = SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(
|
|
34
|
+
// TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
|
|
35
|
+
(statusProperty!.type as any).types[0],
|
|
36
|
+
);
|
|
37
|
+
const options = // TODO(thure): Typescript asserts `statusMeta` doesn’t have `.value`, but in runtime it does.
|
|
38
|
+
(statusMeta as any).value.singleSelect.options as { id: string; title: string; color: string }[];
|
|
39
|
+
return options.find(({ id }) => id === status);
|
|
40
|
+
};
|
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.
|
|
@@ -8,9 +8,9 @@ import { withPluginManager } from '@dxos/app-framework/testing';
|
|
|
8
8
|
import { corePlugins } from '@dxos/plugin-testing';
|
|
9
9
|
import { faker } from '@dxos/random';
|
|
10
10
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
-
import { type Organization, type Person, type
|
|
11
|
+
import { type Organization, type Person, type Pipeline, type Task } from '@dxos/types';
|
|
12
12
|
|
|
13
|
-
import { OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
13
|
+
import { FormCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
14
14
|
import { translations } from '../translations';
|
|
15
15
|
|
|
16
16
|
import { DefaultStory, createOrganization, createPerson, createProject, createTask } from './testing';
|
|
@@ -18,23 +18,31 @@ import { DefaultStory, createOrganization, createPerson, createProject, createTa
|
|
|
18
18
|
faker.seed(999);
|
|
19
19
|
|
|
20
20
|
const meta = {
|
|
21
|
-
title: 'plugins/plugin-preview/Card',
|
|
21
|
+
title: 'plugins/plugin-preview/cards/Card',
|
|
22
22
|
render: DefaultStory,
|
|
23
23
|
decorators: [
|
|
24
|
-
withTheme,
|
|
25
|
-
withLayout({ layout: '
|
|
24
|
+
withTheme(),
|
|
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>;
|
|
35
35
|
|
|
36
36
|
export default meta;
|
|
37
37
|
|
|
38
|
+
export const _Form: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
39
|
+
args: {
|
|
40
|
+
Component: FormCard,
|
|
41
|
+
createObject: createPerson,
|
|
42
|
+
image: true,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
38
46
|
export const _Person: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
39
47
|
args: {
|
|
40
48
|
Component: PersonCard,
|
|
@@ -51,7 +59,7 @@ export const _Organization: StoryObj<typeof DefaultStory<Organization.Organizati
|
|
|
51
59
|
},
|
|
52
60
|
};
|
|
53
61
|
|
|
54
|
-
export const _Project: StoryObj<typeof DefaultStory<
|
|
62
|
+
export const _Project: StoryObj<typeof DefaultStory<Pipeline.Pipeline>> = {
|
|
55
63
|
args: {
|
|
56
64
|
Component: ProjectCard,
|
|
57
65
|
createObject: createProject,
|
package/src/stories/testing.tsx
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type FC, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type SurfaceComponentProps } from '@dxos/app-
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { Obj, Ref } from '@dxos/echo';
|
|
9
9
|
import { faker } from '@dxos/random';
|
|
10
|
-
import { Card } from '@dxos/react-ui
|
|
11
|
-
import { CardContainer } from '@dxos/react-ui-mosaic/testing';
|
|
12
|
-
import { Organization, Person,
|
|
10
|
+
import { Card } from '@dxos/react-ui';
|
|
11
|
+
import { CardContainer, type CardContainerProps } from '@dxos/react-ui-mosaic/testing';
|
|
12
|
+
import { Organization, Person, Pipeline, Task } from '@dxos/types';
|
|
13
13
|
|
|
14
14
|
export type DefaultStoryProps<T extends Obj.Any> = {
|
|
15
15
|
Component: FC<SurfaceComponentProps<T>>;
|
|
@@ -18,18 +18,22 @@ export type DefaultStoryProps<T extends Obj.Any> = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export const DefaultStory = <T extends Obj.Any>({ Component, createObject, image }: DefaultStoryProps<T>) => {
|
|
21
|
-
// TODO(wittjosiah): ECHO objects don't work when passed via Storybook args.
|
|
22
21
|
const object = useMemo(() => createObject(), [createObject]);
|
|
23
|
-
const roles:
|
|
22
|
+
const roles: CardContainerProps['role'][] = ['intrinsic', 'popover'];
|
|
24
23
|
|
|
25
24
|
return (
|
|
26
|
-
<div className='grid grid-
|
|
25
|
+
<div className='w-full h-full grid grid-cols-2 py-16 gap-8'>
|
|
27
26
|
{roles.map((role, i) => (
|
|
28
|
-
<div key={i} className='flex justify-center'>
|
|
29
|
-
<div className='flex flex-col gap-4
|
|
30
|
-
<
|
|
27
|
+
<div key={i} className='flex h-full justify-center overflow-hidden'>
|
|
28
|
+
<div className='flex flex-col gap-4 w-full items-center'>
|
|
29
|
+
<span className='text-sm text-description'>{role}</span>
|
|
31
30
|
<CardContainer role={role}>
|
|
32
|
-
<Card.Root>
|
|
31
|
+
<Card.Root border={false}>
|
|
32
|
+
<Card.Toolbar>
|
|
33
|
+
<Card.DragHandle />
|
|
34
|
+
<Card.Title>{Obj.getLabel(object)}</Card.Title>
|
|
35
|
+
<Card.Menu />
|
|
36
|
+
</Card.Toolbar>
|
|
33
37
|
<Component role={role} subject={image ? object : omitImage(object)} />
|
|
34
38
|
</Card.Root>
|
|
35
39
|
</CardContainer>
|
|
@@ -45,14 +49,15 @@ export const omitImage = ({ image: _, ...rest }: any) => rest;
|
|
|
45
49
|
/**
|
|
46
50
|
* Factory functions for creating test objects at render time.
|
|
47
51
|
*/
|
|
48
|
-
export const createOrganization = (): Organization.Organization =>
|
|
49
|
-
Obj.make(Organization.Organization, {
|
|
52
|
+
export const createOrganization = (): Organization.Organization => {
|
|
53
|
+
return Obj.make(Organization.Organization, {
|
|
50
54
|
name: faker.company.name(),
|
|
51
55
|
image:
|
|
52
56
|
'https://plus.unsplash.com/premium_photo-1672116452571-896980a801c8?q=80&w=2671&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
|
|
53
57
|
website: faker.internet.url(),
|
|
54
58
|
description: faker.lorem.paragraph(),
|
|
55
59
|
});
|
|
60
|
+
};
|
|
56
61
|
|
|
57
62
|
export const createPerson = (): Person.Person => {
|
|
58
63
|
const organization = createOrganization();
|
|
@@ -69,16 +74,18 @@ export const createPerson = (): Person.Person => {
|
|
|
69
74
|
});
|
|
70
75
|
};
|
|
71
76
|
|
|
72
|
-
export const createProject = ():
|
|
73
|
-
Obj.make(
|
|
77
|
+
export const createProject = (): Pipeline.Pipeline => {
|
|
78
|
+
return Obj.make(Pipeline.Pipeline, {
|
|
74
79
|
name: faker.person.fullName(),
|
|
75
80
|
image: 'https://dxos.network/dxos-logotype-blue.png',
|
|
76
81
|
description: faker.lorem.paragraph(),
|
|
77
82
|
columns: [],
|
|
78
83
|
});
|
|
84
|
+
};
|
|
79
85
|
|
|
80
|
-
export const createTask = (): Task.Task =>
|
|
81
|
-
Obj.make(Task.Task, {
|
|
86
|
+
export const createTask = (): Task.Task => {
|
|
87
|
+
return Obj.make(Task.Task, {
|
|
82
88
|
title: faker.lorem.sentence(),
|
|
83
89
|
status: faker.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
|
|
84
90
|
});
|
|
91
|
+
};
|