@dxos/plugin-deck 0.6.14-main.f49f251 → 0.6.14-staging.8758a12
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/chunk-NIRHDTX4.mjs +17 -0
- package/dist/lib/browser/chunk-NIRHDTX4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +59 -91
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types.mjs +11 -0
- package/dist/lib/browser/types.mjs.map +7 -0
- package/dist/types/src/DeckPlugin.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts +4 -2
- package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/DeckLayout.d.ts +3 -2
- package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Plank.d.ts +1 -1
- package/dist/types/src/components/DeckLayout/Plank.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +0 -4
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +13 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +34 -27
- package/src/DeckPlugin.tsx +15 -1
- package/src/components/DeckLayout/ComplementarySidebar.tsx +12 -25
- package/src/components/DeckLayout/DeckLayout.tsx +5 -4
- package/src/components/DeckLayout/Plank.tsx +22 -15
- package/src/components/LayoutSettings.tsx +13 -13
- package/src/translations.ts +0 -6
- package/src/types.ts +15 -0
|
@@ -34,10 +34,12 @@ import { DECK_PLUGIN } from '../../meta';
|
|
|
34
34
|
import { useDeckContext } from '../DeckContext';
|
|
35
35
|
import { useLayout } from '../LayoutContext';
|
|
36
36
|
|
|
37
|
+
const UNKNOWN_ID = 'unknown_id';
|
|
38
|
+
|
|
37
39
|
export type PlankProps = {
|
|
38
|
-
entry
|
|
40
|
+
entry?: LayoutEntry;
|
|
39
41
|
layoutParts: LayoutParts;
|
|
40
|
-
// TODO(wittjosiah): Remove.
|
|
42
|
+
// TODO(wittjosiah): Remove. Pass in LayoutCoordinate instead of LayoutEntry.
|
|
41
43
|
part: LayoutPart;
|
|
42
44
|
layoutMode: Layout['layoutMode'];
|
|
43
45
|
flatDeck?: boolean;
|
|
@@ -47,26 +49,28 @@ export type PlankProps = {
|
|
|
47
49
|
export const Plank = memo(({ entry, layoutParts, part, flatDeck, searchEnabled, layoutMode }: PlankProps) => {
|
|
48
50
|
const { t } = useTranslation(DECK_PLUGIN);
|
|
49
51
|
const dispatch = useIntentDispatcher();
|
|
52
|
+
const coordinate: LayoutCoordinate = useMemo(() => ({ part, entryId: entry?.id ?? UNKNOWN_ID }), [entry?.id, part]);
|
|
50
53
|
const { popoverAnchorId, scrollIntoView } = useLayout();
|
|
51
54
|
const { plankSizing } = useDeckContext();
|
|
52
55
|
const { graph } = useGraph();
|
|
53
|
-
const node = useNode(graph, entry
|
|
56
|
+
const node = useNode(graph, entry?.id);
|
|
54
57
|
const rootElement = useRef<HTMLDivElement | null>(null);
|
|
55
58
|
const resizeable = layoutMode === 'deck';
|
|
56
59
|
|
|
57
|
-
const attendableAttrs = useAttendableAttributes(
|
|
58
|
-
const coordinate: LayoutCoordinate = useMemo(() => ({ part, entryId: entry.id }), [entry.id, part]);
|
|
60
|
+
const attendableAttrs = useAttendableAttributes(coordinate.entryId);
|
|
59
61
|
const index = indexInPart(layoutParts, coordinate);
|
|
60
62
|
const length = partLength(layoutParts, part);
|
|
61
63
|
const canIncrementStart = part === 'main' && index !== undefined && index > 0 && length !== undefined && length > 1;
|
|
62
64
|
const canIncrementEnd = part === 'main' && index !== undefined && index < length - 1 && length !== undefined;
|
|
63
65
|
|
|
64
|
-
const size = plankSizing?.[
|
|
66
|
+
const size = plankSizing?.[coordinate.entryId] as number | undefined;
|
|
65
67
|
const setSize = useCallback(
|
|
66
|
-
debounce(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
debounce(
|
|
69
|
+
(newSize: number) =>
|
|
70
|
+
dispatch({ action: DeckAction.UPDATE_PLANK_SIZE, data: { id: coordinate.entryId, size: newSize } }),
|
|
71
|
+
200,
|
|
72
|
+
),
|
|
73
|
+
[dispatch, coordinate.entryId],
|
|
70
74
|
);
|
|
71
75
|
|
|
72
76
|
// TODO(thure): Tabster’s focus group should handle moving focus to Main, but something is blocking it.
|
|
@@ -77,25 +81,28 @@ export const Plank = memo(({ entry, layoutParts, part, flatDeck, searchEnabled,
|
|
|
77
81
|
}, []);
|
|
78
82
|
|
|
79
83
|
useLayoutEffect(() => {
|
|
80
|
-
if (scrollIntoView ===
|
|
84
|
+
if (scrollIntoView === coordinate.entryId) {
|
|
81
85
|
rootElement.current?.focus({ preventScroll: true });
|
|
82
86
|
layoutMode === 'deck' && rootElement.current?.scrollIntoView({ behavior: 'smooth', inline: 'center' });
|
|
83
87
|
}
|
|
84
|
-
}, [scrollIntoView, layoutMode]);
|
|
88
|
+
}, [coordinate.entryId, scrollIntoView, layoutMode]);
|
|
85
89
|
|
|
86
90
|
const isSolo = layoutMode === 'solo' && part === 'solo';
|
|
87
|
-
const isSuppressed =
|
|
91
|
+
const isSuppressed =
|
|
92
|
+
(layoutMode === 'solo' && part !== 'solo') ||
|
|
93
|
+
(layoutMode === 'deck' && part === 'solo') ||
|
|
94
|
+
coordinate.entryId === UNKNOWN_ID;
|
|
88
95
|
|
|
89
96
|
const sizeAttrs = useMainSize();
|
|
90
97
|
|
|
91
98
|
const data = useMemo(
|
|
92
99
|
() =>
|
|
93
100
|
node && {
|
|
94
|
-
...(entry
|
|
101
|
+
...(entry?.path ? { subject: node.data, path: entry.path } : { object: node.data }),
|
|
95
102
|
coordinate,
|
|
96
103
|
popoverAnchorId,
|
|
97
104
|
},
|
|
98
|
-
[node],
|
|
105
|
+
[node, node?.data, entry?.path, coordinate, popoverAnchorId],
|
|
99
106
|
);
|
|
100
107
|
|
|
101
108
|
// TODO(wittjosiah): Change prop to accept a component.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { Input, Select, useTranslation } from '@dxos/react-ui';
|
|
8
|
-
import {
|
|
8
|
+
import { DeprecatedFormInput } from '@dxos/react-ui-data';
|
|
9
9
|
|
|
10
10
|
import { DECK_PLUGIN } from '../meta';
|
|
11
11
|
import {
|
|
@@ -23,7 +23,7 @@ export const LayoutSettings = ({ settings }: { settings: DeckSettingsProps }) =>
|
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<>
|
|
26
|
-
<
|
|
26
|
+
<DeprecatedFormInput label={t('select new plank positioning label')}>
|
|
27
27
|
<Select.Root
|
|
28
28
|
value={settings.newPlankPositioning ?? 'start'}
|
|
29
29
|
onValueChange={(value) => (settings.newPlankPositioning = value as NewPlankPositioning)}
|
|
@@ -41,8 +41,8 @@ export const LayoutSettings = ({ settings }: { settings: DeckSettingsProps }) =>
|
|
|
41
41
|
</Select.Content>
|
|
42
42
|
</Select.Portal>
|
|
43
43
|
</Select.Root>
|
|
44
|
-
</
|
|
45
|
-
<
|
|
44
|
+
</DeprecatedFormInput>
|
|
45
|
+
<DeprecatedFormInput label={t('settings overscroll label')}>
|
|
46
46
|
<Select.Root
|
|
47
47
|
value={settings.overscroll ?? 'none'}
|
|
48
48
|
onValueChange={(value) => (settings.overscroll = value as Overscroll)}
|
|
@@ -60,24 +60,24 @@ export const LayoutSettings = ({ settings }: { settings: DeckSettingsProps }) =>
|
|
|
60
60
|
</Select.Content>
|
|
61
61
|
</Select.Portal>
|
|
62
62
|
</Select.Root>
|
|
63
|
-
</
|
|
64
|
-
<
|
|
63
|
+
</DeprecatedFormInput>
|
|
64
|
+
<DeprecatedFormInput label={t('settings show hints label')}>
|
|
65
65
|
<Input.Switch checked={settings.showHints} onCheckedChange={(checked) => (settings.showHints = checked)} />
|
|
66
|
-
</
|
|
66
|
+
</DeprecatedFormInput>
|
|
67
67
|
{!isSocket && (
|
|
68
|
-
<
|
|
68
|
+
<DeprecatedFormInput label={t('settings native redirect label')}>
|
|
69
69
|
<Input.Switch
|
|
70
70
|
checked={settings.enableNativeRedirect}
|
|
71
71
|
onCheckedChange={(checked) => (settings.enableNativeRedirect = checked)}
|
|
72
72
|
/>
|
|
73
|
-
</
|
|
73
|
+
</DeprecatedFormInput>
|
|
74
74
|
)}
|
|
75
|
-
<
|
|
75
|
+
<DeprecatedFormInput label={t('settings custom slots')}>
|
|
76
76
|
<Input.Switch checked={settings.customSlots} onCheckedChange={(checked) => (settings.customSlots = checked)} />
|
|
77
|
-
</
|
|
78
|
-
<
|
|
77
|
+
</DeprecatedFormInput>
|
|
78
|
+
<DeprecatedFormInput label={t('settings flat deck')}>
|
|
79
79
|
<Input.Switch checked={settings.flatDeck} onCheckedChange={(checked) => (settings.flatDeck = checked)} />
|
|
80
|
-
</
|
|
80
|
+
</DeprecatedFormInput>
|
|
81
81
|
</>
|
|
82
82
|
);
|
|
83
83
|
};
|
package/src/translations.ts
CHANGED
|
@@ -39,12 +39,6 @@ export default [
|
|
|
39
39
|
'settings overscroll centering label': 'Centering',
|
|
40
40
|
'settings overscroll none label': 'None',
|
|
41
41
|
'settings flat deck': 'Flatten deck appearance',
|
|
42
|
-
|
|
43
|
-
// ComplementarySidebar
|
|
44
|
-
'open settings label': 'Show settings',
|
|
45
|
-
'open comments label': 'Show Comments',
|
|
46
|
-
'open automation label': 'Show Automation',
|
|
47
|
-
'open debug label': 'Show Debug',
|
|
48
42
|
},
|
|
49
43
|
},
|
|
50
44
|
},
|
package/src/types.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
|
+
Plugin,
|
|
6
7
|
GraphBuilderProvides,
|
|
7
8
|
IntentResolverProvides,
|
|
8
9
|
LayoutProvides,
|
|
@@ -11,6 +12,7 @@ import type {
|
|
|
11
12
|
SurfaceProvides,
|
|
12
13
|
TranslationsProvides,
|
|
13
14
|
} from '@dxos/app-framework';
|
|
15
|
+
import { type Label } from '@dxos/react-ui';
|
|
14
16
|
|
|
15
17
|
// TODO(Zan): In the future we should consider adding new planks adjacent to the attended plank.
|
|
16
18
|
export const NewPlankPositions = ['start', 'end'] as const;
|
|
@@ -19,6 +21,19 @@ export type NewPlankPositioning = (typeof NewPlankPositions)[number];
|
|
|
19
21
|
export const OverscrollOptions = ['none', 'centering'] as const;
|
|
20
22
|
export type Overscroll = (typeof OverscrollOptions)[number];
|
|
21
23
|
|
|
24
|
+
// TODO(wittjosiah): Include a predicate for whether the panel is visible for the current subject.
|
|
25
|
+
export type Panel = { id: string; label: Label; icon: string };
|
|
26
|
+
|
|
27
|
+
// TODO(wittjosiah): Is this generic enough to be in the app framework?
|
|
28
|
+
export type PanelProvides = {
|
|
29
|
+
complementary: {
|
|
30
|
+
panels: Panel[];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const parsePanelPlugin = (plugin?: Plugin) =>
|
|
35
|
+
Array.isArray((plugin?.provides as any).complementary?.panels) ? (plugin as Plugin<PanelProvides>) : undefined;
|
|
36
|
+
|
|
22
37
|
export type DeckSettingsProps = {
|
|
23
38
|
showHints: boolean;
|
|
24
39
|
customSlots: boolean;
|