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

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 (115) 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 +32 -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 +32 -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 +31 -0
  48. package/dist/types/src/stories/Card.stories.d.ts.map +1 -0
  49. package/dist/types/src/stories/testing.d.ts +19 -0
  50. package/dist/types/src/stories/testing.d.ts.map +1 -0
  51. package/dist/types/src/translations.d.ts +6 -0
  52. package/dist/types/src/translations.d.ts.map +1 -1
  53. package/dist/types/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +46 -33
  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/cards/TaskCard.tsx +40 -0
  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 +68 -0
  70. package/src/stories/testing.tsx +84 -0
  71. package/src/translations.ts +6 -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-2UCEZUQW.mjs +0 -69
  75. package/dist/lib/browser/preview-popover-2UCEZUQW.mjs.map +0 -7
  76. package/dist/lib/browser/react-surface-CZMUEWPV.mjs +0 -303
  77. package/dist/lib/browser/react-surface-CZMUEWPV.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-OSHWR2YE.mjs +0 -71
  81. package/dist/lib/node-esm/preview-popover-OSHWR2YE.mjs.map +0 -7
  82. package/dist/lib/node-esm/react-surface-IPZBISWS.mjs +0 -304
  83. package/dist/lib/node-esm/react-surface-IPZBISWS.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/ContactCard.d.ts +0 -7
  89. package/dist/types/src/components/ContactCard.d.ts.map +0 -1
  90. package/dist/types/src/components/OrganizationCard.d.ts +0 -5
  91. package/dist/types/src/components/OrganizationCard.d.ts.map +0 -1
  92. package/dist/types/src/components/ProjectCard.d.ts +0 -5
  93. package/dist/types/src/components/ProjectCard.d.ts.map +0 -1
  94. package/dist/types/src/components/index.d.ts +0 -4
  95. package/dist/types/src/components/index.d.ts.map +0 -1
  96. package/dist/types/src/testing/ExtrinsicPreviews.stories.d.ts +0 -35
  97. package/dist/types/src/testing/ExtrinsicPreviews.stories.d.ts.map +0 -1
  98. package/dist/types/src/testing/IntrinsicPreviews.stories.d.ts +0 -35
  99. package/dist/types/src/testing/IntrinsicPreviews.stories.d.ts.map +0 -1
  100. package/dist/types/src/testing/PopoverPreviews.stories.d.ts +0 -35
  101. package/dist/types/src/testing/PopoverPreviews.stories.d.ts.map +0 -1
  102. package/dist/types/src/testing/util.d.ts +0 -80
  103. package/dist/types/src/testing/util.d.ts.map +0 -1
  104. package/dist/types/src/types.d.ts +0 -6
  105. package/dist/types/src/types.d.ts.map +0 -1
  106. package/src/capabilities/preview-popover.ts +0 -74
  107. package/src/capabilities/react-surface.tsx +0 -163
  108. package/src/components/ContactCard.tsx +0 -70
  109. package/src/components/OrganizationCard.tsx +0 -41
  110. package/src/components/ProjectCard.tsx +0 -20
  111. package/src/testing/ExtrinsicPreviews.stories.tsx +0 -55
  112. package/src/testing/IntrinsicPreviews.stories.tsx +0 -55
  113. package/src/testing/PopoverPreviews.stories.tsx +0 -55
  114. package/src/testing/util.tsx +0 -79
  115. package/src/types.ts +0 -11
@@ -1,80 +0,0 @@
1
- import type { Meta } from '@storybook/react-vite';
2
- import { type FC } from 'react';
3
- import type { PreviewProps } from '../types';
4
- export type StoryProps = {
5
- Component: FC<PreviewProps<any>>;
6
- icon?: string;
7
- withImage?: boolean;
8
- subject: 'project' | 'contact' | 'organization';
9
- role: 'card--popover' | 'card--intrinsic' | 'card--extrinsic' | 'card--transclusion';
10
- };
11
- export declare const render: Meta<StoryProps>['render'];
12
- export declare const omitImage: ({ image, ...rest }: any) => any;
13
- export declare const data: {
14
- organization: import("@dxos/live-object").Live<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
15
- image?: string | undefined;
16
- id: string;
17
- status?: "active" | "prospect" | "qualified" | "commit" | "reject" | undefined;
18
- name?: string | undefined;
19
- description?: string | undefined;
20
- website?: string | undefined;
21
- }>;
22
- contact: import("@dxos/live-object").Live<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
23
- fields?: {
24
- readonly label: string;
25
- readonly category?: string | undefined;
26
- readonly value: string;
27
- }[] | undefined;
28
- fullName?: string | undefined;
29
- preferredName?: string | undefined;
30
- nickname?: string | undefined;
31
- image?: string | undefined;
32
- organization?: import("@dxos/echo-schema").Ref<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
33
- id: string;
34
- name?: string | undefined;
35
- description?: string | undefined;
36
- status?: "prospect" | "qualified" | "active" | "commit" | "reject" | undefined;
37
- image?: string | undefined;
38
- website?: string | undefined;
39
- }> | undefined;
40
- jobTitle?: string | undefined;
41
- department?: string | undefined;
42
- notes?: string | undefined;
43
- emails?: {
44
- readonly label?: string | undefined;
45
- readonly value: string;
46
- }[] | undefined;
47
- identities?: {
48
- readonly label?: string | undefined;
49
- readonly value: string;
50
- }[] | undefined;
51
- phoneNumbers?: {
52
- readonly label?: string | undefined;
53
- readonly value: string;
54
- }[] | undefined;
55
- addresses?: {
56
- readonly label?: string | undefined;
57
- readonly value: {
58
- readonly street?: string | undefined;
59
- readonly extended?: string | undefined;
60
- readonly locality?: string | undefined;
61
- readonly region?: string | undefined;
62
- readonly postalCode?: string | undefined;
63
- readonly postOfficeBoxNumber?: string | undefined;
64
- readonly country?: string | undefined;
65
- };
66
- }[] | undefined;
67
- urls?: {
68
- readonly label?: string | undefined;
69
- readonly value: string;
70
- }[] | undefined;
71
- birthday?: string | undefined;
72
- }>;
73
- project: import("@dxos/live-object").Live<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
74
- image?: string | undefined;
75
- id: string;
76
- name: string;
77
- description?: string | undefined;
78
- }>;
79
- };
80
- //# sourceMappingURL=util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/testing/util.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAc,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAOvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,cAAc,CAAC;IAChD,IAAI,EAAE,eAAe,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;CACtF,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,CAa7C,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,oBAAoB,GAAG,QAAS,CAAC;AAE3D,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCb,CAAC"}
@@ -1,6 +0,0 @@
1
- import { type PropsWithChildren } from 'react';
2
- export type PreviewProps<T extends object> = PropsWithChildren<{
3
- subject: T;
4
- role?: string;
5
- }>;
6
- //# 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,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI,iBAAiB,CAAC;IAC7D,OAAO,EAAE,CAAC,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC,CAAC"}
@@ -1,74 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capabilities, LayoutAction, contributes, createIntent, type PluginContext } from '@dxos/app-framework';
6
- import { addEventListener } from '@dxos/async';
7
- import { type Client, resolveRef } from '@dxos/client';
8
- import { parseId, type Space } from '@dxos/client/echo';
9
- import { DXN } from '@dxos/keys';
10
- import { type DxRefTagActivate } from '@dxos/lit-ui';
11
- import { log } from '@dxos/log';
12
- import { ClientCapabilities } from '@dxos/plugin-client';
13
- import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';
14
-
15
- const customEventOptions = { capture: true, passive: false };
16
-
17
- const handlePreviewLookup = async (
18
- client: Client,
19
- defaultSpace: Space,
20
- { ref, label }: PreviewLinkRef,
21
- ): Promise<PreviewLinkTarget | null> => {
22
- try {
23
- const dxn = DXN.parse(ref);
24
- if (!dxn) {
25
- return null;
26
- }
27
-
28
- const object = await resolveRef(client, dxn, defaultSpace);
29
- return { label, object };
30
- } catch (err) {
31
- return null;
32
- }
33
- };
34
-
35
- export default (context: PluginContext) => {
36
- // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
37
- const handleDxRefTagActivate = async ({ refId, label, trigger }: DxRefTagActivate) => {
38
- const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
39
- const client = context.getCapability(ClientCapabilities.Client);
40
- const [layout] = context.getCapabilities(Capabilities.Layout);
41
- const { spaceId } = parseId(layout.workspace);
42
- const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
43
- const result = await handlePreviewLookup(client, space, { ref: refId, label });
44
- if (!result) {
45
- return;
46
- }
47
-
48
- await dispatch(
49
- createIntent(LayoutAction.UpdatePopover, {
50
- part: 'popover',
51
- subject: result.object,
52
- options: {
53
- state: true,
54
- variant: 'virtual',
55
- anchor: trigger,
56
- },
57
- }),
58
- );
59
- };
60
-
61
- let cleanup: () => void;
62
- if (document.defaultView) {
63
- cleanup = addEventListener(
64
- document.defaultView,
65
- 'dx-ref-tag-activate' as any,
66
- handleDxRefTagActivate,
67
- customEventOptions,
68
- );
69
- } else {
70
- log.warn('No default view found');
71
- }
72
-
73
- return contributes(Capabilities.Null, null, () => cleanup());
74
- };
@@ -1,163 +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 { useQuery, useSpace } from '@dxos/react-client/echo';
23
- import { useTranslation } from '@dxos/react-ui';
24
- import { Form } from '@dxos/react-ui-form';
25
- import { Card } from '@dxos/react-ui-stack';
26
- import { TableView } from '@dxos/react-ui-table/types';
27
- import { descriptionMessage, mx } from '@dxos/react-ui-theme';
28
- import { DataType } from '@dxos/schema';
29
-
30
- import { ContactCard, OrganizationCard, ProjectCard } from '../components';
31
- import { PREVIEW_PLUGIN } from '../meta';
32
-
33
- export default () =>
34
- contributes(Capabilities.ReactSurface, [
35
- //
36
- // Specific schema types.
37
- //
38
- createSurface({
39
- id: `${PREVIEW_PLUGIN}/schema-popover--contact`,
40
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
41
- filter: (data): data is { subject: DataType.Person } => Obj.instanceOf(DataType.Person, data.subject),
42
- component: ({ data, role }) => {
43
- const { dispatch } = useIntentDispatcher();
44
- const space = getSpace(data.subject);
45
- const defaultSpace = useSpace();
46
-
47
- const currentSpaceOrgs = useQuery(space, Filter.type(DataType.Organization));
48
- const currentSpaceViews = useQuery(space, Filter.type(DataType.View));
49
- const defaultSpaceViews = useQuery(defaultSpace, Filter.type(DataType.View));
50
- const currentSpaceOrgTable = currentSpaceViews.find(
51
- (view) =>
52
- view.query.typename === DataType.Organization.typename &&
53
- Obj.instanceOf(TableView, view.presentation.target),
54
- );
55
- const defaultSpaceOrgTable = defaultSpaceViews.find(
56
- (view) =>
57
- view.query.typename === DataType.Organization.typename &&
58
- Obj.instanceOf(TableView, view.presentation.target),
59
- );
60
-
61
- // TODO(wittjosiah): Generalized way of handling related objects navigation.
62
- const handleOrgClick = useCallback(
63
- (org: DataType.Organization) =>
64
- Effect.gen(function* () {
65
- const view = currentSpaceOrgs.includes(org) ? currentSpaceOrgTable : defaultSpaceOrgTable;
66
- yield* dispatch(
67
- createIntent(LayoutAction.UpdatePopover, {
68
- part: 'popover',
69
- options: {
70
- state: false,
71
- anchorId: '',
72
- },
73
- }),
74
- );
75
- if (view) {
76
- const id = fullyQualifiedId(view);
77
- yield* dispatch(
78
- createIntent(LayoutAction.Open, {
79
- part: 'main',
80
- subject: [id],
81
- options: { workspace: space?.id },
82
- }),
83
- );
84
- yield* dispatch(
85
- createIntent(DeckAction.ChangeCompanion, {
86
- primary: id,
87
- companion: [id, 'selected-objects'].join(ATTENDABLE_PATH_SEPARATOR),
88
- }),
89
- );
90
- yield* dispatch(
91
- createIntent(AttentionAction.Select, {
92
- contextId: id,
93
- selection: { mode: 'multi', ids: [org.id] },
94
- }),
95
- );
96
- }
97
- }).pipe(Effect.runPromise),
98
- [dispatch, currentSpaceOrgs, currentSpaceOrgTable, defaultSpaceOrgTable],
99
- );
100
-
101
- return (
102
- <ContactCard role={role} subject={data.subject} onOrgClick={handleOrgClick}>
103
- {role === 'card--popover' && <Surface role='related' data={data} />}
104
- </ContactCard>
105
- );
106
- },
107
- }),
108
- createSurface({
109
- id: `${PREVIEW_PLUGIN}/schema-popover--organization`,
110
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
111
- filter: (data): data is { subject: DataType.Organization } => Obj.instanceOf(DataType.Organization, data.subject),
112
- component: ({ data, role }) => (
113
- <OrganizationCard role={role} subject={data.subject}>
114
- {role === 'card--popover' && <Surface role='related' data={data} />}
115
- </OrganizationCard>
116
- ),
117
- }),
118
- createSurface({
119
- id: `${PREVIEW_PLUGIN}/schema-popover--project`,
120
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
121
- filter: (data): data is { subject: DataType.Project } => Obj.instanceOf(DataType.Project, data.subject),
122
- component: ({ data, role }) => <ProjectCard subject={data.subject} role={role} />,
123
- }),
124
-
125
- //
126
- // Fallback for any object.
127
- //
128
- createSurface({
129
- id: `${PREVIEW_PLUGIN}/fallback-popover`,
130
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
131
- position: 'fallback',
132
- filter: (data): data is { subject: Obj.Any } => Obj.isObject(data.subject),
133
- component: ({ data, role }) => {
134
- const schema = getSchema(data.subject);
135
- const { t } = useTranslation(PREVIEW_PLUGIN);
136
- if (!schema) {
137
- // TODO(burdon): Use Alert.
138
- return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
139
- }
140
-
141
- const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
142
- const changedPaths = Object.keys(changed).filter((path) => changed[path]);
143
- for (const path of changedPaths) {
144
- const value = values[path];
145
- setValue(data.subject, path as JsonPath, value);
146
- }
147
- }, []);
148
-
149
- return (
150
- <Card.SurfaceRoot role={role}>
151
- <Form
152
- schema={schema}
153
- values={data.subject}
154
- readonly={role === 'card--popover'}
155
- onSave={handleSave}
156
- autoSave
157
- {...(role === 'card--intrinsic' && { outerSpacing: 'blockStart-0' })}
158
- />
159
- </Card.SurfaceRoot>
160
- );
161
- },
162
- }),
163
- ]);
@@ -1,70 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React, { Fragment } from 'react';
6
-
7
- import { Icon, Avatar, Button } from '@dxos/react-ui';
8
- import { 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
- export const ContactCard = ({
15
- children,
16
- subject: { fullName, image, organization, emails },
17
- onOrgClick,
18
- role,
19
- }: PreviewProps<DataType.Person> & { onOrgClick?: (org: DataType.Organization) => void }) => {
20
- const organizationName = organization && typeof organization === 'object' ? organization.target?.name : organization;
21
- return (
22
- <Card.SurfaceRoot role={role}>
23
- <Avatar.Root>
24
- <Card.Text role='group' classNames='grid gap-3 grid-cols-[min-content_1fr]'>
25
- <Avatar.Content imgSrc={image} icon='ph--user--regular' size={16} hue='neutral' />
26
- <div role='none' className='bs-min self-center'>
27
- <Avatar.Label asChild>
28
- <h2 className={cardHeading}>{fullName}</h2>
29
- </Avatar.Label>
30
- </div>
31
- </Card.Text>
32
- </Avatar.Root>
33
- {organizationName && (
34
- <Card.Chrome>
35
- {typeof organization === 'object' && onOrgClick ? (
36
- <Button variant='ghost' classNames='gap-2 text-start' onClick={() => onOrgClick(organization.target!)}>
37
- <Icon icon='ph--buildings--regular' size={5} classNames='text-subdued' />
38
- <span className='min-is-0 flex-1 truncate'>{organizationName}</span>
39
- <Icon icon='ph--arrow-right--regular' />
40
- </Button>
41
- ) : (
42
- <p className='dx-button gap-2' data-variant='ghost'>
43
- <Icon icon='ph--buildings--regular' size={5} classNames='text-subdued' />
44
- <span className='min-is-0 flex-1 truncate'>{organizationName}</span>
45
- </p>
46
- )}
47
- </Card.Chrome>
48
- )}
49
- <dl
50
- className={mx(
51
- cardText,
52
- 'grid gap-2 grid-cols-[min-content_1fr] [&_dt]:text-subdued [&_dt]:pbs-0.5 [&_dd]:min-is-0',
53
- )}
54
- >
55
- {emails?.length &&
56
- emails.map(({ label, value }) => (
57
- <Fragment key={value}>
58
- <dt>
59
- <Icon icon='ph--at--regular' size={5} />
60
- </dt>
61
- <dd key={value} className='break-words'>
62
- {value}
63
- </dd>
64
- </Fragment>
65
- ))}
66
- </dl>
67
- {children}
68
- </Card.SurfaceRoot>
69
- );
70
- };
@@ -1,41 +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 } from '@dxos/react-ui-stack';
9
- import { type DataType } from '@dxos/schema';
10
-
11
- import { type PreviewProps } from '../types';
12
-
13
- export const OrganizationCard = ({
14
- children,
15
- subject: { name, image, description, website },
16
- role,
17
- }: PreviewProps<DataType.Organization>) => {
18
- return (
19
- <Card.SurfaceRoot role={role}>
20
- <Card.Poster alt={name!} {...(image ? { image } : { icon: 'ph--building-office--regular' })} />
21
- <Card.Heading>{name}</Card.Heading>
22
- {description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
23
- {website && (
24
- <Card.Chrome>
25
- <a
26
- className='dx-button dx-focus-ring gap-2'
27
- data-variant='ghost'
28
- href={website}
29
- target='_blank'
30
- rel='noreferrer'
31
- >
32
- <Icon icon='ph--link--regular' size={5} classNames='text-subdued' />
33
- <span className='grow'>{website}</span>
34
- <Icon icon='ph--arrow-square-out--regular' />
35
- </a>
36
- </Card.Chrome>
37
- )}
38
- {children}
39
- </Card.SurfaceRoot>
40
- );
41
- };
@@ -1,20 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { Card } from '@dxos/react-ui-stack';
8
- import { type DataType } from '@dxos/schema';
9
-
10
- import { type PreviewProps } from '../types';
11
-
12
- export const ProjectCard = ({ subject: { name, image, description }, role }: PreviewProps<DataType.Project>) => {
13
- return (
14
- <Card.SurfaceRoot role={role}>
15
- {image && <Card.Poster image={image} alt={name} aspect='auto' />}
16
- <Card.Heading>{name}</Card.Heading>
17
- {description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
18
- </Card.SurfaceRoot>
19
- );
20
- };
@@ -1,55 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { type Meta } from '@storybook/react-vite';
8
-
9
- import { withTheme, withLayout } from '@dxos/storybook-utils';
10
-
11
- import { type StoryProps, render } from './util';
12
- import { ContactCard, OrganizationCard, ProjectCard } from '../components';
13
- import { translations } from '../translations';
14
-
15
- const meta: Meta<StoryProps> = {
16
- title: 'Cards/plugin-preview/Extrinsic',
17
- render,
18
- decorators: [withTheme, withLayout()],
19
- parameters: {
20
- layout: 'centered',
21
- translations,
22
- },
23
- };
24
-
25
- export default meta;
26
-
27
- export const Contact = {
28
- args: {
29
- Component: ContactCard,
30
- icon: 'ph--user--regular',
31
- subject: 'contact',
32
- withImage: true,
33
- role: 'card--extrinsic',
34
- },
35
- };
36
-
37
- export const Organization = {
38
- args: {
39
- Component: OrganizationCard,
40
- icon: 'ph--building-office--regular',
41
- subject: 'organization',
42
- withImage: true,
43
- role: 'card--extrinsic',
44
- },
45
- };
46
-
47
- export const Project = {
48
- args: {
49
- Component: ProjectCard,
50
- icon: 'ph--building--regular',
51
- subject: 'project',
52
- withImage: true,
53
- role: 'card--extrinsic',
54
- },
55
- };
@@ -1,55 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { type Meta } from '@storybook/react-vite';
8
-
9
- import { withTheme, withLayout } from '@dxos/storybook-utils';
10
-
11
- import { type StoryProps, render } from './util';
12
- import { ContactCard, OrganizationCard, ProjectCard } from '../components';
13
- import { translations } from '../translations';
14
-
15
- const meta: Meta<StoryProps> = {
16
- title: 'Cards/plugin-preview/Intrinsic',
17
- render,
18
- decorators: [withTheme, withLayout()],
19
- parameters: {
20
- layout: 'centered',
21
- translations,
22
- },
23
- };
24
-
25
- export default meta;
26
-
27
- export const Contact = {
28
- args: {
29
- Component: ContactCard,
30
- icon: 'ph--user--regular',
31
- subject: 'contact',
32
- withImage: true,
33
- role: 'card--intrinsic',
34
- },
35
- };
36
-
37
- export const Organization = {
38
- args: {
39
- Component: OrganizationCard,
40
- icon: 'ph--building-office--regular',
41
- subject: 'organization',
42
- withImage: true,
43
- role: 'card--intrinsic',
44
- },
45
- };
46
-
47
- export const Project = {
48
- args: {
49
- Component: ProjectCard,
50
- icon: 'ph--building--regular',
51
- subject: 'project',
52
- withImage: true,
53
- role: 'card--intrinsic',
54
- },
55
- };
@@ -1,55 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { type Meta } from '@storybook/react-vite';
8
-
9
- import { withTheme, withLayout } from '@dxos/storybook-utils';
10
-
11
- import { type StoryProps, render } from './util';
12
- import { ContactCard, OrganizationCard, ProjectCard } from '../components';
13
- import { translations } from '../translations';
14
-
15
- const meta: Meta<StoryProps> = {
16
- title: 'Cards/plugin-preview/Popover',
17
- render,
18
- decorators: [withTheme, withLayout()],
19
- parameters: {
20
- layout: 'centered',
21
- translations,
22
- },
23
- };
24
-
25
- export default meta;
26
-
27
- export const Contact = {
28
- args: {
29
- Component: ContactCard,
30
- icon: 'ph--user--regular',
31
- subject: 'contact',
32
- withImage: true,
33
- role: 'card--popover',
34
- },
35
- };
36
-
37
- export const Organization = {
38
- args: {
39
- Component: OrganizationCard,
40
- icon: 'ph--building-office--regular',
41
- subject: 'organization',
42
- withImage: true,
43
- role: 'card--popover',
44
- },
45
- };
46
-
47
- export const Project = {
48
- args: {
49
- Component: ProjectCard,
50
- icon: 'ph--building--regular',
51
- subject: 'project',
52
- withImage: true,
53
- role: 'card--popover',
54
- },
55
- };