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,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,22 +28,23 @@
|
|
|
23
28
|
min,
|
|
24
29
|
max,
|
|
25
30
|
...rest
|
|
26
|
-
}:
|
|
31
|
+
}: Props = $props()
|
|
27
32
|
|
|
28
|
-
const classes = classNames([
|
|
33
|
+
const classes = $derived(classNames([
|
|
29
34
|
styles.counter,
|
|
30
35
|
styles[type],
|
|
31
36
|
theme && styles[theme],
|
|
32
37
|
rounded && styles.rounded,
|
|
33
38
|
className
|
|
34
|
-
])
|
|
39
|
+
]))
|
|
35
40
|
|
|
36
|
-
const subtractIcon = minIcon || minusIcon
|
|
37
|
-
const addIcon = maxIcon || plusIcon
|
|
41
|
+
const subtractIcon = $derived(minIcon || minusIcon)
|
|
42
|
+
const addIcon = $derived(maxIcon || plusIcon)
|
|
38
43
|
|
|
39
|
-
const styleVariable = width
|
|
44
|
+
const styleVariable = $derived(width
|
|
40
45
|
? `--w-counter-width: ${width};`
|
|
41
46
|
: null
|
|
47
|
+
)
|
|
42
48
|
|
|
43
49
|
let intervalId: ReturnType<typeof setTimeout>
|
|
44
50
|
let timeoutId: ReturnType<typeof setTimeout>
|
|
@@ -47,9 +53,9 @@
|
|
|
47
53
|
|
|
48
54
|
const updateValue = (isMin?: boolean) => {
|
|
49
55
|
const direction = isMin ? -1 : 1
|
|
50
|
-
const newValue = value + (direction * step)
|
|
56
|
+
const newValue = value + (direction * Number(step))
|
|
51
57
|
|
|
52
|
-
if ((min !== undefined && newValue < min) || (max !== undefined && newValue > max)) {
|
|
58
|
+
if ((min !== undefined && newValue < Number(min)) || (max !== undefined && newValue > Number(max))) {
|
|
53
59
|
return
|
|
54
60
|
}
|
|
55
61
|
|
|
@@ -115,6 +121,7 @@
|
|
|
115
121
|
{@html subtractIcon}
|
|
116
122
|
</button>
|
|
117
123
|
<input
|
|
124
|
+
{...rest}
|
|
118
125
|
bind:value={value}
|
|
119
126
|
type="number"
|
|
120
127
|
disabled={disabled}
|
|
@@ -122,7 +129,6 @@
|
|
|
122
129
|
min={min}
|
|
123
130
|
max={max}
|
|
124
131
|
oninput={() => onChange?.(value)}
|
|
125
|
-
{...rest}
|
|
126
132
|
/>
|
|
127
133
|
<button
|
|
128
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"
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
@use '../../scss/config.scss' as *;
|
|
2
2
|
|
|
3
|
-
body {
|
|
4
|
-
--w-counter-width: 10ch;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
3
|
.counter {
|
|
4
|
+
--width: var(--w-counter-width, 10ch);
|
|
5
|
+
|
|
8
6
|
@include layout(inline-flex);
|
|
9
7
|
@include border(primary-50);
|
|
10
8
|
@include border-radius();
|
|
@@ -139,7 +137,7 @@ body {
|
|
|
139
137
|
@include spacing(p-xs);
|
|
140
138
|
|
|
141
139
|
flex: 1;
|
|
142
|
-
width: var(--
|
|
140
|
+
width: var(--width);
|
|
143
141
|
appearance: none;
|
|
144
142
|
-moz-appearance: textfield;
|
|
145
143
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ButtonProps } from '../Button/button'
|
|
2
2
|
import type { IconProps } from '../Icon/icon'
|
|
3
3
|
|
|
4
|
-
export type CounterProps = {
|
|
4
|
+
export type CounterProps<T extends object = object> = {
|
|
5
5
|
type?: 'compact' | 'buttons' | 'separated'
|
|
6
6
|
theme?: ButtonProps['theme']
|
|
7
7
|
rounded?: boolean
|
|
@@ -9,13 +9,4 @@ export type CounterProps = {
|
|
|
9
9
|
maxIcon?: IconProps['type'] | string
|
|
10
10
|
width?: string
|
|
11
11
|
className?: string
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type SvelteCounterProps = {
|
|
16
|
-
onChange?: (value: number) => void
|
|
17
|
-
} & CounterProps
|
|
18
|
-
|
|
19
|
-
export type ReactCounterProps = {
|
|
20
|
-
onChange?: (value: number) => void
|
|
21
|
-
} & CounterProps
|
|
12
|
+
} & T
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { DataTableEventType, DataTableProps, HeadingObject } from './datatable'
|
|
3
4
|
|
|
4
5
|
import Button from '../Button/Button.svelte'
|
|
5
6
|
import Input from '../Input/Input.svelte'
|
|
@@ -17,6 +18,11 @@
|
|
|
17
18
|
|
|
18
19
|
import type { ListEventType } from '../List/list'
|
|
19
20
|
|
|
21
|
+
export type Props = DataTableProps & {
|
|
22
|
+
onFilter?: (event: DataTableEventType) => void
|
|
23
|
+
children?: Snippet
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
const {
|
|
21
27
|
headings,
|
|
22
28
|
filterPlaceholder = 'Filter entries',
|
|
@@ -36,34 +42,34 @@
|
|
|
36
42
|
id,
|
|
37
43
|
onFilter,
|
|
38
44
|
children
|
|
39
|
-
}:
|
|
45
|
+
}: Props = $props()
|
|
40
46
|
|
|
41
|
-
let filteredData: any = $
|
|
42
|
-
let toggledData: any = $
|
|
43
|
-
let filteredHeadings: any = $
|
|
47
|
+
let filteredData: any = $derived(data)
|
|
48
|
+
let toggledData: any = $derived(data)
|
|
49
|
+
let filteredHeadings: any = $derived(headings)
|
|
44
50
|
let page: number = $state(1)
|
|
45
51
|
let hasActiveFilter: boolean = $state(false)
|
|
46
52
|
let sortOrder = 1
|
|
47
53
|
|
|
48
|
-
const classes = classNames([
|
|
54
|
+
const classes = $derived(classNames([
|
|
49
55
|
styles.table,
|
|
50
56
|
hover && styles.hover,
|
|
51
57
|
striped && styles[`striped-${striped}s`],
|
|
52
58
|
offsetStripe && styles.offset,
|
|
53
59
|
compact && styles.compact,
|
|
54
60
|
maxHeight && styles.scroll
|
|
55
|
-
])
|
|
61
|
+
]))
|
|
56
62
|
|
|
57
|
-
const footerClasses = classNames([
|
|
63
|
+
const footerClasses = $derived(classNames([
|
|
58
64
|
styles.footer,
|
|
59
65
|
subText && styles.between
|
|
60
|
-
])
|
|
66
|
+
]))
|
|
61
67
|
|
|
62
|
-
const showColumnToggle = headings?.some(heading => {
|
|
68
|
+
const showColumnToggle = $derived(headings?.some(heading => {
|
|
63
69
|
return typeof heading === 'string' ? false : heading.toggleable
|
|
64
|
-
})
|
|
70
|
+
}))
|
|
65
71
|
|
|
66
|
-
const columnToggleItems = [{
|
|
72
|
+
const columnToggleItems = $derived([{
|
|
67
73
|
items: headings?.length ? headings
|
|
68
74
|
.filter(heading => typeof heading !== 'string' && heading.toggleable)
|
|
69
75
|
.map(heading => ({
|
|
@@ -73,15 +79,17 @@
|
|
|
73
79
|
return (h as HeadingObject).name === (heading as HeadingObject).name
|
|
74
80
|
}))
|
|
75
81
|
})) : []
|
|
76
|
-
}]
|
|
82
|
+
}])
|
|
77
83
|
|
|
78
|
-
const columnFilterIndexes = headings?.map(heading => (heading as HeadingObject).filterable)
|
|
84
|
+
const columnFilterIndexes = $derived(headings?.map(heading => (heading as HeadingObject).filterable)
|
|
79
85
|
.map((heading, index) => heading ? index : null)
|
|
80
86
|
.filter(heading => heading !== null) || []
|
|
87
|
+
)
|
|
81
88
|
|
|
82
|
-
const hasPagination = data?.length && itemsPerPage
|
|
89
|
+
const hasPagination = $derived(data?.length && itemsPerPage
|
|
83
90
|
? data.length > itemsPerPage
|
|
84
91
|
: false
|
|
92
|
+
)
|
|
85
93
|
|
|
86
94
|
const filter = debounce((event: Event) => {
|
|
87
95
|
const target = event.target as HTMLInputElement
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { DataTableEventType, DataTableProps, HeadingObject } from './datatable'
|
|
3
3
|
|
|
4
4
|
import Button from '../Button/Button.tsx'
|
|
5
5
|
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
@@ -18,6 +18,11 @@ import styles from './datatable.module.scss'
|
|
|
18
18
|
|
|
19
19
|
import type { ListEventType } from '../List/list'
|
|
20
20
|
|
|
21
|
+
export type Props = DataTableProps & {
|
|
22
|
+
onFilter?: (event: DataTableEventType) => void
|
|
23
|
+
children?: React.ReactNode
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
const DataTable = ({
|
|
22
27
|
headings,
|
|
23
28
|
filterPlaceholder = 'Filter entries',
|
|
@@ -38,7 +43,7 @@ const DataTable = ({
|
|
|
38
43
|
onFilter,
|
|
39
44
|
children
|
|
40
45
|
// eslint-disable-next-line complexity
|
|
41
|
-
}:
|
|
46
|
+
}: Props) => {
|
|
42
47
|
const [filteredData, setFilteredData] = useState<any>(data)
|
|
43
48
|
const [toggledData, setToggledData] = useState(filteredData)
|
|
44
49
|
const [filteredHeadings, setFilteredHeadings] = useState<any>(headings)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte'
|
|
2
|
-
|
|
3
1
|
import type { PaginationProps } from '../Pagination/pagination'
|
|
4
2
|
|
|
5
3
|
export type DataTableEventType = {
|
|
@@ -32,13 +30,3 @@ export type DataTableProps = {
|
|
|
32
30
|
className?: string
|
|
33
31
|
id?: string
|
|
34
32
|
}
|
|
35
|
-
|
|
36
|
-
export type SvelteDataTableProps = {
|
|
37
|
-
onFilter?: (event: DataTableEventType) => void
|
|
38
|
-
children?: Snippet
|
|
39
|
-
} & DataTableProps
|
|
40
|
-
|
|
41
|
-
export type ReactDataTableProps = {
|
|
42
|
-
onFilter?: (event: DataTableEventType) => void
|
|
43
|
-
children?: React.ReactNode
|
|
44
|
-
} & DataTableProps
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
2
3
|
import type { FlexProps } from './flex'
|
|
3
4
|
|
|
4
5
|
import { classNames } from '../../utils/classNames'
|
|
5
6
|
import { getLayoutClasses } from '../../utils/getLayoutClasses'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
export type Props = FlexProps<HTMLAttributes<'div'>>
|
|
8
9
|
|
|
9
10
|
const {
|
|
10
11
|
element = 'div',
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
4
|
+
import type { FlexProps } from './flex'
|
|
3
5
|
|
|
4
6
|
import { classNames } from '../../utils/classNames'
|
|
5
7
|
import { getLayoutClasses } from '../../utils/getLayoutClasses'
|
|
6
8
|
|
|
9
|
+
export type Props = FlexProps<HTMLAttributes<HTMLElement>> & {
|
|
10
|
+
children: Snippet
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
const {
|
|
8
14
|
element = 'div',
|
|
9
15
|
gap,
|
|
@@ -13,17 +19,17 @@
|
|
|
13
19
|
className,
|
|
14
20
|
children,
|
|
15
21
|
...rest
|
|
16
|
-
}:
|
|
22
|
+
}: Props = $props()
|
|
17
23
|
|
|
18
|
-
const classes = classNames([
|
|
24
|
+
const classes = $derived(classNames([
|
|
19
25
|
'flex',
|
|
20
26
|
getLayoutClasses({ gap, alignment, direction, wrap }),
|
|
21
27
|
className
|
|
22
|
-
])
|
|
28
|
+
]))
|
|
23
29
|
|
|
24
|
-
const componentProps = {
|
|
30
|
+
const componentProps = $derived({
|
|
25
31
|
class: classes
|
|
26
|
-
}
|
|
32
|
+
})
|
|
27
33
|
</script>
|
|
28
34
|
|
|
29
35
|
<svelte:element this={element} {...componentProps} {...rest}>
|
package/components/Flex/Flex.tsx
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import type {
|
|
1
|
+
import React, { type JSX } from 'react'
|
|
2
|
+
import type { FlexProps } from './flex'
|
|
3
3
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
import { getLayoutClasses } from '../../utils/getLayoutClasses'
|
|
6
6
|
|
|
7
|
+
export type Props = Omit<FlexProps, 'element'> & {
|
|
8
|
+
Element?: keyof JSX.IntrinsicElements
|
|
9
|
+
children: React.ReactNode
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
const Flex = ({
|
|
8
13
|
Element = 'div',
|
|
9
14
|
gap,
|
|
@@ -13,7 +18,7 @@ const Flex = ({
|
|
|
13
18
|
className,
|
|
14
19
|
children,
|
|
15
20
|
...rest
|
|
16
|
-
}:
|
|
21
|
+
}: Props) => {
|
|
17
22
|
const classes = classNames([
|
|
18
23
|
'flex',
|
|
19
24
|
getLayoutClasses({ gap, alignment, direction, wrap }),
|
package/components/Flex/flex.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import type { JSX } from 'react'
|
|
2
|
-
import type { Snippet } from 'svelte'
|
|
3
|
-
|
|
4
1
|
import type {
|
|
5
2
|
Alignment,
|
|
6
3
|
Direction,
|
|
@@ -9,21 +6,11 @@ import type {
|
|
|
9
6
|
Wrap
|
|
10
7
|
} from '../../utils/getLayoutClasses'
|
|
11
8
|
|
|
12
|
-
export type FlexProps = {
|
|
9
|
+
export type FlexProps<T extends object = object> = {
|
|
13
10
|
element?: string
|
|
14
11
|
gap?: Responsive<Gap>
|
|
15
12
|
alignment?: Responsive<Alignment>
|
|
16
13
|
direction?: Responsive<Direction>
|
|
17
14
|
wrap?: Responsive<Wrap>
|
|
18
15
|
className?: string
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type SvelteFlexProps = {
|
|
23
|
-
children: Snippet
|
|
24
|
-
} & FlexProps
|
|
25
|
-
|
|
26
|
-
export type ReactFlexProps = {
|
|
27
|
-
Element?: keyof JSX.IntrinsicElements
|
|
28
|
-
children: React.ReactNode
|
|
29
|
-
} & Omit<FlexProps, 'element'>
|
|
16
|
+
} & T
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { FooterProps } from './footer'
|
|
3
4
|
|
|
4
5
|
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
|
|
5
6
|
|
|
@@ -7,6 +8,10 @@
|
|
|
7
8
|
|
|
8
9
|
import styles from './footer.module.scss'
|
|
9
10
|
|
|
11
|
+
export type Props = FooterProps & {
|
|
12
|
+
children?: Snippet
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
const {
|
|
11
16
|
logo,
|
|
12
17
|
columns,
|
|
@@ -15,22 +20,22 @@
|
|
|
15
20
|
wrapperClassName,
|
|
16
21
|
subTextClassName,
|
|
17
22
|
children
|
|
18
|
-
}:
|
|
23
|
+
}: Props = $props()
|
|
19
24
|
|
|
20
|
-
const classes = classNames([
|
|
25
|
+
const classes = $derived(classNames([
|
|
21
26
|
styles.footer,
|
|
22
27
|
className
|
|
23
|
-
])
|
|
28
|
+
]))
|
|
24
29
|
|
|
25
|
-
const containerClasses = classNames([
|
|
30
|
+
const containerClasses = $derived(classNames([
|
|
26
31
|
styles.container,
|
|
27
32
|
wrapperClassName
|
|
28
|
-
])
|
|
33
|
+
]))
|
|
29
34
|
|
|
30
|
-
const subTextClasses = classNames([
|
|
35
|
+
const subTextClasses = $derived(classNames([
|
|
31
36
|
styles.subtext,
|
|
32
37
|
subTextClassName
|
|
33
|
-
])
|
|
38
|
+
]))
|
|
34
39
|
</script>
|
|
35
40
|
|
|
36
41
|
<footer class={classes}>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { FooterProps } from './footer'
|
|
3
3
|
|
|
4
4
|
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
5
5
|
|
|
@@ -7,6 +7,10 @@ import { classNames } from '../../utils/classNames'
|
|
|
7
7
|
|
|
8
8
|
import styles from './footer.module.scss'
|
|
9
9
|
|
|
10
|
+
export type Props = FooterProps & {
|
|
11
|
+
children?: React.ReactNode
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
const Footer = ({
|
|
11
15
|
logo,
|
|
12
16
|
columns,
|
|
@@ -15,7 +19,7 @@ const Footer = ({
|
|
|
15
19
|
wrapperClassName,
|
|
16
20
|
subTextClassName,
|
|
17
21
|
children
|
|
18
|
-
}:
|
|
22
|
+
}: Props) => {
|
|
19
23
|
const classes = classNames([
|
|
20
24
|
styles.footer,
|
|
21
25
|
className
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte'
|
|
2
|
-
|
|
3
1
|
import type { ButtonProps } from '../Button/button'
|
|
4
2
|
|
|
5
3
|
export type FooterProps = {
|
|
@@ -25,11 +23,3 @@ export type FooterProps = {
|
|
|
25
23
|
wrapperClassName?: string
|
|
26
24
|
subTextClassName?: string
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
export type SvelteFooterProps = {
|
|
30
|
-
children?: Snippet
|
|
31
|
-
} & FooterProps
|
|
32
|
-
|
|
33
|
-
export type ReactFooterProps = {
|
|
34
|
-
children?: React.ReactNode
|
|
35
|
-
} & FooterProps
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
2
3
|
import type { GridProps } from './grid'
|
|
3
4
|
|
|
4
5
|
import { classNames } from '../../utils/classNames'
|
|
5
6
|
import { getLayoutClasses } from '../../utils/getLayoutClasses'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
export type Props = GridProps<HTMLAttributes<'div'>>
|
|
8
9
|
|
|
9
10
|
const {
|
|
10
11
|
element = 'div',
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
4
|
+
import type { GridProps } from './grid'
|
|
3
5
|
|
|
4
6
|
import { classNames } from '../../utils/classNames'
|
|
5
7
|
import { getLayoutClasses } from '../../utils/getLayoutClasses'
|
|
6
8
|
|
|
9
|
+
export type Props = GridProps<HTMLAttributes<HTMLElement>> & {
|
|
10
|
+
children: Snippet
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
const {
|
|
8
14
|
element = 'div',
|
|
9
15
|
gap,
|
|
@@ -11,17 +17,17 @@
|
|
|
11
17
|
className,
|
|
12
18
|
children,
|
|
13
19
|
...rest
|
|
14
|
-
}:
|
|
20
|
+
}: Props = $props()
|
|
15
21
|
|
|
16
|
-
const classes = classNames([
|
|
22
|
+
const classes = $derived(classNames([
|
|
17
23
|
'grid',
|
|
18
24
|
getLayoutClasses({ gap, column }),
|
|
19
25
|
className
|
|
20
|
-
])
|
|
26
|
+
]))
|
|
21
27
|
|
|
22
|
-
const componentProps = {
|
|
28
|
+
const componentProps = $derived({
|
|
23
29
|
class: classes
|
|
24
|
-
}
|
|
30
|
+
})
|
|
25
31
|
</script>
|
|
26
32
|
|
|
27
33
|
<svelte:element this={element} {...componentProps} {...rest}>
|
package/components/Grid/Grid.tsx
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import type {
|
|
1
|
+
import React, { type JSX } from 'react'
|
|
2
|
+
import type { GridProps } from './grid'
|
|
3
3
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
import { getLayoutClasses } from '../../utils/getLayoutClasses'
|
|
6
6
|
|
|
7
|
+
export type Props = Omit<GridProps, 'element'> & {
|
|
8
|
+
Element?: keyof JSX.IntrinsicElements
|
|
9
|
+
children: React.ReactNode
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
const Grid = ({
|
|
8
13
|
Element = 'div',
|
|
9
14
|
gap,
|
|
@@ -11,7 +16,7 @@ const Grid = ({
|
|
|
11
16
|
className,
|
|
12
17
|
children,
|
|
13
18
|
...rest
|
|
14
|
-
}:
|
|
19
|
+
}: Props) => {
|
|
15
20
|
const classes = classNames([
|
|
16
21
|
'grid',
|
|
17
22
|
getLayoutClasses({ gap, column }),
|
package/components/Grid/grid.ts
CHANGED
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
import type { JSX } from 'react'
|
|
2
|
-
import type { Snippet } from 'svelte'
|
|
3
|
-
|
|
4
1
|
import type {
|
|
5
2
|
Column,
|
|
6
3
|
Gap,
|
|
7
4
|
Responsive
|
|
8
5
|
} from '../../utils/getLayoutClasses'
|
|
9
6
|
|
|
10
|
-
export type GridProps = {
|
|
7
|
+
export type GridProps<T extends object = object> = {
|
|
11
8
|
element?: string
|
|
12
9
|
gap?: Responsive<Gap>
|
|
13
10
|
column?: Responsive<Column>
|
|
14
11
|
className?: string
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type SvelteGridProps = {
|
|
19
|
-
children: Snippet
|
|
20
|
-
} & GridProps
|
|
21
|
-
|
|
22
|
-
export type ReactGridProps = {
|
|
23
|
-
Element?: keyof JSX.IntrinsicElements
|
|
24
|
-
children: React.ReactNode
|
|
25
|
-
} & Omit<GridProps, 'element'>
|
|
12
|
+
} & T
|