@dxos/plugin-stack 0.8.4-main.f9ba587 → 0.8.4-main.fffef41
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/{StackMain-6EC3A3IC.mjs → StackContainer-DD3ZD5OE.mjs} +37 -36
- package/dist/lib/browser/StackContainer-DD3ZD5OE.mjs.map +7 -0
- package/dist/lib/browser/{chunk-VDSBIEAC.mjs → chunk-NHMDZYOB.mjs} +3 -3
- package/dist/lib/browser/chunk-NHMDZYOB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FVB7LGW7.mjs → chunk-UIKFKRFJ.mjs} +7 -5
- package/dist/lib/browser/chunk-UIKFKRFJ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +6 -7
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-HVPK7YZQ.mjs +39 -0
- package/dist/lib/browser/react-surface-HVPK7YZQ.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{StackMain-G55P33OY.mjs → StackContainer-JGWPXSUF.mjs} +37 -36
- package/dist/lib/node-esm/StackContainer-JGWPXSUF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UN5PA7TK.mjs → chunk-BGVQYUYP.mjs} +7 -5
- package/dist/lib/node-esm/chunk-BGVQYUYP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GOXSWCA4.mjs → chunk-ZZFA7HIV.mjs} +3 -3
- package/dist/lib/node-esm/chunk-ZZFA7HIV.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +6 -7
- 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-HYSD7AC2.mjs +40 -0
- package/dist/lib/node-esm/react-surface-HYSD7AC2.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/StackPlugin.d.ts +1 -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.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/StackContainer.d.ts +9 -0
- package/dist/types/src/components/StackContainer.d.ts.map +1 -0
- package/dist/types/src/components/StackSection.d.ts.map +1 -1
- package/dist/types/src/components/StackSettings.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/stack.d.ts +3 -3
- package/dist/types/src/types/stack.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +6 -4
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +36 -36
- package/src/StackPlugin.ts +39 -40
- package/src/capabilities/react-surface.tsx +7 -12
- package/src/components/{StackMain.tsx → StackContainer.tsx} +64 -52
- package/src/components/StackSection.tsx +7 -6
- package/src/components/StackSettings.tsx +15 -8
- package/src/components/index.ts +1 -1
- package/src/meta.ts +6 -3
- package/src/translations.ts +1 -0
- package/src/types/index.ts +1 -1
- package/src/types/stack.ts +2 -2
- package/src/types/types.ts +3 -4
- package/dist/lib/browser/StackMain-6EC3A3IC.mjs.map +0 -7
- package/dist/lib/browser/chunk-FVB7LGW7.mjs.map +0 -7
- package/dist/lib/browser/chunk-VDSBIEAC.mjs.map +0 -7
- package/dist/lib/browser/react-surface-KLOW5O2E.mjs +0 -46
- package/dist/lib/browser/react-surface-KLOW5O2E.mjs.map +0 -7
- package/dist/lib/node-esm/StackMain-G55P33OY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GOXSWCA4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UN5PA7TK.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-H33L4IMD.mjs +0 -47
- package/dist/lib/node-esm/react-surface-H33L4IMD.mjs.map +0 -7
- package/dist/types/src/components/StackMain.d.ts +0 -9
- package/dist/types/src/components/StackMain.d.ts.map +0 -1
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.fffef41",
|
|
4
4
|
"description": "DXOS Surface plugin for Stack entities",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"source": "./src/index.ts",
|
|
13
14
|
"types": "./dist/types/src/index.d.ts",
|
|
14
15
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
16
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
17
|
},
|
|
17
18
|
"./types": {
|
|
19
|
+
"source": "./src/types/index.ts",
|
|
18
20
|
"types": "./dist/types/src/types/index.d.ts",
|
|
19
21
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
20
22
|
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
@@ -35,49 +37,47 @@
|
|
|
35
37
|
"dependencies": {
|
|
36
38
|
"@fluentui/react-tabster": "^9.24.2",
|
|
37
39
|
"@preact-signals/safe-react": "^0.9.0",
|
|
38
|
-
"@preact/signals-core": "^1.
|
|
40
|
+
"@preact/signals-core": "^1.12.1",
|
|
39
41
|
"@radix-ui/react-collapsible": "1.1.3",
|
|
40
|
-
"effect": "3.
|
|
42
|
+
"effect": "3.18.3",
|
|
41
43
|
"node-fetch": "^2.6.0",
|
|
42
|
-
"react-is": "~
|
|
43
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
44
|
-
"@dxos/async": "0.8.4-main.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/echo
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/plugin-
|
|
51
|
-
"@dxos/plugin-
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/react-ui-form": "0.8.4-main.
|
|
56
|
-
"@dxos/react-ui-
|
|
57
|
-
"@dxos/react-ui-searchlist": "0.8.4-main.
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/util": "0.8.4-main.
|
|
44
|
+
"react-is": "~19.2.0",
|
|
45
|
+
"@dxos/app-framework": "0.8.4-main.fffef41",
|
|
46
|
+
"@dxos/async": "0.8.4-main.fffef41",
|
|
47
|
+
"@dxos/invariant": "0.8.4-main.fffef41",
|
|
48
|
+
"@dxos/client": "0.8.4-main.fffef41",
|
|
49
|
+
"@dxos/echo": "0.8.4-main.fffef41",
|
|
50
|
+
"@dxos/local-storage": "0.8.4-main.fffef41",
|
|
51
|
+
"@dxos/plugin-deck": "0.8.4-main.fffef41",
|
|
52
|
+
"@dxos/plugin-graph": "0.8.4-main.fffef41",
|
|
53
|
+
"@dxos/plugin-space": "0.8.4-main.fffef41",
|
|
54
|
+
"@dxos/react-client": "0.8.4-main.fffef41",
|
|
55
|
+
"@dxos/react-ui-attention": "0.8.4-main.fffef41",
|
|
56
|
+
"@dxos/plugin-client": "0.8.4-main.fffef41",
|
|
57
|
+
"@dxos/react-ui-form": "0.8.4-main.fffef41",
|
|
58
|
+
"@dxos/react-ui-stack": "0.8.4-main.fffef41",
|
|
59
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.fffef41",
|
|
60
|
+
"@dxos/schema": "0.8.4-main.fffef41",
|
|
61
|
+
"@dxos/types": "0.8.4-main.fffef41",
|
|
62
|
+
"@dxos/util": "0.8.4-main.fffef41"
|
|
61
63
|
},
|
|
62
64
|
"devDependencies": {
|
|
63
65
|
"@babel/core": "^7.18.13",
|
|
64
|
-
"@
|
|
65
|
-
"@types/react": "~
|
|
66
|
-
"
|
|
67
|
-
"react": "~
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/storybook-utils": "0.8.4-main.f9ba587"
|
|
66
|
+
"@types/react": "~19.2.2",
|
|
67
|
+
"@types/react-dom": "~19.2.2",
|
|
68
|
+
"react": "~19.2.0",
|
|
69
|
+
"react-dom": "~19.2.0",
|
|
70
|
+
"vite": "7.1.9",
|
|
71
|
+
"@dxos/react-ui": "0.8.4-main.fffef41",
|
|
72
|
+
"@dxos/react-ui-theme": "0.8.4-main.fffef41",
|
|
73
|
+
"@dxos/storybook-utils": "0.8.4-main.fffef41"
|
|
73
74
|
},
|
|
74
75
|
"peerDependencies": {
|
|
75
|
-
"@phosphor-icons/react": "^2.1.5",
|
|
76
76
|
"effect": "^3.13.3",
|
|
77
|
-
"react": "
|
|
78
|
-
"react-dom": "
|
|
79
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
80
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
77
|
+
"react": "^19.0.0",
|
|
78
|
+
"react-dom": "^19.0.0",
|
|
79
|
+
"@dxos/react-ui": "0.8.4-main.fffef41",
|
|
80
|
+
"@dxos/react-ui-theme": "0.8.4-main.fffef41"
|
|
81
81
|
},
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
package/src/StackPlugin.ts
CHANGED
|
@@ -2,51 +2,50 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Capabilities, contributes, defineModule, definePlugin
|
|
5
|
+
import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
|
|
6
6
|
import { type Obj } from '@dxos/echo';
|
|
7
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
},
|
|
14
|
+
export const StackPlugin = definePlugin(meta, () => [
|
|
15
|
+
defineModule({
|
|
16
|
+
id: `${meta.id}/module/translations`,
|
|
17
|
+
activatesOn: Events.SetupTranslations,
|
|
18
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
19
|
+
}),
|
|
20
|
+
defineModule({
|
|
21
|
+
id: `${meta.id}/module/metadata`,
|
|
22
|
+
activatesOn: Events.SetupMetadata,
|
|
23
|
+
activate: () => [
|
|
24
|
+
contributes(Capabilities.Metadata, {
|
|
25
|
+
id: SECTION_IDENTIFIER,
|
|
26
|
+
metadata: {
|
|
27
|
+
parse: (section: { object: Obj.Any }, type: string) => {
|
|
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
|
+
}
|
|
38
36
|
},
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
37
|
+
},
|
|
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,
|
|
50
|
+
}),
|
|
51
|
+
]);
|
|
@@ -6,29 +6,24 @@ import React from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
8
8
|
import { Obj } from '@dxos/echo';
|
|
9
|
-
import {
|
|
10
|
-
import { DataType } from '@dxos/schema';
|
|
9
|
+
import { Collection } from '@dxos/schema';
|
|
11
10
|
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { StackContainer } from '../components';
|
|
12
|
+
import { meta } from '../meta';
|
|
14
13
|
|
|
15
14
|
export default () =>
|
|
16
15
|
contributes(
|
|
17
16
|
Capabilities.ReactSurface,
|
|
18
17
|
createSurface({
|
|
19
|
-
id: `${
|
|
18
|
+
id: `${meta.id}/article`,
|
|
20
19
|
role: 'article',
|
|
21
|
-
filter: (data): data is { id?: string; subject:
|
|
22
|
-
Obj.instanceOf(
|
|
20
|
+
filter: (data): data is { id?: string; subject: Collection.Collection } =>
|
|
21
|
+
Obj.instanceOf(Collection.Collection, data.subject),
|
|
23
22
|
component: ({ data }) => {
|
|
24
23
|
// This allows the id to be overridden by the surface for situations where the id of the collection
|
|
25
24
|
// is not the same as the id of what is being represented (e.g., a space with a root collection).
|
|
26
25
|
const id = typeof data.id === 'string' ? data.id : undefined;
|
|
27
|
-
return (
|
|
28
|
-
<div role='none' className='overflow-auto' style={{ contain: 'layout' }}>
|
|
29
|
-
<StackMain id={id ?? fullyQualifiedId(data.subject)} collection={data.subject} />
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
26
|
+
return <StackContainer id={id ?? Obj.getDXN(data.subject).toString()} collection={data.subject} />;
|
|
32
27
|
},
|
|
33
28
|
}),
|
|
34
29
|
);
|
|
@@ -2,30 +2,21 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import { Option } from 'effect';
|
|
5
|
+
import * as Option from 'effect/Option';
|
|
7
6
|
import React, { useCallback, useState } from 'react';
|
|
8
7
|
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
createIntent,
|
|
13
|
-
useAppGraph,
|
|
14
|
-
useCapabilities,
|
|
15
|
-
useIntentDispatcher,
|
|
16
|
-
} from '@dxos/app-framework';
|
|
17
|
-
import { fullyQualifiedId, isLiveObject } from '@dxos/client/echo';
|
|
8
|
+
import { Capabilities, LayoutAction, createIntent } from '@dxos/app-framework';
|
|
9
|
+
import { useAppGraph, useCapabilities, useIntentDispatcher } from '@dxos/app-framework/react';
|
|
10
|
+
import { isLiveObject } from '@dxos/client/echo';
|
|
18
11
|
import { Obj } from '@dxos/echo';
|
|
19
12
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
20
|
-
import {
|
|
13
|
+
import { Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
21
14
|
import { AttentionProvider } from '@dxos/react-ui-attention';
|
|
22
|
-
import { Stack } from '@dxos/react-ui-stack';
|
|
23
|
-
import { type
|
|
15
|
+
import { Stack, StackItem } from '@dxos/react-ui-stack';
|
|
16
|
+
import { type Collection } from '@dxos/schema';
|
|
24
17
|
import { isNonNullable } from '@dxos/util';
|
|
25
18
|
|
|
26
|
-
import {
|
|
27
|
-
import { StackSection } from './StackSection';
|
|
28
|
-
import { STACK_PLUGIN } from '../meta';
|
|
19
|
+
import { meta } from '../meta';
|
|
29
20
|
import {
|
|
30
21
|
type AddSectionPosition,
|
|
31
22
|
type CollapsedSections,
|
|
@@ -34,15 +25,18 @@ import {
|
|
|
34
25
|
type StackSectionView,
|
|
35
26
|
} from '../types';
|
|
36
27
|
|
|
37
|
-
|
|
28
|
+
import { StackContext } from './StackContext';
|
|
29
|
+
import { StackSection } from './StackSection';
|
|
30
|
+
|
|
31
|
+
type StackContainerProps = {
|
|
38
32
|
id: string;
|
|
39
|
-
collection:
|
|
33
|
+
collection: Collection.Collection;
|
|
40
34
|
};
|
|
41
35
|
|
|
42
|
-
const
|
|
36
|
+
const StackContainer = ({ id, collection }: StackContainerProps) => {
|
|
43
37
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
44
38
|
const { graph } = useAppGraph();
|
|
45
|
-
const { t } = useTranslation(
|
|
39
|
+
const { t } = useTranslation(meta.id);
|
|
46
40
|
const allMetadata = useCapabilities(Capabilities.Metadata);
|
|
47
41
|
const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});
|
|
48
42
|
|
|
@@ -66,13 +60,13 @@ const StackMain = ({ id, collection }: StackMainProps) => {
|
|
|
66
60
|
?.metadata as StackSectionMetadata;
|
|
67
61
|
const view = {
|
|
68
62
|
// ...stack.sections[object.id],
|
|
69
|
-
collapsed: collapsedSections[
|
|
63
|
+
collapsed: collapsedSections[Obj.getDXN(object).toString()],
|
|
70
64
|
title:
|
|
71
65
|
(object as any)?.title ??
|
|
72
66
|
// TODO(wittjosiah): `getNode` is not reactive.
|
|
73
|
-
toLocalizedString(graph.getNode(
|
|
67
|
+
toLocalizedString(graph.getNode(Obj.getDXN(object).toString()).pipe(Option.getOrNull)?.properties.label, t),
|
|
74
68
|
} as StackSectionView;
|
|
75
|
-
return { id:
|
|
69
|
+
return { id: Obj.getDXN(object).toString(), object, metadata, view } satisfies StackSectionItem;
|
|
76
70
|
}) ?? [];
|
|
77
71
|
|
|
78
72
|
const handleDelete = useCallback(
|
|
@@ -80,10 +74,15 @@ const StackMain = ({ id, collection }: StackMainProps) => {
|
|
|
80
74
|
const index = collection.objects
|
|
81
75
|
.map((object) => object.target)
|
|
82
76
|
.filter(isNonNullable)
|
|
83
|
-
.findIndex((section) =>
|
|
77
|
+
.findIndex((section) => Obj.getDXN(section).toString() === id);
|
|
84
78
|
const object = collection.objects[index].target;
|
|
85
79
|
if (isLiveObject(object)) {
|
|
86
|
-
await dispatch(
|
|
80
|
+
await dispatch(
|
|
81
|
+
createIntent(SpaceAction.RemoveObjects, {
|
|
82
|
+
objects: [object],
|
|
83
|
+
target: collection,
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
87
86
|
|
|
88
87
|
// TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.
|
|
89
88
|
// delete stack.sections[Path.last(path)];
|
|
@@ -98,7 +97,7 @@ const StackMain = ({ id, collection }: StackMainProps) => {
|
|
|
98
97
|
// TODO(wittjosiah): Use object creation dialog.
|
|
99
98
|
createIntent(LayoutAction.UpdateDialog, {
|
|
100
99
|
part: 'dialog',
|
|
101
|
-
subject: `${
|
|
100
|
+
subject: `${meta.id}/AddSectionDialog`,
|
|
102
101
|
options: {
|
|
103
102
|
blockAlign: 'start',
|
|
104
103
|
props: {
|
|
@@ -126,35 +125,48 @@ const StackMain = ({ id, collection }: StackMainProps) => {
|
|
|
126
125
|
);
|
|
127
126
|
|
|
128
127
|
const handleAddSection = useCallback(
|
|
129
|
-
() =>
|
|
128
|
+
() =>
|
|
129
|
+
dispatch?.(
|
|
130
|
+
createIntent(SpaceAction.OpenCreateObject, {
|
|
131
|
+
target: collection,
|
|
132
|
+
navigable: false,
|
|
133
|
+
}),
|
|
134
|
+
),
|
|
130
135
|
[collection, dispatch],
|
|
131
136
|
);
|
|
132
137
|
|
|
133
138
|
return (
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
139
|
+
<StackItem.Content
|
|
140
|
+
toolbar
|
|
141
|
+
classNames='container-max-width overflow-hidden border-l border-r border-subduedSeparator'
|
|
142
|
+
>
|
|
143
|
+
<Toolbar.Root>
|
|
144
|
+
<Toolbar.IconButton
|
|
145
|
+
icon='ph--plus--regular'
|
|
146
|
+
iconOnly
|
|
147
|
+
label='Add section'
|
|
148
|
+
data-testid='stack.addSection'
|
|
149
|
+
onClick={handleAddSection}
|
|
150
|
+
/>
|
|
151
|
+
</Toolbar.Root>
|
|
152
|
+
<AttentionProvider id={id}>
|
|
153
|
+
<StackContext.Provider
|
|
154
|
+
value={{
|
|
155
|
+
onCollapse: handleCollapse,
|
|
156
|
+
onNavigate: handleNavigate,
|
|
157
|
+
onDelete: handleDelete,
|
|
158
|
+
onAdd: handleAdd,
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
<Stack orientation='vertical' size='intrinsic' id={id} data-testid='main.stack' classNames='overflow-y-auto'>
|
|
162
|
+
{items.map((item) => (
|
|
163
|
+
<StackSection key={item.id} {...item} />
|
|
164
|
+
))}
|
|
165
|
+
</Stack>
|
|
166
|
+
</StackContext.Provider>
|
|
167
|
+
</AttentionProvider>
|
|
168
|
+
</StackItem.Content>
|
|
157
169
|
);
|
|
158
170
|
};
|
|
159
171
|
|
|
160
|
-
export default
|
|
172
|
+
export default StackContainer;
|
|
@@ -5,16 +5,17 @@
|
|
|
5
5
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
6
6
|
import React, { useMemo, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { Surface } from '@dxos/app-framework';
|
|
9
|
-
import { DropdownMenu, Icon,
|
|
8
|
+
import { Surface } from '@dxos/app-framework/react';
|
|
9
|
+
import { DropdownMenu, Icon, IconButton, useTranslation } from '@dxos/react-ui';
|
|
10
10
|
import { useAttentionAttributes } from '@dxos/react-ui-attention';
|
|
11
11
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
12
|
-
import {
|
|
12
|
+
import { getSize, mx, textBlockWidth } from '@dxos/react-ui-theme';
|
|
13
|
+
|
|
14
|
+
import { meta } from '../meta';
|
|
15
|
+
import { type StackSectionItem } from '../types';
|
|
13
16
|
|
|
14
17
|
import { CaretDownUp } from './CaretDownUp';
|
|
15
18
|
import { useStack } from './StackContext';
|
|
16
|
-
import { STACK_PLUGIN } from '../meta';
|
|
17
|
-
import { type StackSectionItem } from '../types';
|
|
18
19
|
|
|
19
20
|
const sectionActionDimensions = 'p-1 mlb-1 shrink-0 min-bs-0 is-[--rail-action] bs-min';
|
|
20
21
|
|
|
@@ -26,7 +27,7 @@ export const StackSection = ({
|
|
|
26
27
|
object,
|
|
27
28
|
metadata: { icon = 'ph--placeholder--regular' },
|
|
28
29
|
}: StackSectionProps) => {
|
|
29
|
-
const { t } = useTranslation(
|
|
30
|
+
const { t } = useTranslation(meta.id);
|
|
30
31
|
const { onNavigate, onAdd, onCollapse, onDelete } = useStack();
|
|
31
32
|
const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);
|
|
32
33
|
const attentionAttrs = useAttentionAttributes(id);
|
|
@@ -5,19 +5,26 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { Input, useTranslation } from '@dxos/react-ui';
|
|
8
|
-
import {
|
|
8
|
+
import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from '@dxos/react-ui-form';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { meta } from '../meta';
|
|
11
11
|
import { type StackSettingsProps } from '../types';
|
|
12
12
|
|
|
13
13
|
export const StackSettings = ({ settings }: { settings: StackSettingsProps }) => {
|
|
14
|
-
const { t } = useTranslation(
|
|
14
|
+
const { t } = useTranslation(meta.id);
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
<ControlPage>
|
|
18
|
+
<ControlSection title={t('settings title', { ns: meta.id })}>
|
|
19
|
+
<ControlGroup>
|
|
20
|
+
<ControlItemInput title={t('settings separation label')}>
|
|
21
|
+
<Input.Switch
|
|
22
|
+
checked={settings.separation}
|
|
23
|
+
onCheckedChange={(checked) => (settings.separation = !!checked)}
|
|
24
|
+
/>
|
|
25
|
+
</ControlItemInput>
|
|
26
|
+
</ControlGroup>
|
|
27
|
+
</ControlSection>
|
|
28
|
+
</ControlPage>
|
|
22
29
|
);
|
|
23
30
|
};
|
package/src/components/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const STACK_PLUGIN = 'dxos.org/plugin/stack';
|
|
8
8
|
export const SECTION_IDENTIFIER = 'dxos.org/type/StackSection';
|
|
9
9
|
|
|
10
10
|
export const meta: PluginMeta = {
|
|
11
|
-
id:
|
|
11
|
+
id: 'dxos.org/plugin/stack',
|
|
12
12
|
// TODO(wittjosiah): Prevents "stacks" language from being exposed to users in settings panel.
|
|
13
13
|
// Conside renaming this to the collection plugin and trying to factor more collections logic from the space plugin.
|
|
14
14
|
name: 'Collections',
|
|
15
|
-
description:
|
|
15
|
+
description: trim`
|
|
16
|
+
Organize and view curated collections of workspace objects in customizable layouts.
|
|
17
|
+
Group related items together and manage collections with sections and filtering.
|
|
18
|
+
`,
|
|
16
19
|
icon: 'ph--stack-simple--regular',
|
|
17
20
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-stack',
|
|
18
21
|
};
|
package/src/translations.ts
CHANGED
|
@@ -12,6 +12,7 @@ export const translations = [
|
|
|
12
12
|
'en-US': {
|
|
13
13
|
[meta.id]: {
|
|
14
14
|
'plugin name': 'Stacks',
|
|
15
|
+
'settings title': 'Stack plugin settings',
|
|
15
16
|
'settings separation label': 'Separate sections',
|
|
16
17
|
'add section beforeAll dialog title': 'Add a section to the start',
|
|
17
18
|
'add section afterAll dialog title': 'Add a section to the end',
|
package/src/types/index.ts
CHANGED
package/src/types/stack.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { TypedObject } from '@dxos/echo
|
|
7
|
+
import { TypedObject } from '@dxos/echo/internal';
|
|
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.
|
package/src/types/types.ts
CHANGED
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type IconProps } from '@phosphor-icons/react';
|
|
6
5
|
import { type FC } from 'react';
|
|
7
6
|
|
|
8
7
|
import { type Obj } from '@dxos/echo';
|
|
9
8
|
import { type Label } from '@dxos/react-ui';
|
|
10
9
|
import { type StackItemSize } from '@dxos/react-ui-stack';
|
|
11
|
-
import { type
|
|
10
|
+
import { type Collection } from '@dxos/schema';
|
|
12
11
|
|
|
13
12
|
export type AddSectionPosition = 'before' | 'after' | 'beforeAll' | 'afterAll';
|
|
14
13
|
|
|
15
14
|
export type CollapsedSections = Record<string, boolean>;
|
|
16
15
|
|
|
17
|
-
export type CollectionItem =
|
|
16
|
+
export type CollectionItem = Collection.Collection['objects'][number];
|
|
18
17
|
|
|
19
18
|
export type StackSectionView = {
|
|
20
19
|
title?: string;
|
|
@@ -29,7 +28,7 @@ type StackSectionAction = {
|
|
|
29
28
|
testId: string;
|
|
30
29
|
type: string | [string, { ns: string }];
|
|
31
30
|
label: string | [string, { ns: string }];
|
|
32
|
-
icon: FC<
|
|
31
|
+
icon: FC<{ className?: string; size?: number }>;
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
export type StackSectionMetadata = {
|