@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
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.c351d160a8",
|
|
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,49 +39,51 @@
|
|
|
33
39
|
"src"
|
|
34
40
|
],
|
|
35
41
|
"dependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@preact/signals-core": "^1.9.0",
|
|
42
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
43
|
+
"@fluentui/react-tabster": "9.26.11",
|
|
39
44
|
"@radix-ui/react-collapsible": "1.1.3",
|
|
40
|
-
"effect": "3.
|
|
45
|
+
"effect": "3.19.16",
|
|
41
46
|
"node-fetch": "^2.6.0",
|
|
42
|
-
"react-is": "~
|
|
43
|
-
"@dxos/app-
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/client": "0.8.4-main.
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/echo
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/plugin-
|
|
52
|
-
"@dxos/plugin-
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/react-ui-attention": "0.8.4-main.
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/react-ui-searchlist": "0.8.4-main.
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
47
|
+
"react-is": "~19.2.0",
|
|
48
|
+
"@dxos/app-toolkit": "0.8.4-main.c351d160a8",
|
|
49
|
+
"@dxos/app-framework": "0.8.4-main.c351d160a8",
|
|
50
|
+
"@dxos/client": "0.8.4-main.c351d160a8",
|
|
51
|
+
"@dxos/async": "0.8.4-main.c351d160a8",
|
|
52
|
+
"@dxos/echo": "0.8.4-main.c351d160a8",
|
|
53
|
+
"@dxos/echo-atom": "0.8.4-main.c351d160a8",
|
|
54
|
+
"@dxos/operation": "0.8.4-main.c351d160a8",
|
|
55
|
+
"@dxos/invariant": "0.8.4-main.c351d160a8",
|
|
56
|
+
"@dxos/plugin-client": "0.8.4-main.c351d160a8",
|
|
57
|
+
"@dxos/plugin-deck": "0.8.4-main.c351d160a8",
|
|
58
|
+
"@dxos/plugin-graph": "0.8.4-main.c351d160a8",
|
|
59
|
+
"@dxos/react-client": "0.8.4-main.c351d160a8",
|
|
60
|
+
"@dxos/plugin-space": "0.8.4-main.c351d160a8",
|
|
61
|
+
"@dxos/react-ui-attention": "0.8.4-main.c351d160a8",
|
|
62
|
+
"@dxos/react-ui-stack": "0.8.4-main.c351d160a8",
|
|
63
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.c351d160a8",
|
|
64
|
+
"@dxos/react-ui-form": "0.8.4-main.c351d160a8",
|
|
65
|
+
"@dxos/schema": "0.8.4-main.c351d160a8",
|
|
66
|
+
"@dxos/util": "0.8.4-main.c351d160a8",
|
|
67
|
+
"@dxos/types": "0.8.4-main.c351d160a8"
|
|
61
68
|
},
|
|
62
69
|
"devDependencies": {
|
|
63
70
|
"@babel/core": "^7.18.13",
|
|
64
|
-
"@types/react": "~
|
|
65
|
-
"@types/react-dom": "~
|
|
66
|
-
"react": "~
|
|
67
|
-
"react-dom": "~
|
|
68
|
-
"vite": "
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/react-ui
|
|
71
|
-
"@dxos/
|
|
71
|
+
"@types/react": "~19.2.7",
|
|
72
|
+
"@types/react-dom": "~19.2.3",
|
|
73
|
+
"react": "~19.2.3",
|
|
74
|
+
"react-dom": "~19.2.3",
|
|
75
|
+
"vite": "^7.1.11",
|
|
76
|
+
"@dxos/storybook-utils": "0.8.4-main.c351d160a8",
|
|
77
|
+
"@dxos/react-ui": "0.8.4-main.c351d160a8",
|
|
78
|
+
"@dxos/ui-theme": "0.8.4-main.c351d160a8"
|
|
72
79
|
},
|
|
73
80
|
"peerDependencies": {
|
|
74
|
-
"effect": "^
|
|
75
|
-
"
|
|
76
|
-
"react
|
|
77
|
-
"
|
|
78
|
-
"@dxos/react-ui
|
|
81
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
82
|
+
"effect": "3.19.16",
|
|
83
|
+
"react": "~19.2.3",
|
|
84
|
+
"react-dom": "~19.2.3",
|
|
85
|
+
"@dxos/react-ui": "0.8.4-main.c351d160a8",
|
|
86
|
+
"@dxos/ui-theme": "0.8.4-main.c351d160a8"
|
|
79
87
|
},
|
|
80
88
|
"publishConfig": {
|
|
81
89
|
"access": "public"
|
package/src/StackPlugin.ts
CHANGED
|
@@ -2,51 +2,35 @@
|
|
|
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
9
|
import { ReactSurface } from './capabilities';
|
|
10
|
-
import {
|
|
10
|
+
import { SECTION_IDENTIFIER, meta } from './meta';
|
|
11
11
|
import { translations } from './translations';
|
|
12
12
|
import { StackViewType } from './types';
|
|
13
13
|
|
|
14
|
-
export const StackPlugin = ()
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
id:
|
|
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
|
-
]);
|
|
14
|
+
export const StackPlugin = Plugin.define(meta).pipe(
|
|
15
|
+
AppPlugin.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
|
+
AppPlugin.addSchemaModule({ schema: [StackViewType] }),
|
|
33
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
34
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
35
|
+
Plugin.make,
|
|
36
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
11
|
+
import { Collection } from '@dxos/echo';
|
|
12
|
+
|
|
13
|
+
import { StackContainer } from '../../containers';
|
|
14
|
+
import { meta } from '../../meta';
|
|
15
|
+
|
|
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';
|
|
13
16
|
|
|
14
17
|
import { CaretDownUp } from './CaretDownUp';
|
|
15
|
-
import { useStack } from '
|
|
16
|
-
import { STACK_PLUGIN } from '../meta';
|
|
17
|
-
import { type StackSectionItem } from '../types';
|
|
18
|
+
import { useStack } from '../StackContext';
|
|
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
|
|
@@ -55,27 +58,27 @@ export const StackSection = ({
|
|
|
55
58
|
{view.collapsed ? (
|
|
56
59
|
<DropdownMenu.Item onClick={() => onNavigate(id)} data-testid='section.navigate-to'>
|
|
57
60
|
<Icon icon='ph--arrow-right--regular' size={5} />
|
|
58
|
-
<span className='
|
|
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
72
|
<Icon icon='ph--arrow-line-up--regular' size={5} />
|
|
70
|
-
<span className='
|
|
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
76
|
<Icon icon='ph--arrow-line-down--regular' size={5} />
|
|
74
|
-
<span className='
|
|
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
80
|
<Icon icon='ph--trash--regular' size={5} />
|
|
78
|
-
<span className='
|
|
81
|
+
<span className='ms-2 grow'>{t('remove section label')}</span>
|
|
79
82
|
</DropdownMenu.Item>
|
|
80
83
|
</DropdownMenu.Viewport>
|
|
81
84
|
<DropdownMenu.Arrow />
|
|
@@ -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,30 @@
|
|
|
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 } 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
|
+
<Settings.Root>
|
|
18
|
+
<Settings.Section title={t('settings title', { ns: meta.id })}>
|
|
19
|
+
<Settings.Group>
|
|
20
|
+
<Settings.ItemInput title={t('settings separation label')}>
|
|
21
|
+
<Input.Switch
|
|
22
|
+
checked={settings.separation}
|
|
23
|
+
onCheckedChange={(checked) => (settings.separation = !!checked)}
|
|
24
|
+
/>
|
|
25
|
+
</Settings.ItemInput>
|
|
26
|
+
</Settings.Group>
|
|
27
|
+
</Settings.Section>
|
|
28
|
+
</Settings.Root>
|
|
29
|
+
);
|
|
30
|
+
};
|
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 SurfaceComponentProps } 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/types';
|
|
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 = SurfaceComponentProps<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
|
+
};
|
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
|
|
8
|
-
export const SECTION_IDENTIFIER = 'dxos.org/type/StackSection';
|
|
8
|
+
export const SECTION_IDENTIFIER = 'org.dxos.type.stack-section';
|
|
9
9
|
|
|
10
|
-
export const meta:
|
|
11
|
-
id:
|
|
10
|
+
export const meta: Plugin.Meta = {
|
|
11
|
+
id: 'org.dxos.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
|
};
|