@dxos/plugin-preview 0.8.4-main.1da679c → 0.8.4-main.21d9917

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 (108) hide show
  1. package/dist/lib/browser/chunk-XLN6KTHK.mjs +17 -0
  2. package/dist/lib/browser/chunk-XLN6KTHK.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +29 -38
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/preview-popover-Y67LE6TV.mjs +78 -0
  7. package/dist/lib/browser/preview-popover-Y67LE6TV.mjs.map +7 -0
  8. package/dist/lib/browser/react-surface-XYEFQ6NI.mjs +263 -0
  9. package/dist/lib/browser/react-surface-XYEFQ6NI.mjs.map +7 -0
  10. package/dist/lib/node-esm/chunk-2G4FUGDA.mjs +19 -0
  11. package/dist/lib/node-esm/chunk-2G4FUGDA.mjs.map +7 -0
  12. package/dist/lib/node-esm/index.mjs +29 -38
  13. package/dist/lib/node-esm/index.mjs.map +4 -4
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/preview-popover-BGV2P6UX.mjs +80 -0
  16. package/dist/lib/node-esm/preview-popover-BGV2P6UX.mjs.map +7 -0
  17. package/dist/lib/node-esm/react-surface-PSUCURVT.mjs +264 -0
  18. package/dist/lib/node-esm/react-surface-PSUCURVT.mjs.map +7 -0
  19. package/dist/types/src/PreviewPlugin.d.ts +2 -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/index.d.ts +3 -0
  24. package/dist/types/src/capabilities/preview-popover/index.d.ts.map +1 -0
  25. package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts +5 -0
  26. package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts.map +1 -0
  27. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  28. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  29. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  30. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  31. package/dist/types/src/cards/FormCard.d.ts +7 -0
  32. package/dist/types/src/cards/FormCard.d.ts.map +1 -0
  33. package/dist/types/src/cards/OrganizationCard.d.ts +5 -0
  34. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -0
  35. package/dist/types/src/cards/PersonCard.d.ts +5 -0
  36. package/dist/types/src/cards/PersonCard.d.ts.map +1 -0
  37. package/dist/types/src/cards/ProjectCard.d.ts +5 -0
  38. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -0
  39. package/dist/types/src/cards/TaskCard.d.ts +5 -0
  40. package/dist/types/src/cards/TaskCard.d.ts.map +1 -0
  41. package/dist/types/src/cards/index.d.ts +6 -0
  42. package/dist/types/src/cards/index.d.ts.map +1 -0
  43. package/dist/types/src/index.d.ts +0 -1
  44. package/dist/types/src/index.d.ts.map +1 -1
  45. package/dist/types/src/meta.d.ts +2 -3
  46. package/dist/types/src/meta.d.ts.map +1 -1
  47. package/dist/types/src/stories/Card.stories.d.ts +11 -7
  48. package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
  49. package/dist/types/src/stories/testing.d.ts +14 -12
  50. package/dist/types/src/stories/testing.d.ts.map +1 -1
  51. package/dist/types/src/translations.d.ts +3 -0
  52. package/dist/types/src/translations.d.ts.map +1 -1
  53. package/dist/types/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +44 -35
  55. package/src/PreviewPlugin.tsx +13 -26
  56. package/src/capabilities/index.ts +2 -4
  57. package/src/capabilities/preview-popover/index.ts +7 -0
  58. package/src/capabilities/preview-popover/preview-popover.ts +77 -0
  59. package/src/capabilities/react-surface/index.ts +7 -0
  60. package/src/capabilities/react-surface/react-surface.tsx +97 -0
  61. package/src/cards/FormCard.tsx +63 -0
  62. package/src/cards/OrganizationCard.tsx +29 -0
  63. package/src/cards/PersonCard.tsx +47 -0
  64. package/src/cards/ProjectCard.tsx +22 -0
  65. package/src/{components → cards}/TaskCard.tsx +16 -22
  66. package/src/{components → cards}/index.ts +3 -1
  67. package/src/index.ts +0 -1
  68. package/src/meta.ts +8 -5
  69. package/src/stories/Card.stories.tsx +34 -25
  70. package/src/stories/testing.tsx +40 -70
  71. package/src/translations.ts +3 -0
  72. package/dist/lib/browser/chunk-Z73ENKLE.mjs +0 -14
  73. package/dist/lib/browser/chunk-Z73ENKLE.mjs.map +0 -7
  74. package/dist/lib/browser/preview-popover-EIATF2VR.mjs +0 -65
  75. package/dist/lib/browser/preview-popover-EIATF2VR.mjs.map +0 -7
  76. package/dist/lib/browser/react-surface-B5AX4QFQ.mjs +0 -471
  77. package/dist/lib/browser/react-surface-B5AX4QFQ.mjs.map +0 -7
  78. package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs +0 -16
  79. package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs.map +0 -7
  80. package/dist/lib/node-esm/preview-popover-623SB5KV.mjs +0 -67
  81. package/dist/lib/node-esm/preview-popover-623SB5KV.mjs.map +0 -7
  82. package/dist/lib/node-esm/react-surface-F5E3ITVY.mjs +0 -472
  83. package/dist/lib/node-esm/react-surface-F5E3ITVY.mjs.map +0 -7
  84. package/dist/types/src/capabilities/preview-popover.d.ts +0 -4
  85. package/dist/types/src/capabilities/preview-popover.d.ts.map +0 -1
  86. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  87. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  88. package/dist/types/src/components/CardSubjectMenu.d.ts +0 -12
  89. package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
  90. package/dist/types/src/components/ContactCard.d.ts +0 -7
  91. package/dist/types/src/components/ContactCard.d.ts.map +0 -1
  92. package/dist/types/src/components/OrganizationCard.d.ts +0 -5
  93. package/dist/types/src/components/OrganizationCard.d.ts.map +0 -1
  94. package/dist/types/src/components/ProjectCard.d.ts +0 -5
  95. package/dist/types/src/components/ProjectCard.d.ts.map +0 -1
  96. package/dist/types/src/components/TaskCard.d.ts +0 -5
  97. package/dist/types/src/components/TaskCard.d.ts.map +0 -1
  98. package/dist/types/src/components/index.d.ts +0 -4
  99. package/dist/types/src/components/index.d.ts.map +0 -1
  100. package/dist/types/src/types.d.ts +0 -9
  101. package/dist/types/src/types.d.ts.map +0 -1
  102. package/src/capabilities/preview-popover.ts +0 -69
  103. package/src/capabilities/react-surface.tsx +0 -181
  104. package/src/components/CardSubjectMenu.tsx +0 -67
  105. package/src/components/ContactCard.tsx +0 -78
  106. package/src/components/OrganizationCard.tsx +0 -44
  107. package/src/components/ProjectCard.tsx +0 -28
  108. package/src/types.ts +0 -14
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import { DataType } from '@dxos/schema';
3
- import { type PreviewProps } from '../types';
4
- export declare const TaskCard: ({ subject, role, activeSpace }: PreviewProps<DataType.Task>) => React.JSX.Element;
5
- //# sourceMappingURL=TaskCard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TaskCard.d.ts","sourceRoot":"","sources":["../../../../src/components/TaskCard.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAiB7C,eAAO,MAAM,QAAQ,GAAI,gCAAgC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,sBAgBnF,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from './ContactCard';
2
- export * from './OrganizationCard';
3
- export * from './ProjectCard';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
@@ -1,9 +0,0 @@
1
- import { type Schema } from 'effect';
2
- import { type PropsWithChildren } from 'react';
3
- import { type Space } from '@dxos/react-client/echo';
4
- export type PreviewProps<T extends Schema.Schema.Type<any>> = PropsWithChildren<{
5
- subject: T;
6
- role?: string;
7
- activeSpace?: Space;
8
- }>;
9
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,iBAAiB,CAAC;IAC9E,OAAO,EAAE,CAAC,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,CAAC,CAAC"}
@@ -1,69 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capabilities, LayoutAction, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
6
- import { addEventListener } from '@dxos/async';
7
- import { type Client } from '@dxos/client';
8
- import { type Space, parseId } from '@dxos/client/echo';
9
- import { DXN } from '@dxos/keys';
10
- import { log } from '@dxos/log';
11
- import { ClientCapabilities } from '@dxos/plugin-client';
12
- import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';
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
- try {
23
- const object = await defaultSpace.db.ref(DXN.parse(ref)).load();
24
- return { label, object };
25
- } catch (err) {
26
- return null;
27
- }
28
- };
29
-
30
- export default (context: PluginContext) => {
31
- // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
32
- const handleDxAnchorActivate = async ({ refId, label, trigger }: DxAnchorActivate) => {
33
- const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
34
- const client = context.getCapability(ClientCapabilities.Client);
35
- const [layout] = context.getCapabilities(Capabilities.Layout);
36
- const { spaceId } = parseId(layout.workspace);
37
- const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
38
- const result = await handlePreviewLookup(client, space, { ref: refId, label });
39
- if (!result) {
40
- return;
41
- }
42
-
43
- await dispatch(
44
- createIntent(LayoutAction.UpdatePopover, {
45
- part: 'popover',
46
- subject: result.object,
47
- options: {
48
- state: true,
49
- variant: 'virtual',
50
- anchor: trigger,
51
- },
52
- }),
53
- );
54
- };
55
-
56
- let cleanup: () => void;
57
- if (document.defaultView) {
58
- cleanup = addEventListener(
59
- document.defaultView,
60
- DX_ANCHOR_ACTIVATE as any,
61
- handleDxAnchorActivate,
62
- customEventOptions,
63
- );
64
- } else {
65
- log.warn('No default view found');
66
- }
67
-
68
- return contributes(Capabilities.Null, null, () => cleanup());
69
- };
@@ -1,181 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Effect } from 'effect';
6
- import React, { useCallback } from 'react';
7
-
8
- import {
9
- Capabilities,
10
- LayoutAction,
11
- Surface,
12
- contributes,
13
- createIntent,
14
- createSurface,
15
- useIntentDispatcher,
16
- } from '@dxos/app-framework';
17
- import { fullyQualifiedId, getSchema, getSpace } from '@dxos/client/echo';
18
- import { Filter, Obj } from '@dxos/echo';
19
- import { type JsonPath, setValue } from '@dxos/echo-schema';
20
- import { AttentionAction } from '@dxos/plugin-attention/types';
21
- import { ATTENDABLE_PATH_SEPARATOR, DeckAction } from '@dxos/plugin-deck/types';
22
- import { useActiveSpace } from '@dxos/plugin-space';
23
- import { useQuery, useSpace } from '@dxos/react-client/echo';
24
- import { useTranslation } from '@dxos/react-ui';
25
- import { Form } from '@dxos/react-ui-form';
26
- import { Card } from '@dxos/react-ui-stack';
27
- import { Table } from '@dxos/react-ui-table/types';
28
- import { descriptionMessage, mx } from '@dxos/react-ui-theme';
29
- import { DataType, type ProjectionModel, typenameFromQuery } from '@dxos/schema';
30
-
31
- import { ContactCard, OrganizationCard, ProjectCard } from '../components';
32
- import { TaskCard } from '../components/TaskCard';
33
- import { PREVIEW_PLUGIN } from '../meta';
34
-
35
- export default () =>
36
- contributes(Capabilities.ReactSurface, [
37
- //
38
- // Specific schema types.
39
- //
40
- createSurface({
41
- id: `${PREVIEW_PLUGIN}/schema-popover--contact`,
42
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
43
- filter: (data): data is { subject: DataType.Person } => Obj.instanceOf(DataType.Person, data.subject),
44
- component: ({ data, role }) => {
45
- const { dispatch } = useIntentDispatcher();
46
- const space = getSpace(data.subject);
47
- const defaultSpace = useSpace();
48
- const activeSpace = useActiveSpace();
49
-
50
- const currentSpaceOrgs = useQuery(space, Filter.type(DataType.Organization));
51
- const currentSpaceViews = useQuery(space, Filter.type(DataType.View));
52
- const defaultSpaceViews = useQuery(defaultSpace, Filter.type(DataType.View));
53
- const currentSpaceOrgTable = currentSpaceViews.find(
54
- (view) =>
55
- typenameFromQuery(view.query) === DataType.Organization.typename &&
56
- Obj.instanceOf(Table.Table, view.presentation.target),
57
- );
58
- const defaultSpaceOrgTable = defaultSpaceViews.find(
59
- (view) =>
60
- typenameFromQuery(view.query) === DataType.Organization.typename &&
61
- Obj.instanceOf(Table.Table, view.presentation.target),
62
- );
63
-
64
- // TODO(wittjosiah): Generalized way of handling related objects navigation.
65
- const handleOrgClick = useCallback(
66
- (org: DataType.Organization) =>
67
- Effect.gen(function* () {
68
- const view = currentSpaceOrgs.includes(org) ? currentSpaceOrgTable : defaultSpaceOrgTable;
69
- yield* dispatch(
70
- createIntent(LayoutAction.UpdatePopover, {
71
- part: 'popover',
72
- options: {
73
- state: false,
74
- anchorId: '',
75
- },
76
- }),
77
- );
78
- if (view) {
79
- const id = fullyQualifiedId(view);
80
- yield* dispatch(
81
- createIntent(LayoutAction.Open, {
82
- part: 'main',
83
- subject: [id],
84
- options: { workspace: space?.id },
85
- }),
86
- );
87
- yield* dispatch(
88
- createIntent(DeckAction.ChangeCompanion, {
89
- primary: id,
90
- companion: [id, 'selected-objects'].join(ATTENDABLE_PATH_SEPARATOR),
91
- }),
92
- );
93
- yield* dispatch(
94
- createIntent(AttentionAction.Select, {
95
- contextId: id,
96
- selection: { mode: 'multi', ids: [org.id] },
97
- }),
98
- );
99
- }
100
- }).pipe(Effect.runPromise),
101
- [dispatch, currentSpaceOrgs, currentSpaceOrgTable, defaultSpaceOrgTable],
102
- );
103
-
104
- return (
105
- <ContactCard role={role} subject={data.subject} activeSpace={activeSpace} onOrgClick={handleOrgClick}>
106
- {role === 'card--popover' && <Surface role='related' data={data} />}
107
- </ContactCard>
108
- );
109
- },
110
- }),
111
- createSurface({
112
- id: `${PREVIEW_PLUGIN}/schema-popover--organization`,
113
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
114
- filter: (data): data is { subject: DataType.Organization } => Obj.instanceOf(DataType.Organization, data.subject),
115
- component: ({ data, role }) => {
116
- const activeSpace = useActiveSpace();
117
-
118
- return (
119
- <OrganizationCard role={role} subject={data.subject} activeSpace={activeSpace}>
120
- {role === 'card--popover' && <Surface role='related' data={data} />}
121
- </OrganizationCard>
122
- );
123
- },
124
- }),
125
- createSurface({
126
- id: `${PREVIEW_PLUGIN}/schema-popover--project`,
127
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
128
- filter: (data): data is { subject: DataType.Project } => Obj.instanceOf(DataType.Project, data.subject),
129
- component: ({ data, role }) => {
130
- const activeSpace = useActiveSpace();
131
-
132
- return <ProjectCard subject={data.subject} role={role} activeSpace={activeSpace} />;
133
- },
134
- }),
135
- createSurface({
136
- id: `${PREVIEW_PLUGIN}/schema-popover--task`,
137
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
138
- filter: (data): data is { subject: DataType.Task } => Obj.instanceOf(DataType.Task, data.subject),
139
- component: ({ data, role }) => <TaskCard subject={data.subject} role={role} />,
140
- }),
141
-
142
- //
143
- // Fallback for any object.
144
- //
145
- createSurface({
146
- id: `${PREVIEW_PLUGIN}/fallback-popover`,
147
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
148
- position: 'fallback',
149
- filter: (data): data is { subject: Obj.Any; projection?: ProjectionModel } => Obj.isObject(data.subject),
150
- component: ({ data, role }) => {
151
- const schema = getSchema(data.subject);
152
- const { t } = useTranslation(PREVIEW_PLUGIN);
153
- if (!schema) {
154
- // TODO(burdon): Use Alert.
155
- return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
156
- }
157
-
158
- const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
159
- const changedPaths = Object.keys(changed).filter((path) => changed[path]);
160
- for (const path of changedPaths) {
161
- const value = values[path];
162
- setValue(data.subject, path as JsonPath, value);
163
- }
164
- }, []);
165
-
166
- return (
167
- <Card.SurfaceRoot role={role}>
168
- <Form
169
- schema={schema}
170
- projection={data.projection}
171
- values={data.subject}
172
- readonly={role === 'card--popover' ? 'static' : false}
173
- onSave={handleSave}
174
- autoSave
175
- {...(role === 'card--intrinsic' && { outerSpacing: 'blockStart-0' })}
176
- />
177
- </Card.SurfaceRoot>
178
- );
179
- },
180
- }),
181
- ]);
@@ -1,67 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Rx } from '@effect-rx/rx-react';
6
- import React from 'react';
7
-
8
- import { 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 { type Space } from '@dxos/react-client/echo';
13
- import { IconButton, type IconButtonProps, useTranslation } from '@dxos/react-ui';
14
- import { type ActionGraphProps, DropdownMenu, MenuProvider, useMenuActions } from '@dxos/react-ui-menu';
15
-
16
- const useSubjectMenuGroupItems = (subject: Obj.Any, activeSpace?: Space) => {
17
- const { dispatchPromise: dispatch } = useIntentDispatcher();
18
- const result: ActionGraphProps = { edges: [], nodes: [] };
19
- if (activeSpace && Obj.getDXN(subject).asQueueDXN()) {
20
- result.nodes.push({
21
- type: ACTION_TYPE,
22
- id: `${subject.id}/add-to-space`,
23
- // TODO(wittjosiah): Update reference to point to db object when adding?
24
- data: () => dispatch(createIntent(SpaceAction.AddObject, { object: subject, target: activeSpace, hidden: true })),
25
- properties: {
26
- label: ['add object to space label', { ns: 'os' }],
27
- icon: 'ph--file-plus--regular',
28
- },
29
- });
30
- }
31
- result.nodes.forEach(({ id: target }) => {
32
- result.edges.push({ source: 'root', target });
33
- });
34
- return useMenuActions(Rx.make(result));
35
- };
36
-
37
- /**
38
- * This is a generic menu for objects that tries to infer common actions.
39
- */
40
- export const CardSubjectMenu = ({
41
- subject,
42
- activeSpace,
43
- ...props
44
- }: Omit<IconButtonProps, 'icon' | 'label'> & { subject: Obj.Any; activeSpace?: Space }) => {
45
- const { t } = useTranslation('os');
46
- const menuProps = useSubjectMenuGroupItems(subject, activeSpace);
47
-
48
- if (!activeSpace) {
49
- return null;
50
- }
51
-
52
- return (
53
- <MenuProvider {...menuProps}>
54
- <DropdownMenu.Root>
55
- <DropdownMenu.Trigger asChild>
56
- <IconButton
57
- iconOnly
58
- variant='ghost'
59
- icon='ph--dots-three-vertical--bold'
60
- label={t('more options label')}
61
- {...props}
62
- />
63
- </DropdownMenu.Trigger>
64
- </DropdownMenu.Root>
65
- </MenuProvider>
66
- );
67
- };
@@ -1,78 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React, { Fragment } from 'react';
6
-
7
- import { Avatar, Button, Icon } from '@dxos/react-ui';
8
- import { Card, cardHeading, cardText } from '@dxos/react-ui-stack';
9
- import { mx } from '@dxos/react-ui-theme';
10
- import { type DataType } from '@dxos/schema';
11
-
12
- import { type PreviewProps } from '../types';
13
-
14
- import { CardSubjectMenu } from './CardSubjectMenu';
15
-
16
- export const ContactCard = ({
17
- children,
18
- subject,
19
- activeSpace,
20
- onOrgClick,
21
- role,
22
- }: PreviewProps<DataType.Person> & { onOrgClick?: (org: DataType.Organization) => void }) => {
23
- const { fullName, image, organization, emails } = subject;
24
- const organizationName = organization && typeof organization === 'object' ? organization.target?.name : organization;
25
- return (
26
- <Card.SurfaceRoot role={role}>
27
- <Avatar.Root>
28
- <Card.Text role='group' classNames='grid gap-3 grid-cols-[min-content_1fr]'>
29
- <Avatar.Content imgSrc={image} icon='ph--user--regular' size={16} hue='neutral' />
30
- <div role='none' className='bs-min self-center flex items-center'>
31
- <Avatar.Label asChild>
32
- <h2 className={mx(cardHeading, 'grow')}>{fullName}</h2>
33
- </Avatar.Label>
34
- <CardSubjectMenu subject={subject} activeSpace={activeSpace} />
35
- </div>
36
- </Card.Text>
37
- </Avatar.Root>
38
- {organizationName && (
39
- <Card.Chrome>
40
- {typeof organization === 'object' && onOrgClick ? (
41
- <Button variant='ghost' classNames='gap-2 text-start' onClick={() => onOrgClick(organization.target!)}>
42
- <Icon icon='ph--buildings--regular' size={5} classNames='text-subdued' />
43
- <span className='min-is-0 flex-1 truncate'>{organizationName}</span>
44
- <Icon icon='ph--arrow-right--regular' />
45
- </Button>
46
- ) : (
47
- <p className='dx-button gap-2' data-variant='ghost'>
48
- <Icon icon='ph--buildings--regular' size={5} classNames='text-subdued' />
49
- <span className='min-is-0 flex-1 truncate'>{organizationName}</span>
50
- </p>
51
- )}
52
- </Card.Chrome>
53
- )}
54
- {emails?.length && (
55
- <dl
56
- className={mx(
57
- cardText,
58
- 'grid gap-2 grid-cols-[min-content_1fr] [&_dt]:text-subdued [&_dt]:pbs-0.5 [&_dd]:min-is-0',
59
- )}
60
- >
61
- {emails?.length &&
62
- emails.map(({ label, value }) => (
63
- <Fragment key={value}>
64
- <dt>
65
- <span className='sr-only'>{label}</span>
66
- <Icon icon='ph--at--regular' size={5} />
67
- </dt>
68
- <dd key={value} className='break-words'>
69
- {value}
70
- </dd>
71
- </Fragment>
72
- ))}
73
- </dl>
74
- )}
75
- {children}
76
- </Card.SurfaceRoot>
77
- );
78
- };
@@ -1,44 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { Icon } from '@dxos/react-ui';
8
- import { Card, cardNoSpacing, cardSpacing } from '@dxos/react-ui-stack';
9
- import { mx } from '@dxos/react-ui-theme';
10
- import { type DataType } from '@dxos/schema';
11
-
12
- import { type PreviewProps } from '../types';
13
-
14
- import { CardSubjectMenu } from './CardSubjectMenu';
15
-
16
- export const OrganizationCard = ({ children, subject, role, activeSpace }: PreviewProps<DataType.Organization>) => {
17
- const { name, image, description, website } = subject;
18
- return (
19
- <Card.SurfaceRoot role={role}>
20
- <Card.Poster alt={name!} {...(image ? { image } : { icon: 'ph--building-office--regular' })} />
21
- <div role='none' className={mx('flex items-center gap-2', cardSpacing)}>
22
- <Card.Heading classNames={cardNoSpacing}>{name}</Card.Heading>
23
- <CardSubjectMenu subject={subject} activeSpace={activeSpace} />
24
- </div>
25
- {description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
26
- {website && (
27
- <Card.Chrome>
28
- <a
29
- className='dx-button dx-focus-ring gap-2'
30
- data-variant='ghost'
31
- href={website}
32
- target='_blank'
33
- rel='noreferrer'
34
- >
35
- <Icon icon='ph--link--regular' size={5} classNames='text-subdued' />
36
- <span className='min-is-0 flex-1 truncate'>{website}</span>
37
- <Icon icon='ph--arrow-square-out--regular' />
38
- </a>
39
- </Card.Chrome>
40
- )}
41
- {children}
42
- </Card.SurfaceRoot>
43
- );
44
- };
@@ -1,28 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { Obj } from '@dxos/echo';
8
- import { Card, cardNoSpacing, cardSpacing } from '@dxos/react-ui-stack';
9
- import { mx } from '@dxos/react-ui-theme';
10
- import { type DataType } from '@dxos/schema';
11
-
12
- import { type PreviewProps } from '../types';
13
-
14
- import { CardSubjectMenu } from './CardSubjectMenu';
15
-
16
- export const ProjectCard = ({ subject, role, activeSpace }: PreviewProps<DataType.Project>) => {
17
- const { name, image, description } = subject;
18
- return (
19
- <Card.SurfaceRoot role={role}>
20
- {image && <Card.Poster image={image} alt={Obj.getLabel(subject) ?? ''} aspect='auto' />}
21
- <div role='none' className={mx('flex items-center gap-2', cardSpacing)}>
22
- <Card.Heading classNames={cardNoSpacing}>{name}</Card.Heading>
23
- <CardSubjectMenu subject={subject} activeSpace={activeSpace} />
24
- </div>
25
- {description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
26
- </Card.SurfaceRoot>
27
- );
28
- };
package/src/types.ts DELETED
@@ -1,14 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type Schema } from 'effect';
6
- import { type PropsWithChildren } from 'react';
7
-
8
- import { type Space } from '@dxos/react-client/echo';
9
-
10
- export type PreviewProps<T extends Schema.Schema.Type<any>> = PropsWithChildren<{
11
- subject: T;
12
- role?: string;
13
- activeSpace?: Space;
14
- }>;