tera-system-ui 0.0.3 → 0.0.6
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/components/command/components/CommandInput.svelte +4 -1
- package/dist/components/dialog/Dialog.d.ts +52 -0
- package/dist/components/dialog/Dialog.js +6 -0
- package/dist/components/dialog/Dialog.svelte +69 -50
- package/dist/components/dialog/Dialog.svelte.d.ts +1 -8
- package/dist/components/dialog/dialog.scss +25 -5
- package/dist/components/language-picker-button/LanguagePickerButton.svelte +1 -1
- package/dist/components/light-dark-toggle/LightDarkToggle.svelte +10 -10
- package/dist/components/popover/Popover.d.ts +1 -0
- package/dist/components/popover/Popover.svelte +22 -14
- package/dist/components/popover-responsive/PopoverResponsive.d.ts +8 -0
- package/dist/components/popover-responsive/PopoverResponsive.js +7 -0
- package/dist/components/popover-responsive/PopoverResponsive.svelte +87 -0
- package/dist/components/popover-responsive/PopoverResponsive.svelte.d.ts +11 -0
- package/dist/components/popover-responsive/index.d.ts +1 -0
- package/dist/components/popover-responsive/index.js +1 -0
- package/dist/components/side-navigation/SideNavigation.d.ts +2 -1
- package/dist/components/side-navigation/SideNavigation.js +8 -5
- package/dist/components/side-navigation/SideNavigation.svelte +5 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +3 -2
|
@@ -17,6 +17,12 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
|
17
17
|
dialog: string;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
+
padding: {
|
|
21
|
+
none: {
|
|
22
|
+
dialogContainer: string;
|
|
23
|
+
body: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
20
26
|
}, {
|
|
21
27
|
base: string;
|
|
22
28
|
dialog: string;
|
|
@@ -42,6 +48,12 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
|
42
48
|
dialog: string;
|
|
43
49
|
};
|
|
44
50
|
};
|
|
51
|
+
padding: {
|
|
52
|
+
none: {
|
|
53
|
+
dialogContainer: string;
|
|
54
|
+
body: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
45
57
|
}, {
|
|
46
58
|
size: {
|
|
47
59
|
xs: {
|
|
@@ -60,6 +72,12 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
|
60
72
|
dialog: string;
|
|
61
73
|
};
|
|
62
74
|
};
|
|
75
|
+
padding: {
|
|
76
|
+
none: {
|
|
77
|
+
dialogContainer: string;
|
|
78
|
+
body: string;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
63
81
|
}>, {
|
|
64
82
|
size: {
|
|
65
83
|
xs: {
|
|
@@ -78,6 +96,12 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
|
78
96
|
dialog: string;
|
|
79
97
|
};
|
|
80
98
|
};
|
|
99
|
+
padding: {
|
|
100
|
+
none: {
|
|
101
|
+
dialogContainer: string;
|
|
102
|
+
body: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
81
105
|
}, {
|
|
82
106
|
base: string;
|
|
83
107
|
dialog: string;
|
|
@@ -103,6 +127,12 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
|
103
127
|
dialog: string;
|
|
104
128
|
};
|
|
105
129
|
};
|
|
130
|
+
padding: {
|
|
131
|
+
none: {
|
|
132
|
+
dialogContainer: string;
|
|
133
|
+
body: string;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
106
136
|
}, {
|
|
107
137
|
base: string;
|
|
108
138
|
dialog: string;
|
|
@@ -128,6 +158,12 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
|
128
158
|
dialog: string;
|
|
129
159
|
};
|
|
130
160
|
};
|
|
161
|
+
padding: {
|
|
162
|
+
none: {
|
|
163
|
+
dialogContainer: string;
|
|
164
|
+
body: string;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
131
167
|
}, {
|
|
132
168
|
size: {
|
|
133
169
|
xs: {
|
|
@@ -146,10 +182,26 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
|
146
182
|
dialog: string;
|
|
147
183
|
};
|
|
148
184
|
};
|
|
185
|
+
padding: {
|
|
186
|
+
none: {
|
|
187
|
+
dialogContainer: string;
|
|
188
|
+
body: string;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
149
191
|
}>, unknown, unknown, undefined>>;
|
|
150
192
|
type DialogVariants = VariantProps<typeof styles>;
|
|
151
193
|
export interface DialogProps extends DialogVariants {
|
|
152
194
|
children?: any;
|
|
153
195
|
class?: string;
|
|
196
|
+
id?: string;
|
|
197
|
+
open?: boolean;
|
|
198
|
+
closeOnClickOutside?: boolean;
|
|
199
|
+
closeButton?: boolean;
|
|
200
|
+
header?: any;
|
|
201
|
+
footer?: any;
|
|
202
|
+
position?: 'top' | 'center';
|
|
203
|
+
staticRender?: boolean;
|
|
204
|
+
triggerRef?: HTMLElement;
|
|
205
|
+
focusTriggerAfterClose?: boolean;
|
|
154
206
|
}
|
|
155
207
|
export {};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import IconX from "../icons/IconX.svelte";
|
|
4
4
|
import {Button} from "../button";
|
|
5
5
|
import './dialog.scss'
|
|
6
|
+
import {sleep} from "../../internal/helpers/sleep";
|
|
6
7
|
|
|
7
8
|
let {
|
|
8
9
|
children, open = $bindable(),
|
|
@@ -12,29 +13,42 @@
|
|
|
12
13
|
header,
|
|
13
14
|
footer,
|
|
14
15
|
class: className,
|
|
16
|
+
position = 'center',
|
|
17
|
+
padding,
|
|
18
|
+
staticRender = false,
|
|
19
|
+
triggerRef,
|
|
20
|
+
focusTriggerAfterClose,
|
|
15
21
|
...props
|
|
16
|
-
}: DialogProps
|
|
17
|
-
id?: string
|
|
18
|
-
open?: boolean
|
|
19
|
-
closeOnClickOutside?: boolean
|
|
20
|
-
closeButton?: boolean,
|
|
21
|
-
header?: any,
|
|
22
|
-
footer?: any,
|
|
23
|
-
} = $props();
|
|
22
|
+
}: DialogProps = $props();
|
|
24
23
|
|
|
25
24
|
let dialog;
|
|
26
25
|
|
|
26
|
+
let hasOpened = $state(false);
|
|
27
|
+
|
|
27
28
|
// Watch for prop changes to open/close the dialog
|
|
28
29
|
$effect(() => {
|
|
29
|
-
if (open)
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
if (open) {
|
|
31
|
+
stillAnimating = open
|
|
32
|
+
dialog?.showModal();
|
|
33
|
+
|
|
34
|
+
if (!hasOpened)
|
|
35
|
+
hasOpened = true
|
|
36
|
+
} else {
|
|
37
|
+
dialog?.close()
|
|
38
|
+
sleep(200).then(() => {
|
|
39
|
+
stillAnimating = open
|
|
40
|
+
console.log('stillAnimating', stillAnimating)
|
|
41
|
+
})
|
|
32
42
|
|
|
43
|
+
if (focusTriggerAfterClose && hasOpened && triggerRef) {
|
|
44
|
+
triggerRef.focus()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
})
|
|
33
48
|
|
|
34
49
|
// Close dialog on clicking outside (optional)
|
|
35
|
-
function handleClickOutside(
|
|
36
|
-
if (closeOnClickOutside &&
|
|
37
|
-
open = false;
|
|
50
|
+
function handleClickOutside(e) {
|
|
51
|
+
if (closeOnClickOutside && e.target === dialog) {
|
|
38
52
|
dialog?.close();
|
|
39
53
|
}
|
|
40
54
|
}
|
|
@@ -46,43 +60,48 @@
|
|
|
46
60
|
|
|
47
61
|
// onmousedown={closeOnClickOutside ? 'event.target==this && this.close()' : ''}
|
|
48
62
|
|
|
49
|
-
const {base, dialog: dialogStyle, dialogContainer, header: headerStyle, body, footer: footerStyle} = styles({
|
|
63
|
+
const {base, dialog: dialogStyle, dialogContainer, header: headerStyle, body, footer: footerStyle} = styles({
|
|
64
|
+
size,
|
|
65
|
+
padding
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
let stillAnimating = $state()
|
|
69
|
+
|
|
50
70
|
</script>
|
|
51
71
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
</form>
|
|
71
|
-
{/if}
|
|
72
|
+
{#if staticRender || (!staticRender && (open || stillAnimating))}
|
|
73
|
+
<dialog class={dialogStyle() + ` ${className}`}
|
|
74
|
+
data-position={position}
|
|
75
|
+
bind:this={dialog}
|
|
76
|
+
onclose={handleClose}
|
|
77
|
+
onmousedown={handleClickOutside}
|
|
78
|
+
>
|
|
79
|
+
<button class=""></button>
|
|
80
|
+
<div class={"dialog-box " + dialogContainer()}>
|
|
81
|
+
{#if (closeButton)}
|
|
82
|
+
<form method="dialog">
|
|
83
|
+
<Button class="absolute right-1 top-1 [&>svg]:opacity-45 [&>svg]:hover:opacity-90 z-10" icon
|
|
84
|
+
variant="ghost"
|
|
85
|
+
size="sm">
|
|
86
|
+
<IconX/>
|
|
87
|
+
</Button>
|
|
88
|
+
</form>
|
|
89
|
+
{/if}
|
|
72
90
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
{#if header}
|
|
92
|
+
<header class={headerStyle()}>
|
|
93
|
+
{@render header?.()}
|
|
94
|
+
</header>
|
|
95
|
+
{/if}
|
|
78
96
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
</dialog>
|
|
97
|
+
<main class={body()}>
|
|
98
|
+
{@render children?.()}
|
|
99
|
+
</main>
|
|
100
|
+
{#if footer}
|
|
101
|
+
<footer class={footerStyle()}>
|
|
102
|
+
{@render footer?.()}
|
|
103
|
+
</footer>
|
|
104
|
+
{/if}
|
|
105
|
+
</div>
|
|
106
|
+
</dialog>
|
|
107
|
+
{/if}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { type DialogProps } from "./Dialog";
|
|
2
2
|
import './dialog.scss';
|
|
3
|
-
declare const Dialog: import("svelte").Component<DialogProps
|
|
4
|
-
id?: string;
|
|
5
|
-
open?: boolean;
|
|
6
|
-
closeOnClickOutside?: boolean;
|
|
7
|
-
closeButton?: boolean;
|
|
8
|
-
header?: any;
|
|
9
|
-
footer?: any;
|
|
10
|
-
}, {}, "open">;
|
|
3
|
+
declare const Dialog: import("svelte").Component<DialogProps, {}, "open">;
|
|
11
4
|
export default Dialog;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
.dialog-box {
|
|
2
|
-
max-height: min(calc(100svh -
|
|
2
|
+
max-height: min(calc(100svh - 2rem), 50rem);
|
|
3
3
|
overflow-y: auto;
|
|
4
4
|
overscroll-behavior: contain;
|
|
5
5
|
display: grid;
|
|
6
6
|
grid-template-rows: auto 1fr auto;
|
|
7
7
|
@apply bg-neutral-token-1 relative;
|
|
8
|
+
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
dialog, dialog:modal {
|
|
@@ -13,14 +14,21 @@ dialog, dialog:modal {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
dialog {
|
|
16
|
-
|
|
17
|
+
&[data-position="top"] {
|
|
18
|
+
position: fixed;
|
|
19
|
+
top: 0;
|
|
20
|
+
left: 50%;
|
|
21
|
+
transform: translateX(-50%) translateY(-1rem);
|
|
22
|
+
margin: 0;
|
|
23
|
+
}
|
|
17
24
|
|
|
25
|
+
|
|
26
|
+
--transition-duration: 0.2s;
|
|
18
27
|
transform: translateY(0px);
|
|
19
28
|
|
|
20
29
|
&, &::backdrop {
|
|
21
30
|
transition: display var(--transition-duration) allow-discrete, overlay var(--transition-duration) allow-discrete, opacity var(--transition-duration), transform var(--transition-duration) allow-discrete,;
|
|
22
31
|
opacity: 0;
|
|
23
|
-
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
&[open] {
|
|
@@ -31,8 +39,15 @@ dialog {
|
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
&:not([open]) {
|
|
42
|
+
transform: translateX(0) translateY(-40px);
|
|
43
|
+
|
|
44
|
+
&[data-position="top"] {
|
|
45
|
+
top: 0;
|
|
46
|
+
left: 50%;
|
|
47
|
+
transform: translateX(-50%) translateY(-40px);
|
|
48
|
+
}
|
|
49
|
+
|
|
34
50
|
opacity: 0;
|
|
35
|
-
transform: translateY(-40px) scale(1); /* Reset to initial closed position */
|
|
36
51
|
|
|
37
52
|
&::backdrop {
|
|
38
53
|
opacity: 0; /* Fade-out backdrop */
|
|
@@ -41,8 +56,13 @@ dialog {
|
|
|
41
56
|
|
|
42
57
|
@starting-style {
|
|
43
58
|
&[open] {
|
|
44
|
-
transform: translateY(-40px)
|
|
59
|
+
transform: translateX(0) translateY(-40px);
|
|
45
60
|
|
|
61
|
+
&[data-position="top"] {
|
|
62
|
+
top: 0;
|
|
63
|
+
left: 50%;
|
|
64
|
+
transform: translateX(-50%) translateY(-40px);
|
|
65
|
+
}
|
|
46
66
|
}
|
|
47
67
|
|
|
48
68
|
&[open],
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
<img class="size-6 flag-img" src={getFlagUrl(currentLangItem.flag)} alt={currentLangItem.flag}>
|
|
82
82
|
</button>
|
|
83
83
|
|
|
84
|
-
<Dialog bind:open={openDialog} class="text-neutral-token-13" size="xs">
|
|
84
|
+
<Dialog bind:open={openDialog} class="text-neutral-token-13" size="xs" staticRender>
|
|
85
85
|
{#snippet header()}
|
|
86
86
|
Select language
|
|
87
87
|
{/snippet}
|
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
|
|
7
7
|
let {children, ...props}: LightDarkToggleProps = $props();
|
|
8
8
|
|
|
9
|
-
$effect(() => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
9
|
+
// $effect(() => {
|
|
10
|
+
// const htmlElement = document.documentElement;
|
|
11
|
+
// // Check for saved theme preference
|
|
12
|
+
// const currentTheme = localStorage.getItem('theme');
|
|
13
|
+
// if (currentTheme === 'dark') {
|
|
14
|
+
// htmlElement.classList.add('dark');
|
|
15
|
+
// } else {
|
|
16
|
+
// htmlElement.classList.remove('dark');
|
|
17
|
+
// }
|
|
18
|
+
// })
|
|
19
19
|
|
|
20
20
|
function toggleLightDarkTheme() {
|
|
21
21
|
const htmlElement = document.documentElement;
|
|
@@ -4,13 +4,18 @@
|
|
|
4
4
|
import {cn} from "../../utils/utils";
|
|
5
5
|
|
|
6
6
|
import {clickOutside} from "../../actions/clickOutside"
|
|
7
|
+
import {onDestroy, onMount} from "svelte";
|
|
7
8
|
|
|
8
9
|
let {
|
|
9
|
-
children,
|
|
10
|
+
children,
|
|
11
|
+
triggerRef,
|
|
12
|
+
class: className,
|
|
13
|
+
open = $bindable(),
|
|
10
14
|
offset: offsetAmount = 3,
|
|
11
15
|
padding: paddingAmount = 12,
|
|
12
16
|
focusTriggerAfterClose = true,
|
|
13
17
|
flip: enableFlip = false,
|
|
18
|
+
autoTrigger = true,
|
|
14
19
|
...props
|
|
15
20
|
}: PopoverProps = $props();
|
|
16
21
|
|
|
@@ -71,12 +76,20 @@
|
|
|
71
76
|
});
|
|
72
77
|
}
|
|
73
78
|
|
|
79
|
+
onMount(() => {
|
|
80
|
+
if (autoTrigger)
|
|
81
|
+
triggerRef?.addEventListener("click", togglePopover);
|
|
82
|
+
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
onDestroy(() => {
|
|
86
|
+
if (autoTrigger)
|
|
87
|
+
triggerRef?.removeEventListener("click", togglePopover);
|
|
88
|
+
|
|
89
|
+
})
|
|
74
90
|
|
|
75
91
|
$effect(() => {
|
|
76
92
|
let cleanup: any
|
|
77
|
-
if (triggerRef) {
|
|
78
|
-
triggerRef.addEventListener("click", togglePopover);
|
|
79
|
-
}
|
|
80
93
|
|
|
81
94
|
if (open) {
|
|
82
95
|
hasOpenedYet = true
|
|
@@ -91,21 +104,16 @@
|
|
|
91
104
|
} else {
|
|
92
105
|
cleanup?.()
|
|
93
106
|
if (focusTriggerAfterClose && hasOpenedYet) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
}, 100)
|
|
107
|
+
try {
|
|
108
|
+
triggerRef.focus()
|
|
109
|
+
} catch (e) {
|
|
110
|
+
console.warn('Trigger element focus after close Popover error', e)
|
|
111
|
+
}
|
|
101
112
|
}
|
|
102
113
|
}
|
|
103
114
|
|
|
104
115
|
return () => {
|
|
105
116
|
cleanup?.()
|
|
106
|
-
if (triggerRef) {
|
|
107
|
-
triggerRef.removeEventListener("click", togglePopover);
|
|
108
|
-
}
|
|
109
117
|
}
|
|
110
118
|
})
|
|
111
119
|
</script>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type VariantProps } from "tailwind-variants";
|
|
2
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{}, undefined, "", import("tailwind-variants/dist/config").TVConfig<{}, {}>, {}, undefined, import("tailwind-variants").TVReturnType<{}, undefined, "", import("tailwind-variants/dist/config").TVConfig<{}, {}>, unknown, unknown, undefined>>;
|
|
3
|
+
type PopoverResponsiveVariants = VariantProps<typeof styles>;
|
|
4
|
+
export interface PopoverResponsiveProps extends PopoverResponsiveVariants {
|
|
5
|
+
children?: any;
|
|
6
|
+
class?: string;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type PopoverResponsiveProps} from "./PopoverResponsive";
|
|
3
|
+
import {Dialog, Popover} from "../..";
|
|
4
|
+
import {onMount} from "svelte";
|
|
5
|
+
import {getScreenWidth, SCREEN_BREAK_POINTS} from "../side-navigation/SideNavigation";
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
triggerRef,
|
|
10
|
+
class: className,
|
|
11
|
+
open = $bindable(),
|
|
12
|
+
offset = 3,
|
|
13
|
+
popoverPadding = 12,
|
|
14
|
+
focusTriggerAfterClose = true,
|
|
15
|
+
flip = false,
|
|
16
|
+
...props
|
|
17
|
+
}: PopoverResponsiveProps & {
|
|
18
|
+
dialogPadding?: string,
|
|
19
|
+
popoverPadding?: number,
|
|
20
|
+
offset?: number,
|
|
21
|
+
open?: boolean,
|
|
22
|
+
focusTriggerAfterClose?: boolean,
|
|
23
|
+
flip?: boolean,
|
|
24
|
+
triggerRef?: HTMLElement,
|
|
25
|
+
} = $props();
|
|
26
|
+
|
|
27
|
+
let openPopover = $state(false)
|
|
28
|
+
let openDialog = $state(false)
|
|
29
|
+
|
|
30
|
+
$effect(() => {
|
|
31
|
+
open = openPopover || openDialog
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
$effect(() => {
|
|
35
|
+
toggleOpen(open)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
function toggleOpen(open?: boolean) {
|
|
39
|
+
if (getScreenWidth() >= SCREEN_BREAK_POINTS.sm) {
|
|
40
|
+
if (open === undefined) {
|
|
41
|
+
openPopover = !(openDialog || openPopover)
|
|
42
|
+
} else {
|
|
43
|
+
openPopover = open
|
|
44
|
+
}
|
|
45
|
+
openDialog = false
|
|
46
|
+
} else {
|
|
47
|
+
if (open === undefined) {
|
|
48
|
+
openDialog = !(openDialog || openPopover)
|
|
49
|
+
} else {
|
|
50
|
+
openDialog = open
|
|
51
|
+
}
|
|
52
|
+
openPopover = false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
console.log('toggleOpen Responsive Popover', open)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
onMount(() => {
|
|
59
|
+
triggerRef?.addEventListener('click', () => {
|
|
60
|
+
toggleOpen()
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
<Popover bind:open={openPopover}
|
|
67
|
+
triggerRef={triggerRef}
|
|
68
|
+
autoTrigger={false}
|
|
69
|
+
padding={popoverPadding}
|
|
70
|
+
focusTriggerAfterClose={focusTriggerAfterClose}
|
|
71
|
+
offset={offset}
|
|
72
|
+
flip={flip}
|
|
73
|
+
class={className}
|
|
74
|
+
{...props}
|
|
75
|
+
>
|
|
76
|
+
{@render children?.()}
|
|
77
|
+
</Popover>
|
|
78
|
+
|
|
79
|
+
<Dialog bind:open={openDialog}
|
|
80
|
+
position="top"
|
|
81
|
+
padding="none"
|
|
82
|
+
class={className}
|
|
83
|
+
triggerRef={triggerRef}
|
|
84
|
+
focusTriggerAfterClose={focusTriggerAfterClose}
|
|
85
|
+
>
|
|
86
|
+
{@render children?.()}
|
|
87
|
+
</Dialog>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type PopoverResponsiveProps } from "./PopoverResponsive";
|
|
2
|
+
declare const PopoverResponsive: import("svelte").Component<PopoverResponsiveProps & {
|
|
3
|
+
dialogPadding?: string;
|
|
4
|
+
popoverPadding?: number;
|
|
5
|
+
offset?: number;
|
|
6
|
+
open?: boolean;
|
|
7
|
+
focusTriggerAfterClose?: boolean;
|
|
8
|
+
flip?: boolean;
|
|
9
|
+
triggerRef?: HTMLElement;
|
|
10
|
+
}, {}, "open">;
|
|
11
|
+
export default PopoverResponsive;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as PopoverResponsive } from './PopoverResponsive.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as PopoverResponsive } from './PopoverResponsive.svelte';
|
|
@@ -5,7 +5,7 @@ export interface SideNavigationProps extends SideNavigationVariants {
|
|
|
5
5
|
children?: any;
|
|
6
6
|
class?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const SCREEN_BREAK_POINTS: {
|
|
9
9
|
sm: number;
|
|
10
10
|
md: number;
|
|
11
11
|
lg: number;
|
|
@@ -14,5 +14,6 @@ export declare const BEAK_POINTS: {
|
|
|
14
14
|
export declare const mainLayout: () => HTMLElement | null;
|
|
15
15
|
export declare const getSideNavState: () => string | undefined;
|
|
16
16
|
export declare const setSideNavState: (state: any) => void;
|
|
17
|
+
export declare function getScreenWidth(): number;
|
|
17
18
|
export declare function toggleSideNavigation(): void;
|
|
18
19
|
export {};
|
|
@@ -5,7 +5,7 @@ export const styles = tv({
|
|
|
5
5
|
compoundVariants: [],
|
|
6
6
|
defaultVariants: {},
|
|
7
7
|
});
|
|
8
|
-
export const
|
|
8
|
+
export const SCREEN_BREAK_POINTS = {
|
|
9
9
|
sm: 640,
|
|
10
10
|
md: 768,
|
|
11
11
|
lg: 1024,
|
|
@@ -23,17 +23,20 @@ export const setSideNavState = (state) => {
|
|
|
23
23
|
mainLayout()?.removeAttribute('data-side-nav-state');
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
+
export function getScreenWidth() {
|
|
27
|
+
return Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
|
|
28
|
+
}
|
|
26
29
|
export function toggleSideNavigation() {
|
|
27
|
-
let screenWidth =
|
|
30
|
+
let screenWidth = getScreenWidth();
|
|
28
31
|
let currentSideNavState = getSideNavState();
|
|
29
32
|
let state;
|
|
30
|
-
if (screenWidth <
|
|
33
|
+
if (screenWidth < SCREEN_BREAK_POINTS.md) {
|
|
31
34
|
state = currentSideNavState == undefined ? "expand" : undefined;
|
|
32
35
|
}
|
|
33
|
-
else if (screenWidth >=
|
|
36
|
+
else if (screenWidth >= SCREEN_BREAK_POINTS.md && screenWidth < SCREEN_BREAK_POINTS.xl) {
|
|
34
37
|
state = currentSideNavState == undefined ? "expand" : undefined;
|
|
35
38
|
}
|
|
36
|
-
else if (screenWidth >=
|
|
39
|
+
else if (screenWidth >= SCREEN_BREAK_POINTS.xl) {
|
|
37
40
|
state = currentSideNavState == undefined ? "compact" : undefined;
|
|
38
41
|
}
|
|
39
42
|
setSideNavState(state);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
SCREEN_BREAK_POINTS,
|
|
4
4
|
mainLayout,
|
|
5
5
|
setSideNavState,
|
|
6
6
|
type SideNavigationProps,
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
|
|
26
26
|
function handleClickOutside() {
|
|
27
27
|
let screenWidth = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0)
|
|
28
|
-
if (screenWidth <
|
|
28
|
+
if (screenWidth < SCREEN_BREAK_POINTS.md) {
|
|
29
29
|
setSideNavState(undefined)
|
|
30
|
-
} else if (screenWidth >=
|
|
30
|
+
} else if (screenWidth >= SCREEN_BREAK_POINTS.md && screenWidth < SCREEN_BREAK_POINTS.xl) {
|
|
31
31
|
setSideNavState(undefined)
|
|
32
|
-
} else if (screenWidth >=
|
|
32
|
+
} else if (screenWidth >= SCREEN_BREAK_POINTS.xl) {
|
|
33
33
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
{#each NAV_ITEM as item}
|
|
100
100
|
<SideNavItem href={item.href} class={isSelected(item.href) ? 'selected' : ''}>
|
|
101
101
|
{#snippet icon()}
|
|
102
|
-
<
|
|
102
|
+
<item.icon/>
|
|
103
103
|
{/snippet}
|
|
104
104
|
{item.title}
|
|
105
105
|
</SideNavItem>
|
package/dist/index.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export { Input } from './components/input';
|
|
|
9
9
|
export { LanguagePickerButton } from './components/language-picker-button';
|
|
10
10
|
export { LightDarkToggle } from './components/light-dark-toggle';
|
|
11
11
|
export { Popover } from './components/popover';
|
|
12
|
+
export { PopoverResponsive } from './components/popover-responsive';
|
|
12
13
|
export { SideNavigation, SideNavigationLayout, toggleSideNavigation } from './components/side-navigation';
|
|
13
14
|
export { TeraUiContext } from './components/tera-ui-context';
|
package/dist/index.js
CHANGED
|
@@ -9,5 +9,6 @@ export { Input } from './components/input';
|
|
|
9
9
|
export { LanguagePickerButton } from './components/language-picker-button';
|
|
10
10
|
export { LightDarkToggle } from './components/light-dark-toggle';
|
|
11
11
|
export { Popover } from './components/popover';
|
|
12
|
+
export { PopoverResponsive } from './components/popover-responsive';
|
|
12
13
|
export { SideNavigation, SideNavigationLayout, toggleSideNavigation } from './components/side-navigation';
|
|
13
14
|
export { TeraUiContext } from './components/tera-ui-context';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tera-system-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite dev",
|
|
6
6
|
"build": "vite build && npm run package",
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@floating-ui/dom": "^1.6.12",
|
|
91
|
-
"@inlang/paraglide-sveltekit": "0.11.5"
|
|
91
|
+
"@inlang/paraglide-sveltekit": "0.11.5",
|
|
92
|
+
"@tabler/icons-svelte": "^3.21.0"
|
|
92
93
|
}
|
|
93
94
|
}
|