@dxos/plugin-preview 0.8.4-main.422d1c7879 → 0.8.4-main.43cb759274
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.
- package/LICENSE +102 -5
- package/dist/lib/neutral/PreviewPlugin.mjs +9 -0
- package/dist/lib/neutral/PreviewPlugin.mjs.map +7 -0
- package/dist/lib/neutral/PreviewPlugin.node.mjs +17 -0
- package/dist/lib/neutral/PreviewPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/PreviewPlugin.workerd.mjs +17 -0
- package/dist/lib/neutral/PreviewPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +9 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3SWUVHXJ.mjs +28 -0
- package/dist/lib/neutral/chunk-3SWUVHXJ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QOM5APM7.mjs +23 -0
- package/dist/lib/neutral/chunk-QOM5APM7.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +7 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +7 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +11 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/preview-popover-FLMYMFCH.mjs +94 -0
- package/dist/lib/neutral/preview-popover-FLMYMFCH.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-HDOPNIQM.mjs +406 -0
- package/dist/lib/neutral/react-surface-HDOPNIQM.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +7 -0
- package/dist/lib/neutral/testing.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +21 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/types/src/PreviewPlugin.d.ts +1 -0
- package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
- package/dist/types/src/PreviewPlugin.node.d.ts +4 -0
- package/dist/types/src/PreviewPlugin.node.d.ts.map +1 -0
- package/dist/types/src/PreviewPlugin.test.d.ts +2 -0
- package/dist/types/src/PreviewPlugin.test.d.ts.map +1 -0
- package/dist/types/src/PreviewPlugin.workerd.d.ts +4 -0
- package/dist/types/src/PreviewPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/cards/ExpandoCard.d.ts +4 -0
- package/dist/types/src/cards/ExpandoCard.d.ts.map +1 -0
- package/dist/types/src/cards/FormCard.d.ts +12 -2
- package/dist/types/src/cards/FormCard.d.ts.map +1 -1
- package/dist/types/src/cards/JsonCard.d.ts.map +1 -1
- package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
- package/dist/types/src/cards/PersonCard.d.ts.map +1 -1
- package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
- package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
- package/dist/types/src/cards/index.d.ts +1 -0
- package/dist/types/src/cards/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +3 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/stories/Card.stories.d.ts +31 -9
- package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts +43 -4
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +8 -9
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +70 -41
- package/src/PreviewPlugin.node.ts +16 -0
- package/src/PreviewPlugin.test.ts +25 -0
- package/src/PreviewPlugin.tsx +4 -3
- package/src/PreviewPlugin.workerd.ts +16 -0
- package/src/capabilities/preview-popover.ts +29 -4
- package/src/capabilities/react-surface.tsx +59 -18
- package/src/cards/ExpandoCard.tsx +76 -0
- package/src/cards/FormCard.tsx +90 -23
- package/src/cards/JsonCard.tsx +5 -2
- package/src/cards/OrganizationCard.tsx +2 -2
- package/src/cards/PersonCard.tsx +2 -2
- package/src/cards/ProjectCard.tsx +2 -2
- package/src/cards/TaskCard.tsx +4 -3
- package/src/cards/index.ts +1 -0
- package/src/index.ts +0 -2
- package/src/meta.ts +7 -4
- package/src/plugin.ts +9 -0
- package/src/stories/Card.stories.tsx +76 -6
- package/src/stories/testing.tsx +69 -7
- package/src/testing.ts +7 -0
- package/dist/lib/browser/index.mjs +0 -59
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -61
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
package/src/cards/JsonCard.tsx
CHANGED
|
@@ -9,8 +9,11 @@ import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
|
9
9
|
|
|
10
10
|
export const JsonCard = ({ data }: { data: unknown }) => {
|
|
11
11
|
return (
|
|
12
|
-
<Card.
|
|
12
|
+
<Card.Body>
|
|
13
|
+
<span />
|
|
14
|
+
{/* TODO(wittjosiah): Span whole row. */}
|
|
13
15
|
<JsonHighlighter data={data} />
|
|
14
|
-
|
|
16
|
+
<span />
|
|
17
|
+
</Card.Body>
|
|
15
18
|
);
|
|
16
19
|
};
|
|
@@ -12,7 +12,7 @@ export const OrganizationCard = ({ subject }: AppSurface.ObjectCardProps<Organiz
|
|
|
12
12
|
const { name, image, description, website } = subject;
|
|
13
13
|
|
|
14
14
|
return (
|
|
15
|
-
<Card.
|
|
15
|
+
<Card.Body>
|
|
16
16
|
<Card.Poster
|
|
17
17
|
alt={name ?? ''}
|
|
18
18
|
{...(image ? { image } : { icon: 'ph--building-office--regular' })}
|
|
@@ -24,6 +24,6 @@ export const OrganizationCard = ({ subject }: AppSurface.ObjectCardProps<Organiz
|
|
|
24
24
|
</Card.Row>
|
|
25
25
|
)}
|
|
26
26
|
{website && <Card.Link label={website} href={website} />}
|
|
27
|
-
</Card.
|
|
27
|
+
</Card.Body>
|
|
28
28
|
);
|
|
29
29
|
};
|
package/src/cards/PersonCard.tsx
CHANGED
|
@@ -35,7 +35,7 @@ export const PersonCard = ({ subject }: AppSurface.ObjectCardProps<Person.Person
|
|
|
35
35
|
}, [invoke, organization]);
|
|
36
36
|
|
|
37
37
|
return (
|
|
38
|
-
<Card.
|
|
38
|
+
<Card.Body>
|
|
39
39
|
<Avatar.Root>
|
|
40
40
|
{image && (
|
|
41
41
|
<Card.Row className='py-1'>
|
|
@@ -60,6 +60,6 @@ export const PersonCard = ({ subject }: AppSurface.ObjectCardProps<Person.Person
|
|
|
60
60
|
</Card.Row>
|
|
61
61
|
))}
|
|
62
62
|
</Avatar.Root>
|
|
63
|
-
</Card.
|
|
63
|
+
</Card.Body>
|
|
64
64
|
);
|
|
65
65
|
};
|
|
@@ -13,10 +13,10 @@ export const ProjectCard = ({ subject }: AppSurface.ObjectCardProps<Pipeline.Pip
|
|
|
13
13
|
const { image, description } = subject;
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
|
-
<Card.
|
|
16
|
+
<Card.Body>
|
|
17
17
|
{image && <Card.Poster image={image} alt={Obj.getLabel(subject) ?? ''} aspect='auto' />}
|
|
18
18
|
{/* <CardHeader label={name} subject={subject} db={db} /> */}
|
|
19
19
|
{description && <Card.Text variant='description'>{description}</Card.Text>}
|
|
20
|
-
</Card.
|
|
20
|
+
</Card.Body>
|
|
21
21
|
);
|
|
22
22
|
};
|
package/src/cards/TaskCard.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import * as SchemaAST from 'effect/SchemaAST';
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
9
|
+
import { Type } from '@dxos/echo';
|
|
9
10
|
import { type PropertyMetaAnnotation, PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
10
11
|
import { Card } from '@dxos/react-ui';
|
|
11
12
|
import { Task } from '@dxos/types';
|
|
@@ -15,7 +16,7 @@ export const TaskCard = ({ subject }: AppSurface.ObjectCardProps<Task.Task>) =>
|
|
|
15
16
|
const statusOption = getActiveStatusOption(status);
|
|
16
17
|
|
|
17
18
|
return (
|
|
18
|
-
<Card.
|
|
19
|
+
<Card.Body>
|
|
19
20
|
<Card.Row>
|
|
20
21
|
{statusOption && (
|
|
21
22
|
<div>
|
|
@@ -25,13 +26,13 @@ export const TaskCard = ({ subject }: AppSurface.ObjectCardProps<Task.Task>) =>
|
|
|
25
26
|
</div>
|
|
26
27
|
)}
|
|
27
28
|
</Card.Row>
|
|
28
|
-
</Card.
|
|
29
|
+
</Card.Body>
|
|
29
30
|
);
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
// TODO(thure): Should this move upstream as a helper? Is there an easier way to get options?
|
|
33
34
|
const getActiveStatusOption = (status?: string) => {
|
|
34
|
-
const properties = SchemaAST.getPropertySignatures(Task.Task.ast);
|
|
35
|
+
const properties = SchemaAST.getPropertySignatures(Type.getSchema(Task.Task).ast);
|
|
35
36
|
const statusProperty = properties.find((p) => p.name === 'status');
|
|
36
37
|
// TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
|
|
37
38
|
const statusMeta = SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(
|
package/src/cards/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { DXN } from '@dxos/keys';
|
|
6
7
|
import { trim } from '@dxos/util';
|
|
7
8
|
|
|
8
|
-
export const meta
|
|
9
|
-
|
|
9
|
+
export const meta = Plugin.makeMeta({
|
|
10
|
+
key: DXN.make('org.dxos.plugin.preview'),
|
|
10
11
|
name: 'Preview',
|
|
12
|
+
author: 'DXOS',
|
|
11
13
|
description: trim`
|
|
12
14
|
Rich preview panel for viewing object content without opening full editors.
|
|
13
15
|
Quick peek at documents, images, and data with inline rendering.
|
|
14
16
|
`,
|
|
15
17
|
icon: 'ph--eye--regular',
|
|
16
18
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',
|
|
17
|
-
|
|
19
|
+
tags: ['system'],
|
|
20
|
+
});
|
package/src/plugin.ts
ADDED
|
@@ -9,12 +9,24 @@ import { withPluginManager } from '@dxos/app-framework/testing';
|
|
|
9
9
|
import { corePlugins } from '@dxos/plugin-testing';
|
|
10
10
|
import { random } from '@dxos/random';
|
|
11
11
|
import { Card } from '@dxos/react-ui';
|
|
12
|
-
import { withLayout } from '@dxos/react-ui/testing';
|
|
12
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
13
|
+
import { type Expando } from '@dxos/schema';
|
|
13
14
|
import { type Organization, type Person, type Pipeline, type Task } from '@dxos/types';
|
|
14
15
|
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
import {
|
|
16
|
+
import { translations } from '#translations';
|
|
17
|
+
|
|
18
|
+
import { ExpandoCard, FormCard, JsonCard, OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
|
|
19
|
+
import {
|
|
20
|
+
DefaultStory,
|
|
21
|
+
createExpando,
|
|
22
|
+
createOrganization,
|
|
23
|
+
createPerson,
|
|
24
|
+
createPersonEmpty,
|
|
25
|
+
createProject,
|
|
26
|
+
createTableEmpty,
|
|
27
|
+
createTask,
|
|
28
|
+
createUnknown,
|
|
29
|
+
} from './testing';
|
|
18
30
|
|
|
19
31
|
random.seed(999);
|
|
20
32
|
|
|
@@ -22,6 +34,11 @@ const meta = {
|
|
|
22
34
|
title: 'plugins/plugin-preview/cards/Card',
|
|
23
35
|
render: DefaultStory,
|
|
24
36
|
decorators: [
|
|
37
|
+
// `Card` and its descendants in `@dxos/react-ui` consume `ThemeContext`
|
|
38
|
+
// for tx-token resolution; without this the stories trip the surface's
|
|
39
|
+
// `ErrorBoundary` with "Missing ThemeContext" and the storybook test
|
|
40
|
+
// assert-no-error fails.
|
|
41
|
+
withTheme(),
|
|
25
42
|
withLayout({ layout: 'fullscreen' }),
|
|
26
43
|
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
27
44
|
withPluginManager({ plugins: corePlugins() }),
|
|
@@ -43,6 +60,52 @@ export const _Form: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
|
43
60
|
},
|
|
44
61
|
};
|
|
45
62
|
|
|
63
|
+
export const _FormEditable: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
64
|
+
args: {
|
|
65
|
+
Component: FormCard,
|
|
66
|
+
createObject: createPerson,
|
|
67
|
+
image: true,
|
|
68
|
+
componentProps: { readonly: false, layout: 'full' },
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Empty-state variant: the subject has no resolvable schema so `FormCard` renders
|
|
74
|
+
* `<Card.Body><Card.Row><Card.Text variant='description'>No preview</Card.Text></Card.Row></Card.Body>`.
|
|
75
|
+
* Use this story to verify the empty message lands in the card's center column.
|
|
76
|
+
*/
|
|
77
|
+
export const _FormEmpty: StoryObj<typeof DefaultStory> = {
|
|
78
|
+
args: {
|
|
79
|
+
Component: FormCard,
|
|
80
|
+
createObject: createUnknown,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* No-values variant: the subject has a valid schema (Person) but no populated
|
|
86
|
+
* fields, so `FormCard` falls through to the same empty state instead of
|
|
87
|
+
* rendering an empty scrollarea.
|
|
88
|
+
*/
|
|
89
|
+
export const _FormNoValues: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
90
|
+
args: {
|
|
91
|
+
Component: FormCard,
|
|
92
|
+
createObject: createPersonEmpty,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Table-like variant: the subject has values only in form-hidden fields
|
|
98
|
+
* (`view`, `sizes` annotated `FormInputAnnotation.set(false)`). `FormCard`
|
|
99
|
+
* must consult the schema's form-input annotations — not just `Object.keys` —
|
|
100
|
+
* to recognize this case and fall through to the empty state.
|
|
101
|
+
*/
|
|
102
|
+
export const _FormTableEmpty: StoryObj<typeof DefaultStory<any>> = {
|
|
103
|
+
args: {
|
|
104
|
+
Component: FormCard,
|
|
105
|
+
createObject: createTableEmpty,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
46
109
|
export const _Person: StoryObj<typeof DefaultStory<Person.Person>> = {
|
|
47
110
|
args: {
|
|
48
111
|
Component: PersonCard,
|
|
@@ -75,6 +138,13 @@ export const _Task: StoryObj<typeof DefaultStory<Task.Task>> = {
|
|
|
75
138
|
},
|
|
76
139
|
};
|
|
77
140
|
|
|
141
|
+
export const _Expando: StoryObj<typeof DefaultStory<Expando.Expando>> = {
|
|
142
|
+
args: {
|
|
143
|
+
Component: ExpandoCard,
|
|
144
|
+
createObject: createExpando,
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
|
|
78
148
|
export const _Json = {
|
|
79
149
|
render: () => {
|
|
80
150
|
const data = {
|
|
@@ -94,10 +164,10 @@ export const _Json = {
|
|
|
94
164
|
<div className='flex justify-center p-16'>
|
|
95
165
|
<div className='dx-card-min-width dx-card-max-width'>
|
|
96
166
|
<Card.Root>
|
|
97
|
-
<Card.
|
|
167
|
+
<Card.Header>
|
|
98
168
|
<Card.IconBlock />
|
|
99
169
|
<Card.Title>JSON</Card.Title>
|
|
100
|
-
</Card.
|
|
170
|
+
</Card.Header>
|
|
101
171
|
<JsonCard data={data} />
|
|
102
172
|
</Card.Root>
|
|
103
173
|
</div>
|
package/src/stories/testing.tsx
CHANGED
|
@@ -2,22 +2,31 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
5
6
|
import React, { type FC, useMemo } from 'react';
|
|
6
7
|
|
|
7
8
|
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
|
-
import { Obj, Ref } from '@dxos/echo';
|
|
9
|
+
import { DXN, Obj, Ref, Type } from '@dxos/echo';
|
|
10
|
+
import { Annotation } from '@dxos/echo';
|
|
9
11
|
import { random } from '@dxos/random';
|
|
10
12
|
import { Card } from '@dxos/react-ui';
|
|
11
13
|
import { CardContainer, type CardContainerProps } from '@dxos/react-ui-mosaic/testing';
|
|
14
|
+
import { Expando } from '@dxos/schema';
|
|
12
15
|
import { Organization, Person, Pipeline, Task } from '@dxos/types';
|
|
13
16
|
|
|
14
|
-
export type DefaultStoryProps<T extends Obj.Any> = {
|
|
15
|
-
Component: FC<AppSurface.ObjectCardProps<T
|
|
17
|
+
export type DefaultStoryProps<T extends Obj.Any, P extends {} = {}> = {
|
|
18
|
+
Component: FC<AppSurface.ObjectCardProps<T> & P>;
|
|
16
19
|
createObject: () => T;
|
|
17
20
|
image?: boolean;
|
|
21
|
+
componentProps?: P;
|
|
18
22
|
};
|
|
19
23
|
|
|
20
|
-
export const DefaultStory = <T extends Obj.Any
|
|
24
|
+
export const DefaultStory = <T extends Obj.Any, P extends {} = {}>({
|
|
25
|
+
Component,
|
|
26
|
+
createObject,
|
|
27
|
+
image,
|
|
28
|
+
componentProps,
|
|
29
|
+
}: DefaultStoryProps<T, P>) => {
|
|
21
30
|
const object = useMemo(() => createObject(), [createObject]);
|
|
22
31
|
const roles: CardContainerProps['role'][] = ['intrinsic', 'popover'];
|
|
23
32
|
|
|
@@ -29,12 +38,16 @@ export const DefaultStory = <T extends Obj.Any>({ Component, createObject, image
|
|
|
29
38
|
<span className='text-sm text-description'>{role}</span>
|
|
30
39
|
<CardContainer role={role}>
|
|
31
40
|
<Card.Root border={false}>
|
|
32
|
-
<Card.
|
|
41
|
+
<Card.Header>
|
|
33
42
|
<Card.DragHandle />
|
|
34
43
|
<Card.Title>{Obj.getLabel(object)}</Card.Title>
|
|
35
44
|
<Card.Menu />
|
|
36
|
-
</Card.
|
|
37
|
-
<Component
|
|
45
|
+
</Card.Header>
|
|
46
|
+
<Component
|
|
47
|
+
role={role ?? 'card--content'}
|
|
48
|
+
subject={image ? object : omitImage(object)}
|
|
49
|
+
{...(componentProps ?? ({} as P))}
|
|
50
|
+
/>
|
|
38
51
|
</Card.Root>
|
|
39
52
|
</CardContainer>
|
|
40
53
|
</div>
|
|
@@ -89,3 +102,52 @@ export const createTask = (): Task.Task => {
|
|
|
89
102
|
status: random.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
|
|
90
103
|
});
|
|
91
104
|
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Plain object cast as `Obj.Any` — has no schema, typename, or database, so cards
|
|
108
|
+
* like `FormCard` fall through to their empty/unsupported state. Use to story-pin
|
|
109
|
+
* fallback rendering.
|
|
110
|
+
*/
|
|
111
|
+
export const createUnknown = (): Obj.Any => ({}) as unknown as Obj.Any;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Typed object with no user-facing values (only `id`). All Person fields are
|
|
115
|
+
* optional, so `Obj.make(Person, {})` is valid and triggers the FormCard
|
|
116
|
+
* "no values" branch in readonly mode.
|
|
117
|
+
*/
|
|
118
|
+
export const createPersonEmpty = (): Person.Person => Obj.make(Person.Person, {});
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Mock of the `Table` schema (org.dxos.type.table): an optional `name` plus
|
|
122
|
+
* `view` and `sizes` fields annotated with `FormInputAnnotation.set(false)`.
|
|
123
|
+
* When constructed without a `name`, no form-renderable field has a value so
|
|
124
|
+
* FormCard should fall through to its empty state — even though
|
|
125
|
+
* `Object.keys(subject)` includes `view`/`sizes`.
|
|
126
|
+
*/
|
|
127
|
+
const TableLike = Schema.Struct({
|
|
128
|
+
name: Schema.String.pipe(Schema.optional),
|
|
129
|
+
view: Schema.String.pipe(Annotation.FormInputAnnotation.set(false)),
|
|
130
|
+
sizes: Schema.Record({ key: Schema.String, value: Schema.Number }).pipe(
|
|
131
|
+
Schema.mutable,
|
|
132
|
+
Annotation.FormInputAnnotation.set(false),
|
|
133
|
+
),
|
|
134
|
+
}).pipe(Type.makeObject(DXN.make('org.dxos.test.tableLike', '0.1.0')));
|
|
135
|
+
type TableLike = Type.InstanceType<typeof TableLike>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Table-like object with values only in form-hidden fields (`view`, `sizes`).
|
|
139
|
+
* `Object.keys` includes them, but a naive `hasValues` check would
|
|
140
|
+
* misclassify this as having data. FormCard must consult the schema's
|
|
141
|
+
* form-input annotations to correctly fall through to the empty state.
|
|
142
|
+
*/
|
|
143
|
+
export const createTableEmpty = (): TableLike =>
|
|
144
|
+
Obj.make(TableLike, { view: 'view-dxn:placeholder', sizes: {} } as Obj.MakeProps<typeof TableLike>);
|
|
145
|
+
|
|
146
|
+
export const createExpando = (): Expando.Expando => {
|
|
147
|
+
return Expando.make({
|
|
148
|
+
name: random.person.fullName(),
|
|
149
|
+
email: random.internet.email(),
|
|
150
|
+
age: random.number.int({ min: 18, max: 80 }),
|
|
151
|
+
active: random.datatype.boolean(),
|
|
152
|
+
});
|
|
153
|
+
};
|
package/src/testing.ts
ADDED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
|
-
import { trim } from "@dxos/util";
|
|
3
|
-
var meta = {
|
|
4
|
-
id: "org.dxos.plugin.preview",
|
|
5
|
-
name: "Preview",
|
|
6
|
-
description: trim`
|
|
7
|
-
Rich preview panel for viewing object content without opening full editors.
|
|
8
|
-
Quick peek at documents, images, and data with inline rendering.
|
|
9
|
-
`,
|
|
10
|
-
icon: "ph--eye--regular",
|
|
11
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview"
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// src/PreviewPlugin.tsx
|
|
15
|
-
import { ActivationEvents, Plugin } from "@dxos/app-framework";
|
|
16
|
-
import { AppPlugin } from "@dxos/app-toolkit";
|
|
17
|
-
import { Organization, Person } from "@dxos/types";
|
|
18
|
-
import { PreviewPopover, ReactSurface } from "#capabilities";
|
|
19
|
-
import { meta as meta3 } from "#meta";
|
|
20
|
-
|
|
21
|
-
// src/translations.ts
|
|
22
|
-
import { meta as meta2 } from "#meta";
|
|
23
|
-
var translations = [
|
|
24
|
-
{
|
|
25
|
-
"en-US": {
|
|
26
|
-
[meta2.id]: {
|
|
27
|
-
"unable-to-create-preview.message": "No preview",
|
|
28
|
-
"todo.label": "To do",
|
|
29
|
-
"in-progress.label": "In progress",
|
|
30
|
-
"done.label": "Done",
|
|
31
|
-
"open-object.label": "Open",
|
|
32
|
-
"add-object-to-space.label": "Add to space",
|
|
33
|
-
"more-options.label": "More options"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
// src/PreviewPlugin.tsx
|
|
40
|
-
var PreviewPlugin = Plugin.define(meta3).pipe(AppPlugin.addSchemaModule({
|
|
41
|
-
schema: [
|
|
42
|
-
Person.Person,
|
|
43
|
-
Organization.Organization
|
|
44
|
-
],
|
|
45
|
-
id: "schema"
|
|
46
|
-
}), AppPlugin.addSurfaceModule({
|
|
47
|
-
activate: ReactSurface
|
|
48
|
-
}), AppPlugin.addTranslationsModule({
|
|
49
|
-
translations
|
|
50
|
-
}), Plugin.addModule({
|
|
51
|
-
id: "preview-popover",
|
|
52
|
-
activatesOn: ActivationEvents.Startup,
|
|
53
|
-
activate: PreviewPopover
|
|
54
|
-
}), Plugin.make);
|
|
55
|
-
export {
|
|
56
|
-
PreviewPlugin,
|
|
57
|
-
meta
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts", "../../../src/PreviewPlugin.tsx", "../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'org.dxos.plugin.preview',\n name: 'Preview',\n description: trim`\n Rich preview panel for viewing object content without opening full editors.\n Quick peek at documents, images, and data with inline rendering.\n `,\n icon: 'ph--eye--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ActivationEvents, Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\nimport { Organization, Person } from '@dxos/types';\n\nimport { PreviewPopover, ReactSurface } from '#capabilities';\nimport { meta } from '#meta';\n\nimport { translations } from './translations';\n\nexport const PreviewPlugin = Plugin.define(meta).pipe(\n AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization], id: 'schema' }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.addModule({\n id: 'preview-popover',\n activatesOn: ActivationEvents.Startup,\n activate: PreviewPopover,\n }),\n Plugin.make,\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nimport { meta } from '#meta';\n\nexport const translations = [\n {\n 'en-US': {\n [meta.id]: {\n 'unable-to-create-preview.message': 'No preview',\n 'todo.label': 'To do',\n 'in-progress.label': 'In progress',\n 'done.label': 'Done',\n 'open-object.label': 'Open',\n 'add-object-to-space.label': 'Add to space',\n 'more-options.label': 'More options',\n },\n },\n },\n] as const satisfies Resource[];\n"],
|
|
5
|
-
"mappings": ";AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,QAAQ;AACV;;;ACZA,SAASC,kBAAkBC,cAAc;AACzC,SAASC,iBAAiB;AAC1B,SAASC,cAAcC,cAAc;AAErC,SAASC,gBAAgBC,oBAAoB;AAC7C,SAASC,QAAAA,aAAY;;;ACHrB,SAASC,QAAAA,aAAY;AAEd,IAAMC,eAAe;EAC1B;IACE,SAAS;MACP,CAACC,MAAKC,EAAE,GAAG;QACT,oCAAoC;QACpC,cAAc;QACd,qBAAqB;QACrB,cAAc;QACd,qBAAqB;QACrB,6BAA6B;QAC7B,sBAAsB;MACxB;IACF;EACF;;;;ADRK,IAAMC,gBAAgBC,OAAOC,OAAOC,KAAAA,EAAMC,KAC/CC,UAAUC,gBAAgB;EAAEC,QAAQ;IAACC,OAAOA;IAAQC,aAAaA;;EAAeC,IAAI;AAAS,CAAA,GAC7FL,UAAUM,iBAAiB;EAAEC,UAAUC;AAAa,CAAA,GACpDR,UAAUS,sBAAsB;EAAEC;AAAa,CAAA,GAC/Cd,OAAOe,UAAU;EACfN,IAAI;EACJO,aAAaC,iBAAiBC;EAC9BP,UAAUQ;AACZ,CAAA,GACAnB,OAAOoB,IAAI;",
|
|
6
|
-
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "source", "ActivationEvents", "Plugin", "AppPlugin", "Organization", "Person", "PreviewPopover", "ReactSurface", "meta", "meta", "translations", "meta", "id", "PreviewPlugin", "Plugin", "define", "meta", "pipe", "AppPlugin", "addSchemaModule", "schema", "Person", "Organization", "id", "addSurfaceModule", "activate", "ReactSurface", "addTranslationsModule", "translations", "addModule", "activatesOn", "ActivationEvents", "Startup", "PreviewPopover", "make"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/meta.ts":{"bytes":1673,"imports":[{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/translations.ts":{"bytes":1898,"imports":[{"path":"#meta","kind":"import-statement","external":true}],"format":"esm"},"src/PreviewPlugin.tsx":{"bytes":3181,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"#capabilities","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true},{"path":"src/translations.ts","kind":"import-statement","original":"./translations"}],"format":"esm"},"src/index.ts":{"bytes":555,"imports":[{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"src/PreviewPlugin.tsx","kind":"import-statement","original":"./PreviewPlugin"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3249},"dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"#capabilities","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true}],"exports":["PreviewPlugin","meta"],"entryPoint":"src/index.ts","inputs":{"src/meta.ts":{"bytesInOutput":389},"src/index.ts":{"bytesInOutput":0},"src/PreviewPlugin.tsx":{"bytesInOutput":664},"src/translations.ts":{"bytesInOutput":418}},"bytes":1633}}}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/meta.ts
|
|
4
|
-
import { trim } from "@dxos/util";
|
|
5
|
-
var meta = {
|
|
6
|
-
id: "org.dxos.plugin.preview",
|
|
7
|
-
name: "Preview",
|
|
8
|
-
description: trim`
|
|
9
|
-
Rich preview panel for viewing object content without opening full editors.
|
|
10
|
-
Quick peek at documents, images, and data with inline rendering.
|
|
11
|
-
`,
|
|
12
|
-
icon: "ph--eye--regular",
|
|
13
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview"
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// src/PreviewPlugin.tsx
|
|
17
|
-
import { ActivationEvents, Plugin } from "@dxos/app-framework";
|
|
18
|
-
import { AppPlugin } from "@dxos/app-toolkit";
|
|
19
|
-
import { Organization, Person } from "@dxos/types";
|
|
20
|
-
import { PreviewPopover, ReactSurface } from "#capabilities";
|
|
21
|
-
import { meta as meta3 } from "#meta";
|
|
22
|
-
|
|
23
|
-
// src/translations.ts
|
|
24
|
-
import { meta as meta2 } from "#meta";
|
|
25
|
-
var translations = [
|
|
26
|
-
{
|
|
27
|
-
"en-US": {
|
|
28
|
-
[meta2.id]: {
|
|
29
|
-
"unable-to-create-preview.message": "No preview",
|
|
30
|
-
"todo.label": "To do",
|
|
31
|
-
"in-progress.label": "In progress",
|
|
32
|
-
"done.label": "Done",
|
|
33
|
-
"open-object.label": "Open",
|
|
34
|
-
"add-object-to-space.label": "Add to space",
|
|
35
|
-
"more-options.label": "More options"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
// src/PreviewPlugin.tsx
|
|
42
|
-
var PreviewPlugin = Plugin.define(meta3).pipe(AppPlugin.addSchemaModule({
|
|
43
|
-
schema: [
|
|
44
|
-
Person.Person,
|
|
45
|
-
Organization.Organization
|
|
46
|
-
],
|
|
47
|
-
id: "schema"
|
|
48
|
-
}), AppPlugin.addSurfaceModule({
|
|
49
|
-
activate: ReactSurface
|
|
50
|
-
}), AppPlugin.addTranslationsModule({
|
|
51
|
-
translations
|
|
52
|
-
}), Plugin.addModule({
|
|
53
|
-
id: "preview-popover",
|
|
54
|
-
activatesOn: ActivationEvents.Startup,
|
|
55
|
-
activate: PreviewPopover
|
|
56
|
-
}), Plugin.make);
|
|
57
|
-
export {
|
|
58
|
-
PreviewPlugin,
|
|
59
|
-
meta
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts", "../../../src/PreviewPlugin.tsx", "../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'org.dxos.plugin.preview',\n name: 'Preview',\n description: trim`\n Rich preview panel for viewing object content without opening full editors.\n Quick peek at documents, images, and data with inline rendering.\n `,\n icon: 'ph--eye--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ActivationEvents, Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\nimport { Organization, Person } from '@dxos/types';\n\nimport { PreviewPopover, ReactSurface } from '#capabilities';\nimport { meta } from '#meta';\n\nimport { translations } from './translations';\n\nexport const PreviewPlugin = Plugin.define(meta).pipe(\n AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization], id: 'schema' }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.addModule({\n id: 'preview-popover',\n activatesOn: ActivationEvents.Startup,\n activate: PreviewPopover,\n }),\n Plugin.make,\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nimport { meta } from '#meta';\n\nexport const translations = [\n {\n 'en-US': {\n [meta.id]: {\n 'unable-to-create-preview.message': 'No preview',\n 'todo.label': 'To do',\n 'in-progress.label': 'In progress',\n 'done.label': 'Done',\n 'open-object.label': 'Open',\n 'add-object-to-space.label': 'Add to space',\n 'more-options.label': 'More options',\n },\n },\n },\n] as const satisfies Resource[];\n"],
|
|
5
|
-
"mappings": ";;;AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,QAAQ;AACV;;;ACZA,SAASC,kBAAkBC,cAAc;AACzC,SAASC,iBAAiB;AAC1B,SAASC,cAAcC,cAAc;AAErC,SAASC,gBAAgBC,oBAAoB;AAC7C,SAASC,QAAAA,aAAY;;;ACHrB,SAASC,QAAAA,aAAY;AAEd,IAAMC,eAAe;EAC1B;IACE,SAAS;MACP,CAACC,MAAKC,EAAE,GAAG;QACT,oCAAoC;QACpC,cAAc;QACd,qBAAqB;QACrB,cAAc;QACd,qBAAqB;QACrB,6BAA6B;QAC7B,sBAAsB;MACxB;IACF;EACF;;;;ADRK,IAAMC,gBAAgBC,OAAOC,OAAOC,KAAAA,EAAMC,KAC/CC,UAAUC,gBAAgB;EAAEC,QAAQ;IAACC,OAAOA;IAAQC,aAAaA;;EAAeC,IAAI;AAAS,CAAA,GAC7FL,UAAUM,iBAAiB;EAAEC,UAAUC;AAAa,CAAA,GACpDR,UAAUS,sBAAsB;EAAEC;AAAa,CAAA,GAC/Cd,OAAOe,UAAU;EACfN,IAAI;EACJO,aAAaC,iBAAiBC;EAC9BP,UAAUQ;AACZ,CAAA,GACAnB,OAAOoB,IAAI;",
|
|
6
|
-
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "source", "ActivationEvents", "Plugin", "AppPlugin", "Organization", "Person", "PreviewPopover", "ReactSurface", "meta", "meta", "translations", "meta", "id", "PreviewPlugin", "Plugin", "define", "meta", "pipe", "AppPlugin", "addSchemaModule", "schema", "Person", "Organization", "id", "addSurfaceModule", "activate", "ReactSurface", "addTranslationsModule", "translations", "addModule", "activatesOn", "ActivationEvents", "Startup", "PreviewPopover", "make"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/meta.ts":{"bytes":1673,"imports":[{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/translations.ts":{"bytes":1898,"imports":[{"path":"#meta","kind":"import-statement","external":true}],"format":"esm"},"src/PreviewPlugin.tsx":{"bytes":3181,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"#capabilities","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true},{"path":"src/translations.ts","kind":"import-statement","original":"./translations"}],"format":"esm"},"src/index.ts":{"bytes":555,"imports":[{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"src/PreviewPlugin.tsx","kind":"import-statement","original":"./PreviewPlugin"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3251},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"#capabilities","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true}],"exports":["PreviewPlugin","meta"],"entryPoint":"src/index.ts","inputs":{"src/meta.ts":{"bytesInOutput":389},"src/index.ts":{"bytesInOutput":0},"src/PreviewPlugin.tsx":{"bytesInOutput":664},"src/translations.ts":{"bytesInOutput":418}},"bytes":1726}}}
|