@dxos/plugin-preview 0.8.4-main.fcfe5033a5 → 0.8.4-staging.60fe92afc8
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/LICENSE +102 -5
- 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/PreviewPlugin.workerd.mjs +17 -0
- package/dist/lib/neutral/PreviewPlugin.workerd.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/neutral/chunk-QOM5APM7.mjs +23 -0
- package/dist/lib/neutral/chunk-QOM5APM7.mjs.map +7 -0
- 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/neutral/preview-popover-FLMYMFCH.mjs +94 -0
- package/dist/lib/neutral/preview-popover-FLMYMFCH.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-FE7E2JP7.mjs +418 -0
- package/dist/lib/neutral/react-surface-FE7E2JP7.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/PreviewPlugin.workerd.d.ts +4 -0
- package/dist/types/src/PreviewPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -1
- 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 +12 -2
- package/dist/types/src/cards/FormCard.d.ts.map +1 -1
- package/dist/types/src/cards/JsonCard.d.ts.map +1 -1
- package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
- package/dist/types/src/cards/PersonCard.d.ts.map +1 -1
- package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
- 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 +1 -1
- package/dist/types/src/meta.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 +31 -9
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +43 -4
- 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 +70 -44
- package/src/PreviewPlugin.node.ts +16 -0
- package/src/PreviewPlugin.test.ts +25 -0
- package/src/PreviewPlugin.tsx +4 -3
- package/src/PreviewPlugin.workerd.ts +16 -0
- package/src/capabilities/preview-popover.ts +34 -6
- package/src/capabilities/react-surface.tsx +59 -18
- package/src/cards/ExpandoCard.tsx +76 -0
- package/src/cards/FormCard.tsx +102 -25
- package/src/cards/JsonCard.tsx +7 -4
- package/src/cards/OrganizationCard.tsx +2 -2
- package/src/cards/PersonCard.tsx +4 -4
- package/src/cards/ProjectCard.tsx +2 -2
- package/src/cards/TaskCard.tsx +4 -3
- package/src/cards/index.ts +1 -0
- package/src/index.ts +0 -2
- package/src/meta.ts +7 -4
- package/src/plugin.ts +9 -0
- package/src/stories/Card.stories.tsx +76 -6
- package/src/stories/testing.tsx +69 -7
- package/src/testing.ts +7 -0
- package/dist/lib/browser/index.mjs +0 -59
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -61
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-preview",
|
|
3
|
-
"version": "0.8.4-
|
|
3
|
+
"version": "0.8.4-staging.60fe92afc8",
|
|
4
4
|
"description": "Preview plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -8,72 +8,98 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/dxos/dxos"
|
|
10
10
|
},
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
12
12
|
"author": "DXOS.org",
|
|
13
13
|
"sideEffects": true,
|
|
14
14
|
"type": "module",
|
|
15
15
|
"imports": {
|
|
16
|
-
"#capabilities":
|
|
17
|
-
|
|
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
|
+
"workerd": "./src/PreviewPlugin.workerd.ts",
|
|
29
|
+
"node": "./src/PreviewPlugin.node.ts",
|
|
30
|
+
"default": "./src/PreviewPlugin.tsx"
|
|
31
|
+
},
|
|
32
|
+
"types": "./dist/types/src/PreviewPlugin.d.ts",
|
|
33
|
+
"workerd": "./dist/lib/neutral/PreviewPlugin.workerd.mjs",
|
|
34
|
+
"node": "./dist/lib/neutral/PreviewPlugin.node.mjs",
|
|
35
|
+
"default": "./dist/lib/neutral/PreviewPlugin.mjs"
|
|
36
|
+
},
|
|
37
|
+
"#translations": {
|
|
38
|
+
"source": "./src/translations.ts",
|
|
39
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
40
|
+
"default": "./dist/lib/neutral/translations.mjs"
|
|
41
|
+
}
|
|
18
42
|
},
|
|
19
43
|
"exports": {
|
|
20
44
|
".": {
|
|
21
45
|
"source": "./src/index.ts",
|
|
22
46
|
"types": "./dist/types/src/index.d.ts",
|
|
23
|
-
"
|
|
47
|
+
"default": "./dist/lib/neutral/index.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./plugin": {
|
|
50
|
+
"source": "./src/plugin.ts",
|
|
51
|
+
"types": "./dist/types/src/plugin.d.ts",
|
|
52
|
+
"default": "./dist/lib/neutral/plugin.mjs"
|
|
53
|
+
},
|
|
54
|
+
"./testing": {
|
|
55
|
+
"source": "./src/testing.ts",
|
|
56
|
+
"types": "./dist/types/src/testing.d.ts",
|
|
57
|
+
"default": "./dist/lib/neutral/testing.mjs"
|
|
58
|
+
},
|
|
59
|
+
"./translations": {
|
|
60
|
+
"source": "./src/translations.ts",
|
|
61
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
62
|
+
"default": "./dist/lib/neutral/translations.mjs"
|
|
24
63
|
}
|
|
25
64
|
},
|
|
26
65
|
"types": "dist/types/src/index.d.ts",
|
|
27
|
-
"typesVersions": {
|
|
28
|
-
"*": {}
|
|
29
|
-
},
|
|
30
66
|
"files": [
|
|
31
67
|
"dist",
|
|
32
68
|
"src"
|
|
33
69
|
],
|
|
34
70
|
"dependencies": {
|
|
35
|
-
"@
|
|
36
|
-
"@dxos/app-toolkit": "0.8.4-
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/echo": "0.8.4-
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/react-ui-form": "0.8.4-main.fcfe5033a5",
|
|
54
|
-
"@dxos/react-ui-mosaic": "0.8.4-main.fcfe5033a5",
|
|
55
|
-
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.fcfe5033a5",
|
|
56
|
-
"@dxos/react-ui-menu": "0.8.4-main.fcfe5033a5",
|
|
57
|
-
"@dxos/react-ui-table": "0.8.4-main.fcfe5033a5",
|
|
58
|
-
"@dxos/schema": "0.8.4-main.fcfe5033a5",
|
|
59
|
-
"@dxos/types": "0.8.4-main.fcfe5033a5",
|
|
60
|
-
"@dxos/ui-editor": "0.8.4-main.fcfe5033a5",
|
|
61
|
-
"@dxos/util": "0.8.4-main.fcfe5033a5",
|
|
62
|
-
"@dxos/ui-theme": "0.8.4-main.fcfe5033a5"
|
|
71
|
+
"@dxos/app-framework": "0.8.4-staging.60fe92afc8",
|
|
72
|
+
"@dxos/app-toolkit": "0.8.4-staging.60fe92afc8",
|
|
73
|
+
"@dxos/async": "0.8.4-staging.60fe92afc8",
|
|
74
|
+
"@dxos/client": "0.8.4-staging.60fe92afc8",
|
|
75
|
+
"@dxos/echo-react": "0.8.4-staging.60fe92afc8",
|
|
76
|
+
"@dxos/echo": "0.8.4-staging.60fe92afc8",
|
|
77
|
+
"@dxos/effect": "0.8.4-staging.60fe92afc8",
|
|
78
|
+
"@dxos/keys": "0.8.4-staging.60fe92afc8",
|
|
79
|
+
"@dxos/log": "0.8.4-staging.60fe92afc8",
|
|
80
|
+
"@dxos/react-ui": "0.8.4-staging.60fe92afc8",
|
|
81
|
+
"@dxos/plugin-client": "0.8.4-staging.60fe92afc8",
|
|
82
|
+
"@dxos/react-ui-form": "0.8.4-staging.60fe92afc8",
|
|
83
|
+
"@dxos/react-ui-mosaic": "0.8.4-staging.60fe92afc8",
|
|
84
|
+
"@dxos/schema": "0.8.4-staging.60fe92afc8",
|
|
85
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-staging.60fe92afc8",
|
|
86
|
+
"@dxos/ui-editor": "0.8.4-staging.60fe92afc8",
|
|
87
|
+
"@dxos/types": "0.8.4-staging.60fe92afc8",
|
|
88
|
+
"@dxos/util": "0.8.4-staging.60fe92afc8"
|
|
63
89
|
},
|
|
64
90
|
"devDependencies": {
|
|
65
|
-
"effect": "3.
|
|
91
|
+
"effect": "3.21.3",
|
|
66
92
|
"react": "~19.2.3",
|
|
67
93
|
"react-dom": "~19.2.3",
|
|
68
|
-
"vite": "^
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
94
|
+
"vite": "^8.0.16",
|
|
95
|
+
"@dxos/echo-react": "0.8.4-staging.60fe92afc8",
|
|
96
|
+
"@dxos/plugin-testing": "0.8.4-staging.60fe92afc8",
|
|
97
|
+
"@dxos/random": "0.8.4-staging.60fe92afc8",
|
|
98
|
+
"@dxos/storybook-utils": "0.8.4-staging.60fe92afc8",
|
|
99
|
+
"@dxos/react-ui-components": "0.8.4-staging.60fe92afc8"
|
|
74
100
|
},
|
|
75
101
|
"peerDependencies": {
|
|
76
|
-
"effect": "3.
|
|
102
|
+
"effect": "3.21.3",
|
|
77
103
|
"react": "~19.2.3",
|
|
78
104
|
"react-dom": "~19.2.3"
|
|
79
105
|
},
|
|
@@ -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
|
@@ -8,11 +8,10 @@ import { Organization, Person } from '@dxos/types';
|
|
|
8
8
|
|
|
9
9
|
import { PreviewPopover, ReactSurface } from '#capabilities';
|
|
10
10
|
import { meta } from '#meta';
|
|
11
|
-
|
|
12
|
-
import { translations } from './translations';
|
|
11
|
+
import { translations } from '#translations';
|
|
13
12
|
|
|
14
13
|
export const PreviewPlugin = Plugin.define(meta).pipe(
|
|
15
|
-
AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization]
|
|
14
|
+
AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization] }),
|
|
16
15
|
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
17
16
|
AppPlugin.addTranslationsModule({ translations }),
|
|
18
17
|
Plugin.addModule({
|
|
@@ -22,3 +21,5 @@ export const PreviewPlugin = Plugin.define(meta).pipe(
|
|
|
22
21
|
}),
|
|
23
22
|
Plugin.make,
|
|
24
23
|
);
|
|
24
|
+
|
|
25
|
+
export default PreviewPlugin;
|
|
@@ -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;
|
|
@@ -10,9 +10,9 @@ import { addEventListener } from '@dxos/async';
|
|
|
10
10
|
import { type Client } from '@dxos/client';
|
|
11
11
|
import { type Space } from '@dxos/client/echo';
|
|
12
12
|
import { Obj } from '@dxos/echo';
|
|
13
|
-
import {
|
|
13
|
+
import { EID } from '@dxos/keys';
|
|
14
14
|
import { log } from '@dxos/log';
|
|
15
|
-
import { ClientCapabilities } from '@dxos/plugin-client
|
|
15
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
16
16
|
import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';
|
|
17
17
|
import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/ui-editor';
|
|
18
18
|
|
|
@@ -24,7 +24,7 @@ const handlePreviewLookup = async (
|
|
|
24
24
|
{ dxn, label }: PreviewLinkRef,
|
|
25
25
|
): Promise<PreviewLinkTarget | null> => {
|
|
26
26
|
try {
|
|
27
|
-
const object = await defaultSpace.db.makeRef(
|
|
27
|
+
const object = await defaultSpace.db.makeRef(EID.parse(dxn)).load();
|
|
28
28
|
return { label, object };
|
|
29
29
|
} catch {
|
|
30
30
|
return null;
|
|
@@ -37,6 +37,10 @@ export default Capability.makeModule(
|
|
|
37
37
|
const capabilities = yield* Capability.Service;
|
|
38
38
|
|
|
39
39
|
// TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
|
|
40
|
+
// Monotonic activation token: each invocation captures its own sequence; only the
|
|
41
|
+
// most recent activation is allowed to commit popover state. Prevents a slow
|
|
42
|
+
// open (async lookup) from clobbering a later close that fires while it's in flight.
|
|
43
|
+
let activationSequence = 0;
|
|
40
44
|
const handleAnchorActivate = async ({
|
|
41
45
|
dxn,
|
|
42
46
|
label,
|
|
@@ -45,13 +49,32 @@ export default Capability.makeModule(
|
|
|
45
49
|
title: titleProp,
|
|
46
50
|
side,
|
|
47
51
|
props,
|
|
52
|
+
state,
|
|
48
53
|
}: DxAnchorActivate) => {
|
|
54
|
+
const sequence = ++activationSequence;
|
|
49
55
|
const { invokePromise } = capabilities.get(Capabilities.OperationInvoker);
|
|
56
|
+
|
|
57
|
+
// Explicit close: callers pass `state: false` on pointer-leave to dismiss
|
|
58
|
+
// the popover. Operation schema requires anchor + kind, so use placeholders;
|
|
59
|
+
// they're overwritten in ephemeral state but only `state` is read by the UI.
|
|
60
|
+
if (state === false) {
|
|
61
|
+
await invokePromise(LayoutOperation.UpdatePopover, {
|
|
62
|
+
variant: 'virtual',
|
|
63
|
+
anchor: trigger,
|
|
64
|
+
kind: 'base',
|
|
65
|
+
state: false,
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
50
70
|
const client = capabilities.get(ClientCapabilities.Client);
|
|
51
71
|
const registry = capabilities.get(Capabilities.AtomRegistry);
|
|
72
|
+
// Layout is optional: in standalone harnesses (Storybook, tests) no plugin contributes
|
|
73
|
+
// `AppCapabilities.Layout`, and `getAll` returns an empty array. Reading `registry.get(undefined)`
|
|
74
|
+
// would crash inside Atom's identity check (`'~atom/Serializable' in undefined`). When layout
|
|
75
|
+
// isn't available, fall through to the personal-space default.
|
|
52
76
|
const [layoutAtom] = capabilities.getAll(AppCapabilities.Layout);
|
|
53
|
-
const
|
|
54
|
-
const spaceId = getSpaceIdFromPath(layout.workspace);
|
|
77
|
+
const spaceId = layoutAtom && getSpaceIdFromPath(registry.get(layoutAtom).workspace);
|
|
55
78
|
const space = (spaceId && client.spaces.get(spaceId)) ?? getPersonalSpace(client);
|
|
56
79
|
if (!space) {
|
|
57
80
|
return;
|
|
@@ -60,8 +83,13 @@ export default Capability.makeModule(
|
|
|
60
83
|
if (!result) {
|
|
61
84
|
return;
|
|
62
85
|
}
|
|
86
|
+
// A newer activation (open or close) arrived while the lookup was in flight; bail
|
|
87
|
+
// out so we don't clobber the latest state.
|
|
88
|
+
if (sequence !== activationSequence) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
63
91
|
|
|
64
|
-
const title = titleProp ?? Obj.getLabel(result.object);
|
|
92
|
+
const title = titleProp ?? Obj.getLabel(result.object, { fallback: 'typename' });
|
|
65
93
|
|
|
66
94
|
await invokePromise(LayoutOperation.UpdatePopover, {
|
|
67
95
|
subjectRef: dxn,
|
|
@@ -8,12 +8,12 @@ import React from 'react';
|
|
|
8
8
|
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
9
|
import { Surface } from '@dxos/app-framework/ui';
|
|
10
10
|
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
11
|
-
import { Obj } from '@dxos/echo';
|
|
11
|
+
import { Obj, Type } from '@dxos/echo';
|
|
12
12
|
import { Card } from '@dxos/react-ui';
|
|
13
|
-
import { type ProjectionModel } from '@dxos/schema';
|
|
13
|
+
import { Expando, type ProjectionModel } from '@dxos/schema';
|
|
14
14
|
import { Organization, Person, Pipeline, Task } from '@dxos/types';
|
|
15
15
|
|
|
16
|
-
import { FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
16
|
+
import { ExpandoCard, FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
17
17
|
|
|
18
18
|
export default Capability.makeModule(() =>
|
|
19
19
|
Effect.succeed(
|
|
@@ -24,8 +24,8 @@ export default Capability.makeModule(() =>
|
|
|
24
24
|
//
|
|
25
25
|
|
|
26
26
|
Surface.create<{ subject: Person.Person }>({
|
|
27
|
-
id: '
|
|
28
|
-
position: '
|
|
27
|
+
id: 'schemaPopoverContact',
|
|
28
|
+
position: 'first',
|
|
29
29
|
filter: AppSurface.object(AppSurface.Card, Person.Person),
|
|
30
30
|
component: ({ data, role }) => {
|
|
31
31
|
return (
|
|
@@ -37,8 +37,8 @@ export default Capability.makeModule(() =>
|
|
|
37
37
|
},
|
|
38
38
|
}),
|
|
39
39
|
Surface.create({
|
|
40
|
-
id: '
|
|
41
|
-
position: '
|
|
40
|
+
id: 'schemaPopoverOrganization',
|
|
41
|
+
position: 'first',
|
|
42
42
|
filter: AppSurface.object(AppSurface.Card, Organization.Organization),
|
|
43
43
|
component: ({ data, role }) => {
|
|
44
44
|
return (
|
|
@@ -50,30 +50,71 @@ export default Capability.makeModule(() =>
|
|
|
50
50
|
},
|
|
51
51
|
}),
|
|
52
52
|
Surface.create({
|
|
53
|
-
id: '
|
|
54
|
-
position: '
|
|
53
|
+
id: 'schemaPopoverProject',
|
|
54
|
+
position: 'first',
|
|
55
55
|
filter: AppSurface.object(AppSurface.Card, Pipeline.Pipeline),
|
|
56
56
|
component: ({ data, role }) => {
|
|
57
57
|
return <ProjectCard role={role} subject={data.subject} />;
|
|
58
58
|
},
|
|
59
59
|
}),
|
|
60
60
|
Surface.create({
|
|
61
|
-
id: '
|
|
62
|
-
position: '
|
|
61
|
+
id: 'schemaPopoverTask',
|
|
62
|
+
position: 'first',
|
|
63
63
|
filter: AppSurface.object(AppSurface.Card, Task.Task),
|
|
64
64
|
component: ({ data, role }) => {
|
|
65
65
|
return <TaskCard role={role} subject={data.subject} />;
|
|
66
66
|
},
|
|
67
67
|
}),
|
|
68
|
+
Surface.create<AppSurface.ObjectCardData<Expando.Expando>>({
|
|
69
|
+
id: 'schemaPopoverExpando',
|
|
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
|
+
Surface.create({
|
|
77
|
+
id: 'schemaPopoverDynamicType',
|
|
78
|
+
role: 'card--content',
|
|
79
|
+
filter: (data): data is { subject: Obj.Unknown } => {
|
|
80
|
+
if (!Obj.isObject(data.subject)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const type = Obj.getType(data.subject);
|
|
84
|
+
if (type) {
|
|
85
|
+
return Type.getDatabase(type) != null;
|
|
86
|
+
}
|
|
87
|
+
// Obj.getType fails for database-registered schemas (DXN mismatch); fall back to typename query.
|
|
88
|
+
try {
|
|
89
|
+
const db = Obj.getDatabase(data.subject);
|
|
90
|
+
const typename = Obj.getTypename(data.subject);
|
|
91
|
+
return (
|
|
92
|
+
!!db &&
|
|
93
|
+
!!typename &&
|
|
94
|
+
db.graph.registry
|
|
95
|
+
.list()
|
|
96
|
+
.filter(Type.isType)
|
|
97
|
+
.some((t) => Type.getTypename(t) === typename)
|
|
98
|
+
);
|
|
99
|
+
} catch {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
component: ({ data, role }) => {
|
|
104
|
+
// Dynamic/mutable schemas render an editable, full-layout form;
|
|
105
|
+
// FormCard handles both static and runtime schema resolution internally.
|
|
106
|
+
return <FormCard role={role} subject={data.subject} readonly={false} layout='full' />;
|
|
107
|
+
},
|
|
108
|
+
}),
|
|
68
109
|
|
|
69
110
|
//
|
|
70
111
|
// Fallback for any object.
|
|
71
112
|
//
|
|
72
113
|
|
|
73
114
|
Surface.create({
|
|
74
|
-
id: '
|
|
115
|
+
id: 'fallbackPopover',
|
|
75
116
|
role: 'card--content',
|
|
76
|
-
position: '
|
|
117
|
+
position: 'last',
|
|
77
118
|
filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
|
|
78
119
|
component: ({ data, role }) => {
|
|
79
120
|
return <FormCard role={role} subject={data.subject} projection={data.projection} />;
|
|
@@ -81,9 +122,9 @@ export default Capability.makeModule(() =>
|
|
|
81
122
|
}),
|
|
82
123
|
|
|
83
124
|
Surface.create({
|
|
84
|
-
id: '
|
|
125
|
+
id: 'fallbackJson',
|
|
85
126
|
role: 'card--content',
|
|
86
|
-
position: '
|
|
127
|
+
position: 'last',
|
|
87
128
|
filter: (data): data is Record<string, unknown> => true,
|
|
88
129
|
component: ({ data }) => {
|
|
89
130
|
return <JsonCard data={data} />;
|
|
@@ -92,12 +133,12 @@ export default Capability.makeModule(() =>
|
|
|
92
133
|
|
|
93
134
|
Surface.create({
|
|
94
135
|
id: 'section',
|
|
95
|
-
position: '
|
|
136
|
+
position: 'last',
|
|
96
137
|
filter: AppSurface.subject(AppSurface.Section, Obj.isObject),
|
|
97
138
|
component: ({ data }) => {
|
|
98
139
|
return (
|
|
99
|
-
<div
|
|
100
|
-
<div
|
|
140
|
+
<div className='flex w-full justify-center'>
|
|
141
|
+
<div className='py-2 dx-card-min-width dx-card-max-width'>
|
|
101
142
|
<Card.Root>
|
|
102
143
|
<Surface.Surface type={AppSurface.Card} data={data} limit={1} />
|
|
103
144
|
</Card.Root>
|
|
@@ -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 { SchemaEx } 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 = SchemaEx.splitJsonPath(path as SchemaEx.JsonPath);
|
|
58
|
+
Obj.setValue(subject, parts, value);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
[subject],
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Card.Body>
|
|
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.Body>
|
|
75
|
+
);
|
|
76
|
+
};
|