@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
package/lib/Logout.svelte
CHANGED
package/lib/TopBarContent.svelte
CHANGED
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
children?: Snippet;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
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
|
|
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
|
|
39
|
+
stack.push(props);
|
|
40
|
+
current = props;
|
|
38
41
|
onDestroy(() => {
|
|
39
|
-
stack
|
|
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
|
|
25
|
-
* the available actions or their labels depend on state that changes after the menu is attached
|
|
26
|
-
*
|
|
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(
|
|
83
|
+
build(entries);
|
|
85
84
|
}
|
|
86
85
|
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
|
|
87
89
|
menu.showPopover();
|
|
88
90
|
_forcePopover = true;
|
|
89
91
|
|