@hyvor/design 0.0.67 → 0.0.68
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 +2 -7
- package/dist/components/ActionList/ActionListGroup.svelte +24 -29
- package/dist/components/ActionList/ActionListItem.svelte +86 -88
- package/dist/components/ActionList/Selected.svelte +17 -20
- package/dist/components/Avatar/Avatar.svelte +7 -11
- package/dist/components/Avatar/AvatarStack.svelte +16 -20
- package/dist/components/Base/Base.svelte +3 -3
- package/dist/components/Box/Box.svelte +8 -8
- package/dist/components/Button/Button.svelte +33 -42
- package/dist/components/Button/ButtonGroup.svelte +6 -6
- package/dist/components/Callout/Callout.svelte +88 -86
- package/dist/components/Callout/Callout.svelte.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.svelte +113 -121
- package/dist/components/CodeBlock/CodeBlock.svelte +26 -23
- package/dist/components/CodeBlock/getCode.js +6 -6
- package/dist/components/CodeBlock/hljs.scss +189 -191
- package/dist/components/CodeBlock/prism.scss +370 -7
- package/dist/components/ColorPicker/ColorPicker.svelte +42 -42
- package/dist/components/Dark/DarkProvider.svelte +9 -9
- package/dist/components/Dark/DarkToggle.svelte +7 -10
- package/dist/components/Divider/Divider.svelte +6 -7
- package/dist/components/Dropdown/Dropdown.svelte +33 -108
- package/dist/components/Dropdown/DropdownContent.svelte +120 -0
- package/dist/components/Dropdown/DropdownContent.svelte.d.ts +24 -0
- package/dist/components/FormControl/Caption.svelte +9 -9
- package/dist/components/FormControl/FormControl.svelte +18 -18
- package/dist/components/FormControl/InputGroup.svelte +7 -8
- package/dist/components/FormControl/Label.svelte +5 -5
- package/dist/components/FormControl/Validation.svelte +18 -16
- package/dist/components/FormControl/Validation.svelte.d.ts +1 -1
- package/dist/components/HyvorBar/BarProducts.svelte +52 -0
- package/dist/components/HyvorBar/BarProducts.svelte.d.ts +39 -0
- package/dist/components/HyvorBar/BarSupport.svelte +119 -0
- package/dist/components/HyvorBar/BarSupport.svelte.d.ts +19 -0
- package/dist/components/HyvorBar/BarUpdates.svelte +58 -0
- package/dist/components/HyvorBar/BarUpdates.svelte.d.ts +18 -0
- package/dist/components/HyvorBar/BarUpdatesList.svelte +134 -0
- package/dist/components/HyvorBar/BarUpdatesList.svelte.d.ts +18 -0
- package/dist/components/HyvorBar/BarUser.svelte +60 -0
- package/dist/components/HyvorBar/BarUser.svelte.d.ts +16 -0
- package/dist/components/HyvorBar/BarUserPreview.svelte +42 -0
- package/dist/components/HyvorBar/BarUserPreview.svelte.d.ts +14 -0
- package/dist/components/HyvorBar/HyvorBar.svelte +150 -0
- package/dist/components/HyvorBar/HyvorBar.svelte.d.ts +19 -0
- package/dist/components/HyvorBar/bar.d.ts +33 -0
- package/dist/components/HyvorBar/bar.js +74 -0
- package/dist/components/HyvorBar/img/G2.svelte +9 -0
- package/dist/components/HyvorBar/img/G2.svelte.d.ts +23 -0
- package/dist/components/HyvorBar/img/Trustpilot.svelte +11 -0
- package/dist/components/HyvorBar/img/Trustpilot.svelte.d.ts +23 -0
- package/dist/components/IconButton/IconButton.svelte +19 -23
- package/dist/components/IconMessage/IconMessage.svelte +89 -38
- package/dist/components/IconMessage/IconMessage.svelte.d.ts +9 -1
- package/dist/components/Internationalization/InternationalizationProvider.svelte +2 -2
- package/dist/components/Internationalization/InternationalizationProvider.svelte.d.ts +1 -1
- package/dist/components/Internationalization/LanguageToggle.svelte +33 -36
- package/dist/components/Internationalization/LanguageToggle.svelte.d.ts +2 -2
- package/dist/components/Internationalization/T.svelte.d.ts +3 -3
- package/dist/components/Internationalization/i18n.d.ts +4 -4
- package/dist/components/Internationalization/i18n.js +13 -11
- package/dist/components/Internationalization/t.d.ts +3 -3
- package/dist/components/Internationalization/t.js +4 -4
- package/dist/components/Internationalization/types.d.ts +1 -1
- package/dist/components/Link/Link.svelte +53 -58
- package/dist/components/Loader/LoadButton.svelte +15 -29
- package/dist/components/Loader/Loader.svelte +56 -69
- package/dist/components/Modal/ConfirmModalProvider.svelte +18 -36
- package/dist/components/Modal/Modal.svelte +134 -164
- package/dist/components/Modal/ModalFooter.svelte +23 -26
- package/dist/components/Modal/confirm.d.ts +1 -1
- package/dist/components/Modal/confirm.js +4 -4
- package/dist/components/Modal/modal-types.d.ts +2 -2
- package/dist/components/NavLink/NavLink.svelte +78 -86
- package/dist/components/Radio/Radio.svelte +23 -31
- package/dist/components/Slider/Slider.svelte +71 -79
- package/dist/components/SplitControl/SplitControl.svelte +28 -42
- package/dist/components/Switch/Switch.svelte +60 -65
- package/dist/components/TabNav/TabNav.svelte +6 -10
- package/dist/components/TabNav/TabNavItem.svelte +36 -43
- package/dist/components/Table/Table.svelte +7 -4
- package/dist/components/Table/TableRow.svelte +23 -23
- package/dist/components/Tag/Tag.svelte +28 -36
- package/dist/components/Text/Text.svelte +15 -22
- package/dist/components/TextInput/TextInput.svelte +26 -26
- package/dist/components/Textarea/Textarea.svelte +38 -38
- package/dist/components/Toast/ToastIcon.svelte +29 -31
- package/dist/components/Toast/ToastMessage.svelte +33 -39
- package/dist/components/Toast/ToastProvider.svelte +16 -16
- package/dist/components/Toast/cleaner.js +5 -5
- package/dist/components/Toast/toast.d.ts +2 -2
- package/dist/components/Toast/toast.js +10 -10
- package/dist/components/Tooltip/Tooltip.svelte +82 -83
- package/dist/components/directives/clickOutside.js +4 -4
- package/dist/components/directives/debounce.d.ts +1 -0
- package/dist/components/directives/debounce.js +8 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/index.css +31 -33
- package/dist/marketing/Container/Container.svelte +8 -8
- package/dist/marketing/Docs/Content/Content.svelte +8 -7
- package/dist/marketing/Docs/Content/DocsImage.svelte +52 -62
- package/dist/marketing/Docs/Docs.svelte +21 -24
- package/dist/marketing/Docs/Nav/Nav.svelte +21 -22
- package/dist/marketing/Docs/Nav/NavCategory.svelte +28 -28
- package/dist/marketing/Docs/Nav/NavItem.svelte +21 -24
- package/dist/marketing/Docs/Sidebar/Sidebar.svelte +22 -25
- package/dist/marketing/Docs/Toc.svelte +17 -19
- package/dist/marketing/Document/Document.svelte +5 -5
- package/dist/marketing/Document/DocumentTitle.svelte +49 -49
- package/dist/marketing/Footer/Footer.svelte +111 -119
- package/dist/marketing/Footer/FooterLinkList.svelte +24 -26
- package/dist/marketing/Header/Header.svelte +7 -15
- package/dist/marketing/Logo/LogoBlogs.svelte +41 -0
- package/dist/marketing/Logo/LogoBlogs.svelte.d.ts +16 -0
- package/dist/marketing/Logo/LogoCore.svelte +41 -0
- package/dist/marketing/Logo/LogoCore.svelte.d.ts +16 -0
- package/dist/marketing/Logo/LogoFortguard.svelte +49 -0
- package/dist/marketing/Logo/LogoFortguard.svelte.d.ts +16 -0
- package/dist/marketing/Logo/LogoTalk.svelte +27 -0
- package/dist/marketing/Logo/LogoTalk.svelte.d.ts +16 -0
- package/dist/stores/dark.js +8 -8
- package/dist/variables.scss +41 -48
- package/package.json +59 -58
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} G2Props */
|
|
2
|
+
/** @typedef {typeof __propDef.events} G2Events */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} G2Slots */
|
|
4
|
+
export default class G2 extends SvelteComponent<{
|
|
5
|
+
[x: string]: never;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {}> {
|
|
9
|
+
}
|
|
10
|
+
export type G2Props = typeof __propDef.props;
|
|
11
|
+
export type G2Events = typeof __propDef.events;
|
|
12
|
+
export type G2Slots = typeof __propDef.slots;
|
|
13
|
+
import { SvelteComponent } from "svelte";
|
|
14
|
+
declare const __propDef: {
|
|
15
|
+
props: {
|
|
16
|
+
[x: string]: never;
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {};
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg
|
|
2
|
+
fill="#000000"
|
|
3
|
+
width="12"
|
|
4
|
+
height="12"
|
|
5
|
+
viewBox="0 0 24 24"
|
|
6
|
+
role="img"
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
><path
|
|
9
|
+
d="M12,17.964l5.214-1.321l2.179,6.714L12,17.964z M24,9.286h-9.179L12,0.643L9.179,9.286 H0l7.429,5.357l-2.821,8.643l7.429-5.357l4.571-3.286L24,9.286L24,9.286L24,9.286L24,9.286z"
|
|
10
|
+
/>
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} TrustpilotProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} TrustpilotEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} TrustpilotSlots */
|
|
4
|
+
export default class Trustpilot extends SvelteComponent<{
|
|
5
|
+
[x: string]: never;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {}> {
|
|
9
|
+
}
|
|
10
|
+
export type TrustpilotProps = typeof __propDef.props;
|
|
11
|
+
export type TrustpilotEvents = typeof __propDef.events;
|
|
12
|
+
export type TrustpilotSlots = typeof __propDef.slots;
|
|
13
|
+
import { SvelteComponent } from "svelte";
|
|
14
|
+
declare const __propDef: {
|
|
15
|
+
props: {
|
|
16
|
+
[x: string]: never;
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {};
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -11,29 +11,25 @@ size = (typeof size === "number" ? size : sizes[size]) + "px";
|
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
<svelte:element
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
role="button"
|
|
32
|
-
tabindex="0"
|
|
33
|
-
|
|
34
|
-
{...$$restProps}
|
|
14
|
+
this={as}
|
|
15
|
+
class="button {color} {variant}"
|
|
16
|
+
style:width={size}
|
|
17
|
+
style:height={size}
|
|
18
|
+
on:keyup
|
|
19
|
+
on:keydown
|
|
20
|
+
on:keypress
|
|
21
|
+
on:focus
|
|
22
|
+
on:blur
|
|
23
|
+
on:click
|
|
24
|
+
on:mouseover
|
|
25
|
+
on:mouseenter
|
|
26
|
+
on:mouseleave
|
|
27
|
+
on:change
|
|
28
|
+
role="button"
|
|
29
|
+
tabindex="0"
|
|
30
|
+
{...$$restProps}
|
|
35
31
|
>
|
|
36
|
-
|
|
32
|
+
<slot />
|
|
37
33
|
</svelte:element>
|
|
38
34
|
|
|
39
35
|
<style>.button {
|
|
@@ -239,4 +235,4 @@ size = (typeof size === "number" ? size : sizes[size]) + "px";
|
|
|
239
235
|
cursor: not-allowed;
|
|
240
236
|
opacity: 0.2;
|
|
241
237
|
box-shadow: none !important;
|
|
242
|
-
}</style>
|
|
238
|
+
}</style>
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import {} from "svelte";
|
|
2
|
+
import { IconBug, IconInbox } from "@hyvor/icons";
|
|
3
|
+
import Button from "../Button/Button.svelte";
|
|
4
|
+
export let size = "medium";
|
|
2
5
|
export let icon = null;
|
|
3
6
|
export let message = null;
|
|
4
|
-
export let iconSize =
|
|
5
|
-
|
|
7
|
+
export let iconSize = void 0;
|
|
8
|
+
const iconsSizes = {
|
|
9
|
+
small: 35,
|
|
10
|
+
medium: 50,
|
|
11
|
+
large: 75
|
|
12
|
+
};
|
|
13
|
+
iconSize = iconSize || iconsSizes[size];
|
|
14
|
+
export let padding = void 0;
|
|
15
|
+
const paddings = {
|
|
16
|
+
small: 15,
|
|
17
|
+
medium: 40,
|
|
18
|
+
large: 60
|
|
19
|
+
};
|
|
20
|
+
padding = padding === void 0 ? paddings[size] : padding;
|
|
6
21
|
export let empty = false;
|
|
7
22
|
export let error = false;
|
|
8
23
|
export let iconColor = null;
|
|
@@ -12,46 +27,82 @@ if (empty) {
|
|
|
12
27
|
}
|
|
13
28
|
if (error) {
|
|
14
29
|
message = message || "Something went wrong";
|
|
15
|
-
icon =
|
|
16
|
-
iconColor = iconColor || "var(--
|
|
30
|
+
icon = IconBug;
|
|
31
|
+
iconColor = iconColor || "var(--gray-dark)";
|
|
17
32
|
}
|
|
18
33
|
iconColor = iconColor || "var(--gray-dark)";
|
|
34
|
+
export let cta = null;
|
|
35
|
+
function onCtaClick(e) {
|
|
36
|
+
if (cta) {
|
|
37
|
+
cta.onClick(e);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
19
40
|
</script>
|
|
20
41
|
|
|
21
|
-
<div class="icon-message" style:padding={padding +
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
<div class="icon-message {size}" style:padding={padding + 'px'}>
|
|
43
|
+
<div class="icon" style:color={iconColor} {...$$restProps}>
|
|
44
|
+
{#if $$slots.icon}
|
|
45
|
+
<slot name="icon" />
|
|
46
|
+
{:else if icon}
|
|
47
|
+
<svelte:component this={icon} size={iconSize + 'px'} />
|
|
48
|
+
{/if}
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<div class="message">
|
|
52
|
+
{#if $$slots.default}
|
|
53
|
+
<slot />
|
|
54
|
+
{:else if $$slots.message}
|
|
55
|
+
<slot name="message" />
|
|
56
|
+
{:else if message}
|
|
57
|
+
{message}
|
|
58
|
+
{/if}
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
{#if cta || $$slots.cta}
|
|
62
|
+
<div class="cta">
|
|
63
|
+
{#if $$slots.cta}
|
|
64
|
+
<slot name="cta" />
|
|
65
|
+
{:else}
|
|
66
|
+
<Button on:click={onCtaClick} {size} {...cta?.props}>
|
|
67
|
+
{cta?.text}
|
|
68
|
+
</Button>
|
|
69
|
+
{/if}
|
|
70
|
+
</div>
|
|
71
|
+
{/if}
|
|
37
72
|
</div>
|
|
38
73
|
|
|
39
74
|
<style>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
.icon-message {
|
|
76
|
+
width: 100%;
|
|
77
|
+
height: 100%;
|
|
78
|
+
flex: 1;
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
position: relative;
|
|
83
|
+
flex-direction: column; /* Change to column direction */
|
|
84
|
+
text-align: center;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.icon {
|
|
88
|
+
display: inline-flex;
|
|
89
|
+
align-items: flex-end;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.message {
|
|
93
|
+
/* Add message styles here */
|
|
94
|
+
color: var(--text-light);
|
|
95
|
+
margin-top: 10px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.icon-message.small .message {
|
|
99
|
+
margin-top: 8px;
|
|
100
|
+
}
|
|
101
|
+
.icon-message.large .message {
|
|
102
|
+
margin-top: 13px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.cta {
|
|
106
|
+
margin-top: 15px;
|
|
107
|
+
}
|
|
57
108
|
</style>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type
|
|
2
|
+
import { type ComponentType } from 'svelte';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
[x: string]: any;
|
|
6
|
+
size?: "small" | "medium" | "large" | undefined;
|
|
6
7
|
icon?: ComponentType | null | undefined;
|
|
7
8
|
message?: string | null | undefined;
|
|
8
9
|
iconSize?: number | undefined;
|
|
@@ -10,13 +11,20 @@ declare const __propDef: {
|
|
|
10
11
|
empty?: boolean | undefined;
|
|
11
12
|
error?: boolean | undefined;
|
|
12
13
|
iconColor?: string | null | undefined;
|
|
14
|
+
cta?: {
|
|
15
|
+
text: string;
|
|
16
|
+
onClick: (e: MouseEvent) => void;
|
|
17
|
+
props?: Record<string, any> | undefined;
|
|
18
|
+
} | null | undefined;
|
|
13
19
|
};
|
|
14
20
|
events: {
|
|
15
21
|
[evt: string]: CustomEvent<any>;
|
|
16
22
|
};
|
|
17
23
|
slots: {
|
|
18
24
|
icon: {};
|
|
25
|
+
default: {};
|
|
19
26
|
message: {};
|
|
27
|
+
cta: {};
|
|
20
28
|
};
|
|
21
29
|
};
|
|
22
30
|
export type IconMessageProps = typeof __propDef.props;
|
|
@@ -21,43 +21,40 @@ function handleClick(language) {
|
|
|
21
21
|
}
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
|
-
|
|
25
24
|
{#if i18n && $currentLanguage}
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
</Dropdown>
|
|
55
|
-
|
|
25
|
+
<Dropdown bind:show {position} {align}>
|
|
26
|
+
<span slot="trigger">
|
|
27
|
+
{#if icon}
|
|
28
|
+
<IconButton color="input" {size}>
|
|
29
|
+
{$currentLanguage.flag}
|
|
30
|
+
</IconButton>
|
|
31
|
+
{:else}
|
|
32
|
+
<Button color="input" {size}>
|
|
33
|
+
<span slot="start">{$currentLanguage.flag}</span>
|
|
34
|
+
{$currentLanguage.name}
|
|
35
|
+
<svelte:component this={caret} slot="end" size={12} />
|
|
36
|
+
</Button>
|
|
37
|
+
{/if}
|
|
38
|
+
</span>
|
|
39
|
+
<ActionList slot="content">
|
|
40
|
+
{#each i18n.languages as language (language.code)}
|
|
41
|
+
<ActionListItem on:click={() => handleClick(language)}>
|
|
42
|
+
<span class="flag" slot="start">{language.flag}</span>
|
|
43
|
+
<span class="name">
|
|
44
|
+
{language.name}
|
|
45
|
+
</span>
|
|
46
|
+
<Text small light>
|
|
47
|
+
{language.region}
|
|
48
|
+
</Text>
|
|
49
|
+
</ActionListItem>
|
|
50
|
+
{/each}
|
|
51
|
+
</ActionList>
|
|
52
|
+
</Dropdown>
|
|
56
53
|
{/if}
|
|
57
54
|
|
|
58
55
|
<style>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
</style>
|
|
56
|
+
.flag {
|
|
57
|
+
margin-right: 6px;
|
|
58
|
+
font-size: 20px;
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { type ComponentProps, type ComponentType } from
|
|
3
|
-
import Dropdown from
|
|
2
|
+
import { type ComponentProps, type ComponentType } from 'svelte';
|
|
3
|
+
import Dropdown from '../Dropdown/Dropdown.svelte';
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
6
|
position?: ComponentProps<Dropdown>['position'];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { type ToDotPaths, type I18nStrings } from
|
|
3
|
-
import { type ComponentType } from
|
|
4
|
-
import { type PrimitiveType } from
|
|
2
|
+
import { type ToDotPaths, type I18nStrings } from './types.js';
|
|
3
|
+
import { type ComponentType } from 'svelte';
|
|
4
|
+
import { type PrimitiveType } from 'intl-messageformat';
|
|
5
5
|
declare class __sveltets_Render<StringsT extends I18nStrings> {
|
|
6
6
|
props(): {
|
|
7
7
|
key: ToDotPaths<StringsT>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="svelte" />
|
|
2
|
-
import type { PrimitiveType } from
|
|
3
|
-
import { type Readable, type Writable } from
|
|
4
|
-
import T from
|
|
5
|
-
import type { ToDotPaths, I18nStrings } from
|
|
2
|
+
import type { PrimitiveType } from 'intl-messageformat';
|
|
3
|
+
import { type Readable, type Writable } from 'svelte/store';
|
|
4
|
+
import T from './T.svelte';
|
|
5
|
+
import type { ToDotPaths, I18nStrings } from './types.js';
|
|
6
6
|
export type i18nLoaderType = () => Promise<any>;
|
|
7
7
|
interface LanguageBase {
|
|
8
8
|
name: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { deepmerge } from
|
|
2
|
-
import { writable, derived } from
|
|
3
|
-
import { t } from
|
|
4
|
-
import T from
|
|
1
|
+
import { deepmerge } from 'deepmerge-ts';
|
|
2
|
+
import { writable, derived } from 'svelte/store';
|
|
3
|
+
import { t } from './t.js';
|
|
4
|
+
import T from './T.svelte';
|
|
5
5
|
export class InternationalizationService {
|
|
6
6
|
languages = [];
|
|
7
7
|
locale;
|
|
@@ -10,7 +10,7 @@ export class InternationalizationService {
|
|
|
10
10
|
stringsCache = new Map();
|
|
11
11
|
defaultStrings;
|
|
12
12
|
constructor(languages) {
|
|
13
|
-
const defaultLanguage = languages.find(l => l.default);
|
|
13
|
+
const defaultLanguage = languages.find((l) => l.default);
|
|
14
14
|
if (!defaultLanguage) {
|
|
15
15
|
throw new Error('Default language not found');
|
|
16
16
|
}
|
|
@@ -19,7 +19,7 @@ export class InternationalizationService {
|
|
|
19
19
|
throw new Error('Default strings not found for the default language');
|
|
20
20
|
}
|
|
21
21
|
this.locale = writable(defaultLanguage.code);
|
|
22
|
-
this.localeLanguage = derived(this.locale, $locale => this.languageByCode($locale));
|
|
22
|
+
this.localeLanguage = derived(this.locale, ($locale) => this.languageByCode($locale));
|
|
23
23
|
this.defaultStrings = defaultStrings;
|
|
24
24
|
this.strings.set(this.defaultStrings);
|
|
25
25
|
this.stringsCache.set(defaultLanguage.code, this.defaultStrings);
|
|
@@ -39,7 +39,9 @@ export class InternationalizationService {
|
|
|
39
39
|
this.locale.set(code);
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
|
-
this.languageByCode(code)
|
|
42
|
+
this.languageByCode(code)
|
|
43
|
+
?.loader()
|
|
44
|
+
.then(({ default: strings }) => {
|
|
43
45
|
this.stringsCache.set(code, strings);
|
|
44
46
|
this.setStrings(code);
|
|
45
47
|
this.locale.set(code);
|
|
@@ -49,16 +51,16 @@ export class InternationalizationService {
|
|
|
49
51
|
register(language) {
|
|
50
52
|
this.languages.push({
|
|
51
53
|
...language,
|
|
52
|
-
loader: language.hasOwnProperty('strings')
|
|
53
|
-
() => Promise.resolve(language.strings)
|
|
54
|
-
language.loader
|
|
54
|
+
loader: language.hasOwnProperty('strings')
|
|
55
|
+
? () => Promise.resolve(language.strings)
|
|
56
|
+
: language.loader
|
|
55
57
|
});
|
|
56
58
|
}
|
|
57
59
|
found(code) {
|
|
58
60
|
return !!this.languageByCode(code);
|
|
59
61
|
}
|
|
60
62
|
languageByCode(code) {
|
|
61
|
-
return this.languages.find(l => l.code === code);
|
|
63
|
+
return this.languages.find((l) => l.code === code);
|
|
62
64
|
}
|
|
63
65
|
t(key, params = {}) {
|
|
64
66
|
return t(key, params, this);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type PrimitiveType } from
|
|
2
|
-
import { type InternationalizationService } from
|
|
3
|
-
import type { I18nStrings, ToDotPaths } from
|
|
1
|
+
import { type PrimitiveType } from 'intl-messageformat';
|
|
2
|
+
import { type InternationalizationService } from './i18n.js';
|
|
3
|
+
import type { I18nStrings, ToDotPaths } from './types.js';
|
|
4
4
|
type ParamValue = PrimitiveType | ((chunks: string | string[]) => string);
|
|
5
5
|
type ParamsType = Record<string, ParamValue>;
|
|
6
6
|
export declare function getMessage(key: string, params: ParamsType, $strings: Record<string, any>, $locale: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IntlMessageFormat } from
|
|
2
|
-
import { getContext } from
|
|
3
|
-
import { get } from
|
|
4
|
-
import { getStringByKey } from
|
|
1
|
+
import { IntlMessageFormat } from 'intl-messageformat';
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
import { get } from 'svelte/store';
|
|
4
|
+
import { getStringByKey } from './i18n.js';
|
|
5
5
|
export function getMessage(key, params, $strings, $locale) {
|
|
6
6
|
const string = getStringByKey($strings, key);
|
|
7
7
|
if (string) {
|
|
@@ -2,6 +2,6 @@ export type I18nStrings = {
|
|
|
2
2
|
[key: string]: string | I18nStrings;
|
|
3
3
|
};
|
|
4
4
|
export type ToDotPaths<T> = T extends object ? {
|
|
5
|
-
[K in keyof T]: `${Exclude<K, symbol>}${
|
|
5
|
+
[K in keyof T]: `${Exclude<K, symbol>}${'' | `.${ToDotPaths<T[K]>}`}`;
|
|
6
6
|
}[keyof T] : never;
|
|
7
7
|
export type FromDotPath<T, K extends string> = K extends keyof T ? T[K] : K extends `${infer K0}.${infer KR}` ? K0 extends keyof T ? FromDotPath<T[K0], KR> : never : never;
|
|
@@ -4,69 +4,64 @@ export let underline = true;
|
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
6
|
<a
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
on:change
|
|
22
|
-
|
|
23
|
-
{...$$restProps}
|
|
7
|
+
{href}
|
|
8
|
+
class="color-{color}"
|
|
9
|
+
class:underline
|
|
10
|
+
on:keyup
|
|
11
|
+
on:keydown
|
|
12
|
+
on:keypress
|
|
13
|
+
on:focus
|
|
14
|
+
on:blur
|
|
15
|
+
on:click
|
|
16
|
+
on:mouseover
|
|
17
|
+
on:mouseenter
|
|
18
|
+
on:mouseleave
|
|
19
|
+
on:change
|
|
20
|
+
{...$$restProps}
|
|
24
21
|
>
|
|
22
|
+
{#if $$slots.start}
|
|
23
|
+
<span class="slot start-slot"><slot name="start" /></span>
|
|
24
|
+
{/if}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
<span class="slot start-slot"><slot name="start" /></span>
|
|
28
|
-
{/if}
|
|
29
|
-
|
|
30
|
-
<slot />
|
|
31
|
-
|
|
32
|
-
{#if $$slots.end}
|
|
33
|
-
<span class="slot end-slot"><slot name="end" /></span>
|
|
34
|
-
{/if}
|
|
26
|
+
<slot />
|
|
35
27
|
|
|
28
|
+
{#if $$slots.end}
|
|
29
|
+
<span class="slot end-slot"><slot name="end" /></span>
|
|
30
|
+
{/if}
|
|
36
31
|
</a>
|
|
37
32
|
|
|
38
33
|
<style>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
34
|
+
a {
|
|
35
|
+
display: inline-flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
color: var(--local-color);
|
|
38
|
+
}
|
|
39
|
+
a.color-link {
|
|
40
|
+
--local-color: var(--link);
|
|
41
|
+
}
|
|
42
|
+
a.color-accent {
|
|
43
|
+
--local-color: var(--accent);
|
|
44
|
+
}
|
|
45
|
+
a.color-text {
|
|
46
|
+
--local-color: var(--text);
|
|
47
|
+
}
|
|
48
|
+
a.underline {
|
|
49
|
+
text-decoration: underline;
|
|
50
|
+
text-decoration-color: var(--local-color);
|
|
51
|
+
}
|
|
52
|
+
a:not(.underline):hover {
|
|
53
|
+
text-decoration: underline;
|
|
54
|
+
}
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
.slot {
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
}
|
|
65
60
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</style>
|
|
61
|
+
.start-slot {
|
|
62
|
+
margin-right: 4px;
|
|
63
|
+
}
|
|
64
|
+
.end-slot {
|
|
65
|
+
margin-left: 4px;
|
|
66
|
+
}
|
|
67
|
+
</style>
|