@dxos/plugin-deck 0.8.1-staging.391c573 → 0.8.1-staging.9eaf14f
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/{app-graph-builder-IYHAGFA3.mjs → app-graph-builder-VYZ4IWI3.mjs} +3 -3
- package/dist/lib/browser/{check-app-scheme-S3EYUPMF.mjs → check-app-scheme-SEYECDHI.mjs} +2 -2
- package/dist/lib/browser/{chunk-YCKJNTKG.mjs → chunk-6ZSOFCPP.mjs} +26 -6
- package/dist/lib/browser/chunk-6ZSOFCPP.mjs.map +7 -0
- package/dist/lib/browser/chunk-B4LOJUWW.mjs +24 -0
- package/dist/lib/browser/{chunk-Z23S33X6.mjs → chunk-FJBMNSUC.mjs} +638 -483
- package/dist/lib/browser/chunk-FJBMNSUC.mjs.map +7 -0
- package/dist/lib/browser/chunk-FLOVGNYB.mjs +81 -0
- package/dist/lib/browser/chunk-FLOVGNYB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-N7TEPFVR.mjs → chunk-NSATFAEE.mjs} +3 -3
- package/dist/lib/browser/{chunk-N7TEPFVR.mjs.map → chunk-NSATFAEE.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-FYKBOM3C.mjs → chunk-RJNCG4ND.mjs} +66 -40
- package/dist/lib/browser/chunk-RJNCG4ND.mjs.map +7 -0
- package/dist/lib/browser/{chunk-22AQ5IVX.mjs → chunk-XMCG42ID.mjs} +2 -3
- package/dist/lib/browser/chunk-XMCG42ID.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +14 -9
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-P5BVUQKU.mjs → intent-resolver-UDYKO2QW.mjs} +78 -88
- package/dist/lib/browser/intent-resolver-UDYKO2QW.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-root-EP4UF3KA.mjs → react-root-XLXN2VEW.mjs} +8 -10
- package/dist/lib/browser/react-root-XLXN2VEW.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-5B3RLJCD.mjs → react-surface-WNGMZL7I.mjs} +11 -10
- package/dist/lib/browser/react-surface-WNGMZL7I.mjs.map +7 -0
- package/dist/lib/browser/{settings-X3P2HKQJ.mjs → settings-HMDGSBGO.mjs} +5 -4
- package/dist/lib/browser/settings-HMDGSBGO.mjs.map +7 -0
- package/dist/lib/browser/{state-2MOTLKVR.mjs → state-7TN26M42.mjs} +7 -11
- package/dist/lib/browser/state-7TN26M42.mjs.map +7 -0
- package/dist/lib/browser/tools-SC6QEN7R.mjs +78 -0
- package/dist/lib/browser/tools-SC6QEN7R.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +12 -6
- package/dist/lib/browser/{url-handler-MVHTKUYA.mjs → url-handler-ODG4B6NX.mjs} +7 -9
- package/dist/lib/browser/url-handler-ODG4B6NX.mjs.map +7 -0
- package/dist/types/src/DeckPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +36 -14
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-root.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +18 -6
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/capabilities/tools.d.ts +1 -0
- package/dist/types/src/capabilities/tools.d.ts.map +1 -1
- package/dist/types/src/capabilities/url-handler.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/ActiveNode.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Banner.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/DeckLayout.d.ts +1 -4
- package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Toast.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/index.d.ts +1 -0
- package/dist/types/src/components/DeckLayout/index.d.ts.map +1 -1
- package/dist/types/src/components/DeckSettings/DeckSettings.d.ts +6 -0
- package/dist/types/src/components/DeckSettings/DeckSettings.d.ts.map +1 -0
- package/dist/types/src/components/DeckSettings/index.d.ts +2 -0
- package/dist/types/src/components/DeckSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/Plank/Plank.d.ts +14 -0
- package/dist/types/src/components/Plank/Plank.d.ts.map +1 -0
- package/dist/types/src/components/Plank/Plank.stories.d.ts +8 -0
- package/dist/types/src/components/Plank/Plank.stories.d.ts.map +1 -0
- package/dist/types/src/components/{DeckLayout → Plank}/PlankControls.d.ts +8 -1
- package/dist/types/src/components/Plank/PlankControls.d.ts.map +1 -0
- package/dist/types/src/components/{DeckLayout → Plank}/PlankError.d.ts +2 -2
- package/dist/types/src/components/Plank/PlankError.d.ts.map +1 -0
- package/dist/types/src/components/Plank/PlankHeading.d.ts +20 -0
- package/dist/types/src/components/Plank/PlankHeading.d.ts.map +1 -0
- package/dist/types/src/components/Plank/PlankLoading.d.ts.map +1 -0
- package/dist/types/src/components/Plank/index.d.ts +6 -0
- package/dist/types/src/components/Plank/index.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/ComplementarySidebar.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/Sidebar.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/SidebarButton.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/index.d.ts +4 -0
- package/dist/types/src/components/Sidebar/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +0 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +0 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/layout.d.ts +7 -1
- package/dist/types/src/layout.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -5
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +4 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +50 -48
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/set-active.d.ts +2 -2
- package/dist/types/src/util/set-active.d.ts.map +1 -1
- package/dist/types/src/util/useCompanions.d.ts +8 -0
- package/dist/types/src/util/useCompanions.d.ts.map +1 -0
- package/dist/types/src/util/useHoistStatusbar.d.ts.map +1 -1
- package/package.json +28 -29
- package/src/DeckPlugin.ts +0 -1
- package/src/capabilities/capabilities.ts +3 -4
- package/src/capabilities/intent-resolver.ts +63 -9
- package/src/capabilities/react-root.tsx +1 -9
- package/src/capabilities/react-surface.tsx +3 -4
- package/src/capabilities/settings.ts +7 -2
- package/src/capabilities/state.ts +4 -11
- package/src/capabilities/tools.ts +34 -22
- package/src/capabilities/url-handler.ts +2 -8
- package/src/components/DeckLayout/ActiveNode.tsx +2 -1
- package/src/components/DeckLayout/Banner.tsx +5 -3
- package/src/components/DeckLayout/ContentEmpty.tsx +1 -1
- package/src/components/DeckLayout/DeckLayout.tsx +58 -24
- package/src/components/DeckLayout/Fullscreen.tsx +1 -1
- package/src/components/DeckLayout/Toast.tsx +1 -1
- package/src/components/DeckLayout/index.ts +2 -0
- package/src/components/{LayoutSettings.tsx → DeckSettings/DeckSettings.tsx} +15 -10
- package/src/components/DeckSettings/index.ts +5 -0
- package/src/components/Plank/Plank.stories.tsx +43 -0
- package/src/components/Plank/Plank.tsx +230 -0
- package/src/components/{DeckLayout → Plank}/PlankControls.tsx +73 -27
- package/src/components/{DeckLayout → Plank}/PlankError.tsx +3 -3
- package/src/components/Plank/PlankHeading.tsx +207 -0
- package/src/components/Plank/index.ts +9 -0
- package/src/components/{DeckLayout → Sidebar}/ComplementarySidebar.tsx +65 -81
- package/src/components/Sidebar/index.ts +7 -0
- package/src/components/index.ts +1 -1
- package/src/events.ts +0 -1
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +1 -0
- package/src/layout.ts +19 -2
- package/src/meta.ts +4 -4
- package/src/translations.ts +4 -0
- package/src/types.ts +81 -79
- package/src/util/index.ts +1 -0
- package/src/util/set-active.ts +2 -2
- package/src/util/useCompanions.ts +18 -0
- package/src/util/useHoistStatusbar.ts +2 -2
- package/dist/lib/browser/chunk-22AQ5IVX.mjs.map +0 -7
- package/dist/lib/browser/chunk-FYKBOM3C.mjs.map +0 -7
- package/dist/lib/browser/chunk-IZ5RPJ6T.mjs +0 -24
- package/dist/lib/browser/chunk-YCKJNTKG.mjs.map +0 -7
- package/dist/lib/browser/chunk-Z23S33X6.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-P5BVUQKU.mjs.map +0 -7
- package/dist/lib/browser/react-root-EP4UF3KA.mjs.map +0 -7
- package/dist/lib/browser/react-surface-5B3RLJCD.mjs.map +0 -7
- package/dist/lib/browser/settings-X3P2HKQJ.mjs.map +0 -7
- package/dist/lib/browser/state-2MOTLKVR.mjs.map +0 -7
- package/dist/lib/browser/tools-64LXGLYR.mjs +0 -59
- package/dist/lib/browser/tools-64LXGLYR.mjs.map +0 -7
- package/dist/lib/browser/url-handler-MVHTKUYA.mjs.map +0 -7
- package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts.map +0 -1
- package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts +0 -15
- package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts.map +0 -1
- package/dist/types/src/components/DeckLayout/Plank.d.ts +0 -13
- package/dist/types/src/components/DeckLayout/Plank.d.ts.map +0 -1
- package/dist/types/src/components/DeckLayout/PlankControls.d.ts.map +0 -1
- package/dist/types/src/components/DeckLayout/PlankError.d.ts.map +0 -1
- package/dist/types/src/components/DeckLayout/PlankLoading.d.ts.map +0 -1
- package/dist/types/src/components/DeckLayout/Sidebar.d.ts.map +0 -1
- package/dist/types/src/components/DeckLayout/SidebarButton.d.ts.map +0 -1
- package/dist/types/src/components/LayoutSettings.d.ts +0 -6
- package/dist/types/src/components/LayoutSettings.d.ts.map +0 -1
- package/dist/types/src/hooks/useNode.d.ts +0 -11
- package/dist/types/src/hooks/useNode.d.ts.map +0 -1
- package/src/components/DeckLayout/NodePlankHeading.tsx +0 -148
- package/src/components/DeckLayout/Plank.tsx +0 -149
- package/src/hooks/useNode.ts +0 -46
- /package/dist/lib/browser/{app-graph-builder-IYHAGFA3.mjs.map → app-graph-builder-VYZ4IWI3.mjs.map} +0 -0
- /package/dist/lib/browser/{check-app-scheme-S3EYUPMF.mjs.map → check-app-scheme-SEYECDHI.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-IZ5RPJ6T.mjs.map → chunk-B4LOJUWW.mjs.map} +0 -0
- /package/dist/types/src/components/{DeckLayout → Plank}/PlankLoading.d.ts +0 -0
- /package/dist/types/src/components/{DeckLayout → Sidebar}/ComplementarySidebar.d.ts +0 -0
- /package/dist/types/src/components/{DeckLayout → Sidebar}/Sidebar.d.ts +0 -0
- /package/dist/types/src/components/{DeckLayout → Sidebar}/SidebarButton.d.ts +0 -0
- /package/src/components/{DeckLayout → Plank}/PlankLoading.tsx +0 -0
- /package/src/components/{DeckLayout → Sidebar}/Sidebar.tsx +0 -0
- /package/src/components/{DeckLayout → Sidebar}/SidebarButton.tsx +0 -0
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Graph, type Node } from '@dxos/plugin-graph';
|
|
2
|
-
/**
|
|
3
|
-
* React hook to get a node from the graph.
|
|
4
|
-
*
|
|
5
|
-
* @param graph Graph to find the node in.
|
|
6
|
-
* @param id Id of the node to find.
|
|
7
|
-
* @param timeout Optional timeout in milliseconds to wait for the node to be found.
|
|
8
|
-
* @returns Node if found, undefined otherwise.
|
|
9
|
-
*/
|
|
10
|
-
export declare const useNode: <T = any>(graph: Graph, id?: string, timeout?: number) => Node<T> | undefined;
|
|
11
|
-
//# sourceMappingURL=useNode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useNode.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;;;;GAOG;AAEH,eAAO,MAAM,OAAO,GAAI,CAAC,eAAe,KAAK,OAAO,MAAM,YAAY,MAAM,KAAG,IAAI,CAAC,CAAC,CAAC,GAAG,SA4BxF,CAAC"}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { Fragment, memo, useCallback, useEffect, useMemo } from 'react';
|
|
6
|
-
|
|
7
|
-
import { createIntent, LayoutAction, Surface, useAppGraph, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
-
import { type Node } from '@dxos/plugin-graph';
|
|
9
|
-
import { Icon, Popover, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
10
|
-
import { StackItem, type StackItemSigilAction } from '@dxos/react-ui-stack';
|
|
11
|
-
import { TextTooltip } from '@dxos/react-ui-text-tooltip';
|
|
12
|
-
|
|
13
|
-
import { PlankControls } from './PlankControls';
|
|
14
|
-
import { DECK_PLUGIN } from '../../meta';
|
|
15
|
-
import { DeckAction, SLUG_PATH_SEPARATOR } from '../../types';
|
|
16
|
-
import { useBreakpoints } from '../../util';
|
|
17
|
-
import { soloInlinePadding } from '../fragments';
|
|
18
|
-
|
|
19
|
-
export type NodePlankHeadingProps = {
|
|
20
|
-
id: string;
|
|
21
|
-
part: 'solo' | 'deck' | 'complementary';
|
|
22
|
-
node?: Node;
|
|
23
|
-
canIncrementStart?: boolean;
|
|
24
|
-
canIncrementEnd?: boolean;
|
|
25
|
-
popoverAnchorId?: string;
|
|
26
|
-
pending?: boolean;
|
|
27
|
-
actions?: StackItemSigilAction[];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const NodePlankHeading = memo(
|
|
31
|
-
({
|
|
32
|
-
id,
|
|
33
|
-
part,
|
|
34
|
-
node,
|
|
35
|
-
canIncrementStart,
|
|
36
|
-
canIncrementEnd,
|
|
37
|
-
popoverAnchorId,
|
|
38
|
-
pending,
|
|
39
|
-
actions = [],
|
|
40
|
-
}: NodePlankHeadingProps) => {
|
|
41
|
-
const { t } = useTranslation(DECK_PLUGIN);
|
|
42
|
-
const { graph } = useAppGraph();
|
|
43
|
-
const breakpoint = useBreakpoints();
|
|
44
|
-
const icon = node?.properties?.icon ?? 'ph--placeholder--regular';
|
|
45
|
-
const label = pending
|
|
46
|
-
? t('pending heading')
|
|
47
|
-
: toLocalizedString(node?.properties?.label ?? ['plank heading fallback label', { ns: DECK_PLUGIN }], t);
|
|
48
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
49
|
-
const ActionRoot = node && popoverAnchorId === `dxos.org/ui/${DECK_PLUGIN}/${node.id}` ? Popover.Anchor : Fragment;
|
|
50
|
-
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
const frame = requestAnimationFrame(() => {
|
|
53
|
-
// Load actions for the node.
|
|
54
|
-
node && graph.actions(node);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
return () => cancelAnimationFrame(frame);
|
|
58
|
-
}, [node]);
|
|
59
|
-
|
|
60
|
-
// NOTE(Zan): Node ids may now contain a path like `${space}:${id}~comments`
|
|
61
|
-
const attendableId = id.split(SLUG_PATH_SEPARATOR).at(0);
|
|
62
|
-
const capabilities = useMemo(
|
|
63
|
-
() => ({
|
|
64
|
-
solo: breakpoint !== 'mobile' && (part === 'solo' || part === 'deck'),
|
|
65
|
-
incrementStart: canIncrementStart,
|
|
66
|
-
incrementEnd: canIncrementEnd,
|
|
67
|
-
}),
|
|
68
|
-
[breakpoint, part, canIncrementStart, canIncrementEnd],
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const sigilActions = useMemo(
|
|
72
|
-
() => node && [actions, graph.actions(node)].filter((a) => a.length > 0),
|
|
73
|
-
[actions, node, graph],
|
|
74
|
-
);
|
|
75
|
-
const handleAction = useCallback((action: StackItemSigilAction) => {
|
|
76
|
-
typeof action.data === 'function' && action.data?.({ node: action as Node, caller: DECK_PLUGIN });
|
|
77
|
-
}, []);
|
|
78
|
-
|
|
79
|
-
const handlePlankAction = useCallback(
|
|
80
|
-
(eventType: DeckAction.PartAdjustment) => {
|
|
81
|
-
if (eventType === 'solo') {
|
|
82
|
-
return dispatch(createIntent(DeckAction.Adjust, { type: eventType, id }));
|
|
83
|
-
} else if (eventType === 'close') {
|
|
84
|
-
if (part === 'complementary') {
|
|
85
|
-
return dispatch(
|
|
86
|
-
createIntent(LayoutAction.UpdateComplementary, {
|
|
87
|
-
part: 'complementary',
|
|
88
|
-
options: { state: 'collapsed' },
|
|
89
|
-
}),
|
|
90
|
-
);
|
|
91
|
-
} else {
|
|
92
|
-
return dispatch(
|
|
93
|
-
createIntent(LayoutAction.Close, { part: 'main', subject: [id], options: { state: false } }),
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
} else {
|
|
97
|
-
return dispatch(createIntent(DeckAction.Adjust, { type: eventType, id }));
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
[dispatch, id, part],
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<StackItem.Heading
|
|
105
|
-
classNames={[
|
|
106
|
-
'plb-1 border-be border-separator items-stretch gap-1 sticky inline-start-12 app-drag',
|
|
107
|
-
part === 'solo' ? soloInlinePadding : 'pli-1',
|
|
108
|
-
]}
|
|
109
|
-
>
|
|
110
|
-
<ActionRoot>
|
|
111
|
-
{node && sigilActions ? (
|
|
112
|
-
<StackItem.Sigil
|
|
113
|
-
icon={icon}
|
|
114
|
-
related={part === 'complementary'}
|
|
115
|
-
attendableId={attendableId}
|
|
116
|
-
triggerLabel={t('actions menu label')}
|
|
117
|
-
actions={sigilActions}
|
|
118
|
-
onAction={handleAction}
|
|
119
|
-
>
|
|
120
|
-
<Surface role='menu-footer' data={{ subject: node.data }} />
|
|
121
|
-
</StackItem.Sigil>
|
|
122
|
-
) : (
|
|
123
|
-
<StackItem.SigilButton>
|
|
124
|
-
<span className='sr-only'>{label}</span>
|
|
125
|
-
<Icon icon={icon} size={5} />
|
|
126
|
-
</StackItem.SigilButton>
|
|
127
|
-
)}
|
|
128
|
-
</ActionRoot>
|
|
129
|
-
<TextTooltip text={label} onlyWhenTruncating>
|
|
130
|
-
<StackItem.HeadingLabel
|
|
131
|
-
attendableId={attendableId}
|
|
132
|
-
related={part === 'complementary'}
|
|
133
|
-
{...(pending && { classNames: 'text-description' })}
|
|
134
|
-
>
|
|
135
|
-
{label}
|
|
136
|
-
</StackItem.HeadingLabel>
|
|
137
|
-
</TextTooltip>
|
|
138
|
-
{node && part !== 'complementary' && <Surface role='navbar-end' data={{ subject: node.data }} />}
|
|
139
|
-
<PlankControls
|
|
140
|
-
capabilities={capabilities}
|
|
141
|
-
isSolo={part === 'solo'}
|
|
142
|
-
onClick={handlePlankAction}
|
|
143
|
-
close={part === 'complementary' ? 'minify-end' : true}
|
|
144
|
-
/>
|
|
145
|
-
</StackItem.Heading>
|
|
146
|
-
);
|
|
147
|
-
},
|
|
148
|
-
);
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type KeyboardEvent, memo, useCallback, useLayoutEffect, useMemo, useRef } from 'react';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
createIntent,
|
|
9
|
-
LayoutAction,
|
|
10
|
-
Surface,
|
|
11
|
-
useCapability,
|
|
12
|
-
useAppGraph,
|
|
13
|
-
useIntentDispatcher,
|
|
14
|
-
} from '@dxos/app-framework';
|
|
15
|
-
import { debounce } from '@dxos/async';
|
|
16
|
-
import { useAttendableAttributes } from '@dxos/react-ui-attention';
|
|
17
|
-
import { StackItem, railGridHorizontal } from '@dxos/react-ui-stack';
|
|
18
|
-
import { mainIntrinsicSize, mx } from '@dxos/react-ui-theme';
|
|
19
|
-
|
|
20
|
-
import { NodePlankHeading, type NodePlankHeadingProps } from './NodePlankHeading';
|
|
21
|
-
import { PlankContentError, PlankError } from './PlankError';
|
|
22
|
-
import { PlankLoading } from './PlankLoading';
|
|
23
|
-
import { DeckCapabilities } from '../../capabilities';
|
|
24
|
-
import { useNode, useMainSize } from '../../hooks';
|
|
25
|
-
import { DeckAction, type LayoutMode } from '../../types';
|
|
26
|
-
|
|
27
|
-
const UNKNOWN_ID = 'unknown_id';
|
|
28
|
-
|
|
29
|
-
export type PlankProps = {
|
|
30
|
-
id?: string;
|
|
31
|
-
part: NodePlankHeadingProps['part'];
|
|
32
|
-
path?: string[];
|
|
33
|
-
order?: number;
|
|
34
|
-
active?: string[];
|
|
35
|
-
layoutMode: LayoutMode;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const Plank = memo(({ id = UNKNOWN_ID, part, path, order, active, layoutMode }: PlankProps) => {
|
|
39
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
40
|
-
const { deck, popoverAnchorId, scrollIntoView } = useCapability(DeckCapabilities.DeckState);
|
|
41
|
-
const { graph } = useAppGraph();
|
|
42
|
-
const node = useNode(graph, id);
|
|
43
|
-
const rootElement = useRef<HTMLDivElement | null>(null);
|
|
44
|
-
const canResize = layoutMode === 'deck';
|
|
45
|
-
const Root = part === 'solo' ? 'article' : StackItem.Root;
|
|
46
|
-
|
|
47
|
-
const attendableAttrs = useAttendableAttributes(id);
|
|
48
|
-
const index = active ? active.findIndex((entryId) => entryId === id) : 0;
|
|
49
|
-
const length = active?.length ?? 1;
|
|
50
|
-
const canIncrementStart = active && index !== undefined && index > 0 && length !== undefined && length > 1;
|
|
51
|
-
const canIncrementEnd = active && index !== undefined && index < length - 1 && length !== undefined;
|
|
52
|
-
|
|
53
|
-
const key = id.split('+')[0];
|
|
54
|
-
const size = deck.plankSizing[key] as number | undefined;
|
|
55
|
-
const setSize = useCallback(
|
|
56
|
-
debounce((nextSize: number) => {
|
|
57
|
-
return dispatch(createIntent(DeckAction.UpdatePlankSize, { id: key, size: nextSize }));
|
|
58
|
-
}, 200),
|
|
59
|
-
[dispatch, key],
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
// TODO(thure): Tabster’s focus group should handle moving focus to Main, but something is blocking it.
|
|
63
|
-
const handleKeyDown = useCallback((event: KeyboardEvent) => {
|
|
64
|
-
if (event.target === event.currentTarget && event.key === 'Escape') {
|
|
65
|
-
rootElement.current?.closest('main')?.focus();
|
|
66
|
-
}
|
|
67
|
-
}, []);
|
|
68
|
-
|
|
69
|
-
useLayoutEffect(() => {
|
|
70
|
-
if (scrollIntoView === id) {
|
|
71
|
-
// TODO(wittjosiah): When focused on page load, the focus is always visible.
|
|
72
|
-
// Forcing focus to something smaller than the plank prevents large focus ring in the interim.
|
|
73
|
-
const focusable = rootElement.current?.querySelector('button') || rootElement.current;
|
|
74
|
-
focusable?.focus({ preventScroll: true });
|
|
75
|
-
layoutMode === 'deck' && focusable?.scrollIntoView({ behavior: 'smooth', inline: 'center' });
|
|
76
|
-
// Clear the scroll into view state once it has been actioned.
|
|
77
|
-
void dispatch(createIntent(LayoutAction.ScrollIntoView, { part: 'current', subject: undefined }));
|
|
78
|
-
}
|
|
79
|
-
}, [id, scrollIntoView, layoutMode]);
|
|
80
|
-
|
|
81
|
-
const isSolo = layoutMode === 'solo' && part === 'solo';
|
|
82
|
-
const isAttendable = isSolo || (layoutMode === 'deck' && part === 'deck');
|
|
83
|
-
|
|
84
|
-
const sizeAttrs = useMainSize();
|
|
85
|
-
|
|
86
|
-
const data = useMemo(
|
|
87
|
-
() =>
|
|
88
|
-
node && {
|
|
89
|
-
subject: node.data,
|
|
90
|
-
path,
|
|
91
|
-
popoverAnchorId,
|
|
92
|
-
},
|
|
93
|
-
[node, node?.data, path, popoverAnchorId],
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
// TODO(wittjosiah): Change prop to accept a component.
|
|
97
|
-
const placeholder = useMemo(() => <PlankLoading />, []);
|
|
98
|
-
|
|
99
|
-
const className = mx(
|
|
100
|
-
'attention-surface relative',
|
|
101
|
-
isSolo && mainIntrinsicSize,
|
|
102
|
-
isSolo && railGridHorizontal,
|
|
103
|
-
isSolo ? 'grid absolute inset-0' : '!border-separator border-li',
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<Root
|
|
108
|
-
ref={rootElement}
|
|
109
|
-
data-testid='deck.plank'
|
|
110
|
-
tabIndex={0}
|
|
111
|
-
{...(part === 'solo'
|
|
112
|
-
? ({ ...sizeAttrs, className } as any)
|
|
113
|
-
: {
|
|
114
|
-
item: { id },
|
|
115
|
-
size,
|
|
116
|
-
onSizeChange: setSize,
|
|
117
|
-
classNames: className,
|
|
118
|
-
order,
|
|
119
|
-
role: 'article',
|
|
120
|
-
})}
|
|
121
|
-
{...(isAttendable ? attendableAttrs : {})}
|
|
122
|
-
onKeyDown={handleKeyDown}
|
|
123
|
-
>
|
|
124
|
-
{node ? (
|
|
125
|
-
<>
|
|
126
|
-
<NodePlankHeading
|
|
127
|
-
id={id}
|
|
128
|
-
part={part}
|
|
129
|
-
node={node}
|
|
130
|
-
canIncrementStart={canIncrementStart}
|
|
131
|
-
canIncrementEnd={canIncrementEnd}
|
|
132
|
-
popoverAnchorId={popoverAnchorId}
|
|
133
|
-
/>
|
|
134
|
-
<Surface
|
|
135
|
-
key={node.id}
|
|
136
|
-
role='article'
|
|
137
|
-
data={data}
|
|
138
|
-
limit={1}
|
|
139
|
-
fallback={PlankContentError}
|
|
140
|
-
placeholder={placeholder}
|
|
141
|
-
/>
|
|
142
|
-
</>
|
|
143
|
-
) : (
|
|
144
|
-
<PlankError id={id} part={part} />
|
|
145
|
-
)}
|
|
146
|
-
{canResize && <StackItem.ResizeHandle />}
|
|
147
|
-
</Root>
|
|
148
|
-
);
|
|
149
|
-
});
|
package/src/hooks/useNode.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useEffect, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type Graph, type Node } from '@dxos/plugin-graph';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* React hook to get a node from the graph.
|
|
11
|
-
*
|
|
12
|
-
* @param graph Graph to find the node in.
|
|
13
|
-
* @param id Id of the node to find.
|
|
14
|
-
* @param timeout Optional timeout in milliseconds to wait for the node to be found.
|
|
15
|
-
* @returns Node if found, undefined otherwise.
|
|
16
|
-
*/
|
|
17
|
-
// TODO(wittjosiah): Factor out.
|
|
18
|
-
export const useNode = <T = any>(graph: Graph, id?: string, timeout?: number): Node<T> | undefined => {
|
|
19
|
-
const [nodeState, setNodeState] = useState<Node<T> | undefined>(id ? graph.findNode(id, false) : undefined);
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (!id && nodeState) {
|
|
23
|
-
setNodeState(undefined);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (nodeState?.id === id || !id) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Set timeout did not seem to effectively not block the UI thread.
|
|
31
|
-
const frame = requestAnimationFrame(async () => {
|
|
32
|
-
try {
|
|
33
|
-
const node = await graph.waitForNode(id, timeout);
|
|
34
|
-
if (node) {
|
|
35
|
-
setNodeState(node);
|
|
36
|
-
}
|
|
37
|
-
} catch {
|
|
38
|
-
// TODO(ZaymonFC): This leaves the resolved node in an invalid state in the case of a timeout.
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return () => cancelAnimationFrame(frame);
|
|
43
|
-
}, [graph, id, timeout, nodeState?.id]);
|
|
44
|
-
|
|
45
|
-
return nodeState;
|
|
46
|
-
};
|
/package/dist/lib/browser/{app-graph-builder-IYHAGFA3.mjs.map → app-graph-builder-VYZ4IWI3.mjs.map}
RENAMED
|
File without changes
|
/package/dist/lib/browser/{check-app-scheme-S3EYUPMF.mjs.map → check-app-scheme-SEYECDHI.mjs.map}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|