@dxos/plugin-preview 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29
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/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/capabilities/index.mjs +9 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3SWUVHXJ.mjs +28 -0
- package/dist/lib/neutral/chunk-3SWUVHXJ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-52UEVZSF.mjs +17 -0
- 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/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 +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 +8 -0
- package/dist/types/src/cards/index.d.ts.map +1 -0
- 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 -3
- 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 +23 -12
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +16 -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 -6
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +87 -38
- package/src/PreviewPlugin.node.ts +16 -0
- package/src/PreviewPlugin.test.ts +25 -0
- package/src/PreviewPlugin.tsx +19 -29
- package/src/capabilities/index.ts +3 -3
- package/src/capabilities/preview-popover.ts +70 -43
- package/src/capabilities/react-surface.tsx +106 -152
- 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 +29 -0
- package/src/cards/PersonCard.tsx +65 -0
- package/src/cards/ProjectCard.tsx +22 -0
- package/src/cards/TaskCard.tsx +44 -0
- package/src/cards/index.ts +11 -0
- package/src/index.ts +0 -3
- package/src/meta.ts +8 -5
- package/src/plugin.ts +9 -0
- package/src/stories/Card.stories.tsx +89 -27
- package/src/stories/testing.tsx +64 -77
- package/src/testing.ts +7 -0
- package/src/translations.ts +8 -5
- package/dist/lib/browser/chunk-Z73ENKLE.mjs +0 -14
- package/dist/lib/browser/chunk-Z73ENKLE.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -63
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/preview-popover-HC6LHWXZ.mjs +0 -64
- package/dist/lib/browser/preview-popover-HC6LHWXZ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JGO43GLE.mjs +0 -381
- package/dist/lib/browser/react-surface-JGO43GLE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs +0 -16
- package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -64
- 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-ROGTBCTT.mjs +0 -66
- package/dist/lib/node-esm/preview-popover-ROGTBCTT.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-Q7F36L3Z.mjs +0 -382
- package/dist/lib/node-esm/react-surface-Q7F36L3Z.mjs.map +0 -7
- package/dist/types/src/components/CardSubjectMenu.d.ts +0 -10
- 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 -7
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/components/CardSubjectMenu.tsx +0 -56
- package/src/components/ContactCard.tsx +0 -76
- package/src/components/OrganizationCard.tsx +0 -44
- package/src/components/ProjectCard.tsx +0 -28
- package/src/components/TaskCard.tsx +0 -46
- package/src/components/index.ts +0 -7
- package/src/types.ts +0 -11
|
@@ -2,58 +2,120 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
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';
|
|
8
15
|
|
|
9
|
-
import {
|
|
16
|
+
import { translations } from '#translations';
|
|
10
17
|
|
|
11
|
-
import {
|
|
18
|
+
import { ExpandoCard, FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
19
|
+
import { DefaultStory, createExpando, createOrganization, createPerson, createProject, createTask } from './testing';
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
random.seed(999);
|
|
14
22
|
|
|
15
23
|
const meta = {
|
|
16
|
-
title: 'plugins/plugin-preview/Card',
|
|
17
|
-
render:
|
|
24
|
+
title: 'plugins/plugin-preview/cards/Card',
|
|
25
|
+
render: DefaultStory,
|
|
18
26
|
decorators: [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
parameters: {
|
|
36
|
+
parameters: {
|
|
37
|
+
layout: 'fullscreen',
|
|
38
|
+
translations,
|
|
39
|
+
},
|
|
26
40
|
tags: ['cards'],
|
|
27
|
-
} satisfies Meta<typeof
|
|
41
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
28
42
|
|
|
29
43
|
export default meta;
|
|
30
44
|
|
|
31
|
-
|
|
45
|
+
export const _Form: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
46
|
+
args: {
|
|
47
|
+
Component: FormCard,
|
|
48
|
+
createObject: createPerson,
|
|
49
|
+
image: true,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const _Person: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
54
|
+
args: {
|
|
55
|
+
Component: PersonCard,
|
|
56
|
+
createObject: createPerson,
|
|
57
|
+
image: true,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
32
60
|
|
|
33
|
-
export const
|
|
61
|
+
export const _Organization: StoryObj<typeof DefaultStory<Organization.Organization>> = {
|
|
34
62
|
args: {
|
|
35
|
-
|
|
36
|
-
|
|
63
|
+
Component: OrganizationCard,
|
|
64
|
+
createObject: createOrganization,
|
|
65
|
+
image: true,
|
|
37
66
|
},
|
|
38
67
|
};
|
|
39
68
|
|
|
40
|
-
export const
|
|
69
|
+
export const _Project: StoryObj<typeof DefaultStory<Pipeline.Pipeline>> = {
|
|
41
70
|
args: {
|
|
42
|
-
|
|
43
|
-
|
|
71
|
+
Component: ProjectCard,
|
|
72
|
+
createObject: createProject,
|
|
73
|
+
image: true,
|
|
44
74
|
},
|
|
45
75
|
};
|
|
46
76
|
|
|
47
|
-
export const
|
|
77
|
+
export const _Task: StoryObj<typeof DefaultStory<Task.Task>> = {
|
|
48
78
|
args: {
|
|
49
|
-
|
|
50
|
-
|
|
79
|
+
Component: TaskCard,
|
|
80
|
+
createObject: createTask,
|
|
81
|
+
image: true,
|
|
51
82
|
},
|
|
52
83
|
};
|
|
53
84
|
|
|
54
|
-
export const
|
|
85
|
+
export const _Expando: StoryObj<typeof DefaultStory<Expando.Expando>> = {
|
|
55
86
|
args: {
|
|
56
|
-
|
|
57
|
-
|
|
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
|
+
);
|
|
58
120
|
},
|
|
59
121
|
};
|
package/src/stories/testing.tsx
CHANGED
|
@@ -2,39 +2,43 @@
|
|
|
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
|
-
|
|
16
|
-
faker.seed(1234);
|
|
17
|
-
|
|
18
|
-
type CardProps<T extends object> = {
|
|
19
|
-
Component: FC<PreviewProps<T>>;
|
|
20
|
-
subject: T;
|
|
21
|
-
icon?: string;
|
|
15
|
+
export type DefaultStoryProps<T extends Obj.Any> = {
|
|
16
|
+
Component: FC<AppSurface.ObjectCardProps<T>>;
|
|
17
|
+
createObject: () => T;
|
|
22
18
|
image?: boolean;
|
|
23
19
|
};
|
|
24
20
|
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
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'];
|
|
29
24
|
|
|
30
|
-
export const Defaultstory = ({ role, cards }: DefaultstoryProps) => {
|
|
31
25
|
return (
|
|
32
|
-
<div className='grid grid-cols-
|
|
33
|
-
{
|
|
34
|
-
<div key={i} className='flex justify-center'>
|
|
35
|
-
<
|
|
36
|
-
<
|
|
37
|
-
|
|
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>
|
|
40
|
+
</CardContainer>
|
|
41
|
+
</div>
|
|
38
42
|
</div>
|
|
39
43
|
))}
|
|
40
44
|
</div>
|
|
@@ -43,72 +47,55 @@ export const Defaultstory = ({ role, cards }: DefaultstoryProps) => {
|
|
|
43
47
|
|
|
44
48
|
export const omitImage = ({ image: _, ...rest }: any) => rest;
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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(),
|
|
50
56
|
image:
|
|
51
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',
|
|
52
|
-
website:
|
|
53
|
-
description:
|
|
58
|
+
website: random.internet.url(),
|
|
59
|
+
description: random.lorem.paragraph(),
|
|
54
60
|
});
|
|
61
|
+
};
|
|
55
62
|
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
export const createPerson = (): Person.Person => {
|
|
64
|
+
const organization = createOrganization();
|
|
65
|
+
return Obj.make(Person.Person, {
|
|
66
|
+
fullName: random.person.fullName(),
|
|
58
67
|
image:
|
|
59
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',
|
|
60
69
|
organization: Ref.make(organization),
|
|
61
70
|
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
|
-
},
|
|
71
|
+
{ label: 'Work', value: random.internet.email() },
|
|
72
|
+
{ label: 'Work', value: random.internet.email() },
|
|
73
|
+
{ label: 'Work', value: random.internet.email() },
|
|
74
74
|
],
|
|
75
75
|
});
|
|
76
|
+
};
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
export const createProject = (): Pipeline.Pipeline => {
|
|
79
|
+
return Obj.make(Pipeline.Pipeline, {
|
|
80
|
+
name: random.person.fullName(),
|
|
79
81
|
image: 'https://dxos.network/dxos-logotype-blue.png',
|
|
80
|
-
description:
|
|
82
|
+
description: random.lorem.paragraph(),
|
|
83
|
+
columns: [],
|
|
81
84
|
});
|
|
85
|
+
};
|
|
82
86
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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),
|
|
86
91
|
});
|
|
92
|
+
};
|
|
87
93
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
];
|
|
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
|
+
});
|
|
114
101
|
};
|
package/src/testing.ts
ADDED
package/src/translations.ts
CHANGED
|
@@ -4,16 +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
|
|
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',
|
|
17
20
|
},
|
|
18
21
|
},
|
|
19
22
|
},
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
|
-
var PREVIEW_PLUGIN = "dxos.org/plugin/preview";
|
|
3
|
-
var meta = {
|
|
4
|
-
id: PREVIEW_PLUGIN,
|
|
5
|
-
name: "Preview",
|
|
6
|
-
icon: "ph--eye--regular",
|
|
7
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview"
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
PREVIEW_PLUGIN,
|
|
12
|
-
meta
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=chunk-Z73ENKLE.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 PREVIEW_PLUGIN = 'dxos.org/plugin/preview';\n\nexport const meta: PluginMeta = {\n id: PREVIEW_PLUGIN,\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,iBAAiB;AAEvB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;EACNC,MAAM;EACNC,QAAQ;AACV;",
|
|
6
|
-
"names": ["PREVIEW_PLUGIN", "meta", "id", "name", "icon", "source"]
|
|
7
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PREVIEW_PLUGIN,
|
|
3
|
-
meta
|
|
4
|
-
} from "./chunk-Z73ENKLE.mjs";
|
|
5
|
-
|
|
6
|
-
// src/PreviewPlugin.tsx
|
|
7
|
-
import { Capabilities, Events, contributes, defineModule, definePlugin } from "@dxos/app-framework";
|
|
8
|
-
import { ClientCapabilities, ClientEvents } from "@dxos/plugin-client";
|
|
9
|
-
import { DataType } from "@dxos/schema";
|
|
10
|
-
|
|
11
|
-
// src/capabilities/index.ts
|
|
12
|
-
import { lazy } from "@dxos/app-framework";
|
|
13
|
-
var PreviewPopover = lazy(() => import("./preview-popover-HC6LHWXZ.mjs"));
|
|
14
|
-
var ReactSurface = lazy(() => import("./react-surface-JGO43GLE.mjs"));
|
|
15
|
-
|
|
16
|
-
// src/translations.ts
|
|
17
|
-
var translations = [
|
|
18
|
-
{
|
|
19
|
-
"en-US": {
|
|
20
|
-
[meta.id]: {
|
|
21
|
-
"unable to create preview message": "No preview",
|
|
22
|
-
"todo label": "To do",
|
|
23
|
-
"in-progress label": "In progress",
|
|
24
|
-
"done label": "Done"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
// src/PreviewPlugin.tsx
|
|
31
|
-
var PreviewPlugin = () => definePlugin(meta, [
|
|
32
|
-
defineModule({
|
|
33
|
-
id: `${meta.id}/module/translations`,
|
|
34
|
-
activatesOn: Events.SetupTranslations,
|
|
35
|
-
activate: () => contributes(Capabilities.Translations, translations)
|
|
36
|
-
}),
|
|
37
|
-
defineModule({
|
|
38
|
-
id: `${meta.id}/module/schema`,
|
|
39
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
40
|
-
activate: () => [
|
|
41
|
-
contributes(ClientCapabilities.Schema, [
|
|
42
|
-
DataType.Person,
|
|
43
|
-
DataType.Organization
|
|
44
|
-
])
|
|
45
|
-
]
|
|
46
|
-
}),
|
|
47
|
-
defineModule({
|
|
48
|
-
id: `${meta.id}/module/preview-popover`,
|
|
49
|
-
activatesOn: Events.Startup,
|
|
50
|
-
activate: PreviewPopover
|
|
51
|
-
}),
|
|
52
|
-
defineModule({
|
|
53
|
-
id: `${meta.id}/module/react-surface`,
|
|
54
|
-
activatesOn: Events.SetupReactSurface,
|
|
55
|
-
activate: ReactSurface
|
|
56
|
-
})
|
|
57
|
-
]);
|
|
58
|
-
export {
|
|
59
|
-
PREVIEW_PLUGIN,
|
|
60
|
-
PreviewPlugin,
|
|
61
|
-
meta
|
|
62
|
-
};
|
|
63
|
-
//# 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 = () =>\n 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 },\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;MAChB;IACF;EACF;;;;AFNK,IAAMC,gBAAgB,MAC3BC,aAAaC,MAAM;EACjBC,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":1243,"imports":[],"format":"esm"},"src/capabilities/preview-popover.ts":{"bytes":8163,"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}],"format":"esm"},"src/components/CardSubjectMenu.tsx":{"bytes":6586,"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-graph","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-menu","kind":"import-statement","external":true}],"format":"esm"},"src/components/ContactCard.tsx":{"bytes":9925,"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/OrganizationCard.tsx":{"bytes":5918,"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/ProjectCard.tsx":{"bytes":4005,"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":"@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":687,"imports":[{"path":"src/components/ContactCard.tsx","kind":"import-statement","original":"./ContactCard"},{"path":"src/components/OrganizationCard.tsx","kind":"import-statement","original":"./OrganizationCard"},{"path":"src/components/ProjectCard.tsx","kind":"import-statement","original":"./ProjectCard"}],"format":"esm"},"src/capabilities/react-surface.tsx":{"bytes":24480,"imports":[{"path":"effect","kind":"import-statement","external":true},{"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-schema","kind":"import-statement","external":true},{"path":"@dxos/plugin-attention/types","kind":"import-statement","external":true},{"path":"@dxos/plugin-deck/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-form","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@dxos/react-ui-table/types","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"},{"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":1503,"imports":[{"path":"src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"src/PreviewPlugin.tsx":{"bytes":4743,"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":3372},"dist/lib/browser/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-Z73ENKLE.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-HC6LHWXZ.mjs","kind":"dynamic-import"},{"path":"dist/lib/browser/react-surface-JGO43GLE.mjs","kind":"dynamic-import"}],"exports":["PREVIEW_PLUGIN","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":242}},"bytes":1644},"dist/lib/browser/preview-popover-HC6LHWXZ.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4297},"dist/lib/browser/preview-popover-HC6LHWXZ.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}],"exports":["default"],"entryPoint":"src/capabilities/preview-popover.ts","inputs":{"src/capabilities/preview-popover.ts":{"bytesInOutput":1954}},"bytes":2096},"dist/lib/browser/react-surface-JGO43GLE.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":25248},"dist/lib/browser/react-surface-JGO43GLE.mjs":{"imports":[{"path":"dist/lib/browser/chunk-Z73ENKLE.mjs","kind":"import-statement"},{"path":"effect","kind":"import-statement","external":true},{"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-schema","kind":"import-statement","external":true},{"path":"@dxos/plugin-attention/types","kind":"import-statement","external":true},{"path":"@dxos/plugin-deck/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-form","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@dxos/react-ui-table/types","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":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-graph","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","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/echo","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}],"exports":["default"],"entryPoint":"src/capabilities/react-surface.tsx","inputs":{"src/capabilities/react-surface.tsx":{"bytesInOutput":6055},"src/components/ContactCard.tsx":{"bytesInOutput":3053},"src/components/CardSubjectMenu.tsx":{"bytesInOutput":1574},"src/components/index.ts":{"bytesInOutput":0},"src/components/OrganizationCard.tsx":{"bytesInOutput":1784},"src/components/ProjectCard.tsx":{"bytesInOutput":1148}},"bytes":14032},"dist/lib/browser/chunk-Z73ENKLE.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":613},"dist/lib/browser/chunk-Z73ENKLE.mjs":{"imports":[],"exports":["PREVIEW_PLUGIN","meta"],"inputs":{"src/meta.ts":{"bytesInOutput":216}},"bytes":313}}}
|
|
@@ -1,64 +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
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-preview/src/capabilities/preview-popover.ts";
|
|
9
|
-
var customEventOptions = {
|
|
10
|
-
capture: true,
|
|
11
|
-
passive: false
|
|
12
|
-
};
|
|
13
|
-
var handlePreviewLookup = async (client, defaultSpace, { ref, label }) => {
|
|
14
|
-
try {
|
|
15
|
-
const object = await defaultSpace.db.ref(DXN.parse(ref)).load();
|
|
16
|
-
return {
|
|
17
|
-
label,
|
|
18
|
-
object
|
|
19
|
-
};
|
|
20
|
-
} catch (err) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
var preview_popover_default = (context) => {
|
|
25
|
-
const handleDxAnchorActivate = async ({ refId, label, trigger }) => {
|
|
26
|
-
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
27
|
-
const client = context.getCapability(ClientCapabilities.Client);
|
|
28
|
-
const [layout] = context.getCapabilities(Capabilities.Layout);
|
|
29
|
-
const { spaceId } = parseId(layout.workspace);
|
|
30
|
-
const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
|
|
31
|
-
const result = await handlePreviewLookup(client, space, {
|
|
32
|
-
ref: refId,
|
|
33
|
-
label
|
|
34
|
-
});
|
|
35
|
-
if (!result) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
await dispatch(createIntent(LayoutAction.UpdatePopover, {
|
|
39
|
-
part: "popover",
|
|
40
|
-
subject: result.object,
|
|
41
|
-
options: {
|
|
42
|
-
state: true,
|
|
43
|
-
variant: "virtual",
|
|
44
|
-
anchor: trigger
|
|
45
|
-
}
|
|
46
|
-
}));
|
|
47
|
-
};
|
|
48
|
-
let cleanup;
|
|
49
|
-
if (document.defaultView) {
|
|
50
|
-
cleanup = addEventListener(document.defaultView, "dx-anchor-activate", handleDxAnchorActivate, customEventOptions);
|
|
51
|
-
} else {
|
|
52
|
-
log.warn("No default view found", void 0, {
|
|
53
|
-
F: __dxlog_file,
|
|
54
|
-
L: 65,
|
|
55
|
-
S: void 0,
|
|
56
|
-
C: (f, a) => f(...a)
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return contributes(Capabilities.Null, null, () => cleanup());
|
|
60
|
-
};
|
|
61
|
-
export {
|
|
62
|
-
preview_popover_default as default
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=preview-popover-HC6LHWXZ.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 { type DxAnchorActivate } from '@dxos/lit-ui';\nimport { log } from '@dxos/log';\nimport { ClientCapabilities } from '@dxos/plugin-client';\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 (err) {\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;AAEpB,SAASC,WAAW;AACpB,SAASC,0BAA0B;;AAGnC,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,IAAIT,IAAIa,MAAMJ,GAAAA,CAAAA,EAAMK,KAAI;AAC7D,WAAO;MAAEJ;MAAOC;IAAO;EACzB,SAASI,KAAK;AACZ,WAAO;EACT;AACF;AAEA,IAAA,0BAAe,CAACC,YAAAA;AAEd,QAAMC,yBAAyB,OAAO,EAAEC,OAAOR,OAAOS,QAAO,MAAoB;AAC/E,UAAM,EAAEC,iBAAiBC,SAAQ,IAAKL,QAAQM,cAAc5B,aAAa6B,gBAAgB;AACzF,UAAMhB,SAASS,QAAQM,cAAcpB,mBAAmBsB,MAAM;AAC9D,UAAM,CAACC,MAAAA,IAAUT,QAAQU,gBAAgBhC,aAAaiC,MAAM;AAC5D,UAAM,EAAEC,QAAO,IAAK7B,QAAQ0B,OAAOI,SAAS;AAC5C,UAAMC,SAASF,WAAWrB,OAAOwB,OAAOC,IAAIJ,OAAAA,MAAarB,OAAOwB,OAAOE;AACvE,UAAMC,SAAS,MAAM5B,oBAAoBC,QAAQuB,OAAO;MAAErB,KAAKS;MAAOR;IAAM,CAAA;AAC5E,QAAI,CAACwB,QAAQ;AACX;IACF;AAEA,UAAMb,SACJxB,aAAaF,aAAawC,eAAe;MACvCC,MAAM;MACNC,SAASH,OAAOvB;MAChB2B,SAAS;QACPC,OAAO;QACPC,SAAS;QACTC,QAAQtB;MACV;IACF,CAAA,CAAA;EAEJ;AAEA,MAAIuB;AACJ,MAAIC,SAASC,aAAa;AACxBF,cAAU5C,iBACR6C,SAASC,aACT,sBACA3B,wBACAd,kBAAAA;EAEJ,OAAO;AACLF,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", "customEventOptions", "capture", "passive", "handlePreviewLookup", "client", "defaultSpace", "ref", "label", "object", "db", "parse", "load", "err", "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
|
-
}
|