@dxos/plugin-stack 0.8.4-main.c1de068 → 0.8.4-main.c351d160a8
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-RE6RUEUV.mjs +294 -0
- package/dist/lib/browser/StackContainer-RE6RUEUV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FVB7LGW7.mjs → chunk-G4CLPE5A.mjs} +8 -6
- package/dist/lib/browser/chunk-G4CLPE5A.mjs.map +7 -0
- package/dist/lib/browser/{chunk-IRTROCUQ.mjs → chunk-YPQYUBQP.mjs} +10 -11
- package/dist/lib/browser/chunk-YPQYUBQP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +39 -55
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-FZ42XC67.mjs +33 -0
- package/dist/lib/browser/react-surface-FZ42XC67.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/StackContainer-OPQ76B4H.mjs +295 -0
- package/dist/lib/node-esm/StackContainer-OPQ76B4H.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LRAZXJ65.mjs → chunk-LELGTQAL.mjs} +10 -11
- package/dist/lib/node-esm/chunk-LELGTQAL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UN5PA7TK.mjs → chunk-LOZ6GH5A.mjs} +8 -6
- package/dist/lib/node-esm/chunk-LOZ6GH5A.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +39 -55
- 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-CYNJK3QD.mjs +34 -0
- package/dist/lib/node-esm/react-surface-CYNJK3QD.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 -4
- 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 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +5 -4
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/stack.d.ts +13 -14
- package/dist/types/src/types/stack.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +3 -3
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +45 -37
- package/src/StackPlugin.ts +26 -42
- 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} +22 -19
- 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 +9 -6
- package/src/translations.ts +4 -3
- package/src/types/stack.ts +12 -8
- package/src/types/types.ts +3 -3
- package/dist/lib/browser/StackMain-ET24BQFZ.mjs +0 -299
- package/dist/lib/browser/StackMain-ET24BQFZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FVB7LGW7.mjs.map +0 -7
- package/dist/lib/browser/chunk-IRTROCUQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-KODSQDIY.mjs +0 -46
- package/dist/lib/browser/react-surface-KODSQDIY.mjs.map +0 -7
- package/dist/lib/node-esm/StackMain-LCMLZ4MS.mjs +0 -300
- package/dist/lib/node-esm/StackMain-LCMLZ4MS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LRAZXJ65.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UN5PA7TK.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SWMUVIYU.mjs +0 -47
- package/dist/lib/node-esm/react-surface-SWMUVIYU.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/StackContext.d.ts.map +0 -1
- package/dist/types/src/components/StackMain.d.ts +0 -9
- package/dist/types/src/components/StackMain.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 -34
- package/src/components/StackMain.tsx +0 -159
- package/src/components/StackSettings.tsx +0 -23
- /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,159 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Option } from 'effect';
|
|
6
|
-
import React, { useCallback, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
Capabilities,
|
|
10
|
-
LayoutAction,
|
|
11
|
-
createIntent,
|
|
12
|
-
useAppGraph,
|
|
13
|
-
useCapabilities,
|
|
14
|
-
useIntentDispatcher,
|
|
15
|
-
} from '@dxos/app-framework';
|
|
16
|
-
import { fullyQualifiedId, isLiveObject } from '@dxos/client/echo';
|
|
17
|
-
import { Obj } from '@dxos/echo';
|
|
18
|
-
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
19
|
-
import { Icon, Button, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
20
|
-
import { AttentionProvider } from '@dxos/react-ui-attention';
|
|
21
|
-
import { Stack } from '@dxos/react-ui-stack';
|
|
22
|
-
import { type DataType } from '@dxos/schema';
|
|
23
|
-
import { isNonNullable } from '@dxos/util';
|
|
24
|
-
|
|
25
|
-
import { StackContext } from './StackContext';
|
|
26
|
-
import { StackSection } from './StackSection';
|
|
27
|
-
import { STACK_PLUGIN } from '../meta';
|
|
28
|
-
import {
|
|
29
|
-
type AddSectionPosition,
|
|
30
|
-
type CollapsedSections,
|
|
31
|
-
type StackSectionItem,
|
|
32
|
-
type StackSectionMetadata,
|
|
33
|
-
type StackSectionView,
|
|
34
|
-
} from '../types';
|
|
35
|
-
|
|
36
|
-
type StackMainProps = {
|
|
37
|
-
id: string;
|
|
38
|
-
collection: DataType.Collection;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const StackMain = ({ id, collection }: StackMainProps) => {
|
|
42
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
43
|
-
const { graph } = useAppGraph();
|
|
44
|
-
const { t } = useTranslation(STACK_PLUGIN);
|
|
45
|
-
const allMetadata = useCapabilities(Capabilities.Metadata);
|
|
46
|
-
const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});
|
|
47
|
-
|
|
48
|
-
// TODO(wittjosiah): Re-implement stack views with relations.
|
|
49
|
-
// const defaultStack = useMemo(() => Obj.make(StackViewType, { sections: {} }), [collection]);
|
|
50
|
-
// const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;
|
|
51
|
-
// useEffect(() => {
|
|
52
|
-
// if (!collection.views[StackViewType.typename]) {
|
|
53
|
-
// collection.views[StackViewType.typename] = Ref.make(stack);
|
|
54
|
-
// }
|
|
55
|
-
// }, [collection, stack]);
|
|
56
|
-
|
|
57
|
-
const items =
|
|
58
|
-
collection.objects
|
|
59
|
-
// TODO(wittjosiah): Should the database handle this differently?
|
|
60
|
-
// TODO(wittjosiah): Render placeholders for missing objects so they can be removed from the stack?
|
|
61
|
-
.map((object) => object.target)
|
|
62
|
-
.filter(isNonNullable)
|
|
63
|
-
.map((object) => {
|
|
64
|
-
const metadata = allMetadata.find((m) => m.id === (Obj.getTypename(object) ?? 'never'))
|
|
65
|
-
?.metadata as StackSectionMetadata;
|
|
66
|
-
const view = {
|
|
67
|
-
// ...stack.sections[object.id],
|
|
68
|
-
collapsed: collapsedSections[fullyQualifiedId(object)],
|
|
69
|
-
title:
|
|
70
|
-
(object as any)?.title ??
|
|
71
|
-
// TODO(wittjosiah): `getNode` is not reactive.
|
|
72
|
-
toLocalizedString(graph.getNode(fullyQualifiedId(object)).pipe(Option.getOrNull)?.properties.label, t),
|
|
73
|
-
} as StackSectionView;
|
|
74
|
-
return { id: fullyQualifiedId(object), object, metadata, view } satisfies StackSectionItem;
|
|
75
|
-
}) ?? [];
|
|
76
|
-
|
|
77
|
-
const handleDelete = useCallback(
|
|
78
|
-
async (id: string) => {
|
|
79
|
-
const index = collection.objects
|
|
80
|
-
.map((object) => object.target)
|
|
81
|
-
.filter(isNonNullable)
|
|
82
|
-
.findIndex((section) => fullyQualifiedId(section) === id);
|
|
83
|
-
const object = collection.objects[index].target;
|
|
84
|
-
if (isLiveObject(object)) {
|
|
85
|
-
await dispatch(createIntent(SpaceAction.RemoveObjects, { objects: [object], target: collection }));
|
|
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: `${STACK_PLUGIN}/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
|
-
() => dispatch?.(createIntent(SpaceAction.OpenCreateObject, { target: collection, navigable: false })),
|
|
129
|
-
[collection, dispatch],
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<AttentionProvider id={id}>
|
|
134
|
-
<StackContext.Provider
|
|
135
|
-
value={{
|
|
136
|
-
onCollapse: handleCollapse,
|
|
137
|
-
onNavigate: handleNavigate,
|
|
138
|
-
onDelete: handleDelete,
|
|
139
|
-
onAdd: handleAdd,
|
|
140
|
-
}}
|
|
141
|
-
>
|
|
142
|
-
<Stack orientation='vertical' size='intrinsic' id={id} data-testid='main.stack'>
|
|
143
|
-
{items.map((item) => (
|
|
144
|
-
<StackSection key={item.id} {...item} />
|
|
145
|
-
))}
|
|
146
|
-
</Stack>
|
|
147
|
-
|
|
148
|
-
<div role='none' className='flex mlb-2 pli-2 justify-center'>
|
|
149
|
-
<Button data-testid='stack.createSection' classNames='gap-2' onClick={handleAddSection}>
|
|
150
|
-
<Icon icon='ph--plus' />
|
|
151
|
-
<span className='sr-only'>{t('add section label')}</span>
|
|
152
|
-
</Button>
|
|
153
|
-
</div>
|
|
154
|
-
</StackContext.Provider>
|
|
155
|
-
</AttentionProvider>
|
|
156
|
-
);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
export default StackMain;
|
|
@@ -1,23 +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 { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
9
|
-
|
|
10
|
-
import { STACK_PLUGIN } from '../meta';
|
|
11
|
-
import { type StackSettingsProps } from '../types';
|
|
12
|
-
|
|
13
|
-
export const StackSettings = ({ settings }: { settings: StackSettingsProps }) => {
|
|
14
|
-
const { t } = useTranslation(STACK_PLUGIN);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<DeprecatedFormContainer>
|
|
18
|
-
<DeprecatedFormInput label={t('settings separation label')}>
|
|
19
|
-
<Input.Switch checked={settings.separation} onCheckedChange={(checked) => (settings.separation = !!checked)} />
|
|
20
|
-
</DeprecatedFormInput>
|
|
21
|
-
</DeprecatedFormContainer>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
File without changes
|
|
File without changes
|