@dxos/plugin-preview 0.8.4-main.406dc2a → 0.8.4-main.4a85c3132b
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/chunk-XLN6KTHK.mjs +17 -0
- package/dist/lib/browser/chunk-XLN6KTHK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +26 -35
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/preview-popover-5YUZCO2D.mjs +82 -0
- package/dist/lib/browser/preview-popover-5YUZCO2D.mjs.map +7 -0
- package/dist/lib/browser/react-surface-O25YV7AH.mjs +233 -0
- package/dist/lib/browser/react-surface-O25YV7AH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-L3IZVX56.mjs → chunk-2G4FUGDA.mjs} +6 -1
- package/dist/lib/node-esm/chunk-2G4FUGDA.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +26 -35
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/preview-popover-7QRYVL73.mjs +84 -0
- package/dist/lib/node-esm/preview-popover-7QRYVL73.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-YA3XXW7A.mjs +234 -0
- package/dist/lib/node-esm/react-surface-YA3XXW7A.mjs.map +7 -0
- package/dist/types/src/PreviewPlugin.d.ts +2 -1
- package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/preview-popover/index.d.ts +3 -0
- package/dist/types/src/capabilities/preview-popover/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts +5 -0
- package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/cards/FormCard.d.ts +7 -0
- package/dist/types/src/cards/FormCard.d.ts.map +1 -0
- package/dist/types/src/cards/OrganizationCard.d.ts +5 -0
- package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -0
- package/dist/types/src/cards/PersonCard.d.ts +5 -0
- package/dist/types/src/cards/PersonCard.d.ts.map +1 -0
- package/dist/types/src/cards/ProjectCard.d.ts +5 -0
- package/dist/types/src/cards/ProjectCard.d.ts.map +1 -0
- package/dist/types/src/cards/TaskCard.d.ts +5 -0
- package/dist/types/src/cards/TaskCard.d.ts.map +1 -0
- package/dist/types/src/cards/index.d.ts +6 -0
- package/dist/types/src/cards/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/stories/Card.stories.d.ts +8 -6
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +14 -12
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +45 -34
- package/src/PreviewPlugin.tsx +12 -23
- package/src/capabilities/index.ts +2 -4
- package/src/capabilities/preview-popover/index.ts +7 -0
- package/src/capabilities/preview-popover/preview-popover.ts +90 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +97 -0
- package/src/cards/FormCard.tsx +47 -0
- package/src/cards/OrganizationCard.tsx +29 -0
- package/src/cards/PersonCard.tsx +47 -0
- package/src/cards/ProjectCard.tsx +22 -0
- package/src/{components → cards}/TaskCard.tsx +18 -24
- package/src/{components → cards}/index.ts +3 -1
- package/src/index.ts +0 -1
- package/src/meta.ts +7 -2
- package/src/stories/Card.stories.tsx +39 -22
- package/src/stories/testing.tsx +47 -70
- package/dist/lib/browser/chunk-XKCIQK3C.mjs +0 -12
- package/dist/lib/browser/chunk-XKCIQK3C.mjs.map +0 -7
- package/dist/lib/browser/preview-popover-RKHENTFP.mjs +0 -65
- package/dist/lib/browser/preview-popover-RKHENTFP.mjs.map +0 -7
- package/dist/lib/browser/react-surface-X56QWACK.mjs +0 -448
- package/dist/lib/browser/react-surface-X56QWACK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-L3IZVX56.mjs.map +0 -7
- package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs +0 -67
- package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-4P7UCMK7.mjs +0 -449
- package/dist/lib/node-esm/react-surface-4P7UCMK7.mjs.map +0 -7
- package/dist/types/src/capabilities/preview-popover.d.ts +0 -4
- package/dist/types/src/capabilities/preview-popover.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/CardSubjectMenu.d.ts +0 -12
- package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
- package/dist/types/src/components/ContactCard.d.ts +0 -7
- package/dist/types/src/components/ContactCard.d.ts.map +0 -1
- package/dist/types/src/components/OrganizationCard.d.ts +0 -5
- package/dist/types/src/components/OrganizationCard.d.ts.map +0 -1
- package/dist/types/src/components/ProjectCard.d.ts +0 -5
- package/dist/types/src/components/ProjectCard.d.ts.map +0 -1
- package/dist/types/src/components/TaskCard.d.ts +0 -5
- package/dist/types/src/components/TaskCard.d.ts.map +0 -1
- package/dist/types/src/components/index.d.ts +0 -4
- package/dist/types/src/components/index.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -9
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/preview-popover.ts +0 -69
- package/src/capabilities/react-surface.tsx +0 -134
- package/src/components/CardSubjectMenu.tsx +0 -82
- package/src/components/ContactCard.tsx +0 -78
- package/src/components/OrganizationCard.tsx +0 -44
- package/src/components/ProjectCard.tsx +0 -28
- package/src/types.ts +0 -14
|
@@ -4,56 +4,73 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
|
|
7
|
-
import { IntentPlugin } from '@dxos/app-framework';
|
|
8
7
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
-
import {
|
|
8
|
+
import { corePlugins } from '@dxos/plugin-testing';
|
|
9
|
+
import { faker } from '@dxos/random';
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
+
import { type Organization, type Person, type Pipeline, type Task } from '@dxos/types';
|
|
10
12
|
|
|
13
|
+
import { FormCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
11
14
|
import { translations } from '../translations';
|
|
12
15
|
|
|
13
|
-
import {
|
|
16
|
+
import { DefaultStory, createOrganization, createPerson, createProject, createTask } from './testing';
|
|
17
|
+
|
|
18
|
+
faker.seed(999);
|
|
14
19
|
|
|
15
20
|
const meta = {
|
|
16
|
-
title: 'plugins/plugin-preview/Card',
|
|
17
|
-
render:
|
|
21
|
+
title: 'plugins/plugin-preview/cards/Card',
|
|
22
|
+
render: DefaultStory,
|
|
18
23
|
decorators: [
|
|
19
|
-
withTheme
|
|
20
|
-
|
|
24
|
+
withTheme(),
|
|
25
|
+
withLayout({ layout: 'fullscreen' }),
|
|
26
|
+
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
27
|
+
withPluginManager({ plugins: corePlugins() }),
|
|
21
28
|
],
|
|
22
29
|
parameters: {
|
|
23
|
-
layout: '
|
|
30
|
+
layout: 'fullscreen',
|
|
24
31
|
translations,
|
|
25
32
|
},
|
|
26
33
|
tags: ['cards'],
|
|
27
|
-
} satisfies Meta<typeof
|
|
34
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
28
35
|
|
|
29
36
|
export default meta;
|
|
30
37
|
|
|
31
|
-
|
|
38
|
+
export const _Form: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
39
|
+
args: {
|
|
40
|
+
Component: FormCard,
|
|
41
|
+
createObject: createPerson,
|
|
42
|
+
image: true,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
32
45
|
|
|
33
|
-
export const
|
|
46
|
+
export const _Person: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
34
47
|
args: {
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
Component: PersonCard,
|
|
49
|
+
createObject: createPerson,
|
|
50
|
+
image: true,
|
|
37
51
|
},
|
|
38
52
|
};
|
|
39
53
|
|
|
40
|
-
export const
|
|
54
|
+
export const _Organization: StoryObj<typeof DefaultStory<Organization.Organization>> = {
|
|
41
55
|
args: {
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
Component: OrganizationCard,
|
|
57
|
+
createObject: createOrganization,
|
|
58
|
+
image: true,
|
|
44
59
|
},
|
|
45
60
|
};
|
|
46
61
|
|
|
47
|
-
export const
|
|
62
|
+
export const _Project: StoryObj<typeof DefaultStory<Pipeline.Pipeline>> = {
|
|
48
63
|
args: {
|
|
49
|
-
|
|
50
|
-
|
|
64
|
+
Component: ProjectCard,
|
|
65
|
+
createObject: createProject,
|
|
66
|
+
image: true,
|
|
51
67
|
},
|
|
52
68
|
};
|
|
53
69
|
|
|
54
|
-
export const
|
|
70
|
+
export const _Task: StoryObj<typeof DefaultStory<Task.Task>> = {
|
|
55
71
|
args: {
|
|
56
|
-
|
|
57
|
-
|
|
72
|
+
Component: TaskCard,
|
|
73
|
+
createObject: createTask,
|
|
74
|
+
image: true,
|
|
58
75
|
},
|
|
59
76
|
};
|
package/src/stories/testing.tsx
CHANGED
|
@@ -2,39 +2,42 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { type FC } from 'react';
|
|
5
|
+
import React, { type FC, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
7
8
|
import { Obj, Ref } from '@dxos/echo';
|
|
8
9
|
import { faker } from '@dxos/random';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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';
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
faker.seed(1234);
|
|
17
|
-
|
|
18
|
-
type CardProps<T extends object> = {
|
|
19
|
-
Component: FC<PreviewProps<T>>;
|
|
20
|
-
subject: T;
|
|
21
|
-
icon?: string;
|
|
14
|
+
export type DefaultStoryProps<T extends Obj.Any> = {
|
|
15
|
+
Component: FC<SurfaceComponentProps<T>>;
|
|
16
|
+
createObject: () => T;
|
|
22
17
|
image?: boolean;
|
|
23
18
|
};
|
|
24
19
|
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
20
|
+
export const DefaultStory = <T extends Obj.Any>({ Component, createObject, image }: DefaultStoryProps<T>) => {
|
|
21
|
+
const object = useMemo(() => createObject(), [createObject]);
|
|
22
|
+
const roles: CardContainerProps['role'][] = ['intrinsic', 'popover'];
|
|
29
23
|
|
|
30
|
-
export const Defaultstory = ({ role, cards }: DefaultstoryProps) => {
|
|
31
24
|
return (
|
|
32
|
-
<div className='grid grid-cols-
|
|
33
|
-
{
|
|
34
|
-
<div key={i} className='flex justify-center'>
|
|
35
|
-
<
|
|
36
|
-
<
|
|
37
|
-
|
|
25
|
+
<div className='w-full h-full grid grid-cols-2 py-16 gap-8'>
|
|
26
|
+
{roles.map((role, i) => (
|
|
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>
|
|
30
|
+
<CardContainer role={role}>
|
|
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} subject={image ? object : omitImage(object)} />
|
|
38
|
+
</Card.Root>
|
|
39
|
+
</CardContainer>
|
|
40
|
+
</div>
|
|
38
41
|
</div>
|
|
39
42
|
))}
|
|
40
43
|
</div>
|
|
@@ -43,72 +46,46 @@ export const Defaultstory = ({ role, cards }: DefaultstoryProps) => {
|
|
|
43
46
|
|
|
44
47
|
export const omitImage = ({ image: _, ...rest }: any) => rest;
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Factory functions for creating test objects at render time.
|
|
51
|
+
*/
|
|
52
|
+
export const createOrganization = (): Organization.Organization => {
|
|
53
|
+
return Obj.make(Organization.Organization, {
|
|
49
54
|
name: faker.company.name(),
|
|
50
55
|
image:
|
|
51
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',
|
|
52
57
|
website: faker.internet.url(),
|
|
53
58
|
description: faker.lorem.paragraph(),
|
|
54
59
|
});
|
|
60
|
+
};
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
export const createPerson = (): Person.Person => {
|
|
63
|
+
const organization = createOrganization();
|
|
64
|
+
return Obj.make(Person.Person, {
|
|
57
65
|
fullName: faker.person.fullName(),
|
|
58
66
|
image:
|
|
59
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',
|
|
60
68
|
organization: Ref.make(organization),
|
|
61
69
|
emails: [
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
label: 'Work',
|
|
68
|
-
value: faker.internet.email(),
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
label: 'Work',
|
|
72
|
-
value: faker.internet.email(),
|
|
73
|
-
},
|
|
70
|
+
{ label: 'Work', value: faker.internet.email() },
|
|
71
|
+
{ label: 'Work', value: faker.internet.email() },
|
|
72
|
+
{ label: 'Work', value: faker.internet.email() },
|
|
74
73
|
],
|
|
75
74
|
});
|
|
75
|
+
};
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
export const createProject = (): Pipeline.Pipeline => {
|
|
78
|
+
return Obj.make(Pipeline.Pipeline, {
|
|
78
79
|
name: faker.person.fullName(),
|
|
79
80
|
image: 'https://dxos.network/dxos-logotype-blue.png',
|
|
80
81
|
description: faker.lorem.paragraph(),
|
|
82
|
+
columns: [],
|
|
81
83
|
});
|
|
84
|
+
};
|
|
82
85
|
|
|
83
|
-
|
|
86
|
+
export const createTask = (): Task.Task => {
|
|
87
|
+
return Obj.make(Task.Task, {
|
|
84
88
|
title: faker.lorem.sentence(),
|
|
85
|
-
status: faker.helpers.arrayElement(['todo', 'in-progress', 'done']),
|
|
89
|
+
status: faker.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
|
|
86
90
|
});
|
|
87
|
-
|
|
88
|
-
return [
|
|
89
|
-
{
|
|
90
|
-
Component: OrganizationCard,
|
|
91
|
-
subject: organization,
|
|
92
|
-
icon: 'ph--building-office--regular',
|
|
93
|
-
image,
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
Component: ContactCard,
|
|
97
|
-
subject: contact,
|
|
98
|
-
icon: 'ph--user--regular',
|
|
99
|
-
image,
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
Component: ProjectCard,
|
|
103
|
-
subject: project,
|
|
104
|
-
icon: 'ph--building--regular',
|
|
105
|
-
image,
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
Component: TaskCard,
|
|
109
|
-
subject: task,
|
|
110
|
-
icon: 'ph--list-checks--regular',
|
|
111
|
-
image,
|
|
112
|
-
},
|
|
113
|
-
];
|
|
114
91
|
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
|
-
var meta = {
|
|
3
|
-
id: "dxos.org/plugin/preview",
|
|
4
|
-
name: "Preview",
|
|
5
|
-
icon: "ph--eye--regular",
|
|
6
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview"
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
meta
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=chunk-XKCIQK3C.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 PluginMeta } from '@dxos/app-framework';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/preview',\n name: 'Preview',\n icon: 'ph--eye--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',\n};\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,QAAQ;AACV;",
|
|
6
|
-
"names": ["meta", "id", "name", "icon", "source"]
|
|
7
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// src/capabilities/preview-popover.ts
|
|
2
|
-
import { Capabilities, LayoutAction, contributes, createIntent } from "@dxos/app-framework";
|
|
3
|
-
import { addEventListener } from "@dxos/async";
|
|
4
|
-
import { parseId } from "@dxos/client/echo";
|
|
5
|
-
import { DXN } from "@dxos/keys";
|
|
6
|
-
import { log } from "@dxos/log";
|
|
7
|
-
import { ClientCapabilities } from "@dxos/plugin-client";
|
|
8
|
-
import { DX_ANCHOR_ACTIVATE } from "@dxos/react-ui";
|
|
9
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-preview/src/capabilities/preview-popover.ts";
|
|
10
|
-
var customEventOptions = {
|
|
11
|
-
capture: true,
|
|
12
|
-
passive: false
|
|
13
|
-
};
|
|
14
|
-
var handlePreviewLookup = async (client, defaultSpace, { ref, label }) => {
|
|
15
|
-
try {
|
|
16
|
-
const object = await defaultSpace.db.ref(DXN.parse(ref)).load();
|
|
17
|
-
return {
|
|
18
|
-
label,
|
|
19
|
-
object
|
|
20
|
-
};
|
|
21
|
-
} catch {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
var preview_popover_default = ((context) => {
|
|
26
|
-
const handleDxAnchorActivate = async ({ refId, label, trigger }) => {
|
|
27
|
-
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
28
|
-
const client = context.getCapability(ClientCapabilities.Client);
|
|
29
|
-
const [layout] = context.getCapabilities(Capabilities.Layout);
|
|
30
|
-
const { spaceId } = parseId(layout.workspace);
|
|
31
|
-
const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
|
|
32
|
-
const result = await handlePreviewLookup(client, space, {
|
|
33
|
-
ref: refId,
|
|
34
|
-
label
|
|
35
|
-
});
|
|
36
|
-
if (!result) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
await dispatch(createIntent(LayoutAction.UpdatePopover, {
|
|
40
|
-
part: "popover",
|
|
41
|
-
subject: result.object,
|
|
42
|
-
options: {
|
|
43
|
-
state: true,
|
|
44
|
-
variant: "virtual",
|
|
45
|
-
anchor: trigger
|
|
46
|
-
}
|
|
47
|
-
}));
|
|
48
|
-
};
|
|
49
|
-
let cleanup;
|
|
50
|
-
if (document.defaultView) {
|
|
51
|
-
cleanup = addEventListener(document.defaultView, DX_ANCHOR_ACTIVATE, handleDxAnchorActivate, customEventOptions);
|
|
52
|
-
} else {
|
|
53
|
-
log.warn("No default view found", void 0, {
|
|
54
|
-
F: __dxlog_file,
|
|
55
|
-
L: 65,
|
|
56
|
-
S: void 0,
|
|
57
|
-
C: (f, a) => f(...a)
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return contributes(Capabilities.Null, null, () => cleanup());
|
|
61
|
-
});
|
|
62
|
-
export {
|
|
63
|
-
preview_popover_default as default
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=preview-popover-RKHENTFP.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/preview-popover.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, LayoutAction, type PluginContext, contributes, createIntent } 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/react-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.ref(DXN.parse(ref)).load();\n return { label, object };\n } catch {\n return null;\n }\n};\n\nexport default (context: PluginContext) => {\n // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.\n const handleDxAnchorActivate = async ({ refId, label, trigger }: DxAnchorActivate) => {\n const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);\n const client = context.getCapability(ClientCapabilities.Client);\n const [layout] = context.getCapabilities(Capabilities.Layout);\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 dispatch(\n createIntent(LayoutAction.UpdatePopover, {\n part: 'popover',\n subject: result.object,\n options: {\n state: true,\n variant: 'virtual',\n anchor: trigger,\n },\n }),\n );\n };\n\n let cleanup: () => void;\n if (document.defaultView) {\n cleanup = addEventListener(\n document.defaultView,\n DX_ANCHOR_ACTIVATE as any,\n handleDxAnchorActivate,\n customEventOptions,\n );\n } else {\n log.warn('No default view found');\n }\n\n return contributes(Capabilities.Null, null, () => cleanup());\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,cAAcC,cAAkCC,aAAaC,oBAAoB;AAC1F,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,GAAGH,IAAIV,IAAIc,MAAMJ,GAAAA,CAAAA,EAAMK,KAAI;AAC7D,WAAO;MAAEJ;MAAOC;IAAO;EACzB,QAAQ;AACN,WAAO;EACT;AACF;AAEA,IAAA,2BAAe,CAACI,YAAAA;AAEd,QAAMC,yBAAyB,OAAO,EAAEC,OAAOP,OAAOQ,QAAO,MAAoB;AAC/E,UAAM,EAAEC,iBAAiBC,SAAQ,IAAKL,QAAQM,cAAc5B,aAAa6B,gBAAgB;AACzF,UAAMf,SAASQ,QAAQM,cAAcpB,mBAAmBsB,MAAM;AAC9D,UAAM,CAACC,MAAAA,IAAUT,QAAQU,gBAAgBhC,aAAaiC,MAAM;AAC5D,UAAM,EAAEC,QAAO,IAAK7B,QAAQ0B,OAAOI,SAAS;AAC5C,UAAMC,SAASF,WAAWpB,OAAOuB,OAAOC,IAAIJ,OAAAA,MAAapB,OAAOuB,OAAOE;AACvE,UAAMC,SAAS,MAAM3B,oBAAoBC,QAAQsB,OAAO;MAAEpB,KAAKQ;MAAOP;IAAM,CAAA;AAC5E,QAAI,CAACuB,QAAQ;AACX;IACF;AAEA,UAAMb,SACJxB,aAAaF,aAAawC,eAAe;MACvCC,MAAM;MACNC,SAASH,OAAOtB;MAChB0B,SAAS;QACPC,OAAO;QACPC,SAAS;QACTC,QAAQtB;MACV;IACF,CAAA,CAAA;EAEJ;AAEA,MAAIuB;AACJ,MAAIC,SAASC,aAAa;AACxBF,cAAU5C,iBACR6C,SAASC,aACTzC,oBACAc,wBACAb,kBAAAA;EAEJ,OAAO;AACLH,QAAI4C,KAAK,yBAAA,QAAA;;;;;;EACX;AAEA,SAAOjD,YAAYF,aAAaoD,MAAM,MAAM,MAAMJ,QAAAA,CAAAA;AACpD;",
|
|
6
|
-
"names": ["Capabilities", "LayoutAction", "contributes", "createIntent", "addEventListener", "parseId", "DXN", "log", "ClientCapabilities", "DX_ANCHOR_ACTIVATE", "customEventOptions", "capture", "passive", "handlePreviewLookup", "client", "defaultSpace", "ref", "label", "object", "db", "parse", "load", "context", "handleDxAnchorActivate", "refId", "trigger", "dispatchPromise", "dispatch", "getCapability", "IntentDispatcher", "Client", "layout", "getCapabilities", "Layout", "spaceId", "workspace", "space", "spaces", "get", "default", "result", "UpdatePopover", "part", "subject", "options", "state", "variant", "anchor", "cleanup", "document", "defaultView", "warn", "Null"]
|
|
7
|
-
}
|