@dxos/plugin-stack 0.8.4-main.b97322e → 0.8.4-main.bcb3aa67d6
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/index.mjs +71 -78
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +21 -4
- package/dist/lib/browser/types/index.mjs.map +4 -4
- package/dist/lib/node-esm/index.mjs +72 -78
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +22 -4
- package/dist/lib/node-esm/types/index.mjs.map +4 -4
- 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 +2 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- 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 +31 -29
- 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 +52 -37
- package/src/StackPlugin.ts +29 -44
- package/src/capabilities/index.ts +2 -2
- package/src/capabilities/react-surface.tsx +22 -25
- 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} +29 -26
- package/src/components/StackSection/index.ts +5 -0
- package/src/components/StackSettings/StackSettings.tsx +28 -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 +22 -20
- 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 +0 -19
- package/dist/lib/browser/chunk-FVB7LGW7.mjs.map +0 -7
- package/dist/lib/browser/chunk-IRTROCUQ.mjs +0 -28
- 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 +0 -30
- package/dist/lib/node-esm/chunk-LRAZXJ65.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UN5PA7TK.mjs +0 -21
- 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/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/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
package/package.json
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-stack",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.bcb3aa67d6",
|
|
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",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#capabilities": "./src/capabilities/index.ts",
|
|
17
|
+
"#components": "./src/components/index.ts",
|
|
18
|
+
"#containers": "./src/containers/index.ts",
|
|
19
|
+
"#meta": "./src/meta.ts",
|
|
20
|
+
"#types": "./src/types/index.ts"
|
|
21
|
+
},
|
|
11
22
|
"exports": {
|
|
12
23
|
".": {
|
|
24
|
+
"source": "./src/index.ts",
|
|
13
25
|
"types": "./dist/types/src/index.d.ts",
|
|
14
26
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
27
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
28
|
},
|
|
17
29
|
"./types": {
|
|
30
|
+
"source": "./src/types/index.ts",
|
|
18
31
|
"types": "./dist/types/src/types/index.d.ts",
|
|
19
32
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
20
33
|
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
@@ -33,49 +46,51 @@
|
|
|
33
46
|
"src"
|
|
34
47
|
],
|
|
35
48
|
"dependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@preact/signals-core": "^1.9.0",
|
|
49
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
50
|
+
"@fluentui/react-tabster": "9.26.11",
|
|
39
51
|
"@radix-ui/react-collapsible": "1.1.3",
|
|
40
|
-
"effect": "3.
|
|
52
|
+
"effect": "3.20.0",
|
|
41
53
|
"node-fetch": "^2.6.0",
|
|
42
|
-
"react-is": "~
|
|
43
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/client": "0.8.4-main.
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/echo": "0.8.4-main.
|
|
48
|
-
"@dxos/invariant": "0.8.4-main.
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/plugin-
|
|
52
|
-
"@dxos/plugin-deck": "0.8.4-main.
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/plugin-space": "0.8.4-main.
|
|
55
|
-
"@dxos/react-
|
|
56
|
-
"@dxos/react-ui-
|
|
57
|
-
"@dxos/react-ui-form": "0.8.4-main.
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
54
|
+
"react-is": "~19.2.0",
|
|
55
|
+
"@dxos/app-framework": "0.8.4-main.bcb3aa67d6",
|
|
56
|
+
"@dxos/app-toolkit": "0.8.4-main.bcb3aa67d6",
|
|
57
|
+
"@dxos/client": "0.8.4-main.bcb3aa67d6",
|
|
58
|
+
"@dxos/async": "0.8.4-main.bcb3aa67d6",
|
|
59
|
+
"@dxos/echo": "0.8.4-main.bcb3aa67d6",
|
|
60
|
+
"@dxos/invariant": "0.8.4-main.bcb3aa67d6",
|
|
61
|
+
"@dxos/echo-atom": "0.8.4-main.bcb3aa67d6",
|
|
62
|
+
"@dxos/operation": "0.8.4-main.bcb3aa67d6",
|
|
63
|
+
"@dxos/plugin-client": "0.8.4-main.bcb3aa67d6",
|
|
64
|
+
"@dxos/plugin-deck": "0.8.4-main.bcb3aa67d6",
|
|
65
|
+
"@dxos/plugin-graph": "0.8.4-main.bcb3aa67d6",
|
|
66
|
+
"@dxos/plugin-space": "0.8.4-main.bcb3aa67d6",
|
|
67
|
+
"@dxos/react-client": "0.8.4-main.bcb3aa67d6",
|
|
68
|
+
"@dxos/react-ui-attention": "0.8.4-main.bcb3aa67d6",
|
|
69
|
+
"@dxos/react-ui-form": "0.8.4-main.bcb3aa67d6",
|
|
70
|
+
"@dxos/react-ui-stack": "0.8.4-main.bcb3aa67d6",
|
|
71
|
+
"@dxos/schema": "0.8.4-main.bcb3aa67d6",
|
|
72
|
+
"@dxos/types": "0.8.4-main.bcb3aa67d6",
|
|
73
|
+
"@dxos/util": "0.8.4-main.bcb3aa67d6",
|
|
74
|
+
"@dxos/react-ui-search": "0.8.4-main.bcb3aa67d6"
|
|
61
75
|
},
|
|
62
76
|
"devDependencies": {
|
|
63
77
|
"@babel/core": "^7.18.13",
|
|
64
|
-
"@types/react": "~
|
|
65
|
-
"@types/react-dom": "~
|
|
66
|
-
"react": "~
|
|
67
|
-
"react-dom": "~
|
|
68
|
-
"vite": "
|
|
69
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
78
|
+
"@types/react": "~19.2.7",
|
|
79
|
+
"@types/react-dom": "~19.2.3",
|
|
80
|
+
"react": "~19.2.3",
|
|
81
|
+
"react-dom": "~19.2.3",
|
|
82
|
+
"vite": "^7.1.11",
|
|
83
|
+
"@dxos/react-ui": "0.8.4-main.bcb3aa67d6",
|
|
84
|
+
"@dxos/storybook-utils": "0.8.4-main.bcb3aa67d6",
|
|
85
|
+
"@dxos/ui-theme": "0.8.4-main.bcb3aa67d6"
|
|
72
86
|
},
|
|
73
87
|
"peerDependencies": {
|
|
74
|
-
"effect": "^
|
|
75
|
-
"
|
|
76
|
-
"react
|
|
77
|
-
"
|
|
78
|
-
"@dxos/react-ui
|
|
88
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
89
|
+
"effect": "3.20.0",
|
|
90
|
+
"react": "~19.2.3",
|
|
91
|
+
"react-dom": "~19.2.3",
|
|
92
|
+
"@dxos/react-ui": "0.8.4-main.bcb3aa67d6",
|
|
93
|
+
"@dxos/ui-theme": "0.8.4-main.bcb3aa67d6"
|
|
79
94
|
},
|
|
80
95
|
"publishConfig": {
|
|
81
96
|
"access": "public"
|
package/src/StackPlugin.ts
CHANGED
|
@@ -2,51 +2,36 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
6
7
|
import { type Obj } from '@dxos/echo';
|
|
7
|
-
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import { meta, SECTION_IDENTIFIER } from './meta';
|
|
9
|
+
import { SECTION_IDENTIFIER, meta } from '#meta';
|
|
11
10
|
import { translations } from './translations';
|
|
12
|
-
import { StackViewType } from '
|
|
11
|
+
import { StackViewType } from '#types';
|
|
13
12
|
|
|
14
|
-
|
|
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
|
+
import { ReactSurface } from '#capabilities';
|
|
14
|
+
|
|
15
|
+
export const StackPlugin = Plugin.define(meta).pipe(
|
|
16
|
+
AppPlugin.addMetadataModule({
|
|
17
|
+
metadata: {
|
|
18
|
+
id: SECTION_IDENTIFIER,
|
|
19
|
+
metadata: {
|
|
20
|
+
parse: (section: { object: Obj.Unknown }, type: string) => {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case 'node':
|
|
23
|
+
return { id: section.object.id, label: (section.object as any).title, data: section.object };
|
|
24
|
+
case 'object':
|
|
25
|
+
return section.object;
|
|
26
|
+
case 'view-object':
|
|
27
|
+
return section;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
AppPlugin.addSchemaModule({ schema: [StackViewType] }),
|
|
34
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
35
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
36
|
+
Plugin.make,
|
|
37
|
+
);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
7
|
+
export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
|
|
@@ -2,33 +2,30 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
|
|
7
|
-
import { Capabilities,
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
8
10
|
import { Obj } from '@dxos/echo';
|
|
9
|
-
import {
|
|
10
|
-
import { DataType } from '@dxos/schema';
|
|
11
|
+
import { Collection } from '@dxos/echo';
|
|
11
12
|
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
13
|
+
import { StackContainer } from '#containers';
|
|
14
|
+
import { meta } from '#meta';
|
|
14
15
|
|
|
15
|
-
export default () =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
);
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
34
|
-
);
|
|
16
|
+
export default Capability.makeModule(() =>
|
|
17
|
+
Effect.succeed(
|
|
18
|
+
Capability.contributes(
|
|
19
|
+
Capabilities.ReactSurface,
|
|
20
|
+
Surface.create({
|
|
21
|
+
id: `${meta.id}.article`,
|
|
22
|
+
role: 'article',
|
|
23
|
+
filter: (data): data is { attendableId: string; subject: Collection.Collection } =>
|
|
24
|
+
typeof data.attendableId === 'string' && Obj.instanceOf(Collection.Collection, data.subject),
|
|
25
|
+
component: ({ role, data }) => {
|
|
26
|
+
return <StackContainer attendableId={data.attendableId} role={role} subject={data.subject} />;
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
),
|
|
30
|
+
),
|
|
31
|
+
);
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import { createContext, useContext } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type AddSectionPosition } from '
|
|
7
|
+
import { type AddSectionPosition } from '#types';
|
|
8
8
|
|
|
9
9
|
export type StackContextValue = {
|
|
10
|
+
attendableId: string;
|
|
10
11
|
onCollapse: (id: string, collapsed: boolean) => void;
|
|
11
12
|
onNavigate: (id: string) => Promise<void>;
|
|
12
13
|
onDelete: (id: string) => Promise<void>;
|
|
@@ -14,6 +15,7 @@ export type StackContextValue = {
|
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
export const StackContext = createContext<StackContextValue>({
|
|
18
|
+
attendableId: '',
|
|
17
19
|
onCollapse: () => {},
|
|
18
20
|
onNavigate: async () => {},
|
|
19
21
|
onDelete: async () => {},
|
|
@@ -5,18 +5,19 @@
|
|
|
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/ui';
|
|
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 } from '@dxos/ui-theme';
|
|
13
|
+
|
|
14
|
+
import { meta } from '#meta';
|
|
15
|
+
import { type StackSectionItem } from '#types';
|
|
16
|
+
import { useStack } from '../StackContext';
|
|
13
17
|
|
|
14
18
|
import { CaretDownUp } from './CaretDownUp';
|
|
15
|
-
import { useStack } from './StackContext';
|
|
16
|
-
import { STACK_PLUGIN } from '../meta';
|
|
17
|
-
import { type StackSectionItem } from '../types';
|
|
18
19
|
|
|
19
|
-
const sectionActionDimensions = 'p-1
|
|
20
|
+
const sectionActionDimensions = 'p-1 my-1 shrink-0 min-h-0 w-(--dx-rail-action) h-min';
|
|
20
21
|
|
|
21
22
|
export type StackSectionProps = StackSectionItem;
|
|
22
23
|
|
|
@@ -26,16 +27,18 @@ export const StackSection = ({
|
|
|
26
27
|
object,
|
|
27
28
|
metadata: { icon = 'ph--placeholder--regular' },
|
|
28
29
|
}: StackSectionProps) => {
|
|
29
|
-
const { t } = useTranslation(
|
|
30
|
-
const { onNavigate, onAdd, onCollapse, onDelete } = useStack();
|
|
30
|
+
const { t } = useTranslation(meta.id);
|
|
31
|
+
const { attendableId: parentAttendableId, onNavigate, onAdd, onCollapse, onDelete } = useStack();
|
|
31
32
|
const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);
|
|
32
|
-
const
|
|
33
|
+
const attendableId = `${parentAttendableId}/${object.id}`;
|
|
34
|
+
const attentionAttrs = useAttentionAttributes(attendableId);
|
|
33
35
|
const stackItem = useMemo(() => ({ id }), [id]);
|
|
36
|
+
const data = useMemo(() => ({ attendableId, subject: object }), [object, attendableId]);
|
|
34
37
|
|
|
35
38
|
return (
|
|
36
39
|
<CollapsiblePrimitive.Root asChild open={!view.collapsed} onOpenChange={(nextOpen) => onCollapse?.(id, !nextOpen)}>
|
|
37
40
|
<StackItem.Root item={stackItem} role='section' {...attentionAttrs}>
|
|
38
|
-
<StackItem.Heading classNames='attention-surface'>
|
|
41
|
+
<StackItem.Heading classNames='dx-attention-surface'>
|
|
39
42
|
<span className='sr-only'>{view.title}</span>
|
|
40
43
|
<StackItem.HeadingStickyContent>
|
|
41
44
|
<DropdownMenu.Root
|
|
@@ -46,7 +49,7 @@ export const StackSection = ({
|
|
|
46
49
|
>
|
|
47
50
|
<DropdownMenu.Trigger asChild>
|
|
48
51
|
<StackItem.SigilButton>
|
|
49
|
-
<Icon icon={icon}
|
|
52
|
+
<Icon icon={icon} classNames='transition-opacity' />
|
|
50
53
|
</StackItem.SigilButton>
|
|
51
54
|
</DropdownMenu.Trigger>
|
|
52
55
|
<DropdownMenu.Portal>
|
|
@@ -54,28 +57,28 @@ export const StackSection = ({
|
|
|
54
57
|
<DropdownMenu.Viewport>
|
|
55
58
|
{view.collapsed ? (
|
|
56
59
|
<DropdownMenu.Item onClick={() => onNavigate(id)} data-testid='section.navigate-to'>
|
|
57
|
-
<Icon icon='ph--arrow-right--regular'
|
|
58
|
-
<span className='
|
|
60
|
+
<Icon icon='ph--arrow-right--regular' />
|
|
61
|
+
<span className='ms-2 grow'>{t('navigate-to-section.label')}</span>
|
|
59
62
|
</DropdownMenu.Item>
|
|
60
63
|
) : (
|
|
61
64
|
<CollapsiblePrimitive.Trigger asChild>
|
|
62
65
|
<DropdownMenu.Item>
|
|
63
66
|
<CaretDownUp className={getSize(5)} />
|
|
64
|
-
<span className='
|
|
67
|
+
<span className='ms-2 grow'>{t('collapse.label')}</span>
|
|
65
68
|
</DropdownMenu.Item>
|
|
66
69
|
</CollapsiblePrimitive.Trigger>
|
|
67
70
|
)}
|
|
68
71
|
<DropdownMenu.Item onClick={() => onAdd(id, 'before')} data-testid='section.add-before'>
|
|
69
|
-
<Icon icon='ph--arrow-line-up--regular'
|
|
70
|
-
<span className='
|
|
72
|
+
<Icon icon='ph--arrow-line-up--regular' />
|
|
73
|
+
<span className='ms-2 grow'>{t('add-section-before.label')}</span>
|
|
71
74
|
</DropdownMenu.Item>
|
|
72
75
|
<DropdownMenu.Item onClick={() => onAdd(id, 'after')} data-testid='section.add-after'>
|
|
73
|
-
<Icon icon='ph--arrow-line-down--regular'
|
|
74
|
-
<span className='
|
|
76
|
+
<Icon icon='ph--arrow-line-down--regular' />
|
|
77
|
+
<span className='ms-2 grow'>{t('add-section-after.label')}</span>
|
|
75
78
|
</DropdownMenu.Item>
|
|
76
79
|
<DropdownMenu.Item onClick={() => onDelete(id)} data-testid='section.remove'>
|
|
77
|
-
<Icon icon='ph--trash--regular'
|
|
78
|
-
<span className='
|
|
80
|
+
<Icon icon='ph--trash--regular' />
|
|
81
|
+
<span className='ms-2 grow'>{t('remove-section.label')}</span>
|
|
79
82
|
</DropdownMenu.Item>
|
|
80
83
|
</DropdownMenu.Viewport>
|
|
81
84
|
<DropdownMenu.Arrow />
|
|
@@ -87,7 +90,7 @@ export const StackSection = ({
|
|
|
87
90
|
<IconButton
|
|
88
91
|
iconOnly
|
|
89
92
|
variant='ghost'
|
|
90
|
-
label={t('expand
|
|
93
|
+
label={t('expand.label')}
|
|
91
94
|
icon='ph--caret-up-down--regular'
|
|
92
95
|
classNames={sectionActionDimensions}
|
|
93
96
|
/>
|
|
@@ -97,7 +100,7 @@ export const StackSection = ({
|
|
|
97
100
|
iconOnly
|
|
98
101
|
variant='ghost'
|
|
99
102
|
onClick={() => onNavigate(id)}
|
|
100
|
-
label={t('navigate
|
|
103
|
+
label={t('navigate-to-section.label')}
|
|
101
104
|
icon='ph--arrow-right--regular'
|
|
102
105
|
data-testid='section.navigate-to'
|
|
103
106
|
classNames={sectionActionDimensions}
|
|
@@ -106,11 +109,11 @@ export const StackSection = ({
|
|
|
106
109
|
</StackItem.HeadingStickyContent>
|
|
107
110
|
</StackItem.Heading>
|
|
108
111
|
<CollapsiblePrimitive.Content>
|
|
109
|
-
<Surface role='section' data={
|
|
112
|
+
<Surface.Surface role='section' data={data} limit={1} placeholder={<></>} />
|
|
110
113
|
</CollapsiblePrimitive.Content>
|
|
111
114
|
{view.collapsed && (
|
|
112
|
-
<StackItem.Content classNames='attention-surface'>
|
|
113
|
-
<h2 className={mx('flex items-center p-4 font-medium'
|
|
115
|
+
<StackItem.Content classNames='dx-attention-surface'>
|
|
116
|
+
<h2 className={mx('flex items-center p-4 font-medium')}>{view.title}</h2>
|
|
114
117
|
</StackItem.Content>
|
|
115
118
|
)}
|
|
116
119
|
</StackItem.Root>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Input, useTranslation } from '@dxos/react-ui';
|
|
8
|
+
import { Settings as SettingsForm } 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
|
+
<SettingsForm.Viewport>
|
|
18
|
+
<SettingsForm.Section title={t('settings.title', { ns: meta.id })}>
|
|
19
|
+
<SettingsForm.Item title={t('settings.separation.label')} description={t('settings.separation.description')}>
|
|
20
|
+
<Input.Switch
|
|
21
|
+
checked={settings.separation}
|
|
22
|
+
onCheckedChange={(checked) => (settings.separation = !!checked)}
|
|
23
|
+
/>
|
|
24
|
+
</SettingsForm.Item>
|
|
25
|
+
</SettingsForm.Section>
|
|
26
|
+
</SettingsForm.Viewport>
|
|
27
|
+
);
|
|
28
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Atom, useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
7
|
+
import React, { useCallback, useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import { useCapabilities, useOperationInvoker } from '@dxos/app-framework/ui';
|
|
10
|
+
import { AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';
|
|
11
|
+
import { type ObjectSurfaceProps } from '@dxos/app-toolkit/ui';
|
|
12
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
13
|
+
import { Obj, type Ref } from '@dxos/echo';
|
|
14
|
+
import { type Collection } from '@dxos/echo';
|
|
15
|
+
import { AtomObj } from '@dxos/echo-atom';
|
|
16
|
+
import { Graph } from '@dxos/plugin-graph';
|
|
17
|
+
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
18
|
+
import { Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
19
|
+
import { Stack, StackItem } from '@dxos/react-ui-stack';
|
|
20
|
+
import { isNonNullable } from '@dxos/util';
|
|
21
|
+
|
|
22
|
+
import { StackContext, StackSection } from '#components';
|
|
23
|
+
import { meta } from '#meta';
|
|
24
|
+
import {
|
|
25
|
+
type AddSectionPosition,
|
|
26
|
+
type CollapsedSections,
|
|
27
|
+
type StackSectionItem,
|
|
28
|
+
type StackSectionMetadata,
|
|
29
|
+
type StackSectionView,
|
|
30
|
+
} from '#types';
|
|
31
|
+
|
|
32
|
+
const collectionObjectsFamily = Atom.family((collection: Collection.Collection) =>
|
|
33
|
+
Atom.make((get) => {
|
|
34
|
+
const snapshot = get(AtomObj.make(collection));
|
|
35
|
+
return (
|
|
36
|
+
snapshot.objects
|
|
37
|
+
// TODO(wittjosiah): Why isn't this type inferred correctly?
|
|
38
|
+
.map((ref: Ref.Ref<Obj.Unknown>) => get(AtomObj.makeWithReactive(ref)))
|
|
39
|
+
.filter(isNonNullable)
|
|
40
|
+
);
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
type StackContainerProps = ObjectSurfaceProps<Collection.Collection>;
|
|
45
|
+
|
|
46
|
+
export const StackContainer = ({ attendableId, subject: collection }: StackContainerProps) => {
|
|
47
|
+
const { invokePromise } = useOperationInvoker();
|
|
48
|
+
const { graph } = useAppGraph();
|
|
49
|
+
const { t } = useTranslation(meta.id);
|
|
50
|
+
const allMetadata = useCapabilities(AppCapabilities.Metadata);
|
|
51
|
+
const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});
|
|
52
|
+
|
|
53
|
+
// TODO(wittjosiah): Re-implement stack views with relations.
|
|
54
|
+
// const defaultStack = useMemo(() => Obj.make(StackViewType, { sections: {} }), [collection]);
|
|
55
|
+
// const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;
|
|
56
|
+
// useEffect(() => {
|
|
57
|
+
// if (!collection.views[StackViewType.typename]) {
|
|
58
|
+
// collection.views[StackViewType.typename] = Ref.make(stack);
|
|
59
|
+
// }
|
|
60
|
+
// }, [collection, stack]);
|
|
61
|
+
|
|
62
|
+
const collectionObjects = useAtomValue(collectionObjectsFamily(collection));
|
|
63
|
+
const items = collectionObjects.map((object: Obj.Unknown) => {
|
|
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[Obj.getDXN(object).toString()],
|
|
69
|
+
title:
|
|
70
|
+
(object as any)?.title ??
|
|
71
|
+
// TODO(wittjosiah): `getNode` is not reactive.
|
|
72
|
+
toLocalizedString(
|
|
73
|
+
Graph.getNode(graph, Obj.getDXN(object).toString()).pipe(Option.getOrNull)?.properties.label,
|
|
74
|
+
t,
|
|
75
|
+
),
|
|
76
|
+
} as StackSectionView;
|
|
77
|
+
return { id: Obj.getDXN(object).toString(), object, metadata, view } satisfies StackSectionItem;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const handleDelete = useCallback(
|
|
81
|
+
async (id: string) => {
|
|
82
|
+
const index = collection.objects
|
|
83
|
+
.map((object) => object.target)
|
|
84
|
+
.filter(isNonNullable)
|
|
85
|
+
.findIndex((section) => Obj.getDXN(section).toString() === id);
|
|
86
|
+
const object = collection.objects[index].target;
|
|
87
|
+
if (Obj.isObject(object)) {
|
|
88
|
+
await invokePromise(SpaceOperation.RemoveObjects, {
|
|
89
|
+
objects: [object],
|
|
90
|
+
target: collection,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.
|
|
94
|
+
// delete stack.sections[Path.last(path)];
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
[collection, invokePromise],
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const handleAdd = useCallback(
|
|
101
|
+
async (id: string, position: AddSectionPosition) => {
|
|
102
|
+
// TODO(wittjosiah): Use object creation dialog.
|
|
103
|
+
await invokePromise(LayoutOperation.UpdateDialog, {
|
|
104
|
+
subject: `${meta.id}.AddSectionDialog`,
|
|
105
|
+
blockAlign: 'start',
|
|
106
|
+
props: {
|
|
107
|
+
path: id,
|
|
108
|
+
position,
|
|
109
|
+
collection,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
[collection, invokePromise],
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const handleNavigate = useCallback(
|
|
117
|
+
async (id: string) => {
|
|
118
|
+
await invokePromise(LayoutOperation.Open, { subject: [id] });
|
|
119
|
+
},
|
|
120
|
+
[invokePromise],
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const handleCollapse = useCallback(
|
|
124
|
+
(id: string, collapsed: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: collapsed })),
|
|
125
|
+
[],
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const handleAddSection = useCallback(
|
|
129
|
+
() =>
|
|
130
|
+
invokePromise(SpaceOperation.OpenCreateObject, {
|
|
131
|
+
target: collection,
|
|
132
|
+
navigable: false,
|
|
133
|
+
}),
|
|
134
|
+
[collection, invokePromise],
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<StackItem.Content toolbar classNames='dx-document'>
|
|
139
|
+
<Toolbar.Root>
|
|
140
|
+
<Toolbar.IconButton
|
|
141
|
+
icon='ph--plus--regular'
|
|
142
|
+
iconOnly
|
|
143
|
+
label='Add section'
|
|
144
|
+
data-testid='stack.addSection'
|
|
145
|
+
onClick={handleAddSection}
|
|
146
|
+
/>
|
|
147
|
+
</Toolbar.Root>
|
|
148
|
+
<StackContext.Provider
|
|
149
|
+
value={{
|
|
150
|
+
attendableId: attendableId!,
|
|
151
|
+
onCollapse: handleCollapse,
|
|
152
|
+
onNavigate: handleNavigate,
|
|
153
|
+
onDelete: handleDelete,
|
|
154
|
+
onAdd: handleAdd,
|
|
155
|
+
}}
|
|
156
|
+
>
|
|
157
|
+
<Stack
|
|
158
|
+
orientation='vertical'
|
|
159
|
+
size='intrinsic'
|
|
160
|
+
id={Obj.getDXN(collection).toString()}
|
|
161
|
+
data-testid='main.stack'
|
|
162
|
+
classNames='overflow-y-auto'
|
|
163
|
+
>
|
|
164
|
+
{items.map((item) => (
|
|
165
|
+
<StackSection key={item.id} {...item} />
|
|
166
|
+
))}
|
|
167
|
+
</Stack>
|
|
168
|
+
</StackContext.Provider>
|
|
169
|
+
</StackItem.Content>
|
|
170
|
+
);
|
|
171
|
+
};
|