@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.
Files changed (184) hide show
  1. package/dist/components/ActionList/ActionList.svelte +21 -13
  2. package/dist/components/ActionList/ActionList.svelte.d.ts +8 -20
  3. package/dist/components/ActionList/ActionListGroup.svelte +40 -35
  4. package/dist/components/ActionList/ActionListGroup.svelte.d.ts +8 -20
  5. package/dist/components/ActionList/ActionListItem.svelte +129 -107
  6. package/dist/components/ActionList/ActionListItem.svelte.d.ts +27 -25
  7. package/dist/components/ActionList/Selected.svelte +27 -24
  8. package/dist/components/ActionList/Selected.svelte.d.ts +6 -17
  9. package/dist/components/Avatar/Avatar.svelte +22 -19
  10. package/dist/components/Avatar/Avatar.svelte.d.ts +7 -18
  11. package/dist/components/Avatar/AvatarStack.svelte +29 -27
  12. package/dist/components/Avatar/AvatarStack.svelte.d.ts +6 -18
  13. package/dist/components/Base/Base.svelte +16 -8
  14. package/dist/components/Base/Base.svelte.d.ts +6 -18
  15. package/dist/components/Box/Box.svelte +16 -9
  16. package/dist/components/Box/Box.svelte.d.ts +7 -19
  17. package/dist/components/Button/Button.svelte +65 -47
  18. package/dist/components/Button/Button.svelte.d.ts +16 -39
  19. package/dist/components/Button/ButtonGroup.svelte +14 -6
  20. package/dist/components/Button/ButtonGroup.svelte.d.ts +5 -27
  21. package/dist/components/Callout/Callout.svelte +110 -87
  22. package/dist/components/Callout/Callout.svelte.d.ts +11 -22
  23. package/dist/components/Checkbox/Checkbox.svelte +156 -144
  24. package/dist/components/Checkbox/Checkbox.svelte.d.ts +11 -34
  25. package/dist/components/CodeBlock/CodeBlock.svelte +45 -32
  26. package/dist/components/CodeBlock/CodeBlock.svelte.d.ts +6 -17
  27. package/dist/components/CodeBlock/getCode.js +8 -6
  28. package/dist/components/CodeBlock/hljs.scss +189 -191
  29. package/dist/components/CodeBlock/prism.scss +370 -7
  30. package/dist/components/ColorPicker/ColorPicker.svelte +75 -56
  31. package/dist/components/ColorPicker/ColorPicker.svelte.d.ts +25 -19
  32. package/dist/components/Dark/DarkProvider.svelte +16 -14
  33. package/dist/components/Dark/DarkProvider.svelte.d.ts +16 -12
  34. package/dist/components/Dark/DarkToggle.svelte +15 -16
  35. package/dist/components/Dark/DarkToggle.svelte.d.ts +16 -12
  36. package/dist/components/Divider/Divider.svelte +23 -13
  37. package/dist/components/Divider/Divider.svelte.d.ts +9 -20
  38. package/dist/components/Dropdown/Dropdown.svelte +58 -114
  39. package/dist/components/Dropdown/Dropdown.svelte.d.ts +13 -24
  40. package/dist/components/Dropdown/DropdownContent.svelte +152 -0
  41. package/dist/components/Dropdown/DropdownContent.svelte.d.ts +12 -0
  42. package/dist/components/FormControl/Caption.svelte +18 -11
  43. package/dist/components/FormControl/Caption.svelte.d.ts +7 -19
  44. package/dist/components/FormControl/FormControl.svelte +28 -19
  45. package/dist/components/FormControl/FormControl.svelte.d.ts +6 -27
  46. package/dist/components/FormControl/InputGroup.svelte +22 -15
  47. package/dist/components/FormControl/InputGroup.svelte.d.ts +7 -19
  48. package/dist/components/FormControl/Label.svelte +15 -6
  49. package/dist/components/FormControl/Label.svelte.d.ts +6 -27
  50. package/dist/components/FormControl/Validation.svelte +30 -19
  51. package/dist/components/FormControl/Validation.svelte.d.ts +9 -21
  52. package/dist/components/HyvorBar/BarProducts.svelte +71 -0
  53. package/dist/components/HyvorBar/BarProducts.svelte.d.ts +32 -0
  54. package/dist/components/HyvorBar/BarSupport.svelte +183 -0
  55. package/dist/components/HyvorBar/BarSupport.svelte.d.ts +8 -0
  56. package/dist/components/HyvorBar/BarUpdates.svelte +68 -0
  57. package/dist/components/HyvorBar/BarUpdates.svelte.d.ts +7 -0
  58. package/dist/components/HyvorBar/BarUpdatesList.svelte +159 -0
  59. package/dist/components/HyvorBar/BarUpdatesList.svelte.d.ts +7 -0
  60. package/dist/components/HyvorBar/BarUser.svelte +72 -0
  61. package/dist/components/HyvorBar/BarUser.svelte.d.ts +5 -0
  62. package/dist/components/HyvorBar/BarUserPreview.svelte +43 -0
  63. package/dist/components/HyvorBar/BarUserPreview.svelte.d.ts +18 -0
  64. package/dist/components/HyvorBar/HyvorBar.svelte +183 -0
  65. package/dist/components/HyvorBar/HyvorBar.svelte.d.ts +8 -0
  66. package/dist/components/HyvorBar/bar.d.ts +33 -0
  67. package/dist/components/HyvorBar/bar.js +74 -0
  68. package/dist/components/HyvorBar/img/G2.svelte +9 -0
  69. package/dist/components/HyvorBar/img/G2.svelte.d.ts +26 -0
  70. package/dist/components/HyvorBar/img/Trustpilot.svelte +11 -0
  71. package/dist/components/HyvorBar/img/Trustpilot.svelte.d.ts +26 -0
  72. package/dist/components/IconButton/IconButton.svelte +49 -32
  73. package/dist/components/IconButton/IconButton.svelte.d.ts +10 -33
  74. package/dist/components/IconMessage/IconMessage.svelte +157 -51
  75. package/dist/components/IconMessage/IconMessage.svelte.d.ts +19 -27
  76. package/dist/components/Internationalization/InternationalizationProvider.svelte +15 -8
  77. package/dist/components/Internationalization/InternationalizationProvider.svelte.d.ts +7 -19
  78. package/dist/components/Internationalization/LanguageToggle.svelte +80 -57
  79. package/dist/components/Internationalization/LanguageToggle.svelte.d.ts +11 -22
  80. package/dist/components/Internationalization/T.svelte +158 -114
  81. package/dist/components/Internationalization/T.svelte.d.ts +17 -15
  82. package/dist/components/Internationalization/i18n.d.ts +3 -5
  83. package/dist/components/Internationalization/i18n.js +13 -11
  84. package/dist/components/Internationalization/t.d.ts +2 -3
  85. package/dist/components/Internationalization/t.js +4 -4
  86. package/dist/components/Internationalization/types.d.ts +2 -1
  87. package/dist/components/Link/Link.svelte +68 -61
  88. package/dist/components/Link/Link.svelte.d.ts +11 -34
  89. package/dist/components/Loader/LoadButton.svelte +39 -38
  90. package/dist/components/Loader/LoadButton.svelte.d.ts +29 -42
  91. package/dist/components/Loader/Loader.svelte +121 -107
  92. package/dist/components/Loader/Loader.svelte.d.ts +15 -27
  93. package/dist/components/Modal/ConfirmModalProvider.svelte +41 -51
  94. package/dist/components/Modal/ConfirmModalProvider.svelte.d.ts +3 -14
  95. package/dist/components/Modal/Modal.svelte +202 -203
  96. package/dist/components/Modal/Modal.svelte.d.ts +31 -29
  97. package/dist/components/Modal/ModalFooter.svelte +36 -31
  98. package/dist/components/Modal/ModalFooter.svelte.d.ts +22 -18
  99. package/dist/components/Modal/confirm.d.ts +2 -2
  100. package/dist/components/Modal/confirm.js +4 -4
  101. package/dist/components/Modal/modal-types.d.ts +4 -4
  102. package/dist/components/NavLink/NavLink.svelte +94 -89
  103. package/dist/components/NavLink/NavLink.svelte.d.ts +11 -33
  104. package/dist/components/Radio/Radio.svelte +46 -35
  105. package/dist/components/Radio/Radio.svelte.d.ts +10 -33
  106. package/dist/components/Slider/Slider.svelte +129 -120
  107. package/dist/components/Slider/Slider.svelte.d.ts +24 -20
  108. package/dist/components/SplitControl/SplitControl.svelte +43 -48
  109. package/dist/components/SplitControl/SplitControl.svelte.d.ts +11 -24
  110. package/dist/components/Switch/Switch.svelte +77 -67
  111. package/dist/components/Switch/Switch.svelte.d.ts +8 -31
  112. package/dist/components/TabNav/TabNav.svelte +33 -23
  113. package/dist/components/TabNav/TabNav.svelte.d.ts +7 -19
  114. package/dist/components/TabNav/TabNavItem.svelte +65 -51
  115. package/dist/components/TabNav/TabNavItem.svelte.d.ts +10 -24
  116. package/dist/components/Table/Table.svelte +17 -7
  117. package/dist/components/Table/Table.svelte.d.ts +7 -19
  118. package/dist/components/Table/TableRow.svelte +32 -24
  119. package/dist/components/Table/TableRow.svelte.d.ts +7 -19
  120. package/dist/components/Tag/Tag.svelte +75 -49
  121. package/dist/components/Tag/Tag.svelte.d.ts +16 -39
  122. package/dist/components/Text/Text.svelte +33 -26
  123. package/dist/components/Text/Text.svelte.d.ts +10 -22
  124. package/dist/components/TextInput/TextInput.svelte +54 -33
  125. package/dist/components/TextInput/TextInput.svelte.d.ts +12 -36
  126. package/dist/components/Textarea/Textarea.svelte +68 -46
  127. package/dist/components/Textarea/Textarea.svelte.d.ts +13 -37
  128. package/dist/components/Toast/ToastIcon.svelte +55 -46
  129. package/dist/components/Toast/ToastIcon.svelte.d.ts +5 -16
  130. package/dist/components/Toast/ToastMessage.svelte +42 -41
  131. package/dist/components/Toast/ToastMessage.svelte.d.ts +5 -16
  132. package/dist/components/Toast/ToastProvider.svelte +22 -20
  133. package/dist/components/Toast/ToastProvider.svelte.d.ts +16 -12
  134. package/dist/components/Toast/cleaner.js +5 -5
  135. package/dist/components/Toast/toast.d.ts +3 -3
  136. package/dist/components/Toast/toast.js +10 -10
  137. package/dist/components/Tooltip/Tooltip.svelte +163 -148
  138. package/dist/components/Tooltip/Tooltip.svelte.d.ts +35 -23
  139. package/dist/components/directives/clickOutside.js +4 -4
  140. package/dist/components/directives/debounce.d.ts +1 -0
  141. package/dist/components/directives/debounce.js +8 -0
  142. package/dist/components/index.d.ts +1 -0
  143. package/dist/components/index.js +1 -0
  144. package/dist/index.css +31 -33
  145. package/dist/marketing/Container/Container.svelte +15 -9
  146. package/dist/marketing/Container/Container.svelte.d.ts +6 -18
  147. package/dist/marketing/Docs/Content/Content.svelte +48 -35
  148. package/dist/marketing/Docs/Content/Content.svelte.d.ts +5 -16
  149. package/dist/marketing/Docs/Content/DocsImage.svelte +67 -69
  150. package/dist/marketing/Docs/Content/DocsImage.svelte.d.ts +9 -20
  151. package/dist/marketing/Docs/Docs.svelte +28 -25
  152. package/dist/marketing/Docs/Docs.svelte.d.ts +6 -29
  153. package/dist/marketing/Docs/Nav/Nav.svelte +96 -70
  154. package/dist/marketing/Docs/Nav/Nav.svelte.d.ts +5 -16
  155. package/dist/marketing/Docs/Nav/NavCategory.svelte +39 -29
  156. package/dist/marketing/Docs/Nav/NavCategory.svelte.d.ts +8 -20
  157. package/dist/marketing/Docs/Nav/NavItem.svelte +30 -26
  158. package/dist/marketing/Docs/Nav/NavItem.svelte.d.ts +6 -18
  159. package/dist/marketing/Docs/Sidebar/Sidebar.svelte +22 -25
  160. package/dist/marketing/Docs/Sidebar/Sidebar.svelte.d.ts +22 -19
  161. package/dist/marketing/Docs/Toc.svelte +64 -56
  162. package/dist/marketing/Docs/Toc.svelte.d.ts +3 -14
  163. package/dist/marketing/Document/Document.svelte +15 -8
  164. package/dist/marketing/Document/Document.svelte.d.ts +7 -19
  165. package/dist/marketing/Document/DocumentTitle.svelte +65 -54
  166. package/dist/marketing/Document/DocumentTitle.svelte.d.ts +9 -20
  167. package/dist/marketing/Footer/Footer.svelte +154 -145
  168. package/dist/marketing/Footer/Footer.svelte.d.ts +8 -20
  169. package/dist/marketing/Footer/FooterLinkList.svelte +31 -27
  170. package/dist/marketing/Footer/FooterLinkList.svelte.d.ts +6 -18
  171. package/dist/marketing/Header/Header.svelte +47 -37
  172. package/dist/marketing/Header/Header.svelte.d.ts +10 -22
  173. package/dist/marketing/Logo/LogoBlogs.svelte +46 -0
  174. package/dist/marketing/Logo/LogoBlogs.svelte.d.ts +5 -0
  175. package/dist/marketing/Logo/LogoCore.svelte +46 -0
  176. package/dist/marketing/Logo/LogoCore.svelte.d.ts +5 -0
  177. package/dist/marketing/Logo/LogoFortguard.svelte +54 -0
  178. package/dist/marketing/Logo/LogoFortguard.svelte.d.ts +5 -0
  179. package/dist/marketing/Logo/LogoTalk.svelte +32 -0
  180. package/dist/marketing/Logo/LogoTalk.svelte.d.ts +5 -0
  181. package/dist/stores/dark.d.ts +0 -1
  182. package/dist/stores/dark.js +8 -8
  183. package/dist/variables.scss +41 -48
  184. package/package.json +59 -58
@@ -1,117 +1,161 @@
1
- <script generics="StringsT extends I18nStrings">import {} from "./types.js";
2
- import {
3
- getContext,
4
- onMount,
5
- tick,
6
- afterUpdate,
7
- getAllContexts
8
- } from "svelte";
9
- import { getStringByKey, InternationalizationService } from "./i18n.js";
10
- import { IntlMessageFormat } from "intl-messageformat";
11
- import { browser } from "$app/environment";
12
- import { getMessage as getMessageBase } from "./t.js";
13
- export let key;
14
- export let params = {};
15
- const context = getAllContexts();
16
- let hasComponentParams = false;
17
- function getElementFunc(el) {
18
- return (chunks) => {
19
- const children = typeof chunks === "string" ? chunks : chunks.join("");
20
- return `<${el}>${children}</${el}>`;
21
- };
22
- }
23
- function getParamsForBackend() {
24
- let retParams = {};
25
- for (let [key2, value] of Object.entries(params)) {
26
- let newValue;
27
- if (typeof value === "object" && value !== null) {
28
- if (value.hasOwnProperty("component")) {
29
- newValue = (chunks) => {
30
- const children = typeof chunks === "string" ? chunks : chunks.join("");
31
- return children;
32
- };
33
- hasComponentParams = true;
34
- } else if (value.hasOwnProperty("element")) {
35
- newValue = getElementFunc(value.element);
36
- }
37
- } else {
38
- newValue = value;
39
- }
40
- retParams[key2] = newValue;
41
- }
42
- return retParams;
43
- }
44
- const componentBindings = /* @__PURE__ */ new Map();
45
- function getParamsForFrontend() {
46
- let retParams = {};
47
- for (let [key2, value] of Object.entries(params)) {
48
- let newValue;
49
- if (typeof value === "object" && value !== null) {
50
- if (value.hasOwnProperty("component")) {
51
- const { component, props } = value;
52
- newValue = (chunks) => {
53
- const children = typeof chunks === "string" ? chunks : chunks.join("");
54
- const id = key2 + "-" + Math.random().toString(36).substring(7) + "-" + Date.now().toString();
55
- componentBindings.set(id, {
56
- component,
57
- props: {
58
- ...props,
59
- children
60
- }
61
- });
62
- return '<span id="' + id + '">' + children + "</span>";
63
- };
64
- } else if (value.hasOwnProperty("element")) {
65
- newValue = getElementFunc(value.element);
66
- }
67
- } else {
68
- newValue = value;
69
- }
70
- retParams[key2] = newValue;
71
- }
72
- return retParams;
73
- }
74
- const i18n = getContext("i18n");
75
- const locale = i18n.locale;
76
- const strings = i18n.strings;
77
- let message = getMessage(getParamsForBackend());
78
- function getMessage(processedParams) {
79
- return getMessageBase(key, processedParams, $strings, $locale);
80
- }
81
- function bindComponents() {
82
- for (let [id, binding] of componentBindings) {
83
- const el = document.getElementById(id);
84
- if (el) {
85
- el.innerHTML = "";
86
- new binding.component({
87
- target: el,
88
- hydrate: true,
89
- props: binding.props,
90
- context
91
- });
92
- }
93
- }
94
- }
95
- async function renderFrontend() {
96
- message = getMessage(getParamsForFrontend());
97
- await tick();
98
- if (hasComponentParams)
99
- bindComponents();
100
- }
101
- let mounted = false;
102
- $: {
103
- params;
104
- key;
105
- if (browser && mounted) {
106
- renderFrontend();
107
- }
108
- }
109
- onMount(async () => {
110
- mounted = true;
111
- if (hasComponentParams) {
112
- renderFrontend();
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 { SvelteComponent } from "svelte";
2
- import { type ToDotPaths, type I18nStrings } from "./types.js";
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 | undefined;
10
- component?: ComponentType | undefined;
11
- props?: Record<string, any> | undefined;
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
- export type TProps<StringsT extends I18nStrings> = ReturnType<__sveltets_Render<StringsT>['props']>;
20
- export type TEvents<StringsT extends I18nStrings> = ReturnType<__sveltets_Render<StringsT>['events']>;
21
- export type TSlots<StringsT extends I18nStrings> = ReturnType<__sveltets_Render<StringsT>['slots']>;
22
- export default class T<StringsT extends I18nStrings> extends SvelteComponent<TProps<StringsT>, TEvents<StringsT>, TSlots<StringsT>> {
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
- export {};
24
+ declare const T: $$IsomorphicComponent;
25
+ type T<StringsT extends I18nStrings> = InstanceType<typeof T<StringsT>>;
26
+ export default T;
@@ -1,8 +1,6 @@
1
- /// <reference types="svelte" />
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";
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 "deepmerge-ts";
2
- import { writable, derived } from "svelte/store";
3
- import { t } from "./t.js";
4
- import T from "./T.svelte";
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)?.loader().then(({ default: strings }) => {
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 PrimitiveType } from "intl-messageformat";
2
- import { type InternationalizationService } from "./i18n.js";
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 "intl-messageformat";
2
- import { getContext } from "svelte";
3
- import { get } from "svelte/store";
4
- import { getStringByKey } from "./i18n.js";
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>}${"" | `.${ToDotPaths<T[K]>}`}`;
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>export let href;
2
- export let color = "link";
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
- class="color-{color}"
10
- class:underline={underline}
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
- on:keyup
13
- on:keydown
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
- {...$$restProps}
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
- {#if $$slots.start}
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
- a {
40
- display: inline-flex;
41
- align-items: center;
42
- color: var(--local-color);
43
- }
44
- a.color-link {
45
- --local-color: var(--link);
46
- }
47
- a.color-accent {
48
- --local-color: var(--accent);
49
- }
50
- a.color-text {
51
- --local-color: var(--text);
52
- }
53
- a.underline {
54
- text-decoration: underline;
55
- text-decoration-color: var(--local-color);
56
- }
57
- a:not(.underline):hover {
58
- text-decoration: underline;
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
- .slot {
62
- display: inline-flex;
63
- align-items: center;
64
- }
68
+ .slot {
69
+ display: inline-flex;
70
+ align-items: center;
71
+ }
65
72
 
66
- .start-slot {
67
- margin-right: 4px;
68
- }
69
- .end-slot {
70
- margin-left: 4px;
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
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- [x: string]: any;
5
- href: string;
6
- color?: "accent" | "text" | "link" | undefined;
7
- underline?: boolean | undefined;
8
- };
9
- events: {
10
- keyup: KeyboardEvent;
11
- keydown: KeyboardEvent;
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;