@dxos/plugin-preview 0.8.4-main.f5c0578 → 0.8.4-main.fcc0d83b33
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 +33 -53
- 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 +33 -52
- 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/PreviewPlugin.d.ts +2 -1
- package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +3 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/preview-popover.d.ts +3 -2
- package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- 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 +7 -0
- package/dist/types/src/cards/FormCard.d.ts.map +1 -0
- 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 +5 -0
- package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -0
- package/dist/types/src/cards/PersonCard.d.ts +5 -0
- package/dist/types/src/cards/PersonCard.d.ts.map +1 -0
- package/dist/types/src/cards/ProjectCard.d.ts +5 -0
- package/dist/types/src/cards/ProjectCard.d.ts.map +1 -0
- package/dist/types/src/cards/TaskCard.d.ts +5 -0
- package/dist/types/src/cards/TaskCard.d.ts.map +1 -0
- package/dist/types/src/cards/index.d.ts +8 -0
- package/dist/types/src/cards/index.d.ts.map +1 -0
- 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 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/stories/Card.stories.d.ts +34 -46
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +17 -14
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +56 -37
- package/src/PreviewPlugin.tsx +17 -29
- package/src/capabilities/index.ts +3 -3
- package/src/capabilities/preview-popover.ts +72 -50
- package/src/capabilities/react-surface.tsx +106 -151
- package/src/cards/ExpandoCard.tsx +76 -0
- package/src/cards/FormCard.tsx +48 -0
- package/src/cards/JsonCard.tsx +19 -0
- package/src/cards/OrganizationCard.tsx +29 -0
- package/src/cards/PersonCard.tsx +65 -0
- package/src/cards/ProjectCard.tsx +22 -0
- package/src/cards/TaskCard.tsx +44 -0
- package/src/cards/index.ts +11 -0
- package/src/index.ts +0 -1
- package/src/meta.ts +8 -5
- package/src/stories/Card.stories.tsx +96 -28
- package/src/stories/testing.tsx +66 -68
- package/src/translations.ts +8 -2
- package/dist/lib/browser/chunk-Z73ENKLE.mjs +0 -14
- package/dist/lib/browser/chunk-Z73ENKLE.mjs.map +0 -7
- package/dist/lib/browser/preview-popover-MAIBTJKJ.mjs +0 -69
- package/dist/lib/browser/preview-popover-MAIBTJKJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-H4RYYXVQ.mjs +0 -379
- package/dist/lib/browser/react-surface-H4RYYXVQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs +0 -16
- package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs.map +0 -7
- package/dist/lib/node-esm/preview-popover-LZGHYW23.mjs +0 -71
- package/dist/lib/node-esm/preview-popover-LZGHYW23.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-4C44XCLH.mjs +0 -380
- package/dist/lib/node-esm/react-surface-4C44XCLH.mjs.map +0 -7
- package/dist/types/src/components/CardSubjectMenu.d.ts +0 -10
- package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
- package/dist/types/src/components/ContactCard.d.ts +0 -7
- package/dist/types/src/components/ContactCard.d.ts.map +0 -1
- package/dist/types/src/components/OrganizationCard.d.ts +0 -5
- package/dist/types/src/components/OrganizationCard.d.ts.map +0 -1
- package/dist/types/src/components/ProjectCard.d.ts +0 -5
- package/dist/types/src/components/ProjectCard.d.ts.map +0 -1
- package/dist/types/src/components/index.d.ts +0 -4
- package/dist/types/src/components/index.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -7
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/components/CardSubjectMenu.tsx +0 -56
- package/src/components/ContactCard.tsx +0 -76
- package/src/components/OrganizationCard.tsx +0 -44
- package/src/components/ProjectCard.tsx +0 -27
- package/src/components/index.ts +0 -7
- package/src/types.ts +0 -11
package/package.json
CHANGED
|
@@ -1,66 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-preview",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.fcc0d83b33",
|
|
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,
|
|
10
14
|
"type": "module",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#capabilities": "./src/capabilities/index.ts",
|
|
17
|
+
"#meta": "./src/meta.ts",
|
|
18
|
+
"#translations": "./src/translations.ts"
|
|
19
|
+
},
|
|
11
20
|
"exports": {
|
|
12
21
|
".": {
|
|
13
22
|
"source": "./src/index.ts",
|
|
14
23
|
"types": "./dist/types/src/index.d.ts",
|
|
15
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"
|
|
16
31
|
}
|
|
17
32
|
},
|
|
18
33
|
"types": "dist/types/src/index.d.ts",
|
|
19
|
-
"typesVersions": {
|
|
20
|
-
"*": {}
|
|
21
|
-
},
|
|
22
34
|
"files": [
|
|
23
35
|
"dist",
|
|
24
36
|
"src"
|
|
25
37
|
],
|
|
26
38
|
"dependencies": {
|
|
27
|
-
"@effect-
|
|
28
|
-
"@
|
|
29
|
-
"@dxos/app-
|
|
30
|
-
"@dxos/app-
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/plugin-client": "0.8.4-main.
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/react-
|
|
42
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
43
|
-
"@dxos/react-ui-
|
|
44
|
-
"@dxos/react-ui-form": "0.8.4-main.
|
|
45
|
-
"@dxos/react-ui-
|
|
46
|
-
"@dxos/react-ui-
|
|
47
|
-
"@dxos/react-ui-table": "0.8.4-main.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
39
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
40
|
+
"@dxos/async": "0.8.4-main.fcc0d83b33",
|
|
41
|
+
"@dxos/app-graph": "0.8.4-main.fcc0d83b33",
|
|
42
|
+
"@dxos/app-toolkit": "0.8.4-main.fcc0d83b33",
|
|
43
|
+
"@dxos/client": "0.8.4-main.fcc0d83b33",
|
|
44
|
+
"@dxos/echo": "0.8.4-main.fcc0d83b33",
|
|
45
|
+
"@dxos/effect": "0.8.4-main.fcc0d83b33",
|
|
46
|
+
"@dxos/keys": "0.8.4-main.fcc0d83b33",
|
|
47
|
+
"@dxos/lit-ui": "0.8.4-main.fcc0d83b33",
|
|
48
|
+
"@dxos/operation": "0.8.4-main.fcc0d83b33",
|
|
49
|
+
"@dxos/app-framework": "0.8.4-main.fcc0d83b33",
|
|
50
|
+
"@dxos/plugin-client": "0.8.4-main.fcc0d83b33",
|
|
51
|
+
"@dxos/plugin-deck": "0.8.4-main.fcc0d83b33",
|
|
52
|
+
"@dxos/react-client": "0.8.4-main.fcc0d83b33",
|
|
53
|
+
"@dxos/react-ui": "0.8.4-main.fcc0d83b33",
|
|
54
|
+
"@dxos/react-ui-editor": "0.8.4-main.fcc0d83b33",
|
|
55
|
+
"@dxos/react-ui-menu": "0.8.4-main.fcc0d83b33",
|
|
56
|
+
"@dxos/react-ui-form": "0.8.4-main.fcc0d83b33",
|
|
57
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.fcc0d83b33",
|
|
58
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.fcc0d83b33",
|
|
59
|
+
"@dxos/react-ui-table": "0.8.4-main.fcc0d83b33",
|
|
60
|
+
"@dxos/schema": "0.8.4-main.fcc0d83b33",
|
|
61
|
+
"@dxos/ui-editor": "0.8.4-main.fcc0d83b33",
|
|
62
|
+
"@dxos/types": "0.8.4-main.fcc0d83b33",
|
|
63
|
+
"@dxos/ui-theme": "0.8.4-main.fcc0d83b33",
|
|
64
|
+
"@dxos/util": "0.8.4-main.fcc0d83b33",
|
|
65
|
+
"@dxos/log": "0.8.4-main.fcc0d83b33",
|
|
66
|
+
"@dxos/plugin-attention": "0.8.4-main.fcc0d83b33"
|
|
51
67
|
},
|
|
52
68
|
"devDependencies": {
|
|
53
|
-
"effect": "3.
|
|
54
|
-
"react": "~
|
|
55
|
-
"react-dom": "~
|
|
56
|
-
"vite": "
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
69
|
+
"effect": "3.20.0",
|
|
70
|
+
"react": "~19.2.3",
|
|
71
|
+
"react-dom": "~19.2.3",
|
|
72
|
+
"vite": "^8.0.10",
|
|
73
|
+
"@dxos/plugin-testing": "0.8.4-main.fcc0d83b33",
|
|
74
|
+
"@dxos/echo-db": "0.8.4-main.fcc0d83b33",
|
|
75
|
+
"@dxos/random": "0.8.4-main.fcc0d83b33",
|
|
76
|
+
"@dxos/storybook-utils": "0.8.4-main.fcc0d83b33",
|
|
77
|
+
"@dxos/react-ui-components": "0.8.4-main.fcc0d83b33"
|
|
59
78
|
},
|
|
60
79
|
"peerDependencies": {
|
|
61
|
-
"effect": "
|
|
62
|
-
"react": "~
|
|
63
|
-
"react-dom": "~
|
|
80
|
+
"effect": "3.20.0",
|
|
81
|
+
"react": "~19.2.3",
|
|
82
|
+
"react-dom": "~19.2.3"
|
|
64
83
|
},
|
|
65
84
|
"publishConfig": {
|
|
66
85
|
"access": "public"
|
package/src/PreviewPlugin.tsx
CHANGED
|
@@ -2,34 +2,22 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { ActivationEvents, Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
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
|
-
export const PreviewPlugin = ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}),
|
|
25
|
-
defineModule({
|
|
26
|
-
id: `${meta.id}/module/preview-popover`,
|
|
27
|
-
activatesOn: Events.Startup,
|
|
28
|
-
activate: PreviewPopover,
|
|
29
|
-
}),
|
|
30
|
-
defineModule({
|
|
31
|
-
id: `${meta.id}/module/react-surface`,
|
|
32
|
-
activatesOn: Events.SetupReactSurface,
|
|
33
|
-
activate: ReactSurface,
|
|
34
|
-
}),
|
|
35
|
-
]);
|
|
13
|
+
export const PreviewPlugin = Plugin.define(meta).pipe(
|
|
14
|
+
AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization], id: 'schema' }),
|
|
15
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
16
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
17
|
+
Plugin.addModule({
|
|
18
|
+
id: 'preview-popover',
|
|
19
|
+
activatesOn: ActivationEvents.Startup,
|
|
20
|
+
activate: PreviewPopover,
|
|
21
|
+
}),
|
|
22
|
+
Plugin.make,
|
|
23
|
+
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
export const PreviewPopover = lazy(() => import('./preview-popover'));
|
|
8
|
-
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
7
|
+
export const PreviewPopover = Capability.lazy('PreviewPopover', () => import('./preview-popover'));
|
|
8
|
+
export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
|
|
@@ -2,73 +2,95 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities, LayoutOperation, getPersonalSpace, getSpaceIdFromPath } from '@dxos/app-toolkit';
|
|
6
9
|
import { addEventListener } from '@dxos/async';
|
|
7
|
-
import { type Client
|
|
8
|
-
import { type Space
|
|
10
|
+
import { type Client } from '@dxos/client';
|
|
11
|
+
import { type Space } from '@dxos/client/echo';
|
|
12
|
+
import { Obj } from '@dxos/echo';
|
|
9
13
|
import { DXN } from '@dxos/keys';
|
|
10
|
-
import { type DxRefTagActivate } from '@dxos/lit-ui';
|
|
11
14
|
import { log } from '@dxos/log';
|
|
12
|
-
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
13
|
-
import {
|
|
15
|
+
import { ClientCapabilities } from '@dxos/plugin-client/types';
|
|
16
|
+
import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';
|
|
17
|
+
import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/ui-editor';
|
|
14
18
|
|
|
15
19
|
const customEventOptions = { capture: true, passive: false };
|
|
16
20
|
|
|
17
21
|
const handlePreviewLookup = async (
|
|
18
22
|
client: Client,
|
|
19
23
|
defaultSpace: Space,
|
|
20
|
-
{
|
|
24
|
+
{ dxn, label }: PreviewLinkRef,
|
|
21
25
|
): Promise<PreviewLinkTarget | null> => {
|
|
22
26
|
try {
|
|
23
|
-
const
|
|
24
|
-
if (!dxn) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const object = await resolveRef(client, dxn, defaultSpace);
|
|
27
|
+
const object = await defaultSpace.db.makeRef(DXN.parse(dxn)).load();
|
|
29
28
|
return { label, object };
|
|
30
|
-
} catch
|
|
29
|
+
} catch {
|
|
31
30
|
return null;
|
|
32
31
|
}
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
export default (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
export default Capability.makeModule(
|
|
35
|
+
Effect.fnUntraced(function* () {
|
|
36
|
+
// Get context for lazy capability access in callbacks.
|
|
37
|
+
const capabilities = yield* Capability.Service;
|
|
38
|
+
|
|
39
|
+
// TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
|
|
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);
|
|
50
|
+
const client = capabilities.get(ClientCapabilities.Client);
|
|
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.
|
|
56
|
+
const [layoutAtom] = capabilities.getAll(AppCapabilities.Layout);
|
|
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
|
+
}
|
|
62
|
+
const result = await handlePreviewLookup(client, space, { dxn, label });
|
|
63
|
+
if (!result) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
47
66
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
const title = titleProp ?? Obj.getLabel(result.object);
|
|
68
|
+
|
|
69
|
+
await invokePromise(LayoutOperation.UpdatePopover, {
|
|
70
|
+
subjectRef: dxn,
|
|
51
71
|
subject: result.object,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
state: true,
|
|
73
|
+
variant: 'virtual',
|
|
74
|
+
anchor: trigger,
|
|
75
|
+
...(kind && { kind }),
|
|
76
|
+
...(title && { title }),
|
|
77
|
+
...(side && { side }),
|
|
78
|
+
...(props && { props }),
|
|
79
|
+
});
|
|
80
|
+
};
|
|
60
81
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
let cleanup: () => void;
|
|
83
|
+
if (document.defaultView) {
|
|
84
|
+
cleanup = addEventListener(
|
|
85
|
+
document.defaultView,
|
|
86
|
+
DX_ANCHOR_ACTIVATE as any,
|
|
87
|
+
handleAnchorActivate,
|
|
88
|
+
customEventOptions,
|
|
89
|
+
);
|
|
90
|
+
} else {
|
|
91
|
+
log.warn('no default view found');
|
|
92
|
+
}
|
|
72
93
|
|
|
73
|
-
|
|
74
|
-
}
|
|
94
|
+
return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => cleanup?.()));
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
@@ -2,162 +2,117 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import React
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
useIntentDispatcher,
|
|
16
|
-
} from '@dxos/app-framework';
|
|
17
|
-
import { fullyQualifiedId, getSchema, getSpace } from '@dxos/client/echo';
|
|
18
|
-
import { Filter, Obj } from '@dxos/echo';
|
|
19
|
-
import { type JsonPath, setValue } from '@dxos/echo-schema';
|
|
20
|
-
import { AttentionAction } from '@dxos/plugin-attention/types';
|
|
21
|
-
import { ATTENDABLE_PATH_SEPARATOR, DeckAction } from '@dxos/plugin-deck/types';
|
|
22
|
-
import { useQuery, useSpace } from '@dxos/react-client/echo';
|
|
23
|
-
import { useTranslation } from '@dxos/react-ui';
|
|
24
|
-
import { Form } from '@dxos/react-ui-form';
|
|
25
|
-
import { Card } from '@dxos/react-ui-stack';
|
|
26
|
-
import { TableView } from '@dxos/react-ui-table/types';
|
|
27
|
-
import { descriptionMessage, mx } from '@dxos/react-ui-theme';
|
|
28
|
-
import { DataType } from '@dxos/schema';
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
10
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
|
+
import { Card } from '@dxos/react-ui';
|
|
13
|
+
import { Expando, type ProjectionModel } from '@dxos/schema';
|
|
14
|
+
import { Organization, Person, Pipeline, Task } from '@dxos/types';
|
|
29
15
|
|
|
30
|
-
import {
|
|
31
|
-
import { PREVIEW_PLUGIN } from '../meta';
|
|
16
|
+
import { ExpandoCard, FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
32
17
|
|
|
33
|
-
export default () =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
|
|
41
|
-
filter: (data): data is { subject: DataType.Person } => Obj.instanceOf(DataType.Person, data.subject),
|
|
42
|
-
component: ({ data, role }) => {
|
|
43
|
-
const { dispatch } = useIntentDispatcher();
|
|
44
|
-
const space = getSpace(data.subject);
|
|
45
|
-
const defaultSpace = useSpace();
|
|
18
|
+
export default Capability.makeModule(() =>
|
|
19
|
+
Effect.succeed(
|
|
20
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
21
|
+
//
|
|
22
|
+
// Specific schema types.
|
|
23
|
+
// TODO(burdon): Create helpers and factor out.
|
|
24
|
+
//
|
|
46
25
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
26
|
+
Surface.create<{ subject: Person.Person }>({
|
|
27
|
+
id: 'schema-popover--contact',
|
|
28
|
+
position: 'hoist',
|
|
29
|
+
filter: AppSurface.object(AppSurface.Card, Person.Person),
|
|
30
|
+
component: ({ data, role }) => {
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<PersonCard role={role} subject={data.subject} />
|
|
34
|
+
<Surface.Surface type={AppSurface.Related} data={data} limit={1} />
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
Surface.create({
|
|
40
|
+
id: 'schema-popover--organization',
|
|
41
|
+
position: 'hoist',
|
|
42
|
+
filter: AppSurface.object(AppSurface.Card, Organization.Organization),
|
|
43
|
+
component: ({ data, role }) => {
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<OrganizationCard role={role} subject={data.subject} />
|
|
47
|
+
<Surface.Surface type={AppSurface.Related} data={data} limit={1} />
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
Surface.create({
|
|
53
|
+
id: 'schema-popover--project',
|
|
54
|
+
position: 'hoist',
|
|
55
|
+
filter: AppSurface.object(AppSurface.Card, Pipeline.Pipeline),
|
|
56
|
+
component: ({ data, role }) => {
|
|
57
|
+
return <ProjectCard role={role} subject={data.subject} />;
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
Surface.create({
|
|
61
|
+
id: 'schema-popover--task',
|
|
62
|
+
position: 'hoist',
|
|
63
|
+
filter: AppSurface.object(AppSurface.Card, Task.Task),
|
|
64
|
+
component: ({ data, role }) => {
|
|
65
|
+
return <TaskCard role={role} subject={data.subject} />;
|
|
66
|
+
},
|
|
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
|
+
}),
|
|
60
75
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Effect.gen(function* () {
|
|
65
|
-
const view = currentSpaceOrgs.includes(org) ? currentSpaceOrgTable : defaultSpaceOrgTable;
|
|
66
|
-
yield* dispatch(
|
|
67
|
-
createIntent(LayoutAction.UpdatePopover, {
|
|
68
|
-
part: 'popover',
|
|
69
|
-
options: {
|
|
70
|
-
state: false,
|
|
71
|
-
anchorId: '',
|
|
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],
|
|
99
|
-
);
|
|
76
|
+
//
|
|
77
|
+
// Fallback for any object.
|
|
78
|
+
//
|
|
100
79
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
|
|
111
|
-
filter: (data): data is { subject: DataType.Organization } => Obj.instanceOf(DataType.Organization, data.subject),
|
|
112
|
-
component: ({ data, role }) => (
|
|
113
|
-
<OrganizationCard role={role} subject={data.subject}>
|
|
114
|
-
{role === 'card--popover' && <Surface role='related' data={data} />}
|
|
115
|
-
</OrganizationCard>
|
|
116
|
-
),
|
|
117
|
-
}),
|
|
118
|
-
createSurface({
|
|
119
|
-
id: `${PREVIEW_PLUGIN}/schema-popover--project`,
|
|
120
|
-
role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
|
|
121
|
-
filter: (data): data is { subject: DataType.Project } => Obj.instanceOf(DataType.Project, data.subject),
|
|
122
|
-
component: ({ data, role }) => <ProjectCard subject={data.subject} role={role} />,
|
|
123
|
-
}),
|
|
80
|
+
Surface.create({
|
|
81
|
+
id: 'fallback-popover',
|
|
82
|
+
role: 'card--content',
|
|
83
|
+
position: 'fallback',
|
|
84
|
+
filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
|
|
85
|
+
component: ({ data, role }) => {
|
|
86
|
+
return <FormCard role={role} subject={data.subject} projection={data.projection} />;
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
124
89
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const schema = getSchema(data.subject);
|
|
135
|
-
const { t } = useTranslation(PREVIEW_PLUGIN);
|
|
136
|
-
if (!schema) {
|
|
137
|
-
// TODO(burdon): Use Alert.
|
|
138
|
-
return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
|
|
139
|
-
}
|
|
90
|
+
Surface.create({
|
|
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
|
+
}),
|
|
140
99
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
);
|
|
161
|
-
},
|
|
162
|
-
}),
|
|
163
|
-
]);
|
|
100
|
+
Surface.create({
|
|
101
|
+
id: 'section',
|
|
102
|
+
position: 'fallback',
|
|
103
|
+
filter: AppSurface.subject(AppSurface.Section, Obj.isObject),
|
|
104
|
+
component: ({ data }) => {
|
|
105
|
+
return (
|
|
106
|
+
<div role='none' className='flex w-full justify-center'>
|
|
107
|
+
<div role='none' className='py-2 dx-card-min-width dx-card-max-width'>
|
|
108
|
+
<Card.Root>
|
|
109
|
+
<Surface.Surface type={AppSurface.Card} data={data} limit={1} />
|
|
110
|
+
</Card.Root>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
]),
|
|
117
|
+
),
|
|
118
|
+
);
|