@dxos/plugin-preview 0.8.2-main.10c050d
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 +8 -0
- package/README.md +1 -0
- package/dist/lib/browser/chunk-B2VK6GFP.mjs +28 -0
- package/dist/lib/browser/chunk-B2VK6GFP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +72 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/preview-popover-S3OY3CFZ.mjs +65 -0
- package/dist/lib/browser/preview-popover-S3OY3CFZ.mjs.map +7 -0
- package/dist/lib/browser/react-surface-XDHP6EN7.mjs +285 -0
- package/dist/lib/browser/react-surface-XDHP6EN7.mjs.map +7 -0
- package/dist/lib/node/chunk-VFSOM2B4.cjs +55 -0
- package/dist/lib/node/chunk-VFSOM2B4.cjs.map +7 -0
- package/dist/lib/node/index.cjs +97 -0
- package/dist/lib/node/index.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -0
- package/dist/lib/node/preview-popover-GPBOHU5E.cjs +84 -0
- package/dist/lib/node/preview-popover-GPBOHU5E.cjs.map +7 -0
- package/dist/lib/node/react-surface-CPAQ7ZYR.cjs +297 -0
- package/dist/lib/node/react-surface-CPAQ7ZYR.cjs.map +7 -0
- package/dist/lib/node-esm/chunk-PYKIS3N7.mjs +30 -0
- package/dist/lib/node-esm/chunk-PYKIS3N7.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +73 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/preview-popover-EQAEYYDT.mjs +67 -0
- package/dist/lib/node-esm/preview-popover-EQAEYYDT.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-QJRHN4PN.mjs +286 -0
- package/dist/lib/node-esm/react-surface-QJRHN4PN.mjs.map +7 -0
- package/dist/types/src/Preview.stories.d.ts +141 -0
- package/dist/types/src/Preview.stories.d.ts.map +1 -0
- package/dist/types/src/PreviewPlugin.d.ts +2 -0
- package/dist/types/src/PreviewPlugin.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +3 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/preview-popover.d.ts +4 -0
- package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/ContactCard.d.ts +7 -0
- package/dist/types/src/components/ContactCard.d.ts.map +1 -0
- package/dist/types/src/components/OrganizationCard.d.ts +5 -0
- package/dist/types/src/components/OrganizationCard.d.ts.map +1 -0
- package/dist/types/src/components/ProjectCard.d.ts +5 -0
- package/dist/types/src/components/ProjectCard.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +4 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +4 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +9 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +25 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +61 -0
- package/src/Preview.stories.tsx +145 -0
- package/src/PreviewPlugin.tsx +35 -0
- package/src/capabilities/index.ts +8 -0
- package/src/capabilities/preview-popover.ts +65 -0
- package/src/capabilities/react-surface.tsx +126 -0
- package/src/components/ContactCard.tsx +70 -0
- package/src/components/OrganizationCard.tsx +48 -0
- package/src/components/ProjectCard.tsx +24 -0
- package/src/components/index.ts +7 -0
- package/src/index.ts +8 -0
- package/src/meta.ts +14 -0
- package/src/translations.ts +15 -0
- package/src/types.ts +40 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Capabilities, LayoutAction, contributes, createIntent, type PluginContext } from '@dxos/app-framework';
|
|
6
|
+
import { addEventListener } from '@dxos/async';
|
|
7
|
+
import { type Client, resolveRef } from '@dxos/client';
|
|
8
|
+
import { parseId, type Space } from '@dxos/client/echo';
|
|
9
|
+
import { DXN } from '@dxos/keys';
|
|
10
|
+
import { type DxRefTagActivate } from '@dxos/lit-ui';
|
|
11
|
+
import { log } from '@dxos/log';
|
|
12
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
13
|
+
import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';
|
|
14
|
+
|
|
15
|
+
const customEventOptions = { capture: true, passive: false };
|
|
16
|
+
|
|
17
|
+
const handlePreviewLookup = async (
|
|
18
|
+
client: Client,
|
|
19
|
+
defaultSpace: Space,
|
|
20
|
+
{ ref, label }: PreviewLinkRef,
|
|
21
|
+
): Promise<PreviewLinkTarget | null> => {
|
|
22
|
+
const dxn = DXN.parse(ref);
|
|
23
|
+
if (!dxn) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const object = await resolveRef(client, dxn, defaultSpace);
|
|
28
|
+
return { label, object };
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default (context: PluginContext) => {
|
|
32
|
+
// TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
|
|
33
|
+
const handleDxRefTagActivate = async ({ refId, label, trigger }: DxRefTagActivate) => {
|
|
34
|
+
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
35
|
+
const client = context.getCapability(ClientCapabilities.Client);
|
|
36
|
+
const [layout] = context.getCapabilities(Capabilities.Layout);
|
|
37
|
+
const { spaceId } = parseId(layout.workspace);
|
|
38
|
+
const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
|
|
39
|
+
const result = await handlePreviewLookup(client, space, { ref: refId, label });
|
|
40
|
+
if (!result) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
await dispatch(
|
|
45
|
+
createIntent(LayoutAction.UpdatePopover, {
|
|
46
|
+
part: 'popover',
|
|
47
|
+
subject: result.object,
|
|
48
|
+
options: {
|
|
49
|
+
state: true,
|
|
50
|
+
variant: 'virtual',
|
|
51
|
+
anchor: trigger,
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
let cleanup: () => void;
|
|
58
|
+
if (document.defaultView) {
|
|
59
|
+
cleanup = addEventListener(document.defaultView, 'dx-ref-tag-activate', handleDxRefTagActivate, customEventOptions);
|
|
60
|
+
} else {
|
|
61
|
+
log.warn('No default view found');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return contributes(Capabilities.Null, null, () => cleanup());
|
|
65
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
Capabilities,
|
|
9
|
+
LayoutAction,
|
|
10
|
+
Surface,
|
|
11
|
+
contributes,
|
|
12
|
+
createIntent,
|
|
13
|
+
createSurface,
|
|
14
|
+
useIntentDispatcher,
|
|
15
|
+
} from '@dxos/app-framework';
|
|
16
|
+
import { Filter, fullyQualifiedId, getSchema, getSpace, isEchoObject, type AnyLiveObject } from '@dxos/client/echo';
|
|
17
|
+
import { isInstanceOf, type JsonPath, setValue } from '@dxos/echo-schema';
|
|
18
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
19
|
+
import { Form } from '@dxos/react-ui-form';
|
|
20
|
+
import { TableType } from '@dxos/react-ui-table';
|
|
21
|
+
import { descriptionMessage } from '@dxos/react-ui-theme';
|
|
22
|
+
import { DataType } from '@dxos/schema';
|
|
23
|
+
|
|
24
|
+
import { ContactCard, OrganizationCard, ProjectCard } from '../components';
|
|
25
|
+
import { PREVIEW_PLUGIN } from '../meta';
|
|
26
|
+
import { kanbanCardWithoutPoster } from '../types';
|
|
27
|
+
|
|
28
|
+
export default () =>
|
|
29
|
+
contributes(Capabilities.ReactSurface, [
|
|
30
|
+
//
|
|
31
|
+
// Specific schema types.
|
|
32
|
+
//
|
|
33
|
+
createSurface({
|
|
34
|
+
id: `${PREVIEW_PLUGIN}/schema-popover--contact`,
|
|
35
|
+
role: ['popover', 'card--kanban', 'card'],
|
|
36
|
+
filter: (data): data is { subject: DataType.Person } => isInstanceOf(DataType.Person, data.subject),
|
|
37
|
+
component: ({ data, role }) => {
|
|
38
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
39
|
+
const handleOrgClick = useCallback(
|
|
40
|
+
async (org: DataType.Organization) => {
|
|
41
|
+
const space = getSpace(org);
|
|
42
|
+
const tablesQuery = await space?.db.query(Filter.type(TableType)).run();
|
|
43
|
+
const currentSpaceOrgTable = tablesQuery?.objects.find((table) => {
|
|
44
|
+
return table.view?.target?.query?.typename === DataType.Organization.typename;
|
|
45
|
+
});
|
|
46
|
+
await dispatch(
|
|
47
|
+
createIntent(LayoutAction.UpdatePopover, {
|
|
48
|
+
part: 'popover',
|
|
49
|
+
options: {
|
|
50
|
+
state: false,
|
|
51
|
+
anchorId: '',
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
55
|
+
if (currentSpaceOrgTable) {
|
|
56
|
+
return dispatch(
|
|
57
|
+
createIntent(LayoutAction.Open, {
|
|
58
|
+
part: 'main',
|
|
59
|
+
subject: [fullyQualifiedId(currentSpaceOrgTable)],
|
|
60
|
+
options: { workspace: space?.id },
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
[dispatch],
|
|
66
|
+
);
|
|
67
|
+
return (
|
|
68
|
+
<ContactCard subject={data.subject} onOrgClick={handleOrgClick} role={role}>
|
|
69
|
+
{role === 'popover' && <Surface role='related' data={data} />}
|
|
70
|
+
</ContactCard>
|
|
71
|
+
);
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
createSurface({
|
|
75
|
+
id: `${PREVIEW_PLUGIN}/schema-popover--organization`,
|
|
76
|
+
role: ['popover', 'card--kanban', 'card'],
|
|
77
|
+
filter: (data): data is { subject: DataType.Organization } => isInstanceOf(DataType.Organization, data.subject),
|
|
78
|
+
component: ({ data, role }) => (
|
|
79
|
+
<OrganizationCard subject={data.subject} role={role}>
|
|
80
|
+
{role === 'popover' && <Surface role='related' data={data} />}
|
|
81
|
+
</OrganizationCard>
|
|
82
|
+
),
|
|
83
|
+
}),
|
|
84
|
+
createSurface({
|
|
85
|
+
id: `${PREVIEW_PLUGIN}/schema-popover--project`,
|
|
86
|
+
role: ['popover', 'card--kanban', 'card'],
|
|
87
|
+
filter: (data): data is { subject: DataType.Project } => isInstanceOf(DataType.Project, data.subject),
|
|
88
|
+
component: ({ data, role }) => <ProjectCard subject={data.subject} role={role} />,
|
|
89
|
+
}),
|
|
90
|
+
|
|
91
|
+
//
|
|
92
|
+
// Fallback for any object.
|
|
93
|
+
//
|
|
94
|
+
createSurface({
|
|
95
|
+
id: `${PREVIEW_PLUGIN}/fallback-popover`,
|
|
96
|
+
role: ['popover', 'card--kanban', 'card'],
|
|
97
|
+
position: 'fallback',
|
|
98
|
+
filter: (data): data is { subject: AnyLiveObject<any> } => isEchoObject(data.subject),
|
|
99
|
+
component: ({ data, role }) => {
|
|
100
|
+
const schema = getSchema(data.subject);
|
|
101
|
+
const { t } = useTranslation(PREVIEW_PLUGIN);
|
|
102
|
+
if (!schema) {
|
|
103
|
+
return <p className={descriptionMessage}>{t('unable to create preview message')}</p>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
|
|
107
|
+
const changedPaths = Object.keys(changed).filter((path) => changed[path]);
|
|
108
|
+
for (const path of changedPaths) {
|
|
109
|
+
const value = values[path];
|
|
110
|
+
setValue(data.subject, path as JsonPath, value);
|
|
111
|
+
}
|
|
112
|
+
}, []);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<Form
|
|
116
|
+
schema={schema}
|
|
117
|
+
values={data.subject}
|
|
118
|
+
readonly={role === 'popover'}
|
|
119
|
+
onSave={handleSave}
|
|
120
|
+
autoSave
|
|
121
|
+
{...(role === 'card--kanban' && { classNames: kanbanCardWithoutPoster })}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
},
|
|
125
|
+
}),
|
|
126
|
+
]);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { Fragment } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Icon, Avatar, Button } from '@dxos/react-ui';
|
|
8
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
9
|
+
import { type DataType } from '@dxos/schema';
|
|
10
|
+
|
|
11
|
+
import { type PreviewProps, popoverCard, previewTitle, previewProse, previewChrome, defaultCard } from '../types';
|
|
12
|
+
|
|
13
|
+
export const ContactCard = ({
|
|
14
|
+
children,
|
|
15
|
+
classNames,
|
|
16
|
+
role,
|
|
17
|
+
subject: { fullName, image, organization, emails },
|
|
18
|
+
onOrgClick,
|
|
19
|
+
}: PreviewProps<DataType.Person> & { onOrgClick?: (org: DataType.Organization) => void }) => {
|
|
20
|
+
const organizationName = organization && typeof organization === 'object' ? organization.target?.name : organization;
|
|
21
|
+
return (
|
|
22
|
+
<div role='none' className={mx(role === 'popover' ? popoverCard : defaultCard, classNames)}>
|
|
23
|
+
<Avatar.Root>
|
|
24
|
+
<div role='group' className={mx(previewProse, 'grid gap-3 grid-cols-[min-content_1fr]')}>
|
|
25
|
+
<Avatar.Content imgSrc={image} icon='ph--user--regular' size={16} hue='neutral' />
|
|
26
|
+
<div role='none' className='bs-min self-center'>
|
|
27
|
+
<Avatar.Label asChild>
|
|
28
|
+
<h2 className={previewTitle}>{fullName}</h2>
|
|
29
|
+
</Avatar.Label>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</Avatar.Root>
|
|
33
|
+
{organizationName && (
|
|
34
|
+
<div role='none' className={previewChrome}>
|
|
35
|
+
{typeof organization === 'object' && onOrgClick ? (
|
|
36
|
+
<Button variant='ghost' classNames='gap-2 text-start' onClick={() => onOrgClick(organization.target!)}>
|
|
37
|
+
<Icon icon='ph--buildings--regular' size={5} classNames='text-subdued' />
|
|
38
|
+
<span className='min-is-0 flex-1 truncate'>{organizationName}</span>
|
|
39
|
+
<Icon icon='ph--arrow-right--regular' />
|
|
40
|
+
</Button>
|
|
41
|
+
) : (
|
|
42
|
+
<p className='dx-button gap-2' data-variant='ghost'>
|
|
43
|
+
<Icon icon='ph--buildings--regular' size={5} classNames='text-subdued' />
|
|
44
|
+
<span className='min-is-0 flex-1 truncate'>{organizationName}</span>
|
|
45
|
+
</p>
|
|
46
|
+
)}
|
|
47
|
+
</div>
|
|
48
|
+
)}
|
|
49
|
+
<dl
|
|
50
|
+
className={mx(
|
|
51
|
+
previewProse,
|
|
52
|
+
'grid gap-2 grid-cols-[min-content_1fr] [&_dt]:text-subdued [&_dt]:pbs-0.5 [&_dd]:min-is-0',
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
55
|
+
{emails?.length &&
|
|
56
|
+
emails.map(({ label, value }) => (
|
|
57
|
+
<Fragment key={value}>
|
|
58
|
+
<dt>
|
|
59
|
+
<Icon icon='ph--at--regular' size={5} />
|
|
60
|
+
</dt>
|
|
61
|
+
<dd key={value} className='break-words'>
|
|
62
|
+
{value}
|
|
63
|
+
</dd>
|
|
64
|
+
</Fragment>
|
|
65
|
+
))}
|
|
66
|
+
</dl>
|
|
67
|
+
{children}
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Icon } from '@dxos/react-ui';
|
|
8
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
9
|
+
import { type DataType } from '@dxos/schema';
|
|
10
|
+
|
|
11
|
+
import { type PreviewProps, popoverCard, previewTitle, previewProse, previewChrome, defaultCard } from '../types';
|
|
12
|
+
|
|
13
|
+
export const OrganizationCard = ({
|
|
14
|
+
children,
|
|
15
|
+
classNames,
|
|
16
|
+
subject: { name, image, description, website },
|
|
17
|
+
role,
|
|
18
|
+
}: PreviewProps<DataType.Organization>) => {
|
|
19
|
+
return (
|
|
20
|
+
<div role='none' className={mx(role === 'popover' ? popoverCard : defaultCard, classNames)}>
|
|
21
|
+
{image ? (
|
|
22
|
+
<img className='aspect-video object-cover is-full bs-auto' src={image} alt={name} />
|
|
23
|
+
) : (
|
|
24
|
+
<div role='image' className='grid aspect-video place-items-center bg-inputSurface text-subdued'>
|
|
25
|
+
<Icon icon='ph--building-office--regular' size={10} />
|
|
26
|
+
</div>
|
|
27
|
+
)}
|
|
28
|
+
<h2 className={mx(previewTitle, previewProse)}>{name}</h2>
|
|
29
|
+
{description && <p className={mx(previewProse, 'line-clamp-2')}>{description}</p>}
|
|
30
|
+
{website && (
|
|
31
|
+
<div role='none' className={previewChrome}>
|
|
32
|
+
<a
|
|
33
|
+
className='dx-button dx-focus-ring gap-2'
|
|
34
|
+
data-variant='ghost'
|
|
35
|
+
href={website}
|
|
36
|
+
target='_blank'
|
|
37
|
+
rel='noreferrer'
|
|
38
|
+
>
|
|
39
|
+
<Icon icon='ph--link--regular' size={5} classNames='text-subdued' />
|
|
40
|
+
<span className='grow'>{website}</span>
|
|
41
|
+
<Icon icon='ph--arrow-square-out--regular' />
|
|
42
|
+
</a>
|
|
43
|
+
</div>
|
|
44
|
+
)}
|
|
45
|
+
{children}
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
8
|
+
import { type DataType } from '@dxos/schema';
|
|
9
|
+
|
|
10
|
+
import { type PreviewProps, popoverCard, previewTitle, defaultCard } from '../types';
|
|
11
|
+
|
|
12
|
+
export const ProjectCard = ({
|
|
13
|
+
classNames,
|
|
14
|
+
role,
|
|
15
|
+
subject: { name, image, description },
|
|
16
|
+
}: PreviewProps<DataType.Project>) => {
|
|
17
|
+
return (
|
|
18
|
+
<div role='none' className={mx(role === 'popover' ? popoverCard : defaultCard, classNames)}>
|
|
19
|
+
{image && <img className='is-full bs-auto' src={image} alt={name} />}
|
|
20
|
+
<h2 className={mx(previewTitle, 'pli-3 mlb-3')}>{name}</h2>
|
|
21
|
+
{description && <p className='pli-3 line-clamp-2 mlb-3'>{description}</p>}
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
};
|
package/src/index.ts
ADDED
package/src/meta.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
export const PREVIEW_PLUGIN = 'dxos.org/plugin/preview';
|
|
8
|
+
|
|
9
|
+
export const meta: PluginMeta = {
|
|
10
|
+
id: PREVIEW_PLUGIN,
|
|
11
|
+
name: 'Preview',
|
|
12
|
+
icon: 'ph--eye--regular',
|
|
13
|
+
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',
|
|
14
|
+
};
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type PropsWithChildren } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
8
|
+
|
|
9
|
+
// TODO(burdon): Better place for these defs?
|
|
10
|
+
export type PreviewProps<T extends object> = PropsWithChildren<
|
|
11
|
+
ThemedClassName<{
|
|
12
|
+
subject: T;
|
|
13
|
+
role: string;
|
|
14
|
+
}>
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
// TODO(burdon): Update react-ui-card (to use grid) and re-use here.
|
|
18
|
+
// - See https://dxos-storybook.pages.dev/?path=/story/ui-react-ui-card-card--draggable
|
|
19
|
+
// - Standardize Header, actions, image, body, etc.
|
|
20
|
+
// - Support different grid layouts (e.g., image to the side, on top, etc.)
|
|
21
|
+
// - Should co-exist naturally with react-ui-form (e.g., as main content).
|
|
22
|
+
// - Considerations for drag-and-drop.
|
|
23
|
+
/**
|
|
24
|
+
* <Card.Root>
|
|
25
|
+
* <Card.Header>
|
|
26
|
+
* <Card.Title>
|
|
27
|
+
* <Card.Action>
|
|
28
|
+
* </Card.Header>
|
|
29
|
+
* <Card.Body>
|
|
30
|
+
* <Card.Image>
|
|
31
|
+
* <Form />
|
|
32
|
+
* </Card.Body>
|
|
33
|
+
* </Card.Root>
|
|
34
|
+
*/
|
|
35
|
+
export const popoverCard = 'popover-card-width rounded-lg overflow-hidden';
|
|
36
|
+
export const defaultCard = '';
|
|
37
|
+
export const kanbanCardWithoutPoster = 'pbs-[--rail-action]';
|
|
38
|
+
export const previewTitle = 'text-lg font-medium line-clamp-2';
|
|
39
|
+
export const previewProse = 'pli-3 mlb-3';
|
|
40
|
+
export const previewChrome = 'pli-1.5 mlb-1.5 [&_.dx-button]:pli-1.5 [&_.dx-button]:text-start [&_.dx-button]:is-full';
|