@dxos/plugin-navtree 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8
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/LICENSE +102 -5
- package/PLUGIN.mdl +376 -0
- package/README.md +1 -1
- package/dist/lib/neutral/CommandsDialogContent-UBGIQ5FI.mjs +112 -0
- package/dist/lib/neutral/CommandsDialogContent-UBGIQ5FI.mjs.map +7 -0
- package/dist/lib/neutral/CommandsTrigger-BH5WLMHK.mjs +27 -0
- package/dist/lib/neutral/CommandsTrigger-BH5WLMHK.mjs.map +7 -0
- package/dist/lib/neutral/NavTreeContainer-6AR4BFDD.mjs +12 -0
- package/dist/lib/neutral/NavTreeContainer-6AR4BFDD.mjs.map +7 -0
- package/dist/lib/neutral/NavTreeDocumentTitle-H3E6ZLYE.mjs +22 -0
- package/dist/lib/neutral/NavTreeDocumentTitle-H3E6ZLYE.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.mjs +68 -0
- package/dist/lib/neutral/NavTreePlugin.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.node.mjs +18 -0
- package/dist/lib/neutral/NavTreePlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.workerd.mjs +16 -0
- package/dist/lib/neutral/NavTreePlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-Z347LKSF.mjs +42 -0
- package/dist/lib/neutral/app-graph-builder-Z347LKSF.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +17 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5OPDKH6B.mjs +273 -0
- package/dist/lib/neutral/chunk-5OPDKH6B.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-JOSNCOV4.mjs +79 -0
- package/dist/lib/neutral/chunk-JOSNCOV4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MDGKDQMZ.mjs +37 -0
- package/dist/lib/neutral/chunk-MDGKDQMZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T7QS2EFI.mjs +8 -0
- package/dist/lib/neutral/chunk-T7QS2EFI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZSWYB7JW.mjs +27 -0
- package/dist/lib/neutral/chunk-ZSWYB7JW.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +805 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +20 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/expose-26FV4W5D.mjs +38 -0
- package/dist/lib/neutral/expose-26FV4W5D.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +178 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +34 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{browser/keyboard-HMTMA33N.mjs → neutral/keyboard-EJ65BVTC.mjs} +25 -20
- package/dist/lib/neutral/keyboard-EJ65BVTC.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +12 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs +13 -0
- package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-Q5XMAG7Z.mjs +50 -0
- package/dist/lib/neutral/react-surface-Q5XMAG7Z.mjs.map +7 -0
- package/dist/lib/neutral/state-VVJEWUHM.mjs +126 -0
- package/dist/lib/neutral/state-VVJEWUHM.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +439 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +23 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/NavTreePlugin.d.ts +3 -1
- package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
- package/dist/types/src/NavTreePlugin.node.d.ts +4 -0
- package/dist/types/src/NavTreePlugin.node.d.ts.map +1 -0
- package/dist/types/src/NavTreePlugin.test.d.ts +2 -0
- package/dist/types/src/NavTreePlugin.test.d.ts.map +1 -0
- package/dist/types/src/NavTreePlugin.workerd.d.ts +4 -0
- package/dist/types/src/NavTreePlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +7 -105
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts +3 -2
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +4 -18
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.d.ts +11 -4
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +25 -5
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/{NavTreeContext.d.ts → NavTreeContext/NavTreeContext.d.ts} +1 -1
- package/dist/types/src/components/NavTreeContext/NavTreeContext.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeContext/index.d.ts +2 -0
- package/dist/types/src/components/NavTreeContext/index.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +13 -9
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +33 -4
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L0Menu.d.ts +10 -5
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +4 -7
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts +5 -4
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts.map +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts +8 -5
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +8 -17
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts +6 -0
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts +28 -0
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsDialogContent/index.d.ts +2 -0
- package/dist/types/src/containers/CommandsDialogContent/index.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsTrigger/CommandsTrigger.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsTrigger/index.d.ts +2 -0
- package/dist/types/src/containers/CommandsTrigger/index.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts +9 -0
- package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeContainer/index.d.ts +3 -0
- package/dist/types/src/containers/NavTreeContainer/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.d.ts +1 -1
- package/dist/types/src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts +2 -0
- package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +7 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/experimental/Tree.d.ts +3 -4
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.stories.d.ts +23 -6
- package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +5 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useActions.d.ts +11 -0
- package/dist/types/src/hooks/useActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useLoadDescendents.d.ts +6 -0
- package/dist/types/src/hooks/useLoadDescendents.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavTreeModel.d.ts +7 -0
- package/dist/types/src/hooks/useNavTreeModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavTreeState.d.ts +18 -0
- package/dist/types/src/hooks/useNavTreeState.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +4 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/expose.d.ts +5 -0
- package/dist/types/src/operations/expose.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing/app-graph-builder.d.ts +2 -3
- package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/testing/generator.d.ts +5 -6
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/testing/update-state.d.ts +2 -2
- package/dist/types/src/testing/update-state.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -11
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/NavTreeCapabilities.d.ts +13 -0
- package/dist/types/src/types/NavTreeCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/NavTreeEvents.d.ts +3 -0
- package/dist/types/src/types/NavTreeEvents.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/{types.d.ts → types/schema.d.ts} +14 -9
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +12 -8
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +124 -62
- package/src/NavTreePlugin.node.ts +17 -0
- package/src/NavTreePlugin.test.ts +27 -0
- package/src/NavTreePlugin.tsx +56 -87
- package/src/NavTreePlugin.workerd.ts +16 -0
- package/src/capabilities/app-graph-builder.ts +34 -44
- package/src/capabilities/index.ts +10 -8
- package/src/capabilities/keyboard.ts +58 -51
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +46 -38
- package/src/capabilities/state.ts +132 -84
- package/src/components/NavTree/NavTree.stories.tsx +112 -106
- package/src/components/NavTree/NavTree.tsx +69 -33
- package/src/components/{NavTreeContext.tsx → NavTreeContext/NavTreeContext.tsx} +1 -1
- package/src/components/NavTreeContext/index.ts +5 -0
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +25 -19
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +78 -54
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +40 -51
- package/src/components/Sidebar/L0Menu.tsx +182 -210
- package/src/components/Sidebar/L1Panel.tsx +185 -110
- package/src/components/Sidebar/L1Tabs.tsx +18 -34
- package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +9 -9
- package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +20 -12
- package/src/components/index.ts +1 -3
- package/src/components/types.ts +13 -19
- package/src/containers/CommandsDialogContent/CommandsDialogContent.stories.tsx +46 -0
- package/src/containers/CommandsDialogContent/CommandsDialogContent.tsx +127 -0
- package/src/containers/CommandsDialogContent/index.ts +5 -0
- package/src/containers/CommandsTrigger/CommandsTrigger.tsx +28 -0
- package/src/containers/CommandsTrigger/index.ts +5 -0
- package/src/containers/NavTreeContainer/NavTreeContainer.tsx +271 -0
- package/src/containers/NavTreeContainer/index.ts +6 -0
- package/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.tsx +5 -4
- package/src/containers/NavTreeDocumentTitle/index.ts +5 -0
- package/src/containers/index.ts +12 -0
- package/src/experimental/Tree.stories.tsx +105 -110
- package/src/experimental/Tree.tsx +7 -24
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useActions.ts +44 -0
- package/src/hooks/useLoadDescendents.ts +23 -0
- package/src/hooks/useNavTreeModel.ts +120 -0
- package/src/hooks/useNavTreeState.ts +35 -0
- package/src/index.ts +1 -3
- package/src/meta.ts +26 -8
- package/src/operations/expose.ts +42 -0
- package/src/operations/index.ts +7 -0
- package/src/plugin.ts +11 -0
- package/src/testing/app-graph-builder.ts +169 -238
- package/src/testing/generator.ts +36 -39
- package/src/testing/update-state.ts +6 -6
- package/src/translations.ts +8 -10
- package/src/types/NavTreeCapabilities.ts +21 -0
- package/src/types/NavTreeEvents.ts +12 -0
- package/src/types/index.ts +8 -0
- package/src/{types.ts → types/schema.ts} +13 -8
- package/src/util.ts +28 -17
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/app-graph-builder-6JDBQ25U.mjs +0 -45
- package/dist/lib/browser/app-graph-builder-6JDBQ25U.mjs.map +0 -7
- package/dist/lib/browser/chunk-ERDGQTH5.mjs +0 -16
- package/dist/lib/browser/chunk-ERDGQTH5.mjs.map +0 -7
- package/dist/lib/browser/chunk-SNGLGBFJ.mjs +0 -1469
- package/dist/lib/browser/chunk-SNGLGBFJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-WCARAZ7J.mjs +0 -15
- package/dist/lib/browser/chunk-WCARAZ7J.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -148
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-N35ZIHFD.mjs +0 -47
- package/dist/lib/browser/intent-resolver-N35ZIHFD.mjs.map +0 -7
- package/dist/lib/browser/keyboard-HMTMA33N.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-WKWXMM2N.mjs +0 -51
- package/dist/lib/browser/react-surface-WKWXMM2N.mjs.map +0 -7
- package/dist/lib/browser/state-P5DGL7KS.mjs +0 -117
- package/dist/lib/browser/state-P5DGL7KS.mjs.map +0 -7
- package/dist/types/src/capabilities/capabilities.d.ts +0 -21
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts +0 -5
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +0 -1
- package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +0 -1
- package/dist/types/src/components/CommandsDialog/index.d.ts +0 -3
- package/dist/types/src/components/CommandsDialog/index.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeContainer.d.ts +0 -9
- package/dist/types/src/components/NavTreeContainer.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeContext.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/hooks.d.ts +0 -3
- package/dist/types/src/hooks.d.ts.map +0 -1
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -20
- package/src/capabilities/intent-resolver.ts +0 -37
- package/src/components/CommandsDialog/CommandsDialog.tsx +0 -118
- package/src/components/CommandsDialog/CommandsTrigger.tsx +0 -35
- package/src/components/CommandsDialog/index.ts +0 -6
- package/src/components/NavTreeContainer.tsx +0 -337
- package/src/events.ts +0 -11
- package/src/hooks.ts +0 -21
- /package/dist/types/src/{components/CommandsDialog → containers/CommandsTrigger}/CommandsTrigger.d.ts +0 -0
|
@@ -2,64 +2,49 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
5
|
+
import { Atom, type Registry } from '@effect-atom/atom-react';
|
|
7
6
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
|
-
import
|
|
9
|
-
import React from 'react';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
IntentPlugin,
|
|
14
|
-
LayoutAction,
|
|
15
|
-
SettingsPlugin,
|
|
16
|
-
contributes,
|
|
17
|
-
createResolver,
|
|
18
|
-
defineCapability,
|
|
19
|
-
useCapability,
|
|
20
|
-
} from '@dxos/app-framework';
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
import React, { type KeyboardEvent, useCallback, useRef } from 'react';
|
|
9
|
+
import { expect, userEvent, within } from 'storybook/test';
|
|
10
|
+
|
|
11
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
21
12
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
|
|
28
|
-
import { ThemePlugin } from '@dxos/plugin-theme';
|
|
29
|
-
import { faker } from '@dxos/random';
|
|
13
|
+
import { useAtomCapability } from '@dxos/app-framework/ui';
|
|
14
|
+
import { AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';
|
|
15
|
+
import { Operation, OperationHandlerSet } from '@dxos/compute';
|
|
16
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
17
|
+
import { random } from '@dxos/random';
|
|
30
18
|
import { IconButton, Input, Main, Toolbar } from '@dxos/react-ui';
|
|
31
19
|
import { useAttention, useAttentionAttributes } from '@dxos/react-ui-attention';
|
|
32
20
|
import { Stack, StackItem } from '@dxos/react-ui-stack';
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
21
|
+
import { withLayout } from '@dxos/react-ui/testing';
|
|
22
|
+
import { mx } from '@dxos/ui-theme';
|
|
35
23
|
|
|
36
|
-
import {
|
|
37
|
-
import { storybookGraphBuilders } from '
|
|
38
|
-
import { translations } from '
|
|
39
|
-
import { NavTreeContainer } from '../NavTreeContainer';
|
|
24
|
+
import { NavTreeContainer } from '#containers';
|
|
25
|
+
import { storybookGraphBuilders } from '#testing';
|
|
26
|
+
import { translations } from '#translations';
|
|
40
27
|
|
|
41
|
-
|
|
28
|
+
import { NavTreePlugin } from '../../NavTreePlugin';
|
|
42
29
|
|
|
43
|
-
|
|
30
|
+
random.seed(1234);
|
|
44
31
|
|
|
45
|
-
|
|
46
|
-
// TODO(burdon): Consider similar containment of: Table, Sheet, Kanban Column, Form, etc.
|
|
32
|
+
const StoryState = Capability.make<Atom.Atom<{ tab: string }>>('story-state');
|
|
47
33
|
|
|
48
34
|
const container = 'flex flex-col grow gap-2 p-4 rounded-md';
|
|
49
35
|
|
|
50
|
-
// TODO(burdon): Factor out PlankHeader.
|
|
51
36
|
const StoryPlankHeading = ({ attendableId }: { attendableId: string }) => {
|
|
52
37
|
const { hasAttention } = useAttention(attendableId);
|
|
53
38
|
console.log('hasAttention', hasAttention);
|
|
54
39
|
return (
|
|
55
40
|
<div className='flex p-1 items-center border-b border-separator'>
|
|
56
41
|
<IconButton
|
|
57
|
-
density='
|
|
58
|
-
icon='ph--
|
|
42
|
+
density='lg'
|
|
43
|
+
icon='ph--circle--regular'
|
|
59
44
|
label='Test'
|
|
60
45
|
iconOnly
|
|
61
46
|
variant={hasAttention ? 'primary' : 'ghost'}
|
|
62
|
-
classNames='
|
|
47
|
+
classNames='w-(--dx-rail-action) h-(--dx-rail-action)'
|
|
63
48
|
/>
|
|
64
49
|
<StackItem.ResizeHandle />
|
|
65
50
|
</div>
|
|
@@ -68,25 +53,36 @@ const StoryPlankHeading = ({ attendableId }: { attendableId: string }) => {
|
|
|
68
53
|
|
|
69
54
|
const StoryPlank = ({ attendableId }: { attendableId: string }) => {
|
|
70
55
|
const attentionAttrs = useAttentionAttributes(attendableId);
|
|
56
|
+
const rootElement = useRef<HTMLDivElement | null>(null);
|
|
57
|
+
|
|
58
|
+
// NOTE(thure): This is the same workaround as in Plank, but that component is out of scope for this story.
|
|
59
|
+
// TODO(thure): Tabster’s focus group should handle moving focus to Main, but something is blocking it.
|
|
60
|
+
const handleKeyDown = useCallback((event: KeyboardEvent) => {
|
|
61
|
+
if (event.target === event.currentTarget && event.key === 'Escape') {
|
|
62
|
+
rootElement.current?.closest('main')?.focus();
|
|
63
|
+
}
|
|
64
|
+
}, []);
|
|
71
65
|
|
|
72
66
|
return (
|
|
73
67
|
<StackItem.Root
|
|
74
68
|
item={{ id: attendableId }}
|
|
75
69
|
{...attentionAttrs}
|
|
76
|
-
classNames='bg-
|
|
70
|
+
classNames='bg-base-surface border-e border-separator'
|
|
77
71
|
size={30}
|
|
72
|
+
onKeyDown={handleKeyDown}
|
|
73
|
+
ref={rootElement}
|
|
78
74
|
>
|
|
79
75
|
<StoryPlankHeading attendableId={attendableId} />
|
|
80
76
|
<StackItem.Content toolbar>
|
|
81
|
-
<Toolbar.Root classNames='border-b border-
|
|
77
|
+
<Toolbar.Root classNames='border-b border-subdued-separator'>
|
|
82
78
|
<Toolbar.Button>Test</Toolbar.Button>
|
|
83
79
|
</Toolbar.Root>
|
|
84
80
|
|
|
85
|
-
<div className={mx(container, 'm-2 bg-
|
|
81
|
+
<div className={mx(container, 'm-2 bg-current-surface')}>
|
|
86
82
|
<Input.Root>
|
|
87
83
|
<Input.Label>Level 1 (group)</Input.Label>
|
|
88
84
|
</Input.Root>
|
|
89
|
-
<div className={mx(container, 'bg-
|
|
85
|
+
<div className={mx(container, 'bg-base-surface')}>
|
|
90
86
|
<Input.Root>
|
|
91
87
|
<Input.Label>Level 2 (base)</Input.Label>
|
|
92
88
|
<Input.TextArea placeholder='Enter text' />
|
|
@@ -99,10 +95,10 @@ const StoryPlank = ({ attendableId }: { attendableId: string }) => {
|
|
|
99
95
|
};
|
|
100
96
|
|
|
101
97
|
const DefaultStory = () => {
|
|
102
|
-
const state =
|
|
98
|
+
const state = useAtomCapability(StoryState);
|
|
103
99
|
|
|
104
100
|
return (
|
|
105
|
-
<Main.Root
|
|
101
|
+
<Main.Root navigationSidebarState='expanded'>
|
|
106
102
|
<Main.NavigationSidebar label='Navigation' classNames='grid'>
|
|
107
103
|
<NavTreeContainer tab={state.tab} />
|
|
108
104
|
</Main.NavigationSidebar>
|
|
@@ -116,85 +112,95 @@ const DefaultStory = () => {
|
|
|
116
112
|
);
|
|
117
113
|
};
|
|
118
114
|
|
|
119
|
-
const meta
|
|
120
|
-
title: 'plugins/plugin-navtree/NavTree',
|
|
115
|
+
const meta = {
|
|
116
|
+
title: 'plugins/plugin-navtree/components/NavTree',
|
|
121
117
|
component: NavTreeContainer,
|
|
122
118
|
render: DefaultStory,
|
|
123
119
|
decorators: [
|
|
120
|
+
withLayout({ layout: 'fullscreen' }),
|
|
124
121
|
withPluginManager({
|
|
125
122
|
plugins: [
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
AttentionPlugin(),
|
|
123
|
+
...corePlugins(),
|
|
124
|
+
StorybookPlugin({
|
|
125
|
+
initialState: { sidebarState: 'expanded' },
|
|
126
|
+
}),
|
|
127
|
+
|
|
132
128
|
NavTreePlugin(),
|
|
133
129
|
],
|
|
134
|
-
capabilities: (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
130
|
+
capabilities: () => {
|
|
131
|
+
const storyStateAtom = Atom.make({ tab: 'root/space-0' }).pipe(Atom.keepAlive);
|
|
132
|
+
return [
|
|
133
|
+
Capability.contributes(StoryState, storyStateAtom),
|
|
134
|
+
Capability.contributes(AppCapabilities.AppGraphBuilder, storybookGraphBuilders()),
|
|
135
|
+
Capability.contributes(
|
|
136
|
+
Capabilities.OperationHandler,
|
|
137
|
+
OperationHandlerSet.make(
|
|
138
|
+
Operation.withHandler(LayoutOperation.SwitchWorkspace, ({ subject }) =>
|
|
139
|
+
Effect.gen(function* () {
|
|
140
|
+
const registry: Registry.Registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
141
|
+
registry.set(storyStateAtom, { tab: subject });
|
|
142
|
+
}),
|
|
143
|
+
),
|
|
144
|
+
),
|
|
145
|
+
),
|
|
146
|
+
];
|
|
147
|
+
},
|
|
149
148
|
}),
|
|
150
|
-
withLayout({ fullscreen: true }),
|
|
151
149
|
],
|
|
152
150
|
parameters: {
|
|
151
|
+
layout: 'fullscreen',
|
|
153
152
|
translations,
|
|
154
153
|
},
|
|
155
|
-
}
|
|
154
|
+
} satisfies Meta<typeof NavTreeContainer>;
|
|
156
155
|
|
|
157
156
|
export default meta;
|
|
158
157
|
|
|
159
158
|
type Story = StoryObj<typeof NavTreeContainer>;
|
|
160
159
|
|
|
161
|
-
export const Default: Story = {
|
|
160
|
+
export const Default: Story = {
|
|
161
|
+
play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
|
|
162
|
+
const canvas = within(canvasElement);
|
|
162
163
|
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
164
|
+
// Plugin startup is async; the treegrid only appears after the Startup event
|
|
165
|
+
// fires and the graph is built. Use a generous timeout so slower CI runners
|
|
166
|
+
// don't race the default 1 s limit.
|
|
167
|
+
const treegridElement = await canvas.findByRole('treegrid', {}, { timeout: 10000 });
|
|
168
|
+
const treegridParent = treegridElement.parentElement;
|
|
169
|
+
if (treegridParent) {
|
|
170
|
+
await userEvent.click(treegridParent);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Press Escape
|
|
174
|
+
await userEvent.keyboard('{Escape}');
|
|
175
|
+
|
|
176
|
+
// Confirm that focus is on an element with attribute data-main-landmark="0"
|
|
177
|
+
await expect(document.activeElement).toHaveAttribute('data-main-landmark', '0');
|
|
178
|
+
|
|
179
|
+
// Press Tab
|
|
180
|
+
await userEvent.keyboard('{Tab}');
|
|
181
|
+
|
|
182
|
+
// Confirm that focus is now on an element with data-main-landmark="1"
|
|
183
|
+
await expect(document.activeElement).toHaveAttribute('data-main-landmark', '1');
|
|
184
|
+
|
|
185
|
+
// Press Tab
|
|
186
|
+
await userEvent.keyboard('{Tab}');
|
|
187
|
+
|
|
188
|
+
// Confirm that focus is now on an element with data-main-landmark="0"
|
|
189
|
+
await expect(document.activeElement).toHaveAttribute('data-main-landmark', '0');
|
|
190
|
+
|
|
191
|
+
// Press Shift-Tab
|
|
192
|
+
await userEvent.keyboard('{Shift>}{Tab}{/Shift}');
|
|
193
|
+
|
|
194
|
+
// Press Enter
|
|
195
|
+
await userEvent.keyboard('{Enter}');
|
|
196
|
+
|
|
197
|
+
// Confirm that focus is now on an element with data-attendable-id="space-0:object-0"
|
|
198
|
+
await expect(document.activeElement).toHaveAttribute('data-attendable-id', 'space-0:object-0');
|
|
199
|
+
|
|
200
|
+
// Press Escape
|
|
201
|
+
await userEvent.keyboard('{Escape}');
|
|
202
|
+
|
|
203
|
+
// Confirm that focus is now on an element with data-main-landmark="1"
|
|
204
|
+
await expect(document.activeElement).toHaveAttribute('data-main-landmark', '1');
|
|
205
|
+
},
|
|
200
206
|
};
|
|
@@ -2,52 +2,36 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { useMemo } from 'react';
|
|
5
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { Node, useConnections, useActions as useGraphActions } from '@dxos/plugin-graph';
|
|
8
9
|
import { Tabs } from '@dxos/react-ui-tabs';
|
|
10
|
+
import { byPosition } from '@dxos/util';
|
|
11
|
+
|
|
12
|
+
import { useLoadDescendents } from '#hooks';
|
|
9
13
|
|
|
10
|
-
import { useLoadDescendents } from '../../hooks';
|
|
11
|
-
import { type NavTreeItemGraphNode } from '../../types';
|
|
12
14
|
import { useNavTreeContext } from '../NavTreeContext';
|
|
13
15
|
import { L0Menu, L1Tabs, type L1TabsProps } from '../Sidebar';
|
|
14
16
|
|
|
15
17
|
export const NAV_TREE_ITEM = 'NavTreeItem';
|
|
16
18
|
|
|
17
|
-
export type NavTreeProps =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const topLevelWorkspaces = useItems(root, { disposition: 'workspace' });
|
|
24
|
-
const topLevelNavigation = useItems(root, { disposition: 'navigation' });
|
|
25
|
-
const l0Items = useMemo(
|
|
26
|
-
() => [
|
|
27
|
-
// prettier-ignore
|
|
28
|
-
...topLevelCollections,
|
|
29
|
-
...topLevelWorkspaces,
|
|
30
|
-
...topLevelNavigation,
|
|
31
|
-
],
|
|
32
|
-
[topLevelCollections, topLevelWorkspaces, topLevelNavigation],
|
|
33
|
-
);
|
|
34
|
-
const pinnedItems = useItems(root, { disposition: 'pin-end', sort: true });
|
|
35
|
-
const userAccountItem = useItems(root, { disposition: 'user-account' })[0];
|
|
36
|
-
const topLevelItems = useMemo(
|
|
37
|
-
() => [
|
|
38
|
-
// prettier-ignore
|
|
39
|
-
...l0Items,
|
|
40
|
-
...pinnedItems,
|
|
41
|
-
...(userAccountItem ? [userAccountItem] : []),
|
|
42
|
-
],
|
|
43
|
-
[l0Items, pinnedItems, userAccountItem],
|
|
44
|
-
);
|
|
19
|
+
export type NavTreeProps = { id: string; root?: Node.Node; tab: string } & Pick<L1TabsProps, 'open'>;
|
|
20
|
+
|
|
21
|
+
// TODO(wittjosiah): Refactor to Radix-style.
|
|
22
|
+
export const NavTree = forwardRef<HTMLDivElement, NavTreeProps>(({ id, root, tab, ...props }, forwardedRef) => {
|
|
23
|
+
const { onBack, onItemHover } = useNavTreeContext();
|
|
24
|
+
const { topLevelActions, l0Items, pinnedItems, userAccountItem, topLevelItems } = useTopLevelNavItems(root);
|
|
45
25
|
|
|
46
26
|
useLoadDescendents(root);
|
|
47
27
|
const path = useMemo(() => [id], [id]);
|
|
48
28
|
|
|
49
29
|
return (
|
|
50
|
-
|
|
30
|
+
// TODO(thure): `Tabs.Root` forces all items that should be able to receive focus to use `Tabs.Tab(Primitive)` since
|
|
31
|
+
// it uses RovingFocus and doesn't support moving focus to an item that is not a tab. Assess whether this situation
|
|
32
|
+
// should change including whether it should motivate a change in the design/taxonomy, or if this means this should
|
|
33
|
+
// not use `react-ui-tabs` at all.
|
|
34
|
+
<Tabs.Root value={tab} orientation='vertical' classNames='relative' ref={forwardedRef}>
|
|
51
35
|
<L0Menu
|
|
52
36
|
menuActions={topLevelActions}
|
|
53
37
|
topLevelItems={l0Items}
|
|
@@ -55,8 +39,60 @@ export const NavTree = ({ id, root, ...props }: NavTreeProps) => {
|
|
|
55
39
|
userAccountItem={userAccountItem}
|
|
56
40
|
path={path}
|
|
57
41
|
parent={root}
|
|
42
|
+
onItemHover={onItemHover}
|
|
58
43
|
/>
|
|
59
44
|
<L1Tabs topLevelItems={topLevelItems} path={path} currentItemId={tab} onBack={onBack} {...props} />
|
|
60
45
|
</Tabs.Root>
|
|
61
46
|
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Partitions root children into workspaces, pinned items, user-account, and top-level actions.
|
|
51
|
+
*/
|
|
52
|
+
const useTopLevelNavItems = (root?: Node.Node) => {
|
|
53
|
+
const { graph } = useAppGraph();
|
|
54
|
+
const rootId = root?.id ?? Node.RootId;
|
|
55
|
+
const rootOutboundItems = useConnections(graph, rootId, 'child');
|
|
56
|
+
const rootActions = useGraphActions(graph, rootId);
|
|
57
|
+
|
|
58
|
+
const { topLevelActions, l0Items, pinnedItems, userAccountItem } = useMemo(() => {
|
|
59
|
+
const topLevelWorkspaces: Node.Node[] = [];
|
|
60
|
+
const outboundPinnedItems: Node.Node[] = [];
|
|
61
|
+
let userAccountItem: Node.Node | undefined;
|
|
62
|
+
for (const node of rootOutboundItems) {
|
|
63
|
+
switch (node.properties.disposition) {
|
|
64
|
+
case 'workspace':
|
|
65
|
+
topLevelWorkspaces.push(node);
|
|
66
|
+
break;
|
|
67
|
+
case 'pin-end':
|
|
68
|
+
outboundPinnedItems.push(node);
|
|
69
|
+
break;
|
|
70
|
+
case 'user-account':
|
|
71
|
+
userAccountItem ??= node;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const topLevelActions = rootActions
|
|
77
|
+
.filter((action) => action.properties.disposition === 'menu')
|
|
78
|
+
.toSorted((a, b) => byPosition(a.properties, b.properties));
|
|
79
|
+
const pinnedItems = [
|
|
80
|
+
...outboundPinnedItems,
|
|
81
|
+
...rootActions.filter((action) => action.properties.disposition === 'pin-end'),
|
|
82
|
+
].toSorted((a, b) => byPosition(a.properties, b.properties));
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
pinnedItems,
|
|
86
|
+
topLevelActions,
|
|
87
|
+
userAccountItem,
|
|
88
|
+
l0Items: topLevelWorkspaces,
|
|
89
|
+
};
|
|
90
|
+
}, [rootActions, rootOutboundItems]);
|
|
91
|
+
|
|
92
|
+
const topLevelItems = useMemo(
|
|
93
|
+
() => [...l0Items, ...pinnedItems, ...(userAccountItem ? [userAccountItem] : [])],
|
|
94
|
+
[l0Items, pinnedItems, userAccountItem],
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return { topLevelActions, l0Items, pinnedItems, userAccountItem, topLevelItems };
|
|
62
98
|
};
|
|
@@ -6,7 +6,7 @@ import { createContext, useContext } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
8
|
|
|
9
|
-
import { type NavTreeContextValue } from '
|
|
9
|
+
import { type NavTreeContextValue } from '../types';
|
|
10
10
|
|
|
11
11
|
export const NavTreeContext = createContext<NavTreeContextValue | null>(null);
|
|
12
12
|
|
|
@@ -2,57 +2,63 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
8
7
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { ProcessManagerPlugin } from '@dxos/app-framework';
|
|
9
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
+
import { type Node } from '@dxos/app-graph';
|
|
11
|
+
import { corePlugins } from '@dxos/plugin-testing';
|
|
12
|
+
import { random } from '@dxos/random';
|
|
12
13
|
|
|
13
14
|
import { NavTreeItemAction, type NavTreeItemActionMenuProps } from './NavTreeItemAction';
|
|
14
15
|
|
|
15
16
|
const parent = {
|
|
16
|
-
id:
|
|
17
|
+
id: random.string.uuid(),
|
|
17
18
|
type: 'node',
|
|
18
19
|
data: null,
|
|
19
20
|
properties: {
|
|
20
|
-
label:
|
|
21
|
+
label: random.lorem.words(2),
|
|
21
22
|
icon: 'ph--circle--regular',
|
|
22
23
|
},
|
|
23
|
-
} satisfies NodeArg<any>;
|
|
24
|
+
} satisfies Node.NodeArg<any>;
|
|
24
25
|
|
|
25
26
|
// TODO(burdon): Factor out across tests.
|
|
26
|
-
const menuActions =
|
|
27
|
+
const menuActions = random.helpers.multiple(
|
|
27
28
|
() =>
|
|
28
29
|
({
|
|
29
|
-
id:
|
|
30
|
+
id: random.string.uuid(),
|
|
30
31
|
type: 'action',
|
|
31
|
-
data: () =>
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
data: () =>
|
|
33
|
+
Effect.sync(() => {
|
|
34
|
+
console.log('invoke');
|
|
35
|
+
}),
|
|
34
36
|
properties: {
|
|
35
|
-
label:
|
|
37
|
+
label: random.lorem.words(2),
|
|
36
38
|
icon: 'ph--circle--regular',
|
|
37
39
|
},
|
|
38
|
-
}) satisfies NodeArg<any>,
|
|
40
|
+
}) satisfies Node.NodeArg<any>,
|
|
39
41
|
{ count: 20 },
|
|
40
42
|
);
|
|
41
43
|
|
|
42
|
-
const meta
|
|
43
|
-
title: 'plugins/plugin-navtree/NavTreeItemAction',
|
|
44
|
+
const meta = {
|
|
45
|
+
title: 'plugins/plugin-navtree/components/NavTreeItemAction',
|
|
44
46
|
component: NavTreeItemAction,
|
|
45
|
-
decorators: [withTheme, withLayout()],
|
|
46
47
|
args: {
|
|
47
48
|
icon: 'ph--list--regular',
|
|
48
49
|
parent,
|
|
49
50
|
menuActions,
|
|
50
51
|
label: 'Select action',
|
|
51
52
|
} satisfies Partial<NavTreeItemActionMenuProps>,
|
|
53
|
+
decorators: [
|
|
54
|
+
withPluginManager({
|
|
55
|
+
plugins: [...corePlugins(), ProcessManagerPlugin()],
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
52
58
|
parameters: {
|
|
53
59
|
layout: 'centered',
|
|
54
60
|
},
|
|
55
|
-
}
|
|
61
|
+
} satisfies Meta<typeof NavTreeItemAction>;
|
|
56
62
|
|
|
57
63
|
export default meta;
|
|
58
64
|
|