@dxos/plugin-preview 0.8.4-main.ae835ea → 0.8.4-main.bc2380dfbc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/dist/lib/neutral/PreviewPlugin.mjs +9 -0
- package/dist/lib/neutral/PreviewPlugin.mjs.map +7 -0
- package/dist/lib/neutral/PreviewPlugin.node.mjs +17 -0
- package/dist/lib/neutral/PreviewPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/PreviewPlugin.workerd.mjs +17 -0
- package/dist/lib/neutral/PreviewPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +9 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3SWUVHXJ.mjs +28 -0
- package/dist/lib/neutral/chunk-3SWUVHXJ.mjs.map +7 -0
- package/dist/lib/{browser/chunk-CEWM5LJG.mjs → neutral/chunk-52UEVZSF.mjs} +2 -2
- package/dist/lib/neutral/chunk-52UEVZSF.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +7 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +7 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +11 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/preview-popover-MPPEMUIA.mjs +78 -0
- package/dist/lib/neutral/preview-popover-MPPEMUIA.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-YFFJXXPQ.mjs +348 -0
- package/dist/lib/neutral/react-surface-YFFJXXPQ.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +7 -0
- package/dist/lib/neutral/testing.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +21 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/types/src/PreviewPlugin.d.ts +3 -1
- package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
- package/dist/types/src/PreviewPlugin.node.d.ts +4 -0
- package/dist/types/src/PreviewPlugin.node.d.ts.map +1 -0
- package/dist/types/src/PreviewPlugin.test.d.ts +2 -0
- package/dist/types/src/PreviewPlugin.test.d.ts.map +1 -0
- package/dist/types/src/PreviewPlugin.workerd.d.ts +4 -0
- package/dist/types/src/PreviewPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/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 +3 -2
- package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/cards/ExpandoCard.d.ts +4 -0
- package/dist/types/src/cards/ExpandoCard.d.ts.map +1 -0
- package/dist/types/src/cards/FormCard.d.ts +7 -0
- package/dist/types/src/cards/FormCard.d.ts.map +1 -0
- 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 +3 -3
- package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
- 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 +3 -3
- package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
- package/dist/types/src/cards/TaskCard.d.ts +3 -3
- package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
- package/dist/types/src/cards/index.d.ts +4 -1
- package/dist/types/src/cards/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -2
- 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/plugin.d.ts +3 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/stories/Card.stories.d.ts +22 -14
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +15 -12
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +8 -9
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +90 -39
- package/src/PreviewPlugin.node.ts +16 -0
- package/src/PreviewPlugin.test.ts +25 -0
- package/src/PreviewPlugin.tsx +17 -26
- package/src/PreviewPlugin.workerd.ts +16 -0
- package/src/capabilities/index.ts +3 -3
- package/src/capabilities/preview-popover.ts +68 -41
- package/src/capabilities/react-surface.tsx +104 -135
- package/src/cards/ExpandoCard.tsx +76 -0
- package/src/cards/FormCard.tsx +48 -0
- package/src/cards/JsonCard.tsx +19 -0
- package/src/cards/OrganizationCard.tsx +17 -13
- package/src/cards/PersonCard.tsx +65 -0
- package/src/cards/ProjectCard.tsx +9 -11
- package/src/cards/TaskCard.tsx +26 -28
- package/src/cards/index.ts +4 -1
- package/src/index.ts +0 -3
- package/src/meta.ts +3 -3
- package/src/plugin.ts +9 -0
- package/src/stories/Card.stories.tsx +83 -24
- package/src/stories/testing.tsx +64 -76
- package/src/testing.ts +7 -0
- package/src/translations.ts +8 -8
- package/dist/lib/browser/chunk-CEWM5LJG.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -64
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- 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-3AR3BFLF.mjs +0 -515
- package/dist/lib/browser/react-surface-3AR3BFLF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Q5MUNELK.mjs +0 -19
- package/dist/lib/node-esm/chunk-Q5MUNELK.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -65
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs +0 -67
- package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-L37JR7U2.mjs +0 -516
- package/dist/lib/node-esm/react-surface-L37JR7U2.mjs.map +0 -7
- package/dist/types/src/cards/ContactCard.d.ts +0 -5
- package/dist/types/src/cards/ContactCard.d.ts.map +0 -1
- package/dist/types/src/components/CardComponents.d.ts +0 -16
- package/dist/types/src/components/CardComponents.d.ts.map +0 -1
- package/dist/types/src/components/CardSubjectMenu.d.ts +0 -8
- package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
- package/dist/types/src/components/index.d.ts +0 -3
- package/dist/types/src/components/index.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -10
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/cards/ContactCard.tsx +0 -65
- package/src/components/CardComponents.tsx +0 -67
- package/src/components/CardSubjectMenu.tsx +0 -91
- package/src/components/index.ts +0 -6
- package/src/types.ts +0 -15
|
@@ -3,60 +3,119 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React from 'react';
|
|
6
7
|
|
|
7
|
-
import { IntentPlugin } from '@dxos/app-framework';
|
|
8
8
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { corePlugins } from '@dxos/plugin-testing';
|
|
10
|
+
import { random } from '@dxos/random';
|
|
11
|
+
import { Card } from '@dxos/react-ui';
|
|
12
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
13
|
+
import { type Expando } from '@dxos/schema';
|
|
14
|
+
import { type Organization, type Person, type Pipeline, type Task } from '@dxos/types';
|
|
11
15
|
|
|
12
|
-
import { translations } from '
|
|
16
|
+
import { translations } from '#translations';
|
|
13
17
|
|
|
14
|
-
import {
|
|
18
|
+
import { ExpandoCard, FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
19
|
+
import { DefaultStory, createExpando, createOrganization, createPerson, createProject, createTask } from './testing';
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
random.seed(999);
|
|
17
22
|
|
|
18
23
|
const meta = {
|
|
19
|
-
title: 'plugins/plugin-preview/Card',
|
|
20
|
-
render:
|
|
24
|
+
title: 'plugins/plugin-preview/cards/Card',
|
|
25
|
+
render: DefaultStory,
|
|
21
26
|
decorators: [
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
31
|
+
withTheme(),
|
|
32
|
+
withLayout({ layout: 'fullscreen' }),
|
|
33
|
+
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
34
|
+
withPluginManager({ plugins: corePlugins() }),
|
|
24
35
|
],
|
|
25
36
|
parameters: {
|
|
26
37
|
layout: 'fullscreen',
|
|
27
38
|
translations,
|
|
28
39
|
},
|
|
29
40
|
tags: ['cards'],
|
|
30
|
-
} satisfies Meta<typeof
|
|
41
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
31
42
|
|
|
32
43
|
export default meta;
|
|
33
44
|
|
|
34
|
-
|
|
45
|
+
export const _Form: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
46
|
+
args: {
|
|
47
|
+
Component: FormCard,
|
|
48
|
+
createObject: createPerson,
|
|
49
|
+
image: true,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
35
52
|
|
|
36
|
-
export const
|
|
53
|
+
export const _Person: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
37
54
|
args: {
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
Component: PersonCard,
|
|
56
|
+
createObject: createPerson,
|
|
57
|
+
image: true,
|
|
40
58
|
},
|
|
41
59
|
};
|
|
42
60
|
|
|
43
|
-
export const
|
|
61
|
+
export const _Organization: StoryObj<typeof DefaultStory<Organization.Organization>> = {
|
|
44
62
|
args: {
|
|
45
|
-
|
|
46
|
-
|
|
63
|
+
Component: OrganizationCard,
|
|
64
|
+
createObject: createOrganization,
|
|
65
|
+
image: true,
|
|
47
66
|
},
|
|
48
67
|
};
|
|
49
68
|
|
|
50
|
-
export const
|
|
69
|
+
export const _Project: StoryObj<typeof DefaultStory<Pipeline.Pipeline>> = {
|
|
51
70
|
args: {
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
Component: ProjectCard,
|
|
72
|
+
createObject: createProject,
|
|
73
|
+
image: true,
|
|
54
74
|
},
|
|
55
75
|
};
|
|
56
76
|
|
|
57
|
-
export const
|
|
77
|
+
export const _Task: StoryObj<typeof DefaultStory<Task.Task>> = {
|
|
58
78
|
args: {
|
|
59
|
-
|
|
60
|
-
|
|
79
|
+
Component: TaskCard,
|
|
80
|
+
createObject: createTask,
|
|
81
|
+
image: true,
|
|
82
|
+
},
|
|
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
|
+
);
|
|
61
120
|
},
|
|
62
121
|
};
|
package/src/stories/testing.tsx
CHANGED
|
@@ -2,112 +2,100 @@
|
|
|
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 AppSurface } from '@dxos/app-toolkit/ui';
|
|
7
8
|
import { Obj, Ref } from '@dxos/echo';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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 { Expando } from '@dxos/schema';
|
|
13
|
+
import { Organization, Person, Pipeline, Task } from '@dxos/types';
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type CardProps<T extends Obj.Any> = {
|
|
16
|
-
Component: FC<PreviewProps<T>>;
|
|
17
|
-
subject: T;
|
|
18
|
-
icon?: string;
|
|
15
|
+
export type DefaultStoryProps<T extends Obj.Any> = {
|
|
16
|
+
Component: FC<AppSurface.ObjectCardProps<T>>;
|
|
17
|
+
createObject: () => T;
|
|
19
18
|
image?: boolean;
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
21
|
+
export const DefaultStory = <T extends Obj.Any>({ Component, createObject, image }: DefaultStoryProps<T>) => {
|
|
22
|
+
const object = useMemo(() => createObject(), [createObject]);
|
|
23
|
+
const roles: CardContainerProps['role'][] = ['intrinsic', 'popover'];
|
|
26
24
|
|
|
27
|
-
export const Defaultstory = ({ role, cards }: DefaultstoryProps) => {
|
|
28
25
|
return (
|
|
29
|
-
<div className='
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
<div
|
|
33
|
-
<
|
|
34
|
-
|
|
26
|
+
<div className='h-full w-full grid grid-cols-2 py-16 gap-8'>
|
|
27
|
+
{roles.map((role, i) => (
|
|
28
|
+
<div key={i} className='flex h-full justify-center overflow-hidden'>
|
|
29
|
+
<div className='flex flex-col gap-4 w-full items-center'>
|
|
30
|
+
<span className='text-sm text-description'>{role}</span>
|
|
31
|
+
<CardContainer role={role}>
|
|
32
|
+
<Card.Root border={false}>
|
|
33
|
+
<Card.Toolbar>
|
|
34
|
+
<Card.DragHandle />
|
|
35
|
+
<Card.Title>{Obj.getLabel(object)}</Card.Title>
|
|
36
|
+
<Card.Menu />
|
|
37
|
+
</Card.Toolbar>
|
|
38
|
+
<Component role={role ?? 'card--content'} subject={image ? object : omitImage(object)} />
|
|
39
|
+
</Card.Root>
|
|
35
40
|
</CardContainer>
|
|
36
41
|
</div>
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
</div>
|
|
43
|
+
))}
|
|
39
44
|
</div>
|
|
40
45
|
);
|
|
41
46
|
};
|
|
42
47
|
|
|
43
48
|
export const omitImage = ({ image: _, ...rest }: any) => rest;
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Factory functions for creating test objects at render time.
|
|
52
|
+
*/
|
|
53
|
+
export const createOrganization = (): Organization.Organization => {
|
|
54
|
+
return Obj.make(Organization.Organization, {
|
|
55
|
+
name: random.company.name(),
|
|
49
56
|
image:
|
|
50
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',
|
|
51
|
-
website:
|
|
52
|
-
description:
|
|
58
|
+
website: random.internet.url(),
|
|
59
|
+
description: random.lorem.paragraph(),
|
|
53
60
|
});
|
|
61
|
+
};
|
|
54
62
|
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
export const createPerson = (): Person.Person => {
|
|
64
|
+
const organization = createOrganization();
|
|
65
|
+
return Obj.make(Person.Person, {
|
|
66
|
+
fullName: random.person.fullName(),
|
|
57
67
|
image:
|
|
58
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',
|
|
59
69
|
organization: Ref.make(organization),
|
|
60
70
|
emails: [
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
label: 'Work',
|
|
67
|
-
value: faker.internet.email(),
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
label: 'Work',
|
|
71
|
-
value: faker.internet.email(),
|
|
72
|
-
},
|
|
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
|
});
|
|
76
|
+
};
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
export const createProject = (): Pipeline.Pipeline => {
|
|
79
|
+
return Obj.make(Pipeline.Pipeline, {
|
|
80
|
+
name: random.person.fullName(),
|
|
78
81
|
image: 'https://dxos.network/dxos-logotype-blue.png',
|
|
79
|
-
description:
|
|
82
|
+
description: random.lorem.paragraph(),
|
|
83
|
+
columns: [],
|
|
80
84
|
});
|
|
85
|
+
};
|
|
81
86
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
export const createTask = (): Task.Task => {
|
|
88
|
+
return Obj.make(Task.Task, {
|
|
89
|
+
title: random.lorem.sentence(),
|
|
90
|
+
status: random.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
|
|
85
91
|
});
|
|
92
|
+
};
|
|
86
93
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
{
|
|
95
|
-
Component: ContactCard,
|
|
96
|
-
subject: contact,
|
|
97
|
-
icon: 'ph--user--regular',
|
|
98
|
-
image,
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
Component: ProjectCard,
|
|
102
|
-
subject: project,
|
|
103
|
-
icon: 'ph--building--regular',
|
|
104
|
-
image,
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
Component: TaskCard,
|
|
108
|
-
subject: task,
|
|
109
|
-
icon: 'ph--list-checks--regular',
|
|
110
|
-
image,
|
|
111
|
-
},
|
|
112
|
-
];
|
|
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(),
|
|
100
|
+
});
|
|
113
101
|
};
|
package/src/testing.ts
ADDED
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,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';\nimport { trim } from '@dxos/util';\n\nexport const meta: PluginMeta = {\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,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,QAAQ;AACV;",
|
|
6
|
-
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "source"]
|
|
7
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
meta
|
|
3
|
-
} from "./chunk-CEWM5LJG.mjs";
|
|
4
|
-
|
|
5
|
-
// src/PreviewPlugin.tsx
|
|
6
|
-
import { Capabilities, Events, contributes, defineModule, definePlugin } from "@dxos/app-framework";
|
|
7
|
-
import { ClientCapabilities, ClientEvents } from "@dxos/plugin-client";
|
|
8
|
-
import { DataType } from "@dxos/schema";
|
|
9
|
-
|
|
10
|
-
// src/capabilities/index.ts
|
|
11
|
-
import { lazy } from "@dxos/app-framework";
|
|
12
|
-
var PreviewPopover = lazy(() => import("./preview-popover-RKHENTFP.mjs"));
|
|
13
|
-
var ReactSurface = lazy(() => import("./react-surface-3AR3BFLF.mjs"));
|
|
14
|
-
|
|
15
|
-
// src/translations.ts
|
|
16
|
-
var translations = [
|
|
17
|
-
{
|
|
18
|
-
"en-US": {
|
|
19
|
-
[meta.id]: {
|
|
20
|
-
"unable to create preview message": "No preview",
|
|
21
|
-
"todo label": "To do",
|
|
22
|
-
"in-progress label": "In progress",
|
|
23
|
-
"done label": "Done",
|
|
24
|
-
"open object label": "Open",
|
|
25
|
-
"add object to space label": "Add to space",
|
|
26
|
-
"more options label": "More options"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
// src/PreviewPlugin.tsx
|
|
33
|
-
var PreviewPlugin = definePlugin(meta, () => [
|
|
34
|
-
defineModule({
|
|
35
|
-
id: `${meta.id}/module/translations`,
|
|
36
|
-
activatesOn: Events.SetupTranslations,
|
|
37
|
-
activate: () => contributes(Capabilities.Translations, translations)
|
|
38
|
-
}),
|
|
39
|
-
defineModule({
|
|
40
|
-
id: `${meta.id}/module/schema`,
|
|
41
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
42
|
-
activate: () => [
|
|
43
|
-
contributes(ClientCapabilities.Schema, [
|
|
44
|
-
DataType.Person,
|
|
45
|
-
DataType.Organization
|
|
46
|
-
])
|
|
47
|
-
]
|
|
48
|
-
}),
|
|
49
|
-
defineModule({
|
|
50
|
-
id: `${meta.id}/module/preview-popover`,
|
|
51
|
-
activatesOn: Events.Startup,
|
|
52
|
-
activate: PreviewPopover
|
|
53
|
-
}),
|
|
54
|
-
defineModule({
|
|
55
|
-
id: `${meta.id}/module/react-surface`,
|
|
56
|
-
activatesOn: Events.SetupReactSurface,
|
|
57
|
-
activate: ReactSurface
|
|
58
|
-
})
|
|
59
|
-
]);
|
|
60
|
-
export {
|
|
61
|
-
PreviewPlugin,
|
|
62
|
-
meta
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/PreviewPlugin.tsx", "../../../src/capabilities/index.ts", "../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';\nimport { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';\nimport { DataType } from '@dxos/schema';\n\nimport { PreviewPopover, ReactSurface } from './capabilities';\nimport { meta } from './meta';\nimport { translations } from './translations';\n\nexport const PreviewPlugin = definePlugin(meta, () => [\n defineModule({\n id: `${meta.id}/module/translations`,\n activatesOn: Events.SetupTranslations,\n activate: () => contributes(Capabilities.Translations, translations),\n }),\n defineModule({\n id: `${meta.id}/module/schema`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () => [contributes(ClientCapabilities.Schema, [DataType.Person, DataType.Organization])],\n }),\n defineModule({\n id: `${meta.id}/module/preview-popover`,\n activatesOn: Events.Startup,\n activate: PreviewPopover,\n }),\n defineModule({\n id: `${meta.id}/module/react-surface`,\n activatesOn: Events.SetupReactSurface,\n activate: ReactSurface,\n }),\n]);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const PreviewPopover = lazy(() => import('./preview-popover'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nimport { meta } from './meta';\n\nexport const translations = [\n {\n 'en-US': {\n [meta.id]: {\n 'unable to create preview message': 'No preview',\n 'todo label': 'To do',\n 'in-progress label': 'In progress',\n 'done label': 'Done',\n 'open object label': 'Open',\n 'add object to space label': 'Add to space',\n 'more options label': 'More options',\n },\n },\n },\n] as const satisfies Resource[];\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,SAASA,cAAcC,QAAQC,aAAaC,cAAcC,oBAAoB;AAC9E,SAASC,oBAAoBC,oBAAoB;AACjD,SAASC,gBAAgB;;;ACFzB,SAASC,YAAY;AAEd,IAAMC,iBAAiBC,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAMC,eAAeD,KAAK,MAAM,OAAO,8BAAA,CAAA;;;ACCvC,IAAME,eAAe;EAC1B;IACE,SAAS;MACP,CAACC,KAAKC,EAAE,GAAG;QACT,oCAAoC;QACpC,cAAc;QACd,qBAAqB;QACrB,cAAc;QACd,qBAAqB;QACrB,6BAA6B;QAC7B,sBAAsB;MACxB;IACF;EACF;;;;AFTK,IAAMC,gBAAgBC,aAAaC,MAAM,MAAM;EACpDC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,UAAU,MAAMC,YAAYC,aAAaC,cAAcC,YAAAA;EACzD,CAAA;EACAT,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaQ,aAAaC;IAC1BN,UAAU,MAAM;MAACC,YAAYM,mBAAmBC,QAAQ;QAACC,SAASC;QAAQD,SAASE;OAAa;;EAClG,CAAA;EACAhB,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOc;IACpBZ,UAAUa;EACZ,CAAA;EACAlB,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOgB;IACpBd,UAAUe;EACZ,CAAA;CACD;",
|
|
6
|
-
"names": ["Capabilities", "Events", "contributes", "defineModule", "definePlugin", "ClientCapabilities", "ClientEvents", "DataType", "lazy", "PreviewPopover", "lazy", "ReactSurface", "translations", "meta", "id", "PreviewPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupTranslations", "activate", "contributes", "Capabilities", "Translations", "translations", "ClientEvents", "SetupSchema", "ClientCapabilities", "Schema", "DataType", "Person", "Organization", "Startup", "PreviewPopover", "SetupReactSurface", "ReactSurface"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/meta.ts":{"bytes":1677,"imports":[{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/capabilities/preview-popover.ts":{"bytes":8281,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"format":"esm"},"src/components/CardSubjectMenu.tsx":{"bytes":10351,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/plugin-space/types","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-menu","kind":"import-statement","external":true},{"path":"src/meta.ts","kind":"import-statement","original":"../meta"}],"format":"esm"},"src/components/CardComponents.tsx":{"bytes":8366,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"src/components/CardSubjectMenu.tsx","kind":"import-statement","original":"./CardSubjectMenu"}],"format":"esm"},"src/components/index.ts":{"bytes":594,"imports":[{"path":"src/components/CardComponents.tsx","kind":"import-statement","original":"./CardComponents"},{"path":"src/components/CardSubjectMenu.tsx","kind":"import-statement","original":"./CardSubjectMenu"}],"format":"esm"},"src/cards/ContactCard.tsx":{"bytes":8371,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"src/components/index.ts","kind":"import-statement","original":"../components"}],"format":"esm"},"src/cards/OrganizationCard.tsx":{"bytes":3709,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"src/components/index.ts","kind":"import-statement","original":"../components"}],"format":"esm"},"src/cards/ProjectCard.tsx":{"bytes":3254,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"src/components/index.ts","kind":"import-statement","original":"../components"}],"format":"esm"},"src/cards/TaskCard.tsx":{"bytes":6971,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/components/index.ts","kind":"import-statement","original":"../components"}],"format":"esm"},"src/cards/index.ts":{"bytes":770,"imports":[{"path":"src/cards/ContactCard.tsx","kind":"import-statement","original":"./ContactCard"},{"path":"src/cards/OrganizationCard.tsx","kind":"import-statement","original":"./OrganizationCard"},{"path":"src/cards/ProjectCard.tsx","kind":"import-statement","original":"./ProjectCard"},{"path":"src/cards/TaskCard.tsx","kind":"import-statement","original":"./TaskCard"}],"format":"esm"},"src/capabilities/react-surface.tsx":{"bytes":20699,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/plugin-space","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-form","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/cards/index.ts","kind":"import-statement","original":"../cards"},{"path":"src/meta.ts","kind":"import-statement","original":"../meta"}],"format":"esm"},"src/capabilities/index.ts":{"bytes":1037,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"src/capabilities/preview-popover.ts","kind":"dynamic-import","original":"./preview-popover"},{"path":"src/capabilities/react-surface.tsx","kind":"dynamic-import","original":"./react-surface"}],"format":"esm"},"src/translations.ts":{"bytes":1903,"imports":[{"path":"src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"src/PreviewPlugin.tsx":{"bytes":4683,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/capabilities/index.ts","kind":"import-statement","original":"./capabilities"},{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"src/translations.ts","kind":"import-statement","original":"./translations"}],"format":"esm"},"src/index.ts":{"bytes":595,"imports":[{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"src/PreviewPlugin.tsx","kind":"import-statement","original":"./PreviewPlugin"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3502},"dist/lib/browser/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-CEWM5LJG.mjs","kind":"import-statement"},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"dist/lib/browser/preview-popover-RKHENTFP.mjs","kind":"dynamic-import"},{"path":"dist/lib/browser/react-surface-3AR3BFLF.mjs","kind":"dynamic-import"}],"exports":["PreviewPlugin","meta"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0},"src/PreviewPlugin.tsx":{"bytesInOutput":952},"src/capabilities/index.ts":{"bytesInOutput":190},"src/translations.ts":{"bytesInOutput":378}},"bytes":1744},"dist/lib/browser/preview-popover-RKHENTFP.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4339},"dist/lib/browser/preview-popover-RKHENTFP.mjs":{"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"src/capabilities/preview-popover.ts","inputs":{"src/capabilities/preview-popover.ts":{"bytesInOutput":2001}},"bytes":2143},"dist/lib/browser/react-surface-3AR3BFLF.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":30099},"dist/lib/browser/react-surface-3AR3BFLF.mjs":{"imports":[{"path":"dist/lib/browser/chunk-CEWM5LJG.mjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/plugin-space","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-form","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/plugin-space/types","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-menu","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"src/capabilities/react-surface.tsx","inputs":{"src/capabilities/react-surface.tsx":{"bytesInOutput":5408},"src/cards/ContactCard.tsx":{"bytesInOutput":2405},"src/components/CardComponents.tsx":{"bytesInOutput":2664},"src/components/CardSubjectMenu.tsx":{"bytesInOutput":2638},"src/components/index.ts":{"bytesInOutput":0},"src/cards/index.ts":{"bytesInOutput":0},"src/cards/OrganizationCard.tsx":{"bytesInOutput":993},"src/cards/ProjectCard.tsx":{"bytesInOutput":854},"src/cards/TaskCard.tsx":{"bytesInOutput":1787}},"bytes":17240},"dist/lib/browser/chunk-CEWM5LJG.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":803},"dist/lib/browser/chunk-CEWM5LJG.mjs":{"imports":[{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["meta"],"inputs":{"src/meta.ts":{"bytesInOutput":389}},"bytes":468}}}
|
|
@@ -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
|
-
}
|