@dxos/plugin-preview 0.8.4-main.67995b8 → 0.8.4-main.ae835ea

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 (101) hide show
  1. package/dist/lib/browser/chunk-CEWM5LJG.mjs +17 -0
  2. package/dist/lib/browser/chunk-CEWM5LJG.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +11 -7
  4. package/dist/lib/browser/index.mjs.map +2 -2
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/{preview-popover-2UCEZUQW.mjs → preview-popover-RKHENTFP.mjs} +9 -13
  7. package/dist/lib/browser/preview-popover-RKHENTFP.mjs.map +7 -0
  8. package/dist/lib/browser/react-surface-3AR3BFLF.mjs +515 -0
  9. package/dist/lib/browser/react-surface-3AR3BFLF.mjs.map +7 -0
  10. package/dist/lib/node-esm/chunk-Q5MUNELK.mjs +19 -0
  11. package/dist/lib/node-esm/chunk-Q5MUNELK.mjs.map +7 -0
  12. package/dist/lib/node-esm/index.mjs +11 -7
  13. package/dist/lib/node-esm/index.mjs.map +2 -2
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/{preview-popover-OSHWR2YE.mjs → preview-popover-TZKX67EY.mjs} +9 -13
  16. package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs.map +7 -0
  17. package/dist/lib/node-esm/react-surface-L37JR7U2.mjs +516 -0
  18. package/dist/lib/node-esm/react-surface-L37JR7U2.mjs.map +7 -0
  19. package/dist/types/src/PreviewPlugin.d.ts +1 -1
  20. package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
  21. package/dist/types/src/capabilities/index.d.ts +2 -2
  22. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  23. package/dist/types/src/capabilities/preview-popover.d.ts +1 -1
  24. package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -1
  25. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  26. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  27. package/dist/types/src/cards/ContactCard.d.ts +5 -0
  28. package/dist/types/src/cards/ContactCard.d.ts.map +1 -0
  29. package/dist/types/src/cards/OrganizationCard.d.ts +5 -0
  30. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -0
  31. package/dist/types/src/cards/ProjectCard.d.ts +5 -0
  32. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -0
  33. package/dist/types/src/cards/TaskCard.d.ts +5 -0
  34. package/dist/types/src/cards/TaskCard.d.ts.map +1 -0
  35. package/dist/types/src/cards/index.d.ts +5 -0
  36. package/dist/types/src/cards/index.d.ts.map +1 -0
  37. package/dist/types/src/components/CardComponents.d.ts +16 -0
  38. package/dist/types/src/components/CardComponents.d.ts.map +1 -0
  39. package/dist/types/src/components/CardSubjectMenu.d.ts +8 -0
  40. package/dist/types/src/components/CardSubjectMenu.d.ts.map +1 -0
  41. package/dist/types/src/components/index.d.ts +2 -3
  42. package/dist/types/src/components/index.d.ts.map +1 -1
  43. package/dist/types/src/meta.d.ts +0 -1
  44. package/dist/types/src/meta.d.ts.map +1 -1
  45. package/dist/types/src/stories/Card.stories.d.ts +30 -0
  46. package/dist/types/src/stories/Card.stories.d.ts.map +1 -0
  47. package/dist/types/src/stories/testing.d.ts +18 -0
  48. package/dist/types/src/stories/testing.d.ts.map +1 -0
  49. package/dist/types/src/translations.d.ts +6 -0
  50. package/dist/types/src/translations.d.ts.map +1 -1
  51. package/dist/types/src/types.d.ts +5 -1
  52. package/dist/types/src/types.d.ts.map +1 -1
  53. package/dist/types/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +34 -31
  55. package/src/PreviewPlugin.tsx +22 -23
  56. package/src/capabilities/preview-popover.ts +9 -14
  57. package/src/capabilities/react-surface.tsx +65 -79
  58. package/src/cards/ContactCard.tsx +65 -0
  59. package/src/cards/OrganizationCard.tsx +25 -0
  60. package/src/cards/ProjectCard.tsx +24 -0
  61. package/src/cards/TaskCard.tsx +46 -0
  62. package/src/cards/index.ts +8 -0
  63. package/src/components/CardComponents.tsx +67 -0
  64. package/src/components/CardSubjectMenu.tsx +91 -0
  65. package/src/components/index.ts +2 -3
  66. package/src/meta.ts +6 -3
  67. package/src/stories/Card.stories.tsx +62 -0
  68. package/src/stories/testing.tsx +113 -0
  69. package/src/translations.ts +6 -0
  70. package/src/types.ts +6 -2
  71. package/dist/lib/browser/chunk-Z73ENKLE.mjs +0 -14
  72. package/dist/lib/browser/chunk-Z73ENKLE.mjs.map +0 -7
  73. package/dist/lib/browser/preview-popover-2UCEZUQW.mjs.map +0 -7
  74. package/dist/lib/browser/react-surface-CZMUEWPV.mjs +0 -303
  75. package/dist/lib/browser/react-surface-CZMUEWPV.mjs.map +0 -7
  76. package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs +0 -16
  77. package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs.map +0 -7
  78. package/dist/lib/node-esm/preview-popover-OSHWR2YE.mjs.map +0 -7
  79. package/dist/lib/node-esm/react-surface-IPZBISWS.mjs +0 -304
  80. package/dist/lib/node-esm/react-surface-IPZBISWS.mjs.map +0 -7
  81. package/dist/types/src/components/ContactCard.d.ts +0 -7
  82. package/dist/types/src/components/ContactCard.d.ts.map +0 -1
  83. package/dist/types/src/components/OrganizationCard.d.ts +0 -5
  84. package/dist/types/src/components/OrganizationCard.d.ts.map +0 -1
  85. package/dist/types/src/components/ProjectCard.d.ts +0 -5
  86. package/dist/types/src/components/ProjectCard.d.ts.map +0 -1
  87. package/dist/types/src/testing/ExtrinsicPreviews.stories.d.ts +0 -35
  88. package/dist/types/src/testing/ExtrinsicPreviews.stories.d.ts.map +0 -1
  89. package/dist/types/src/testing/IntrinsicPreviews.stories.d.ts +0 -35
  90. package/dist/types/src/testing/IntrinsicPreviews.stories.d.ts.map +0 -1
  91. package/dist/types/src/testing/PopoverPreviews.stories.d.ts +0 -35
  92. package/dist/types/src/testing/PopoverPreviews.stories.d.ts.map +0 -1
  93. package/dist/types/src/testing/util.d.ts +0 -80
  94. package/dist/types/src/testing/util.d.ts.map +0 -1
  95. package/src/components/ContactCard.tsx +0 -70
  96. package/src/components/OrganizationCard.tsx +0 -41
  97. package/src/components/ProjectCard.tsx +0 -20
  98. package/src/testing/ExtrinsicPreviews.stories.tsx +0 -55
  99. package/src/testing/IntrinsicPreviews.stories.tsx +0 -55
  100. package/src/testing/PopoverPreviews.stories.tsx +0 -55
  101. package/src/testing/util.tsx +0 -79
@@ -0,0 +1,91 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Rx } from '@effect-rx/rx-react';
6
+ import React from 'react';
7
+
8
+ import { LayoutAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';
9
+ import { ACTION_TYPE } from '@dxos/app-graph';
10
+ import { Obj } from '@dxos/echo';
11
+ import { SpaceAction } from '@dxos/plugin-space/types';
12
+ import { fullyQualifiedId } from '@dxos/react-client/echo';
13
+ import { IconButton, type IconButtonProps, useTranslation } from '@dxos/react-ui';
14
+ import {
15
+ type ActionGraphProps,
16
+ DropdownMenu,
17
+ type MenuActions,
18
+ MenuProvider,
19
+ useMenuActions,
20
+ } from '@dxos/react-ui-menu';
21
+
22
+ import { meta } from '../meta';
23
+ import { type PreviewProps } from '../types';
24
+
25
+ /**
26
+ * Generic menu for objects; builds menu with common actions.
27
+ */
28
+ // TODO(burdon): Reconcile title and menu with main Card header.
29
+ export const CardSubjectMenu = ({
30
+ subject,
31
+ activeSpace,
32
+ ...props
33
+ }: PreviewProps & 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
+ return (
42
+ <MenuProvider {...menuProps}>
43
+ <DropdownMenu.Root>
44
+ <DropdownMenu.Trigger asChild>
45
+ <IconButton
46
+ variant='ghost'
47
+ icon='ph--dots-three-vertical--bold'
48
+ iconOnly
49
+ label={t('more options label')}
50
+ size={5}
51
+ {...props}
52
+ />
53
+ </DropdownMenu.Trigger>
54
+ </DropdownMenu.Root>
55
+ </MenuProvider>
56
+ );
57
+ };
58
+
59
+ const useSubjectMenuGroupItems = ({ subject, activeSpace }: PreviewProps): MenuActions => {
60
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
61
+ const result: ActionGraphProps = { edges: [], nodes: [] };
62
+
63
+ result.nodes.push({
64
+ type: ACTION_TYPE,
65
+ id: `${subject.id}/open`,
66
+ data: () => dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [fullyQualifiedId(subject)] })),
67
+ properties: {
68
+ label: ['open object label', { ns: meta.id }],
69
+ icon: 'ph--arrow-right--regular',
70
+ },
71
+ });
72
+
73
+ if (activeSpace && Obj.getDXN(subject).asQueueDXN()) {
74
+ result.nodes.push({
75
+ type: ACTION_TYPE,
76
+ id: `${subject.id}/add-to-space`,
77
+ // TODO(wittjosiah): Update reference to point to db object when adding?
78
+ data: () => dispatch(createIntent(SpaceAction.AddObject, { object: subject, target: activeSpace, hidden: true })),
79
+ properties: {
80
+ label: ['add object to space label', { ns: meta.id }],
81
+ icon: 'ph--file-plus--regular',
82
+ },
83
+ });
84
+ }
85
+
86
+ result.nodes.forEach(({ id: target }) => {
87
+ result.edges.push({ source: 'root', target });
88
+ });
89
+
90
+ return useMenuActions(Rx.make(result));
91
+ };
@@ -2,6 +2,5 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './ContactCard';
6
- export * from './OrganizationCard';
7
- export * from './ProjectCard';
5
+ export * from './CardComponents';
6
+ export * from './CardSubjectMenu';
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: PREVIEW_PLUGIN,
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
  };
@@ -0,0 +1,62 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+
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';
11
+
12
+ import { translations } from '../translations';
13
+
14
+ import { Defaultstory, createCards } from './testing';
15
+
16
+ faker.seed(999);
17
+
18
+ const meta = {
19
+ title: 'plugins/plugin-preview/Card',
20
+ render: Defaultstory,
21
+ decorators: [
22
+ withTheme, // TODO(wittjosiah): Try to write story which does not depend on plugin manager.
23
+ withPluginManager({ plugins: [IntentPlugin()] }),
24
+ ],
25
+ parameters: {
26
+ layout: 'fullscreen',
27
+ translations,
28
+ },
29
+ tags: ['cards'],
30
+ } satisfies Meta<typeof Defaultstory>;
31
+
32
+ export default meta;
33
+
34
+ type Story = StoryObj<typeof meta>;
35
+
36
+ export const Popover: Story = {
37
+ args: {
38
+ role: 'card--popover',
39
+ cards: createCards(),
40
+ },
41
+ };
42
+
43
+ export const Intrinsic: Story = {
44
+ args: {
45
+ role: 'card--intrinsic',
46
+ cards: createCards(),
47
+ },
48
+ };
49
+
50
+ export const Extrinsic: Story = {
51
+ args: {
52
+ role: 'card--extrinsic',
53
+ cards: createCards(),
54
+ },
55
+ };
56
+
57
+ export const ExtrinsicNoImage: Story = {
58
+ args: {
59
+ role: 'card--extrinsic',
60
+ cards: createCards(false),
61
+ },
62
+ };
@@ -0,0 +1,113 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { type FC } from 'react';
6
+
7
+ import { Obj, Ref } from '@dxos/echo';
8
+ import { faker } from '@dxos/random';
9
+ import { CardContainer } from '@dxos/react-ui-stack/testing';
10
+ import { DataType } from '@dxos/schema';
11
+
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;
19
+ image?: boolean;
20
+ };
21
+
22
+ export type DefaultstoryProps = {
23
+ role: 'card--popover' | 'card--intrinsic' | 'card--extrinsic' | 'card--transclusion';
24
+ cards: CardProps<any>[];
25
+ };
26
+
27
+ export const Defaultstory = ({ role, cards }: DefaultstoryProps) => {
28
+ 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)} />
35
+ </CardContainer>
36
+ </div>
37
+ ))}
38
+ </div>
39
+ </div>
40
+ );
41
+ };
42
+
43
+ export const omitImage = ({ image: _, ...rest }: any) => rest;
44
+
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, {
48
+ name: faker.company.name(),
49
+ image:
50
+ '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
+ website: faker.internet.url(),
52
+ description: faker.lorem.paragraph(),
53
+ });
54
+
55
+ const contact = Obj.make(DataType.Person, {
56
+ fullName: faker.person.fullName(),
57
+ image:
58
+ '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
+ organization: Ref.make(organization),
60
+ 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
+ },
73
+ ],
74
+ });
75
+
76
+ const project = DataType.makeProject({
77
+ name: faker.person.fullName(),
78
+ image: 'https://dxos.network/dxos-logotype-blue.png',
79
+ description: faker.lorem.paragraph(),
80
+ });
81
+
82
+ const task = Obj.make(DataType.Task, {
83
+ title: faker.lorem.sentence(),
84
+ status: faker.helpers.arrayElement(['todo', 'in-progress', 'done']),
85
+ });
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
+ };
@@ -11,6 +11,12 @@ export const translations = [
11
11
  'en-US': {
12
12
  [meta.id]: {
13
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',
14
20
  },
15
21
  },
16
22
  },
package/src/types.ts CHANGED
@@ -4,8 +4,12 @@
4
4
 
5
5
  import { type PropsWithChildren } from 'react';
6
6
 
7
- // TODO(burdon): Better place for these defs?
8
- export type PreviewProps<T extends object> = PropsWithChildren<{
7
+ import { type Obj } from '@dxos/echo';
8
+ import { type Space } from '@dxos/react-client/echo';
9
+
10
+ export type PreviewProps<T extends Obj.Any = Obj.Any> = PropsWithChildren<{
9
11
  subject: T;
10
12
  role?: string;
13
+ activeSpace?: Space;
14
+ onSelect?: (obj: Obj.Any) => void;
11
15
  }>;
@@ -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, contributes, createIntent, type PluginContext } from '@dxos/app-framework';\nimport { addEventListener } from '@dxos/async';\nimport { type Client, resolveRef } from '@dxos/client';\nimport { parseId, type Space } from '@dxos/client/echo';\nimport { DXN } from '@dxos/keys';\nimport { type DxRefTagActivate } 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 dxn = DXN.parse(ref);\n if (!dxn) {\n return null;\n }\n\n const object = await resolveRef(client, dxn, defaultSpace);\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 handleDxRefTagActivate = async ({ refId, label, trigger }: DxRefTagActivate) => {\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-ref-tag-activate' as any,\n handleDxRefTagActivate,\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,cAAcC,aAAaC,oBAAwC;AAC1F,SAASC,wBAAwB;AACjC,SAAsBC,kBAAkB;AACxC,SAASC,eAA2B;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,MAAMX,IAAIY,MAAMH,GAAAA;AACtB,QAAI,CAACE,KAAK;AACR,aAAO;IACT;AAEA,UAAME,SAAS,MAAMf,WAAWS,QAAQI,KAAKH,YAAAA;AAC7C,WAAO;MAAEE;MAAOG;IAAO;EACzB,SAASC,KAAK;AACZ,WAAO;EACT;AACF;AAEA,IAAA,0BAAe,CAACC,YAAAA;AAEd,QAAMC,yBAAyB,OAAO,EAAEC,OAAOP,OAAOQ,QAAO,MAAoB;AAC/E,UAAM,EAAEC,iBAAiBC,SAAQ,IAAKL,QAAQM,cAAc5B,aAAa6B,gBAAgB;AACzF,UAAMf,SAASQ,QAAQM,cAAcnB,mBAAmBqB,MAAM;AAC9D,UAAM,CAACC,MAAAA,IAAUT,QAAQU,gBAAgBhC,aAAaiC,MAAM;AAC5D,UAAM,EAAEC,QAAO,IAAK5B,QAAQyB,OAAOI,SAAS;AAC5C,UAAMC,SAASF,WAAWpB,OAAOuB,OAAOC,IAAIJ,OAAAA,MAAapB,OAAOuB,OAAOE;AACvE,UAAMC,SAAS,MAAM3B,oBAAoBC,QAAQsB,OAAO;MAAEpB,KAAKQ;MAAOP;IAAM,CAAA;AAC5E,QAAI,CAACuB,QAAQ;AACX;IACF;AAEA,UAAMb,SACJxB,aAAaF,aAAawC,eAAe;MACvCC,MAAM;MACNC,SAASH,OAAOpB;MAChBwB,SAAS;QACPC,OAAO;QACPC,SAAS;QACTC,QAAQtB;MACV;IACF,CAAA,CAAA;EAEJ;AAEA,MAAIuB;AACJ,MAAIC,SAASC,aAAa;AACxBF,cAAU5C,iBACR6C,SAASC,aACT,uBACA3B,wBACAb,kBAAAA;EAEJ,OAAO;AACLF,QAAI2C,KAAK,yBAAA,QAAA;;;;;;EACX;AAEA,SAAOjD,YAAYF,aAAaoD,MAAM,MAAM,MAAMJ,QAAAA,CAAAA;AACpD;",
6
- "names": ["Capabilities", "LayoutAction", "contributes", "createIntent", "addEventListener", "resolveRef", "parseId", "DXN", "log", "ClientCapabilities", "customEventOptions", "capture", "passive", "handlePreviewLookup", "client", "defaultSpace", "ref", "label", "dxn", "parse", "object", "err", "context", "handleDxRefTagActivate", "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
- }
@@ -1,303 +0,0 @@
1
- import {
2
- PREVIEW_PLUGIN
3
- } from "./chunk-Z73ENKLE.mjs";
4
-
5
- // src/capabilities/react-surface.tsx
6
- import { Effect } from "effect";
7
- import React4, { useCallback } from "react";
8
- import { Capabilities, LayoutAction, Surface, contributes, createIntent, createSurface, useIntentDispatcher } from "@dxos/app-framework";
9
- import { fullyQualifiedId, getSchema, getSpace } from "@dxos/client/echo";
10
- import { Filter, Obj } from "@dxos/echo";
11
- import { setValue } from "@dxos/echo-schema";
12
- import { AttentionAction } from "@dxos/plugin-attention/types";
13
- import { ATTENDABLE_PATH_SEPARATOR, DeckAction } from "@dxos/plugin-deck/types";
14
- import { useQuery, useSpace } from "@dxos/react-client/echo";
15
- import { useTranslation } from "@dxos/react-ui";
16
- import { Form } from "@dxos/react-ui-form";
17
- import { Card as Card4 } from "@dxos/react-ui-stack";
18
- import { TableView } from "@dxos/react-ui-table/types";
19
- import { descriptionMessage, mx as mx2 } from "@dxos/react-ui-theme";
20
- import { DataType } from "@dxos/schema";
21
-
22
- // src/components/ContactCard.tsx
23
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
24
- import React, { Fragment } from "react";
25
- import { Icon, Avatar, Button } from "@dxos/react-ui";
26
- import { Card, cardHeading, cardText } from "@dxos/react-ui-stack";
27
- import { mx } from "@dxos/react-ui-theme";
28
- var ContactCard = ({ children, subject: { fullName, image, organization, emails }, onOrgClick, role }) => {
29
- var _effect = _useSignals();
30
- try {
31
- const organizationName = organization && typeof organization === "object" ? organization.target?.name : organization;
32
- return /* @__PURE__ */ React.createElement(Card.SurfaceRoot, {
33
- role
34
- }, /* @__PURE__ */ React.createElement(Avatar.Root, null, /* @__PURE__ */ React.createElement(Card.Text, {
35
- role: "group",
36
- classNames: "grid gap-3 grid-cols-[min-content_1fr]"
37
- }, /* @__PURE__ */ React.createElement(Avatar.Content, {
38
- imgSrc: image,
39
- icon: "ph--user--regular",
40
- size: 16,
41
- hue: "neutral"
42
- }), /* @__PURE__ */ React.createElement("div", {
43
- role: "none",
44
- className: "bs-min self-center"
45
- }, /* @__PURE__ */ React.createElement(Avatar.Label, {
46
- asChild: true
47
- }, /* @__PURE__ */ React.createElement("h2", {
48
- className: cardHeading
49
- }, fullName))))), organizationName && /* @__PURE__ */ React.createElement(Card.Chrome, null, typeof organization === "object" && onOrgClick ? /* @__PURE__ */ React.createElement(Button, {
50
- variant: "ghost",
51
- classNames: "gap-2 text-start",
52
- onClick: () => onOrgClick(organization.target)
53
- }, /* @__PURE__ */ React.createElement(Icon, {
54
- icon: "ph--buildings--regular",
55
- size: 5,
56
- classNames: "text-subdued"
57
- }), /* @__PURE__ */ React.createElement("span", {
58
- className: "min-is-0 flex-1 truncate"
59
- }, organizationName), /* @__PURE__ */ React.createElement(Icon, {
60
- icon: "ph--arrow-right--regular"
61
- })) : /* @__PURE__ */ React.createElement("p", {
62
- className: "dx-button gap-2",
63
- "data-variant": "ghost"
64
- }, /* @__PURE__ */ React.createElement(Icon, {
65
- icon: "ph--buildings--regular",
66
- size: 5,
67
- classNames: "text-subdued"
68
- }), /* @__PURE__ */ React.createElement("span", {
69
- className: "min-is-0 flex-1 truncate"
70
- }, organizationName))), /* @__PURE__ */ React.createElement("dl", {
71
- className: mx(cardText, "grid gap-2 grid-cols-[min-content_1fr] [&_dt]:text-subdued [&_dt]:pbs-0.5 [&_dd]:min-is-0")
72
- }, emails?.length && emails.map(({ label, value }) => /* @__PURE__ */ React.createElement(Fragment, {
73
- key: value
74
- }, /* @__PURE__ */ React.createElement("dt", null, /* @__PURE__ */ React.createElement(Icon, {
75
- icon: "ph--at--regular",
76
- size: 5
77
- })), /* @__PURE__ */ React.createElement("dd", {
78
- key: value,
79
- className: "break-words"
80
- }, value)))), children);
81
- } finally {
82
- _effect.f();
83
- }
84
- };
85
-
86
- // src/components/OrganizationCard.tsx
87
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
88
- import React2 from "react";
89
- import { Icon as Icon2 } from "@dxos/react-ui";
90
- import { Card as Card2 } from "@dxos/react-ui-stack";
91
- var OrganizationCard = ({ children, subject: { name, image, description, website }, role }) => {
92
- var _effect = _useSignals2();
93
- try {
94
- return /* @__PURE__ */ React2.createElement(Card2.SurfaceRoot, {
95
- role
96
- }, /* @__PURE__ */ React2.createElement(Card2.Poster, {
97
- alt: name,
98
- ...image ? {
99
- image
100
- } : {
101
- icon: "ph--building-office--regular"
102
- }
103
- }), /* @__PURE__ */ React2.createElement(Card2.Heading, null, name), description && /* @__PURE__ */ React2.createElement(Card2.Text, {
104
- classNames: "line-clamp-2"
105
- }, description), website && /* @__PURE__ */ React2.createElement(Card2.Chrome, null, /* @__PURE__ */ React2.createElement("a", {
106
- className: "dx-button dx-focus-ring gap-2",
107
- "data-variant": "ghost",
108
- href: website,
109
- target: "_blank",
110
- rel: "noreferrer"
111
- }, /* @__PURE__ */ React2.createElement(Icon2, {
112
- icon: "ph--link--regular",
113
- size: 5,
114
- classNames: "text-subdued"
115
- }), /* @__PURE__ */ React2.createElement("span", {
116
- className: "grow"
117
- }, website), /* @__PURE__ */ React2.createElement(Icon2, {
118
- icon: "ph--arrow-square-out--regular"
119
- }))), children);
120
- } finally {
121
- _effect.f();
122
- }
123
- };
124
-
125
- // src/components/ProjectCard.tsx
126
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
127
- import React3 from "react";
128
- import { Card as Card3 } from "@dxos/react-ui-stack";
129
- var ProjectCard = ({ subject: { name, image, description }, role }) => {
130
- var _effect = _useSignals3();
131
- try {
132
- return /* @__PURE__ */ React3.createElement(Card3.SurfaceRoot, {
133
- role
134
- }, image && /* @__PURE__ */ React3.createElement(Card3.Poster, {
135
- image,
136
- alt: name,
137
- aspect: "auto"
138
- }), /* @__PURE__ */ React3.createElement(Card3.Heading, null, name), description && /* @__PURE__ */ React3.createElement(Card3.Text, {
139
- classNames: "line-clamp-2"
140
- }, description));
141
- } finally {
142
- _effect.f();
143
- }
144
- };
145
-
146
- // src/capabilities/react-surface.tsx
147
- var react_surface_default = () => contributes(Capabilities.ReactSurface, [
148
- //
149
- // Specific schema types.
150
- //
151
- createSurface({
152
- id: `${PREVIEW_PLUGIN}/schema-popover--contact`,
153
- role: [
154
- "card--popover",
155
- "card--intrinsic",
156
- "card--transclusion",
157
- "card--extrinsic",
158
- "card"
159
- ],
160
- filter: (data) => Obj.instanceOf(DataType.Person, data.subject),
161
- component: ({ data, role }) => {
162
- const { dispatch } = useIntentDispatcher();
163
- const space = getSpace(data.subject);
164
- const defaultSpace = useSpace();
165
- const currentSpaceOrgs = useQuery(space, Filter.type(DataType.Organization));
166
- const currentSpaceViews = useQuery(space, Filter.type(DataType.View));
167
- const defaultSpaceViews = useQuery(defaultSpace, Filter.type(DataType.View));
168
- const currentSpaceOrgTable = currentSpaceViews.find((view) => view.query.typename === DataType.Organization.typename && Obj.instanceOf(TableView, view.presentation.target));
169
- const defaultSpaceOrgTable = defaultSpaceViews.find((view) => view.query.typename === DataType.Organization.typename && Obj.instanceOf(TableView, view.presentation.target));
170
- const handleOrgClick = useCallback((org) => Effect.gen(function* () {
171
- const view = currentSpaceOrgs.includes(org) ? currentSpaceOrgTable : defaultSpaceOrgTable;
172
- yield* dispatch(createIntent(LayoutAction.UpdatePopover, {
173
- part: "popover",
174
- options: {
175
- state: false,
176
- anchorId: ""
177
- }
178
- }));
179
- if (view) {
180
- const id = fullyQualifiedId(view);
181
- yield* dispatch(createIntent(LayoutAction.Open, {
182
- part: "main",
183
- subject: [
184
- id
185
- ],
186
- options: {
187
- workspace: space?.id
188
- }
189
- }));
190
- yield* dispatch(createIntent(DeckAction.ChangeCompanion, {
191
- primary: id,
192
- companion: [
193
- id,
194
- "selected-objects"
195
- ].join(ATTENDABLE_PATH_SEPARATOR)
196
- }));
197
- yield* dispatch(createIntent(AttentionAction.Select, {
198
- contextId: id,
199
- selection: {
200
- mode: "multi",
201
- ids: [
202
- org.id
203
- ]
204
- }
205
- }));
206
- }
207
- }).pipe(Effect.runPromise), [
208
- dispatch,
209
- currentSpaceOrgs,
210
- currentSpaceOrgTable,
211
- defaultSpaceOrgTable
212
- ]);
213
- return /* @__PURE__ */ React4.createElement(ContactCard, {
214
- role,
215
- subject: data.subject,
216
- onOrgClick: handleOrgClick
217
- }, role === "card--popover" && /* @__PURE__ */ React4.createElement(Surface, {
218
- role: "related",
219
- data
220
- }));
221
- }
222
- }),
223
- createSurface({
224
- id: `${PREVIEW_PLUGIN}/schema-popover--organization`,
225
- role: [
226
- "card--popover",
227
- "card--intrinsic",
228
- "card--transclusion",
229
- "card--extrinsic",
230
- "card"
231
- ],
232
- filter: (data) => Obj.instanceOf(DataType.Organization, data.subject),
233
- component: ({ data, role }) => /* @__PURE__ */ React4.createElement(OrganizationCard, {
234
- role,
235
- subject: data.subject
236
- }, role === "card--popover" && /* @__PURE__ */ React4.createElement(Surface, {
237
- role: "related",
238
- data
239
- }))
240
- }),
241
- createSurface({
242
- id: `${PREVIEW_PLUGIN}/schema-popover--project`,
243
- role: [
244
- "card--popover",
245
- "card--intrinsic",
246
- "card--transclusion",
247
- "card--extrinsic",
248
- "card"
249
- ],
250
- filter: (data) => Obj.instanceOf(DataType.Project, data.subject),
251
- component: ({ data, role }) => /* @__PURE__ */ React4.createElement(ProjectCard, {
252
- subject: data.subject,
253
- role
254
- })
255
- }),
256
- //
257
- // Fallback for any object.
258
- //
259
- createSurface({
260
- id: `${PREVIEW_PLUGIN}/fallback-popover`,
261
- role: [
262
- "card--popover",
263
- "card--intrinsic",
264
- "card--transclusion",
265
- "card--extrinsic",
266
- "card"
267
- ],
268
- position: "fallback",
269
- filter: (data) => Obj.isObject(data.subject),
270
- component: ({ data, role }) => {
271
- const schema = getSchema(data.subject);
272
- const { t } = useTranslation(PREVIEW_PLUGIN);
273
- if (!schema) {
274
- return /* @__PURE__ */ React4.createElement("p", {
275
- className: mx2(descriptionMessage)
276
- }, t("unable to create preview message"));
277
- }
278
- const handleSave = useCallback((values, { changed }) => {
279
- const changedPaths = Object.keys(changed).filter((path) => changed[path]);
280
- for (const path of changedPaths) {
281
- const value = values[path];
282
- setValue(data.subject, path, value);
283
- }
284
- }, []);
285
- return /* @__PURE__ */ React4.createElement(Card4.SurfaceRoot, {
286
- role
287
- }, /* @__PURE__ */ React4.createElement(Form, {
288
- schema,
289
- values: data.subject,
290
- readonly: role === "card--popover",
291
- onSave: handleSave,
292
- autoSave: true,
293
- ...role === "card--intrinsic" && {
294
- outerSpacing: "blockStart-0"
295
- }
296
- }));
297
- }
298
- })
299
- ]);
300
- export {
301
- react_surface_default as default
302
- };
303
- //# sourceMappingURL=react-surface-CZMUEWPV.mjs.map