@hyvor/design 0.0.68 → 1.0.3
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/ActionList/ActionList.svelte +22 -9
- package/dist/components/ActionList/ActionList.svelte.d.ts +8 -20
- package/dist/components/ActionList/ActionListGroup.svelte +18 -8
- package/dist/components/ActionList/ActionListGroup.svelte.d.ts +8 -20
- package/dist/components/ActionList/ActionListItem.svelte +49 -25
- package/dist/components/ActionList/ActionListItem.svelte.d.ts +27 -25
- package/dist/components/ActionList/Selected.svelte +10 -4
- package/dist/components/ActionList/Selected.svelte.d.ts +6 -17
- package/dist/components/Avatar/Avatar.svelte +16 -9
- package/dist/components/Avatar/Avatar.svelte.d.ts +7 -18
- package/dist/components/Avatar/AvatarStack.svelte +14 -8
- package/dist/components/Avatar/AvatarStack.svelte.d.ts +6 -18
- package/dist/components/Base/Base.svelte +14 -6
- package/dist/components/Base/Base.svelte.d.ts +6 -18
- package/dist/components/Box/Box.svelte +10 -3
- package/dist/components/Box/Box.svelte.d.ts +7 -19
- package/dist/components/Button/Button.svelte +52 -25
- package/dist/components/Button/Button.svelte.d.ts +16 -39
- package/dist/components/Button/ButtonGroup.svelte +9 -1
- package/dist/components/Button/ButtonGroup.svelte.d.ts +5 -27
- package/dist/components/Callout/Callout.svelte +41 -20
- package/dist/components/Callout/Callout.svelte.d.ts +11 -23
- package/dist/components/Checkbox/Checkbox.svelte +58 -38
- package/dist/components/Checkbox/Checkbox.svelte.d.ts +11 -34
- package/dist/components/CodeBlock/CodeBlock.svelte +21 -11
- package/dist/components/CodeBlock/CodeBlock.svelte.d.ts +6 -17
- package/dist/components/CodeBlock/getCode.js +2 -0
- package/dist/components/ColorPicker/ColorPicker.svelte +34 -15
- package/dist/components/ColorPicker/ColorPicker.svelte.d.ts +25 -19
- package/dist/components/Dark/DarkProvider.svelte +7 -5
- package/dist/components/Dark/DarkProvider.svelte.d.ts +16 -12
- package/dist/components/Dark/DarkToggle.svelte +8 -6
- package/dist/components/Dark/DarkToggle.svelte.d.ts +16 -12
- package/dist/components/Divider/Divider.svelte +17 -6
- package/dist/components/Divider/Divider.svelte.d.ts +9 -20
- package/dist/components/Dropdown/Dropdown.svelte +33 -14
- package/dist/components/Dropdown/Dropdown.svelte.d.ts +13 -24
- package/dist/components/Dropdown/DropdownContent.svelte +124 -92
- package/dist/components/Dropdown/DropdownContent.svelte.d.ts +12 -24
- package/dist/components/FormControl/Caption.svelte +10 -3
- package/dist/components/FormControl/Caption.svelte.d.ts +7 -19
- package/dist/components/FormControl/FormControl.svelte +11 -2
- package/dist/components/FormControl/FormControl.svelte.d.ts +6 -27
- package/dist/components/FormControl/InputGroup.svelte +17 -9
- package/dist/components/FormControl/InputGroup.svelte.d.ts +7 -19
- package/dist/components/FormControl/Label.svelte +11 -2
- package/dist/components/FormControl/Label.svelte.d.ts +6 -27
- package/dist/components/FormControl/Validation.svelte +18 -9
- package/dist/components/FormControl/Validation.svelte.d.ts +8 -20
- package/dist/components/HyvorBar/BarProducts.svelte +44 -25
- package/dist/components/HyvorBar/BarProducts.svelte.d.ts +14 -21
- package/dist/components/HyvorBar/BarSupport.svelte +165 -101
- package/dist/components/HyvorBar/BarSupport.svelte.d.ts +7 -18
- package/dist/components/HyvorBar/BarUpdates.svelte +25 -15
- package/dist/components/HyvorBar/BarUpdates.svelte.d.ts +6 -17
- package/dist/components/HyvorBar/BarUpdatesList.svelte +73 -48
- package/dist/components/HyvorBar/BarUpdatesList.svelte.d.ts +6 -17
- package/dist/components/HyvorBar/BarUser.svelte +36 -24
- package/dist/components/HyvorBar/BarUser.svelte.d.ts +5 -16
- package/dist/components/HyvorBar/BarUserPreview.svelte +2 -1
- package/dist/components/HyvorBar/BarUserPreview.svelte.d.ts +16 -12
- package/dist/components/HyvorBar/HyvorBar.svelte +69 -36
- package/dist/components/HyvorBar/HyvorBar.svelte.d.ts +7 -18
- package/dist/components/HyvorBar/bar.d.ts +2 -2
- package/dist/components/HyvorBar/img/G2.svelte.d.ts +22 -19
- package/dist/components/HyvorBar/img/Trustpilot.svelte.d.ts +22 -19
- package/dist/components/IconButton/IconButton.svelte +43 -22
- package/dist/components/IconButton/IconButton.svelte.d.ts +10 -33
- package/dist/components/IconMessage/IconMessage.svelte +111 -56
- package/dist/components/IconMessage/IconMessage.svelte.d.ts +19 -35
- package/dist/components/Internationalization/InternationalizationProvider.svelte +14 -7
- package/dist/components/Internationalization/InternationalizationProvider.svelte.d.ts +6 -18
- package/dist/components/Internationalization/LanguageToggle.svelte +73 -47
- package/dist/components/Internationalization/LanguageToggle.svelte.d.ts +10 -21
- package/dist/components/Internationalization/T.svelte +158 -114
- package/dist/components/Internationalization/T.svelte.d.ts +17 -15
- package/dist/components/Internationalization/i18n.d.ts +1 -3
- package/dist/components/Internationalization/t.d.ts +1 -2
- package/dist/components/Internationalization/types.d.ts +1 -0
- package/dist/components/Link/Link.svelte +31 -19
- package/dist/components/Link/Link.svelte.d.ts +11 -34
- package/dist/components/Loader/LoadButton.svelte +24 -9
- package/dist/components/Loader/LoadButton.svelte.d.ts +29 -42
- package/dist/components/Loader/Loader.svelte +69 -42
- package/dist/components/Loader/Loader.svelte.d.ts +15 -27
- package/dist/components/Modal/ConfirmModalProvider.svelte +28 -20
- package/dist/components/Modal/ConfirmModalProvider.svelte.d.ts +3 -14
- package/dist/components/Modal/Modal.svelte +76 -47
- package/dist/components/Modal/Modal.svelte.d.ts +31 -29
- package/dist/components/Modal/ModalFooter.svelte +14 -6
- package/dist/components/Modal/ModalFooter.svelte.d.ts +22 -18
- package/dist/components/Modal/confirm.d.ts +2 -2
- package/dist/components/Modal/modal-types.d.ts +2 -2
- package/dist/components/NavLink/NavLink.svelte +31 -18
- package/dist/components/NavLink/NavLink.svelte.d.ts +11 -33
- package/dist/components/Radio/Radio.svelte +35 -16
- package/dist/components/Radio/Radio.svelte.d.ts +10 -33
- package/dist/components/Slider/Slider.svelte +53 -36
- package/dist/components/Slider/Slider.svelte.d.ts +24 -20
- package/dist/components/SplitControl/SplitControl.svelte +27 -18
- package/dist/components/SplitControl/SplitControl.svelte.d.ts +11 -24
- package/dist/components/Switch/Switch.svelte +30 -15
- package/dist/components/Switch/Switch.svelte.d.ts +8 -31
- package/dist/components/TabNav/TabNav.svelte +29 -15
- package/dist/components/TabNav/TabNav.svelte.d.ts +7 -19
- package/dist/components/TabNav/TabNavItem.svelte +36 -15
- package/dist/components/TabNav/TabNavItem.svelte.d.ts +10 -24
- package/dist/components/Table/Table.svelte +11 -4
- package/dist/components/Table/Table.svelte.d.ts +7 -19
- package/dist/components/Table/TableRow.svelte +11 -3
- package/dist/components/Table/TableRow.svelte.d.ts +7 -19
- package/dist/components/Tag/Tag.svelte +65 -31
- package/dist/components/Tag/Tag.svelte.d.ts +16 -39
- package/dist/components/Text/Text.svelte +20 -6
- package/dist/components/Text/Text.svelte.d.ts +10 -22
- package/dist/components/TextInput/TextInput.svelte +42 -21
- package/dist/components/TextInput/TextInput.svelte.d.ts +12 -36
- package/dist/components/Textarea/Textarea.svelte +46 -24
- package/dist/components/Textarea/Textarea.svelte.d.ts +13 -37
- package/dist/components/Toast/ToastIcon.svelte +26 -15
- package/dist/components/Toast/ToastIcon.svelte.d.ts +5 -16
- package/dist/components/Toast/ToastMessage.svelte +11 -4
- package/dist/components/Toast/ToastMessage.svelte.d.ts +5 -16
- package/dist/components/Toast/ToastProvider.svelte +6 -4
- package/dist/components/Toast/ToastProvider.svelte.d.ts +16 -12
- package/dist/components/Toast/toast.d.ts +2 -2
- package/dist/components/Tooltip/Tooltip.svelte +71 -55
- package/dist/components/Tooltip/Tooltip.svelte.d.ts +35 -23
- package/dist/marketing/Container/Container.svelte +8 -2
- package/dist/marketing/Container/Container.svelte.d.ts +6 -18
- package/dist/marketing/Docs/Content/Content.svelte +41 -29
- package/dist/marketing/Docs/Content/Content.svelte.d.ts +5 -16
- package/dist/marketing/Docs/Content/DocsImage.svelte +17 -9
- package/dist/marketing/Docs/Content/DocsImage.svelte.d.ts +9 -20
- package/dist/marketing/Docs/Docs.svelte +9 -3
- package/dist/marketing/Docs/Docs.svelte.d.ts +6 -29
- package/dist/marketing/Docs/Nav/Nav.svelte +77 -50
- package/dist/marketing/Docs/Nav/Nav.svelte.d.ts +5 -16
- package/dist/marketing/Docs/Nav/NavCategory.svelte +16 -6
- package/dist/marketing/Docs/Nav/NavCategory.svelte.d.ts +8 -20
- package/dist/marketing/Docs/Nav/NavItem.svelte +10 -3
- package/dist/marketing/Docs/Nav/NavItem.svelte.d.ts +6 -18
- package/dist/marketing/Docs/Sidebar/Sidebar.svelte.d.ts +22 -19
- package/dist/marketing/Docs/Toc.svelte +49 -39
- package/dist/marketing/Docs/Toc.svelte.d.ts +3 -14
- package/dist/marketing/Document/Document.svelte +11 -4
- package/dist/marketing/Document/Document.svelte.d.ts +7 -19
- package/dist/marketing/Document/DocumentTitle.svelte +16 -5
- package/dist/marketing/Document/DocumentTitle.svelte.d.ts +9 -20
- package/dist/marketing/Footer/Footer.svelte +55 -38
- package/dist/marketing/Footer/Footer.svelte.d.ts +8 -20
- package/dist/marketing/Footer/FooterLinkList.svelte +8 -2
- package/dist/marketing/Footer/FooterLinkList.svelte.d.ts +6 -18
- package/dist/marketing/Header/Header.svelte +41 -23
- package/dist/marketing/Header/Header.svelte.d.ts +10 -22
- package/dist/marketing/Logo/LogoBlogs.svelte +6 -1
- package/dist/marketing/Logo/LogoBlogs.svelte.d.ts +5 -16
- package/dist/marketing/Logo/LogoCore.svelte +6 -1
- package/dist/marketing/Logo/LogoCore.svelte.d.ts +5 -16
- package/dist/marketing/Logo/LogoFortguard.svelte +7 -2
- package/dist/marketing/Logo/LogoFortguard.svelte.d.ts +5 -16
- package/dist/marketing/Logo/LogoTalk.svelte +6 -1
- package/dist/marketing/Logo/LogoTalk.svelte.d.ts +5 -16
- package/dist/stores/dark.d.ts +0 -1
- package/package.json +8 -8
|
@@ -1,33 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
keyup: KeyboardEvent;
|
|
12
|
-
keydown: KeyboardEvent;
|
|
13
|
-
keypress: KeyboardEvent;
|
|
14
|
-
focus: FocusEvent;
|
|
15
|
-
blur: FocusEvent;
|
|
16
|
-
click: MouseEvent;
|
|
17
|
-
mouseover: MouseEvent;
|
|
18
|
-
mouseenter: MouseEvent;
|
|
19
|
-
mouseleave: MouseEvent;
|
|
20
|
-
change: Event;
|
|
21
|
-
} & {
|
|
22
|
-
[evt: string]: CustomEvent<any>;
|
|
23
|
-
};
|
|
24
|
-
slots: {
|
|
25
|
-
default: {};
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export type IconButtonProps = typeof __propDef.props;
|
|
29
|
-
export type IconButtonEvents = typeof __propDef.events;
|
|
30
|
-
export type IconButtonSlots = typeof __propDef.slots;
|
|
31
|
-
export default class IconButton extends SvelteComponent<IconButtonProps, IconButtonEvents, IconButtonSlots> {
|
|
32
|
-
}
|
|
33
|
-
export {};
|
|
1
|
+
declare const IconButton: import("svelte").Component<{
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
size?: "small" | "medium" | "large" | number;
|
|
4
|
+
color?: "accent" | "gray" | "input" | "green" | "red" | "blue" | "orange";
|
|
5
|
+
variant?: "fill" | "fill-light" | "outline" | "outline-fill" | "invisible";
|
|
6
|
+
as?: "button" | "a";
|
|
7
|
+
children?: import("svelte").Snippet;
|
|
8
|
+
}, {}, "size">;
|
|
9
|
+
type IconButton = ReturnType<typeof IconButton>;
|
|
10
|
+
export default IconButton;
|
|
@@ -1,71 +1,126 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
iconColor
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { type Component, type Snippet } from 'svelte';
|
|
3
|
+
import { IconBug, IconInbox } from '@hyvor/icons';
|
|
4
|
+
import Button from '../Button/Button.svelte';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
size?: 'small' | 'medium' | 'large';
|
|
8
|
+
icon?: Component;
|
|
9
|
+
iconSize?: number;
|
|
10
|
+
padding?: number;
|
|
11
|
+
empty?: boolean;
|
|
12
|
+
error?: boolean;
|
|
13
|
+
iconColor?: string;
|
|
14
|
+
cta?:
|
|
15
|
+
| {
|
|
16
|
+
text: string;
|
|
17
|
+
onClick: (e: MouseEvent) => void;
|
|
18
|
+
props?: Record<string, any>;
|
|
19
|
+
}
|
|
20
|
+
| Snippet;
|
|
21
|
+
|
|
22
|
+
children?: Snippet;
|
|
23
|
+
message?: Snippet | string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let {
|
|
27
|
+
size = 'medium',
|
|
28
|
+
icon,
|
|
29
|
+
iconSize,
|
|
30
|
+
padding,
|
|
31
|
+
empty = false,
|
|
32
|
+
error = false,
|
|
33
|
+
iconColor,
|
|
34
|
+
cta,
|
|
35
|
+
|
|
36
|
+
children,
|
|
37
|
+
message,
|
|
38
|
+
|
|
39
|
+
...rest
|
|
40
|
+
}: Props = $props();
|
|
41
|
+
|
|
42
|
+
// export let size: 'small' | 'medium' | 'large' = 'medium';
|
|
43
|
+
|
|
44
|
+
// export let icon: ComponentType | null = null;
|
|
45
|
+
// export let message: string | null = null;
|
|
46
|
+
|
|
47
|
+
// export let iconSize: number | undefined = undefined;
|
|
48
|
+
const iconsSizes = {
|
|
49
|
+
small: 35,
|
|
50
|
+
medium: 50,
|
|
51
|
+
large: 75
|
|
52
|
+
};
|
|
53
|
+
iconSize = iconSize || iconsSizes[size];
|
|
54
|
+
|
|
55
|
+
// export let padding: number | undefined = undefined;
|
|
56
|
+
|
|
57
|
+
const paddings = {
|
|
58
|
+
small: 15,
|
|
59
|
+
medium: 40,
|
|
60
|
+
large: 60
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
padding = padding === undefined ? paddings[size] : padding;
|
|
64
|
+
|
|
65
|
+
//console.log(icon?.prototype);
|
|
66
|
+
// $inspect(icon?.prototype, icon?);
|
|
67
|
+
|
|
68
|
+
// export let empty: boolean = false;
|
|
69
|
+
// export let error: boolean = false;
|
|
70
|
+
|
|
71
|
+
// export let iconColor: string | null = null;
|
|
72
|
+
|
|
73
|
+
if (empty) {
|
|
74
|
+
message = message || 'No results found';
|
|
75
|
+
icon = IconInbox;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (error) {
|
|
79
|
+
message = message || 'Something went wrong';
|
|
80
|
+
icon = IconBug;
|
|
81
|
+
iconColor = iconColor || 'var(--gray-dark)';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const Icon = icon;
|
|
85
|
+
|
|
86
|
+
iconColor = iconColor || 'var(--gray-dark)';
|
|
87
|
+
|
|
88
|
+
// export let cta: {
|
|
89
|
+
// text: string;
|
|
90
|
+
// onClick: (e: MouseEvent) => void;
|
|
91
|
+
// props?: Record<string, any>;
|
|
92
|
+
// } | null = null;
|
|
93
|
+
|
|
94
|
+
function onCtaClick(e: MouseEvent) {
|
|
95
|
+
if (cta && typeof cta === 'object') {
|
|
96
|
+
cta.onClick(e);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
40
99
|
</script>
|
|
41
100
|
|
|
42
101
|
<div class="icon-message {size}" style:padding={padding + 'px'}>
|
|
43
|
-
<div class="icon" style:color={iconColor} {
|
|
44
|
-
{
|
|
45
|
-
<slot name="icon" />
|
|
46
|
-
{:else if icon}
|
|
47
|
-
<svelte:component this={icon} size={iconSize + 'px'} />
|
|
48
|
-
{/if}
|
|
102
|
+
<div class="icon" style:color={iconColor} {...rest}>
|
|
103
|
+
<Icon size={iconSize + 'px'} />
|
|
49
104
|
</div>
|
|
50
105
|
|
|
51
106
|
<div class="message">
|
|
52
|
-
{#if
|
|
53
|
-
|
|
54
|
-
{:else if
|
|
55
|
-
<slot name="message" />
|
|
56
|
-
{:else if message}
|
|
107
|
+
{#if children}
|
|
108
|
+
{@render children()}
|
|
109
|
+
{:else if typeof message === 'string'}
|
|
57
110
|
{message}
|
|
111
|
+
{:else if message}
|
|
112
|
+
{@render message()}
|
|
58
113
|
{/if}
|
|
59
114
|
</div>
|
|
60
115
|
|
|
61
|
-
{#if cta
|
|
116
|
+
{#if cta}
|
|
62
117
|
<div class="cta">
|
|
63
|
-
{#if
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
<Button on:click={onCtaClick} {size} {...cta?.props}>
|
|
67
|
-
{cta?.text}
|
|
118
|
+
{#if typeof cta === 'object'}
|
|
119
|
+
<Button on:click={onCtaClick} {size} {...cta.props}>
|
|
120
|
+
{cta.text}
|
|
68
121
|
</Button>
|
|
122
|
+
{:else}
|
|
123
|
+
{@render cta()}
|
|
69
124
|
{/if}
|
|
70
125
|
</div>
|
|
71
126
|
{/if}
|
|
@@ -1,35 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
events: {
|
|
21
|
-
[evt: string]: CustomEvent<any>;
|
|
22
|
-
};
|
|
23
|
-
slots: {
|
|
24
|
-
icon: {};
|
|
25
|
-
default: {};
|
|
26
|
-
message: {};
|
|
27
|
-
cta: {};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export type IconMessageProps = typeof __propDef.props;
|
|
31
|
-
export type IconMessageEvents = typeof __propDef.events;
|
|
32
|
-
export type IconMessageSlots = typeof __propDef.slots;
|
|
33
|
-
export default class IconMessage extends SvelteComponent<IconMessageProps, IconMessageEvents, IconMessageSlots> {
|
|
34
|
-
}
|
|
35
|
-
export {};
|
|
1
|
+
import { type Component, type Snippet } from 'svelte';
|
|
2
|
+
declare const IconMessage: Component<{
|
|
3
|
+
size?: "small" | "medium" | "large";
|
|
4
|
+
icon?: Component;
|
|
5
|
+
iconSize?: number;
|
|
6
|
+
padding?: number;
|
|
7
|
+
empty?: boolean;
|
|
8
|
+
error?: boolean;
|
|
9
|
+
iconColor?: string;
|
|
10
|
+
cta?: {
|
|
11
|
+
text: string;
|
|
12
|
+
onClick: (e: MouseEvent) => void;
|
|
13
|
+
props?: Record<string, any>;
|
|
14
|
+
} | Snippet;
|
|
15
|
+
children?: Snippet;
|
|
16
|
+
message?: Snippet | string;
|
|
17
|
+
}, {}, "">;
|
|
18
|
+
type IconMessage = ReturnType<typeof IconMessage>;
|
|
19
|
+
export default IconMessage;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { setContext } from 'svelte';
|
|
3
|
+
import { InternationalizationService, type Language } from './i18n.js';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
languages: Language[];
|
|
7
|
+
children?: import('svelte').Snippet;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let { languages, children }: Props = $props();
|
|
11
|
+
const i18n = new InternationalizationService(languages);
|
|
12
|
+
const locale = i18n.locale;
|
|
13
|
+
setContext('i18n', i18n);
|
|
7
14
|
</script>
|
|
8
15
|
|
|
9
16
|
{#key $locale}
|
|
10
|
-
|
|
17
|
+
{@render children?.()}
|
|
11
18
|
{/key}
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import { type Language } from './i18n.js';
|
|
3
|
-
declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
slots: {
|
|
11
|
-
default: {};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export type InternationalizationProviderProps = typeof __propDef.props;
|
|
15
|
-
export type InternationalizationProviderEvents = typeof __propDef.events;
|
|
16
|
-
export type InternationalizationProviderSlots = typeof __propDef.slots;
|
|
17
|
-
export default class InternationalizationProvider extends SvelteComponent<InternationalizationProviderProps, InternationalizationProviderEvents, InternationalizationProviderSlots> {
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
2
|
+
declare const InternationalizationProvider: import("svelte").Component<{
|
|
3
|
+
languages: Language[];
|
|
4
|
+
children?: import("svelte").Snippet;
|
|
5
|
+
}, {}, "">;
|
|
6
|
+
type InternationalizationProvider = ReturnType<typeof InternationalizationProvider>;
|
|
7
|
+
export default InternationalizationProvider;
|
|
@@ -1,54 +1,80 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, type Component, type ComponentProps } from 'svelte';
|
|
3
|
+
import Dropdown from '../Dropdown/Dropdown.svelte';
|
|
4
|
+
import Button from '../Button/Button.svelte';
|
|
5
|
+
import { type Language, type InternationalizationService } from './i18n.js';
|
|
6
|
+
import ActionList from '../ActionList/ActionList.svelte';
|
|
7
|
+
import ActionListItem from '../ActionList/ActionListItem.svelte';
|
|
8
|
+
import Text from '../Text/Text.svelte';
|
|
9
|
+
import { IconCaretDown } from '@hyvor/icons';
|
|
10
|
+
import IconButton from '../IconButton/IconButton.svelte';
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
position?: ComponentProps<typeof Dropdown>['position'];
|
|
14
|
+
align?: ComponentProps<typeof Dropdown>['align'];
|
|
15
|
+
caret?: Component;
|
|
16
|
+
icon?: boolean;
|
|
17
|
+
size?: 'medium' | 'small';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
position = 'bottom',
|
|
22
|
+
align = 'start',
|
|
23
|
+
caret = IconCaretDown,
|
|
24
|
+
icon = false,
|
|
25
|
+
size = 'medium'
|
|
26
|
+
}: Props = $props();
|
|
27
|
+
|
|
28
|
+
const i18n = getContext<InternationalizationService>('i18n');
|
|
29
|
+
const currentLanguage = i18n ? i18n.localeLanguage : undefined;
|
|
30
|
+
|
|
31
|
+
let show = $state(false);
|
|
32
|
+
|
|
33
|
+
function handleClick(language: Language) {
|
|
34
|
+
i18n.setLocale(language.code);
|
|
35
|
+
show = false;
|
|
36
|
+
}
|
|
22
37
|
</script>
|
|
23
38
|
|
|
24
39
|
{#if i18n && $currentLanguage}
|
|
25
40
|
<Dropdown bind:show {position} {align}>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
{#snippet trigger()}
|
|
42
|
+
<span>
|
|
43
|
+
{#if icon}
|
|
44
|
+
<IconButton color="input" {size}>
|
|
45
|
+
{$currentLanguage.flag}
|
|
46
|
+
</IconButton>
|
|
47
|
+
{:else}
|
|
48
|
+
<Button color="input" {size}>
|
|
49
|
+
{#snippet start()}
|
|
50
|
+
<span>{$currentLanguage.flag}</span>
|
|
51
|
+
{/snippet}
|
|
52
|
+
{$currentLanguage.name}
|
|
53
|
+
{#snippet end()}
|
|
54
|
+
{@const SvelteComponent = caret}
|
|
55
|
+
<SvelteComponent size={12} />
|
|
56
|
+
{/snippet}
|
|
57
|
+
</Button>
|
|
58
|
+
{/if}
|
|
59
|
+
</span>
|
|
60
|
+
{/snippet}
|
|
61
|
+
{#snippet content()}
|
|
62
|
+
<ActionList>
|
|
63
|
+
{#each i18n.languages as language (language.code)}
|
|
64
|
+
<ActionListItem on:click={() => handleClick(language)}>
|
|
65
|
+
{#snippet start()}
|
|
66
|
+
<span class="flag">{language.flag}</span>
|
|
67
|
+
{/snippet}
|
|
68
|
+
<span class="name">
|
|
69
|
+
{language.name}
|
|
70
|
+
</span>
|
|
71
|
+
<Text small light>
|
|
72
|
+
{language.region}
|
|
73
|
+
</Text>
|
|
74
|
+
</ActionListItem>
|
|
75
|
+
{/each}
|
|
76
|
+
</ActionList>
|
|
77
|
+
{/snippet}
|
|
52
78
|
</Dropdown>
|
|
53
79
|
{/if}
|
|
54
80
|
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type ComponentProps, type ComponentType } from 'svelte';
|
|
1
|
+
import { type Component, type ComponentProps } from 'svelte';
|
|
3
2
|
import Dropdown from '../Dropdown/Dropdown.svelte';
|
|
4
|
-
declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
[evt: string]: CustomEvent<any>;
|
|
14
|
-
};
|
|
15
|
-
slots: {};
|
|
16
|
-
};
|
|
17
|
-
export type LanguageToggleProps = typeof __propDef.props;
|
|
18
|
-
export type LanguageToggleEvents = typeof __propDef.events;
|
|
19
|
-
export type LanguageToggleSlots = typeof __propDef.slots;
|
|
20
|
-
export default class LanguageToggle extends SvelteComponent<LanguageToggleProps, LanguageToggleEvents, LanguageToggleSlots> {
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
3
|
+
declare const LanguageToggle: Component<{
|
|
4
|
+
position?: ComponentProps<typeof Dropdown>["position"];
|
|
5
|
+
align?: ComponentProps<typeof Dropdown>["align"];
|
|
6
|
+
caret?: Component;
|
|
7
|
+
icon?: boolean;
|
|
8
|
+
size?: "medium" | "small";
|
|
9
|
+
}, {}, "">;
|
|
10
|
+
type LanguageToggle = ReturnType<typeof LanguageToggle>;
|
|
11
|
+
export default LanguageToggle;
|