@streamscloud/kit 0.1.2 → 0.1.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.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const cardActionContainer = (node) => {
|
|
2
2
|
const handleHover = () => {
|
|
3
|
-
node.style.setProperty('--card-actions--opacity', '1');
|
|
3
|
+
node.style.setProperty('--sc-kit--card-actions--opacity', '1');
|
|
4
4
|
};
|
|
5
5
|
const handleHoverOut = () => {
|
|
6
|
-
node.style.setProperty('--card-actions--opacity', '');
|
|
6
|
+
node.style.setProperty('--sc-kit--card-actions--opacity', '');
|
|
7
7
|
};
|
|
8
8
|
node.addEventListener('mouseenter', handleHover);
|
|
9
9
|
node.addEventListener('mouseleave', handleHoverOut);
|
|
@@ -5,6 +5,7 @@ import { createPopper } from '@popperjs/core';
|
|
|
5
5
|
import { untrack } from 'svelte';
|
|
6
6
|
let { position = 'bottom-start', disabled = false, keepDropdownOpen = false, fixedPosition = false, offset = 8, boundaryMargin = 8, backdrop = false, isOpenRequested, on, children, trigger } = $props();
|
|
7
7
|
let opened = $state(false);
|
|
8
|
+
let dropdownEl = $state(null);
|
|
8
9
|
$effect(() => untrack(() => {
|
|
9
10
|
on?.mounted?.({
|
|
10
11
|
toggleOpen: (value) => {
|
|
@@ -40,16 +41,22 @@ $effect(() => untrack(() => {
|
|
|
40
41
|
}));
|
|
41
42
|
$effect(() => {
|
|
42
43
|
return () => {
|
|
43
|
-
window.removeEventListener('click',
|
|
44
|
+
window.removeEventListener('click', handleOutsideClick, true);
|
|
44
45
|
};
|
|
45
46
|
});
|
|
47
|
+
const handleOutsideClick = (event) => {
|
|
48
|
+
if (dropdownEl?.contains(event.target)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
close();
|
|
52
|
+
};
|
|
46
53
|
const open = () => {
|
|
47
54
|
opened = true;
|
|
48
|
-
window.addEventListener('click',
|
|
55
|
+
window.addEventListener('click', handleOutsideClick, true);
|
|
49
56
|
};
|
|
50
57
|
const close = () => {
|
|
51
58
|
opened = false;
|
|
52
|
-
window.removeEventListener('click',
|
|
59
|
+
window.removeEventListener('click', handleOutsideClick, true);
|
|
53
60
|
};
|
|
54
61
|
const handleClick = (event) => {
|
|
55
62
|
event.stopPropagation();
|
|
@@ -119,7 +126,7 @@ const initPopper = (node) => {
|
|
|
119
126
|
role="none">
|
|
120
127
|
</div>
|
|
121
128
|
{/if}
|
|
122
|
-
<div class="dropdown" class:dropdown--disabled={disabled} onclick={handleClick} onkeydown={() => ({})} role="none">
|
|
129
|
+
<div class="dropdown" class:dropdown--disabled={disabled} bind:this={dropdownEl} onclick={handleClick} onkeydown={() => ({})} role="none">
|
|
123
130
|
<button type="button" class="dropdown__trigger">
|
|
124
131
|
{#if trigger}
|
|
125
132
|
{@render trigger()}
|