@axium/client 0.44.1 → 0.44.3

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/lib/Icon.svelte CHANGED
@@ -15,6 +15,7 @@
15
15
  width: var(--size, 1em);
16
16
  height: var(--size, 1em);
17
17
  display: inline-block;
18
+ flex-shrink: 0;
18
19
  fill: var(--fill, hsl(var(--hue) 0 var(--fg-light)));
19
20
  user-select: none;
20
21
  }
package/lib/Logout.svelte CHANGED
@@ -19,7 +19,9 @@
19
19
  onclick={e => {
20
20
  e.preventDefault();
21
21
  history.back();
22
- }}>{text('Logout.back')}</button
22
+ }}
23
23
  >
24
+ {text('Logout.back')}
25
+ </button>
24
26
  {/if}
25
27
  </FormDialog>
@@ -12,12 +12,14 @@
12
12
  children?: Snippet;
13
13
  }
14
14
 
15
- let stack = $state.raw<TopBarContentProps[]>([]);
15
+ /** Mounted contents, oldest first. */
16
+ const stack: TopBarContentProps[] = [];
17
+ let current = $state.raw<TopBarContentProps>();
16
18
  let middle = $state<HTMLElement>();
17
19
 
18
20
  /** The content registered by the most recently mounted `TopBarContent`. */
19
21
  export function currentContent(): TopBarContentProps | undefined {
20
- return stack.at(-1);
22
+ return current;
21
23
  }
22
24
 
23
25
  /** Marks the element in the top bar that the current content's children are moved into. */
@@ -34,9 +36,11 @@
34
36
 
35
37
  const props: TopBarContentProps = $props();
36
38
 
37
- stack = [...stack, props];
39
+ stack.push(props);
40
+ current = props;
38
41
  onDestroy(() => {
39
- stack = stack.filter(entry => entry !== props);
42
+ stack.splice(stack.indexOf(props), 1);
43
+ current = stack.at(-1);
40
44
  });
41
45
 
42
46
  const moveToTopBar: Attachment<HTMLElement> = element => {
@@ -21,9 +21,9 @@ export type ContextMenuEntry = ContextMenuItem | ContextMenuHeader | false | nul
21
21
  /**
22
22
  * Attach a context menu to an element with the given actions.
23
23
  *
24
- * Pass a function instead of a fixed list to have the menu rebuilt every time it opens — useful when
25
- * the available actions or their labels depend on state that changes after the menu is attached (e.g. a
26
- * selection).
24
+ * Pass a function instead of a fixed list to have the menu rebuilt every time it opens.
25
+ * Useful when the available actions or their labels depend on state that changes after the menu is attached.
26
+ * When the function returns no entries, the browser's own menu is shown instead.
27
27
  */
28
28
  export function contextMenu(...menuItems: ContextMenuEntry[] | [() => ContextMenuEntry[]]): Attachment<HTMLElement> {
29
29
  return function _attachContextMenu(element: HTMLElement) {
@@ -74,16 +74,18 @@ export function contextMenu(...menuItems: ContextMenuEntry[] | [() => ContextMen
74
74
  if (node instanceof HTMLDialogElement || (node.popover && node !== menu)) return;
75
75
  }
76
76
 
77
- e.preventDefault();
78
- e.stopPropagation();
79
-
80
77
  if (typeof menuItems[0] == 'function') {
78
+ const entries = menuItems[0]();
79
+ if (!entries.some(Boolean)) return;
81
80
  for (const icon of mountedIcons) unmount(icon);
82
81
  mountedIcons.clear();
83
82
  menu.replaceChildren();
84
- build(menuItems[0]());
83
+ build(entries);
85
84
  }
86
85
 
86
+ e.preventDefault();
87
+ e.stopPropagation();
88
+
87
89
  menu.showPopover();
88
90
  _forcePopover = true;
89
91
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/client",
3
- "version": "0.44.1",
3
+ "version": "0.44.3",
4
4
  "author": "James Prevett <jp@jamespre.dev>",
5
5
  "funding": {
6
6
  "type": "individual",