@dxos/plugin-preview 0.8.4-main.dedc0f3 → 0.8.4-main.e8ec1fe
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-CEWM5LJG.mjs +17 -0
- package/dist/lib/browser/chunk-CEWM5LJG.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +11 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{preview-popover-HC6LHWXZ.mjs → preview-popover-IAPAEKZL.mjs} +7 -6
- package/dist/lib/browser/preview-popover-IAPAEKZL.mjs.map +7 -0
- package/dist/lib/browser/react-surface-LRMZKOJS.mjs +498 -0
- package/dist/lib/browser/react-surface-LRMZKOJS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Q5MUNELK.mjs +19 -0
- package/dist/lib/node-esm/chunk-Q5MUNELK.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +11 -10
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{preview-popover-ROGTBCTT.mjs → preview-popover-CH2LDYWM.mjs} +7 -6
- package/dist/lib/node-esm/preview-popover-CH2LDYWM.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-65UVGBIZ.mjs +499 -0
- package/dist/lib/node-esm/react-surface-65UVGBIZ.mjs.map +7 -0
- package/dist/types/src/PreviewPlugin.d.ts +1 -1
- package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- 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 +5 -0
- package/dist/types/src/cards/index.d.ts.map +1 -0
- package/dist/types/src/components/CardComponents.d.ts +16 -0
- package/dist/types/src/components/CardComponents.d.ts.map +1 -0
- package/dist/types/src/components/CardSubjectMenu.d.ts +3 -5
- package/dist/types/src/components/CardSubjectMenu.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/stories/Card.stories.d.ts +3 -1
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +4 -3
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +10 -5
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -32
- package/src/PreviewPlugin.tsx +23 -24
- package/src/capabilities/preview-popover.ts +5 -5
- package/src/capabilities/react-surface.tsx +89 -96
- package/src/cards/OrganizationCard.tsx +34 -0
- package/src/cards/PersonCard.tsx +63 -0
- package/src/cards/ProjectCard.tsx +24 -0
- package/src/{components → cards}/TaskCard.tsx +10 -10
- package/src/cards/index.ts +8 -0
- package/src/components/CardComponents.tsx +67 -0
- package/src/components/CardSubjectMenu.tsx +73 -26
- package/src/components/index.ts +2 -3
- package/src/meta.ts +6 -3
- package/src/stories/Card.stories.tsx +11 -8
- package/src/stories/testing.tsx +21 -21
- package/src/translations.ts +3 -0
- package/src/types.ts +23 -5
- package/dist/lib/browser/chunk-Z73ENKLE.mjs +0 -14
- package/dist/lib/browser/chunk-Z73ENKLE.mjs.map +0 -7
- 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/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/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/src/components/ContactCard.tsx +0 -76
- package/src/components/OrganizationCard.tsx +0 -44
- package/src/components/ProjectCard.tsx +0 -28
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Button, Icon } from '@dxos/react-ui';
|
|
8
|
+
import { Card, cardNoSpacing, cardSpacing } from '@dxos/react-ui-stack';
|
|
9
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
10
|
+
|
|
11
|
+
import { type CardPreviewProps } from '../types';
|
|
12
|
+
|
|
13
|
+
import { CardSubjectMenu } from './CardSubjectMenu';
|
|
14
|
+
|
|
15
|
+
export const gridRow = 'is-full grid grid-cols-[1.5rem_1fr_min-content] gap-2 items-center';
|
|
16
|
+
|
|
17
|
+
// TODO(burdon): Standardize card grid for common rows.
|
|
18
|
+
|
|
19
|
+
export const CardHeader = ({ label, subject, activeSpace }: { label?: string } & CardPreviewProps) => {
|
|
20
|
+
return (
|
|
21
|
+
<div role='none' className={mx('flex items-center gap-2', cardSpacing)}>
|
|
22
|
+
<Card.Heading classNames={cardNoSpacing}>{label}</Card.Heading>
|
|
23
|
+
<CardSubjectMenu subject={subject} activeSpace={activeSpace} />
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const CardRow = ({ icon, label, onClick }: { icon: string; label: string; onClick?: () => void }) => {
|
|
29
|
+
if (!onClick) {
|
|
30
|
+
return (
|
|
31
|
+
<Card.Chrome>
|
|
32
|
+
<p data-variant='ghost' className={mx(gridRow, 'dx-button')}>
|
|
33
|
+
<Icon icon={icon} size={5} classNames='text-subdued' />
|
|
34
|
+
<span className='min-is-0 flex-1 truncate col-span-2'>{label}</span>
|
|
35
|
+
</p>
|
|
36
|
+
</Card.Chrome>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Card.Chrome>
|
|
42
|
+
<Button variant='ghost' classNames={mx(gridRow, 'text-start')} onClick={onClick}>
|
|
43
|
+
<Icon icon={icon} size={5} classNames='text-subdued' />
|
|
44
|
+
<span className='min-is-0 flex-1 truncate'>{label}</span>
|
|
45
|
+
<Icon icon='ph--arrow-right--regular' />
|
|
46
|
+
</Button>
|
|
47
|
+
</Card.Chrome>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const CardLink = ({ label, href }: { label: string; href: string }) => {
|
|
52
|
+
return (
|
|
53
|
+
<Card.Chrome>
|
|
54
|
+
<a
|
|
55
|
+
className={mx(gridRow, 'dx-button dx-focus-ring')}
|
|
56
|
+
data-variant='ghost'
|
|
57
|
+
href={href}
|
|
58
|
+
target='_blank'
|
|
59
|
+
rel='noreferrer'
|
|
60
|
+
>
|
|
61
|
+
<Icon icon='ph--link--regular' size={5} classNames='text-subdued' />
|
|
62
|
+
<span className='min-is-0 flex-1 truncate'>{label}</span>
|
|
63
|
+
<Icon icon='ph--arrow-square-out--regular' />
|
|
64
|
+
</a>
|
|
65
|
+
</Card.Chrome>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
@@ -2,50 +2,50 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import { LayoutAction, createIntent } from '@dxos/app-framework';
|
|
9
|
+
import { useIntentDispatcher } from '@dxos/app-framework/react';
|
|
9
10
|
import { ACTION_TYPE } from '@dxos/app-graph';
|
|
10
|
-
import {
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
11
13
|
import { IconButton, type IconButtonProps, useTranslation } from '@dxos/react-ui';
|
|
12
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
type ActionGraphProps,
|
|
16
|
+
DropdownMenu,
|
|
17
|
+
type MenuActions,
|
|
18
|
+
MenuProvider,
|
|
19
|
+
useMenuActions,
|
|
20
|
+
} from '@dxos/react-ui-menu';
|
|
13
21
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const result: ActionGraphProps = { edges: [], nodes: [] };
|
|
17
|
-
result.nodes.push({
|
|
18
|
-
type: ACTION_TYPE,
|
|
19
|
-
id: `${subject.id}/add-to-space`,
|
|
20
|
-
data: () => console.log('[TO DO]', 'add object to space', subject),
|
|
21
|
-
properties: {
|
|
22
|
-
label: ['add object to space label', { ns: 'os' }],
|
|
23
|
-
icon: 'ph--file-plus--regular',
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
result.nodes.forEach(({ id: target }) => {
|
|
27
|
-
result.edges.push({ source: 'root', target });
|
|
28
|
-
});
|
|
29
|
-
return useMenuActions(Rx.make(result));
|
|
30
|
-
};
|
|
22
|
+
import { meta } from '../meta';
|
|
23
|
+
import { type CardPreviewProps } from '../types';
|
|
31
24
|
|
|
32
25
|
/**
|
|
33
|
-
*
|
|
26
|
+
* Generic menu for objects; builds menu with common actions.
|
|
34
27
|
*/
|
|
28
|
+
// TODO(burdon): Reconcile title and menu with main Card header.
|
|
35
29
|
export const CardSubjectMenu = ({
|
|
36
30
|
subject,
|
|
31
|
+
activeSpace,
|
|
37
32
|
...props
|
|
38
|
-
}: Omit<IconButtonProps, 'icon' | 'label'>
|
|
39
|
-
const { t } = useTranslation(
|
|
40
|
-
const menuProps = useSubjectMenuGroupItems(subject);
|
|
33
|
+
}: CardPreviewProps & Omit<IconButtonProps, 'icon' | 'label'>) => {
|
|
34
|
+
const { t } = useTranslation(meta.id);
|
|
35
|
+
const menuProps = useSubjectMenuGroupItems({ subject, activeSpace });
|
|
36
|
+
|
|
37
|
+
if (!activeSpace) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
41
|
return (
|
|
42
42
|
<MenuProvider {...menuProps}>
|
|
43
43
|
<DropdownMenu.Root>
|
|
44
44
|
<DropdownMenu.Trigger asChild>
|
|
45
45
|
<IconButton
|
|
46
|
-
iconOnly
|
|
47
46
|
variant='ghost'
|
|
48
47
|
icon='ph--dots-three-vertical--bold'
|
|
48
|
+
iconOnly
|
|
49
49
|
label={t('more options label')}
|
|
50
50
|
{...props}
|
|
51
51
|
/>
|
|
@@ -54,3 +54,50 @@ export const CardSubjectMenu = ({
|
|
|
54
54
|
</MenuProvider>
|
|
55
55
|
);
|
|
56
56
|
};
|
|
57
|
+
|
|
58
|
+
const useSubjectMenuGroupItems = ({ subject, activeSpace }: CardPreviewProps): MenuActions => {
|
|
59
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
60
|
+
const result: ActionGraphProps = { edges: [], nodes: [] };
|
|
61
|
+
|
|
62
|
+
result.nodes.push({
|
|
63
|
+
type: ACTION_TYPE,
|
|
64
|
+
id: `${subject.id}/open`,
|
|
65
|
+
data: () =>
|
|
66
|
+
dispatch(
|
|
67
|
+
createIntent(LayoutAction.Open, {
|
|
68
|
+
part: 'main',
|
|
69
|
+
subject: [Obj.getDXN(subject).toString()],
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
72
|
+
properties: {
|
|
73
|
+
label: ['open object label', { ns: meta.id }],
|
|
74
|
+
icon: 'ph--arrow-right--regular',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (activeSpace && Obj.getDXN(subject).asQueueDXN()) {
|
|
79
|
+
result.nodes.push({
|
|
80
|
+
type: ACTION_TYPE,
|
|
81
|
+
id: `${subject.id}/add-to-space`,
|
|
82
|
+
// TODO(wittjosiah): Update reference to point to db object when adding?
|
|
83
|
+
data: () =>
|
|
84
|
+
dispatch(
|
|
85
|
+
createIntent(SpaceAction.AddObject, {
|
|
86
|
+
object: subject,
|
|
87
|
+
target: activeSpace,
|
|
88
|
+
hidden: true,
|
|
89
|
+
}),
|
|
90
|
+
),
|
|
91
|
+
properties: {
|
|
92
|
+
label: ['add object to space label', { ns: meta.id }],
|
|
93
|
+
icon: 'ph--file-plus--regular',
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
result.nodes.forEach(({ id: target }) => {
|
|
99
|
+
result.edges.push({ source: 'root', target });
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return useMenuActions(Atom.make(result));
|
|
103
|
+
};
|
package/src/components/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
-
|
|
7
|
-
export const PREVIEW_PLUGIN = 'dxos.org/plugin/preview';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
8
7
|
|
|
9
8
|
export const meta: PluginMeta = {
|
|
10
|
-
id:
|
|
9
|
+
id: 'dxos.org/plugin/preview',
|
|
11
10
|
name: 'Preview',
|
|
11
|
+
description: trim`
|
|
12
|
+
Rich preview panel for viewing object content without opening full editors.
|
|
13
|
+
Quick peek at documents, images, and data with inline rendering.
|
|
14
|
+
`,
|
|
12
15
|
icon: 'ph--eye--regular',
|
|
13
16
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',
|
|
14
17
|
};
|
|
@@ -2,27 +2,30 @@
|
|
|
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';
|
|
8
6
|
|
|
9
|
-
import {
|
|
7
|
+
import { IntentPlugin } from '@dxos/app-framework';
|
|
8
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
+
import { faker } from '@dxos/random';
|
|
10
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
10
11
|
|
|
11
12
|
import { translations } from '../translations';
|
|
12
13
|
|
|
13
14
|
import { Defaultstory, createCards } from './testing';
|
|
14
15
|
|
|
16
|
+
faker.seed(999);
|
|
17
|
+
|
|
15
18
|
const meta = {
|
|
16
19
|
title: 'plugins/plugin-preview/Card',
|
|
17
20
|
render: Defaultstory,
|
|
18
21
|
decorators: [
|
|
19
22
|
withTheme,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
classNames: 'flex flex-col justify-center',
|
|
23
|
-
}),
|
|
23
|
+
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
24
|
+
withPluginManager({ plugins: [IntentPlugin()] }),
|
|
24
25
|
],
|
|
25
|
-
parameters: {
|
|
26
|
+
parameters: {
|
|
27
|
+
translations,
|
|
28
|
+
},
|
|
26
29
|
tags: ['cards'],
|
|
27
30
|
} satisfies Meta<typeof Defaultstory>;
|
|
28
31
|
|
package/src/stories/testing.tsx
CHANGED
|
@@ -7,16 +7,14 @@ import React, { type FC } from 'react';
|
|
|
7
7
|
import { Obj, Ref } from '@dxos/echo';
|
|
8
8
|
import { faker } from '@dxos/random';
|
|
9
9
|
import { CardContainer } from '@dxos/react-ui-stack/testing';
|
|
10
|
-
import {
|
|
10
|
+
import { Organization, Person, Task } from '@dxos/types';
|
|
11
|
+
import { Project } from '@dxos/types';
|
|
11
12
|
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { type PreviewProps } from '../types';
|
|
13
|
+
import { OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
14
|
+
import { type CardPreviewProps } from '../types';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
type CardProps<T extends object> = {
|
|
19
|
-
Component: FC<PreviewProps<T>>;
|
|
16
|
+
type CardProps<T extends Obj.Any> = {
|
|
17
|
+
Component: FC<CardPreviewProps<T>>;
|
|
20
18
|
subject: T;
|
|
21
19
|
icon?: string;
|
|
22
20
|
image?: boolean;
|
|
@@ -29,14 +27,16 @@ export type DefaultstoryProps = {
|
|
|
29
27
|
|
|
30
28
|
export const Defaultstory = ({ role, cards }: DefaultstoryProps) => {
|
|
31
29
|
return (
|
|
32
|
-
<div className='
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
<div className='flex bs-full'>
|
|
31
|
+
<div className='flex shrink-0 gap-8 overflow-x-auto pbe-4'>
|
|
32
|
+
{cards.map(({ Component, icon, image, subject }, i) => (
|
|
33
|
+
<div key={i} className='flex is-[24rem] justify-center'>
|
|
34
|
+
<CardContainer icon={icon} role={role}>
|
|
35
|
+
<Component role={role} subject={image ? subject : omitImage(subject)} />
|
|
36
|
+
</CardContainer>
|
|
37
|
+
</div>
|
|
38
|
+
))}
|
|
39
|
+
</div>
|
|
40
40
|
</div>
|
|
41
41
|
);
|
|
42
42
|
};
|
|
@@ -45,7 +45,7 @@ export const omitImage = ({ image: _, ...rest }: any) => rest;
|
|
|
45
45
|
|
|
46
46
|
// TODO(burdon): Test data should exercise the standard data generators.
|
|
47
47
|
export const createCards = (image = true): CardProps<any>[] => {
|
|
48
|
-
const organization = Obj.make(
|
|
48
|
+
const organization = Obj.make(Organization.Organization, {
|
|
49
49
|
name: faker.company.name(),
|
|
50
50
|
image:
|
|
51
51
|
'https://plus.unsplash.com/premium_photo-1672116452571-896980a801c8?q=80&w=2671&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
|
|
@@ -53,7 +53,7 @@ export const createCards = (image = true): CardProps<any>[] => {
|
|
|
53
53
|
description: faker.lorem.paragraph(),
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
const contact = Obj.make(
|
|
56
|
+
const contact = Obj.make(Person.Person, {
|
|
57
57
|
fullName: faker.person.fullName(),
|
|
58
58
|
image:
|
|
59
59
|
'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',
|
|
@@ -74,13 +74,13 @@ export const createCards = (image = true): CardProps<any>[] => {
|
|
|
74
74
|
],
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
const project =
|
|
77
|
+
const project = Project.make({
|
|
78
78
|
name: faker.person.fullName(),
|
|
79
79
|
image: 'https://dxos.network/dxos-logotype-blue.png',
|
|
80
80
|
description: faker.lorem.paragraph(),
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
const task = Obj.make(
|
|
83
|
+
const task = Obj.make(Task.Task, {
|
|
84
84
|
title: faker.lorem.sentence(),
|
|
85
85
|
status: faker.helpers.arrayElement(['todo', 'in-progress', 'done']),
|
|
86
86
|
});
|
|
@@ -93,7 +93,7 @@ export const createCards = (image = true): CardProps<any>[] => {
|
|
|
93
93
|
image,
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
|
-
Component:
|
|
96
|
+
Component: PersonCard,
|
|
97
97
|
subject: contact,
|
|
98
98
|
icon: 'ph--user--regular',
|
|
99
99
|
image,
|
package/src/translations.ts
CHANGED
|
@@ -14,6 +14,9 @@ export const translations = [
|
|
|
14
14
|
'todo label': 'To do',
|
|
15
15
|
'in-progress label': 'In progress',
|
|
16
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
|
},
|
package/src/types.ts
CHANGED
|
@@ -2,10 +2,28 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Schema } from 'effect';
|
|
6
5
|
import { type PropsWithChildren } from 'react';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import { type SurfaceCardRole, type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
8
|
+
import { type Obj } from '@dxos/echo';
|
|
9
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use {@link SurfaceComponentProps} instead.
|
|
13
|
+
*/
|
|
14
|
+
// TODO(burdon): Remove?
|
|
15
|
+
export type CardPreviewProps<
|
|
16
|
+
Subject extends Obj.Any = Obj.Any,
|
|
17
|
+
Role extends SurfaceCardRole = SurfaceCardRole,
|
|
18
|
+
> = PropsWithChildren<
|
|
19
|
+
SurfaceComponentProps<
|
|
20
|
+
Subject,
|
|
21
|
+
{
|
|
22
|
+
// TODO(burdon): Why is this required (why active?)
|
|
23
|
+
activeSpace?: Space;
|
|
24
|
+
// TODO(burdon): Remove in favor of intents?
|
|
25
|
+
onSelect?: (obj: Obj.Any) => void;
|
|
26
|
+
},
|
|
27
|
+
Role
|
|
28
|
+
>
|
|
29
|
+
>;
|
|
@@ -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,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
|
-
}
|