@dxos/plugin-stack 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7
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 → StackContainer-OLHE5F4E.mjs} +74 -54
- package/dist/lib/browser/StackContainer-OLHE5F4E.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4X7CK6FM.mjs → chunk-G4CLPE5A.mjs} +3 -3
- package/dist/lib/browser/chunk-G4CLPE5A.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CD32XYEB.mjs → chunk-YPQYUBQP.mjs} +2 -2
- package/dist/lib/browser/{chunk-CD32XYEB.mjs.map → chunk-YPQYUBQP.mjs.map} +1 -1
- package/dist/lib/browser/index.mjs +10 -9
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-JS4ERDMQ.mjs +33 -0
- package/dist/lib/browser/react-surface-JS4ERDMQ.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{StackContainer-PTZGEQFQ.mjs → StackContainer-W3M7BKLT.mjs} +74 -54
- package/dist/lib/node-esm/StackContainer-W3M7BKLT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-26XWE7UY.mjs → chunk-LELGTQAL.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-26XWE7UY.mjs.map → chunk-LELGTQAL.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-HEEGXPSW.mjs → chunk-LOZ6GH5A.mjs} +3 -3
- package/dist/lib/node-esm/chunk-LOZ6GH5A.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +10 -9
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-YKS4OHR3.mjs +34 -0
- package/dist/lib/node-esm/react-surface-YKS4OHR3.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/StackPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/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 -9
- 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 +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +1 -1
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +31 -27
- package/src/StackPlugin.ts +6 -5
- package/src/capabilities/react-surface/react-surface.tsx +10 -12
- 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} +17 -15
- 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/{components → containers/StackContainer}/StackContainer.tsx +67 -62
- package/src/containers/StackContainer/index.ts +7 -0
- package/src/containers/index.ts +7 -0
- package/src/meta.ts +2 -2
- package/src/types/stack.ts +1 -1
- package/src/types/types.ts +1 -1
- package/dist/lib/browser/StackContainer-FUGH3ZJH.mjs.map +0 -7
- package/dist/lib/browser/chunk-4X7CK6FM.mjs.map +0 -7
- package/dist/lib/browser/react-surface-ZEFLABZS.mjs +0 -40
- package/dist/lib/browser/react-surface-ZEFLABZS.mjs.map +0 -7
- package/dist/lib/node-esm/StackContainer-PTZGEQFQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HEEGXPSW.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-JQOFHBYS.mjs +0 -41
- package/dist/lib/node-esm/react-surface-JQOFHBYS.mjs.map +0 -7
- package/dist/types/src/components/CaretDownUp.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/dist/types/src/components/StackContext.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/StackSettings.tsx +0 -30
- /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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-stack",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.6fa680abb7",
|
|
4
4
|
"description": "DXOS Surface plugin for Stack entities",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -39,29 +39,32 @@
|
|
|
39
39
|
"src"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
42
43
|
"@fluentui/react-tabster": "9.26.11",
|
|
43
44
|
"@radix-ui/react-collapsible": "1.1.3",
|
|
44
|
-
"effect": "3.19.
|
|
45
|
+
"effect": "3.19.16",
|
|
45
46
|
"node-fetch": "^2.6.0",
|
|
46
47
|
"react-is": "~19.2.0",
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/plugin-deck": "0.8.4-main.
|
|
55
|
-
"@dxos/plugin-
|
|
56
|
-
"@dxos/plugin-
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/react-client": "0.8.4-main.
|
|
59
|
-
"@dxos/react-ui-form": "0.8.4-main.
|
|
60
|
-
"@dxos/react-ui-searchlist": "0.8.4-main.
|
|
61
|
-
"@dxos/react-ui-
|
|
62
|
-
"@dxos/schema": "0.8.4-main.
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/util": "0.8.4-main.
|
|
48
|
+
"@dxos/async": "0.8.4-main.6fa680abb7",
|
|
49
|
+
"@dxos/app-framework": "0.8.4-main.6fa680abb7",
|
|
50
|
+
"@dxos/client": "0.8.4-main.6fa680abb7",
|
|
51
|
+
"@dxos/echo": "0.8.4-main.6fa680abb7",
|
|
52
|
+
"@dxos/echo-atom": "0.8.4-main.6fa680abb7",
|
|
53
|
+
"@dxos/invariant": "0.8.4-main.6fa680abb7",
|
|
54
|
+
"@dxos/operation": "0.8.4-main.6fa680abb7",
|
|
55
|
+
"@dxos/plugin-deck": "0.8.4-main.6fa680abb7",
|
|
56
|
+
"@dxos/plugin-client": "0.8.4-main.6fa680abb7",
|
|
57
|
+
"@dxos/plugin-graph": "0.8.4-main.6fa680abb7",
|
|
58
|
+
"@dxos/plugin-space": "0.8.4-main.6fa680abb7",
|
|
59
|
+
"@dxos/react-client": "0.8.4-main.6fa680abb7",
|
|
60
|
+
"@dxos/react-ui-form": "0.8.4-main.6fa680abb7",
|
|
61
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.6fa680abb7",
|
|
62
|
+
"@dxos/react-ui-attention": "0.8.4-main.6fa680abb7",
|
|
63
|
+
"@dxos/schema": "0.8.4-main.6fa680abb7",
|
|
64
|
+
"@dxos/react-ui-stack": "0.8.4-main.6fa680abb7",
|
|
65
|
+
"@dxos/util": "0.8.4-main.6fa680abb7",
|
|
66
|
+
"@dxos/types": "0.8.4-main.6fa680abb7",
|
|
67
|
+
"@dxos/app-toolkit": "0.8.4-main.6fa680abb7"
|
|
65
68
|
},
|
|
66
69
|
"devDependencies": {
|
|
67
70
|
"@babel/core": "^7.18.13",
|
|
@@ -69,17 +72,18 @@
|
|
|
69
72
|
"@types/react-dom": "~19.2.3",
|
|
70
73
|
"react": "~19.2.3",
|
|
71
74
|
"react-dom": "~19.2.3",
|
|
72
|
-
"vite": "7.1.
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
75
|
+
"vite": "^7.1.11",
|
|
76
|
+
"@dxos/react-ui": "0.8.4-main.6fa680abb7",
|
|
77
|
+
"@dxos/storybook-utils": "0.8.4-main.6fa680abb7",
|
|
78
|
+
"@dxos/ui-theme": "0.8.4-main.6fa680abb7"
|
|
76
79
|
},
|
|
77
80
|
"peerDependencies": {
|
|
78
|
-
"effect": "
|
|
81
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
82
|
+
"effect": "3.19.16",
|
|
79
83
|
"react": "~19.2.3",
|
|
80
84
|
"react-dom": "~19.2.3",
|
|
81
|
-
"@dxos/ui
|
|
82
|
-
"@dxos/
|
|
85
|
+
"@dxos/react-ui": "0.8.4-main.6fa680abb7",
|
|
86
|
+
"@dxos/ui-theme": "0.8.4-main.6fa680abb7"
|
|
83
87
|
},
|
|
84
88
|
"publishConfig": {
|
|
85
89
|
"access": "public"
|
package/src/StackPlugin.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
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
8
|
|
|
8
9
|
import { ReactSurface } from './capabilities';
|
|
@@ -11,8 +12,7 @@ import { translations } from './translations';
|
|
|
11
12
|
import { StackViewType } from './types';
|
|
12
13
|
|
|
13
14
|
export const StackPlugin = Plugin.define(meta).pipe(
|
|
14
|
-
|
|
15
|
-
Common.Plugin.addMetadataModule({
|
|
15
|
+
AppPlugin.addMetadataModule({
|
|
16
16
|
metadata: {
|
|
17
17
|
id: SECTION_IDENTIFIER,
|
|
18
18
|
metadata: {
|
|
@@ -29,7 +29,8 @@ export const StackPlugin = Plugin.define(meta).pipe(
|
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
}),
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
AppPlugin.addSchemaModule({ schema: [StackViewType] }),
|
|
33
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
34
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
34
35
|
Plugin.make,
|
|
35
36
|
);
|
|
@@ -5,27 +5,25 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
9
10
|
import { Obj } from '@dxos/echo';
|
|
10
|
-
import { Collection } from '@dxos/
|
|
11
|
+
import { Collection } from '@dxos/echo';
|
|
11
12
|
|
|
12
|
-
import { StackContainer } from '../../
|
|
13
|
+
import { StackContainer } from '../../containers';
|
|
13
14
|
import { meta } from '../../meta';
|
|
14
15
|
|
|
15
16
|
export default Capability.makeModule(() =>
|
|
16
17
|
Effect.succeed(
|
|
17
18
|
Capability.contributes(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
id: `${meta.id}
|
|
19
|
+
Capabilities.ReactSurface,
|
|
20
|
+
Surface.create({
|
|
21
|
+
id: `${meta.id}.article`,
|
|
21
22
|
role: 'article',
|
|
22
|
-
filter: (data): data is {
|
|
23
|
-
Obj.instanceOf(Collection.Collection, data.subject),
|
|
23
|
+
filter: (data): data is { attendableId: string; subject: Collection.Collection } =>
|
|
24
|
+
typeof data.attendableId === 'string' && Obj.instanceOf(Collection.Collection, data.subject),
|
|
24
25
|
component: ({ role, data }) => {
|
|
25
|
-
|
|
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} />;
|
|
26
|
+
return <StackContainer attendableId={data.attendableId} role={role} subject={data.subject} />;
|
|
29
27
|
},
|
|
30
28
|
}),
|
|
31
29
|
),
|
|
@@ -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,19 +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/
|
|
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
12
|
import { getSize, mx, textBlockWidth } from '@dxos/ui-theme';
|
|
13
13
|
|
|
14
|
-
import { meta } from '
|
|
15
|
-
import { type StackSectionItem } from '
|
|
14
|
+
import { meta } from '../../meta';
|
|
15
|
+
import { type StackSectionItem } from '../../types';
|
|
16
16
|
|
|
17
17
|
import { CaretDownUp } from './CaretDownUp';
|
|
18
|
-
import { useStack } from '
|
|
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
|
|
|
@@ -28,15 +28,17 @@ export const StackSection = ({
|
|
|
28
28
|
metadata: { icon = 'ph--placeholder--regular' },
|
|
29
29
|
}: StackSectionProps) => {
|
|
30
30
|
const { t } = useTranslation(meta.id);
|
|
31
|
-
const { onNavigate, onAdd, onCollapse, onDelete } = useStack();
|
|
31
|
+
const { attendableId: parentAttendableId, onNavigate, onAdd, onCollapse, onDelete } = useStack();
|
|
32
32
|
const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);
|
|
33
|
-
const
|
|
33
|
+
const attendableId = `${parentAttendableId}/${object.id}`;
|
|
34
|
+
const attentionAttrs = useAttentionAttributes(attendableId);
|
|
34
35
|
const stackItem = useMemo(() => ({ id }), [id]);
|
|
36
|
+
const data = useMemo(() => ({ attendableId, subject: object }), [object, attendableId]);
|
|
35
37
|
|
|
36
38
|
return (
|
|
37
39
|
<CollapsiblePrimitive.Root asChild open={!view.collapsed} onOpenChange={(nextOpen) => onCollapse?.(id, !nextOpen)}>
|
|
38
40
|
<StackItem.Root item={stackItem} role='section' {...attentionAttrs}>
|
|
39
|
-
<StackItem.Heading classNames='attention-surface'>
|
|
41
|
+
<StackItem.Heading classNames='dx-attention-surface'>
|
|
40
42
|
<span className='sr-only'>{view.title}</span>
|
|
41
43
|
<StackItem.HeadingStickyContent>
|
|
42
44
|
<DropdownMenu.Root
|
|
@@ -56,27 +58,27 @@ export const StackSection = ({
|
|
|
56
58
|
{view.collapsed ? (
|
|
57
59
|
<DropdownMenu.Item onClick={() => onNavigate(id)} data-testid='section.navigate-to'>
|
|
58
60
|
<Icon icon='ph--arrow-right--regular' size={5} />
|
|
59
|
-
<span className='
|
|
61
|
+
<span className='ms-2 grow'>{t('navigate to section label')}</span>
|
|
60
62
|
</DropdownMenu.Item>
|
|
61
63
|
) : (
|
|
62
64
|
<CollapsiblePrimitive.Trigger asChild>
|
|
63
65
|
<DropdownMenu.Item>
|
|
64
66
|
<CaretDownUp className={getSize(5)} />
|
|
65
|
-
<span className='
|
|
67
|
+
<span className='ms-2 grow'>{t('collapse label')}</span>
|
|
66
68
|
</DropdownMenu.Item>
|
|
67
69
|
</CollapsiblePrimitive.Trigger>
|
|
68
70
|
)}
|
|
69
71
|
<DropdownMenu.Item onClick={() => onAdd(id, 'before')} data-testid='section.add-before'>
|
|
70
72
|
<Icon icon='ph--arrow-line-up--regular' size={5} />
|
|
71
|
-
<span className='
|
|
73
|
+
<span className='ms-2 grow'>{t('add section before label')}</span>
|
|
72
74
|
</DropdownMenu.Item>
|
|
73
75
|
<DropdownMenu.Item onClick={() => onAdd(id, 'after')} data-testid='section.add-after'>
|
|
74
76
|
<Icon icon='ph--arrow-line-down--regular' size={5} />
|
|
75
|
-
<span className='
|
|
77
|
+
<span className='ms-2 grow'>{t('add section after label')}</span>
|
|
76
78
|
</DropdownMenu.Item>
|
|
77
79
|
<DropdownMenu.Item onClick={() => onDelete(id)} data-testid='section.remove'>
|
|
78
80
|
<Icon icon='ph--trash--regular' size={5} />
|
|
79
|
-
<span className='
|
|
81
|
+
<span className='ms-2 grow'>{t('remove section label')}</span>
|
|
80
82
|
</DropdownMenu.Item>
|
|
81
83
|
</DropdownMenu.Viewport>
|
|
82
84
|
<DropdownMenu.Arrow />
|
|
@@ -107,10 +109,10 @@ export const StackSection = ({
|
|
|
107
109
|
</StackItem.HeadingStickyContent>
|
|
108
110
|
</StackItem.Heading>
|
|
109
111
|
<CollapsiblePrimitive.Content>
|
|
110
|
-
<Surface role='section' data={
|
|
112
|
+
<Surface.Surface role='section' data={data} limit={1} placeholder={<></>} />
|
|
111
113
|
</CollapsiblePrimitive.Content>
|
|
112
114
|
{view.collapsed && (
|
|
113
|
-
<StackItem.Content classNames='attention-surface'>
|
|
115
|
+
<StackItem.Content classNames='dx-attention-surface'>
|
|
114
116
|
<h2 className={mx('flex items-center p-4 font-medium', textBlockWidth)}>{view.title}</h2>
|
|
115
117
|
</StackItem.Content>
|
|
116
118
|
)}
|
|
@@ -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
|
@@ -2,42 +2,52 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Atom, useAtomValue } from '@effect-atom/atom-react';
|
|
5
6
|
import * as Option from 'effect/Option';
|
|
6
7
|
import React, { useCallback, useState } from 'react';
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { type SurfaceComponentProps } from '@dxos/app-
|
|
11
|
-
import {
|
|
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';
|
|
12
16
|
import { Graph } from '@dxos/plugin-graph';
|
|
13
17
|
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
14
18
|
import { Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
15
|
-
import { AttentionProvider } from '@dxos/react-ui-attention';
|
|
16
19
|
import { Stack, StackItem } from '@dxos/react-ui-stack';
|
|
17
|
-
import { type Collection } from '@dxos/schema';
|
|
18
20
|
import { isNonNullable } from '@dxos/util';
|
|
19
21
|
|
|
20
|
-
import {
|
|
22
|
+
import { StackContext, StackSection } from '../../components';
|
|
23
|
+
import { meta } from '../../meta';
|
|
21
24
|
import {
|
|
22
25
|
type AddSectionPosition,
|
|
23
26
|
type CollapsedSections,
|
|
24
27
|
type StackSectionItem,
|
|
25
28
|
type StackSectionMetadata,
|
|
26
29
|
type StackSectionView,
|
|
27
|
-
} from '
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
);
|
|
31
43
|
|
|
32
|
-
type StackContainerProps = SurfaceComponentProps<Collection.Collection
|
|
33
|
-
id: string;
|
|
34
|
-
};
|
|
44
|
+
type StackContainerProps = SurfaceComponentProps<Collection.Collection>;
|
|
35
45
|
|
|
36
|
-
const StackContainer = ({
|
|
46
|
+
export const StackContainer = ({ attendableId, subject: collection }: StackContainerProps) => {
|
|
37
47
|
const { invokePromise } = useOperationInvoker();
|
|
38
48
|
const { graph } = useAppGraph();
|
|
39
49
|
const { t } = useTranslation(meta.id);
|
|
40
|
-
const allMetadata = useCapabilities(
|
|
50
|
+
const allMetadata = useCapabilities(AppCapabilities.Metadata);
|
|
41
51
|
const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});
|
|
42
52
|
|
|
43
53
|
// TODO(wittjosiah): Re-implement stack views with relations.
|
|
@@ -49,28 +59,23 @@ const StackContainer = ({ id, subject: collection }: StackContainerProps) => {
|
|
|
49
59
|
// }
|
|
50
60
|
// }, [collection, stack]);
|
|
51
61
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.
|
|
58
|
-
.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
t,
|
|
70
|
-
),
|
|
71
|
-
} as StackSectionView;
|
|
72
|
-
return { id: Obj.getDXN(object).toString(), object, metadata, view } satisfies StackSectionItem;
|
|
73
|
-
}) ?? [];
|
|
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
|
+
});
|
|
74
79
|
|
|
75
80
|
const handleDelete = useCallback(
|
|
76
81
|
async (id: string) => {
|
|
@@ -95,8 +100,8 @@ const StackContainer = ({ id, subject: collection }: StackContainerProps) => {
|
|
|
95
100
|
const handleAdd = useCallback(
|
|
96
101
|
async (id: string, position: AddSectionPosition) => {
|
|
97
102
|
// TODO(wittjosiah): Use object creation dialog.
|
|
98
|
-
await invokePromise(
|
|
99
|
-
subject: `${meta.id}
|
|
103
|
+
await invokePromise(LayoutOperation.UpdateDialog, {
|
|
104
|
+
subject: `${meta.id}.AddSectionDialog`,
|
|
100
105
|
blockAlign: 'start',
|
|
101
106
|
props: {
|
|
102
107
|
path: id,
|
|
@@ -110,7 +115,7 @@ const StackContainer = ({ id, subject: collection }: StackContainerProps) => {
|
|
|
110
115
|
|
|
111
116
|
const handleNavigate = useCallback(
|
|
112
117
|
async (id: string) => {
|
|
113
|
-
await invokePromise(
|
|
118
|
+
await invokePromise(LayoutOperation.Open, { subject: [id] });
|
|
114
119
|
},
|
|
115
120
|
[invokePromise],
|
|
116
121
|
);
|
|
@@ -130,10 +135,7 @@ const StackContainer = ({ id, subject: collection }: StackContainerProps) => {
|
|
|
130
135
|
);
|
|
131
136
|
|
|
132
137
|
return (
|
|
133
|
-
<StackItem.Content
|
|
134
|
-
toolbar
|
|
135
|
-
classNames='container-max-width overflow-hidden border-l border-r border-subduedSeparator'
|
|
136
|
-
>
|
|
138
|
+
<StackItem.Content toolbar classNames='dx-article overflow-hidden border-l border-r border-subdued-separator'>
|
|
137
139
|
<Toolbar.Root>
|
|
138
140
|
<Toolbar.IconButton
|
|
139
141
|
icon='ph--plus--regular'
|
|
@@ -143,24 +145,27 @@ const StackContainer = ({ id, subject: collection }: StackContainerProps) => {
|
|
|
143
145
|
onClick={handleAddSection}
|
|
144
146
|
/>
|
|
145
147
|
</Toolbar.Root>
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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'
|
|
154
163
|
>
|
|
155
|
-
|
|
156
|
-
{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
</StackContext.Provider>
|
|
161
|
-
</AttentionProvider>
|
|
164
|
+
{items.map((item) => (
|
|
165
|
+
<StackSection key={item.id} {...item} />
|
|
166
|
+
))}
|
|
167
|
+
</Stack>
|
|
168
|
+
</StackContext.Provider>
|
|
162
169
|
</StackItem.Content>
|
|
163
170
|
);
|
|
164
171
|
};
|
|
165
|
-
|
|
166
|
-
export default StackContainer;
|
package/src/meta.ts
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import { type Plugin } from '@dxos/app-framework';
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
export const SECTION_IDENTIFIER = 'dxos.
|
|
8
|
+
export const SECTION_IDENTIFIER = 'org.dxos.type.stack-section';
|
|
9
9
|
|
|
10
10
|
export const meta: Plugin.Meta = {
|
|
11
|
-
id: 'dxos.
|
|
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',
|
package/src/types/stack.ts
CHANGED
|
@@ -23,7 +23,7 @@ export const StackViewType = Schema.Struct({
|
|
|
23
23
|
sections: Schema.Record({ key: Schema.String, value: SectionSchema }),
|
|
24
24
|
}).pipe(
|
|
25
25
|
Type.object({
|
|
26
|
-
typename: 'dxos.
|
|
26
|
+
typename: 'org.dxos.type.stack-view',
|
|
27
27
|
version: '0.1.0',
|
|
28
28
|
}),
|
|
29
29
|
);
|
package/src/types/types.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
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 Collection } from '@dxos/schema';
|
|
11
11
|
|
|
12
12
|
export type AddSectionPosition = 'before' | 'after' | 'beforeAll' | 'afterAll';
|
|
13
13
|
|