flowbite-svelte
Advanced tools
Comparing version
@@ -0,1 +1,2 @@ | ||
// @ts-nocheck | ||
export function uiHelpers() { | ||
@@ -2,0 +3,0 @@ let isOpen = $state(false); |
@@ -54,3 +54,4 @@ /** | ||
} | ||
$effect(() => { | ||
// Initialize the action | ||
function initialize() { | ||
// Only add event listeners if options is not null | ||
@@ -69,17 +70,25 @@ if (options !== null) { | ||
node.addEventListener("focusout", handleFocusOut); | ||
return () => { | ||
node.removeEventListener("keydown", handleKeydown); | ||
node.removeEventListener("focusout", handleFocusOut); | ||
// Only restore focus if not closing via outside click and focus hasn't moved outside | ||
if (!isClosingViaOutsideClick && !isFocusMovedOutside && previous) { | ||
setTimeout(() => { | ||
previous.focus({ preventScroll: true }); | ||
}, 0); | ||
} | ||
}; | ||
} | ||
}); | ||
// Return the action object with destroy method | ||
} | ||
// Cleanup function | ||
function cleanup() { | ||
if (options !== null) { | ||
node.removeEventListener("keydown", handleKeydown); | ||
node.removeEventListener("focusout", handleFocusOut); | ||
// Only restore focus if not closing via outside click and focus hasn't moved outside | ||
if (!isClosingViaOutsideClick && !isFocusMovedOutside && previous) { | ||
setTimeout(() => { | ||
previous.focus({ preventScroll: true }); | ||
}, 0); | ||
} | ||
} | ||
} | ||
// Initialize on mount | ||
initialize(); | ||
// Return the action object with update and destroy methods | ||
return { | ||
update(newOptions = {}) { | ||
// Clean up existing listeners first | ||
node.removeEventListener("keydown", handleKeydown); | ||
node.removeEventListener("focusout", handleFocusOut); | ||
// Update the closing state | ||
@@ -90,11 +99,4 @@ if (newOptions && newOptions.isClosing !== undefined) { | ||
options = newOptions; | ||
// Clean up existing listeners if options becomes null | ||
if (options === null) { | ||
node.removeEventListener("keydown", handleKeydown); | ||
node.removeEventListener("focusout", handleFocusOut); | ||
} | ||
else if (options !== null) { | ||
// Add listener if it wasn't already there | ||
node.removeEventListener("keydown", handleKeydown); | ||
node.removeEventListener("focusout", handleFocusOut); | ||
// Reinitialize with new options | ||
if (options !== null) { | ||
node.addEventListener("keydown", handleKeydown); | ||
@@ -105,14 +107,5 @@ node.addEventListener("focusout", handleFocusOut); | ||
destroy() { | ||
if (options !== null) { | ||
node.removeEventListener("keydown", handleKeydown); | ||
node.removeEventListener("focusout", handleFocusOut); | ||
// Only restore focus if not closing via outside click and focus hasn't moved outside | ||
if (!isClosingViaOutsideClick && !isFocusMovedOutside && previous) { | ||
setTimeout(() => { | ||
previous.focus({ preventScroll: true }); | ||
}, 0); | ||
} | ||
} | ||
cleanup(); | ||
} | ||
}; | ||
} |
{ | ||
"name": "flowbite-svelte", | ||
"version": "1.8.0", | ||
"version": "1.8.1", | ||
"description": "Flowbite components for Svelte", | ||
@@ -22,3 +22,3 @@ "main": "dist/index.js", | ||
"@flowbite-svelte-plugins/datatable": "^0.3.4", | ||
"@flowbite-svelte-plugins/texteditor": "^0.9.3", | ||
"@flowbite-svelte-plugins/texteditor": "^0.9.5", | ||
"@playwright/test": "^1.53.1", | ||
@@ -25,0 +25,0 @@ "@sveltejs/adapter-auto": "^6.0.1", |
1302846
-0.05%33520
-0.02%21
-4.55%51
-1.92%86
-1.15%