tera-system-ui 0.0.1 → 0.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/actions/clickOutside.d.ts +6 -0
- package/dist/{components/side-navigation → actions}/clickOutside.js +3 -2
- package/dist/components/button/Button.d.ts +2 -2
- package/dist/components/button/Button.js +5 -5
- package/dist/components/button/Button.svelte +10 -8
- package/dist/components/button/Button.svelte.d.ts +3 -1
- package/dist/components/combobox/Combobox.d.ts +8 -0
- package/dist/components/combobox/Combobox.js +7 -0
- package/dist/components/combobox/Combobox.svelte +8 -0
- package/dist/components/combobox/Combobox.svelte.d.ts +3 -0
- package/dist/components/combobox/index.d.ts +1 -0
- package/dist/components/combobox/index.js +1 -0
- package/dist/components/command/command.d.ts +33 -0
- package/dist/components/command/command.js +512 -0
- package/dist/components/command/command.scss +73 -0
- package/dist/components/command/components/Command.svelte +120 -0
- package/dist/components/command/components/Command.svelte.d.ts +3 -0
- package/dist/components/command/components/CommandEmpty.svelte +30 -0
- package/dist/components/command/components/CommandEmpty.svelte.d.ts +3 -0
- package/dist/components/command/components/CommandGroup.svelte +110 -0
- package/dist/components/command/components/CommandGroup.svelte.d.ts +3 -0
- package/dist/components/command/components/CommandInput.svelte +90 -0
- package/dist/components/command/components/CommandInput.svelte.d.ts +7 -0
- package/dist/components/command/components/CommandItem.svelte +110 -0
- package/dist/components/command/components/CommandItem.svelte.d.ts +3 -0
- package/dist/components/command/components/CommandList.svelte +56 -0
- package/dist/components/command/components/CommandList.svelte.d.ts +5 -0
- package/dist/components/command/components/CommandLoading.svelte +29 -0
- package/dist/components/command/components/CommandLoading.svelte.d.ts +8 -0
- package/dist/components/command/components/CommandSeparator.svelte +21 -0
- package/dist/components/command/components/CommandSeparator.svelte.d.ts +3 -0
- package/dist/components/command/index.d.ts +12 -0
- package/dist/components/command/index.js +19 -0
- package/dist/components/command/types.d.ts +227 -0
- package/dist/components/command/types.js +1 -0
- package/dist/components/dialog/Dialog.svelte +1 -67
- package/dist/components/dialog/Dialog.svelte.d.ts +1 -0
- package/dist/components/dialog/dialog.scss +58 -0
- package/dist/components/icons/IconArrowBigRightFilled.svelte +10 -0
- package/dist/components/icons/IconArrowBigRightFilled.svelte.d.ts +4 -0
- package/dist/components/icons/IconBookmarkPlus.svelte +10 -0
- package/dist/components/icons/IconBookmarkPlus.svelte.d.ts +4 -0
- package/dist/components/icons/IconChevronDown.svelte +10 -0
- package/dist/components/icons/IconChevronDown.svelte.d.ts +4 -0
- package/dist/components/icons/IconCopy.svelte +10 -0
- package/dist/components/icons/IconCopy.svelte.d.ts +4 -0
- package/dist/components/icons/IconCopyCheckFilled.svelte +10 -0
- package/dist/components/icons/IconCopyCheckFilled.svelte.d.ts +4 -0
- package/dist/components/icons/IconLoader2.svelte +10 -0
- package/dist/components/icons/IconLoader2.svelte.d.ts +4 -0
- package/dist/components/icons/IconPointFilled.svelte +10 -0
- package/dist/components/icons/IconPointFilled.svelte.d.ts +4 -0
- package/dist/components/icons/IconSearch.svelte +10 -0
- package/dist/components/icons/IconSearch.svelte.d.ts +4 -0
- package/dist/components/icons/IconSwitchHorizontal.svelte +10 -0
- package/dist/components/icons/IconSwitchHorizontal.svelte.d.ts +4 -0
- package/dist/components/icons/IconSwitchVertical.svelte +10 -0
- package/dist/components/icons/IconSwitchVertical.svelte.d.ts +4 -0
- package/dist/components/icons/index.d.ts +17 -0
- package/dist/components/icons/index.js +17 -0
- package/dist/components/input/Input.d.ts +116 -0
- package/dist/components/input/Input.js +36 -0
- package/dist/components/input/Input.svelte +19 -8
- package/dist/components/input/Input.svelte.d.ts +2 -22
- package/dist/components/language-picker-button/LanguagePickerButton.svelte +13 -10
- package/dist/components/language-picker-button/LanguagePickerButton.svelte.d.ts +0 -2
- package/dist/components/popover/Popover.d.ts +14 -0
- package/dist/components/popover/Popover.js +8 -0
- package/dist/components/popover/Popover.svelte +129 -0
- package/dist/components/popover/Popover.svelte.d.ts +3 -0
- package/dist/components/popover/index.d.ts +1 -0
- package/dist/components/popover/index.js +1 -0
- package/dist/components/side-navigation/SideNavigation.js +0 -1
- package/dist/components/side-navigation/SideNavigation.svelte +40 -20
- package/dist/components/tera-ui-context/TeraUiContext.d.ts +11 -0
- package/dist/components/tera-ui-context/TeraUiContext.js +1 -0
- package/dist/components/tera-ui-context/TeraUiContext.svelte +21 -0
- package/dist/components/tera-ui-context/TeraUiContext.svelte.d.ts +3 -0
- package/dist/components/tera-ui-context/global-context.d.ts +3 -0
- package/dist/components/tera-ui-context/global-context.js +15 -0
- package/dist/components/tera-ui-context/index.d.ts +1 -0
- package/dist/components/tera-ui-context/index.js +1 -0
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/language.d.ts +2 -0
- package/dist/i18n/language.js +10 -0
- package/dist/i18n.d.ts +1 -0
- package/dist/i18n.js +4 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +13 -2
- package/dist/internal/command-score.d.ts +1 -0
- package/dist/internal/command-score.js +119 -0
- package/dist/internal/helpers/callbacks.d.ts +12 -0
- package/dist/internal/helpers/callbacks.js +15 -0
- package/dist/internal/helpers/event.d.ts +14 -0
- package/dist/internal/helpers/event.js +17 -0
- package/dist/internal/helpers/id.d.ts +1 -0
- package/dist/internal/helpers/id.js +4 -0
- package/dist/internal/helpers/index.d.ts +8 -0
- package/dist/internal/helpers/index.js +8 -0
- package/dist/internal/helpers/is.d.ts +4 -0
- package/dist/internal/helpers/is.js +10 -0
- package/dist/internal/helpers/kbd.d.ts +35 -0
- package/dist/internal/helpers/kbd.js +35 -0
- package/dist/internal/helpers/object.d.ts +2 -0
- package/dist/internal/helpers/object.js +19 -0
- package/dist/internal/helpers/sleep.d.ts +1 -0
- package/dist/internal/helpers/sleep.js +3 -0
- package/dist/internal/helpers/store.d.ts +29 -0
- package/dist/internal/helpers/store.js +80 -0
- package/dist/internal/helpers/style.d.ts +12 -0
- package/dist/internal/helpers/style.js +18 -0
- package/dist/internal/index.d.ts +3 -0
- package/dist/internal/index.js +3 -0
- package/dist/internal/types.d.ts +18 -0
- package/dist/internal/types.js +1 -0
- package/dist/themes/index.d.ts +1 -0
- package/dist/themes/index.js +1 -0
- package/dist/themes/scrollbar.scss +37 -0
- package/dist/themes/tera-ui-base.css +174 -0
- package/dist/themes/tw-preset.cjs +151 -0
- package/dist/themes/tw-preset.d.cts +149 -0
- package/package.json +41 -19
- package/scripts/generate-ts-index.js +137 -0
- package/dist/components/input/input.d.ts +0 -49
- package/dist/components/input/input.js +0 -14
- package/dist/components/side-navigation/clickOutside.d.ts +0 -4
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { type VariantProps } from "tailwind-variants";
|
|
2
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
variant: {
|
|
4
|
+
outlined: string;
|
|
5
|
+
filled: string;
|
|
6
|
+
borderless: string;
|
|
7
|
+
};
|
|
8
|
+
disabled: {
|
|
9
|
+
true: string;
|
|
10
|
+
false: string;
|
|
11
|
+
};
|
|
12
|
+
size: {
|
|
13
|
+
sm: string;
|
|
14
|
+
md: string;
|
|
15
|
+
lg: string;
|
|
16
|
+
};
|
|
17
|
+
}, undefined, "relative w-full inline-flex items-center justify-center rounded outline-none transition-all duration-element-react ring-primary-token-5/50", import("tailwind-variants/dist/config").TVConfig<{
|
|
18
|
+
variant: {
|
|
19
|
+
outlined: string;
|
|
20
|
+
filled: string;
|
|
21
|
+
borderless: string;
|
|
22
|
+
};
|
|
23
|
+
disabled: {
|
|
24
|
+
true: string;
|
|
25
|
+
false: string;
|
|
26
|
+
};
|
|
27
|
+
size: {
|
|
28
|
+
sm: string;
|
|
29
|
+
md: string;
|
|
30
|
+
lg: string;
|
|
31
|
+
};
|
|
32
|
+
}, {
|
|
33
|
+
variant: {
|
|
34
|
+
outlined: string;
|
|
35
|
+
filled: string;
|
|
36
|
+
borderless: string;
|
|
37
|
+
};
|
|
38
|
+
disabled: {
|
|
39
|
+
true: string;
|
|
40
|
+
false: string;
|
|
41
|
+
};
|
|
42
|
+
size: {
|
|
43
|
+
sm: string;
|
|
44
|
+
md: string;
|
|
45
|
+
lg: string;
|
|
46
|
+
};
|
|
47
|
+
}>, {
|
|
48
|
+
variant: {
|
|
49
|
+
outlined: string;
|
|
50
|
+
filled: string;
|
|
51
|
+
borderless: string;
|
|
52
|
+
};
|
|
53
|
+
disabled: {
|
|
54
|
+
true: string;
|
|
55
|
+
false: string;
|
|
56
|
+
};
|
|
57
|
+
size: {
|
|
58
|
+
sm: string;
|
|
59
|
+
md: string;
|
|
60
|
+
lg: string;
|
|
61
|
+
};
|
|
62
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
63
|
+
variant: {
|
|
64
|
+
outlined: string;
|
|
65
|
+
filled: string;
|
|
66
|
+
borderless: string;
|
|
67
|
+
};
|
|
68
|
+
disabled: {
|
|
69
|
+
true: string;
|
|
70
|
+
false: string;
|
|
71
|
+
};
|
|
72
|
+
size: {
|
|
73
|
+
sm: string;
|
|
74
|
+
md: string;
|
|
75
|
+
lg: string;
|
|
76
|
+
};
|
|
77
|
+
}, undefined, "relative w-full inline-flex items-center justify-center rounded outline-none transition-all duration-element-react ring-primary-token-5/50", import("tailwind-variants/dist/config").TVConfig<{
|
|
78
|
+
variant: {
|
|
79
|
+
outlined: string;
|
|
80
|
+
filled: string;
|
|
81
|
+
borderless: string;
|
|
82
|
+
};
|
|
83
|
+
disabled: {
|
|
84
|
+
true: string;
|
|
85
|
+
false: string;
|
|
86
|
+
};
|
|
87
|
+
size: {
|
|
88
|
+
sm: string;
|
|
89
|
+
md: string;
|
|
90
|
+
lg: string;
|
|
91
|
+
};
|
|
92
|
+
}, {
|
|
93
|
+
variant: {
|
|
94
|
+
outlined: string;
|
|
95
|
+
filled: string;
|
|
96
|
+
borderless: string;
|
|
97
|
+
};
|
|
98
|
+
disabled: {
|
|
99
|
+
true: string;
|
|
100
|
+
false: string;
|
|
101
|
+
};
|
|
102
|
+
size: {
|
|
103
|
+
sm: string;
|
|
104
|
+
md: string;
|
|
105
|
+
lg: string;
|
|
106
|
+
};
|
|
107
|
+
}>, unknown, unknown, undefined>>;
|
|
108
|
+
type InputVariants = VariantProps<typeof styles>;
|
|
109
|
+
export interface InputProps extends InputVariants {
|
|
110
|
+
children?: any;
|
|
111
|
+
class?: string;
|
|
112
|
+
value?: string;
|
|
113
|
+
ref?: HTMLInputElement;
|
|
114
|
+
prefix?: any;
|
|
115
|
+
}
|
|
116
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { tv } from "tailwind-variants";
|
|
2
|
+
export const styles = tv({
|
|
3
|
+
base: 'relative w-full inline-flex items-center justify-center rounded outline-none transition-all duration-element-react ring-primary-token-5/50',
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
outlined: 'border border-neutral-token-5 bg-transparent focus:border-primary-token-6 hover:border-primary-token-5 focus-visible:ring-2',
|
|
7
|
+
filled: 'bg-neutral-token-3 border border-neutral-token-3 focus:bg-transparent focus:border-primary-token-6 hover:bg-neutral-token-4 focus-visible:ring-2',
|
|
8
|
+
borderless: 'bg-transparent border-0',
|
|
9
|
+
},
|
|
10
|
+
disabled: {
|
|
11
|
+
true: 'cursor-not-allowed opacity-70 text-neutral-token-10',
|
|
12
|
+
false: 'cursor-text',
|
|
13
|
+
},
|
|
14
|
+
size: {
|
|
15
|
+
sm: 'h-6 px-2 text-sm',
|
|
16
|
+
md: 'h-8 px-3 text-base',
|
|
17
|
+
lg: 'h-10 px-3 text-lg',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
compoundVariants: [
|
|
21
|
+
{
|
|
22
|
+
variant: 'outlined',
|
|
23
|
+
disabled: true,
|
|
24
|
+
class: 'hover:border-neutral-token-5'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
variant: 'filled',
|
|
28
|
+
disabled: true,
|
|
29
|
+
class: 'hover:bg-neutral-token-3'
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
variant: 'outlined',
|
|
34
|
+
size: 'md'
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {type InputProps, styles} from "./
|
|
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();
|
|
3
15
|
|
|
4
|
-
// Define component props with inferred types
|
|
5
|
-
export let size: InputProps['size'] = 'md';
|
|
6
|
-
export let placeholder: string = '';
|
|
7
|
-
export let value: string = '';
|
|
8
16
|
</script>
|
|
9
17
|
|
|
10
18
|
<input
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
type="text"
|
|
20
|
+
bind:this={ref}
|
|
21
|
+
class={styles({ variant, disabled , size, className})}
|
|
22
|
+
{disabled}
|
|
23
|
+
{...props}
|
|
13
24
|
bind:value
|
|
14
|
-
/>
|
|
25
|
+
/>
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
import { type InputProps } from "./
|
|
2
|
-
|
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports & {
|
|
10
|
-
$set?: any;
|
|
11
|
-
$on?: any;
|
|
12
|
-
};
|
|
13
|
-
z_$$bindings?: Bindings;
|
|
14
|
-
}
|
|
15
|
-
declare const Input: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
-
size?: InputProps["size"];
|
|
17
|
-
placeholder?: string;
|
|
18
|
-
value?: string;
|
|
19
|
-
}, {
|
|
20
|
-
[evt: string]: CustomEvent<any>;
|
|
21
|
-
}, {}, {}, string>;
|
|
22
|
-
type Input = InstanceType<typeof Input>;
|
|
1
|
+
import { type InputProps } from "./Input";
|
|
2
|
+
declare const Input: import("svelte").Component<InputProps, {}, "ref" | "value">;
|
|
23
3
|
export default Input;
|
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
import {IconLanguage} from "../icons";
|
|
4
4
|
import {Dialog} from "../dialog";
|
|
5
5
|
import IconCheck from "../icons/IconCheck.svelte";
|
|
6
|
+
import {getGlobalContext} from "../tera-ui-context/global-context";
|
|
6
7
|
|
|
7
8
|
let {
|
|
8
9
|
children,
|
|
9
|
-
currentLangCode = 'en',
|
|
10
10
|
onLangSelect,
|
|
11
|
-
supportedLanguages = ['en'],
|
|
12
11
|
...props
|
|
13
12
|
}: LanguagePickerButtonProps & {
|
|
14
|
-
currentLangCode: string,
|
|
15
|
-
supportedLanguages: string[],
|
|
16
13
|
onLangSelect: (langCode: string) => void
|
|
17
14
|
} = $props();
|
|
18
15
|
|
|
16
|
+
let context = getGlobalContext()
|
|
17
|
+
|
|
18
|
+
|
|
19
19
|
const LANGUAGE_LIST = [
|
|
20
20
|
{
|
|
21
21
|
code: "en",
|
|
@@ -57,15 +57,18 @@
|
|
|
57
57
|
label: "Tiếng Việt",
|
|
58
58
|
flag: 'vietnam'
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
].filter(lang => context.supportLanguages!.includes(lang.code))
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
let currentLangItem = $derived(LANGUAGE_LIST.find(l => l.code === context.language)!)
|
|
61
65
|
|
|
62
|
-
let currentLangItem = $derived(LANGUAGE_LIST.find(l => l.code === currentLangCode)!)
|
|
63
66
|
|
|
64
67
|
function getFlagUrl(flag: string) {
|
|
65
68
|
if (flag === 'spain') {
|
|
66
|
-
return
|
|
69
|
+
return `${context.basePath ?? ''}/world-flags/${flag}.png`
|
|
67
70
|
}
|
|
68
|
-
return
|
|
71
|
+
return `${context.basePath ?? ''}/world-flags/${flag}.svg`
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
let openDialog = $state(false)
|
|
@@ -89,9 +92,9 @@
|
|
|
89
92
|
onLangSelect?.(lang.code)
|
|
90
93
|
openDialog = false
|
|
91
94
|
}}
|
|
92
|
-
data-selected={lang.code ===
|
|
95
|
+
data-selected={lang.code === context.language ? '' : undefined}>
|
|
93
96
|
<div class="flex items-center gap-2">
|
|
94
|
-
<img class="size-
|
|
97
|
+
<img class="size-8 flag-img" src={getFlagUrl(lang.flag)} alt={currentLangItem.flag} loading="lazy">
|
|
95
98
|
{lang.label}
|
|
96
99
|
</div>
|
|
97
100
|
<div class="check">
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { type LanguagePickerButtonProps } from "./LanguagePickerButton";
|
|
2
2
|
declare const LanguagePickerButton: import("svelte").Component<LanguagePickerButtonProps & {
|
|
3
|
-
currentLangCode: string;
|
|
4
|
-
supportedLanguages: string[];
|
|
5
3
|
onLangSelect: (langCode: string) => void;
|
|
6
4
|
}, {}, "">;
|
|
7
5
|
export default LanguagePickerButton;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type VariantProps } from "tailwind-variants";
|
|
2
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{}, undefined, "", import("tailwind-variants/dist/config").TVConfig<{}, {}>, {}, undefined, import("tailwind-variants").TVReturnType<{}, undefined, "", import("tailwind-variants/dist/config").TVConfig<{}, {}>, unknown, unknown, undefined>>;
|
|
3
|
+
type PopoverVariants = VariantProps<typeof styles>;
|
|
4
|
+
export interface PopoverProps extends PopoverVariants {
|
|
5
|
+
children?: any;
|
|
6
|
+
class?: string;
|
|
7
|
+
triggerRef: any;
|
|
8
|
+
offset?: number;
|
|
9
|
+
padding?: number;
|
|
10
|
+
open?: boolean;
|
|
11
|
+
focusTriggerAfterClose?: boolean;
|
|
12
|
+
flip?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type PopoverProps} from "./Popover";
|
|
3
|
+
import {arrow, autoUpdate, computePosition, flip, offset, shift, size} from "@floating-ui/dom";
|
|
4
|
+
import {cn} from "../../utils/utils";
|
|
5
|
+
|
|
6
|
+
import {clickOutside} from "../../actions/clickOutside"
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
children, triggerRef, class: className, open = $bindable(),
|
|
10
|
+
offset: offsetAmount = 3,
|
|
11
|
+
padding: paddingAmount = 12,
|
|
12
|
+
focusTriggerAfterClose = true,
|
|
13
|
+
flip: enableFlip = false,
|
|
14
|
+
...props
|
|
15
|
+
}: PopoverProps = $props();
|
|
16
|
+
|
|
17
|
+
let hasOpenedYet = $state(false)
|
|
18
|
+
|
|
19
|
+
function togglePopover() {
|
|
20
|
+
open = !open;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
function handleClickOutside(e) {
|
|
25
|
+
open = false
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let popover = $state();
|
|
29
|
+
let arrowElement = $state();
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
function updatePosition() {
|
|
33
|
+
computePosition(triggerRef, popover, {
|
|
34
|
+
placement: 'bottom',
|
|
35
|
+
middleware: [
|
|
36
|
+
offset(offsetAmount),
|
|
37
|
+
size({
|
|
38
|
+
apply({rects, elements}) {
|
|
39
|
+
Object.assign(elements.floating.style, {
|
|
40
|
+
minWidth: `${rects.reference.width}px`,
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
enableFlip ? flip() : undefined,
|
|
45
|
+
shift({padding: paddingAmount}),
|
|
46
|
+
arrow({element: arrowElement}),
|
|
47
|
+
],
|
|
48
|
+
}).then(({x, y, placement, middlewareData}) => {
|
|
49
|
+
Object.assign(popover.style, {
|
|
50
|
+
left: `${x}px`,
|
|
51
|
+
top: `${y}px`,
|
|
52
|
+
});
|
|
53
|
+
//
|
|
54
|
+
// // Accessing the data
|
|
55
|
+
// const {x: arrowX, y: arrowY} = middlewareData.arrow;
|
|
56
|
+
//
|
|
57
|
+
// const staticSide = {
|
|
58
|
+
// top: 'bottom',
|
|
59
|
+
// right: 'left',
|
|
60
|
+
// bottom: 'top',
|
|
61
|
+
// left: 'right',
|
|
62
|
+
// }[placement.split('-')[0]];
|
|
63
|
+
//
|
|
64
|
+
// Object.assign(arrowElement.style, {
|
|
65
|
+
// left: arrowX != null ? `${arrowX}px` : '',
|
|
66
|
+
// top: arrowY != null ? `${arrowY}px` : '',
|
|
67
|
+
// right: '',
|
|
68
|
+
// bottom: '',
|
|
69
|
+
// [staticSide]: '-4px',
|
|
70
|
+
// });
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
$effect(() => {
|
|
76
|
+
let cleanup: any
|
|
77
|
+
if (triggerRef) {
|
|
78
|
+
triggerRef.addEventListener("click", togglePopover);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (open) {
|
|
82
|
+
hasOpenedYet = true
|
|
83
|
+
updatePosition()
|
|
84
|
+
|
|
85
|
+
// Start auto updates.
|
|
86
|
+
cleanup = autoUpdate(
|
|
87
|
+
triggerRef,
|
|
88
|
+
popover,
|
|
89
|
+
updatePosition,
|
|
90
|
+
);
|
|
91
|
+
} else {
|
|
92
|
+
cleanup?.()
|
|
93
|
+
if (focusTriggerAfterClose && hasOpenedYet) {
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
try {
|
|
96
|
+
triggerRef.focus()
|
|
97
|
+
} catch (e) {
|
|
98
|
+
console.warn('Trigger element focus after close Popover error', e)
|
|
99
|
+
}
|
|
100
|
+
}, 100)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return () => {
|
|
105
|
+
cleanup?.()
|
|
106
|
+
if (triggerRef) {
|
|
107
|
+
triggerRef.removeEventListener("click", togglePopover);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
</script>
|
|
112
|
+
|
|
113
|
+
<!-- Popover Content -->
|
|
114
|
+
{#if open}
|
|
115
|
+
<div bind:this={popover}
|
|
116
|
+
class={cn("overflow-hidden absolute z-10 bg-neutral-token-1 shadow-2xl rounded-container border border-neutral-token-5", className)}
|
|
117
|
+
use:clickOutside={{exceptElement: triggerRef}}
|
|
118
|
+
onclick_outside={handleClickOutside}
|
|
119
|
+
{...props}
|
|
120
|
+
>
|
|
121
|
+
<!-- <div bind:this={arrowElement} class="size-2 absolute rotate-45 bg-inherit"></div>-->
|
|
122
|
+
{@render children?.()}
|
|
123
|
+
</div>
|
|
124
|
+
{/if}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
<style>
|
|
128
|
+
|
|
129
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Popover } from './Popover.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Popover } from './Popover.svelte';
|
|
@@ -16,7 +16,6 @@ export const getSideNavState = () => {
|
|
|
16
16
|
return mainLayout()?.getAttribute('data-side-nav-state') || undefined;
|
|
17
17
|
};
|
|
18
18
|
export const setSideNavState = (state) => {
|
|
19
|
-
console.log(mainLayout());
|
|
20
19
|
if (state !== undefined) {
|
|
21
20
|
mainLayout()?.setAttribute('data-side-nav-state', state);
|
|
22
21
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
type SideNavigationProps,
|
|
7
7
|
toggleSideNavigation
|
|
8
8
|
} from "./SideNavigation";
|
|
9
|
-
import {clickOutside} from "
|
|
9
|
+
import {clickOutside} from "../../actions/clickOutside"
|
|
10
10
|
import {Button} from "../button";
|
|
11
11
|
import {IconHamburger} from "../icons";
|
|
12
12
|
import {BrandLogo} from "../brand-logo";
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
import IconCalculator from "../icons/IconCalculator.svelte";
|
|
17
17
|
import {LightDarkToggle} from "../light-dark-toggle";
|
|
18
18
|
|
|
19
|
+
import {getGlobalContext} from "../tera-ui-context/global-context";
|
|
20
|
+
|
|
19
21
|
let {children, ...props}: SideNavigationProps = $props();
|
|
20
22
|
|
|
21
23
|
let temporaryExpand: any = undefined
|
|
@@ -42,6 +44,34 @@
|
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
let globalContext = getGlobalContext()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
function isSelected(href: string) {
|
|
52
|
+
const pathname = globalContext?.sideNavHref
|
|
53
|
+
return pathname?.startsWith(href)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
const NAV_ITEM = [
|
|
59
|
+
{
|
|
60
|
+
href: '/calculator',
|
|
61
|
+
icon: IconCalculator,
|
|
62
|
+
title: 'CalcES Scientific Calculator',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
href: '/convert',
|
|
66
|
+
icon: IconTransform,
|
|
67
|
+
title: 'Unit Converter',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
href: '/docs/calculator-usages/calces',
|
|
71
|
+
icon: IconBook,
|
|
72
|
+
title: 'CalcES Documentation',
|
|
73
|
+
},
|
|
74
|
+
]
|
|
45
75
|
</script>
|
|
46
76
|
|
|
47
77
|
<nav class="side-nav_main-side-bar grid grid-rows-[auto_1fr_auto]"
|
|
@@ -49,7 +79,7 @@
|
|
|
49
79
|
onclick_outside={handleClickOutside}
|
|
50
80
|
>
|
|
51
81
|
<div class="flex mt-2 gap-1 items-center">
|
|
52
|
-
<Button variant="ghost"
|
|
82
|
+
<Button variant="ghost" ring={false}
|
|
53
83
|
onclick={toggleSideNavigation}
|
|
54
84
|
>
|
|
55
85
|
<IconHamburger/>
|
|
@@ -66,24 +96,14 @@
|
|
|
66
96
|
handleHover(false)
|
|
67
97
|
}}
|
|
68
98
|
>
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
<IconTransform/>
|
|
78
|
-
{/snippet}
|
|
79
|
-
Unit Converter
|
|
80
|
-
</SideNavItem>
|
|
81
|
-
<SideNavItem href="/docs/calculator-usages/calces">
|
|
82
|
-
{#snippet icon()}
|
|
83
|
-
<IconBook/>
|
|
84
|
-
{/snippet}
|
|
85
|
-
CalcES Documentation
|
|
86
|
-
</SideNavItem>
|
|
99
|
+
{#each NAV_ITEM as item}
|
|
100
|
+
<SideNavItem href={item.href} class={isSelected(item.href) ? 'selected' : ''}>
|
|
101
|
+
{#snippet icon()}
|
|
102
|
+
<svelte:component this={item.icon}/>
|
|
103
|
+
{/snippet}
|
|
104
|
+
{item.title}
|
|
105
|
+
</SideNavItem>
|
|
106
|
+
{/each}
|
|
87
107
|
</ul>
|
|
88
108
|
<div>
|
|
89
109
|
<div class="w-[3rem] mb-8 flex justify-center">
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AvailableLanguageTag } from "../../i18n/language";
|
|
2
|
+
export type TeraUiContext = {
|
|
3
|
+
basePath?: string;
|
|
4
|
+
supportLanguages?: AvailableLanguageTag[];
|
|
5
|
+
language?: AvailableLanguageTag;
|
|
6
|
+
sideNavHref?: string;
|
|
7
|
+
};
|
|
8
|
+
export interface TeraUiContextProps extends TeraUiContext {
|
|
9
|
+
children?: any;
|
|
10
|
+
class?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type TeraUiContextProps} from "./TeraUiContext";
|
|
3
|
+
import {setGlobalContext} from "./global-context";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
supportLanguages = ['en'],
|
|
9
|
+
language = 'en',
|
|
10
|
+
...props
|
|
11
|
+
}: TeraUiContextProps = $props();
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
setGlobalContext({
|
|
15
|
+
supportLanguages,
|
|
16
|
+
language,
|
|
17
|
+
...props
|
|
18
|
+
})
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
{@render children()}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getContext, setContext } from "svelte";
|
|
2
|
+
export function setGlobalContext(data) {
|
|
3
|
+
setContext('globalContext', data);
|
|
4
|
+
}
|
|
5
|
+
export function getGlobalContext() {
|
|
6
|
+
let context = getContext('globalContext');
|
|
7
|
+
if (!context) {
|
|
8
|
+
console.warn('tera-system-ui', 'Not set global context yet!', 'Using default context data');
|
|
9
|
+
return {
|
|
10
|
+
language: 'en',
|
|
11
|
+
supportLanguages: ['en']
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TeraUiContext } from './TeraUiContext.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TeraUiContext } from './TeraUiContext.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type AvailableLanguageTag, availableLanguageTags } from './language';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { availableLanguageTags } from './language';
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const i18n: any;
|
package/dist/i18n.js
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { BrandLogo } from './components/brand-logo';
|
|
2
|
+
export { Button } from './components/button';
|
|
3
|
+
export { Combobox } from './components/combobox';
|
|
4
|
+
export { Command } from './components/command';
|
|
5
|
+
export { Dialog } from './components/dialog';
|
|
6
|
+
export { Header } from './components/header';
|
|
7
|
+
export { IconArrowBigRightFilled, IconBook, IconBookmarkPlus, IconCalculator, IconCheck, IconChevronDown, IconCopy, IconCopyCheckFilled, IconHamburger, IconLanguage, IconLoader2, IconMoon, IconPointFilled, IconSearch, IconSun, IconSwitchHorizontal, IconSwitchVertical, IconTransform, IconX } from './components/icons';
|
|
8
|
+
export { Input } from './components/input';
|
|
9
|
+
export { LanguagePickerButton } from './components/language-picker-button';
|
|
10
|
+
export { LightDarkToggle } from './components/light-dark-toggle';
|
|
11
|
+
export { Popover } from './components/popover';
|
|
12
|
+
export { SideNavigation, SideNavigationLayout, toggleSideNavigation } from './components/side-navigation';
|
|
13
|
+
export { TeraUiContext } from './components/tera-ui-context';
|