@dxos/plugin-stack 0.7.4 → 0.7.5-feature-compute.4d9d99a

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.
Files changed (65) hide show
  1. package/dist/lib/browser/StackMain-VH3YESQL.mjs +295 -0
  2. package/dist/lib/browser/StackMain-VH3YESQL.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-DS5KGEJG.mjs → chunk-WTGFKPPQ.mjs} +3 -3
  4. package/dist/lib/browser/chunk-WTGFKPPQ.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +78 -235
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/node/StackMain-USQVAFKL.cjs +309 -0
  9. package/dist/lib/node/StackMain-USQVAFKL.cjs.map +7 -0
  10. package/dist/lib/node/{chunk-PA5PRDM6.cjs → chunk-CZCFFT2J.cjs} +7 -7
  11. package/dist/lib/node/chunk-CZCFFT2J.cjs.map +7 -0
  12. package/dist/lib/node/index.cjs +80 -231
  13. package/dist/lib/node/index.cjs.map +4 -4
  14. package/dist/lib/node/meta.json +1 -1
  15. package/dist/lib/node-esm/StackMain-DW27O56R.mjs +296 -0
  16. package/dist/lib/node-esm/StackMain-DW27O56R.mjs.map +7 -0
  17. package/dist/lib/node-esm/{chunk-JEQMG2E2.mjs → chunk-SJU6TPRI.mjs} +3 -3
  18. package/dist/lib/node-esm/chunk-SJU6TPRI.mjs.map +7 -0
  19. package/dist/lib/node-esm/index.mjs +78 -235
  20. package/dist/lib/node-esm/index.mjs.map +4 -4
  21. package/dist/lib/node-esm/meta.json +1 -1
  22. package/dist/types/src/StackPlugin.d.ts +1 -3
  23. package/dist/types/src/StackPlugin.d.ts.map +1 -1
  24. package/dist/types/src/components/StackMain.d.ts.map +1 -1
  25. package/dist/types/src/components/StackSection.d.ts.map +1 -1
  26. package/dist/types/src/components/index.d.ts +1 -2
  27. package/dist/types/src/components/index.d.ts.map +1 -1
  28. package/dist/types/src/index.d.ts +1 -3
  29. package/dist/types/src/index.d.ts.map +1 -1
  30. package/dist/types/src/meta.d.ts +1 -2
  31. package/dist/types/src/meta.d.ts.map +1 -1
  32. package/dist/types/src/types/stack.d.ts +6 -12
  33. package/dist/types/src/types/stack.d.ts.map +1 -1
  34. package/dist/types/src/types/types.d.ts +2 -17
  35. package/dist/types/src/types/types.d.ts.map +1 -1
  36. package/dist/types/tsconfig.tsbuildinfo +1 -0
  37. package/package.json +22 -31
  38. package/src/StackPlugin.tsx +61 -73
  39. package/src/components/StackMain.tsx +66 -76
  40. package/src/components/StackSection.tsx +2 -4
  41. package/src/components/index.ts +0 -1
  42. package/src/index.ts +1 -6
  43. package/src/meta.ts +1 -1
  44. package/src/types/types.ts +2 -31
  45. package/dist/lib/browser/StackMain-4D4J4IRK.mjs +0 -391
  46. package/dist/lib/browser/StackMain-4D4J4IRK.mjs.map +0 -7
  47. package/dist/lib/browser/chunk-DS5KGEJG.mjs.map +0 -7
  48. package/dist/lib/browser/meta.mjs +0 -11
  49. package/dist/lib/browser/meta.mjs.map +0 -7
  50. package/dist/lib/node/StackMain-V7C55NCF.cjs +0 -403
  51. package/dist/lib/node/StackMain-V7C55NCF.cjs.map +0 -7
  52. package/dist/lib/node/chunk-PA5PRDM6.cjs.map +0 -7
  53. package/dist/lib/node/meta.cjs +0 -32
  54. package/dist/lib/node/meta.cjs.map +0 -7
  55. package/dist/lib/node-esm/StackMain-5I43UWGF.mjs +0 -392
  56. package/dist/lib/node-esm/StackMain-5I43UWGF.mjs.map +0 -7
  57. package/dist/lib/node-esm/chunk-JEQMG2E2.mjs.map +0 -7
  58. package/dist/lib/node-esm/meta.mjs +0 -12
  59. package/dist/lib/node-esm/meta.mjs.map +0 -7
  60. package/dist/types/src/components/AddSection.d.ts +0 -6
  61. package/dist/types/src/components/AddSection.d.ts.map +0 -1
  62. package/dist/types/src/components/AddSectionDialog.d.ts +0 -14
  63. package/dist/types/src/components/AddSectionDialog.d.ts.map +0 -1
  64. package/src/components/AddSection.tsx +0 -102
  65. 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").AbstractTypedObject<{
7
- sections: {
8
- [x: string]: {
9
- readonly height?: number | undefined;
10
- readonly custom?: {
11
- readonly [x: string]: any;
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;;;;;;;;;;;;;;;;;;AAGH,qBAAa,aAAc,SAAQ,kBAEjC;CAAG"}
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: CollectionType['objects'][number];
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,KAAK,EACV,MAAM,EACN,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KA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
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.4",
3
+ "version": "0.7.5-feature-compute.4d9d99a",
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.4",
50
- "@dxos/async": "0.7.4",
51
- "@dxos/client": "0.7.4",
52
- "@dxos/echo-schema": "0.7.4",
53
- "@dxos/invariant": "0.7.4",
54
- "@dxos/local-storage": "0.7.4",
55
- "@dxos/plugin-graph": "0.7.4",
56
- "@dxos/plugin-client": "0.7.4",
57
- "@dxos/plugin-ipfs": "0.7.4",
58
- "@dxos/plugin-space": "0.7.4",
59
- "@dxos/react-client": "0.7.4",
60
- "@dxos/react-ui-attention": "0.7.4",
61
- "@dxos/react-ui-form": "0.7.4",
62
- "@dxos/react-ui-mosaic": "0.7.4",
63
- "@dxos/react-ui-stack": "0.7.4",
64
- "@dxos/react-ui-searchlist": "0.7.4",
65
- "@dxos/util": "0.7.4"
41
+ "@dxos/app-framework": "0.7.5-feature-compute.4d9d99a",
42
+ "@dxos/async": "0.7.5-feature-compute.4d9d99a",
43
+ "@dxos/client": "0.7.5-feature-compute.4d9d99a",
44
+ "@dxos/echo-schema": "0.7.5-feature-compute.4d9d99a",
45
+ "@dxos/invariant": "0.7.5-feature-compute.4d9d99a",
46
+ "@dxos/plugin-graph": "0.7.5-feature-compute.4d9d99a",
47
+ "@dxos/local-storage": "0.7.5-feature-compute.4d9d99a",
48
+ "@dxos/plugin-client": "0.7.5-feature-compute.4d9d99a",
49
+ "@dxos/plugin-space": "0.7.5-feature-compute.4d9d99a",
50
+ "@dxos/react-client": "0.7.5-feature-compute.4d9d99a",
51
+ "@dxos/react-ui-attention": "0.7.5-feature-compute.4d9d99a",
52
+ "@dxos/react-ui-form": "0.7.5-feature-compute.4d9d99a",
53
+ "@dxos/react-ui-mosaic": "0.7.5-feature-compute.4d9d99a",
54
+ "@dxos/react-ui-searchlist": "0.7.5-feature-compute.4d9d99a",
55
+ "@dxos/react-ui-stack": "0.7.5-feature-compute.4d9d99a",
56
+ "@dxos/util": "0.7.5-feature-compute.4d9d99a"
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.4",
76
- "@dxos/react-ui": "0.7.4",
77
- "@dxos/storybook-utils": "0.7.4"
66
+ "@dxos/react-ui-theme": "0.7.5-feature-compute.4d9d99a",
67
+ "@dxos/react-ui": "0.7.5-feature-compute.4d9d99a",
68
+ "@dxos/storybook-utils": "0.7.5-feature-compute.4d9d99a"
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.4",
84
- "@dxos/react-ui-theme": "0.7.4"
74
+ "@dxos/react-ui": "0.7.5-feature-compute.4d9d99a",
75
+ "@dxos/react-ui-theme": "0.7.5-feature-compute.4d9d99a"
85
76
  },
86
77
  "publishConfig": {
87
78
  "access": "public"
@@ -4,47 +4,45 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { type Plugin, type PluginDefinition } from '@dxos/app-framework';
8
- import { create, type ReactiveEchoObject, fullyQualifiedId } from '@dxos/client/echo';
9
- import { LocalStorageStore } from '@dxos/local-storage';
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, StackSettings, AddSectionDialog, dataHasAddSectionDialogProps } from './components';
15
- import meta, { SECTION_IDENTIFIER, STACK_PLUGIN } from './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 = (): PluginDefinition<StackPluginProvides> => {
21
- const settings = new LocalStorageStore<StackSettingsProps>(STACK_PLUGIN, { separation: true });
22
- const stackState = create<StackState>({ creators: [] });
23
-
24
- return {
25
- meta,
26
- ready: async (plugins) => {
27
- settings.prop({ key: 'separation', type: LocalStorageStore.bool() });
28
-
29
- for (const plugin of plugins) {
30
- if (plugin.meta.id === STACK_PLUGIN) {
31
- continue;
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
- [SECTION_IDENTIFIER]: {
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
- translations,
63
- echo: {
64
- system: [StackViewType],
65
- },
66
- surface: {
67
- component: ({ data, role }) => {
68
- switch (data.component) {
69
- case `${STACK_PLUGIN}/AddSectionDialog`:
70
- return dataHasAddSectionDialogProps(data) ? <AddSectionDialog {...data.subject} /> : null;
71
- }
72
-
73
- const primary = data.active ?? data.object;
74
- // This allows the id to be overridden by the surface for situations where the id of the collection
75
- // is not the same as the id of what is being represented (e.g., a space with a root collection).
76
- const id = typeof data.id === 'string' ? data.id : undefined;
77
- switch (role) {
78
- case 'main':
79
- return primary instanceof CollectionType ? (
80
- <Main.Content bounce classNames={[baseSurface, topbarBlockPaddingStart, bottombarBlockPaddingEnd]}>
81
- <StackMain id={id ?? fullyQualifiedId(primary)} collection={primary} />
82
- </Main.Content>
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(primary)} collection={primary} />
82
+ <StackMain id={id ?? fullyQualifiedId(data.subject)} collection={data.subject} />
88
83
  </div>
89
- ) : null;
90
- case 'settings': {
91
- return data.plugin === meta.id ? <StackSettings settings={settings.values} /> : null;
92
- }
93
- default:
94
- return null;
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
- parseMetadataResolverPlugin,
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 metadataPlugin = useResolvePlugin(parseMetadataResolverPlugin);
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 = metadataPlugin?.provides.metadata.resolver(
64
- getType(object)?.objectId ?? 'never',
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 = async (id: string) => {
76
- const index = collection.objects.filter(nonNullable).findIndex((section) => fullyQualifiedId(section) === id);
77
- if (index >= 0) {
78
- await dispatch({
79
- action: SpaceAction.REMOVE_OBJECTS,
80
- data: { objects: [collection.objects[index]], collection },
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
- // TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.
84
- // delete stack.sections[Path.last(path)];
85
- }
86
- };
87
-
88
- const handleAdd = (id: string, position: AddSectionPosition) => {
89
- void dispatch?.({
90
- action: LayoutAction.SET_LAYOUT,
91
- data: {
92
- element: 'dialog',
93
- component: `${STACK_PLUGIN}/AddSectionDialog`,
94
- subject: { path: id, position, collection },
95
- },
96
- });
97
- };
98
-
99
- const handleNavigate = async (id: string) => {
100
- await dispatch([
101
- {
102
- action: NavigationAction.OPEN,
103
- data: { activeParts: { main: [id] } },
104
- },
105
- {
106
- action: LayoutAction.SCROLL_INTO_VIEW,
107
- data: { id },
108
- },
109
- ]);
110
- };
111
-
112
- const handleCollapse = (id: string, collapsed: boolean) => {
113
- setCollapsedSections((prev) => ({ ...prev, [id]: collapsed }));
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' separators={false} id={id} data-testid='main.stack'>
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
- {items.length === 0 ? (
133
- <AddSection collection={collection} />
134
- ) : (
135
- <div role='none' className='flex mlb-2 pli-2 justify-center'>
136
- <Button
137
- data-testid='stack.createSection'
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 style={{ zIndex: 70 }}>
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'>
@@ -7,4 +7,3 @@ import { lazy } from 'react';
7
7
  export const StackMain = lazy(() => import('./StackMain'));
8
8
 
9
9
  export * from './StackSettings';
10
- export * from './AddSectionDialog';
package/src/index.ts CHANGED
@@ -2,10 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { StackPlugin } from './StackPlugin';
6
-
7
- export default StackPlugin;
8
-
9
- export * from './types';
10
-
5
+ export * from './meta';
11
6
  export * from './StackPlugin';
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 default {
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.