@dxos/plugin-preview 0.8.4-main.d05673bc65 → 0.8.4-main.dfabb4ec29
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/neutral/PreviewPlugin.mjs +9 -0
- package/dist/lib/neutral/PreviewPlugin.mjs.map +7 -0
- package/dist/lib/neutral/PreviewPlugin.node.mjs +17 -0
- package/dist/lib/neutral/PreviewPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +9 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3SWUVHXJ.mjs +28 -0
- package/dist/lib/neutral/chunk-3SWUVHXJ.mjs.map +7 -0
- package/dist/lib/{browser/chunk-KLQDOIFV.mjs → neutral/chunk-52UEVZSF.mjs} +1 -1
- package/dist/lib/{browser/chunk-KLQDOIFV.mjs.map → neutral/chunk-52UEVZSF.mjs.map} +2 -2
- package/dist/lib/neutral/index.mjs +7 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +7 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +11 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/{browser/preview-popover-X2ZJM5MK.mjs → neutral/preview-popover-MPPEMUIA.mjs} +10 -13
- package/dist/lib/neutral/preview-popover-MPPEMUIA.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-YFFJXXPQ.mjs +348 -0
- package/dist/lib/neutral/react-surface-YFFJXXPQ.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +7 -0
- package/dist/lib/neutral/testing.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +21 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/types/src/PreviewPlugin.d.ts +1 -0
- package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
- package/dist/types/src/PreviewPlugin.node.d.ts +4 -0
- package/dist/types/src/PreviewPlugin.node.d.ts.map +1 -0
- package/dist/types/src/PreviewPlugin.test.d.ts +2 -0
- package/dist/types/src/PreviewPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +3 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/cards/ExpandoCard.d.ts +4 -0
- package/dist/types/src/cards/ExpandoCard.d.ts.map +1 -0
- package/dist/types/src/cards/FormCard.d.ts +2 -2
- package/dist/types/src/cards/FormCard.d.ts.map +1 -1
- package/dist/types/src/cards/JsonCard.d.ts +5 -0
- package/dist/types/src/cards/JsonCard.d.ts.map +1 -0
- package/dist/types/src/cards/OrganizationCard.d.ts +2 -2
- package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
- package/dist/types/src/cards/PersonCard.d.ts +2 -2
- package/dist/types/src/cards/PersonCard.d.ts.map +1 -1
- package/dist/types/src/cards/ProjectCard.d.ts +2 -2
- package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
- package/dist/types/src/cards/TaskCard.d.ts +2 -2
- package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
- package/dist/types/src/cards/index.d.ts +2 -0
- package/dist/types/src/cards/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +3 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/stories/Card.stories.d.ts +15 -9
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +4 -2
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +8 -9
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +78 -40
- package/src/PreviewPlugin.node.ts +16 -0
- package/src/PreviewPlugin.test.ts +25 -0
- package/src/PreviewPlugin.tsx +6 -4
- package/src/capabilities/index.ts +4 -2
- package/src/capabilities/{preview-popover/preview-popover.ts → preview-popover.ts} +10 -4
- package/src/capabilities/react-surface.tsx +118 -0
- package/src/cards/ExpandoCard.tsx +76 -0
- package/src/cards/FormCard.tsx +5 -5
- package/src/cards/JsonCard.tsx +19 -0
- package/src/cards/OrganizationCard.tsx +3 -3
- package/src/cards/PersonCard.tsx +27 -9
- package/src/cards/ProjectCard.tsx +2 -2
- package/src/cards/TaskCard.tsx +15 -11
- package/src/cards/index.ts +2 -0
- package/src/index.ts +0 -2
- package/src/plugin.ts +9 -0
- package/src/stories/Card.stories.tsx +50 -5
- package/src/stories/testing.tsx +26 -16
- package/src/testing.ts +7 -0
- package/src/translations.ts +8 -8
- package/dist/lib/browser/index.mjs +0 -55
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/preview-popover-X2ZJM5MK.mjs.map +0 -7
- package/dist/lib/browser/react-surface-XGUZ4J2A.mjs +0 -236
- package/dist/lib/browser/react-surface-XGUZ4J2A.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GFWHEHC5.mjs +0 -19
- package/dist/lib/node-esm/chunk-GFWHEHC5.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -56
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/preview-popover-6FLDJHHB.mjs +0 -83
- package/dist/lib/node-esm/preview-popover-6FLDJHHB.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-DGHIAODG.mjs +0 -237
- package/dist/lib/node-esm/react-surface-DGHIAODG.mjs.map +0 -7
- package/dist/types/src/capabilities/preview-popover/index.d.ts +0 -3
- package/dist/types/src/capabilities/preview-popover/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/src/capabilities/preview-popover/index.ts +0 -7
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -97
- /package/dist/types/src/capabilities/{preview-popover/preview-popover.d.ts → preview-popover.d.ts} +0 -0
- /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-preview",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.dfabb4ec29",
|
|
4
4
|
"description": "Preview plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -12,64 +12,102 @@
|
|
|
12
12
|
"author": "DXOS.org",
|
|
13
13
|
"sideEffects": true,
|
|
14
14
|
"type": "module",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#capabilities": {
|
|
17
|
+
"source": "./src/capabilities/index.ts",
|
|
18
|
+
"types": "./dist/types/src/capabilities/index.d.ts",
|
|
19
|
+
"default": "./dist/lib/neutral/capabilities/index.mjs"
|
|
20
|
+
},
|
|
21
|
+
"#meta": {
|
|
22
|
+
"source": "./src/meta.ts",
|
|
23
|
+
"types": "./dist/types/src/meta.d.ts",
|
|
24
|
+
"default": "./dist/lib/neutral/meta.mjs"
|
|
25
|
+
},
|
|
26
|
+
"#plugin": {
|
|
27
|
+
"source": {
|
|
28
|
+
"node": "./src/PreviewPlugin.node.ts",
|
|
29
|
+
"default": "./src/PreviewPlugin.tsx"
|
|
30
|
+
},
|
|
31
|
+
"types": "./dist/types/src/PreviewPlugin.d.ts",
|
|
32
|
+
"node": "./dist/lib/neutral/PreviewPlugin.node.mjs",
|
|
33
|
+
"default": "./dist/lib/neutral/PreviewPlugin.mjs"
|
|
34
|
+
},
|
|
35
|
+
"#translations": {
|
|
36
|
+
"source": "./src/translations.ts",
|
|
37
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
38
|
+
"default": "./dist/lib/neutral/translations.mjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
15
41
|
"exports": {
|
|
16
42
|
".": {
|
|
17
43
|
"source": "./src/index.ts",
|
|
18
44
|
"types": "./dist/types/src/index.d.ts",
|
|
19
|
-
"
|
|
45
|
+
"default": "./dist/lib/neutral/index.mjs"
|
|
46
|
+
},
|
|
47
|
+
"./plugin": {
|
|
48
|
+
"source": "./src/plugin.ts",
|
|
49
|
+
"types": "./dist/types/src/plugin.d.ts",
|
|
50
|
+
"default": "./dist/lib/neutral/plugin.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./testing": {
|
|
53
|
+
"source": "./src/testing.ts",
|
|
54
|
+
"types": "./dist/types/src/testing.d.ts",
|
|
55
|
+
"default": "./dist/lib/neutral/testing.mjs"
|
|
56
|
+
},
|
|
57
|
+
"./translations": {
|
|
58
|
+
"source": "./src/translations.ts",
|
|
59
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
60
|
+
"default": "./dist/lib/neutral/translations.mjs"
|
|
20
61
|
}
|
|
21
62
|
},
|
|
22
63
|
"types": "dist/types/src/index.d.ts",
|
|
23
|
-
"typesVersions": {
|
|
24
|
-
"*": {}
|
|
25
|
-
},
|
|
26
64
|
"files": [
|
|
27
65
|
"dist",
|
|
28
66
|
"src"
|
|
29
67
|
],
|
|
30
68
|
"dependencies": {
|
|
31
69
|
"@effect-atom/atom-react": "^0.5.0",
|
|
32
|
-
"@dxos/app-
|
|
33
|
-
"@dxos/app-
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/client": "0.8.4-main.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/keys": "0.8.4-main.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/log": "0.8.4-main.
|
|
42
|
-
"@dxos/operation": "0.8.4-main.
|
|
43
|
-
"@dxos/plugin-attention": "0.8.4-main.
|
|
44
|
-
"@dxos/plugin-
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/react-ui
|
|
48
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
49
|
-
"@dxos/react-ui-
|
|
50
|
-
"@dxos/react-ui-
|
|
51
|
-
"@dxos/react-ui-
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/ui-editor": "0.8.4-main.
|
|
70
|
+
"@dxos/app-framework": "0.8.4-main.dfabb4ec29",
|
|
71
|
+
"@dxos/app-toolkit": "0.8.4-main.dfabb4ec29",
|
|
72
|
+
"@dxos/async": "0.8.4-main.dfabb4ec29",
|
|
73
|
+
"@dxos/client": "0.8.4-main.dfabb4ec29",
|
|
74
|
+
"@dxos/app-graph": "0.8.4-main.dfabb4ec29",
|
|
75
|
+
"@dxos/keys": "0.8.4-main.dfabb4ec29",
|
|
76
|
+
"@dxos/effect": "0.8.4-main.dfabb4ec29",
|
|
77
|
+
"@dxos/lit-ui": "0.8.4-main.dfabb4ec29",
|
|
78
|
+
"@dxos/echo": "0.8.4-main.dfabb4ec29",
|
|
79
|
+
"@dxos/log": "0.8.4-main.dfabb4ec29",
|
|
80
|
+
"@dxos/operation": "0.8.4-main.dfabb4ec29",
|
|
81
|
+
"@dxos/plugin-attention": "0.8.4-main.dfabb4ec29",
|
|
82
|
+
"@dxos/plugin-deck": "0.8.4-main.dfabb4ec29",
|
|
83
|
+
"@dxos/react-client": "0.8.4-main.dfabb4ec29",
|
|
84
|
+
"@dxos/plugin-client": "0.8.4-main.dfabb4ec29",
|
|
85
|
+
"@dxos/react-ui": "0.8.4-main.dfabb4ec29",
|
|
86
|
+
"@dxos/react-ui-form": "0.8.4-main.dfabb4ec29",
|
|
87
|
+
"@dxos/react-ui-editor": "0.8.4-main.dfabb4ec29",
|
|
88
|
+
"@dxos/react-ui-menu": "0.8.4-main.dfabb4ec29",
|
|
89
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.dfabb4ec29",
|
|
90
|
+
"@dxos/schema": "0.8.4-main.dfabb4ec29",
|
|
91
|
+
"@dxos/types": "0.8.4-main.dfabb4ec29",
|
|
92
|
+
"@dxos/ui-theme": "0.8.4-main.dfabb4ec29",
|
|
93
|
+
"@dxos/react-ui-table": "0.8.4-main.dfabb4ec29",
|
|
94
|
+
"@dxos/util": "0.8.4-main.dfabb4ec29",
|
|
95
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.dfabb4ec29",
|
|
96
|
+
"@dxos/ui-editor": "0.8.4-main.dfabb4ec29"
|
|
59
97
|
},
|
|
60
98
|
"devDependencies": {
|
|
61
|
-
"effect": "3.
|
|
99
|
+
"effect": "3.20.0",
|
|
62
100
|
"react": "~19.2.3",
|
|
63
101
|
"react-dom": "~19.2.3",
|
|
64
|
-
"vite": "^
|
|
65
|
-
"@dxos/echo-db": "0.8.4-main.
|
|
66
|
-
"@dxos/plugin-testing": "0.8.4-main.
|
|
67
|
-
"@dxos/random": "0.8.4-main.
|
|
68
|
-
"@dxos/react-ui-components": "0.8.4-main.
|
|
69
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
102
|
+
"vite": "^8.0.10",
|
|
103
|
+
"@dxos/echo-db": "0.8.4-main.dfabb4ec29",
|
|
104
|
+
"@dxos/plugin-testing": "0.8.4-main.dfabb4ec29",
|
|
105
|
+
"@dxos/random": "0.8.4-main.dfabb4ec29",
|
|
106
|
+
"@dxos/react-ui-components": "0.8.4-main.dfabb4ec29",
|
|
107
|
+
"@dxos/storybook-utils": "0.8.4-main.dfabb4ec29"
|
|
70
108
|
},
|
|
71
109
|
"peerDependencies": {
|
|
72
|
-
"effect": "3.
|
|
110
|
+
"effect": "3.20.0",
|
|
73
111
|
"react": "~19.2.3",
|
|
74
112
|
"react-dom": "~19.2.3"
|
|
75
113
|
},
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
7
|
+
import { Organization, Person } from '@dxos/types';
|
|
8
|
+
|
|
9
|
+
import { meta } from '#meta';
|
|
10
|
+
|
|
11
|
+
export const PreviewPlugin = Plugin.define(meta).pipe(
|
|
12
|
+
AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization] }),
|
|
13
|
+
Plugin.make,
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default PreviewPlugin;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { ClientPlugin } from '@dxos/plugin-client/plugin';
|
|
8
|
+
import { createComposerTestApp } from '@dxos/plugin-testing/harness';
|
|
9
|
+
|
|
10
|
+
import { PreviewPlugin } from '#plugin';
|
|
11
|
+
|
|
12
|
+
import { meta } from './meta';
|
|
13
|
+
|
|
14
|
+
const moduleId = (name: string) => `${meta.id}.module.${name}`;
|
|
15
|
+
|
|
16
|
+
describe('PreviewPlugin', () => {
|
|
17
|
+
test('modules activate on the expected events', { timeout: 10_000 }, async ({ expect }) => {
|
|
18
|
+
await using harness = await createComposerTestApp({
|
|
19
|
+
plugins: [ClientPlugin({}), PreviewPlugin()],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// After autoStart: schema auto-cascades from ClientPlugin.
|
|
23
|
+
expect(harness.manager.getActive()).toContain(moduleId('schema'));
|
|
24
|
+
});
|
|
25
|
+
});
|
package/src/PreviewPlugin.tsx
CHANGED
|
@@ -6,12 +6,12 @@ import { ActivationEvents, Plugin } from '@dxos/app-framework';
|
|
|
6
6
|
import { AppPlugin } from '@dxos/app-toolkit';
|
|
7
7
|
import { Organization, Person } from '@dxos/types';
|
|
8
8
|
|
|
9
|
-
import { PreviewPopover, ReactSurface } from '
|
|
10
|
-
import { meta } from '
|
|
11
|
-
import { translations } from '
|
|
9
|
+
import { PreviewPopover, ReactSurface } from '#capabilities';
|
|
10
|
+
import { meta } from '#meta';
|
|
11
|
+
import { translations } from '#translations';
|
|
12
12
|
|
|
13
13
|
export const PreviewPlugin = Plugin.define(meta).pipe(
|
|
14
|
-
AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization]
|
|
14
|
+
AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization] }),
|
|
15
15
|
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
16
16
|
AppPlugin.addTranslationsModule({ translations }),
|
|
17
17
|
Plugin.addModule({
|
|
@@ -21,3 +21,5 @@ export const PreviewPlugin = Plugin.define(meta).pipe(
|
|
|
21
21
|
}),
|
|
22
22
|
Plugin.make,
|
|
23
23
|
);
|
|
24
|
+
|
|
25
|
+
export default PreviewPlugin;
|
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
export const PreviewPopover = Capability.lazy('PreviewPopover', () => import('./preview-popover'));
|
|
8
|
+
export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
7
|
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
-
import { AppCapabilities, LayoutOperation, getSpaceIdFromPath } from '@dxos/app-toolkit';
|
|
8
|
+
import { AppCapabilities, LayoutOperation, getPersonalSpace, getSpaceIdFromPath } from '@dxos/app-toolkit';
|
|
9
9
|
import { addEventListener } from '@dxos/async';
|
|
10
10
|
import { type Client } from '@dxos/client';
|
|
11
11
|
import { type Space } from '@dxos/client/echo';
|
|
@@ -49,10 +49,16 @@ export default Capability.makeModule(
|
|
|
49
49
|
const { invokePromise } = capabilities.get(Capabilities.OperationInvoker);
|
|
50
50
|
const client = capabilities.get(ClientCapabilities.Client);
|
|
51
51
|
const registry = capabilities.get(Capabilities.AtomRegistry);
|
|
52
|
+
// Layout is optional: in standalone harnesses (Storybook, tests) no plugin contributes
|
|
53
|
+
// `AppCapabilities.Layout`, and `getAll` returns an empty array. Reading `registry.get(undefined)`
|
|
54
|
+
// would crash inside Atom's identity check (`'~atom/Serializable' in undefined`). When layout
|
|
55
|
+
// isn't available, fall through to the personal-space default.
|
|
52
56
|
const [layoutAtom] = capabilities.getAll(AppCapabilities.Layout);
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
57
|
+
const spaceId = layoutAtom && getSpaceIdFromPath(registry.get(layoutAtom).workspace);
|
|
58
|
+
const space = (spaceId && client.spaces.get(spaceId)) ?? getPersonalSpace(client);
|
|
59
|
+
if (!space) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
56
62
|
const result = await handlePreviewLookup(client, space, { dxn, label });
|
|
57
63
|
if (!result) {
|
|
58
64
|
return;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
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';
|
|
15
|
+
|
|
16
|
+
import { ExpandoCard, FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
17
|
+
|
|
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
|
+
//
|
|
25
|
+
|
|
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
|
+
}),
|
|
75
|
+
|
|
76
|
+
//
|
|
77
|
+
// Fallback for any object.
|
|
78
|
+
//
|
|
79
|
+
|
|
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
|
+
}),
|
|
89
|
+
|
|
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
|
+
}),
|
|
99
|
+
|
|
100
|
+
Surface.create({
|
|
101
|
+
id: 'section',
|
|
102
|
+
position: 'fallback',
|
|
103
|
+
filter: AppSurface.subject(AppSurface.Section, Obj.isObject),
|
|
104
|
+
component: ({ data }) => {
|
|
105
|
+
return (
|
|
106
|
+
<div className='flex w-full justify-center'>
|
|
107
|
+
<div 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
|
+
);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import React, { useCallback, useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { type JsonPath, splitJsonPath } from '@dxos/effect';
|
|
11
|
+
import { Card } from '@dxos/react-ui';
|
|
12
|
+
import { Form } from '@dxos/react-ui-form';
|
|
13
|
+
|
|
14
|
+
const schemaForValue = (value: unknown): Schema.Schema.AnyNoContext | undefined => {
|
|
15
|
+
switch (typeof value) {
|
|
16
|
+
case 'string':
|
|
17
|
+
return Schema.String;
|
|
18
|
+
case 'number':
|
|
19
|
+
return Schema.Number;
|
|
20
|
+
case 'boolean':
|
|
21
|
+
return Schema.Boolean;
|
|
22
|
+
default:
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Reserved keys: `id`, plus any `~`-prefixed key (ECHO uses `~`-prefixed
|
|
29
|
+
* string keys to brand entity instances and schemas — KindId,
|
|
30
|
+
* SchemaKindId, SnapshotKindId, etc. — and the `~` namespace is reserved
|
|
31
|
+
* for that purpose). They show up in `Object.keys` but aren't user data.
|
|
32
|
+
*/
|
|
33
|
+
const isInternalKey = (key: string) => key === 'id' || key.startsWith('~');
|
|
34
|
+
|
|
35
|
+
export const ExpandoCard = ({ subject, ignorePaths }: AppSurface.ObjectCardProps) => {
|
|
36
|
+
const schema = useMemo(() => {
|
|
37
|
+
const ignored = new Set(ignorePaths ?? []);
|
|
38
|
+
const fields: Record<string, Schema.Schema.AnyNoContext> = {};
|
|
39
|
+
for (const key of Object.keys(subject)) {
|
|
40
|
+
if (isInternalKey(key) || ignored.has(key)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const fieldSchema = schemaForValue((subject as any)[key]);
|
|
44
|
+
if (fieldSchema) {
|
|
45
|
+
fields[key] = fieldSchema;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return Schema.Struct(fields);
|
|
49
|
+
}, [subject, ignorePaths]);
|
|
50
|
+
|
|
51
|
+
const handleSave = useCallback(
|
|
52
|
+
(values: any, { changed }: { changed: Record<string, boolean> }) => {
|
|
53
|
+
const paths = Object.keys(changed).filter((path) => changed[path]);
|
|
54
|
+
Obj.update(subject, () => {
|
|
55
|
+
for (const path of paths) {
|
|
56
|
+
const value = values[path];
|
|
57
|
+
const parts = splitJsonPath(path as JsonPath);
|
|
58
|
+
Obj.setValue(subject, parts, value);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
[subject],
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Card.Content>
|
|
67
|
+
<Form.Root schema={schema} values={subject} autoSave onSave={handleSave}>
|
|
68
|
+
<Form.Viewport>
|
|
69
|
+
<Form.Content>
|
|
70
|
+
<Form.FieldSet />
|
|
71
|
+
</Form.Content>
|
|
72
|
+
</Form.Viewport>
|
|
73
|
+
</Form.Root>
|
|
74
|
+
</Card.Content>
|
|
75
|
+
);
|
|
76
|
+
};
|
package/src/cards/FormCard.tsx
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { Obj } from '@dxos/echo';
|
|
9
9
|
import { type JsonPath, splitJsonPath } from '@dxos/effect';
|
|
10
10
|
import { Card, useTranslation } from '@dxos/react-ui';
|
|
@@ -12,16 +12,16 @@ import { Form, omitId } from '@dxos/react-ui-form';
|
|
|
12
12
|
import { type ProjectionModel } from '@dxos/schema';
|
|
13
13
|
import { descriptionMessage, mx } from '@dxos/ui-theme';
|
|
14
14
|
|
|
15
|
-
import { meta } from '
|
|
15
|
+
import { meta } from '#meta';
|
|
16
16
|
|
|
17
|
-
export const FormCard = ({ subject, projection }:
|
|
17
|
+
export const FormCard = ({ subject, projection }: AppSurface.ObjectCardProps & { projection?: ProjectionModel }) => {
|
|
18
18
|
const { t } = useTranslation(meta.id);
|
|
19
19
|
const echoSchema = Obj.getSchema(subject);
|
|
20
20
|
const schema = useMemo(() => echoSchema && omitId(echoSchema), [echoSchema]);
|
|
21
21
|
|
|
22
22
|
const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
|
|
23
23
|
const paths = Object.keys(changed).filter((path) => changed[path]);
|
|
24
|
-
Obj.
|
|
24
|
+
Obj.update(subject, () => {
|
|
25
25
|
for (const path of paths) {
|
|
26
26
|
const value = values[path];
|
|
27
27
|
const parts = splitJsonPath(path as JsonPath);
|
|
@@ -31,7 +31,7 @@ export const FormCard = ({ subject, projection }: SurfaceComponentProps & { proj
|
|
|
31
31
|
}, []);
|
|
32
32
|
|
|
33
33
|
if (!schema) {
|
|
34
|
-
return <p className={mx(descriptionMessage)}>{t('unable
|
|
34
|
+
return <p className={mx(descriptionMessage)}>{t('unable-to-create-preview.message')}</p>;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return (
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Card } from '@dxos/react-ui';
|
|
8
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
9
|
+
|
|
10
|
+
export const JsonCard = ({ data }: { data: unknown }) => {
|
|
11
|
+
return (
|
|
12
|
+
<Card.Content>
|
|
13
|
+
<span />
|
|
14
|
+
{/* TODO(wittjosiah): Span whole row. */}
|
|
15
|
+
<JsonHighlighter data={data} />
|
|
16
|
+
<span />
|
|
17
|
+
</Card.Content>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { Card } from '@dxos/react-ui';
|
|
9
9
|
import { type Organization } from '@dxos/types';
|
|
10
10
|
|
|
11
|
-
export const OrganizationCard = ({ subject }:
|
|
12
|
-
const { image, description, website } = subject;
|
|
11
|
+
export const OrganizationCard = ({ subject }: AppSurface.ObjectCardProps<Organization.Organization>) => {
|
|
12
|
+
const { name, image, description, website } = subject;
|
|
13
13
|
|
|
14
14
|
return (
|
|
15
15
|
<Card.Content>
|
package/src/cards/PersonCard.tsx
CHANGED
|
@@ -2,16 +2,38 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React, { useCallback } from 'react';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
+
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
9
|
+
import { LayoutOperation, getObjectPathFromObject, getSpacePath } from '@dxos/app-toolkit';
|
|
10
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
8
13
|
import { Avatar } from '@dxos/react-ui';
|
|
9
14
|
import { Card } from '@dxos/react-ui';
|
|
10
15
|
import { type Person } from '@dxos/types';
|
|
11
16
|
|
|
12
|
-
export const PersonCard = ({ subject }:
|
|
17
|
+
export const PersonCard = ({ subject }: AppSurface.ObjectCardProps<Person.Person>) => {
|
|
18
|
+
const { invoke } = useOperationInvoker();
|
|
13
19
|
const { image, organization: { target: organization } = {}, emails = [] } = subject;
|
|
14
20
|
|
|
21
|
+
const handleOrganizationClick = useCallback(() => {
|
|
22
|
+
if (!organization) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return Effect.gen(function* () {
|
|
27
|
+
const organizationPath = getObjectPathFromObject(organization);
|
|
28
|
+
const db = Obj.getDatabase(organization);
|
|
29
|
+
yield* invoke(LayoutOperation.UpdatePopover, { state: false, anchorId: '' });
|
|
30
|
+
yield* invoke(LayoutOperation.Open, {
|
|
31
|
+
subject: [organizationPath],
|
|
32
|
+
workspace: db ? getSpacePath(db.spaceId) : undefined,
|
|
33
|
+
});
|
|
34
|
+
}).pipe(runAndForwardErrors);
|
|
35
|
+
}, [invoke, organization]);
|
|
36
|
+
|
|
15
37
|
return (
|
|
16
38
|
<Card.Content>
|
|
17
39
|
<Avatar.Root>
|
|
@@ -20,7 +42,7 @@ export const PersonCard = ({ subject }: SurfaceComponentProps<Person.Person>) =>
|
|
|
20
42
|
<Avatar.Content
|
|
21
43
|
imgSrc={image}
|
|
22
44
|
icon='ph--user--regular'
|
|
23
|
-
size={
|
|
45
|
+
size={20}
|
|
24
46
|
classNames={!image && 'opacity-50'}
|
|
25
47
|
hue='neutral'
|
|
26
48
|
variant='square'
|
|
@@ -28,11 +50,7 @@ export const PersonCard = ({ subject }: SurfaceComponentProps<Person.Person>) =>
|
|
|
28
50
|
</Card.Row>
|
|
29
51
|
)}
|
|
30
52
|
{organization?.name && (
|
|
31
|
-
<Card.Action
|
|
32
|
-
icon='ph--buildings--regular'
|
|
33
|
-
label={organization.name}
|
|
34
|
-
// onClick={onSelect ? () => onSelect(organization) : undefined}
|
|
35
|
-
/>
|
|
53
|
+
<Card.Action icon='ph--buildings--regular' label={organization.name} onClick={handleOrganizationClick} />
|
|
36
54
|
)}
|
|
37
55
|
{emails.map(({ value }) => (
|
|
38
56
|
<Card.Row key={value} icon='ph--at--regular'>
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { Obj } from '@dxos/echo';
|
|
9
9
|
import { Card } from '@dxos/react-ui';
|
|
10
10
|
import { type Pipeline } from '@dxos/types';
|
|
11
11
|
|
|
12
|
-
export const ProjectCard = ({ subject }:
|
|
12
|
+
export const ProjectCard = ({ subject }: AppSurface.ObjectCardProps<Pipeline.Pipeline>) => {
|
|
13
13
|
const { image, description } = subject;
|
|
14
14
|
|
|
15
15
|
return (
|
package/src/cards/TaskCard.tsx
CHANGED
|
@@ -5,23 +5,26 @@
|
|
|
5
5
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { type
|
|
8
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
9
9
|
import { type PropertyMetaAnnotation, PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
10
10
|
import { Card } from '@dxos/react-ui';
|
|
11
11
|
import { Task } from '@dxos/types';
|
|
12
12
|
|
|
13
|
-
export const TaskCard = ({ subject }:
|
|
13
|
+
export const TaskCard = ({ subject }: AppSurface.ObjectCardProps<Task.Task>) => {
|
|
14
14
|
const { title, status } = subject;
|
|
15
15
|
const statusOption = getActiveStatusOption(status);
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
18
|
<Card.Content>
|
|
19
|
-
<Card.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
<Card.Row>
|
|
20
|
+
{statusOption && (
|
|
21
|
+
<div>
|
|
22
|
+
<span className='dx-tag' data-hue={statusOption.color}>
|
|
23
|
+
{statusOption.title}
|
|
24
|
+
</span>
|
|
25
|
+
</div>
|
|
26
|
+
)}
|
|
27
|
+
</Card.Row>
|
|
25
28
|
</Card.Content>
|
|
26
29
|
);
|
|
27
30
|
};
|
|
@@ -30,11 +33,12 @@ export const TaskCard = ({ subject }: SurfaceComponentProps<Task.Task>) => {
|
|
|
30
33
|
const getActiveStatusOption = (status?: string) => {
|
|
31
34
|
const properties = SchemaAST.getPropertySignatures(Task.Task.ast);
|
|
32
35
|
const statusProperty = properties.find((p) => p.name === 'status');
|
|
36
|
+
// TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
|
|
33
37
|
const statusMeta = SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(
|
|
34
|
-
// TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
|
|
35
38
|
(statusProperty!.type as any).types[0],
|
|
36
39
|
);
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
|
|
41
|
+
// TODO(thure): Typescript asserts `statusMeta` doesn’t have `.value`, but in runtime it does.
|
|
42
|
+
const options = (statusMeta as any).value.singleSelect.options as { id: string; title: string; color: string }[];
|
|
39
43
|
return options.find(({ id }) => id === status);
|
|
40
44
|
};
|