@dxos/plugin-preview 0.8.4-main.3c1ae3b → 0.8.4-main.52d7546f51

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