webcoreui 0.8.1 → 0.10.0
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 +36 -6
- package/astro.d.ts +23 -0
- package/astro.js +8 -0
- package/components/Accordion/Accordion.astro +15 -10
- package/components/Accordion/Accordion.svelte +14 -12
- package/components/Accordion/Accordion.tsx +2 -2
- package/components/Accordion/accordion.module.scss +1 -0
- package/components/Alert/Alert.svelte +17 -12
- package/components/Alert/Alert.tsx +1 -1
- package/components/Alert/alert.ts +10 -3
- package/components/AspectRatio/AspectRatio.svelte +7 -4
- package/components/AspectRatio/aspectratio.ts +6 -0
- package/components/Avatar/Avatar.svelte +11 -9
- package/components/Badge/Badge.svelte +14 -10
- package/components/Badge/badge.ts +3 -2
- package/components/Banner/Banner.astro +10 -4
- package/components/Banner/Banner.svelte +14 -10
- package/components/Banner/Banner.tsx +1 -0
- package/components/Banner/banner.ts +6 -0
- package/components/BottomNavigation/BottomNavigation.astro +51 -0
- package/components/BottomNavigation/BottomNavigation.svelte +47 -0
- package/components/BottomNavigation/BottomNavigation.tsx +63 -0
- package/components/BottomNavigation/bottomnavigation.module.scss +70 -0
- package/components/BottomNavigation/bottomnavigation.ts +16 -0
- package/components/Breadcrumb/Breadcrumb.astro +1 -1
- package/components/Breadcrumb/Breadcrumb.svelte +8 -6
- package/components/Breadcrumb/Breadcrumb.tsx +2 -2
- package/components/Button/Button.svelte +12 -8
- package/components/Button/Button.tsx +2 -2
- package/components/Button/button.ts +2 -3
- package/components/Card/Card.svelte +14 -10
- package/components/Card/card.module.scss +1 -0
- package/components/Card/card.ts +6 -0
- package/components/Carousel/Carousel.astro +46 -41
- package/components/Carousel/carousel.ts +3 -0
- package/components/Checkbox/Checkbox.astro +8 -2
- package/components/Checkbox/Checkbox.svelte +12 -8
- package/components/Checkbox/Checkbox.tsx +3 -1
- package/components/Checkbox/checkbox.module.scss +4 -0
- package/components/Checkbox/checkbox.ts +1 -0
- package/components/Collapsible/Collapsible.astro +8 -5
- package/components/Collapsible/Collapsible.svelte +54 -49
- package/components/Collapsible/collapsible.ts +8 -0
- package/components/ConditionalWrapper/ConditionalWrapper.svelte +10 -6
- package/components/ConditionalWrapper/conditionalwrapper.ts +6 -0
- package/components/Copy/Copy.astro +80 -0
- package/components/Copy/Copy.svelte +68 -0
- package/components/Copy/Copy.tsx +74 -0
- package/components/Copy/copy.module.scss +37 -0
- package/components/Copy/copy.ts +20 -0
- package/components/DataTable/DataTable.astro +103 -93
- package/components/DataTable/DataTable.svelte +276 -272
- package/components/DataTable/datatable.ts +5 -2
- package/components/Flex/Flex.astro +34 -0
- package/components/Flex/Flex.svelte +31 -0
- package/components/Flex/Flex.tsx +30 -0
- package/components/Flex/flex.ts +28 -0
- package/components/Footer/Footer.svelte +12 -9
- package/components/Footer/footer.ts +6 -0
- package/components/Grid/Grid.astro +32 -0
- package/components/Grid/Grid.svelte +29 -0
- package/components/Grid/Grid.tsx +28 -0
- package/components/Grid/grid.ts +24 -0
- package/components/Group/Group.svelte +7 -4
- package/components/Group/group.ts +6 -0
- package/components/Icon/Icon.astro +19 -5
- package/components/Icon/Icon.svelte +23 -7
- package/components/Icon/Icon.tsx +19 -5
- package/components/Icon/icon.ts +10 -3
- package/components/Icon/map.ts +10 -10
- package/components/Input/Input.astro +1 -1
- package/components/Input/Input.svelte +26 -20
- package/components/Input/Input.tsx +4 -1
- package/components/Input/input.ts +10 -3
- package/components/Kbd/Kbd.svelte +7 -4
- package/components/Kbd/kbd.ts +6 -0
- package/components/List/List.astro +65 -60
- package/components/List/List.svelte +149 -147
- package/components/List/List.tsx +1 -1
- package/components/List/list.module.scss +3 -0
- package/components/Masonry/Masonry.svelte +12 -10
- package/components/Menu/Menu.astro +8 -3
- package/components/Menu/Menu.svelte +19 -10
- package/components/Menu/Menu.tsx +3 -1
- package/components/Menu/menu.ts +6 -0
- package/components/Modal/Modal.astro +1 -0
- package/components/Modal/Modal.svelte +18 -13
- package/components/Modal/Modal.tsx +2 -1
- package/components/Modal/modal.ts +6 -1
- package/components/Pagination/Pagination.astro +75 -69
- package/components/Pagination/Pagination.svelte +30 -26
- package/components/Pagination/Pagination.tsx +5 -4
- package/components/Pagination/pagination.module.scss +4 -0
- package/components/Popover/Popover.svelte +10 -6
- package/components/Popover/popover.ts +6 -0
- package/components/Progress/Progress.svelte +12 -10
- package/components/Progress/progress.ts +1 -1
- package/components/Radio/Radio.astro +3 -1
- package/components/Radio/Radio.svelte +14 -10
- package/components/Radio/Radio.tsx +5 -3
- package/components/Radio/radio.ts +5 -2
- package/components/Rating/Rating.svelte +16 -14
- package/components/Ribbon/Ribbon.svelte +9 -6
- package/components/Ribbon/ribbon.ts +6 -0
- package/components/Select/Select.astro +85 -42
- package/components/Select/Select.svelte +62 -21
- package/components/Select/Select.tsx +41 -7
- package/components/Select/select.ts +4 -1
- package/components/Sheet/Sheet.svelte +9 -5
- package/components/Sheet/sheet.ts +6 -2
- package/components/Sidebar/Sidebar.svelte +7 -4
- package/components/Sidebar/sidebar.ts +6 -0
- package/components/Skeleton/Skeleton.astro +2 -2
- package/components/Skeleton/Skeleton.svelte +11 -9
- package/components/Skeleton/Skeleton.tsx +2 -2
- package/components/Slider/Slider.svelte +15 -13
- package/components/Slider/slider.module.scss +4 -0
- package/components/Slider/slider.ts +4 -2
- package/components/Spinner/Spinner.svelte +7 -5
- package/components/Spoiler/Spoiler.astro +13 -8
- package/components/Spoiler/Spoiler.svelte +13 -10
- package/components/Spoiler/spoiler.ts +6 -0
- package/components/Stepper/Stepper.svelte +9 -7
- package/components/Switch/Switch.astro +3 -2
- package/components/Switch/Switch.svelte +15 -11
- package/components/Switch/Switch.tsx +3 -1
- package/components/Switch/switch.ts +1 -0
- package/components/Table/Table.svelte +11 -9
- package/components/Table/table.ts +1 -1
- package/components/Tabs/Tabs.astro +8 -5
- package/components/Tabs/Tabs.svelte +14 -11
- package/components/Tabs/tabs.ts +7 -1
- package/components/Textarea/Textarea.astro +3 -1
- package/components/Textarea/Textarea.svelte +51 -47
- package/components/Textarea/textarea.ts +24 -18
- package/components/ThemeSwitcher/ThemeSwitcher.astro +43 -37
- package/components/ThemeSwitcher/ThemeSwitcher.svelte +14 -10
- package/components/ThemeSwitcher/themeswitcher.ts +7 -0
- package/components/Timeline/Timeline.svelte +12 -9
- package/components/Timeline/timeline.ts +7 -2
- package/components/TimelineItem/TimelineItem.svelte +8 -5
- package/components/TimelineItem/timelineitem.ts +6 -0
- package/components/Toast/Toast.svelte +18 -10
- package/components/Toast/toast.ts +6 -1
- package/icons/alert.svg +2 -2
- package/icons/check.svg +2 -2
- package/icons/chevron-down.svg +3 -0
- package/icons/chevron-left.svg +3 -0
- package/icons/chevron-right.svg +3 -0
- package/icons/chevron-up.svg +3 -0
- package/icons/circle-check.svg +3 -3
- package/icons/copy.svg +3 -0
- package/icons/info.svg +3 -3
- package/icons.d.ts +5 -5
- package/icons.js +5 -5
- package/index.d.ts +75 -2
- package/index.js +2 -0
- package/package.json +31 -22
- package/react.d.ts +23 -0
- package/react.js +8 -0
- package/scss/global/utility.scss +48 -3
- package/svelte.d.ts +111 -88
- package/svelte.js +8 -0
- package/utils/DOMUtils.ts +2 -2
- package/utils/bodyFreeze.ts +13 -0
- package/utils/classNames.ts +1 -1
- package/utils/getLayoutClasses.ts +141 -0
- package/utils/modal.ts +16 -4
- package/utils/popover.ts +30 -4
- package/icons/arrow-down.svg +0 -3
- package/icons/arrow-left.svg +0 -3
- package/icons/arrow-right.svg +0 -3
- package/icons/components.svg +0 -3
- package/icons/file.svg +0 -3
- package/scss/webcore.config.scss +0 -0
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
import styles from './skeleton.module.scss'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const {
|
|
9
|
+
animate = 'wave',
|
|
10
|
+
type = 'rounded',
|
|
11
|
+
width,
|
|
12
|
+
height,
|
|
13
|
+
color,
|
|
14
|
+
waveColor,
|
|
15
|
+
className
|
|
16
|
+
}: SkeletonProps = $props()
|
|
15
17
|
|
|
16
18
|
const classes = classNames([
|
|
17
19
|
animate && styles[animate],
|
|
@@ -21,8 +23,8 @@
|
|
|
21
23
|
])
|
|
22
24
|
|
|
23
25
|
const styleVariables = classNames([
|
|
24
|
-
width && `width: ${width}px;`,
|
|
25
|
-
height && `height: ${height}px;`,
|
|
26
|
+
width && `max-width: ${width}px;`,
|
|
27
|
+
height && `max-height: ${height}px;`,
|
|
26
28
|
color && `--w-skeleton-color: ${color};`,
|
|
27
29
|
waveColor && `--w-skeleton-wave-color: ${waveColor};`
|
|
28
30
|
])
|
|
@@ -22,8 +22,8 @@ const Skeleton = ({
|
|
|
22
22
|
])
|
|
23
23
|
|
|
24
24
|
const styleVariables = {
|
|
25
|
-
...(width && {
|
|
26
|
-
...(height && {
|
|
25
|
+
...(width && { maxWidth: `${width}px` }),
|
|
26
|
+
...(height && { maxHeight: `${height}px` }),
|
|
27
27
|
...(color && { '--w-skeleton-color': color }),
|
|
28
28
|
...(waveColor && { '--w-skeleton-wave-color': waveColor })
|
|
29
29
|
} as React.CSSProperties
|
|
@@ -5,17 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
import styles from './slider.module.scss'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
const {
|
|
9
|
+
min,
|
|
10
|
+
max,
|
|
11
|
+
value,
|
|
12
|
+
step,
|
|
13
|
+
disabled,
|
|
14
|
+
color,
|
|
15
|
+
background,
|
|
16
|
+
thumb,
|
|
17
|
+
id,
|
|
18
|
+
className,
|
|
19
|
+
onChange
|
|
20
|
+
}: SvelteSliderProps = $props()
|
|
19
21
|
|
|
20
22
|
const classes = classNames([
|
|
21
23
|
styles.slider,
|
|
@@ -37,7 +39,7 @@
|
|
|
37
39
|
step={step}
|
|
38
40
|
disabled={disabled}
|
|
39
41
|
class={classes}
|
|
40
|
-
id={id
|
|
42
|
+
id={id}
|
|
41
43
|
style={styleVariables || null}
|
|
42
|
-
|
|
44
|
+
onchange={onChange}
|
|
43
45
|
/>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { InputTarget } from '../Input/input'
|
|
2
|
+
|
|
1
3
|
export type SliderProps = {
|
|
2
4
|
min: number
|
|
3
5
|
max: number
|
|
@@ -12,9 +14,9 @@ export type SliderProps = {
|
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export type SvelteSliderProps = {
|
|
15
|
-
onChange?: (
|
|
17
|
+
onChange?: (event: Event & InputTarget) => void
|
|
16
18
|
} & SliderProps
|
|
17
19
|
|
|
18
20
|
export type ReactSliderProps = {
|
|
19
|
-
onChange?: (
|
|
21
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void
|
|
20
22
|
} & SliderProps
|
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
import styles from './spinner.module.scss'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const {
|
|
9
|
+
color,
|
|
10
|
+
width,
|
|
11
|
+
speed,
|
|
12
|
+
size,
|
|
13
|
+
dashArray
|
|
14
|
+
}: SpinnerProps = $props()
|
|
13
15
|
|
|
14
16
|
const classes = classNames([
|
|
15
17
|
styles.spinner,
|
|
@@ -39,12 +39,17 @@ const style = color
|
|
|
39
39
|
<script>
|
|
40
40
|
import { on } from '../../utils/DOMUtils'
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
const addEventListeners = () => {
|
|
43
|
+
on('[data-id="w-spoiler"]', 'click', (event: Event) => {
|
|
44
|
+
const target = event.currentTarget as HTMLDivElement
|
|
45
|
+
|
|
46
|
+
target.dataset.visible = 'true'
|
|
47
|
+
target.removeAttribute('data-tooltip')
|
|
48
|
+
target.removeAttribute('role')
|
|
49
|
+
target.removeAttribute('tabindex')
|
|
50
|
+
}, true)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
on(document, 'astro:after-swap', addEventListeners)
|
|
54
|
+
addEventListeners()
|
|
50
55
|
</script>
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { SvelteSpoilerProps } from './spoiler'
|
|
3
3
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
|
|
6
6
|
import styles from './spoiler.module.scss'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const {
|
|
9
|
+
color,
|
|
10
|
+
animated = true,
|
|
11
|
+
block,
|
|
12
|
+
tooltip,
|
|
13
|
+
tooltipPosition,
|
|
14
|
+
children
|
|
15
|
+
}: SvelteSpoilerProps = $props()
|
|
13
16
|
|
|
14
17
|
const classes = classNames([
|
|
15
18
|
styles.spoiler,
|
|
@@ -34,12 +37,12 @@
|
|
|
34
37
|
<span
|
|
35
38
|
class={classes}
|
|
36
39
|
style={style}
|
|
37
|
-
data-tooltip={tooltip
|
|
40
|
+
data-tooltip={tooltip}
|
|
38
41
|
data-position={tooltipPosition}
|
|
39
42
|
role="button"
|
|
40
43
|
tabindex="0"
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
onclick={toggle}
|
|
45
|
+
onkeyup={toggle}
|
|
43
46
|
>
|
|
44
|
-
|
|
47
|
+
{@render children?.()}
|
|
45
48
|
</span>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
|
|
1
3
|
export type SpoilerProps = {
|
|
2
4
|
color?: string
|
|
3
5
|
animated?: boolean
|
|
@@ -6,6 +8,10 @@ export type SpoilerProps = {
|
|
|
6
8
|
tooltipPosition?: 'bottom' | null
|
|
7
9
|
}
|
|
8
10
|
|
|
11
|
+
export type SvelteSpoilerProps = {
|
|
12
|
+
children: Snippet
|
|
13
|
+
} & SpoilerProps
|
|
14
|
+
|
|
9
15
|
export type ReactSpoilerProps = {
|
|
10
16
|
children: React.ReactNode
|
|
11
17
|
} & SpoilerProps
|
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
import styles from './stepper.module.scss'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const {
|
|
11
|
+
items,
|
|
12
|
+
color,
|
|
13
|
+
completedColor,
|
|
14
|
+
activeColor,
|
|
15
|
+
borderless,
|
|
16
|
+
vertical,
|
|
17
|
+
className
|
|
18
|
+
}: StepperProps = $props()
|
|
17
19
|
|
|
18
20
|
const classes = classNames([
|
|
19
21
|
styles.stepper,
|
|
@@ -16,7 +16,8 @@ const {
|
|
|
16
16
|
small,
|
|
17
17
|
square,
|
|
18
18
|
disabled,
|
|
19
|
-
className
|
|
19
|
+
className,
|
|
20
|
+
...rest
|
|
20
21
|
} = Astro.props
|
|
21
22
|
|
|
22
23
|
const classes = [
|
|
@@ -35,7 +36,7 @@ const styleVariables = classNames([
|
|
|
35
36
|
---
|
|
36
37
|
|
|
37
38
|
<label class:list={classes} style={styleVariables}>
|
|
38
|
-
<input type="checkbox" checked={toggled} disabled={disabled} />
|
|
39
|
+
<input type="checkbox" checked={toggled} disabled={disabled} {...rest} />
|
|
39
40
|
<span class={styles.toggle}></span>
|
|
40
41
|
{label && <span class={styles.label}>{label}</span>}
|
|
41
42
|
</label>
|
|
@@ -5,16 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
import styles from './switch.module.scss'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
const {
|
|
9
|
+
label,
|
|
10
|
+
toggled,
|
|
11
|
+
offColor,
|
|
12
|
+
onColor,
|
|
13
|
+
reverse,
|
|
14
|
+
small,
|
|
15
|
+
square,
|
|
16
|
+
disabled,
|
|
17
|
+
className,
|
|
18
|
+
onClick,
|
|
19
|
+
...rest
|
|
20
|
+
}: SvelteSwitchProps = $props()
|
|
18
21
|
|
|
19
22
|
const classes = classNames([
|
|
20
23
|
styles.switch,
|
|
@@ -36,7 +39,8 @@
|
|
|
36
39
|
type="checkbox"
|
|
37
40
|
checked={toggled}
|
|
38
41
|
disabled={disabled}
|
|
39
|
-
|
|
42
|
+
onclick={onClick}
|
|
43
|
+
{...rest}
|
|
40
44
|
/>
|
|
41
45
|
<span class={styles.toggle}></span>
|
|
42
46
|
{#if label}
|
|
@@ -15,7 +15,8 @@ const Switch = ({
|
|
|
15
15
|
square,
|
|
16
16
|
disabled,
|
|
17
17
|
className,
|
|
18
|
-
onClick
|
|
18
|
+
onClick,
|
|
19
|
+
...rest
|
|
19
20
|
}: ReactSwitchProps) => {
|
|
20
21
|
const classes = classNames([
|
|
21
22
|
styles.switch,
|
|
@@ -38,6 +39,7 @@ const Switch = ({
|
|
|
38
39
|
defaultChecked={toggled}
|
|
39
40
|
disabled={disabled}
|
|
40
41
|
onClick={onClick}
|
|
42
|
+
{...rest}
|
|
41
43
|
/>
|
|
42
44
|
<span className={styles.toggle}></span>
|
|
43
45
|
{label && <span className={styles.label}>{label}</span>}
|
|
@@ -5,15 +5,17 @@
|
|
|
5
5
|
|
|
6
6
|
import styles from './table.module.scss'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
const {
|
|
9
|
+
headings,
|
|
10
|
+
footer,
|
|
11
|
+
data,
|
|
12
|
+
hover,
|
|
13
|
+
striped,
|
|
14
|
+
offsetStripe,
|
|
15
|
+
compact,
|
|
16
|
+
maxHeight,
|
|
17
|
+
className
|
|
18
|
+
}: TableProps = $props()
|
|
17
19
|
|
|
18
20
|
const classes = classNames([
|
|
19
21
|
styles.table,
|
|
@@ -42,10 +42,10 @@ const classes = [
|
|
|
42
42
|
</section>
|
|
43
43
|
|
|
44
44
|
<script>
|
|
45
|
-
|
|
45
|
+
import { on } from '../../utils/DOMUtils'
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const addEventListeners = () => {
|
|
48
|
+
on('[data-id="w-tabs"]', 'click', (event: Event) => {
|
|
49
49
|
const target = event.target as HTMLDivElement
|
|
50
50
|
|
|
51
51
|
if (target.dataset.value) {
|
|
@@ -72,6 +72,9 @@ const classes = [
|
|
|
72
72
|
}
|
|
73
73
|
})
|
|
74
74
|
}
|
|
75
|
-
})
|
|
76
|
-
}
|
|
75
|
+
}, true)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
on(document, 'astro:after-swap', addEventListeners)
|
|
79
|
+
addEventListeners()
|
|
77
80
|
</script>
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { SvelteTabsProps } from './tabs'
|
|
3
3
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
|
|
6
6
|
import styles from './tabs.module.scss'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const {
|
|
9
|
+
items,
|
|
10
|
+
theme,
|
|
11
|
+
vertical,
|
|
12
|
+
even,
|
|
13
|
+
className,
|
|
14
|
+
children
|
|
15
|
+
}: SvelteTabsProps = $props()
|
|
13
16
|
|
|
14
|
-
let active = ''
|
|
15
|
-
let tabContainer: HTMLDivElement
|
|
17
|
+
let active = $state('')
|
|
18
|
+
let tabContainer: HTMLDivElement | undefined = $state()
|
|
16
19
|
|
|
17
20
|
const classes = classNames([
|
|
18
21
|
styles.tabs,
|
|
@@ -23,7 +26,7 @@
|
|
|
23
26
|
])
|
|
24
27
|
|
|
25
28
|
const setTab = (tab: string) => {
|
|
26
|
-
const tabs = tabContainer
|
|
29
|
+
const tabs = tabContainer!.querySelectorAll('[data-tab]')
|
|
27
30
|
|
|
28
31
|
active = tab
|
|
29
32
|
|
|
@@ -44,7 +47,7 @@
|
|
|
44
47
|
<button
|
|
45
48
|
data-active={active ? active === item.value : item.active}
|
|
46
49
|
disabled={item.disabled}
|
|
47
|
-
|
|
50
|
+
onclick={() => setTab(item.value)}
|
|
48
51
|
>
|
|
49
52
|
{@html item.label}
|
|
50
53
|
</button>
|
|
@@ -52,6 +55,6 @@
|
|
|
52
55
|
</div>
|
|
53
56
|
</div>
|
|
54
57
|
<div class={styles.content} bind:this={tabContainer}>
|
|
55
|
-
|
|
58
|
+
{@render children?.()}
|
|
56
59
|
</div>
|
|
57
60
|
</section>
|
package/components/Tabs/tabs.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
|
|
1
3
|
export type TabsProps = {
|
|
2
4
|
items: {
|
|
3
5
|
label: string
|
|
@@ -5,12 +7,16 @@ export type TabsProps = {
|
|
|
5
7
|
active?: boolean
|
|
6
8
|
disabled?: boolean
|
|
7
9
|
}[]
|
|
8
|
-
theme?: 'boxed' | 'outline'
|
|
10
|
+
theme?: 'boxed' | 'outline'
|
|
9
11
|
vertical?: boolean
|
|
10
12
|
even?: boolean
|
|
11
13
|
className?: string
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
export type SvelteTabsProps = {
|
|
17
|
+
children: Snippet
|
|
18
|
+
} & TabsProps
|
|
19
|
+
|
|
14
20
|
export type ReactTabsProps = {
|
|
15
21
|
children: React.ReactNode
|
|
16
22
|
} & TabsProps
|
|
@@ -13,7 +13,8 @@ const {
|
|
|
13
13
|
subText,
|
|
14
14
|
value = '',
|
|
15
15
|
disabled,
|
|
16
|
-
className
|
|
16
|
+
className,
|
|
17
|
+
...rest
|
|
17
18
|
} = Astro.props
|
|
18
19
|
|
|
19
20
|
const classes = [
|
|
@@ -41,5 +42,6 @@ const useLabel = !!(label || subText)
|
|
|
41
42
|
placeholder={placeholder}
|
|
42
43
|
disabled={disabled}
|
|
43
44
|
class:list={classes}
|
|
45
|
+
{...rest}
|
|
44
46
|
>{value}</textarea>
|
|
45
47
|
</ConditionalWrapper>
|
|
@@ -1,47 +1,51 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { SvelteTextareaProps } from './textarea'
|
|
3
|
-
|
|
4
|
-
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
|
|
5
|
-
|
|
6
|
-
import { classNames } from '../../utils/classNames'
|
|
7
|
-
|
|
8
|
-
import styles from './textarea.module.scss'
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SvelteTextareaProps } from './textarea'
|
|
3
|
+
|
|
4
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
|
|
5
|
+
|
|
6
|
+
import { classNames } from '../../utils/classNames'
|
|
7
|
+
|
|
8
|
+
import styles from './textarea.module.scss'
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
label,
|
|
12
|
+
placeholder,
|
|
13
|
+
subText,
|
|
14
|
+
value = '',
|
|
15
|
+
disabled,
|
|
16
|
+
className,
|
|
17
|
+
onChange,
|
|
18
|
+
onKeyUp,
|
|
19
|
+
...rest
|
|
20
|
+
}: SvelteTextareaProps = $props()
|
|
21
|
+
|
|
22
|
+
const classes = classNames([
|
|
23
|
+
styles.textarea,
|
|
24
|
+
className
|
|
25
|
+
])
|
|
26
|
+
|
|
27
|
+
const useLabel = !!(label || subText)
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<ConditionalWrapper
|
|
31
|
+
condition={useLabel}
|
|
32
|
+
element="label"
|
|
33
|
+
class={styles['label-wrapper']}
|
|
34
|
+
>
|
|
35
|
+
{#if label}
|
|
36
|
+
<div class={styles.label}>{label}</div>
|
|
37
|
+
{/if}
|
|
38
|
+
<textarea
|
|
39
|
+
placeholder={placeholder}
|
|
40
|
+
disabled={disabled}
|
|
41
|
+
class={classes}
|
|
42
|
+
onchange={onChange}
|
|
43
|
+
onkeyup={onKeyUp}
|
|
44
|
+
{...rest}
|
|
45
|
+
>{value}</textarea>
|
|
46
|
+
{#if subText}
|
|
47
|
+
<div class={styles.subtext}>
|
|
48
|
+
{@html subText}
|
|
49
|
+
</div>
|
|
50
|
+
{/if}
|
|
51
|
+
</ConditionalWrapper>
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
type Target = {
|
|
2
|
+
target: HTMLTextAreaElement
|
|
3
|
+
currentTarget: HTMLTextAreaElement
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type TextareaProps = {
|
|
7
|
+
label?: string
|
|
8
|
+
placeholder?: string
|
|
9
|
+
subText?: string
|
|
10
|
+
value?: string
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
className?: string
|
|
13
|
+
[key: string]: any
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type SvelteTextareaProps = {
|
|
17
|
+
onChange?: (event: Event & Target) => void
|
|
18
|
+
onKeyUp?: (event: KeyboardEvent & Target) => void
|
|
19
|
+
} & TextareaProps
|
|
20
|
+
|
|
21
|
+
export type ReactTextareaProps = {
|
|
22
|
+
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement> & Target) => void
|
|
23
|
+
onKeyUp?: (event: React.KeyboardEvent<HTMLTextAreaElement> & Target) => void
|
|
24
|
+
} & TextareaProps
|