tera-system-ui 0.0.29 → 0.0.34

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 (32) hide show
  1. package/dist/components/avatar/Avatar.d.ts +1 -0
  2. package/dist/components/avatar/Avatar.svelte +2 -1
  3. package/dist/components/language-picker-button/LanguagePickerButton.d.ts +3 -0
  4. package/dist/components/language-picker-button/LanguagePickerButton.svelte +13 -5
  5. package/dist/components/side-navigation/SideNavigation.d.ts +2 -0
  6. package/dist/components/side-navigation/SideNavigation.svelte +8 -7
  7. package/dist/components/side-navigation/SideNavigationLayout.svelte +2 -2
  8. package/dist/components/side-navigation/SideNavigationLayout.svelte.d.ts +1 -0
  9. package/dist/components/tera-ui-context/TeraUiContext.svelte +6 -6
  10. package/dist/components/tera-ui-context/global-context.js +1 -0
  11. package/dist/components/user-avatar-with-menu/UserAvatarWithMenu.svelte +4 -3
  12. package/dist/internal/service/user.service.d.ts +1 -1
  13. package/dist/internal/service/user.service.js +2 -2
  14. package/dist/paraglide/messages/de.d.ts +2 -0
  15. package/dist/paraglide/messages/de.js +16 -0
  16. package/dist/paraglide/messages/en.d.ts +2 -0
  17. package/dist/paraglide/messages/en.js +16 -0
  18. package/dist/paraglide/messages/es.d.ts +2 -0
  19. package/dist/paraglide/messages/es.js +16 -0
  20. package/dist/paraglide/messages/fr.d.ts +2 -0
  21. package/dist/paraglide/messages/fr.js +16 -0
  22. package/dist/paraglide/messages/it.d.ts +2 -0
  23. package/dist/paraglide/messages/it.js +16 -0
  24. package/dist/paraglide/messages/pt.d.ts +2 -0
  25. package/dist/paraglide/messages/pt.js +16 -0
  26. package/dist/paraglide/messages/ru.d.ts +2 -0
  27. package/dist/paraglide/messages/ru.js +16 -0
  28. package/dist/paraglide/messages/vi.d.ts +2 -0
  29. package/dist/paraglide/messages/vi.js +16 -0
  30. package/dist/paraglide/messages.d.ts +6 -0
  31. package/dist/paraglide/messages.js +56 -0
  32. package/package.json +2 -2
@@ -78,5 +78,6 @@ export interface AvatarProps extends AvatarVariants {
78
78
  src?: string;
79
79
  ref?: any;
80
80
  userUid?: string;
81
+ apiUrl?: string;
81
82
  }
82
83
  export {};
@@ -12,6 +12,7 @@
12
12
  border = true,
13
13
  ref = $bindable(),
14
14
  userUid,
15
+ apiUrl,
15
16
  ...props
16
17
  }: AvatarProps = $props();
17
18
 
@@ -21,7 +22,7 @@
21
22
  isError = true
22
23
  }
23
24
 
24
- let imgUrl = src ? src : userUid ? getUserAvatarUrl(userUid) : undefined
25
+ let imgUrl = src ? src : userUid ? getUserAvatarUrl(userUid, apiUrl) : undefined
25
26
  </script>
26
27
 
27
28
  <div bind:this={ref}
@@ -4,5 +4,8 @@ type LanguagePickerButtonVariants = VariantProps<typeof styles>;
4
4
  export interface LanguagePickerButtonProps extends LanguagePickerButtonVariants {
5
5
  children?: any;
6
6
  class?: string;
7
+ language?: string;
8
+ supportLanguages?: string[];
9
+ basePath?: string;
7
10
  }
8
11
  export {};
@@ -9,6 +9,10 @@
9
9
  let {
10
10
  children,
11
11
  onLangSelect,
12
+
13
+ language,
14
+ supportLanguages,
15
+ basePath,
12
16
  ...props
13
17
  }: LanguagePickerButtonProps & {
14
18
  onLangSelect: (langCode: string) => void
@@ -16,6 +20,10 @@
16
20
 
17
21
  let context = getGlobalContext()
18
22
 
23
+ supportLanguages = supportLanguages ?? context.supportLanguages!;
24
+ language = language ?? context.language
25
+ basePath = basePath ?? context.basePath
26
+
19
27
 
20
28
  const LANGUAGE_LIST = [
21
29
  {
@@ -59,17 +67,17 @@
59
67
  flag: 'vietnam'
60
68
  }
61
69
  // @ts-ignore
62
- ].filter(lang => context.supportLanguages!.includes(lang.code))
70
+ ].filter(lang => supportLanguages.includes(lang.code))
63
71
 
64
72
 
65
- let currentLangItem = $derived(LANGUAGE_LIST.find(l => l.code === context.language)!)
73
+ let currentLangItem = $derived(LANGUAGE_LIST.find(l => l.code === language)!)
66
74
 
67
75
 
68
76
  function getFlagUrl(flag: string) {
69
77
  if (flag === 'spain') {
70
- return `${context.basePath ?? ''}/world-flags/${flag}.png`
78
+ return `${basePath ?? ''}/world-flags/${flag}.png`
71
79
  }
72
- return `${context.basePath ?? ''}/world-flags/${flag}.svg`
80
+ return `${basePath ?? ''}/world-flags/${flag}.svg`
73
81
  }
74
82
 
75
83
  let openDialog = $state(false)
@@ -95,7 +103,7 @@
95
103
  onLangSelect?.(lang.code)
96
104
  openDialog = false
97
105
  }}
98
- data-selected={lang.code === context.language ? '' : undefined}>
106
+ data-selected={lang.code === language ? '' : undefined}>
99
107
  <div class="flex items-center gap-2">
100
108
  <img class="size-8 flag-img" src={getFlagUrl(lang.flag)} alt={currentLangItem.flag} loading="lazy">
101
109
  {lang.label}
@@ -4,6 +4,8 @@ type SideNavigationVariants = VariantProps<typeof styles>;
4
4
  export interface SideNavigationProps extends SideNavigationVariants {
5
5
  children?: any;
6
6
  class?: string;
7
+ sideNavHref?: string;
8
+ language?: string;
7
9
  }
8
10
  export declare const SCREEN_BREAK_POINTS: {
9
11
  sm: number;
@@ -19,7 +19,7 @@
19
19
 
20
20
  import {getGlobalContext} from "../tera-ui-context/global-context";
21
21
 
22
- let {children, ...props}: SideNavigationProps = $props();
22
+ let {children, sideNavHref, language, ...props}: SideNavigationProps = $props();
23
23
 
24
24
  let temporaryExpand: any = undefined
25
25
 
@@ -47,23 +47,24 @@
47
47
 
48
48
  let globalContext = getGlobalContext()
49
49
 
50
- console.log('SideNavigation get global context', globalContext)
50
+ sideNavHref = sideNavHref || globalContext?.sideNavHref
51
+ language = language || globalContext?.language
52
+
53
+ let langPath = (language === 'en' || !language) ? '' : `/${language}`
51
54
 
52
55
  function isSelected(href: string) {
53
- const pathname = globalContext?.sideNavHref
54
- return pathname?.startsWith(href)
56
+ return sideNavHref?.startsWith(href)
55
57
  }
56
58
 
57
59
 
58
-
59
60
  const NAV_ITEM = [
60
61
  {
61
- href: '/calculator',
62
+ href: `/calculator${langPath}`,
62
63
  icon: IconCalculator,
63
64
  title: m.text_calces_scientific_calculator(),
64
65
  },
65
66
  {
66
- href: '/convert',
67
+ href: `/convert${langPath}`,
67
68
  icon: IconTransform,
68
69
  title: m.text_unit_converter(),
69
70
  },
@@ -2,7 +2,7 @@
2
2
  import {SideNavigation} from "./";
3
3
  import './sidenav.scss'
4
4
 
5
- let {children} = $props()
5
+ let {children, language} = $props()
6
6
  </script>
7
7
 
8
8
  <main
@@ -10,7 +10,7 @@
10
10
  class="side-nav_main-layout relative"
11
11
  data-side-nav-state="compact"
12
12
  >
13
- <SideNavigation/>
13
+ <SideNavigation language={language}/>
14
14
 
15
15
  <section class="side-nav_main-content">
16
16
  {@render children?.()}
@@ -1,6 +1,7 @@
1
1
  import './sidenav.scss';
2
2
  declare const SideNavigationLayout: import("svelte").Component<{
3
3
  children: any;
4
+ language: any;
4
5
  }, {}, "">;
5
6
  type SideNavigationLayout = ReturnType<typeof SideNavigationLayout>;
6
7
  export default SideNavigationLayout;
@@ -2,8 +2,6 @@
2
2
  import {type TeraUiContextProps} from "./TeraUiContext";
3
3
  import {setGlobalContext} from "./global-context";
4
4
  import {setLanguageTag} from "../../paraglide/runtime";
5
- import * as m from '../../paraglide/messages'
6
-
7
5
 
8
6
  let {
9
7
  children,
@@ -12,17 +10,19 @@
12
10
  ...props
13
11
  }: TeraUiContextProps = $props();
14
12
 
15
-
16
13
  setGlobalContext({
17
14
  supportLanguages,
18
15
  language,
19
16
  ...props
20
17
  })
21
18
 
22
- setLanguageTag(language)
23
- console.log('setLanguageTag', language)
24
- console.log('test translate', m.text_select_language())
19
+ console.log('tera-system-ui', 'TeraUIContext props', {
20
+ supportLanguages,
21
+ language,
22
+ ...props
23
+ })
25
24
 
25
+ setLanguageTag(language)
26
26
  </script>
27
27
 
28
28
  {@render children()}
@@ -12,6 +12,7 @@ export function setGlobalContext(data) {
12
12
  }
13
13
  export function getGlobalContext() {
14
14
  let context = getContext('globalContext') || get(globalContextStore);
15
+ console.log('tera-system-ui', 'getGlobalContext', context);
15
16
  if (!context) {
16
17
  console.error('tera-system-ui', 'Not set global context yet!', 'Using default context data');
17
18
  return {
@@ -10,12 +10,13 @@
10
10
  } from "../dropdown-menu";
11
11
  import {IconLogout, IconSettings} from "../icons";
12
12
  import {extractShortUsernameFromEmail} from "../../internal/service/user.service";
13
-
13
+ import * as m from '../../paraglide/messages'
14
14
  let {children, user, onLogout,...props}: UserAvatarWithMenuProps = $props();
15
15
 
16
16
  let shortUserName = extractShortUsernameFromEmail(user?.email)
17
17
  let triggerRef = $state()
18
18
  let open = $state(false)
19
+
19
20
  </script>
20
21
 
21
22
 
@@ -54,14 +55,14 @@
54
55
  href="/account-settings"
55
56
  >
56
57
  <IconSettings/>
57
- Account Settings
58
+ {m.text_account_settings()}
58
59
  </DropdownMenuItem>
59
60
  </DropdownMenuGroup>
60
61
  <DropdownMenuSeparator/>
61
62
  <DropdownMenuGroup>
62
63
  <DropdownMenuItem onclick={onLogout}>
63
64
  <IconLogout/>
64
- Logout
65
+ {m.text_logout()}
65
66
  </DropdownMenuItem>
66
67
  </DropdownMenuGroup>
67
68
  </DropdownMenu>
@@ -1,2 +1,2 @@
1
1
  export declare function extractShortUsernameFromEmail(email: string): string;
2
- export declare function getUserAvatarUrl(userUid: string): string;
2
+ export declare function getUserAvatarUrl(userUid: string, apiUrl?: string): string;
@@ -14,7 +14,7 @@ export function extractShortUsernameFromEmail(email) {
14
14
  shortForm = shortForm.slice(0, 4).toUpperCase();
15
15
  return shortForm || '?';
16
16
  }
17
- export function getUserAvatarUrl(userUid) {
18
- let baseUrl = `${getGlobalContext().apiUrl || 'https://hoidap.xyz/api/v1'}/users`;
17
+ export function getUserAvatarUrl(userUid, apiUrl) {
18
+ let baseUrl = `${apiUrl || getGlobalContext().apiUrl || 'https://hoidap.xyz/api/v1'}/users`;
19
19
  return `${baseUrl}/avatar/${encodeURI(userUid)}`;
20
20
  }
@@ -2,3 +2,5 @@ export function text_select_language(): string;
2
2
  export function text_unit_converter(): string;
3
3
  export function text_calces_scientific_calculator(): string;
4
4
  export function text_calces_documentation(): string;
5
+ export function text_account_settings(): string;
6
+ export function text_logout(): string;
@@ -40,3 +40,19 @@ export const text_calces_scientific_calculator = () => `CalcES Sci. Rechner`
40
40
  */
41
41
  /* @__NO_SIDE_EFFECTS__ */
42
42
  export const text_calces_documentation = () => `CalcES Dokumentation`
43
+
44
+
45
+ /**
46
+ *
47
+ * @returns {string}
48
+ */
49
+ /* @__NO_SIDE_EFFECTS__ */
50
+ export const text_account_settings = () => `Kontoeinstellungen`
51
+
52
+
53
+ /**
54
+ *
55
+ * @returns {string}
56
+ */
57
+ /* @__NO_SIDE_EFFECTS__ */
58
+ export const text_logout = () => `Abmelden`
@@ -2,3 +2,5 @@ export function text_select_language(): string;
2
2
  export function text_unit_converter(): string;
3
3
  export function text_calces_scientific_calculator(): string;
4
4
  export function text_calces_documentation(): string;
5
+ export function text_account_settings(): string;
6
+ export function text_logout(): string;
@@ -40,3 +40,19 @@ export const text_calces_scientific_calculator = () => `CalcES Scientific Calcul
40
40
  */
41
41
  /* @__NO_SIDE_EFFECTS__ */
42
42
  export const text_calces_documentation = () => `CalcES Documentation`
43
+
44
+
45
+ /**
46
+ *
47
+ * @returns {string}
48
+ */
49
+ /* @__NO_SIDE_EFFECTS__ */
50
+ export const text_account_settings = () => `Account Settings`
51
+
52
+
53
+ /**
54
+ *
55
+ * @returns {string}
56
+ */
57
+ /* @__NO_SIDE_EFFECTS__ */
58
+ export const text_logout = () => `Logout`
@@ -2,3 +2,5 @@ export function text_select_language(): string;
2
2
  export function text_unit_converter(): string;
3
3
  export function text_calces_scientific_calculator(): string;
4
4
  export function text_calces_documentation(): string;
5
+ export function text_account_settings(): string;
6
+ export function text_logout(): string;
@@ -40,3 +40,19 @@ export const text_calces_scientific_calculator = () => `Calculadora Científica`
40
40
  */
41
41
  /* @__NO_SIDE_EFFECTS__ */
42
42
  export const text_calces_documentation = () => `Documentación de CalcES`
43
+
44
+
45
+ /**
46
+ *
47
+ * @returns {string}
48
+ */
49
+ /* @__NO_SIDE_EFFECTS__ */
50
+ export const text_account_settings = () => `Configuración de la cuenta`
51
+
52
+
53
+ /**
54
+ *
55
+ * @returns {string}
56
+ */
57
+ /* @__NO_SIDE_EFFECTS__ */
58
+ export const text_logout = () => `Cerrar sesión`
@@ -2,3 +2,5 @@ export function text_select_language(): string;
2
2
  export function text_unit_converter(): string;
3
3
  export function text_calces_scientific_calculator(): string;
4
4
  export function text_calces_documentation(): string;
5
+ export function text_account_settings(): string;
6
+ export function text_logout(): string;
@@ -40,3 +40,19 @@ export const text_calces_scientific_calculator = () => `Calculatrice Scientifiqu
40
40
  */
41
41
  /* @__NO_SIDE_EFFECTS__ */
42
42
  export const text_calces_documentation = () => `Documentation de CalcES`
43
+
44
+
45
+ /**
46
+ *
47
+ * @returns {string}
48
+ */
49
+ /* @__NO_SIDE_EFFECTS__ */
50
+ export const text_account_settings = () => `Paramètres du compte`
51
+
52
+
53
+ /**
54
+ *
55
+ * @returns {string}
56
+ */
57
+ /* @__NO_SIDE_EFFECTS__ */
58
+ export const text_logout = () => `Déconnexion`
@@ -2,3 +2,5 @@ export function text_select_language(): string;
2
2
  export function text_unit_converter(): string;
3
3
  export function text_calces_scientific_calculator(): string;
4
4
  export function text_calces_documentation(): string;
5
+ export function text_account_settings(): string;
6
+ export function text_logout(): string;
@@ -40,3 +40,19 @@ export const text_calces_scientific_calculator = () => `Calcolatrice Scientifica
40
40
  */
41
41
  /* @__NO_SIDE_EFFECTS__ */
42
42
  export const text_calces_documentation = () => `Documentazione di CalcES`
43
+
44
+
45
+ /**
46
+ *
47
+ * @returns {string}
48
+ */
49
+ /* @__NO_SIDE_EFFECTS__ */
50
+ export const text_account_settings = () => `Impostazioni dell'account`
51
+
52
+
53
+ /**
54
+ *
55
+ * @returns {string}
56
+ */
57
+ /* @__NO_SIDE_EFFECTS__ */
58
+ export const text_logout = () => `Disconnettersi`
@@ -2,3 +2,5 @@ export function text_select_language(): string;
2
2
  export function text_unit_converter(): string;
3
3
  export function text_calces_scientific_calculator(): string;
4
4
  export function text_calces_documentation(): string;
5
+ export function text_account_settings(): string;
6
+ export function text_logout(): string;
@@ -40,3 +40,19 @@ export const text_calces_scientific_calculator = () => `Calculadora Científica`
40
40
  */
41
41
  /* @__NO_SIDE_EFFECTS__ */
42
42
  export const text_calces_documentation = () => `Documentação CalcES`
43
+
44
+
45
+ /**
46
+ *
47
+ * @returns {string}
48
+ */
49
+ /* @__NO_SIDE_EFFECTS__ */
50
+ export const text_account_settings = () => `Configurações da conta`
51
+
52
+
53
+ /**
54
+ *
55
+ * @returns {string}
56
+ */
57
+ /* @__NO_SIDE_EFFECTS__ */
58
+ export const text_logout = () => `Sair`
@@ -2,3 +2,5 @@ export function text_select_language(): string;
2
2
  export function text_unit_converter(): string;
3
3
  export function text_calces_scientific_calculator(): string;
4
4
  export function text_calces_documentation(): string;
5
+ export function text_account_settings(): string;
6
+ export function text_logout(): string;
@@ -40,3 +40,19 @@ export const text_calces_scientific_calculator = () => `Научный каль
40
40
  */
41
41
  /* @__NO_SIDE_EFFECTS__ */
42
42
  export const text_calces_documentation = () => `Документация CalcES`
43
+
44
+
45
+ /**
46
+ *
47
+ * @returns {string}
48
+ */
49
+ /* @__NO_SIDE_EFFECTS__ */
50
+ export const text_account_settings = () => `Настройки аккаунта`
51
+
52
+
53
+ /**
54
+ *
55
+ * @returns {string}
56
+ */
57
+ /* @__NO_SIDE_EFFECTS__ */
58
+ export const text_logout = () => `Выйти`
@@ -2,3 +2,5 @@ export function text_select_language(): string;
2
2
  export function text_unit_converter(): string;
3
3
  export function text_calces_scientific_calculator(): string;
4
4
  export function text_calces_documentation(): string;
5
+ export function text_account_settings(): string;
6
+ export function text_logout(): string;
@@ -40,3 +40,19 @@ export const text_calces_scientific_calculator = () => `Máy Tính Khoa Học`
40
40
  */
41
41
  /* @__NO_SIDE_EFFECTS__ */
42
42
  export const text_calces_documentation = () => `Tài Liệu CalcES`
43
+
44
+
45
+ /**
46
+ *
47
+ * @returns {string}
48
+ */
49
+ /* @__NO_SIDE_EFFECTS__ */
50
+ export const text_account_settings = () => `Cài đặt tài khoản`
51
+
52
+
53
+ /**
54
+ *
55
+ * @returns {string}
56
+ */
57
+ /* @__NO_SIDE_EFFECTS__ */
58
+ export const text_logout = () => `Đăng xuất`
@@ -10,3 +10,9 @@ export function text_calces_scientific_calculator(params?: {}, options?: {
10
10
  export function text_calces_documentation(params?: {}, options?: {
11
11
  languageTag?: "de" | "en" | "es" | "fr" | "pt" | "vi" | "ru" | "it";
12
12
  }): string;
13
+ export function text_account_settings(params?: {}, options?: {
14
+ languageTag?: "de" | "en" | "es" | "fr" | "pt" | "vi" | "ru" | "it";
15
+ }): string;
16
+ export function text_logout(params?: {}, options?: {
17
+ languageTag?: "de" | "en" | "es" | "fr" | "pt" | "vi" | "ru" | "it";
18
+ }): string;
@@ -120,3 +120,59 @@ export const text_calces_documentation = (params = {}, options = {}) => {
120
120
  }[options.languageTag ?? languageTag()]()
121
121
  }
122
122
 
123
+
124
+
125
+ /**
126
+ * This message has been compiled by [inlang paraglide](https://inlang.com/m/gerre34r/library-inlang-paraglideJs).
127
+ *
128
+ * - Don't edit the message's code. Use [Sherlock (VS Code extension)](https://inlang.com/m/r7kp499g/app-inlang-ideExtension),
129
+ * the [web editor](https://inlang.com/m/tdozzpar/app-inlang-finkLocalizationEditor) instead, or edit the translation files manually.
130
+ *
131
+ * - The params are NonNullable<unknown> because the inlang SDK does not provide information on the type of a param (yet).
132
+ *
133
+ * @param {{}} params
134
+ * @param {{ languageTag?: "de" | "en" | "es" | "fr" | "pt" | "vi" | "ru" | "it" }} options
135
+ * @returns {string}
136
+ */
137
+ /* @__NO_SIDE_EFFECTS__ */
138
+ export const text_account_settings = (params = {}, options = {}) => {
139
+ return {
140
+ de: de.text_account_settings,
141
+ en: en.text_account_settings,
142
+ es: es.text_account_settings,
143
+ fr: fr.text_account_settings,
144
+ it: it.text_account_settings,
145
+ pt: pt.text_account_settings,
146
+ ru: ru.text_account_settings,
147
+ vi: vi.text_account_settings
148
+ }[options.languageTag ?? languageTag()]()
149
+ }
150
+
151
+
152
+
153
+ /**
154
+ * This message has been compiled by [inlang paraglide](https://inlang.com/m/gerre34r/library-inlang-paraglideJs).
155
+ *
156
+ * - Don't edit the message's code. Use [Sherlock (VS Code extension)](https://inlang.com/m/r7kp499g/app-inlang-ideExtension),
157
+ * the [web editor](https://inlang.com/m/tdozzpar/app-inlang-finkLocalizationEditor) instead, or edit the translation files manually.
158
+ *
159
+ * - The params are NonNullable<unknown> because the inlang SDK does not provide information on the type of a param (yet).
160
+ *
161
+ * @param {{}} params
162
+ * @param {{ languageTag?: "de" | "en" | "es" | "fr" | "pt" | "vi" | "ru" | "it" }} options
163
+ * @returns {string}
164
+ */
165
+ /* @__NO_SIDE_EFFECTS__ */
166
+ export const text_logout = (params = {}, options = {}) => {
167
+ return {
168
+ de: de.text_logout,
169
+ en: en.text_logout,
170
+ es: es.text_logout,
171
+ fr: fr.text_logout,
172
+ it: it.text_logout,
173
+ pt: pt.text_logout,
174
+ ru: ru.text_logout,
175
+ vi: vi.text_logout
176
+ }[options.languageTag ?? languageTag()]()
177
+ }
178
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tera-system-ui",
3
- "version": "0.0.29",
3
+ "version": "0.0.34",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "npm run customPrepublish && npm run generate-index && vite build && npm run package && npm run postpublish",
@@ -65,7 +65,7 @@
65
65
  "@storybook/addon-interactions": "^8.4.4",
66
66
  "@storybook/addon-links": "^8.4.4",
67
67
  "@storybook/addon-styling": "^1.3.7",
68
- "@storybook/addon-svelte-csf": "^5.0.0-next.8",
68
+ "@storybook/addon-svelte-csf": "^5.0.0-next.11",
69
69
  "@storybook/addon-themes": "^8.4.4",
70
70
  "@storybook/addon-viewport": "^8.4.4",
71
71
  "@storybook/blocks": "^8.4.4",