@hyvor/design 0.0.67 → 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 +21 -13
- package/dist/components/ActionList/ActionList.svelte.d.ts +8 -20
- package/dist/components/ActionList/ActionListGroup.svelte +40 -35
- package/dist/components/ActionList/ActionListGroup.svelte.d.ts +8 -20
- package/dist/components/ActionList/ActionListItem.svelte +129 -107
- package/dist/components/ActionList/ActionListItem.svelte.d.ts +27 -25
- package/dist/components/ActionList/Selected.svelte +27 -24
- package/dist/components/ActionList/Selected.svelte.d.ts +6 -17
- package/dist/components/Avatar/Avatar.svelte +22 -19
- package/dist/components/Avatar/Avatar.svelte.d.ts +7 -18
- package/dist/components/Avatar/AvatarStack.svelte +29 -27
- package/dist/components/Avatar/AvatarStack.svelte.d.ts +6 -18
- package/dist/components/Base/Base.svelte +16 -8
- package/dist/components/Base/Base.svelte.d.ts +6 -18
- package/dist/components/Box/Box.svelte +16 -9
- package/dist/components/Box/Box.svelte.d.ts +7 -19
- package/dist/components/Button/Button.svelte +65 -47
- package/dist/components/Button/Button.svelte.d.ts +16 -39
- package/dist/components/Button/ButtonGroup.svelte +14 -6
- package/dist/components/Button/ButtonGroup.svelte.d.ts +5 -27
- package/dist/components/Callout/Callout.svelte +110 -87
- package/dist/components/Callout/Callout.svelte.d.ts +11 -22
- package/dist/components/Checkbox/Checkbox.svelte +156 -144
- package/dist/components/Checkbox/Checkbox.svelte.d.ts +11 -34
- package/dist/components/CodeBlock/CodeBlock.svelte +45 -32
- package/dist/components/CodeBlock/CodeBlock.svelte.d.ts +6 -17
- package/dist/components/CodeBlock/getCode.js +8 -6
- package/dist/components/CodeBlock/hljs.scss +189 -191
- package/dist/components/CodeBlock/prism.scss +370 -7
- package/dist/components/ColorPicker/ColorPicker.svelte +75 -56
- package/dist/components/ColorPicker/ColorPicker.svelte.d.ts +25 -19
- package/dist/components/Dark/DarkProvider.svelte +16 -14
- package/dist/components/Dark/DarkProvider.svelte.d.ts +16 -12
- package/dist/components/Dark/DarkToggle.svelte +15 -16
- package/dist/components/Dark/DarkToggle.svelte.d.ts +16 -12
- package/dist/components/Divider/Divider.svelte +23 -13
- package/dist/components/Divider/Divider.svelte.d.ts +9 -20
- package/dist/components/Dropdown/Dropdown.svelte +58 -114
- package/dist/components/Dropdown/Dropdown.svelte.d.ts +13 -24
- package/dist/components/Dropdown/DropdownContent.svelte +152 -0
- package/dist/components/Dropdown/DropdownContent.svelte.d.ts +12 -0
- package/dist/components/FormControl/Caption.svelte +18 -11
- package/dist/components/FormControl/Caption.svelte.d.ts +7 -19
- package/dist/components/FormControl/FormControl.svelte +28 -19
- package/dist/components/FormControl/FormControl.svelte.d.ts +6 -27
- package/dist/components/FormControl/InputGroup.svelte +22 -15
- package/dist/components/FormControl/InputGroup.svelte.d.ts +7 -19
- package/dist/components/FormControl/Label.svelte +15 -6
- package/dist/components/FormControl/Label.svelte.d.ts +6 -27
- package/dist/components/FormControl/Validation.svelte +30 -19
- package/dist/components/FormControl/Validation.svelte.d.ts +9 -21
- package/dist/components/HyvorBar/BarProducts.svelte +71 -0
- package/dist/components/HyvorBar/BarProducts.svelte.d.ts +32 -0
- package/dist/components/HyvorBar/BarSupport.svelte +183 -0
- package/dist/components/HyvorBar/BarSupport.svelte.d.ts +8 -0
- package/dist/components/HyvorBar/BarUpdates.svelte +68 -0
- package/dist/components/HyvorBar/BarUpdates.svelte.d.ts +7 -0
- package/dist/components/HyvorBar/BarUpdatesList.svelte +159 -0
- package/dist/components/HyvorBar/BarUpdatesList.svelte.d.ts +7 -0
- package/dist/components/HyvorBar/BarUser.svelte +72 -0
- package/dist/components/HyvorBar/BarUser.svelte.d.ts +5 -0
- package/dist/components/HyvorBar/BarUserPreview.svelte +43 -0
- package/dist/components/HyvorBar/BarUserPreview.svelte.d.ts +18 -0
- package/dist/components/HyvorBar/HyvorBar.svelte +183 -0
- package/dist/components/HyvorBar/HyvorBar.svelte.d.ts +8 -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 +26 -0
- package/dist/components/HyvorBar/img/Trustpilot.svelte +11 -0
- package/dist/components/HyvorBar/img/Trustpilot.svelte.d.ts +26 -0
- package/dist/components/IconButton/IconButton.svelte +49 -32
- package/dist/components/IconButton/IconButton.svelte.d.ts +10 -33
- package/dist/components/IconMessage/IconMessage.svelte +157 -51
- package/dist/components/IconMessage/IconMessage.svelte.d.ts +19 -27
- package/dist/components/Internationalization/InternationalizationProvider.svelte +15 -8
- package/dist/components/Internationalization/InternationalizationProvider.svelte.d.ts +7 -19
- package/dist/components/Internationalization/LanguageToggle.svelte +80 -57
- package/dist/components/Internationalization/LanguageToggle.svelte.d.ts +11 -22
- 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 +3 -5
- package/dist/components/Internationalization/i18n.js +13 -11
- package/dist/components/Internationalization/t.d.ts +2 -3
- package/dist/components/Internationalization/t.js +4 -4
- package/dist/components/Internationalization/types.d.ts +2 -1
- package/dist/components/Link/Link.svelte +68 -61
- package/dist/components/Link/Link.svelte.d.ts +11 -34
- package/dist/components/Loader/LoadButton.svelte +39 -38
- package/dist/components/Loader/LoadButton.svelte.d.ts +29 -42
- package/dist/components/Loader/Loader.svelte +121 -107
- package/dist/components/Loader/Loader.svelte.d.ts +15 -27
- package/dist/components/Modal/ConfirmModalProvider.svelte +41 -51
- package/dist/components/Modal/ConfirmModalProvider.svelte.d.ts +3 -14
- package/dist/components/Modal/Modal.svelte +202 -203
- package/dist/components/Modal/Modal.svelte.d.ts +31 -29
- package/dist/components/Modal/ModalFooter.svelte +36 -31
- package/dist/components/Modal/ModalFooter.svelte.d.ts +22 -18
- package/dist/components/Modal/confirm.d.ts +2 -2
- package/dist/components/Modal/confirm.js +4 -4
- package/dist/components/Modal/modal-types.d.ts +4 -4
- package/dist/components/NavLink/NavLink.svelte +94 -89
- package/dist/components/NavLink/NavLink.svelte.d.ts +11 -33
- package/dist/components/Radio/Radio.svelte +46 -35
- package/dist/components/Radio/Radio.svelte.d.ts +10 -33
- package/dist/components/Slider/Slider.svelte +129 -120
- package/dist/components/Slider/Slider.svelte.d.ts +24 -20
- package/dist/components/SplitControl/SplitControl.svelte +43 -48
- package/dist/components/SplitControl/SplitControl.svelte.d.ts +11 -24
- package/dist/components/Switch/Switch.svelte +77 -67
- package/dist/components/Switch/Switch.svelte.d.ts +8 -31
- package/dist/components/TabNav/TabNav.svelte +33 -23
- package/dist/components/TabNav/TabNav.svelte.d.ts +7 -19
- package/dist/components/TabNav/TabNavItem.svelte +65 -51
- package/dist/components/TabNav/TabNavItem.svelte.d.ts +10 -24
- package/dist/components/Table/Table.svelte +17 -7
- package/dist/components/Table/Table.svelte.d.ts +7 -19
- package/dist/components/Table/TableRow.svelte +32 -24
- package/dist/components/Table/TableRow.svelte.d.ts +7 -19
- package/dist/components/Tag/Tag.svelte +75 -49
- package/dist/components/Tag/Tag.svelte.d.ts +16 -39
- package/dist/components/Text/Text.svelte +33 -26
- package/dist/components/Text/Text.svelte.d.ts +10 -22
- package/dist/components/TextInput/TextInput.svelte +54 -33
- package/dist/components/TextInput/TextInput.svelte.d.ts +12 -36
- package/dist/components/Textarea/Textarea.svelte +68 -46
- package/dist/components/Textarea/Textarea.svelte.d.ts +13 -37
- package/dist/components/Toast/ToastIcon.svelte +55 -46
- package/dist/components/Toast/ToastIcon.svelte.d.ts +5 -16
- package/dist/components/Toast/ToastMessage.svelte +42 -41
- package/dist/components/Toast/ToastMessage.svelte.d.ts +5 -16
- package/dist/components/Toast/ToastProvider.svelte +22 -20
- package/dist/components/Toast/ToastProvider.svelte.d.ts +16 -12
- package/dist/components/Toast/cleaner.js +5 -5
- package/dist/components/Toast/toast.d.ts +3 -3
- package/dist/components/Toast/toast.js +10 -10
- package/dist/components/Tooltip/Tooltip.svelte +163 -148
- package/dist/components/Tooltip/Tooltip.svelte.d.ts +35 -23
- 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 +15 -9
- package/dist/marketing/Container/Container.svelte.d.ts +6 -18
- package/dist/marketing/Docs/Content/Content.svelte +48 -35
- package/dist/marketing/Docs/Content/Content.svelte.d.ts +5 -16
- package/dist/marketing/Docs/Content/DocsImage.svelte +67 -69
- package/dist/marketing/Docs/Content/DocsImage.svelte.d.ts +9 -20
- package/dist/marketing/Docs/Docs.svelte +28 -25
- package/dist/marketing/Docs/Docs.svelte.d.ts +6 -29
- package/dist/marketing/Docs/Nav/Nav.svelte +96 -70
- package/dist/marketing/Docs/Nav/Nav.svelte.d.ts +5 -16
- package/dist/marketing/Docs/Nav/NavCategory.svelte +39 -29
- package/dist/marketing/Docs/Nav/NavCategory.svelte.d.ts +8 -20
- package/dist/marketing/Docs/Nav/NavItem.svelte +30 -26
- package/dist/marketing/Docs/Nav/NavItem.svelte.d.ts +6 -18
- package/dist/marketing/Docs/Sidebar/Sidebar.svelte +22 -25
- package/dist/marketing/Docs/Sidebar/Sidebar.svelte.d.ts +22 -19
- package/dist/marketing/Docs/Toc.svelte +64 -56
- package/dist/marketing/Docs/Toc.svelte.d.ts +3 -14
- package/dist/marketing/Document/Document.svelte +15 -8
- package/dist/marketing/Document/Document.svelte.d.ts +7 -19
- package/dist/marketing/Document/DocumentTitle.svelte +65 -54
- package/dist/marketing/Document/DocumentTitle.svelte.d.ts +9 -20
- package/dist/marketing/Footer/Footer.svelte +154 -145
- package/dist/marketing/Footer/Footer.svelte.d.ts +8 -20
- package/dist/marketing/Footer/FooterLinkList.svelte +31 -27
- package/dist/marketing/Footer/FooterLinkList.svelte.d.ts +6 -18
- package/dist/marketing/Header/Header.svelte +47 -37
- package/dist/marketing/Header/Header.svelte.d.ts +10 -22
- package/dist/marketing/Logo/LogoBlogs.svelte +46 -0
- package/dist/marketing/Logo/LogoBlogs.svelte.d.ts +5 -0
- package/dist/marketing/Logo/LogoCore.svelte +46 -0
- package/dist/marketing/Logo/LogoCore.svelte.d.ts +5 -0
- package/dist/marketing/Logo/LogoFortguard.svelte +54 -0
- package/dist/marketing/Logo/LogoFortguard.svelte.d.ts +5 -0
- package/dist/marketing/Logo/LogoTalk.svelte +32 -0
- package/dist/marketing/Logo/LogoTalk.svelte.d.ts +5 -0
- package/dist/stores/dark.d.ts +0 -1
- package/dist/stores/dark.js +8 -8
- package/dist/variables.scss +41 -48
- package/package.json +59 -58
|
@@ -1,117 +1,161 @@
|
|
|
1
|
-
<script generics="StringsT extends I18nStrings">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
let
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
1
|
+
<script lang="ts" generics="StringsT extends I18nStrings">
|
|
2
|
+
import { run } from 'svelte/legacy';
|
|
3
|
+
|
|
4
|
+
import { type ToDotPaths, type I18nStrings, type PrimitiveType } from './types.js';
|
|
5
|
+
import { getContext, onMount, tick, getAllContexts, type Component, hydrate } from 'svelte';
|
|
6
|
+
import { InternationalizationService } from './i18n.js';
|
|
7
|
+
import { browser } from '$app/environment';
|
|
8
|
+
import { getMessage as getMessageBase } from './t.js';
|
|
9
|
+
|
|
10
|
+
type ComponentDeclaration = {
|
|
11
|
+
element?: string;
|
|
12
|
+
component?: Component<any>;
|
|
13
|
+
props?: Record<string, any>;
|
|
14
|
+
};
|
|
15
|
+
type InputParams = Record<string, PrimitiveType | ComponentDeclaration>;
|
|
16
|
+
type ParamValue = PrimitiveType | ((chunks: string | string[]) => string);
|
|
17
|
+
|
|
18
|
+
interface Props {
|
|
19
|
+
key: ToDotPaths<StringsT>;
|
|
20
|
+
params?: InputParams;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let { key, params = {} }: Props = $props();
|
|
24
|
+
|
|
25
|
+
const context = getAllContexts();
|
|
26
|
+
|
|
27
|
+
let hasComponentParams = false;
|
|
28
|
+
|
|
29
|
+
function getElementFunc(el: string) {
|
|
30
|
+
return (chunks: string | string[]) => {
|
|
31
|
+
const children = typeof chunks === 'string' ? chunks : chunks.join('');
|
|
32
|
+
return `<${el}>${children}</${el}>`;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* In backend processing (SSR), we only render the strings inside it
|
|
38
|
+
* The components are not rendered.
|
|
39
|
+
* However, if components are found, we set hasComponentParams to true
|
|
40
|
+
* so that we can render the components in the frontend later.
|
|
41
|
+
*/
|
|
42
|
+
function getParamsForBackend() {
|
|
43
|
+
let retParams: Record<string, ParamValue> = {};
|
|
44
|
+
|
|
45
|
+
for (let [key, value] of Object.entries(params)) {
|
|
46
|
+
let newValue: ParamValue;
|
|
47
|
+
if (typeof value === 'object' && value !== null) {
|
|
48
|
+
if (value.hasOwnProperty('component')) {
|
|
49
|
+
newValue = (chunks: string | string[]) => {
|
|
50
|
+
const children = typeof chunks === 'string' ? chunks : chunks.join('');
|
|
51
|
+
return children;
|
|
52
|
+
};
|
|
53
|
+
hasComponentParams = true;
|
|
54
|
+
} else if (value.hasOwnProperty('element')) {
|
|
55
|
+
newValue = getElementFunc((value as any).element as string);
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
newValue = value as PrimitiveType;
|
|
59
|
+
}
|
|
60
|
+
retParams[key] = newValue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return retParams;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* In frontend processing, we render the components
|
|
68
|
+
*/
|
|
69
|
+
interface ComponentBinding {
|
|
70
|
+
component: Component<any>;
|
|
71
|
+
props: Record<string, any>;
|
|
72
|
+
}
|
|
73
|
+
const componentBindings = new Map<string, ComponentBinding>();
|
|
74
|
+
function getParamsForFrontend() {
|
|
75
|
+
let retParams: Record<string, ParamValue> = {};
|
|
76
|
+
|
|
77
|
+
for (let [key, value] of Object.entries(params)) {
|
|
78
|
+
let newValue: ParamValue;
|
|
79
|
+
if (typeof value === 'object' && value !== null) {
|
|
80
|
+
if (value.hasOwnProperty('component')) {
|
|
81
|
+
const { component, props } = value as ComponentDeclaration;
|
|
82
|
+
|
|
83
|
+
newValue = (chunks: string | string[]) => {
|
|
84
|
+
const children = typeof chunks === 'string' ? chunks : chunks.join('');
|
|
85
|
+
const id =
|
|
86
|
+
key + '-' + Math.random().toString(36).substring(7) + '-' + Date.now().toString();
|
|
87
|
+
componentBindings.set(id, {
|
|
88
|
+
component: component!,
|
|
89
|
+
props: {
|
|
90
|
+
...props,
|
|
91
|
+
children
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return '<span id="' + id + '">' + children + '</span>';
|
|
95
|
+
};
|
|
96
|
+
} else if (value.hasOwnProperty('element')) {
|
|
97
|
+
newValue = getElementFunc((value as any).element as string);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
newValue = value as PrimitiveType;
|
|
101
|
+
}
|
|
102
|
+
retParams[key] = newValue;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return retParams;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const i18n = getContext<InternationalizationService>('i18n');
|
|
109
|
+
const locale = i18n.locale;
|
|
110
|
+
const strings = i18n.strings;
|
|
111
|
+
|
|
112
|
+
let message = $state(getMessage(getParamsForBackend()));
|
|
113
|
+
|
|
114
|
+
function getMessage(processedParams: Record<string, ParamValue>) {
|
|
115
|
+
return getMessageBase(key, processedParams, $strings, $locale);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function bindComponents() {
|
|
119
|
+
for (let [id, binding] of componentBindings) {
|
|
120
|
+
const el = document.getElementById(id);
|
|
121
|
+
if (el) {
|
|
122
|
+
el.innerHTML = '';
|
|
123
|
+
hydrate(binding.component, {
|
|
124
|
+
target: el,
|
|
125
|
+
props: binding.props,
|
|
126
|
+
context
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function renderFrontend() {
|
|
133
|
+
message = getMessage(getParamsForFrontend());
|
|
134
|
+
await tick();
|
|
135
|
+
if (hasComponentParams) bindComponents();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let mounted = $state(false);
|
|
139
|
+
|
|
140
|
+
run(() => {
|
|
141
|
+
params;
|
|
142
|
+
key;
|
|
143
|
+
if (browser && mounted) {
|
|
144
|
+
renderFrontend();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
onMount(async () => {
|
|
149
|
+
mounted = true;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* If there are components,
|
|
153
|
+
* we wait for the tick, then bind the components
|
|
154
|
+
*/
|
|
155
|
+
if (hasComponentParams) {
|
|
156
|
+
renderFrontend();
|
|
157
|
+
}
|
|
158
|
+
});
|
|
115
159
|
</script>
|
|
116
160
|
|
|
117
161
|
{@html message}
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
3
|
-
import { type ComponentType } from "svelte";
|
|
4
|
-
import { type PrimitiveType } from "intl-messageformat";
|
|
1
|
+
import { type ToDotPaths, type I18nStrings, type PrimitiveType } from './types.js';
|
|
2
|
+
import { type Component } from 'svelte';
|
|
5
3
|
declare class __sveltets_Render<StringsT extends I18nStrings> {
|
|
6
4
|
props(): {
|
|
7
5
|
key: ToDotPaths<StringsT>;
|
|
8
6
|
params?: Record<string, PrimitiveType | {
|
|
9
|
-
element?: string
|
|
10
|
-
component?:
|
|
11
|
-
props?: Record<string, any
|
|
7
|
+
element?: string;
|
|
8
|
+
component?: Component<any>;
|
|
9
|
+
props?: Record<string, any>;
|
|
12
10
|
}> | undefined;
|
|
13
11
|
};
|
|
14
|
-
events(): {}
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
16
|
-
};
|
|
12
|
+
events(): {};
|
|
17
13
|
slots(): {};
|
|
14
|
+
bindings(): "";
|
|
15
|
+
exports(): {};
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
interface $$IsomorphicComponent {
|
|
18
|
+
new <StringsT extends I18nStrings>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<StringsT>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<StringsT>['props']>, ReturnType<__sveltets_Render<StringsT>['events']>, ReturnType<__sveltets_Render<StringsT>['slots']>> & {
|
|
19
|
+
$$bindings?: ReturnType<__sveltets_Render<StringsT>['bindings']>;
|
|
20
|
+
} & ReturnType<__sveltets_Render<StringsT>['exports']>;
|
|
21
|
+
<StringsT extends I18nStrings>(internal: unknown, props: ReturnType<__sveltets_Render<StringsT>['props']> & {}): ReturnType<__sveltets_Render<StringsT>['exports']>;
|
|
22
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
declare const T: $$IsomorphicComponent;
|
|
25
|
+
type T<StringsT extends I18nStrings> = InstanceType<typeof T<StringsT>>;
|
|
26
|
+
export default T;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import T from "./T.svelte";
|
|
5
|
-
import type { ToDotPaths, I18nStrings } from "./types.js";
|
|
1
|
+
import { type Readable, type Writable } from 'svelte/store';
|
|
2
|
+
import T from './T.svelte';
|
|
3
|
+
import type { ToDotPaths, I18nStrings, PrimitiveType } from './types.js';
|
|
6
4
|
export type i18nLoaderType = () => Promise<any>;
|
|
7
5
|
interface LanguageBase {
|
|
8
6
|
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,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
3
|
-
import type { I18nStrings, ToDotPaths } from "./types.js";
|
|
1
|
+
import { type InternationalizationService } from './i18n.js';
|
|
2
|
+
import type { I18nStrings, PrimitiveType, ToDotPaths } from './types.js';
|
|
4
3
|
type ParamValue = PrimitiveType | ((chunks: string | string[]) => string);
|
|
5
4
|
type ParamsType = Record<string, ParamValue>;
|
|
6
5
|
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) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export type I18nStrings = {
|
|
2
2
|
[key: string]: string | I18nStrings;
|
|
3
3
|
};
|
|
4
|
+
export type PrimitiveType = string | number | boolean | null | undefined | Date;
|
|
4
5
|
export type ToDotPaths<T> = T extends object ? {
|
|
5
|
-
[K in keyof T]: `${Exclude<K, symbol>}${
|
|
6
|
+
[K in keyof T]: `${Exclude<K, symbol>}${'' | `.${ToDotPaths<T[K]>}`}`;
|
|
6
7
|
}[keyof T] : never;
|
|
7
8
|
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;
|
|
@@ -1,72 +1,79 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
export let underline = true;
|
|
4
|
-
</script>
|
|
5
|
-
|
|
6
|
-
<a
|
|
7
|
-
{href}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createBubbler } from 'svelte/legacy';
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const bubble = createBubbler();
|
|
5
|
+
interface Props {
|
|
6
|
+
href: string;
|
|
7
|
+
color?: 'link' | 'accent' | 'text';
|
|
8
|
+
underline?: boolean;
|
|
9
|
+
start?: import('svelte').Snippet;
|
|
10
|
+
children?: import('svelte').Snippet;
|
|
11
|
+
end?: import('svelte').Snippet;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
on:keypress
|
|
15
|
-
on:focus
|
|
16
|
-
on:blur
|
|
17
|
-
on:click
|
|
18
|
-
on:mouseover
|
|
19
|
-
on:mouseenter
|
|
20
|
-
on:mouseleave
|
|
21
|
-
on:change
|
|
15
|
+
let { href, color = 'link', underline = true, start, children, end, ...rest }: Props = $props();
|
|
16
|
+
</script>
|
|
22
17
|
|
|
23
|
-
|
|
18
|
+
<a
|
|
19
|
+
{href}
|
|
20
|
+
class="color-{color}"
|
|
21
|
+
class:underline
|
|
22
|
+
onkeyup={bubble('keyup')}
|
|
23
|
+
onkeydown={bubble('keydown')}
|
|
24
|
+
onkeypress={bubble('keypress')}
|
|
25
|
+
onfocus={bubble('focus')}
|
|
26
|
+
onblur={bubble('blur')}
|
|
27
|
+
onclick={bubble('click')}
|
|
28
|
+
onmouseover={bubble('mouseover')}
|
|
29
|
+
onmouseenter={bubble('mouseenter')}
|
|
30
|
+
onmouseleave={bubble('mouseleave')}
|
|
31
|
+
onchange={bubble('change')}
|
|
32
|
+
{...rest}
|
|
24
33
|
>
|
|
34
|
+
{#if start}
|
|
35
|
+
<span class="slot start-slot">{@render start?.()}</span>
|
|
36
|
+
{/if}
|
|
25
37
|
|
|
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}
|
|
38
|
+
{@render children?.()}
|
|
35
39
|
|
|
40
|
+
{#if end}
|
|
41
|
+
<span class="slot end-slot">{@render end?.()}</span>
|
|
42
|
+
{/if}
|
|
36
43
|
</a>
|
|
37
44
|
|
|
38
45
|
<style>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
a {
|
|
47
|
+
display: inline-flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
color: var(--local-color);
|
|
50
|
+
}
|
|
51
|
+
a.color-link {
|
|
52
|
+
--local-color: var(--link);
|
|
53
|
+
}
|
|
54
|
+
a.color-accent {
|
|
55
|
+
--local-color: var(--accent);
|
|
56
|
+
}
|
|
57
|
+
a.color-text {
|
|
58
|
+
--local-color: var(--text);
|
|
59
|
+
}
|
|
60
|
+
a.underline {
|
|
61
|
+
text-decoration: underline;
|
|
62
|
+
text-decoration-color: var(--local-color);
|
|
63
|
+
}
|
|
64
|
+
a:not(.underline):hover {
|
|
65
|
+
text-decoration: underline;
|
|
66
|
+
}
|
|
60
67
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
.slot {
|
|
69
|
+
display: inline-flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
}
|
|
65
72
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</style>
|
|
73
|
+
.start-slot {
|
|
74
|
+
margin-right: 4px;
|
|
75
|
+
}
|
|
76
|
+
.end-slot {
|
|
77
|
+
margin-left: 4px;
|
|
78
|
+
}
|
|
79
|
+
</style>
|
|
@@ -1,34 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
keypress: KeyboardEvent;
|
|
13
|
-
focus: FocusEvent;
|
|
14
|
-
blur: FocusEvent;
|
|
15
|
-
click: MouseEvent;
|
|
16
|
-
mouseover: MouseEvent;
|
|
17
|
-
mouseenter: MouseEvent;
|
|
18
|
-
mouseleave: MouseEvent;
|
|
19
|
-
change: Event;
|
|
20
|
-
} & {
|
|
21
|
-
[evt: string]: CustomEvent<any>;
|
|
22
|
-
};
|
|
23
|
-
slots: {
|
|
24
|
-
start: {};
|
|
25
|
-
default: {};
|
|
26
|
-
end: {};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export type LinkProps = typeof __propDef.props;
|
|
30
|
-
export type LinkEvents = typeof __propDef.events;
|
|
31
|
-
export type LinkSlots = typeof __propDef.slots;
|
|
32
|
-
export default class Link extends SvelteComponent<LinkProps, LinkEvents, LinkSlots> {
|
|
33
|
-
}
|
|
34
|
-
export {};
|
|
1
|
+
declare const Link: import("svelte").Component<{
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
href: string;
|
|
4
|
+
color?: "link" | "accent" | "text";
|
|
5
|
+
underline?: boolean;
|
|
6
|
+
start?: import("svelte").Snippet;
|
|
7
|
+
children?: import("svelte").Snippet;
|
|
8
|
+
end?: import("svelte").Snippet;
|
|
9
|
+
}, {}, "">;
|
|
10
|
+
type Link = ReturnType<typeof Link>;
|
|
11
|
+
export default Link;
|