@dxos/plugin-stack 0.8.4-main.70d3990 → 0.8.4-main.74a063c4e0

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 (90) hide show
  1. package/dist/lib/browser/index.mjs +71 -77
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/types/index.mjs +21 -4
  5. package/dist/lib/browser/types/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/index.mjs +72 -77
  7. package/dist/lib/node-esm/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/meta.json +1 -1
  9. package/dist/lib/node-esm/types/index.mjs +22 -4
  10. package/dist/lib/node-esm/types/index.mjs.map +4 -4
  11. package/dist/types/src/StackPlugin.d.ts +2 -1
  12. package/dist/types/src/StackPlugin.d.ts.map +1 -1
  13. package/dist/types/src/capabilities/index.d.ts +2 -1
  14. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  15. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  16. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  17. package/dist/types/src/components/{StackContext.d.ts → StackContext/StackContext.d.ts} +2 -1
  18. package/dist/types/src/components/StackContext/StackContext.d.ts.map +1 -0
  19. package/dist/types/src/components/StackContext/index.d.ts +2 -0
  20. package/dist/types/src/components/StackContext/index.d.ts.map +1 -0
  21. package/dist/types/src/components/StackSection/CaretDownUp.d.ts.map +1 -0
  22. package/dist/types/src/components/{StackSection.d.ts → StackSection/StackSection.d.ts} +1 -1
  23. package/dist/types/src/components/StackSection/StackSection.d.ts.map +1 -0
  24. package/dist/types/src/components/StackSection/index.d.ts +2 -0
  25. package/dist/types/src/components/StackSection/index.d.ts.map +1 -0
  26. package/dist/types/src/components/{StackSettings.d.ts → StackSettings/StackSettings.d.ts} +1 -1
  27. package/dist/types/src/components/StackSettings/StackSettings.d.ts.map +1 -0
  28. package/dist/types/src/components/StackSettings/index.d.ts +2 -0
  29. package/dist/types/src/components/StackSettings/index.d.ts.map +1 -0
  30. package/dist/types/src/components/index.d.ts +2 -7
  31. package/dist/types/src/components/index.d.ts.map +1 -1
  32. package/dist/types/src/containers/StackContainer/StackContainer.d.ts +7 -0
  33. package/dist/types/src/containers/StackContainer/StackContainer.d.ts.map +1 -0
  34. package/dist/types/src/containers/StackContainer/index.d.ts +2 -0
  35. package/dist/types/src/containers/StackContainer/index.d.ts.map +1 -0
  36. package/dist/types/src/containers/index.d.ts +3 -0
  37. package/dist/types/src/containers/index.d.ts.map +1 -0
  38. package/dist/types/src/meta.d.ts +3 -3
  39. package/dist/types/src/meta.d.ts.map +1 -1
  40. package/dist/types/src/translations.d.ts +31 -30
  41. package/dist/types/src/translations.d.ts.map +1 -1
  42. package/dist/types/src/types/stack.d.ts +12 -13
  43. package/dist/types/src/types/stack.d.ts.map +1 -1
  44. package/dist/types/src/types/types.d.ts +2 -2
  45. package/dist/types/src/types/types.d.ts.map +1 -1
  46. package/dist/types/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +49 -36
  48. package/src/StackPlugin.ts +27 -41
  49. package/src/capabilities/index.ts +2 -2
  50. package/src/capabilities/react-surface.tsx +21 -21
  51. package/src/components/{StackContext.tsx → StackContext/StackContext.tsx} +3 -1
  52. package/src/components/StackContext/index.ts +5 -0
  53. package/src/components/{StackSection.tsx → StackSection/StackSection.tsx} +26 -24
  54. package/src/components/StackSection/index.ts +5 -0
  55. package/src/components/StackSettings/StackSettings.tsx +28 -0
  56. package/src/components/StackSettings/index.ts +5 -0
  57. package/src/components/index.ts +2 -4
  58. package/src/containers/StackContainer/StackContainer.tsx +170 -0
  59. package/src/containers/StackContainer/index.ts +5 -0
  60. package/src/containers/index.ts +7 -0
  61. package/src/meta.ts +4 -4
  62. package/src/translations.ts +22 -21
  63. package/src/types/stack.ts +11 -7
  64. package/src/types/types.ts +2 -2
  65. package/dist/lib/browser/StackContainer-DD3ZD5OE.mjs +0 -299
  66. package/dist/lib/browser/StackContainer-DD3ZD5OE.mjs.map +0 -7
  67. package/dist/lib/browser/chunk-NHMDZYOB.mjs +0 -28
  68. package/dist/lib/browser/chunk-NHMDZYOB.mjs.map +0 -7
  69. package/dist/lib/browser/chunk-UIKFKRFJ.mjs +0 -21
  70. package/dist/lib/browser/chunk-UIKFKRFJ.mjs.map +0 -7
  71. package/dist/lib/browser/react-surface-HVPK7YZQ.mjs +0 -39
  72. package/dist/lib/browser/react-surface-HVPK7YZQ.mjs.map +0 -7
  73. package/dist/lib/node-esm/StackContainer-JGWPXSUF.mjs +0 -300
  74. package/dist/lib/node-esm/StackContainer-JGWPXSUF.mjs.map +0 -7
  75. package/dist/lib/node-esm/chunk-BGVQYUYP.mjs +0 -23
  76. package/dist/lib/node-esm/chunk-BGVQYUYP.mjs.map +0 -7
  77. package/dist/lib/node-esm/chunk-ZZFA7HIV.mjs +0 -30
  78. package/dist/lib/node-esm/chunk-ZZFA7HIV.mjs.map +0 -7
  79. package/dist/lib/node-esm/react-surface-HYSD7AC2.mjs +0 -40
  80. package/dist/lib/node-esm/react-surface-HYSD7AC2.mjs.map +0 -7
  81. package/dist/types/src/components/CaretDownUp.d.ts.map +0 -1
  82. package/dist/types/src/components/StackContainer.d.ts +0 -9
  83. package/dist/types/src/components/StackContainer.d.ts.map +0 -1
  84. package/dist/types/src/components/StackContext.d.ts.map +0 -1
  85. package/dist/types/src/components/StackSection.d.ts.map +0 -1
  86. package/dist/types/src/components/StackSettings.d.ts.map +0 -1
  87. package/src/components/StackContainer.tsx +0 -172
  88. package/src/components/StackSettings.tsx +0 -30
  89. /package/dist/types/src/components/{CaretDownUp.d.ts → StackSection/CaretDownUp.d.ts} +0 -0
  90. /package/src/components/{CaretDownUp.tsx → StackSection/CaretDownUp.tsx} +0 -0
package/package.json CHANGED
@@ -1,13 +1,24 @@
1
1
  {
2
2
  "name": "@dxos/plugin-stack",
3
- "version": "0.8.4-main.70d3990",
3
+ "version": "0.8.4-main.74a063c4e0",
4
4
  "description": "DXOS Surface plugin for Stack entities",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
13
  "sideEffects": true,
10
14
  "type": "module",
15
+ "imports": {
16
+ "#capabilities": "./src/capabilities/index.ts",
17
+ "#components": "./src/components/index.ts",
18
+ "#containers": "./src/containers/index.ts",
19
+ "#meta": "./src/meta.ts",
20
+ "#types": "./src/types/index.ts"
21
+ },
11
22
  "exports": {
12
23
  ".": {
13
24
  "source": "./src/index.ts",
@@ -35,49 +46,51 @@
35
46
  "src"
36
47
  ],
37
48
  "dependencies": {
38
- "@fluentui/react-tabster": "^9.24.2",
39
- "@preact-signals/safe-react": "^0.9.0",
40
- "@preact/signals-core": "^1.12.1",
49
+ "@effect-atom/atom-react": "^0.5.0",
50
+ "@fluentui/react-tabster": "9.26.11",
41
51
  "@radix-ui/react-collapsible": "1.1.3",
42
- "effect": "3.18.3",
52
+ "effect": "3.20.0",
43
53
  "node-fetch": "^2.6.0",
44
54
  "react-is": "~19.2.0",
45
- "@dxos/async": "0.8.4-main.70d3990",
46
- "@dxos/app-framework": "0.8.4-main.70d3990",
47
- "@dxos/client": "0.8.4-main.70d3990",
48
- "@dxos/echo": "0.8.4-main.70d3990",
49
- "@dxos/invariant": "0.8.4-main.70d3990",
50
- "@dxos/local-storage": "0.8.4-main.70d3990",
51
- "@dxos/plugin-deck": "0.8.4-main.70d3990",
52
- "@dxos/plugin-client": "0.8.4-main.70d3990",
53
- "@dxos/plugin-graph": "0.8.4-main.70d3990",
54
- "@dxos/plugin-space": "0.8.4-main.70d3990",
55
- "@dxos/react-client": "0.8.4-main.70d3990",
56
- "@dxos/react-ui-attention": "0.8.4-main.70d3990",
57
- "@dxos/react-ui-form": "0.8.4-main.70d3990",
58
- "@dxos/react-ui-stack": "0.8.4-main.70d3990",
59
- "@dxos/schema": "0.8.4-main.70d3990",
60
- "@dxos/types": "0.8.4-main.70d3990",
61
- "@dxos/util": "0.8.4-main.70d3990",
62
- "@dxos/react-ui-searchlist": "0.8.4-main.70d3990"
55
+ "@dxos/app-framework": "0.8.4-main.74a063c4e0",
56
+ "@dxos/async": "0.8.4-main.74a063c4e0",
57
+ "@dxos/client": "0.8.4-main.74a063c4e0",
58
+ "@dxos/echo": "0.8.4-main.74a063c4e0",
59
+ "@dxos/app-toolkit": "0.8.4-main.74a063c4e0",
60
+ "@dxos/invariant": "0.8.4-main.74a063c4e0",
61
+ "@dxos/operation": "0.8.4-main.74a063c4e0",
62
+ "@dxos/plugin-client": "0.8.4-main.74a063c4e0",
63
+ "@dxos/plugin-graph": "0.8.4-main.74a063c4e0",
64
+ "@dxos/plugin-deck": "0.8.4-main.74a063c4e0",
65
+ "@dxos/echo-atom": "0.8.4-main.74a063c4e0",
66
+ "@dxos/plugin-space": "0.8.4-main.74a063c4e0",
67
+ "@dxos/react-client": "0.8.4-main.74a063c4e0",
68
+ "@dxos/react-ui-attention": "0.8.4-main.74a063c4e0",
69
+ "@dxos/react-ui-form": "0.8.4-main.74a063c4e0",
70
+ "@dxos/react-ui-search": "0.8.4-main.74a063c4e0",
71
+ "@dxos/react-ui-stack": "0.8.4-main.74a063c4e0",
72
+ "@dxos/schema": "0.8.4-main.74a063c4e0",
73
+ "@dxos/util": "0.8.4-main.74a063c4e0",
74
+ "@dxos/types": "0.8.4-main.74a063c4e0"
63
75
  },
64
76
  "devDependencies": {
65
77
  "@babel/core": "^7.18.13",
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.70d3990",
72
- "@dxos/react-ui-theme": "0.8.4-main.70d3990",
73
- "@dxos/storybook-utils": "0.8.4-main.70d3990"
78
+ "@types/react": "~19.2.7",
79
+ "@types/react-dom": "~19.2.3",
80
+ "react": "~19.2.3",
81
+ "react-dom": "~19.2.3",
82
+ "vite": "^7.1.11",
83
+ "@dxos/storybook-utils": "0.8.4-main.74a063c4e0",
84
+ "@dxos/react-ui": "0.8.4-main.74a063c4e0",
85
+ "@dxos/ui-theme": "0.8.4-main.74a063c4e0"
74
86
  },
75
87
  "peerDependencies": {
76
- "effect": "^3.13.3",
77
- "react": "^19.0.0",
78
- "react-dom": "^19.0.0",
79
- "@dxos/react-ui": "0.8.4-main.70d3990",
80
- "@dxos/react-ui-theme": "0.8.4-main.70d3990"
88
+ "@effect-atom/atom-react": "^0.5.0",
89
+ "effect": "3.20.0",
90
+ "react": "~19.2.3",
91
+ "react-dom": "~19.2.3",
92
+ "@dxos/react-ui": "0.8.4-main.74a063c4e0",
93
+ "@dxos/ui-theme": "0.8.4-main.74a063c4e0"
81
94
  },
82
95
  "publishConfig": {
83
96
  "access": "public"
@@ -2,50 +2,36 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
5
+ import { Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
6
7
  import { type Obj } from '@dxos/echo';
7
- import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
8
8
 
9
- import { ReactSurface } from './capabilities';
10
- import { SECTION_IDENTIFIER, meta } from './meta';
9
+ import { ReactSurface } from '#capabilities';
10
+ import { SECTION_IDENTIFIER, meta } from '#meta';
11
+ import { StackViewType } from '#types';
12
+
11
13
  import { translations } from './translations';
12
- import { StackViewType } from './types';
13
14
 
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
- }
36
- },
15
+ export const StackPlugin = Plugin.define(meta).pipe(
16
+ AppPlugin.addMetadataModule({
17
+ metadata: {
18
+ id: SECTION_IDENTIFIER,
19
+ metadata: {
20
+ parse: (section: { object: Obj.Unknown }, type: string) => {
21
+ switch (type) {
22
+ case 'node':
23
+ return { id: section.object.id, label: (section.object as any).title, data: section.object };
24
+ case 'object':
25
+ return section.object;
26
+ case 'view-object':
27
+ return section;
28
+ }
37
29
  },
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,
30
+ },
31
+ },
50
32
  }),
51
- ]);
33
+ AppPlugin.addSchemaModule({ schema: [StackViewType] }),
34
+ AppPlugin.addSurfaceModule({ activate: ReactSurface }),
35
+ AppPlugin.addTranslationsModule({ translations }),
36
+ Plugin.make,
37
+ );
@@ -2,6 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { lazy } from '@dxos/app-framework';
5
+ import { Capability } from '@dxos/app-framework';
6
6
 
7
- export const ReactSurface = lazy(() => import('./react-surface'));
7
+ export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -2,28 +2,28 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ import * as Effect from 'effect/Effect';
5
6
  import React from 'react';
6
7
 
7
- import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
- import { Obj } from '@dxos/echo';
9
- import { Collection } from '@dxos/schema';
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { Surface } from '@dxos/app-framework/ui';
10
+ import { AppSurface } from '@dxos/app-toolkit/ui';
11
+ import { Collection } from '@dxos/echo';
10
12
 
11
- import { StackContainer } from '../components';
12
- import { meta } from '../meta';
13
+ import { StackContainer } from '#containers';
13
14
 
14
- export default () =>
15
- contributes(
16
- Capabilities.ReactSurface,
17
- createSurface({
18
- id: `${meta.id}/article`,
19
- role: 'article',
20
- filter: (data): data is { id?: string; subject: Collection.Collection } =>
21
- Obj.instanceOf(Collection.Collection, data.subject),
22
- component: ({ data }) => {
23
- // This allows the id to be overridden by the surface for situations where the id of the collection
24
- // is not the same as the id of what is being represented (e.g., a space with a root collection).
25
- const id = typeof data.id === 'string' ? data.id : undefined;
26
- return <StackContainer id={id ?? Obj.getDXN(data.subject).toString()} collection={data.subject} />;
27
- },
28
- }),
29
- );
15
+ export default Capability.makeModule(() =>
16
+ Effect.succeed(
17
+ Capability.contributes(
18
+ Capabilities.ReactSurface,
19
+ Surface.create({
20
+ id: 'article',
21
+ role: 'article',
22
+ filter: AppSurface.objectArticle(Collection.Collection),
23
+ component: ({ role, data }) => {
24
+ return <StackContainer attendableId={data.attendableId} role={role} subject={data.subject} />;
25
+ },
26
+ }),
27
+ ),
28
+ ),
29
+ );
@@ -4,9 +4,10 @@
4
4
 
5
5
  import { createContext, useContext } from 'react';
6
6
 
7
- import { type AddSectionPosition } from '../types';
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 () => {},
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './StackContext';
@@ -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/react';
8
+ import { Surface } from '@dxos/app-framework/ui';
9
9
  import { DropdownMenu, Icon, IconButton, useTranslation } from '@dxos/react-ui';
10
10
  import { useAttentionAttributes } from '@dxos/react-ui-attention';
11
11
  import { StackItem } from '@dxos/react-ui-stack';
12
- import { getSize, mx, textBlockWidth } from '@dxos/react-ui-theme';
12
+ import { getSize, mx } from '@dxos/ui-theme';
13
13
 
14
- import { meta } from '../meta';
15
- import { type StackSectionItem } from '../types';
14
+ import { meta } from '#meta';
15
+ import { type StackSectionItem } from '#types';
16
16
 
17
+ import { useStack } from '../StackContext';
17
18
  import { CaretDownUp } from './CaretDownUp';
18
- import { useStack } from './StackContext';
19
19
 
20
- const sectionActionDimensions = 'p-1 mlb-1 shrink-0 min-bs-0 is-[--rail-action] bs-min';
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 attentionAttrs = useAttentionAttributes(id);
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
@@ -47,7 +49,7 @@ export const StackSection = ({
47
49
  >
48
50
  <DropdownMenu.Trigger asChild>
49
51
  <StackItem.SigilButton>
50
- <Icon icon={icon} size={5} classNames='transition-opacity' />
52
+ <Icon icon={icon} classNames='transition-opacity' />
51
53
  </StackItem.SigilButton>
52
54
  </DropdownMenu.Trigger>
53
55
  <DropdownMenu.Portal>
@@ -55,28 +57,28 @@ export const StackSection = ({
55
57
  <DropdownMenu.Viewport>
56
58
  {view.collapsed ? (
57
59
  <DropdownMenu.Item onClick={() => onNavigate(id)} data-testid='section.navigate-to'>
58
- <Icon icon='ph--arrow-right--regular' size={5} />
59
- <span className='mis-2 grow'>{t('navigate to section label')}</span>
60
+ <Icon icon='ph--arrow-right--regular' />
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='mis-2 grow'>{t('collapse label')}</span>
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
- <Icon icon='ph--arrow-line-up--regular' size={5} />
71
- <span className='mis-2 grow'>{t('add section before label')}</span>
72
+ <Icon icon='ph--arrow-line-up--regular' />
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
- <Icon icon='ph--arrow-line-down--regular' size={5} />
75
- <span className='mis-2 grow'>{t('add section after label')}</span>
76
+ <Icon icon='ph--arrow-line-down--regular' />
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
- <Icon icon='ph--trash--regular' size={5} />
79
- <span className='mis-2 grow'>{t('remove section label')}</span>
80
+ <Icon icon='ph--trash--regular' />
81
+ <span className='ms-2 grow'>{t('remove-section.label')}</span>
80
82
  </DropdownMenu.Item>
81
83
  </DropdownMenu.Viewport>
82
84
  <DropdownMenu.Arrow />
@@ -88,7 +90,7 @@ export const StackSection = ({
88
90
  <IconButton
89
91
  iconOnly
90
92
  variant='ghost'
91
- label={t('expand label')}
93
+ label={t('expand.label')}
92
94
  icon='ph--caret-up-down--regular'
93
95
  classNames={sectionActionDimensions}
94
96
  />
@@ -98,7 +100,7 @@ export const StackSection = ({
98
100
  iconOnly
99
101
  variant='ghost'
100
102
  onClick={() => onNavigate(id)}
101
- label={t('navigate to section label')}
103
+ label={t('navigate-to-section.label')}
102
104
  icon='ph--arrow-right--regular'
103
105
  data-testid='section.navigate-to'
104
106
  classNames={sectionActionDimensions}
@@ -107,11 +109,11 @@ export const StackSection = ({
107
109
  </StackItem.HeadingStickyContent>
108
110
  </StackItem.Heading>
109
111
  <CollapsiblePrimitive.Content>
110
- <Surface role='section' data={{ subject: object }} limit={1} placeholder={<></>} />
112
+ <Surface.Surface role='section' data={data} limit={1} placeholder={<></>} />
111
113
  </CollapsiblePrimitive.Content>
112
114
  {view.collapsed && (
113
- <StackItem.Content classNames='attention-surface'>
114
- <h2 className={mx('flex items-center p-4 font-medium', textBlockWidth)}>{view.title}</h2>
115
+ <StackItem.Content classNames='dx-attention-surface'>
116
+ <h2 className={mx('flex items-center p-4 font-medium')}>{view.title}</h2>
115
117
  </StackItem.Content>
116
118
  )}
117
119
  </StackItem.Root>
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './StackSection';
@@ -0,0 +1,28 @@
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 as SettingsForm } 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
+ <SettingsForm.Viewport>
18
+ <SettingsForm.Section title={t('settings.title', { ns: meta.id })}>
19
+ <SettingsForm.Item title={t('settings.separation.label')} description={t('settings.separation.description')}>
20
+ <Input.Switch
21
+ checked={settings.separation}
22
+ onCheckedChange={(checked) => (settings.separation = !!checked)}
23
+ />
24
+ </SettingsForm.Item>
25
+ </SettingsForm.Section>
26
+ </SettingsForm.Viewport>
27
+ );
28
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export * from './StackSettings';
@@ -2,8 +2,6 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { lazy } from 'react';
6
-
7
- export const StackContainer = lazy(() => import('./StackContainer'));
8
-
5
+ export * from './StackContext';
6
+ export * from './StackSection';
9
7
  export * from './StackSettings';
@@ -0,0 +1,170 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { Atom, useAtomValue } from '@effect-atom/atom-react';
6
+ import * as Option from 'effect/Option';
7
+ import React, { useCallback, useState } from 'react';
8
+
9
+ import { useCapabilities, useOperationInvoker } from '@dxos/app-framework/ui';
10
+ import { AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';
11
+ import { useAppGraph, type AppSurface } from '@dxos/app-toolkit/ui';
12
+ import { Obj, type Ref } from '@dxos/echo';
13
+ import { type Collection } from '@dxos/echo';
14
+ import { AtomObj } from '@dxos/echo-atom';
15
+ import { Graph } from '@dxos/plugin-graph';
16
+ import { SpaceOperation } from '@dxos/plugin-space/operations';
17
+ import { Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';
18
+ import { Stack, StackItem } from '@dxos/react-ui-stack';
19
+ import { isNonNullable } from '@dxos/util';
20
+
21
+ import { StackContext, StackSection } from '#components';
22
+ import { meta } from '#meta';
23
+ import {
24
+ type AddSectionPosition,
25
+ type CollapsedSections,
26
+ type StackSectionItem,
27
+ type StackSectionMetadata,
28
+ type StackSectionView,
29
+ } from '#types';
30
+
31
+ const collectionObjectsFamily = Atom.family((collection: Collection.Collection) =>
32
+ Atom.make((get) => {
33
+ const snapshot = get(AtomObj.make(collection));
34
+ return (
35
+ snapshot.objects
36
+ // TODO(wittjosiah): Why isn't this type inferred correctly?
37
+ .map((ref: Ref.Ref<Obj.Unknown>) => get(AtomObj.makeWithReactive(ref)))
38
+ .filter(isNonNullable)
39
+ );
40
+ }),
41
+ );
42
+
43
+ type StackContainerProps = AppSurface.ObjectArticleProps<Collection.Collection>;
44
+
45
+ export const StackContainer = ({ attendableId, subject: collection }: StackContainerProps) => {
46
+ const { invokePromise } = useOperationInvoker();
47
+ const { graph } = useAppGraph();
48
+ const { t } = useTranslation(meta.id);
49
+ const allMetadata = useCapabilities(AppCapabilities.Metadata);
50
+ const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});
51
+
52
+ // TODO(wittjosiah): Re-implement stack views with relations.
53
+ // const defaultStack = useMemo(() => Obj.make(StackViewType, { sections: {} }), [collection]);
54
+ // const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;
55
+ // useEffect(() => {
56
+ // if (!collection.views[StackViewType.typename]) {
57
+ // collection.views[StackViewType.typename] = Ref.make(stack);
58
+ // }
59
+ // }, [collection, stack]);
60
+
61
+ const collectionObjects = useAtomValue(collectionObjectsFamily(collection));
62
+ const items = collectionObjects.map((object: Obj.Unknown) => {
63
+ const metadata = allMetadata.find((m) => m.id === (Obj.getTypename(object) ?? 'never'))
64
+ ?.metadata as StackSectionMetadata;
65
+ const view = {
66
+ // ...stack.sections[object.id],
67
+ collapsed: collapsedSections[Obj.getDXN(object).toString()],
68
+ title:
69
+ (object as any)?.title ??
70
+ // TODO(wittjosiah): `getNode` is not reactive.
71
+ toLocalizedString(
72
+ Graph.getNode(graph, Obj.getDXN(object).toString()).pipe(Option.getOrNull)?.properties.label,
73
+ t,
74
+ ),
75
+ } as StackSectionView;
76
+ return { id: Obj.getDXN(object).toString(), object, metadata, view } satisfies StackSectionItem;
77
+ });
78
+
79
+ const handleDelete = useCallback(
80
+ async (id: string) => {
81
+ const index = collection.objects
82
+ .map((object) => object.target)
83
+ .filter(isNonNullable)
84
+ .findIndex((section) => Obj.getDXN(section).toString() === id);
85
+ const object = collection.objects[index].target;
86
+ if (Obj.isObject(object)) {
87
+ await invokePromise(SpaceOperation.RemoveObjects, {
88
+ objects: [object],
89
+ target: collection,
90
+ });
91
+
92
+ // TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.
93
+ // delete stack.sections[Path.last(path)];
94
+ }
95
+ },
96
+ [collection, invokePromise],
97
+ );
98
+
99
+ const handleAdd = useCallback(
100
+ async (id: string, position: AddSectionPosition) => {
101
+ // TODO(wittjosiah): Use object creation dialog.
102
+ await invokePromise(LayoutOperation.UpdateDialog, {
103
+ subject: `${meta.id}.AddSectionDialog`,
104
+ blockAlign: 'start',
105
+ props: {
106
+ path: id,
107
+ position,
108
+ collection,
109
+ },
110
+ });
111
+ },
112
+ [collection, invokePromise],
113
+ );
114
+
115
+ const handleNavigate = useCallback(
116
+ async (id: string) => {
117
+ await invokePromise(LayoutOperation.Open, { subject: [id] });
118
+ },
119
+ [invokePromise],
120
+ );
121
+
122
+ const handleCollapse = useCallback(
123
+ (id: string, collapsed: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: collapsed })),
124
+ [],
125
+ );
126
+
127
+ const handleAddSection = useCallback(
128
+ () =>
129
+ invokePromise(SpaceOperation.OpenCreateObject, {
130
+ target: collection,
131
+ navigable: false,
132
+ }),
133
+ [collection, invokePromise],
134
+ );
135
+
136
+ return (
137
+ <StackItem.Content toolbar classNames='dx-document'>
138
+ <Toolbar.Root>
139
+ <Toolbar.IconButton
140
+ icon='ph--plus--regular'
141
+ iconOnly
142
+ label='Add section'
143
+ data-testid='stack.addSection'
144
+ onClick={handleAddSection}
145
+ />
146
+ </Toolbar.Root>
147
+ <StackContext.Provider
148
+ value={{
149
+ attendableId,
150
+ onCollapse: handleCollapse,
151
+ onNavigate: handleNavigate,
152
+ onDelete: handleDelete,
153
+ onAdd: handleAdd,
154
+ }}
155
+ >
156
+ <Stack
157
+ orientation='vertical'
158
+ size='intrinsic'
159
+ id={Obj.getDXN(collection).toString()}
160
+ data-testid='main.stack'
161
+ classNames='overflow-y-auto'
162
+ >
163
+ {items.map((item) => (
164
+ <StackSection key={item.id} {...item} />
165
+ ))}
166
+ </Stack>
167
+ </StackContext.Provider>
168
+ </StackItem.Content>
169
+ );
170
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export { StackContainer as default } from './StackContainer';
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentType, lazy } from 'react';
6
+
7
+ export const StackContainer: ComponentType<any> = lazy(() => import('./StackContainer'));