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

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 (83) hide show
  1. package/dist/lib/browser/index.mjs +41 -46
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +42 -46
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/PreviewPlugin.d.ts +2 -1
  8. package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
  9. package/dist/types/src/capabilities/index.d.ts +3 -2
  10. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  11. package/dist/types/src/capabilities/preview-popover.d.ts +3 -2
  12. package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -1
  13. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  14. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  15. package/dist/types/src/cards/FormCard.d.ts +7 -0
  16. package/dist/types/src/cards/FormCard.d.ts.map +1 -0
  17. package/dist/types/src/cards/JsonCard.d.ts +5 -0
  18. package/dist/types/src/cards/JsonCard.d.ts.map +1 -0
  19. package/dist/types/src/cards/OrganizationCard.d.ts +3 -3
  20. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
  21. package/dist/types/src/cards/PersonCard.d.ts +5 -0
  22. package/dist/types/src/cards/PersonCard.d.ts.map +1 -0
  23. package/dist/types/src/cards/ProjectCard.d.ts +3 -3
  24. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
  25. package/dist/types/src/cards/TaskCard.d.ts +3 -3
  26. package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
  27. package/dist/types/src/cards/index.d.ts +3 -1
  28. package/dist/types/src/cards/index.d.ts.map +1 -1
  29. package/dist/types/src/index.d.ts +0 -1
  30. package/dist/types/src/index.d.ts.map +1 -1
  31. package/dist/types/src/meta.d.ts +2 -2
  32. package/dist/types/src/meta.d.ts.map +1 -1
  33. package/dist/types/src/stories/Card.stories.d.ts +19 -13
  34. package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
  35. package/dist/types/src/stories/testing.d.ts +13 -12
  36. package/dist/types/src/stories/testing.d.ts.map +1 -1
  37. package/dist/types/src/translations.d.ts +8 -8
  38. package/dist/types/src/translations.d.ts.map +1 -1
  39. package/dist/types/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +49 -34
  41. package/src/PreviewPlugin.tsx +15 -25
  42. package/src/capabilities/index.ts +3 -3
  43. package/src/capabilities/preview-popover.ts +66 -42
  44. package/src/capabilities/react-surface.tsx +103 -135
  45. package/src/cards/FormCard.tsx +48 -0
  46. package/src/cards/JsonCard.tsx +16 -0
  47. package/src/cards/OrganizationCard.tsx +17 -13
  48. package/src/cards/PersonCard.tsx +65 -0
  49. package/src/cards/ProjectCard.tsx +9 -11
  50. package/src/cards/TaskCard.tsx +26 -28
  51. package/src/cards/index.ts +3 -1
  52. package/src/index.ts +0 -1
  53. package/src/meta.ts +3 -3
  54. package/src/stories/Card.stories.tsx +67 -21
  55. package/src/stories/testing.tsx +47 -69
  56. package/src/translations.ts +8 -8
  57. package/dist/lib/browser/chunk-CEWM5LJG.mjs +0 -17
  58. package/dist/lib/browser/chunk-CEWM5LJG.mjs.map +0 -7
  59. package/dist/lib/browser/preview-popover-RKHENTFP.mjs +0 -65
  60. package/dist/lib/browser/preview-popover-RKHENTFP.mjs.map +0 -7
  61. package/dist/lib/browser/react-surface-3AR3BFLF.mjs +0 -515
  62. package/dist/lib/browser/react-surface-3AR3BFLF.mjs.map +0 -7
  63. package/dist/lib/node-esm/chunk-Q5MUNELK.mjs +0 -19
  64. package/dist/lib/node-esm/chunk-Q5MUNELK.mjs.map +0 -7
  65. package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs +0 -67
  66. package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs.map +0 -7
  67. package/dist/lib/node-esm/react-surface-L37JR7U2.mjs +0 -516
  68. package/dist/lib/node-esm/react-surface-L37JR7U2.mjs.map +0 -7
  69. package/dist/types/src/cards/ContactCard.d.ts +0 -5
  70. package/dist/types/src/cards/ContactCard.d.ts.map +0 -1
  71. package/dist/types/src/components/CardComponents.d.ts +0 -16
  72. package/dist/types/src/components/CardComponents.d.ts.map +0 -1
  73. package/dist/types/src/components/CardSubjectMenu.d.ts +0 -8
  74. package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
  75. package/dist/types/src/components/index.d.ts +0 -3
  76. package/dist/types/src/components/index.d.ts.map +0 -1
  77. package/dist/types/src/types.d.ts +0 -10
  78. package/dist/types/src/types.d.ts.map +0 -1
  79. package/src/cards/ContactCard.tsx +0 -65
  80. package/src/components/CardComponents.tsx +0 -67
  81. package/src/components/CardSubjectMenu.tsx +0 -91
  82. package/src/components/index.ts +0 -6
  83. package/src/types.ts +0 -15
@@ -1,67 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // src/capabilities/preview-popover.ts
4
- import { Capabilities, LayoutAction, contributes, createIntent } from "@dxos/app-framework";
5
- import { addEventListener } from "@dxos/async";
6
- import { parseId } from "@dxos/client/echo";
7
- import { DXN } from "@dxos/keys";
8
- import { log } from "@dxos/log";
9
- import { ClientCapabilities } from "@dxos/plugin-client";
10
- import { DX_ANCHOR_ACTIVATE } from "@dxos/react-ui";
11
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-preview/src/capabilities/preview-popover.ts";
12
- var customEventOptions = {
13
- capture: true,
14
- passive: false
15
- };
16
- var handlePreviewLookup = async (client, defaultSpace, { ref, label }) => {
17
- try {
18
- const object = await defaultSpace.db.ref(DXN.parse(ref)).load();
19
- return {
20
- label,
21
- object
22
- };
23
- } catch {
24
- return null;
25
- }
26
- };
27
- var preview_popover_default = ((context) => {
28
- const handleDxAnchorActivate = async ({ refId, label, trigger }) => {
29
- const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
30
- const client = context.getCapability(ClientCapabilities.Client);
31
- const [layout] = context.getCapabilities(Capabilities.Layout);
32
- const { spaceId } = parseId(layout.workspace);
33
- const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
34
- const result = await handlePreviewLookup(client, space, {
35
- ref: refId,
36
- label
37
- });
38
- if (!result) {
39
- return;
40
- }
41
- await dispatch(createIntent(LayoutAction.UpdatePopover, {
42
- part: "popover",
43
- subject: result.object,
44
- options: {
45
- state: true,
46
- variant: "virtual",
47
- anchor: trigger
48
- }
49
- }));
50
- };
51
- let cleanup;
52
- if (document.defaultView) {
53
- cleanup = addEventListener(document.defaultView, DX_ANCHOR_ACTIVATE, handleDxAnchorActivate, customEventOptions);
54
- } else {
55
- log.warn("No default view found", void 0, {
56
- F: __dxlog_file,
57
- L: 65,
58
- S: void 0,
59
- C: (f, a) => f(...a)
60
- });
61
- }
62
- return contributes(Capabilities.Null, null, () => cleanup());
63
- });
64
- export {
65
- preview_popover_default as default
66
- };
67
- //# sourceMappingURL=preview-popover-TZKX67EY.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/preview-popover.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, LayoutAction, type PluginContext, contributes, createIntent } from '@dxos/app-framework';\nimport { addEventListener } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space, parseId } from '@dxos/client/echo';\nimport { DXN } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';\nimport { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';\n\nconst customEventOptions = { capture: true, passive: false };\n\nconst handlePreviewLookup = async (\n client: Client,\n defaultSpace: Space,\n { ref, label }: PreviewLinkRef,\n): Promise<PreviewLinkTarget | null> => {\n try {\n const object = await defaultSpace.db.ref(DXN.parse(ref)).load();\n return { label, object };\n } catch {\n return null;\n }\n};\n\nexport default (context: PluginContext) => {\n // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.\n const handleDxAnchorActivate = async ({ refId, label, trigger }: DxAnchorActivate) => {\n const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);\n const client = context.getCapability(ClientCapabilities.Client);\n const [layout] = context.getCapabilities(Capabilities.Layout);\n const { spaceId } = parseId(layout.workspace);\n const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;\n const result = await handlePreviewLookup(client, space, { ref: refId, label });\n if (!result) {\n return;\n }\n\n await dispatch(\n createIntent(LayoutAction.UpdatePopover, {\n part: 'popover',\n subject: result.object,\n options: {\n state: true,\n variant: 'virtual',\n anchor: trigger,\n },\n }),\n );\n };\n\n let cleanup: () => void;\n if (document.defaultView) {\n cleanup = addEventListener(\n document.defaultView,\n DX_ANCHOR_ACTIVATE as any,\n handleDxAnchorActivate,\n customEventOptions,\n );\n } else {\n log.warn('No default view found');\n }\n\n return contributes(Capabilities.Null, null, () => cleanup());\n};\n"],
5
- "mappings": ";;;AAIA,SAASA,cAAcC,cAAkCC,aAAaC,oBAAoB;AAC1F,SAASC,wBAAwB;AAEjC,SAAqBC,eAAe;AACpC,SAASC,WAAW;AACpB,SAASC,WAAW;AACpB,SAASC,0BAA0B;AACnC,SAASC,0BAAiD;;AAG1D,IAAMC,qBAAqB;EAAEC,SAAS;EAAMC,SAAS;AAAM;AAE3D,IAAMC,sBAAsB,OAC1BC,QACAC,cACA,EAAEC,KAAKC,MAAK,MAAkB;AAE9B,MAAI;AACF,UAAMC,SAAS,MAAMH,aAAaI,GAAGH,IAAIV,IAAIc,MAAMJ,GAAAA,CAAAA,EAAMK,KAAI;AAC7D,WAAO;MAAEJ;MAAOC;IAAO;EACzB,QAAQ;AACN,WAAO;EACT;AACF;AAEA,IAAA,2BAAe,CAACI,YAAAA;AAEd,QAAMC,yBAAyB,OAAO,EAAEC,OAAOP,OAAOQ,QAAO,MAAoB;AAC/E,UAAM,EAAEC,iBAAiBC,SAAQ,IAAKL,QAAQM,cAAc5B,aAAa6B,gBAAgB;AACzF,UAAMf,SAASQ,QAAQM,cAAcpB,mBAAmBsB,MAAM;AAC9D,UAAM,CAACC,MAAAA,IAAUT,QAAQU,gBAAgBhC,aAAaiC,MAAM;AAC5D,UAAM,EAAEC,QAAO,IAAK7B,QAAQ0B,OAAOI,SAAS;AAC5C,UAAMC,SAASF,WAAWpB,OAAOuB,OAAOC,IAAIJ,OAAAA,MAAapB,OAAOuB,OAAOE;AACvE,UAAMC,SAAS,MAAM3B,oBAAoBC,QAAQsB,OAAO;MAAEpB,KAAKQ;MAAOP;IAAM,CAAA;AAC5E,QAAI,CAACuB,QAAQ;AACX;IACF;AAEA,UAAMb,SACJxB,aAAaF,aAAawC,eAAe;MACvCC,MAAM;MACNC,SAASH,OAAOtB;MAChB0B,SAAS;QACPC,OAAO;QACPC,SAAS;QACTC,QAAQtB;MACV;IACF,CAAA,CAAA;EAEJ;AAEA,MAAIuB;AACJ,MAAIC,SAASC,aAAa;AACxBF,cAAU5C,iBACR6C,SAASC,aACTzC,oBACAc,wBACAb,kBAAAA;EAEJ,OAAO;AACLH,QAAI4C,KAAK,yBAAA,QAAA;;;;;;EACX;AAEA,SAAOjD,YAAYF,aAAaoD,MAAM,MAAM,MAAMJ,QAAAA,CAAAA;AACpD;",
6
- "names": ["Capabilities", "LayoutAction", "contributes", "createIntent", "addEventListener", "parseId", "DXN", "log", "ClientCapabilities", "DX_ANCHOR_ACTIVATE", "customEventOptions", "capture", "passive", "handlePreviewLookup", "client", "defaultSpace", "ref", "label", "object", "db", "parse", "load", "context", "handleDxAnchorActivate", "refId", "trigger", "dispatchPromise", "dispatch", "getCapability", "IntentDispatcher", "Client", "layout", "getCapabilities", "Layout", "spaceId", "workspace", "space", "spaces", "get", "default", "result", "UpdatePopover", "part", "subject", "options", "state", "variant", "anchor", "cleanup", "document", "defaultView", "warn", "Null"]
7
- }
@@ -1,516 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- meta
4
- } from "./chunk-Q5MUNELK.mjs";
5
-
6
- // src/capabilities/react-surface.tsx
7
- import React7, { useCallback } from "react";
8
- import { Capabilities, LayoutAction as LayoutAction2, Surface, contributes, createIntent as createIntent2, createSurface, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
9
- import { fullyQualifiedId as fullyQualifiedId2, getSchema, getSpace } from "@dxos/client/echo";
10
- import { Obj as Obj3 } from "@dxos/echo";
11
- import { setValue } from "@dxos/echo/internal";
12
- import { useActiveSpace } from "@dxos/plugin-space";
13
- import { useTranslation as useTranslation2 } from "@dxos/react-ui";
14
- import { Form } from "@dxos/react-ui-form";
15
- import { Card as Card6 } from "@dxos/react-ui-stack";
16
- import { descriptionMessage, mx as mx4 } from "@dxos/react-ui-theme";
17
- import { DataType as DataType2 } from "@dxos/schema";
18
-
19
- // src/cards/ContactCard.tsx
20
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
21
- import React3, { Fragment } from "react";
22
- import { Avatar, Icon as Icon2 } from "@dxos/react-ui";
23
- import { Card as Card2, cardHeading, cardText } from "@dxos/react-ui-stack";
24
- import { mx as mx2 } from "@dxos/react-ui-theme";
25
-
26
- // src/components/CardComponents.tsx
27
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
28
- import React2 from "react";
29
- import { Button, Icon } from "@dxos/react-ui";
30
- import { Card, cardNoSpacing, cardSpacing } from "@dxos/react-ui-stack";
31
- import { mx } from "@dxos/react-ui-theme";
32
-
33
- // src/components/CardSubjectMenu.tsx
34
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
35
- import { Rx } from "@effect-rx/rx-react";
36
- import React from "react";
37
- import { LayoutAction, createIntent, useIntentDispatcher } from "@dxos/app-framework";
38
- import { ACTION_TYPE } from "@dxos/app-graph";
39
- import { Obj } from "@dxos/echo";
40
- import { SpaceAction } from "@dxos/plugin-space/types";
41
- import { fullyQualifiedId } from "@dxos/react-client/echo";
42
- import { IconButton, useTranslation } from "@dxos/react-ui";
43
- import { DropdownMenu, MenuProvider, useMenuActions } from "@dxos/react-ui-menu";
44
- var CardSubjectMenu = ({ subject, activeSpace, ...props }) => {
45
- var _effect = _useSignals();
46
- try {
47
- const { t } = useTranslation(meta.id);
48
- const menuProps = useSubjectMenuGroupItems({
49
- subject,
50
- activeSpace
51
- });
52
- if (!activeSpace) {
53
- return null;
54
- }
55
- return /* @__PURE__ */ React.createElement(MenuProvider, menuProps, /* @__PURE__ */ React.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React.createElement(DropdownMenu.Trigger, {
56
- asChild: true
57
- }, /* @__PURE__ */ React.createElement(IconButton, {
58
- variant: "ghost",
59
- icon: "ph--dots-three-vertical--bold",
60
- iconOnly: true,
61
- label: t("more options label"),
62
- size: 5,
63
- ...props
64
- }))));
65
- } finally {
66
- _effect.f();
67
- }
68
- };
69
- var useSubjectMenuGroupItems = ({ subject, activeSpace }) => {
70
- const { dispatchPromise: dispatch } = useIntentDispatcher();
71
- const result = {
72
- edges: [],
73
- nodes: []
74
- };
75
- result.nodes.push({
76
- type: ACTION_TYPE,
77
- id: `${subject.id}/open`,
78
- data: () => dispatch(createIntent(LayoutAction.Open, {
79
- part: "main",
80
- subject: [
81
- fullyQualifiedId(subject)
82
- ]
83
- })),
84
- properties: {
85
- label: [
86
- "open object label",
87
- {
88
- ns: meta.id
89
- }
90
- ],
91
- icon: "ph--arrow-right--regular"
92
- }
93
- });
94
- if (activeSpace && Obj.getDXN(subject).asQueueDXN()) {
95
- result.nodes.push({
96
- type: ACTION_TYPE,
97
- id: `${subject.id}/add-to-space`,
98
- // TODO(wittjosiah): Update reference to point to db object when adding?
99
- data: () => dispatch(createIntent(SpaceAction.AddObject, {
100
- object: subject,
101
- target: activeSpace,
102
- hidden: true
103
- })),
104
- properties: {
105
- label: [
106
- "add object to space label",
107
- {
108
- ns: meta.id
109
- }
110
- ],
111
- icon: "ph--file-plus--regular"
112
- }
113
- });
114
- }
115
- result.nodes.forEach(({ id: target }) => {
116
- result.edges.push({
117
- source: "root",
118
- target
119
- });
120
- });
121
- return useMenuActions(Rx.make(result));
122
- };
123
-
124
- // src/components/CardComponents.tsx
125
- var gridRow = "is-full grid grid-cols-[1.5rem_1fr_min-content] gap-2 items-center";
126
- var CardHeader = ({ label, subject, activeSpace }) => {
127
- var _effect = _useSignals2();
128
- try {
129
- return /* @__PURE__ */ React2.createElement("div", {
130
- role: "none",
131
- className: mx("flex items-center gap-2", cardSpacing)
132
- }, /* @__PURE__ */ React2.createElement(Card.Heading, {
133
- classNames: cardNoSpacing
134
- }, label), /* @__PURE__ */ React2.createElement(CardSubjectMenu, {
135
- subject,
136
- activeSpace
137
- }));
138
- } finally {
139
- _effect.f();
140
- }
141
- };
142
- var CardRow = ({ icon, label, onClick }) => {
143
- var _effect = _useSignals2();
144
- try {
145
- if (!onClick) {
146
- return /* @__PURE__ */ React2.createElement(Card.Chrome, null, /* @__PURE__ */ React2.createElement("p", {
147
- "data-variant": "ghost",
148
- className: mx(gridRow, "dx-button")
149
- }, /* @__PURE__ */ React2.createElement(Icon, {
150
- icon,
151
- size: 5,
152
- classNames: "text-subdued"
153
- }), /* @__PURE__ */ React2.createElement("span", {
154
- className: "min-is-0 flex-1 truncate col-span-2"
155
- }, label)));
156
- }
157
- return /* @__PURE__ */ React2.createElement(Card.Chrome, null, /* @__PURE__ */ React2.createElement(Button, {
158
- variant: "ghost",
159
- classNames: mx(gridRow, "text-start"),
160
- onClick
161
- }, /* @__PURE__ */ React2.createElement(Icon, {
162
- icon,
163
- size: 5,
164
- classNames: "text-subdued"
165
- }), /* @__PURE__ */ React2.createElement("span", {
166
- className: "min-is-0 flex-1 truncate"
167
- }, label), /* @__PURE__ */ React2.createElement(Icon, {
168
- icon: "ph--arrow-right--regular"
169
- })));
170
- } finally {
171
- _effect.f();
172
- }
173
- };
174
- var CardLink = ({ label, href }) => {
175
- var _effect = _useSignals2();
176
- try {
177
- return /* @__PURE__ */ React2.createElement(Card.Chrome, null, /* @__PURE__ */ React2.createElement("a", {
178
- className: mx(gridRow, "dx-button dx-focus-ring"),
179
- "data-variant": "ghost",
180
- href,
181
- target: "_blank",
182
- rel: "noreferrer"
183
- }, /* @__PURE__ */ React2.createElement(Icon, {
184
- icon: "ph--link--regular",
185
- size: 5,
186
- classNames: "text-subdued"
187
- }), /* @__PURE__ */ React2.createElement("span", {
188
- className: "min-is-0 flex-1 truncate"
189
- }, label), /* @__PURE__ */ React2.createElement(Icon, {
190
- icon: "ph--arrow-square-out--regular"
191
- })));
192
- } finally {
193
- _effect.f();
194
- }
195
- };
196
-
197
- // src/cards/ContactCard.tsx
198
- var ContactCard = ({ children, role, subject, activeSpace, onSelect }) => {
199
- var _effect = _useSignals3();
200
- try {
201
- const { fullName, image, organization: { target: organization } = {}, emails } = subject;
202
- return /* @__PURE__ */ React3.createElement(Card2.SurfaceRoot, {
203
- role
204
- }, /* @__PURE__ */ React3.createElement(Avatar.Root, null, /* @__PURE__ */ React3.createElement(Card2.Text, {
205
- role: "group",
206
- classNames: mx2("grid gap-2 grid-cols-[1fr_min-content]")
207
- }, /* @__PURE__ */ React3.createElement("div", {
208
- role: "none",
209
- className: mx2(gridRow, "grid-rows-2")
210
- }, activeSpace ? /* @__PURE__ */ React3.createElement(CardSubjectMenu, {
211
- subject,
212
- activeSpace
213
- }) : /* @__PURE__ */ React3.createElement("div", null), /* @__PURE__ */ React3.createElement(Avatar.Label, {
214
- asChild: true
215
- }, /* @__PURE__ */ React3.createElement("h2", {
216
- className: mx2(cardHeading, "grow truncate")
217
- }, fullName))), /* @__PURE__ */ React3.createElement(Avatar.Content, {
218
- imgSrc: image,
219
- icon: "ph--user--regular",
220
- size: 16,
221
- classNames: "text-subdued",
222
- hue: "neutral",
223
- variant: "square"
224
- }))), organization?.name && /* @__PURE__ */ React3.createElement(CardRow, {
225
- icon: "ph--buildings--regular",
226
- label: organization.name,
227
- onClick: onSelect ? () => onSelect(organization) : void 0
228
- }), emails?.length && /* @__PURE__ */ React3.createElement("dl", {
229
- className: mx2(cardText, gridRow, "[&_dt]:text-subdued [&_dt]:pbs-0.5 [&_dd]:min-is-0")
230
- }, emails?.length && emails.map(({ label, value }) => /* @__PURE__ */ React3.createElement(Fragment, {
231
- key: value
232
- }, /* @__PURE__ */ React3.createElement("dt", null, /* @__PURE__ */ React3.createElement("span", {
233
- className: "sr-only"
234
- }, label), /* @__PURE__ */ React3.createElement(Icon2, {
235
- icon: "ph--at--regular",
236
- size: 5
237
- })), /* @__PURE__ */ React3.createElement("dd", {
238
- key: value,
239
- className: "col-span-2 break-words"
240
- }, value)))), children);
241
- } finally {
242
- _effect.f();
243
- }
244
- };
245
-
246
- // src/cards/OrganizationCard.tsx
247
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
248
- import React4 from "react";
249
- import { Card as Card3 } from "@dxos/react-ui-stack";
250
- var OrganizationCard = ({ children, subject, role, activeSpace }) => {
251
- var _effect = _useSignals4();
252
- try {
253
- const { name, image, description, website } = subject;
254
- return /* @__PURE__ */ React4.createElement(Card3.SurfaceRoot, {
255
- role
256
- }, /* @__PURE__ */ React4.createElement(Card3.Poster, {
257
- alt: name ?? "",
258
- ...image ? {
259
- image
260
- } : {
261
- icon: "ph--building-office--regular"
262
- }
263
- }), /* @__PURE__ */ React4.createElement(CardHeader, {
264
- label: name,
265
- subject,
266
- activeSpace
267
- }), description && /* @__PURE__ */ React4.createElement(Card3.Text, {
268
- classNames: "line-clamp-2"
269
- }, description), website && /* @__PURE__ */ React4.createElement(CardLink, {
270
- label: website,
271
- href: website
272
- }), children);
273
- } finally {
274
- _effect.f();
275
- }
276
- };
277
-
278
- // src/cards/ProjectCard.tsx
279
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
280
- import React5 from "react";
281
- import { Obj as Obj2 } from "@dxos/echo";
282
- import { Card as Card4 } from "@dxos/react-ui-stack";
283
- var ProjectCard = ({ subject, role, activeSpace }) => {
284
- var _effect = _useSignals5();
285
- try {
286
- const { name, image, description } = subject;
287
- return /* @__PURE__ */ React5.createElement(Card4.SurfaceRoot, {
288
- role
289
- }, image && /* @__PURE__ */ React5.createElement(Card4.Poster, {
290
- image,
291
- alt: Obj2.getLabel(subject) ?? "",
292
- aspect: "auto"
293
- }), /* @__PURE__ */ React5.createElement(CardHeader, {
294
- label: name,
295
- subject,
296
- activeSpace
297
- }), description && /* @__PURE__ */ React5.createElement(Card4.Text, {
298
- classNames: "line-clamp-2"
299
- }, description));
300
- } finally {
301
- _effect.f();
302
- }
303
- };
304
-
305
- // src/cards/TaskCard.tsx
306
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
307
- import * as SchemaAST from "effect/SchemaAST";
308
- import React6 from "react";
309
- import { PropertyMetaAnnotationId } from "@dxos/echo/internal";
310
- import { Card as Card5, cardNoSpacing as cardNoSpacing2, cardSpacing as cardSpacing2 } from "@dxos/react-ui-stack";
311
- import { mx as mx3 } from "@dxos/react-ui-theme";
312
- import { DataType } from "@dxos/schema";
313
- var getActiveStatusOption = (status) => {
314
- const properties = SchemaAST.getPropertySignatures(DataType.Task.ast);
315
- const statusProperty = properties.find((p) => p.name === "status");
316
- const statusMeta = SchemaAST.getAnnotation(PropertyMetaAnnotationId)(
317
- // TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
318
- statusProperty.type.types[0]
319
- );
320
- const options = statusMeta.value.singleSelect.options;
321
- return options.find(({ id }) => id === status);
322
- };
323
- var TaskCard = ({ subject, role, activeSpace }) => {
324
- var _effect = _useSignals6();
325
- try {
326
- const { title, status } = subject;
327
- const statusOption = getActiveStatusOption(status);
328
- return /* @__PURE__ */ React6.createElement(Card5.SurfaceRoot, {
329
- role
330
- }, /* @__PURE__ */ React6.createElement("div", {
331
- role: "none",
332
- className: mx3("flex items-center gap-2", cardSpacing2)
333
- }, /* @__PURE__ */ React6.createElement(Card5.Heading, {
334
- classNames: [
335
- cardNoSpacing2,
336
- "min-is-0 flex-1 truncate"
337
- ]
338
- }, title), statusOption && /* @__PURE__ */ React6.createElement("span", {
339
- className: "dx-tag",
340
- "data-hue": statusOption.color
341
- }, statusOption.title), /* @__PURE__ */ React6.createElement(CardSubjectMenu, {
342
- subject,
343
- activeSpace
344
- })));
345
- } finally {
346
- _effect.f();
347
- }
348
- };
349
-
350
- // src/capabilities/react-surface.tsx
351
- var react_surface_default = (() => contributes(Capabilities.ReactSurface, [
352
- //
353
- // Specific schema types.
354
- //
355
- createSurface({
356
- id: `${meta.id}/schema-popover--contact`,
357
- role: [
358
- "card--popover",
359
- "card--intrinsic",
360
- "card--transclusion",
361
- "card--extrinsic",
362
- "card"
363
- ],
364
- filter: (data) => Obj3.instanceOf(DataType2.Person, data.subject),
365
- component: ({ data, role }) => {
366
- const { dispatchPromise: dispatch } = useIntentDispatcher2();
367
- const space = getSpace(data.subject);
368
- const activeSpace = useActiveSpace();
369
- const handleSelect = useCallback((org) => dispatch(createIntent2(LayoutAction2.Open, {
370
- part: "main",
371
- subject: [
372
- fullyQualifiedId2(org)
373
- ],
374
- options: {
375
- workspace: space?.id
376
- }
377
- })), [
378
- dispatch
379
- ]);
380
- return /* @__PURE__ */ React7.createElement(ContactCard, {
381
- role,
382
- subject: data.subject,
383
- activeSpace,
384
- onSelect: handleSelect
385
- }, role === "card--popover" && /* @__PURE__ */ React7.createElement(Surface, {
386
- role: "related",
387
- data
388
- }));
389
- }
390
- }),
391
- createSurface({
392
- id: `${meta.id}/schema-popover--organization`,
393
- role: [
394
- "card--popover",
395
- "card--intrinsic",
396
- "card--transclusion",
397
- "card--extrinsic",
398
- "card"
399
- ],
400
- filter: (data) => Obj3.instanceOf(DataType2.Organization, data.subject),
401
- component: ({ data, role }) => {
402
- const activeSpace = useActiveSpace();
403
- return /* @__PURE__ */ React7.createElement(OrganizationCard, {
404
- role,
405
- subject: data.subject,
406
- activeSpace
407
- }, role === "card--popover" && /* @__PURE__ */ React7.createElement(Surface, {
408
- role: "related",
409
- data
410
- }));
411
- }
412
- }),
413
- createSurface({
414
- id: `${meta.id}/schema-popover--project`,
415
- role: [
416
- "card--popover",
417
- "card--intrinsic",
418
- "card--transclusion",
419
- "card--extrinsic",
420
- "card"
421
- ],
422
- filter: (data) => Obj3.instanceOf(DataType2.Project, data.subject),
423
- component: ({ data, role }) => {
424
- const activeSpace = useActiveSpace();
425
- return /* @__PURE__ */ React7.createElement(ProjectCard, {
426
- subject: data.subject,
427
- role,
428
- activeSpace
429
- });
430
- }
431
- }),
432
- createSurface({
433
- id: `${meta.id}/schema-popover--task`,
434
- role: [
435
- "card--popover",
436
- "card--intrinsic",
437
- "card--transclusion",
438
- "card--extrinsic",
439
- "card"
440
- ],
441
- filter: (data) => Obj3.instanceOf(DataType2.Task, data.subject),
442
- component: ({ data, role }) => /* @__PURE__ */ React7.createElement(TaskCard, {
443
- subject: data.subject,
444
- role
445
- })
446
- }),
447
- //
448
- // Fallback for any object.
449
- //
450
- createSurface({
451
- id: `${meta.id}/fallback-popover`,
452
- role: [
453
- "card--popover",
454
- "card--intrinsic",
455
- "card--transclusion",
456
- "card--extrinsic",
457
- "card"
458
- ],
459
- position: "fallback",
460
- filter: (data) => Obj3.isObject(data.subject),
461
- component: ({ data, role }) => {
462
- const schema = getSchema(data.subject);
463
- const { t } = useTranslation2(meta.id);
464
- if (!schema) {
465
- return /* @__PURE__ */ React7.createElement("p", {
466
- className: mx4(descriptionMessage)
467
- }, t("unable to create preview message"));
468
- }
469
- const handleSave = useCallback((values, { changed }) => {
470
- const changedPaths = Object.keys(changed).filter((path) => changed[path]);
471
- for (const path of changedPaths) {
472
- const value = values[path];
473
- setValue(data.subject, path, value);
474
- }
475
- }, []);
476
- return /* @__PURE__ */ React7.createElement(Card6.SurfaceRoot, {
477
- role
478
- }, /* @__PURE__ */ React7.createElement(Form, {
479
- schema,
480
- projection: data.projection,
481
- values: data.subject,
482
- readonly: role === "card--popover" ? "static" : false,
483
- onSave: handleSave,
484
- autoSave: true,
485
- ...role === "card--intrinsic" && {
486
- outerSpacing: "blockStart-0"
487
- }
488
- }));
489
- }
490
- }),
491
- createSurface({
492
- id: `${meta.id}/section`,
493
- role: [
494
- "section"
495
- ],
496
- position: "fallback",
497
- filter: (data) => Obj3.isObject(data.subject),
498
- component: ({ data }) => {
499
- return /* @__PURE__ */ React7.createElement("div", {
500
- role: "none",
501
- className: "flex justify-center"
502
- }, /* @__PURE__ */ React7.createElement("div", {
503
- role: "none",
504
- className: "card-max-width"
505
- }, /* @__PURE__ */ React7.createElement(Surface, {
506
- role: "card",
507
- data,
508
- limit: 1
509
- })));
510
- }
511
- })
512
- ]));
513
- export {
514
- react_surface_default as default
515
- };
516
- //# sourceMappingURL=react-surface-L37JR7U2.mjs.map