@hashrytech/quick-components-kit 0.8.3 → 0.8.5
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/CHANGELOG.md +12 -0
- package/dist/overlay/Overlay.svelte +6 -29
- package/dist/overlay/Overlay.svelte.d.ts +2 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @hashrytech/quick-components-kit
|
|
2
2
|
|
|
3
|
+
## 0.8.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: scroll disable fix for overlay component
|
|
8
|
+
|
|
9
|
+
## 0.8.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fix: Removing open and close for overlay component
|
|
14
|
+
|
|
3
15
|
## 0.8.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -3,14 +3,11 @@
|
|
|
3
3
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
4
|
import { fade } from 'svelte/transition';
|
|
5
5
|
import {twMerge} from 'tailwind-merge';
|
|
6
|
-
import { browser } from '$app/environment';
|
|
7
6
|
|
|
8
7
|
export type OverlayProps = {
|
|
9
|
-
open?: boolean;
|
|
10
|
-
escapeKeyClose?: boolean;
|
|
11
8
|
disableBodyScroll?: boolean;
|
|
12
9
|
ariaLabel?: string;
|
|
13
|
-
|
|
10
|
+
transitionDuration?: number;
|
|
14
11
|
children?: Snippet;
|
|
15
12
|
onclick?: (event: MouseEvent) => void;
|
|
16
13
|
class?: ClassNameValue;
|
|
@@ -19,40 +16,20 @@
|
|
|
19
16
|
</script>
|
|
20
17
|
|
|
21
18
|
<script lang="ts">
|
|
22
|
-
let {
|
|
19
|
+
let {disableBodyScroll=true, transitionDuration=0, ariaLabel="Modal", onclick, children, ...props}: OverlayProps = $props();
|
|
23
20
|
|
|
24
21
|
const lockScroll = () => document.body.style.overflow = 'hidden';
|
|
25
22
|
const unlockScroll = () => document.body.style.overflow = '';
|
|
26
23
|
|
|
27
|
-
$effect(() => {
|
|
28
|
-
if (open && disableBodyScroll) lockScroll(); else unlockScroll();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
24
|
onMount(() => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
});
|
|
25
|
+
lockScroll();
|
|
26
|
+
});
|
|
36
27
|
|
|
37
28
|
onDestroy(() => {
|
|
38
|
-
|
|
39
|
-
window.removeEventListener('keydown', handleKeydown);
|
|
40
|
-
}
|
|
29
|
+
unlockScroll();
|
|
41
30
|
});
|
|
42
31
|
|
|
43
|
-
export function closeOverlay() {
|
|
44
|
-
open = false;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
function handleKeydown (event: { key: string; }) {
|
|
48
|
-
if(open && escapeKeyClose && event.key === "Escape") {
|
|
49
|
-
closeOverlay();
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
32
|
</script>
|
|
54
33
|
|
|
55
|
-
{
|
|
56
|
-
<div transition:fade={{duration: overlayTransitionDuration}} class={twMerge("fixed top-0 left-0 right-0 bottom-0 bg-overlay-primary", props.class)} role="presentation" {onclick}></div>
|
|
57
|
-
{/if}
|
|
34
|
+
<div transition:fade={{duration: transitionDuration}} class={twMerge("fixed top-0 left-0 right-0 bottom-0 bg-overlay-primary", props.class)} role="presentation" {onclick}></div>
|
|
58
35
|
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { type Snippet } from 'svelte';
|
|
2
2
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
3
|
export type OverlayProps = {
|
|
4
|
-
open?: boolean;
|
|
5
|
-
escapeKeyClose?: boolean;
|
|
6
4
|
disableBodyScroll?: boolean;
|
|
7
5
|
ariaLabel?: string;
|
|
8
|
-
|
|
6
|
+
transitionDuration?: number;
|
|
9
7
|
children?: Snippet;
|
|
10
8
|
onclick?: (event: MouseEvent) => void;
|
|
11
9
|
class?: ClassNameValue;
|
|
12
10
|
};
|
|
13
|
-
declare const Overlay: import("svelte").Component<OverlayProps, {
|
|
14
|
-
closeOverlay: () => void;
|
|
15
|
-
}, "open">;
|
|
11
|
+
declare const Overlay: import("svelte").Component<OverlayProps, {}, "">;
|
|
16
12
|
type Overlay = ReturnType<typeof Overlay>;
|
|
17
13
|
export default Overlay;
|