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