@dxos/plugin-stack 0.8.2-staging.7ac8446 → 0.8.3-main.672df60

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 (66) hide show
  1. package/dist/lib/browser/StackMain-HZI5H2RA.mjs +315 -0
  2. package/dist/lib/browser/StackMain-HZI5H2RA.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-L34RFJ2L.mjs → chunk-XOUJQIK6.mjs} +10 -9
  4. package/dist/lib/browser/chunk-XOUJQIK6.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +10 -38
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/react-surface-FIWIAQRE.mjs +46 -0
  9. package/dist/lib/browser/react-surface-FIWIAQRE.mjs.map +7 -0
  10. package/dist/lib/browser/types/index.mjs +1 -1
  11. package/dist/lib/node/StackMain-NPXLFG5C.cjs +329 -0
  12. package/dist/lib/node/StackMain-NPXLFG5C.cjs.map +7 -0
  13. package/dist/lib/node/{chunk-6IPBX635.cjs → chunk-5QWZH22T.cjs} +12 -11
  14. package/dist/lib/node/chunk-5QWZH22T.cjs.map +7 -0
  15. package/dist/lib/node/index.cjs +5 -29
  16. package/dist/lib/node/index.cjs.map +4 -4
  17. package/dist/lib/node/meta.json +1 -1
  18. package/dist/lib/node/react-surface-73G6PBCV.cjs +64 -0
  19. package/dist/lib/node/react-surface-73G6PBCV.cjs.map +7 -0
  20. package/dist/lib/node/types/index.cjs +3 -3
  21. package/dist/lib/node/types/index.cjs.map +1 -1
  22. package/dist/lib/node-esm/StackMain-QH6CGYPK.mjs +316 -0
  23. package/dist/lib/node-esm/StackMain-QH6CGYPK.mjs.map +7 -0
  24. package/dist/lib/node-esm/{chunk-3ZYHKSIS.mjs → chunk-3R62SZZT.mjs} +10 -9
  25. package/dist/lib/node-esm/chunk-3R62SZZT.mjs.map +7 -0
  26. package/dist/lib/node-esm/index.mjs +10 -38
  27. package/dist/lib/node-esm/index.mjs.map +4 -4
  28. package/dist/lib/node-esm/meta.json +1 -1
  29. package/dist/lib/node-esm/react-surface-SCL5YFJ5.mjs +47 -0
  30. package/dist/lib/node-esm/react-surface-SCL5YFJ5.mjs.map +7 -0
  31. package/dist/lib/node-esm/types/index.mjs +1 -1
  32. package/dist/types/src/StackPlugin.d.ts.map +1 -1
  33. package/dist/types/src/capabilities/index.d.ts +2 -0
  34. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  35. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  36. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  37. package/dist/types/src/components/CaretDownUp.d.ts.map +1 -1
  38. package/dist/types/src/components/StackMain.d.ts.map +1 -1
  39. package/dist/types/src/components/StackSection.d.ts +2 -1
  40. package/dist/types/src/components/StackSection.d.ts.map +1 -1
  41. package/dist/types/src/components/StackSettings.d.ts.map +1 -1
  42. package/dist/types/src/translations.d.ts +1 -0
  43. package/dist/types/src/translations.d.ts.map +1 -1
  44. package/dist/types/src/types/stack.d.ts +11 -11
  45. package/dist/types/src/types/stack.d.ts.map +1 -1
  46. package/dist/types/src/types/types.d.ts +2 -2
  47. package/dist/types/src/types/types.d.ts.map +1 -1
  48. package/dist/types/tsconfig.tsbuildinfo +1 -1
  49. package/package.json +27 -23
  50. package/src/StackPlugin.ts +53 -0
  51. package/src/capabilities/index.ts +7 -0
  52. package/src/capabilities/react-surface.tsx +33 -0
  53. package/src/components/StackMain.tsx +11 -9
  54. package/src/components/StackSection.tsx +8 -6
  55. package/src/types/stack.ts +7 -5
  56. package/src/types/types.ts +2 -2
  57. package/dist/lib/browser/StackMain-E42SHTS6.mjs +0 -295
  58. package/dist/lib/browser/StackMain-E42SHTS6.mjs.map +0 -7
  59. package/dist/lib/browser/chunk-L34RFJ2L.mjs.map +0 -7
  60. package/dist/lib/node/StackMain-4N6IFLMF.cjs +0 -309
  61. package/dist/lib/node/StackMain-4N6IFLMF.cjs.map +0 -7
  62. package/dist/lib/node/chunk-6IPBX635.cjs.map +0 -7
  63. package/dist/lib/node-esm/StackMain-QFKYWI2J.mjs +0 -296
  64. package/dist/lib/node-esm/StackMain-QFKYWI2J.mjs.map +0 -7
  65. package/dist/lib/node-esm/chunk-3ZYHKSIS.mjs.map +0 -7
  66. package/src/StackPlugin.tsx +0 -76
@@ -1,296 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- STACK_PLUGIN
4
- } from "./chunk-YW7WYA4H.mjs";
5
- import {
6
- StackViewType
7
- } from "./chunk-3ZYHKSIS.mjs";
8
-
9
- // packages/plugins/plugin-stack/src/components/StackMain.tsx
10
- import { Plus } from "@phosphor-icons/react";
11
- import React3, { useCallback, useEffect, useMemo, useState as useState2 } from "react";
12
- import { Capabilities, createIntent, LayoutAction, useAppGraph, useCapabilities, useIntentDispatcher } from "@dxos/app-framework";
13
- import { create, getType, fullyQualifiedId, isReactiveObject, makeRef } from "@dxos/client/echo";
14
- import { SpaceAction } from "@dxos/plugin-space/types";
15
- import { Button, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
16
- import { AttentionProvider } from "@dxos/react-ui-attention";
17
- import { Stack } from "@dxos/react-ui-stack";
18
- import { isNonNullable } from "@dxos/util";
19
-
20
- // packages/plugins/plugin-stack/src/components/StackContext.tsx
21
- import { createContext, useContext } from "react";
22
- var StackContext = /* @__PURE__ */ createContext({
23
- onCollapse: () => {
24
- },
25
- onNavigate: async () => {
26
- },
27
- onDelete: async () => {
28
- },
29
- onAdd: () => {
30
- }
31
- });
32
- var useStack = () => useContext(StackContext);
33
-
34
- // packages/plugins/plugin-stack/src/components/StackSection.tsx
35
- import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
36
- import React2, { useState } from "react";
37
- import { Surface } from "@dxos/app-framework";
38
- import { DropdownMenu, Icon, useTranslation, IconButton } from "@dxos/react-ui";
39
- import { useAttendableAttributes } from "@dxos/react-ui-attention";
40
- import { StackItem } from "@dxos/react-ui-stack";
41
- import { mx, getSize, textBlockWidth } from "@dxos/react-ui-theme";
42
-
43
- // packages/plugins/plugin-stack/src/components/CaretDownUp.tsx
44
- import React from "react";
45
- var CaretDownUp = ({ children, ...props }) => {
46
- return /* @__PURE__ */ React.createElement("svg", {
47
- xmlns: "http://www.w3.org/2000/svg",
48
- viewBox: "0 0 256 256",
49
- ...props
50
- }, /* @__PURE__ */ React.createElement("rect", {
51
- width: "256",
52
- height: "256",
53
- fill: "none"
54
- }), /* @__PURE__ */ React.createElement("polyline", {
55
- points: "80 224 128 176 176 224",
56
- fill: "none",
57
- stroke: "currentColor",
58
- strokeLinecap: "round",
59
- strokeLinejoin: "round",
60
- strokeWidth: "16"
61
- }), /* @__PURE__ */ React.createElement("polyline", {
62
- points: "80 32 128 80 176 32",
63
- fill: "none",
64
- stroke: "currentColor",
65
- strokeLinecap: "round",
66
- strokeLinejoin: "round",
67
- strokeWidth: "16"
68
- }), children);
69
- };
70
-
71
- // packages/plugins/plugin-stack/src/components/StackSection.tsx
72
- var sectionActionDimensions = "p-1 mlb-1 shrink-0 min-bs-0 is-[--rail-action] bs-min";
73
- var StackSection = ({ id, view, object, metadata: { icon = "ph--placeholder--regular" } }) => {
74
- const { t } = useTranslation(STACK_PLUGIN);
75
- const { onNavigate, onAdd, onCollapse, onDelete } = useStack();
76
- const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);
77
- const attendableAttrs = useAttendableAttributes(id);
78
- return /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Root, {
79
- asChild: true,
80
- open: !view.collapsed,
81
- onOpenChange: (nextOpen) => onCollapse?.(id, !nextOpen)
82
- }, /* @__PURE__ */ React2.createElement(StackItem.Root, {
83
- item: {
84
- id
85
- },
86
- role: "section",
87
- ...attendableAttrs,
88
- classNames: "border-be border-separator"
89
- }, /* @__PURE__ */ React2.createElement(StackItem.Heading, {
90
- classNames: "attention-surface border-ie !border-separator"
91
- }, /* @__PURE__ */ React2.createElement("span", {
92
- className: "sr-only"
93
- }, view.title), /* @__PURE__ */ React2.createElement("div", {
94
- role: "none",
95
- className: "sticky -block-start-px bg-[--sticky-bg] p-1 is-full"
96
- }, /* @__PURE__ */ React2.createElement(DropdownMenu.Root, {
97
- open: optionsMenuOpen,
98
- onOpenChange: setOptionsMenuOpen
99
- }, /* @__PURE__ */ React2.createElement(DropdownMenu.Trigger, {
100
- asChild: true
101
- }, /* @__PURE__ */ React2.createElement(StackItem.SigilButton, null, /* @__PURE__ */ React2.createElement(Icon, {
102
- icon,
103
- size: 5,
104
- classNames: "transition-opacity"
105
- }))), /* @__PURE__ */ React2.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Viewport, null, view.collapsed ? /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
106
- onClick: () => onNavigate(id),
107
- "data-testid": "section.navigate-to"
108
- }, /* @__PURE__ */ React2.createElement(Icon, {
109
- icon: "ph--arrow-square-out--regular",
110
- size: 5
111
- }), /* @__PURE__ */ React2.createElement("span", {
112
- className: "mis-2 grow"
113
- }, t("navigate to section label"))) : /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Trigger, {
114
- asChild: true
115
- }, /* @__PURE__ */ React2.createElement(DropdownMenu.Item, null, /* @__PURE__ */ React2.createElement(CaretDownUp, {
116
- className: getSize(5)
117
- }), /* @__PURE__ */ React2.createElement("span", {
118
- className: "mis-2 grow"
119
- }, t("collapse label")))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
120
- onClick: () => onAdd(id, "before"),
121
- "data-testid": "section.add-before"
122
- }, /* @__PURE__ */ React2.createElement(Icon, {
123
- icon: "ph--arrow-line-up--regular",
124
- size: 5
125
- }), /* @__PURE__ */ React2.createElement("span", {
126
- className: "mis-2 grow"
127
- }, t("add section before label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
128
- onClick: () => onAdd(id, "after"),
129
- "data-testid": "section.add-after"
130
- }, /* @__PURE__ */ React2.createElement(Icon, {
131
- icon: "ph--arrow-line-down--regular",
132
- size: 5
133
- }), /* @__PURE__ */ React2.createElement("span", {
134
- className: "mis-2 grow"
135
- }, t("add section after label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
136
- onClick: () => onDelete(id),
137
- "data-testid": "section.remove"
138
- }, /* @__PURE__ */ React2.createElement(Icon, {
139
- icon: "ph--trash--regular",
140
- size: 5
141
- }), /* @__PURE__ */ React2.createElement("span", {
142
- className: "mis-2 grow"
143
- }, t("remove section label")))), /* @__PURE__ */ React2.createElement(DropdownMenu.Arrow, null)))), view.collapsed ? /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Trigger, {
144
- asChild: true
145
- }, /* @__PURE__ */ React2.createElement(IconButton, {
146
- iconOnly: true,
147
- variant: "ghost",
148
- label: t("expand label"),
149
- icon: "ph--caret-up-down--regular",
150
- classNames: sectionActionDimensions
151
- })) : /* @__PURE__ */ React2.createElement(IconButton, {
152
- iconOnly: true,
153
- variant: "ghost",
154
- onClick: () => onNavigate(id),
155
- label: t("navigate to section label"),
156
- icon: "ph--arrow-square-out--regular",
157
- "data-testid": "section.navigate-to",
158
- classNames: sectionActionDimensions
159
- }))), /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Content, null, /* @__PURE__ */ React2.createElement(Surface, {
160
- role: "section",
161
- data: {
162
- subject: object
163
- },
164
- limit: 1,
165
- placeholder: /* @__PURE__ */ React2.createElement(React2.Fragment, null)
166
- })), view.collapsed && /* @__PURE__ */ React2.createElement(StackItem.Content, {
167
- classNames: "attention-surface"
168
- }, /* @__PURE__ */ React2.createElement("h2", {
169
- className: mx("flex items-center p-4 font-medium", textBlockWidth)
170
- }, view.title))));
171
- };
172
-
173
- // packages/plugins/plugin-stack/src/components/StackMain.tsx
174
- var StackMain = ({ id, collection }) => {
175
- const { dispatchPromise: dispatch } = useIntentDispatcher();
176
- const { graph } = useAppGraph();
177
- const { t } = useTranslation2(STACK_PLUGIN);
178
- const allMetadata = useCapabilities(Capabilities.Metadata);
179
- const defaultStack = useMemo(() => create(StackViewType, {
180
- sections: {}
181
- }), [
182
- collection
183
- ]);
184
- const stack = collection.views[StackViewType.typename]?.target ?? defaultStack;
185
- const [collapsedSections, setCollapsedSections] = useState2({});
186
- useEffect(() => {
187
- if (!collection.views[StackViewType.typename]) {
188
- collection.views[StackViewType.typename] = makeRef(stack);
189
- }
190
- }, [
191
- collection,
192
- stack
193
- ]);
194
- const items = collection.objects.map((object) => object.target).filter(isNonNullable).map((object) => {
195
- const metadata = allMetadata.find((m) => m.id === (getType(object)?.objectId ?? "never"))?.metadata;
196
- const view = {
197
- ...stack.sections[object.id],
198
- collapsed: collapsedSections[fullyQualifiedId(object)],
199
- title: object?.title ?? toLocalizedString(graph.findNode(fullyQualifiedId(object))?.properties.label, t)
200
- };
201
- return {
202
- id: fullyQualifiedId(object),
203
- object,
204
- metadata,
205
- view
206
- };
207
- }) ?? [];
208
- const handleDelete = useCallback(async (id2) => {
209
- const index = collection.objects.map((object2) => object2.target).filter(isNonNullable).findIndex((section) => fullyQualifiedId(section) === id2);
210
- const object = collection.objects[index].target;
211
- if (isReactiveObject(object)) {
212
- await dispatch(createIntent(SpaceAction.RemoveObjects, {
213
- objects: [
214
- object
215
- ],
216
- target: collection
217
- }));
218
- }
219
- }, [
220
- collection,
221
- dispatch
222
- ]);
223
- const handleAdd = useCallback(async (id2, position) => {
224
- await dispatch?.(
225
- // TODO(wittjosiah): Use object creation dialog.
226
- createIntent(LayoutAction.UpdateDialog, {
227
- part: "dialog",
228
- subject: `${STACK_PLUGIN}/AddSectionDialog`,
229
- options: {
230
- blockAlign: "start",
231
- props: {
232
- path: id2,
233
- position,
234
- collection
235
- }
236
- }
237
- })
238
- );
239
- }, [
240
- collection,
241
- dispatch
242
- ]);
243
- const handleNavigate = useCallback(async (id2) => {
244
- await dispatch(createIntent(LayoutAction.Open, {
245
- part: "main",
246
- subject: [
247
- id2
248
- ]
249
- }));
250
- }, [
251
- dispatch
252
- ]);
253
- const handleCollapse = useCallback((id2, collapsed) => setCollapsedSections((prev) => ({
254
- ...prev,
255
- [id2]: collapsed
256
- })), []);
257
- const handleAddSection = useCallback(() => dispatch?.(createIntent(SpaceAction.OpenCreateObject, {
258
- target: collection,
259
- navigable: false
260
- })), [
261
- collection,
262
- dispatch
263
- ]);
264
- return /* @__PURE__ */ React3.createElement(AttentionProvider, {
265
- id
266
- }, /* @__PURE__ */ React3.createElement(StackContext.Provider, {
267
- value: {
268
- onCollapse: handleCollapse,
269
- onNavigate: handleNavigate,
270
- onDelete: handleDelete,
271
- onAdd: handleAdd
272
- }
273
- }, /* @__PURE__ */ React3.createElement(Stack, {
274
- orientation: "vertical",
275
- size: "intrinsic",
276
- id,
277
- "data-testid": "main.stack"
278
- }, items.map((item) => /* @__PURE__ */ React3.createElement(StackSection, {
279
- key: item.id,
280
- ...item
281
- }))), /* @__PURE__ */ React3.createElement("div", {
282
- role: "none",
283
- className: "flex mlb-2 pli-2 justify-center"
284
- }, /* @__PURE__ */ React3.createElement(Button, {
285
- "data-testid": "stack.createSection",
286
- classNames: "gap-2",
287
- onClick: handleAddSection
288
- }, /* @__PURE__ */ React3.createElement(Plus, null), /* @__PURE__ */ React3.createElement("span", {
289
- className: "sr-only"
290
- }, t("add section label"))))));
291
- };
292
- var StackMain_default = StackMain;
293
- export {
294
- StackMain_default as default
295
- };
296
- //# sourceMappingURL=StackMain-QFKYWI2J.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/StackMain.tsx", "../../../src/components/StackContext.tsx", "../../../src/components/StackSection.tsx", "../../../src/components/CaretDownUp.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plus } from '@phosphor-icons/react';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport {\n Capabilities,\n createIntent,\n LayoutAction,\n useAppGraph,\n useCapabilities,\n useIntentDispatcher,\n} from '@dxos/app-framework';\nimport { create, getType, fullyQualifiedId, isReactiveObject, makeRef } from '@dxos/client/echo';\nimport { SpaceAction } from '@dxos/plugin-space/types';\nimport { type CollectionType } from '@dxos/plugin-space/types';\nimport { Button, toLocalizedString, useTranslation } from '@dxos/react-ui';\nimport { AttentionProvider } from '@dxos/react-ui-attention';\nimport { Stack } from '@dxos/react-ui-stack';\nimport { isNonNullable } from '@dxos/util';\n\nimport { StackContext } from './StackContext';\nimport { StackSection } from './StackSection';\nimport { STACK_PLUGIN } from '../meta';\nimport {\n StackViewType,\n type CollapsedSections,\n type StackSectionMetadata,\n type StackSectionView,\n type StackSectionItem,\n type AddSectionPosition,\n} from '../types';\n\ntype StackMainProps = {\n id: string;\n collection: CollectionType;\n};\n\nconst StackMain = ({ id, collection }: StackMainProps) => {\n const { dispatchPromise: dispatch } = useIntentDispatcher();\n const { graph } = useAppGraph();\n const { t } = useTranslation(STACK_PLUGIN);\n const allMetadata = useCapabilities(Capabilities.Metadata);\n const defaultStack = useMemo(() => create(StackViewType, { sections: {} }), [collection]);\n const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;\n const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});\n\n useEffect(() => {\n if (!collection.views[StackViewType.typename]) {\n collection.views[StackViewType.typename] = makeRef(stack);\n }\n }, [collection, stack]);\n\n const items =\n collection.objects\n // TODO(wittjosiah): Should the database handle this differently?\n // TODO(wittjosiah): Render placeholders for missing objects so they can be removed from the stack?\n .map((object) => object.target)\n .filter(isNonNullable)\n .map((object) => {\n const metadata = allMetadata.find((m) => m.id === (getType(object)?.objectId ?? 'never'))\n ?.metadata as StackSectionMetadata;\n const view = {\n ...stack.sections[object.id],\n collapsed: collapsedSections[fullyQualifiedId(object)],\n title:\n (object as any)?.title ?? toLocalizedString(graph.findNode(fullyQualifiedId(object))?.properties.label, t),\n } as StackSectionView;\n return { id: fullyQualifiedId(object), object, metadata, view } satisfies StackSectionItem;\n }) ?? [];\n\n const handleDelete = useCallback(\n async (id: string) => {\n const index = collection.objects\n .map((object) => object.target)\n .filter(isNonNullable)\n .findIndex((section) => fullyQualifiedId(section) === id);\n const object = collection.objects[index].target;\n if (isReactiveObject(object)) {\n await dispatch(createIntent(SpaceAction.RemoveObjects, { objects: [object], target: collection }));\n\n // TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.\n // delete stack.sections[Path.last(path)];\n }\n },\n [collection, dispatch],\n );\n\n const handleAdd = useCallback(\n async (id: string, position: AddSectionPosition) => {\n await dispatch?.(\n // TODO(wittjosiah): Use object creation dialog.\n createIntent(LayoutAction.UpdateDialog, {\n part: 'dialog',\n subject: `${STACK_PLUGIN}/AddSectionDialog`,\n options: {\n blockAlign: 'start',\n props: {\n path: id,\n position,\n collection,\n },\n },\n }),\n );\n },\n [collection, dispatch],\n );\n\n const handleNavigate = useCallback(\n async (id: string) => {\n await dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [id] }));\n },\n [dispatch],\n );\n\n const handleCollapse = useCallback(\n (id: string, collapsed: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: collapsed })),\n [],\n );\n\n const handleAddSection = useCallback(\n () => dispatch?.(createIntent(SpaceAction.OpenCreateObject, { target: collection, navigable: false })),\n [collection, dispatch],\n );\n\n return (\n <AttentionProvider id={id}>\n <StackContext.Provider\n value={{\n onCollapse: handleCollapse,\n onNavigate: handleNavigate,\n onDelete: handleDelete,\n onAdd: handleAdd,\n }}\n >\n <Stack orientation='vertical' size='intrinsic' id={id} data-testid='main.stack'>\n {items.map((item) => (\n <StackSection key={item.id} {...item} />\n ))}\n </Stack>\n\n <div role='none' className='flex mlb-2 pli-2 justify-center'>\n <Button data-testid='stack.createSection' classNames='gap-2' onClick={handleAddSection}>\n <Plus />\n <span className='sr-only'>{t('add section label')}</span>\n </Button>\n </div>\n </StackContext.Provider>\n </AttentionProvider>\n );\n};\n\nexport default StackMain;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { type AddSectionPosition } from '../types';\n\nexport type StackContextValue = {\n onCollapse: (id: string, collapsed: boolean) => void;\n onNavigate: (id: string) => Promise<void>;\n onDelete: (id: string) => Promise<void>;\n onAdd: (id: string, position: AddSectionPosition) => void;\n};\n\nexport const StackContext = createContext<StackContextValue>({\n onCollapse: () => {},\n onNavigate: async () => {},\n onDelete: async () => {},\n onAdd: () => {},\n});\n\nexport const useStack = () => useContext(StackContext);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as CollapsiblePrimitive from '@radix-ui/react-collapsible';\nimport React, { useState } from 'react';\n\nimport { Surface } from '@dxos/app-framework';\nimport { DropdownMenu, Icon, useTranslation, IconButton } from '@dxos/react-ui';\nimport { useAttendableAttributes } from '@dxos/react-ui-attention';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { mx, getSize, textBlockWidth } from '@dxos/react-ui-theme';\n\nimport { CaretDownUp } from './CaretDownUp';\nimport { useStack } from './StackContext';\nimport { STACK_PLUGIN } from '../meta';\nimport { type StackSectionItem } from '../types';\n\nconst sectionActionDimensions = 'p-1 mlb-1 shrink-0 min-bs-0 is-[--rail-action] bs-min';\n\nexport const StackSection = ({\n id,\n view,\n object,\n metadata: { icon = 'ph--placeholder--regular' },\n}: StackSectionItem) => {\n const { t } = useTranslation(STACK_PLUGIN);\n const { onNavigate, onAdd, onCollapse, onDelete } = useStack();\n const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);\n const attendableAttrs = useAttendableAttributes(id);\n\n return (\n <CollapsiblePrimitive.Root asChild open={!view.collapsed} onOpenChange={(nextOpen) => onCollapse?.(id, !nextOpen)}>\n <StackItem.Root item={{ id }} role='section' {...attendableAttrs} classNames='border-be border-separator'>\n <StackItem.Heading classNames='attention-surface border-ie !border-separator'>\n <span className='sr-only'>{view.title}</span>\n <div role='none' className='sticky -block-start-px bg-[--sticky-bg] p-1 is-full'>\n <DropdownMenu.Root\n {...{\n open: optionsMenuOpen,\n onOpenChange: setOptionsMenuOpen,\n }}\n >\n <DropdownMenu.Trigger asChild>\n <StackItem.SigilButton>\n <Icon icon={icon} size={5} classNames='transition-opacity' />\n </StackItem.SigilButton>\n </DropdownMenu.Trigger>\n <DropdownMenu.Portal>\n <DropdownMenu.Content>\n <DropdownMenu.Viewport>\n {view.collapsed ? (\n <DropdownMenu.Item onClick={() => onNavigate(id)} data-testid='section.navigate-to'>\n <Icon icon='ph--arrow-square-out--regular' size={5} />\n <span className='mis-2 grow'>{t('navigate to section label')}</span>\n </DropdownMenu.Item>\n ) : (\n <CollapsiblePrimitive.Trigger asChild>\n <DropdownMenu.Item>\n <CaretDownUp className={getSize(5)} />\n <span className='mis-2 grow'>{t('collapse label')}</span>\n </DropdownMenu.Item>\n </CollapsiblePrimitive.Trigger>\n )}\n <DropdownMenu.Item onClick={() => onAdd(id, 'before')} data-testid='section.add-before'>\n <Icon icon='ph--arrow-line-up--regular' size={5} />\n <span className='mis-2 grow'>{t('add section before label')}</span>\n </DropdownMenu.Item>\n <DropdownMenu.Item onClick={() => onAdd(id, 'after')} data-testid='section.add-after'>\n <Icon icon='ph--arrow-line-down--regular' size={5} />\n <span className='mis-2 grow'>{t('add section after label')}</span>\n </DropdownMenu.Item>\n <DropdownMenu.Item onClick={() => onDelete(id)} data-testid='section.remove'>\n <Icon icon='ph--trash--regular' size={5} />\n <span className='mis-2 grow'>{t('remove section label')}</span>\n </DropdownMenu.Item>\n </DropdownMenu.Viewport>\n <DropdownMenu.Arrow />\n </DropdownMenu.Content>\n </DropdownMenu.Portal>\n </DropdownMenu.Root>\n {view.collapsed ? (\n <CollapsiblePrimitive.Trigger asChild>\n <IconButton\n iconOnly\n variant='ghost'\n label={t('expand label')}\n icon='ph--caret-up-down--regular'\n classNames={sectionActionDimensions}\n />\n </CollapsiblePrimitive.Trigger>\n ) : (\n <IconButton\n iconOnly\n variant='ghost'\n onClick={() => onNavigate(id)}\n label={t('navigate to section label')}\n icon='ph--arrow-square-out--regular'\n data-testid='section.navigate-to'\n classNames={sectionActionDimensions}\n />\n )}\n </div>\n </StackItem.Heading>\n <CollapsiblePrimitive.Content>\n <Surface role='section' data={{ subject: object }} limit={1} placeholder={<></>} />\n </CollapsiblePrimitive.Content>\n {view.collapsed && (\n <StackItem.Content classNames='attention-surface'>\n <h2 className={mx('flex items-center p-4 font-medium', textBlockWidth)}>{view.title}</h2>\n </StackItem.Content>\n )}\n </StackItem.Root>\n </CollapsiblePrimitive.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { type ComponentPropsWithoutRef } from 'react';\n\nexport const CaretDownUp = ({ children, ...props }: ComponentPropsWithoutRef<'svg'>) => {\n return (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' {...props}>\n <rect width='256' height='256' fill='none' />\n <polyline\n points='80 224 128 176 176 224'\n fill='none'\n stroke='currentColor'\n strokeLinecap='round'\n strokeLinejoin='round'\n strokeWidth='16'\n />\n <polyline\n points='80 32 128 80 176 32'\n fill='none'\n stroke='currentColor'\n strokeLinecap='round'\n strokeLinejoin='round'\n strokeWidth='16'\n />\n {children}\n </svg>\n );\n};\n"],
5
- "mappings": ";;;;;;;;;AAIA,SAASA,YAAY;AACrB,OAAOC,UAASC,aAAaC,WAAWC,SAASC,YAAAA,iBAAgB;AAEjE,SACEC,cACAC,cACAC,cACAC,aACAC,iBACAC,2BACK;AACP,SAASC,QAAQC,SAASC,kBAAkBC,kBAAkBC,eAAe;AAC7E,SAASC,mBAAmB;AAE5B,SAASC,QAAQC,mBAAmBC,kBAAAA,uBAAsB;AAC1D,SAASC,yBAAyB;AAClC,SAASC,aAAa;AACtB,SAASC,qBAAqB;;;ACjB9B,SAASC,eAAeC,kBAAkB;AAWnC,IAAMC,eAAeC,8BAAiC;EAC3DC,YAAY,MAAA;EAAO;EACnBC,YAAY,YAAA;EAAa;EACzBC,UAAU,YAAA;EAAa;EACvBC,OAAO,MAAA;EAAO;AAChB,CAAA;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W;EAAM,CAAA,CAAA,GACnG;IAACvE;IAAYE;GAAS;AAGxB,SACE,gBAAAsE,OAAA,cAACC,mBAAAA;IAAkB1E;KACjB,gBAAAyE,OAAA,cAACE,aAAaC,UAAQ;IACpBC,OAAO;MACLC,YAAYV;MACZW,YAAYb;MACZc,UAAUjC;MACVkC,OAAOzB;IACT;KAEA,gBAAAiB,OAAA,cAACS,OAAAA;IAAMC,aAAY;IAAWC,MAAK;IAAYpF;IAAQqF,eAAY;KAChEzD,MAAME,IAAI,CAACwD,SACV,gBAAAb,OAAA,cAACc,cAAAA;IAAaC,KAAKF,KAAKtF;IAAK,GAAGsF;QAIpC,gBAAAb,OAAA,cAACgB,OAAAA;IAAIC,MAAK;IAAOC,WAAU;KACzB,gBAAAlB,OAAA,cAACmB,QAAAA;IAAOP,eAAY;IAAsBQ,YAAW;IAAQC,SAASxB;KACpE,gBAAAG,OAAA,cAACsB,MAAAA,IAAAA,GACD,gBAAAtB,OAAA,cAACuB,QAAAA;IAAKL,WAAU;KAAWpF,EAAE,mBAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAMzC;AAEA,IAAA,oBAAeR;",
6
- "names": ["Plus", "React", "useCallback", "useEffect", "useMemo", "useState", "Capabilities", "createIntent", "LayoutAction", "useAppGraph", "useCapabilities", "useIntentDispatcher", "create", "getType", "fullyQualifiedId", "isReactiveObject", "makeRef", "SpaceAction", "Button", "toLocalizedString", "useTranslation", "AttentionProvider", "Stack", "isNonNullable", "createContext", "useContext", "StackContext", "createContext", "onCollapse", "onNavigate", "onDelete", "onAdd", "useStack", "useContext", "CollapsiblePrimitive", "React", "useState", "Surface", "DropdownMenu", "Icon", "useTranslation", "IconButton", "useAttendableAttributes", "StackItem", "mx", "getSize", "textBlockWidth", "React", "CaretDownUp", "children", "props", "svg", "xmlns", "viewBox", "rect", "width", "height", "fill", "polyline", "points", "stroke", "strokeLinecap", "strokeLinejoin", "strokeWidth", "sectionActionDimensions", "StackSection", "id", "view", "object", "metadata", "icon", "t", "useTranslation", "STACK_PLUGIN", "onNavigate", "onAdd", "onCollapse", "onDelete", "useStack", "optionsMenuOpen", "setOptionsMenuOpen", "useState", "attendableAttrs", "useAttendableAttributes", "React", "Root", "asChild", "open", "collapsed", "onOpenChange", "nextOpen", "StackItem", "item", "role", "classNames", "Heading", "span", "className", "title", "div", "DropdownMenu", "Trigger", "SigilButton", "Icon", "size", "Portal", "Content", "Viewport", "Item", "onClick", "data-testid", "CaretDownUp", "getSize", "Arrow", "IconButton", "iconOnly", "variant", "label", "Surface", "data", "subject", "limit", "placeholder", "h2", "mx", "textBlockWidth", "StackMain", "id", "collection", "dispatchPromise", "dispatch", "useIntentDispatcher", "graph", "useAppGraph", "t", "useTranslation", "STACK_PLUGIN", "allMetadata", "useCapabilities", "Capabilities", "Metadata", "defaultStack", "useMemo", "create", "StackViewType", "sections", "stack", "views", "typename", "target", "collapsedSections", "setCollapsedSections", "useState", "useEffect", "makeRef", "items", "objects", "map", "object", "filter", "isNonNullable", "metadata", "find", "m", "getType", "objectId", "view", "collapsed", "fullyQualifiedId", "title", "toLocalizedString", "findNode", "properties", "label", "handleDelete", "useCallback", "index", "findIndex", "section", "isReactiveObject", "createIntent", "SpaceAction", "RemoveObjects", "handleAdd", "position", "LayoutAction", "UpdateDialog", "part", "subject", "options", "blockAlign", "props", "path", "handleNavigate", "Open", "handleCollapse", "prev", "handleAddSection", "OpenCreateObject", "navigable", "React", "AttentionProvider", "StackContext", "Provider", "value", "onCollapse", "onNavigate", "onDelete", "onAdd", "Stack", "orientation", "size", "data-testid", "item", "StackSection", "key", "div", "role", "className", "Button", "classNames", "onClick", "Plus", "span"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types/stack.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { S, TypedObject } from '@dxos/echo-schema';\n\n// All section metadata needs to be optional/have defaults.\n// Any objects added to the collection will start with the section defaults.\n// If an object is removed from the collection without removing the section metadata this is fine.\n// Stack components should clean-up the superfluous data on future edits.\n\nexport const SectionSchema = S.Struct({\n height: S.optional(S.Number),\n // Space for data that isn't stack-specific but is specific to this view instance.\n // e.g. cover/fill for an image\n custom: S.optional(S.Record({ key: S.String, value: S.Any })),\n});\n\n// TODO(burdon): Should be just type/Stack?\nexport class StackViewType extends TypedObject({ typename: 'dxos.org/type/StackView', version: '0.1.0' })({\n sections: S.mutable(S.Record({ key: S.String, value: SectionSchema })),\n}) {}\n"],
5
- "mappings": ";;;AAIA,SAASA,GAAGC,mBAAmB;AAOxB,IAAMC,gBAAgBC,EAAEC,OAAO;EACpCC,QAAQF,EAAEG,SAASH,EAAEI,MAAM;;;EAG3BC,QAAQL,EAAEG,SAASH,EAAEM,OAAO;IAAEC,KAAKP,EAAEQ;IAAQC,OAAOT,EAAEU;EAAI,CAAA,CAAA;AAC5D,CAAA;AAGO,IAAMC,gBAAN,cAA4BC,YAAY;EAAEC,UAAU;EAA2BC,SAAS;AAAQ,CAAA,EAAG;EACxGC,UAAUf,EAAEgB,QAAQhB,EAAEM,OAAO;IAAEC,KAAKP,EAAEQ;IAAQC,OAAOV;EAAc,CAAA,CAAA;AACrE,CAAA,EAAA;AAAI;",
6
- "names": ["S", "TypedObject", "SectionSchema", "S", "Struct", "height", "optional", "Number", "custom", "Record", "key", "String", "value", "Any", "StackViewType", "TypedObject", "typename", "version", "sections", "mutable"]
7
- }
@@ -1,76 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { Capabilities, contributes, createSurface, defineModule, definePlugin, Events } from '@dxos/app-framework';
8
- import { type ReactiveEchoObject, fullyQualifiedId } from '@dxos/client/echo';
9
- import { isInstanceOf } from '@dxos/echo-schema';
10
- import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
11
- import { CollectionType } from '@dxos/plugin-space/types';
12
-
13
- import { StackMain } from './components';
14
- import { meta, SECTION_IDENTIFIER, STACK_PLUGIN } from './meta';
15
- import translations from './translations';
16
- import { StackViewType } from './types';
17
-
18
- export const StackPlugin = () =>
19
- definePlugin(meta, [
20
- defineModule({
21
- id: `${meta.id}/module/translations`,
22
- activatesOn: Events.SetupTranslations,
23
- activate: () => contributes(Capabilities.Translations, translations),
24
- }),
25
- defineModule({
26
- id: `${meta.id}/module/metadata`,
27
- activatesOn: Events.SetupMetadata,
28
- activate: () => [
29
- contributes(Capabilities.Metadata, {
30
- id: SECTION_IDENTIFIER,
31
- metadata: {
32
- parse: (section: { object: ReactiveEchoObject<any> }, type: string) => {
33
- switch (type) {
34
- case 'node':
35
- // TODO(wittjosiah): Remove cast.
36
- return { id: section.object.id, label: section.object.title, data: section.object };
37
- case 'object':
38
- return section.object;
39
- case 'view-object':
40
- return section;
41
- }
42
- },
43
- },
44
- }),
45
- ],
46
- }),
47
- defineModule({
48
- id: `${meta.id}/module/schema`,
49
- activatesOn: ClientEvents.SetupSchema,
50
- activate: () => contributes(ClientCapabilities.Schema, [StackViewType]),
51
- }),
52
- defineModule({
53
- id: `${meta.id}/module/react-surface`,
54
- activatesOn: Events.SetupReactSurface,
55
- activate: () =>
56
- contributes(
57
- Capabilities.ReactSurface,
58
- createSurface({
59
- id: `${STACK_PLUGIN}/article`,
60
- role: 'article',
61
- filter: (data): data is { id?: string; subject: CollectionType } =>
62
- isInstanceOf(CollectionType, data.subject),
63
- component: ({ data }) => {
64
- // This allows the id to be overridden by the surface for situations where the id of the collection
65
- // is not the same as the id of what is being represented (e.g., a space with a root collection).
66
- const id = typeof data.id === 'string' ? data.id : undefined;
67
- return (
68
- <div role='none' className='overflow-auto' style={{ contain: 'layout' }}>
69
- <StackMain id={id ?? fullyQualifiedId(data.subject)} collection={data.subject} />
70
- </div>
71
- );
72
- },
73
- }),
74
- ),
75
- }),
76
- ]);