@dxos/plugin-preview 0.8.4-main.4a85c3132b → 0.8.4-main.51f1e5ca51
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 +16 -31
- 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 +17 -31
- 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/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/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/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 +47 -39
- package/src/PreviewPlugin.tsx +3 -3
- package/src/capabilities/index.ts +4 -2
- package/src/capabilities/{preview-popover/preview-popover.ts → preview-popover.ts} +12 -6
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +45 -24
- package/src/cards/ExpandoCard.tsx +76 -0
- package/src/cards/FormCard.tsx +9 -8
- 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/meta.ts +1 -1
- package/src/stories/Card.stories.tsx +50 -5
- package/src/stories/testing.tsx +26 -16
- package/src/translations.ts +8 -8
- package/dist/lib/browser/chunk-XLN6KTHK.mjs +0 -17
- package/dist/lib/browser/chunk-XLN6KTHK.mjs.map +0 -7
- package/dist/lib/browser/preview-popover-5YUZCO2D.mjs +0 -82
- package/dist/lib/browser/preview-popover-5YUZCO2D.mjs.map +0 -7
- package/dist/lib/browser/react-surface-O25YV7AH.mjs +0 -233
- package/dist/lib/browser/react-surface-O25YV7AH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2G4FUGDA.mjs +0 -19
- package/dist/lib/node-esm/chunk-2G4FUGDA.mjs.map +0 -7
- package/dist/lib/node-esm/preview-popover-7QRYVL73.mjs +0 -84
- package/dist/lib/node-esm/preview-popover-7QRYVL73.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-YA3XXW7A.mjs +0 -234
- package/dist/lib/node-esm/react-surface-YA3XXW7A.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/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
|
@@ -3,24 +3,31 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React from 'react';
|
|
6
7
|
|
|
7
8
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
8
9
|
import { corePlugins } from '@dxos/plugin-testing';
|
|
9
|
-
import {
|
|
10
|
+
import { random } from '@dxos/random';
|
|
11
|
+
import { Card } from '@dxos/react-ui';
|
|
10
12
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
13
|
+
import { type Expando } from '@dxos/schema';
|
|
11
14
|
import { type Organization, type Person, type Pipeline, type Task } from '@dxos/types';
|
|
12
15
|
|
|
13
|
-
import {
|
|
14
|
-
import { translations } from '../translations';
|
|
16
|
+
import { translations } from '#translations';
|
|
15
17
|
|
|
16
|
-
import {
|
|
18
|
+
import { ExpandoCard, FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
19
|
+
import { DefaultStory, createExpando, createOrganization, createPerson, createProject, createTask } from './testing';
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
random.seed(999);
|
|
19
22
|
|
|
20
23
|
const meta = {
|
|
21
24
|
title: 'plugins/plugin-preview/cards/Card',
|
|
22
25
|
render: DefaultStory,
|
|
23
26
|
decorators: [
|
|
27
|
+
// `Card` and its descendants in `@dxos/react-ui` consume `ThemeContext`
|
|
28
|
+
// for tx-token resolution; without this the stories trip the surface's
|
|
29
|
+
// `ErrorBoundary` with "Missing ThemeContext" and the storybook test
|
|
30
|
+
// assert-no-error fails.
|
|
24
31
|
withTheme(),
|
|
25
32
|
withLayout({ layout: 'fullscreen' }),
|
|
26
33
|
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
@@ -74,3 +81,41 @@ export const _Task: StoryObj<typeof DefaultStory<Task.Task>> = {
|
|
|
74
81
|
image: true,
|
|
75
82
|
},
|
|
76
83
|
};
|
|
84
|
+
|
|
85
|
+
export const _Expando: StoryObj<typeof DefaultStory<Expando.Expando>> = {
|
|
86
|
+
args: {
|
|
87
|
+
Component: ExpandoCard,
|
|
88
|
+
createObject: createExpando,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const _Json = {
|
|
93
|
+
render: () => {
|
|
94
|
+
const data = {
|
|
95
|
+
subject: {
|
|
96
|
+
id: random.string.uuid(),
|
|
97
|
+
name: random.person.fullName(),
|
|
98
|
+
email: random.internet.email(),
|
|
99
|
+
tags: [random.lorem.word(), random.lorem.word(), random.lorem.word()],
|
|
100
|
+
nested: {
|
|
101
|
+
count: random.number.int({ max: 100 }),
|
|
102
|
+
active: random.datatype.boolean(),
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<div className='flex justify-center p-16'>
|
|
109
|
+
<div className='dx-card-min-width dx-card-max-width'>
|
|
110
|
+
<Card.Root>
|
|
111
|
+
<Card.Toolbar>
|
|
112
|
+
<Card.IconBlock />
|
|
113
|
+
<Card.Title>JSON</Card.Title>
|
|
114
|
+
</Card.Toolbar>
|
|
115
|
+
<JsonCard data={data} />
|
|
116
|
+
</Card.Root>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
};
|
package/src/stories/testing.tsx
CHANGED
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type FC, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { Obj, Ref } from '@dxos/echo';
|
|
9
|
-
import {
|
|
9
|
+
import { random } from '@dxos/random';
|
|
10
10
|
import { Card } from '@dxos/react-ui';
|
|
11
11
|
import { CardContainer, type CardContainerProps } from '@dxos/react-ui-mosaic/testing';
|
|
12
|
+
import { Expando } from '@dxos/schema';
|
|
12
13
|
import { Organization, Person, Pipeline, Task } from '@dxos/types';
|
|
13
14
|
|
|
14
15
|
export type DefaultStoryProps<T extends Obj.Any> = {
|
|
15
|
-
Component: FC<
|
|
16
|
+
Component: FC<AppSurface.ObjectCardProps<T>>;
|
|
16
17
|
createObject: () => T;
|
|
17
18
|
image?: boolean;
|
|
18
19
|
};
|
|
@@ -22,7 +23,7 @@ export const DefaultStory = <T extends Obj.Any>({ Component, createObject, image
|
|
|
22
23
|
const roles: CardContainerProps['role'][] = ['intrinsic', 'popover'];
|
|
23
24
|
|
|
24
25
|
return (
|
|
25
|
-
<div className='
|
|
26
|
+
<div className='h-full w-full grid grid-cols-2 py-16 gap-8'>
|
|
26
27
|
{roles.map((role, i) => (
|
|
27
28
|
<div key={i} className='flex h-full justify-center overflow-hidden'>
|
|
28
29
|
<div className='flex flex-col gap-4 w-full items-center'>
|
|
@@ -34,7 +35,7 @@ export const DefaultStory = <T extends Obj.Any>({ Component, createObject, image
|
|
|
34
35
|
<Card.Title>{Obj.getLabel(object)}</Card.Title>
|
|
35
36
|
<Card.Menu />
|
|
36
37
|
</Card.Toolbar>
|
|
37
|
-
<Component role={role} subject={image ? object : omitImage(object)} />
|
|
38
|
+
<Component role={role ?? 'card--content'} subject={image ? object : omitImage(object)} />
|
|
38
39
|
</Card.Root>
|
|
39
40
|
</CardContainer>
|
|
40
41
|
</div>
|
|
@@ -51,41 +52,50 @@ export const omitImage = ({ image: _, ...rest }: any) => rest;
|
|
|
51
52
|
*/
|
|
52
53
|
export const createOrganization = (): Organization.Organization => {
|
|
53
54
|
return Obj.make(Organization.Organization, {
|
|
54
|
-
name:
|
|
55
|
+
name: random.company.name(),
|
|
55
56
|
image:
|
|
56
57
|
'https://plus.unsplash.com/premium_photo-1672116452571-896980a801c8?q=80&w=2671&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
|
|
57
|
-
website:
|
|
58
|
-
description:
|
|
58
|
+
website: random.internet.url(),
|
|
59
|
+
description: random.lorem.paragraph(),
|
|
59
60
|
});
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
export const createPerson = (): Person.Person => {
|
|
63
64
|
const organization = createOrganization();
|
|
64
65
|
return Obj.make(Person.Person, {
|
|
65
|
-
fullName:
|
|
66
|
+
fullName: random.person.fullName(),
|
|
66
67
|
image:
|
|
67
68
|
'https://plus.unsplash.com/premium_photo-1664536392779-049ba8fde933?q=80&w=2574&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
|
|
68
69
|
organization: Ref.make(organization),
|
|
69
70
|
emails: [
|
|
70
|
-
{ label: 'Work', value:
|
|
71
|
-
{ label: 'Work', value:
|
|
72
|
-
{ label: 'Work', value:
|
|
71
|
+
{ label: 'Work', value: random.internet.email() },
|
|
72
|
+
{ label: 'Work', value: random.internet.email() },
|
|
73
|
+
{ label: 'Work', value: random.internet.email() },
|
|
73
74
|
],
|
|
74
75
|
});
|
|
75
76
|
};
|
|
76
77
|
|
|
77
78
|
export const createProject = (): Pipeline.Pipeline => {
|
|
78
79
|
return Obj.make(Pipeline.Pipeline, {
|
|
79
|
-
name:
|
|
80
|
+
name: random.person.fullName(),
|
|
80
81
|
image: 'https://dxos.network/dxos-logotype-blue.png',
|
|
81
|
-
description:
|
|
82
|
+
description: random.lorem.paragraph(),
|
|
82
83
|
columns: [],
|
|
83
84
|
});
|
|
84
85
|
};
|
|
85
86
|
|
|
86
87
|
export const createTask = (): Task.Task => {
|
|
87
88
|
return Obj.make(Task.Task, {
|
|
88
|
-
title:
|
|
89
|
-
status:
|
|
89
|
+
title: random.lorem.sentence(),
|
|
90
|
+
status: random.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const createExpando = (): Expando.Expando => {
|
|
95
|
+
return Expando.make({
|
|
96
|
+
name: random.person.fullName(),
|
|
97
|
+
email: random.internet.email(),
|
|
98
|
+
age: random.number.int({ min: 18, max: 80 }),
|
|
99
|
+
active: random.datatype.boolean(),
|
|
90
100
|
});
|
|
91
101
|
};
|
package/src/translations.ts
CHANGED
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
import { meta } from '
|
|
7
|
+
import { meta } from '#meta';
|
|
8
8
|
|
|
9
9
|
export const translations = [
|
|
10
10
|
{
|
|
11
11
|
'en-US': {
|
|
12
12
|
[meta.id]: {
|
|
13
|
-
'unable
|
|
14
|
-
'todo
|
|
15
|
-
'in-progress
|
|
16
|
-
'done
|
|
17
|
-
'open
|
|
18
|
-
'add
|
|
19
|
-
'more
|
|
13
|
+
'unable-to-create-preview.message': 'No preview',
|
|
14
|
+
'todo.label': 'To do',
|
|
15
|
+
'in-progress.label': 'In progress',
|
|
16
|
+
'done.label': 'Done',
|
|
17
|
+
'open-object.label': 'Open',
|
|
18
|
+
'add-object-to-space.label': 'Add to space',
|
|
19
|
+
'more-options.label': 'More options',
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
22
|
},
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
|
-
import { trim } from "@dxos/util";
|
|
3
|
-
var meta = {
|
|
4
|
-
id: "dxos.org/plugin/preview",
|
|
5
|
-
name: "Preview",
|
|
6
|
-
description: trim`
|
|
7
|
-
Rich preview panel for viewing object content without opening full editors.
|
|
8
|
-
Quick peek at documents, images, and data with inline rendering.
|
|
9
|
-
`,
|
|
10
|
-
icon: "ph--eye--regular",
|
|
11
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview"
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
meta
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=chunk-XLN6KTHK.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'dxos.org/plugin/preview',\n name: 'Preview',\n description: trim`\n Rich preview panel for viewing object content without opening full editors.\n Quick peek at documents, images, and data with inline rendering.\n `,\n icon: 'ph--eye--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',\n};\n"],
|
|
5
|
-
"mappings": ";AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,QAAQ;AACV;",
|
|
6
|
-
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "source"]
|
|
7
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// src/capabilities/preview-popover/preview-popover.ts
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
4
|
-
import { AppCapabilities, LayoutOperation } from "@dxos/app-toolkit";
|
|
5
|
-
import { addEventListener } from "@dxos/async";
|
|
6
|
-
import { parseId } from "@dxos/client/echo";
|
|
7
|
-
import { Obj } from "@dxos/echo";
|
|
8
|
-
import { DXN } from "@dxos/keys";
|
|
9
|
-
import { log } from "@dxos/log";
|
|
10
|
-
import { ClientCapabilities } from "@dxos/plugin-client";
|
|
11
|
-
import { DX_ANCHOR_ACTIVATE } from "@dxos/react-ui";
|
|
12
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-preview/src/capabilities/preview-popover/preview-popover.ts";
|
|
13
|
-
var customEventOptions = {
|
|
14
|
-
capture: true,
|
|
15
|
-
passive: false
|
|
16
|
-
};
|
|
17
|
-
var handlePreviewLookup = async (client, defaultSpace, { dxn, label }) => {
|
|
18
|
-
try {
|
|
19
|
-
const object = await defaultSpace.db.makeRef(DXN.parse(dxn)).load();
|
|
20
|
-
return {
|
|
21
|
-
label,
|
|
22
|
-
object
|
|
23
|
-
};
|
|
24
|
-
} catch {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var preview_popover_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
29
|
-
const capabilities = yield* Capability.Service;
|
|
30
|
-
const handleAnchorActivate = async ({ dxn, label, trigger, kind = "card", title: titleProp, side, props }) => {
|
|
31
|
-
const { invokePromise } = capabilities.get(Capabilities.OperationInvoker);
|
|
32
|
-
const client = capabilities.get(ClientCapabilities.Client);
|
|
33
|
-
const registry = capabilities.get(Capabilities.AtomRegistry);
|
|
34
|
-
const [layoutAtom] = capabilities.getAll(AppCapabilities.Layout);
|
|
35
|
-
const layout = registry.get(layoutAtom);
|
|
36
|
-
const { spaceId } = parseId(layout.workspace);
|
|
37
|
-
const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
|
|
38
|
-
const result = await handlePreviewLookup(client, space, {
|
|
39
|
-
dxn,
|
|
40
|
-
label
|
|
41
|
-
});
|
|
42
|
-
if (!result) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const title = titleProp ?? Obj.getLabel(result.object);
|
|
46
|
-
await invokePromise(LayoutOperation.UpdatePopover, {
|
|
47
|
-
subjectRef: dxn,
|
|
48
|
-
subject: result.object,
|
|
49
|
-
state: true,
|
|
50
|
-
variant: "virtual",
|
|
51
|
-
anchor: trigger,
|
|
52
|
-
...kind && {
|
|
53
|
-
kind
|
|
54
|
-
},
|
|
55
|
-
...title && {
|
|
56
|
-
title
|
|
57
|
-
},
|
|
58
|
-
...side && {
|
|
59
|
-
side
|
|
60
|
-
},
|
|
61
|
-
...props && {
|
|
62
|
-
props
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
let cleanup;
|
|
67
|
-
if (document.defaultView) {
|
|
68
|
-
cleanup = addEventListener(document.defaultView, DX_ANCHOR_ACTIVATE, handleAnchorActivate, customEventOptions);
|
|
69
|
-
} else {
|
|
70
|
-
log.warn("no default view found", void 0, {
|
|
71
|
-
F: __dxlog_file,
|
|
72
|
-
L: 85,
|
|
73
|
-
S: this,
|
|
74
|
-
C: (f, a) => f(...a)
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => cleanup?.()));
|
|
78
|
-
}));
|
|
79
|
-
export {
|
|
80
|
-
preview_popover_default as default
|
|
81
|
-
};
|
|
82
|
-
//# sourceMappingURL=preview-popover-5YUZCO2D.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/preview-popover/preview-popover.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';\nimport { addEventListener } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space, parseId } from '@dxos/client/echo';\nimport { Obj } from '@dxos/echo';\nimport { DXN } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';\nimport { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/ui-editor';\n\nconst customEventOptions = { capture: true, passive: false };\n\nconst handlePreviewLookup = async (\n client: Client,\n defaultSpace: Space,\n { dxn, label }: PreviewLinkRef,\n): Promise<PreviewLinkTarget | null> => {\n try {\n const object = await defaultSpace.db.makeRef(DXN.parse(dxn)).load();\n return { label, object };\n } catch {\n return null;\n }\n};\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n // Get context for lazy capability access in callbacks.\n const capabilities = yield* Capability.Service;\n\n // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.\n const handleAnchorActivate = async ({\n dxn,\n label,\n trigger,\n kind = 'card',\n title: titleProp,\n side,\n props,\n }: DxAnchorActivate) => {\n const { invokePromise } = capabilities.get(Capabilities.OperationInvoker);\n const client = capabilities.get(ClientCapabilities.Client);\n const registry = capabilities.get(Capabilities.AtomRegistry);\n const [layoutAtom] = capabilities.getAll(AppCapabilities.Layout);\n const layout = registry.get(layoutAtom);\n const { spaceId } = parseId(layout.workspace);\n const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;\n const result = await handlePreviewLookup(client, space, { dxn, label });\n if (!result) {\n return;\n }\n\n const title = titleProp ?? Obj.getLabel(result.object);\n\n await invokePromise(LayoutOperation.UpdatePopover, {\n subjectRef: dxn,\n subject: result.object,\n state: true,\n variant: 'virtual',\n anchor: trigger,\n ...(kind && { kind }),\n ...(title && { title }),\n ...(side && { side }),\n ...(props && { props }),\n });\n };\n\n let cleanup: () => void;\n if (document.defaultView) {\n cleanup = addEventListener(\n document.defaultView,\n DX_ANCHOR_ACTIVATE as any,\n handleAnchorActivate,\n customEventOptions,\n );\n } else {\n log.warn('no default view found');\n }\n\n return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => cleanup?.()));\n }),\n);\n"],
|
|
5
|
-
"mappings": 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nB,QAAQC,aAAa1B,IAAI6C,SAASD,OAAO/B,MAAM;AAErD,UAAMgB,cAAchC,gBAAgBiD,eAAe;MACjDC,YAAYpC;MACZqC,SAASJ,OAAO/B;MAChBoC,OAAO;MACPC,SAAS;MACTC,QAAQ5B;MACR,GAAIC,QAAQ;QAAEA;MAAK;MACnB,GAAIC,SAAS;QAAEA;MAAM;MACrB,GAAIE,QAAQ;QAAEA;MAAK;MACnB,GAAIC,SAAS;QAAEA;MAAM;IACvB,CAAA;EACF;AAEA,MAAIwB;AACJ,MAAIC,SAASC,aAAa;AACxBF,cAAUtD,iBACRuD,SAASC,aACTlD,oBACAkB,sBACAjB,kBAAAA;EAEJ,OAAO;AACLH,QAAIqD,KAAK,yBAAA,QAAA;;;;;;EACX;AAEA,SAAO5D,WAAW6D,YAAY9D,aAAa+D,MAAM,MAAM,MAAaC,YAAK,MAAMN,UAAAA,CAAAA,CAAAA;AACjF,CAAA,CAAA;",
|
|
6
|
-
"names": ["Effect", "Capabilities", "Capability", "AppCapabilities", "LayoutOperation", "addEventListener", "parseId", "Obj", "DXN", "log", "ClientCapabilities", "DX_ANCHOR_ACTIVATE", "customEventOptions", "capture", "passive", "handlePreviewLookup", "client", "defaultSpace", "dxn", "label", "object", "db", "makeRef", "parse", "load", "makeModule", "fnUntraced", "capabilities", "Service", "handleAnchorActivate", "trigger", "kind", "title", "titleProp", "side", "props", "invokePromise", "get", "OperationInvoker", "Client", "registry", "AtomRegistry", "layoutAtom", "getAll", "Layout", "layout", "spaceId", "workspace", "space", "spaces", "default", "result", "getLabel", "UpdatePopover", "subjectRef", "subject", "state", "variant", "anchor", "cleanup", "document", "defaultView", "warn", "contributes", "Null", "sync"]
|
|
7
|
-
}
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
meta
|
|
3
|
-
} from "./chunk-XLN6KTHK.mjs";
|
|
4
|
-
|
|
5
|
-
// src/capabilities/react-surface/react-surface.tsx
|
|
6
|
-
import * as Effect from "effect/Effect";
|
|
7
|
-
import React6 from "react";
|
|
8
|
-
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
9
|
-
import { Surface } from "@dxos/app-framework/ui";
|
|
10
|
-
import { Obj as Obj3 } from "@dxos/echo";
|
|
11
|
-
import { Card as Card6 } from "@dxos/react-ui";
|
|
12
|
-
import { Organization, Person, Pipeline, Task as Task2 } from "@dxos/types";
|
|
13
|
-
|
|
14
|
-
// src/cards/FormCard.tsx
|
|
15
|
-
import React, { useCallback } from "react";
|
|
16
|
-
import { Obj } from "@dxos/echo";
|
|
17
|
-
import { splitJsonPath } from "@dxos/effect";
|
|
18
|
-
import { Card, useTranslation } from "@dxos/react-ui";
|
|
19
|
-
import { Form, omitId } from "@dxos/react-ui-form";
|
|
20
|
-
import { descriptionMessage, mx } from "@dxos/ui-theme";
|
|
21
|
-
var FormCard = ({ subject, projection }) => {
|
|
22
|
-
const { t } = useTranslation(meta.id);
|
|
23
|
-
const schema = Obj.getSchema(subject);
|
|
24
|
-
const handleSave = useCallback((values, { changed }) => {
|
|
25
|
-
const paths = Object.keys(changed).filter((path) => changed[path]);
|
|
26
|
-
Obj.change(subject, () => {
|
|
27
|
-
for (const path of paths) {
|
|
28
|
-
const value = values[path];
|
|
29
|
-
const parts = splitJsonPath(path);
|
|
30
|
-
Obj.setValue(subject, parts, value);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}, []);
|
|
34
|
-
if (!schema) {
|
|
35
|
-
return /* @__PURE__ */ React.createElement("p", {
|
|
36
|
-
className: mx(descriptionMessage)
|
|
37
|
-
}, t("unable to create preview message"));
|
|
38
|
-
}
|
|
39
|
-
return /* @__PURE__ */ React.createElement(Card.Content, null, /* @__PURE__ */ React.createElement(Form.Root, {
|
|
40
|
-
schema: omitId(schema),
|
|
41
|
-
projection,
|
|
42
|
-
values: subject,
|
|
43
|
-
autoSave: true,
|
|
44
|
-
onSave: handleSave
|
|
45
|
-
}, /* @__PURE__ */ React.createElement(Form.Viewport, null, /* @__PURE__ */ React.createElement(Form.Content, null, /* @__PURE__ */ React.createElement(Form.FieldSet, null)))));
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// src/cards/OrganizationCard.tsx
|
|
49
|
-
import React2 from "react";
|
|
50
|
-
import { Card as Card2 } from "@dxos/react-ui";
|
|
51
|
-
var OrganizationCard = ({ subject }) => {
|
|
52
|
-
const { image, description, website } = subject;
|
|
53
|
-
return /* @__PURE__ */ React2.createElement(Card2.Content, null, /* @__PURE__ */ React2.createElement(Card2.Poster, {
|
|
54
|
-
alt: name ?? "",
|
|
55
|
-
...image ? {
|
|
56
|
-
image
|
|
57
|
-
} : {
|
|
58
|
-
icon: "ph--building-office--regular"
|
|
59
|
-
},
|
|
60
|
-
classNames: !image && "opacity-50"
|
|
61
|
-
}), description && /* @__PURE__ */ React2.createElement(Card2.Row, null, /* @__PURE__ */ React2.createElement(Card2.Text, {
|
|
62
|
-
variant: "description"
|
|
63
|
-
}, description)), website && /* @__PURE__ */ React2.createElement(Card2.Link, {
|
|
64
|
-
label: website,
|
|
65
|
-
href: website
|
|
66
|
-
}));
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// src/cards/PersonCard.tsx
|
|
70
|
-
import React3 from "react";
|
|
71
|
-
import { Avatar } from "@dxos/react-ui";
|
|
72
|
-
import { Card as Card3 } from "@dxos/react-ui";
|
|
73
|
-
var PersonCard = ({ subject }) => {
|
|
74
|
-
const { image, organization: { target: organization } = {}, emails = [] } = subject;
|
|
75
|
-
return /* @__PURE__ */ React3.createElement(Card3.Content, null, /* @__PURE__ */ React3.createElement(Avatar.Root, null, image && /* @__PURE__ */ React3.createElement(Card3.Row, {
|
|
76
|
-
className: "py-1"
|
|
77
|
-
}, /* @__PURE__ */ React3.createElement(Avatar.Content, {
|
|
78
|
-
imgSrc: image,
|
|
79
|
-
icon: "ph--user--regular",
|
|
80
|
-
size: 16,
|
|
81
|
-
classNames: !image && "opacity-50",
|
|
82
|
-
hue: "neutral",
|
|
83
|
-
variant: "square"
|
|
84
|
-
})), organization?.name && /* @__PURE__ */ React3.createElement(Card3.Action, {
|
|
85
|
-
icon: "ph--buildings--regular",
|
|
86
|
-
label: organization.name
|
|
87
|
-
}), emails.map(({ value }) => /* @__PURE__ */ React3.createElement(Card3.Row, {
|
|
88
|
-
key: value,
|
|
89
|
-
icon: "ph--at--regular"
|
|
90
|
-
}, /* @__PURE__ */ React3.createElement(Card3.Text, {
|
|
91
|
-
truncate: true,
|
|
92
|
-
className: "text-primary-text"
|
|
93
|
-
}, value)))));
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// src/cards/ProjectCard.tsx
|
|
97
|
-
import React4 from "react";
|
|
98
|
-
import { Obj as Obj2 } from "@dxos/echo";
|
|
99
|
-
import { Card as Card4 } from "@dxos/react-ui";
|
|
100
|
-
var ProjectCard = ({ subject }) => {
|
|
101
|
-
const { image, description } = subject;
|
|
102
|
-
return /* @__PURE__ */ React4.createElement(Card4.Content, null, image && /* @__PURE__ */ React4.createElement(Card4.Poster, {
|
|
103
|
-
image,
|
|
104
|
-
alt: Obj2.getLabel(subject) ?? "",
|
|
105
|
-
aspect: "auto"
|
|
106
|
-
}), description && /* @__PURE__ */ React4.createElement(Card4.Text, {
|
|
107
|
-
variant: "description"
|
|
108
|
-
}, description));
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// src/cards/TaskCard.tsx
|
|
112
|
-
import * as SchemaAST from "effect/SchemaAST";
|
|
113
|
-
import React5 from "react";
|
|
114
|
-
import { PropertyMetaAnnotationId } from "@dxos/echo/internal";
|
|
115
|
-
import { Card as Card5 } from "@dxos/react-ui";
|
|
116
|
-
import { Task } from "@dxos/types";
|
|
117
|
-
var TaskCard = ({ subject }) => {
|
|
118
|
-
const { title, status } = subject;
|
|
119
|
-
const statusOption = getActiveStatusOption(status);
|
|
120
|
-
return /* @__PURE__ */ React5.createElement(Card5.Content, null, /* @__PURE__ */ React5.createElement(Card5.Heading, {
|
|
121
|
-
classNames: "min-w-0 flex-1 truncate"
|
|
122
|
-
}, title), statusOption && /* @__PURE__ */ React5.createElement("span", {
|
|
123
|
-
className: "dx-tag",
|
|
124
|
-
"data-hue": statusOption.color
|
|
125
|
-
}, statusOption.title));
|
|
126
|
-
};
|
|
127
|
-
var getActiveStatusOption = (status) => {
|
|
128
|
-
const properties = SchemaAST.getPropertySignatures(Task.Task.ast);
|
|
129
|
-
const statusProperty = properties.find((p) => p.name === "status");
|
|
130
|
-
const statusMeta = SchemaAST.getAnnotation(PropertyMetaAnnotationId)(
|
|
131
|
-
// TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
|
|
132
|
-
statusProperty.type.types[0]
|
|
133
|
-
);
|
|
134
|
-
const options = statusMeta.value.singleSelect.options;
|
|
135
|
-
return options.find(({ id }) => id === status);
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
// src/capabilities/react-surface/react-surface.tsx
|
|
139
|
-
var react_surface_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(Capabilities.ReactSurface, [
|
|
140
|
-
//
|
|
141
|
-
// Specific schema types.
|
|
142
|
-
// TODO(burdon): Create helpers and factor out.
|
|
143
|
-
//
|
|
144
|
-
Surface.create({
|
|
145
|
-
id: `${meta.id}/schema-popover--contact`,
|
|
146
|
-
role: "card--content",
|
|
147
|
-
position: "hoist",
|
|
148
|
-
filter: (data) => Obj3.instanceOf(Person.Person, data.subject),
|
|
149
|
-
component: ({ data, role }) => {
|
|
150
|
-
return /* @__PURE__ */ React6.createElement(PersonCard, {
|
|
151
|
-
role,
|
|
152
|
-
subject: data.subject
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
}),
|
|
156
|
-
Surface.create({
|
|
157
|
-
id: `${meta.id}/schema-popover--organization`,
|
|
158
|
-
role: "card--content",
|
|
159
|
-
position: "hoist",
|
|
160
|
-
filter: (data) => Obj3.instanceOf(Organization.Organization, data.subject),
|
|
161
|
-
component: ({ data, role }) => {
|
|
162
|
-
return /* @__PURE__ */ React6.createElement(OrganizationCard, {
|
|
163
|
-
role,
|
|
164
|
-
subject: data.subject
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}),
|
|
168
|
-
Surface.create({
|
|
169
|
-
id: `${meta.id}/schema-popover--project`,
|
|
170
|
-
role: "card--content",
|
|
171
|
-
position: "hoist",
|
|
172
|
-
filter: (data) => Obj3.instanceOf(Pipeline.Pipeline, data.subject),
|
|
173
|
-
component: ({ data, role }) => {
|
|
174
|
-
return /* @__PURE__ */ React6.createElement(ProjectCard, {
|
|
175
|
-
role,
|
|
176
|
-
subject: data.subject
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
}),
|
|
180
|
-
Surface.create({
|
|
181
|
-
id: `${meta.id}/schema-popover--task`,
|
|
182
|
-
role: "card--content",
|
|
183
|
-
position: "hoist",
|
|
184
|
-
filter: (data) => Obj3.instanceOf(Task2.Task, data.subject),
|
|
185
|
-
component: ({ data, role }) => {
|
|
186
|
-
return /* @__PURE__ */ React6.createElement(TaskCard, {
|
|
187
|
-
role,
|
|
188
|
-
subject: data.subject
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}),
|
|
192
|
-
//
|
|
193
|
-
// Fallback for any object.
|
|
194
|
-
//
|
|
195
|
-
Surface.create({
|
|
196
|
-
id: `${meta.id}/fallback-popover`,
|
|
197
|
-
role: "card--content",
|
|
198
|
-
position: "fallback",
|
|
199
|
-
filter: (data) => Obj3.isObject(data.subject),
|
|
200
|
-
component: ({ data, role }) => {
|
|
201
|
-
return /* @__PURE__ */ React6.createElement(FormCard, {
|
|
202
|
-
role,
|
|
203
|
-
subject: data.subject,
|
|
204
|
-
projection: data.projection
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
}),
|
|
208
|
-
Surface.create({
|
|
209
|
-
id: `${meta.id}/section`,
|
|
210
|
-
role: [
|
|
211
|
-
"section"
|
|
212
|
-
],
|
|
213
|
-
position: "fallback",
|
|
214
|
-
filter: (data) => Obj3.isObject(data.subject),
|
|
215
|
-
component: ({ data }) => {
|
|
216
|
-
return /* @__PURE__ */ React6.createElement("div", {
|
|
217
|
-
role: "none",
|
|
218
|
-
className: "flex w-full justify-center"
|
|
219
|
-
}, /* @__PURE__ */ React6.createElement("div", {
|
|
220
|
-
role: "none",
|
|
221
|
-
className: "pt-2 pb-2 dx-card-min-width dx-card-max-width"
|
|
222
|
-
}, /* @__PURE__ */ React6.createElement(Card6.Root, null, /* @__PURE__ */ React6.createElement(Surface.Surface, {
|
|
223
|
-
role: "card--content",
|
|
224
|
-
data,
|
|
225
|
-
limit: 1
|
|
226
|
-
}))));
|
|
227
|
-
}
|
|
228
|
-
})
|
|
229
|
-
])));
|
|
230
|
-
export {
|
|
231
|
-
react_surface_default as default
|
|
232
|
-
};
|
|
233
|
-
//# sourceMappingURL=react-surface-O25YV7AH.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface/react-surface.tsx", "../../../src/cards/FormCard.tsx", "../../../src/cards/OrganizationCard.tsx", "../../../src/cards/PersonCard.tsx", "../../../src/cards/ProjectCard.tsx", "../../../src/cards/TaskCard.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport React from 'react';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { Surface } from '@dxos/app-framework/ui';\nimport { Obj } from '@dxos/echo';\nimport { Card } from '@dxos/react-ui';\nimport { type ProjectionModel } from '@dxos/schema';\nimport { Organization, Person, Pipeline, Task } from '@dxos/types';\n\nimport { FormCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../../cards';\nimport { meta } from '../../meta';\n\nexport default Capability.makeModule(() =>\n Effect.succeed(\n Capability.contributes(Capabilities.ReactSurface, [\n //\n // Specific schema types.\n // TODO(burdon): Create helpers and factor out.\n //\n\n Surface.create<{ subject: Person.Person }>({\n id: `${meta.id}/schema-popover--contact`,\n role: 'card--content',\n position: 'hoist',\n filter: (data): data is { subject: Person.Person } => Obj.instanceOf(Person.Person, data.subject),\n component: ({ data, role }) => {\n return <PersonCard role={role} subject={data.subject} />;\n },\n }),\n Surface.create({\n id: `${meta.id}/schema-popover--organization`,\n role: 'card--content',\n position: 'hoist',\n filter: (data): data is { subject: Organization.Organization } =>\n Obj.instanceOf(Organization.Organization, data.subject),\n component: ({ data, role }) => {\n return <OrganizationCard role={role} subject={data.subject} />;\n },\n }),\n Surface.create({\n id: `${meta.id}/schema-popover--project`,\n role: 'card--content',\n position: 'hoist',\n filter: (data): data is { subject: Pipeline.Pipeline } => Obj.instanceOf(Pipeline.Pipeline, data.subject),\n component: ({ data, role }) => {\n return <ProjectCard role={role} subject={data.subject} />;\n },\n }),\n Surface.create({\n id: `${meta.id}/schema-popover--task`,\n role: 'card--content',\n position: 'hoist',\n filter: (data): data is { subject: Task.Task } => Obj.instanceOf(Task.Task, data.subject),\n component: ({ data, role }) => {\n return <TaskCard role={role} subject={data.subject} />;\n },\n }),\n\n //\n // Fallback for any object.\n //\n\n Surface.create({\n id: `${meta.id}/fallback-popover`,\n role: 'card--content',\n position: 'fallback',\n filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),\n component: ({ data, role }) => {\n return <FormCard role={role} subject={data.subject} projection={data.projection} />;\n },\n }),\n\n Surface.create({\n id: `${meta.id}/section`,\n role: ['section'],\n position: 'fallback',\n filter: (data): data is { subject: Obj.Unknown } => Obj.isObject(data.subject),\n component: ({ data }) => {\n return (\n <div role='none' className='flex w-full justify-center'>\n <div role='none' className='pt-2 pb-2 dx-card-min-width dx-card-max-width'>\n <Card.Root>\n <Surface.Surface role='card--content' data={data} limit={1} />\n </Card.Root>\n </div>\n </div>\n );\n },\n }),\n ]),\n ),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';\nimport { Obj } from '@dxos/echo';\nimport { type JsonPath, splitJsonPath } from '@dxos/effect';\nimport { Card, useTranslation } from '@dxos/react-ui';\nimport { Form, omitId } from '@dxos/react-ui-form';\nimport { type ProjectionModel } from '@dxos/schema';\nimport { descriptionMessage, mx } from '@dxos/ui-theme';\n\nimport { meta } from '../meta';\n\nexport const FormCard = ({ subject, projection }: SurfaceComponentProps & { projection?: ProjectionModel }) => {\n const { t } = useTranslation(meta.id);\n const schema = Obj.getSchema(subject);\n\n const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {\n const paths = Object.keys(changed).filter((path) => changed[path]);\n Obj.change(subject, () => {\n for (const path of paths) {\n const value = values[path];\n const parts = splitJsonPath(path as JsonPath);\n Obj.setValue(subject, parts, value);\n }\n });\n }, []);\n\n if (!schema) {\n return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;\n }\n\n return (\n <Card.Content>\n <Form.Root schema={omitId(schema)} projection={projection} values={subject} autoSave onSave={handleSave}>\n <Form.Viewport>\n <Form.Content>\n <Form.FieldSet />\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n </Card.Content>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';\nimport { Card } from '@dxos/react-ui';\nimport { type Organization } from '@dxos/types';\n\nexport const OrganizationCard = ({ subject }: SurfaceComponentProps<Organization.Organization>) => {\n const { image, description, website } = subject;\n\n return (\n <Card.Content>\n <Card.Poster\n alt={name ?? ''}\n {...(image ? { image } : { icon: 'ph--building-office--regular' })}\n classNames={!image && 'opacity-50'}\n />\n {description && (\n <Card.Row>\n <Card.Text variant='description'>{description}</Card.Text>\n </Card.Row>\n )}\n {website && <Card.Link label={website} href={website} />}\n </Card.Content>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';\nimport { Avatar } from '@dxos/react-ui';\nimport { Card } from '@dxos/react-ui';\nimport { type Person } from '@dxos/types';\n\nexport const PersonCard = ({ subject }: SurfaceComponentProps<Person.Person>) => {\n const { image, organization: { target: organization } = {}, emails = [] } = subject;\n\n return (\n <Card.Content>\n <Avatar.Root>\n {image && (\n <Card.Row className='py-1'>\n <Avatar.Content\n imgSrc={image}\n icon='ph--user--regular'\n size={16}\n classNames={!image && 'opacity-50'}\n hue='neutral'\n variant='square'\n />\n </Card.Row>\n )}\n {organization?.name && (\n <Card.Action\n icon='ph--buildings--regular'\n label={organization.name}\n // onClick={onSelect ? () => onSelect(organization) : undefined}\n />\n )}\n {emails.map(({ value }) => (\n <Card.Row key={value} icon='ph--at--regular'>\n <Card.Text truncate className='text-primary-text'>\n {value}\n </Card.Text>\n </Card.Row>\n ))}\n </Avatar.Root>\n </Card.Content>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';\nimport { Obj } from '@dxos/echo';\nimport { Card } from '@dxos/react-ui';\nimport { type Pipeline } from '@dxos/types';\n\nexport const ProjectCard = ({ subject }: SurfaceComponentProps<Pipeline.Pipeline>) => {\n const { image, description } = subject;\n\n return (\n <Card.Content>\n {image && <Card.Poster image={image} alt={Obj.getLabel(subject) ?? ''} aspect='auto' />}\n {/* <CardHeader label={name} subject={subject} db={db} /> */}\n {description && <Card.Text variant='description'>{description}</Card.Text>}\n </Card.Content>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as SchemaAST from 'effect/SchemaAST';\nimport React from 'react';\n\nimport { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';\nimport { type PropertyMetaAnnotation, PropertyMetaAnnotationId } from '@dxos/echo/internal';\nimport { Card } from '@dxos/react-ui';\nimport { Task } from '@dxos/types';\n\nexport const TaskCard = ({ subject }: SurfaceComponentProps<Task.Task>) => {\n const { title, status } = subject;\n const statusOption = getActiveStatusOption(status);\n\n return (\n <Card.Content>\n <Card.Heading classNames='min-w-0 flex-1 truncate'>{title}</Card.Heading>\n {statusOption && (\n <span className='dx-tag' data-hue={statusOption.color}>\n {statusOption.title}\n </span>\n )}\n </Card.Content>\n );\n};\n\n// TODO(thure): Should this move upstream as a helper? Is there an easier way to get options?\nconst getActiveStatusOption = (status?: string) => {\n const properties = SchemaAST.getPropertySignatures(Task.Task.ast);\n const statusProperty = properties.find((p) => p.name === 'status');\n const statusMeta = SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(\n // TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.\n (statusProperty!.type as any).types[0],\n );\n const options = // TODO(thure): Typescript asserts `statusMeta` doesn’t have `.value`, but in runtime it does.\n (statusMeta as any).value.singleSelect.options as { id: string; title: string; color: string }[];\n return options.find(({ id }) => id === status);\n};\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,YAAYA,YAAY;AACxB,OAAOC,YAAW;AAElB,SAASC,cAAcC,kBAAkB;AACzC,SAASC,eAAe;AACxB,SAASC,OAAAA,YAAW;AACpB,SAASC,QAAAA,aAAY;AAErB,SAASC,cAAcC,QAAQC,UAAUC,QAAAA,aAAY;;;ACRrD,OAAOC,SAASC,mBAAmB;AAGnC,SAASC,WAAW;AACpB,SAAwBC,qBAAqB;AAC7C,SAASC,MAAMC,sBAAsB;AACrC,SAASC,MAAMC,cAAc;AAE7B,SAASC,oBAAoBC,UAAU;AAIhC,IAAMC,WAAW,CAAC,EAAEC,SAASC,WAAU,MAA4D;AACxG,QAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,QAAMC,SAASC,IAAIC,UAAUR,OAAAA;AAE7B,QAAMS,aAAaC,YAAY,CAACC,QAAa,EAAEC,QAAO,MAAwC;AAC5F,UAAMC,QAAQC,OAAOC,KAAKH,OAAAA,EAASI,OAAO,CAACC,SAASL,QAAQK,IAAAA,CAAK;AACjE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zB,gBAAAZ,OAAA,cAACW,OAAAA;QAAIpB,MAAK;QAAOqB,WAAU;SACzB,gBAAAZ,OAAA,cAACa,MAAKC,MAAI,MACR,gBAAAd,OAAA,cAACb,QAAQA,SAAO;QAACI,MAAK;QAAgBG;QAAYqB,OAAO;;IAKnE;EACF,CAAA;CACD,CAAA,CAAA;",
|
|
6
|
-
"names": ["Effect", "React", "Capabilities", "Capability", "Surface", "Obj", "Card", "Organization", "Person", "Pipeline", "Task", "React", "useCallback", "Obj", "splitJsonPath", "Card", "useTranslation", "Form", "omitId", "descriptionMessage", "mx", "FormCard", "subject", "projection", "t", "useTranslation", "meta", "id", "schema", "Obj", "getSchema", "handleSave", "useCallback", "values", "changed", "paths", "Object", "keys", "filter", "path", "change", "value", "parts", "splitJsonPath", "setValue", "p", "className", "mx", "descriptionMessage", "Card", "Content", "Form", "Root", "omitId", "autoSave", "onSave", "Viewport", "FieldSet", "React", "Card", "OrganizationCard", "subject", "image", "description", "website", "React", "Card", "Content", "Poster", "alt", "name", "icon", "classNames", "Row", "Text", "variant", "Link", "label", "href", "React", "Avatar", "Card", "PersonCard", "subject", "image", "organization", "target", "emails", "React", "Card", "Content", "Avatar", "Root", "Row", "className", "imgSrc", "icon", "size", "classNames", "hue", "variant", "name", "Action", "label", "map", "value", "key", "Text", "truncate", "React", "Obj", "Card", "ProjectCard", "subject", "image", "description", "React", "Card", "Content", "Poster", "alt", "Obj", "getLabel", "aspect", "Text", "variant", "SchemaAST", "React", "PropertyMetaAnnotationId", "Card", "Task", "TaskCard", "subject", "title", "status", "statusOption", "getActiveStatusOption", "React", "Card", "Content", "Heading", "classNames", "span", "className", "data-hue", "color", "properties", "getPropertySignatures", "Task", "ast", "statusProperty", "find", "p", "name", "statusMeta", "getAnnotation", "PropertyMetaAnnotationId", "type", "types", "options", "value", "singleSelect", "id", "Capability", "makeModule", "succeed", "contributes", "Capabilities", "ReactSurface", "Surface", "create", "id", "meta", "role", "position", "filter", "data", "Obj", "instanceOf", "Person", "subject", "component", "React", "PersonCard", "Organization", "OrganizationCard", "Pipeline", "ProjectCard", "Task", "TaskCard", "isObject", "FormCard", "projection", "div", "className", "Card", "Root", "limit"]
|
|
7
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/meta.ts
|
|
4
|
-
import { trim } from "@dxos/util";
|
|
5
|
-
var meta = {
|
|
6
|
-
id: "dxos.org/plugin/preview",
|
|
7
|
-
name: "Preview",
|
|
8
|
-
description: trim`
|
|
9
|
-
Rich preview panel for viewing object content without opening full editors.
|
|
10
|
-
Quick peek at documents, images, and data with inline rendering.
|
|
11
|
-
`,
|
|
12
|
-
icon: "ph--eye--regular",
|
|
13
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview"
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
meta
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=chunk-2G4FUGDA.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'dxos.org/plugin/preview',\n name: 'Preview',\n description: trim`\n Rich preview panel for viewing object content without opening full editors.\n Quick peek at documents, images, and data with inline rendering.\n `,\n icon: 'ph--eye--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',\n};\n"],
|
|
5
|
-
"mappings": ";;;AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,QAAQ;AACV;",
|
|
6
|
-
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "source"]
|
|
7
|
-
}
|