@getmicdrop/svelte-components 5.12.0 → 5.13.0
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/dist/index.spec.js +0 -1
- package/dist/patterns/navigation/Header.svelte +23 -27
- package/dist/patterns/navigation/Header.svelte.d.ts.map +1 -1
- package/dist/primitives/AvatarButton/AvatarButton.svelte +57 -0
- package/dist/primitives/AvatarButton/AvatarButton.svelte.d.ts +18 -0
- package/dist/primitives/AvatarButton/AvatarButton.svelte.d.ts.map +1 -0
- package/dist/primitives/BottomSheet/BottomSheet.spec.js +19 -19
- package/dist/primitives/BottomSheet/BottomSheet.svelte +5 -5
- package/dist/primitives/BottomSheet/BottomSheet.svelte.d.ts +2 -2
- package/dist/primitives/BottomSheet/BottomSheet.svelte.d.ts.map +1 -1
- package/dist/primitives/BottomSheet/BottomSheetWrapper.test.svelte +3 -3
- package/dist/primitives/BottomSheet/BottomSheetWrapper.test.svelte.d.ts +1 -1
- package/dist/primitives/Button/Button.spec.js +8 -8
- package/dist/primitives/Button/Button.svelte +9 -45
- package/dist/primitives/Button/Button.svelte.d.ts.map +1 -1
- package/dist/primitives/CardAction/CardAction.svelte +68 -0
- package/dist/primitives/CardAction/CardAction.svelte.d.ts +20 -0
- package/dist/primitives/CardAction/CardAction.svelte.d.ts.map +1 -0
- package/dist/primitives/Drawer/Drawer.spec.js +33 -33
- package/dist/primitives/Drawer/Drawer.svelte +5 -9
- package/dist/primitives/Drawer/Drawer.svelte.d.ts +2 -3
- package/dist/primitives/Drawer/Drawer.svelte.d.ts.map +1 -1
- package/dist/primitives/LandingButton/LandingButton.svelte +92 -0
- package/dist/primitives/LandingButton/LandingButton.svelte.d.ts +22 -0
- package/dist/primitives/LandingButton/LandingButton.svelte.d.ts.map +1 -0
- package/dist/primitives/MenuItem/MenuItem.svelte +85 -0
- package/dist/primitives/MenuItem/MenuItem.svelte.d.ts +24 -0
- package/dist/primitives/MenuItem/MenuItem.svelte.d.ts.map +1 -0
- package/dist/primitives/Modal/Modal.spec.js +7 -7
- package/dist/primitives/Modal/Modal.stories.svelte +3 -3
- package/dist/primitives/Modal/Modal.svelte +25 -18
- package/dist/primitives/Modal/Modal.svelte.d.ts +5 -5
- package/dist/primitives/Modal/Modal.svelte.d.ts.map +1 -1
- package/dist/primitives/Modal/ModalTestWrapper.svelte +3 -3
- package/dist/primitives/Modal/ModalTestWrapper.svelte.d.ts +2 -2
- package/dist/primitives/NavItem/NavItem.svelte +75 -0
- package/dist/primitives/NavItem/NavItem.svelte.d.ts +20 -0
- package/dist/primitives/NavItem/NavItem.svelte.d.ts.map +1 -0
- package/dist/primitives/SearchResultItem/SearchResultItem.svelte +109 -0
- package/dist/primitives/SearchResultItem/SearchResultItem.svelte.d.ts +26 -0
- package/dist/primitives/SearchResultItem/SearchResultItem.svelte.d.ts.map +1 -0
- package/dist/primitives/SidebarToggle/SidebarToggle.svelte +55 -0
- package/dist/primitives/SidebarToggle/SidebarToggle.svelte.d.ts +18 -0
- package/dist/primitives/SidebarToggle/SidebarToggle.svelte.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +7 -0
- package/dist/primitives/index.js +21 -0
- package/dist/recipes/SuperLogin/SuperLogin.svelte +3 -3
- package/dist/recipes/SuperLogin/SuperLogin.svelte.d.ts.map +1 -1
- package/dist/recipes/inputs/index.d.ts +0 -1
- package/dist/recipes/inputs/index.js +0 -1
- package/dist/recipes/modals/AlertModal.spec.js +2 -2
- package/dist/recipes/modals/AlertModal.svelte +6 -6
- package/dist/recipes/modals/AlertModal.svelte.d.ts +3 -3
- package/dist/recipes/modals/ConfirmationModal.spec.js +2 -2
- package/dist/recipes/modals/ConfirmationModal.svelte +5 -5
- package/dist/recipes/modals/ConfirmationModal.svelte.d.ts +3 -3
- package/dist/recipes/modals/InputModal.spec.js +2 -2
- package/dist/recipes/modals/InputModal.svelte +4 -4
- package/dist/recipes/modals/InputModal.svelte.d.ts +3 -3
- package/dist/recipes/modals/ModalTestWrapper.spec.js +49 -49
- package/dist/recipes/modals/ModalTestWrapper.svelte +3 -3
- package/dist/recipes/modals/ModalTestWrapper.svelte.d.ts +2 -2
- package/dist/recipes/modals/StatusModal.spec.js +2 -2
- package/dist/recipes/modals/StatusModal.svelte +4 -4
- package/dist/recipes/modals/StatusModal.svelte.d.ts +3 -3
- package/dist/stories/ComponentConsolidation.stories.svelte +10 -10
- package/dist/stories/PrimitivesGallery.svelte +25 -21
- package/dist/stories/PrimitivesGallery.svelte.d.ts.map +1 -1
- package/dist/stories/RecipesGallery.spec.js +9 -18
- package/dist/stories/RecipesGallery.svelte +5 -22
- package/dist/stories/RecipesGallery.svelte.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/recipes/inputs/SelectDropdown.spec.d.ts +0 -2
- package/dist/recipes/inputs/SelectDropdown.spec.d.ts.map +0 -1
- package/dist/recipes/inputs/SelectDropdown.spec.js +0 -518
- package/dist/recipes/inputs/SelectDropdown.svelte +0 -171
- package/dist/recipes/inputs/SelectDropdown.svelte.d.ts +0 -16
- package/dist/recipes/inputs/SelectDropdown.svelte.d.ts.map +0 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* <AlertModal
|
|
10
|
-
* bind:
|
|
10
|
+
* bind:open={showAlert}
|
|
11
11
|
* variant="success"
|
|
12
12
|
* title="Changes saved"
|
|
13
13
|
* message="Your changes have been saved successfully."
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
let {
|
|
23
23
|
/** Whether the modal is visible */
|
|
24
|
-
|
|
24
|
+
open = $bindable(false),
|
|
25
25
|
/** Alert variant */
|
|
26
26
|
variant = 'info',
|
|
27
27
|
/** Alert title */
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
/** Auto-close delay in milliseconds (0 to disable) */
|
|
34
34
|
autoClose = 0,
|
|
35
35
|
/** Modal size */
|
|
36
|
-
size = '
|
|
36
|
+
size = 'sm',
|
|
37
37
|
/** Callbacks */
|
|
38
38
|
onclose,
|
|
39
39
|
onconfirm,
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
let styles = $derived(variantStyles[variant] || variantStyles.info);
|
|
67
67
|
|
|
68
68
|
function closeModal() {
|
|
69
|
-
|
|
69
|
+
open = false;
|
|
70
70
|
onclose?.();
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
|
|
78
78
|
// Start auto-close timer when modal opens
|
|
79
79
|
$effect(() => {
|
|
80
|
-
if (
|
|
80
|
+
if (open && autoClose > 0) {
|
|
81
81
|
const timer = setTimeout(() => {
|
|
82
82
|
closeModal();
|
|
83
83
|
}, autoClose);
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
});
|
|
87
87
|
</script>
|
|
88
88
|
|
|
89
|
-
<Modal bind:
|
|
89
|
+
<Modal bind:open {size}>
|
|
90
90
|
{#snippet header()}
|
|
91
91
|
<div class="text-center">
|
|
92
92
|
<div class="flex justify-center items-center">
|
|
@@ -4,7 +4,7 @@ type AlertModal = {
|
|
|
4
4
|
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
5
|
};
|
|
6
6
|
declare const AlertModal: import("svelte").Component<{
|
|
7
|
-
|
|
7
|
+
open?: boolean;
|
|
8
8
|
variant?: string;
|
|
9
9
|
title?: string;
|
|
10
10
|
message?: string;
|
|
@@ -13,9 +13,9 @@ declare const AlertModal: import("svelte").Component<{
|
|
|
13
13
|
size?: string;
|
|
14
14
|
onclose: any;
|
|
15
15
|
onconfirm: any;
|
|
16
|
-
}, {}, "
|
|
16
|
+
}, {}, "open">;
|
|
17
17
|
type $$ComponentProps = {
|
|
18
|
-
|
|
18
|
+
open?: boolean;
|
|
19
19
|
variant?: string;
|
|
20
20
|
title?: string;
|
|
21
21
|
message?: string;
|
|
@@ -12,7 +12,7 @@ function setupTest(args = {}) {
|
|
|
12
12
|
const user = userEvent.setup();
|
|
13
13
|
const { component } = render(ConfirmationModal, {
|
|
14
14
|
props: {
|
|
15
|
-
|
|
15
|
+
open: true,
|
|
16
16
|
title: "Test Modal",
|
|
17
17
|
description: "This is a test description",
|
|
18
18
|
actions: defaultActions.map((a) => ({ ...a, onClick: vi.fn() })),
|
|
@@ -28,7 +28,7 @@ describe("ConfirmationModal Component Tests", () => {
|
|
|
28
28
|
// Use getAllByText/queryAllByText and check length or first element
|
|
29
29
|
|
|
30
30
|
test("Does not render when show is false", () => {
|
|
31
|
-
render(ConfirmationModal, { props: {
|
|
31
|
+
render(ConfirmationModal, { props: { open: false } });
|
|
32
32
|
expect(screen.queryByText("Test Modal")).not.toBeInTheDocument();
|
|
33
33
|
});
|
|
34
34
|
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
import { triggerHaptic } from '../../utils/haptic.js';
|
|
7
7
|
|
|
8
8
|
let {
|
|
9
|
-
|
|
10
|
-
size = "
|
|
9
|
+
open = $bindable(false),
|
|
10
|
+
size = "md",
|
|
11
11
|
title = "",
|
|
12
12
|
description = "",
|
|
13
13
|
warningText = "",
|
|
@@ -66,13 +66,13 @@
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
action.onClick?.();
|
|
69
|
-
|
|
69
|
+
open = false;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
const handleClose = () => {
|
|
73
73
|
if (disabled || loading) return;
|
|
74
74
|
onclose?.();
|
|
75
|
-
|
|
75
|
+
open = false;
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
const getVariant = (action) => {
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
};
|
|
108
108
|
</script>
|
|
109
109
|
|
|
110
|
-
<Modal bind:
|
|
110
|
+
<Modal bind:open {size} oncancel={handleClose} {...restProps}>
|
|
111
111
|
{#snippet header()}
|
|
112
112
|
<div>
|
|
113
113
|
{#if closeBtn}
|
|
@@ -4,7 +4,7 @@ type ConfirmationModal = {
|
|
|
4
4
|
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
5
|
};
|
|
6
6
|
declare const ConfirmationModal: import("svelte").Component<{
|
|
7
|
-
|
|
7
|
+
open?: boolean;
|
|
8
8
|
size?: string;
|
|
9
9
|
title?: string;
|
|
10
10
|
description?: string;
|
|
@@ -22,9 +22,9 @@ declare const ConfirmationModal: import("svelte").Component<{
|
|
|
22
22
|
onconfirm: any;
|
|
23
23
|
oncancel: any;
|
|
24
24
|
onclose: any;
|
|
25
|
-
} & Record<string, any>, {}, "
|
|
25
|
+
} & Record<string, any>, {}, "open">;
|
|
26
26
|
type $$ComponentProps = {
|
|
27
|
-
|
|
27
|
+
open?: boolean;
|
|
28
28
|
size?: string;
|
|
29
29
|
title?: string;
|
|
30
30
|
description?: string;
|
|
@@ -8,7 +8,7 @@ function setupTest(args = {}) {
|
|
|
8
8
|
const user = userEvent.setup();
|
|
9
9
|
const { component } = render(InputModal, {
|
|
10
10
|
props: {
|
|
11
|
-
|
|
11
|
+
open: true,
|
|
12
12
|
title: "Test Input Modal",
|
|
13
13
|
...args,
|
|
14
14
|
},
|
|
@@ -27,7 +27,7 @@ describe("InputModal Component Tests", () => {
|
|
|
27
27
|
|
|
28
28
|
// Basic rendering tests
|
|
29
29
|
test("Does not render when show is false", () => {
|
|
30
|
-
render(InputModal, { props: {
|
|
30
|
+
render(InputModal, { props: { open: false } });
|
|
31
31
|
expect(screen.queryByText("Test Input Modal")).not.toBeInTheDocument();
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
import { typography } from '../../tokens/typography';
|
|
7
7
|
|
|
8
8
|
let {
|
|
9
|
-
|
|
10
|
-
size = "
|
|
9
|
+
open = $bindable(false),
|
|
10
|
+
size = "md", // "sm" | "md" | "lg" | "xl"
|
|
11
11
|
title = "",
|
|
12
12
|
description = "",
|
|
13
13
|
closeBtn = false, // To show close button
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
const closeModal = () => {
|
|
71
|
-
|
|
71
|
+
open = false;
|
|
72
72
|
onclose?.();
|
|
73
73
|
};
|
|
74
74
|
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
};
|
|
79
79
|
</script>
|
|
80
80
|
|
|
81
|
-
<Modal bind:
|
|
81
|
+
<Modal bind:open {size} {persistent}>
|
|
82
82
|
{#snippet header()}
|
|
83
83
|
<div class="text-left">
|
|
84
84
|
{#if closeBtn}
|
|
@@ -4,7 +4,7 @@ type InputModal = {
|
|
|
4
4
|
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
5
|
};
|
|
6
6
|
declare const InputModal: import("svelte").Component<{
|
|
7
|
-
|
|
7
|
+
open?: boolean;
|
|
8
8
|
size?: string;
|
|
9
9
|
title?: string;
|
|
10
10
|
description?: string;
|
|
@@ -29,9 +29,9 @@ declare const InputModal: import("svelte").Component<{
|
|
|
29
29
|
onconfirm: any;
|
|
30
30
|
oncancel: any;
|
|
31
31
|
onclose: any;
|
|
32
|
-
}, {}, "
|
|
32
|
+
}, {}, "open" | "inputValue">;
|
|
33
33
|
type $$ComponentProps = {
|
|
34
|
-
|
|
34
|
+
open?: boolean;
|
|
35
35
|
size?: string;
|
|
36
36
|
title?: string;
|
|
37
37
|
description?: string;
|
|
@@ -13,18 +13,18 @@ describe('ModalTestWrapper', () => {
|
|
|
13
13
|
|
|
14
14
|
describe('Basic Rendering', () => {
|
|
15
15
|
it('should not render when show is false', () => {
|
|
16
|
-
render(ModalTestWrapper, { props: {
|
|
16
|
+
render(ModalTestWrapper, { props: { open: false } });
|
|
17
17
|
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it('should render when show is true', () => {
|
|
21
|
-
render(ModalTestWrapper, { props: {
|
|
21
|
+
render(ModalTestWrapper, { props: { open: true } });
|
|
22
22
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it('should render modal without errors when no props provided', () => {
|
|
26
26
|
expect(() => {
|
|
27
|
-
render(ModalTestWrapper, { props: {
|
|
27
|
+
render(ModalTestWrapper, { props: { open: true } });
|
|
28
28
|
}).not.toThrow();
|
|
29
29
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
30
30
|
});
|
|
@@ -35,7 +35,7 @@ describe('ModalTestWrapper', () => {
|
|
|
35
35
|
expect(() => {
|
|
36
36
|
render(ModalTestWrapper, {
|
|
37
37
|
props: {
|
|
38
|
-
|
|
38
|
+
open: true,
|
|
39
39
|
title: 'Test Modal Title'
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -46,7 +46,7 @@ describe('ModalTestWrapper', () => {
|
|
|
46
46
|
expect(() => {
|
|
47
47
|
render(ModalTestWrapper, {
|
|
48
48
|
props: {
|
|
49
|
-
|
|
49
|
+
open: true,
|
|
50
50
|
description: 'Test modal description'
|
|
51
51
|
}
|
|
52
52
|
});
|
|
@@ -57,7 +57,7 @@ describe('ModalTestWrapper', () => {
|
|
|
57
57
|
expect(() => {
|
|
58
58
|
render(ModalTestWrapper, {
|
|
59
59
|
props: {
|
|
60
|
-
|
|
60
|
+
open: true,
|
|
61
61
|
warningText: 'Warning message'
|
|
62
62
|
}
|
|
63
63
|
});
|
|
@@ -69,7 +69,7 @@ describe('ModalTestWrapper', () => {
|
|
|
69
69
|
expect(() => {
|
|
70
70
|
render(ModalTestWrapper, {
|
|
71
71
|
props: {
|
|
72
|
-
|
|
72
|
+
open: true,
|
|
73
73
|
oncancel
|
|
74
74
|
}
|
|
75
75
|
});
|
|
@@ -81,7 +81,7 @@ describe('ModalTestWrapper', () => {
|
|
|
81
81
|
expect(() => {
|
|
82
82
|
render(ModalTestWrapper, {
|
|
83
83
|
props: {
|
|
84
|
-
|
|
84
|
+
open: true,
|
|
85
85
|
title: 'Full Test',
|
|
86
86
|
description: 'Full description',
|
|
87
87
|
warningText: 'Full warning',
|
|
@@ -96,13 +96,13 @@ describe('ModalTestWrapper', () => {
|
|
|
96
96
|
describe('Show Prop Binding', () => {
|
|
97
97
|
it('should render when show is true and not render when false', () => {
|
|
98
98
|
const { unmount: unmount1 } = render(ModalTestWrapper, {
|
|
99
|
-
props: {
|
|
99
|
+
props: { open: true }
|
|
100
100
|
});
|
|
101
101
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
102
102
|
unmount1();
|
|
103
103
|
|
|
104
104
|
render(ModalTestWrapper, {
|
|
105
|
-
props: {
|
|
105
|
+
props: { open: false }
|
|
106
106
|
});
|
|
107
107
|
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
108
108
|
});
|
|
@@ -110,14 +110,14 @@ describe('ModalTestWrapper', () => {
|
|
|
110
110
|
it('should support bindable show prop behavior', () => {
|
|
111
111
|
// Test that show can be initially false
|
|
112
112
|
const { unmount } = render(ModalTestWrapper, {
|
|
113
|
-
props: {
|
|
113
|
+
props: { open: false }
|
|
114
114
|
});
|
|
115
115
|
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
116
116
|
unmount();
|
|
117
117
|
|
|
118
118
|
// Test that show can be initially true
|
|
119
119
|
render(ModalTestWrapper, {
|
|
120
|
-
props: {
|
|
120
|
+
props: { open: true }
|
|
121
121
|
});
|
|
122
122
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
123
123
|
});
|
|
@@ -127,7 +127,7 @@ describe('ModalTestWrapper', () => {
|
|
|
127
127
|
it('should not error when oncancel is not provided', () => {
|
|
128
128
|
expect(() => {
|
|
129
129
|
render(ModalTestWrapper, {
|
|
130
|
-
props: {
|
|
130
|
+
props: { open: true }
|
|
131
131
|
});
|
|
132
132
|
}).not.toThrow();
|
|
133
133
|
});
|
|
@@ -136,7 +136,7 @@ describe('ModalTestWrapper', () => {
|
|
|
136
136
|
const oncancel = vi.fn();
|
|
137
137
|
render(ModalTestWrapper, {
|
|
138
138
|
props: {
|
|
139
|
-
|
|
139
|
+
open: true,
|
|
140
140
|
oncancel
|
|
141
141
|
}
|
|
142
142
|
});
|
|
@@ -149,7 +149,7 @@ describe('ModalTestWrapper', () => {
|
|
|
149
149
|
it('should update when title changes', () => {
|
|
150
150
|
const { rerender } = render(ModalTestWrapper, {
|
|
151
151
|
props: {
|
|
152
|
-
|
|
152
|
+
open: true,
|
|
153
153
|
title: 'Original Title'
|
|
154
154
|
}
|
|
155
155
|
});
|
|
@@ -157,7 +157,7 @@ describe('ModalTestWrapper', () => {
|
|
|
157
157
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
158
158
|
|
|
159
159
|
rerender({
|
|
160
|
-
|
|
160
|
+
open: true,
|
|
161
161
|
title: 'Updated Title'
|
|
162
162
|
});
|
|
163
163
|
|
|
@@ -167,7 +167,7 @@ describe('ModalTestWrapper', () => {
|
|
|
167
167
|
it('should update when description changes', () => {
|
|
168
168
|
const { rerender } = render(ModalTestWrapper, {
|
|
169
169
|
props: {
|
|
170
|
-
|
|
170
|
+
open: true,
|
|
171
171
|
description: 'Original Description'
|
|
172
172
|
}
|
|
173
173
|
});
|
|
@@ -175,7 +175,7 @@ describe('ModalTestWrapper', () => {
|
|
|
175
175
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
176
176
|
|
|
177
177
|
rerender({
|
|
178
|
-
|
|
178
|
+
open: true,
|
|
179
179
|
description: 'Updated Description'
|
|
180
180
|
});
|
|
181
181
|
|
|
@@ -185,7 +185,7 @@ describe('ModalTestWrapper', () => {
|
|
|
185
185
|
it('should update when warningText changes', () => {
|
|
186
186
|
const { rerender } = render(ModalTestWrapper, {
|
|
187
187
|
props: {
|
|
188
|
-
|
|
188
|
+
open: true,
|
|
189
189
|
warningText: 'Original Warning'
|
|
190
190
|
}
|
|
191
191
|
});
|
|
@@ -193,7 +193,7 @@ describe('ModalTestWrapper', () => {
|
|
|
193
193
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
194
194
|
|
|
195
195
|
rerender({
|
|
196
|
-
|
|
196
|
+
open: true,
|
|
197
197
|
warningText: 'Updated Warning'
|
|
198
198
|
});
|
|
199
199
|
|
|
@@ -203,7 +203,7 @@ describe('ModalTestWrapper', () => {
|
|
|
203
203
|
it('should handle adding and removing warning text', () => {
|
|
204
204
|
const { rerender } = render(ModalTestWrapper, {
|
|
205
205
|
props: {
|
|
206
|
-
|
|
206
|
+
open: true,
|
|
207
207
|
description: 'Main text'
|
|
208
208
|
}
|
|
209
209
|
});
|
|
@@ -211,7 +211,7 @@ describe('ModalTestWrapper', () => {
|
|
|
211
211
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
212
212
|
|
|
213
213
|
rerender({
|
|
214
|
-
|
|
214
|
+
open: true,
|
|
215
215
|
description: 'Main text',
|
|
216
216
|
warningText: 'New warning'
|
|
217
217
|
});
|
|
@@ -219,7 +219,7 @@ describe('ModalTestWrapper', () => {
|
|
|
219
219
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
220
220
|
|
|
221
221
|
rerender({
|
|
222
|
-
|
|
222
|
+
open: true,
|
|
223
223
|
description: 'Main text',
|
|
224
224
|
warningText: ''
|
|
225
225
|
});
|
|
@@ -233,7 +233,7 @@ describe('ModalTestWrapper', () => {
|
|
|
233
233
|
expect(() => {
|
|
234
234
|
render(ModalTestWrapper, {
|
|
235
235
|
props: {
|
|
236
|
-
|
|
236
|
+
open: true,
|
|
237
237
|
title: '',
|
|
238
238
|
description: '',
|
|
239
239
|
warningText: ''
|
|
@@ -247,7 +247,7 @@ describe('ModalTestWrapper', () => {
|
|
|
247
247
|
expect(() => {
|
|
248
248
|
render(ModalTestWrapper, {
|
|
249
249
|
props: {
|
|
250
|
-
|
|
250
|
+
open: true,
|
|
251
251
|
title: undefined,
|
|
252
252
|
description: undefined,
|
|
253
253
|
warningText: undefined
|
|
@@ -260,7 +260,7 @@ describe('ModalTestWrapper', () => {
|
|
|
260
260
|
expect(() => {
|
|
261
261
|
render(ModalTestWrapper, {
|
|
262
262
|
props: {
|
|
263
|
-
|
|
263
|
+
open: true,
|
|
264
264
|
oncancel: null
|
|
265
265
|
}
|
|
266
266
|
});
|
|
@@ -275,7 +275,7 @@ describe('ModalTestWrapper', () => {
|
|
|
275
275
|
expect(() => {
|
|
276
276
|
render(ModalTestWrapper, {
|
|
277
277
|
props: {
|
|
278
|
-
|
|
278
|
+
open: true,
|
|
279
279
|
title: longTitle,
|
|
280
280
|
description: longDescription,
|
|
281
281
|
warningText: longWarning
|
|
@@ -292,7 +292,7 @@ describe('ModalTestWrapper', () => {
|
|
|
292
292
|
expect(() => {
|
|
293
293
|
render(ModalTestWrapper, {
|
|
294
294
|
props: {
|
|
295
|
-
|
|
295
|
+
open: true,
|
|
296
296
|
title: specialTitle,
|
|
297
297
|
description: specialDescription
|
|
298
298
|
}
|
|
@@ -305,7 +305,7 @@ describe('ModalTestWrapper', () => {
|
|
|
305
305
|
expect(() => {
|
|
306
306
|
render(ModalTestWrapper, {
|
|
307
307
|
props: {
|
|
308
|
-
|
|
308
|
+
open: true,
|
|
309
309
|
title: '🎉 Success! 你好',
|
|
310
310
|
description: 'Test with émojis and spëcial çharacters',
|
|
311
311
|
warningText: '⚠️ Warning'
|
|
@@ -319,7 +319,7 @@ describe('ModalTestWrapper', () => {
|
|
|
319
319
|
describe('TypeScript Interface Compliance', () => {
|
|
320
320
|
it('should accept all defined Props', () => {
|
|
321
321
|
const validProps = {
|
|
322
|
-
|
|
322
|
+
open: true,
|
|
323
323
|
title: 'Test',
|
|
324
324
|
description: 'Description',
|
|
325
325
|
warningText: 'Warning',
|
|
@@ -339,7 +339,7 @@ describe('ModalTestWrapper', () => {
|
|
|
339
339
|
|
|
340
340
|
it('should work with only show prop', () => {
|
|
341
341
|
expect(() => {
|
|
342
|
-
render(ModalTestWrapper, { props: {
|
|
342
|
+
render(ModalTestWrapper, { props: { open: true } });
|
|
343
343
|
}).not.toThrow();
|
|
344
344
|
});
|
|
345
345
|
});
|
|
@@ -347,17 +347,17 @@ describe('ModalTestWrapper', () => {
|
|
|
347
347
|
describe('Integration with Modal Primitive', () => {
|
|
348
348
|
it('should pass show prop to underlying Modal', () => {
|
|
349
349
|
const { rerender } = render(ModalTestWrapper, {
|
|
350
|
-
props: {
|
|
350
|
+
props: { open: false }
|
|
351
351
|
});
|
|
352
352
|
|
|
353
353
|
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
354
354
|
|
|
355
|
-
rerender({
|
|
355
|
+
rerender({ open: true });
|
|
356
356
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
357
357
|
});
|
|
358
358
|
|
|
359
359
|
it('should render Modal with correct role', () => {
|
|
360
|
-
render(ModalTestWrapper, { props: {
|
|
360
|
+
render(ModalTestWrapper, { props: { open: true } });
|
|
361
361
|
const dialog = screen.getByRole('dialog');
|
|
362
362
|
expect(dialog).toBeInTheDocument();
|
|
363
363
|
expect(dialog).toHaveAttribute('aria-modal', 'true');
|
|
@@ -368,7 +368,7 @@ describe('ModalTestWrapper', () => {
|
|
|
368
368
|
|
|
369
369
|
render(ModalTestWrapper, {
|
|
370
370
|
props: {
|
|
371
|
-
|
|
371
|
+
open: true,
|
|
372
372
|
oncancel
|
|
373
373
|
}
|
|
374
374
|
});
|
|
@@ -380,12 +380,12 @@ describe('ModalTestWrapper', () => {
|
|
|
380
380
|
|
|
381
381
|
describe('Accessibility', () => {
|
|
382
382
|
it('should render with proper dialog role', () => {
|
|
383
|
-
render(ModalTestWrapper, { props: {
|
|
383
|
+
render(ModalTestWrapper, { props: { open: true } });
|
|
384
384
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
385
385
|
});
|
|
386
386
|
|
|
387
387
|
it('should have aria-modal attribute', () => {
|
|
388
|
-
render(ModalTestWrapper, { props: {
|
|
388
|
+
render(ModalTestWrapper, { props: { open: true } });
|
|
389
389
|
const dialog = screen.getByRole('dialog');
|
|
390
390
|
expect(dialog).toHaveAttribute('aria-modal', 'true');
|
|
391
391
|
});
|
|
@@ -394,12 +394,12 @@ describe('ModalTestWrapper', () => {
|
|
|
394
394
|
describe('Component Lifecycle', () => {
|
|
395
395
|
it('should mount without errors', () => {
|
|
396
396
|
expect(() => {
|
|
397
|
-
render(ModalTestWrapper, { props: {
|
|
397
|
+
render(ModalTestWrapper, { props: { open: true } });
|
|
398
398
|
}).not.toThrow();
|
|
399
399
|
});
|
|
400
400
|
|
|
401
401
|
it('should unmount without errors', () => {
|
|
402
|
-
const { unmount } = render(ModalTestWrapper, { props: {
|
|
402
|
+
const { unmount } = render(ModalTestWrapper, { props: { open: true } });
|
|
403
403
|
expect(() => {
|
|
404
404
|
unmount();
|
|
405
405
|
}).not.toThrow();
|
|
@@ -407,7 +407,7 @@ describe('ModalTestWrapper', () => {
|
|
|
407
407
|
|
|
408
408
|
it('should handle multiple mounts and unmounts', () => {
|
|
409
409
|
for (let i = 0; i < 3; i++) {
|
|
410
|
-
const { unmount } = render(ModalTestWrapper, { props: {
|
|
410
|
+
const { unmount } = render(ModalTestWrapper, { props: { open: true } });
|
|
411
411
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
412
412
|
unmount();
|
|
413
413
|
}
|
|
@@ -417,19 +417,19 @@ describe('ModalTestWrapper', () => {
|
|
|
417
417
|
describe('Reactive Behavior', () => {
|
|
418
418
|
it('should react to show prop changes', () => {
|
|
419
419
|
const { rerender } = render(ModalTestWrapper, {
|
|
420
|
-
props: {
|
|
420
|
+
props: { open: false }
|
|
421
421
|
});
|
|
422
422
|
|
|
423
423
|
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
424
424
|
|
|
425
|
-
rerender({
|
|
425
|
+
rerender({ open: true });
|
|
426
426
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
427
427
|
});
|
|
428
428
|
|
|
429
429
|
it('should maintain modal state during prop updates', () => {
|
|
430
430
|
const { rerender } = render(ModalTestWrapper, {
|
|
431
431
|
props: {
|
|
432
|
-
|
|
432
|
+
open: true,
|
|
433
433
|
title: 'Original'
|
|
434
434
|
}
|
|
435
435
|
});
|
|
@@ -437,7 +437,7 @@ describe('ModalTestWrapper', () => {
|
|
|
437
437
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
438
438
|
|
|
439
439
|
rerender({
|
|
440
|
-
|
|
440
|
+
open: true,
|
|
441
441
|
title: 'Updated',
|
|
442
442
|
description: 'New description'
|
|
443
443
|
});
|
|
@@ -451,7 +451,7 @@ describe('ModalTestWrapper', () => {
|
|
|
451
451
|
|
|
452
452
|
const { rerender } = render(ModalTestWrapper, {
|
|
453
453
|
props: {
|
|
454
|
-
|
|
454
|
+
open: true,
|
|
455
455
|
oncancel: oncancel1
|
|
456
456
|
}
|
|
457
457
|
});
|
|
@@ -459,7 +459,7 @@ describe('ModalTestWrapper', () => {
|
|
|
459
459
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
460
460
|
|
|
461
461
|
rerender({
|
|
462
|
-
|
|
462
|
+
open: true,
|
|
463
463
|
oncancel: oncancel2
|
|
464
464
|
});
|
|
465
465
|
|
|
@@ -471,7 +471,7 @@ describe('ModalTestWrapper', () => {
|
|
|
471
471
|
it('should handle presence of description without warning', () => {
|
|
472
472
|
render(ModalTestWrapper, {
|
|
473
473
|
props: {
|
|
474
|
-
|
|
474
|
+
open: true,
|
|
475
475
|
description: 'Main text only'
|
|
476
476
|
}
|
|
477
477
|
});
|
|
@@ -481,7 +481,7 @@ describe('ModalTestWrapper', () => {
|
|
|
481
481
|
it('should handle warning without description', () => {
|
|
482
482
|
render(ModalTestWrapper, {
|
|
483
483
|
props: {
|
|
484
|
-
|
|
484
|
+
open: true,
|
|
485
485
|
warningText: 'Warning only'
|
|
486
486
|
}
|
|
487
487
|
});
|
|
@@ -491,7 +491,7 @@ describe('ModalTestWrapper', () => {
|
|
|
491
491
|
it('should handle both description and warning', () => {
|
|
492
492
|
render(ModalTestWrapper, {
|
|
493
493
|
props: {
|
|
494
|
-
|
|
494
|
+
open: true,
|
|
495
495
|
description: 'Main text',
|
|
496
496
|
warningText: 'Warning text'
|
|
497
497
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
7
|
/** Whether the modal is visible */
|
|
8
|
-
|
|
8
|
+
open?: boolean;
|
|
9
9
|
/** Modal title */
|
|
10
10
|
title?: string;
|
|
11
11
|
/** Modal description */
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
let {
|
|
26
|
-
|
|
26
|
+
open = $bindable(false),
|
|
27
27
|
title = '',
|
|
28
28
|
description = '',
|
|
29
29
|
warningText = '',
|
|
@@ -62,4 +62,4 @@
|
|
|
62
62
|
{/if}
|
|
63
63
|
{/snippet}
|
|
64
64
|
|
|
65
|
-
<Modal bind:
|
|
65
|
+
<Modal bind:open {oncancel} header={headerContent} body={bodyContent} footer={footerContent} />
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
interface Props {
|
|
3
3
|
/** Whether the modal is visible */
|
|
4
|
-
|
|
4
|
+
open?: boolean;
|
|
5
5
|
/** Modal title */
|
|
6
6
|
title?: string;
|
|
7
7
|
/** Modal description */
|
|
@@ -17,7 +17,7 @@ interface Props {
|
|
|
17
17
|
/** Footer content */
|
|
18
18
|
footer?: Snippet;
|
|
19
19
|
}
|
|
20
|
-
declare const ModalTestWrapper: import("svelte").Component<Props, {}, "
|
|
20
|
+
declare const ModalTestWrapper: import("svelte").Component<Props, {}, "open">;
|
|
21
21
|
type ModalTestWrapper = ReturnType<typeof ModalTestWrapper>;
|
|
22
22
|
export default ModalTestWrapper;
|
|
23
23
|
//# sourceMappingURL=ModalTestWrapper.svelte.d.ts.map
|
|
@@ -7,7 +7,7 @@ function setupTest(args = {}) {
|
|
|
7
7
|
const user = userEvent.setup();
|
|
8
8
|
const { component } = render(StatusModal, {
|
|
9
9
|
props: {
|
|
10
|
-
|
|
10
|
+
open: true,
|
|
11
11
|
title: "Test Status",
|
|
12
12
|
description: "This is a test description",
|
|
13
13
|
...args,
|
|
@@ -27,7 +27,7 @@ describe("StatusModal Component Tests", () => {
|
|
|
27
27
|
|
|
28
28
|
describe("Basic Rendering", () => {
|
|
29
29
|
test("Does not render when show is false", () => {
|
|
30
|
-
render(StatusModal, { props: {
|
|
30
|
+
render(StatusModal, { props: { open: false } });
|
|
31
31
|
expect(screen.queryByText("Test Status")).not.toBeInTheDocument();
|
|
32
32
|
});
|
|
33
33
|
|