Skip to content

Commit 39889dd

Browse files
committed
refactor: pre-rxjs refactor
1 parent 5b93d8c commit 39889dd

File tree

6 files changed

+38
-35
lines changed

6 files changed

+38
-35
lines changed

demo/src/lib/basic.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import Basic from "./basic.svelte";
55
export const openBasic = (): ModalInstance<CustomBasicProps> => {
66
return manager.open<CustomBasicProps>({
77
component: Basic,
8-
backdrop: {
9-
class: "custom-backdrop-class",
10-
attributes: {
11-
"data-where-am-i": "backdrop",
12-
"data-my-component-name": "basic.svelte"
13-
}
14-
},
8+
// backdrop: {
9+
// class: "custom-backdrop-class",
10+
// attributes: {
11+
// "data-where-am-i": "backdrop",
12+
// "data-my-component-name": "basic.svelte"
13+
// }
14+
// },
1515
dialog: {
1616
attributes: {
1717
"data-where-am-i": "dialog",

demo/src/lib/escapable.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@ export const openEscapeable = (): ModalInstance<EscapableProps> => {
2626
const instance = manager.open<EscapableProps>({
2727
id: "modal-escapable",
2828
component: Modal,
29-
backdrop: false,
29+
backdrop: {
30+
class: "custom-backdrop-class",
31+
attributes: {
32+
"data-where-am-i": "backdrop",
33+
"data-my-component-name": "escapable.svelte"
34+
}
35+
},
36+
dialog: {
37+
class: "custom-dialog-class",
38+
attributes: {
39+
"data-where-am-i": "dialog",
40+
"data-my-component-name": "escapable.svelte"
41+
}
42+
},
3043
keybindings: [
3144
{
3245
key: Key.Escape,
@@ -35,13 +48,6 @@ export const openEscapeable = (): ModalInstance<EscapableProps> => {
3548
instance.manager.open<EscapableProps>({
3649
id: `${instance.config.id}-escapable`,
3750
component: CloseConfirmation,
38-
backdrop: {
39-
class: "custom-backdrop-class",
40-
attributes: {
41-
"data-where-am-i": "backdrop",
42-
"data-my-component-name": "escapable.svelte"
43-
}
44-
},
4551
props: {
4652
ref: instance as unknown as ModalInstance<EscapableProps>,
4753
close: (parent: ModalInstance<EscapableProps>) => {

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"name": "@mateothegreat/svelte5-modal-manager",
33
"version": "0.2.5",
44
"type": "module",
5-
"moduleResolution": "bundler",
6-
"svelte": "./index.js",
7-
"types": "./index.d.ts",
85
"exports": {
9-
".": "./src/index.ts"
6+
".": {
7+
"types": "./src/index.ts",
8+
"svelte": "./src/index.ts"
9+
}
1010
},
1111
"files": [
1212
"./src"
@@ -17,23 +17,23 @@
1717
"dev": "cd demo && npm run dev"
1818
},
1919
"devDependencies": {
20-
"@sveltejs/package": "^2.3.12",
21-
"@sveltejs/vite-plugin-svelte": "^5.1.0",
20+
"@sveltejs/package": "^2.3.10",
21+
"@sveltejs/vite-plugin-svelte": "^5.0.3",
2222
"@testing-library/svelte": "^5.2.8",
2323
"@tsconfig/svelte": "^5.0.4",
2424
"@types/node": "^24.0.10",
2525
"autoprefixer": "^10.4.21",
2626
"cpx": "^1.5.0",
2727
"jsdom": "^26.1.0",
28-
"prettier-plugin-svelte": "^3.4.0",
29-
"prettier-plugin-tailwindcss": "^0.6.13",
28+
"prettier-plugin-svelte": "^3.3.3",
29+
"prettier-plugin-tailwindcss": "^0.6.11",
3030
"rimraf": "^6.0.1",
31-
"runed": "^0.29.2",
32-
"svelte": "^5.35.3",
33-
"svelte-check": "^4.2.2",
31+
"runed": "^0.23.4",
32+
"svelte": "^5.22.6",
33+
"svelte-check": "^4.1.5",
3434
"tslib": "^2.8.1",
35-
"typescript": "^5.8.3",
36-
"vitest": "^3.2.4"
35+
"typescript": "^5.8.2",
36+
"vitest": "^3.0.8"
3737
},
3838
"peerDependencies": {
3939
"svelte": "^5.0.0"

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./lib";

src/lib/manager.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export class ModalManager {
5454
* @param id - The unique identifier of the modal to close.
5555
*/
5656
close(id: string): void {
57-
console.log("closing", id, this.instances.get(id)?.overlay);
5857
unmount(this.instances.get(id)?.overlay);
5958

6059
this.instances.delete(id);
@@ -89,7 +88,6 @@ export class ModalManager {
8988
// Move all modals that were above this one down by 1
9089
for (const modal of this.instances.values()) {
9190
if (modal.index > currentIndex) {
92-
console.log("moving down", modal.config.id, modal.index, modal.index - 1);
9391
modal.index--;
9492
}
9593
}
@@ -110,7 +108,6 @@ export class ModalManager {
110108
private reorder(): void {
111109
const modals = Array.from(this.instances.values()).sort((a, b) => a.index - b.index);
112110
modals.forEach((modal, i) => {
113-
console.log("reordering", modal.config.id, modal.index, i);
114111
modal.index = i;
115112

116113
// Set the last modal as top

src/lib/modal.svelte

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@
7171
}
7272
};
7373
74-
const backdropConfig = $derived(backdrop(instance.config.backdrop));
74+
const backdropConfig = backdrop(instance.config.backdrop);
7575
</script>
7676

77-
{#if backdropConfig}
77+
{#if backdropConfig && instance.manager.instances.size === 0}
7878
<div
7979
onmousedown={handleClick}
8080
id={instance.config.id}
@@ -101,6 +101,7 @@
101101
class={instance.config.dialog?.class}
102102
class:modal-content={true}
103103
{...instance.config.dialog?.attributes}>
104+
{JSON.stringify(instance.config.dialog)}
104105
<div class="dialog-wrapper">
105106
<instance.config.component {instance} />
106107
</div>
@@ -120,8 +121,6 @@
120121
left: 0;
121122
right: 0;
122123
top: 0;
123-
background-color: rgba(0, 0, 0, 0.5);
124-
backdrop-filter: blur(4px);
125124
transition: all 500ms;
126125
display: flex;
127126
justify-content: center;

0 commit comments

Comments
 (0)