@dxos/plugin-stack 0.8.3-staging.0fa589b → 0.8.4-main.1068cf700f

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 (94) hide show
  1. package/dist/lib/browser/StackContainer-TFG62M42.mjs +275 -0
  2. package/dist/lib/browser/StackContainer-TFG62M42.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-XHZTILS3.mjs → chunk-4X7CK6FM.mjs} +8 -6
  4. package/dist/lib/browser/chunk-4X7CK6FM.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-KBJKTX5V.mjs → chunk-CD32XYEB.mjs} +11 -12
  6. package/dist/lib/browser/chunk-CD32XYEB.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +44 -60
  8. package/dist/lib/browser/index.mjs.map +4 -4
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/react-surface-RMMCIEXY.mjs +41 -0
  11. package/dist/lib/browser/react-surface-RMMCIEXY.mjs.map +7 -0
  12. package/dist/lib/browser/types/index.mjs +1 -1
  13. package/dist/lib/node-esm/StackContainer-G4QUICWO.mjs +276 -0
  14. package/dist/lib/node-esm/StackContainer-G4QUICWO.mjs.map +7 -0
  15. package/dist/lib/node-esm/{chunk-KEWNJDTP.mjs → chunk-26XWE7UY.mjs} +11 -12
  16. package/dist/lib/node-esm/chunk-26XWE7UY.mjs.map +7 -0
  17. package/dist/lib/node-esm/{chunk-YW7WYA4H.mjs → chunk-HEEGXPSW.mjs} +8 -6
  18. package/dist/lib/node-esm/chunk-HEEGXPSW.mjs.map +7 -0
  19. package/dist/lib/node-esm/index.mjs +44 -60
  20. package/dist/lib/node-esm/index.mjs.map +4 -4
  21. package/dist/lib/node-esm/meta.json +1 -1
  22. package/dist/lib/node-esm/react-surface-R5QS3JT6.mjs +42 -0
  23. package/dist/lib/node-esm/react-surface-R5QS3JT6.mjs.map +7 -0
  24. package/dist/lib/node-esm/types/index.mjs +1 -1
  25. package/dist/types/src/StackPlugin.d.ts +2 -1
  26. package/dist/types/src/StackPlugin.d.ts.map +1 -1
  27. package/dist/types/src/capabilities/index.d.ts +1 -1
  28. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  29. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  30. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  31. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  32. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  33. package/dist/types/src/components/StackContainer.d.ts +9 -0
  34. package/dist/types/src/components/StackContainer.d.ts.map +1 -0
  35. package/dist/types/src/components/StackSection.d.ts.map +1 -1
  36. package/dist/types/src/components/StackSettings.d.ts.map +1 -1
  37. package/dist/types/src/components/index.d.ts +7 -2
  38. package/dist/types/src/components/index.d.ts.map +1 -1
  39. package/dist/types/src/meta.d.ts +2 -3
  40. package/dist/types/src/meta.d.ts.map +1 -1
  41. package/dist/types/src/translations.d.ts +36 -35
  42. package/dist/types/src/translations.d.ts.map +1 -1
  43. package/dist/types/src/types/index.d.ts +1 -1
  44. package/dist/types/src/types/index.d.ts.map +1 -1
  45. package/dist/types/src/types/stack.d.ts +13 -14
  46. package/dist/types/src/types/stack.d.ts.map +1 -1
  47. package/dist/types/src/types/types.d.ts +7 -5
  48. package/dist/types/src/types/types.d.ts.map +1 -1
  49. package/dist/types/tsconfig.tsbuildinfo +1 -1
  50. package/package.json +42 -39
  51. package/src/StackPlugin.ts +27 -43
  52. package/src/capabilities/index.ts +1 -3
  53. package/src/capabilities/react-surface/index.ts +7 -0
  54. package/src/capabilities/react-surface/react-surface.tsx +34 -0
  55. package/src/components/StackContainer.tsx +167 -0
  56. package/src/components/StackSection.tsx +8 -7
  57. package/src/components/StackSettings.tsx +15 -8
  58. package/src/components/index.ts +1 -1
  59. package/src/meta.ts +8 -5
  60. package/src/translations.ts +9 -7
  61. package/src/types/index.ts +1 -1
  62. package/src/types/stack.ts +12 -8
  63. package/src/types/types.ts +4 -5
  64. package/dist/lib/browser/StackMain-VQUBQKYP.mjs +0 -298
  65. package/dist/lib/browser/StackMain-VQUBQKYP.mjs.map +0 -7
  66. package/dist/lib/browser/chunk-KBJKTX5V.mjs.map +0 -7
  67. package/dist/lib/browser/chunk-XHZTILS3.mjs.map +0 -7
  68. package/dist/lib/browser/react-surface-7NC5QPP4.mjs +0 -46
  69. package/dist/lib/browser/react-surface-7NC5QPP4.mjs.map +0 -7
  70. package/dist/lib/node/StackMain-33HO2PMZ.cjs +0 -314
  71. package/dist/lib/node/StackMain-33HO2PMZ.cjs.map +0 -7
  72. package/dist/lib/node/chunk-F7ZNJ53O.cjs +0 -43
  73. package/dist/lib/node/chunk-F7ZNJ53O.cjs.map +0 -7
  74. package/dist/lib/node/chunk-R6Q5AF3V.cjs +0 -51
  75. package/dist/lib/node/chunk-R6Q5AF3V.cjs.map +0 -7
  76. package/dist/lib/node/index.cjs +0 -123
  77. package/dist/lib/node/index.cjs.map +0 -7
  78. package/dist/lib/node/meta.json +0 -1
  79. package/dist/lib/node/react-surface-BUYFGQTR.cjs +0 -64
  80. package/dist/lib/node/react-surface-BUYFGQTR.cjs.map +0 -7
  81. package/dist/lib/node/types/index.cjs +0 -31
  82. package/dist/lib/node/types/index.cjs.map +0 -7
  83. package/dist/lib/node-esm/StackMain-7L5JME2D.mjs +0 -299
  84. package/dist/lib/node-esm/StackMain-7L5JME2D.mjs.map +0 -7
  85. package/dist/lib/node-esm/chunk-KEWNJDTP.mjs.map +0 -7
  86. package/dist/lib/node-esm/chunk-YW7WYA4H.mjs.map +0 -7
  87. package/dist/lib/node-esm/react-surface-2ODZHHA7.mjs +0 -47
  88. package/dist/lib/node-esm/react-surface-2ODZHHA7.mjs.map +0 -7
  89. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  90. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  91. package/dist/types/src/components/StackMain.d.ts +0 -9
  92. package/dist/types/src/components/StackMain.d.ts.map +0 -1
  93. package/src/capabilities/react-surface.tsx +0 -34
  94. package/src/components/StackMain.tsx +0 -160
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { type DataType } from '@dxos/schema';
3
- type StackMainProps = {
4
- id: string;
5
- collection: DataType.Collection;
6
- };
7
- declare const StackMain: ({ id, collection }: StackMainProps) => React.JSX.Element;
8
- export default StackMain;
9
- //# sourceMappingURL=StackMain.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StackMain.d.ts","sourceRoot":"","sources":["../../../../src/components/StackMain.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAgBrD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAc7C,KAAK,cAAc,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC;CACjC,CAAC;AAEF,QAAA,MAAM,SAAS,GAAI,oBAAoB,cAAc,sBAoHpD,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,34 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
- import { Obj } from '@dxos/echo';
9
- import { fullyQualifiedId } from '@dxos/react-client/echo';
10
- import { DataType } from '@dxos/schema';
11
-
12
- import { StackMain } from '../components';
13
- import { STACK_PLUGIN } from '../meta';
14
-
15
- export default () =>
16
- contributes(
17
- Capabilities.ReactSurface,
18
- createSurface({
19
- id: `${STACK_PLUGIN}/article`,
20
- role: 'article',
21
- filter: (data): data is { id?: string; subject: DataType.Collection } =>
22
- Obj.instanceOf(DataType.Collection, data.subject),
23
- component: ({ data }) => {
24
- // This allows the id to be overridden by the surface for situations where the id of the collection
25
- // is not the same as the id of what is being represented (e.g., a space with a root collection).
26
- 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
- );
32
- },
33
- }),
34
- );
@@ -1,160 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { Plus } from '@phosphor-icons/react';
6
- import { Option } from 'effect';
7
- import React, { useCallback, useState } from 'react';
8
-
9
- import {
10
- Capabilities,
11
- LayoutAction,
12
- createIntent,
13
- useAppGraph,
14
- useCapabilities,
15
- useIntentDispatcher,
16
- } from '@dxos/app-framework';
17
- import { fullyQualifiedId, isLiveObject } from '@dxos/client/echo';
18
- import { Obj } from '@dxos/echo';
19
- import { SpaceAction } from '@dxos/plugin-space/types';
20
- import { Button, toLocalizedString, useTranslation } from '@dxos/react-ui';
21
- import { AttentionProvider } from '@dxos/react-ui-attention';
22
- import { Stack } from '@dxos/react-ui-stack';
23
- import { type DataType } from '@dxos/schema';
24
- import { isNonNullable } from '@dxos/util';
25
-
26
- import { StackContext } from './StackContext';
27
- import { StackSection } from './StackSection';
28
- import { STACK_PLUGIN } from '../meta';
29
- import {
30
- type AddSectionPosition,
31
- type CollapsedSections,
32
- type StackSectionItem,
33
- type StackSectionMetadata,
34
- type StackSectionView,
35
- } from '../types';
36
-
37
- type StackMainProps = {
38
- id: string;
39
- collection: DataType.Collection;
40
- };
41
-
42
- const StackMain = ({ id, collection }: StackMainProps) => {
43
- const { dispatchPromise: dispatch } = useIntentDispatcher();
44
- const { graph } = useAppGraph();
45
- const { t } = useTranslation(STACK_PLUGIN);
46
- const allMetadata = useCapabilities(Capabilities.Metadata);
47
- const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});
48
-
49
- // TODO(wittjosiah): Re-implement stack views with relations.
50
- // const defaultStack = useMemo(() => Obj.make(StackViewType, { sections: {} }), [collection]);
51
- // const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;
52
- // useEffect(() => {
53
- // if (!collection.views[StackViewType.typename]) {
54
- // collection.views[StackViewType.typename] = Ref.make(stack);
55
- // }
56
- // }, [collection, stack]);
57
-
58
- const items =
59
- collection.objects
60
- // TODO(wittjosiah): Should the database handle this differently?
61
- // TODO(wittjosiah): Render placeholders for missing objects so they can be removed from the stack?
62
- .map((object) => object.target)
63
- .filter(isNonNullable)
64
- .map((object) => {
65
- const metadata = allMetadata.find((m) => m.id === (Obj.getTypename(object) ?? 'never'))
66
- ?.metadata as StackSectionMetadata;
67
- const view = {
68
- // ...stack.sections[object.id],
69
- collapsed: collapsedSections[fullyQualifiedId(object)],
70
- title:
71
- (object as any)?.title ??
72
- // TODO(wittjosiah): `getNode` is not reactive.
73
- toLocalizedString(graph.getNode(fullyQualifiedId(object)).pipe(Option.getOrNull)?.properties.label, t),
74
- } as StackSectionView;
75
- return { id: fullyQualifiedId(object), object, metadata, view } satisfies StackSectionItem;
76
- }) ?? [];
77
-
78
- const handleDelete = useCallback(
79
- async (id: string) => {
80
- const index = collection.objects
81
- .map((object) => object.target)
82
- .filter(isNonNullable)
83
- .findIndex((section) => fullyQualifiedId(section) === id);
84
- const object = collection.objects[index].target;
85
- if (isLiveObject(object)) {
86
- await dispatch(createIntent(SpaceAction.RemoveObjects, { objects: [object], target: collection }));
87
-
88
- // TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.
89
- // delete stack.sections[Path.last(path)];
90
- }
91
- },
92
- [collection, dispatch],
93
- );
94
-
95
- const handleAdd = useCallback(
96
- async (id: string, position: AddSectionPosition) => {
97
- await dispatch?.(
98
- // TODO(wittjosiah): Use object creation dialog.
99
- createIntent(LayoutAction.UpdateDialog, {
100
- part: 'dialog',
101
- subject: `${STACK_PLUGIN}/AddSectionDialog`,
102
- options: {
103
- blockAlign: 'start',
104
- props: {
105
- path: id,
106
- position,
107
- collection,
108
- },
109
- },
110
- }),
111
- );
112
- },
113
- [collection, dispatch],
114
- );
115
-
116
- const handleNavigate = useCallback(
117
- async (id: string) => {
118
- await dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [id] }));
119
- },
120
- [dispatch],
121
- );
122
-
123
- const handleCollapse = useCallback(
124
- (id: string, collapsed: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: collapsed })),
125
- [],
126
- );
127
-
128
- const handleAddSection = useCallback(
129
- () => dispatch?.(createIntent(SpaceAction.OpenCreateObject, { target: collection, navigable: false })),
130
- [collection, dispatch],
131
- );
132
-
133
- return (
134
- <AttentionProvider id={id}>
135
- <StackContext.Provider
136
- value={{
137
- onCollapse: handleCollapse,
138
- onNavigate: handleNavigate,
139
- onDelete: handleDelete,
140
- onAdd: handleAdd,
141
- }}
142
- >
143
- <Stack orientation='vertical' size='intrinsic' id={id} data-testid='main.stack'>
144
- {items.map((item) => (
145
- <StackSection key={item.id} {...item} />
146
- ))}
147
- </Stack>
148
-
149
- <div role='none' className='flex mlb-2 pli-2 justify-center'>
150
- <Button data-testid='stack.createSection' classNames='gap-2' onClick={handleAddSection}>
151
- <Plus />
152
- <span className='sr-only'>{t('add section label')}</span>
153
- </Button>
154
- </div>
155
- </StackContext.Provider>
156
- </AttentionProvider>
157
- );
158
- };
159
-
160
- export default StackMain;