tera-system-ui 0.0.21 → 0.0.23
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/avatar/Avatar.d.ts +82 -0
- package/dist/components/avatar/Avatar.js +35 -0
- package/dist/components/avatar/Avatar.svelte +43 -0
- package/dist/components/avatar/Avatar.svelte.d.ts +3 -0
- package/dist/components/avatar/index.d.ts +1 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/dialog/Dialog.astro +2 -1
- package/dist/components/dialog/Dialog.d.ts +2 -0
- package/dist/components/dialog/Dialog.svelte +8 -8
- package/dist/components/dialog/Dialog.svelte.d.ts +1 -1
- package/dist/components/dropdown-menu/DropdownMenu.d.ts +22 -0
- package/dist/components/dropdown-menu/DropdownMenu.js +15 -0
- package/dist/components/dropdown-menu/components/DropdownMenu.svelte +34 -0
- package/dist/components/dropdown-menu/components/DropdownMenu.svelte.d.ts +3 -0
- package/dist/components/dropdown-menu/components/DropdownMenuGroup.svelte +12 -0
- package/dist/components/dropdown-menu/components/DropdownMenuGroup.svelte.d.ts +5 -0
- package/dist/components/dropdown-menu/components/DropdownMenuHeader.svelte +12 -0
- package/dist/components/dropdown-menu/components/DropdownMenuHeader.svelte.d.ts +5 -0
- package/dist/components/dropdown-menu/components/DropdownMenuItem.svelte +30 -0
- package/dist/components/dropdown-menu/components/DropdownMenuItem.svelte.d.ts +3 -0
- package/dist/components/dropdown-menu/components/DropdownMenuSeparator.svelte +11 -0
- package/dist/components/dropdown-menu/components/DropdownMenuSeparator.svelte.d.ts +5 -0
- package/dist/components/dropdown-menu/index.d.ts +5 -0
- package/dist/components/dropdown-menu/index.js +5 -0
- package/dist/components/icons/IconLogout.svelte +10 -0
- package/dist/components/icons/IconLogout.svelte.d.ts +4 -0
- package/dist/components/icons/IconSettings.svelte +10 -0
- package/dist/components/icons/IconSettings.svelte.d.ts +4 -0
- package/dist/components/icons/index.d.ts +2 -0
- package/dist/components/icons/index.js +2 -0
- package/dist/components/popover/Popover.svelte +25 -3
- package/dist/components/slider/Slider.d.ts +9 -0
- package/dist/components/slider/Slider.js +7 -0
- package/dist/components/slider/Slider.svelte +228 -0
- package/dist/components/slider/Slider.svelte.d.ts +3 -0
- package/dist/components/slider/index.d.ts +1 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/tabs/Tabs.d.ts +17 -0
- package/dist/components/tabs/Tabs.js +15 -0
- package/dist/components/tabs/components/Tabs.svelte +48 -0
- package/dist/components/tabs/components/Tabs.svelte.d.ts +3 -0
- package/dist/components/tabs/components/TabsContent.svelte +36 -0
- package/dist/components/tabs/components/TabsContent.svelte.d.ts +6 -0
- package/dist/components/tabs/components/TabsItem.svelte +32 -0
- package/dist/components/tabs/components/TabsItem.svelte.d.ts +6 -0
- package/dist/components/tabs/components/TabsList.svelte +42 -0
- package/dist/components/tabs/components/TabsList.svelte.d.ts +5 -0
- package/dist/components/tabs/index.d.ts +4 -0
- package/dist/components/tabs/index.js +4 -0
- package/dist/components/tabs/tabs.svelte.d.ts +3 -0
- package/dist/components/tabs/tabs.svelte.js +11 -0
- package/dist/components/tera-ui-context/TeraUiContext.d.ts +1 -0
- package/dist/components/text-area/TextArea.d.ts +145 -0
- package/dist/components/text-area/TextArea.js +39 -0
- package/dist/components/text-area/TextArea.svelte +89 -0
- package/dist/components/text-area/TextArea.svelte.d.ts +3 -0
- package/dist/components/text-area/index.d.ts +1 -0
- package/dist/components/text-area/index.js +1 -0
- package/dist/components/user-avatar-with-menu/UserAvatarWithMenu.d.ts +11 -0
- package/dist/components/user-avatar-with-menu/UserAvatarWithMenu.js +7 -0
- package/dist/components/user-avatar-with-menu/UserAvatarWithMenu.svelte +68 -0
- package/dist/components/user-avatar-with-menu/UserAvatarWithMenu.svelte.d.ts +3 -0
- package/dist/components/user-avatar-with-menu/index.d.ts +1 -0
- package/dist/components/user-avatar-with-menu/index.js +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +7 -1
- package/dist/internal/service/user.service.d.ts +2 -0
- package/dist/internal/service/user.service.js +20 -0
- package/dist/types/user-data.d.ts +31 -0
- package/dist/types/user-data.js +1 -0
- package/package.json +25 -24
- package/scripts/add-component-template.js +1 -1
- package/scripts/generate-ts-index.js +8 -6
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {type SliderProps} from "./Slider";
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
children,
|
|
6
|
+
min = 0,
|
|
7
|
+
max = 100,
|
|
8
|
+
step = 1,
|
|
9
|
+
value = $bindable(),
|
|
10
|
+
showTicks = false,
|
|
11
|
+
onchange,
|
|
12
|
+
...props
|
|
13
|
+
}: SliderProps = $props();
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
let slider = $state<HTMLElement>()
|
|
17
|
+
let sliderHandle = $state<HTMLElement>()
|
|
18
|
+
let sliderTrack = $state<HTMLElement>()
|
|
19
|
+
let sliderRail = $state<HTMLElement>()
|
|
20
|
+
let sliderTooltip = $state<HTMLElement>()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
$effect(() => {
|
|
24
|
+
if (!slider || !sliderHandle || !sliderTrack || !sliderRail) return
|
|
25
|
+
slider.addEventListener('pointerdown', (e) => {
|
|
26
|
+
sliderHandle.setAttribute('data-state', 'dragging');
|
|
27
|
+
onDrag(e)
|
|
28
|
+
document.addEventListener('pointermove', onDrag);
|
|
29
|
+
document.addEventListener('pointerup', () => {
|
|
30
|
+
document.removeEventListener('pointermove', onDrag);
|
|
31
|
+
sliderHandle.removeAttribute('data-state');
|
|
32
|
+
toggleToolTip(false)
|
|
33
|
+
|
|
34
|
+
}, {once: true});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// For touch support
|
|
38
|
+
slider.addEventListener('touchstart', (e) => {
|
|
39
|
+
sliderHandle.setAttribute('data-state', 'dragging');
|
|
40
|
+
onDrag(e)
|
|
41
|
+
document.addEventListener('touchmove', onDrag);
|
|
42
|
+
document.addEventListener('touchend', () => {
|
|
43
|
+
document.removeEventListener('touchmove', onDrag);
|
|
44
|
+
toggleToolTip(false)
|
|
45
|
+
sliderHandle.removeAttribute('data-state');
|
|
46
|
+
}, {once: true});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
sliderHandle.addEventListener('pointerenter', (e) => {
|
|
50
|
+
toggleToolTip(true)
|
|
51
|
+
sliderHandle.addEventListener('pointerleave', (e) => {
|
|
52
|
+
toggleToolTip(false)
|
|
53
|
+
}, {once: true});
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
let tooltipInterval
|
|
59
|
+
|
|
60
|
+
function toggleToolTip(open) {
|
|
61
|
+
if (tooltipInterval) clearInterval(tooltipInterval)
|
|
62
|
+
|
|
63
|
+
if (open) {
|
|
64
|
+
sliderTooltip.classList.add('show');
|
|
65
|
+
} else {
|
|
66
|
+
tooltipInterval = setTimeout(() => {
|
|
67
|
+
sliderTooltip.classList.remove('show');
|
|
68
|
+
}, 300)
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const calculateValue = (position) => {
|
|
74
|
+
const sliderWidth = sliderRail.offsetWidth;
|
|
75
|
+
|
|
76
|
+
// calculate step size in px
|
|
77
|
+
const stepSize = sliderWidth / ((max - min) / step)
|
|
78
|
+
|
|
79
|
+
// Clamp position within the slider width
|
|
80
|
+
const clampedPosition = Math.max(0, Math.min(position, sliderWidth));
|
|
81
|
+
// Calculate nearest step position
|
|
82
|
+
const stepCount = Math.round(clampedPosition / stepSize);
|
|
83
|
+
|
|
84
|
+
console.log(stepCount)
|
|
85
|
+
return min + stepCount
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const onDrag = (event) => {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
event.stopPropagation();
|
|
91
|
+
toggleToolTip(true)
|
|
92
|
+
|
|
93
|
+
let position
|
|
94
|
+
|
|
95
|
+
if (event.type.startsWith('touch')) {
|
|
96
|
+
const touch = event.touches[0];
|
|
97
|
+
position = touch.clientX - slider.getBoundingClientRect().left;
|
|
98
|
+
} else {
|
|
99
|
+
position = event.clientX - slider.getBoundingClientRect().left;
|
|
100
|
+
}
|
|
101
|
+
let newValue = calculateValue(position);
|
|
102
|
+
|
|
103
|
+
if (newValue !== value) {
|
|
104
|
+
value = newValue;
|
|
105
|
+
onchange?.(value);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
updateSliderByValue(newValue)
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
$effect(() => {
|
|
113
|
+
if (value == undefined) {
|
|
114
|
+
value = min
|
|
115
|
+
}
|
|
116
|
+
updateSliderByValue(value)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
function updateSliderByValue(v: number) {
|
|
120
|
+
const percentage = ((value - min) / (max - min)) * 100
|
|
121
|
+
|
|
122
|
+
// Update the position of the handle and track width
|
|
123
|
+
sliderHandle.style.left = `${percentage}%`;
|
|
124
|
+
sliderTooltip.style.left = `${percentage}%`;
|
|
125
|
+
sliderTrack.style.width = `${percentage}%`;
|
|
126
|
+
}
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
<div bind:this={slider} class="cursor-pointer w-full relative mx-1 py-2.5">
|
|
131
|
+
<div data-slider-rail bind:this={sliderRail} class="w-full h-1.5 bg-neutral-token-4 rounded-full overflow-hidden">
|
|
132
|
+
<div data-slider-track bind:this={sliderTrack} class="rounded-full w-full h-full bg-primary-token-4"></div>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
<div
|
|
136
|
+
bind:this={sliderHandle}
|
|
137
|
+
data-slider-handle
|
|
138
|
+
tabindex="0"
|
|
139
|
+
role="slider"
|
|
140
|
+
aria-valuemin={`${(min ?? 0)}`}
|
|
141
|
+
aria-valuemax={`${(max ?? 0)}`}
|
|
142
|
+
aria-valuenow={`${(value ?? 0)}`}
|
|
143
|
+
aria-orientation="horizontal"
|
|
144
|
+
class="slider-handle -translate-x-1/2 absolute top-1/2 -translate-y-1/2 rounded-full bg-neutral-token-1 border-[3px] border-primary-token-5 size-4"
|
|
145
|
+
>
|
|
146
|
+
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<div bind:this={sliderTooltip} data-slider-tooltip class="">
|
|
150
|
+
<span class="z-10 relative">
|
|
151
|
+
{value}
|
|
152
|
+
</span>
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<!-- <input-->
|
|
156
|
+
<!-- type="range"-->
|
|
157
|
+
<!-- min={min}-->
|
|
158
|
+
<!-- max={max}-->
|
|
159
|
+
<!-- step={step}-->
|
|
160
|
+
<!-- oninput={(event) => {-->
|
|
161
|
+
<!-- value = event.target.value;-->
|
|
162
|
+
<!-- handleChange(event);-->
|
|
163
|
+
<!-- }}-->
|
|
164
|
+
<!-- class="w-full appearance-none bg-gray-300 rounded-lg h-2 focus:outline-none focus:ring-2 focus:ring-blue-500 transition"-->
|
|
165
|
+
<!-- />-->
|
|
166
|
+
|
|
167
|
+
<!-- {#if showTicks}-->
|
|
168
|
+
<!-- <div class="relative mt-2 flex justify-between text-xs text-gray-500">-->
|
|
169
|
+
<!-- {#each ticks as tick}-->
|
|
170
|
+
<!-- <div class="flex-1">-->
|
|
171
|
+
<!-- <div-->
|
|
172
|
+
<!-- class="h-2 w-0.5 bg-gray-400 mx-auto"-->
|
|
173
|
+
<!-- style="transform: translateX(-50%);"-->
|
|
174
|
+
<!-- ></div>-->
|
|
175
|
+
<!-- </div>-->
|
|
176
|
+
<!-- {/each}-->
|
|
177
|
+
<!-- </div>-->
|
|
178
|
+
<!-- {/if}-->
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<style>.slider-handle {
|
|
182
|
+
transition: all 0.2s ease-in-out, left 0s;
|
|
183
|
+
}
|
|
184
|
+
.slider-handle:global([data-state="dragging"]), .slider-handle:hover, .slider-handle:focus, .slider-handle:active, .slider-handle:focus-visible {
|
|
185
|
+
--tw-scale-x: 1.25;
|
|
186
|
+
--tw-scale-y: 1.25;
|
|
187
|
+
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
188
|
+
border-color: hsl(var(--tw---token-color-primary-token-7));
|
|
189
|
+
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
|
190
|
+
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0.35rem + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
191
|
+
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
|
192
|
+
--tw-ring-color: hsl(var(--tw---token-color-primary-token-2));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
[data-slider-tooltip] {
|
|
196
|
+
position: absolute;
|
|
197
|
+
left: 50%;
|
|
198
|
+
z-index: 10;
|
|
199
|
+
width: -moz-fit-content;
|
|
200
|
+
width: fit-content;
|
|
201
|
+
border-radius: var(--border-radius-base);
|
|
202
|
+
background-color: hsl(var(--tw---token-color-neutral-token-12));
|
|
203
|
+
padding-left: 0.375rem;
|
|
204
|
+
padding-right: 0.375rem;
|
|
205
|
+
padding-top: 0.25rem;
|
|
206
|
+
padding-bottom: 0.25rem;
|
|
207
|
+
color: hsl(var(--tw---token-color-neutral-token-1));
|
|
208
|
+
transition: all 0.2s ease-in-out, left 0s;
|
|
209
|
+
opacity: 0;
|
|
210
|
+
transform: translateY(-3rem) translateX(-50%) scale(0.9);
|
|
211
|
+
}
|
|
212
|
+
[data-slider-tooltip]:after {
|
|
213
|
+
content: "";
|
|
214
|
+
position: absolute;
|
|
215
|
+
bottom: -0.15rem;
|
|
216
|
+
left: 50%;
|
|
217
|
+
width: 0.75rem;
|
|
218
|
+
height: 0.75rem;
|
|
219
|
+
--tw-translate-x: -50%;
|
|
220
|
+
--tw-rotate: 45deg;
|
|
221
|
+
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
222
|
+
border-radius: 0.125rem;
|
|
223
|
+
background-color: hsl(var(--tw---token-color-neutral-token-12));
|
|
224
|
+
}
|
|
225
|
+
[data-slider-tooltip]:global(.show) {
|
|
226
|
+
opacity: 1;
|
|
227
|
+
transform: translateY(-3.5rem) translateX(-50%) scale(1);
|
|
228
|
+
}</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Slider } from './Slider.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Slider } from './Slider.svelte';
|
|
@@ -0,0 +1,17 @@
|
|
|
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 TabsVariants = VariantProps<typeof styles>;
|
|
4
|
+
export interface TabsProps extends TabsVariants {
|
|
5
|
+
children?: any;
|
|
6
|
+
class?: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
}
|
|
9
|
+
export type TabsContext = {
|
|
10
|
+
setValue: (value: string) => void;
|
|
11
|
+
getValue: () => string | undefined;
|
|
12
|
+
currentTab?: any;
|
|
13
|
+
state: any;
|
|
14
|
+
};
|
|
15
|
+
export declare function getCtx(): TabsContext;
|
|
16
|
+
export declare function setCtx(context: TabsContext): void;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {setCtx, type TabsProps} from "../Tabs";
|
|
3
|
+
import {cn} from "../../../utils/utils";
|
|
4
|
+
import {createTabs} from "../tabs.svelte";
|
|
5
|
+
import {untrack} from "svelte";
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
value = $bindable(),
|
|
10
|
+
class: className,
|
|
11
|
+
...props
|
|
12
|
+
}: TabsProps = $props();
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
function setValue(v: string) {
|
|
16
|
+
console.log('Change value', v)
|
|
17
|
+
value = v
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getValue() {
|
|
21
|
+
return value
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let tabsState = createTabs(value)
|
|
25
|
+
|
|
26
|
+
setCtx({
|
|
27
|
+
setValue: setValue,
|
|
28
|
+
getValue: getValue,
|
|
29
|
+
currentTab: value,
|
|
30
|
+
state: tabsState
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
$effect(() => {
|
|
34
|
+
value = tabsState.currentTab
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
$effect(() => {
|
|
38
|
+
tabsState.currentTab = value
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
let tabs = $state()
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<div bind:this={tabs}
|
|
45
|
+
data-tabs-root
|
|
46
|
+
class={cn("grid grid-rows-[auto_1fr] max-h-full gap-2", className)}>
|
|
47
|
+
{@render children?.()}
|
|
48
|
+
</div>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {getCtx} from "../Tabs";
|
|
3
|
+
import {cn} from "../../../utils/utils";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
children,
|
|
7
|
+
class: className,
|
|
8
|
+
value,
|
|
9
|
+
...props
|
|
10
|
+
} = $props();
|
|
11
|
+
|
|
12
|
+
let context = getCtx()
|
|
13
|
+
|
|
14
|
+
$effect(() => {
|
|
15
|
+
// console.log(context.state.currentTab)
|
|
16
|
+
})
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div
|
|
20
|
+
role="tabpanel"
|
|
21
|
+
data-value={value}
|
|
22
|
+
data-state={context.state.currentTab === value ? 'active' : 'inactive'}
|
|
23
|
+
class={cn("bg-neutral-token-1 overflow-auto", className)}>
|
|
24
|
+
{@render children?.()}
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<style>
|
|
28
|
+
[data-state="active"] {
|
|
29
|
+
display: block
|
|
30
|
+
}
|
|
31
|
+
[data-state="inactive"] {
|
|
32
|
+
display: none
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
</style>
|
|
36
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {cn} from "../../../utils/utils";
|
|
3
|
+
import {getCtx} from "../Tabs";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
children,
|
|
7
|
+
class: className,
|
|
8
|
+
value,
|
|
9
|
+
...props
|
|
10
|
+
} = $props();
|
|
11
|
+
|
|
12
|
+
let context = getCtx()
|
|
13
|
+
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<div>
|
|
17
|
+
<button class={cn("tab-button font-semibold px-2.5 py-1.5 text-neutral-token-8 hover:text-primary-token-4")}
|
|
18
|
+
data-value={value}
|
|
19
|
+
data-state={value === context.state.currentTab ? 'active' : 'inactive'}
|
|
20
|
+
onclick={() => {
|
|
21
|
+
context.state.currentTab = value
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
{@render children?.()}
|
|
25
|
+
</button>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<style>
|
|
29
|
+
button[data-state="active"] {
|
|
30
|
+
color: hsl(var(--tw---token-color-primary-token-6))
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {cn} from "../../../utils/utils";
|
|
3
|
+
import {getCtx} from "../Tabs";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
children,
|
|
7
|
+
class: className,
|
|
8
|
+
...props
|
|
9
|
+
} = $props();
|
|
10
|
+
|
|
11
|
+
let tabIndicator = $state()
|
|
12
|
+
let tabsList = $state()
|
|
13
|
+
|
|
14
|
+
function updateIndicator(button) {
|
|
15
|
+
const rect = button.getBoundingClientRect();
|
|
16
|
+
const containerRect = tabsList.getBoundingClientRect();
|
|
17
|
+
|
|
18
|
+
const left = rect.left - containerRect.left;
|
|
19
|
+
const width = rect.width;
|
|
20
|
+
|
|
21
|
+
tabIndicator.style.left = `${left}px`;
|
|
22
|
+
tabIndicator.style.width = `${width}px`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
let context = getCtx()
|
|
27
|
+
|
|
28
|
+
$effect(() => {
|
|
29
|
+
let tabButton = tabsList?.querySelector(`button[data-value="${context.state.currentTab}"]`)
|
|
30
|
+
updateIndicator(tabButton);
|
|
31
|
+
})
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<div bind:this={tabsList}
|
|
35
|
+
data-tabs-list
|
|
36
|
+
role="tablist"
|
|
37
|
+
data-orientation="horizontal"
|
|
38
|
+
class={cn("relative flex gap-2 items-end border-b border-neutral-token-5")}>
|
|
39
|
+
|
|
40
|
+
{@render children?.()}
|
|
41
|
+
<div bind:this={tabIndicator} class="absolute bottom-0 h-0.5 bg-primary-token-5 transition-all duration-300"></div>
|
|
42
|
+
</div>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as Tabs } from './components/Tabs.svelte';
|
|
2
|
+
export { default as TabsList } from './components/TabsList.svelte';
|
|
3
|
+
export { default as TabsItem } from './components/TabsItem.svelte';
|
|
4
|
+
export { default as TabsContent } from './components/TabsContent.svelte';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as Tabs } from './components/Tabs.svelte';
|
|
2
|
+
export { default as TabsList } from './components/TabsList.svelte';
|
|
3
|
+
export { default as TabsItem } from './components/TabsItem.svelte';
|
|
4
|
+
export { default as TabsContent } from './components/TabsContent.svelte';
|
|
@@ -0,0 +1,145 @@
|
|
|
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
|
+
allowClear: {
|
|
18
|
+
true: string;
|
|
19
|
+
};
|
|
20
|
+
}, undefined, "relative w-full inline-flex items-center justify-center rounded outline-none transition ease-in-out ring-primary-token-5/50", import("tailwind-variants/dist/config").TVConfig<{
|
|
21
|
+
variant: {
|
|
22
|
+
outlined: string;
|
|
23
|
+
filled: string;
|
|
24
|
+
borderless: string;
|
|
25
|
+
};
|
|
26
|
+
disabled: {
|
|
27
|
+
true: string;
|
|
28
|
+
false: string;
|
|
29
|
+
};
|
|
30
|
+
size: {
|
|
31
|
+
sm: string;
|
|
32
|
+
md: string;
|
|
33
|
+
lg: string;
|
|
34
|
+
};
|
|
35
|
+
allowClear: {
|
|
36
|
+
true: string;
|
|
37
|
+
};
|
|
38
|
+
}, {
|
|
39
|
+
variant: {
|
|
40
|
+
outlined: string;
|
|
41
|
+
filled: string;
|
|
42
|
+
borderless: string;
|
|
43
|
+
};
|
|
44
|
+
disabled: {
|
|
45
|
+
true: string;
|
|
46
|
+
false: string;
|
|
47
|
+
};
|
|
48
|
+
size: {
|
|
49
|
+
sm: string;
|
|
50
|
+
md: string;
|
|
51
|
+
lg: string;
|
|
52
|
+
};
|
|
53
|
+
allowClear: {
|
|
54
|
+
true: string;
|
|
55
|
+
};
|
|
56
|
+
}>, {
|
|
57
|
+
variant: {
|
|
58
|
+
outlined: string;
|
|
59
|
+
filled: string;
|
|
60
|
+
borderless: string;
|
|
61
|
+
};
|
|
62
|
+
disabled: {
|
|
63
|
+
true: string;
|
|
64
|
+
false: string;
|
|
65
|
+
};
|
|
66
|
+
size: {
|
|
67
|
+
sm: string;
|
|
68
|
+
md: string;
|
|
69
|
+
lg: string;
|
|
70
|
+
};
|
|
71
|
+
allowClear: {
|
|
72
|
+
true: string;
|
|
73
|
+
};
|
|
74
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
75
|
+
variant: {
|
|
76
|
+
outlined: string;
|
|
77
|
+
filled: string;
|
|
78
|
+
borderless: string;
|
|
79
|
+
};
|
|
80
|
+
disabled: {
|
|
81
|
+
true: string;
|
|
82
|
+
false: string;
|
|
83
|
+
};
|
|
84
|
+
size: {
|
|
85
|
+
sm: string;
|
|
86
|
+
md: string;
|
|
87
|
+
lg: string;
|
|
88
|
+
};
|
|
89
|
+
allowClear: {
|
|
90
|
+
true: string;
|
|
91
|
+
};
|
|
92
|
+
}, undefined, "relative w-full inline-flex items-center justify-center rounded outline-none transition ease-in-out ring-primary-token-5/50", import("tailwind-variants/dist/config").TVConfig<{
|
|
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
|
+
allowClear: {
|
|
108
|
+
true: string;
|
|
109
|
+
};
|
|
110
|
+
}, {
|
|
111
|
+
variant: {
|
|
112
|
+
outlined: string;
|
|
113
|
+
filled: string;
|
|
114
|
+
borderless: string;
|
|
115
|
+
};
|
|
116
|
+
disabled: {
|
|
117
|
+
true: string;
|
|
118
|
+
false: string;
|
|
119
|
+
};
|
|
120
|
+
size: {
|
|
121
|
+
sm: string;
|
|
122
|
+
md: string;
|
|
123
|
+
lg: string;
|
|
124
|
+
};
|
|
125
|
+
allowClear: {
|
|
126
|
+
true: string;
|
|
127
|
+
};
|
|
128
|
+
}>, unknown, unknown, undefined>>;
|
|
129
|
+
type TextAreaVariants = VariantProps<typeof styles>;
|
|
130
|
+
export type AutoSizeConfig = boolean | {
|
|
131
|
+
minRows?: number;
|
|
132
|
+
maxRows?: number;
|
|
133
|
+
};
|
|
134
|
+
export interface TextAreaProps extends TextAreaVariants {
|
|
135
|
+
children?: any;
|
|
136
|
+
class?: string;
|
|
137
|
+
value?: string;
|
|
138
|
+
ref?: HTMLInputElement;
|
|
139
|
+
prefix?: any;
|
|
140
|
+
onchange?: (event: any) => void;
|
|
141
|
+
autoSize?: AutoSizeConfig;
|
|
142
|
+
rows?: any;
|
|
143
|
+
allowClear?: boolean;
|
|
144
|
+
}
|
|
145
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
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 ease-in-out 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: 'px-2 pt-0.5 pb-0.5 text-sm',
|
|
16
|
+
md: 'px-3 pt-1 pb-0.5 text-base',
|
|
17
|
+
lg: 'px-3 pt-1 pb-0.5 text-lg',
|
|
18
|
+
},
|
|
19
|
+
allowClear: {
|
|
20
|
+
true: 'pr-5'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
compoundVariants: [
|
|
24
|
+
{
|
|
25
|
+
variant: 'outlined',
|
|
26
|
+
disabled: true,
|
|
27
|
+
class: 'hover:border-neutral-token-5'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
variant: 'filled',
|
|
31
|
+
disabled: true,
|
|
32
|
+
class: 'hover:bg-neutral-token-3'
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
variant: 'outlined',
|
|
37
|
+
size: 'md'
|
|
38
|
+
},
|
|
39
|
+
});
|