@dxos/plugin-preview 0.8.4-main.7ace549 → 0.8.4-main.937b3ca
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-CEWM5LJG.mjs → chunk-XLN6KTHK.mjs} +1 -1
- package/dist/lib/browser/chunk-XLN6KTHK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +24 -34
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{preview-popover-4QZ2WDE6.mjs → preview-popover-Y67LE6TV.mjs} +33 -20
- package/dist/lib/browser/preview-popover-Y67LE6TV.mjs.map +7 -0
- package/dist/lib/browser/react-surface-XYEFQ6NI.mjs +263 -0
- package/dist/lib/browser/react-surface-XYEFQ6NI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Q5MUNELK.mjs → chunk-2G4FUGDA.mjs} +1 -1
- package/dist/lib/node-esm/chunk-2G4FUGDA.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +24 -34
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{preview-popover-FJ2ARIGS.mjs → preview-popover-BGV2P6UX.mjs} +33 -20
- package/dist/lib/node-esm/preview-popover-BGV2P6UX.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-PSUCURVT.mjs +264 -0
- package/dist/lib/node-esm/react-surface-PSUCURVT.mjs.map +7 -0
- package/dist/types/src/PreviewPlugin.d.ts +2 -1
- package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/preview-popover/index.d.ts +3 -0
- package/dist/types/src/capabilities/preview-popover/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts +5 -0
- package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/cards/FormCard.d.ts +7 -0
- package/dist/types/src/cards/FormCard.d.ts.map +1 -0
- package/dist/types/src/cards/OrganizationCard.d.ts +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/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/stories/Card.stories.d.ts +8 -6
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +13 -12
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -34
- package/src/PreviewPlugin.tsx +10 -22
- package/src/capabilities/index.ts +2 -4
- package/src/capabilities/preview-popover/index.ts +7 -0
- package/src/capabilities/preview-popover/preview-popover.ts +77 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +97 -0
- package/src/cards/FormCard.tsx +63 -0
- package/src/cards/OrganizationCard.tsx +12 -17
- package/src/cards/PersonCard.tsx +35 -51
- package/src/cards/ProjectCard.tsx +7 -9
- package/src/cards/TaskCard.tsx +11 -17
- package/src/cards/index.ts +1 -0
- package/src/index.ts +0 -1
- package/src/meta.ts +2 -2
- package/src/stories/Card.stories.tsx +26 -20
- package/src/stories/testing.tsx +41 -71
- package/dist/lib/browser/chunk-CEWM5LJG.mjs.map +0 -7
- package/dist/lib/browser/preview-popover-4QZ2WDE6.mjs.map +0 -7
- package/dist/lib/browser/react-surface-X4KEMECS.mjs +0 -498
- package/dist/lib/browser/react-surface-X4KEMECS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Q5MUNELK.mjs.map +0 -7
- package/dist/lib/node-esm/preview-popover-FJ2ARIGS.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-DR3UAH6F.mjs +0 -499
- package/dist/lib/node-esm/react-surface-DR3UAH6F.mjs.map +0 -7
- package/dist/types/src/capabilities/preview-popover.d.ts +0 -4
- package/dist/types/src/capabilities/preview-popover.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/CardComponents.d.ts +0 -16
- package/dist/types/src/components/CardComponents.d.ts.map +0 -1
- package/dist/types/src/components/CardSubjectMenu.d.ts +0 -8
- package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
- package/dist/types/src/components/index.d.ts +0 -3
- package/dist/types/src/components/index.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -12
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/preview-popover.ts +0 -69
- package/src/capabilities/react-surface.tsx +0 -157
- package/src/components/CardComponents.tsx +0 -67
- package/src/components/CardSubjectMenu.tsx +0 -103
- package/src/components/index.ts +0 -6
- package/src/types.ts +0 -25
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-preview",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.937b3ca",
|
|
4
4
|
"description": "Preview plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"sideEffects": true,
|
|
@@ -24,44 +28,49 @@
|
|
|
24
28
|
"src"
|
|
25
29
|
],
|
|
26
30
|
"dependencies": {
|
|
27
|
-
"@effect-atom/atom-react": "^0.
|
|
28
|
-
"@
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/plugin-client": "0.8.4-main.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/react-
|
|
43
|
-
"@dxos/react-ui
|
|
44
|
-
"@dxos/react-ui-
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/react-ui-
|
|
47
|
-
"@dxos/react-ui-
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/types": "0.8.4-main.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
31
|
+
"@effect-atom/atom-react": "^0.4.6",
|
|
32
|
+
"@dxos/app-framework": "0.8.4-main.937b3ca",
|
|
33
|
+
"@dxos/async": "0.8.4-main.937b3ca",
|
|
34
|
+
"@dxos/effect": "0.8.4-main.937b3ca",
|
|
35
|
+
"@dxos/client": "0.8.4-main.937b3ca",
|
|
36
|
+
"@dxos/keys": "0.8.4-main.937b3ca",
|
|
37
|
+
"@dxos/lit-ui": "0.8.4-main.937b3ca",
|
|
38
|
+
"@dxos/app-graph": "0.8.4-main.937b3ca",
|
|
39
|
+
"@dxos/echo": "0.8.4-main.937b3ca",
|
|
40
|
+
"@dxos/log": "0.8.4-main.937b3ca",
|
|
41
|
+
"@dxos/plugin-client": "0.8.4-main.937b3ca",
|
|
42
|
+
"@dxos/plugin-attention": "0.8.4-main.937b3ca",
|
|
43
|
+
"@dxos/plugin-deck": "0.8.4-main.937b3ca",
|
|
44
|
+
"@dxos/operation": "0.8.4-main.937b3ca",
|
|
45
|
+
"@dxos/plugin-space": "0.8.4-main.937b3ca",
|
|
46
|
+
"@dxos/react-client": "0.8.4-main.937b3ca",
|
|
47
|
+
"@dxos/react-ui": "0.8.4-main.937b3ca",
|
|
48
|
+
"@dxos/react-ui-editor": "0.8.4-main.937b3ca",
|
|
49
|
+
"@dxos/react-ui-form": "0.8.4-main.937b3ca",
|
|
50
|
+
"@dxos/react-ui-menu": "0.8.4-main.937b3ca",
|
|
51
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.937b3ca",
|
|
52
|
+
"@dxos/react-ui-table": "0.8.4-main.937b3ca",
|
|
53
|
+
"@dxos/types": "0.8.4-main.937b3ca",
|
|
54
|
+
"@dxos/schema": "0.8.4-main.937b3ca",
|
|
55
|
+
"@dxos/ui-editor": "0.8.4-main.937b3ca",
|
|
56
|
+
"@dxos/ui-theme": "0.8.4-main.937b3ca",
|
|
57
|
+
"@dxos/util": "0.8.4-main.937b3ca"
|
|
52
58
|
},
|
|
53
59
|
"devDependencies": {
|
|
54
|
-
"effect": "3.
|
|
55
|
-
"react": "~19.2.
|
|
56
|
-
"react-dom": "~19.2.
|
|
60
|
+
"effect": "3.19.11",
|
|
61
|
+
"react": "~19.2.3",
|
|
62
|
+
"react-dom": "~19.2.3",
|
|
57
63
|
"vite": "7.1.9",
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
64
|
+
"@dxos/echo-db": "0.8.4-main.937b3ca",
|
|
65
|
+
"@dxos/plugin-testing": "0.8.4-main.937b3ca",
|
|
66
|
+
"@dxos/react-ui-components": "0.8.4-main.937b3ca",
|
|
67
|
+
"@dxos/random": "0.8.4-main.937b3ca",
|
|
68
|
+
"@dxos/storybook-utils": "0.8.4-main.937b3ca"
|
|
60
69
|
},
|
|
61
70
|
"peerDependencies": {
|
|
62
|
-
"effect": "
|
|
63
|
-
"react": "
|
|
64
|
-
"react-dom": "
|
|
71
|
+
"effect": "3.19.11",
|
|
72
|
+
"react": "~19.2.3",
|
|
73
|
+
"react-dom": "~19.2.3"
|
|
65
74
|
},
|
|
66
75
|
"publishConfig": {
|
|
67
76
|
"access": "public"
|
package/src/PreviewPlugin.tsx
CHANGED
|
@@ -2,33 +2,21 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
5
|
+
import { Common, Plugin } from '@dxos/app-framework';
|
|
7
6
|
import { Organization, Person } from '@dxos/types';
|
|
8
7
|
|
|
9
8
|
import { PreviewPopover, ReactSurface } from './capabilities';
|
|
10
9
|
import { meta } from './meta';
|
|
11
10
|
import { translations } from './translations';
|
|
12
11
|
|
|
13
|
-
export const PreviewPlugin =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
id: `${meta.id}/module/schema`,
|
|
21
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
22
|
-
activate: () => [contributes(ClientCapabilities.Schema, [Person.Person, Organization.Organization])],
|
|
23
|
-
}),
|
|
24
|
-
defineModule({
|
|
25
|
-
id: `${meta.id}/module/preview-popover`,
|
|
26
|
-
activatesOn: Events.Startup,
|
|
12
|
+
export const PreviewPlugin = Plugin.define(meta).pipe(
|
|
13
|
+
Common.Plugin.addTranslationsModule({ translations }),
|
|
14
|
+
Common.Plugin.addSchemaModule({ schema: [Person.Person, Organization.Organization], id: 'schema' }),
|
|
15
|
+
Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
|
|
16
|
+
Plugin.addModule({
|
|
17
|
+
id: 'preview-popover',
|
|
18
|
+
activatesOn: Common.ActivationEvent.Startup,
|
|
27
19
|
activate: PreviewPopover,
|
|
28
20
|
}),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
activatesOn: Events.SetupReactSurface,
|
|
32
|
-
activate: ReactSurface,
|
|
33
|
-
}),
|
|
34
|
-
]);
|
|
21
|
+
Plugin.make,
|
|
22
|
+
);
|
|
@@ -2,7 +2,5 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const PreviewPopover = lazy(() => import('./preview-popover'));
|
|
8
|
-
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
5
|
+
export * from './preview-popover';
|
|
6
|
+
export * from './react-surface';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
8
|
+
import { addEventListener } from '@dxos/async';
|
|
9
|
+
import { type Client } from '@dxos/client';
|
|
10
|
+
import { type Space, parseId } from '@dxos/client/echo';
|
|
11
|
+
import { DXN } from '@dxos/keys';
|
|
12
|
+
import { log } from '@dxos/log';
|
|
13
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
14
|
+
import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';
|
|
15
|
+
import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/ui-editor';
|
|
16
|
+
|
|
17
|
+
const customEventOptions = { capture: true, passive: false };
|
|
18
|
+
|
|
19
|
+
const handlePreviewLookup = async (
|
|
20
|
+
client: Client,
|
|
21
|
+
defaultSpace: Space,
|
|
22
|
+
{ ref, label }: PreviewLinkRef,
|
|
23
|
+
): Promise<PreviewLinkTarget | null> => {
|
|
24
|
+
try {
|
|
25
|
+
const object = await defaultSpace.db.makeRef(DXN.parse(ref)).load();
|
|
26
|
+
return { label, object };
|
|
27
|
+
} catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default Capability.makeModule(
|
|
33
|
+
Effect.fnUntraced(function* () {
|
|
34
|
+
// Get context for lazy capability access in callbacks.
|
|
35
|
+
const capabilities = yield* Capability.Service;
|
|
36
|
+
|
|
37
|
+
// TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
|
|
38
|
+
const handleAnchorActivate = async ({ refId, label, trigger, kind, title, side, props }: DxAnchorActivate) => {
|
|
39
|
+
const { invokePromise } = capabilities.get(Common.Capability.OperationInvoker);
|
|
40
|
+
const client = capabilities.get(ClientCapabilities.Client);
|
|
41
|
+
const registry = capabilities.get(Common.Capability.AtomRegistry);
|
|
42
|
+
const [layoutAtom] = capabilities.getAll(Common.Capability.Layout);
|
|
43
|
+
const layout = registry.get(layoutAtom);
|
|
44
|
+
const { spaceId } = parseId(layout.workspace);
|
|
45
|
+
const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
|
|
46
|
+
const result = await handlePreviewLookup(client, space, { ref: refId, label });
|
|
47
|
+
if (!result) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
await invokePromise(Common.LayoutOperation.UpdatePopover, {
|
|
52
|
+
subject: result.object,
|
|
53
|
+
state: true,
|
|
54
|
+
variant: 'virtual',
|
|
55
|
+
anchor: trigger,
|
|
56
|
+
...(kind && { kind }),
|
|
57
|
+
...(title && { title }),
|
|
58
|
+
...(side && { side }),
|
|
59
|
+
...(props && { props }),
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
let cleanup: () => void;
|
|
64
|
+
if (document.defaultView) {
|
|
65
|
+
cleanup = addEventListener(
|
|
66
|
+
document.defaultView,
|
|
67
|
+
DX_ANCHOR_ACTIVATE as any,
|
|
68
|
+
handleAnchorActivate,
|
|
69
|
+
customEventOptions,
|
|
70
|
+
);
|
|
71
|
+
} else {
|
|
72
|
+
log.warn('No default view found');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return Capability.contributes(Common.Capability.Null, null, () => Effect.sync(() => cleanup?.()));
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
9
|
+
import { Surface } from '@dxos/app-framework/react';
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
11
|
+
import { Card } from '@dxos/react-ui-mosaic';
|
|
12
|
+
import { type ProjectionModel } from '@dxos/schema';
|
|
13
|
+
import { Organization, Person, Project, Task } from '@dxos/types';
|
|
14
|
+
|
|
15
|
+
import { FormCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../../cards';
|
|
16
|
+
import { meta } from '../../meta';
|
|
17
|
+
|
|
18
|
+
export default Capability.makeModule(() =>
|
|
19
|
+
Effect.succeed(
|
|
20
|
+
Capability.contributes(Common.Capability.ReactSurface, [
|
|
21
|
+
//
|
|
22
|
+
// Specific schema types.
|
|
23
|
+
// TODO(burdon): Create helpers and factor out.
|
|
24
|
+
//
|
|
25
|
+
|
|
26
|
+
Common.createSurface<{ subject: Person.Person }>({
|
|
27
|
+
id: `${meta.id}/schema-popover--contact`,
|
|
28
|
+
role: 'card--content',
|
|
29
|
+
position: 'hoist',
|
|
30
|
+
filter: (data): data is { subject: Person.Person } => Obj.instanceOf(Person.Person, data.subject),
|
|
31
|
+
component: ({ data, role }) => {
|
|
32
|
+
return <PersonCard role={role} subject={data.subject} />;
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
Common.createSurface({
|
|
36
|
+
id: `${meta.id}/schema-popover--organization`,
|
|
37
|
+
role: 'card--content',
|
|
38
|
+
position: 'hoist',
|
|
39
|
+
filter: (data): data is { subject: Organization.Organization } =>
|
|
40
|
+
Obj.instanceOf(Organization.Organization, data.subject),
|
|
41
|
+
component: ({ data, role }) => {
|
|
42
|
+
return <OrganizationCard role={role} subject={data.subject} />;
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
Common.createSurface({
|
|
46
|
+
id: `${meta.id}/schema-popover--project`,
|
|
47
|
+
role: 'card--content',
|
|
48
|
+
position: 'hoist',
|
|
49
|
+
filter: (data): data is { subject: Project.Project } => Obj.instanceOf(Project.Project, data.subject),
|
|
50
|
+
component: ({ data, role }) => {
|
|
51
|
+
return <ProjectCard role={role} subject={data.subject} />;
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
Common.createSurface({
|
|
55
|
+
id: `${meta.id}/schema-popover--task`,
|
|
56
|
+
role: 'card--content',
|
|
57
|
+
position: 'hoist',
|
|
58
|
+
filter: (data): data is { subject: Task.Task } => Obj.instanceOf(Task.Task, data.subject),
|
|
59
|
+
component: ({ data, role }) => {
|
|
60
|
+
return <TaskCard role={role} subject={data.subject} />;
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
|
|
64
|
+
//
|
|
65
|
+
// Fallback for any object.
|
|
66
|
+
//
|
|
67
|
+
|
|
68
|
+
Common.createSurface({
|
|
69
|
+
id: `${meta.id}/fallback-popover`,
|
|
70
|
+
role: 'card--content',
|
|
71
|
+
position: 'fallback',
|
|
72
|
+
filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
|
|
73
|
+
component: ({ data, role }) => {
|
|
74
|
+
return <FormCard role={role} subject={data.subject} projection={data.projection} />;
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
|
|
78
|
+
Common.createSurface({
|
|
79
|
+
id: `${meta.id}/section`,
|
|
80
|
+
role: ['section'],
|
|
81
|
+
position: 'fallback',
|
|
82
|
+
filter: (data): data is { subject: Obj.Unknown } => Obj.isObject(data.subject),
|
|
83
|
+
component: ({ data }) => {
|
|
84
|
+
return (
|
|
85
|
+
<div role='none' className='flex is-full justify-center'>
|
|
86
|
+
<div role='none' className='pbs-2 pbe-2 card-min-width card-max-width'>
|
|
87
|
+
<Card.Root>
|
|
88
|
+
<Surface role='card--content' data={data} limit={1} />
|
|
89
|
+
</Card.Root>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
}),
|
|
95
|
+
]),
|
|
96
|
+
),
|
|
97
|
+
);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Common } from '@dxos/app-framework';
|
|
8
|
+
import { type SurfaceComponentProps, useOperationInvoker } from '@dxos/app-framework/react';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { type JsonPath, splitJsonPath } from '@dxos/effect';
|
|
11
|
+
import { IconButton, useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import { Form, omitId } from '@dxos/react-ui-form';
|
|
13
|
+
import { Card } from '@dxos/react-ui-mosaic';
|
|
14
|
+
import { type ProjectionModel } from '@dxos/schema';
|
|
15
|
+
import { descriptionMessage, mx } from '@dxos/ui-theme';
|
|
16
|
+
|
|
17
|
+
import { meta } from '../meta';
|
|
18
|
+
|
|
19
|
+
export const FormCard = ({ subject, projection }: SurfaceComponentProps & { projection?: ProjectionModel }) => {
|
|
20
|
+
const { invokePromise } = useOperationInvoker();
|
|
21
|
+
const schema = Obj.getSchema(subject);
|
|
22
|
+
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
|
+
}
|
|
33
|
+
|
|
34
|
+
const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
|
|
35
|
+
const paths = Object.keys(changed).filter((path) => changed[path]);
|
|
36
|
+
Obj.change(subject, () => {
|
|
37
|
+
for (const path of paths) {
|
|
38
|
+
const value = values[path];
|
|
39
|
+
const parts = splitJsonPath(path as JsonPath);
|
|
40
|
+
Obj.setValue(subject, parts, value);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}, []);
|
|
44
|
+
|
|
45
|
+
const label = Obj.getLabel(subject) ?? Obj.getTypename(subject) ?? t('unable to create preview message');
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Card.Root id={subject.id}>
|
|
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>
|
|
54
|
+
<Form.Root schema={omitId(schema)} projection={projection} values={subject} autoSave onSave={handleSave}>
|
|
55
|
+
<Form.Viewport>
|
|
56
|
+
<Form.Content>
|
|
57
|
+
<Form.FieldSet />
|
|
58
|
+
</Form.Content>
|
|
59
|
+
</Form.Viewport>
|
|
60
|
+
</Form.Root>
|
|
61
|
+
</Card.Root>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
@@ -4,31 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
8
|
+
import { Card } from '@dxos/react-ui-mosaic';
|
|
8
9
|
import { type Organization } from '@dxos/types';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export const OrganizationCard = ({
|
|
14
|
-
children,
|
|
15
|
-
subject,
|
|
16
|
-
role,
|
|
17
|
-
activeSpace,
|
|
18
|
-
}: CardPreviewProps<Organization.Organization>) => {
|
|
19
|
-
const { name, image, description, website } = subject;
|
|
11
|
+
export const OrganizationCard = ({ subject }: SurfaceComponentProps<Organization.Organization>) => {
|
|
12
|
+
const { image, description, website } = subject;
|
|
20
13
|
|
|
21
14
|
return (
|
|
22
|
-
<Card.
|
|
15
|
+
<Card.Content>
|
|
23
16
|
<Card.Poster
|
|
24
17
|
alt={name ?? ''}
|
|
25
18
|
{...(image ? { image } : { icon: 'ph--building-office--regular' })}
|
|
26
19
|
classNames={!image && 'opacity-50'}
|
|
27
20
|
/>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
{description && (
|
|
22
|
+
<Card.Row>
|
|
23
|
+
<Card.Text variant='description'>{description}</Card.Text>
|
|
24
|
+
</Card.Row>
|
|
25
|
+
)}
|
|
26
|
+
{website && <Card.Link label={website} href={website} />}
|
|
27
|
+
</Card.Content>
|
|
33
28
|
);
|
|
34
29
|
};
|
package/src/cards/PersonCard.tsx
CHANGED
|
@@ -2,62 +2,46 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React
|
|
5
|
+
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
8
|
+
import { Avatar } from '@dxos/react-ui';
|
|
9
|
+
import { Card } from '@dxos/react-ui-mosaic';
|
|
10
10
|
import { type Person } from '@dxos/types';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const PersonCard = ({ children, role, subject, activeSpace, onSelect }: CardPreviewProps<Person.Person>) => {
|
|
16
|
-
const { fullName, image, organization: { target: organization } = {}, emails = [] } = subject;
|
|
12
|
+
export const PersonCard = ({ subject }: SurfaceComponentProps<Person.Person>) => {
|
|
13
|
+
const { image, organization: { target: organization } = {}, emails = [] } = subject;
|
|
17
14
|
|
|
18
15
|
return (
|
|
19
|
-
<
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
<Avatar.Root>
|
|
17
|
+
<Card.Content>
|
|
18
|
+
{image && (
|
|
19
|
+
<Card.Row className='plb-1'>
|
|
20
|
+
<Avatar.Content
|
|
21
|
+
imgSrc={image}
|
|
22
|
+
icon='ph--user--regular'
|
|
23
|
+
size={16}
|
|
24
|
+
classNames={!image && 'opacity-50'}
|
|
25
|
+
hue='neutral'
|
|
26
|
+
variant='square'
|
|
27
|
+
/>
|
|
28
|
+
</Card.Row>
|
|
29
|
+
)}
|
|
30
|
+
{organization?.name && (
|
|
31
|
+
<Card.Action
|
|
32
|
+
icon='ph--buildings--regular'
|
|
33
|
+
label={organization.name}
|
|
34
|
+
// onClick={onSelect ? () => onSelect(organization) : undefined}
|
|
35
35
|
/>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<dl className={mx(cardText, gridRow, '[&_dt]:text-subdued [&_dt]:pbs-0.5 [&_dd]:min-is-0')}>
|
|
47
|
-
{emails.map(({ label, value }) => (
|
|
48
|
-
<Fragment key={value}>
|
|
49
|
-
<dt>
|
|
50
|
-
<span className='sr-only'>{label}</span>
|
|
51
|
-
<Icon icon='ph--at--regular' size={5} />
|
|
52
|
-
</dt>
|
|
53
|
-
<dd key={value} className='col-span-2 break-words'>
|
|
54
|
-
{value}
|
|
55
|
-
</dd>
|
|
56
|
-
</Fragment>
|
|
57
|
-
))}
|
|
58
|
-
</dl>
|
|
59
|
-
)}
|
|
60
|
-
{children}
|
|
61
|
-
</Card.SurfaceRoot>
|
|
36
|
+
)}
|
|
37
|
+
{emails.map(({ value }) => (
|
|
38
|
+
<Card.Row key={value} icon='ph--at--regular'>
|
|
39
|
+
<Card.Text truncate className='text-primaryText'>
|
|
40
|
+
{value}
|
|
41
|
+
</Card.Text>
|
|
42
|
+
</Card.Row>
|
|
43
|
+
))}
|
|
44
|
+
</Card.Content>
|
|
45
|
+
</Avatar.Root>
|
|
62
46
|
);
|
|
63
47
|
};
|
|
@@ -4,21 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
7
8
|
import { Obj } from '@dxos/echo';
|
|
8
|
-
import { Card } from '@dxos/react-ui-
|
|
9
|
+
import { Card } from '@dxos/react-ui-mosaic';
|
|
9
10
|
import { type Project } from '@dxos/types';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
import { type CardPreviewProps } from '../types';
|
|
13
|
-
|
|
14
|
-
export const ProjectCard = ({ subject, role, activeSpace }: CardPreviewProps<Project.Project>) => {
|
|
12
|
+
export const ProjectCard = ({ subject }: SurfaceComponentProps<Project.Project>) => {
|
|
15
13
|
const { name, image, description } = subject;
|
|
16
14
|
|
|
17
15
|
return (
|
|
18
|
-
<Card.
|
|
16
|
+
<Card.Content>
|
|
19
17
|
{image && <Card.Poster image={image} alt={Obj.getLabel(subject) ?? ''} aspect='auto' />}
|
|
20
|
-
<CardHeader label={name} subject={subject}
|
|
21
|
-
{description && <Card.Text
|
|
22
|
-
</Card.
|
|
18
|
+
{/* <CardHeader label={name} subject={subject} db={db} /> */}
|
|
19
|
+
{description && <Card.Text variant='description'>{description}</Card.Text>}
|
|
20
|
+
</Card.Content>
|
|
23
21
|
);
|
|
24
22
|
};
|
package/src/cards/TaskCard.tsx
CHANGED
|
@@ -5,14 +5,11 @@
|
|
|
5
5
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
+
import { type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
8
9
|
import { type PropertyMetaAnnotation, PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
9
|
-
import { Card
|
|
10
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
10
|
+
import { Card } from '@dxos/react-ui-mosaic';
|
|
11
11
|
import { Task } from '@dxos/types';
|
|
12
12
|
|
|
13
|
-
import { CardSubjectMenu } from '../components';
|
|
14
|
-
import { type CardPreviewProps } from '../types';
|
|
15
|
-
|
|
16
13
|
// TODO(thure): Should this move upstream as a helper? Is there an easier way to get options?
|
|
17
14
|
const getActiveStatusOption = (status?: string) => {
|
|
18
15
|
const properties = SchemaAST.getPropertySignatures(Task.Task.ast);
|
|
@@ -26,21 +23,18 @@ const getActiveStatusOption = (status?: string) => {
|
|
|
26
23
|
return options.find(({ id }) => id === status);
|
|
27
24
|
};
|
|
28
25
|
|
|
29
|
-
export const TaskCard = ({ subject
|
|
26
|
+
export const TaskCard = ({ subject }: SurfaceComponentProps<Task.Task>) => {
|
|
30
27
|
const { title, status } = subject;
|
|
31
28
|
const statusOption = getActiveStatusOption(status);
|
|
32
29
|
|
|
33
30
|
return (
|
|
34
|
-
<Card.
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
{statusOption
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<CardSubjectMenu subject={subject} activeSpace={activeSpace} />
|
|
43
|
-
</div>
|
|
44
|
-
</Card.SurfaceRoot>
|
|
31
|
+
<Card.Content>
|
|
32
|
+
<Card.Heading classNames='min-is-0 flex-1 truncate'>{title}</Card.Heading>
|
|
33
|
+
{statusOption && (
|
|
34
|
+
<span className='dx-tag' data-hue={statusOption.color}>
|
|
35
|
+
{statusOption.title}
|
|
36
|
+
</span>
|
|
37
|
+
)}
|
|
38
|
+
</Card.Content>
|
|
45
39
|
);
|
|
46
40
|
};
|
package/src/cards/index.ts
CHANGED