@domicile-desktop/manganese-bar-module-tray 1.1.1 → 1.2.0

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/package.json CHANGED
@@ -1,43 +1,46 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@cprussin/option-result": "^2.0.1",
4
- "@domicile-desktop/component-library": "2.0.1",
5
- "@domicile-desktop/manganese-bar": "1.1.1",
6
- "@domicile-desktop/manganese-host": "2.0.1",
7
- "@domicile-desktop/manganese-page-requests": "1.1.1",
8
- "@domicile-desktop/react": "0.1.1",
9
- "@domicile-desktop/sdk": "2.1.0",
10
- "@domicile-desktop/system-apps": "1.1.1",
11
- "@pandacss/dev": "^1.12.1",
12
- "react": "^19.2.8",
13
- "zod": "^4.5.4"
4
+ "@domicile-desktop/component-library": "2.2.0",
5
+ "@domicile-desktop/manganese-bar": "1.1.3",
6
+ "@domicile-desktop/manganese-host": "2.0.3",
7
+ "@domicile-desktop/manganese-page-requests": "1.3.0",
8
+ "@domicile-desktop/react": "0.2.0",
9
+ "@domicile-desktop/sdk": "3.0.0",
10
+ "@domicile-desktop/system-apps": "1.3.0",
11
+ "@pandacss/dev": "^1.12.2",
12
+ "@phosphor-icons/react": "^2.1.10",
13
+ "react": "^19.3.1",
14
+ "zod": "^4.6.7"
14
15
  },
15
16
  "description": "A manganese bar item: the system tray: apps' StatusNotifierItems and extension actions.",
16
17
  "devDependencies": {
17
18
  "@cprussin/tsconfig": "^5.0.0",
18
19
  "@domicile-desktop/test-support": "0.0.2",
19
- "@pandacss/preset-panda": "^1.12.1",
20
+ "@pandacss/preset-panda": "^1.12.2",
20
21
  "@testing-library/react": "^16.3.3",
21
- "@testing-library/user-event": "^14.6.7",
22
- "@types/bun": "^1.4.2",
23
- "@types/react": "^19.2.18",
24
- "@types/react-dom": "^19.2.7",
25
- "postcss": "^8.5.28",
22
+ "@testing-library/user-event": "^14.6.10",
23
+ "@types/bun": "^1.4.4",
24
+ "@types/react": "^19.3.0",
25
+ "@types/react-dom": "^19.3.0",
26
+ "postcss": "^8.5.32",
26
27
  "typescript": "^7.0.2"
27
28
  },
28
29
  "engines": {
29
- "bun": ">=1.4.2",
30
- "node": ">=24"
30
+ "bun": ">=1.4.2"
31
31
  },
32
32
  "exports": {
33
33
  ".": "./src/bar-item.tsx",
34
34
  "./extensions/shown": "./src/extensions/shown.ts",
35
35
  "./extensions/useExtensions": "./src/extensions/useExtensions.ts",
36
+ "./extensions/useFocusedProfile": "./src/extensions/useFocusedProfile.ts",
37
+ "./extensions/useInstalledExtensions": "./src/extensions/useInstalledExtensions.ts",
36
38
  "./extensions/useOpenedPopup": "./src/extensions/useOpenedPopup.ts",
37
39
  "./tray-context": "./src/tray-context.ts",
38
40
  "./tray-entry": "./src/tray-entry.ts",
39
41
  "./useTray": "./src/useTray.ts",
40
- "./useTrayOrder": "./src/useTrayOrder.ts"
42
+ "./useTrayOrder": "./src/useTrayOrder.ts",
43
+ "./useTrayPins": "./src/useTrayPins.ts"
41
44
  },
42
45
  "files": [
43
46
  "src/**",
@@ -62,5 +65,5 @@
62
65
  "test:unit": "bun test"
63
66
  },
64
67
  "type": "module",
65
- "version": "1.1.1"
68
+ "version": "1.2.0"
66
69
  }
package/src/Tray.tsx CHANGED
@@ -4,6 +4,7 @@ import type {
4
4
  ExtensionPopup,
5
5
  } from "@domicile-desktop/sdk/extension";
6
6
  import type { TrayItem } from "@domicile-desktop/sdk/tray";
7
+ import type { ReactNode } from "react";
7
8
  import { useEffect, useRef, useState } from "react";
8
9
 
9
10
  import { css } from "../styled-system/css";
@@ -33,6 +34,12 @@ type Props = {
33
34
  opened: ExtensionPopup | undefined;
34
35
  /** The user's icon order; see `useTrayOrder`. */
35
36
  order: readonly string[];
37
+ /** After the icons: the button for the menu of every icon. */
38
+ end?: ReactNode | undefined;
39
+ /** An icon was dragged onto `end`: keep icon `key` out of the tray. */
40
+ onUnpin?: ((key: string) => void) | undefined;
41
+ /** The keys of the icons kept out of the tray; see `useTrayPins`. */
42
+ unpinned?: ReadonlySet<string> | undefined;
36
43
  };
37
44
 
38
45
  /**
@@ -48,18 +55,30 @@ type Props = {
48
55
  *
49
56
  * Disabled actions are hidden. The state is each action's default, not the
50
57
  * focused tab's; see docs/architecture/EXTENSIONS.md.
58
+ *
59
+ * Unpinned icons are left out, except an extension whose popup is open, which
60
+ * shows while it is so the popup hangs from it. An icon dragged onto `end` is
61
+ * unpinned.
51
62
  */
52
63
  export const Tray = ({
53
64
  domicile,
65
+ end,
54
66
  extensions,
55
67
  items,
56
68
  onMove,
57
69
  onActivate,
58
70
  onOpen,
71
+ onUnpin = () => undefined,
59
72
  opened,
60
73
  order,
74
+ unpinned = new Set(),
61
75
  }: Props) => {
62
- const entries = trayEntries(items, extensions, order);
76
+ const entries = trayEntries(items, extensions, order).filter(
77
+ (entry) =>
78
+ !unpinned.has(entry.key) ||
79
+ (entry.kind === TrayEntryKind.Extension &&
80
+ opened?.id === entry.extension.id),
81
+ );
63
82
  const shown = entries.map(({ key }) => key);
64
83
 
65
84
  // The key of the icon being dragged while the button is down.
@@ -94,6 +113,11 @@ export const Tray = ({
94
113
  event.stopPropagation();
95
114
  }
96
115
  }}
116
+ // Any press starts afresh, the menu's button's too, so a drag
117
+ // suppresses only its own release's click.
118
+ onPointerDownCapture={() => {
119
+ moved.current = false;
120
+ }}
97
121
  >
98
122
  {entries.map((entry) => (
99
123
  <div
@@ -101,7 +125,6 @@ export const Tray = ({
101
125
  key={entry.key}
102
126
  onPointerDown={(event) => {
103
127
  if (event.button === PRIMARY_BUTTON) {
104
- moved.current = false;
105
128
  setDragged(entry.key);
106
129
  }
107
130
  }}
@@ -121,6 +144,23 @@ export const Tray = ({
121
144
  />
122
145
  </div>
123
146
  ))}
147
+ {end !== undefined && (
148
+ <div
149
+ className={entryStyles}
150
+ onPointerOver={() => {
151
+ if (dragged !== undefined) {
152
+ moved.current = true;
153
+ }
154
+ }}
155
+ onPointerUp={() => {
156
+ if (dragged !== undefined) {
157
+ onUnpin(dragged);
158
+ }
159
+ }}
160
+ >
161
+ {end}
162
+ </div>
163
+ )}
124
164
  </div>
125
165
  );
126
166
  };
package/src/TrayIcon.tsx CHANGED
@@ -1,17 +1,12 @@
1
1
  import { Button } from "@domicile-desktop/component-library/Button";
2
- import type { Point } from "@domicile-desktop/component-library/ContextMenu";
3
- import { watchMenu } from "@domicile-desktop/sdk/dbusmenu";
2
+ import type { watchMenu } from "@domicile-desktop/sdk/dbusmenu";
4
3
  import type { Domicile } from "@domicile-desktop/sdk/desktop/desktop";
5
4
  import type { TrayItem } from "@domicile-desktop/sdk/tray";
6
- import { useState } from "react";
7
5
 
8
6
  import { css } from "../styled-system/css";
9
7
  import { center } from "../styled-system/patterns";
10
8
  import type { MenuIcons } from "./menu-icons";
11
- import { desktopMenuIcons } from "./menu-icons";
12
- import { TrayMenu } from "./TrayMenu";
13
- import { useMenuIcons } from "./useMenuIcons";
14
- import { useTrayMenu } from "./useTrayMenu";
9
+ import { useItemMenu } from "./useItemMenu";
15
10
 
16
11
  /** The middle button, as `MouseEvent.button` numbers it. */
17
12
  const MIDDLE_BUTTON = 1;
@@ -39,23 +34,12 @@ type Props = {
39
34
  * An icon without an image shows the first letter of its title, so it can still
40
35
  * be clicked.
41
36
  */
42
- export const TrayIcon = ({
43
- domicile,
44
- icons = desktopMenuIcons,
45
- item: { bus, icon, id, itemIsMenu, menu, title },
46
- watch = watchMenu,
47
- }: Props) => {
48
- // Where the open menu hangs from, or `undefined` while it is closed.
49
- const [at, setAt] = useState<Point | undefined>(undefined);
50
- const opened = useTrayMenu(domicile, bus, menu, at !== undefined, watch);
51
- const pictures = useMenuIcons(domicile, opened?.menu, icons);
37
+ export const TrayIcon = ({ domicile, icons, item, watch }: Props) => {
38
+ const { icon, id, itemIsMenu, title } = item;
39
+ const menu = useItemMenu(domicile, item, watch, icons);
52
40
  const showMenu = (button: HTMLElement) => {
53
- if (menu === undefined) {
54
- domicile.tray.activate(id, "context");
55
- } else {
56
- const box = button.getBoundingClientRect();
57
- setAt({ x: box.left, y: box.bottom });
58
- }
41
+ const box = button.getBoundingClientRect();
42
+ menu.show({ x: box.left, y: box.bottom });
59
43
  };
60
44
  return (
61
45
  <>
@@ -92,19 +76,7 @@ export const TrayIcon = ({
92
76
  />
93
77
  )}
94
78
  </Button>
95
- {at !== undefined && opened !== undefined && (
96
- <TrayMenu
97
- at={at}
98
- icons={pictures}
99
- label={title}
100
- menu={opened.menu}
101
- onClick={opened.click}
102
- onClose={() => {
103
- setAt(undefined);
104
- }}
105
- onShow={opened.aboutToShow}
106
- />
107
- )}
79
+ {menu.opened}
108
80
  </>
109
81
  );
110
82
  };