tera-system-ui 0.1.14 → 0.1.16
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/dialog/Dialog.d.ts +3 -0
- package/dist/components/dialog/Dialog.svelte +7 -3
- package/dist/components/tabs/{Tabs.d.ts → Tabs.svelte.d.ts} +4 -5
- package/dist/components/tabs/Tabs.svelte.js +24 -0
- package/dist/components/tabs/components/Tabs.svelte +10 -25
- package/dist/components/tabs/components/Tabs.svelte.d.ts +1 -1
- package/dist/components/tabs/components/TabsContent.svelte +2 -2
- package/dist/components/tabs/components/TabsItem.svelte +4 -4
- package/dist/components/tabs/components/TabsList.svelte +4 -5
- package/package.json +1 -1
- package/dist/components/tabs/Tabs.js +0 -15
|
@@ -220,6 +220,9 @@ type DialogPropsCommon = {
|
|
|
220
220
|
focusTriggerAfterClose?: boolean;
|
|
221
221
|
padding?: 'none' | undefined;
|
|
222
222
|
containerClass?: string;
|
|
223
|
+
headerClass?: string;
|
|
224
|
+
bodyClass?: string;
|
|
225
|
+
footerClass?: string;
|
|
223
226
|
};
|
|
224
227
|
export type DialogProps = DialogVariants & DialogPropsCommon & {
|
|
225
228
|
children?: any;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import {Button} from "../button";
|
|
5
5
|
import './dialog.scss'
|
|
6
6
|
import {sleep} from "../../internal/helpers/sleep";
|
|
7
|
+
import {cn} from "../../utils";
|
|
7
8
|
|
|
8
9
|
let {
|
|
9
10
|
children, open = $bindable(),
|
|
@@ -20,6 +21,9 @@
|
|
|
20
21
|
triggerRef,
|
|
21
22
|
focusTriggerAfterClose,
|
|
22
23
|
containerClass,
|
|
24
|
+
headerClass,
|
|
25
|
+
bodyClass,
|
|
26
|
+
footerClass,
|
|
23
27
|
...props
|
|
24
28
|
}: DialogProps = $props();
|
|
25
29
|
|
|
@@ -91,16 +95,16 @@
|
|
|
91
95
|
|
|
92
96
|
<div class={"dialog-box " + dialogContainer({className: containerClass})}>
|
|
93
97
|
{#if header}
|
|
94
|
-
<header class={headerStyle()}>
|
|
98
|
+
<header class={cn(headerStyle(), headerClass)}>
|
|
95
99
|
{@render header?.()}
|
|
96
100
|
</header>
|
|
97
101
|
{/if}
|
|
98
102
|
|
|
99
|
-
<main class={body()}>
|
|
103
|
+
<main class={cn(body(), bodyClass)}>
|
|
100
104
|
{@render children?.()}
|
|
101
105
|
</main>
|
|
102
106
|
{#if footer}
|
|
103
|
-
<footer class={footerStyle()}>
|
|
107
|
+
<footer class={cn(footerStyle(), footerClass)}>
|
|
104
108
|
{@render footer?.()}
|
|
105
109
|
</footer>
|
|
106
110
|
{/if}
|
|
@@ -5,13 +5,12 @@ export interface TabsProps extends TabsVariants {
|
|
|
5
5
|
children?: any;
|
|
6
6
|
class?: string;
|
|
7
7
|
value?: string;
|
|
8
|
+
onchange?: (value: string) => void;
|
|
8
9
|
}
|
|
9
10
|
export type TabsContext = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
currentTab?: any;
|
|
13
|
-
state: any;
|
|
11
|
+
currentTab?: string;
|
|
12
|
+
onchange: (value: string) => void;
|
|
14
13
|
};
|
|
15
14
|
export declare function getCtx(): TabsContext;
|
|
16
|
-
export declare function
|
|
15
|
+
export declare function createContext(context: TabsContext): void;
|
|
17
16
|
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { tv } from "tailwind-variants";
|
|
2
|
+
import { getContext, setContext } from "svelte";
|
|
3
|
+
export const styles = tv({
|
|
4
|
+
base: '',
|
|
5
|
+
variants: {},
|
|
6
|
+
compoundVariants: [],
|
|
7
|
+
defaultVariants: {},
|
|
8
|
+
});
|
|
9
|
+
const CONTEXT_NAME = 'Tabs';
|
|
10
|
+
export function getCtx() {
|
|
11
|
+
return getContext(CONTEXT_NAME);
|
|
12
|
+
}
|
|
13
|
+
export function createContext(context) {
|
|
14
|
+
let currentTab = $state(context.currentTab);
|
|
15
|
+
setContext(CONTEXT_NAME, {
|
|
16
|
+
get currentTab() {
|
|
17
|
+
return currentTab;
|
|
18
|
+
},
|
|
19
|
+
set currentTab(value) {
|
|
20
|
+
context.onchange(value);
|
|
21
|
+
currentTab = value;
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -1,48 +1,33 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import {createContext, getCtx, type TabsProps} from "../Tabs.svelte";
|
|
3
3
|
import {cn} from "../../../utils/utils";
|
|
4
|
-
import {createTabs} from "../tabs.svelte";
|
|
5
|
-
import {untrack} from "svelte";
|
|
6
4
|
|
|
7
5
|
let {
|
|
8
6
|
children,
|
|
9
7
|
value = $bindable(),
|
|
10
8
|
class: className,
|
|
9
|
+
onchange,
|
|
11
10
|
...props
|
|
12
11
|
}: TabsProps = $props();
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
value = v
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function getValue() {
|
|
21
|
-
return value
|
|
13
|
+
function onTabChange(currentTab: string) {
|
|
14
|
+
onchange?.(currentTab)
|
|
15
|
+
value = currentTab
|
|
22
16
|
}
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
setCtx({
|
|
27
|
-
setValue: setValue,
|
|
28
|
-
getValue: getValue,
|
|
18
|
+
createContext({
|
|
29
19
|
currentTab: value,
|
|
30
|
-
|
|
20
|
+
onchange: onTabChange
|
|
31
21
|
})
|
|
32
22
|
|
|
33
|
-
|
|
34
|
-
value = tabsState.currentTab
|
|
35
|
-
})
|
|
23
|
+
const context = getCtx()
|
|
36
24
|
|
|
37
25
|
$effect(() => {
|
|
38
|
-
|
|
26
|
+
context.currentTab = value
|
|
39
27
|
})
|
|
40
|
-
|
|
41
|
-
let tabs = $state()
|
|
42
28
|
</script>
|
|
43
29
|
|
|
44
|
-
<div
|
|
45
|
-
data-tabs-root
|
|
30
|
+
<div data-tabs-root
|
|
46
31
|
class={cn("grid grid-rows-[auto_1fr] max-h-full gap-2", className)}>
|
|
47
32
|
{@render children?.()}
|
|
48
33
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {getCtx} from "../Tabs";
|
|
2
|
+
import {getCtx} from "../Tabs.svelte";
|
|
3
3
|
import {cn} from "../../../utils/utils";
|
|
4
4
|
|
|
5
5
|
let {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<div
|
|
20
20
|
role="tabpanel"
|
|
21
21
|
data-value={value}
|
|
22
|
-
data-state={context.
|
|
22
|
+
data-state={context.currentTab === value ? 'active' : 'inactive'}
|
|
23
23
|
class={cn("bg-neutral-token-1 overflow-auto", className)}>
|
|
24
24
|
{@render children?.()}
|
|
25
25
|
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {cn} from "../../../utils/utils";
|
|
3
|
-
import {getCtx} from "../Tabs";
|
|
3
|
+
import {getCtx} from "../Tabs.svelte";
|
|
4
4
|
|
|
5
5
|
let {
|
|
6
6
|
children,
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
<div>
|
|
17
17
|
<button class={cn("tab-button font-semibold px-2.5 py-1.5 text-neutral-token-8 hover:text-primary-token-4")}
|
|
18
18
|
data-value={value}
|
|
19
|
-
data-state={value === context.
|
|
19
|
+
data-state={value === context.currentTab ? 'active' : 'inactive'}
|
|
20
20
|
onclick={() => {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
context.currentTab = value
|
|
22
|
+
}}
|
|
23
23
|
>
|
|
24
24
|
{@render children?.()}
|
|
25
25
|
</button>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {cn, consoleLog, observeVisibility} from "../../../utils/utils";
|
|
3
|
-
import {getCtx} from "../Tabs";
|
|
3
|
+
import {getCtx} from "../Tabs.svelte";
|
|
4
4
|
import {onMount} from "svelte";
|
|
5
5
|
|
|
6
6
|
let {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
let tabsList = $state()
|
|
14
14
|
|
|
15
15
|
function updateIndicator() {
|
|
16
|
-
let button = tabsList?.querySelector(`button[data-value="${context.
|
|
16
|
+
let button = tabsList?.querySelector(`button[data-value="${context.currentTab}"]`)
|
|
17
17
|
|
|
18
18
|
const rect = button.getBoundingClientRect();
|
|
19
19
|
const containerRect = tabsList.getBoundingClientRect();
|
|
@@ -24,21 +24,20 @@
|
|
|
24
24
|
tabIndicator.style.left = `${left}px`;
|
|
25
25
|
tabIndicator.style.width = `${width}px`;
|
|
26
26
|
|
|
27
|
-
consoleLog('TabList', 'tabIndicator', tabIndicator)
|
|
27
|
+
// consoleLog('TabList', 'tabIndicator', tabIndicator)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
let context = getCtx()
|
|
32
32
|
|
|
33
33
|
$effect(() => {
|
|
34
|
-
context.
|
|
34
|
+
context.currentTab
|
|
35
35
|
updateIndicator();
|
|
36
36
|
})
|
|
37
37
|
|
|
38
38
|
onMount(() => {
|
|
39
39
|
const stopObserving = observeVisibility(tabIndicator, (isVisible, entry) => {
|
|
40
40
|
if (isVisible) {
|
|
41
|
-
consoleLog('Element is visible:', entry.target);
|
|
42
41
|
updateIndicator()
|
|
43
42
|
}
|
|
44
43
|
});
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { tv } from "tailwind-variants";
|
|
2
|
-
import { getContext, setContext } from "svelte";
|
|
3
|
-
export const styles = tv({
|
|
4
|
-
base: '',
|
|
5
|
-
variants: {},
|
|
6
|
-
compoundVariants: [],
|
|
7
|
-
defaultVariants: {},
|
|
8
|
-
});
|
|
9
|
-
const CONTEXT_NAME = 'Tabs';
|
|
10
|
-
export function getCtx() {
|
|
11
|
-
return getContext(CONTEXT_NAME);
|
|
12
|
-
}
|
|
13
|
-
export function setCtx(context) {
|
|
14
|
-
setContext(CONTEXT_NAME, context);
|
|
15
|
-
}
|