@dxos/plugin-stack 0.8.4-main.84f28bd → 0.8.4-main.9735255
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-FUGH3ZJH.mjs +274 -0
- package/dist/lib/browser/StackContainer-FUGH3ZJH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FVB7LGW7.mjs → chunk-4X7CK6FM.mjs} +7 -5
- package/dist/lib/browser/chunk-4X7CK6FM.mjs.map +7 -0
- package/dist/lib/browser/{chunk-VDSBIEAC.mjs → chunk-CD32XYEB.mjs} +10 -11
- package/dist/lib/browser/chunk-CD32XYEB.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +38 -55
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-ZEFLABZS.mjs +40 -0
- package/dist/lib/browser/react-surface-ZEFLABZS.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/StackContainer-PTZGEQFQ.mjs +275 -0
- package/dist/lib/node-esm/StackContainer-PTZGEQFQ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GOXSWCA4.mjs → chunk-26XWE7UY.mjs} +10 -11
- package/dist/lib/node-esm/chunk-26XWE7UY.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UN5PA7TK.mjs → chunk-HEEGXPSW.mjs} +7 -5
- package/dist/lib/node-esm/chunk-HEEGXPSW.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +38 -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-JQOFHBYS.mjs +41 -0
- package/dist/lib/node-esm/react-surface-JQOFHBYS.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/StackContainer.d.ts +9 -0
- package/dist/types/src/components/StackContainer.d.ts.map +1 -0
- package/dist/types/src/components/StackSection.d.ts.map +1 -1
- package/dist/types/src/components/StackSettings.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +7 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- 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/index.d.ts +1 -1
- package/dist/types/src/types/index.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 +7 -5
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +41 -39
- package/src/StackPlugin.ts +25 -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 +33 -0
- package/src/components/StackContainer.tsx +166 -0
- package/src/components/StackSection.tsx +7 -6
- package/src/components/StackSettings.tsx +15 -8
- package/src/components/index.ts +1 -1
- package/src/meta.ts +8 -5
- package/src/translations.ts +4 -3
- package/src/types/index.ts +1 -1
- package/src/types/stack.ts +12 -8
- package/src/types/types.ts +4 -5
- package/dist/lib/browser/StackMain-6EC3A3IC.mjs +0 -298
- package/dist/lib/browser/StackMain-6EC3A3IC.mjs.map +0 -7
- package/dist/lib/browser/chunk-FVB7LGW7.mjs.map +0 -7
- package/dist/lib/browser/chunk-VDSBIEAC.mjs.map +0 -7
- package/dist/lib/browser/react-surface-KLOW5O2E.mjs +0 -46
- package/dist/lib/browser/react-surface-KLOW5O2E.mjs.map +0 -7
- package/dist/lib/node-esm/StackMain-G55P33OY.mjs +0 -299
- package/dist/lib/node-esm/StackMain-G55P33OY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GOXSWCA4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UN5PA7TK.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-H33L4IMD.mjs +0 -47
- package/dist/lib/node-esm/react-surface-H33L4IMD.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/StackMain.d.ts +0 -9
- package/dist/types/src/components/StackMain.d.ts.map +0 -1
- package/src/capabilities/react-surface.tsx +0 -34
- package/src/components/StackMain.tsx +0 -160
package/package.json
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-stack",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.9735255",
|
|
4
4
|
"description": "DXOS Surface plugin for Stack entities",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"sideEffects": true,
|
|
10
14
|
"type": "module",
|
|
11
15
|
"exports": {
|
|
12
16
|
".": {
|
|
17
|
+
"source": "./src/index.ts",
|
|
13
18
|
"types": "./dist/types/src/index.d.ts",
|
|
14
19
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
20
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
21
|
},
|
|
17
22
|
"./types": {
|
|
23
|
+
"source": "./src/types/index.ts",
|
|
18
24
|
"types": "./dist/types/src/types/index.d.ts",
|
|
19
25
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
20
26
|
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
@@ -33,51 +39,47 @@
|
|
|
33
39
|
"src"
|
|
34
40
|
],
|
|
35
41
|
"dependencies": {
|
|
36
|
-
"@fluentui/react-tabster": "
|
|
37
|
-
"@preact-signals/safe-react": "^0.9.0",
|
|
38
|
-
"@preact/signals-core": "^1.9.0",
|
|
42
|
+
"@fluentui/react-tabster": "9.26.11",
|
|
39
43
|
"@radix-ui/react-collapsible": "1.1.3",
|
|
40
|
-
"effect": "3.
|
|
44
|
+
"effect": "3.19.11",
|
|
41
45
|
"node-fetch": "^2.6.0",
|
|
42
|
-
"react-is": "~
|
|
43
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
44
|
-
"@dxos/async": "0.8.4-main.
|
|
45
|
-
"@dxos/client": "0.8.4-main.
|
|
46
|
-
"@dxos/echo": "0.8.4-main.
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/plugin-
|
|
51
|
-
"@dxos/plugin-
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/plugin-
|
|
54
|
-
"@dxos/react-
|
|
55
|
-
"@dxos/react-ui-
|
|
56
|
-
"@dxos/react-ui-
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/react-ui-
|
|
59
|
-
"@dxos/schema": "0.8.4-main.
|
|
60
|
-
"@dxos/util": "0.8.4-main.
|
|
46
|
+
"react-is": "~19.2.0",
|
|
47
|
+
"@dxos/app-framework": "0.8.4-main.9735255",
|
|
48
|
+
"@dxos/async": "0.8.4-main.9735255",
|
|
49
|
+
"@dxos/client": "0.8.4-main.9735255",
|
|
50
|
+
"@dxos/echo": "0.8.4-main.9735255",
|
|
51
|
+
"@dxos/invariant": "0.8.4-main.9735255",
|
|
52
|
+
"@dxos/operation": "0.8.4-main.9735255",
|
|
53
|
+
"@dxos/plugin-client": "0.8.4-main.9735255",
|
|
54
|
+
"@dxos/plugin-deck": "0.8.4-main.9735255",
|
|
55
|
+
"@dxos/plugin-space": "0.8.4-main.9735255",
|
|
56
|
+
"@dxos/react-client": "0.8.4-main.9735255",
|
|
57
|
+
"@dxos/plugin-graph": "0.8.4-main.9735255",
|
|
58
|
+
"@dxos/react-ui-attention": "0.8.4-main.9735255",
|
|
59
|
+
"@dxos/react-ui-form": "0.8.4-main.9735255",
|
|
60
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.9735255",
|
|
61
|
+
"@dxos/types": "0.8.4-main.9735255",
|
|
62
|
+
"@dxos/react-ui-stack": "0.8.4-main.9735255",
|
|
63
|
+
"@dxos/schema": "0.8.4-main.9735255",
|
|
64
|
+
"@dxos/util": "0.8.4-main.9735255"
|
|
61
65
|
},
|
|
62
66
|
"devDependencies": {
|
|
63
67
|
"@babel/core": "^7.18.13",
|
|
64
|
-
"@
|
|
65
|
-
"@types/react": "~
|
|
66
|
-
"
|
|
67
|
-
"react": "~
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/storybook-utils": "0.8.4-main.84f28bd"
|
|
68
|
+
"@types/react": "~19.2.7",
|
|
69
|
+
"@types/react-dom": "~19.2.3",
|
|
70
|
+
"react": "~19.2.3",
|
|
71
|
+
"react-dom": "~19.2.3",
|
|
72
|
+
"vite": "7.1.9",
|
|
73
|
+
"@dxos/react-ui": "0.8.4-main.9735255",
|
|
74
|
+
"@dxos/ui-theme": "0.8.4-main.9735255",
|
|
75
|
+
"@dxos/storybook-utils": "0.8.4-main.9735255"
|
|
73
76
|
},
|
|
74
77
|
"peerDependencies": {
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"react": "~
|
|
78
|
-
"react-
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/react-ui-theme": "0.8.4-main.84f28bd"
|
|
78
|
+
"effect": "3.19.11",
|
|
79
|
+
"react": "~19.2.3",
|
|
80
|
+
"react-dom": "~19.2.3",
|
|
81
|
+
"@dxos/react-ui": "0.8.4-main.9735255",
|
|
82
|
+
"@dxos/ui-theme": "0.8.4-main.9735255"
|
|
81
83
|
},
|
|
82
84
|
"publishConfig": {
|
|
83
85
|
"access": "public"
|
package/src/StackPlugin.ts
CHANGED
|
@@ -2,51 +2,34 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Common, Plugin } from '@dxos/app-framework';
|
|
6
6
|
import { type Obj } from '@dxos/echo';
|
|
7
|
-
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
8
7
|
|
|
9
8
|
import { ReactSurface } from './capabilities';
|
|
10
|
-
import {
|
|
9
|
+
import { SECTION_IDENTIFIER, meta } from './meta';
|
|
11
10
|
import { translations } from './translations';
|
|
12
11
|
import { StackViewType } from './types';
|
|
13
12
|
|
|
14
|
-
export const StackPlugin = ()
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
}),
|
|
40
|
-
],
|
|
41
|
-
}),
|
|
42
|
-
defineModule({
|
|
43
|
-
id: `${meta.id}/module/schema`,
|
|
44
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
45
|
-
activate: () => contributes(ClientCapabilities.Schema, [StackViewType]),
|
|
46
|
-
}),
|
|
47
|
-
defineModule({
|
|
48
|
-
id: `${meta.id}/module/react-surface`,
|
|
49
|
-
activatesOn: Events.SetupReactSurface,
|
|
50
|
-
activate: ReactSurface,
|
|
51
|
-
}),
|
|
52
|
-
]);
|
|
13
|
+
export const StackPlugin = Plugin.define(meta).pipe(
|
|
14
|
+
Common.Plugin.addTranslationsModule({ translations }),
|
|
15
|
+
Common.Plugin.addMetadataModule({
|
|
16
|
+
metadata: {
|
|
17
|
+
id: SECTION_IDENTIFIER,
|
|
18
|
+
metadata: {
|
|
19
|
+
parse: (section: { object: Obj.Unknown }, type: string) => {
|
|
20
|
+
switch (type) {
|
|
21
|
+
case 'node':
|
|
22
|
+
return { id: section.object.id, label: (section.object as any).title, data: section.object };
|
|
23
|
+
case 'object':
|
|
24
|
+
return section.object;
|
|
25
|
+
case 'view-object':
|
|
26
|
+
return section;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
Common.Plugin.addSchemaModule({ schema: [StackViewType] }),
|
|
33
|
+
Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
|
|
34
|
+
Plugin.make,
|
|
35
|
+
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { Collection } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
import { StackContainer } from '../../components';
|
|
13
|
+
import { meta } from '../../meta';
|
|
14
|
+
|
|
15
|
+
export default Capability.makeModule(() =>
|
|
16
|
+
Effect.succeed(
|
|
17
|
+
Capability.contributes(
|
|
18
|
+
Common.Capability.ReactSurface,
|
|
19
|
+
Common.createSurface({
|
|
20
|
+
id: `${meta.id}/article`,
|
|
21
|
+
role: 'article',
|
|
22
|
+
filter: (data): data is { id?: string; subject: Collection.Collection } =>
|
|
23
|
+
Obj.instanceOf(Collection.Collection, data.subject),
|
|
24
|
+
component: ({ role, data }) => {
|
|
25
|
+
// This allows the id to be overridden by the surface for situations where the id of the collection
|
|
26
|
+
// is not the same as the id of what is being represented (e.g., a space with a root collection).
|
|
27
|
+
const id = typeof data.id === 'string' ? data.id : undefined;
|
|
28
|
+
return <StackContainer id={id ?? Obj.getDXN(data.subject).toString()} role={role} subject={data.subject} />;
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
),
|
|
33
|
+
);
|
|
@@ -0,0 +1,166 @@
|
|
|
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 { Common } from '@dxos/app-framework';
|
|
9
|
+
import { useAppGraph, useCapabilities, useOperationInvoker } from '@dxos/app-framework/react';
|
|
10
|
+
import { type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
|
+
import { Graph } from '@dxos/plugin-graph';
|
|
13
|
+
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
14
|
+
import { Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
15
|
+
import { AttentionProvider } from '@dxos/react-ui-attention';
|
|
16
|
+
import { Stack, StackItem } from '@dxos/react-ui-stack';
|
|
17
|
+
import { type Collection } from '@dxos/schema';
|
|
18
|
+
import { isNonNullable } from '@dxos/util';
|
|
19
|
+
|
|
20
|
+
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
|
+
import { StackContext } from './StackContext';
|
|
30
|
+
import { StackSection } from './StackSection';
|
|
31
|
+
|
|
32
|
+
type StackContainerProps = SurfaceComponentProps<Collection.Collection> & {
|
|
33
|
+
id: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const StackContainer = ({ id, subject: collection }: StackContainerProps) => {
|
|
37
|
+
const { invokePromise } = useOperationInvoker();
|
|
38
|
+
const { graph } = useAppGraph();
|
|
39
|
+
const { t } = useTranslation(meta.id);
|
|
40
|
+
const allMetadata = useCapabilities(Common.Capability.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(
|
|
68
|
+
Graph.getNode(graph, Obj.getDXN(object).toString()).pipe(Option.getOrNull)?.properties.label,
|
|
69
|
+
t,
|
|
70
|
+
),
|
|
71
|
+
} as StackSectionView;
|
|
72
|
+
return { id: Obj.getDXN(object).toString(), object, metadata, view } satisfies StackSectionItem;
|
|
73
|
+
}) ?? [];
|
|
74
|
+
|
|
75
|
+
const handleDelete = useCallback(
|
|
76
|
+
async (id: string) => {
|
|
77
|
+
const index = collection.objects
|
|
78
|
+
.map((object) => object.target)
|
|
79
|
+
.filter(isNonNullable)
|
|
80
|
+
.findIndex((section) => Obj.getDXN(section).toString() === id);
|
|
81
|
+
const object = collection.objects[index].target;
|
|
82
|
+
if (Obj.isObject(object)) {
|
|
83
|
+
await invokePromise(SpaceOperation.RemoveObjects, {
|
|
84
|
+
objects: [object],
|
|
85
|
+
target: collection,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.
|
|
89
|
+
// delete stack.sections[Path.last(path)];
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
[collection, invokePromise],
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const handleAdd = useCallback(
|
|
96
|
+
async (id: string, position: AddSectionPosition) => {
|
|
97
|
+
// TODO(wittjosiah): Use object creation dialog.
|
|
98
|
+
await invokePromise(Common.LayoutOperation.UpdateDialog, {
|
|
99
|
+
subject: `${meta.id}/AddSectionDialog`,
|
|
100
|
+
blockAlign: 'start',
|
|
101
|
+
props: {
|
|
102
|
+
path: id,
|
|
103
|
+
position,
|
|
104
|
+
collection,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
[collection, invokePromise],
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const handleNavigate = useCallback(
|
|
112
|
+
async (id: string) => {
|
|
113
|
+
await invokePromise(Common.LayoutOperation.Open, { subject: [id] });
|
|
114
|
+
},
|
|
115
|
+
[invokePromise],
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const handleCollapse = useCallback(
|
|
119
|
+
(id: string, collapsed: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: collapsed })),
|
|
120
|
+
[],
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const handleAddSection = useCallback(
|
|
124
|
+
() =>
|
|
125
|
+
invokePromise(SpaceOperation.OpenCreateObject, {
|
|
126
|
+
target: collection,
|
|
127
|
+
navigable: false,
|
|
128
|
+
}),
|
|
129
|
+
[collection, invokePromise],
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<StackItem.Content
|
|
134
|
+
toolbar
|
|
135
|
+
classNames='container-max-width overflow-hidden border-l border-r border-subduedSeparator'
|
|
136
|
+
>
|
|
137
|
+
<Toolbar.Root>
|
|
138
|
+
<Toolbar.IconButton
|
|
139
|
+
icon='ph--plus--regular'
|
|
140
|
+
iconOnly
|
|
141
|
+
label='Add section'
|
|
142
|
+
data-testid='stack.addSection'
|
|
143
|
+
onClick={handleAddSection}
|
|
144
|
+
/>
|
|
145
|
+
</Toolbar.Root>
|
|
146
|
+
<AttentionProvider id={id}>
|
|
147
|
+
<StackContext.Provider
|
|
148
|
+
value={{
|
|
149
|
+
onCollapse: handleCollapse,
|
|
150
|
+
onNavigate: handleNavigate,
|
|
151
|
+
onDelete: handleDelete,
|
|
152
|
+
onAdd: handleAdd,
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
<Stack orientation='vertical' size='intrinsic' id={id} data-testid='main.stack' classNames='overflow-y-auto'>
|
|
156
|
+
{items.map((item) => (
|
|
157
|
+
<StackSection key={item.id} {...item} />
|
|
158
|
+
))}
|
|
159
|
+
</Stack>
|
|
160
|
+
</StackContext.Provider>
|
|
161
|
+
</AttentionProvider>
|
|
162
|
+
</StackItem.Content>
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export default StackContainer;
|
|
@@ -5,16 +5,17 @@
|
|
|
5
5
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
6
6
|
import React, { useMemo, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { Surface } from '@dxos/app-framework';
|
|
9
|
-
import { DropdownMenu, Icon,
|
|
8
|
+
import { Surface } from '@dxos/app-framework/react';
|
|
9
|
+
import { DropdownMenu, Icon, IconButton, useTranslation } from '@dxos/react-ui';
|
|
10
10
|
import { useAttentionAttributes } from '@dxos/react-ui-attention';
|
|
11
11
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
12
|
-
import {
|
|
12
|
+
import { getSize, mx, textBlockWidth } from '@dxos/ui-theme';
|
|
13
|
+
|
|
14
|
+
import { meta } from '../meta';
|
|
15
|
+
import { type StackSectionItem } from '../types';
|
|
13
16
|
|
|
14
17
|
import { CaretDownUp } from './CaretDownUp';
|
|
15
18
|
import { useStack } from './StackContext';
|
|
16
|
-
import { STACK_PLUGIN } from '../meta';
|
|
17
|
-
import { type StackSectionItem } from '../types';
|
|
18
19
|
|
|
19
20
|
const sectionActionDimensions = 'p-1 mlb-1 shrink-0 min-bs-0 is-[--rail-action] bs-min';
|
|
20
21
|
|
|
@@ -26,7 +27,7 @@ export const StackSection = ({
|
|
|
26
27
|
object,
|
|
27
28
|
metadata: { icon = 'ph--placeholder--regular' },
|
|
28
29
|
}: StackSectionProps) => {
|
|
29
|
-
const { t } = useTranslation(
|
|
30
|
+
const { t } = useTranslation(meta.id);
|
|
30
31
|
const { onNavigate, onAdd, onCollapse, onDelete } = useStack();
|
|
31
32
|
const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);
|
|
32
33
|
const attentionAttrs = useAttentionAttributes(id);
|
|
@@ -5,19 +5,26 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { Input, useTranslation } from '@dxos/react-ui';
|
|
8
|
-
import {
|
|
8
|
+
import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from '@dxos/react-ui-form';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { meta } from '../meta';
|
|
11
11
|
import { type StackSettingsProps } from '../types';
|
|
12
12
|
|
|
13
13
|
export const StackSettings = ({ settings }: { settings: StackSettingsProps }) => {
|
|
14
|
-
const { t } = useTranslation(
|
|
14
|
+
const { t } = useTranslation(meta.id);
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
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>
|
|
22
29
|
);
|
|
23
30
|
};
|
package/src/components/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const STACK_PLUGIN = 'dxos.org/plugin/stack';
|
|
8
8
|
export const SECTION_IDENTIFIER = 'dxos.org/type/StackSection';
|
|
9
9
|
|
|
10
|
-
export const meta:
|
|
11
|
-
id:
|
|
10
|
+
export const meta: Plugin.Meta = {
|
|
11
|
+
id: 'dxos.org/plugin/stack',
|
|
12
12
|
// TODO(wittjosiah): Prevents "stacks" language from being exposed to users in settings panel.
|
|
13
13
|
// Conside renaming this to the collection plugin and trying to factor more collections logic from the space plugin.
|
|
14
14
|
name: 'Collections',
|
|
15
|
-
description:
|
|
15
|
+
description: trim`
|
|
16
|
+
Organize and view curated collections of workspace objects in customizable layouts.
|
|
17
|
+
Group related items together and manage collections with sections and filtering.
|
|
18
|
+
`,
|
|
16
19
|
icon: 'ph--stack-simple--regular',
|
|
17
20
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-stack',
|
|
18
21
|
};
|
package/src/translations.ts
CHANGED
|
@@ -12,6 +12,7 @@ export const translations = [
|
|
|
12
12
|
'en-US': {
|
|
13
13
|
[meta.id]: {
|
|
14
14
|
'plugin name': 'Stacks',
|
|
15
|
+
'settings title': 'Stack plugin settings',
|
|
15
16
|
'settings separation label': 'Separate sections',
|
|
16
17
|
'add section beforeAll dialog title': 'Add a section to the start',
|
|
17
18
|
'add section afterAll dialog title': 'Add a section to the end',
|
|
@@ -20,16 +21,16 @@ export const translations = [
|
|
|
20
21
|
'add section input placeholder': 'Find the type of section to add',
|
|
21
22
|
'upload file label': 'Add file',
|
|
22
23
|
'add section label': 'Add section',
|
|
23
|
-
'empty stack message': 'Drag
|
|
24
|
+
'empty stack message': 'Drag objects into the stack.',
|
|
24
25
|
'remove section label': 'Delete',
|
|
25
|
-
'navigate to section label': 'Navigate to
|
|
26
|
+
'navigate to section label': 'Navigate to object',
|
|
26
27
|
'untitled section title': 'Untitled section',
|
|
27
28
|
'add section before label': 'Add before',
|
|
28
29
|
'add section after label': 'Add after',
|
|
29
30
|
'expand label': 'Expand',
|
|
30
31
|
'collapse label': 'Collapse',
|
|
31
32
|
'open chat thread label': 'Open chat thread',
|
|
32
|
-
'drag handle label': 'Press space or enter to begin dragging this
|
|
33
|
+
'drag handle label': 'Press space or enter to begin dragging this object.',
|
|
33
34
|
},
|
|
34
35
|
},
|
|
35
36
|
},
|
package/src/types/index.ts
CHANGED
package/src/types/stack.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Type } from '@dxos/echo';
|
|
8
8
|
|
|
9
9
|
// All section metadata needs to be optional/have defaults.
|
|
10
10
|
// Any objects added to the collection will start with the section defaults.
|
|
@@ -19,9 +19,13 @@ export const SectionSchema = Schema.Struct({
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
// TODO(wittjosiah): This needs a relation to be connected to a stack.
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
export const StackViewType = Schema.Struct({
|
|
23
|
+
sections: Schema.Record({ key: Schema.String, value: SectionSchema }),
|
|
24
|
+
}).pipe(
|
|
25
|
+
Type.object({
|
|
26
|
+
typename: 'dxos.org/type/StackView',
|
|
27
|
+
version: '0.1.0',
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export interface StackViewType extends Schema.Schema.Type<typeof StackViewType> {}
|
package/src/types/types.ts
CHANGED
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type IconProps } from '@phosphor-icons/react';
|
|
6
5
|
import { type FC } from 'react';
|
|
7
6
|
|
|
8
7
|
import { type Obj } from '@dxos/echo';
|
|
9
8
|
import { type Label } from '@dxos/react-ui';
|
|
10
9
|
import { type StackItemSize } from '@dxos/react-ui-stack';
|
|
11
|
-
import { type
|
|
10
|
+
import { type Collection } from '@dxos/schema';
|
|
12
11
|
|
|
13
12
|
export type AddSectionPosition = 'before' | 'after' | 'beforeAll' | 'afterAll';
|
|
14
13
|
|
|
15
14
|
export type CollapsedSections = Record<string, boolean>;
|
|
16
15
|
|
|
17
|
-
export type CollectionItem =
|
|
16
|
+
export type CollectionItem = Collection.Collection['objects'][number];
|
|
18
17
|
|
|
19
18
|
export type StackSectionView = {
|
|
20
19
|
title?: string;
|
|
@@ -29,7 +28,7 @@ type StackSectionAction = {
|
|
|
29
28
|
testId: string;
|
|
30
29
|
type: string | [string, { ns: string }];
|
|
31
30
|
label: string | [string, { ns: string }];
|
|
32
|
-
icon: FC<
|
|
31
|
+
icon: FC<{ className?: string; size?: number }>;
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
export type StackSectionMetadata = {
|
|
@@ -40,7 +39,7 @@ export type StackSectionMetadata = {
|
|
|
40
39
|
|
|
41
40
|
export type StackSectionItem = {
|
|
42
41
|
id: string;
|
|
43
|
-
object: Obj.
|
|
42
|
+
object: Obj.Unknown;
|
|
44
43
|
view: StackSectionView;
|
|
45
44
|
metadata: StackSectionMetadata;
|
|
46
45
|
};
|