webcoreui 1.4.0 → 1.5.0-beta.1
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/README.md +15 -1
- package/astro.d.ts +62 -56
- package/astro.js +4 -0
- package/components/Accordion/Accordion.astro +1 -1
- package/components/Accordion/Accordion.svelte +60 -58
- package/components/Accordion/Accordion.tsx +3 -1
- package/components/Alert/Alert.astro +2 -1
- package/components/Alert/Alert.svelte +12 -5
- package/components/Alert/Alert.tsx +10 -3
- package/components/Alert/alert.ts +2 -18
- package/components/AspectRatio/AspectRatio.astro +1 -1
- package/components/AspectRatio/AspectRatio.svelte +27 -22
- package/components/AspectRatio/AspectRatio.tsx +6 -3
- package/components/AspectRatio/aspectratio.ts +0 -10
- package/components/Avatar/Avatar.astro +1 -1
- package/components/Avatar/Avatar.svelte +7 -5
- package/components/Avatar/Avatar.tsx +3 -2
- package/components/Avatar/avatar.module.scss +3 -5
- package/components/Badge/Badge.astro +2 -1
- package/components/Badge/Badge.svelte +11 -4
- package/components/Badge/Badge.tsx +8 -3
- package/components/Badge/badge.module.scss +5 -6
- package/components/Badge/badge.ts +11 -13
- package/components/Banner/Banner.astro +1 -1
- package/components/Banner/Banner.svelte +11 -5
- package/components/Banner/Banner.tsx +6 -2
- package/components/Banner/banner.module.scss +4 -6
- package/components/Banner/banner.ts +0 -10
- package/components/BottomNavigation/BottomNavigation.astro +1 -1
- package/components/BottomNavigation/BottomNavigation.svelte +7 -4
- package/components/BottomNavigation/BottomNavigation.tsx +3 -2
- package/components/BottomNavigation/bottomnavigation.module.scss +68 -70
- package/components/Breadcrumb/Breadcrumb.astro +1 -1
- package/components/Breadcrumb/Breadcrumb.svelte +5 -3
- package/components/Breadcrumb/Breadcrumb.tsx +3 -1
- package/components/Button/Button.astro +2 -1
- package/components/Button/Button.svelte +11 -4
- package/components/Button/Button.tsx +7 -2
- package/components/Button/button.module.scss +9 -12
- package/components/Button/button.ts +23 -20
- package/components/Card/Card.astro +9 -2
- package/components/Card/Card.svelte +21 -8
- package/components/Card/Card.tsx +23 -6
- package/components/Card/card.module.scss +12 -9
- package/components/Card/card.ts +3 -16
- package/components/Carousel/Carousel.astro +3 -3
- package/components/Carousel/Carousel.svelte +24 -19
- package/components/Carousel/Carousel.tsx +9 -4
- package/components/Carousel/carousel.module.scss +3 -5
- package/components/Carousel/carousel.ts +0 -12
- package/components/CarouselItem/CarouselItem.astro +14 -0
- package/components/CarouselItem/CarouselItem.svelte +18 -0
- package/components/CarouselItem/CarouselItem.tsx +18 -0
- package/components/CarouselItem/carouselItem.ts +4 -0
- package/components/Checkbox/Checkbox.astro +3 -6
- package/components/Checkbox/Checkbox.svelte +13 -10
- package/components/Checkbox/Checkbox.tsx +8 -5
- package/components/Checkbox/checkbox.module.scss +4 -6
- package/components/Checkbox/checkbox.ts +2 -17
- package/components/Collapsible/Collapsible.astro +1 -1
- package/components/Collapsible/Collapsible.svelte +13 -6
- package/components/Collapsible/Collapsible.tsx +8 -2
- package/components/Collapsible/collapsible.module.scss +5 -5
- package/components/Collapsible/collapsible.ts +0 -15
- package/components/ConditionalWrapper/ConditionalWrapper.astro +1 -1
- package/components/ConditionalWrapper/ConditionalWrapper.svelte +8 -2
- package/components/ConditionalWrapper/ConditionalWrapper.tsx +7 -2
- package/components/ConditionalWrapper/conditionalwrapper.ts +2 -14
- package/components/ContextMenu/ContextMenu.astro +2 -1
- package/components/ContextMenu/ContextMenu.svelte +17 -9
- package/components/ContextMenu/ContextMenu.tsx +8 -2
- package/components/ContextMenu/contextmenu.ts +2 -17
- package/components/Copy/Copy.astro +2 -2
- package/components/Copy/Copy.svelte +10 -5
- package/components/Copy/Copy.tsx +7 -3
- package/components/Copy/copy.ts +2 -12
- package/components/Counter/Counter.astro +3 -2
- package/components/Counter/Counter.svelte +16 -10
- package/components/Counter/Counter.tsx +11 -7
- package/components/Counter/counter.module.scss +3 -5
- package/components/Counter/counter.ts +2 -11
- package/components/DataTable/DataTable.astro +1 -1
- package/components/DataTable/DataTable.svelte +23 -15
- package/components/DataTable/DataTable.tsx +7 -2
- package/components/DataTable/datatable.ts +0 -12
- package/components/Flex/Flex.astro +2 -1
- package/components/Flex/Flex.svelte +12 -6
- package/components/Flex/Flex.tsx +8 -3
- package/components/Flex/flex.ts +2 -15
- package/components/Footer/Footer.astro +1 -1
- package/components/Footer/Footer.svelte +13 -8
- package/components/Footer/Footer.tsx +6 -2
- package/components/Footer/footer.ts +0 -10
- package/components/Grid/Grid.astro +2 -1
- package/components/Grid/Grid.svelte +12 -6
- package/components/Grid/Grid.tsx +8 -3
- package/components/Grid/grid.ts +2 -15
- package/components/Group/Group.astro +1 -1
- package/components/Group/Group.svelte +9 -4
- package/components/Group/Group.tsx +6 -2
- package/components/Group/group.ts +0 -10
- package/components/Icon/Icon.astro +1 -1
- package/components/Icon/Icon.svelte +16 -9
- package/components/Icon/Icon.tsx +3 -2
- package/components/Image/Image.astro +2 -1
- package/components/Image/Image.svelte +54 -51
- package/components/Image/Image.tsx +3 -1
- package/components/Image/image.ts +2 -3
- package/components/ImageLoader/ImageLoader.astro +1 -1
- package/components/ImageLoader/ImageLoader.svelte +5 -3
- package/components/ImageLoader/ImageLoader.tsx +3 -1
- package/components/Input/Input.astro +3 -2
- package/components/Input/Input.svelte +19 -9
- package/components/Input/Input.tsx +11 -3
- package/components/Input/input.ts +26 -53
- package/components/Kbd/Kbd.astro +1 -1
- package/components/Kbd/Kbd.svelte +9 -4
- package/components/Kbd/Kbd.tsx +6 -2
- package/components/Kbd/kbd.ts +0 -10
- package/components/List/List.astro +1 -1
- package/components/List/List.svelte +13 -9
- package/components/List/List.tsx +10 -6
- package/components/List/list.ts +0 -8
- package/components/Masonry/Masonry.astro +1 -1
- package/components/Masonry/Masonry.svelte +14 -9
- package/components/Masonry/Masonry.tsx +7 -3
- package/components/Masonry/masonry.module.scss +4 -6
- package/components/Masonry/masonry.ts +2 -13
- package/components/Menu/Menu.astro +1 -1
- package/components/Menu/Menu.svelte +13 -7
- package/components/Menu/Menu.tsx +6 -2
- package/components/Menu/menu.ts +0 -10
- package/components/Modal/Modal.astro +2 -3
- package/components/Modal/Modal.svelte +12 -8
- package/components/Modal/Modal.tsx +6 -4
- package/components/Modal/modal.module.scss +5 -5
- package/components/Modal/modal.ts +2 -14
- package/components/OTPInput/OTPInput.astro +3 -5
- package/components/OTPInput/OTPInput.svelte +10 -10
- package/components/OTPInput/OTPInput.tsx +10 -8
- package/components/OTPInput/otpinput.module.scss +0 -12
- package/components/OTPInput/otpinput.ts +2 -4
- package/components/Pagination/Pagination.astro +1 -1
- package/components/Pagination/Pagination.svelte +8 -4
- package/components/Pagination/Pagination.tsx +6 -2
- package/components/Pagination/pagination.ts +0 -8
- package/components/Popover/Popover.astro +3 -7
- package/components/Popover/Popover.svelte +11 -10
- package/components/Popover/Popover.tsx +9 -12
- package/components/Popover/popover.ts +2 -15
- package/components/Progress/Progress.astro +1 -1
- package/components/Progress/Progress.svelte +8 -6
- package/components/Progress/Progress.tsx +3 -1
- package/components/Progress/progress.module.scss +15 -17
- package/components/Radio/Radio.astro +4 -4
- package/components/Radio/Radio.svelte +15 -8
- package/components/Radio/Radio.tsx +8 -5
- package/components/Radio/radio.module.scss +4 -6
- package/components/Radio/radio.ts +3 -14
- package/components/RangeSlider/RangeSlider.astro +5 -2
- package/components/RangeSlider/RangeSlider.svelte +20 -35
- package/components/RangeSlider/RangeSlider.tsx +11 -4
- package/components/RangeSlider/rangeslider.module.scss +14 -16
- package/components/RangeSlider/rangeslider.ts +1 -9
- package/components/Rating/Rating.astro +1 -1
- package/components/Rating/Rating.svelte +10 -7
- package/components/Rating/Rating.tsx +3 -1
- package/components/Rating/rating.module.scss +13 -15
- package/components/Ribbon/Ribbon.astro +1 -1
- package/components/Ribbon/Ribbon.svelte +9 -4
- package/components/Ribbon/Ribbon.tsx +6 -2
- package/components/Ribbon/ribbon.module.scss +9 -11
- package/components/Ribbon/ribbon.ts +0 -10
- package/components/Select/Select.astro +3 -1
- package/components/Select/Select.svelte +179 -171
- package/components/Select/Select.tsx +11 -4
- package/components/Select/select.ts +2 -12
- package/components/Sheet/Sheet.astro +2 -1
- package/components/Sheet/Sheet.svelte +7 -5
- package/components/Sheet/Sheet.tsx +5 -4
- package/components/Sheet/sheet.ts +3 -10
- package/components/Sidebar/Sidebar.astro +1 -1
- package/components/Sidebar/Sidebar.svelte +9 -4
- package/components/Sidebar/Sidebar.tsx +6 -2
- package/components/Sidebar/sidebar.ts +0 -10
- package/components/Skeleton/Skeleton.astro +1 -1
- package/components/Skeleton/Skeleton.svelte +7 -5
- package/components/Skeleton/Skeleton.tsx +3 -1
- package/components/Skeleton/skeleton.module.scss +6 -9
- package/components/Slider/Slider.astro +7 -5
- package/components/Slider/Slider.svelte +18 -10
- package/components/Slider/Slider.tsx +12 -6
- package/components/Slider/slider.module.scss +12 -14
- package/components/Slider/slider.ts +3 -12
- package/components/SpeedDial/SpeedDial.astro +1 -1
- package/components/SpeedDial/SpeedDial.svelte +6 -4
- package/components/SpeedDial/SpeedDial.tsx +4 -2
- package/components/SpeedDial/speeddial.module.scss +4 -6
- package/components/Spinner/Spinner.astro +1 -1
- package/components/Spinner/Spinner.svelte +7 -5
- package/components/Spinner/Spinner.tsx +3 -1
- package/components/Spinner/spinner.module.scss +13 -14
- package/components/Spoiler/Spoiler.astro +1 -1
- package/components/Spoiler/Spoiler.svelte +11 -5
- package/components/Spoiler/Spoiler.tsx +6 -2
- package/components/Spoiler/spoiler.module.scss +3 -5
- package/components/Spoiler/spoiler.ts +0 -10
- package/components/Stepper/Stepper.astro +1 -1
- package/components/Stepper/Stepper.svelte +7 -5
- package/components/Stepper/Stepper.tsx +3 -1
- package/components/Stepper/stepper.defaults.scss +5 -0
- package/components/Stepper/stepper.module.scss +11 -13
- package/components/Switch/Switch.astro +7 -2
- package/components/Switch/Switch.svelte +17 -8
- package/components/Switch/Switch.tsx +8 -4
- package/components/Switch/switch.module.scss +5 -7
- package/components/Switch/switch.ts +2 -16
- package/components/Tab/Tab.astro +25 -0
- package/components/Tab/Tab.svelte +28 -0
- package/components/Tab/Tab.tsx +30 -0
- package/components/Tab/tab.ts +6 -0
- package/components/Table/Table.astro +1 -1
- package/components/Table/Table.svelte +5 -3
- package/components/Table/Table.tsx +3 -1
- package/components/Tabs/Tabs.astro +58 -25
- package/components/Tabs/Tabs.svelte +47 -14
- package/components/Tabs/Tabs.tsx +42 -11
- package/components/Tabs/tabs.module.scss +7 -6
- package/components/Tabs/tabs.ts +0 -10
- package/components/Textarea/Textarea.astro +3 -6
- package/components/Textarea/Textarea.svelte +13 -10
- package/components/Textarea/Textarea.tsx +9 -7
- package/components/Textarea/textarea.ts +2 -17
- package/components/ThemeSwitcher/ThemeSwitcher.astro +1 -1
- package/components/ThemeSwitcher/ThemeSwitcher.svelte +14 -8
- package/components/ThemeSwitcher/ThemeSwitcher.tsx +7 -2
- package/components/ThemeSwitcher/themeswitcher.module.scss +10 -12
- package/components/ThemeSwitcher/themeswitcher.ts +0 -13
- package/components/Timeline/Timeline.astro +1 -1
- package/components/Timeline/Timeline.svelte +11 -6
- package/components/Timeline/Timeline.tsx +6 -2
- package/components/Timeline/timeline.module.scss +6 -8
- package/components/Timeline/timeline.ts +0 -10
- package/components/TimelineItem/TimelineItem.astro +1 -1
- package/components/TimelineItem/TimelineItem.svelte +9 -4
- package/components/TimelineItem/TimelineItem.tsx +8 -3
- package/components/TimelineItem/timelineitem.module.scss +4 -4
- package/components/TimelineItem/timelineitem.ts +0 -12
- package/components/Toast/Toast.astro +2 -1
- package/components/Toast/Toast.svelte +9 -7
- package/components/Toast/Toast.tsx +5 -4
- package/components/Toast/toast.ts +3 -11
- package/package.json +19 -19
- package/react.d.ts +145 -138
- package/react.js +4 -0
- package/scss/config/functions.scss +41 -0
- package/scss/config/mixins.scss +65 -0
- package/scss/config.scss +1 -0
- package/scss/global/theme.scss +209 -194
- package/scss/setup.scss +6 -3
- package/svelte.d.ts +145 -138
- package/svelte.js +4 -0
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
@use '../../scss/config.scss' as *;
|
|
2
2
|
|
|
3
|
-
body {
|
|
4
|
-
--w-stepper-color-border: var(--w-color-primary-50);
|
|
5
|
-
--w-stepper-color-active: var(--w-color-info);
|
|
6
|
-
--w-stepper-color-complete: var(--w-color-success);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
3
|
$size: 20px;
|
|
10
4
|
|
|
11
5
|
.stepper {
|
|
6
|
+
--border: var(--w-stepper-color-border, var(--w-color-primary-50));
|
|
7
|
+
--active: var(--w-stepper-color-active, var(--w-color-info));
|
|
8
|
+
--complete: var(--w-stepper-color-complete, var(--w-color-success));
|
|
9
|
+
|
|
12
10
|
@include layout(flex, default, column);
|
|
13
11
|
@include spacing(0);
|
|
14
12
|
@include size('w100%');
|
|
@@ -16,7 +14,7 @@ $size: 20px;
|
|
|
16
14
|
list-style-type: none;
|
|
17
15
|
|
|
18
16
|
&:not(.borderless) .number {
|
|
19
|
-
border: 2px solid var(--
|
|
17
|
+
border: 2px solid var(--border);
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
li {
|
|
@@ -31,7 +29,7 @@ $size: 20px;
|
|
|
31
29
|
|
|
32
30
|
&::before {
|
|
33
31
|
@include position(absolute, l16px);
|
|
34
|
-
@include background(var(--
|
|
32
|
+
@include background(var(--border));
|
|
35
33
|
@include size(w2px);
|
|
36
34
|
|
|
37
35
|
top: -50%;
|
|
@@ -42,18 +40,18 @@ $size: 20px;
|
|
|
42
40
|
|
|
43
41
|
&.completed::before,
|
|
44
42
|
&.active::before {
|
|
45
|
-
@include background(var(--
|
|
43
|
+
@include background(var(--complete));
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
&.active .number {
|
|
50
|
-
border-color: var(--
|
|
51
|
-
color: var(--
|
|
48
|
+
border-color: var(--active);
|
|
49
|
+
color: var(--active);
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
&.completed .number {
|
|
55
|
-
border-color: var(--
|
|
56
|
-
color: var(--
|
|
53
|
+
border-color: var(--complete);
|
|
54
|
+
color: var(--complete);
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
.number {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
2
3
|
import type { SwitchProps } from './switch'
|
|
3
4
|
|
|
4
5
|
import { classNames } from '../../utils/classNames'
|
|
5
6
|
|
|
6
7
|
import styles from './switch.module.scss'
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
export type Props = SwitchProps<HTMLAttributes<'textarea'>>
|
|
9
10
|
|
|
10
11
|
const {
|
|
11
12
|
label,
|
|
@@ -36,7 +37,11 @@ const styleVariables = classNames([
|
|
|
36
37
|
---
|
|
37
38
|
|
|
38
39
|
<label class:list={classes} style={styleVariables}>
|
|
39
|
-
<input
|
|
40
|
+
<input
|
|
41
|
+
{...rest}
|
|
42
|
+
type="checkbox"
|
|
43
|
+
checked={toggled}
|
|
44
|
+
/>
|
|
40
45
|
<span class={styles.toggle}></span>
|
|
41
46
|
{label && <span class={styles.label} set:html={label} />}
|
|
42
47
|
</label>
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
ChangeEventHandler,
|
|
4
|
+
HTMLInputAttributes,
|
|
5
|
+
MouseEventHandler
|
|
6
|
+
} from 'svelte/elements'
|
|
7
|
+
import type { SwitchProps } from './switch'
|
|
3
8
|
|
|
4
9
|
import { classNames } from '../../utils/classNames'
|
|
5
10
|
|
|
6
11
|
import styles from './switch.module.scss'
|
|
7
12
|
|
|
13
|
+
export type Props = SwitchProps<HTMLInputAttributes> & {
|
|
14
|
+
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
15
|
+
onClick?: MouseEventHandler<HTMLInputElement>
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
const {
|
|
9
19
|
label,
|
|
10
20
|
toggled,
|
|
@@ -18,31 +28,30 @@
|
|
|
18
28
|
onClick,
|
|
19
29
|
onChange,
|
|
20
30
|
...rest
|
|
21
|
-
}:
|
|
31
|
+
}: Props = $props()
|
|
22
32
|
|
|
23
|
-
const classes = classNames([
|
|
33
|
+
const classes = $derived(classNames([
|
|
24
34
|
styles.switch,
|
|
25
35
|
reverse && styles.reverse,
|
|
26
36
|
small && styles.small,
|
|
27
37
|
square && styles.square,
|
|
28
38
|
disabled && styles.disabled,
|
|
29
39
|
className
|
|
30
|
-
])
|
|
40
|
+
]))
|
|
31
41
|
|
|
32
|
-
const styleVariables = classNames([
|
|
42
|
+
const styleVariables = $derived(classNames([
|
|
33
43
|
offColor && `--w-switch-off-color: ${offColor};`,
|
|
34
44
|
onColor && `--w-switch-on-color: ${onColor};`
|
|
35
|
-
])
|
|
45
|
+
]))
|
|
36
46
|
</script>
|
|
37
47
|
|
|
38
48
|
<label class={classes} style={styleVariables || null}>
|
|
39
49
|
<input
|
|
50
|
+
{...rest}
|
|
40
51
|
type="checkbox"
|
|
41
52
|
checked={toggled}
|
|
42
|
-
disabled={disabled}
|
|
43
53
|
onclick={onClick}
|
|
44
54
|
onchange={onChange}
|
|
45
|
-
{...rest}
|
|
46
55
|
/>
|
|
47
56
|
<span class={styles.toggle}></span>
|
|
48
57
|
{#if label}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { SwitchProps } from './switch'
|
|
3
3
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
|
|
6
6
|
import styles from './switch.module.scss'
|
|
7
7
|
|
|
8
|
+
export type Props = SwitchProps<React.InputHTMLAttributes<HTMLInputElement>> & {
|
|
9
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>
|
|
10
|
+
onClick?: React.MouseEventHandler<HTMLInputElement>
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
const Switch = ({
|
|
9
14
|
label,
|
|
10
15
|
toggled,
|
|
@@ -16,7 +21,7 @@ const Switch = ({
|
|
|
16
21
|
disabled,
|
|
17
22
|
className,
|
|
18
23
|
...rest
|
|
19
|
-
}:
|
|
24
|
+
}: Props) => {
|
|
20
25
|
const classes = classNames([
|
|
21
26
|
styles.switch,
|
|
22
27
|
reverse && styles.reverse,
|
|
@@ -34,10 +39,9 @@ const Switch = ({
|
|
|
34
39
|
return (
|
|
35
40
|
<label className={classes} style={styleVariables || null}>
|
|
36
41
|
<input
|
|
42
|
+
{...rest}
|
|
37
43
|
type="checkbox"
|
|
38
44
|
defaultChecked={toggled}
|
|
39
|
-
disabled={disabled}
|
|
40
|
-
{...rest}
|
|
41
45
|
/>
|
|
42
46
|
<span className={styles.toggle}></span>
|
|
43
47
|
{label && (
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
@use '../../scss/config.scss' as *;
|
|
2
2
|
|
|
3
|
-
body {
|
|
4
|
-
--w-switch-off-color: var(--w-color-primary-50);
|
|
5
|
-
--w-switch-on-color: var(--w-color-primary);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
3
|
.switch {
|
|
4
|
+
--off-color: var(--w-switch-off-color, var(--w-color-primary-50));
|
|
5
|
+
--on-color: var(--w-switch-on-color, var(--w-color-primary));
|
|
6
|
+
|
|
9
7
|
@include layout(inline-flex, v-center, sm);
|
|
10
8
|
cursor: pointer;
|
|
11
9
|
user-select: none;
|
|
@@ -53,7 +51,7 @@ body {
|
|
|
53
51
|
@include visibility(none);
|
|
54
52
|
|
|
55
53
|
&:checked + span {
|
|
56
|
-
@include background(var(--
|
|
54
|
+
@include background(var(--on-color));
|
|
57
55
|
|
|
58
56
|
&::before {
|
|
59
57
|
transform: translateX(30px);
|
|
@@ -66,7 +64,7 @@ body {
|
|
|
66
64
|
@include position(relative);
|
|
67
65
|
@include size(w60px, h30px);
|
|
68
66
|
@include border-radius(xl);
|
|
69
|
-
@include background(var(--
|
|
67
|
+
@include background(var(--off-color));
|
|
70
68
|
|
|
71
69
|
&::before {
|
|
72
70
|
@include transition(transform);
|
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type SwitchProps = {
|
|
1
|
+
export type SwitchProps<T extends object = object> = {
|
|
4
2
|
label?: string
|
|
5
3
|
reverse?: boolean
|
|
6
4
|
toggled?: boolean
|
|
7
|
-
disabled?: boolean
|
|
8
5
|
small?: boolean
|
|
9
6
|
square?: boolean
|
|
10
7
|
onColor?: string
|
|
11
8
|
offColor?: string
|
|
12
9
|
className?: string
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type SvelteSwitchProps = {
|
|
17
|
-
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
18
|
-
onClick?: MouseEventHandler<HTMLInputElement>
|
|
19
|
-
} & SwitchProps
|
|
20
|
-
|
|
21
|
-
export type ReactSwitchProps = {
|
|
22
|
-
onChange?: React.ChangeEventHandler<HTMLInputElement>
|
|
23
|
-
onClick?: React.MouseEventHandler<HTMLInputElement>
|
|
24
|
-
} & SwitchProps
|
|
10
|
+
} & T
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
3
|
+
import type { TabProps } from './tab'
|
|
4
|
+
|
|
5
|
+
export type Props = TabProps<HTMLAttributes<'section'>>
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
element = 'div',
|
|
9
|
+
id,
|
|
10
|
+
active,
|
|
11
|
+
className,
|
|
12
|
+
...rest
|
|
13
|
+
} = Astro.props
|
|
14
|
+
|
|
15
|
+
const Element = element
|
|
16
|
+
|
|
17
|
+
const props = {
|
|
18
|
+
...rest,
|
|
19
|
+
'class': className,
|
|
20
|
+
'data-tab': id,
|
|
21
|
+
'data-active': active
|
|
22
|
+
}
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
<Element {...props}><slot /></Element>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
4
|
+
import type { TabProps } from './tab'
|
|
5
|
+
|
|
6
|
+
export type Props = TabProps<HTMLAttributes<HTMLElement>> & {
|
|
7
|
+
children: Snippet
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
element = 'div',
|
|
12
|
+
id,
|
|
13
|
+
active,
|
|
14
|
+
className,
|
|
15
|
+
children,
|
|
16
|
+
...rest
|
|
17
|
+
}: Props = $props()
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<svelte:element
|
|
21
|
+
{...rest}
|
|
22
|
+
{...(className && { class: className })}
|
|
23
|
+
this={element}
|
|
24
|
+
data-tab={id}
|
|
25
|
+
data-active={active}
|
|
26
|
+
>
|
|
27
|
+
{@render children?.()}
|
|
28
|
+
</svelte:element>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { TabProps } from './tab'
|
|
3
|
+
|
|
4
|
+
export type Props = TabProps<React.HTMLAttributes<HTMLElement>> & {
|
|
5
|
+
children: React.ReactNode
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const Tab = ({
|
|
9
|
+
element = 'div',
|
|
10
|
+
id,
|
|
11
|
+
active,
|
|
12
|
+
className,
|
|
13
|
+
children,
|
|
14
|
+
...rest
|
|
15
|
+
}: Props) => {
|
|
16
|
+
const Element = element as React.ElementType<React.HTMLAttributes<HTMLElement>>
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Element
|
|
20
|
+
{...rest}
|
|
21
|
+
className={className}
|
|
22
|
+
data-tab={id}
|
|
23
|
+
data-active={active}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</Element>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default Tab
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
|
|
6
6
|
import styles from './table.module.scss'
|
|
7
|
+
|
|
8
|
+
export type Props = TableProps
|
|
7
9
|
|
|
8
10
|
const {
|
|
9
11
|
headings,
|
|
@@ -15,9 +17,9 @@
|
|
|
15
17
|
compact,
|
|
16
18
|
maxHeight,
|
|
17
19
|
className
|
|
18
|
-
}:
|
|
20
|
+
}: Props = $props()
|
|
19
21
|
|
|
20
|
-
const classes = classNames([
|
|
22
|
+
const classes = $derived(classNames([
|
|
21
23
|
styles.table,
|
|
22
24
|
hover && styles.hover,
|
|
23
25
|
striped && styles[`striped-${striped}s`],
|
|
@@ -25,7 +27,7 @@
|
|
|
25
27
|
compact && styles.compact,
|
|
26
28
|
maxHeight && styles.scroll,
|
|
27
29
|
className
|
|
28
|
-
])
|
|
30
|
+
]))
|
|
29
31
|
</script>
|
|
30
32
|
|
|
31
33
|
<div class={classes} style={maxHeight ? `max-height:${maxHeight}` : null}>
|
|
@@ -4,6 +4,8 @@ import type { TableProps } from './table'
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
|
|
6
6
|
import styles from './table.module.scss'
|
|
7
|
+
|
|
8
|
+
export type Props = TableProps
|
|
7
9
|
|
|
8
10
|
const Table = ({
|
|
9
11
|
headings,
|
|
@@ -15,7 +17,7 @@ const Table = ({
|
|
|
15
17
|
compact,
|
|
16
18
|
maxHeight,
|
|
17
19
|
className
|
|
18
|
-
}:
|
|
20
|
+
}: Props) => {
|
|
19
21
|
const classes = classNames([
|
|
20
22
|
styles.table,
|
|
21
23
|
hover && styles.hover,
|
|
@@ -3,7 +3,7 @@ import type { TabsProps } from './tabs'
|
|
|
3
3
|
|
|
4
4
|
import styles from './tabs.module.scss'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export type Props = TabsProps
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
9
|
items,
|
|
@@ -20,6 +20,12 @@ const classes = [
|
|
|
20
20
|
even && styles.even,
|
|
21
21
|
className
|
|
22
22
|
]
|
|
23
|
+
|
|
24
|
+
const hasActive = items.some(item => item.active)
|
|
25
|
+
|
|
26
|
+
if (!hasActive) {
|
|
27
|
+
items[0].active = true
|
|
28
|
+
}
|
|
23
29
|
---
|
|
24
30
|
|
|
25
31
|
<section class:list={classes} data-id="w-tabs">
|
|
@@ -36,45 +42,72 @@ const classes = [
|
|
|
36
42
|
))}
|
|
37
43
|
</div>
|
|
38
44
|
</div>
|
|
39
|
-
<div
|
|
45
|
+
<div
|
|
46
|
+
class={styles.content}
|
|
47
|
+
data-id="w-tabs-content"
|
|
48
|
+
data-active-index={items.findIndex(item => item.active)}
|
|
49
|
+
>
|
|
40
50
|
<slot />
|
|
41
51
|
</div>
|
|
42
52
|
</section>
|
|
43
53
|
|
|
44
54
|
<script>
|
|
45
|
-
import { on } from '../../utils/DOMUtils'
|
|
55
|
+
import { get, on } from '../../utils/DOMUtils'
|
|
56
|
+
|
|
57
|
+
const setActiveTab = () => {
|
|
58
|
+
const tabContents = get('[data-id="w-tabs-content"]', true) as NodeListOf<HTMLDivElement>
|
|
59
|
+
|
|
60
|
+
tabContents.forEach((tabContent) => {
|
|
61
|
+
const contentChildren = Array.from(tabContent.children) as HTMLElement[]
|
|
62
|
+
|
|
63
|
+
if (!contentChildren.some(element => element.dataset.active === 'true')) {
|
|
64
|
+
const index = Number(tabContent.dataset.activeIndex)
|
|
65
|
+
|
|
66
|
+
if (contentChildren[index]) {
|
|
67
|
+
contentChildren[index].dataset.active = 'true'
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
46
72
|
|
|
47
73
|
const addEventListeners = () => {
|
|
48
74
|
on('[data-id="w-tabs"]', 'click', (event: Event) => {
|
|
49
|
-
const target = event.target as
|
|
75
|
+
const target = event.target as HTMLButtonElement
|
|
76
|
+
|
|
77
|
+
if (!target.dataset.value) {
|
|
78
|
+
return
|
|
79
|
+
}
|
|
50
80
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
?.nextElementSibling as HTMLDivElement
|
|
81
|
+
const tabContent = target.parentElement
|
|
82
|
+
?.parentElement
|
|
83
|
+
?.nextElementSibling as HTMLDivElement
|
|
55
84
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
} else {
|
|
61
|
-
element.dataset.active = false
|
|
62
|
-
}
|
|
63
|
-
})
|
|
85
|
+
const btns = Array.from(target.parentElement?.querySelectorAll('button') as NodeListOf<HTMLButtonElement>)
|
|
86
|
+
const clickedIndex = btns.indexOf(target)
|
|
87
|
+
const contentChildren = Array.from(tabContent.children) as HTMLElement[]
|
|
88
|
+
const hasExplicitTabs = contentChildren.some((element: HTMLElement) => element.dataset.tab)
|
|
64
89
|
|
|
65
|
-
|
|
90
|
+
btns.forEach((tab: HTMLElement, index: number) => {
|
|
91
|
+
tab.dataset.active = index === clickedIndex ? 'true' : 'false'
|
|
66
92
|
|
|
67
|
-
|
|
68
|
-
|
|
93
|
+
if (contentChildren[index]) {
|
|
94
|
+
const content = contentChildren[index]
|
|
69
95
|
|
|
70
|
-
if (
|
|
71
|
-
|
|
96
|
+
if (hasExplicitTabs) {
|
|
97
|
+
content.dataset.active = content.dataset.tab === target.dataset.value ? 'true' : 'false'
|
|
98
|
+
} else {
|
|
99
|
+
content.dataset.active = index === clickedIndex ? 'true' : 'false'
|
|
72
100
|
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
101
|
+
}
|
|
102
|
+
})
|
|
75
103
|
}, true)
|
|
76
104
|
}
|
|
77
105
|
|
|
78
|
-
|
|
79
|
-
|
|
106
|
+
const initTabs = () => {
|
|
107
|
+
setActiveTab()
|
|
108
|
+
addEventListeners()
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
on(document, 'astro:after-swap', initTabs)
|
|
112
|
+
initTabs()
|
|
80
113
|
</script>
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type
|
|
2
|
+
import { onMount, type Snippet } from 'svelte'
|
|
3
|
+
import type { TabsProps } from './tabs'
|
|
3
4
|
|
|
4
5
|
import { classNames } from '../../utils/classNames'
|
|
5
6
|
|
|
6
7
|
import styles from './tabs.module.scss'
|
|
7
8
|
|
|
9
|
+
export type Props = TabsProps & {
|
|
10
|
+
children: Snippet
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
const {
|
|
9
14
|
items,
|
|
10
15
|
theme,
|
|
@@ -12,42 +17,70 @@
|
|
|
12
17
|
even,
|
|
13
18
|
className,
|
|
14
19
|
children
|
|
15
|
-
}:
|
|
20
|
+
}: Props = $props()
|
|
16
21
|
|
|
17
22
|
let active = $state('')
|
|
18
23
|
let tabContainer: HTMLDivElement | undefined = $state()
|
|
19
24
|
|
|
20
|
-
const
|
|
25
|
+
const usedInAstro = $derived(tabContainer?.children[0]?.nodeName === 'ASTRO-SLOT')
|
|
26
|
+
const hasActive = $derived(items.some(item => item.active))
|
|
27
|
+
const itemsState = $derived.by(() => {
|
|
28
|
+
if (!hasActive) {
|
|
29
|
+
items[0].active = true
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return items
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const classes = $derived(classNames([
|
|
21
36
|
styles.tabs,
|
|
22
37
|
theme && styles[theme],
|
|
23
38
|
vertical && styles.vertical,
|
|
24
39
|
even && styles.even,
|
|
25
40
|
className
|
|
26
|
-
])
|
|
27
|
-
|
|
28
|
-
const setTab = (tab: string) => {
|
|
29
|
-
const tabs = tabContainer!.querySelectorAll('[data-tab]')
|
|
41
|
+
]))
|
|
30
42
|
|
|
31
|
-
|
|
43
|
+
const setTab = (tab: string, index: number) => {
|
|
44
|
+
const contentChildren = usedInAstro
|
|
45
|
+
? Array.from(tabContainer!.children[0].children) as HTMLElement[]
|
|
46
|
+
: Array.from(tabContainer!.children) as HTMLElement[]
|
|
32
47
|
|
|
33
|
-
|
|
34
|
-
item.dataset.active = false
|
|
48
|
+
const hasExplicitTabs = contentChildren.some((el: HTMLElement) => el.dataset.tab)
|
|
35
49
|
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
contentChildren.forEach((item: HTMLElement, i: number) => {
|
|
51
|
+
if (hasExplicitTabs) {
|
|
52
|
+
item.dataset.active = item.dataset.tab === tab ? 'true' : 'false'
|
|
53
|
+
} else {
|
|
54
|
+
item.dataset.active = i === index ? 'true' : 'false'
|
|
38
55
|
}
|
|
39
56
|
})
|
|
57
|
+
|
|
58
|
+
active = tab
|
|
40
59
|
}
|
|
60
|
+
|
|
61
|
+
onMount(() => {
|
|
62
|
+
const contentChildren = usedInAstro
|
|
63
|
+
? Array.from(tabContainer!.children[0].children) as HTMLElement[]
|
|
64
|
+
: Array.from(tabContainer!.children) as HTMLElement[]
|
|
65
|
+
|
|
66
|
+
if (!contentChildren.some(element => element.dataset.active === 'true')) {
|
|
67
|
+
const index = itemsState.findIndex(item => item.active)
|
|
68
|
+
|
|
69
|
+
if (contentChildren[index]) {
|
|
70
|
+
contentChildren[index].dataset.active = 'true'
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
})
|
|
41
74
|
</script>
|
|
42
75
|
|
|
43
76
|
<section class={classes}>
|
|
44
77
|
<div class={styles.wrapper}>
|
|
45
78
|
<div class={styles.items}>
|
|
46
|
-
{#each
|
|
79
|
+
{#each itemsState as item, i}
|
|
47
80
|
<button
|
|
48
81
|
data-active={active ? active === item.value : item.active}
|
|
49
82
|
disabled={item.disabled}
|
|
50
|
-
onclick={() => setTab(item.value)}
|
|
83
|
+
onclick={() => setTab(item.value, i)}
|
|
51
84
|
>
|
|
52
85
|
{@html item.label}
|
|
53
86
|
</button>
|