@dxos/plugin-deck 0.6.12-main.15a606f → 0.6.12-main.2d19bf1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/lib/browser/{chunk-YVHGFQQR.mjs → chunk-GVOGPULO.mjs} +1 -1
  2. package/dist/lib/browser/chunk-GVOGPULO.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +145 -85
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/meta.mjs +1 -1
  7. package/dist/types/src/DeckPlugin.d.ts.map +1 -1
  8. package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts +1 -1
  9. package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts.map +1 -1
  10. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts +3 -4
  11. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
  12. package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts +4 -3
  13. package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts.map +1 -1
  14. package/dist/types/src/components/DeckLayout/Sidebar.d.ts +2 -3
  15. package/dist/types/src/components/DeckLayout/Sidebar.d.ts.map +1 -1
  16. package/dist/types/src/components/DeckLayout/StatusBar.d.ts +3 -1
  17. package/dist/types/src/components/DeckLayout/StatusBar.d.ts.map +1 -1
  18. package/dist/types/src/components/LayoutSettings.d.ts.map +1 -1
  19. package/dist/types/src/meta.d.ts.map +1 -1
  20. package/dist/types/src/translations.d.ts +3 -1
  21. package/dist/types/src/translations.d.ts.map +1 -1
  22. package/dist/types/src/types.d.ts +1 -1
  23. package/dist/types/src/types.d.ts.map +1 -1
  24. package/package.json +26 -26
  25. package/src/DeckPlugin.tsx +23 -28
  26. package/src/components/DeckLayout/ComplementarySidebar.tsx +59 -10
  27. package/src/components/DeckLayout/DeckLayout.tsx +9 -18
  28. package/src/components/DeckLayout/NodePlankHeading.tsx +10 -7
  29. package/src/components/DeckLayout/Plank.tsx +2 -2
  30. package/src/components/DeckLayout/Sidebar.tsx +6 -5
  31. package/src/components/DeckLayout/StatusBar.tsx +10 -2
  32. package/src/components/LayoutSettings.tsx +5 -8
  33. package/src/meta.ts +3 -1
  34. package/src/translations.ts +3 -1
  35. package/src/types.ts +1 -1
  36. package/dist/lib/browser/chunk-YVHGFQQR.mjs.map +0 -7
@@ -2,12 +2,18 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import React from 'react';
5
+ import React, { useMemo } from 'react';
6
6
 
7
- import { type LayoutParts, SLUG_PATH_SEPARATOR, Surface } from '@dxos/app-framework';
7
+ import {
8
+ type LayoutParts,
9
+ NavigationAction,
10
+ SLUG_PATH_SEPARATOR,
11
+ Surface,
12
+ useIntentDispatcher,
13
+ } from '@dxos/app-framework';
8
14
  import { useGraph } from '@dxos/plugin-graph';
9
15
  import { Main } from '@dxos/react-ui';
10
- import { createAttendableAttributes, useAttendedIds } from '@dxos/react-ui-attention';
16
+ import { useAttended } from '@dxos/react-ui-attention';
11
17
  import { deckGrid } from '@dxos/react-ui-deck';
12
18
  import { mx } from '@dxos/react-ui-theme';
13
19
 
@@ -15,6 +21,7 @@ import { NodePlankHeading } from './NodePlankHeading';
15
21
  import { PlankContentError } from './PlankError';
16
22
  import { PlankLoading } from './PlankLoading';
17
23
  import { useNode, useNodeActionExpander } from '../../hooks';
24
+ import { DECK_PLUGIN } from '../../meta';
18
25
  import { useLayout } from '../LayoutContext';
19
26
 
20
27
  export type ComplementarySidebarProps = {
@@ -23,18 +30,59 @@ export type ComplementarySidebarProps = {
23
30
  flatDeck?: boolean;
24
31
  };
25
32
 
26
- export const ComplementarySidebar = ({ context, layoutParts, flatDeck }: ComplementarySidebarProps) => {
33
+ const panels = ['comments', 'settings'] as const;
34
+ type Panel = (typeof panels)[number];
35
+ const getPanel = (part?: string): Panel => {
36
+ if (part && panels.findIndex((panel) => panel === part) !== -1) {
37
+ return part as Panel;
38
+ } else {
39
+ return 'settings';
40
+ }
41
+ };
42
+
43
+ export const ComplementarySidebar = ({ layoutParts, flatDeck }: ComplementarySidebarProps) => {
27
44
  const { popoverAnchorId } = useLayout();
28
- const attended = useAttendedIds();
29
- const id = attended[0] ? `${attended[0]}${SLUG_PATH_SEPARATOR}${context}` : undefined;
45
+ const attended = useAttended();
46
+ const part = getPanel(layoutParts.complementary?.[0].id);
47
+ const id = attended[0] ? `${attended[0]}${SLUG_PATH_SEPARATOR}${part}` : undefined;
30
48
  const { graph } = useGraph();
31
49
  const node = useNode(graph, id);
32
- const complementaryAttrs = createAttendableAttributes(id?.split(SLUG_PATH_SEPARATOR)[0] ?? 'never');
50
+ const dispatch = useIntentDispatcher();
33
51
 
34
52
  useNodeActionExpander(node);
35
53
 
54
+ const actions = useMemo(
55
+ () => [
56
+ {
57
+ id: 'complementary-settings',
58
+ data: () => {
59
+ void dispatch({ action: NavigationAction.OPEN, data: { activeParts: { complementary: 'settings' } } });
60
+ },
61
+ properties: {
62
+ label: ['settings label', { ns: DECK_PLUGIN }],
63
+ icon: 'ph--gear--regular',
64
+ menuItemType: 'toggle',
65
+ isChecked: part === 'settings',
66
+ },
67
+ },
68
+ {
69
+ id: 'complementary-comments',
70
+ data: () => {
71
+ void dispatch({ action: NavigationAction.OPEN, data: { activeParts: { complementary: 'comments' } } });
72
+ },
73
+ properties: {
74
+ label: ['comments label', { ns: DECK_PLUGIN }],
75
+ icon: 'ph--chat-text--regular',
76
+ menuItemType: 'toggle',
77
+ isChecked: part === 'comments',
78
+ },
79
+ },
80
+ ],
81
+ [part],
82
+ );
83
+
36
84
  return (
37
- <Main.ComplementarySidebar {...complementaryAttrs}>
85
+ <Main.ComplementarySidebar>
38
86
  <div role='none' className={mx(deckGrid, 'grid-cols-1 bs-full')}>
39
87
  <NodePlankHeading
40
88
  node={node}
@@ -43,12 +91,13 @@ export const ComplementarySidebar = ({ context, layoutParts, flatDeck }: Complem
43
91
  layoutPart='complementary'
44
92
  popoverAnchorId={popoverAnchorId}
45
93
  flatDeck={flatDeck}
94
+ actions={actions}
46
95
  />
47
96
  {/* TODO(wittjosiah): Render some placeholder when node is undefined. */}
48
97
  {node && (
49
98
  <Surface
50
- role='article'
51
- data={{ subject: node.data, part: 'complementary', popoverAnchorId }}
99
+ role={`complementary--${part}`}
100
+ data={{ subject: node.properties.object, popoverAnchorId }}
52
101
  limit={1}
53
102
  fallback={PlankContentError}
54
103
  placeholder={<PlankLoading />}
@@ -6,7 +6,6 @@ import { Sidebar as MenuIcon } from '@phosphor-icons/react';
6
6
  import React, { useCallback, useEffect, useMemo, useRef, type UIEvent } from 'react';
7
7
 
8
8
  import {
9
- type Attention,
10
9
  type LayoutEntry,
11
10
  type LayoutParts,
12
11
  Surface,
@@ -15,6 +14,7 @@ import {
15
14
  usePlugin,
16
15
  } from '@dxos/app-framework';
17
16
  import { Button, Dialog, Main, Popover, useOnTransition, useTranslation } from '@dxos/react-ui';
17
+ import { useAttended } from '@dxos/react-ui-attention';
18
18
  import { Deck } from '@dxos/react-ui-deck';
19
19
  import { getSize } from '@dxos/react-ui-theme';
20
20
 
@@ -34,11 +34,10 @@ import { useLayout } from '../LayoutContext';
34
34
 
35
35
  export type DeckLayoutProps = {
36
36
  layoutParts: LayoutParts;
37
- attention: Attention;
38
37
  toasts: ToastSchema[];
39
38
  flatDeck?: boolean;
40
39
  overscroll: Overscroll;
41
- showHintsFooter: boolean;
40
+ showHints: boolean;
42
41
  slots?: {
43
42
  wallpaper?: { classNames?: string };
44
43
  };
@@ -47,11 +46,10 @@ export type DeckLayoutProps = {
47
46
 
48
47
  export const DeckLayout = ({
49
48
  layoutParts,
50
- attention,
51
49
  toasts,
52
50
  flatDeck,
53
51
  overscroll,
54
- showHintsFooter,
52
+ showHints,
55
53
  slots,
56
54
  onDismissToast,
57
55
  }: DeckLayoutProps) => {
@@ -69,6 +67,7 @@ export const DeckLayout = ({
69
67
  } = context;
70
68
  const { t } = useTranslation(DECK_PLUGIN);
71
69
  const { plankSizing } = useDeckContext();
70
+ const attended = useAttended();
72
71
  const searchPlugin = usePlugin('dxos.org/plugin/search');
73
72
  const fullScreenSlug = useMemo(() => firstIdInPart(layoutParts, 'fullScreen'), [layoutParts]);
74
73
 
@@ -78,7 +77,7 @@ export const DeckLayout = ({
78
77
  // Ensure the first plank is attended when the deck is first rendered.
79
78
  useEffect(() => {
80
79
  const firstId = layoutMode === 'solo' ? firstIdInPart(layoutParts, 'solo') : firstIdInPart(layoutParts, 'main');
81
- if (attention.attended.size === 0 && firstId) {
80
+ if (attended.length === 0 && firstId) {
82
81
  // TODO(wittjosiah): Focusing the type button is a workaround.
83
82
  // If the plank is directly focused on first load the focus ring appears.
84
83
  document.querySelector<HTMLElement>(`article[data-attendable-id="${firstId}"] button`)?.focus();
@@ -117,8 +116,7 @@ export const DeckLayout = ({
117
116
  [layoutMode],
118
117
  );
119
118
 
120
- const firstAttendedId = useMemo(() => Array.from(attention.attended ?? [])[0], [attention.attended]);
121
-
119
+ const firstAttendedId = attended[0];
122
120
  useEffect(() => {
123
121
  // TODO(burdon): Can we prevent the need to re-scroll since the planks are preserved?
124
122
  // E.g., hide the deck and just move the solo article?
@@ -193,7 +191,7 @@ export const DeckLayout = ({
193
191
  </Main.Notch>
194
192
 
195
193
  {/* Left sidebar. */}
196
- <Sidebar attention={attention} layoutParts={layoutParts} />
194
+ <Sidebar layoutParts={layoutParts} />
197
195
 
198
196
  {/* Right sidebar. */}
199
197
  {/* TODO(wittjosiah): Get context from layout parts. */}
@@ -236,15 +234,8 @@ export const DeckLayout = ({
236
234
  </Main.Content>
237
235
  )}
238
236
 
239
- <StatusBar />
240
-
241
- {/* Help hints. */}
242
- {/* TODO(burdon): Need to make room for this in status bar. */}
243
- {showHintsFooter && (
244
- <div className='fixed bottom-0 left-0 right-0 h-[32px] z-[1] flex justify-center'>
245
- <Surface role='hints' limit={1} />
246
- </div>
247
- )}
237
+ {/* Footer status. */}
238
+ <StatusBar showHints={showHints} />
248
239
 
249
240
  {/* Global popovers. */}
250
241
  <Popover.Portal>
@@ -14,11 +14,10 @@ import {
14
14
  partLength,
15
15
  type LayoutParts,
16
16
  type LayoutPart,
17
- type LayoutEntry,
18
17
  } from '@dxos/app-framework';
19
18
  import { type Node, useGraph } from '@dxos/plugin-graph';
20
19
  import { Icon, Popover, toLocalizedString, useMediaQuery, useTranslation } from '@dxos/react-ui';
21
- import { PlankHeading } from '@dxos/react-ui-deck';
20
+ import { PlankHeading, type PlankHeadingAction } from '@dxos/react-ui-deck';
22
21
  import { TextTooltip } from '@dxos/react-ui-text-tooltip';
23
22
 
24
23
  import { DECK_PLUGIN } from '../../meta';
@@ -28,20 +27,19 @@ export const NodePlankHeading = ({
28
27
  id,
29
28
  layoutParts,
30
29
  layoutPart,
31
- // TODO(wittjosiah): Unused?
32
- layoutEntry,
33
30
  popoverAnchorId,
34
31
  pending,
35
32
  flatDeck,
33
+ actions = [],
36
34
  }: {
37
35
  node?: Node;
38
36
  id?: string;
39
37
  layoutParts?: LayoutParts;
40
38
  layoutPart?: LayoutPart;
41
- layoutEntry?: LayoutEntry;
42
39
  popoverAnchorId?: string;
43
40
  pending?: boolean;
44
41
  flatDeck?: boolean;
42
+ actions?: PlankHeadingAction[];
45
43
  }) => {
46
44
  const { t } = useTranslation(DECK_PLUGIN);
47
45
  const { graph } = useGraph();
@@ -79,9 +77,10 @@ export const NodePlankHeading = ({
79
77
  {node ? (
80
78
  <PlankHeading.ActionsMenu
81
79
  icon={icon}
80
+ related={layoutPart === 'complementary'}
82
81
  attendableId={attendableId}
83
82
  triggerLabel={t('actions menu label')}
84
- actions={graph.actions(node)}
83
+ actions={[actions, graph.actions(node)].filter((a) => a.length > 0)}
85
84
  onAction={(action) =>
86
85
  typeof action.data === 'function' && action.data?.({ node: action as Node, caller: DECK_PLUGIN })
87
86
  }
@@ -96,7 +95,11 @@ export const NodePlankHeading = ({
96
95
  )}
97
96
  </ActionRoot>
98
97
  <TextTooltip text={label} onlyWhenTruncating>
99
- <PlankHeading.Label attendableId={node?.id} {...(pending && { classNames: 'text-description' })}>
98
+ <PlankHeading.Label
99
+ attendableId={attendableId}
100
+ related={layoutPart === 'complementary'}
101
+ {...(pending && { classNames: 'text-description' })}
102
+ >
100
103
  {label}
101
104
  </PlankHeading.Label>
102
105
  </TextTooltip>
@@ -19,7 +19,7 @@ import {
19
19
  import { debounce } from '@dxos/async';
20
20
  import { useGraph } from '@dxos/plugin-graph';
21
21
  import { Button, Tooltip, useTranslation } from '@dxos/react-ui';
22
- import { createAttendableAttributes } from '@dxos/react-ui-attention';
22
+ import { useAttendableAttributes } from '@dxos/react-ui-attention';
23
23
  import { Plank as NaturalPlank } from '@dxos/react-ui-deck';
24
24
  import { mainIntrinsicSize } from '@dxos/react-ui-theme';
25
25
 
@@ -52,7 +52,7 @@ export const Plank = ({ entry, layoutParts, part, flatDeck, searchEnabled, layou
52
52
  const rootElement = useRef<HTMLDivElement | null>(null);
53
53
  const resizeable = layoutMode === 'deck';
54
54
 
55
- const attendableAttrs = createAttendableAttributes(entry.id);
55
+ const attendableAttrs = useAttendableAttributes(entry.id);
56
56
  const coordinate: LayoutCoordinate = { part, entryId: entry.id };
57
57
 
58
58
  const size = plankSizing?.[entry.id] as number | undefined;
@@ -4,18 +4,19 @@
4
4
 
5
5
  import React, { useMemo } from 'react';
6
6
 
7
- import { type Attention, type LayoutParts, openIds, Surface } from '@dxos/app-framework';
7
+ import { type LayoutParts, openIds, Surface } from '@dxos/app-framework';
8
8
  import { Main } from '@dxos/react-ui';
9
+ import { useAttended } from '@dxos/react-ui-attention';
9
10
 
10
11
  import { useLayout } from '../LayoutContext';
11
12
 
12
13
  export type SidebarProps = {
13
- attention: Attention;
14
14
  layoutParts: LayoutParts;
15
15
  };
16
16
 
17
- export const Sidebar = ({ attention, layoutParts }: SidebarProps) => {
17
+ export const Sidebar = ({ layoutParts }: SidebarProps) => {
18
18
  const { layoutMode, popoverAnchorId } = useLayout();
19
+ const attended = useAttended();
19
20
 
20
21
  const activeIds = useMemo(() => {
21
22
  if (layoutMode === 'solo') {
@@ -31,9 +32,9 @@ export const Sidebar = ({ attention, layoutParts }: SidebarProps) => {
31
32
  () => ({
32
33
  popoverAnchorId,
33
34
  activeIds,
34
- attended: attention.attended,
35
+ attended,
35
36
  }),
36
- [popoverAnchorId, activeIds, attention.attended],
37
+ [popoverAnchorId, activeIds, attended],
37
38
  );
38
39
  return (
39
40
  <Main.NavigationSidebar>
@@ -9,10 +9,18 @@ import { mainPadding, mx } from '@dxos/react-ui-theme';
9
9
 
10
10
  import { useMainSize } from '../../hooks';
11
11
 
12
- export const StatusBar = () => {
12
+ export const StatusBar = ({ showHints }: { showHints?: boolean }) => {
13
13
  const sizeAttrs = useMainSize();
14
14
  return (
15
- <div role='none' {...sizeAttrs} className={mx('fixed block-end-0 inset-inline-0 z-[2]', mainPadding)}>
15
+ <div
16
+ role='none'
17
+ {...sizeAttrs}
18
+ className={mx(
19
+ 'fixed flex justify-between block-end-0 inset-inline-0 items-center border-bs border-separator z-[2]',
20
+ mainPadding,
21
+ )}
22
+ >
23
+ <div role='none'>{showHints && <Surface role='hints' limit={1} />}</div>
16
24
  <Surface role='status-bar' limit={1} />
17
25
  </div>
18
26
  );
@@ -61,25 +61,22 @@ export const LayoutSettings = ({ settings }: { settings: DeckSettingsProps }) =>
61
61
  </Select.Portal>
62
62
  </Select.Root>
63
63
  </SettingsValue>
64
- <SettingsValue label={t('settings show footer label')}>
65
- <Input.Switch checked={settings.showFooter} onCheckedChange={(checked) => (settings.showFooter = !!checked)} />
64
+ <SettingsValue label={t('settings show hints label')}>
65
+ <Input.Switch checked={settings.showHints} onCheckedChange={(checked) => (settings.showHints = checked)} />
66
66
  </SettingsValue>
67
67
  {!isSocket && (
68
68
  <SettingsValue label={t('settings native redirect label')}>
69
69
  <Input.Switch
70
70
  checked={settings.enableNativeRedirect}
71
- onCheckedChange={(checked) => (settings.enableNativeRedirect = !!checked)}
71
+ onCheckedChange={(checked) => (settings.enableNativeRedirect = checked)}
72
72
  />
73
73
  </SettingsValue>
74
74
  )}
75
75
  <SettingsValue label={t('settings custom slots')}>
76
- <Input.Switch
77
- checked={settings.customSlots}
78
- onCheckedChange={(checked) => (settings.customSlots = !!checked)}
79
- />
76
+ <Input.Switch checked={settings.customSlots} onCheckedChange={(checked) => (settings.customSlots = checked)} />
80
77
  </SettingsValue>
81
78
  <SettingsValue label={t('settings flat deck')}>
82
- <Input.Switch checked={settings.flatDeck} onCheckedChange={(checked) => (settings.flatDeck = !!checked)} />
79
+ <Input.Switch checked={settings.flatDeck} onCheckedChange={(checked) => (settings.flatDeck = checked)} />
83
80
  </SettingsValue>
84
81
  </>
85
82
  );
package/src/meta.ts CHANGED
@@ -2,9 +2,11 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ import { type PluginMeta } from '@dxos/app-framework';
6
+
5
7
  export const DECK_PLUGIN = 'dxos.org/plugin/deck';
6
8
 
7
9
  export default {
8
10
  id: DECK_PLUGIN,
9
11
  name: 'Deck',
10
- };
12
+ } satisfies PluginMeta;
@@ -16,7 +16,7 @@ export default [
16
16
  'content fallback description':
17
17
  'No plugin had a response for the address you navigated to. Double-check the URL, and ensure you’ve enabled a plugin that supports the object.',
18
18
  'toggle fullscreen label': 'Toggle fullscreen',
19
- 'settings show footer label': 'Show footer (experimental)',
19
+ 'settings show hints label': 'Show hints',
20
20
  'settings native redirect label': 'Enable native url redirect (experimental)',
21
21
  'settings custom slots': 'Theme option (experimental)',
22
22
  'settings new plank position start label': 'Start',
@@ -41,6 +41,8 @@ export default [
41
41
  'settings overscroll centering label': 'Centering',
42
42
  'settings overscroll none label': 'None',
43
43
  'settings flat deck': 'Flatten deck appearance',
44
+ 'comments label': 'Show Comments',
45
+ 'settings label': 'Show Settings',
44
46
  },
45
47
  },
46
48
  },
package/src/types.ts CHANGED
@@ -20,7 +20,7 @@ export const OverscrollOptions = ['none', 'centering'] as const;
20
20
  export type Overscroll = (typeof OverscrollOptions)[number];
21
21
 
22
22
  export type DeckSettingsProps = {
23
- showFooter: boolean;
23
+ showHints: boolean;
24
24
  customSlots: boolean;
25
25
  flatDeck: boolean;
26
26
  enableNativeRedirect: boolean;
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport const DECK_PLUGIN = 'dxos.org/plugin/deck';\n\nexport default {\n id: DECK_PLUGIN,\n name: 'Deck',\n};\n"],
5
- "mappings": ";AAIO,IAAMA,cAAc;AAE3B,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;",
6
- "names": ["DECK_PLUGIN", "id", "name"]
7
- }