@dxos/plugin-preview 0.8.4-main.9735255 → 0.8.4-main.9be5663bfe
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 +30 -25
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +31 -25
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +3 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/preview-popover.d.ts +5 -0
- package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.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 +3 -3
- package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
- package/dist/types/src/cards/TaskCard.d.ts +2 -2
- package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
- package/dist/types/src/cards/index.d.ts +1 -0
- package/dist/types/src/cards/index.d.ts.map +1 -1
- package/dist/types/src/stories/Card.stories.d.ts +16 -11
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +4 -4
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -8
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +41 -36
- package/src/PreviewPlugin.tsx +9 -7
- package/src/capabilities/index.ts +4 -2
- package/src/capabilities/{preview-popover/preview-popover.ts → preview-popover.ts} +31 -15
- package/src/capabilities/react-surface.tsx +116 -0
- package/src/cards/FormCard.tsx +13 -28
- package/src/cards/JsonCard.tsx +16 -0
- package/src/cards/OrganizationCard.tsx +4 -4
- package/src/cards/PersonCard.tsx +34 -16
- package/src/cards/ProjectCard.tsx +5 -5
- package/src/cards/TaskCard.tsx +16 -12
- package/src/cards/index.ts +1 -0
- package/src/meta.ts +1 -1
- package/src/stories/Card.stories.tsx +50 -11
- package/src/stories/testing.tsx +38 -31
- 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-Y67LE6TV.mjs +0 -78
- package/dist/lib/browser/preview-popover-Y67LE6TV.mjs.map +0 -7
- package/dist/lib/browser/react-surface-YCDD5VZC.mjs +0 -263
- package/dist/lib/browser/react-surface-YCDD5VZC.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-BGV2P6UX.mjs +0 -80
- package/dist/lib/node-esm/preview-popover-BGV2P6UX.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-MYZZR7AQ.mjs +0 -264
- package/dist/lib/node-esm/react-surface-MYZZR7AQ.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 +0 -5
- 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 +0 -5
- 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
|
@@ -3,38 +3,46 @@
|
|
|
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 {
|
|
11
|
-
import {
|
|
10
|
+
import { random } from '@dxos/random';
|
|
11
|
+
import { Card } from '@dxos/react-ui';
|
|
12
|
+
import { withLayout } from '@dxos/react-ui/testing';
|
|
13
|
+
import { type Organization, type Person, type Pipeline, type Task } from '@dxos/types';
|
|
12
14
|
|
|
13
|
-
import { OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
15
|
+
import { FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
14
16
|
import { translations } from '../translations';
|
|
15
|
-
|
|
16
17
|
import { DefaultStory, createOrganization, createPerson, createProject, createTask } from './testing';
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
random.seed(999);
|
|
19
20
|
|
|
20
21
|
const meta = {
|
|
21
|
-
title: 'plugins/plugin-preview/Card',
|
|
22
|
+
title: 'plugins/plugin-preview/cards/Card',
|
|
22
23
|
render: DefaultStory,
|
|
23
24
|
decorators: [
|
|
24
|
-
|
|
25
|
-
withLayout({ layout: 'column', scroll: true }),
|
|
25
|
+
withLayout({ layout: 'fullscreen' }),
|
|
26
26
|
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
27
27
|
withPluginManager({ plugins: corePlugins() }),
|
|
28
28
|
],
|
|
29
29
|
parameters: {
|
|
30
|
-
translations,
|
|
31
30
|
layout: 'fullscreen',
|
|
31
|
+
translations,
|
|
32
32
|
},
|
|
33
33
|
tags: ['cards'],
|
|
34
34
|
} satisfies Meta<typeof DefaultStory>;
|
|
35
35
|
|
|
36
36
|
export default meta;
|
|
37
37
|
|
|
38
|
+
export const _Form: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
39
|
+
args: {
|
|
40
|
+
Component: FormCard,
|
|
41
|
+
createObject: createPerson,
|
|
42
|
+
image: true,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
38
46
|
export const _Person: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
39
47
|
args: {
|
|
40
48
|
Component: PersonCard,
|
|
@@ -51,7 +59,7 @@ export const _Organization: StoryObj<typeof DefaultStory<Organization.Organizati
|
|
|
51
59
|
},
|
|
52
60
|
};
|
|
53
61
|
|
|
54
|
-
export const _Project: StoryObj<typeof DefaultStory<
|
|
62
|
+
export const _Project: StoryObj<typeof DefaultStory<Pipeline.Pipeline>> = {
|
|
55
63
|
args: {
|
|
56
64
|
Component: ProjectCard,
|
|
57
65
|
createObject: createProject,
|
|
@@ -66,3 +74,34 @@ export const _Task: StoryObj<typeof DefaultStory<Task.Task>> = {
|
|
|
66
74
|
image: true,
|
|
67
75
|
},
|
|
68
76
|
};
|
|
77
|
+
|
|
78
|
+
export const _Json = {
|
|
79
|
+
render: () => {
|
|
80
|
+
const data = {
|
|
81
|
+
subject: {
|
|
82
|
+
id: random.string.uuid(),
|
|
83
|
+
name: random.person.fullName(),
|
|
84
|
+
email: random.internet.email(),
|
|
85
|
+
tags: [random.lorem.word(), random.lorem.word(), random.lorem.word()],
|
|
86
|
+
nested: {
|
|
87
|
+
count: random.number.int({ max: 100 }),
|
|
88
|
+
active: random.datatype.boolean(),
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div className='flex justify-center p-16'>
|
|
95
|
+
<div className='dx-card-min-width dx-card-max-width'>
|
|
96
|
+
<Card.Root>
|
|
97
|
+
<Card.Toolbar>
|
|
98
|
+
<Card.IconBlock />
|
|
99
|
+
<Card.Title>JSON</Card.Title>
|
|
100
|
+
</Card.Toolbar>
|
|
101
|
+
<JsonCard data={data} />
|
|
102
|
+
</Card.Root>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
};
|
package/src/stories/testing.tsx
CHANGED
|
@@ -4,33 +4,37 @@
|
|
|
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 {
|
|
10
|
-
import { Card } from '@dxos/react-ui
|
|
11
|
-
import { CardContainer } from '@dxos/react-ui-mosaic/testing';
|
|
12
|
-
import { Organization, Person,
|
|
9
|
+
import { random } from '@dxos/random';
|
|
10
|
+
import { Card } from '@dxos/react-ui';
|
|
11
|
+
import { CardContainer, type CardContainerProps } from '@dxos/react-ui-mosaic/testing';
|
|
12
|
+
import { Organization, Person, Pipeline, Task } from '@dxos/types';
|
|
13
13
|
|
|
14
14
|
export type DefaultStoryProps<T extends Obj.Any> = {
|
|
15
|
-
Component: FC<
|
|
15
|
+
Component: FC<AppSurface.ObjectCardProps<T>>;
|
|
16
16
|
createObject: () => T;
|
|
17
17
|
image?: boolean;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export const DefaultStory = <T extends Obj.Any>({ Component, createObject, image }: DefaultStoryProps<T>) => {
|
|
21
|
-
// TODO(wittjosiah): ECHO objects don't work when passed via Storybook args.
|
|
22
21
|
const object = useMemo(() => createObject(), [createObject]);
|
|
23
|
-
const roles:
|
|
22
|
+
const roles: CardContainerProps['role'][] = ['intrinsic', 'popover'];
|
|
24
23
|
|
|
25
24
|
return (
|
|
26
|
-
<div className='grid grid-
|
|
25
|
+
<div className='h-full w-full grid grid-cols-2 py-16 gap-8'>
|
|
27
26
|
{roles.map((role, i) => (
|
|
28
|
-
<div key={i} className='flex justify-center'>
|
|
29
|
-
<div className='flex flex-col gap-4
|
|
30
|
-
<
|
|
27
|
+
<div key={i} className='flex h-full justify-center overflow-hidden'>
|
|
28
|
+
<div className='flex flex-col gap-4 w-full items-center'>
|
|
29
|
+
<span className='text-sm text-description'>{role}</span>
|
|
31
30
|
<CardContainer role={role}>
|
|
32
|
-
<Card.Root>
|
|
33
|
-
<
|
|
31
|
+
<Card.Root border={false}>
|
|
32
|
+
<Card.Toolbar>
|
|
33
|
+
<Card.DragHandle />
|
|
34
|
+
<Card.Title>{Obj.getLabel(object)}</Card.Title>
|
|
35
|
+
<Card.Menu />
|
|
36
|
+
</Card.Toolbar>
|
|
37
|
+
<Component role={role ?? 'card--content'} subject={image ? object : omitImage(object)} />
|
|
34
38
|
</Card.Root>
|
|
35
39
|
</CardContainer>
|
|
36
40
|
</div>
|
|
@@ -45,40 +49,43 @@ export const omitImage = ({ image: _, ...rest }: any) => rest;
|
|
|
45
49
|
/**
|
|
46
50
|
* Factory functions for creating test objects at render time.
|
|
47
51
|
*/
|
|
48
|
-
export const createOrganization = (): Organization.Organization =>
|
|
49
|
-
Obj.make(Organization.Organization, {
|
|
50
|
-
name:
|
|
52
|
+
export const createOrganization = (): Organization.Organization => {
|
|
53
|
+
return Obj.make(Organization.Organization, {
|
|
54
|
+
name: random.company.name(),
|
|
51
55
|
image:
|
|
52
56
|
'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',
|
|
53
|
-
website:
|
|
54
|
-
description:
|
|
57
|
+
website: random.internet.url(),
|
|
58
|
+
description: random.lorem.paragraph(),
|
|
55
59
|
});
|
|
60
|
+
};
|
|
56
61
|
|
|
57
62
|
export const createPerson = (): Person.Person => {
|
|
58
63
|
const organization = createOrganization();
|
|
59
64
|
return Obj.make(Person.Person, {
|
|
60
|
-
fullName:
|
|
65
|
+
fullName: random.person.fullName(),
|
|
61
66
|
image:
|
|
62
67
|
'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',
|
|
63
68
|
organization: Ref.make(organization),
|
|
64
69
|
emails: [
|
|
65
|
-
{ label: 'Work', value:
|
|
66
|
-
{ label: 'Work', value:
|
|
67
|
-
{ label: 'Work', value:
|
|
70
|
+
{ label: 'Work', value: random.internet.email() },
|
|
71
|
+
{ label: 'Work', value: random.internet.email() },
|
|
72
|
+
{ label: 'Work', value: random.internet.email() },
|
|
68
73
|
],
|
|
69
74
|
});
|
|
70
75
|
};
|
|
71
76
|
|
|
72
|
-
export const createProject = ():
|
|
73
|
-
Obj.make(
|
|
74
|
-
name:
|
|
77
|
+
export const createProject = (): Pipeline.Pipeline => {
|
|
78
|
+
return Obj.make(Pipeline.Pipeline, {
|
|
79
|
+
name: random.person.fullName(),
|
|
75
80
|
image: 'https://dxos.network/dxos-logotype-blue.png',
|
|
76
|
-
description:
|
|
81
|
+
description: random.lorem.paragraph(),
|
|
77
82
|
columns: [],
|
|
78
83
|
});
|
|
84
|
+
};
|
|
79
85
|
|
|
80
|
-
export const createTask = (): Task.Task =>
|
|
81
|
-
Obj.make(Task.Task, {
|
|
82
|
-
title:
|
|
83
|
-
status:
|
|
86
|
+
export const createTask = (): Task.Task => {
|
|
87
|
+
return Obj.make(Task.Task, {
|
|
88
|
+
title: random.lorem.sentence(),
|
|
89
|
+
status: random.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
|
|
84
90
|
});
|
|
91
|
+
};
|
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,78 +0,0 @@
|
|
|
1
|
-
// src/capabilities/preview-popover/preview-popover.ts
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import { Capability, Common } from "@dxos/app-framework";
|
|
4
|
-
import { addEventListener } from "@dxos/async";
|
|
5
|
-
import { parseId } from "@dxos/client/echo";
|
|
6
|
-
import { DXN } from "@dxos/keys";
|
|
7
|
-
import { log } from "@dxos/log";
|
|
8
|
-
import { ClientCapabilities } from "@dxos/plugin-client";
|
|
9
|
-
import { DX_ANCHOR_ACTIVATE } from "@dxos/react-ui";
|
|
10
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-preview/src/capabilities/preview-popover/preview-popover.ts";
|
|
11
|
-
var customEventOptions = {
|
|
12
|
-
capture: true,
|
|
13
|
-
passive: false
|
|
14
|
-
};
|
|
15
|
-
var handlePreviewLookup = async (client, defaultSpace, { ref, label }) => {
|
|
16
|
-
try {
|
|
17
|
-
const object = await defaultSpace.db.makeRef(DXN.parse(ref)).load();
|
|
18
|
-
return {
|
|
19
|
-
label,
|
|
20
|
-
object
|
|
21
|
-
};
|
|
22
|
-
} catch {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var preview_popover_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
27
|
-
const capabilities = yield* Capability.Service;
|
|
28
|
-
const handleAnchorActivate = async ({ refId, label, trigger, kind, title, side, props }) => {
|
|
29
|
-
const { invokePromise } = capabilities.get(Common.Capability.OperationInvoker);
|
|
30
|
-
const client = capabilities.get(ClientCapabilities.Client);
|
|
31
|
-
const registry = capabilities.get(Common.Capability.AtomRegistry);
|
|
32
|
-
const [layoutAtom] = capabilities.getAll(Common.Capability.Layout);
|
|
33
|
-
const layout = registry.get(layoutAtom);
|
|
34
|
-
const { spaceId } = parseId(layout.workspace);
|
|
35
|
-
const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
|
|
36
|
-
const result = await handlePreviewLookup(client, space, {
|
|
37
|
-
ref: refId,
|
|
38
|
-
label
|
|
39
|
-
});
|
|
40
|
-
if (!result) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
await invokePromise(Common.LayoutOperation.UpdatePopover, {
|
|
44
|
-
subject: result.object,
|
|
45
|
-
state: true,
|
|
46
|
-
variant: "virtual",
|
|
47
|
-
anchor: trigger,
|
|
48
|
-
...kind && {
|
|
49
|
-
kind
|
|
50
|
-
},
|
|
51
|
-
...title && {
|
|
52
|
-
title
|
|
53
|
-
},
|
|
54
|
-
...side && {
|
|
55
|
-
side
|
|
56
|
-
},
|
|
57
|
-
...props && {
|
|
58
|
-
props
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
let cleanup;
|
|
63
|
-
if (document.defaultView) {
|
|
64
|
-
cleanup = addEventListener(document.defaultView, DX_ANCHOR_ACTIVATE, handleAnchorActivate, customEventOptions);
|
|
65
|
-
} else {
|
|
66
|
-
log.warn("No default view found", void 0, {
|
|
67
|
-
F: __dxlog_file,
|
|
68
|
-
L: 72,
|
|
69
|
-
S: this,
|
|
70
|
-
C: (f, a) => f(...a)
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return Capability.contributes(Common.Capability.Null, null, () => Effect.sync(() => cleanup?.()));
|
|
74
|
-
}));
|
|
75
|
-
export {
|
|
76
|
-
preview_popover_default as default
|
|
77
|
-
};
|
|
78
|
-
//# sourceMappingURL=preview-popover-Y67LE6TV.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 { Capability, Common } from '@dxos/app-framework';\nimport { addEventListener } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space, parseId } from '@dxos/client/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 { ref, label }: PreviewLinkRef,\n): Promise<PreviewLinkTarget | null> => {\n try {\n const object = await defaultSpace.db.makeRef(DXN.parse(ref)).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 ({ refId, label, trigger, kind, title, side, props }: DxAnchorActivate) => {\n const { invokePromise } = capabilities.get(Common.Capability.OperationInvoker);\n const client = capabilities.get(ClientCapabilities.Client);\n const registry = capabilities.get(Common.Capability.AtomRegistry);\n const [layoutAtom] = capabilities.getAll(Common.Capability.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, { ref: refId, label });\n if (!result) {\n return;\n }\n\n await invokePromise(Common.LayoutOperation.UpdatePopover, {\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(Common.Capability.Null, null, () => Effect.sync(() => cleanup?.()));\n }),\n);\n"],
|
|
5
|
-
"mappings": ";AAIA,YAAYA,YAAY;AAExB,SAASC,YAAYC,cAAc;AACnC,SAASC,wBAAwB;AAEjC,SAAqBC,eAAe;AACpC,SAASC,WAAW;AACpB,SAASC,WAAW;AACpB,SAASC,0BAA0B;AACnC,SAASC,0BAAiD;;AAG1D,IAAMC,qBAAqB;EAAEC,SAAS;EAAMC,SAAS;AAAM;AAE3D,IAAMC,sBAAsB,OAC1BC,QACAC,cACA,EAAEC,KAAKC,MAAK,MAAkB;AAE9B,MAAI;AACF,UAAMC,SAAS,MAAMH,aAAaI,GAAGC,QAAQd,IAAIe,MAAML,GAAAA,CAAAA,EAAMM,KAAI;AACjE,WAAO;MAAEL;MAAOC;IAAO;EACzB,QAAQ;AACN,WAAO;EACT;AACF;AAEA,IAAA,0BAAehB,WAAWqB,WACjBC,kBAAW,aAAA;AAEhB,QAAMC,eAAe,OAAOvB,WAAWwB;AAGvC,QAAMC,uBAAuB,OAAO,EAAEC,OAAOX,OAAOY,SAASC,MAAMC,OAAOC,MAAMC,MAAK,MAAoB;AACvG,UAAM,EAAEC,cAAa,IAAKT,aAAaU,IAAIhC,OAAOD,WAAWkC,gBAAgB;AAC7E,UAAMtB,SAASW,aAAaU,IAAI3B,mBAAmB6B,MAAM;AACzD,UAAMC,WAAWb,aAAaU,IAAIhC,OAAOD,WAAWqC,YAAY;AAChE,UAAM,CAACC,UAAAA,IAAcf,aAAagB,OAAOtC,OAAOD,WAAWwC,MAAM;AACjE,UAAMC,SAASL,SAASH,IAAIK,UAAAA;AAC5B,UAAM,EAAEI,QAAO,IAAKvC,QAAQsC,OAAOE,SAAS;AAC5C,UAAMC,SAASF,WAAW9B,OAAOiC,OAAOZ,IAAIS,OAAAA,MAAa9B,OAAOiC,OAAOC;AACvE,UAAMC,SAAS,MAAMpC,oBAAoBC,QAAQgC,OAAO;MAAE9B,KAAKY;MAAOX;IAAM,CAAA;AAC5E,QAAI,CAACgC,QAAQ;AACX;IACF;AAEA,UAAMf,cAAc/B,OAAO+C,gBAAgBC,eAAe;MACxDC,SAASH,OAAO/B;MAChBmC,OAAO;MACPC,SAAS;MACTC,QAAQ1B;MACR,GAAIC,QAAQ;QAAEA;MAAK;MACnB,GAAIC,SAAS;QAAEA;MAAM;MACrB,GAAIC,QAAQ;QAAEA;MAAK;MACnB,GAAIC,SAAS;QAAEA;MAAM;IACvB,CAAA;EACF;AAEA,MAAIuB;AACJ,MAAIC,SAASC,aAAa;AACxBF,cAAUpD,iBACRqD,SAASC,aACTjD,oBACAkB,sBACAjB,kBAAAA;EAEJ,OAAO;AACLH,QAAIoD,KAAK,yBAAA,QAAA;;;;;;EACX;AAEA,SAAOzD,WAAW0D,YAAYzD,OAAOD,WAAW2D,MAAM,MAAM,MAAaC,YAAK,MAAMN,UAAAA,CAAAA,CAAAA;AACtF,CAAA,CAAA;",
|
|
6
|
-
"names": ["Effect", "Capability", "Common", "addEventListener", "parseId", "DXN", "log", "ClientCapabilities", "DX_ANCHOR_ACTIVATE", "customEventOptions", "capture", "passive", "handlePreviewLookup", "client", "defaultSpace", "ref", "label", "object", "db", "makeRef", "parse", "load", "makeModule", "fnUntraced", "capabilities", "Service", "handleAnchorActivate", "refId", "trigger", "kind", "title", "side", "props", "invokePromise", "get", "OperationInvoker", "Client", "registry", "AtomRegistry", "layoutAtom", "getAll", "Layout", "layout", "spaceId", "workspace", "space", "spaces", "default", "result", "LayoutOperation", "UpdatePopover", "subject", "state", "variant", "anchor", "cleanup", "document", "defaultView", "warn", "contributes", "Null", "sync"]
|
|
7
|
-
}
|
|
@@ -1,263 +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 { Capability, Common as Common2 } from "@dxos/app-framework";
|
|
9
|
-
import { Surface } from "@dxos/app-framework/react";
|
|
10
|
-
import { Obj as Obj3 } from "@dxos/echo";
|
|
11
|
-
import { Card as Card6 } from "@dxos/react-ui-mosaic";
|
|
12
|
-
import { Organization, Person, Project, Task as Task2 } from "@dxos/types";
|
|
13
|
-
|
|
14
|
-
// src/cards/FormCard.tsx
|
|
15
|
-
import React, { useCallback } from "react";
|
|
16
|
-
import { Common } from "@dxos/app-framework";
|
|
17
|
-
import { useOperationInvoker } from "@dxos/app-framework/react";
|
|
18
|
-
import { Obj } from "@dxos/echo";
|
|
19
|
-
import { splitJsonPath } from "@dxos/effect";
|
|
20
|
-
import { IconButton, useTranslation } from "@dxos/react-ui";
|
|
21
|
-
import { Form, omitId } from "@dxos/react-ui-form";
|
|
22
|
-
import { Card } from "@dxos/react-ui-mosaic";
|
|
23
|
-
import { descriptionMessage, mx } from "@dxos/ui-theme";
|
|
24
|
-
var FormCard = ({ subject, projection }) => {
|
|
25
|
-
const { invokePromise } = useOperationInvoker();
|
|
26
|
-
const schema = Obj.getSchema(subject);
|
|
27
|
-
const { t } = useTranslation(meta.id);
|
|
28
|
-
const handleNavigate = useCallback(async () => {
|
|
29
|
-
await invokePromise(Common.LayoutOperation.UpdatePopover, {
|
|
30
|
-
state: false,
|
|
31
|
-
anchorId: ""
|
|
32
|
-
});
|
|
33
|
-
await invokePromise(Common.LayoutOperation.Open, {
|
|
34
|
-
subject: [
|
|
35
|
-
Obj.getDXN(subject).toString()
|
|
36
|
-
]
|
|
37
|
-
});
|
|
38
|
-
}, [
|
|
39
|
-
invokePromise,
|
|
40
|
-
subject
|
|
41
|
-
]);
|
|
42
|
-
if (!schema) {
|
|
43
|
-
return /* @__PURE__ */ React.createElement("p", {
|
|
44
|
-
className: mx(descriptionMessage)
|
|
45
|
-
}, t("unable to create preview message"));
|
|
46
|
-
}
|
|
47
|
-
const handleSave = useCallback((values, { changed }) => {
|
|
48
|
-
const paths = Object.keys(changed).filter((path) => changed[path]);
|
|
49
|
-
Obj.change(subject, () => {
|
|
50
|
-
for (const path of paths) {
|
|
51
|
-
const value = values[path];
|
|
52
|
-
const parts = splitJsonPath(path);
|
|
53
|
-
Obj.setValue(subject, parts, value);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}, []);
|
|
57
|
-
const label = Obj.getLabel(subject) ?? Obj.getTypename(subject) ?? t("unable to create preview message");
|
|
58
|
-
return /* @__PURE__ */ React.createElement(Card.Root, {
|
|
59
|
-
id: subject.id
|
|
60
|
-
}, /* @__PURE__ */ React.createElement(Card.Heading, {
|
|
61
|
-
classNames: "flex items-center"
|
|
62
|
-
}, label, /* @__PURE__ */ React.createElement("span", {
|
|
63
|
-
className: "grow"
|
|
64
|
-
}), /* @__PURE__ */ React.createElement(IconButton, {
|
|
65
|
-
iconOnly: true,
|
|
66
|
-
icon: "ph--arrow-right--regular",
|
|
67
|
-
label: t("open object label"),
|
|
68
|
-
onClick: handleNavigate
|
|
69
|
-
})), /* @__PURE__ */ React.createElement(Form.Root, {
|
|
70
|
-
schema: omitId(schema),
|
|
71
|
-
projection,
|
|
72
|
-
values: subject,
|
|
73
|
-
autoSave: true,
|
|
74
|
-
onSave: handleSave
|
|
75
|
-
}, /* @__PURE__ */ React.createElement(Form.Viewport, null, /* @__PURE__ */ React.createElement(Form.Content, null, /* @__PURE__ */ React.createElement(Form.FieldSet, null)))));
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// src/cards/OrganizationCard.tsx
|
|
79
|
-
import React2 from "react";
|
|
80
|
-
import { Card as Card2 } from "@dxos/react-ui-mosaic";
|
|
81
|
-
var OrganizationCard = ({ subject }) => {
|
|
82
|
-
const { image, description, website } = subject;
|
|
83
|
-
return /* @__PURE__ */ React2.createElement(Card2.Content, null, /* @__PURE__ */ React2.createElement(Card2.Poster, {
|
|
84
|
-
alt: name ?? "",
|
|
85
|
-
...image ? {
|
|
86
|
-
image
|
|
87
|
-
} : {
|
|
88
|
-
icon: "ph--building-office--regular"
|
|
89
|
-
},
|
|
90
|
-
classNames: !image && "opacity-50"
|
|
91
|
-
}), description && /* @__PURE__ */ React2.createElement(Card2.Row, null, /* @__PURE__ */ React2.createElement(Card2.Text, {
|
|
92
|
-
variant: "description"
|
|
93
|
-
}, description)), website && /* @__PURE__ */ React2.createElement(Card2.Link, {
|
|
94
|
-
label: website,
|
|
95
|
-
href: website
|
|
96
|
-
}));
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// src/cards/PersonCard.tsx
|
|
100
|
-
import React3 from "react";
|
|
101
|
-
import { Avatar } from "@dxos/react-ui";
|
|
102
|
-
import { Card as Card3 } from "@dxos/react-ui-mosaic";
|
|
103
|
-
var PersonCard = ({ subject }) => {
|
|
104
|
-
const { image, organization: { target: organization } = {}, emails = [] } = subject;
|
|
105
|
-
return /* @__PURE__ */ React3.createElement(Avatar.Root, null, /* @__PURE__ */ React3.createElement(Card3.Content, null, image && /* @__PURE__ */ React3.createElement(Card3.Row, {
|
|
106
|
-
className: "plb-1"
|
|
107
|
-
}, /* @__PURE__ */ React3.createElement(Avatar.Content, {
|
|
108
|
-
imgSrc: image,
|
|
109
|
-
icon: "ph--user--regular",
|
|
110
|
-
size: 16,
|
|
111
|
-
classNames: !image && "opacity-50",
|
|
112
|
-
hue: "neutral",
|
|
113
|
-
variant: "square"
|
|
114
|
-
})), organization?.name && /* @__PURE__ */ React3.createElement(Card3.Action, {
|
|
115
|
-
icon: "ph--buildings--regular",
|
|
116
|
-
label: organization.name
|
|
117
|
-
}), emails.map(({ value }) => /* @__PURE__ */ React3.createElement(Card3.Row, {
|
|
118
|
-
key: value,
|
|
119
|
-
icon: "ph--at--regular"
|
|
120
|
-
}, /* @__PURE__ */ React3.createElement(Card3.Text, {
|
|
121
|
-
truncate: true,
|
|
122
|
-
className: "text-primaryText"
|
|
123
|
-
}, value)))));
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// src/cards/ProjectCard.tsx
|
|
127
|
-
import React4 from "react";
|
|
128
|
-
import { Obj as Obj2 } from "@dxos/echo";
|
|
129
|
-
import { Card as Card4 } from "@dxos/react-ui-mosaic";
|
|
130
|
-
var ProjectCard = ({ subject }) => {
|
|
131
|
-
const { name: name2, image, description } = subject;
|
|
132
|
-
return /* @__PURE__ */ React4.createElement(Card4.Content, null, image && /* @__PURE__ */ React4.createElement(Card4.Poster, {
|
|
133
|
-
image,
|
|
134
|
-
alt: Obj2.getLabel(subject) ?? "",
|
|
135
|
-
aspect: "auto"
|
|
136
|
-
}), description && /* @__PURE__ */ React4.createElement(Card4.Text, {
|
|
137
|
-
variant: "description"
|
|
138
|
-
}, description));
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// src/cards/TaskCard.tsx
|
|
142
|
-
import * as SchemaAST from "effect/SchemaAST";
|
|
143
|
-
import React5 from "react";
|
|
144
|
-
import { PropertyMetaAnnotationId } from "@dxos/echo/internal";
|
|
145
|
-
import { Card as Card5 } from "@dxos/react-ui-mosaic";
|
|
146
|
-
import { Task } from "@dxos/types";
|
|
147
|
-
var TaskCard = ({ subject }) => {
|
|
148
|
-
const { title, status } = subject;
|
|
149
|
-
const statusOption = getActiveStatusOption(status);
|
|
150
|
-
return /* @__PURE__ */ React5.createElement(Card5.Content, null, /* @__PURE__ */ React5.createElement(Card5.Heading, {
|
|
151
|
-
classNames: "min-is-0 flex-1 truncate"
|
|
152
|
-
}, title), statusOption && /* @__PURE__ */ React5.createElement("span", {
|
|
153
|
-
className: "dx-tag",
|
|
154
|
-
"data-hue": statusOption.color
|
|
155
|
-
}, statusOption.title));
|
|
156
|
-
};
|
|
157
|
-
var getActiveStatusOption = (status) => {
|
|
158
|
-
const properties = SchemaAST.getPropertySignatures(Task.Task.ast);
|
|
159
|
-
const statusProperty = properties.find((p) => p.name === "status");
|
|
160
|
-
const statusMeta = SchemaAST.getAnnotation(PropertyMetaAnnotationId)(
|
|
161
|
-
// TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
|
|
162
|
-
statusProperty.type.types[0]
|
|
163
|
-
);
|
|
164
|
-
const options = statusMeta.value.singleSelect.options;
|
|
165
|
-
return options.find(({ id }) => id === status);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
// src/capabilities/react-surface/react-surface.tsx
|
|
169
|
-
var react_surface_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(Common2.Capability.ReactSurface, [
|
|
170
|
-
//
|
|
171
|
-
// Specific schema types.
|
|
172
|
-
// TODO(burdon): Create helpers and factor out.
|
|
173
|
-
//
|
|
174
|
-
Common2.createSurface({
|
|
175
|
-
id: `${meta.id}/schema-popover--contact`,
|
|
176
|
-
role: "card--content",
|
|
177
|
-
position: "hoist",
|
|
178
|
-
filter: (data) => Obj3.instanceOf(Person.Person, data.subject),
|
|
179
|
-
component: ({ data, role }) => {
|
|
180
|
-
return /* @__PURE__ */ React6.createElement(PersonCard, {
|
|
181
|
-
role,
|
|
182
|
-
subject: data.subject
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}),
|
|
186
|
-
Common2.createSurface({
|
|
187
|
-
id: `${meta.id}/schema-popover--organization`,
|
|
188
|
-
role: "card--content",
|
|
189
|
-
position: "hoist",
|
|
190
|
-
filter: (data) => Obj3.instanceOf(Organization.Organization, data.subject),
|
|
191
|
-
component: ({ data, role }) => {
|
|
192
|
-
return /* @__PURE__ */ React6.createElement(OrganizationCard, {
|
|
193
|
-
role,
|
|
194
|
-
subject: data.subject
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}),
|
|
198
|
-
Common2.createSurface({
|
|
199
|
-
id: `${meta.id}/schema-popover--project`,
|
|
200
|
-
role: "card--content",
|
|
201
|
-
position: "hoist",
|
|
202
|
-
filter: (data) => Obj3.instanceOf(Project.Project, data.subject),
|
|
203
|
-
component: ({ data, role }) => {
|
|
204
|
-
return /* @__PURE__ */ React6.createElement(ProjectCard, {
|
|
205
|
-
role,
|
|
206
|
-
subject: data.subject
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
}),
|
|
210
|
-
Common2.createSurface({
|
|
211
|
-
id: `${meta.id}/schema-popover--task`,
|
|
212
|
-
role: "card--content",
|
|
213
|
-
position: "hoist",
|
|
214
|
-
filter: (data) => Obj3.instanceOf(Task2.Task, data.subject),
|
|
215
|
-
component: ({ data, role }) => {
|
|
216
|
-
return /* @__PURE__ */ React6.createElement(TaskCard, {
|
|
217
|
-
role,
|
|
218
|
-
subject: data.subject
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
}),
|
|
222
|
-
//
|
|
223
|
-
// Fallback for any object.
|
|
224
|
-
//
|
|
225
|
-
Common2.createSurface({
|
|
226
|
-
id: `${meta.id}/fallback-popover`,
|
|
227
|
-
role: "card--content",
|
|
228
|
-
position: "fallback",
|
|
229
|
-
filter: (data) => Obj3.isObject(data.subject),
|
|
230
|
-
component: ({ data, role }) => {
|
|
231
|
-
return /* @__PURE__ */ React6.createElement(FormCard, {
|
|
232
|
-
role,
|
|
233
|
-
subject: data.subject,
|
|
234
|
-
projection: data.projection
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
}),
|
|
238
|
-
Common2.createSurface({
|
|
239
|
-
id: `${meta.id}/section`,
|
|
240
|
-
role: [
|
|
241
|
-
"section"
|
|
242
|
-
],
|
|
243
|
-
position: "fallback",
|
|
244
|
-
filter: (data) => Obj3.isObject(data.subject),
|
|
245
|
-
component: ({ data }) => {
|
|
246
|
-
return /* @__PURE__ */ React6.createElement("div", {
|
|
247
|
-
role: "none",
|
|
248
|
-
className: "flex is-full justify-center"
|
|
249
|
-
}, /* @__PURE__ */ React6.createElement("div", {
|
|
250
|
-
role: "none",
|
|
251
|
-
className: "pbs-2 pbe-2 card-min-width card-max-width"
|
|
252
|
-
}, /* @__PURE__ */ React6.createElement(Card6.Root, null, /* @__PURE__ */ React6.createElement(Surface, {
|
|
253
|
-
role: "card--content",
|
|
254
|
-
data,
|
|
255
|
-
limit: 1
|
|
256
|
-
}))));
|
|
257
|
-
}
|
|
258
|
-
})
|
|
259
|
-
])));
|
|
260
|
-
export {
|
|
261
|
-
react_surface_default as default
|
|
262
|
-
};
|
|
263
|
-
//# sourceMappingURL=react-surface-YCDD5VZC.mjs.map
|