@dxos/plugin-preview 0.8.2-main.12df754 → 0.8.2-main.30e4dbb

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 (37) hide show
  1. package/dist/lib/browser/index.mjs +289 -6
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +291 -4
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +289 -6
  8. package/dist/lib/node-esm/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/Preview.stories.d.ts +203 -0
  11. package/dist/types/src/Preview.stories.d.ts.map +1 -0
  12. package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
  13. package/dist/types/src/components/ContactCard.d.ts +7 -0
  14. package/dist/types/src/components/ContactCard.d.ts.map +1 -0
  15. package/dist/types/src/components/OrganizationCard.d.ts +5 -0
  16. package/dist/types/src/components/OrganizationCard.d.ts.map +1 -0
  17. package/dist/types/src/components/ProjectCard.d.ts +5 -0
  18. package/dist/types/src/components/ProjectCard.d.ts.map +1 -0
  19. package/dist/types/src/components/index.d.ts +4 -0
  20. package/dist/types/src/components/index.d.ts.map +1 -0
  21. package/dist/types/src/index.d.ts +1 -0
  22. package/dist/types/src/index.d.ts.map +1 -1
  23. package/dist/types/src/translations.d.ts +9 -0
  24. package/dist/types/src/translations.d.ts.map +1 -0
  25. package/dist/types/src/types.d.ts +25 -0
  26. package/dist/types/src/types.d.ts.map +1 -0
  27. package/dist/types/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +22 -10
  29. package/src/Preview.stories.tsx +145 -0
  30. package/src/PreviewPlugin.tsx +136 -9
  31. package/src/components/ContactCard.tsx +70 -0
  32. package/src/components/OrganizationCard.tsx +42 -0
  33. package/src/components/ProjectCard.tsx +24 -0
  34. package/src/components/index.ts +7 -0
  35. package/src/index.ts +2 -0
  36. package/src/translations.ts +15 -0
  37. package/src/types.ts +40 -0
@@ -0,0 +1,203 @@
1
+ import '@dxos-theme';
2
+ import { type Meta } from '@storybook/react';
3
+ import React, { type FC } from 'react';
4
+ import { DataType } from '@dxos/schema';
5
+ type StoryProps = {
6
+ Component: FC<{
7
+ subject: any;
8
+ }>;
9
+ icon: string;
10
+ subject: any;
11
+ };
12
+ declare const meta: Meta<StoryProps>;
13
+ export default meta;
14
+ export declare const ContactWithImage: {
15
+ args: {
16
+ Component: ({ children, classNames, role, subject: { fullName, image, organization, emails }, onOrgClick, }: import("./types").PreviewProps<DataType.Person> & {
17
+ onOrgClick?: (org: DataType.Organization) => void;
18
+ }) => React.JSX.Element;
19
+ icon: string;
20
+ subject: Omit<{
21
+ readonly id: string;
22
+ fullName?: string | undefined;
23
+ preferredName?: string | undefined;
24
+ nickname?: string | undefined;
25
+ image?: string | undefined;
26
+ organization?: import("@dxos/echo-schema").Ref<{
27
+ readonly id: string;
28
+ description?: string | undefined;
29
+ name?: string | undefined;
30
+ status?: "prospect" | "qualified" | "active" | "commit" | "reject" | undefined;
31
+ image?: string | undefined;
32
+ website?: string | undefined;
33
+ }> | undefined;
34
+ jobTitle?: string | undefined;
35
+ department?: string | undefined;
36
+ notes?: string | undefined;
37
+ emails?: {
38
+ readonly label?: string | undefined;
39
+ readonly value: string;
40
+ }[] | undefined;
41
+ identities?: {
42
+ readonly label?: string | undefined;
43
+ readonly value: string;
44
+ }[] | undefined;
45
+ phoneNumbers?: {
46
+ readonly label?: string | undefined;
47
+ readonly value: string;
48
+ }[] | undefined;
49
+ addresses?: {
50
+ readonly label?: string | undefined;
51
+ readonly value: {
52
+ readonly street?: string | undefined;
53
+ readonly extended?: string | undefined;
54
+ readonly locality?: string | undefined;
55
+ readonly region?: string | undefined;
56
+ readonly postalCode?: string | undefined;
57
+ readonly postOfficeBoxNumber?: string | undefined;
58
+ readonly country?: string | undefined;
59
+ };
60
+ }[] | undefined;
61
+ urls?: {
62
+ readonly label?: string | undefined;
63
+ readonly value: string;
64
+ }[] | undefined;
65
+ birthday?: {
66
+ toString: () => string;
67
+ toDateString: () => string;
68
+ toTimeString: () => string;
69
+ toLocaleString: {
70
+ (): string;
71
+ (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
72
+ (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
73
+ };
74
+ toLocaleDateString: {
75
+ (): string;
76
+ (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
77
+ (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
78
+ };
79
+ toLocaleTimeString: {
80
+ (): string;
81
+ (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
82
+ (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
83
+ };
84
+ valueOf: () => number;
85
+ getTime: () => number;
86
+ getFullYear: () => number;
87
+ getUTCFullYear: () => number;
88
+ getMonth: () => number;
89
+ getUTCMonth: () => number;
90
+ getDate: () => number;
91
+ getUTCDate: () => number;
92
+ getDay: () => number;
93
+ getUTCDay: () => number;
94
+ getHours: () => number;
95
+ getUTCHours: () => number;
96
+ getMinutes: () => number;
97
+ getUTCMinutes: () => number;
98
+ getSeconds: () => number;
99
+ getUTCSeconds: () => number;
100
+ getMilliseconds: () => number;
101
+ getUTCMilliseconds: () => number;
102
+ getTimezoneOffset: () => number;
103
+ setTime: (time: number) => number;
104
+ setMilliseconds: (ms: number) => number;
105
+ setUTCMilliseconds: (ms: number) => number;
106
+ setSeconds: (sec: number, ms?: number) => number;
107
+ setUTCSeconds: (sec: number, ms?: number) => number;
108
+ setMinutes: (min: number, sec?: number, ms?: number) => number;
109
+ setUTCMinutes: (min: number, sec?: number, ms?: number) => number;
110
+ setHours: (hours: number, min?: number, sec?: number, ms?: number) => number;
111
+ setUTCHours: (hours: number, min?: number, sec?: number, ms?: number) => number;
112
+ setDate: (date: number) => number;
113
+ setUTCDate: (date: number) => number;
114
+ setMonth: (month: number, date?: number) => number;
115
+ setUTCMonth: (month: number, date?: number) => number;
116
+ setFullYear: (year: number, month?: number, date?: number) => number;
117
+ setUTCFullYear: (year: number, month?: number, date?: number) => number;
118
+ toUTCString: () => string;
119
+ toISOString: () => string;
120
+ toJSON: (key?: any) => string;
121
+ [Symbol.toPrimitive]: {
122
+ (hint: "default"): string;
123
+ (hint: "string"): string;
124
+ (hint: "number"): number;
125
+ (hint: string): string | number;
126
+ };
127
+ } | undefined;
128
+ fields?: {
129
+ readonly label: string;
130
+ readonly value: string;
131
+ readonly category?: string | undefined;
132
+ }[] | undefined;
133
+ }, "id"> & {
134
+ id?: string;
135
+ } & {
136
+ id: string;
137
+ };
138
+ role: string;
139
+ };
140
+ };
141
+ export declare const ContactNoImage: {
142
+ args: {
143
+ Component: ({ children, classNames, role, subject: { fullName, image, organization, emails }, onOrgClick, }: import("./types").PreviewProps<DataType.Person> & {
144
+ onOrgClick?: (org: DataType.Organization) => void;
145
+ }) => React.JSX.Element;
146
+ icon: string;
147
+ subject: any;
148
+ role: string;
149
+ };
150
+ };
151
+ export declare const OrganizationWithImage: {
152
+ args: {
153
+ Component: ({ children, classNames, subject: { name, image, description, website }, role, }: import("./types").PreviewProps<DataType.Organization>) => React.JSX.Element;
154
+ icon: string;
155
+ subject: Omit<{
156
+ readonly id: string;
157
+ image?: string | undefined;
158
+ status?: "prospect" | "qualified" | "active" | "commit" | "reject" | undefined;
159
+ name?: string | undefined;
160
+ description?: string | undefined;
161
+ website?: string | undefined;
162
+ }, "id"> & {
163
+ id?: string;
164
+ } & {
165
+ id: string;
166
+ };
167
+ role: string;
168
+ };
169
+ };
170
+ export declare const OrganizationNoImage: {
171
+ args: {
172
+ Component: ({ children, classNames, subject: { name, image, description, website }, role, }: import("./types").PreviewProps<DataType.Organization>) => React.JSX.Element;
173
+ icon: string;
174
+ subject: any;
175
+ role: string;
176
+ };
177
+ };
178
+ export declare const ProjectWithImage: {
179
+ args: {
180
+ Component: ({ classNames, role, subject: { name, image, description }, }: import("./types").PreviewProps<DataType.Project>) => React.JSX.Element;
181
+ icon: string;
182
+ subject: Omit<{
183
+ readonly id: string;
184
+ image?: string | undefined;
185
+ name: string;
186
+ description?: string | undefined;
187
+ }, "id"> & {
188
+ id?: string;
189
+ } & {
190
+ id: string;
191
+ };
192
+ role: string;
193
+ };
194
+ };
195
+ export declare const ProjectNoImage: {
196
+ args: {
197
+ Component: ({ classNames, role, subject: { name, image, description }, }: import("./types").PreviewProps<DataType.Project>) => React.JSX.Element;
198
+ icon: string;
199
+ subject: any;
200
+ role: string;
201
+ };
202
+ };
203
+ //# sourceMappingURL=Preview.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Preview.stories.d.ts","sourceRoot":"","sources":["../../../src/Preview.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAMvC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAQxC,KAAK,UAAU,GAAG;IAChB,SAAS,EAAE,EAAE,CAAC;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAAU,CAoB1B,CAAC;AAEF,eAAe,IAAI,CAAC;AA2CpB,eAAO,MAAM,gBAAgB;;;sBA3ElB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkFX,CAAC;AAEF,eAAO,MAAM,cAAc;;;sBApFhB,CAAC;;;;;;CA2FX,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;CAOjC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;CAO/B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;CAO5B,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;CAO1B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewPlugin.d.ts","sourceRoot":"","sources":["../../../src/PreviewPlugin.tsx"],"names":[],"mappings":"AAyCA,eAAO,MAAM,aAAa,4CA6CtB,CAAC"}
1
+ {"version":3,"file":"PreviewPlugin.d.ts","sourceRoot":"","sources":["../../../src/PreviewPlugin.tsx"],"names":[],"mappings":"AA+DA,eAAO,MAAM,aAAa,4CAsJtB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { type DataType } from '@dxos/schema';
3
+ import { type PreviewProps } from '../types';
4
+ export declare const ContactCard: ({ children, classNames, role, subject: { fullName, image, organization, emails }, onOrgClick, }: PreviewProps<DataType.Person> & {
5
+ onOrgClick?: (org: DataType.Organization) => void;
6
+ }) => React.JSX.Element;
7
+ //# sourceMappingURL=ContactCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContactCard.d.ts","sourceRoot":"","sources":["../../../../src/components/ContactCard.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,KAAK,YAAY,EAAuE,MAAM,UAAU,CAAC;AAElH,eAAO,MAAM,WAAW,GAAI,iGAMzB,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;IAAE,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,CAAC,YAAY,KAAK,IAAI,CAAA;CAAE,sBAmDvF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { type DataType } from '@dxos/schema';
3
+ import { type PreviewProps } from '../types';
4
+ export declare const OrganizationCard: ({ children, classNames, subject: { name, image, description, website }, role, }: PreviewProps<DataType.Organization>) => React.JSX.Element;
5
+ //# sourceMappingURL=OrganizationCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OrganizationCard.d.ts","sourceRoot":"","sources":["../../../../src/components/OrganizationCard.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,KAAK,YAAY,EAAuE,MAAM,UAAU,CAAC;AAElH,eAAO,MAAM,gBAAgB,GAAI,iFAK9B,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,sBAwBrC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { type DataType } from '@dxos/schema';
3
+ import { type PreviewProps } from '../types';
4
+ export declare const ProjectCard: ({ classNames, role, subject: { name, image, description }, }: PreviewProps<DataType.Project>) => React.JSX.Element;
5
+ //# sourceMappingURL=ProjectCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProjectCard.d.ts","sourceRoot":"","sources":["../../../../src/components/ProjectCard.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,KAAK,YAAY,EAA0C,MAAM,UAAU,CAAC;AAErF,eAAO,MAAM,WAAW,GAAI,8DAIzB,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,sBAQhC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './ContactCard';
2
+ export * from './OrganizationCard';
3
+ export * from './ProjectCard';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './meta';
2
+ export * from './types';
2
3
  export * from './PreviewPlugin';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AAExB,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ 'en-US': {
3
+ "dxos.org/plugin/preview": {
4
+ 'unable to create preview message': string;
5
+ };
6
+ };
7
+ }[];
8
+ export default _default;
9
+ //# sourceMappingURL=translations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;AAMA,wBAQE"}
@@ -0,0 +1,25 @@
1
+ import { type PropsWithChildren } from 'react';
2
+ import { type ThemedClassName } from '@dxos/react-ui';
3
+ export type PreviewProps<T extends object> = PropsWithChildren<ThemedClassName<{
4
+ subject: T;
5
+ role: string;
6
+ }>>;
7
+ /**
8
+ * <Card.Root>
9
+ * <Card.Header>
10
+ * <Card.Title>
11
+ * <Card.Action>
12
+ * </Card.Header>
13
+ * <Card.Body>
14
+ * <Card.Image>
15
+ * <Form />
16
+ * </Card.Body>
17
+ * </Card.Root>
18
+ */
19
+ export declare const popoverCard = "popover-consistent-width rounded-lg overflow-hidden";
20
+ export declare const defaultCard = "";
21
+ export declare const kanbanCardWithoutPoster = "pbs-[--rail-action]";
22
+ export declare const previewTitle = "text-lg font-medium line-clamp-2";
23
+ export declare const previewProse = "pli-3 mlb-3";
24
+ export declare const previewChrome = "pli-1.5 mlb-1.5 [&_.dx-button]:pli-1.5 [&_.dx-button]:text-start [&_.dx-button]:is-full";
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI,iBAAiB,CAC5D,eAAe,CAAC;IACd,OAAO,EAAE,CAAC,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CACH,CAAC;AAQF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,wDAAwD,CAAC;AACjF,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAC7D,eAAO,MAAM,YAAY,qCAAqC,CAAC;AAC/D,eAAO,MAAM,YAAY,gBAAgB,CAAC;AAC1C,eAAO,MAAM,aAAa,4FAA4F,CAAC"}
@@ -1 +1 @@
1
- {"version":"5.7.3"}
1
+ {"version":"5.8.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-preview",
3
- "version": "0.8.2-main.12df754",
3
+ "version": "0.8.2-main.30e4dbb",
4
4
  "description": "Preview plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -23,21 +23,33 @@
23
23
  "src"
24
24
  ],
25
25
  "dependencies": {
26
- "@dxos/app-framework": "0.8.2-main.12df754",
27
- "@dxos/client": "0.8.2-main.12df754",
28
- "@dxos/async": "0.8.2-main.12df754",
29
- "@dxos/keys": "0.8.2-main.12df754",
30
- "@dxos/lit-ui": "0.8.2-main.12df754",
31
- "@dxos/log": "0.8.2-main.12df754",
32
- "@dxos/react-ui-editor": "0.8.2-main.12df754",
33
- "@dxos/plugin-client": "0.8.2-main.12df754"
26
+ "effect": "3.14.21",
27
+ "@dxos/client": "0.8.2-main.30e4dbb",
28
+ "@dxos/app-framework": "0.8.2-main.30e4dbb",
29
+ "@dxos/echo-schema": "0.8.2-main.30e4dbb",
30
+ "@dxos/keys": "0.8.2-main.30e4dbb",
31
+ "@dxos/log": "0.8.2-main.30e4dbb",
32
+ "@dxos/lit-ui": "0.8.2-main.30e4dbb",
33
+ "@dxos/plugin-client": "0.8.2-main.30e4dbb",
34
+ "@dxos/react-client": "0.8.2-main.30e4dbb",
35
+ "@dxos/async": "0.8.2-main.30e4dbb",
36
+ "@dxos/react-ui": "0.8.2-main.30e4dbb",
37
+ "@dxos/react-ui-editor": "0.8.2-main.30e4dbb",
38
+ "@dxos/react-ui-form": "0.8.2-main.30e4dbb",
39
+ "@dxos/react-ui-table": "0.8.2-main.30e4dbb",
40
+ "@dxos/react-ui-theme": "0.8.2-main.30e4dbb",
41
+ "@dxos/schema": "0.8.2-main.30e4dbb",
42
+ "@dxos/util": "0.8.2-main.30e4dbb"
34
43
  },
35
44
  "devDependencies": {
45
+ "effect": "3.14.21",
36
46
  "react": "~18.2.0",
37
47
  "react-dom": "~18.2.0",
38
- "vite": "5.4.7"
48
+ "vite": "5.4.7",
49
+ "@dxos/random": "0.8.2-main.30e4dbb"
39
50
  },
40
51
  "peerDependencies": {
52
+ "effect": "^3.13.3",
41
53
  "react": "~18.2.0",
42
54
  "react-dom": "~18.2.0"
43
55
  },
@@ -0,0 +1,145 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import '@dxos-theme';
6
+
7
+ import { type Meta } from '@storybook/react';
8
+ import React, { type FC } from 'react';
9
+
10
+ import { create } from '@dxos/echo-schema';
11
+ import { faker } from '@dxos/random';
12
+ import { makeRef } from '@dxos/react-client/echo';
13
+ import { Icon, Popover } from '@dxos/react-ui';
14
+ import { DataType } from '@dxos/schema';
15
+ import { withTheme, withLayout } from '@dxos/storybook-utils';
16
+
17
+ import { ContactCard, OrganizationCard, ProjectCard } from './components';
18
+ import translations from './translations';
19
+
20
+ faker.seed(1234);
21
+
22
+ type StoryProps = {
23
+ Component: FC<{ subject: any }>;
24
+ icon: string;
25
+ subject: any;
26
+ };
27
+
28
+ const meta: Meta<StoryProps> = {
29
+ title: 'plugins/plugin-preview/Preview',
30
+ render: ({ Component, icon, ...args }) => {
31
+ return (
32
+ <Popover.Root open>
33
+ <Popover.Content>
34
+ <Component {...args} />
35
+ <Popover.Arrow />
36
+ </Popover.Content>
37
+ <Popover.Trigger>
38
+ <Icon icon={icon} size={5} />
39
+ </Popover.Trigger>
40
+ </Popover.Root>
41
+ );
42
+ },
43
+ decorators: [withTheme, withLayout()],
44
+ parameters: {
45
+ layout: 'centered',
46
+ translations,
47
+ },
48
+ };
49
+
50
+ export default meta;
51
+
52
+ const omitImage = ({ image, ...rest }: any) => rest;
53
+
54
+ const data = (() => {
55
+ const organization = create(DataType.Organization, {
56
+ name: faker.company.name(),
57
+ image:
58
+ 'https://plus.unsplash.com/premium_photo-1672116452571-896980a801c8?q=80&w=2671&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
59
+ website: faker.internet.url(),
60
+ description: faker.lorem.paragraph(),
61
+ });
62
+
63
+ const contact = create(DataType.Person, {
64
+ fullName: faker.person.fullName(),
65
+ image:
66
+ 'https://plus.unsplash.com/premium_photo-1664536392779-049ba8fde933?q=80&w=2574&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
67
+ organization: makeRef(organization),
68
+ emails: [
69
+ {
70
+ label: 'Work',
71
+ value: faker.internet.email(),
72
+ },
73
+ {
74
+ label: 'Work',
75
+ value: faker.internet.email(),
76
+ },
77
+ {
78
+ label: 'Work',
79
+ value: faker.internet.email(),
80
+ },
81
+ ],
82
+ });
83
+
84
+ const project = create(DataType.Project, {
85
+ name: faker.person.fullName(),
86
+ image: 'https://dxos.network/dxos-logotype-blue.png',
87
+ description: faker.lorem.paragraph(),
88
+ });
89
+
90
+ return { organization, contact, project };
91
+ })();
92
+
93
+ export const ContactWithImage = {
94
+ args: {
95
+ Component: ContactCard,
96
+ icon: 'ph--user--regular',
97
+ subject: data.contact,
98
+ role: 'popover',
99
+ },
100
+ };
101
+
102
+ export const ContactNoImage = {
103
+ args: {
104
+ Component: ContactCard,
105
+ icon: 'ph--user--regular',
106
+ subject: omitImage(data.contact),
107
+ role: 'popover',
108
+ },
109
+ };
110
+
111
+ export const OrganizationWithImage = {
112
+ args: {
113
+ Component: OrganizationCard,
114
+ icon: 'ph--building-office--regular',
115
+ subject: data.organization,
116
+ role: 'popover',
117
+ },
118
+ };
119
+
120
+ export const OrganizationNoImage = {
121
+ args: {
122
+ Component: OrganizationCard,
123
+ icon: 'ph--building-office--regular',
124
+ subject: omitImage(data.organization),
125
+ role: 'popover',
126
+ },
127
+ };
128
+
129
+ export const ProjectWithImage = {
130
+ args: {
131
+ Component: ProjectCard,
132
+ icon: 'ph--building--regular',
133
+ subject: data.project,
134
+ role: 'popover',
135
+ },
136
+ };
137
+
138
+ export const ProjectNoImage = {
139
+ args: {
140
+ Component: ProjectCard,
141
+ icon: 'ph--building--regular',
142
+ subject: omitImage(data.project),
143
+ role: 'popover',
144
+ },
145
+ };