@@ -29,7 +29,7 @@ const { id = 'modal', open = false, closeOnOutsideClick = false } = Astro.props;
2929<script >
3030 document.addEventListener('DOMContentLoaded', () => {
3131 // Function to toggle body scroll
32- const toggleBodyScroll = (disable) => {
32+ const toggleBodyScroll = (disable: any ) => {
3333 if (disable) {
3434 // Save the current scroll position
3535 const scrollY = window.scrollY;
@@ -49,7 +49,7 @@ const { id = 'modal', open = false, closeOnOutsideClick = false } = Astro.props;
4949 };
5050
5151 // Function to open modal
52- const openModal = (modal) => {
52+ const openModal = (modal: any ) => {
5353 if (modal) {
5454 // Disable body scroll
5555 toggleBodyScroll(true);
@@ -60,7 +60,7 @@ const { id = 'modal', open = false, closeOnOutsideClick = false } = Astro.props;
6060 };
6161
6262 // Function to close modal
63- const closeModal = (modal) => {
63+ const closeModal = (modal: any ) => {
6464 if (modal) {
6565 // Enable body scroll
6666 toggleBodyScroll(false);
@@ -72,22 +72,25 @@ const { id = 'modal', open = false, closeOnOutsideClick = false } = Astro.props;
7272
7373 // Open modal buttons
7474 document.querySelectorAll('[data-open-modal]').forEach(button => {
75- button.addEventListener('click', () => {
76- const modal = document.getElementById(button.dataset.openModal);
75+ const btn = button as HTMLElement;
76+ btn.addEventListener('click', () => {
77+ const modal = document.getElementById(btn.dataset.openModal!);
7778 openModal(modal);
7879 });
7980 });
8081
8182 // Close modal buttons
8283 document.querySelectorAll('[data-close-modal]').forEach(button => {
83- button.addEventListener('click', () => {
84+ const btn = button as HTMLElement;
85+ btn.addEventListener('click', () => {
8486 const modal = button.closest('[data-modal-wrapper]');
8587 closeModal(modal);
8688 });
8789 });
8890
8991 // Close when clicking outside the modal content - only if enabled
90- document.querySelectorAll('[data-modal-wrapper]').forEach(modal => {
92+ document.querySelectorAll('[data-modal-wrapper]').forEach(m => {
93+ const modal = m as HTMLElement;
9194 const closeOnOutsideClick = modal.dataset.closeOnOutsideClick === 'true';
9295
9396 if (closeOnOutsideClick) {
0 commit comments