@dxos/plugin-stack 0.6.14-staging.77003c1 → 0.6.14-staging.7b35391
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.
- package/dist/lib/browser/StackMain-Z2DSTC42.mjs +390 -0
- package/dist/lib/browser/StackMain-Z2DSTC42.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ONAKM24Z.mjs → chunk-DS5KGEJG.mjs} +5 -2
- package/dist/lib/browser/chunk-DS5KGEJG.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +18 -8
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/node/StackMain-YK5QQBXA.cjs +402 -0
- package/dist/lib/node/StackMain-YK5QQBXA.cjs.map +7 -0
- package/dist/lib/node/{chunk-O5SQVKNW.cjs → chunk-PA5PRDM6.cjs} +8 -5
- package/dist/lib/node/chunk-PA5PRDM6.cjs.map +7 -0
- package/dist/lib/node/index.cjs +29 -19
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.cjs +4 -4
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/StackMain-GCZYK7GH.mjs +391 -0
- package/dist/lib/node-esm/StackMain-GCZYK7GH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-J57BXQJY.mjs → chunk-JEQMG2E2.mjs} +5 -2
- package/dist/lib/node-esm/chunk-JEQMG2E2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +18 -8
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +1 -1
- package/dist/types/src/StackPlugin.d.ts.map +1 -1
- package/dist/types/src/components/AddSectionDialog.d.ts +1 -1
- package/dist/types/src/components/AddSectionDialog.d.ts.map +1 -1
- package/dist/types/src/components/CaretDownUp.d.ts +3 -0
- package/dist/types/src/components/CaretDownUp.d.ts.map +1 -0
- package/dist/types/src/components/StackContext.d.ts +10 -0
- package/dist/types/src/components/StackContext.d.ts.map +1 -0
- package/dist/types/src/components/StackMain.d.ts +1 -2
- package/dist/types/src/components/StackMain.d.ts.map +1 -1
- package/dist/types/src/components/StackSection.d.ts +4 -0
- package/dist/types/src/components/StackSection.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -0
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +17 -8
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +24 -0
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +24 -23
- package/src/StackPlugin.tsx +3 -11
- package/src/components/AddSectionDialog.tsx +1 -2
- package/src/components/CaretDownUp.tsx +30 -0
- package/src/components/StackContext.tsx +23 -0
- package/src/components/StackMain.tsx +49 -111
- package/src/components/StackSection.tsx +118 -0
- package/src/meta.ts +3 -0
- package/src/translations.ts +9 -0
- package/src/types/types.ts +30 -0
- package/dist/lib/browser/StackMain-KKC3XIAY.mjs +0 -277
- package/dist/lib/browser/StackMain-KKC3XIAY.mjs.map +0 -7
- package/dist/lib/browser/chunk-ONAKM24Z.mjs.map +0 -7
- package/dist/lib/node/StackMain-ME6LYFGI.cjs +0 -296
- package/dist/lib/node/StackMain-ME6LYFGI.cjs.map +0 -7
- package/dist/lib/node/chunk-O5SQVKNW.cjs.map +0 -7
- package/dist/lib/node-esm/StackMain-D3P3PIMI.mjs +0 -278
- package/dist/lib/node-esm/StackMain-D3P3PIMI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-J57BXQJY.mjs.map +0 -7
|
@@ -0,0 +1,390 @@
|
|
|
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 React4, { useEffect, useMemo, useState as useState2 } from "react";
|
|
11
|
+
import { LayoutAction, NavigationAction, parseMetadataResolverPlugin, useIntentDispatcher as useIntentDispatcher2, useResolvePlugin } from "@dxos/app-framework";
|
|
12
|
+
import { create, getType, fullyQualifiedId } from "@dxos/client/echo";
|
|
13
|
+
import { useGraph } from "@dxos/plugin-graph";
|
|
14
|
+
import { SpaceAction } from "@dxos/plugin-space";
|
|
15
|
+
import { Button, toLocalizedString as toLocalizedString2, useTranslation as useTranslation3 } 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/AddSection.tsx
|
|
21
|
+
import { useArrowNavigationGroup } from "@fluentui/react-tabster";
|
|
22
|
+
import React, { useCallback } from "react";
|
|
23
|
+
import { usePlugin, useIntentDispatcher } from "@dxos/app-framework";
|
|
24
|
+
import { toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
25
|
+
import { getSize, mx } from "@dxos/react-ui-theme";
|
|
26
|
+
var CreatorTile = ({ Icon: Icon2, label, testId, handleAdd }) => {
|
|
27
|
+
const onClick = useCallback((_) => handleAdd(), [
|
|
28
|
+
handleAdd
|
|
29
|
+
]);
|
|
30
|
+
const onKeyDown = useCallback((event) => {
|
|
31
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
handleAdd();
|
|
34
|
+
}
|
|
35
|
+
}, [
|
|
36
|
+
handleAdd
|
|
37
|
+
]);
|
|
38
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
39
|
+
role: "button",
|
|
40
|
+
"aria-label": label,
|
|
41
|
+
tabIndex: 0,
|
|
42
|
+
className: mx("flex items-center w-[10rem] h-16 overflow-hidden", "border rounded-md border-separator shadow-sm hover:bg-hoverSurface cursor-pointer"),
|
|
43
|
+
onClick,
|
|
44
|
+
onKeyDown,
|
|
45
|
+
"data-testid": testId
|
|
46
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
47
|
+
className: "flex h-full w-12 items-center justify-center bg-scrim shrink-0 border-r border-separator"
|
|
48
|
+
}, /* @__PURE__ */ React.createElement(Icon2, {
|
|
49
|
+
weight: "thin",
|
|
50
|
+
className: getSize(6)
|
|
51
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
52
|
+
className: "overflow-hidden items-center p-2 px-3"
|
|
53
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
54
|
+
className: "capitalize"
|
|
55
|
+
}, label)));
|
|
56
|
+
};
|
|
57
|
+
var AddSection = ({ collection }) => {
|
|
58
|
+
const domAttributes = useArrowNavigationGroup({
|
|
59
|
+
axis: "grid"
|
|
60
|
+
});
|
|
61
|
+
const dispatch = useIntentDispatcher();
|
|
62
|
+
const { t } = useTranslation(STACK_PLUGIN);
|
|
63
|
+
const stackPlugin = usePlugin(STACK_PLUGIN);
|
|
64
|
+
const stackCreators = stackPlugin?.provides?.stack.creators ?? [];
|
|
65
|
+
const handleAdd = useCallback(async (creator) => {
|
|
66
|
+
const { data: section } = await dispatch(creator.intent) ?? {};
|
|
67
|
+
collection.objects = [
|
|
68
|
+
section
|
|
69
|
+
];
|
|
70
|
+
const stack = collection.views[StackViewType.typename];
|
|
71
|
+
if (stack) {
|
|
72
|
+
stack.sections[section.id] = {};
|
|
73
|
+
}
|
|
74
|
+
}, [
|
|
75
|
+
collection,
|
|
76
|
+
dispatch
|
|
77
|
+
]);
|
|
78
|
+
if (stackCreators.length === 0) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
82
|
+
...domAttributes,
|
|
83
|
+
role: "none",
|
|
84
|
+
className: "flex flex-wrap items-center p-8 gap-4"
|
|
85
|
+
}, stackCreators.map((creator) => {
|
|
86
|
+
const { id, type, icon, testId } = creator;
|
|
87
|
+
return /* @__PURE__ */ React.createElement(CreatorTile, {
|
|
88
|
+
key: id,
|
|
89
|
+
label: toLocalizedString(type, t),
|
|
90
|
+
testId,
|
|
91
|
+
Icon: icon,
|
|
92
|
+
handleAdd: () => handleAdd(creator)
|
|
93
|
+
});
|
|
94
|
+
}));
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// packages/plugins/plugin-stack/src/components/StackContext.tsx
|
|
98
|
+
import { createContext, useContext } from "react";
|
|
99
|
+
var StackContext = /* @__PURE__ */ createContext({
|
|
100
|
+
onCollapse: () => {
|
|
101
|
+
},
|
|
102
|
+
onNavigate: async () => {
|
|
103
|
+
},
|
|
104
|
+
onDelete: async () => {
|
|
105
|
+
},
|
|
106
|
+
onAdd: () => {
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
var useStack = () => useContext(StackContext);
|
|
110
|
+
|
|
111
|
+
// packages/plugins/plugin-stack/src/components/StackSection.tsx
|
|
112
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
113
|
+
import React3, { useState } from "react";
|
|
114
|
+
import { Surface } from "@dxos/app-framework";
|
|
115
|
+
import { DropdownMenu, Icon, useTranslation as useTranslation2, IconButton } from "@dxos/react-ui";
|
|
116
|
+
import { useAttendableAttributes } from "@dxos/react-ui-attention";
|
|
117
|
+
import { StackItem } from "@dxos/react-ui-stack";
|
|
118
|
+
import { mx as mx2, getSize as getSize2, textBlockWidth } from "@dxos/react-ui-theme";
|
|
119
|
+
|
|
120
|
+
// packages/plugins/plugin-stack/src/components/CaretDownUp.tsx
|
|
121
|
+
import React2 from "react";
|
|
122
|
+
var CaretDownUp = ({ children, ...props }) => {
|
|
123
|
+
return /* @__PURE__ */ React2.createElement("svg", {
|
|
124
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
125
|
+
viewBox: "0 0 256 256",
|
|
126
|
+
...props
|
|
127
|
+
}, /* @__PURE__ */ React2.createElement("rect", {
|
|
128
|
+
width: "256",
|
|
129
|
+
height: "256",
|
|
130
|
+
fill: "none"
|
|
131
|
+
}), /* @__PURE__ */ React2.createElement("polyline", {
|
|
132
|
+
points: "80 224 128 176 176 224",
|
|
133
|
+
fill: "none",
|
|
134
|
+
stroke: "currentColor",
|
|
135
|
+
strokeLinecap: "round",
|
|
136
|
+
strokeLinejoin: "round",
|
|
137
|
+
strokeWidth: "16"
|
|
138
|
+
}), /* @__PURE__ */ React2.createElement("polyline", {
|
|
139
|
+
points: "80 32 128 80 176 32",
|
|
140
|
+
fill: "none",
|
|
141
|
+
stroke: "currentColor",
|
|
142
|
+
strokeLinecap: "round",
|
|
143
|
+
strokeLinejoin: "round",
|
|
144
|
+
strokeWidth: "16"
|
|
145
|
+
}), children);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// packages/plugins/plugin-stack/src/components/StackSection.tsx
|
|
149
|
+
var sectionActionDimensions = "m-1 p-1 shrink-0 min-bs-0 is-[--rail-action] bs-min";
|
|
150
|
+
var StackSection = ({ id, view, object, metadata: { icon = "ph--placeholder--regular" } }) => {
|
|
151
|
+
const { t } = useTranslation2(STACK_PLUGIN);
|
|
152
|
+
const { onNavigate, onAdd, onCollapse, onDelete } = useStack();
|
|
153
|
+
const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);
|
|
154
|
+
const attendableAttrs = useAttendableAttributes(id);
|
|
155
|
+
return /* @__PURE__ */ React3.createElement(CollapsiblePrimitive.Root, {
|
|
156
|
+
asChild: true,
|
|
157
|
+
open: !view.collapsed,
|
|
158
|
+
onOpenChange: (nextOpen) => onCollapse?.(id, !nextOpen)
|
|
159
|
+
}, /* @__PURE__ */ React3.createElement(StackItem.Root, {
|
|
160
|
+
item: {
|
|
161
|
+
id
|
|
162
|
+
},
|
|
163
|
+
role: "section",
|
|
164
|
+
...attendableAttrs
|
|
165
|
+
}, /* @__PURE__ */ React3.createElement(StackItem.Heading, {
|
|
166
|
+
classNames: "attention-surface"
|
|
167
|
+
}, /* @__PURE__ */ React3.createElement("span", {
|
|
168
|
+
className: "sr-only"
|
|
169
|
+
}, view.title), /* @__PURE__ */ React3.createElement("div", {
|
|
170
|
+
role: "none",
|
|
171
|
+
className: "sticky -block-start-px bg-[--sticky-bg]"
|
|
172
|
+
}, /* @__PURE__ */ React3.createElement(DropdownMenu.Root, {
|
|
173
|
+
open: optionsMenuOpen,
|
|
174
|
+
onOpenChange: setOptionsMenuOpen
|
|
175
|
+
}, /* @__PURE__ */ React3.createElement(DropdownMenu.Trigger, {
|
|
176
|
+
asChild: true
|
|
177
|
+
}, /* @__PURE__ */ React3.createElement(StackItem.SigilButton, null, /* @__PURE__ */ React3.createElement(Icon, {
|
|
178
|
+
icon,
|
|
179
|
+
size: 5,
|
|
180
|
+
classNames: "transition-opacity"
|
|
181
|
+
}))), /* @__PURE__ */ React3.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Content, {
|
|
182
|
+
style: {
|
|
183
|
+
zIndex: 70
|
|
184
|
+
}
|
|
185
|
+
}, /* @__PURE__ */ React3.createElement(DropdownMenu.Viewport, null, view.collapsed ? /* @__PURE__ */ React3.createElement(DropdownMenu.Item, {
|
|
186
|
+
onClick: () => onNavigate(id),
|
|
187
|
+
"data-testid": "section.navigate-to"
|
|
188
|
+
}, /* @__PURE__ */ React3.createElement(Icon, {
|
|
189
|
+
icon: "ph--arrow-square-out--regular",
|
|
190
|
+
size: 5
|
|
191
|
+
}), /* @__PURE__ */ React3.createElement("span", {
|
|
192
|
+
className: "mis-2 grow"
|
|
193
|
+
}, t("navigate to section label"))) : /* @__PURE__ */ React3.createElement(CollapsiblePrimitive.Trigger, {
|
|
194
|
+
asChild: true
|
|
195
|
+
}, /* @__PURE__ */ React3.createElement(DropdownMenu.Item, null, /* @__PURE__ */ React3.createElement(CaretDownUp, {
|
|
196
|
+
className: getSize2(5)
|
|
197
|
+
}), /* @__PURE__ */ React3.createElement("span", {
|
|
198
|
+
className: "mis-2 grow"
|
|
199
|
+
}, t("collapse label")))), /* @__PURE__ */ React3.createElement(DropdownMenu.Item, {
|
|
200
|
+
onClick: () => onAdd(id, "before"),
|
|
201
|
+
"data-testid": "section.add-before"
|
|
202
|
+
}, /* @__PURE__ */ React3.createElement(Icon, {
|
|
203
|
+
icon: "ph--arrow-line-up--regular",
|
|
204
|
+
size: 5
|
|
205
|
+
}), /* @__PURE__ */ React3.createElement("span", {
|
|
206
|
+
className: "mis-2 grow"
|
|
207
|
+
}, t("add section before label"))), /* @__PURE__ */ React3.createElement(DropdownMenu.Item, {
|
|
208
|
+
onClick: () => onAdd(id, "after"),
|
|
209
|
+
"data-testid": "section.add-after"
|
|
210
|
+
}, /* @__PURE__ */ React3.createElement(Icon, {
|
|
211
|
+
icon: "ph--arrow-line-down--regular",
|
|
212
|
+
size: 5
|
|
213
|
+
}), /* @__PURE__ */ React3.createElement("span", {
|
|
214
|
+
className: "mis-2 grow"
|
|
215
|
+
}, t("add section after label"))), /* @__PURE__ */ React3.createElement(DropdownMenu.Item, {
|
|
216
|
+
onClick: () => onDelete(id),
|
|
217
|
+
"data-testid": "section.remove"
|
|
218
|
+
}, /* @__PURE__ */ React3.createElement(Icon, {
|
|
219
|
+
icon: "ph--trash--regular",
|
|
220
|
+
size: 5
|
|
221
|
+
}), /* @__PURE__ */ React3.createElement("span", {
|
|
222
|
+
className: "mis-2 grow"
|
|
223
|
+
}, t("remove section label")))), /* @__PURE__ */ React3.createElement(DropdownMenu.Arrow, null)))), view.collapsed ? /* @__PURE__ */ React3.createElement(CollapsiblePrimitive.Trigger, {
|
|
224
|
+
asChild: true
|
|
225
|
+
}, /* @__PURE__ */ React3.createElement(IconButton, {
|
|
226
|
+
iconOnly: true,
|
|
227
|
+
tooltipZIndex: "70",
|
|
228
|
+
variant: "ghost",
|
|
229
|
+
label: t("expand label"),
|
|
230
|
+
icon: "ph--caret-up-down--regular",
|
|
231
|
+
classNames: sectionActionDimensions
|
|
232
|
+
})) : /* @__PURE__ */ React3.createElement(IconButton, {
|
|
233
|
+
iconOnly: true,
|
|
234
|
+
tooltipZIndex: "70",
|
|
235
|
+
variant: "ghost",
|
|
236
|
+
onClick: () => onNavigate(id),
|
|
237
|
+
label: t("navigate to section label"),
|
|
238
|
+
icon: "ph--arrow-square-out--regular",
|
|
239
|
+
"data-testid": "section.navigate-to",
|
|
240
|
+
classNames: sectionActionDimensions
|
|
241
|
+
}))), /* @__PURE__ */ React3.createElement(CollapsiblePrimitive.Content, null, /* @__PURE__ */ React3.createElement(Surface, {
|
|
242
|
+
role: "section",
|
|
243
|
+
data: {
|
|
244
|
+
object
|
|
245
|
+
},
|
|
246
|
+
limit: 1,
|
|
247
|
+
placeholder: /* @__PURE__ */ React3.createElement(React3.Fragment, null)
|
|
248
|
+
})), view.collapsed && /* @__PURE__ */ React3.createElement(StackItem.Content, {
|
|
249
|
+
toolbar: false,
|
|
250
|
+
classNames: "attention-surface"
|
|
251
|
+
}, /* @__PURE__ */ React3.createElement("h2", {
|
|
252
|
+
className: mx2("flex items-center p-4 font-medium is-full", textBlockWidth)
|
|
253
|
+
}, view.title))));
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// packages/plugins/plugin-stack/src/components/StackMain.tsx
|
|
257
|
+
var StackMain = ({ id, collection }) => {
|
|
258
|
+
const dispatch = useIntentDispatcher2();
|
|
259
|
+
const { graph } = useGraph();
|
|
260
|
+
const { t } = useTranslation3(STACK_PLUGIN);
|
|
261
|
+
const metadataPlugin = useResolvePlugin(parseMetadataResolverPlugin);
|
|
262
|
+
const defaultStack = useMemo(() => create(StackViewType, {
|
|
263
|
+
sections: {}
|
|
264
|
+
}), [
|
|
265
|
+
collection
|
|
266
|
+
]);
|
|
267
|
+
const stack = collection.views[StackViewType.typename] ?? defaultStack;
|
|
268
|
+
const [collapsedSections, setCollapsedSections] = useState2({});
|
|
269
|
+
useEffect(() => {
|
|
270
|
+
if (!collection.views[StackViewType.typename]) {
|
|
271
|
+
collection.views[StackViewType.typename] = stack;
|
|
272
|
+
}
|
|
273
|
+
}, [
|
|
274
|
+
collection,
|
|
275
|
+
stack
|
|
276
|
+
]);
|
|
277
|
+
const items = collection.objects.filter(nonNullable).map((object) => {
|
|
278
|
+
const metadata = metadataPlugin?.provides.metadata.resolver(getType(object)?.objectId ?? "never");
|
|
279
|
+
const view = {
|
|
280
|
+
...stack.sections[object.id],
|
|
281
|
+
collapsed: collapsedSections[fullyQualifiedId(object)],
|
|
282
|
+
title: object?.title ?? toLocalizedString2(graph.findNode(fullyQualifiedId(object))?.properties.label, t)
|
|
283
|
+
};
|
|
284
|
+
return {
|
|
285
|
+
id: fullyQualifiedId(object),
|
|
286
|
+
object,
|
|
287
|
+
metadata,
|
|
288
|
+
view
|
|
289
|
+
};
|
|
290
|
+
}) ?? [];
|
|
291
|
+
const handleDelete = async (id2) => {
|
|
292
|
+
const index = collection.objects.filter(nonNullable).findIndex((section) => fullyQualifiedId(section) === id2);
|
|
293
|
+
if (index >= 0) {
|
|
294
|
+
await dispatch({
|
|
295
|
+
action: SpaceAction.REMOVE_OBJECTS,
|
|
296
|
+
data: {
|
|
297
|
+
objects: [
|
|
298
|
+
collection.objects[index]
|
|
299
|
+
],
|
|
300
|
+
collection
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
const handleAdd = (id2, position) => {
|
|
306
|
+
void dispatch?.({
|
|
307
|
+
action: LayoutAction.SET_LAYOUT,
|
|
308
|
+
data: {
|
|
309
|
+
element: "dialog",
|
|
310
|
+
component: `${STACK_PLUGIN}/AddSectionDialog`,
|
|
311
|
+
subject: {
|
|
312
|
+
path: id2,
|
|
313
|
+
position,
|
|
314
|
+
collection
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
const handleNavigate = async (id2) => {
|
|
320
|
+
await dispatch([
|
|
321
|
+
{
|
|
322
|
+
action: NavigationAction.OPEN,
|
|
323
|
+
data: {
|
|
324
|
+
activeParts: {
|
|
325
|
+
main: [
|
|
326
|
+
id2
|
|
327
|
+
]
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
action: LayoutAction.SCROLL_INTO_VIEW,
|
|
333
|
+
data: {
|
|
334
|
+
id: id2
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
]);
|
|
338
|
+
};
|
|
339
|
+
const handleCollapse = (id2, collapsed) => {
|
|
340
|
+
setCollapsedSections((prev) => ({
|
|
341
|
+
...prev,
|
|
342
|
+
[id2]: collapsed
|
|
343
|
+
}));
|
|
344
|
+
};
|
|
345
|
+
return /* @__PURE__ */ React4.createElement(AttentionProvider, {
|
|
346
|
+
id
|
|
347
|
+
}, /* @__PURE__ */ React4.createElement(StackContext.Provider, {
|
|
348
|
+
value: {
|
|
349
|
+
onCollapse: handleCollapse,
|
|
350
|
+
onNavigate: handleNavigate,
|
|
351
|
+
onDelete: handleDelete,
|
|
352
|
+
onAdd: handleAdd
|
|
353
|
+
}
|
|
354
|
+
}, /* @__PURE__ */ React4.createElement(Stack, {
|
|
355
|
+
orientation: "vertical",
|
|
356
|
+
size: "intrinsic",
|
|
357
|
+
id,
|
|
358
|
+
"data-testid": "main.stack",
|
|
359
|
+
classNames: "divide-y-reverse"
|
|
360
|
+
}, items.map((item) => /* @__PURE__ */ React4.createElement(StackSection, {
|
|
361
|
+
key: item.id,
|
|
362
|
+
...item
|
|
363
|
+
}))), items.length === 0 ? /* @__PURE__ */ React4.createElement(AddSection, {
|
|
364
|
+
collection
|
|
365
|
+
}) : /* @__PURE__ */ React4.createElement("div", {
|
|
366
|
+
role: "none",
|
|
367
|
+
className: "flex mlb-2 pli-2 justify-center"
|
|
368
|
+
}, /* @__PURE__ */ React4.createElement(Button, {
|
|
369
|
+
"data-testid": "stack.createSection",
|
|
370
|
+
classNames: "gap-2",
|
|
371
|
+
onClick: () => dispatch?.({
|
|
372
|
+
action: LayoutAction.SET_LAYOUT,
|
|
373
|
+
data: {
|
|
374
|
+
element: "dialog",
|
|
375
|
+
component: "dxos.org/plugin/stack/AddSectionDialog",
|
|
376
|
+
subject: {
|
|
377
|
+
position: "afterAll",
|
|
378
|
+
collection
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
})
|
|
382
|
+
}, /* @__PURE__ */ React4.createElement(Plus, null), /* @__PURE__ */ React4.createElement("span", {
|
|
383
|
+
className: "sr-only"
|
|
384
|
+
}, t("add section label"))))));
|
|
385
|
+
};
|
|
386
|
+
var StackMain_default = StackMain;
|
|
387
|
+
export {
|
|
388
|
+
StackMain_default as default
|
|
389
|
+
};
|
|
390
|
+
//# sourceMappingURL=StackMain-Z2DSTC42.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/StackMain.tsx", "../../../src/components/AddSection.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, { useEffect, useMemo, useState } from 'react';\n\nimport {\n LayoutAction,\n NavigationAction,\n parseMetadataResolverPlugin,\n useIntentDispatcher,\n useResolvePlugin,\n} from '@dxos/app-framework';\nimport { create, getType, fullyQualifiedId } 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 { AddSection } from './AddSection';\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 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] as StackViewType) ?? defaultStack;\n const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});\n\n useEffect(() => {\n if (!collection.views[StackViewType.typename]) {\n collection.views[StackViewType.typename] = 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 .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 = async (id: string) => {\n const index = collection.objects.filter(nonNullable).findIndex((section) => fullyQualifiedId(section) === id);\n if (index >= 0) {\n await dispatch({\n action: SpaceAction.REMOVE_OBJECTS,\n data: { objects: [collection.objects[index]], collection },\n });\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\n const handleAdd = (id: string, position: AddSectionPosition) => {\n void dispatch?.({\n action: LayoutAction.SET_LAYOUT,\n data: {\n element: 'dialog',\n component: `${STACK_PLUGIN}/AddSectionDialog`,\n subject: { path: id, position, collection },\n },\n });\n };\n\n const handleNavigate = async (id: string) => {\n await dispatch([\n {\n action: NavigationAction.OPEN,\n data: { activeParts: { main: [id] } },\n },\n {\n action: LayoutAction.SCROLL_INTO_VIEW,\n data: { id },\n },\n ]);\n };\n\n const handleCollapse = (id: string, collapsed: boolean) => {\n setCollapsedSections((prev) => ({ ...prev, [id]: collapsed }));\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' classNames='divide-y-reverse'>\n {items.map((item) => (\n <StackSection key={item.id} {...item} />\n ))}\n </Stack>\n\n {items.length === 0 ? (\n <AddSection collection={collection} />\n ) : (\n <div role='none' className='flex mlb-2 pli-2 justify-center'>\n <Button\n data-testid='stack.createSection'\n classNames='gap-2'\n onClick={() =>\n dispatch?.({\n action: LayoutAction.SET_LAYOUT,\n data: {\n element: 'dialog',\n component: 'dxos.org/plugin/stack/AddSectionDialog',\n subject: { position: 'afterAll', collection },\n },\n })\n }\n >\n <Plus />\n <span className='sr-only'>{t('add section label')}</span>\n </Button>\n </div>\n )}\n </StackContext.Provider>\n </AttentionProvider>\n );\n};\n\nexport default StackMain;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport { type IconProps } from '@phosphor-icons/react';\nimport React, { type FC, type KeyboardEvent, type MouseEvent, useCallback } from 'react';\n\nimport { usePlugin, useIntentDispatcher } from '@dxos/app-framework';\nimport { type CollectionType } from '@dxos/plugin-space/types';\nimport { toLocalizedString, useTranslation } from '@dxos/react-ui';\nimport { getSize, mx } from '@dxos/react-ui-theme';\n\nimport { STACK_PLUGIN } from '../meta';\nimport { StackViewType, type StackSectionCreator, type StackPluginProvides } from '../types';\n\nconst CreatorTile = ({\n Icon,\n label,\n testId,\n handleAdd,\n}: {\n Icon: FC<IconProps>;\n testId: string;\n label: string;\n handleAdd: () => void;\n}) => {\n const onClick = useCallback((_: MouseEvent<HTMLDivElement>) => handleAdd(), [handleAdd]);\n const onKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n handleAdd();\n }\n },\n [handleAdd],\n );\n\n return (\n <div\n role='button'\n aria-label={label}\n tabIndex={0}\n className={mx(\n 'flex items-center w-[10rem] h-16 overflow-hidden',\n 'border rounded-md border-separator shadow-sm hover:bg-hoverSurface cursor-pointer',\n )}\n onClick={onClick}\n onKeyDown={onKeyDown}\n data-testid={testId}\n >\n <div className='flex h-full w-12 items-center justify-center bg-scrim shrink-0 border-r border-separator'>\n <Icon weight='thin' className={getSize(6)} />\n </div>\n <div className='overflow-hidden items-center p-2 px-3'>\n <span className='capitalize'>{label}</span>\n </div>\n </div>\n );\n};\n\nexport const AddSection = ({ collection }: { collection: CollectionType }) => {\n const domAttributes = useArrowNavigationGroup({ axis: 'grid' });\n const dispatch = useIntentDispatcher();\n const { t } = useTranslation(STACK_PLUGIN);\n\n const stackPlugin = usePlugin<StackPluginProvides>(STACK_PLUGIN);\n const stackCreators = stackPlugin?.provides?.stack.creators ?? [];\n\n const handleAdd = useCallback(\n async (creator: StackSectionCreator) => {\n const { data: section } = (await dispatch(creator.intent)) ?? {};\n collection.objects = [section];\n const stack = collection.views[StackViewType.typename];\n if (stack) {\n stack.sections[section.id] = {};\n }\n },\n [collection, dispatch],\n );\n\n if (stackCreators.length === 0) {\n return null;\n }\n\n return (\n <div {...domAttributes} role='none' className='flex flex-wrap items-center p-8 gap-4'>\n {stackCreators.map((creator) => {\n const { id, type, icon, testId } = creator;\n return (\n <CreatorTile\n key={id}\n label={toLocalizedString(type, t)}\n testId={testId}\n Icon={icon}\n handleAdd={() => handleAdd(creator)}\n />\n );\n })}\n </div>\n );\n};\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}>\n <StackItem.Heading classNames='attention-surface'>\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 style={{ zIndex: 70 }}>\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 tooltipZIndex='70'\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 tooltipZIndex='70'\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={{ 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,WAAWC,SAASC,YAAAA,iBAAgB;AAEpD,SACEC,cACAC,kBACAC,6BACAC,uBAAAA,sBACAC,wBACK;AACP,SAASC,QAAQC,SAASC,wBAAwB;AAClD,SAASC,gBAAgB;AACzB,SAASC,mBAAmB;AAE5B,SAASC,QAAQC,qBAAAA,oBAAmBC,kBAAAA,uBAAsB;AAC1D,SAASC,yBAAyB;AAClC,SAASC,aAAa;AACtB,SAASC,mBAAmB;;;ACjB5B,SAASC,+BAA+B;AAExC,OAAOC,SAAuDC,mBAAmB;AAEjF,SAASC,WAAWC,2BAA2B;AA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A;AAO3C;AAEA,IAAA,oBAAeP;",
|
|
6
|
+
"names": ["Plus", "React", "useEffect", "useMemo", "useState", "LayoutAction", "NavigationAction", "parseMetadataResolverPlugin", "useIntentDispatcher", "useResolvePlugin", "create", "getType", "fullyQualifiedId", "useGraph", "SpaceAction", "Button", "toLocalizedString", "useTranslation", "AttentionProvider", "Stack", "nonNullable", "useArrowNavigationGroup", "React", "useCallback", "usePlugin", "useIntentDispatcher", "toLocalizedString", "useTranslation", "getSize", "mx", "CreatorTile", "Icon", "label", "testId", "handleAdd", "onClick", "useCallback", "_", "onKeyDown", "event", "key", "preventDefault", "div", "role", "aria-label", "tabIndex", "className", "mx", "data-testid", "weight", "getSize", "span", "AddSection", "collection", "domAttributes", "useArrowNavigationGroup", "axis", "dispatch", "useIntentDispatcher", "t", "useTranslation", "STACK_PLUGIN", "stackPlugin", "usePlugin", "stackCreators", "provides", "stack", "creators", "creator", "data", "section", "intent", "objects", "views", "StackViewType", "typename", "sections", "id", "length", "map", "type", "icon", "toLocalizedString", "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", "React", "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", "Heading", "classNames", "span", "className", "title", "div", "DropdownMenu", "Trigger", "SigilButton", "Icon", "size", "Portal", "Content", "style", "zIndex", "Viewport", "Item", "onClick", "data-testid", "CaretDownUp", "getSize", "Arrow", "IconButton", "iconOnly", "tooltipZIndex", "variant", "label", "Surface", "data", "limit", "placeholder", "toolbar", "h2", "mx", "textBlockWidth", "StackMain", "id", "collection", "dispatch", "useIntentDispatcher", "graph", "useGraph", "t", "useTranslation", "STACK_PLUGIN", "metadataPlugin", "useResolvePlugin", "parseMetadataResolverPlugin", "defaultStack", "useMemo", "create", "StackViewType", "sections", "stack", "views", "typename", "collapsedSections", "setCollapsedSections", "useState", "useEffect", "items", "objects", "filter", "nonNullable", "map", "object", "metadata", "provides", "resolver", "getType", "objectId", "view", "collapsed", "fullyQualifiedId", "title", "toLocalizedString", "findNode", "properties", "label", "handleDelete", "index", "findIndex", "section", "action", "SpaceAction", "REMOVE_OBJECTS", "data", "handleAdd", "position", "LayoutAction", "SET_LAYOUT", "element", "component", "subject", "path", "handleNavigate", "NavigationAction", "OPEN", "activeParts", "main", "SCROLL_INTO_VIEW", "handleCollapse", "prev", "React", "AttentionProvider", "StackContext", "Provider", "value", "onCollapse", "onNavigate", "onDelete", "onAdd", "Stack", "orientation", "size", "data-testid", "classNames", "item", "StackSection", "key", "length", "AddSection", "div", "role", "className", "Button", "onClick", "Plus", "span"]
|
|
7
|
+
}
|
|
@@ -4,8 +4,11 @@ var SECTION_IDENTIFIER = "dxos.org/type/StackSection";
|
|
|
4
4
|
var meta_default = {
|
|
5
5
|
id: STACK_PLUGIN,
|
|
6
6
|
// TODO(wittjosiah): Prevents "stacks" language from being exposed to users in settings panel.
|
|
7
|
+
// Conside renaming this to the collection plugin and trying to factor more collections logic from the space plugin.
|
|
7
8
|
name: "Collections",
|
|
8
|
-
|
|
9
|
+
description: "View collections of objects within the deck.",
|
|
10
|
+
icon: "ph--stack-simple--regular",
|
|
11
|
+
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-stack"
|
|
9
12
|
};
|
|
10
13
|
|
|
11
14
|
export {
|
|
@@ -13,4 +16,4 @@ export {
|
|
|
13
16
|
SECTION_IDENTIFIER,
|
|
14
17
|
meta_default
|
|
15
18
|
};
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-DS5KGEJG.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const STACK_PLUGIN = 'dxos.org/plugin/stack';\nexport const SECTION_IDENTIFIER = 'dxos.org/type/StackSection';\n\nexport default {\n id: STACK_PLUGIN,\n // TODO(wittjosiah): Prevents \"stacks\" language from being exposed to users in settings panel.\n // Conside renaming this to the collection plugin and trying to factor more collections logic from the space plugin.\n name: 'Collections',\n description: 'View collections of objects within the deck.',\n icon: 'ph--stack-simple--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-stack',\n} satisfies PluginMeta;\n"],
|
|
5
|
+
"mappings": ";AAMO,IAAMA,eAAe;AACrB,IAAMC,qBAAqB;AAElC,IAAA,eAAe;EACbC,IAAIF;;;EAGJG,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;AACV;",
|
|
6
|
+
"names": ["STACK_PLUGIN", "SECTION_IDENTIFIER", "id", "name", "description", "icon", "source"]
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
SECTION_IDENTIFIER,
|
|
3
3
|
STACK_PLUGIN,
|
|
4
4
|
meta_default
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-DS5KGEJG.mjs";
|
|
6
6
|
import {
|
|
7
7
|
SectionSchema,
|
|
8
8
|
StackViewType
|
|
@@ -144,7 +144,7 @@ var AddSectionDialog = ({ path, position, collection }) => {
|
|
|
144
144
|
};
|
|
145
145
|
|
|
146
146
|
// packages/plugins/plugin-stack/src/components/index.ts
|
|
147
|
-
var StackMain = lazy(() => import("./StackMain-
|
|
147
|
+
var StackMain = lazy(() => import("./StackMain-Z2DSTC42.mjs"));
|
|
148
148
|
|
|
149
149
|
// packages/plugins/plugin-stack/src/translations.ts
|
|
150
150
|
import { translations as stackTranslations } from "@dxos/react-ui-stack";
|
|
@@ -160,7 +160,16 @@ var translations_default = [
|
|
|
160
160
|
"add section after dialog title": "Add a section",
|
|
161
161
|
"add section input placeholder": "Find the type of section to add",
|
|
162
162
|
"upload file label": "Add file",
|
|
163
|
-
"add section label": "Add section"
|
|
163
|
+
"add section label": "Add section",
|
|
164
|
+
"empty stack message": "Drag items into the stack.",
|
|
165
|
+
"remove section label": "Delete",
|
|
166
|
+
"navigate to section label": "Navigate to item",
|
|
167
|
+
"untitled section title": "Untitled section",
|
|
168
|
+
"add section before label": "Add before",
|
|
169
|
+
"add section after label": "Add after",
|
|
170
|
+
"expand label": "Expand",
|
|
171
|
+
"collapse label": "Collapse",
|
|
172
|
+
"drag handle label": "Press space or enter to begin dragging this item."
|
|
164
173
|
}
|
|
165
174
|
}
|
|
166
175
|
},
|
|
@@ -247,17 +256,18 @@ var StackPlugin = () => {
|
|
|
247
256
|
]
|
|
248
257
|
}, /* @__PURE__ */ React3.createElement(StackMain, {
|
|
249
258
|
id: id ?? fullyQualifiedId(primary),
|
|
250
|
-
collection: primary
|
|
251
|
-
separation: settings.values.separation
|
|
259
|
+
collection: primary
|
|
252
260
|
})) : null;
|
|
253
261
|
case "article":
|
|
254
262
|
return primary instanceof CollectionType ? /* @__PURE__ */ React3.createElement("div", {
|
|
255
263
|
role: "none",
|
|
256
|
-
className: "row-span-2 overflow-auto"
|
|
264
|
+
className: "row-span-2 overflow-auto",
|
|
265
|
+
style: {
|
|
266
|
+
contain: "layout"
|
|
267
|
+
}
|
|
257
268
|
}, /* @__PURE__ */ React3.createElement(StackMain, {
|
|
258
269
|
id: id ?? fullyQualifiedId(primary),
|
|
259
|
-
collection: primary
|
|
260
|
-
separation: settings.values.separation
|
|
270
|
+
collection: primary
|
|
261
271
|
})) : null;
|
|
262
272
|
case "settings": {
|
|
263
273
|
return data.plugin === meta_default.id ? /* @__PURE__ */ React3.createElement(StackSettings, {
|