@dxos/plugin-preview 0.8.4-main.70d3990 → 0.8.4-main.74a063c4e0

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.
Files changed (80) hide show
  1. package/dist/lib/browser/index.mjs +40 -45
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +41 -45
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/PreviewPlugin.d.ts +2 -1
  8. package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
  9. package/dist/types/src/capabilities/index.d.ts +3 -2
  10. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  11. package/dist/types/src/capabilities/preview-popover.d.ts +3 -2
  12. package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -1
  13. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  14. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  15. package/dist/types/src/cards/FormCard.d.ts +7 -0
  16. package/dist/types/src/cards/FormCard.d.ts.map +1 -0
  17. package/dist/types/src/cards/JsonCard.d.ts +5 -0
  18. package/dist/types/src/cards/JsonCard.d.ts.map +1 -0
  19. package/dist/types/src/cards/OrganizationCard.d.ts +2 -2
  20. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
  21. package/dist/types/src/cards/PersonCard.d.ts +2 -2
  22. package/dist/types/src/cards/PersonCard.d.ts.map +1 -1
  23. package/dist/types/src/cards/ProjectCard.d.ts +3 -3
  24. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
  25. package/dist/types/src/cards/TaskCard.d.ts +2 -2
  26. package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
  27. package/dist/types/src/cards/index.d.ts +2 -0
  28. package/dist/types/src/cards/index.d.ts.map +1 -1
  29. package/dist/types/src/index.d.ts +0 -1
  30. package/dist/types/src/index.d.ts.map +1 -1
  31. package/dist/types/src/meta.d.ts +2 -2
  32. package/dist/types/src/meta.d.ts.map +1 -1
  33. package/dist/types/src/stories/Card.stories.d.ts +20 -13
  34. package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
  35. package/dist/types/src/stories/testing.d.ts +13 -12
  36. package/dist/types/src/stories/testing.d.ts.map +1 -1
  37. package/dist/types/src/translations.d.ts +8 -8
  38. package/dist/types/src/translations.d.ts.map +1 -1
  39. package/dist/types/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +49 -35
  41. package/src/PreviewPlugin.tsx +14 -24
  42. package/src/capabilities/index.ts +3 -3
  43. package/src/capabilities/preview-popover.ts +66 -42
  44. package/src/capabilities/react-surface.tsx +101 -142
  45. package/src/cards/FormCard.tsx +48 -0
  46. package/src/cards/JsonCard.tsx +16 -0
  47. package/src/cards/OrganizationCard.tsx +11 -16
  48. package/src/cards/PersonCard.tsx +51 -49
  49. package/src/cards/ProjectCard.tsx +9 -11
  50. package/src/cards/TaskCard.tsx +24 -26
  51. package/src/cards/index.ts +2 -0
  52. package/src/index.ts +0 -1
  53. package/src/meta.ts +3 -3
  54. package/src/stories/Card.stories.tsx +69 -24
  55. package/src/stories/testing.tsx +55 -78
  56. package/src/translations.ts +8 -8
  57. package/dist/lib/browser/chunk-CEWM5LJG.mjs +0 -17
  58. package/dist/lib/browser/chunk-CEWM5LJG.mjs.map +0 -7
  59. package/dist/lib/browser/preview-popover-4QZ2WDE6.mjs +0 -65
  60. package/dist/lib/browser/preview-popover-4QZ2WDE6.mjs.map +0 -7
  61. package/dist/lib/browser/react-surface-X4KEMECS.mjs +0 -498
  62. package/dist/lib/browser/react-surface-X4KEMECS.mjs.map +0 -7
  63. package/dist/lib/node-esm/chunk-Q5MUNELK.mjs +0 -19
  64. package/dist/lib/node-esm/chunk-Q5MUNELK.mjs.map +0 -7
  65. package/dist/lib/node-esm/preview-popover-FJ2ARIGS.mjs +0 -67
  66. package/dist/lib/node-esm/preview-popover-FJ2ARIGS.mjs.map +0 -7
  67. package/dist/lib/node-esm/react-surface-DR3UAH6F.mjs +0 -499
  68. package/dist/lib/node-esm/react-surface-DR3UAH6F.mjs.map +0 -7
  69. package/dist/types/src/components/CardComponents.d.ts +0 -16
  70. package/dist/types/src/components/CardComponents.d.ts.map +0 -1
  71. package/dist/types/src/components/CardSubjectMenu.d.ts +0 -8
  72. package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
  73. package/dist/types/src/components/index.d.ts +0 -3
  74. package/dist/types/src/components/index.d.ts.map +0 -1
  75. package/dist/types/src/types.d.ts +0 -12
  76. package/dist/types/src/types.d.ts.map +0 -1
  77. package/src/components/CardComponents.tsx +0 -67
  78. package/src/components/CardSubjectMenu.tsx +0 -103
  79. package/src/components/index.ts +0 -6
  80. package/src/types.ts +0 -25
@@ -4,31 +4,26 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { Card } from '@dxos/react-ui-stack';
7
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
8
+ import { Card } from '@dxos/react-ui';
8
9
  import { type Organization } from '@dxos/types';
9
10
 
10
- import { CardHeader, CardLink } from '../components';
11
- import { type CardPreviewProps } from '../types';
12
-
13
- export const OrganizationCard = ({
14
- children,
15
- subject,
16
- role,
17
- activeSpace,
18
- }: CardPreviewProps<Organization.Organization>) => {
11
+ export const OrganizationCard = ({ subject }: AppSurface.ObjectCardProps<Organization.Organization>) => {
19
12
  const { name, image, description, website } = subject;
20
13
 
21
14
  return (
22
- <Card.SurfaceRoot id={subject.id} role={role}>
15
+ <Card.Content>
23
16
  <Card.Poster
24
17
  alt={name ?? ''}
25
18
  {...(image ? { image } : { icon: 'ph--building-office--regular' })}
26
19
  classNames={!image && 'opacity-50'}
27
20
  />
28
- <CardHeader label={name} subject={subject} activeSpace={activeSpace} />
29
- {description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
30
- {website && <CardLink label={website} href={website} />}
31
- {children}
32
- </Card.SurfaceRoot>
21
+ {description && (
22
+ <Card.Row>
23
+ <Card.Text variant='description'>{description}</Card.Text>
24
+ </Card.Row>
25
+ )}
26
+ {website && <Card.Link label={website} href={website} />}
27
+ </Card.Content>
33
28
  );
34
29
  };
@@ -2,62 +2,64 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React, { Fragment } from 'react';
5
+ import * as Effect from 'effect/Effect';
6
+ import React, { useCallback } from 'react';
6
7
 
7
- import { Avatar, Icon } from '@dxos/react-ui';
8
- import { Card, cardHeading, cardText } from '@dxos/react-ui-stack';
9
- import { mx } from '@dxos/react-ui-theme';
8
+ import { useOperationInvoker } from '@dxos/app-framework/ui';
9
+ import { LayoutOperation, getObjectPathFromObject, getSpacePath } from '@dxos/app-toolkit';
10
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
11
+ import { Obj } from '@dxos/echo';
12
+ import { runAndForwardErrors } from '@dxos/effect';
13
+ import { Avatar } from '@dxos/react-ui';
14
+ import { Card } from '@dxos/react-ui';
10
15
  import { type Person } from '@dxos/types';
11
16
 
12
- import { CardRow, CardSubjectMenu, gridRow } from '../components';
13
- import { type CardPreviewProps } from '../types';
17
+ export const PersonCard = ({ subject }: AppSurface.ObjectCardProps<Person.Person>) => {
18
+ const { invoke } = useOperationInvoker();
19
+ const { image, organization: { target: organization } = {}, emails = [] } = subject;
14
20
 
15
- export const PersonCard = ({ children, role, subject, activeSpace, onSelect }: CardPreviewProps<Person.Person>) => {
16
- const { fullName, image, organization: { target: organization } = {}, emails = [] } = subject;
21
+ const handleOrganizationClick = useCallback(() => {
22
+ if (!organization) {
23
+ return;
24
+ }
25
+
26
+ return Effect.gen(function* () {
27
+ const organizationPath = getObjectPathFromObject(organization);
28
+ const db = Obj.getDatabase(organization);
29
+ yield* invoke(LayoutOperation.UpdatePopover, { state: false, anchorId: '' });
30
+ yield* invoke(LayoutOperation.Open, {
31
+ subject: [organizationPath],
32
+ workspace: db ? getSpacePath(db.spaceId) : undefined,
33
+ });
34
+ }).pipe(runAndForwardErrors);
35
+ }, [invoke, organization]);
17
36
 
18
37
  return (
19
- <Card.SurfaceRoot id={subject.id} role={role}>
38
+ <Card.Content>
20
39
  <Avatar.Root>
21
- <Card.Text role='group' classNames={mx('grid gap-2 grid-cols-[1fr_min-content]')}>
22
- <div role='none' className={mx(gridRow, 'grid-rows-2')}>
23
- {activeSpace ? <CardSubjectMenu subject={subject} activeSpace={activeSpace} /> : <div />}
24
- <Avatar.Label asChild>
25
- <h2 className={mx(cardHeading, 'grow truncate')}>{fullName}</h2>
26
- </Avatar.Label>
27
- </div>
28
- <Avatar.Content
29
- imgSrc={image}
30
- icon='ph--user--regular'
31
- size={16}
32
- classNames={['text-subdued', !image && 'opacity-50']}
33
- hue='neutral'
34
- variant='square'
35
- />
36
- </Card.Text>
40
+ {image && (
41
+ <Card.Row className='py-1'>
42
+ <Avatar.Content
43
+ imgSrc={image}
44
+ icon='ph--user--regular'
45
+ size={20}
46
+ classNames={!image && 'opacity-50'}
47
+ hue='neutral'
48
+ variant='square'
49
+ />
50
+ </Card.Row>
51
+ )}
52
+ {organization?.name && (
53
+ <Card.Action icon='ph--buildings--regular' label={organization.name} onClick={handleOrganizationClick} />
54
+ )}
55
+ {emails.map(({ value }) => (
56
+ <Card.Row key={value} icon='ph--at--regular'>
57
+ <Card.Text truncate className='text-primary-text'>
58
+ {value}
59
+ </Card.Text>
60
+ </Card.Row>
61
+ ))}
37
62
  </Avatar.Root>
38
- {organization?.name && (
39
- <CardRow
40
- icon='ph--buildings--regular'
41
- label={organization.name}
42
- onClick={onSelect ? () => onSelect(organization) : undefined}
43
- />
44
- )}
45
- {emails.length > 0 && (
46
- <dl className={mx(cardText, gridRow, '[&_dt]:text-subdued [&_dt]:pbs-0.5 [&_dd]:min-is-0')}>
47
- {emails.map(({ label, value }) => (
48
- <Fragment key={value}>
49
- <dt>
50
- <span className='sr-only'>{label}</span>
51
- <Icon icon='ph--at--regular' size={5} />
52
- </dt>
53
- <dd key={value} className='col-span-2 break-words'>
54
- {value}
55
- </dd>
56
- </Fragment>
57
- ))}
58
- </dl>
59
- )}
60
- {children}
61
- </Card.SurfaceRoot>
63
+ </Card.Content>
62
64
  );
63
65
  };
@@ -4,21 +4,19 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
7
8
  import { Obj } from '@dxos/echo';
8
- import { Card } from '@dxos/react-ui-stack';
9
- import { type Project } from '@dxos/types';
9
+ import { Card } from '@dxos/react-ui';
10
+ import { type Pipeline } from '@dxos/types';
10
11
 
11
- import { CardHeader } from '../components';
12
- import { type CardPreviewProps } from '../types';
13
-
14
- export const ProjectCard = ({ subject, role, activeSpace }: CardPreviewProps<Project.Project>) => {
15
- const { name, image, description } = subject;
12
+ export const ProjectCard = ({ subject }: AppSurface.ObjectCardProps<Pipeline.Pipeline>) => {
13
+ const { image, description } = subject;
16
14
 
17
15
  return (
18
- <Card.SurfaceRoot id={subject.id} role={role}>
16
+ <Card.Content>
19
17
  {image && <Card.Poster image={image} alt={Obj.getLabel(subject) ?? ''} aspect='auto' />}
20
- <CardHeader label={name} subject={subject} activeSpace={activeSpace} />
21
- {description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
22
- </Card.SurfaceRoot>
18
+ {/* <CardHeader label={name} subject={subject} db={db} /> */}
19
+ {description && <Card.Text variant='description'>{description}</Card.Text>}
20
+ </Card.Content>
23
21
  );
24
22
  };
@@ -5,42 +5,40 @@
5
5
  import * as SchemaAST from 'effect/SchemaAST';
6
6
  import React from 'react';
7
7
 
8
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
8
9
  import { type PropertyMetaAnnotation, PropertyMetaAnnotationId } from '@dxos/echo/internal';
9
- import { Card, cardNoSpacing, cardSpacing } from '@dxos/react-ui-stack';
10
- import { mx } from '@dxos/react-ui-theme';
10
+ import { Card } from '@dxos/react-ui';
11
11
  import { Task } from '@dxos/types';
12
12
 
13
- import { CardSubjectMenu } from '../components';
14
- import { type CardPreviewProps } from '../types';
13
+ export const TaskCard = ({ subject }: AppSurface.ObjectCardProps<Task.Task>) => {
14
+ const { title, status } = subject;
15
+ const statusOption = getActiveStatusOption(status);
16
+
17
+ return (
18
+ <Card.Content>
19
+ <Card.Row>
20
+ {statusOption && (
21
+ <div>
22
+ <span className='dx-tag' data-hue={statusOption.color}>
23
+ {statusOption.title}
24
+ </span>
25
+ </div>
26
+ )}
27
+ </Card.Row>
28
+ </Card.Content>
29
+ );
30
+ };
15
31
 
16
32
  // TODO(thure): Should this move upstream as a helper? Is there an easier way to get options?
17
33
  const getActiveStatusOption = (status?: string) => {
18
34
  const properties = SchemaAST.getPropertySignatures(Task.Task.ast);
19
35
  const statusProperty = properties.find((p) => p.name === 'status');
36
+ // TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
20
37
  const statusMeta = SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(
21
- // TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
22
38
  (statusProperty!.type as any).types[0],
23
39
  );
24
- const options = // TODO(thure): Typescript asserts `statusMeta` doesn’t have `.value`, but in runtime it does.
25
- (statusMeta as any).value.singleSelect.options as { id: string; title: string; color: string }[];
26
- return options.find(({ id }) => id === status);
27
- };
28
40
 
29
- export const TaskCard = ({ subject, role, activeSpace }: CardPreviewProps<Task.Task>) => {
30
- const { title, status } = subject;
31
- const statusOption = getActiveStatusOption(status);
32
-
33
- return (
34
- <Card.SurfaceRoot id={subject.id} role={role}>
35
- <div role='none' className={mx('flex items-center gap-2', cardSpacing)}>
36
- <Card.Heading classNames={[cardNoSpacing, 'min-is-0 flex-1 truncate']}>{title}</Card.Heading>
37
- {statusOption && (
38
- <span className='dx-tag' data-hue={statusOption.color}>
39
- {statusOption.title}
40
- </span>
41
- )}
42
- <CardSubjectMenu subject={subject} activeSpace={activeSpace} />
43
- </div>
44
- </Card.SurfaceRoot>
45
- );
41
+ // TODO(thure): Typescript asserts `statusMeta` doesn’t have `.value`, but in runtime it does.
42
+ const options = (statusMeta as any).value.singleSelect.options as { id: string; title: string; color: string }[];
43
+ return options.find(({ id }) => id === status);
46
44
  };
@@ -2,6 +2,8 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ export * from './FormCard';
6
+ export * from './JsonCard';
5
7
  export * from './OrganizationCard';
6
8
  export * from './PersonCard';
7
9
  export * from './ProjectCard';
package/src/index.ts CHANGED
@@ -3,6 +3,5 @@
3
3
  //
4
4
 
5
5
  export * from './meta';
6
- export type * from './types';
7
6
 
8
7
  export * from './PreviewPlugin';
package/src/meta.ts CHANGED
@@ -2,11 +2,11 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type PluginMeta } from '@dxos/app-framework';
5
+ import { type Plugin } from '@dxos/app-framework';
6
6
  import { trim } from '@dxos/util';
7
7
 
8
- export const meta: PluginMeta = {
9
- id: 'dxos.org/plugin/preview',
8
+ export const meta: Plugin.Meta = {
9
+ id: 'org.dxos.plugin.preview',
10
10
  name: 'Preview',
11
11
  description: trim`
12
12
  Rich preview panel for viewing object content without opening full editors.
@@ -3,60 +3,105 @@
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 { faker } from '@dxos/random';
10
- import { withTheme } from '@dxos/react-ui/testing';
9
+ import { corePlugins } from '@dxos/plugin-testing';
10
+ import { random } from '@dxos/random';
11
+ import { Card } from '@dxos/react-ui';
12
+ import { withLayout } from '@dxos/react-ui/testing';
13
+ import { type Organization, type Person, type Pipeline, type Task } from '@dxos/types';
11
14
 
15
+ import { FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
12
16
  import { translations } from '../translations';
17
+ import { DefaultStory, createOrganization, createPerson, createProject, createTask } from './testing';
13
18
 
14
- import { Defaultstory, createCards } from './testing';
15
-
16
- faker.seed(999);
19
+ random.seed(999);
17
20
 
18
21
  const meta = {
19
- title: 'plugins/plugin-preview/Card',
20
- render: Defaultstory,
22
+ title: 'plugins/plugin-preview/cards/Card',
23
+ render: DefaultStory,
21
24
  decorators: [
22
- withTheme,
25
+ withLayout({ layout: 'fullscreen' }),
23
26
  // TODO(wittjosiah): Try to write story which does not depend on plugin manager.
24
- withPluginManager({ plugins: [IntentPlugin()] }),
27
+ withPluginManager({ plugins: corePlugins() }),
25
28
  ],
26
29
  parameters: {
30
+ layout: 'fullscreen',
27
31
  translations,
28
32
  },
29
33
  tags: ['cards'],
30
- } satisfies Meta<typeof Defaultstory>;
34
+ } satisfies Meta<typeof DefaultStory>;
31
35
 
32
36
  export default meta;
33
37
 
34
- type Story = StoryObj<typeof meta>;
38
+ export const _Form: StoryObj<typeof DefaultStory<Person.Person>> = {
39
+ args: {
40
+ Component: FormCard,
41
+ createObject: createPerson,
42
+ image: true,
43
+ },
44
+ };
35
45
 
36
- export const Popover: Story = {
46
+ export const _Person: StoryObj<typeof DefaultStory<Person.Person>> = {
37
47
  args: {
38
- role: 'card--popover',
39
- cards: createCards(),
48
+ Component: PersonCard,
49
+ createObject: createPerson,
50
+ image: true,
40
51
  },
41
52
  };
42
53
 
43
- export const Intrinsic: Story = {
54
+ export const _Organization: StoryObj<typeof DefaultStory<Organization.Organization>> = {
44
55
  args: {
45
- role: 'card--intrinsic',
46
- cards: createCards(),
56
+ Component: OrganizationCard,
57
+ createObject: createOrganization,
58
+ image: true,
47
59
  },
48
60
  };
49
61
 
50
- export const Extrinsic: Story = {
62
+ export const _Project: StoryObj<typeof DefaultStory<Pipeline.Pipeline>> = {
51
63
  args: {
52
- role: 'card--extrinsic',
53
- cards: createCards(),
64
+ Component: ProjectCard,
65
+ createObject: createProject,
66
+ image: true,
54
67
  },
55
68
  };
56
69
 
57
- export const ExtrinsicNoImage: Story = {
70
+ export const _Task: StoryObj<typeof DefaultStory<Task.Task>> = {
58
71
  args: {
59
- role: 'card--extrinsic',
60
- cards: createCards(false),
72
+ Component: TaskCard,
73
+ createObject: createTask,
74
+ image: true,
75
+ },
76
+ };
77
+
78
+ export const _Json = {
79
+ render: () => {
80
+ const data = {
81
+ subject: {
82
+ id: random.string.uuid(),
83
+ name: random.person.fullName(),
84
+ email: random.internet.email(),
85
+ tags: [random.lorem.word(), random.lorem.word(), random.lorem.word()],
86
+ nested: {
87
+ count: random.number.int({ max: 100 }),
88
+ active: random.datatype.boolean(),
89
+ },
90
+ },
91
+ };
92
+
93
+ return (
94
+ <div className='flex justify-center p-16'>
95
+ <div className='dx-card-min-width dx-card-max-width'>
96
+ <Card.Root>
97
+ <Card.Toolbar>
98
+ <Card.IconBlock />
99
+ <Card.Title>JSON</Card.Title>
100
+ </Card.Toolbar>
101
+ <JsonCard data={data} />
102
+ </Card.Root>
103
+ </div>
104
+ </div>
105
+ );
61
106
  },
62
107
  };
@@ -2,113 +2,90 @@
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 { faker } from '@dxos/random';
9
- import { CardContainer } from '@dxos/react-ui-stack/testing';
10
- import { Organization, Person, Task } from '@dxos/types';
11
- import { Project } from '@dxos/types';
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 { Organization, Person, Pipeline, Task } from '@dxos/types';
12
13
 
13
- import { OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
14
- import { type CardPreviewProps } from '../types';
15
-
16
- type CardProps<T extends Obj.Any> = {
17
- Component: FC<CardPreviewProps<T>>;
18
- subject: T;
19
- icon?: string;
14
+ export type DefaultStoryProps<T extends Obj.Any> = {
15
+ Component: FC<AppSurface.ObjectCardProps<T>>;
16
+ createObject: () => T;
20
17
  image?: boolean;
21
18
  };
22
19
 
23
- export type DefaultstoryProps = {
24
- role: 'card--popover' | 'card--intrinsic' | 'card--extrinsic' | 'card--transclusion';
25
- cards: CardProps<any>[];
26
- };
20
+ export const DefaultStory = <T extends Obj.Any>({ Component, createObject, image }: DefaultStoryProps<T>) => {
21
+ const object = useMemo(() => createObject(), [createObject]);
22
+ const roles: CardContainerProps['role'][] = ['intrinsic', 'popover'];
27
23
 
28
- export const Defaultstory = ({ role, cards }: DefaultstoryProps) => {
29
24
  return (
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)} />
25
+ <div className='h-full w-full grid grid-cols-2 py-16 gap-8'>
26
+ {roles.map((role, i) => (
27
+ <div key={i} className='flex h-full justify-center overflow-hidden'>
28
+ <div className='flex flex-col gap-4 w-full items-center'>
29
+ <span className='text-sm text-description'>{role}</span>
30
+ <CardContainer role={role}>
31
+ <Card.Root border={false}>
32
+ <Card.Toolbar>
33
+ <Card.DragHandle />
34
+ <Card.Title>{Obj.getLabel(object)}</Card.Title>
35
+ <Card.Menu />
36
+ </Card.Toolbar>
37
+ <Component role={role ?? 'card--content'} subject={image ? object : omitImage(object)} />
38
+ </Card.Root>
36
39
  </CardContainer>
37
40
  </div>
38
- ))}
39
- </div>
41
+ </div>
42
+ ))}
40
43
  </div>
41
44
  );
42
45
  };
43
46
 
44
47
  export const omitImage = ({ image: _, ...rest }: any) => rest;
45
48
 
46
- // TODO(burdon): Test data should exercise the standard data generators.
47
- export const createCards = (image = true): CardProps<any>[] => {
48
- const organization = Obj.make(Organization.Organization, {
49
- name: faker.company.name(),
49
+ /**
50
+ * Factory functions for creating test objects at render time.
51
+ */
52
+ export const createOrganization = (): Organization.Organization => {
53
+ return Obj.make(Organization.Organization, {
54
+ name: random.company.name(),
50
55
  image:
51
56
  'https://plus.unsplash.com/premium_photo-1672116452571-896980a801c8?q=80&w=2671&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
52
- website: faker.internet.url(),
53
- description: faker.lorem.paragraph(),
57
+ website: random.internet.url(),
58
+ description: random.lorem.paragraph(),
54
59
  });
60
+ };
55
61
 
56
- const contact = Obj.make(Person.Person, {
57
- fullName: faker.person.fullName(),
62
+ export const createPerson = (): Person.Person => {
63
+ const organization = createOrganization();
64
+ return Obj.make(Person.Person, {
65
+ fullName: random.person.fullName(),
58
66
  image:
59
67
  'https://plus.unsplash.com/premium_photo-1664536392779-049ba8fde933?q=80&w=2574&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
60
68
  organization: Ref.make(organization),
61
69
  emails: [
62
- {
63
- label: 'Work',
64
- value: faker.internet.email(),
65
- },
66
- {
67
- label: 'Work',
68
- value: faker.internet.email(),
69
- },
70
- {
71
- label: 'Work',
72
- value: faker.internet.email(),
73
- },
70
+ { label: 'Work', value: random.internet.email() },
71
+ { label: 'Work', value: random.internet.email() },
72
+ { label: 'Work', value: random.internet.email() },
74
73
  ],
75
74
  });
75
+ };
76
76
 
77
- const project = Project.make({
78
- name: faker.person.fullName(),
77
+ export const createProject = (): Pipeline.Pipeline => {
78
+ return Obj.make(Pipeline.Pipeline, {
79
+ name: random.person.fullName(),
79
80
  image: 'https://dxos.network/dxos-logotype-blue.png',
80
- description: faker.lorem.paragraph(),
81
+ description: random.lorem.paragraph(),
82
+ columns: [],
81
83
  });
84
+ };
82
85
 
83
- const task = Obj.make(Task.Task, {
84
- title: faker.lorem.sentence(),
85
- status: faker.helpers.arrayElement(['todo', 'in-progress', 'done']),
86
+ export const createTask = (): Task.Task => {
87
+ return Obj.make(Task.Task, {
88
+ title: random.lorem.sentence(),
89
+ status: random.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
86
90
  });
87
-
88
- return [
89
- {
90
- Component: OrganizationCard,
91
- subject: organization,
92
- icon: 'ph--building-office--regular',
93
- image,
94
- },
95
- {
96
- Component: PersonCard,
97
- subject: contact,
98
- icon: 'ph--user--regular',
99
- image,
100
- },
101
- {
102
- Component: ProjectCard,
103
- subject: project,
104
- icon: 'ph--building--regular',
105
- image,
106
- },
107
- {
108
- Component: TaskCard,
109
- subject: task,
110
- icon: 'ph--list-checks--regular',
111
- image,
112
- },
113
- ];
114
91
  };
@@ -4,19 +4,19 @@
4
4
 
5
5
  import { type Resource } from '@dxos/react-ui';
6
6
 
7
- import { meta } from './meta';
7
+ import { meta } from '#meta';
8
8
 
9
9
  export const translations = [
10
10
  {
11
11
  'en-US': {
12
12
  [meta.id]: {
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',
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,17 +0,0 @@
1
- // src/meta.ts
2
- import { trim } from "@dxos/util";
3
- var meta = {
4
- id: "dxos.org/plugin/preview",
5
- name: "Preview",
6
- description: trim`
7
- Rich preview panel for viewing object content without opening full editors.
8
- Quick peek at documents, images, and data with inline rendering.
9
- `,
10
- icon: "ph--eye--regular",
11
- source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview"
12
- };
13
-
14
- export {
15
- meta
16
- };
17
- //# sourceMappingURL=chunk-CEWM5LJG.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';\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
- }