milk-lib 0.0.37 → 0.0.38

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.
@@ -1,15 +1,24 @@
1
1
  <script lang="ts">
2
- import { getContext } from "svelte";
2
+ import { getContext, onMount } from "svelte";
3
3
  import type {IAccordionContentProps, IAccordionItemContext} from "./Accordion.types";
4
4
 
5
5
  let { children }: IAccordionContentProps = $props();
6
6
  const { isOpen } = getContext<IAccordionItemContext>('accordion-item-context');
7
7
  let accordionContent: HTMLDivElement | null = $state(null);
8
- let height = $derived<number>(
9
- accordionContent
10
- ? (accordionContent as HTMLDivElement).getBoundingClientRect?.().height
11
- : 0
12
- );
8
+ let height = $state(0);
9
+
10
+ const recalcHeight = () => {
11
+ height = accordionContent?.getBoundingClientRect?.().height ?? 0;
12
+ };
13
+
14
+ $effect(() => {
15
+ recalcHeight();
16
+ });
17
+
18
+ onMount(() => {
19
+ window.addEventListener('resize', recalcHeight);
20
+ return () => window.removeEventListener('resize', recalcHeight);
21
+ });
13
22
 
14
23
  </script>
15
24
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "milk-lib",
3
3
  "license": "MIT",
4
- "version": "0.0.37",
4
+ "version": "0.0.38",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "vite build && npm run prepack",