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

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 (128) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/neutral/PreviewPlugin.mjs +9 -0
  3. package/dist/lib/neutral/PreviewPlugin.mjs.map +7 -0
  4. package/dist/lib/neutral/PreviewPlugin.node.mjs +17 -0
  5. package/dist/lib/neutral/PreviewPlugin.node.mjs.map +7 -0
  6. package/dist/lib/neutral/PreviewPlugin.workerd.mjs +17 -0
  7. package/dist/lib/neutral/PreviewPlugin.workerd.mjs.map +7 -0
  8. package/dist/lib/neutral/capabilities/index.mjs +9 -0
  9. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  10. package/dist/lib/neutral/chunk-3SWUVHXJ.mjs +28 -0
  11. package/dist/lib/neutral/chunk-3SWUVHXJ.mjs.map +7 -0
  12. package/dist/lib/{browser/chunk-CEWM5LJG.mjs → neutral/chunk-52UEVZSF.mjs} +2 -2
  13. package/dist/lib/neutral/chunk-52UEVZSF.mjs.map +7 -0
  14. package/dist/lib/neutral/index.mjs +7 -0
  15. package/dist/lib/neutral/index.mjs.map +7 -0
  16. package/dist/lib/neutral/meta.json +1 -0
  17. package/dist/lib/neutral/meta.mjs +7 -0
  18. package/dist/lib/neutral/meta.mjs.map +7 -0
  19. package/dist/lib/neutral/plugin.mjs +11 -0
  20. package/dist/lib/neutral/plugin.mjs.map +7 -0
  21. package/dist/lib/neutral/preview-popover-MPPEMUIA.mjs +78 -0
  22. package/dist/lib/neutral/preview-popover-MPPEMUIA.mjs.map +7 -0
  23. package/dist/lib/neutral/react-surface-YFFJXXPQ.mjs +348 -0
  24. package/dist/lib/neutral/react-surface-YFFJXXPQ.mjs.map +7 -0
  25. package/dist/lib/neutral/testing.mjs +7 -0
  26. package/dist/lib/neutral/testing.mjs.map +7 -0
  27. package/dist/lib/neutral/translations.mjs +21 -0
  28. package/dist/lib/neutral/translations.mjs.map +7 -0
  29. package/dist/types/src/PreviewPlugin.d.ts +3 -1
  30. package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
  31. package/dist/types/src/PreviewPlugin.node.d.ts +4 -0
  32. package/dist/types/src/PreviewPlugin.node.d.ts.map +1 -0
  33. package/dist/types/src/PreviewPlugin.test.d.ts +2 -0
  34. package/dist/types/src/PreviewPlugin.test.d.ts.map +1 -0
  35. package/dist/types/src/PreviewPlugin.workerd.d.ts +4 -0
  36. package/dist/types/src/PreviewPlugin.workerd.d.ts.map +1 -0
  37. package/dist/types/src/capabilities/index.d.ts +3 -2
  38. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  39. package/dist/types/src/capabilities/preview-popover.d.ts +3 -2
  40. package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -1
  41. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  42. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  43. package/dist/types/src/cards/ExpandoCard.d.ts +4 -0
  44. package/dist/types/src/cards/ExpandoCard.d.ts.map +1 -0
  45. package/dist/types/src/cards/FormCard.d.ts +7 -0
  46. package/dist/types/src/cards/FormCard.d.ts.map +1 -0
  47. package/dist/types/src/cards/JsonCard.d.ts +5 -0
  48. package/dist/types/src/cards/JsonCard.d.ts.map +1 -0
  49. package/dist/types/src/cards/OrganizationCard.d.ts +3 -3
  50. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
  51. package/dist/types/src/cards/PersonCard.d.ts +5 -0
  52. package/dist/types/src/cards/PersonCard.d.ts.map +1 -0
  53. package/dist/types/src/cards/ProjectCard.d.ts +3 -3
  54. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
  55. package/dist/types/src/cards/TaskCard.d.ts +3 -3
  56. package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
  57. package/dist/types/src/cards/index.d.ts +4 -1
  58. package/dist/types/src/cards/index.d.ts.map +1 -1
  59. package/dist/types/src/index.d.ts +0 -2
  60. package/dist/types/src/index.d.ts.map +1 -1
  61. package/dist/types/src/meta.d.ts +2 -2
  62. package/dist/types/src/meta.d.ts.map +1 -1
  63. package/dist/types/src/plugin.d.ts +3 -0
  64. package/dist/types/src/plugin.d.ts.map +1 -0
  65. package/dist/types/src/stories/Card.stories.d.ts +22 -14
  66. package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
  67. package/dist/types/src/stories/testing.d.ts +15 -12
  68. package/dist/types/src/stories/testing.d.ts.map +1 -1
  69. package/dist/types/src/testing.d.ts +2 -0
  70. package/dist/types/src/testing.d.ts.map +1 -0
  71. package/dist/types/src/translations.d.ts +8 -9
  72. package/dist/types/src/translations.d.ts.map +1 -1
  73. package/dist/types/tsconfig.tsbuildinfo +1 -1
  74. package/package.json +90 -39
  75. package/src/PreviewPlugin.node.ts +16 -0
  76. package/src/PreviewPlugin.test.ts +25 -0
  77. package/src/PreviewPlugin.tsx +17 -26
  78. package/src/PreviewPlugin.workerd.ts +16 -0
  79. package/src/capabilities/index.ts +3 -3
  80. package/src/capabilities/preview-popover.ts +68 -41
  81. package/src/capabilities/react-surface.tsx +104 -135
  82. package/src/cards/ExpandoCard.tsx +76 -0
  83. package/src/cards/FormCard.tsx +48 -0
  84. package/src/cards/JsonCard.tsx +19 -0
  85. package/src/cards/OrganizationCard.tsx +17 -13
  86. package/src/cards/PersonCard.tsx +65 -0
  87. package/src/cards/ProjectCard.tsx +9 -11
  88. package/src/cards/TaskCard.tsx +26 -28
  89. package/src/cards/index.ts +4 -1
  90. package/src/index.ts +0 -3
  91. package/src/meta.ts +3 -3
  92. package/src/plugin.ts +9 -0
  93. package/src/stories/Card.stories.tsx +83 -24
  94. package/src/stories/testing.tsx +64 -76
  95. package/src/testing.ts +7 -0
  96. package/src/translations.ts +8 -8
  97. package/dist/lib/browser/chunk-CEWM5LJG.mjs.map +0 -7
  98. package/dist/lib/browser/index.mjs +0 -64
  99. package/dist/lib/browser/index.mjs.map +0 -7
  100. package/dist/lib/browser/meta.json +0 -1
  101. package/dist/lib/browser/preview-popover-RKHENTFP.mjs +0 -65
  102. package/dist/lib/browser/preview-popover-RKHENTFP.mjs.map +0 -7
  103. package/dist/lib/browser/react-surface-3AR3BFLF.mjs +0 -515
  104. package/dist/lib/browser/react-surface-3AR3BFLF.mjs.map +0 -7
  105. package/dist/lib/node-esm/chunk-Q5MUNELK.mjs +0 -19
  106. package/dist/lib/node-esm/chunk-Q5MUNELK.mjs.map +0 -7
  107. package/dist/lib/node-esm/index.mjs +0 -65
  108. package/dist/lib/node-esm/index.mjs.map +0 -7
  109. package/dist/lib/node-esm/meta.json +0 -1
  110. package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs +0 -67
  111. package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs.map +0 -7
  112. package/dist/lib/node-esm/react-surface-L37JR7U2.mjs +0 -516
  113. package/dist/lib/node-esm/react-surface-L37JR7U2.mjs.map +0 -7
  114. package/dist/types/src/cards/ContactCard.d.ts +0 -5
  115. package/dist/types/src/cards/ContactCard.d.ts.map +0 -1
  116. package/dist/types/src/components/CardComponents.d.ts +0 -16
  117. package/dist/types/src/components/CardComponents.d.ts.map +0 -1
  118. package/dist/types/src/components/CardSubjectMenu.d.ts +0 -8
  119. package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
  120. package/dist/types/src/components/index.d.ts +0 -3
  121. package/dist/types/src/components/index.d.ts.map +0 -1
  122. package/dist/types/src/types.d.ts +0 -10
  123. package/dist/types/src/types.d.ts.map +0 -1
  124. package/src/cards/ContactCard.tsx +0 -65
  125. package/src/components/CardComponents.tsx +0 -67
  126. package/src/components/CardSubjectMenu.tsx +0 -91
  127. package/src/components/index.ts +0 -6
  128. package/src/types.ts +0 -15
@@ -2,148 +2,117 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React, { useCallback } from 'react';
5
+ import * as Effect from 'effect/Effect';
6
+ import React from 'react';
6
7
 
7
- import {
8
- Capabilities,
9
- LayoutAction,
10
- Surface,
11
- contributes,
12
- createIntent,
13
- createSurface,
14
- useIntentDispatcher,
15
- } from '@dxos/app-framework';
16
- import { fullyQualifiedId, getSchema, getSpace } from '@dxos/client/echo';
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { Surface } from '@dxos/app-framework/ui';
10
+ import { AppSurface } from '@dxos/app-toolkit/ui';
17
11
  import { Obj } from '@dxos/echo';
18
- import { type JsonPath, setValue } from '@dxos/echo/internal';
19
- import { useActiveSpace } from '@dxos/plugin-space';
20
- import { useTranslation } from '@dxos/react-ui';
21
- import { Form } from '@dxos/react-ui-form';
22
- import { Card } from '@dxos/react-ui-stack';
23
- import { descriptionMessage, mx } from '@dxos/react-ui-theme';
24
- import { DataType, type ProjectionModel } from '@dxos/schema';
12
+ import { Card } from '@dxos/react-ui';
13
+ import { Expando, type ProjectionModel } from '@dxos/schema';
14
+ import { Organization, Person, Pipeline, Task } from '@dxos/types';
25
15
 
26
- import { ContactCard, OrganizationCard, ProjectCard, TaskCard } from '../cards';
27
- import { meta } from '../meta';
16
+ import { ExpandoCard, FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
28
17
 
29
- export default () =>
30
- contributes(Capabilities.ReactSurface, [
31
- //
32
- // Specific schema types.
33
- //
34
- createSurface({
35
- id: `${meta.id}/schema-popover--contact`,
36
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
37
- filter: (data): data is { subject: DataType.Person } => Obj.instanceOf(DataType.Person, data.subject),
38
- component: ({ data, role }) => {
39
- const { dispatchPromise: dispatch } = useIntentDispatcher();
40
- const space = getSpace(data.subject);
41
- const activeSpace = useActiveSpace();
42
- const handleSelect = useCallback(
43
- (org: Obj.Any) =>
44
- dispatch(
45
- createIntent(LayoutAction.Open, {
46
- part: 'main',
47
- subject: [fullyQualifiedId(org)],
48
- options: {
49
- workspace: space?.id,
50
- },
51
- }),
52
- ),
53
- [dispatch],
54
- );
18
+ export default Capability.makeModule(() =>
19
+ Effect.succeed(
20
+ Capability.contributes(Capabilities.ReactSurface, [
21
+ //
22
+ // Specific schema types.
23
+ // TODO(burdon): Create helpers and factor out.
24
+ //
55
25
 
56
- return (
57
- <ContactCard role={role} subject={data.subject} activeSpace={activeSpace} onSelect={handleSelect}>
58
- {role === 'card--popover' && <Surface role='related' data={data} />}
59
- </ContactCard>
60
- );
61
- },
62
- }),
63
- createSurface({
64
- id: `${meta.id}/schema-popover--organization`,
65
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
66
- filter: (data): data is { subject: DataType.Organization } => Obj.instanceOf(DataType.Organization, data.subject),
67
- component: ({ data, role }) => {
68
- const activeSpace = useActiveSpace();
26
+ Surface.create<{ subject: Person.Person }>({
27
+ id: 'schema-popover--contact',
28
+ position: 'hoist',
29
+ filter: AppSurface.object(AppSurface.Card, Person.Person),
30
+ component: ({ data, role }) => {
31
+ return (
32
+ <>
33
+ <PersonCard role={role} subject={data.subject} />
34
+ <Surface.Surface type={AppSurface.Related} data={data} limit={1} />
35
+ </>
36
+ );
37
+ },
38
+ }),
39
+ Surface.create({
40
+ id: 'schema-popover--organization',
41
+ position: 'hoist',
42
+ filter: AppSurface.object(AppSurface.Card, Organization.Organization),
43
+ component: ({ data, role }) => {
44
+ return (
45
+ <>
46
+ <OrganizationCard role={role} subject={data.subject} />
47
+ <Surface.Surface type={AppSurface.Related} data={data} limit={1} />
48
+ </>
49
+ );
50
+ },
51
+ }),
52
+ Surface.create({
53
+ id: 'schema-popover--project',
54
+ position: 'hoist',
55
+ filter: AppSurface.object(AppSurface.Card, Pipeline.Pipeline),
56
+ component: ({ data, role }) => {
57
+ return <ProjectCard role={role} subject={data.subject} />;
58
+ },
59
+ }),
60
+ Surface.create({
61
+ id: 'schema-popover--task',
62
+ position: 'hoist',
63
+ filter: AppSurface.object(AppSurface.Card, Task.Task),
64
+ component: ({ data, role }) => {
65
+ return <TaskCard role={role} subject={data.subject} />;
66
+ },
67
+ }),
68
+ Surface.create<AppSurface.ObjectCardData<Expando.Expando>>({
69
+ id: 'schema-popover--expando',
70
+ filter: AppSurface.object(AppSurface.Card, Expando.Expando),
71
+ component: ({ data, role }) => {
72
+ return <ExpandoCard role={role} subject={data.subject} ignorePaths={data.ignorePaths} />;
73
+ },
74
+ }),
69
75
 
70
- return (
71
- <OrganizationCard role={role} subject={data.subject} activeSpace={activeSpace}>
72
- {role === 'card--popover' && <Surface role='related' data={data} />}
73
- </OrganizationCard>
74
- );
75
- },
76
- }),
77
- createSurface({
78
- id: `${meta.id}/schema-popover--project`,
79
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
80
- filter: (data): data is { subject: DataType.Project } => Obj.instanceOf(DataType.Project, data.subject),
81
- component: ({ data, role }) => {
82
- const activeSpace = useActiveSpace();
76
+ //
77
+ // Fallback for any object.
78
+ //
83
79
 
84
- return <ProjectCard subject={data.subject} role={role} activeSpace={activeSpace} />;
85
- },
86
- }),
87
- createSurface({
88
- id: `${meta.id}/schema-popover--task`,
89
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
90
- filter: (data): data is { subject: DataType.Task } => Obj.instanceOf(DataType.Task, data.subject),
91
- component: ({ data, role }) => <TaskCard subject={data.subject} role={role} />,
92
- }),
80
+ Surface.create({
81
+ id: 'fallback-popover',
82
+ role: 'card--content',
83
+ position: 'fallback',
84
+ filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
85
+ component: ({ data, role }) => {
86
+ return <FormCard role={role} subject={data.subject} projection={data.projection} />;
87
+ },
88
+ }),
93
89
 
94
- //
95
- // Fallback for any object.
96
- //
97
- createSurface({
98
- id: `${meta.id}/fallback-popover`,
99
- role: ['card--popover', 'card--intrinsic', 'card--transclusion', 'card--extrinsic', 'card'],
100
- position: 'fallback',
101
- filter: (data): data is { subject: Obj.Any; projection?: ProjectionModel } => Obj.isObject(data.subject),
102
- component: ({ data, role }) => {
103
- const schema = getSchema(data.subject);
104
- const { t } = useTranslation(meta.id);
105
- if (!schema) {
106
- // TODO(burdon): Use Alert.
107
- return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
108
- }
90
+ Surface.create({
91
+ id: 'fallback-json',
92
+ role: 'card--content',
93
+ position: 'fallback',
94
+ filter: (data): data is Record<string, unknown> => true,
95
+ component: ({ data }) => {
96
+ return <JsonCard data={data} />;
97
+ },
98
+ }),
109
99
 
110
- const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
111
- const changedPaths = Object.keys(changed).filter((path) => changed[path]);
112
- for (const path of changedPaths) {
113
- const value = values[path];
114
- setValue(data.subject, path as JsonPath, value);
115
- }
116
- }, []);
117
-
118
- return (
119
- <Card.SurfaceRoot role={role}>
120
- <Form
121
- schema={schema}
122
- projection={data.projection}
123
- values={data.subject}
124
- readonly={role === 'card--popover' ? 'static' : false}
125
- onSave={handleSave}
126
- autoSave
127
- {...(role === 'card--intrinsic' && { outerSpacing: 'blockStart-0' })}
128
- />
129
- </Card.SurfaceRoot>
130
- );
131
- },
132
- }),
133
-
134
- createSurface({
135
- id: `${meta.id}/section`,
136
- role: ['section'],
137
- position: 'fallback',
138
- filter: (data): data is { subject: Obj.Any } => Obj.isObject(data.subject),
139
- component: ({ data }) => {
140
- return (
141
- <div role='none' className='flex justify-center'>
142
- <div role='none' className='card-max-width'>
143
- <Surface role='card' data={data} limit={1} />
100
+ Surface.create({
101
+ id: 'section',
102
+ position: 'fallback',
103
+ filter: AppSurface.subject(AppSurface.Section, Obj.isObject),
104
+ component: ({ data }) => {
105
+ return (
106
+ <div className='flex w-full justify-center'>
107
+ <div className='py-2 dx-card-min-width dx-card-max-width'>
108
+ <Card.Root>
109
+ <Surface.Surface type={AppSurface.Card} data={data} limit={1} />
110
+ </Card.Root>
111
+ </div>
144
112
  </div>
145
- </div>
146
- );
147
- },
148
- }),
149
- ]);
113
+ );
114
+ },
115
+ }),
116
+ ]),
117
+ ),
118
+ );
@@ -0,0 +1,76 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+ import React, { useCallback, useMemo } from 'react';
7
+
8
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
9
+ import { Obj } from '@dxos/echo';
10
+ import { type JsonPath, splitJsonPath } from '@dxos/effect';
11
+ import { Card } from '@dxos/react-ui';
12
+ import { Form } from '@dxos/react-ui-form';
13
+
14
+ const schemaForValue = (value: unknown): Schema.Schema.AnyNoContext | undefined => {
15
+ switch (typeof value) {
16
+ case 'string':
17
+ return Schema.String;
18
+ case 'number':
19
+ return Schema.Number;
20
+ case 'boolean':
21
+ return Schema.Boolean;
22
+ default:
23
+ return undefined;
24
+ }
25
+ };
26
+
27
+ /**
28
+ * Reserved keys: `id`, plus any `~`-prefixed key (ECHO uses `~`-prefixed
29
+ * string keys to brand entity instances and schemas — KindId,
30
+ * SchemaKindId, SnapshotKindId, etc. — and the `~` namespace is reserved
31
+ * for that purpose). They show up in `Object.keys` but aren't user data.
32
+ */
33
+ const isInternalKey = (key: string) => key === 'id' || key.startsWith('~');
34
+
35
+ export const ExpandoCard = ({ subject, ignorePaths }: AppSurface.ObjectCardProps) => {
36
+ const schema = useMemo(() => {
37
+ const ignored = new Set(ignorePaths ?? []);
38
+ const fields: Record<string, Schema.Schema.AnyNoContext> = {};
39
+ for (const key of Object.keys(subject)) {
40
+ if (isInternalKey(key) || ignored.has(key)) {
41
+ continue;
42
+ }
43
+ const fieldSchema = schemaForValue((subject as any)[key]);
44
+ if (fieldSchema) {
45
+ fields[key] = fieldSchema;
46
+ }
47
+ }
48
+ return Schema.Struct(fields);
49
+ }, [subject, ignorePaths]);
50
+
51
+ const handleSave = useCallback(
52
+ (values: any, { changed }: { changed: Record<string, boolean> }) => {
53
+ const paths = Object.keys(changed).filter((path) => changed[path]);
54
+ Obj.update(subject, () => {
55
+ for (const path of paths) {
56
+ const value = values[path];
57
+ const parts = splitJsonPath(path as JsonPath);
58
+ Obj.setValue(subject, parts, value);
59
+ }
60
+ });
61
+ },
62
+ [subject],
63
+ );
64
+
65
+ return (
66
+ <Card.Content>
67
+ <Form.Root schema={schema} values={subject} autoSave onSave={handleSave}>
68
+ <Form.Viewport>
69
+ <Form.Content>
70
+ <Form.FieldSet />
71
+ </Form.Content>
72
+ </Form.Viewport>
73
+ </Form.Root>
74
+ </Card.Content>
75
+ );
76
+ };
@@ -0,0 +1,48 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback, useMemo } from 'react';
6
+
7
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
8
+ import { Obj } from '@dxos/echo';
9
+ import { type JsonPath, splitJsonPath } from '@dxos/effect';
10
+ import { Card, useTranslation } from '@dxos/react-ui';
11
+ import { Form, omitId } from '@dxos/react-ui-form';
12
+ import { type ProjectionModel } from '@dxos/schema';
13
+ import { descriptionMessage, mx } from '@dxos/ui-theme';
14
+
15
+ import { meta } from '#meta';
16
+
17
+ export const FormCard = ({ subject, projection }: AppSurface.ObjectCardProps & { projection?: ProjectionModel }) => {
18
+ const { t } = useTranslation(meta.id);
19
+ const echoSchema = Obj.getSchema(subject);
20
+ const schema = useMemo(() => echoSchema && omitId(echoSchema), [echoSchema]);
21
+
22
+ const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
23
+ const paths = Object.keys(changed).filter((path) => changed[path]);
24
+ Obj.update(subject, () => {
25
+ for (const path of paths) {
26
+ const value = values[path];
27
+ const parts = splitJsonPath(path as JsonPath);
28
+ Obj.setValue(subject, parts, value);
29
+ }
30
+ });
31
+ }, []);
32
+
33
+ if (!schema) {
34
+ return <p className={mx(descriptionMessage)}>{t('unable-to-create-preview.message')}</p>;
35
+ }
36
+
37
+ return (
38
+ <Card.Content>
39
+ <Form.Root schema={schema} projection={projection} values={subject} autoSave onSave={handleSave}>
40
+ <Form.Viewport>
41
+ <Form.Content>
42
+ <Form.FieldSet />
43
+ </Form.Content>
44
+ </Form.Viewport>
45
+ </Form.Root>
46
+ </Card.Content>
47
+ );
48
+ };
@@ -0,0 +1,19 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { Card } from '@dxos/react-ui';
8
+ import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
9
+
10
+ export const JsonCard = ({ data }: { data: unknown }) => {
11
+ return (
12
+ <Card.Content>
13
+ <span />
14
+ {/* TODO(wittjosiah): Span whole row. */}
15
+ <JsonHighlighter data={data} />
16
+ <span />
17
+ </Card.Content>
18
+ );
19
+ };
@@ -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 AppSurface } 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 }: AppSurface.ObjectCardProps<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 AppSurface } from '@dxos/app-toolkit/ui';
11
+ import { Obj } from '@dxos/echo';
12
+ import { runAndForwardErrors } from '@dxos/effect';
13
+ import { Avatar } from '@dxos/react-ui';
14
+ import { Card } from '@dxos/react-ui';
15
+ import { type Person } from '@dxos/types';
16
+
17
+ export const PersonCard = ({ subject }: AppSurface.ObjectCardProps<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 AppSurface } 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 }: AppSurface.ObjectCardProps<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 AppSurface } from '@dxos/app-toolkit/ui';
8
9
  import { type PropertyMetaAnnotation, PropertyMetaAnnotationId } from '@dxos/echo/internal';
9
- import { Card, cardNoSpacing, cardSpacing } from '@dxos/react-ui-stack';
10
- import { mx } from '@dxos/react-ui-theme';
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 }: AppSurface.ObjectCardProps<Task.Task>) => {
14
+ const { title, status } = subject;
15
+ const statusOption = getActiveStatusOption(status);
16
+
17
+ return (
18
+ <Card.Content>
19
+ <Card.Row>
20
+ {statusOption && (
21
+ <div>
22
+ <span className='dx-tag' data-hue={statusOption.color}>
23
+ {statusOption.title}
24
+ </span>
25
+ </div>
26
+ )}
27
+ </Card.Row>
28
+ </Card.Content>
29
+ );
30
+ };
15
31
 
16
32
  // TODO(thure): Should this move upstream as a helper? Is there an easier way to get options?
17
33
  const getActiveStatusOption = (status?: string) => {
18
- 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,10 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './ContactCard';
5
+ export * from './ExpandoCard';
6
+ export * from './FormCard';
7
+ export * from './JsonCard';
6
8
  export * from './OrganizationCard';
9
+ export * from './PersonCard';
7
10
  export * from './ProjectCard';
8
11
  export * from './TaskCard';
package/src/index.ts CHANGED
@@ -3,6 +3,3 @@
3
3
  //
4
4
 
5
5
  export * from './meta';
6
- export type * from './types';
7
-
8
- 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.
package/src/plugin.ts ADDED
@@ -0,0 +1,9 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { Plugin } from '@dxos/app-framework';
6
+
7
+ import { meta } from './meta';
8
+
9
+ export const PreviewPlugin = Plugin.lazy(meta, () => import('#plugin'));