tera-system-ui 0.0.19 → 0.0.20
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/brand-logo/BrandLogo.svelte +31 -31
- package/dist/components/button/Button.svelte +49 -49
- package/dist/components/combobox/Combobox.svelte +8 -8
- package/dist/components/command/command.scss +72 -72
- package/dist/components/command/components/Command.svelte +120 -120
- package/dist/components/command/components/CommandEmpty.svelte +30 -30
- package/dist/components/command/components/CommandGroup.svelte +110 -110
- package/dist/components/command/components/CommandInput.svelte +92 -92
- package/dist/components/command/components/CommandItem.svelte +110 -110
- package/dist/components/command/components/CommandList.svelte +56 -56
- package/dist/components/command/components/CommandLoading.svelte +28 -28
- package/dist/components/command/components/CommandSeparator.svelte +21 -21
- package/dist/components/dialog/Dialog.astro +63 -0
- package/dist/components/dialog/Dialog.d.ts +10 -6
- package/dist/components/dialog/Dialog.svelte +109 -107
- package/dist/components/dialog/dialog.scss +115 -112
- package/dist/components/dialog/index.d.ts +1 -0
- package/dist/components/dialog/index.js +1 -0
- package/dist/components/header/Header.svelte +36 -36
- package/dist/components/header/header.scss +19 -19
- package/dist/components/icons/IconArrowBigRightFilled.svelte +10 -10
- package/dist/components/icons/IconBook.svelte +10 -10
- package/dist/components/icons/IconBookmarkPlus.svelte +10 -10
- package/dist/components/icons/IconCalculator.svelte +10 -10
- package/dist/components/icons/IconCheck.svelte +10 -10
- package/dist/components/icons/IconChevronDown.svelte +10 -10
- package/dist/components/icons/IconCopy.svelte +10 -10
- package/dist/components/icons/IconCopyCheckFilled.svelte +10 -10
- package/dist/components/icons/IconHamburger.svelte +10 -10
- package/dist/components/icons/IconLanguage.svelte +10 -10
- package/dist/components/icons/IconLoader2.svelte +10 -10
- package/dist/components/icons/IconMoon.svelte +10 -10
- package/dist/components/icons/IconPointFilled.svelte +10 -10
- package/dist/components/icons/IconSearch.svelte +10 -10
- package/dist/components/icons/IconSun.svelte +10 -10
- package/dist/components/icons/IconSwitchHorizontal.svelte +10 -10
- package/dist/components/icons/IconSwitchVertical.svelte +10 -10
- package/dist/components/icons/IconTransform.svelte +10 -10
- package/dist/components/icons/IconX.svelte +10 -10
- package/dist/components/input/Input.svelte +24 -24
- package/dist/components/language-picker-button/LanguagePickerButton.svelte +109 -109
- package/dist/components/light-dark-toggle/LightDarkToggle.svelte +36 -36
- package/dist/components/popover/Popover.svelte +136 -136
- package/dist/components/popover-responsive/PopoverResponsive.svelte +87 -87
- package/dist/components/side-navigation/SideNavigation.svelte +114 -114
- package/dist/components/side-navigation/SideNavigationItem.svelte +17 -17
- package/dist/components/side-navigation/SideNavigationLayout.svelte +19 -19
- package/dist/components/side-navigation/sidenav.scss +149 -149
- package/dist/components/tera-ui-context/TeraUiContext.d.ts +1 -0
- package/dist/components/tera-ui-context/TeraUiContext.svelte +28 -28
- package/dist/components/tera-ui-context/global-context-store.d.ts +3 -0
- package/dist/components/tera-ui-context/global-context-store.js +2 -0
- package/dist/components/tera-ui-context/global-context.js +11 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/themes/scrollbar.scss +37 -37
- package/dist/themes/tera-ui-base.css +58 -22
- package/dist/themes/tw-preset.cjs +3 -0
- package/dist/themes/tw-preset.d.cts +4 -0
- package/package.json +96 -95
- package/scripts/add-component-template.js +120 -120
- package/scripts/generate-ts-index.js +136 -136
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconCheck} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconCheck class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconCheck} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconCheck class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconChevronDown} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconChevronDown class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconChevronDown} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconChevronDown class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconCopy} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconCopy class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconCopy} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconCopy class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconCopyCheckFilled} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconCopyCheckFilled class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconCopyCheckFilled} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconCopyCheckFilled class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconMenu2} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconMenu2 class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconMenu2} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconMenu2 class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconLanguage} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconLanguage class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconLanguage} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconLanguage class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconLoader2} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconLoader2 class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconLoader2} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconLoader2 class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconMoonStars} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconMoonStars class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconMoonStars} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconMoonStars class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconPointFilled} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconPointFilled class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconPointFilled} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconPointFilled class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconSearch} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconSearch class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconSearch} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconSearch class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconSunHigh} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconSunHigh class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconSunHigh} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconSunHigh class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconSwitchHorizontal} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconSwitchHorizontal class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconSwitchHorizontal} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconSwitchHorizontal class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconSwitchVertical} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconSwitchVertical class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconSwitchVertical} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconSwitchVertical class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconTransform} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconTransform class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconTransform} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconTransform class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type IconsProps, styles} from "./Icons";
|
|
3
|
-
import {IconX} from "@tabler/icons-svelte";
|
|
4
|
-
|
|
5
|
-
let {children, ...props}: IconsProps = $props();
|
|
6
|
-
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<IconX class={styles({...props})}/>
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type IconsProps, styles} from "./Icons";
|
|
3
|
+
import {IconX} from "@tabler/icons-svelte";
|
|
4
|
+
|
|
5
|
+
let {children, ...props}: IconsProps = $props();
|
|
6
|
+
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IconX class={styles({...props})}/>
|
|
10
|
+
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type InputProps, styles} from "./Input";
|
|
3
|
-
|
|
4
|
-
let {
|
|
5
|
-
children,
|
|
6
|
-
class: className,
|
|
7
|
-
value = $bindable(),
|
|
8
|
-
ref = $bindable(),
|
|
9
|
-
size,
|
|
10
|
-
disabled,
|
|
11
|
-
variant = 'outlined',
|
|
12
|
-
prefix,
|
|
13
|
-
...props
|
|
14
|
-
}: InputProps = $props();
|
|
15
|
-
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<input
|
|
19
|
-
type="text"
|
|
20
|
-
bind:this={ref}
|
|
21
|
-
class={styles({ variant, disabled , size, className})}
|
|
22
|
-
{disabled}
|
|
23
|
-
{...props}
|
|
24
|
-
bind:value
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type InputProps, styles} from "./Input";
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
children,
|
|
6
|
+
class: className,
|
|
7
|
+
value = $bindable(),
|
|
8
|
+
ref = $bindable(),
|
|
9
|
+
size,
|
|
10
|
+
disabled,
|
|
11
|
+
variant = 'outlined',
|
|
12
|
+
prefix,
|
|
13
|
+
...props
|
|
14
|
+
}: InputProps = $props();
|
|
15
|
+
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<input
|
|
19
|
+
type="text"
|
|
20
|
+
bind:this={ref}
|
|
21
|
+
class={styles({ variant, disabled , size, className})}
|
|
22
|
+
{disabled}
|
|
23
|
+
{...props}
|
|
24
|
+
bind:value
|
|
25
25
|
/>
|
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {type LanguagePickerButtonProps} from "./LanguagePickerButton";
|
|
3
|
-
import {IconLanguage} from "../icons";
|
|
4
|
-
import {Dialog} from "../dialog";
|
|
5
|
-
import IconCheck from "../icons/IconCheck.svelte";
|
|
6
|
-
import {getGlobalContext} from "../tera-ui-context/global-context";
|
|
7
|
-
import * as m from '../../paraglide/messages.js'
|
|
8
|
-
|
|
9
|
-
let {
|
|
10
|
-
children,
|
|
11
|
-
onLangSelect,
|
|
12
|
-
...props
|
|
13
|
-
}: LanguagePickerButtonProps & {
|
|
14
|
-
onLangSelect: (langCode: string) => void
|
|
15
|
-
} = $props();
|
|
16
|
-
|
|
17
|
-
let context = getGlobalContext()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const LANGUAGE_LIST = [
|
|
21
|
-
{
|
|
22
|
-
code: "en",
|
|
23
|
-
label: "English (US)",
|
|
24
|
-
flag: 'united states'
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
code: "de",
|
|
28
|
-
label: "Deutsch",
|
|
29
|
-
flag: 'germany'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
code: "es",
|
|
33
|
-
label: "Español",
|
|
34
|
-
flag: 'spain'
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
code: "fr",
|
|
38
|
-
label: "Français",
|
|
39
|
-
flag: 'france'
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
code: "it",
|
|
43
|
-
label: "Italiano",
|
|
44
|
-
flag: 'italy'
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
code: "pt",
|
|
48
|
-
label: "Português",
|
|
49
|
-
flag: 'portugal'
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
code: "ru",
|
|
53
|
-
label: "Русский",
|
|
54
|
-
flag: 'russia'
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
code: "vi",
|
|
58
|
-
label: "Tiếng Việt",
|
|
59
|
-
flag: 'vietnam'
|
|
60
|
-
}
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
].filter(lang => context.supportLanguages!.includes(lang.code))
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
let currentLangItem = $derived(LANGUAGE_LIST.find(l => l.code === context.language)!)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
function getFlagUrl(flag: string) {
|
|
69
|
-
if (flag === 'spain') {
|
|
70
|
-
return `${context.basePath ?? ''}/world-flags/${flag}.png`
|
|
71
|
-
}
|
|
72
|
-
return `${context.basePath ?? ''}/world-flags/${flag}.svg`
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
let openDialog = $state(false)
|
|
76
|
-
</script>
|
|
77
|
-
|
|
78
|
-
<!--add component here-->
|
|
79
|
-
<button onclick={() => {openDialog = true}}
|
|
80
|
-
class="h-8 flex items-center bg-neutral-token-4 text-neutral-token-9 rounded-full ps-2 pe-1 hover:bg-neutral-token-5 transition-all duration-element-react">
|
|
81
|
-
<IconLanguage class="size-icon-xs"/>
|
|
82
|
-
<img class="size-6 flag-img" src={getFlagUrl(currentLangItem.flag)} alt={currentLangItem.flag}>
|
|
83
|
-
</button>
|
|
84
|
-
|
|
85
|
-
<Dialog bind:open={openDialog} class="text-neutral-token-13" size="xs" staticRender>
|
|
86
|
-
{#snippet header()}
|
|
87
|
-
{m.text_select_language()}
|
|
88
|
-
{/snippet}
|
|
89
|
-
<div class="grid grid-cols-1 mx-auto gap-2">
|
|
90
|
-
{#each LANGUAGE_LIST as lang}
|
|
91
|
-
<button class="w-full flex gap-1 items-center justify-between text-start px-1 py-1 pe-2 rounded-full bg-neutral-token-3"
|
|
92
|
-
onclick={() => {
|
|
93
|
-
onLangSelect?.(lang.code)
|
|
94
|
-
openDialog = false
|
|
95
|
-
}}
|
|
96
|
-
data-selected={lang.code === context.language ? '' : undefined}>
|
|
97
|
-
<div class="flex items-center gap-2">
|
|
98
|
-
<img class="size-8 flag-img" src={getFlagUrl(lang.flag)} alt={currentLangItem.flag} loading="lazy">
|
|
99
|
-
{lang.label}
|
|
100
|
-
</div>
|
|
101
|
-
<div class="check">
|
|
102
|
-
<IconCheck class="check size-icon-sm"/>
|
|
103
|
-
</div>
|
|
104
|
-
</button>
|
|
105
|
-
{/each}
|
|
106
|
-
</div>
|
|
107
|
-
</Dialog>
|
|
108
|
-
|
|
109
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type LanguagePickerButtonProps} from "./LanguagePickerButton";
|
|
3
|
+
import {IconLanguage} from "../icons";
|
|
4
|
+
import {Dialog} from "../dialog";
|
|
5
|
+
import IconCheck from "../icons/IconCheck.svelte";
|
|
6
|
+
import {getGlobalContext} from "../tera-ui-context/global-context";
|
|
7
|
+
import * as m from '../../paraglide/messages.js'
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
children,
|
|
11
|
+
onLangSelect,
|
|
12
|
+
...props
|
|
13
|
+
}: LanguagePickerButtonProps & {
|
|
14
|
+
onLangSelect: (langCode: string) => void
|
|
15
|
+
} = $props();
|
|
16
|
+
|
|
17
|
+
let context = getGlobalContext()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const LANGUAGE_LIST = [
|
|
21
|
+
{
|
|
22
|
+
code: "en",
|
|
23
|
+
label: "English (US)",
|
|
24
|
+
flag: 'united states'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
code: "de",
|
|
28
|
+
label: "Deutsch",
|
|
29
|
+
flag: 'germany'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
code: "es",
|
|
33
|
+
label: "Español",
|
|
34
|
+
flag: 'spain'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
code: "fr",
|
|
38
|
+
label: "Français",
|
|
39
|
+
flag: 'france'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
code: "it",
|
|
43
|
+
label: "Italiano",
|
|
44
|
+
flag: 'italy'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
code: "pt",
|
|
48
|
+
label: "Português",
|
|
49
|
+
flag: 'portugal'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
code: "ru",
|
|
53
|
+
label: "Русский",
|
|
54
|
+
flag: 'russia'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
code: "vi",
|
|
58
|
+
label: "Tiếng Việt",
|
|
59
|
+
flag: 'vietnam'
|
|
60
|
+
}
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
].filter(lang => context.supportLanguages!.includes(lang.code))
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
let currentLangItem = $derived(LANGUAGE_LIST.find(l => l.code === context.language)!)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
function getFlagUrl(flag: string) {
|
|
69
|
+
if (flag === 'spain') {
|
|
70
|
+
return `${context.basePath ?? ''}/world-flags/${flag}.png`
|
|
71
|
+
}
|
|
72
|
+
return `${context.basePath ?? ''}/world-flags/${flag}.svg`
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let openDialog = $state(false)
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<!--add component here-->
|
|
79
|
+
<button onclick={() => {openDialog = true}}
|
|
80
|
+
class="h-8 flex items-center bg-neutral-token-4 text-neutral-token-9 rounded-full ps-2 pe-1 hover:bg-neutral-token-5 transition-all duration-element-react">
|
|
81
|
+
<IconLanguage class="size-icon-xs"/>
|
|
82
|
+
<img class="size-6 flag-img" src={getFlagUrl(currentLangItem.flag)} alt={currentLangItem.flag}>
|
|
83
|
+
</button>
|
|
84
|
+
|
|
85
|
+
<Dialog bind:open={openDialog} class="text-neutral-token-13" size="xs" staticRender>
|
|
86
|
+
{#snippet header()}
|
|
87
|
+
{m.text_select_language()}
|
|
88
|
+
{/snippet}
|
|
89
|
+
<div class="grid grid-cols-1 mx-auto gap-2">
|
|
90
|
+
{#each LANGUAGE_LIST as lang}
|
|
91
|
+
<button class="w-full flex gap-1 items-center justify-between text-start px-1 py-1 pe-2 rounded-full bg-neutral-token-3"
|
|
92
|
+
onclick={() => {
|
|
93
|
+
onLangSelect?.(lang.code)
|
|
94
|
+
openDialog = false
|
|
95
|
+
}}
|
|
96
|
+
data-selected={lang.code === context.language ? '' : undefined}>
|
|
97
|
+
<div class="flex items-center gap-2">
|
|
98
|
+
<img class="size-8 flag-img" src={getFlagUrl(lang.flag)} alt={currentLangItem.flag} loading="lazy">
|
|
99
|
+
{lang.label}
|
|
100
|
+
</div>
|
|
101
|
+
<div class="check">
|
|
102
|
+
<IconCheck class="check size-icon-sm"/>
|
|
103
|
+
</div>
|
|
104
|
+
</button>
|
|
105
|
+
{/each}
|
|
106
|
+
</div>
|
|
107
|
+
</Dialog>
|
|
108
|
+
|
|
109
|
+
|
|
110
110
|
<style>button .check {
|
|
111
111
|
opacity: 0;
|
|
112
112
|
}
|