@dxos/plugin-preview 0.8.4-main.ae835ea → 0.8.4-main.bcb3aa67d6

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 (83) hide show
  1. package/dist/lib/browser/index.mjs +41 -46
  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 +42 -46
  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 +3 -3
  20. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
  21. package/dist/types/src/cards/PersonCard.d.ts +5 -0
  22. package/dist/types/src/cards/PersonCard.d.ts.map +1 -0
  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 +3 -3
  26. package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
  27. package/dist/types/src/cards/index.d.ts +3 -1
  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 +19 -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 -34
  41. package/src/PreviewPlugin.tsx +15 -25
  42. package/src/capabilities/index.ts +3 -3
  43. package/src/capabilities/preview-popover.ts +66 -42
  44. package/src/capabilities/react-surface.tsx +103 -135
  45. package/src/cards/FormCard.tsx +48 -0
  46. package/src/cards/JsonCard.tsx +16 -0
  47. package/src/cards/OrganizationCard.tsx +17 -13
  48. package/src/cards/PersonCard.tsx +65 -0
  49. package/src/cards/ProjectCard.tsx +9 -11
  50. package/src/cards/TaskCard.tsx +26 -28
  51. package/src/cards/index.ts +3 -1
  52. package/src/index.ts +0 -1
  53. package/src/meta.ts +3 -3
  54. package/src/stories/Card.stories.tsx +67 -21
  55. package/src/stories/testing.tsx +47 -69
  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-RKHENTFP.mjs +0 -65
  60. package/dist/lib/browser/preview-popover-RKHENTFP.mjs.map +0 -7
  61. package/dist/lib/browser/react-surface-3AR3BFLF.mjs +0 -515
  62. package/dist/lib/browser/react-surface-3AR3BFLF.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-TZKX67EY.mjs +0 -67
  66. package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs.map +0 -7
  67. package/dist/lib/node-esm/react-surface-L37JR7U2.mjs +0 -516
  68. package/dist/lib/node-esm/react-surface-L37JR7U2.mjs.map +0 -7
  69. package/dist/types/src/cards/ContactCard.d.ts +0 -5
  70. package/dist/types/src/cards/ContactCard.d.ts.map +0 -1
  71. package/dist/types/src/components/CardComponents.d.ts +0 -16
  72. package/dist/types/src/components/CardComponents.d.ts.map +0 -1
  73. package/dist/types/src/components/CardSubjectMenu.d.ts +0 -8
  74. package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
  75. package/dist/types/src/components/index.d.ts +0 -3
  76. package/dist/types/src/components/index.d.ts.map +0 -1
  77. package/dist/types/src/types.d.ts +0 -10
  78. package/dist/types/src/types.d.ts.map +0 -1
  79. package/src/cards/ContactCard.tsx +0 -65
  80. package/src/components/CardComponents.tsx +0 -67
  81. package/src/components/CardSubjectMenu.tsx +0 -91
  82. package/src/components/index.ts +0 -6
  83. package/src/types.ts +0 -15
@@ -4,22 +4,26 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { Card } from '@dxos/react-ui-stack';
8
- import { type DataType } from '@dxos/schema';
7
+ import { type ObjectSurfaceProps } from '@dxos/app-toolkit/ui';
8
+ import { Card } from '@dxos/react-ui';
9
+ import { type Organization } from '@dxos/types';
9
10
 
10
- import { CardHeader, CardLink } from '../components';
11
- import { type PreviewProps } from '../types';
12
-
13
- export const OrganizationCard = ({ children, subject, role, activeSpace }: PreviewProps<DataType.Organization>) => {
11
+ export const OrganizationCard = ({ subject }: ObjectSurfaceProps<Organization.Organization>) => {
14
12
  const { name, image, description, website } = subject;
15
13
 
16
14
  return (
17
- <Card.SurfaceRoot role={role}>
18
- <Card.Poster alt={name ?? ''} {...(image ? { image } : { icon: 'ph--building-office--regular' })} />
19
- <CardHeader label={name} subject={subject} activeSpace={activeSpace} />
20
- {description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
21
- {website && <CardLink label={website} href={website} />}
22
- {children}
23
- </Card.SurfaceRoot>
15
+ <Card.Content>
16
+ <Card.Poster
17
+ alt={name ?? ''}
18
+ {...(image ? { image } : { icon: 'ph--building-office--regular' })}
19
+ classNames={!image && 'opacity-50'}
20
+ />
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>
24
28
  );
25
29
  };
@@ -0,0 +1,65 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+ import React, { useCallback } from 'react';
7
+
8
+ import { useOperationInvoker } from '@dxos/app-framework/ui';
9
+ import { LayoutOperation, getObjectPathFromObject, getSpacePath } from '@dxos/app-toolkit';
10
+ import { type ObjectSurfaceProps } 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';
15
+ import { type Person } from '@dxos/types';
16
+
17
+ export const PersonCard = ({ subject }: ObjectSurfaceProps<Person.Person>) => {
18
+ const { invoke } = useOperationInvoker();
19
+ const { image, organization: { target: organization } = {}, emails = [] } = subject;
20
+
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]);
36
+
37
+ return (
38
+ <Card.Content>
39
+ <Avatar.Root>
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
+ ))}
62
+ </Avatar.Root>
63
+ </Card.Content>
64
+ );
65
+ };
@@ -4,21 +4,19 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
+ import { type ObjectSurfaceProps } from '@dxos/app-toolkit/ui';
7
8
  import { Obj } from '@dxos/echo';
8
- import { Card } from '@dxos/react-ui-stack';
9
- import { type DataType } from '@dxos/schema';
9
+ import { Card } from '@dxos/react-ui';
10
+ import { type Pipeline } from '@dxos/types';
10
11
 
11
- import { CardHeader } from '../components';
12
- import { type PreviewProps } from '../types';
13
-
14
- export const ProjectCard = ({ subject, role, activeSpace }: PreviewProps<DataType.Project>) => {
15
- const { name, image, description } = subject;
12
+ export const ProjectCard = ({ subject }: ObjectSurfaceProps<Pipeline.Pipeline>) => {
13
+ const { image, description } = subject;
16
14
 
17
15
  return (
18
- <Card.SurfaceRoot 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 ObjectSurfaceProps } 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';
11
- import { DataType } from '@dxos/schema';
10
+ import { Card } from '@dxos/react-ui';
11
+ import { Task } from '@dxos/types';
12
12
 
13
- import { CardSubjectMenu } from '../components';
14
- import { type PreviewProps } from '../types';
13
+ export const TaskCard = ({ subject }: ObjectSurfaceProps<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
- const properties = SchemaAST.getPropertySignatures(DataType.Task.ast);
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 }: PreviewProps<DataType.Task>) => {
30
- const { title, status } = subject;
31
- const statusOption = getActiveStatusOption(status);
32
-
33
- return (
34
- <Card.SurfaceRoot 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,7 +2,9 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './ContactCard';
5
+ export * from './FormCard';
6
+ export * from './JsonCard';
6
7
  export * from './OrganizationCard';
8
+ export * from './PersonCard';
7
9
  export * from './ProjectCard';
8
10
  export * from './TaskCard';
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,106 @@
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 { corePlugins } from '@dxos/plugin-testing';
9
10
  import { faker } from '@dxos/random';
10
- import { withTheme } from '@dxos/react-ui/testing';
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';
13
17
 
14
- import { Defaultstory, createCards } from './testing';
18
+ import { DefaultStory, createOrganization, createPerson, createProject, createTask } from './testing';
15
19
 
16
20
  faker.seed(999);
17
21
 
18
22
  const meta = {
19
- title: 'plugins/plugin-preview/Card',
20
- render: Defaultstory,
23
+ title: 'plugins/plugin-preview/cards/Card',
24
+ render: DefaultStory,
21
25
  decorators: [
22
- withTheme, // TODO(wittjosiah): Try to write story which does not depend on plugin manager.
23
- withPluginManager({ plugins: [IntentPlugin()] }),
26
+ withLayout({ layout: 'fullscreen' }),
27
+ // TODO(wittjosiah): Try to write story which does not depend on plugin manager.
28
+ withPluginManager({ plugins: corePlugins() }),
24
29
  ],
25
30
  parameters: {
26
31
  layout: 'fullscreen',
27
32
  translations,
28
33
  },
29
34
  tags: ['cards'],
30
- } satisfies Meta<typeof Defaultstory>;
35
+ } satisfies Meta<typeof DefaultStory>;
31
36
 
32
37
  export default meta;
33
38
 
34
- type Story = StoryObj<typeof meta>;
39
+ export const _Form: StoryObj<typeof DefaultStory<Person.Person>> = {
40
+ args: {
41
+ Component: FormCard,
42
+ createObject: createPerson,
43
+ image: true,
44
+ },
45
+ };
35
46
 
36
- export const Popover: Story = {
47
+ export const _Person: StoryObj<typeof DefaultStory<Person.Person>> = {
37
48
  args: {
38
- role: 'card--popover',
39
- cards: createCards(),
49
+ Component: PersonCard,
50
+ createObject: createPerson,
51
+ image: true,
40
52
  },
41
53
  };
42
54
 
43
- export const Intrinsic: Story = {
55
+ export const _Organization: StoryObj<typeof DefaultStory<Organization.Organization>> = {
44
56
  args: {
45
- role: 'card--intrinsic',
46
- cards: createCards(),
57
+ Component: OrganizationCard,
58
+ createObject: createOrganization,
59
+ image: true,
47
60
  },
48
61
  };
49
62
 
50
- export const Extrinsic: Story = {
63
+ export const _Project: StoryObj<typeof DefaultStory<Pipeline.Pipeline>> = {
51
64
  args: {
52
- role: 'card--extrinsic',
53
- cards: createCards(),
65
+ Component: ProjectCard,
66
+ createObject: createProject,
67
+ image: true,
54
68
  },
55
69
  };
56
70
 
57
- export const ExtrinsicNoImage: Story = {
71
+ export const _Task: StoryObj<typeof DefaultStory<Task.Task>> = {
58
72
  args: {
59
- role: 'card--extrinsic',
60
- cards: createCards(false),
73
+ Component: TaskCard,
74
+ createObject: createTask,
75
+ image: true,
76
+ },
77
+ };
78
+
79
+ export const _Json = {
80
+ render: () => {
81
+ const data = {
82
+ subject: {
83
+ id: faker.string.uuid(),
84
+ name: faker.person.fullName(),
85
+ email: faker.internet.email(),
86
+ tags: [faker.lorem.word(), faker.lorem.word(), faker.lorem.word()],
87
+ nested: {
88
+ count: faker.number.int({ max: 100 }),
89
+ active: faker.datatype.boolean(),
90
+ },
91
+ },
92
+ };
93
+
94
+ return (
95
+ <div className='flex justify-center p-16'>
96
+ <div className='dx-card-min-width dx-card-max-width'>
97
+ <Card.Root>
98
+ <Card.Toolbar>
99
+ <Card.IconBlock />
100
+ <Card.Title>JSON</Card.Title>
101
+ </Card.Toolbar>
102
+ <JsonCard data={data} />
103
+ </Card.Root>
104
+ </div>
105
+ </div>
106
+ );
61
107
  },
62
108
  };
@@ -2,112 +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 ObjectSurfaceProps } from '@dxos/app-toolkit/ui';
7
8
  import { Obj, Ref } from '@dxos/echo';
8
9
  import { faker } from '@dxos/random';
9
- import { CardContainer } from '@dxos/react-ui-stack/testing';
10
- import { DataType } from '@dxos/schema';
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';
11
13
 
12
- import { ContactCard, OrganizationCard, ProjectCard, TaskCard } from '../cards';
13
- import { type PreviewProps } from '../types';
14
-
15
- type CardProps<T extends Obj.Any> = {
16
- Component: FC<PreviewProps<T>>;
17
- subject: T;
18
- icon?: string;
14
+ export type DefaultStoryProps<T extends Obj.Any> = {
15
+ Component: FC<ObjectSurfaceProps<T>>;
16
+ createObject: () => T;
19
17
  image?: boolean;
20
18
  };
21
19
 
22
- export type DefaultstoryProps = {
23
- role: 'card--popover' | 'card--intrinsic' | 'card--extrinsic' | 'card--transclusion';
24
- cards: CardProps<any>[];
25
- };
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'];
26
23
 
27
- export const Defaultstory = ({ role, cards }: DefaultstoryProps) => {
28
24
  return (
29
- <div className='flex bs-full'>
30
- <div className='flex shrink-0 gap-8 overflow-x-auto pbe-4'>
31
- {cards.map(({ Component, icon, image, subject }, i) => (
32
- <div key={i} className='flex is-[24rem] justify-center'>
33
- <CardContainer icon={icon} role={role}>
34
- <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} subject={image ? object : omitImage(object)} />
38
+ </Card.Root>
35
39
  </CardContainer>
36
40
  </div>
37
- ))}
38
- </div>
41
+ </div>
42
+ ))}
39
43
  </div>
40
44
  );
41
45
  };
42
46
 
43
47
  export const omitImage = ({ image: _, ...rest }: any) => rest;
44
48
 
45
- // TODO(burdon): Test data should exercise the standard data generators.
46
- export const createCards = (image = true): CardProps<any>[] => {
47
- const organization = Obj.make(DataType.Organization, {
49
+ /**
50
+ * Factory functions for creating test objects at render time.
51
+ */
52
+ export const createOrganization = (): Organization.Organization => {
53
+ return Obj.make(Organization.Organization, {
48
54
  name: faker.company.name(),
49
55
  image:
50
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',
51
57
  website: faker.internet.url(),
52
58
  description: faker.lorem.paragraph(),
53
59
  });
60
+ };
54
61
 
55
- const contact = Obj.make(DataType.Person, {
62
+ export const createPerson = (): Person.Person => {
63
+ const organization = createOrganization();
64
+ return Obj.make(Person.Person, {
56
65
  fullName: faker.person.fullName(),
57
66
  image:
58
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',
59
68
  organization: Ref.make(organization),
60
69
  emails: [
61
- {
62
- label: 'Work',
63
- value: faker.internet.email(),
64
- },
65
- {
66
- label: 'Work',
67
- value: faker.internet.email(),
68
- },
69
- {
70
- label: 'Work',
71
- value: faker.internet.email(),
72
- },
70
+ { label: 'Work', value: faker.internet.email() },
71
+ { label: 'Work', value: faker.internet.email() },
72
+ { label: 'Work', value: faker.internet.email() },
73
73
  ],
74
74
  });
75
+ };
75
76
 
76
- const project = DataType.makeProject({
77
+ export const createProject = (): Pipeline.Pipeline => {
78
+ return Obj.make(Pipeline.Pipeline, {
77
79
  name: faker.person.fullName(),
78
80
  image: 'https://dxos.network/dxos-logotype-blue.png',
79
81
  description: faker.lorem.paragraph(),
82
+ columns: [],
80
83
  });
84
+ };
81
85
 
82
- const task = Obj.make(DataType.Task, {
86
+ export const createTask = (): Task.Task => {
87
+ return Obj.make(Task.Task, {
83
88
  title: faker.lorem.sentence(),
84
- status: faker.helpers.arrayElement(['todo', 'in-progress', 'done']),
89
+ status: faker.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
85
90
  });
86
-
87
- return [
88
- {
89
- Component: OrganizationCard,
90
- subject: organization,
91
- icon: 'ph--building-office--regular',
92
- image,
93
- },
94
- {
95
- Component: ContactCard,
96
- subject: contact,
97
- icon: 'ph--user--regular',
98
- image,
99
- },
100
- {
101
- Component: ProjectCard,
102
- subject: project,
103
- icon: 'ph--building--regular',
104
- image,
105
- },
106
- {
107
- Component: TaskCard,
108
- subject: task,
109
- icon: 'ph--list-checks--regular',
110
- image,
111
- },
112
- ];
113
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
- }
@@ -1,65 +0,0 @@
1
- // src/capabilities/preview-popover.ts
2
- import { Capabilities, LayoutAction, contributes, createIntent } from "@dxos/app-framework";
3
- import { addEventListener } from "@dxos/async";
4
- import { parseId } from "@dxos/client/echo";
5
- import { DXN } from "@dxos/keys";
6
- import { log } from "@dxos/log";
7
- import { ClientCapabilities } from "@dxos/plugin-client";
8
- import { DX_ANCHOR_ACTIVATE } from "@dxos/react-ui";
9
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-preview/src/capabilities/preview-popover.ts";
10
- var customEventOptions = {
11
- capture: true,
12
- passive: false
13
- };
14
- var handlePreviewLookup = async (client, defaultSpace, { ref, label }) => {
15
- try {
16
- const object = await defaultSpace.db.ref(DXN.parse(ref)).load();
17
- return {
18
- label,
19
- object
20
- };
21
- } catch {
22
- return null;
23
- }
24
- };
25
- var preview_popover_default = ((context) => {
26
- const handleDxAnchorActivate = async ({ refId, label, trigger }) => {
27
- const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
28
- const client = context.getCapability(ClientCapabilities.Client);
29
- const [layout] = context.getCapabilities(Capabilities.Layout);
30
- const { spaceId } = parseId(layout.workspace);
31
- const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
32
- const result = await handlePreviewLookup(client, space, {
33
- ref: refId,
34
- label
35
- });
36
- if (!result) {
37
- return;
38
- }
39
- await dispatch(createIntent(LayoutAction.UpdatePopover, {
40
- part: "popover",
41
- subject: result.object,
42
- options: {
43
- state: true,
44
- variant: "virtual",
45
- anchor: trigger
46
- }
47
- }));
48
- };
49
- let cleanup;
50
- if (document.defaultView) {
51
- cleanup = addEventListener(document.defaultView, DX_ANCHOR_ACTIVATE, handleDxAnchorActivate, customEventOptions);
52
- } else {
53
- log.warn("No default view found", void 0, {
54
- F: __dxlog_file,
55
- L: 65,
56
- S: void 0,
57
- C: (f, a) => f(...a)
58
- });
59
- }
60
- return contributes(Capabilities.Null, null, () => cleanup());
61
- });
62
- export {
63
- preview_popover_default as default
64
- };
65
- //# sourceMappingURL=preview-popover-RKHENTFP.mjs.map