@dxos/plugin-stack 0.8.3-staging.0fa589b → 0.8.4-main.28f8d3d
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-VQUBQKYP.mjs → StackMain-5DM2ROIH.mjs} +14 -13
- package/dist/lib/browser/StackMain-5DM2ROIH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-XHZTILS3.mjs → chunk-FVB7LGW7.mjs} +2 -2
- package/dist/lib/browser/{chunk-KBJKTX5V.mjs → chunk-IRTROCUQ.mjs} +2 -2
- package/dist/lib/browser/index.mjs +11 -11
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-7NC5QPP4.mjs → react-surface-T4IY2E45.mjs} +8 -8
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{StackMain-7L5JME2D.mjs → StackMain-SZBR33SL.mjs} +14 -13
- package/dist/lib/node-esm/StackMain-SZBR33SL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-KEWNJDTP.mjs → chunk-LRAZXJ65.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-YW7WYA4H.mjs → chunk-UN5PA7TK.mjs} +2 -2
- package/dist/lib/node-esm/index.mjs +11 -11
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-2ODZHHA7.mjs → react-surface-XSH3EWCO.mjs} +8 -8
- package/dist/lib/node-esm/types/index.mjs +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/translations.d.ts +35 -35
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +4 -2
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -27
- package/src/StackPlugin.ts +3 -3
- package/src/components/StackMain.tsx +5 -5
- package/src/components/StackSection.tsx +5 -4
- package/src/translations.ts +5 -4
- package/src/types/index.ts +1 -1
- package/src/types/types.ts +1 -2
- package/dist/lib/browser/StackMain-VQUBQKYP.mjs.map +0 -7
- package/dist/lib/node/StackMain-33HO2PMZ.cjs +0 -314
- package/dist/lib/node/StackMain-33HO2PMZ.cjs.map +0 -7
- package/dist/lib/node/chunk-F7ZNJ53O.cjs +0 -43
- package/dist/lib/node/chunk-F7ZNJ53O.cjs.map +0 -7
- package/dist/lib/node/chunk-R6Q5AF3V.cjs +0 -51
- package/dist/lib/node/chunk-R6Q5AF3V.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -123
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/react-surface-BUYFGQTR.cjs +0 -64
- package/dist/lib/node/react-surface-BUYFGQTR.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs +0 -31
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/StackMain-7L5JME2D.mjs.map +0 -7
- /package/dist/lib/browser/{chunk-XHZTILS3.mjs.map → chunk-FVB7LGW7.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-KBJKTX5V.mjs.map → chunk-IRTROCUQ.mjs.map} +0 -0
- /package/dist/lib/browser/{react-surface-7NC5QPP4.mjs.map → react-surface-T4IY2E45.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-KEWNJDTP.mjs.map → chunk-LRAZXJ65.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-YW7WYA4H.mjs.map → chunk-UN5PA7TK.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-surface-2ODZHHA7.mjs.map → react-surface-XSH3EWCO.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-stack",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4-main.28f8d3d",
|
|
4
4
|
"description": "DXOS Surface plugin for Stack entities",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"source": "./src/index.ts",
|
|
13
14
|
"types": "./dist/types/src/index.d.ts",
|
|
14
15
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
16
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
17
|
},
|
|
17
18
|
"./types": {
|
|
19
|
+
"source": "./src/types/index.ts",
|
|
18
20
|
"types": "./dist/types/src/types/index.d.ts",
|
|
19
21
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
20
22
|
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
@@ -37,47 +39,45 @@
|
|
|
37
39
|
"@preact-signals/safe-react": "^0.9.0",
|
|
38
40
|
"@preact/signals-core": "^1.9.0",
|
|
39
41
|
"@radix-ui/react-collapsible": "1.1.3",
|
|
40
|
-
"effect": "3.
|
|
42
|
+
"effect": "3.17.7",
|
|
41
43
|
"node-fetch": "^2.6.0",
|
|
42
44
|
"react-is": "~18.2.0",
|
|
43
|
-
"@dxos/app-framework": "0.8.
|
|
44
|
-
"@dxos/async": "0.8.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/echo-schema": "0.8.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/plugin-
|
|
52
|
-
"@dxos/plugin-
|
|
53
|
-
"@dxos/plugin-space": "0.8.
|
|
54
|
-
"@dxos/react-client": "0.8.
|
|
55
|
-
"@dxos/react-ui-attention": "0.8.
|
|
56
|
-
"@dxos/react-ui-
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/react-ui-
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
45
|
+
"@dxos/app-framework": "0.8.4-main.28f8d3d",
|
|
46
|
+
"@dxos/async": "0.8.4-main.28f8d3d",
|
|
47
|
+
"@dxos/client": "0.8.4-main.28f8d3d",
|
|
48
|
+
"@dxos/echo": "0.8.4-main.28f8d3d",
|
|
49
|
+
"@dxos/echo-schema": "0.8.4-main.28f8d3d",
|
|
50
|
+
"@dxos/local-storage": "0.8.4-main.28f8d3d",
|
|
51
|
+
"@dxos/plugin-client": "0.8.4-main.28f8d3d",
|
|
52
|
+
"@dxos/invariant": "0.8.4-main.28f8d3d",
|
|
53
|
+
"@dxos/plugin-deck": "0.8.4-main.28f8d3d",
|
|
54
|
+
"@dxos/plugin-graph": "0.8.4-main.28f8d3d",
|
|
55
|
+
"@dxos/plugin-space": "0.8.4-main.28f8d3d",
|
|
56
|
+
"@dxos/react-client": "0.8.4-main.28f8d3d",
|
|
57
|
+
"@dxos/react-ui-attention": "0.8.4-main.28f8d3d",
|
|
58
|
+
"@dxos/react-ui-stack": "0.8.4-main.28f8d3d",
|
|
59
|
+
"@dxos/schema": "0.8.4-main.28f8d3d",
|
|
60
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.28f8d3d",
|
|
61
|
+
"@dxos/util": "0.8.4-main.28f8d3d",
|
|
62
|
+
"@dxos/react-ui-form": "0.8.4-main.28f8d3d"
|
|
61
63
|
},
|
|
62
64
|
"devDependencies": {
|
|
63
65
|
"@babel/core": "^7.18.13",
|
|
64
|
-
"@phosphor-icons/react": "^2.1.5",
|
|
65
66
|
"@types/react": "~18.2.0",
|
|
66
67
|
"@types/react-dom": "~18.2.0",
|
|
67
68
|
"react": "~18.2.0",
|
|
68
69
|
"react-dom": "~18.2.0",
|
|
69
70
|
"vite": "5.4.7",
|
|
70
|
-
"@dxos/react-ui": "0.8.
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
71
|
+
"@dxos/react-ui": "0.8.4-main.28f8d3d",
|
|
72
|
+
"@dxos/react-ui-theme": "0.8.4-main.28f8d3d",
|
|
73
|
+
"@dxos/storybook-utils": "0.8.4-main.28f8d3d"
|
|
73
74
|
},
|
|
74
75
|
"peerDependencies": {
|
|
75
|
-
"@phosphor-icons/react": "^2.1.5",
|
|
76
76
|
"effect": "^3.13.3",
|
|
77
77
|
"react": "~18.2.0",
|
|
78
78
|
"react-dom": "~18.2.0",
|
|
79
|
-
"@dxos/react-ui": "0.8.
|
|
80
|
-
"@dxos/react-ui-theme": "0.8.
|
|
79
|
+
"@dxos/react-ui": "0.8.4-main.28f8d3d",
|
|
80
|
+
"@dxos/react-ui-theme": "0.8.4-main.28f8d3d"
|
|
81
81
|
},
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
package/src/StackPlugin.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Capabilities, contributes, defineModule, definePlugin
|
|
5
|
+
import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
|
|
6
6
|
import { type Obj } from '@dxos/echo';
|
|
7
7
|
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
8
8
|
|
|
9
9
|
import { ReactSurface } from './capabilities';
|
|
10
|
-
import {
|
|
11
|
-
import translations from './translations';
|
|
10
|
+
import { SECTION_IDENTIFIER, meta } from './meta';
|
|
11
|
+
import { translations } from './translations';
|
|
12
12
|
import { StackViewType } from './types';
|
|
13
13
|
|
|
14
14
|
export const StackPlugin = () =>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Plus } from '@phosphor-icons/react';
|
|
6
5
|
import { Option } from 'effect';
|
|
7
6
|
import React, { useCallback, useState } from 'react';
|
|
8
7
|
|
|
@@ -17,14 +16,12 @@ import {
|
|
|
17
16
|
import { fullyQualifiedId, isLiveObject } from '@dxos/client/echo';
|
|
18
17
|
import { Obj } from '@dxos/echo';
|
|
19
18
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
20
|
-
import { Button, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
19
|
+
import { Button, Icon, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
21
20
|
import { AttentionProvider } from '@dxos/react-ui-attention';
|
|
22
21
|
import { Stack } from '@dxos/react-ui-stack';
|
|
23
22
|
import { type DataType } from '@dxos/schema';
|
|
24
23
|
import { isNonNullable } from '@dxos/util';
|
|
25
24
|
|
|
26
|
-
import { StackContext } from './StackContext';
|
|
27
|
-
import { StackSection } from './StackSection';
|
|
28
25
|
import { STACK_PLUGIN } from '../meta';
|
|
29
26
|
import {
|
|
30
27
|
type AddSectionPosition,
|
|
@@ -34,6 +31,9 @@ import {
|
|
|
34
31
|
type StackSectionView,
|
|
35
32
|
} from '../types';
|
|
36
33
|
|
|
34
|
+
import { StackContext } from './StackContext';
|
|
35
|
+
import { StackSection } from './StackSection';
|
|
36
|
+
|
|
37
37
|
type StackMainProps = {
|
|
38
38
|
id: string;
|
|
39
39
|
collection: DataType.Collection;
|
|
@@ -148,7 +148,7 @@ const StackMain = ({ id, collection }: StackMainProps) => {
|
|
|
148
148
|
|
|
149
149
|
<div role='none' className='flex mlb-2 pli-2 justify-center'>
|
|
150
150
|
<Button data-testid='stack.createSection' classNames='gap-2' onClick={handleAddSection}>
|
|
151
|
-
<
|
|
151
|
+
<Icon icon='ph--plus' />
|
|
152
152
|
<span className='sr-only'>{t('add section label')}</span>
|
|
153
153
|
</Button>
|
|
154
154
|
</div>
|
|
@@ -6,16 +6,17 @@ import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
|
6
6
|
import React, { useMemo, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Surface } from '@dxos/app-framework';
|
|
9
|
-
import { DropdownMenu, Icon,
|
|
9
|
+
import { DropdownMenu, Icon, IconButton, useTranslation } from '@dxos/react-ui';
|
|
10
10
|
import { useAttentionAttributes } from '@dxos/react-ui-attention';
|
|
11
11
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
12
|
-
import {
|
|
12
|
+
import { getSize, mx, textBlockWidth } from '@dxos/react-ui-theme';
|
|
13
13
|
|
|
14
|
-
import { CaretDownUp } from './CaretDownUp';
|
|
15
|
-
import { useStack } from './StackContext';
|
|
16
14
|
import { STACK_PLUGIN } from '../meta';
|
|
17
15
|
import { type StackSectionItem } from '../types';
|
|
18
16
|
|
|
17
|
+
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
21
|
|
|
21
22
|
export type StackSectionProps = StackSectionItem;
|
package/src/translations.ts
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type Resource } from '@dxos/react-ui';
|
|
5
6
|
import { translations as stackTranslations } from '@dxos/react-ui-stack';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
+
import { meta } from './meta';
|
|
8
9
|
|
|
9
|
-
export
|
|
10
|
+
export const translations = [
|
|
10
11
|
{
|
|
11
12
|
'en-US': {
|
|
12
|
-
[
|
|
13
|
+
[meta.id]: {
|
|
13
14
|
'plugin name': 'Stacks',
|
|
14
15
|
'settings separation label': 'Separate sections',
|
|
15
16
|
'add section beforeAll dialog title': 'Add a section to the start',
|
|
@@ -33,4 +34,4 @@ export default [
|
|
|
33
34
|
},
|
|
34
35
|
},
|
|
35
36
|
...stackTranslations,
|
|
36
|
-
];
|
|
37
|
+
] as const satisfies Resource[];
|
package/src/types/index.ts
CHANGED
package/src/types/types.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type IconProps } from '@phosphor-icons/react';
|
|
6
5
|
import { type FC } from 'react';
|
|
7
6
|
|
|
8
7
|
import { type Obj } from '@dxos/echo';
|
|
@@ -29,7 +28,7 @@ type StackSectionAction = {
|
|
|
29
28
|
testId: string;
|
|
30
29
|
type: string | [string, { ns: string }];
|
|
31
30
|
label: string | [string, { ns: string }];
|
|
32
|
-
icon: FC<
|
|
31
|
+
icon: FC<{ className?: string; size?: number }>;
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
export type StackSectionMetadata = {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/StackMain.tsx", "../../../src/components/StackContext.tsx", "../../../src/components/StackSection.tsx", "../../../src/components/CaretDownUp.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plus } from '@phosphor-icons/react';\nimport { Option } from 'effect';\nimport React, { useCallback, useState } from 'react';\n\nimport {\n Capabilities,\n LayoutAction,\n createIntent,\n useAppGraph,\n useCapabilities,\n useIntentDispatcher,\n} from '@dxos/app-framework';\nimport { fullyQualifiedId, isLiveObject } from '@dxos/client/echo';\nimport { Obj } from '@dxos/echo';\nimport { SpaceAction } from '@dxos/plugin-space/types';\nimport { Button, toLocalizedString, useTranslation } from '@dxos/react-ui';\nimport { AttentionProvider } from '@dxos/react-ui-attention';\nimport { Stack } from '@dxos/react-ui-stack';\nimport { type DataType } from '@dxos/schema';\nimport { isNonNullable } from '@dxos/util';\n\nimport { StackContext } from './StackContext';\nimport { StackSection } from './StackSection';\nimport { STACK_PLUGIN } from '../meta';\nimport {\n type AddSectionPosition,\n type CollapsedSections,\n type StackSectionItem,\n type StackSectionMetadata,\n type StackSectionView,\n} from '../types';\n\ntype StackMainProps = {\n id: string;\n collection: DataType.Collection;\n};\n\nconst StackMain = ({ id, collection }: StackMainProps) => {\n const { dispatchPromise: dispatch } = useIntentDispatcher();\n const { graph } = useAppGraph();\n const { t } = useTranslation(STACK_PLUGIN);\n const allMetadata = useCapabilities(Capabilities.Metadata);\n const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});\n\n // TODO(wittjosiah): Re-implement stack views with relations.\n // const defaultStack = useMemo(() => Obj.make(StackViewType, { sections: {} }), [collection]);\n // const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;\n // useEffect(() => {\n // if (!collection.views[StackViewType.typename]) {\n // collection.views[StackViewType.typename] = Ref.make(stack);\n // }\n // }, [collection, stack]);\n\n const items =\n collection.objects\n // TODO(wittjosiah): Should the database handle this differently?\n // TODO(wittjosiah): Render placeholders for missing objects so they can be removed from the stack?\n .map((object) => object.target)\n .filter(isNonNullable)\n .map((object) => {\n const metadata = allMetadata.find((m) => m.id === (Obj.getTypename(object) ?? 'never'))\n ?.metadata as StackSectionMetadata;\n const view = {\n // ...stack.sections[object.id],\n collapsed: collapsedSections[fullyQualifiedId(object)],\n title:\n (object as any)?.title ??\n // TODO(wittjosiah): `getNode` is not reactive.\n toLocalizedString(graph.getNode(fullyQualifiedId(object)).pipe(Option.getOrNull)?.properties.label, t),\n } as StackSectionView;\n return { id: fullyQualifiedId(object), object, metadata, view } satisfies StackSectionItem;\n }) ?? [];\n\n const handleDelete = useCallback(\n async (id: string) => {\n const index = collection.objects\n .map((object) => object.target)\n .filter(isNonNullable)\n .findIndex((section) => fullyQualifiedId(section) === id);\n const object = collection.objects[index].target;\n if (isLiveObject(object)) {\n await dispatch(createIntent(SpaceAction.RemoveObjects, { objects: [object], target: collection }));\n\n // TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.\n // delete stack.sections[Path.last(path)];\n }\n },\n [collection, dispatch],\n );\n\n const handleAdd = useCallback(\n async (id: string, position: AddSectionPosition) => {\n await dispatch?.(\n // TODO(wittjosiah): Use object creation dialog.\n createIntent(LayoutAction.UpdateDialog, {\n part: 'dialog',\n subject: `${STACK_PLUGIN}/AddSectionDialog`,\n options: {\n blockAlign: 'start',\n props: {\n path: id,\n position,\n collection,\n },\n },\n }),\n );\n },\n [collection, dispatch],\n );\n\n const handleNavigate = useCallback(\n async (id: string) => {\n await dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [id] }));\n },\n [dispatch],\n );\n\n const handleCollapse = useCallback(\n (id: string, collapsed: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: collapsed })),\n [],\n );\n\n const handleAddSection = useCallback(\n () => dispatch?.(createIntent(SpaceAction.OpenCreateObject, { target: collection, navigable: false })),\n [collection, dispatch],\n );\n\n return (\n <AttentionProvider id={id}>\n <StackContext.Provider\n value={{\n onCollapse: handleCollapse,\n onNavigate: handleNavigate,\n onDelete: handleDelete,\n onAdd: handleAdd,\n }}\n >\n <Stack orientation='vertical' size='intrinsic' id={id} data-testid='main.stack'>\n {items.map((item) => (\n <StackSection key={item.id} {...item} />\n ))}\n </Stack>\n\n <div role='none' className='flex mlb-2 pli-2 justify-center'>\n <Button data-testid='stack.createSection' classNames='gap-2' onClick={handleAddSection}>\n <Plus />\n <span className='sr-only'>{t('add section label')}</span>\n </Button>\n </div>\n </StackContext.Provider>\n </AttentionProvider>\n );\n};\n\nexport default StackMain;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { type AddSectionPosition } from '../types';\n\nexport type StackContextValue = {\n onCollapse: (id: string, collapsed: boolean) => void;\n onNavigate: (id: string) => Promise<void>;\n onDelete: (id: string) => Promise<void>;\n onAdd: (id: string, position: AddSectionPosition) => void;\n};\n\nexport const StackContext = createContext<StackContextValue>({\n onCollapse: () => {},\n onNavigate: async () => {},\n onDelete: async () => {},\n onAdd: () => {},\n});\n\nexport const useStack = () => useContext(StackContext);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as CollapsiblePrimitive from '@radix-ui/react-collapsible';\nimport React, { useMemo, useState } from 'react';\n\nimport { Surface } from '@dxos/app-framework';\nimport { DropdownMenu, Icon, useTranslation, IconButton } from '@dxos/react-ui';\nimport { useAttentionAttributes } from '@dxos/react-ui-attention';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { mx, getSize, textBlockWidth } from '@dxos/react-ui-theme';\n\nimport { CaretDownUp } from './CaretDownUp';\nimport { useStack } from './StackContext';\nimport { STACK_PLUGIN } from '../meta';\nimport { type StackSectionItem } from '../types';\n\nconst sectionActionDimensions = 'p-1 mlb-1 shrink-0 min-bs-0 is-[--rail-action] bs-min';\n\nexport type StackSectionProps = StackSectionItem;\n\nexport const StackSection = ({\n id,\n view,\n object,\n metadata: { icon = 'ph--placeholder--regular' },\n}: StackSectionProps) => {\n const { t } = useTranslation(STACK_PLUGIN);\n const { onNavigate, onAdd, onCollapse, onDelete } = useStack();\n const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);\n const attentionAttrs = useAttentionAttributes(id);\n const stackItem = useMemo(() => ({ id }), [id]);\n\n return (\n <CollapsiblePrimitive.Root asChild open={!view.collapsed} onOpenChange={(nextOpen) => onCollapse?.(id, !nextOpen)}>\n <StackItem.Root item={stackItem} role='section' {...attentionAttrs}>\n <StackItem.Heading classNames='attention-surface'>\n <span className='sr-only'>{view.title}</span>\n <StackItem.HeadingStickyContent>\n <DropdownMenu.Root\n {...{\n open: optionsMenuOpen,\n onOpenChange: setOptionsMenuOpen,\n }}\n >\n <DropdownMenu.Trigger asChild>\n <StackItem.SigilButton>\n <Icon icon={icon} size={5} classNames='transition-opacity' />\n </StackItem.SigilButton>\n </DropdownMenu.Trigger>\n <DropdownMenu.Portal>\n <DropdownMenu.Content>\n <DropdownMenu.Viewport>\n {view.collapsed ? (\n <DropdownMenu.Item onClick={() => onNavigate(id)} data-testid='section.navigate-to'>\n <Icon icon='ph--arrow-right--regular' size={5} />\n <span className='mis-2 grow'>{t('navigate to section label')}</span>\n </DropdownMenu.Item>\n ) : (\n <CollapsiblePrimitive.Trigger asChild>\n <DropdownMenu.Item>\n <CaretDownUp className={getSize(5)} />\n <span className='mis-2 grow'>{t('collapse label')}</span>\n </DropdownMenu.Item>\n </CollapsiblePrimitive.Trigger>\n )}\n <DropdownMenu.Item onClick={() => onAdd(id, 'before')} data-testid='section.add-before'>\n <Icon icon='ph--arrow-line-up--regular' size={5} />\n <span className='mis-2 grow'>{t('add section before label')}</span>\n </DropdownMenu.Item>\n <DropdownMenu.Item onClick={() => onAdd(id, 'after')} data-testid='section.add-after'>\n <Icon icon='ph--arrow-line-down--regular' size={5} />\n <span className='mis-2 grow'>{t('add section after label')}</span>\n </DropdownMenu.Item>\n <DropdownMenu.Item onClick={() => onDelete(id)} data-testid='section.remove'>\n <Icon icon='ph--trash--regular' size={5} />\n <span className='mis-2 grow'>{t('remove section label')}</span>\n </DropdownMenu.Item>\n </DropdownMenu.Viewport>\n <DropdownMenu.Arrow />\n </DropdownMenu.Content>\n </DropdownMenu.Portal>\n </DropdownMenu.Root>\n {view.collapsed ? (\n <CollapsiblePrimitive.Trigger asChild>\n <IconButton\n iconOnly\n variant='ghost'\n label={t('expand label')}\n icon='ph--caret-up-down--regular'\n classNames={sectionActionDimensions}\n />\n </CollapsiblePrimitive.Trigger>\n ) : (\n <IconButton\n iconOnly\n variant='ghost'\n onClick={() => onNavigate(id)}\n label={t('navigate to section label')}\n icon='ph--arrow-right--regular'\n data-testid='section.navigate-to'\n classNames={sectionActionDimensions}\n />\n )}\n </StackItem.HeadingStickyContent>\n </StackItem.Heading>\n <CollapsiblePrimitive.Content>\n <Surface role='section' data={{ subject: object }} limit={1} placeholder={<></>} />\n </CollapsiblePrimitive.Content>\n {view.collapsed && (\n <StackItem.Content classNames='attention-surface'>\n <h2 className={mx('flex items-center p-4 font-medium', textBlockWidth)}>{view.title}</h2>\n </StackItem.Content>\n )}\n </StackItem.Root>\n </CollapsiblePrimitive.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { type ComponentPropsWithoutRef } from 'react';\n\nexport const CaretDownUp = ({ children, ...props }: ComponentPropsWithoutRef<'svg'>) => {\n return (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' {...props}>\n <rect width='256' height='256' fill='none' />\n <polyline\n points='80 224 128 176 176 224'\n fill='none'\n stroke='currentColor'\n strokeLinecap='round'\n strokeLinejoin='round'\n strokeWidth='16'\n />\n <polyline\n points='80 32 128 80 176 32'\n fill='none'\n stroke='currentColor'\n strokeLinecap='round'\n strokeLinejoin='round'\n strokeWidth='16'\n />\n {children}\n </svg>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,SAASA,YAAY;AACrB,SAASC,cAAc;AACvB,OAAOC,UAASC,aAAaC,YAAAA,iBAAgB;AAE7C,SACEC,cACAC,cACAC,cACAC,aACAC,iBACAC,2BACK;AACP,SAASC,kBAAkBC,oBAAoB;AAC/C,SAASC,WAAW;AACpB,SAASC,mBAAmB;AAC5B,SAASC,QAAQC,mBAAmBC,kBAAAA,uBAAsB;AAC1D,SAASC,yBAAyB;AAClC,SAASC,aAAa;AAEtB,SAASC,qBAAqB;;;ACnB9B,SAASC,eAAeC,kBAAkB;AAWnC,IAAMC,eAAeC,8BAAiC;EAC3DC,YAAY,MAAA;EAAO;EACnBC,YAAY,YAAA;EAAa;EACzBC,UAAU,YAAA;EAAa;EACvBC,OAAO,MAAA;EAAO;AAChB,CAAA;AAEO,IAAMC,WAAW,MAAMC,WAAWP,YAAAA;;;;AClBzC,YAAYQ,0BAA0B;AACtC,OAAOC,UAASC,SAASC,gBAAgB;AAEzC,SAASC,eAAe;AACxB,SAASC,cAAcC,MAAMC,gBAAgBC,kBAAkB;AAC/D,SAASC,8BAA8B;AACvC,SAASC,iBAAiB;AAC1B,SAASC,IAAIC,SAASC,sBAAsB;;;;ACP5C,OAAOC,WAA8C;AAE9C,IAAMC,cAAc,CAAC,EAAEC,UAAU,GAAGC,MAAAA,MAAwC;;;AACjF,WACE,sBAAA,c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AA,CAAA,CAAA,CAAA;;;;AAMzC;AAEA,IAAA,oBAAeR;",
|
|
6
|
-
"names": ["Plus", "Option", "React", "useCallback", "useState", "Capabilities", "LayoutAction", "createIntent", "useAppGraph", "useCapabilities", "useIntentDispatcher", "fullyQualifiedId", "isLiveObject", "Obj", "SpaceAction", "Button", "toLocalizedString", "useTranslation", "AttentionProvider", "Stack", "isNonNullable", "createContext", "useContext", "StackContext", "createContext", "onCollapse", "onNavigate", "onDelete", "onAdd", "useStack", "useContext", "CollapsiblePrimitive", "React", "useMemo", "useState", "Surface", "DropdownMenu", "Icon", "useTranslation", "IconButton", "useAttentionAttributes", "StackItem", "mx", "getSize", "textBlockWidth", "React", "CaretDownUp", "children", "props", "svg", "xmlns", "viewBox", "rect", "width", "height", "fill", "polyline", "points", "stroke", "strokeLinecap", "strokeLinejoin", "strokeWidth", "sectionActionDimensions", "StackSection", "id", "view", "object", "metadata", "icon", "t", "useTranslation", "STACK_PLUGIN", "onNavigate", "onAdd", "onCollapse", "onDelete", "useStack", "optionsMenuOpen", "setOptionsMenuOpen", "useState", "attentionAttrs", "useAttentionAttributes", "stackItem", "useMemo", "React", "Root", "asChild", "open", "collapsed", "onOpenChange", "nextOpen", "StackItem", "item", "role", "Heading", "classNames", "span", "className", "title", "HeadingStickyContent", "DropdownMenu", "Trigger", "SigilButton", "Icon", "size", "Portal", "Content", "Viewport", "Item", "onClick", "data-testid", "CaretDownUp", "getSize", "Arrow", "IconButton", "iconOnly", "variant", "label", "Surface", "data", "subject", "limit", "placeholder", "h2", "mx", "textBlockWidth", "StackMain", "id", "collection", "dispatchPromise", "dispatch", "useIntentDispatcher", "graph", "useAppGraph", "t", "useTranslation", "STACK_PLUGIN", "allMetadata", "useCapabilities", "Capabilities", "Metadata", "collapsedSections", "setCollapsedSections", "useState", "items", "objects", "map", "object", "target", "filter", "isNonNullable", "metadata", "find", "m", "Obj", "getTypename", "view", "collapsed", "fullyQualifiedId", "title", "toLocalizedString", "getNode", "pipe", "Option", "getOrNull", "properties", "label", "handleDelete", "useCallback", "index", "findIndex", "section", "isLiveObject", "createIntent", "SpaceAction", "RemoveObjects", "handleAdd", "position", "LayoutAction", "UpdateDialog", "part", "subject", "options", "blockAlign", "props", "path", "handleNavigate", "Open", "handleCollapse", "prev", "handleAddSection", "OpenCreateObject", "navigable", "React", "AttentionProvider", "StackContext", "Provider", "value", "onCollapse", "onNavigate", "onDelete", "onAdd", "Stack", "orientation", "size", "data-testid", "item", "StackSection", "key", "div", "role", "className", "Button", "classNames", "onClick", "Plus", "span"]
|
|
7
|
-
}
|
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var StackMain_33HO2PMZ_exports = {};
|
|
30
|
-
__export(StackMain_33HO2PMZ_exports, {
|
|
31
|
-
default: () => StackMain_default
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(StackMain_33HO2PMZ_exports);
|
|
34
|
-
var import_chunk_F7ZNJ53O = require("./chunk-F7ZNJ53O.cjs");
|
|
35
|
-
var import_tracking = require("@preact-signals/safe-react/tracking");
|
|
36
|
-
var import_react = require("@phosphor-icons/react");
|
|
37
|
-
var import_effect = require("effect");
|
|
38
|
-
var import_react2 = __toESM(require("react"));
|
|
39
|
-
var import_app_framework = require("@dxos/app-framework");
|
|
40
|
-
var import_echo = require("@dxos/client/echo");
|
|
41
|
-
var import_echo2 = require("@dxos/echo");
|
|
42
|
-
var import_types = require("@dxos/plugin-space/types");
|
|
43
|
-
var import_react_ui = require("@dxos/react-ui");
|
|
44
|
-
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
45
|
-
var import_react_ui_stack = require("@dxos/react-ui-stack");
|
|
46
|
-
var import_util = require("@dxos/util");
|
|
47
|
-
var import_react3 = require("react");
|
|
48
|
-
var import_tracking2 = require("@preact-signals/safe-react/tracking");
|
|
49
|
-
var CollapsiblePrimitive = __toESM(require("@radix-ui/react-collapsible"));
|
|
50
|
-
var import_react4 = __toESM(require("react"));
|
|
51
|
-
var import_app_framework2 = require("@dxos/app-framework");
|
|
52
|
-
var import_react_ui2 = require("@dxos/react-ui");
|
|
53
|
-
var import_react_ui_attention2 = require("@dxos/react-ui-attention");
|
|
54
|
-
var import_react_ui_stack2 = require("@dxos/react-ui-stack");
|
|
55
|
-
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
56
|
-
var import_tracking3 = require("@preact-signals/safe-react/tracking");
|
|
57
|
-
var import_react5 = __toESM(require("react"));
|
|
58
|
-
var StackContext = /* @__PURE__ */ (0, import_react3.createContext)({
|
|
59
|
-
onCollapse: () => {
|
|
60
|
-
},
|
|
61
|
-
onNavigate: async () => {
|
|
62
|
-
},
|
|
63
|
-
onDelete: async () => {
|
|
64
|
-
},
|
|
65
|
-
onAdd: () => {
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
var useStack = () => (0, import_react3.useContext)(StackContext);
|
|
69
|
-
var CaretDownUp = ({ children, ...props }) => {
|
|
70
|
-
var _effect = (0, import_tracking3.useSignals)();
|
|
71
|
-
try {
|
|
72
|
-
return /* @__PURE__ */ import_react5.default.createElement("svg", {
|
|
73
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
74
|
-
viewBox: "0 0 256 256",
|
|
75
|
-
...props
|
|
76
|
-
}, /* @__PURE__ */ import_react5.default.createElement("rect", {
|
|
77
|
-
width: "256",
|
|
78
|
-
height: "256",
|
|
79
|
-
fill: "none"
|
|
80
|
-
}), /* @__PURE__ */ import_react5.default.createElement("polyline", {
|
|
81
|
-
points: "80 224 128 176 176 224",
|
|
82
|
-
fill: "none",
|
|
83
|
-
stroke: "currentColor",
|
|
84
|
-
strokeLinecap: "round",
|
|
85
|
-
strokeLinejoin: "round",
|
|
86
|
-
strokeWidth: "16"
|
|
87
|
-
}), /* @__PURE__ */ import_react5.default.createElement("polyline", {
|
|
88
|
-
points: "80 32 128 80 176 32",
|
|
89
|
-
fill: "none",
|
|
90
|
-
stroke: "currentColor",
|
|
91
|
-
strokeLinecap: "round",
|
|
92
|
-
strokeLinejoin: "round",
|
|
93
|
-
strokeWidth: "16"
|
|
94
|
-
}), children);
|
|
95
|
-
} finally {
|
|
96
|
-
_effect.f();
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
var sectionActionDimensions = "p-1 mlb-1 shrink-0 min-bs-0 is-[--rail-action] bs-min";
|
|
100
|
-
var StackSection = ({ id, view, object, metadata: { icon = "ph--placeholder--regular" } }) => {
|
|
101
|
-
var _effect = (0, import_tracking2.useSignals)();
|
|
102
|
-
try {
|
|
103
|
-
const { t } = (0, import_react_ui2.useTranslation)(import_chunk_F7ZNJ53O.STACK_PLUGIN);
|
|
104
|
-
const { onNavigate, onAdd, onCollapse, onDelete } = useStack();
|
|
105
|
-
const [optionsMenuOpen, setOptionsMenuOpen] = (0, import_react4.useState)(false);
|
|
106
|
-
const attentionAttrs = (0, import_react_ui_attention2.useAttentionAttributes)(id);
|
|
107
|
-
const stackItem = (0, import_react4.useMemo)(() => ({
|
|
108
|
-
id
|
|
109
|
-
}), [
|
|
110
|
-
id
|
|
111
|
-
]);
|
|
112
|
-
return /* @__PURE__ */ import_react4.default.createElement(CollapsiblePrimitive.Root, {
|
|
113
|
-
asChild: true,
|
|
114
|
-
open: !view.collapsed,
|
|
115
|
-
onOpenChange: (nextOpen) => onCollapse?.(id, !nextOpen)
|
|
116
|
-
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_stack2.StackItem.Root, {
|
|
117
|
-
item: stackItem,
|
|
118
|
-
role: "section",
|
|
119
|
-
...attentionAttrs
|
|
120
|
-
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_stack2.StackItem.Heading, {
|
|
121
|
-
classNames: "attention-surface"
|
|
122
|
-
}, /* @__PURE__ */ import_react4.default.createElement("span", {
|
|
123
|
-
className: "sr-only"
|
|
124
|
-
}, view.title), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_stack2.StackItem.HeadingStickyContent, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.DropdownMenu.Root, {
|
|
125
|
-
open: optionsMenuOpen,
|
|
126
|
-
onOpenChange: setOptionsMenuOpen
|
|
127
|
-
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.DropdownMenu.Trigger, {
|
|
128
|
-
asChild: true
|
|
129
|
-
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_stack2.StackItem.SigilButton, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Icon, {
|
|
130
|
-
icon,
|
|
131
|
-
size: 5,
|
|
132
|
-
classNames: "transition-opacity"
|
|
133
|
-
}))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.DropdownMenu.Portal, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.DropdownMenu.Content, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.DropdownMenu.Viewport, null, view.collapsed ? /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.DropdownMenu.Item, {
|
|
134
|
-
onClick: () => onNavigate(id),
|
|
135
|
-
"data-testid": "section.navigate-to"
|
|
136
|
-
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Icon, {
|
|
137
|
-
icon: "ph--arrow-right--regular",
|
|
138
|
-
size: 5
|
|
139
|
-
}), /* @__PURE__ */ import_react4.default.createElement("span", {
|
|
140
|
-
className: "mis-2 grow"
|
|
141
|
-
}, t("navigate to section label"))) : /* @__PURE__ */ import_react4.default.createElement(CollapsiblePrimitive.Trigger, {
|
|
142
|
-
asChild: true
|
|
143
|
-
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.DropdownMenu.Item, null, /* @__PURE__ */ import_react4.default.createElement(CaretDownUp, {
|
|
144
|
-
className: (0, import_react_ui_theme.getSize)(5)
|
|
145
|
-
}), /* @__PURE__ */ import_react4.default.createElement("span", {
|
|
146
|
-
className: "mis-2 grow"
|
|
147
|
-
}, t("collapse label")))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.DropdownMenu.Item, {
|
|
148
|
-
onClick: () => onAdd(id, "before"),
|
|
149
|
-
"data-testid": "section.add-before"
|
|
150
|
-
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Icon, {
|
|
151
|
-
icon: "ph--arrow-line-up--regular",
|
|
152
|
-
size: 5
|
|
153
|
-
}), /* @__PURE__ */ import_react4.default.createElement("span", {
|
|
154
|
-
className: "mis-2 grow"
|
|
155
|
-
}, t("add section before label"))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.DropdownMenu.Item, {
|
|
156
|
-
onClick: () => onAdd(id, "after"),
|
|
157
|
-
"data-testid": "section.add-after"
|
|
158
|
-
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Icon, {
|
|
159
|
-
icon: "ph--arrow-line-down--regular",
|
|
160
|
-
size: 5
|
|
161
|
-
}), /* @__PURE__ */ import_react4.default.createElement("span", {
|
|
162
|
-
className: "mis-2 grow"
|
|
163
|
-
}, t("add section after label"))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.DropdownMenu.Item, {
|
|
164
|
-
onClick: () => onDelete(id),
|
|
165
|
-
"data-testid": "section.remove"
|
|
166
|
-
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Icon, {
|
|
167
|
-
icon: "ph--trash--regular",
|
|
168
|
-
size: 5
|
|
169
|
-
}), /* @__PURE__ */ import_react4.default.createElement("span", {
|
|
170
|
-
className: "mis-2 grow"
|
|
171
|
-
}, t("remove section label")))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.DropdownMenu.Arrow, null)))), view.collapsed ? /* @__PURE__ */ import_react4.default.createElement(CollapsiblePrimitive.Trigger, {
|
|
172
|
-
asChild: true
|
|
173
|
-
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.IconButton, {
|
|
174
|
-
iconOnly: true,
|
|
175
|
-
variant: "ghost",
|
|
176
|
-
label: t("expand label"),
|
|
177
|
-
icon: "ph--caret-up-down--regular",
|
|
178
|
-
classNames: sectionActionDimensions
|
|
179
|
-
})) : /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.IconButton, {
|
|
180
|
-
iconOnly: true,
|
|
181
|
-
variant: "ghost",
|
|
182
|
-
onClick: () => onNavigate(id),
|
|
183
|
-
label: t("navigate to section label"),
|
|
184
|
-
icon: "ph--arrow-right--regular",
|
|
185
|
-
"data-testid": "section.navigate-to",
|
|
186
|
-
classNames: sectionActionDimensions
|
|
187
|
-
}))), /* @__PURE__ */ import_react4.default.createElement(CollapsiblePrimitive.Content, null, /* @__PURE__ */ import_react4.default.createElement(import_app_framework2.Surface, {
|
|
188
|
-
role: "section",
|
|
189
|
-
data: {
|
|
190
|
-
subject: object
|
|
191
|
-
},
|
|
192
|
-
limit: 1,
|
|
193
|
-
placeholder: /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null)
|
|
194
|
-
})), view.collapsed && /* @__PURE__ */ import_react4.default.createElement(import_react_ui_stack2.StackItem.Content, {
|
|
195
|
-
classNames: "attention-surface"
|
|
196
|
-
}, /* @__PURE__ */ import_react4.default.createElement("h2", {
|
|
197
|
-
className: (0, import_react_ui_theme.mx)("flex items-center p-4 font-medium", import_react_ui_theme.textBlockWidth)
|
|
198
|
-
}, view.title))));
|
|
199
|
-
} finally {
|
|
200
|
-
_effect.f();
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
var StackMain = ({ id, collection }) => {
|
|
204
|
-
var _effect = (0, import_tracking.useSignals)();
|
|
205
|
-
try {
|
|
206
|
-
const { dispatchPromise: dispatch } = (0, import_app_framework.useIntentDispatcher)();
|
|
207
|
-
const { graph } = (0, import_app_framework.useAppGraph)();
|
|
208
|
-
const { t } = (0, import_react_ui.useTranslation)(import_chunk_F7ZNJ53O.STACK_PLUGIN);
|
|
209
|
-
const allMetadata = (0, import_app_framework.useCapabilities)(import_app_framework.Capabilities.Metadata);
|
|
210
|
-
const [collapsedSections, setCollapsedSections] = (0, import_react2.useState)({});
|
|
211
|
-
const items = collection.objects.map((object) => object.target).filter(import_util.isNonNullable).map((object) => {
|
|
212
|
-
const metadata = allMetadata.find((m) => m.id === (import_echo2.Obj.getTypename(object) ?? "never"))?.metadata;
|
|
213
|
-
const view = {
|
|
214
|
-
// ...stack.sections[object.id],
|
|
215
|
-
collapsed: collapsedSections[(0, import_echo.fullyQualifiedId)(object)],
|
|
216
|
-
title: object?.title ?? // TODO(wittjosiah): `getNode` is not reactive.
|
|
217
|
-
(0, import_react_ui.toLocalizedString)(graph.getNode((0, import_echo.fullyQualifiedId)(object)).pipe(import_effect.Option.getOrNull)?.properties.label, t)
|
|
218
|
-
};
|
|
219
|
-
return {
|
|
220
|
-
id: (0, import_echo.fullyQualifiedId)(object),
|
|
221
|
-
object,
|
|
222
|
-
metadata,
|
|
223
|
-
view
|
|
224
|
-
};
|
|
225
|
-
}) ?? [];
|
|
226
|
-
const handleDelete = (0, import_react2.useCallback)(async (id2) => {
|
|
227
|
-
const index = collection.objects.map((object2) => object2.target).filter(import_util.isNonNullable).findIndex((section) => (0, import_echo.fullyQualifiedId)(section) === id2);
|
|
228
|
-
const object = collection.objects[index].target;
|
|
229
|
-
if ((0, import_echo.isLiveObject)(object)) {
|
|
230
|
-
await dispatch((0, import_app_framework.createIntent)(import_types.SpaceAction.RemoveObjects, {
|
|
231
|
-
objects: [
|
|
232
|
-
object
|
|
233
|
-
],
|
|
234
|
-
target: collection
|
|
235
|
-
}));
|
|
236
|
-
}
|
|
237
|
-
}, [
|
|
238
|
-
collection,
|
|
239
|
-
dispatch
|
|
240
|
-
]);
|
|
241
|
-
const handleAdd = (0, import_react2.useCallback)(async (id2, position) => {
|
|
242
|
-
await dispatch?.(
|
|
243
|
-
// TODO(wittjosiah): Use object creation dialog.
|
|
244
|
-
(0, import_app_framework.createIntent)(import_app_framework.LayoutAction.UpdateDialog, {
|
|
245
|
-
part: "dialog",
|
|
246
|
-
subject: `${import_chunk_F7ZNJ53O.STACK_PLUGIN}/AddSectionDialog`,
|
|
247
|
-
options: {
|
|
248
|
-
blockAlign: "start",
|
|
249
|
-
props: {
|
|
250
|
-
path: id2,
|
|
251
|
-
position,
|
|
252
|
-
collection
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
})
|
|
256
|
-
);
|
|
257
|
-
}, [
|
|
258
|
-
collection,
|
|
259
|
-
dispatch
|
|
260
|
-
]);
|
|
261
|
-
const handleNavigate = (0, import_react2.useCallback)(async (id2) => {
|
|
262
|
-
await dispatch((0, import_app_framework.createIntent)(import_app_framework.LayoutAction.Open, {
|
|
263
|
-
part: "main",
|
|
264
|
-
subject: [
|
|
265
|
-
id2
|
|
266
|
-
]
|
|
267
|
-
}));
|
|
268
|
-
}, [
|
|
269
|
-
dispatch
|
|
270
|
-
]);
|
|
271
|
-
const handleCollapse = (0, import_react2.useCallback)((id2, collapsed) => setCollapsedSections((prev) => ({
|
|
272
|
-
...prev,
|
|
273
|
-
[id2]: collapsed
|
|
274
|
-
})), []);
|
|
275
|
-
const handleAddSection = (0, import_react2.useCallback)(() => dispatch?.((0, import_app_framework.createIntent)(import_types.SpaceAction.OpenCreateObject, {
|
|
276
|
-
target: collection,
|
|
277
|
-
navigable: false
|
|
278
|
-
})), [
|
|
279
|
-
collection,
|
|
280
|
-
dispatch
|
|
281
|
-
]);
|
|
282
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_react_ui_attention.AttentionProvider, {
|
|
283
|
-
id
|
|
284
|
-
}, /* @__PURE__ */ import_react2.default.createElement(StackContext.Provider, {
|
|
285
|
-
value: {
|
|
286
|
-
onCollapse: handleCollapse,
|
|
287
|
-
onNavigate: handleNavigate,
|
|
288
|
-
onDelete: handleDelete,
|
|
289
|
-
onAdd: handleAdd
|
|
290
|
-
}
|
|
291
|
-
}, /* @__PURE__ */ import_react2.default.createElement(import_react_ui_stack.Stack, {
|
|
292
|
-
orientation: "vertical",
|
|
293
|
-
size: "intrinsic",
|
|
294
|
-
id,
|
|
295
|
-
"data-testid": "main.stack"
|
|
296
|
-
}, items.map((item) => /* @__PURE__ */ import_react2.default.createElement(StackSection, {
|
|
297
|
-
key: item.id,
|
|
298
|
-
...item
|
|
299
|
-
}))), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
300
|
-
role: "none",
|
|
301
|
-
className: "flex mlb-2 pli-2 justify-center"
|
|
302
|
-
}, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Button, {
|
|
303
|
-
"data-testid": "stack.createSection",
|
|
304
|
-
classNames: "gap-2",
|
|
305
|
-
onClick: handleAddSection
|
|
306
|
-
}, /* @__PURE__ */ import_react2.default.createElement(import_react.Plus, null), /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
307
|
-
className: "sr-only"
|
|
308
|
-
}, t("add section label"))))));
|
|
309
|
-
} finally {
|
|
310
|
-
_effect.f();
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
var StackMain_default = StackMain;
|
|
314
|
-
//# sourceMappingURL=StackMain-33HO2PMZ.cjs.map
|