webcoreui 1.5.0-0 → 1.5.0-beta.2
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/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 +4 -2
- package/components/Alert/Alert.astro +2 -1
- package/components/Alert/Alert.svelte +9 -2
- 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 +7 -2
- 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 +3 -1
- package/components/Avatar/Avatar.tsx +3 -2
- package/components/Badge/Badge.astro +2 -1
- package/components/Badge/Badge.svelte +9 -2
- package/components/Badge/Badge.tsx +8 -3
- package/components/Badge/badge.ts +11 -13
- package/components/Banner/Banner.astro +1 -1
- package/components/Banner/Banner.svelte +7 -2
- package/components/Banner/Banner.tsx +6 -2
- package/components/Banner/banner.ts +0 -10
- package/components/BottomNavigation/BottomNavigation.astro +1 -1
- package/components/BottomNavigation/BottomNavigation.svelte +3 -1
- package/components/BottomNavigation/BottomNavigation.tsx +3 -2
- package/components/Breadcrumb/Breadcrumb.astro +1 -1
- package/components/Breadcrumb/Breadcrumb.svelte +3 -1
- package/components/Breadcrumb/Breadcrumb.tsx +3 -1
- package/components/Button/Button.astro +2 -1
- package/components/Button/Button.svelte +9 -2
- package/components/Button/Button.tsx +7 -2
- package/components/Button/button.ts +23 -20
- package/components/Card/Card.astro +9 -2
- package/components/Card/Card.svelte +17 -4
- package/components/Card/Card.tsx +23 -6
- package/components/Card/card.module.scss +11 -4
- package/components/Card/card.ts +3 -16
- package/components/Carousel/Carousel.astro +1 -1
- package/components/Carousel/Carousel.svelte +8 -3
- package/components/Carousel/Carousel.tsx +7 -2
- 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 +9 -7
- package/components/Checkbox/Checkbox.tsx +8 -5
- package/components/Checkbox/checkbox.ts +2 -17
- package/components/Collapsible/Collapsible.astro +1 -1
- package/components/Collapsible/Collapsible.svelte +9 -2
- package/components/Collapsible/Collapsible.tsx +8 -2
- 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 +9 -3
- 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 +8 -3
- 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 +10 -5
- package/components/Counter/Counter.tsx +11 -7
- package/components/Counter/counter.ts +2 -11
- package/components/DataTable/DataTable.astro +1 -1
- package/components/DataTable/DataTable.svelte +8 -2
- 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 +8 -2
- 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 +7 -2
- 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 +8 -2
- 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 +7 -2
- 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 +3 -1
- package/components/Icon/Icon.tsx +3 -2
- package/components/Image/Image.astro +2 -1
- package/components/Image/Image.svelte +4 -1
- 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 +3 -1
- package/components/ImageLoader/ImageLoader.tsx +4 -2
- package/components/Input/Input.astro +3 -2
- package/components/Input/Input.svelte +14 -4
- 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 +7 -2
- 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 +6 -2
- package/components/List/List.tsx +8 -4
- package/components/List/list.ts +0 -8
- package/components/Masonry/Masonry.astro +1 -1
- package/components/Masonry/Masonry.svelte +7 -2
- package/components/Masonry/Masonry.tsx +7 -3
- package/components/Masonry/masonry.ts +2 -13
- package/components/Menu/Menu.astro +1 -1
- package/components/Menu/Menu.svelte +7 -2
- 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 +8 -4
- package/components/Modal/Modal.tsx +6 -4
- package/components/Modal/modal.ts +2 -14
- package/components/OTPInput/OTPInput.astro +3 -5
- package/components/OTPInput/OTPInput.svelte +6 -6
- package/components/OTPInput/OTPInput.tsx +10 -8
- package/components/OTPInput/otpinput.ts +2 -4
- package/components/Pagination/Pagination.astro +1 -1
- package/components/Pagination/Pagination.svelte +6 -2
- 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 +9 -8
- 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 +3 -1
- package/components/Progress/Progress.tsx +3 -1
- package/components/Radio/Radio.astro +3 -4
- package/components/Radio/Radio.svelte +10 -5
- package/components/Radio/Radio.tsx +7 -5
- package/components/Radio/radio.ts +2 -14
- package/components/RangeSlider/RangeSlider.astro +1 -1
- package/components/RangeSlider/RangeSlider.svelte +6 -2
- package/components/RangeSlider/RangeSlider.tsx +7 -3
- package/components/RangeSlider/rangeslider.ts +0 -9
- package/components/Rating/Rating.astro +1 -1
- package/components/Rating/Rating.svelte +3 -1
- package/components/Rating/Rating.tsx +3 -1
- package/components/Ribbon/Ribbon.astro +1 -1
- package/components/Ribbon/Ribbon.svelte +7 -2
- package/components/Ribbon/Ribbon.tsx +6 -2
- package/components/Ribbon/ribbon.ts +0 -10
- package/components/Select/Select.astro +1 -1
- package/components/Select/Select.svelte +9 -4
- package/components/Select/Select.tsx +9 -4
- package/components/Select/select.ts +1 -12
- package/components/Sheet/Sheet.astro +2 -1
- package/components/Sheet/Sheet.svelte +5 -3
- 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 +7 -2
- 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 +3 -1
- package/components/Skeleton/Skeleton.tsx +3 -1
- package/components/Slider/Slider.astro +1 -1
- package/components/Slider/Slider.svelte +8 -2
- package/components/Slider/Slider.tsx +6 -2
- package/components/Slider/slider.ts +0 -10
- package/components/SpeedDial/SpeedDial.astro +1 -1
- package/components/SpeedDial/SpeedDial.svelte +3 -1
- package/components/SpeedDial/SpeedDial.tsx +4 -2
- package/components/Spinner/Spinner.astro +1 -1
- package/components/Spinner/Spinner.svelte +3 -1
- package/components/Spinner/Spinner.tsx +3 -1
- package/components/Spoiler/Spoiler.astro +1 -1
- package/components/Spoiler/Spoiler.svelte +7 -2
- package/components/Spoiler/Spoiler.tsx +6 -2
- package/components/Spoiler/spoiler.ts +0 -10
- package/components/Stepper/Stepper.astro +1 -1
- package/components/Stepper/Stepper.svelte +3 -1
- package/components/Stepper/Stepper.tsx +3 -1
- package/components/Switch/Switch.astro +7 -2
- package/components/Switch/Switch.svelte +13 -4
- package/components/Switch/Switch.tsx +8 -4
- 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 +3 -1
- package/components/Table/Table.tsx +3 -1
- package/components/Tabs/Tabs.astro +58 -25
- package/components/Tabs/Tabs.svelte +45 -12
- 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 +10 -7
- 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 +9 -3
- package/components/ThemeSwitcher/ThemeSwitcher.tsx +7 -2
- package/components/ThemeSwitcher/themeswitcher.ts +0 -13
- package/components/Timeline/Timeline.astro +1 -1
- package/components/Timeline/Timeline.svelte +7 -2
- package/components/Timeline/Timeline.tsx +6 -2
- package/components/Timeline/timeline.ts +0 -10
- package/components/TimelineItem/TimelineItem.astro +1 -1
- package/components/TimelineItem/TimelineItem.svelte +7 -2
- package/components/TimelineItem/TimelineItem.tsx +8 -3
- package/components/TimelineItem/timelineitem.ts +0 -12
- package/components/Toast/Toast.astro +2 -1
- package/components/Toast/Toast.svelte +5 -3
- 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/svelte.d.ts +145 -138
- package/svelte.js +4 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { CarouselItemProps } from './carouselItem'
|
|
3
|
+
|
|
4
|
+
export type Props = CarouselItemProps & {
|
|
5
|
+
children: React.ReactNode
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const CarouselItem = ({
|
|
9
|
+
active,
|
|
10
|
+
className,
|
|
11
|
+
children
|
|
12
|
+
}: Props) => (
|
|
13
|
+
<li className={className} data-active={active}>
|
|
14
|
+
{children}
|
|
15
|
+
</li>
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
export default CarouselItem
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
2
3
|
import type { CheckboxProps } from './checkbox'
|
|
3
4
|
|
|
4
5
|
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.astro'
|
|
@@ -7,13 +8,11 @@ import check from '../../icons/check.svg?raw'
|
|
|
7
8
|
|
|
8
9
|
import styles from './checkbox.module.scss'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
export type Props = CheckboxProps<HTMLAttributes<'input'>>
|
|
11
12
|
|
|
12
13
|
const {
|
|
13
|
-
checked,
|
|
14
14
|
label,
|
|
15
15
|
subText,
|
|
16
|
-
disabled,
|
|
17
16
|
color,
|
|
18
17
|
className,
|
|
19
18
|
...rest
|
|
@@ -36,10 +35,8 @@ const style = color
|
|
|
36
35
|
children
|
|
37
36
|
</div>
|
|
38
37
|
<input
|
|
39
|
-
type="checkbox"
|
|
40
|
-
checked={checked}
|
|
41
|
-
disabled={disabled}
|
|
42
38
|
{...rest}
|
|
39
|
+
type="checkbox"
|
|
43
40
|
/>
|
|
44
41
|
<span class={styles.check}>
|
|
45
42
|
<Fragment set:html={check} />
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { ChangeEventHandler, HTMLInputAttributes, MouseEventHandler } from 'svelte/elements'
|
|
3
|
+
import type { CheckboxProps } from './checkbox'
|
|
3
4
|
|
|
4
5
|
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
|
|
5
6
|
|
|
@@ -9,17 +10,20 @@
|
|
|
9
10
|
|
|
10
11
|
import styles from './checkbox.module.scss'
|
|
11
12
|
|
|
13
|
+
export type Props = CheckboxProps<HTMLInputAttributes> & {
|
|
14
|
+
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
15
|
+
onClick?: MouseEventHandler<HTMLInputElement>
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
const {
|
|
13
|
-
checked,
|
|
14
19
|
label,
|
|
15
20
|
subText,
|
|
16
|
-
disabled,
|
|
17
21
|
color,
|
|
18
22
|
className,
|
|
19
23
|
onClick,
|
|
20
24
|
onChange,
|
|
21
25
|
...rest
|
|
22
|
-
}:
|
|
26
|
+
}: Props = $props()
|
|
23
27
|
|
|
24
28
|
const classes = $derived(classNames([
|
|
25
29
|
styles.checkbox,
|
|
@@ -40,12 +44,10 @@
|
|
|
40
44
|
class={styles.wrapper}
|
|
41
45
|
>
|
|
42
46
|
<input
|
|
47
|
+
{...rest}
|
|
43
48
|
type="checkbox"
|
|
44
|
-
checked={checked}
|
|
45
|
-
disabled={disabled}
|
|
46
49
|
onclick={onClick}
|
|
47
50
|
onchange={onChange}
|
|
48
|
-
{...rest}
|
|
49
51
|
/>
|
|
50
52
|
<span class={styles.check}>
|
|
51
53
|
{@html check}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { CheckboxProps } from './checkbox'
|
|
3
3
|
|
|
4
4
|
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
5
5
|
|
|
@@ -9,15 +9,19 @@ import check from '../../icons/check.svg?raw'
|
|
|
9
9
|
|
|
10
10
|
import styles from './checkbox.module.scss'
|
|
11
11
|
|
|
12
|
+
export type Props = CheckboxProps<React.InputHTMLAttributes<HTMLInputElement>> & {
|
|
13
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>
|
|
14
|
+
onClick?: React.MouseEventHandler<HTMLInputElement>
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
const Checkbox = ({
|
|
13
18
|
checked,
|
|
14
19
|
label,
|
|
15
20
|
subText,
|
|
16
|
-
disabled,
|
|
17
21
|
color,
|
|
18
22
|
className,
|
|
19
23
|
...rest
|
|
20
|
-
}:
|
|
24
|
+
}: Props) => {
|
|
21
25
|
const classes = classNames([
|
|
22
26
|
styles.checkbox,
|
|
23
27
|
label && subText && styles.col,
|
|
@@ -39,10 +43,9 @@ const Checkbox = ({
|
|
|
39
43
|
)}
|
|
40
44
|
>
|
|
41
45
|
<input
|
|
46
|
+
{...rest}
|
|
42
47
|
type="checkbox"
|
|
43
48
|
defaultChecked={checked}
|
|
44
|
-
disabled={disabled}
|
|
45
|
-
{...rest}
|
|
46
49
|
/>
|
|
47
50
|
<span
|
|
48
51
|
className={styles.check}
|
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type CheckboxProps = {
|
|
4
|
-
checked?: boolean
|
|
1
|
+
export type CheckboxProps<T extends object = object> = {
|
|
5
2
|
label?: string
|
|
6
3
|
subText?: string
|
|
7
|
-
disabled?: boolean
|
|
8
4
|
color?: string
|
|
9
5
|
className?: string
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type SvelteCheckboxProps = {
|
|
14
|
-
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
15
|
-
onClick?: MouseEventHandler<HTMLInputElement>
|
|
16
|
-
} & CheckboxProps
|
|
17
|
-
|
|
18
|
-
export type ReactCheckboxProps = {
|
|
19
|
-
onChange?: React.ChangeEventHandler<HTMLInputElement>
|
|
20
|
-
onClick?: React.MouseEventHandler<HTMLInputElement>
|
|
21
|
-
} & CheckboxProps
|
|
6
|
+
} & T
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { CollapsibleProps } from './collapsible'
|
|
3
4
|
|
|
4
5
|
import { classNames } from '../../utils/classNames'
|
|
5
6
|
|
|
6
7
|
import styles from './collapsible.module.scss'
|
|
7
8
|
|
|
9
|
+
export type Props = CollapsibleProps & {
|
|
10
|
+
on: Snippet
|
|
11
|
+
off: Snippet
|
|
12
|
+
children: Snippet
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
let {
|
|
9
16
|
initialHeight,
|
|
10
17
|
maxHeight,
|
|
@@ -14,7 +21,7 @@
|
|
|
14
21
|
children,
|
|
15
22
|
off,
|
|
16
23
|
on
|
|
17
|
-
}:
|
|
24
|
+
}: Props = $props()
|
|
18
25
|
|
|
19
26
|
const classes = $derived(classNames([
|
|
20
27
|
styles.collapsible,
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { CollapsibleProps } from './collapsible'
|
|
3
3
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
|
|
6
6
|
import styles from './collapsible.module.scss'
|
|
7
7
|
|
|
8
|
+
export type Props = CollapsibleProps & {
|
|
9
|
+
on: React.ReactNode
|
|
10
|
+
off: React.ReactNode
|
|
11
|
+
children: React.ReactNode
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
const Collapsible = ({
|
|
9
15
|
initialHeight,
|
|
10
16
|
maxHeight,
|
|
@@ -14,7 +20,7 @@ const Collapsible = ({
|
|
|
14
20
|
children,
|
|
15
21
|
className,
|
|
16
22
|
togglesClassName
|
|
17
|
-
}:
|
|
23
|
+
}: Props) => {
|
|
18
24
|
const [toggle, setToggled] = useState(toggled)
|
|
19
25
|
|
|
20
26
|
const classes = classNames([
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte'
|
|
2
|
-
|
|
3
1
|
export type CollapsibleProps = {
|
|
4
2
|
initialHeight?: string
|
|
5
3
|
maxHeight?: string
|
|
@@ -7,16 +5,3 @@ export type CollapsibleProps = {
|
|
|
7
5
|
className?: string
|
|
8
6
|
togglesClassName?: string
|
|
9
7
|
}
|
|
10
|
-
|
|
11
|
-
export type SvelteCollapsibleProps = {
|
|
12
|
-
on: Snippet
|
|
13
|
-
off: Snippet
|
|
14
|
-
children: Snippet
|
|
15
|
-
} & CollapsibleProps
|
|
16
|
-
|
|
17
|
-
export type ReactCollapsibleProps = {
|
|
18
|
-
on: React.ReactNode
|
|
19
|
-
off: React.ReactNode
|
|
20
|
-
children: React.ReactNode
|
|
21
|
-
} & CollapsibleProps
|
|
22
|
-
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { ConditionalWrapperProps } from './conditionalwrapper'
|
|
4
|
+
|
|
5
|
+
export type Props = ConditionalWrapperProps & {
|
|
6
|
+
children: Snippet
|
|
7
|
+
element?: string
|
|
8
|
+
}
|
|
3
9
|
|
|
4
10
|
const {
|
|
5
11
|
condition,
|
|
6
12
|
element = 'div',
|
|
7
13
|
children,
|
|
8
14
|
...rest
|
|
9
|
-
}:
|
|
15
|
+
}: Props = $props()
|
|
10
16
|
</script>
|
|
11
17
|
|
|
12
18
|
{#if condition}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ConditionalWrapperProps } from './conditionalwrapper'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export type Props = ConditionalWrapperProps & {
|
|
4
|
+
wrapper: (_: React.ReactNode) => any
|
|
5
|
+
children: React.ReactNode
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const ConditionalWrapper = ({ condition, wrapper, children }: Props) =>
|
|
4
9
|
condition ? wrapper(children) : children
|
|
5
10
|
|
|
6
11
|
export default ConditionalWrapper
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type ConditionalWrapperProps = {
|
|
1
|
+
export type ConditionalWrapperProps<T extends object = Record<string, unknown>> = {
|
|
4
2
|
condition: boolean
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type SvelteConditionalWrapperProps = {
|
|
9
|
-
children: Snippet
|
|
10
|
-
} & ConditionalWrapperProps
|
|
11
|
-
|
|
12
|
-
export type ReactConditionalWrapperProps = {
|
|
13
|
-
wrapper: (_: React.ReactNode) => any
|
|
14
|
-
children: React.ReactNode
|
|
15
|
-
} & ConditionalWrapperProps
|
|
3
|
+
} & T
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
2
3
|
import type { ContextMenuProps } from './contextmenu'
|
|
3
4
|
|
|
4
5
|
import { classNames } from '../../utils/classNames'
|
|
5
6
|
|
|
6
7
|
import styles from './contextmenu.module.scss'
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
export type Props = ContextMenuProps<HTMLAttributes<'div'>>
|
|
9
10
|
|
|
10
11
|
const {
|
|
11
12
|
element = 'div',
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { onMount } from 'svelte'
|
|
3
|
-
import type {
|
|
2
|
+
import { onMount, type Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
4
|
+
import type { ContextMenuProps } from './contextmenu'
|
|
4
5
|
|
|
5
6
|
import { classNames } from '../../utils/classNames'
|
|
6
7
|
import { on } from '../../utils/DOMUtils'
|
|
7
8
|
|
|
8
9
|
import styles from './contextmenu.module.scss'
|
|
9
10
|
|
|
11
|
+
export type Props = ContextMenuProps<HTMLAttributes<HTMLElement>> & {
|
|
12
|
+
children: Snippet
|
|
13
|
+
context: Snippet
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
const {
|
|
11
17
|
element = 'div',
|
|
12
18
|
className,
|
|
13
19
|
children,
|
|
14
20
|
context,
|
|
15
21
|
...rest
|
|
16
|
-
}:
|
|
22
|
+
}: Props = $props()
|
|
17
23
|
|
|
18
24
|
const classes = $derived(classNames([
|
|
19
25
|
styles.ctx,
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { ContextMenuProps } from './contextmenu'
|
|
3
3
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
import { on } from '../../utils/DOMUtils'
|
|
6
6
|
|
|
7
7
|
import styles from './contextmenu.module.scss'
|
|
8
8
|
|
|
9
|
+
export type Props = Omit<ContextMenuProps, 'element'> & {
|
|
10
|
+
Element?: React.ElementType
|
|
11
|
+
children: React.ReactNode
|
|
12
|
+
context: React.ReactNode
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
const ContextMenu = ({
|
|
10
16
|
Element = 'div',
|
|
11
17
|
className,
|
|
12
18
|
children,
|
|
13
19
|
context,
|
|
14
20
|
...rest
|
|
15
|
-
}:
|
|
21
|
+
}: Props) => {
|
|
16
22
|
const ctx = useRef<HTMLElement>(null)
|
|
17
23
|
const content = useRef<HTMLDivElement>(null)
|
|
18
24
|
const classes = classNames([
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type { Snippet } from 'svelte'
|
|
3
|
-
|
|
4
|
-
export type ContextMenuProps = {
|
|
1
|
+
export type ContextMenuProps<T extends object = object> = {
|
|
5
2
|
element?: string
|
|
6
3
|
className?: string
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type SvelteContextMenuProps = {
|
|
11
|
-
children: Snippet
|
|
12
|
-
context: Snippet
|
|
13
|
-
} & ContextMenuProps
|
|
14
|
-
|
|
15
|
-
export type ReactContextMenuProps = {
|
|
16
|
-
Element?: React.ElementType
|
|
17
|
-
children: React.ReactNode
|
|
18
|
-
context: React.ReactNode
|
|
19
|
-
} & Omit<ContextMenuProps, 'element'>
|
|
4
|
+
} & T
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { CopyProps } from './copy'
|
|
3
3
|
|
|
4
|
-
import Badge from '../Badge/Badge.astro'
|
|
4
|
+
import Badge, { type Props as BadgeProps } from '../Badge/Badge.astro'
|
|
5
5
|
import Icon from '../Icon/Icon.astro'
|
|
6
6
|
|
|
7
7
|
import { classNames } from '../../utils/classNames'
|
|
8
8
|
|
|
9
9
|
import styles from './copy.module.scss'
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
export type Props = CopyProps<BadgeProps>
|
|
12
12
|
|
|
13
13
|
const {
|
|
14
14
|
tooltip,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { CopyProps } from './copy'
|
|
3
4
|
|
|
4
|
-
import Badge from '../Badge/Badge.svelte'
|
|
5
|
+
import Badge, { type Props as BadgeProps } from '../Badge/Badge.svelte'
|
|
5
6
|
|
|
6
7
|
import { classNames } from '../../utils/classNames'
|
|
7
8
|
|
|
@@ -10,6 +11,10 @@
|
|
|
10
11
|
|
|
11
12
|
import styles from './copy.module.scss'
|
|
12
13
|
|
|
14
|
+
export type Props = CopyProps<BadgeProps> & {
|
|
15
|
+
children: Snippet
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
let {
|
|
14
19
|
tooltip = $bindable(''),
|
|
15
20
|
tooltipPosition,
|
|
@@ -18,7 +23,7 @@
|
|
|
18
23
|
className,
|
|
19
24
|
children,
|
|
20
25
|
...rest
|
|
21
|
-
}:
|
|
26
|
+
}: Props = $props()
|
|
22
27
|
|
|
23
28
|
const classes = $derived(classNames([
|
|
24
29
|
styles.copy,
|
package/components/Copy/Copy.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useRef, useState } from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { CopyProps } from './copy'
|
|
3
3
|
|
|
4
|
-
import Badge from '../Badge/Badge.tsx'
|
|
4
|
+
import Badge, { type Props as BadgeProps } from '../Badge/Badge.tsx'
|
|
5
5
|
|
|
6
6
|
import { classNames } from '../../utils/classNames'
|
|
7
7
|
|
|
@@ -10,6 +10,10 @@ import copy from '../../icons/copy.svg?raw'
|
|
|
10
10
|
|
|
11
11
|
import styles from './copy.module.scss'
|
|
12
12
|
|
|
13
|
+
export type Props = CopyProps<BadgeProps> & {
|
|
14
|
+
children: React.ReactNode
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
const Copy = ({
|
|
14
18
|
tooltip,
|
|
15
19
|
tooltipPosition,
|
|
@@ -18,7 +22,7 @@ const Copy = ({
|
|
|
18
22
|
className,
|
|
19
23
|
children,
|
|
20
24
|
...rest
|
|
21
|
-
}:
|
|
25
|
+
}: Props) => {
|
|
22
26
|
const copyButton = useRef<HTMLButtonElement>(null)
|
|
23
27
|
const copiedButton = useRef<HTMLSpanElement>(null)
|
|
24
28
|
const [tooltipText, setTooltipText] = useState(tooltip)
|
package/components/Copy/copy.ts
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte'
|
|
2
|
-
|
|
3
1
|
import type { BadgeProps } from '../Badge/badge'
|
|
4
2
|
import type { IconProps } from '../Icon/icon'
|
|
5
3
|
|
|
6
|
-
export type CopyProps = {
|
|
4
|
+
export type CopyProps<T extends object = object> = {
|
|
7
5
|
tooltip?: string
|
|
8
6
|
tooltipPosition?: 'left' | 'right' | 'bottom' | null
|
|
9
7
|
copyIcon?: IconProps['type'] | string
|
|
10
8
|
copiedIcon?: IconProps['type'] | string
|
|
11
9
|
className?: string
|
|
12
|
-
} & BadgeProps
|
|
13
|
-
|
|
14
|
-
export type SvelteCopyProps = {
|
|
15
|
-
children: Snippet
|
|
16
|
-
} & CopyProps
|
|
17
|
-
|
|
18
|
-
export type ReactCopyProps = {
|
|
19
|
-
children: React.ReactNode
|
|
20
|
-
} & CopyProps
|
|
10
|
+
} & BadgeProps<T>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
2
3
|
import type { CounterProps } from './counter'
|
|
3
4
|
|
|
4
5
|
import Icon from '../Icon/Icon.astro'
|
|
@@ -8,7 +9,7 @@ import plusIcon from '../../icons/plus.svg?raw'
|
|
|
8
9
|
|
|
9
10
|
import styles from './counter.module.scss'
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
export type Props = CounterProps<HTMLAttributes<'input'>>
|
|
12
13
|
|
|
13
14
|
const {
|
|
14
15
|
type = 'compact',
|
|
@@ -49,10 +50,10 @@ const styleVariable = width
|
|
|
49
50
|
</Fragment>
|
|
50
51
|
</button>
|
|
51
52
|
<input
|
|
53
|
+
{...rest}
|
|
52
54
|
type="number"
|
|
53
55
|
value={value}
|
|
54
56
|
disabled={disabled}
|
|
55
|
-
{...rest}
|
|
56
57
|
/>
|
|
57
58
|
<button data-id="w-counter-max" disabled={disabled}>
|
|
58
59
|
<Fragment>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
3
|
+
import type { CounterProps } from './counter'
|
|
3
4
|
|
|
4
5
|
import { classNames } from '../../utils/classNames'
|
|
5
6
|
|
|
@@ -8,6 +9,10 @@
|
|
|
8
9
|
|
|
9
10
|
import styles from './counter.module.scss'
|
|
10
11
|
|
|
12
|
+
export type Props = CounterProps<HTMLInputAttributes> & {
|
|
13
|
+
onChange?: (value: number) => void
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
let {
|
|
12
17
|
type = 'compact',
|
|
13
18
|
theme,
|
|
@@ -23,7 +28,7 @@
|
|
|
23
28
|
min,
|
|
24
29
|
max,
|
|
25
30
|
...rest
|
|
26
|
-
}:
|
|
31
|
+
}: Props = $props()
|
|
27
32
|
|
|
28
33
|
const classes = $derived(classNames([
|
|
29
34
|
styles.counter,
|
|
@@ -48,9 +53,9 @@
|
|
|
48
53
|
|
|
49
54
|
const updateValue = (isMin?: boolean) => {
|
|
50
55
|
const direction = isMin ? -1 : 1
|
|
51
|
-
const newValue = value + (direction * step)
|
|
56
|
+
const newValue = value + (direction * Number(step))
|
|
52
57
|
|
|
53
|
-
if ((min !== undefined && newValue < min) || (max !== undefined && newValue > max)) {
|
|
58
|
+
if ((min !== undefined && newValue < Number(min)) || (max !== undefined && newValue > Number(max))) {
|
|
54
59
|
return
|
|
55
60
|
}
|
|
56
61
|
|
|
@@ -116,6 +121,7 @@
|
|
|
116
121
|
{@html subtractIcon}
|
|
117
122
|
</button>
|
|
118
123
|
<input
|
|
124
|
+
{...rest}
|
|
119
125
|
bind:value={value}
|
|
120
126
|
type="number"
|
|
121
127
|
disabled={disabled}
|
|
@@ -123,7 +129,6 @@
|
|
|
123
129
|
min={min}
|
|
124
130
|
max={max}
|
|
125
131
|
oninput={() => onChange?.(value)}
|
|
126
|
-
{...rest}
|
|
127
132
|
/>
|
|
128
133
|
<button
|
|
129
134
|
data-id="w-counter-max"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useRef, useState } from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { CounterProps } from './counter'
|
|
3
3
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
|
|
@@ -8,6 +8,10 @@ import plusIcon from '../../icons/plus.svg?raw'
|
|
|
8
8
|
|
|
9
9
|
import styles from './counter.module.scss'
|
|
10
10
|
|
|
11
|
+
export type Props = CounterProps<Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'>> & {
|
|
12
|
+
onChange?: (value: number) => void
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
const Counter = ({
|
|
12
16
|
type = 'compact',
|
|
13
17
|
theme,
|
|
@@ -23,8 +27,8 @@ const Counter = ({
|
|
|
23
27
|
min,
|
|
24
28
|
max,
|
|
25
29
|
...rest
|
|
26
|
-
}:
|
|
27
|
-
const [inputValue, setInputValue] = useState(value)
|
|
30
|
+
}: Props) => {
|
|
31
|
+
const [inputValue, setInputValue] = useState<number>(Number(value))
|
|
28
32
|
const intervalId = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
29
33
|
const timeoutId = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
30
34
|
const longPressDelay = useRef(500)
|
|
@@ -48,9 +52,9 @@ const Counter = ({
|
|
|
48
52
|
const updateValue = (isMin?: boolean) => {
|
|
49
53
|
setInputValue((prevValue: number) => {
|
|
50
54
|
const direction = isMin ? -1 : 1
|
|
51
|
-
const newValue = prevValue + (direction * step)
|
|
55
|
+
const newValue = prevValue + (direction * Number(step))
|
|
52
56
|
|
|
53
|
-
if ((min !== undefined && newValue < min) || (max !== undefined && newValue > max)) {
|
|
57
|
+
if ((min !== undefined && newValue < Number(min)) || (max !== undefined && newValue > Number(max))) {
|
|
54
58
|
return prevValue
|
|
55
59
|
}
|
|
56
60
|
|
|
@@ -104,7 +108,7 @@ const Counter = ({
|
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
110
|
|
|
107
|
-
const handleInput = (event: React.
|
|
111
|
+
const handleInput = (event: React.InputEvent<HTMLInputElement>) => {
|
|
108
112
|
const target = event.target
|
|
109
113
|
|
|
110
114
|
if (target instanceof HTMLInputElement) {
|
|
@@ -131,6 +135,7 @@ const Counter = ({
|
|
|
131
135
|
dangerouslySetInnerHTML={{ __html: subtractIcon }}
|
|
132
136
|
/>
|
|
133
137
|
<input
|
|
138
|
+
{...rest}
|
|
134
139
|
value={inputValue}
|
|
135
140
|
type="number"
|
|
136
141
|
disabled={disabled}
|
|
@@ -138,7 +143,6 @@ const Counter = ({
|
|
|
138
143
|
min={min}
|
|
139
144
|
max={max}
|
|
140
145
|
onInput={handleInput}
|
|
141
|
-
{...rest}
|
|
142
146
|
/>
|
|
143
147
|
<button
|
|
144
148
|
data-id="w-counter-max"
|