@dxos/plugin-stack 0.8.4-main.70d3990 → 0.8.4-main.7996785055
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/StackContainer-YNTG5L56.mjs +289 -0
- package/dist/lib/browser/StackContainer-YNTG5L56.mjs.map +7 -0
- package/dist/lib/browser/{chunk-UIKFKRFJ.mjs → chunk-G4CLPE5A.mjs} +3 -3
- package/dist/lib/browser/chunk-G4CLPE5A.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NHMDZYOB.mjs → chunk-YPQYUBQP.mjs} +9 -10
- package/dist/lib/browser/chunk-YPQYUBQP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +35 -50
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-ABL3K6Z6.mjs +33 -0
- package/dist/lib/browser/react-surface-ABL3K6Z6.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/StackContainer-DBMMOHAH.mjs +290 -0
- package/dist/lib/node-esm/StackContainer-DBMMOHAH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZZFA7HIV.mjs → chunk-LELGTQAL.mjs} +9 -10
- package/dist/lib/node-esm/chunk-LELGTQAL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-BGVQYUYP.mjs → chunk-LOZ6GH5A.mjs} +3 -3
- package/dist/lib/node-esm/chunk-LOZ6GH5A.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +35 -50
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-DB42KXY3.mjs +34 -0
- package/dist/lib/node-esm/react-surface-DB42KXY3.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/StackPlugin.d.ts +2 -1
- package/dist/types/src/StackPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/{StackContext.d.ts → StackContext/StackContext.d.ts} +2 -1
- package/dist/types/src/components/StackContext/StackContext.d.ts.map +1 -0
- package/dist/types/src/components/StackContext/index.d.ts +2 -0
- package/dist/types/src/components/StackContext/index.d.ts.map +1 -0
- package/dist/types/src/components/StackSection/CaretDownUp.d.ts.map +1 -0
- package/dist/types/src/components/{StackSection.d.ts → StackSection/StackSection.d.ts} +1 -1
- package/dist/types/src/components/StackSection/StackSection.d.ts.map +1 -0
- package/dist/types/src/components/StackSection/index.d.ts +2 -0
- package/dist/types/src/components/StackSection/index.d.ts.map +1 -0
- package/dist/types/src/components/{StackSettings.d.ts → StackSettings/StackSettings.d.ts} +1 -1
- package/dist/types/src/components/StackSettings/StackSettings.d.ts.map +1 -0
- package/dist/types/src/components/StackSettings/index.d.ts +2 -0
- package/dist/types/src/components/StackSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -7
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/StackContainer/StackContainer.d.ts +7 -0
- package/dist/types/src/containers/StackContainer/StackContainer.d.ts.map +1 -0
- package/dist/types/src/containers/StackContainer/index.d.ts +3 -0
- package/dist/types/src/containers/StackContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +3 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -1
- package/dist/types/src/types/stack.d.ts +12 -13
- package/dist/types/src/types/stack.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -2
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +42 -36
- package/src/StackPlugin.ts +23 -38
- package/src/capabilities/index.ts +1 -3
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +31 -0
- package/src/components/{StackContext.tsx → StackContext/StackContext.tsx} +3 -1
- package/src/components/StackContext/index.ts +5 -0
- package/src/components/{StackSection.tsx → StackSection/StackSection.tsx} +24 -22
- package/src/components/StackSection/index.ts +5 -0
- package/src/components/StackSettings/StackSettings.tsx +30 -0
- package/src/components/StackSettings/index.ts +5 -0
- package/src/components/index.ts +2 -4
- package/src/containers/StackContainer/StackContainer.tsx +171 -0
- package/src/containers/StackContainer/index.ts +7 -0
- package/src/containers/index.ts +7 -0
- package/src/meta.ts +4 -4
- package/src/types/stack.ts +11 -7
- package/src/types/types.ts +2 -2
- package/dist/lib/browser/StackContainer-DD3ZD5OE.mjs +0 -299
- package/dist/lib/browser/StackContainer-DD3ZD5OE.mjs.map +0 -7
- package/dist/lib/browser/chunk-NHMDZYOB.mjs.map +0 -7
- package/dist/lib/browser/chunk-UIKFKRFJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-HVPK7YZQ.mjs +0 -39
- package/dist/lib/browser/react-surface-HVPK7YZQ.mjs.map +0 -7
- package/dist/lib/node-esm/StackContainer-JGWPXSUF.mjs +0 -300
- package/dist/lib/node-esm/StackContainer-JGWPXSUF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BGVQYUYP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZZFA7HIV.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-HYSD7AC2.mjs +0 -40
- package/dist/lib/node-esm/react-surface-HYSD7AC2.mjs.map +0 -7
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/CaretDownUp.d.ts.map +0 -1
- package/dist/types/src/components/StackContainer.d.ts +0 -9
- package/dist/types/src/components/StackContainer.d.ts.map +0 -1
- package/dist/types/src/components/StackContext.d.ts.map +0 -1
- package/dist/types/src/components/StackSection.d.ts.map +0 -1
- package/dist/types/src/components/StackSettings.d.ts.map +0 -1
- package/src/capabilities/react-surface.tsx +0 -29
- package/src/components/StackContainer.tsx +0 -172
- package/src/components/StackSettings.tsx +0 -30
- /package/dist/types/src/components/{CaretDownUp.d.ts → StackSection/CaretDownUp.d.ts} +0 -0
- /package/src/components/{CaretDownUp.tsx → StackSection/CaretDownUp.tsx} +0 -0
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Option from 'effect/Option';
|
|
6
|
-
import React, { useCallback, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
import { Capabilities, LayoutAction, createIntent } from '@dxos/app-framework';
|
|
9
|
-
import { useAppGraph, useCapabilities, useIntentDispatcher } from '@dxos/app-framework/react';
|
|
10
|
-
import { isLiveObject } from '@dxos/client/echo';
|
|
11
|
-
import { Obj } from '@dxos/echo';
|
|
12
|
-
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
13
|
-
import { Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
14
|
-
import { AttentionProvider } from '@dxos/react-ui-attention';
|
|
15
|
-
import { Stack, StackItem } from '@dxos/react-ui-stack';
|
|
16
|
-
import { type Collection } from '@dxos/schema';
|
|
17
|
-
import { isNonNullable } from '@dxos/util';
|
|
18
|
-
|
|
19
|
-
import { meta } from '../meta';
|
|
20
|
-
import {
|
|
21
|
-
type AddSectionPosition,
|
|
22
|
-
type CollapsedSections,
|
|
23
|
-
type StackSectionItem,
|
|
24
|
-
type StackSectionMetadata,
|
|
25
|
-
type StackSectionView,
|
|
26
|
-
} from '../types';
|
|
27
|
-
|
|
28
|
-
import { StackContext } from './StackContext';
|
|
29
|
-
import { StackSection } from './StackSection';
|
|
30
|
-
|
|
31
|
-
type StackContainerProps = {
|
|
32
|
-
id: string;
|
|
33
|
-
collection: Collection.Collection;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const StackContainer = ({ id, collection }: StackContainerProps) => {
|
|
37
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
38
|
-
const { graph } = useAppGraph();
|
|
39
|
-
const { t } = useTranslation(meta.id);
|
|
40
|
-
const allMetadata = useCapabilities(Capabilities.Metadata);
|
|
41
|
-
const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});
|
|
42
|
-
|
|
43
|
-
// TODO(wittjosiah): Re-implement stack views with relations.
|
|
44
|
-
// const defaultStack = useMemo(() => Obj.make(StackViewType, { sections: {} }), [collection]);
|
|
45
|
-
// const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;
|
|
46
|
-
// useEffect(() => {
|
|
47
|
-
// if (!collection.views[StackViewType.typename]) {
|
|
48
|
-
// collection.views[StackViewType.typename] = Ref.make(stack);
|
|
49
|
-
// }
|
|
50
|
-
// }, [collection, stack]);
|
|
51
|
-
|
|
52
|
-
const items =
|
|
53
|
-
collection.objects
|
|
54
|
-
// TODO(wittjosiah): Should the database handle this differently?
|
|
55
|
-
// TODO(wittjosiah): Render placeholders for missing objects so they can be removed from the stack?
|
|
56
|
-
.map((object) => object.target)
|
|
57
|
-
.filter(isNonNullable)
|
|
58
|
-
.map((object) => {
|
|
59
|
-
const metadata = allMetadata.find((m) => m.id === (Obj.getTypename(object) ?? 'never'))
|
|
60
|
-
?.metadata as StackSectionMetadata;
|
|
61
|
-
const view = {
|
|
62
|
-
// ...stack.sections[object.id],
|
|
63
|
-
collapsed: collapsedSections[Obj.getDXN(object).toString()],
|
|
64
|
-
title:
|
|
65
|
-
(object as any)?.title ??
|
|
66
|
-
// TODO(wittjosiah): `getNode` is not reactive.
|
|
67
|
-
toLocalizedString(graph.getNode(Obj.getDXN(object).toString()).pipe(Option.getOrNull)?.properties.label, t),
|
|
68
|
-
} as StackSectionView;
|
|
69
|
-
return { id: Obj.getDXN(object).toString(), object, metadata, view } satisfies StackSectionItem;
|
|
70
|
-
}) ?? [];
|
|
71
|
-
|
|
72
|
-
const handleDelete = useCallback(
|
|
73
|
-
async (id: string) => {
|
|
74
|
-
const index = collection.objects
|
|
75
|
-
.map((object) => object.target)
|
|
76
|
-
.filter(isNonNullable)
|
|
77
|
-
.findIndex((section) => Obj.getDXN(section).toString() === id);
|
|
78
|
-
const object = collection.objects[index].target;
|
|
79
|
-
if (isLiveObject(object)) {
|
|
80
|
-
await dispatch(
|
|
81
|
-
createIntent(SpaceAction.RemoveObjects, {
|
|
82
|
-
objects: [object],
|
|
83
|
-
target: collection,
|
|
84
|
-
}),
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
// TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.
|
|
88
|
-
// delete stack.sections[Path.last(path)];
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
[collection, dispatch],
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
const handleAdd = useCallback(
|
|
95
|
-
async (id: string, position: AddSectionPosition) => {
|
|
96
|
-
await dispatch?.(
|
|
97
|
-
// TODO(wittjosiah): Use object creation dialog.
|
|
98
|
-
createIntent(LayoutAction.UpdateDialog, {
|
|
99
|
-
part: 'dialog',
|
|
100
|
-
subject: `${meta.id}/AddSectionDialog`,
|
|
101
|
-
options: {
|
|
102
|
-
blockAlign: 'start',
|
|
103
|
-
props: {
|
|
104
|
-
path: id,
|
|
105
|
-
position,
|
|
106
|
-
collection,
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
}),
|
|
110
|
-
);
|
|
111
|
-
},
|
|
112
|
-
[collection, dispatch],
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
const handleNavigate = useCallback(
|
|
116
|
-
async (id: string) => {
|
|
117
|
-
await dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [id] }));
|
|
118
|
-
},
|
|
119
|
-
[dispatch],
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
const handleCollapse = useCallback(
|
|
123
|
-
(id: string, collapsed: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: collapsed })),
|
|
124
|
-
[],
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const handleAddSection = useCallback(
|
|
128
|
-
() =>
|
|
129
|
-
dispatch?.(
|
|
130
|
-
createIntent(SpaceAction.OpenCreateObject, {
|
|
131
|
-
target: collection,
|
|
132
|
-
navigable: false,
|
|
133
|
-
}),
|
|
134
|
-
),
|
|
135
|
-
[collection, dispatch],
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
return (
|
|
139
|
-
<StackItem.Content
|
|
140
|
-
toolbar
|
|
141
|
-
classNames='container-max-width overflow-hidden border-l border-r border-subduedSeparator'
|
|
142
|
-
>
|
|
143
|
-
<Toolbar.Root>
|
|
144
|
-
<Toolbar.IconButton
|
|
145
|
-
icon='ph--plus--regular'
|
|
146
|
-
iconOnly
|
|
147
|
-
label='Add section'
|
|
148
|
-
data-testid='stack.addSection'
|
|
149
|
-
onClick={handleAddSection}
|
|
150
|
-
/>
|
|
151
|
-
</Toolbar.Root>
|
|
152
|
-
<AttentionProvider id={id}>
|
|
153
|
-
<StackContext.Provider
|
|
154
|
-
value={{
|
|
155
|
-
onCollapse: handleCollapse,
|
|
156
|
-
onNavigate: handleNavigate,
|
|
157
|
-
onDelete: handleDelete,
|
|
158
|
-
onAdd: handleAdd,
|
|
159
|
-
}}
|
|
160
|
-
>
|
|
161
|
-
<Stack orientation='vertical' size='intrinsic' id={id} data-testid='main.stack' classNames='overflow-y-auto'>
|
|
162
|
-
{items.map((item) => (
|
|
163
|
-
<StackSection key={item.id} {...item} />
|
|
164
|
-
))}
|
|
165
|
-
</Stack>
|
|
166
|
-
</StackContext.Provider>
|
|
167
|
-
</AttentionProvider>
|
|
168
|
-
</StackItem.Content>
|
|
169
|
-
);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
export default StackContainer;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { Input, useTranslation } from '@dxos/react-ui';
|
|
8
|
-
import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from '@dxos/react-ui-form';
|
|
9
|
-
|
|
10
|
-
import { meta } from '../meta';
|
|
11
|
-
import { type StackSettingsProps } from '../types';
|
|
12
|
-
|
|
13
|
-
export const StackSettings = ({ settings }: { settings: StackSettingsProps }) => {
|
|
14
|
-
const { t } = useTranslation(meta.id);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<ControlPage>
|
|
18
|
-
<ControlSection title={t('settings title', { ns: meta.id })}>
|
|
19
|
-
<ControlGroup>
|
|
20
|
-
<ControlItemInput title={t('settings separation label')}>
|
|
21
|
-
<Input.Switch
|
|
22
|
-
checked={settings.separation}
|
|
23
|
-
onCheckedChange={(checked) => (settings.separation = !!checked)}
|
|
24
|
-
/>
|
|
25
|
-
</ControlItemInput>
|
|
26
|
-
</ControlGroup>
|
|
27
|
-
</ControlSection>
|
|
28
|
-
</ControlPage>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
File without changes
|
|
File without changes
|