@dxos/plugin-stack 0.7.4 → 0.7.5-labs.5f04cf6
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-VH3YESQL.mjs +295 -0
- package/dist/lib/browser/StackMain-VH3YESQL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-DS5KGEJG.mjs → chunk-WTGFKPPQ.mjs} +3 -3
- package/dist/lib/browser/chunk-WTGFKPPQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +78 -235
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/StackMain-USQVAFKL.cjs +309 -0
- package/dist/lib/node/StackMain-USQVAFKL.cjs.map +7 -0
- package/dist/lib/node/{chunk-PA5PRDM6.cjs → chunk-CZCFFT2J.cjs} +7 -7
- package/dist/lib/node/chunk-CZCFFT2J.cjs.map +7 -0
- package/dist/lib/node/index.cjs +80 -231
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/StackMain-DW27O56R.mjs +296 -0
- package/dist/lib/node-esm/StackMain-DW27O56R.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JEQMG2E2.mjs → chunk-SJU6TPRI.mjs} +3 -3
- package/dist/lib/node-esm/chunk-SJU6TPRI.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +78 -235
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/StackPlugin.d.ts +1 -3
- package/dist/types/src/StackPlugin.d.ts.map +1 -1
- package/dist/types/src/components/StackMain.d.ts.map +1 -1
- package/dist/types/src/components/StackSection.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types/stack.d.ts +6 -12
- package/dist/types/src/types/stack.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -17
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +22 -31
- package/src/StackPlugin.tsx +61 -73
- package/src/components/StackMain.tsx +66 -76
- package/src/components/StackSection.tsx +2 -4
- package/src/components/index.ts +0 -1
- package/src/index.ts +1 -6
- package/src/meta.ts +1 -1
- package/src/types/types.ts +2 -31
- package/dist/lib/browser/StackMain-4D4J4IRK.mjs +0 -391
- package/dist/lib/browser/StackMain-4D4J4IRK.mjs.map +0 -7
- package/dist/lib/browser/chunk-DS5KGEJG.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -11
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/StackMain-V7C55NCF.cjs +0 -403
- package/dist/lib/node/StackMain-V7C55NCF.cjs.map +0 -7
- package/dist/lib/node/chunk-PA5PRDM6.cjs.map +0 -7
- package/dist/lib/node/meta.cjs +0 -32
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/StackMain-5I43UWGF.mjs +0 -392
- package/dist/lib/node-esm/StackMain-5I43UWGF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JEQMG2E2.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -12
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/types/src/components/AddSection.d.ts +0 -6
- package/dist/types/src/components/AddSection.d.ts.map +0 -1
- package/dist/types/src/components/AddSectionDialog.d.ts +0 -14
- package/dist/types/src/components/AddSectionDialog.d.ts.map +0 -1
- package/src/components/AddSection.tsx +0 -102
- package/src/components/AddSectionDialog.tsx +0 -128
|
@@ -3,18 +3,12 @@ export declare const SectionSchema: S.Struct<{
|
|
|
3
3
|
height: S.optional<typeof S.Number>;
|
|
4
4
|
custom: S.optional<S.Record$<typeof S.String, typeof S.Any>>;
|
|
5
5
|
}>;
|
|
6
|
-
declare const StackViewType_base: import("@dxos/echo-schema").
|
|
7
|
-
sections: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} | undefined;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
} & {
|
|
16
|
-
id: string;
|
|
17
|
-
}, S.Struct.Encoded<{
|
|
6
|
+
declare const StackViewType_base: import("@dxos/echo-schema").TypedObjectPrototype<import("packages/core/echo/echo-schema/dist/types/src/object/common").TypedObjectFields<{
|
|
7
|
+
sections: S.mutable<S.Record$<typeof S.String, S.Struct<{
|
|
8
|
+
height: S.optional<typeof S.Number>;
|
|
9
|
+
custom: S.optional<S.Record$<typeof S.String, typeof S.Any>>;
|
|
10
|
+
}>>>;
|
|
11
|
+
}, import("packages/core/echo/echo-schema/dist/types/src/object/common").TypedObjectOptions>, S.Struct.Encoded<{
|
|
18
12
|
sections: S.mutable<S.Record$<typeof S.String, S.Struct<{
|
|
19
13
|
height: S.optional<typeof S.Number>;
|
|
20
14
|
custom: S.optional<S.Record$<typeof S.String, typeof S.Any>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../../../src/types/stack.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAe,MAAM,mBAAmB,CAAC;AAOnD,eAAO,MAAM,aAAa;;;EAKxB,CAAC
|
|
1
|
+
{"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../../../src/types/stack.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAe,MAAM,mBAAmB,CAAC;AAOnD,eAAO,MAAM,aAAa;;;EAKxB,CAAC;;;;;;;;;;;;AAGH,qBAAa,aAAc,SAAQ,kBAEjC;CAAG"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type IconProps } from '@phosphor-icons/react';
|
|
2
2
|
import { type FC } from 'react';
|
|
3
|
-
import type { Intent, MetadataRecordsProvides, SettingsProvides, SurfaceProvides, TranslationsProvides } from '@dxos/app-framework';
|
|
4
|
-
import { type SchemaProvides } from '@dxos/plugin-space';
|
|
5
3
|
import { type CollectionType } from '@dxos/plugin-space/types';
|
|
4
|
+
import { type ReactiveEchoObject } from '@dxos/react-client/echo';
|
|
6
5
|
import { type Label } from '@dxos/react-ui';
|
|
7
6
|
import { type StackItemSize } from '@dxos/react-ui-stack';
|
|
8
7
|
export type AddSectionPosition = 'before' | 'after' | 'beforeAll' | 'afterAll';
|
|
@@ -33,26 +32,12 @@ export type StackSectionMetadata = {
|
|
|
33
32
|
};
|
|
34
33
|
export type StackSectionItem = {
|
|
35
34
|
id: string;
|
|
36
|
-
object:
|
|
35
|
+
object: ReactiveEchoObject<any>;
|
|
37
36
|
view: StackSectionView;
|
|
38
37
|
metadata: StackSectionMetadata;
|
|
39
38
|
};
|
|
40
|
-
export type StackSectionCreator = StackSectionAction & {
|
|
41
|
-
intent: Intent | Intent[];
|
|
42
|
-
};
|
|
43
|
-
export type StackProvides = {
|
|
44
|
-
stack: {
|
|
45
|
-
creators?: StackSectionCreator[];
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
export type StackState = {
|
|
49
|
-
creators: StackSectionCreator[];
|
|
50
|
-
};
|
|
51
39
|
export type StackSettingsProps = {
|
|
52
40
|
separation: boolean;
|
|
53
41
|
};
|
|
54
|
-
export type StackPluginProvides = SurfaceProvides & MetadataRecordsProvides & SettingsProvides<StackSettingsProps> & TranslationsProvides & SchemaProvides & {
|
|
55
|
-
stack: StackState;
|
|
56
|
-
};
|
|
57
42
|
export {};
|
|
58
43
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,CAAC;AAE/E,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAExD,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxC,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,kBAAkB,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,oBAAoB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.7.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-stack",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5-labs.5f04cf6",
|
|
4
4
|
"description": "DXOS Surface plugin for Stack entities",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -13,11 +13,6 @@
|
|
|
13
13
|
"browser": "./dist/lib/browser/index.mjs",
|
|
14
14
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
15
15
|
},
|
|
16
|
-
"./meta": {
|
|
17
|
-
"types": "./dist/types/src/meta.d.ts",
|
|
18
|
-
"browser": "./dist/lib/browser/meta.mjs",
|
|
19
|
-
"node": "./dist/lib/node-esm/meta.mjs"
|
|
20
|
-
},
|
|
21
16
|
"./types": {
|
|
22
17
|
"types": "./dist/types/src/types/index.d.ts",
|
|
23
18
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
@@ -27,9 +22,6 @@
|
|
|
27
22
|
"types": "dist/types/src/index.d.ts",
|
|
28
23
|
"typesVersions": {
|
|
29
24
|
"*": {
|
|
30
|
-
"meta": [
|
|
31
|
-
"dist/types/src/meta.d.ts"
|
|
32
|
-
],
|
|
33
25
|
"types": [
|
|
34
26
|
"dist/types/src/types/index.d.ts"
|
|
35
27
|
]
|
|
@@ -46,23 +38,22 @@
|
|
|
46
38
|
"@radix-ui/react-collapsible": "^1.0.2",
|
|
47
39
|
"node-fetch": "^2.6.0",
|
|
48
40
|
"react-is": "~18.2.0",
|
|
49
|
-
"@dxos/app-framework": "0.7.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/local-storage": "0.7.
|
|
55
|
-
"@dxos/plugin-
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/plugin-
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/react-ui-
|
|
61
|
-
"@dxos/react-ui-
|
|
62
|
-
"@dxos/react-ui-
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/react-ui-
|
|
65
|
-
"@dxos/util": "0.7.4"
|
|
41
|
+
"@dxos/app-framework": "0.7.5-labs.5f04cf6",
|
|
42
|
+
"@dxos/client": "0.7.5-labs.5f04cf6",
|
|
43
|
+
"@dxos/async": "0.7.5-labs.5f04cf6",
|
|
44
|
+
"@dxos/invariant": "0.7.5-labs.5f04cf6",
|
|
45
|
+
"@dxos/echo-schema": "0.7.5-labs.5f04cf6",
|
|
46
|
+
"@dxos/local-storage": "0.7.5-labs.5f04cf6",
|
|
47
|
+
"@dxos/plugin-client": "0.7.5-labs.5f04cf6",
|
|
48
|
+
"@dxos/react-client": "0.7.5-labs.5f04cf6",
|
|
49
|
+
"@dxos/plugin-space": "0.7.5-labs.5f04cf6",
|
|
50
|
+
"@dxos/react-ui-attention": "0.7.5-labs.5f04cf6",
|
|
51
|
+
"@dxos/plugin-graph": "0.7.5-labs.5f04cf6",
|
|
52
|
+
"@dxos/react-ui-form": "0.7.5-labs.5f04cf6",
|
|
53
|
+
"@dxos/react-ui-mosaic": "0.7.5-labs.5f04cf6",
|
|
54
|
+
"@dxos/react-ui-searchlist": "0.7.5-labs.5f04cf6",
|
|
55
|
+
"@dxos/util": "0.7.5-labs.5f04cf6",
|
|
56
|
+
"@dxos/react-ui-stack": "0.7.5-labs.5f04cf6"
|
|
66
57
|
},
|
|
67
58
|
"devDependencies": {
|
|
68
59
|
"@babel/core": "^7.18.13",
|
|
@@ -72,16 +63,16 @@
|
|
|
72
63
|
"react": "~18.2.0",
|
|
73
64
|
"react-dom": "~18.2.0",
|
|
74
65
|
"vite": "5.4.7",
|
|
75
|
-
"@dxos/react-ui-theme": "0.7.
|
|
76
|
-
"@dxos/react-ui": "0.7.
|
|
77
|
-
"@dxos/storybook-utils": "0.7.
|
|
66
|
+
"@dxos/react-ui-theme": "0.7.5-labs.5f04cf6",
|
|
67
|
+
"@dxos/react-ui": "0.7.5-labs.5f04cf6",
|
|
68
|
+
"@dxos/storybook-utils": "0.7.5-labs.5f04cf6"
|
|
78
69
|
},
|
|
79
70
|
"peerDependencies": {
|
|
80
71
|
"@phosphor-icons/react": "^2.1.5",
|
|
81
72
|
"react": "~18.2.0",
|
|
82
73
|
"react-dom": "~18.2.0",
|
|
83
|
-
"@dxos/react-ui": "0.7.
|
|
84
|
-
"@dxos/react-ui
|
|
74
|
+
"@dxos/react-ui-theme": "0.7.5-labs.5f04cf6",
|
|
75
|
+
"@dxos/react-ui": "0.7.5-labs.5f04cf6"
|
|
85
76
|
},
|
|
86
77
|
"publishConfig": {
|
|
87
78
|
"access": "public"
|
package/src/StackPlugin.tsx
CHANGED
|
@@ -4,47 +4,45 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import {
|
|
8
|
+
Capabilities,
|
|
9
|
+
contributes,
|
|
10
|
+
createSurface,
|
|
11
|
+
defineModule,
|
|
12
|
+
definePlugin,
|
|
13
|
+
Events,
|
|
14
|
+
oneOf,
|
|
15
|
+
} from '@dxos/app-framework';
|
|
16
|
+
import { type ReactiveEchoObject, fullyQualifiedId } from '@dxos/client/echo';
|
|
17
|
+
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
10
18
|
import { CollectionType } from '@dxos/plugin-space/types';
|
|
11
|
-
import { Main } from '@dxos/react-ui';
|
|
12
|
-
import { baseSurface, topbarBlockPaddingStart, bottombarBlockPaddingEnd } from '@dxos/react-ui-theme';
|
|
13
19
|
|
|
14
|
-
import { StackMain
|
|
15
|
-
import meta,
|
|
20
|
+
import { StackMain } from './components';
|
|
21
|
+
import { meta, SECTION_IDENTIFIER, STACK_PLUGIN } from './meta';
|
|
16
22
|
import translations from './translations';
|
|
17
23
|
import { StackViewType } from './types';
|
|
18
|
-
import { type StackPluginProvides, type StackProvides, type StackState, type StackSettingsProps } from './types';
|
|
19
24
|
|
|
20
|
-
export const StackPlugin = ()
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (Array.isArray((plugin as Plugin<StackProvides>).provides?.stack?.creators)) {
|
|
35
|
-
stackState.creators.push(...((plugin as Plugin<StackProvides>).provides.stack.creators ?? []));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
provides: {
|
|
40
|
-
settings: settings.values,
|
|
41
|
-
metadata: {
|
|
42
|
-
records: {
|
|
43
|
-
[StackViewType.typename]: {
|
|
25
|
+
export const StackPlugin = () =>
|
|
26
|
+
definePlugin(meta, [
|
|
27
|
+
defineModule({
|
|
28
|
+
id: `${meta.id}/module/translations`,
|
|
29
|
+
activatesOn: Events.SetupTranslations,
|
|
30
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
31
|
+
}),
|
|
32
|
+
defineModule({
|
|
33
|
+
id: `${meta.id}/module/metadata`,
|
|
34
|
+
activatesOn: oneOf(Events.Startup, Events.SetupAppGraph),
|
|
35
|
+
activate: () => [
|
|
36
|
+
contributes(Capabilities.Metadata, {
|
|
37
|
+
id: StackViewType.typename,
|
|
38
|
+
metadata: {
|
|
44
39
|
placeholder: ['stack title placeholder', { ns: STACK_PLUGIN }],
|
|
45
40
|
icon: 'ph--stack-simple--regular',
|
|
46
41
|
},
|
|
47
|
-
|
|
42
|
+
}),
|
|
43
|
+
contributes(Capabilities.Metadata, {
|
|
44
|
+
id: SECTION_IDENTIFIER,
|
|
45
|
+
metadata: {
|
|
48
46
|
parse: (section: { object: ReactiveEchoObject<any> }, type: string) => {
|
|
49
47
|
switch (type) {
|
|
50
48
|
case 'node':
|
|
@@ -57,45 +55,35 @@ export const StackPlugin = (): PluginDefinition<StackPluginProvides> => {
|
|
|
57
55
|
}
|
|
58
56
|
},
|
|
59
57
|
},
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
) : null;
|
|
84
|
-
case 'article':
|
|
85
|
-
return primary instanceof CollectionType ? (
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
}),
|
|
61
|
+
defineModule({
|
|
62
|
+
id: `${meta.id}/module/schema`,
|
|
63
|
+
activatesOn: ClientEvents.SetupClient,
|
|
64
|
+
activate: () => contributes(ClientCapabilities.SystemSchema, [StackViewType]),
|
|
65
|
+
}),
|
|
66
|
+
defineModule({
|
|
67
|
+
id: `${meta.id}/module/react-surface`,
|
|
68
|
+
activatesOn: Events.Startup,
|
|
69
|
+
activate: () =>
|
|
70
|
+
contributes(
|
|
71
|
+
Capabilities.ReactSurface,
|
|
72
|
+
createSurface({
|
|
73
|
+
id: `${STACK_PLUGIN}/article`,
|
|
74
|
+
role: 'article',
|
|
75
|
+
filter: (data): data is { id?: string; subject: CollectionType } => data.subject instanceof CollectionType,
|
|
76
|
+
component: ({ data }) => {
|
|
77
|
+
// This allows the id to be overridden by the surface for situations where the id of the collection
|
|
78
|
+
// is not the same as the id of what is being represented (e.g., a space with a root collection).
|
|
79
|
+
const id = typeof data.id === 'string' ? data.id : undefined;
|
|
80
|
+
return (
|
|
86
81
|
<div role='none' className='overflow-auto' style={{ contain: 'layout' }}>
|
|
87
|
-
<StackMain id={id ?? fullyQualifiedId(
|
|
82
|
+
<StackMain id={id ?? fullyQualifiedId(data.subject)} collection={data.subject} />
|
|
88
83
|
</div>
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
stack: stackState,
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
};
|
|
84
|
+
);
|
|
85
|
+
},
|
|
86
|
+
}),
|
|
87
|
+
),
|
|
88
|
+
}),
|
|
89
|
+
]);
|
|
@@ -3,25 +3,25 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Plus } from '@phosphor-icons/react';
|
|
6
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
6
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
+
Capabilities,
|
|
10
|
+
createIntent,
|
|
9
11
|
LayoutAction,
|
|
10
12
|
NavigationAction,
|
|
11
|
-
|
|
13
|
+
useCapabilities,
|
|
12
14
|
useIntentDispatcher,
|
|
13
|
-
useResolvePlugin,
|
|
14
15
|
} from '@dxos/app-framework';
|
|
15
|
-
import { create, getType, fullyQualifiedId } from '@dxos/client/echo';
|
|
16
|
+
import { create, getType, fullyQualifiedId, isReactiveObject, makeRef } from '@dxos/client/echo';
|
|
16
17
|
import { useGraph } from '@dxos/plugin-graph';
|
|
17
|
-
import { SpaceAction } from '@dxos/plugin-space';
|
|
18
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
18
19
|
import { type CollectionType } from '@dxos/plugin-space/types';
|
|
19
20
|
import { Button, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
20
21
|
import { AttentionProvider } from '@dxos/react-ui-attention';
|
|
21
22
|
import { Stack } from '@dxos/react-ui-stack';
|
|
22
23
|
import { nonNullable } from '@dxos/util';
|
|
23
24
|
|
|
24
|
-
import { AddSection } from './AddSection';
|
|
25
25
|
import { StackContext } from './StackContext';
|
|
26
26
|
import { StackSection } from './StackSection';
|
|
27
27
|
import { STACK_PLUGIN } from '../meta';
|
|
@@ -40,17 +40,17 @@ type StackMainProps = {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
const StackMain = ({ id, collection }: StackMainProps) => {
|
|
43
|
-
const dispatch = useIntentDispatcher();
|
|
43
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
44
44
|
const { graph } = useGraph();
|
|
45
45
|
const { t } = useTranslation(STACK_PLUGIN);
|
|
46
|
-
const
|
|
46
|
+
const allMetadata = useCapabilities(Capabilities.Metadata);
|
|
47
47
|
const defaultStack = useMemo(() => create(StackViewType, { sections: {} }), [collection]);
|
|
48
|
-
const stack = (collection.views[StackViewType.typename] as StackViewType) ?? defaultStack;
|
|
48
|
+
const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;
|
|
49
49
|
const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});
|
|
50
50
|
|
|
51
51
|
useEffect(() => {
|
|
52
52
|
if (!collection.views[StackViewType.typename]) {
|
|
53
|
-
collection.views[StackViewType.typename] = stack;
|
|
53
|
+
collection.views[StackViewType.typename] = makeRef(stack);
|
|
54
54
|
}
|
|
55
55
|
}, [collection, stack]);
|
|
56
56
|
|
|
@@ -58,11 +58,11 @@ const StackMain = ({ id, collection }: StackMainProps) => {
|
|
|
58
58
|
collection.objects
|
|
59
59
|
// TODO(wittjosiah): Should the database handle this differently?
|
|
60
60
|
// TODO(wittjosiah): Render placeholders for missing objects so they can be removed from the stack?
|
|
61
|
+
.map((object) => object.target)
|
|
61
62
|
.filter(nonNullable)
|
|
62
63
|
.map((object) => {
|
|
63
|
-
const metadata =
|
|
64
|
-
|
|
65
|
-
) as StackSectionMetadata;
|
|
64
|
+
const metadata = allMetadata.find((m) => m.id === (getType(object)?.objectId ?? 'never'))
|
|
65
|
+
?.metadata as StackSectionMetadata;
|
|
66
66
|
const view = {
|
|
67
67
|
...stack.sections[object.id],
|
|
68
68
|
collapsed: collapsedSections[fullyQualifiedId(object)],
|
|
@@ -72,46 +72,53 @@ const StackMain = ({ id, collection }: StackMainProps) => {
|
|
|
72
72
|
return { id: fullyQualifiedId(object), object, metadata, view } satisfies StackSectionItem;
|
|
73
73
|
}) ?? [];
|
|
74
74
|
|
|
75
|
-
const handleDelete =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
const handleDelete = useCallback(
|
|
76
|
+
async (id: string) => {
|
|
77
|
+
const index = collection.objects
|
|
78
|
+
.map((object) => object.target)
|
|
79
|
+
.filter(nonNullable)
|
|
80
|
+
.findIndex((section) => fullyQualifiedId(section) === id);
|
|
81
|
+
const object = collection.objects[index].target;
|
|
82
|
+
if (isReactiveObject(object)) {
|
|
83
|
+
await dispatch(createIntent(SpaceAction.RemoveObjects, { objects: [object], target: collection }));
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
{
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
85
|
+
// TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.
|
|
86
|
+
// delete stack.sections[Path.last(path)];
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
[collection, dispatch],
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const handleAdd = useCallback(
|
|
93
|
+
async (id: string, position: AddSectionPosition) => {
|
|
94
|
+
await dispatch?.(
|
|
95
|
+
createIntent(LayoutAction.SetLayout, {
|
|
96
|
+
element: 'dialog',
|
|
97
|
+
component: `${STACK_PLUGIN}/AddSectionDialog`,
|
|
98
|
+
subject: { path: id, position, collection },
|
|
99
|
+
}),
|
|
100
|
+
);
|
|
101
|
+
},
|
|
102
|
+
[collection, dispatch],
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const handleNavigate = useCallback(
|
|
106
|
+
async (id: string) => {
|
|
107
|
+
await dispatch(createIntent(NavigationAction.Open, { activeParts: { main: [id] } }));
|
|
108
|
+
await dispatch(createIntent(LayoutAction.ScrollIntoView, { id }));
|
|
109
|
+
},
|
|
110
|
+
[dispatch],
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const handleCollapse = useCallback(
|
|
114
|
+
(id: string, collapsed: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: collapsed })),
|
|
115
|
+
[],
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const handleAddSection = useCallback(
|
|
119
|
+
() => dispatch?.(createIntent(SpaceAction.OpenCreateObject, { target: collection, navigable: false })),
|
|
120
|
+
[collection, dispatch],
|
|
121
|
+
);
|
|
115
122
|
|
|
116
123
|
return (
|
|
117
124
|
<AttentionProvider id={id}>
|
|
@@ -123,35 +130,18 @@ const StackMain = ({ id, collection }: StackMainProps) => {
|
|
|
123
130
|
onAdd: handleAdd,
|
|
124
131
|
}}
|
|
125
132
|
>
|
|
126
|
-
<Stack orientation='vertical' size='intrinsic'
|
|
133
|
+
<Stack orientation='vertical' size='intrinsic' id={id} data-testid='main.stack'>
|
|
127
134
|
{items.map((item) => (
|
|
128
135
|
<StackSection key={item.id} {...item} />
|
|
129
136
|
))}
|
|
130
137
|
</Stack>
|
|
131
138
|
|
|
132
|
-
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
classNames='gap-2'
|
|
139
|
-
onClick={() =>
|
|
140
|
-
dispatch?.({
|
|
141
|
-
action: LayoutAction.SET_LAYOUT,
|
|
142
|
-
data: {
|
|
143
|
-
element: 'dialog',
|
|
144
|
-
component: 'dxos.org/plugin/stack/AddSectionDialog',
|
|
145
|
-
subject: { position: 'afterAll', collection },
|
|
146
|
-
},
|
|
147
|
-
})
|
|
148
|
-
}
|
|
149
|
-
>
|
|
150
|
-
<Plus />
|
|
151
|
-
<span className='sr-only'>{t('add section label')}</span>
|
|
152
|
-
</Button>
|
|
153
|
-
</div>
|
|
154
|
-
)}
|
|
139
|
+
<div role='none' className='flex mlb-2 pli-2 justify-center'>
|
|
140
|
+
<Button data-testid='stack.createSection' classNames='gap-2' onClick={handleAddSection}>
|
|
141
|
+
<Plus />
|
|
142
|
+
<span className='sr-only'>{t('add section label')}</span>
|
|
143
|
+
</Button>
|
|
144
|
+
</div>
|
|
155
145
|
</StackContext.Provider>
|
|
156
146
|
</AttentionProvider>
|
|
157
147
|
);
|
|
@@ -47,7 +47,7 @@ export const StackSection = ({
|
|
|
47
47
|
</StackItem.SigilButton>
|
|
48
48
|
</DropdownMenu.Trigger>
|
|
49
49
|
<DropdownMenu.Portal>
|
|
50
|
-
<DropdownMenu.Content
|
|
50
|
+
<DropdownMenu.Content>
|
|
51
51
|
<DropdownMenu.Viewport>
|
|
52
52
|
{view.collapsed ? (
|
|
53
53
|
<DropdownMenu.Item onClick={() => onNavigate(id)} data-testid='section.navigate-to'>
|
|
@@ -83,7 +83,6 @@ export const StackSection = ({
|
|
|
83
83
|
<CollapsiblePrimitive.Trigger asChild>
|
|
84
84
|
<IconButton
|
|
85
85
|
iconOnly
|
|
86
|
-
tooltipZIndex='70'
|
|
87
86
|
variant='ghost'
|
|
88
87
|
label={t('expand label')}
|
|
89
88
|
icon='ph--caret-up-down--regular'
|
|
@@ -93,7 +92,6 @@ export const StackSection = ({
|
|
|
93
92
|
) : (
|
|
94
93
|
<IconButton
|
|
95
94
|
iconOnly
|
|
96
|
-
tooltipZIndex='70'
|
|
97
95
|
variant='ghost'
|
|
98
96
|
onClick={() => onNavigate(id)}
|
|
99
97
|
label={t('navigate to section label')}
|
|
@@ -105,7 +103,7 @@ export const StackSection = ({
|
|
|
105
103
|
</div>
|
|
106
104
|
</StackItem.Heading>
|
|
107
105
|
<CollapsiblePrimitive.Content>
|
|
108
|
-
<Surface role='section' data={{ object }} limit={1} placeholder={<></>} />
|
|
106
|
+
<Surface role='section' data={{ subject: object }} limit={1} placeholder={<></>} />
|
|
109
107
|
</CollapsiblePrimitive.Content>
|
|
110
108
|
{view.collapsed && (
|
|
111
109
|
<StackItem.Content toolbar={false} classNames='attention-surface'>
|
package/src/components/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type PluginMeta } from '@dxos/app-framework';
|
|
|
7
7
|
export const STACK_PLUGIN = 'dxos.org/plugin/stack';
|
|
8
8
|
export const SECTION_IDENTIFIER = 'dxos.org/type/StackSection';
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export const meta = {
|
|
11
11
|
id: STACK_PLUGIN,
|
|
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.
|