@dxos/plugin-stack 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
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-BIFUBD3Y.mjs +289 -0
- package/dist/lib/browser/StackContainer-BIFUBD3Y.mjs.map +7 -0
- package/dist/lib/browser/{chunk-MS4QSWEZ.mjs → chunk-4X7CK6FM.mjs} +6 -2
- package/dist/lib/browser/chunk-4X7CK6FM.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NHMDZYOB.mjs → chunk-CD32XYEB.mjs} +9 -10
- package/dist/lib/browser/chunk-CD32XYEB.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +38 -53
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-PVND4UCN.mjs +34 -0
- package/dist/lib/browser/react-surface-PVND4UCN.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/StackContainer-7XVJHW4D.mjs +290 -0
- package/dist/lib/node-esm/StackContainer-7XVJHW4D.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZZFA7HIV.mjs → chunk-26XWE7UY.mjs} +9 -10
- package/dist/lib/node-esm/chunk-26XWE7UY.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5FDDKAPB.mjs → chunk-HEEGXPSW.mjs} +6 -2
- package/dist/lib/node-esm/chunk-HEEGXPSW.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +38 -53
- 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-SZETVRAZ.mjs +35 -0
- package/dist/lib/node-esm/react-surface-SZETVRAZ.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/index.d.ts +2 -7
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/StackContainer/StackContainer.d.ts +9 -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 +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +4 -4
- package/dist/types/src/types/stack.d.ts +12 -13
- package/dist/types/src/types/stack.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +3 -3
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +42 -35
- package/src/StackPlugin.ts +23 -38
- package/src/capabilities/index.ts +1 -3
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +34 -0
- package/src/components/StackSection.tsx +11 -11
- package/src/components/StackSettings.tsx +9 -9
- package/src/components/index.ts +2 -4
- package/src/containers/StackContainer/StackContainer.tsx +169 -0
- package/src/containers/StackContainer/index.ts +7 -0
- package/src/containers/index.ts +7 -0
- package/src/meta.ts +7 -3
- package/src/translations.ts +3 -3
- package/src/types/stack.ts +11 -7
- package/src/types/types.ts +3 -3
- package/dist/lib/browser/StackContainer-SG7NA37F.mjs +0 -298
- package/dist/lib/browser/StackContainer-SG7NA37F.mjs.map +0 -7
- package/dist/lib/browser/chunk-MS4QSWEZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-NHMDZYOB.mjs.map +0 -7
- package/dist/lib/browser/react-surface-OOWGYXKA.mjs +0 -40
- package/dist/lib/browser/react-surface-OOWGYXKA.mjs.map +0 -7
- package/dist/lib/node-esm/StackContainer-YICKOXHG.mjs +0 -299
- package/dist/lib/node-esm/StackContainer-YICKOXHG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5FDDKAPB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZZFA7HIV.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-C5V2EHVG.mjs +0 -41
- package/dist/lib/node-esm/react-surface-C5V2EHVG.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/StackContainer.d.ts +0 -9
- package/dist/types/src/components/StackContainer.d.ts.map +0 -1
- package/src/capabilities/react-surface.tsx +0 -30
- package/src/components/StackContainer.tsx +0 -162
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-stack",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.c85a9c8dae",
|
|
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,
|
|
@@ -35,48 +39,51 @@
|
|
|
35
39
|
"src"
|
|
36
40
|
],
|
|
37
41
|
"dependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@preact/signals-core": "^1.12.1",
|
|
42
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
43
|
+
"@fluentui/react-tabster": "9.26.11",
|
|
41
44
|
"@radix-ui/react-collapsible": "1.1.3",
|
|
42
|
-
"effect": "3.
|
|
45
|
+
"effect": "3.19.16",
|
|
43
46
|
"node-fetch": "^2.6.0",
|
|
44
47
|
"react-is": "~19.2.0",
|
|
45
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/echo": "0.8.4-main.
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/plugin-
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/react-ui-
|
|
58
|
-
"@dxos/react-
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
48
|
+
"@dxos/app-framework": "0.8.4-main.c85a9c8dae",
|
|
49
|
+
"@dxos/app-toolkit": "0.8.4-main.c85a9c8dae",
|
|
50
|
+
"@dxos/async": "0.8.4-main.c85a9c8dae",
|
|
51
|
+
"@dxos/echo-atom": "0.8.4-main.c85a9c8dae",
|
|
52
|
+
"@dxos/client": "0.8.4-main.c85a9c8dae",
|
|
53
|
+
"@dxos/echo": "0.8.4-main.c85a9c8dae",
|
|
54
|
+
"@dxos/invariant": "0.8.4-main.c85a9c8dae",
|
|
55
|
+
"@dxos/plugin-client": "0.8.4-main.c85a9c8dae",
|
|
56
|
+
"@dxos/operation": "0.8.4-main.c85a9c8dae",
|
|
57
|
+
"@dxos/plugin-deck": "0.8.4-main.c85a9c8dae",
|
|
58
|
+
"@dxos/plugin-graph": "0.8.4-main.c85a9c8dae",
|
|
59
|
+
"@dxos/plugin-space": "0.8.4-main.c85a9c8dae",
|
|
60
|
+
"@dxos/react-ui-form": "0.8.4-main.c85a9c8dae",
|
|
61
|
+
"@dxos/react-client": "0.8.4-main.c85a9c8dae",
|
|
62
|
+
"@dxos/react-ui-attention": "0.8.4-main.c85a9c8dae",
|
|
63
|
+
"@dxos/types": "0.8.4-main.c85a9c8dae",
|
|
64
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.c85a9c8dae",
|
|
65
|
+
"@dxos/react-ui-stack": "0.8.4-main.c85a9c8dae",
|
|
66
|
+
"@dxos/util": "0.8.4-main.c85a9c8dae",
|
|
67
|
+
"@dxos/schema": "0.8.4-main.c85a9c8dae"
|
|
62
68
|
},
|
|
63
69
|
"devDependencies": {
|
|
64
70
|
"@babel/core": "^7.18.13",
|
|
65
|
-
"@types/react": "~19.2.
|
|
66
|
-
"@types/react-dom": "~19.2.
|
|
67
|
-
"react": "~19.2.
|
|
68
|
-
"react-dom": "~19.2.
|
|
69
|
-
"vite": "7.1.
|
|
70
|
-
"@dxos/react-ui
|
|
71
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
72
|
-
"@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/react-ui": "0.8.4-main.c85a9c8dae",
|
|
77
|
+
"@dxos/storybook-utils": "0.8.4-main.c85a9c8dae",
|
|
78
|
+
"@dxos/ui-theme": "0.8.4-main.c85a9c8dae"
|
|
73
79
|
},
|
|
74
80
|
"peerDependencies": {
|
|
75
|
-
"effect": "^
|
|
76
|
-
"
|
|
77
|
-
"react
|
|
78
|
-
"
|
|
79
|
-
"@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.c85a9c8dae",
|
|
86
|
+
"@dxos/ui-theme": "0.8.4-main.c85a9c8dae"
|
|
80
87
|
},
|
|
81
88
|
"publishConfig": {
|
|
82
89
|
"access": "public"
|
package/src/StackPlugin.ts
CHANGED
|
@@ -2,50 +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
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
switch (type) {
|
|
29
|
-
case 'node':
|
|
30
|
-
return { id: section.object.id, label: (section.object as any).title, data: section.object };
|
|
31
|
-
case 'object':
|
|
32
|
-
return section.object;
|
|
33
|
-
case 'view-object':
|
|
34
|
-
return section;
|
|
35
|
-
}
|
|
36
|
-
},
|
|
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
|
+
}
|
|
37
28
|
},
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}),
|
|
41
|
-
defineModule({
|
|
42
|
-
id: `${meta.id}/module/schema`,
|
|
43
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
44
|
-
activate: () => contributes(ClientCapabilities.Schema, [StackViewType]),
|
|
45
|
-
}),
|
|
46
|
-
defineModule({
|
|
47
|
-
id: `${meta.id}/module/react-surface`,
|
|
48
|
-
activatesOn: Events.SetupReactSurface,
|
|
49
|
-
activate: ReactSurface,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
50
31
|
}),
|
|
51
|
-
])
|
|
32
|
+
AppPlugin.addSchemaModule({ schema: [StackViewType] }),
|
|
33
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
34
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
35
|
+
Plugin.make,
|
|
36
|
+
);
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { id?: string; subject: Collection.Collection } =>
|
|
24
|
+
Obj.instanceOf(Collection.Collection, data.subject),
|
|
25
|
+
component: ({ role, data }) => {
|
|
26
|
+
// This allows the id to be overridden by the surface for situations where the id of the collection
|
|
27
|
+
// is not the same as the id of what is being represented (e.g., a space with a root collection).
|
|
28
|
+
const id = typeof data.id === 'string' ? data.id : undefined;
|
|
29
|
+
return <StackContainer id={id ?? Obj.getDXN(data.subject).toString()} role={role} subject={data.subject} />;
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
),
|
|
33
|
+
),
|
|
34
|
+
);
|
|
@@ -5,11 +5,11 @@
|
|
|
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';
|
|
8
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
9
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 { getSize, mx, textBlockWidth } from '@dxos/
|
|
12
|
+
import { getSize, mx, textBlockWidth } from '@dxos/ui-theme';
|
|
13
13
|
|
|
14
14
|
import { meta } from '../meta';
|
|
15
15
|
import { type StackSectionItem } from '../types';
|
|
@@ -17,7 +17,7 @@ import { type StackSectionItem } from '../types';
|
|
|
17
17
|
import { CaretDownUp } from './CaretDownUp';
|
|
18
18
|
import { useStack } from './StackContext';
|
|
19
19
|
|
|
20
|
-
const sectionActionDimensions = 'p-1
|
|
20
|
+
const sectionActionDimensions = 'p-1 my-1 shrink-0 min-h-0 w-(--dx-rail-action) h-min';
|
|
21
21
|
|
|
22
22
|
export type StackSectionProps = StackSectionItem;
|
|
23
23
|
|
|
@@ -36,7 +36,7 @@ export const StackSection = ({
|
|
|
36
36
|
return (
|
|
37
37
|
<CollapsiblePrimitive.Root asChild open={!view.collapsed} onOpenChange={(nextOpen) => onCollapse?.(id, !nextOpen)}>
|
|
38
38
|
<StackItem.Root item={stackItem} role='section' {...attentionAttrs}>
|
|
39
|
-
<StackItem.Heading classNames='attention-surface'>
|
|
39
|
+
<StackItem.Heading classNames='dx-attention-surface'>
|
|
40
40
|
<span className='sr-only'>{view.title}</span>
|
|
41
41
|
<StackItem.HeadingStickyContent>
|
|
42
42
|
<DropdownMenu.Root
|
|
@@ -56,27 +56,27 @@ export const StackSection = ({
|
|
|
56
56
|
{view.collapsed ? (
|
|
57
57
|
<DropdownMenu.Item onClick={() => onNavigate(id)} data-testid='section.navigate-to'>
|
|
58
58
|
<Icon icon='ph--arrow-right--regular' size={5} />
|
|
59
|
-
<span className='
|
|
59
|
+
<span className='ms-2 grow'>{t('navigate to section label')}</span>
|
|
60
60
|
</DropdownMenu.Item>
|
|
61
61
|
) : (
|
|
62
62
|
<CollapsiblePrimitive.Trigger asChild>
|
|
63
63
|
<DropdownMenu.Item>
|
|
64
64
|
<CaretDownUp className={getSize(5)} />
|
|
65
|
-
<span className='
|
|
65
|
+
<span className='ms-2 grow'>{t('collapse label')}</span>
|
|
66
66
|
</DropdownMenu.Item>
|
|
67
67
|
</CollapsiblePrimitive.Trigger>
|
|
68
68
|
)}
|
|
69
69
|
<DropdownMenu.Item onClick={() => onAdd(id, 'before')} data-testid='section.add-before'>
|
|
70
70
|
<Icon icon='ph--arrow-line-up--regular' size={5} />
|
|
71
|
-
<span className='
|
|
71
|
+
<span className='ms-2 grow'>{t('add section before label')}</span>
|
|
72
72
|
</DropdownMenu.Item>
|
|
73
73
|
<DropdownMenu.Item onClick={() => onAdd(id, 'after')} data-testid='section.add-after'>
|
|
74
74
|
<Icon icon='ph--arrow-line-down--regular' size={5} />
|
|
75
|
-
<span className='
|
|
75
|
+
<span className='ms-2 grow'>{t('add section after label')}</span>
|
|
76
76
|
</DropdownMenu.Item>
|
|
77
77
|
<DropdownMenu.Item onClick={() => onDelete(id)} data-testid='section.remove'>
|
|
78
78
|
<Icon icon='ph--trash--regular' size={5} />
|
|
79
|
-
<span className='
|
|
79
|
+
<span className='ms-2 grow'>{t('remove section label')}</span>
|
|
80
80
|
</DropdownMenu.Item>
|
|
81
81
|
</DropdownMenu.Viewport>
|
|
82
82
|
<DropdownMenu.Arrow />
|
|
@@ -107,10 +107,10 @@ export const StackSection = ({
|
|
|
107
107
|
</StackItem.HeadingStickyContent>
|
|
108
108
|
</StackItem.Heading>
|
|
109
109
|
<CollapsiblePrimitive.Content>
|
|
110
|
-
<Surface role='section' data={{ subject: object }} limit={1} placeholder={<></>} />
|
|
110
|
+
<Surface.Surface role='section' data={{ subject: object }} limit={1} placeholder={<></>} />
|
|
111
111
|
</CollapsiblePrimitive.Content>
|
|
112
112
|
{view.collapsed && (
|
|
113
|
-
<StackItem.Content classNames='attention-surface'>
|
|
113
|
+
<StackItem.Content classNames='dx-attention-surface'>
|
|
114
114
|
<h2 className={mx('flex items-center p-4 font-medium', textBlockWidth)}>{view.title}</h2>
|
|
115
115
|
</StackItem.Content>
|
|
116
116
|
)}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { Input, useTranslation } from '@dxos/react-ui';
|
|
8
|
-
import {
|
|
8
|
+
import { Settings } from '@dxos/react-ui-form';
|
|
9
9
|
|
|
10
10
|
import { meta } from '../meta';
|
|
11
11
|
import { type StackSettingsProps } from '../types';
|
|
@@ -14,17 +14,17 @@ export const StackSettings = ({ settings }: { settings: StackSettingsProps }) =>
|
|
|
14
14
|
const { t } = useTranslation(meta.id);
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
<
|
|
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
21
|
<Input.Switch
|
|
22
22
|
checked={settings.separation}
|
|
23
23
|
onCheckedChange={(checked) => (settings.separation = !!checked)}
|
|
24
24
|
/>
|
|
25
|
-
</
|
|
26
|
-
</
|
|
27
|
-
</
|
|
28
|
-
</
|
|
25
|
+
</Settings.ItemInput>
|
|
26
|
+
</Settings.Group>
|
|
27
|
+
</Settings.Section>
|
|
28
|
+
</Settings.Root>
|
|
29
29
|
);
|
|
30
30
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,169 @@
|
|
|
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 { AttentionProvider } from '@dxos/react-ui-attention';
|
|
20
|
+
import { Stack, StackItem } from '@dxos/react-ui-stack';
|
|
21
|
+
import { isNonNullable } from '@dxos/util';
|
|
22
|
+
|
|
23
|
+
import { StackContext, StackSection } from '../../components';
|
|
24
|
+
import { meta } from '../../meta';
|
|
25
|
+
import {
|
|
26
|
+
type AddSectionPosition,
|
|
27
|
+
type CollapsedSections,
|
|
28
|
+
type StackSectionItem,
|
|
29
|
+
type StackSectionMetadata,
|
|
30
|
+
type StackSectionView,
|
|
31
|
+
} from '../../types';
|
|
32
|
+
|
|
33
|
+
const collectionObjectsFamily = Atom.family((collection: Collection.Collection) =>
|
|
34
|
+
Atom.make((get) => {
|
|
35
|
+
const snapshot = get(AtomObj.make(collection));
|
|
36
|
+
return (
|
|
37
|
+
snapshot.objects
|
|
38
|
+
// TODO(wittjosiah): Why isn't this type inferred correctly?
|
|
39
|
+
.map((ref: Ref.Ref<Obj.Unknown>) => get(AtomObj.makeWithReactive(ref)))
|
|
40
|
+
.filter(isNonNullable)
|
|
41
|
+
);
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
type StackContainerProps = SurfaceComponentProps<Collection.Collection> & {
|
|
46
|
+
id: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const StackContainer = ({ id, subject: collection }: StackContainerProps) => {
|
|
50
|
+
const { invokePromise } = useOperationInvoker();
|
|
51
|
+
const { graph } = useAppGraph();
|
|
52
|
+
const { t } = useTranslation(meta.id);
|
|
53
|
+
const allMetadata = useCapabilities(AppCapabilities.Metadata);
|
|
54
|
+
const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});
|
|
55
|
+
|
|
56
|
+
// TODO(wittjosiah): Re-implement stack views with relations.
|
|
57
|
+
// const defaultStack = useMemo(() => Obj.make(StackViewType, { sections: {} }), [collection]);
|
|
58
|
+
// const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;
|
|
59
|
+
// useEffect(() => {
|
|
60
|
+
// if (!collection.views[StackViewType.typename]) {
|
|
61
|
+
// collection.views[StackViewType.typename] = Ref.make(stack);
|
|
62
|
+
// }
|
|
63
|
+
// }, [collection, stack]);
|
|
64
|
+
|
|
65
|
+
const collectionObjects = useAtomValue(collectionObjectsFamily(collection));
|
|
66
|
+
const items = collectionObjects.map((object: Obj.Unknown) => {
|
|
67
|
+
const metadata = allMetadata.find((m) => m.id === (Obj.getTypename(object) ?? 'never'))
|
|
68
|
+
?.metadata as StackSectionMetadata;
|
|
69
|
+
const view = {
|
|
70
|
+
// ...stack.sections[object.id],
|
|
71
|
+
collapsed: collapsedSections[Obj.getDXN(object).toString()],
|
|
72
|
+
title:
|
|
73
|
+
(object as any)?.title ??
|
|
74
|
+
// TODO(wittjosiah): `getNode` is not reactive.
|
|
75
|
+
toLocalizedString(
|
|
76
|
+
Graph.getNode(graph, Obj.getDXN(object).toString()).pipe(Option.getOrNull)?.properties.label,
|
|
77
|
+
t,
|
|
78
|
+
),
|
|
79
|
+
} as StackSectionView;
|
|
80
|
+
return { id: Obj.getDXN(object).toString(), object, metadata, view } satisfies StackSectionItem;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const handleDelete = useCallback(
|
|
84
|
+
async (id: string) => {
|
|
85
|
+
const index = collection.objects
|
|
86
|
+
.map((object) => object.target)
|
|
87
|
+
.filter(isNonNullable)
|
|
88
|
+
.findIndex((section) => Obj.getDXN(section).toString() === id);
|
|
89
|
+
const object = collection.objects[index].target;
|
|
90
|
+
if (Obj.isObject(object)) {
|
|
91
|
+
await invokePromise(SpaceOperation.RemoveObjects, {
|
|
92
|
+
objects: [object],
|
|
93
|
+
target: collection,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.
|
|
97
|
+
// delete stack.sections[Path.last(path)];
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
[collection, invokePromise],
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const handleAdd = useCallback(
|
|
104
|
+
async (id: string, position: AddSectionPosition) => {
|
|
105
|
+
// TODO(wittjosiah): Use object creation dialog.
|
|
106
|
+
await invokePromise(LayoutOperation.UpdateDialog, {
|
|
107
|
+
subject: `${meta.id}/AddSectionDialog`,
|
|
108
|
+
blockAlign: 'start',
|
|
109
|
+
props: {
|
|
110
|
+
path: id,
|
|
111
|
+
position,
|
|
112
|
+
collection,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
[collection, invokePromise],
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const handleNavigate = useCallback(
|
|
120
|
+
async (id: string) => {
|
|
121
|
+
await invokePromise(LayoutOperation.Open, { subject: [id] });
|
|
122
|
+
},
|
|
123
|
+
[invokePromise],
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const handleCollapse = useCallback(
|
|
127
|
+
(id: string, collapsed: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: collapsed })),
|
|
128
|
+
[],
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const handleAddSection = useCallback(
|
|
132
|
+
() =>
|
|
133
|
+
invokePromise(SpaceOperation.OpenCreateObject, {
|
|
134
|
+
target: collection,
|
|
135
|
+
navigable: false,
|
|
136
|
+
}),
|
|
137
|
+
[collection, invokePromise],
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<StackItem.Content toolbar classNames='dx-article overflow-hidden border-l border-r border-subdued-separator'>
|
|
142
|
+
<Toolbar.Root>
|
|
143
|
+
<Toolbar.IconButton
|
|
144
|
+
icon='ph--plus--regular'
|
|
145
|
+
iconOnly
|
|
146
|
+
label='Add section'
|
|
147
|
+
data-testid='stack.addSection'
|
|
148
|
+
onClick={handleAddSection}
|
|
149
|
+
/>
|
|
150
|
+
</Toolbar.Root>
|
|
151
|
+
<AttentionProvider id={id}>
|
|
152
|
+
<StackContext.Provider
|
|
153
|
+
value={{
|
|
154
|
+
onCollapse: handleCollapse,
|
|
155
|
+
onNavigate: handleNavigate,
|
|
156
|
+
onDelete: handleDelete,
|
|
157
|
+
onAdd: handleAdd,
|
|
158
|
+
}}
|
|
159
|
+
>
|
|
160
|
+
<Stack orientation='vertical' size='intrinsic' id={id} data-testid='main.stack' classNames='overflow-y-auto'>
|
|
161
|
+
{items.map((item) => (
|
|
162
|
+
<StackSection key={item.id} {...item} />
|
|
163
|
+
))}
|
|
164
|
+
</Stack>
|
|
165
|
+
</StackContext.Provider>
|
|
166
|
+
</AttentionProvider>
|
|
167
|
+
</StackItem.Content>
|
|
168
|
+
);
|
|
169
|
+
};
|
package/src/meta.ts
CHANGED
|
@@ -2,16 +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
8
|
export const SECTION_IDENTIFIER = 'dxos.org/type/StackSection';
|
|
8
9
|
|
|
9
|
-
export const meta:
|
|
10
|
+
export const meta: Plugin.Meta = {
|
|
10
11
|
id: 'dxos.org/plugin/stack',
|
|
11
12
|
// TODO(wittjosiah): Prevents "stacks" language from being exposed to users in settings panel.
|
|
12
13
|
// Conside renaming this to the collection plugin and trying to factor more collections logic from the space plugin.
|
|
13
14
|
name: 'Collections',
|
|
14
|
-
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
|
+
`,
|
|
15
19
|
icon: 'ph--stack-simple--regular',
|
|
16
20
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-stack',
|
|
17
21
|
};
|
package/src/translations.ts
CHANGED
|
@@ -21,16 +21,16 @@ export const translations = [
|
|
|
21
21
|
'add section input placeholder': 'Find the type of section to add',
|
|
22
22
|
'upload file label': 'Add file',
|
|
23
23
|
'add section label': 'Add section',
|
|
24
|
-
'empty stack message': 'Drag
|
|
24
|
+
'empty stack message': 'Drag objects into the stack.',
|
|
25
25
|
'remove section label': 'Delete',
|
|
26
|
-
'navigate to section label': 'Navigate to
|
|
26
|
+
'navigate to section label': 'Navigate to object',
|
|
27
27
|
'untitled section title': 'Untitled section',
|
|
28
28
|
'add section before label': 'Add before',
|
|
29
29
|
'add section after label': 'Add after',
|
|
30
30
|
'expand label': 'Expand',
|
|
31
31
|
'collapse label': 'Collapse',
|
|
32
32
|
'open chat thread label': 'Open chat thread',
|
|
33
|
-
'drag handle label': 'Press space or enter to begin dragging this
|
|
33
|
+
'drag handle label': 'Press space or enter to begin dragging this object.',
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
},
|
package/src/types/stack.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
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
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
import { type FC } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type Obj } from '@dxos/echo';
|
|
8
|
+
import { type Collection } from '@dxos/echo';
|
|
8
9
|
import { type Label } from '@dxos/react-ui';
|
|
9
10
|
import { type StackItemSize } from '@dxos/react-ui-stack';
|
|
10
|
-
import { type DataType } from '@dxos/schema';
|
|
11
11
|
|
|
12
12
|
export type AddSectionPosition = 'before' | 'after' | 'beforeAll' | 'afterAll';
|
|
13
13
|
|
|
14
14
|
export type CollapsedSections = Record<string, boolean>;
|
|
15
15
|
|
|
16
|
-
export type CollectionItem =
|
|
16
|
+
export type CollectionItem = Collection.Collection['objects'][number];
|
|
17
17
|
|
|
18
18
|
export type StackSectionView = {
|
|
19
19
|
title?: string;
|
|
@@ -39,7 +39,7 @@ export type StackSectionMetadata = {
|
|
|
39
39
|
|
|
40
40
|
export type StackSectionItem = {
|
|
41
41
|
id: string;
|
|
42
|
-
object: Obj.
|
|
42
|
+
object: Obj.Unknown;
|
|
43
43
|
view: StackSectionView;
|
|
44
44
|
metadata: StackSectionMetadata;
|
|
45
45
|
};
|