@dxos/plugin-stack 0.9.1-main.c7dcc2e112 → 0.10.0
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/neutral/StackArticle-DDKRSUE7.mjs +199 -0
- package/dist/lib/neutral/StackArticle-DDKRSUE7.mjs.map +7 -0
- package/dist/lib/neutral/StackPlugin.mjs +4 -2
- package/dist/lib/neutral/StackPlugin.mjs.map +3 -3
- package/dist/lib/neutral/capabilities/index.mjs +3 -1
- package/dist/lib/neutral/capabilities/index.mjs.map +1 -1
- package/dist/lib/neutral/chunk-FDNICBZZ.mjs +18 -0
- package/dist/lib/neutral/chunk-FDNICBZZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-CTWUHXK5.mjs → chunk-ZOIZTRMG.mjs} +3 -5
- package/dist/lib/neutral/chunk-ZOIZTRMG.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +188 -145
- package/dist/lib/neutral/components/index.mjs.map +4 -4
- package/dist/lib/neutral/containers/index.mjs +3 -1
- package/dist/lib/neutral/containers/index.mjs.map +1 -1
- package/dist/lib/neutral/index.mjs +5 -6
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/meta.mjs +2 -1
- package/dist/lib/neutral/plugin.mjs +2 -1
- package/dist/lib/neutral/plugin.mjs.map +1 -1
- package/dist/lib/neutral/{react-surface-MD3CVY2N.mjs → react-surface-IL4CW7ND.mjs} +3 -1
- package/dist/lib/neutral/{react-surface-MD3CVY2N.mjs.map → react-surface-IL4CW7ND.mjs.map} +1 -1
- package/dist/lib/neutral/translations.mjs +8 -6
- package/dist/lib/neutral/translations.mjs.map +3 -3
- package/dist/lib/neutral/types/index.mjs +4 -5
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/components/Stack/Stack.d.ts +67 -0
- package/dist/types/src/components/Stack/Stack.d.ts.map +1 -0
- package/dist/types/src/components/Stack/index.d.ts +2 -0
- package/dist/types/src/components/Stack/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/StackArticle/StackArticle.d.ts +1 -2
- package/dist/types/src/containers/StackArticle/StackArticle.d.ts.map +1 -1
- package/dist/types/src/containers/StackArticle/StackArticle.stories.d.ts +7 -0
- package/dist/types/src/containers/StackArticle/StackArticle.stories.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +4 -0
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +5 -16
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Stack.d.ts +6 -0
- package/dist/types/src/types/Stack.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dx.config.ts +2 -4
- package/package.json +33 -28
- package/src/StackPlugin.ts +2 -2
- package/src/components/Stack/Stack.tsx +319 -0
- package/src/components/{StackContext → Stack}/index.ts +1 -1
- package/src/components/index.ts +1 -3
- package/src/containers/StackArticle/StackArticle.stories.tsx +122 -0
- package/src/containers/StackArticle/StackArticle.tsx +180 -118
- package/src/translations.ts +5 -5
- package/src/types/Stack.ts +12 -0
- package/src/types/index.ts +1 -2
- package/dist/lib/neutral/StackArticle-SBM3FBJM.mjs +0 -124
- package/dist/lib/neutral/StackArticle-SBM3FBJM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-CTWUHXK5.mjs.map +0 -7
- package/dist/lib/neutral/chunk-T4NSFSPH.mjs +0 -24
- package/dist/lib/neutral/chunk-T4NSFSPH.mjs.map +0 -7
- package/dist/types/src/components/StackContext/StackContext.d.ts +0 -11
- package/dist/types/src/components/StackContext/StackContext.d.ts.map +0 -1
- package/dist/types/src/components/StackContext/index.d.ts +0 -2
- package/dist/types/src/components/StackContext/index.d.ts.map +0 -1
- package/dist/types/src/components/StackSection/CaretDownUp.d.ts +0 -3
- package/dist/types/src/components/StackSection/CaretDownUp.d.ts.map +0 -1
- package/dist/types/src/components/StackSection/StackSection.d.ts +0 -5
- package/dist/types/src/components/StackSection/StackSection.d.ts.map +0 -1
- package/dist/types/src/components/StackSection/index.d.ts +0 -2
- package/dist/types/src/components/StackSection/index.d.ts.map +0 -1
- package/dist/types/src/components/StackSettings/StackSettings.d.ts +0 -6
- package/dist/types/src/components/StackSettings/StackSettings.d.ts.map +0 -1
- package/dist/types/src/components/StackSettings/index.d.ts +0 -2
- package/dist/types/src/components/StackSettings/index.d.ts.map +0 -1
- package/dist/types/src/types/stack.d.ts +0 -18
- package/dist/types/src/types/stack.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -44
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/components/StackContext/StackContext.tsx +0 -25
- package/src/components/StackSection/CaretDownUp.tsx +0 -30
- package/src/components/StackSection/StackSection.tsx +0 -124
- package/src/components/StackSection/index.ts +0 -5
- package/src/components/StackSettings/StackSettings.tsx +0 -28
- package/src/components/StackSettings/index.ts +0 -5
- package/src/types/stack.ts +0 -26
- package/src/types/types.ts +0 -46
|
@@ -3,121 +3,160 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Atom, useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
-
import
|
|
7
|
-
import React, { useCallback, useState } from 'react';
|
|
6
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
8
7
|
|
|
9
8
|
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { type Collection, Obj, type Ref } from '@dxos/echo';
|
|
13
|
-
import { Graph } from '@dxos/plugin-graph';
|
|
9
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
10
|
+
import { type Collection, Obj } from '@dxos/echo';
|
|
14
11
|
import { SpaceOperation } from '@dxos/plugin-space';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
12
|
+
import { Panel, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
13
|
+
import { Menu, createMenuAction } from '@dxos/react-ui-menu';
|
|
14
|
+
import { Mosaic, type MosaicEventHandler } from '@dxos/react-ui-mosaic';
|
|
15
|
+
import { arrayMove, isNonNullable } from '@dxos/util';
|
|
18
16
|
|
|
19
|
-
import {
|
|
17
|
+
import { Stack, type StackSectionItem } from '#components';
|
|
20
18
|
import { meta } from '#meta';
|
|
21
|
-
import {
|
|
22
|
-
type AddSectionPosition,
|
|
23
|
-
type CollapsedSections,
|
|
24
|
-
type StackSectionItem,
|
|
25
|
-
type StackSectionMetadata,
|
|
26
|
-
type StackSectionView,
|
|
27
|
-
} from '#types';
|
|
28
|
-
|
|
29
|
-
const collectionObjectsFamily = Atom.family((collection: Collection.Collection) =>
|
|
30
|
-
Atom.make((get) => {
|
|
31
|
-
const snapshot = get(Obj.atom(collection));
|
|
32
|
-
return (
|
|
33
|
-
snapshot.objects
|
|
34
|
-
// TODO(wittjosiah): Why isn't this type inferred correctly?
|
|
35
|
-
.map((ref: Ref.Ref<Obj.Unknown>) => get(Obj.atomReactive(ref)))
|
|
36
|
-
.filter(isNonNullable)
|
|
37
|
-
);
|
|
38
|
-
}),
|
|
39
|
-
);
|
|
40
19
|
|
|
41
|
-
type StackArticleProps = AppSurface.ObjectArticleProps<Collection.Collection>;
|
|
20
|
+
export type StackArticleProps = AppSurface.ObjectArticleProps<Collection.Collection>;
|
|
42
21
|
|
|
43
22
|
export const StackArticle = ({ attendableId, subject: collection }: StackArticleProps) => {
|
|
44
23
|
const { invokePromise } = useOperationInvoker();
|
|
45
|
-
const { graph } = useAppGraph();
|
|
46
24
|
const { t } = useTranslation(meta.profile.key);
|
|
47
|
-
const [collapsedSections, setCollapsedSections] = useState<
|
|
48
|
-
|
|
49
|
-
// TODO(wittjosiah): Re-implement stack views with relations.
|
|
50
|
-
// const defaultStack = useMemo(() => Obj.make(StackViewType, { sections: {} }), [collection]);
|
|
51
|
-
// const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;
|
|
52
|
-
// useEffect(() => {
|
|
53
|
-
// if (!collection.views[StackViewType.typename]) {
|
|
54
|
-
// collection.views[StackViewType.typename] = Ref.make(stack);
|
|
55
|
-
// }
|
|
56
|
-
// }, [collection, stack]);
|
|
57
|
-
|
|
58
|
-
const collectionObjects = useAtomValue(collectionObjectsFamily(collection));
|
|
59
|
-
const items = collectionObjects.map((object: Obj.Unknown) => {
|
|
60
|
-
const iconAnnotation = Obj.getIcon(object);
|
|
61
|
-
const metadata: StackSectionMetadata = { icon: iconAnnotation?.icon };
|
|
62
|
-
const view = {
|
|
63
|
-
// ...stack.sections[object.id],
|
|
64
|
-
collapsed: collapsedSections[Obj.getURI(object)],
|
|
65
|
-
title:
|
|
66
|
-
(object as any)?.title ??
|
|
67
|
-
// TODO(wittjosiah): `getNode` is not reactive.
|
|
68
|
-
toLocalizedString(Graph.getNode(graph, Obj.getURI(object)).pipe(Option.getOrNull)?.properties.label, t),
|
|
69
|
-
} as StackSectionView;
|
|
70
|
-
return { id: Obj.getURI(object), object, metadata, view } satisfies StackSectionItem;
|
|
71
|
-
});
|
|
25
|
+
const [collapsedSections, setCollapsedSections] = useState<Record<string, boolean>>({});
|
|
72
26
|
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
27
|
+
const collectionObjects = useAtomValue(createCollectionObjects(collection));
|
|
28
|
+
const items = useMemo<StackSectionItem[]>(
|
|
29
|
+
() => collectionObjects.map((object) => ({ id: Obj.getURI(object), object })),
|
|
30
|
+
[collectionObjects],
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const collapsed = useMemo<ReadonlySet<string>>(
|
|
34
|
+
() => new Set(Object.keys(collapsedSections).filter((id) => collapsedSections[id])),
|
|
35
|
+
[collapsedSections],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// Index of a section within the collection by its object URI.
|
|
39
|
+
const findIndex = useCallback(
|
|
40
|
+
(id: string) => collection.objects.findIndex((ref) => ref.target != null && Obj.getURI(ref.target) === id),
|
|
41
|
+
[collection],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Reorder sections in place. Placeholder/tile drop locations are 1-based with half-step placeholders
|
|
45
|
+
// between tiles, so the floor of the drop location is the destination array index (see Mosaic.Stack).
|
|
46
|
+
const eventHandler = useMemo<MosaicEventHandler<StackSectionItem>>(
|
|
47
|
+
() => ({
|
|
48
|
+
id: Obj.getURI(collection),
|
|
49
|
+
canDrop: ({ source }) =>
|
|
50
|
+
collection.objects.some((ref) => ref.target != null && Obj.getURI(ref.target) === source.id),
|
|
51
|
+
onDrop: ({ source, target }) => {
|
|
52
|
+
const to =
|
|
53
|
+
target?.type === 'tile' || target?.type === 'placeholder'
|
|
54
|
+
? target.location
|
|
55
|
+
: target?.type === 'container'
|
|
56
|
+
? collection.objects.length
|
|
57
|
+
: -1;
|
|
58
|
+
const insert = typeof to === 'number' && to >= 0 ? Math.floor(to) : -1;
|
|
59
|
+
if (insert < 0) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Obj.update(collection, (collection) => {
|
|
64
|
+
const from = findIndex(source.id);
|
|
65
|
+
if (from !== -1) {
|
|
66
|
+
arrayMove(collection.objects, from, insert);
|
|
67
|
+
}
|
|
84
68
|
});
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
[collection, findIndex],
|
|
72
|
+
);
|
|
85
73
|
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
const handleMoveUp = useCallback(
|
|
75
|
+
(id: string) => {
|
|
76
|
+
const index = findIndex(id);
|
|
77
|
+
if (index > 0) {
|
|
78
|
+
Obj.update(collection, (collection) => {
|
|
79
|
+
const [ref] = collection.objects.splice(index, 1);
|
|
80
|
+
collection.objects.splice(index - 1, 0, ref);
|
|
81
|
+
});
|
|
88
82
|
}
|
|
89
83
|
},
|
|
90
|
-
[collection,
|
|
84
|
+
[collection, findIndex],
|
|
91
85
|
);
|
|
92
86
|
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
collection,
|
|
103
|
-
},
|
|
104
|
-
});
|
|
87
|
+
const handleMoveDown = useCallback(
|
|
88
|
+
(id: string) => {
|
|
89
|
+
const index = findIndex(id);
|
|
90
|
+
if (index >= 0 && index < collection.objects.length - 1) {
|
|
91
|
+
Obj.update(collection, (collection) => {
|
|
92
|
+
const [ref] = collection.objects.splice(index, 1);
|
|
93
|
+
collection.objects.splice(index + 1, 0, ref);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
105
96
|
},
|
|
106
|
-
[collection,
|
|
97
|
+
[collection, findIndex],
|
|
107
98
|
);
|
|
108
99
|
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
const handleDelete = useCallback(
|
|
101
|
+
(id: string) => {
|
|
102
|
+
const index = findIndex(id);
|
|
103
|
+
if (index >= 0) {
|
|
104
|
+
Obj.update(collection, (collection) => {
|
|
105
|
+
collection.objects.splice(index, 1);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
112
108
|
},
|
|
113
|
-
[
|
|
109
|
+
[collection, findIndex],
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const handleAdd = useCallback(
|
|
113
|
+
(id: string) =>
|
|
114
|
+
invokePromise(SpaceOperation.OpenCreateObject, {
|
|
115
|
+
target: collection,
|
|
116
|
+
navigable: false,
|
|
117
|
+
// The created object is appended; move it to immediately after the originating section.
|
|
118
|
+
onCreateObject: (object: Obj.Unknown) => {
|
|
119
|
+
const from = findIndex(Obj.getURI(object));
|
|
120
|
+
const anchor = findIndex(id);
|
|
121
|
+
if (from >= 0 && anchor >= 0) {
|
|
122
|
+
Obj.update(collection, (collection) => {
|
|
123
|
+
const [ref] = collection.objects.splice(from, 1);
|
|
124
|
+
collection.objects.splice(anchor < from ? anchor + 1 : anchor, 0, ref);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
[collection, invokePromise, findIndex],
|
|
114
130
|
);
|
|
115
131
|
|
|
116
132
|
const handleCollapse = useCallback(
|
|
117
|
-
(id: string,
|
|
133
|
+
(id: string, value: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: value })),
|
|
118
134
|
[],
|
|
119
135
|
);
|
|
120
136
|
|
|
137
|
+
const handleCollapseAll = useCallback(
|
|
138
|
+
() => setCollapsedSections(Object.fromEntries(collectionObjects.map((object) => [Obj.getURI(object), true]))),
|
|
139
|
+
[collectionObjects],
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const handleExpandAll = useCallback(() => setCollapsedSections({}), []);
|
|
143
|
+
|
|
144
|
+
const optionsMenu = useMemo(
|
|
145
|
+
() => [
|
|
146
|
+
createMenuAction('collapse-all', handleCollapseAll, {
|
|
147
|
+
label: ['collapse-all.label', { ns: meta.profile.key }],
|
|
148
|
+
icon: 'ph--arrows-in-line-vertical--regular',
|
|
149
|
+
testId: 'stack.collapse-all',
|
|
150
|
+
}),
|
|
151
|
+
createMenuAction('expand-all', handleExpandAll, {
|
|
152
|
+
label: ['expand-all.label', { ns: meta.profile.key }],
|
|
153
|
+
icon: 'ph--arrows-out-line-vertical--regular',
|
|
154
|
+
testId: 'stack.expand-all',
|
|
155
|
+
}),
|
|
156
|
+
],
|
|
157
|
+
[handleCollapseAll, handleExpandAll],
|
|
158
|
+
);
|
|
159
|
+
|
|
121
160
|
const handleAddSection = useCallback(
|
|
122
161
|
() =>
|
|
123
162
|
invokePromise(SpaceOperation.OpenCreateObject, {
|
|
@@ -128,37 +167,60 @@ export const StackArticle = ({ attendableId, subject: collection }: StackArticle
|
|
|
128
167
|
);
|
|
129
168
|
|
|
130
169
|
return (
|
|
131
|
-
<
|
|
132
|
-
<Toolbar
|
|
133
|
-
<Toolbar.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
170
|
+
<Panel.Root>
|
|
171
|
+
<Panel.Toolbar classNames='bg-toolbar-surface'>
|
|
172
|
+
<Toolbar.Root classNames='dx-document'>
|
|
173
|
+
<Toolbar.IconButton
|
|
174
|
+
square
|
|
175
|
+
icon='ph--plus--regular'
|
|
176
|
+
iconOnly
|
|
177
|
+
label={t('add-section.label')}
|
|
178
|
+
data-testid='stack.addSection'
|
|
179
|
+
onClick={handleAddSection}
|
|
180
|
+
/>
|
|
181
|
+
<Toolbar.Separator />
|
|
182
|
+
<Menu.Root>
|
|
183
|
+
<Menu.Trigger asChild>
|
|
184
|
+
<Toolbar.IconButton
|
|
185
|
+
square
|
|
186
|
+
icon='ph--dots-three-vertical--regular'
|
|
187
|
+
iconOnly
|
|
188
|
+
label={t('options.label')}
|
|
189
|
+
data-testid='stack.options'
|
|
190
|
+
/>
|
|
191
|
+
</Menu.Trigger>
|
|
192
|
+
<Menu.Content items={optionsMenu} />
|
|
193
|
+
</Menu.Root>
|
|
194
|
+
</Toolbar.Root>
|
|
195
|
+
</Panel.Toolbar>
|
|
196
|
+
<Panel.Content>
|
|
197
|
+
<Stack.Root
|
|
153
198
|
id={Obj.getURI(collection)}
|
|
154
|
-
|
|
155
|
-
|
|
199
|
+
attendableId={attendableId}
|
|
200
|
+
collapsed={collapsed}
|
|
201
|
+
eventHandler={eventHandler}
|
|
202
|
+
onCollapse={handleCollapse}
|
|
203
|
+
onAdd={handleAdd}
|
|
204
|
+
onMoveUp={handleMoveUp}
|
|
205
|
+
onMoveDown={handleMoveDown}
|
|
206
|
+
onDelete={handleDelete}
|
|
156
207
|
>
|
|
157
|
-
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
208
|
+
<Stack.Content centered padding data-testid='main.stack'>
|
|
209
|
+
<Stack.Viewport>
|
|
210
|
+
<Mosaic.Stack classNames='dx-document' items={items} getId={getId} Tile={Stack.Section} />
|
|
211
|
+
</Stack.Viewport>
|
|
212
|
+
</Stack.Content>
|
|
213
|
+
</Stack.Root>
|
|
214
|
+
</Panel.Content>
|
|
215
|
+
</Panel.Root>
|
|
163
216
|
);
|
|
164
217
|
};
|
|
218
|
+
|
|
219
|
+
const getId = (item: StackSectionItem) => item.id;
|
|
220
|
+
|
|
221
|
+
const createCollectionObjects = Atom.family((collection: Collection.Collection) =>
|
|
222
|
+
Atom.make((get) => {
|
|
223
|
+
const snapshot = get(Obj.atom(collection));
|
|
224
|
+
return snapshot.objects.map((ref) => get(Obj.atomReactive(ref))).filter(isNonNullable);
|
|
225
|
+
}),
|
|
226
|
+
);
|
package/src/translations.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
|
-
import { translations as stackTranslations } from '@dxos/react-ui-stack/translations';
|
|
7
6
|
|
|
8
7
|
import { meta } from '#meta';
|
|
9
8
|
|
|
@@ -12,7 +11,6 @@ export const translations = [
|
|
|
12
11
|
'en-US': {
|
|
13
12
|
[meta.profile.key]: {
|
|
14
13
|
'plugin.name': 'Stacks',
|
|
15
|
-
'settings.title': 'Stack settings',
|
|
16
14
|
'settings.separation.label': 'Separate sections',
|
|
17
15
|
'settings.separation.description': 'Add visual dividers between sections in stacks.',
|
|
18
16
|
'add-section-beforeAll-dialog.title': 'Add a section to the start',
|
|
@@ -26,14 +24,16 @@ export const translations = [
|
|
|
26
24
|
'remove-section.label': 'Delete',
|
|
27
25
|
'navigate-to-section.label': 'Navigate to object',
|
|
28
26
|
'untitled-section.title': 'Untitled section',
|
|
29
|
-
'
|
|
30
|
-
'
|
|
27
|
+
'move-up.label': 'Move up',
|
|
28
|
+
'move-down.label': 'Move down',
|
|
31
29
|
'expand.label': 'Expand',
|
|
32
30
|
'collapse.label': 'Collapse',
|
|
31
|
+
'collapse-all.label': 'Collapse all',
|
|
32
|
+
'expand-all.label': 'Expand all',
|
|
33
|
+
'options.label': 'Options',
|
|
33
34
|
'open-chat-thread.label': 'Open chat thread',
|
|
34
35
|
'drag-handle.label': 'Press space or enter to begin dragging this object.',
|
|
35
36
|
},
|
|
36
37
|
},
|
|
37
38
|
},
|
|
38
|
-
...stackTranslations,
|
|
39
39
|
] as const satisfies Resource[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
|
|
9
|
+
import { DXN, Type } from '@dxos/echo';
|
|
10
|
+
|
|
11
|
+
// TODO(burdon): Placeholder.
|
|
12
|
+
export class Stack extends Type.makeObject<Stack>(DXN.make('org.dxos.type.stack', '0.1.0'))(Schema.Struct({})) {}
|
package/src/types/index.ts
CHANGED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
// src/containers/StackArticle/StackArticle.tsx
|
|
2
|
-
import { Atom, useAtomValue } from "@effect-atom/atom-react";
|
|
3
|
-
import * as Option from "effect/Option";
|
|
4
|
-
import React, { useCallback, useState } from "react";
|
|
5
|
-
import { useOperationInvoker } from "@dxos/app-framework/ui";
|
|
6
|
-
import { LayoutOperation } from "@dxos/app-toolkit";
|
|
7
|
-
import { useAppGraph } from "@dxos/app-toolkit/ui";
|
|
8
|
-
import { Obj } from "@dxos/echo";
|
|
9
|
-
import { Graph } from "@dxos/plugin-graph";
|
|
10
|
-
import { SpaceOperation } from "@dxos/plugin-space";
|
|
11
|
-
import { Toolbar, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
12
|
-
import { Stack, StackItem } from "@dxos/react-ui-stack";
|
|
13
|
-
import { isNonNullable } from "@dxos/util";
|
|
14
|
-
import { StackContext, StackSection } from "#components";
|
|
15
|
-
import { meta } from "#meta";
|
|
16
|
-
var collectionObjectsFamily = Atom.family((collection) => Atom.make((get) => {
|
|
17
|
-
const snapshot = get(Obj.atom(collection));
|
|
18
|
-
return snapshot.objects.map((ref) => get(Obj.atomReactive(ref))).filter(isNonNullable);
|
|
19
|
-
}));
|
|
20
|
-
var StackArticle = ({ attendableId, subject: collection }) => {
|
|
21
|
-
const { invokePromise } = useOperationInvoker();
|
|
22
|
-
const { graph } = useAppGraph();
|
|
23
|
-
const { t } = useTranslation(meta.profile.key);
|
|
24
|
-
const [collapsedSections, setCollapsedSections] = useState({});
|
|
25
|
-
const collectionObjects = useAtomValue(collectionObjectsFamily(collection));
|
|
26
|
-
const items = collectionObjects.map((object) => {
|
|
27
|
-
const iconAnnotation = Obj.getIcon(object);
|
|
28
|
-
const metadata = {
|
|
29
|
-
icon: iconAnnotation?.icon
|
|
30
|
-
};
|
|
31
|
-
const view = {
|
|
32
|
-
// ...stack.sections[object.id],
|
|
33
|
-
collapsed: collapsedSections[Obj.getURI(object)],
|
|
34
|
-
title: object?.title ?? // TODO(wittjosiah): `getNode` is not reactive.
|
|
35
|
-
toLocalizedString(Graph.getNode(graph, Obj.getURI(object)).pipe(Option.getOrNull)?.properties.label, t)
|
|
36
|
-
};
|
|
37
|
-
return {
|
|
38
|
-
id: Obj.getURI(object),
|
|
39
|
-
object,
|
|
40
|
-
metadata,
|
|
41
|
-
view
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
const handleDelete = useCallback(async (id) => {
|
|
45
|
-
const index = collection.objects.map((object2) => object2.target).filter(isNonNullable).findIndex((section) => Obj.getURI(section) === id);
|
|
46
|
-
const object = collection.objects[index].target;
|
|
47
|
-
if (Obj.isObject(object)) {
|
|
48
|
-
await invokePromise(SpaceOperation.RemoveObjects, {
|
|
49
|
-
objects: [
|
|
50
|
-
object
|
|
51
|
-
],
|
|
52
|
-
target: collection
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}, [
|
|
56
|
-
collection,
|
|
57
|
-
invokePromise
|
|
58
|
-
]);
|
|
59
|
-
const handleAdd = useCallback(async (id, position) => {
|
|
60
|
-
await invokePromise(LayoutOperation.UpdateDialog, {
|
|
61
|
-
subject: `${meta.profile.key}.AddSectionDialog`,
|
|
62
|
-
blockAlign: "start",
|
|
63
|
-
props: {
|
|
64
|
-
path: id,
|
|
65
|
-
position,
|
|
66
|
-
collection
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}, [
|
|
70
|
-
collection,
|
|
71
|
-
invokePromise
|
|
72
|
-
]);
|
|
73
|
-
const handleNavigate = useCallback(async (id) => {
|
|
74
|
-
await invokePromise(LayoutOperation.Open, {
|
|
75
|
-
subject: [
|
|
76
|
-
id
|
|
77
|
-
]
|
|
78
|
-
});
|
|
79
|
-
}, [
|
|
80
|
-
invokePromise
|
|
81
|
-
]);
|
|
82
|
-
const handleCollapse = useCallback((id, collapsed) => setCollapsedSections((prev) => ({
|
|
83
|
-
...prev,
|
|
84
|
-
[id]: collapsed
|
|
85
|
-
})), []);
|
|
86
|
-
const handleAddSection = useCallback(() => invokePromise(SpaceOperation.OpenCreateObject, {
|
|
87
|
-
target: collection,
|
|
88
|
-
navigable: false
|
|
89
|
-
}), [
|
|
90
|
-
collection,
|
|
91
|
-
invokePromise
|
|
92
|
-
]);
|
|
93
|
-
return /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
94
|
-
toolbar: true,
|
|
95
|
-
classNames: "dx-document"
|
|
96
|
-
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
|
|
97
|
-
icon: "ph--plus--regular",
|
|
98
|
-
iconOnly: true,
|
|
99
|
-
label: "Add section",
|
|
100
|
-
"data-testid": "stack.addSection",
|
|
101
|
-
onClick: handleAddSection
|
|
102
|
-
})), /* @__PURE__ */ React.createElement(StackContext.Provider, {
|
|
103
|
-
value: {
|
|
104
|
-
attendableId,
|
|
105
|
-
onCollapse: handleCollapse,
|
|
106
|
-
onNavigate: handleNavigate,
|
|
107
|
-
onDelete: handleDelete,
|
|
108
|
-
onAdd: handleAdd
|
|
109
|
-
}
|
|
110
|
-
}, /* @__PURE__ */ React.createElement(Stack, {
|
|
111
|
-
orientation: "vertical",
|
|
112
|
-
size: "intrinsic",
|
|
113
|
-
id: Obj.getURI(collection),
|
|
114
|
-
"data-testid": "main.stack",
|
|
115
|
-
classNames: "overflow-y-auto"
|
|
116
|
-
}, items.map((item) => /* @__PURE__ */ React.createElement(StackSection, {
|
|
117
|
-
key: item.id,
|
|
118
|
-
...item
|
|
119
|
-
})))));
|
|
120
|
-
};
|
|
121
|
-
export {
|
|
122
|
-
StackArticle as default
|
|
123
|
-
};
|
|
124
|
-
//# sourceMappingURL=StackArticle-SBM3FBJM.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/containers/StackArticle/StackArticle.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Atom, useAtomValue } from '@effect-atom/atom-react';\nimport * as Option from 'effect/Option';\nimport React, { useCallback, useState } from 'react';\n\nimport { useOperationInvoker } from '@dxos/app-framework/ui';\nimport { LayoutOperation } from '@dxos/app-toolkit';\nimport { useAppGraph, type AppSurface } from '@dxos/app-toolkit/ui';\nimport { type Collection, Obj, type Ref } from '@dxos/echo';\nimport { Graph } from '@dxos/plugin-graph';\nimport { SpaceOperation } from '@dxos/plugin-space';\nimport { Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';\nimport { Stack, StackItem } from '@dxos/react-ui-stack';\nimport { isNonNullable } from '@dxos/util';\n\nimport { StackContext, StackSection } from '#components';\nimport { meta } from '#meta';\nimport {\n type AddSectionPosition,\n type CollapsedSections,\n type StackSectionItem,\n type StackSectionMetadata,\n type StackSectionView,\n} from '#types';\n\nconst collectionObjectsFamily = Atom.family((collection: Collection.Collection) =>\n Atom.make((get) => {\n const snapshot = get(Obj.atom(collection));\n return (\n snapshot.objects\n // TODO(wittjosiah): Why isn't this type inferred correctly?\n .map((ref: Ref.Ref<Obj.Unknown>) => get(Obj.atomReactive(ref)))\n .filter(isNonNullable)\n );\n }),\n);\n\ntype StackArticleProps = AppSurface.ObjectArticleProps<Collection.Collection>;\n\nexport const StackArticle = ({ attendableId, subject: collection }: StackArticleProps) => {\n const { invokePromise } = useOperationInvoker();\n const { graph } = useAppGraph();\n const { t } = useTranslation(meta.profile.key);\n const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});\n\n // TODO(wittjosiah): Re-implement stack views with relations.\n // const defaultStack = useMemo(() => Obj.make(StackViewType, { sections: {} }), [collection]);\n // const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;\n // useEffect(() => {\n // if (!collection.views[StackViewType.typename]) {\n // collection.views[StackViewType.typename] = Ref.make(stack);\n // }\n // }, [collection, stack]);\n\n const collectionObjects = useAtomValue(collectionObjectsFamily(collection));\n const items = collectionObjects.map((object: Obj.Unknown) => {\n const iconAnnotation = Obj.getIcon(object);\n const metadata: StackSectionMetadata = { icon: iconAnnotation?.icon };\n const view = {\n // ...stack.sections[object.id],\n collapsed: collapsedSections[Obj.getURI(object)],\n title:\n (object as any)?.title ??\n // TODO(wittjosiah): `getNode` is not reactive.\n toLocalizedString(Graph.getNode(graph, Obj.getURI(object)).pipe(Option.getOrNull)?.properties.label, t),\n } as StackSectionView;\n return { id: Obj.getURI(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) => Obj.getURI(section) === id);\n const object = collection.objects[index].target;\n if (Obj.isObject(object)) {\n await invokePromise(SpaceOperation.RemoveObjects, {\n objects: [object],\n target: 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 [collection, invokePromise],\n );\n\n const handleAdd = useCallback(\n async (id: string, position: AddSectionPosition) => {\n // TODO(wittjosiah): Use object creation dialog.\n await invokePromise(LayoutOperation.UpdateDialog, {\n subject: `${meta.profile.key}.AddSectionDialog`,\n blockAlign: 'start',\n props: {\n path: id,\n position,\n collection,\n },\n });\n },\n [collection, invokePromise],\n );\n\n const handleNavigate = useCallback(\n async (id: string) => {\n await invokePromise(LayoutOperation.Open, { subject: [id] });\n },\n [invokePromise],\n );\n\n const handleCollapse = useCallback(\n (id: string, collapsed: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: collapsed })),\n [],\n );\n\n const handleAddSection = useCallback(\n () =>\n invokePromise(SpaceOperation.OpenCreateObject, {\n target: collection,\n navigable: false,\n }),\n [collection, invokePromise],\n );\n\n return (\n <StackItem.Content toolbar classNames='dx-document'>\n <Toolbar.Root>\n <Toolbar.IconButton\n icon='ph--plus--regular'\n iconOnly\n label='Add section'\n data-testid='stack.addSection'\n onClick={handleAddSection}\n />\n </Toolbar.Root>\n <StackContext.Provider\n value={{\n attendableId,\n onCollapse: handleCollapse,\n onNavigate: handleNavigate,\n onDelete: handleDelete,\n onAdd: handleAdd,\n }}\n >\n <Stack\n orientation='vertical'\n size='intrinsic'\n id={Obj.getURI(collection)}\n data-testid='main.stack'\n classNames='overflow-y-auto'\n >\n {items.map((item) => (\n <StackSection key={item.id} {...item} />\n ))}\n </Stack>\n </StackContext.Provider>\n </StackItem.Content>\n );\n};\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["Atom", "useAtomValue", "Option", "React", "useCallback", "useState", "useOperationInvoker", "LayoutOperation", "useAppGraph", "Obj", "Graph", "SpaceOperation", "Toolbar", "toLocalizedString", "useTranslation", "Stack", "StackItem", "isNonNullable", "StackContext", "StackSection", "meta", "collectionObjectsFamily", "family", "collection", "make", "get", "snapshot", "atom", "objects", "map", "ref", "atomReactive", "filter", "StackArticle", "attendableId", "subject", "invokePromise", "graph", "t", "profile", "key", "collapsedSections", "setCollapsedSections", "collectionObjects", "items", "object", "iconAnnotation", "getIcon", "metadata", "icon", "view", "collapsed", "getURI", "title", "getNode", "pipe", "getOrNull", "properties", "label", "id", "handleDelete", "index", "target", "findIndex", "section", "isObject", "RemoveObjects", "handleAdd", "position", "UpdateDialog", "blockAlign", "props", "path", "handleNavigate", "Open", "handleCollapse", "prev", "handleAddSection", "OpenCreateObject", "navigable", "Content", "toolbar", "classNames", "Root", "IconButton", "iconOnly", "data-testid", "onClick", "Provider", "value", "onCollapse", "onNavigate", "onDelete", "onAdd", "orientation", "size", "item"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts", "../../../dx.config.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { DXN } from '@dxos/keys';\n\nimport config from '../dx.config';\n\nexport const SECTION_IDENTIFIER = DXN.make('org.dxos.type.stackSection');\n\nexport const meta = Plugin.getMetaFromConfig(config);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Config2 } from '@dxos/app-framework/config';\nimport { trim } from '@dxos/util';\n\nexport default Config2.make({\n plugin: {\n key: 'org.dxos.plugin.stack',\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 author: 'DXOS',\n description: trim`\n StackPlugin renders any Collection object as a vertically scrollable stack of collapsible sections in the\n Composer article surface. Each section wraps an arbitrary ECHO object and delegates its content rendering\n to the section surface role, enabling any other plugin to contribute its own section renderer.\n\n Sections can be individually collapsed to show only their title, expanded to reveal full content, navigated\n to directly, or removed from the collection. New sections can be inserted before or after any existing\n section via a per-section dropdown menu, or appended via the toolbar Add button.\n\n The plugin registers StackViewType with the ECHO schema module so that per-section view metadata\n (height overrides, custom display data) can be stored and replicated alongside the collection.\n\n A settings panel exposes a separation toggle that controls whether visual dividers are rendered between\n sections.\n `,\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-stack',\n icon: { key: 'ph--stack-simple--regular' },\n spec: 'PLUGIN.mdl',\n },\n});\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,cAAc;AACvB,SAASC,WAAW;;;ACDpB,SAASC,eAAe;AACxB,SAASC,YAAY;AAErB,IAAA,oBAAeD,QAAQE,KAAK;EAC1BC,QAAQ;IACNC,KAAK;;;IAGLC,MAAM;IACNC,QAAQ;IACRC,aAAaN;;;;;;;;;;;;;;;IAebO,QAAQ;IACRC,MAAM;MAAEL,KAAK;IAA4B;IACzCM,MAAM;EACR;AACF,CAAA;;;ADxBO,IAAMC,qBAAqBC,IAAIC,KAAK,4BAAA;AAEpC,IAAMC,OAAOC,OAAOC,kBAAkBC,iBAAAA;",
|
|
6
|
-
"names": ["Plugin", "DXN", "Config2", "trim", "make", "plugin", "key", "name", "author", "description", "source", "icon", "spec", "SECTION_IDENTIFIER", "DXN", "make", "meta", "Plugin", "getMetaFromConfig", "config"]
|
|
7
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// src/types/stack.ts
|
|
2
|
-
import * as Schema from "effect/Schema";
|
|
3
|
-
import { DXN, Type } from "@dxos/echo";
|
|
4
|
-
var SectionSchema = Schema.Struct({
|
|
5
|
-
height: Schema.optional(Schema.Number),
|
|
6
|
-
// Space for data that isn't stack-specific but is specific to this view instance.
|
|
7
|
-
// e.g. cover/fill for an image
|
|
8
|
-
custom: Schema.optional(Schema.Record({
|
|
9
|
-
key: Schema.String,
|
|
10
|
-
value: Schema.Any
|
|
11
|
-
}))
|
|
12
|
-
});
|
|
13
|
-
var StackViewType = Schema.Struct({
|
|
14
|
-
sections: Schema.Record({
|
|
15
|
-
key: Schema.String,
|
|
16
|
-
value: SectionSchema
|
|
17
|
-
})
|
|
18
|
-
}).pipe(Type.makeObject(DXN.make("org.dxos.type.stackView", "0.1.0")));
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
SectionSchema,
|
|
22
|
-
StackViewType
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=chunk-T4NSFSPH.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/stack.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { DXN, Type } from '@dxos/echo';\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 = Schema.Struct({\n height: Schema.optional(Schema.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: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n});\n\n// TODO(wittjosiah): This needs a relation to be connected to a stack.\nexport const StackViewType = Schema.Struct({\n sections: Schema.Record({ key: Schema.String, value: SectionSchema }),\n}).pipe(Type.makeObject(DXN.make('org.dxos.type.stackView', '0.1.0')));\n\nexport type StackViewType = Type.InstanceType<typeof StackViewType>;\n"],
|
|
5
|
-
"mappings": ";AAIA,YAAYA,YAAY;AAExB,SAASC,KAAKC,YAAY;AAOnB,IAAMC,gBAAuBC,cAAO;EACzCC,QAAeC,gBAAgBC,aAAM;;;EAGrCC,QAAeF,gBAAgBG,cAAO;IAAEC,KAAYC;IAAQC,OAAcC;EAAI,CAAA,CAAA;AAChF,CAAA;AAGO,IAAMC,gBAAuBV,cAAO;EACzCW,UAAiBN,cAAO;IAAEC,KAAYC;IAAQC,OAAOT;EAAc,CAAA;AACrE,CAAA,EAAGa,KAAKd,KAAKe,WAAWhB,IAAIiB,KAAK,2BAA2B,OAAA,CAAA,CAAA;",
|
|
6
|
-
"names": ["Schema", "DXN", "Type", "SectionSchema", "Struct", "height", "optional", "Number", "custom", "Record", "key", "String", "value", "Any", "StackViewType", "sections", "pipe", "makeObject", "make"]
|
|
7
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type AddSectionPosition } from '#types';
|
|
2
|
-
export type StackContextValue = {
|
|
3
|
-
attendableId: string;
|
|
4
|
-
onCollapse: (id: string, collapsed: boolean) => void;
|
|
5
|
-
onNavigate: (id: string) => Promise<void>;
|
|
6
|
-
onDelete: (id: string) => Promise<void>;
|
|
7
|
-
onAdd: (id: string, position: AddSectionPosition) => void;
|
|
8
|
-
};
|
|
9
|
-
export declare const StackContext: import("react").Context<StackContextValue>;
|
|
10
|
-
export declare const useStack: () => StackContextValue;
|
|
11
|
-
//# sourceMappingURL=StackContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StackContext.d.ts","sourceRoot":"","sources":["../../../../../src/components/StackContext/StackContext.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACrD,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAC3D,CAAC;AAEF,eAAO,MAAM,YAAY,4CAMvB,CAAC;AAEH,eAAO,MAAM,QAAQ,yBAAiC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/StackContext/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CaretDownUp.d.ts","sourceRoot":"","sources":["../../../../../src/components/StackSection/CaretDownUp.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAE7D,eAAO,MAAM,WAAW,2BAA4B,wBAAwB,CAAC,KAAK,CAAC,sBAuBlF,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type StackSectionItem } from '#types';
|
|
3
|
-
export type StackSectionProps = StackSectionItem;
|
|
4
|
-
export declare const StackSection: ({ id, view, object, metadata: { icon }, }: StackSectionProps) => React.JSX.Element;
|
|
5
|
-
//# sourceMappingURL=StackSection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StackSection.d.ts","sourceRoot":"","sources":["../../../../../src/components/StackSection/StackSection.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAWjD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAO/C,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAEjD,eAAO,MAAM,YAAY,8CAKtB,iBAAiB,sBA6FnB,CAAC"}
|