@dxos/plugin-preview 0.8.4-main.70d3990 → 0.8.4-main.74a063c4e0

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 (80) hide show
  1. package/dist/lib/browser/index.mjs +40 -45
  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 +41 -45
  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 +2 -2
  20. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
  21. package/dist/types/src/cards/PersonCard.d.ts +2 -2
  22. package/dist/types/src/cards/PersonCard.d.ts.map +1 -1
  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 +2 -2
  26. package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
  27. package/dist/types/src/cards/index.d.ts +2 -0
  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 +20 -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 -35
  41. package/src/PreviewPlugin.tsx +14 -24
  42. package/src/capabilities/index.ts +3 -3
  43. package/src/capabilities/preview-popover.ts +66 -42
  44. package/src/capabilities/react-surface.tsx +101 -142
  45. package/src/cards/FormCard.tsx +48 -0
  46. package/src/cards/JsonCard.tsx +16 -0
  47. package/src/cards/OrganizationCard.tsx +11 -16
  48. package/src/cards/PersonCard.tsx +51 -49
  49. package/src/cards/ProjectCard.tsx +9 -11
  50. package/src/cards/TaskCard.tsx +24 -26
  51. package/src/cards/index.ts +2 -0
  52. package/src/index.ts +0 -1
  53. package/src/meta.ts +3 -3
  54. package/src/stories/Card.stories.tsx +69 -24
  55. package/src/stories/testing.tsx +55 -78
  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-4QZ2WDE6.mjs +0 -65
  60. package/dist/lib/browser/preview-popover-4QZ2WDE6.mjs.map +0 -7
  61. package/dist/lib/browser/react-surface-X4KEMECS.mjs +0 -498
  62. package/dist/lib/browser/react-surface-X4KEMECS.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-FJ2ARIGS.mjs +0 -67
  66. package/dist/lib/node-esm/preview-popover-FJ2ARIGS.mjs.map +0 -7
  67. package/dist/lib/node-esm/react-surface-DR3UAH6F.mjs +0 -499
  68. package/dist/lib/node-esm/react-surface-DR3UAH6F.mjs.map +0 -7
  69. package/dist/types/src/components/CardComponents.d.ts +0 -16
  70. package/dist/types/src/components/CardComponents.d.ts.map +0 -1
  71. package/dist/types/src/components/CardSubjectMenu.d.ts +0 -8
  72. package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
  73. package/dist/types/src/components/index.d.ts +0 -3
  74. package/dist/types/src/components/index.d.ts.map +0 -1
  75. package/dist/types/src/types.d.ts +0 -12
  76. package/dist/types/src/types.d.ts.map +0 -1
  77. package/src/components/CardComponents.tsx +0 -67
  78. package/src/components/CardSubjectMenu.tsx +0 -103
  79. package/src/components/index.ts +0 -6
  80. package/src/types.ts +0 -25
@@ -1,19 +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: "dxos.org/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
- export {
17
- meta
18
- };
19
- //# sourceMappingURL=chunk-Q5MUNELK.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/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"],
5
- "mappings": ";;;AAKA,SAASA,YAAY;AAEd,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,QAAQ;AACV;",
6
- "names": ["trim", "meta", "id", "name", "description", "trim", "icon", "source"]
7
- }
@@ -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.makeRef(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 handleAnchorActivate = 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, handleAnchorActivate, 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-FJ2ARIGS.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.makeRef(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 handleAnchorActivate = 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 handleAnchorActivate,\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,GAAGC,QAAQd,IAAIe,MAAML,GAAAA,CAAAA,EAAMM,KAAI;AACjE,WAAO;MAAEL;MAAOC;IAAO;EACzB,QAAQ;AACN,WAAO;EACT;AACF;AAEA,IAAA,2BAAe,CAACK,YAAAA;AAEd,QAAMC,uBAAuB,OAAO,EAAEC,OAAOR,OAAOS,QAAO,MAAoB;AAC7E,UAAM,EAAEC,iBAAiBC,SAAQ,IAAKL,QAAQM,cAAc7B,aAAa8B,gBAAgB;AACzF,UAAMhB,SAASS,QAAQM,cAAcrB,mBAAmBuB,MAAM;AAC9D,UAAM,CAACC,MAAAA,IAAUT,QAAQU,gBAAgBjC,aAAakC,MAAM;AAC5D,UAAM,EAAEC,QAAO,IAAK9B,QAAQ2B,OAAOI,SAAS;AAC5C,UAAMC,SAASF,WAAWrB,OAAOwB,OAAOC,IAAIJ,OAAAA,MAAarB,OAAOwB,OAAOE;AACvE,UAAMC,SAAS,MAAM5B,oBAAoBC,QAAQuB,OAAO;MAAErB,KAAKS;MAAOR;IAAM,CAAA;AAC5E,QAAI,CAACwB,QAAQ;AACX;IACF;AAEA,UAAMb,SACJzB,aAAaF,aAAayC,eAAe;MACvCC,MAAM;MACNC,SAASH,OAAOvB;MAChB2B,SAAS;QACPC,OAAO;QACPC,SAAS;QACTC,QAAQtB;MACV;IACF,CAAA,CAAA;EAEJ;AAEA,MAAIuB;AACJ,MAAIC,SAASC,aAAa;AACxBF,cAAU7C,iBACR8C,SAASC,aACT1C,oBACAe,sBACAd,kBAAAA;EAEJ,OAAO;AACLH,QAAI6C,KAAK,yBAAA,QAAA;;;;;;EACX;AAEA,SAAOlD,YAAYF,aAAaqD,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", "makeRef", "parse", "load", "context", "handleAnchorActivate", "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,499 +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, contributes, createIntent as createIntent2, createSurface } from "@dxos/app-framework";
9
- import { Surface, SurfaceCardRole, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework/react";
10
- import { getSpace } from "@dxos/client/echo";
11
- import { Obj as Obj3 } from "@dxos/echo";
12
- import { setValue } from "@dxos/echo/internal";
13
- import { useActiveSpace } from "@dxos/plugin-space";
14
- import { useTranslation as useTranslation2 } from "@dxos/react-ui";
15
- import { Form } from "@dxos/react-ui-form";
16
- import { Card as Card6 } from "@dxos/react-ui-stack";
17
- import { descriptionMessage, mx as mx4 } from "@dxos/react-ui-theme";
18
- import { Organization, Person, Project, Task as Task2 } from "@dxos/types";
19
-
20
- // src/cards/OrganizationCard.tsx
21
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
22
- import React3 from "react";
23
- import { Card as Card2 } from "@dxos/react-ui-stack";
24
-
25
- // src/components/CardComponents.tsx
26
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
27
- import React2 from "react";
28
- import { Button, Icon } from "@dxos/react-ui";
29
- import { Card, cardNoSpacing, cardSpacing } from "@dxos/react-ui-stack";
30
- import { mx } from "@dxos/react-ui-theme";
31
-
32
- // src/components/CardSubjectMenu.tsx
33
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
34
- import { Atom } from "@effect-atom/atom-react";
35
- import React from "react";
36
- import { LayoutAction, createIntent } from "@dxos/app-framework";
37
- import { useIntentDispatcher } from "@dxos/app-framework/react";
38
- import { ACTION_TYPE } from "@dxos/app-graph";
39
- import { Obj } from "@dxos/echo";
40
- import { SpaceAction } from "@dxos/plugin-space/types";
41
- import { IconButton, useTranslation } from "@dxos/react-ui";
42
- import { DropdownMenu, MenuProvider, useMenuActions } from "@dxos/react-ui-menu";
43
- var CardSubjectMenu = ({ subject, activeSpace, ...props }) => {
44
- var _effect = _useSignals();
45
- try {
46
- const { t } = useTranslation(meta.id);
47
- const menuProps = useSubjectMenuGroupItems({
48
- subject,
49
- activeSpace
50
- });
51
- if (!activeSpace) {
52
- return null;
53
- }
54
- return /* @__PURE__ */ React.createElement(MenuProvider, menuProps, /* @__PURE__ */ React.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React.createElement(DropdownMenu.Trigger, {
55
- asChild: true
56
- }, /* @__PURE__ */ React.createElement(IconButton, {
57
- variant: "ghost",
58
- icon: "ph--dots-three-vertical--bold",
59
- iconOnly: true,
60
- label: t("more options label"),
61
- ...props
62
- }))));
63
- } finally {
64
- _effect.f();
65
- }
66
- };
67
- var useSubjectMenuGroupItems = ({ subject, activeSpace }) => {
68
- const { dispatchPromise: dispatch } = useIntentDispatcher();
69
- const result = {
70
- edges: [],
71
- nodes: []
72
- };
73
- result.nodes.push({
74
- type: ACTION_TYPE,
75
- id: `${subject.id}/open`,
76
- data: () => dispatch(createIntent(LayoutAction.Open, {
77
- part: "main",
78
- subject: [
79
- Obj.getDXN(subject).toString()
80
- ]
81
- })),
82
- properties: {
83
- label: [
84
- "open object label",
85
- {
86
- ns: meta.id
87
- }
88
- ],
89
- icon: "ph--arrow-right--regular"
90
- }
91
- });
92
- if (activeSpace && Obj.getDXN(subject).asQueueDXN()) {
93
- result.nodes.push({
94
- type: ACTION_TYPE,
95
- id: `${subject.id}/add-to-space`,
96
- // TODO(wittjosiah): Update reference to point to db object when adding?
97
- data: () => dispatch(createIntent(SpaceAction.AddObject, {
98
- object: subject,
99
- target: activeSpace,
100
- hidden: true
101
- })),
102
- properties: {
103
- label: [
104
- "add object to space label",
105
- {
106
- ns: meta.id
107
- }
108
- ],
109
- icon: "ph--file-plus--regular"
110
- }
111
- });
112
- }
113
- result.nodes.forEach(({ id: target }) => {
114
- result.edges.push({
115
- source: "root",
116
- target
117
- });
118
- });
119
- return useMenuActions(Atom.make(result));
120
- };
121
-
122
- // src/components/CardComponents.tsx
123
- var gridRow = "is-full grid grid-cols-[1.5rem_1fr_min-content] gap-2 items-center";
124
- var CardHeader = ({ label, subject, activeSpace }) => {
125
- var _effect = _useSignals2();
126
- try {
127
- return /* @__PURE__ */ React2.createElement("div", {
128
- role: "none",
129
- className: mx("flex items-center gap-2", cardSpacing)
130
- }, /* @__PURE__ */ React2.createElement(Card.Heading, {
131
- classNames: cardNoSpacing
132
- }, label), /* @__PURE__ */ React2.createElement(CardSubjectMenu, {
133
- subject,
134
- activeSpace
135
- }));
136
- } finally {
137
- _effect.f();
138
- }
139
- };
140
- var CardRow = ({ icon, label, onClick }) => {
141
- var _effect = _useSignals2();
142
- try {
143
- if (!onClick) {
144
- return /* @__PURE__ */ React2.createElement(Card.Chrome, null, /* @__PURE__ */ React2.createElement("p", {
145
- "data-variant": "ghost",
146
- className: mx(gridRow, "dx-button")
147
- }, /* @__PURE__ */ React2.createElement(Icon, {
148
- icon,
149
- size: 5,
150
- classNames: "text-subdued"
151
- }), /* @__PURE__ */ React2.createElement("span", {
152
- className: "min-is-0 flex-1 truncate col-span-2"
153
- }, label)));
154
- }
155
- return /* @__PURE__ */ React2.createElement(Card.Chrome, null, /* @__PURE__ */ React2.createElement(Button, {
156
- variant: "ghost",
157
- classNames: mx(gridRow, "text-start"),
158
- onClick
159
- }, /* @__PURE__ */ React2.createElement(Icon, {
160
- icon,
161
- size: 5,
162
- classNames: "text-subdued"
163
- }), /* @__PURE__ */ React2.createElement("span", {
164
- className: "min-is-0 flex-1 truncate"
165
- }, label), /* @__PURE__ */ React2.createElement(Icon, {
166
- icon: "ph--arrow-right--regular"
167
- })));
168
- } finally {
169
- _effect.f();
170
- }
171
- };
172
- var CardLink = ({ label, href }) => {
173
- var _effect = _useSignals2();
174
- try {
175
- return /* @__PURE__ */ React2.createElement(Card.Chrome, null, /* @__PURE__ */ React2.createElement("a", {
176
- className: mx(gridRow, "dx-button dx-focus-ring"),
177
- "data-variant": "ghost",
178
- href,
179
- target: "_blank",
180
- rel: "noreferrer"
181
- }, /* @__PURE__ */ React2.createElement(Icon, {
182
- icon: "ph--link--regular",
183
- size: 5,
184
- classNames: "text-subdued"
185
- }), /* @__PURE__ */ React2.createElement("span", {
186
- className: "min-is-0 flex-1 truncate"
187
- }, label), /* @__PURE__ */ React2.createElement(Icon, {
188
- icon: "ph--arrow-square-out--regular"
189
- })));
190
- } finally {
191
- _effect.f();
192
- }
193
- };
194
-
195
- // src/cards/OrganizationCard.tsx
196
- var OrganizationCard = ({ children, subject, role, activeSpace }) => {
197
- var _effect = _useSignals3();
198
- try {
199
- const { name, image, description, website } = subject;
200
- return /* @__PURE__ */ React3.createElement(Card2.SurfaceRoot, {
201
- id: subject.id,
202
- role
203
- }, /* @__PURE__ */ React3.createElement(Card2.Poster, {
204
- alt: name ?? "",
205
- ...image ? {
206
- image
207
- } : {
208
- icon: "ph--building-office--regular"
209
- },
210
- classNames: !image && "opacity-50"
211
- }), /* @__PURE__ */ React3.createElement(CardHeader, {
212
- label: name,
213
- subject,
214
- activeSpace
215
- }), description && /* @__PURE__ */ React3.createElement(Card2.Text, {
216
- classNames: "line-clamp-2"
217
- }, description), website && /* @__PURE__ */ React3.createElement(CardLink, {
218
- label: website,
219
- href: website
220
- }), children);
221
- } finally {
222
- _effect.f();
223
- }
224
- };
225
-
226
- // src/cards/PersonCard.tsx
227
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
228
- import React4, { Fragment } from "react";
229
- import { Avatar, Icon as Icon2 } from "@dxos/react-ui";
230
- import { Card as Card3, cardHeading, cardText } from "@dxos/react-ui-stack";
231
- import { mx as mx2 } from "@dxos/react-ui-theme";
232
- var PersonCard = ({ children, role, subject, activeSpace, onSelect }) => {
233
- var _effect = _useSignals4();
234
- try {
235
- const { fullName, image, organization: { target: organization } = {}, emails = [] } = subject;
236
- return /* @__PURE__ */ React4.createElement(Card3.SurfaceRoot, {
237
- id: subject.id,
238
- role
239
- }, /* @__PURE__ */ React4.createElement(Avatar.Root, null, /* @__PURE__ */ React4.createElement(Card3.Text, {
240
- role: "group",
241
- classNames: mx2("grid gap-2 grid-cols-[1fr_min-content]")
242
- }, /* @__PURE__ */ React4.createElement("div", {
243
- role: "none",
244
- className: mx2(gridRow, "grid-rows-2")
245
- }, activeSpace ? /* @__PURE__ */ React4.createElement(CardSubjectMenu, {
246
- subject,
247
- activeSpace
248
- }) : /* @__PURE__ */ React4.createElement("div", null), /* @__PURE__ */ React4.createElement(Avatar.Label, {
249
- asChild: true
250
- }, /* @__PURE__ */ React4.createElement("h2", {
251
- className: mx2(cardHeading, "grow truncate")
252
- }, fullName))), /* @__PURE__ */ React4.createElement(Avatar.Content, {
253
- imgSrc: image,
254
- icon: "ph--user--regular",
255
- size: 16,
256
- classNames: [
257
- "text-subdued",
258
- !image && "opacity-50"
259
- ],
260
- hue: "neutral",
261
- variant: "square"
262
- }))), organization?.name && /* @__PURE__ */ React4.createElement(CardRow, {
263
- icon: "ph--buildings--regular",
264
- label: organization.name,
265
- onClick: onSelect ? () => onSelect(organization) : void 0
266
- }), emails.length > 0 && /* @__PURE__ */ React4.createElement("dl", {
267
- className: mx2(cardText, gridRow, "[&_dt]:text-subdued [&_dt]:pbs-0.5 [&_dd]:min-is-0")
268
- }, emails.map(({ label, value }) => /* @__PURE__ */ React4.createElement(Fragment, {
269
- key: value
270
- }, /* @__PURE__ */ React4.createElement("dt", null, /* @__PURE__ */ React4.createElement("span", {
271
- className: "sr-only"
272
- }, label), /* @__PURE__ */ React4.createElement(Icon2, {
273
- icon: "ph--at--regular",
274
- size: 5
275
- })), /* @__PURE__ */ React4.createElement("dd", {
276
- key: value,
277
- className: "col-span-2 break-words"
278
- }, value)))), children);
279
- } finally {
280
- _effect.f();
281
- }
282
- };
283
-
284
- // src/cards/ProjectCard.tsx
285
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
286
- import React5 from "react";
287
- import { Obj as Obj2 } from "@dxos/echo";
288
- import { Card as Card4 } from "@dxos/react-ui-stack";
289
- var ProjectCard = ({ subject, role, activeSpace }) => {
290
- var _effect = _useSignals5();
291
- try {
292
- const { name, image, description } = subject;
293
- return /* @__PURE__ */ React5.createElement(Card4.SurfaceRoot, {
294
- id: subject.id,
295
- role
296
- }, image && /* @__PURE__ */ React5.createElement(Card4.Poster, {
297
- image,
298
- alt: Obj2.getLabel(subject) ?? "",
299
- aspect: "auto"
300
- }), /* @__PURE__ */ React5.createElement(CardHeader, {
301
- label: name,
302
- subject,
303
- activeSpace
304
- }), description && /* @__PURE__ */ React5.createElement(Card4.Text, {
305
- classNames: "line-clamp-2"
306
- }, description));
307
- } finally {
308
- _effect.f();
309
- }
310
- };
311
-
312
- // src/cards/TaskCard.tsx
313
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
314
- import * as SchemaAST from "effect/SchemaAST";
315
- import React6 from "react";
316
- import { PropertyMetaAnnotationId } from "@dxos/echo/internal";
317
- import { Card as Card5, cardNoSpacing as cardNoSpacing2, cardSpacing as cardSpacing2 } from "@dxos/react-ui-stack";
318
- import { mx as mx3 } from "@dxos/react-ui-theme";
319
- import { Task } from "@dxos/types";
320
- var getActiveStatusOption = (status) => {
321
- const properties = SchemaAST.getPropertySignatures(Task.Task.ast);
322
- const statusProperty = properties.find((p) => p.name === "status");
323
- const statusMeta = SchemaAST.getAnnotation(PropertyMetaAnnotationId)(
324
- // TODO(thure): Typescript asserts `.type` doesn’t have `.types`, but in runtime it does.
325
- statusProperty.type.types[0]
326
- );
327
- const options = statusMeta.value.singleSelect.options;
328
- return options.find(({ id }) => id === status);
329
- };
330
- var TaskCard = ({ subject, role, activeSpace }) => {
331
- var _effect = _useSignals6();
332
- try {
333
- const { title, status } = subject;
334
- const statusOption = getActiveStatusOption(status);
335
- return /* @__PURE__ */ React6.createElement(Card5.SurfaceRoot, {
336
- id: subject.id,
337
- role
338
- }, /* @__PURE__ */ React6.createElement("div", {
339
- role: "none",
340
- className: mx3("flex items-center gap-2", cardSpacing2)
341
- }, /* @__PURE__ */ React6.createElement(Card5.Heading, {
342
- classNames: [
343
- cardNoSpacing2,
344
- "min-is-0 flex-1 truncate"
345
- ]
346
- }, title), statusOption && /* @__PURE__ */ React6.createElement("span", {
347
- className: "dx-tag",
348
- "data-hue": statusOption.color
349
- }, statusOption.title), /* @__PURE__ */ React6.createElement(CardSubjectMenu, {
350
- subject,
351
- activeSpace
352
- })));
353
- } finally {
354
- _effect.f();
355
- }
356
- };
357
-
358
- // src/capabilities/react-surface.tsx
359
- var react_surface_default = (() => contributes(Capabilities.ReactSurface, [
360
- //
361
- // Specific schema types.
362
- // TODO(burdon): Create helpers and factor out.
363
- //
364
- // TODO(burdon): Infer Role type.
365
- createSurface({
366
- id: `${meta.id}/schema-popover--contact`,
367
- role: SurfaceCardRole.literals,
368
- filter: (data) => Obj3.instanceOf(Person.Person, data.subject),
369
- component: ({ data, role }) => {
370
- const { dispatchPromise: dispatch } = useIntentDispatcher2();
371
- const space = getSpace(data.subject);
372
- const activeSpace = useActiveSpace();
373
- const handleSelect = useCallback((object) => dispatch(createIntent2(LayoutAction2.Open, {
374
- part: "main",
375
- subject: [
376
- Obj3.getDXN(object).toString()
377
- ],
378
- options: {
379
- workspace: space?.id
380
- }
381
- })), [
382
- dispatch
383
- ]);
384
- return /* @__PURE__ */ React7.createElement(PersonCard, {
385
- role,
386
- subject: data.subject,
387
- activeSpace,
388
- onSelect: handleSelect
389
- }, role === "card--popover" && /* @__PURE__ */ React7.createElement(Surface, {
390
- role: "related",
391
- data
392
- }));
393
- }
394
- }),
395
- createSurface({
396
- id: `${meta.id}/schema-popover--organization`,
397
- role: SurfaceCardRole.literals,
398
- filter: (data) => Obj3.instanceOf(Organization.Organization, data.subject),
399
- component: ({ data, role }) => {
400
- const activeSpace = useActiveSpace();
401
- return /* @__PURE__ */ React7.createElement(OrganizationCard, {
402
- role,
403
- subject: data.subject,
404
- activeSpace
405
- }, role === "card--popover" && /* @__PURE__ */ React7.createElement(Surface, {
406
- role: "related",
407
- data
408
- }));
409
- }
410
- }),
411
- createSurface({
412
- id: `${meta.id}/schema-popover--project`,
413
- role: SurfaceCardRole.literals,
414
- filter: (data) => Obj3.instanceOf(Project.Project, data.subject),
415
- component: ({ data, role }) => {
416
- const activeSpace = useActiveSpace();
417
- return /* @__PURE__ */ React7.createElement(ProjectCard, {
418
- subject: data.subject,
419
- role,
420
- activeSpace
421
- });
422
- }
423
- }),
424
- createSurface({
425
- id: `${meta.id}/schema-popover--task`,
426
- role: SurfaceCardRole.literals,
427
- filter: (data) => Obj3.instanceOf(Task2.Task, data.subject),
428
- component: ({ data, role }) => {
429
- return /* @__PURE__ */ React7.createElement(TaskCard, {
430
- subject: data.subject,
431
- role
432
- });
433
- }
434
- }),
435
- //
436
- // Fallback for any object.
437
- //
438
- createSurface({
439
- id: `${meta.id}/fallback-popover`,
440
- role: SurfaceCardRole.literals,
441
- position: "fallback",
442
- filter: (data) => Obj3.isObject(data.subject),
443
- component: ({ data, role }) => {
444
- const schema = Obj3.getSchema(data.subject);
445
- const { t } = useTranslation2(meta.id);
446
- if (!schema) {
447
- return /* @__PURE__ */ React7.createElement("p", {
448
- className: mx4(descriptionMessage)
449
- }, t("unable to create preview message"));
450
- }
451
- const handleSave = useCallback((values, { changed }) => {
452
- const changedPaths = Object.keys(changed).filter((path) => changed[path]);
453
- for (const path of changedPaths) {
454
- const value = values[path];
455
- setValue(data.subject, path, value);
456
- }
457
- }, []);
458
- return /* @__PURE__ */ React7.createElement(Card6.SurfaceRoot, {
459
- role
460
- }, /* @__PURE__ */ React7.createElement(Form, {
461
- id: data.subject.id,
462
- schema,
463
- projection: data.projection,
464
- values: data.subject,
465
- readonly: role === "card--popover" ? "static" : false,
466
- onSave: handleSave,
467
- autoSave: true,
468
- ...role === "card--intrinsic" && {
469
- outerSpacing: "blockStart-0"
470
- }
471
- }));
472
- }
473
- }),
474
- createSurface({
475
- id: `${meta.id}/section`,
476
- role: [
477
- "section"
478
- ],
479
- position: "fallback",
480
- filter: (data) => Obj3.isObject(data.subject),
481
- component: ({ data }) => {
482
- return /* @__PURE__ */ React7.createElement("div", {
483
- role: "none",
484
- className: "flex is-full justify-center"
485
- }, /* @__PURE__ */ React7.createElement("div", {
486
- role: "none",
487
- className: "pbs-2 pbe-2 card-min-width card-max-width"
488
- }, /* @__PURE__ */ React7.createElement(Surface, {
489
- role: "card",
490
- data,
491
- limit: 1
492
- })));
493
- }
494
- })
495
- ]));
496
- export {
497
- react_surface_default as default
498
- };
499
- //# sourceMappingURL=react-surface-DR3UAH6F.mjs.map