@dxos/plugin-stack 0.7.4-staging.f7e8224 → 0.7.5-main.499c70c

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 (43) hide show
  1. package/dist/lib/browser/StackMain-HSYQ5B3Y.mjs +295 -0
  2. package/dist/lib/browser/StackMain-HSYQ5B3Y.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +28 -163
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/node/StackMain-AWN5MFZK.cjs +309 -0
  7. package/dist/lib/node/StackMain-AWN5MFZK.cjs.map +7 -0
  8. package/dist/lib/node/index.cjs +28 -161
  9. package/dist/lib/node/index.cjs.map +4 -4
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node-esm/StackMain-EFCZCMIJ.mjs +296 -0
  12. package/dist/lib/node-esm/StackMain-EFCZCMIJ.mjs.map +7 -0
  13. package/dist/lib/node-esm/index.mjs +28 -163
  14. package/dist/lib/node-esm/index.mjs.map +4 -4
  15. package/dist/lib/node-esm/meta.json +1 -1
  16. package/dist/types/src/StackPlugin.d.ts.map +1 -1
  17. package/dist/types/src/components/StackMain.d.ts.map +1 -1
  18. package/dist/types/src/components/StackSection.d.ts.map +1 -1
  19. package/dist/types/src/components/index.d.ts +0 -1
  20. package/dist/types/src/components/index.d.ts.map +1 -1
  21. package/dist/types/src/types/stack.d.ts +6 -12
  22. package/dist/types/src/types/stack.d.ts.map +1 -1
  23. package/dist/types/src/types/types.d.ts +4 -16
  24. package/dist/types/src/types/types.d.ts.map +1 -1
  25. package/dist/types/tsconfig.tsbuildinfo +1 -0
  26. package/package.json +23 -23
  27. package/src/StackPlugin.tsx +26 -47
  28. package/src/components/StackMain.tsx +60 -69
  29. package/src/components/StackSection.tsx +2 -4
  30. package/src/components/index.ts +0 -1
  31. package/src/types/types.ts +3 -19
  32. package/dist/lib/browser/StackMain-4D4J4IRK.mjs +0 -391
  33. package/dist/lib/browser/StackMain-4D4J4IRK.mjs.map +0 -7
  34. package/dist/lib/node/StackMain-V7C55NCF.cjs +0 -403
  35. package/dist/lib/node/StackMain-V7C55NCF.cjs.map +0 -7
  36. package/dist/lib/node-esm/StackMain-5I43UWGF.mjs +0 -392
  37. package/dist/lib/node-esm/StackMain-5I43UWGF.mjs.map +0 -7
  38. package/dist/types/src/components/AddSection.d.ts +0 -6
  39. package/dist/types/src/components/AddSection.d.ts.map +0 -1
  40. package/dist/types/src/components/AddSectionDialog.d.ts +0 -14
  41. package/dist/types/src/components/AddSectionDialog.d.ts.map +0 -1
  42. package/src/components/AddSection.tsx +0 -102
  43. package/src/components/AddSectionDialog.tsx +0 -128
@@ -0,0 +1,295 @@
1
+ import {
2
+ STACK_PLUGIN
3
+ } from "./chunk-DS5KGEJG.mjs";
4
+ import {
5
+ StackViewType
6
+ } from "./chunk-L34RFJ2L.mjs";
7
+
8
+ // packages/plugins/plugin-stack/src/components/StackMain.tsx
9
+ import { Plus } from "@phosphor-icons/react";
10
+ import React3, { useCallback, useEffect, useMemo, useState as useState2 } from "react";
11
+ import { createIntent, LayoutAction, NavigationAction, parseMetadataResolverPlugin, useIntentDispatcher, useResolvePlugin } from "@dxos/app-framework";
12
+ import { create, getType, fullyQualifiedId, isReactiveObject, makeRef } from "@dxos/client/echo";
13
+ import { useGraph } from "@dxos/plugin-graph";
14
+ import { SpaceAction } from "@dxos/plugin-space";
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 { nonNullable } 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 = "m-1 p-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]"
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
+ toolbar: false,
168
+ classNames: "attention-surface"
169
+ }, /* @__PURE__ */ React2.createElement("h2", {
170
+ className: mx("flex items-center p-4 font-medium is-full", textBlockWidth)
171
+ }, view.title))));
172
+ };
173
+
174
+ // packages/plugins/plugin-stack/src/components/StackMain.tsx
175
+ var StackMain = ({ id, collection }) => {
176
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
177
+ const { graph } = useGraph();
178
+ const { t } = useTranslation2(STACK_PLUGIN);
179
+ const metadataPlugin = useResolvePlugin(parseMetadataResolverPlugin);
180
+ const defaultStack = useMemo(() => create(StackViewType, {
181
+ sections: {}
182
+ }), [
183
+ collection
184
+ ]);
185
+ const stack = collection.views[StackViewType.typename]?.target ?? defaultStack;
186
+ const [collapsedSections, setCollapsedSections] = useState2({});
187
+ useEffect(() => {
188
+ if (!collection.views[StackViewType.typename]) {
189
+ collection.views[StackViewType.typename] = makeRef(stack);
190
+ }
191
+ }, [
192
+ collection,
193
+ stack
194
+ ]);
195
+ const items = collection.objects.map((object) => object.target).filter(nonNullable).map((object) => {
196
+ const metadata = metadataPlugin?.provides.metadata.resolver(getType(object)?.objectId ?? "never");
197
+ const view = {
198
+ ...stack.sections[object.id],
199
+ collapsed: collapsedSections[fullyQualifiedId(object)],
200
+ title: object?.title ?? toLocalizedString(graph.findNode(fullyQualifiedId(object))?.properties.label, t)
201
+ };
202
+ return {
203
+ id: fullyQualifiedId(object),
204
+ object,
205
+ metadata,
206
+ view
207
+ };
208
+ }) ?? [];
209
+ const handleDelete = useCallback(async (id2) => {
210
+ const index = collection.objects.map((object2) => object2.target).filter(nonNullable).findIndex((section) => fullyQualifiedId(section) === id2);
211
+ const object = collection.objects[index].target;
212
+ if (isReactiveObject(object)) {
213
+ await dispatch(createIntent(SpaceAction.RemoveObjects, {
214
+ objects: [
215
+ object
216
+ ],
217
+ target: collection
218
+ }));
219
+ }
220
+ }, [
221
+ collection,
222
+ dispatch
223
+ ]);
224
+ const handleAdd = useCallback(async (id2, position) => {
225
+ await dispatch?.(createIntent(LayoutAction.SetLayout, {
226
+ element: "dialog",
227
+ component: `${STACK_PLUGIN}/AddSectionDialog`,
228
+ subject: {
229
+ path: id2,
230
+ position,
231
+ collection
232
+ }
233
+ }));
234
+ }, [
235
+ collection,
236
+ dispatch
237
+ ]);
238
+ const handleNavigate = useCallback(async (id2) => {
239
+ await dispatch(createIntent(NavigationAction.Open, {
240
+ activeParts: {
241
+ main: [
242
+ id2
243
+ ]
244
+ }
245
+ }));
246
+ await dispatch(createIntent(LayoutAction.ScrollIntoView, {
247
+ id: id2
248
+ }));
249
+ }, [
250
+ dispatch
251
+ ]);
252
+ const handleCollapse = useCallback((id2, collapsed) => setCollapsedSections((prev) => ({
253
+ ...prev,
254
+ [id2]: collapsed
255
+ })), []);
256
+ const handleAddSection = useCallback(() => dispatch?.(createIntent(SpaceAction.OpenCreateObject, {
257
+ target: collection,
258
+ navigable: false
259
+ })), [
260
+ collection,
261
+ dispatch
262
+ ]);
263
+ return /* @__PURE__ */ React3.createElement(AttentionProvider, {
264
+ id
265
+ }, /* @__PURE__ */ React3.createElement(StackContext.Provider, {
266
+ value: {
267
+ onCollapse: handleCollapse,
268
+ onNavigate: handleNavigate,
269
+ onDelete: handleDelete,
270
+ onAdd: handleAdd
271
+ }
272
+ }, /* @__PURE__ */ React3.createElement(Stack, {
273
+ orientation: "vertical",
274
+ size: "intrinsic",
275
+ id,
276
+ "data-testid": "main.stack"
277
+ }, items.map((item) => /* @__PURE__ */ React3.createElement(StackSection, {
278
+ key: item.id,
279
+ ...item
280
+ }))), /* @__PURE__ */ React3.createElement("div", {
281
+ role: "none",
282
+ className: "flex mlb-2 pli-2 justify-center"
283
+ }, /* @__PURE__ */ React3.createElement(Button, {
284
+ "data-testid": "stack.createSection",
285
+ classNames: "gap-2",
286
+ onClick: handleAddSection
287
+ }, /* @__PURE__ */ React3.createElement(Plus, null), /* @__PURE__ */ React3.createElement("span", {
288
+ className: "sr-only"
289
+ }, t("add section label"))))));
290
+ };
291
+ var StackMain_default = StackMain;
292
+ export {
293
+ StackMain_default as default
294
+ };
295
+ //# sourceMappingURL=StackMain-HSYQ5B3Y.mjs.map
@@ -0,0 +1,7 @@
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 createIntent,\n LayoutAction,\n NavigationAction,\n parseMetadataResolverPlugin,\n useIntentDispatcher,\n useResolvePlugin,\n} from '@dxos/app-framework';\nimport { create, getType, fullyQualifiedId, isReactiveObject, makeRef } from '@dxos/client/echo';\nimport { useGraph } from '@dxos/plugin-graph';\nimport { SpaceAction } from '@dxos/plugin-space';\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 { nonNullable } 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 } = useGraph();\n const { t } = useTranslation(STACK_PLUGIN);\n const metadataPlugin = useResolvePlugin(parseMetadataResolverPlugin);\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(nonNullable)\n .map((object) => {\n const metadata = metadataPlugin?.provides.metadata.resolver(\n getType(object)?.objectId ?? 'never',\n ) 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(nonNullable)\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 createIntent(LayoutAction.SetLayout, {\n element: 'dialog',\n component: `${STACK_PLUGIN}/AddSectionDialog`,\n subject: { path: id, position, collection },\n }),\n );\n },\n [collection, dispatch],\n );\n\n const handleNavigate = useCallback(\n async (id: string) => {\n await dispatch(createIntent(NavigationAction.Open, { activeParts: { main: [id] } }));\n await dispatch(createIntent(LayoutAction.ScrollIntoView, { 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 = 'm-1 p-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]'>\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 toolbar={false} classNames='attention-surface'>\n <h2 className={mx('flex items-center p-4 font-medium is-full', 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,kBACAC,6BACAC,qBACAC,wBACK;AACP,SAASC,QAAQC,SAASC,kBAAkBC,kBAAkBC,eAAe;AAC7E,SAASC,gBAAgB;AACzB,SAASC,mBAAmB;AAE5B,SAASC,QAAQC,mBAAmBC,kBAAAA,uBAAsB;AAC1D,SAASC,yBAAyB;AAClC,SAASC,aAAa;AACtB,SAASC,mBAAmB;;;AClB5B,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;AAEO,IAAMC,WAAW,MAAMC,WAAWP,YAAAA;;;AClBzC,YAAYQ,0BAA0B;AACtC,OAAOC,UAASC,gBAAgB;AAEhC,SAASC,eAAe;AACxB,SAASC,cAAcC,MAAMC,gBAAgBC,kBAAkB;AAC/D,SAASC,+BAA+B;AACxC,SAASC,iBAAiB;AAC1B,SAASC,IAAIC,SAASC,sBAAsB;;;ACP5C,OAAOC,WAA8C;AAE9C,IAAMC,cAAc,CAAC,EAAEC,UAAU,GAAGC,MAAAA,MAAwC;AACjF,SACE,sBAAA,cAACC,OAAAA;IAAIC,OAAM;IAA6BC,SAAQ;IAAe,GAAGH;KAChE,sBAAA,cAACI,QAAAA;IAAKC,OAAM;IAAMC,QAAO;IAAMC,MAAK;MACpC,sBAAA,cAACC,YAAAA;IACCC,QAAO;IACPF,MAAK;IACLG,QAAO;IACPC,eAAc;IACdC,gBAAe;IACfC,aAAY;MAEd,sBAAA,cAACL,YAAAA;IACCC,QAAO;IACPF,MAAK;IACLG,QA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,MAAAA,IAAAA,GACD,gBAAAtB,OAAA,cAACuB,QAAAA;IAAKL,WAAU;KAAWrF,EAAE,mBAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAMzC;AAEA,IAAA,oBAAeR;",
6
+ "names": ["Plus", "React", "useCallback", "useEffect", "useMemo", "useState", "createIntent", "LayoutAction", "NavigationAction", "parseMetadataResolverPlugin", "useIntentDispatcher", "useResolvePlugin", "create", "getType", "fullyQualifiedId", "isReactiveObject", "makeRef", "useGraph", "SpaceAction", "Button", "toLocalizedString", "useTranslation", "AttentionProvider", "Stack", "nonNullable", "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", "toolbar", "h2", "mx", "textBlockWidth", "StackMain", "id", "collection", "dispatchPromise", "dispatch", "useIntentDispatcher", "graph", "useGraph", "t", "useTranslation", "STACK_PLUGIN", "metadataPlugin", "useResolvePlugin", "parseMetadataResolverPlugin", "defaultStack", "useMemo", "create", "StackViewType", "sections", "stack", "views", "typename", "target", "collapsedSections", "setCollapsedSections", "useState", "useEffect", "makeRef", "items", "objects", "map", "object", "filter", "nonNullable", "metadata", "provides", "resolver", "getType", "objectId", "view", "collapsed", "fullyQualifiedId", "title", "toLocalizedString", "findNode", "properties", "label", "handleDelete", "useCallback", "index", "findIndex", "section", "isReactiveObject", "createIntent", "SpaceAction", "RemoveObjects", "handleAdd", "position", "LayoutAction", "SetLayout", "element", "component", "subject", "path", "handleNavigate", "NavigationAction", "Open", "activeParts", "main", "ScrollIntoView", "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
+ }
@@ -9,12 +9,11 @@ import {
9
9
  } from "./chunk-L34RFJ2L.mjs";
10
10
 
11
11
  // packages/plugins/plugin-stack/src/StackPlugin.tsx
12
- import React3 from "react";
13
- import { create as create2, fullyQualifiedId } from "@dxos/client/echo";
12
+ import React2 from "react";
13
+ import { createSurface } from "@dxos/app-framework";
14
+ import { fullyQualifiedId } from "@dxos/client/echo";
14
15
  import { LocalStorageStore } from "@dxos/local-storage";
15
16
  import { CollectionType } from "@dxos/plugin-space/types";
16
- import { Main } from "@dxos/react-ui";
17
- import { baseSurface, topbarBlockPaddingStart, bottombarBlockPaddingEnd } from "@dxos/react-ui-theme";
18
17
 
19
18
  // packages/plugins/plugin-stack/src/components/index.ts
20
19
  import { lazy } from "react";
@@ -33,118 +32,8 @@ var StackSettings = ({ settings }) => {
33
32
  })));
34
33
  };
35
34
 
36
- // packages/plugins/plugin-stack/src/components/AddSectionDialog.tsx
37
- import { FilePlus } from "@phosphor-icons/react";
38
- import React2, { useCallback, useRef, useState } from "react";
39
- import { usePlugin, useIntent, LayoutAction, useResolvePlugin, parseFileManagerPlugin } from "@dxos/app-framework";
40
- import { create, getSpace } from "@dxos/client/echo";
41
- import { FileType } from "@dxos/plugin-ipfs/types";
42
- import { Dialog, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
43
- import { Path } from "@dxos/react-ui-mosaic";
44
- import { SearchList } from "@dxos/react-ui-searchlist";
45
- import { getSize, mx } from "@dxos/react-ui-theme";
46
- import { nonNullable } from "@dxos/util";
47
- var dataHasAddSectionDialogProps = (data) => {
48
- return "subject" in data && typeof data.subject === "object" && !!data.subject && "position" in data.subject && typeof data.subject.position === "string" && "collection" in data.subject;
49
- };
50
- var AddSectionDialog = ({ path, position, collection }) => {
51
- const { t } = useTranslation2(STACK_PLUGIN);
52
- const stackPlugin = usePlugin(STACK_PLUGIN);
53
- const fileManagerPlugin = useResolvePlugin(parseFileManagerPlugin);
54
- const fileRef = useRef(null);
55
- const { dispatch } = useIntent();
56
- const space = getSpace(collection);
57
- const [pending, setPending] = useState(false);
58
- const [uploadError, setUploadError] = useState();
59
- const handleAdd = useCallback((sectionObject) => {
60
- const index = position === "beforeAll" ? 0 : position === "afterAll" ? collection.objects.length : collection.objects.filter(nonNullable).findIndex((section) => section.id === Path.last(path));
61
- collection.objects.splice(index + (position === "after" ? 1 : 0), 0, sectionObject);
62
- const stack = collection.views[StackViewType.typename];
63
- if (stack) {
64
- stack.sections[sectionObject.id] = {};
65
- }
66
- setPending(false);
67
- void dispatch?.({
68
- action: LayoutAction.SET_LAYOUT,
69
- data: {
70
- element: "dialog",
71
- state: false
72
- }
73
- });
74
- }, [
75
- collection,
76
- path,
77
- position,
78
- dispatch
79
- ]);
80
- const handleFileUpload = fileManagerPlugin?.provides.file.upload && space ? async (file) => {
81
- const filename = file.name.split(".")[0];
82
- try {
83
- const info = await fileManagerPlugin.provides.file.upload?.(file, space);
84
- if (info) {
85
- const obj = create(FileType, {
86
- type: file.type,
87
- name: filename,
88
- filename,
89
- cid: info.cid
90
- });
91
- handleAdd(obj);
92
- }
93
- } catch (err) {
94
- setUploadError(err);
95
- }
96
- } : void 0;
97
- return /* @__PURE__ */ React2.createElement(Dialog.Content, null, /* @__PURE__ */ React2.createElement(Dialog.Title, null, t(`add section ${position} dialog title`)), /* @__PURE__ */ React2.createElement(SearchList.Root, {
98
- label: t("add section input placeholder")
99
- }, /* @__PURE__ */ React2.createElement(SearchList.Input, {
100
- placeholder: t("add section input placeholder"),
101
- classNames: "pli-3",
102
- disabled: pending
103
- }), /* @__PURE__ */ React2.createElement(SearchList.Content, {
104
- classNames: "min-bs-24 bs-fit max-bs-64 overflow-auto",
105
- ...pending && {
106
- inert: "true"
107
- }
108
- }, stackPlugin?.provides?.stack.creators?.map(({ id, icon: Icon, label: propsLabel, testId, intent }) => {
109
- const label = toLocalizedString(propsLabel, t);
110
- return /* @__PURE__ */ React2.createElement(SearchList.Item, {
111
- value: label,
112
- key: id,
113
- onSelect: async () => {
114
- setPending(true);
115
- const { data: nextSection } = await dispatch({
116
- ...intent,
117
- data: {
118
- space
119
- }
120
- }) ?? {};
121
- handleAdd(nextSection);
122
- },
123
- classNames: "flex items-center gap-2 pli-2",
124
- "data-testid": testId
125
- }, Icon && /* @__PURE__ */ React2.createElement(Icon, {
126
- className: mx(getSize(4), "shrink-0")
127
- }), /* @__PURE__ */ React2.createElement("span", {
128
- className: "grow truncate"
129
- }, label));
130
- }), handleFileUpload && /* @__PURE__ */ React2.createElement(SearchList.Item, {
131
- value: t("upload file label"),
132
- classNames: "flex items-center gap-2 pli-2",
133
- onSelect: () => fileRef.current?.click()
134
- }, /* @__PURE__ */ React2.createElement(FilePlus, null), /* @__PURE__ */ React2.createElement("span", {
135
- className: "grow truncate"
136
- }, t("upload file label"))), uploadError && /* @__PURE__ */ React2.createElement("div", {
137
- className: "text-error-500"
138
- }, uploadError.message))), handleFileUpload && /* @__PURE__ */ React2.createElement("input", {
139
- type: "file",
140
- className: "sr-only",
141
- ref: fileRef,
142
- onChange: ({ target: { files } }) => files && handleFileUpload(files[0])
143
- }));
144
- };
145
-
146
35
  // packages/plugins/plugin-stack/src/components/index.ts
147
- var StackMain = lazy(() => import("./StackMain-4D4J4IRK.mjs"));
36
+ var StackMain = lazy(() => import("./StackMain-HSYQ5B3Y.mjs"));
148
37
 
149
38
  // packages/plugins/plugin-stack/src/translations.ts
150
39
  import { translations as stackTranslations } from "@dxos/react-ui-stack";
@@ -181,24 +70,13 @@ var StackPlugin = () => {
181
70
  const settings = new LocalStorageStore(STACK_PLUGIN, {
182
71
  separation: true
183
72
  });
184
- const stackState = create2({
185
- creators: []
186
- });
187
73
  return {
188
74
  meta: meta_default,
189
- ready: async (plugins) => {
75
+ ready: async () => {
190
76
  settings.prop({
191
77
  key: "separation",
192
78
  type: LocalStorageStore.bool()
193
79
  });
194
- for (const plugin of plugins) {
195
- if (plugin.meta.id === STACK_PLUGIN) {
196
- continue;
197
- }
198
- if (Array.isArray(plugin.provides?.stack?.creators)) {
199
- stackState.creators.push(...plugin.provides.stack.creators ?? []);
200
- }
201
- }
202
80
  },
203
81
  provides: {
204
82
  settings: settings.values,
@@ -238,48 +116,35 @@ var StackPlugin = () => {
238
116
  ]
239
117
  },
240
118
  surface: {
241
- component: ({ data, role }) => {
242
- switch (data.component) {
243
- case `${STACK_PLUGIN}/AddSectionDialog`:
244
- return dataHasAddSectionDialogProps(data) ? /* @__PURE__ */ React3.createElement(AddSectionDialog, data.subject) : null;
245
- }
246
- const primary = data.active ?? data.object;
247
- const id = typeof data.id === "string" ? data.id : void 0;
248
- switch (role) {
249
- case "main":
250
- return primary instanceof CollectionType ? /* @__PURE__ */ React3.createElement(Main.Content, {
251
- bounce: true,
252
- classNames: [
253
- baseSurface,
254
- topbarBlockPaddingStart,
255
- bottombarBlockPaddingEnd
256
- ]
257
- }, /* @__PURE__ */ React3.createElement(StackMain, {
258
- id: id ?? fullyQualifiedId(primary),
259
- collection: primary
260
- })) : null;
261
- case "article":
262
- return primary instanceof CollectionType ? /* @__PURE__ */ React3.createElement("div", {
119
+ definitions: () => [
120
+ createSurface({
121
+ id: `${STACK_PLUGIN}/article`,
122
+ role: "article",
123
+ filter: (data) => data.subject instanceof CollectionType,
124
+ component: ({ data }) => {
125
+ const id = typeof data.id === "string" ? data.id : void 0;
126
+ return /* @__PURE__ */ React2.createElement("div", {
263
127
  role: "none",
264
128
  className: "overflow-auto",
265
129
  style: {
266
130
  contain: "layout"
267
131
  }
268
- }, /* @__PURE__ */ React3.createElement(StackMain, {
269
- id: id ?? fullyQualifiedId(primary),
270
- collection: primary
271
- })) : null;
272
- case "settings": {
273
- return data.plugin === meta_default.id ? /* @__PURE__ */ React3.createElement(StackSettings, {
274
- settings: settings.values
275
- }) : null;
132
+ }, /* @__PURE__ */ React2.createElement(StackMain, {
133
+ id: id ?? fullyQualifiedId(data.subject),
134
+ collection: data.subject
135
+ }));
276
136
  }
277
- default:
278
- return null;
279
- }
280
- }
281
- },
282
- stack: stackState
137
+ }),
138
+ createSurface({
139
+ id: `${STACK_PLUGIN}/settings`,
140
+ role: "settings",
141
+ filter: (data) => data.plugin === meta_default.id,
142
+ component: () => /* @__PURE__ */ React2.createElement(StackSettings, {
143
+ settings: settings.values
144
+ })
145
+ })
146
+ ]
147
+ }
283
148
  }
284
149
  };
285
150
  };