@svadmin/ui 0.22.0 → 0.22.1

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/ui",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "description": "Pre-built admin UI components — AdminApp, AutoTable, AutoForm, Sidebar, Layout",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { cn, type WithElementRef } from "../../../utils.js";
3
3
  import type { HTMLAttributes } from "svelte/elements";
4
+ import { getContext } from "svelte";
4
5
 
5
6
  type Props = WithElementRef<HTMLAttributes<HTMLDivElement>> & {
6
7
  align?: "start" | "center" | "end";
@@ -13,8 +14,11 @@
13
14
  children,
14
15
  ...restProps
15
16
  }: Props = $props();
17
+
18
+ let isOpen = $derived(getContext<() => boolean>("svadmin-dropdown-open")?.() ?? true);
16
19
  </script>
17
20
 
21
+ {#if isOpen}
18
22
  <div
19
23
  bind:this={ref}
20
24
  data-slot="dropdown-menu-content"
@@ -28,3 +32,4 @@
28
32
  >
29
33
  {@render children?.()}
30
34
  </div>
35
+ {/if}
@@ -16,6 +16,8 @@
16
16
  ...restProps
17
17
  }: Props = $props();
18
18
 
19
+ import { setContext } from "svelte";
20
+
19
21
  function handleClickOutside(e: MouseEvent) {
20
22
  if (ref && !ref.contains(e.target as Node)) {
21
23
  open = false;
@@ -23,6 +25,8 @@
23
25
  }
24
26
  }
25
27
 
28
+ setContext("svadmin-dropdown-open", () => open);
29
+
26
30
  $effect(() => {
27
31
  if (open) {
28
32
  document.addEventListener('click', handleClickOutside, true);