webcoreui 0.9.0 → 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 +20 -6
- package/components/Accordion/Accordion.astro +15 -10
- package/components/Accordion/Accordion.svelte +14 -12
- package/components/Accordion/Accordion.tsx +2 -2
- 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 +2 -1
- 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.svelte +7 -5
- 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.ts +6 -0
- package/components/Carousel/Carousel.astro +46 -41
- package/components/Carousel/carousel.ts +3 -0
- package/components/Checkbox/Checkbox.svelte +12 -9
- package/components/Checkbox/checkbox.module.scss +4 -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 +17 -11
- package/components/Copy/Copy.svelte +68 -61
- package/components/Copy/Copy.tsx +1 -0
- package/components/Copy/copy.ts +8 -2
- 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.svelte +14 -10
- package/components/Flex/flex.ts +6 -0
- package/components/Footer/Footer.svelte +12 -9
- package/components/Footer/footer.ts +6 -0
- package/components/Grid/Grid.svelte +12 -8
- package/components/Grid/grid.ts +6 -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 +9 -3
- package/components/Icon/map.ts +8 -10
- package/components/Input/Input.svelte +24 -20
- 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/Masonry/Masonry.svelte +12 -10
- package/components/Menu/Menu.astro +8 -3
- package/components/Menu/Menu.svelte +15 -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 +29 -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.svelte +12 -9
- package/components/Radio/radio.ts +4 -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 +73 -63
- package/components/Select/Select.svelte +27 -22
- package/components/Select/Select.tsx +8 -6
- 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.svelte +9 -7
- 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.svelte +15 -12
- 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.svelte +14 -11
- package/components/Textarea/textarea.ts +9 -4
- 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/info.svg +3 -3
- package/icons.d.ts +4 -5
- package/icons.js +4 -5
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +20 -20
- package/react.d.ts +3 -3
- package/svelte.d.ts +98 -98
- package/utils/bodyFreeze.ts +13 -0
- package/utils/modal.ts +12 -0
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { SvelteFooterProps } from './footer'
|
|
3
3
|
|
|
4
4
|
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
|
|
5
5
|
|
|
@@ -7,12 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
import styles from './footer.module.scss'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const {
|
|
11
|
+
logo,
|
|
12
|
+
columns,
|
|
13
|
+
subText,
|
|
14
|
+
className,
|
|
15
|
+
wrapperClassName,
|
|
16
|
+
subTextClassName,
|
|
17
|
+
children
|
|
18
|
+
}: SvelteFooterProps = $props()
|
|
16
19
|
|
|
17
20
|
const classes = classNames([
|
|
18
21
|
styles.footer,
|
|
@@ -82,12 +85,12 @@
|
|
|
82
85
|
</ConditionalWrapper>
|
|
83
86
|
{/if}
|
|
84
87
|
</ConditionalWrapper>
|
|
85
|
-
{#if subText ||
|
|
88
|
+
{#if subText || children}
|
|
86
89
|
<div class={subTextClasses}>
|
|
87
90
|
{#if subText}
|
|
88
91
|
<span>{@html subText}</span>
|
|
89
92
|
{/if}
|
|
90
|
-
|
|
93
|
+
{@render children?.()}
|
|
91
94
|
</div>
|
|
92
95
|
{/if}
|
|
93
96
|
</div>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
|
|
1
3
|
import type { ButtonProps } from '../Button/button'
|
|
2
4
|
|
|
3
5
|
export type FooterProps = {
|
|
@@ -24,6 +26,10 @@ export type FooterProps = {
|
|
|
24
26
|
subTextClassName?: string
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
export type SvelteFooterProps = {
|
|
30
|
+
children?: Snippet
|
|
31
|
+
} & FooterProps
|
|
32
|
+
|
|
27
33
|
export type ReactFooterProps = {
|
|
28
34
|
children?: React.ReactNode
|
|
29
35
|
} & FooterProps
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { SvelteGridProps } from './grid'
|
|
3
3
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
import { getLayoutClasses } from '../../utils/getLayoutClasses'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const {
|
|
8
|
+
element = 'div',
|
|
9
|
+
gap,
|
|
10
|
+
column,
|
|
11
|
+
className,
|
|
12
|
+
children,
|
|
13
|
+
...rest
|
|
14
|
+
}: SvelteGridProps = $props()
|
|
11
15
|
|
|
12
16
|
const classes = classNames([
|
|
13
17
|
'grid',
|
|
@@ -15,11 +19,11 @@
|
|
|
15
19
|
className
|
|
16
20
|
])
|
|
17
21
|
|
|
18
|
-
const
|
|
22
|
+
const componentProps = {
|
|
19
23
|
class: classes
|
|
20
24
|
}
|
|
21
25
|
</script>
|
|
22
26
|
|
|
23
|
-
<svelte:element this={element} {...
|
|
24
|
-
|
|
27
|
+
<svelte:element this={element} {...componentProps} {...rest}>
|
|
28
|
+
{@render children?.()}
|
|
25
29
|
</svelte:element>
|
package/components/Grid/grid.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
|
|
1
3
|
import type {
|
|
2
4
|
Column,
|
|
3
5
|
Gap,
|
|
@@ -12,6 +14,10 @@ export type GridProps = {
|
|
|
12
14
|
[key: string]: any
|
|
13
15
|
}
|
|
14
16
|
|
|
17
|
+
export type SvelteGridProps = {
|
|
18
|
+
children: Snippet
|
|
19
|
+
} & GridProps
|
|
20
|
+
|
|
15
21
|
export type ReactGridProps = {
|
|
16
22
|
Element?: keyof JSX.IntrinsicElements
|
|
17
23
|
children: React.ReactNode
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { SvelteGroupProps } from './group'
|
|
3
3
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
|
|
6
6
|
import styles from './group.module.scss'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const {
|
|
9
|
+
withSeparator,
|
|
10
|
+
className,
|
|
11
|
+
children
|
|
12
|
+
}: SvelteGroupProps = $props()
|
|
10
13
|
|
|
11
14
|
const classes = classNames([
|
|
12
15
|
styles.group,
|
|
@@ -16,5 +19,5 @@
|
|
|
16
19
|
</script>
|
|
17
20
|
|
|
18
21
|
<div class={classes}>
|
|
19
|
-
|
|
22
|
+
{@render children?.()}
|
|
20
23
|
</div>
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
|
|
1
3
|
export type GroupProps = {
|
|
2
4
|
withSeparator?: boolean
|
|
3
5
|
className?: string
|
|
4
6
|
}
|
|
5
7
|
|
|
8
|
+
export type SvelteGroupProps = {
|
|
9
|
+
children: Snippet
|
|
10
|
+
} & GroupProps
|
|
11
|
+
|
|
6
12
|
export type ReactGroupProps = {
|
|
7
13
|
children: React.ReactNode
|
|
8
14
|
} & GroupProps
|
|
@@ -7,13 +7,27 @@ interface Props extends IconProps {}
|
|
|
7
7
|
const {
|
|
8
8
|
type,
|
|
9
9
|
size = 24,
|
|
10
|
-
color
|
|
10
|
+
color,
|
|
11
|
+
theme,
|
|
12
|
+
iconSet
|
|
11
13
|
} = Astro.props
|
|
12
14
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const icons = {
|
|
16
|
+
...iconMap,
|
|
17
|
+
...(iconSet || {})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const svg = icons[type as keyof typeof iconMap]
|
|
21
|
+
|
|
22
|
+
if (!svg) {
|
|
23
|
+
// eslint-disable-next-line no-console
|
|
24
|
+
console.error('Cannot find icon type:', type)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const icon = svg
|
|
28
|
+
?.replace('width="24"', `width=${size}`)
|
|
29
|
+
?.replace('height="24"', color || theme
|
|
30
|
+
? `height=${size} color=${color || `var(--w-color-${theme})`}`
|
|
17
31
|
: `height=${size}`)
|
|
18
32
|
---
|
|
19
33
|
|
|
@@ -2,14 +2,30 @@
|
|
|
2
2
|
import type { IconProps } from './icon'
|
|
3
3
|
import iconMap from './map'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const {
|
|
6
|
+
type,
|
|
7
|
+
size = 24,
|
|
8
|
+
color,
|
|
9
|
+
theme,
|
|
10
|
+
iconSet
|
|
11
|
+
}: IconProps = $props()
|
|
8
12
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
const icons = {
|
|
14
|
+
...iconMap,
|
|
15
|
+
...(iconSet || {})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const svg = icons[type as keyof typeof iconMap]
|
|
19
|
+
|
|
20
|
+
if (!svg) {
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
console.error('Cannot find icon type:', type)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const icon = svg
|
|
26
|
+
?.replace('width="24"', `width=${size}`)
|
|
27
|
+
?.replace('height="24"', color || theme
|
|
28
|
+
? `height=${size} color=${color || `var(--w-color-${theme})`}`
|
|
13
29
|
: `height=${size}`)
|
|
14
30
|
</script>
|
|
15
31
|
|
package/components/Icon/Icon.tsx
CHANGED
|
@@ -5,12 +5,26 @@ import iconMap from './map'
|
|
|
5
5
|
const Icon = ({
|
|
6
6
|
type,
|
|
7
7
|
size = 24,
|
|
8
|
-
color
|
|
8
|
+
color,
|
|
9
|
+
theme,
|
|
10
|
+
iconSet
|
|
9
11
|
}: IconProps) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const icons = {
|
|
13
|
+
...iconMap,
|
|
14
|
+
...(iconSet || {})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const svg = icons[type as keyof typeof iconMap]
|
|
18
|
+
|
|
19
|
+
if (!svg) {
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.error('Cannot find icon type:', type)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const icon = svg
|
|
25
|
+
?.replace('width="24"', `width=${size}`)
|
|
26
|
+
?.replace('height="24"', color || theme
|
|
27
|
+
? `height=${size} color=${color || `var(--w-color-${theme})`}`
|
|
14
28
|
: `height=${size}`)
|
|
15
29
|
|
|
16
30
|
return <span dangerouslySetInnerHTML={{ __html: icon }} />
|
package/components/Icon/icon.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export type IconProps = {
|
|
2
2
|
type: 'alert'
|
|
3
|
-
| 'arrow-down'
|
|
4
|
-
| 'arrow-left'
|
|
5
|
-
| 'arrow-right'
|
|
6
3
|
| 'check'
|
|
4
|
+
| 'chevron-down'
|
|
5
|
+
| 'chevron-left'
|
|
6
|
+
| 'chevron-right'
|
|
7
|
+
| 'chevron-up'
|
|
7
8
|
| 'circle-check'
|
|
8
9
|
| 'circle-close'
|
|
9
10
|
| 'close'
|
|
@@ -18,6 +19,11 @@ export type IconProps = {
|
|
|
18
19
|
| 'search'
|
|
19
20
|
| 'sun'
|
|
20
21
|
| 'warning'
|
|
22
|
+
| string
|
|
21
23
|
size?: number
|
|
22
24
|
color?: string
|
|
25
|
+
theme?: 'info' | 'success' | 'warning' | 'alert'
|
|
26
|
+
iconSet?: {
|
|
27
|
+
[key: string]: string
|
|
28
|
+
}
|
|
23
29
|
}
|
package/components/Icon/map.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import Alert from '../../icons/alert.svg?raw'
|
|
2
|
-
import ArrowDown from '../../icons/arrow-down.svg?raw'
|
|
3
|
-
import ArrowLeft from '../../icons/arrow-left.svg?raw'
|
|
4
|
-
import ArrowRight from '../../icons/arrow-right.svg?raw'
|
|
5
2
|
import Check from '../../icons/check.svg?raw'
|
|
3
|
+
import ChevronDown from '../../icons/chevron-down.svg?raw'
|
|
4
|
+
import ChevronLeft from '../../icons/chevron-left.svg?raw'
|
|
5
|
+
import ChevronRight from '../../icons/chevron-right.svg?raw'
|
|
6
|
+
import ChevronUp from '../../icons/chevron-up.svg?raw'
|
|
6
7
|
import CircleCheck from '../../icons/circle-check.svg?raw'
|
|
7
8
|
import CircleClose from '../../icons/circle-close.svg?raw'
|
|
8
9
|
import Close from '../../icons/close.svg?raw'
|
|
9
|
-
import Components from '../../icons/components.svg?raw'
|
|
10
10
|
import Copy from '../../icons/copy.svg?raw'
|
|
11
|
-
import File from '../../icons/file.svg?raw'
|
|
12
11
|
import Github from '../../icons/github.svg?raw'
|
|
13
12
|
import Home from '../../icons/home.svg?raw'
|
|
14
13
|
import Info from '../../icons/info.svg?raw'
|
|
@@ -21,16 +20,15 @@ import Warning from '../../icons/warning.svg?raw'
|
|
|
21
20
|
|
|
22
21
|
const iconMap = {
|
|
23
22
|
'alert': Alert,
|
|
24
|
-
'arrow-down': ArrowDown,
|
|
25
|
-
'arrow-left': ArrowLeft,
|
|
26
|
-
'arrow-right': ArrowRight,
|
|
27
23
|
'check': Check,
|
|
24
|
+
'chevron-down': ChevronDown,
|
|
25
|
+
'chevron-left': ChevronLeft,
|
|
26
|
+
'chevron-right': ChevronRight,
|
|
27
|
+
'chevron-up': ChevronUp,
|
|
28
28
|
'circle-check': CircleCheck,
|
|
29
29
|
'circle-close': CircleClose,
|
|
30
30
|
'close': Close,
|
|
31
|
-
'components': Components,
|
|
32
31
|
'copy': Copy,
|
|
33
|
-
'file': File,
|
|
34
32
|
'github': Github,
|
|
35
33
|
'home': Home,
|
|
36
34
|
'info': Info,
|
|
@@ -7,17 +7,21 @@
|
|
|
7
7
|
|
|
8
8
|
import styles from './input.module.scss'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
let {
|
|
11
|
+
type = 'text',
|
|
12
|
+
theme,
|
|
13
|
+
label,
|
|
14
|
+
value = $bindable(''),
|
|
15
|
+
subText,
|
|
16
|
+
className,
|
|
17
|
+
labelClassName,
|
|
18
|
+
onChange,
|
|
19
|
+
onKeyUp,
|
|
20
|
+
onInput,
|
|
21
|
+
onClick,
|
|
22
|
+
children,
|
|
23
|
+
...rest
|
|
24
|
+
}: SvelteInputProps = $props()
|
|
21
25
|
|
|
22
26
|
const classes = classNames([
|
|
23
27
|
styles.input,
|
|
@@ -30,7 +34,7 @@
|
|
|
30
34
|
labelClassName
|
|
31
35
|
])
|
|
32
36
|
|
|
33
|
-
const useLabel = !!(label || subText ||
|
|
37
|
+
const useLabel = !!(label || subText || children)
|
|
34
38
|
</script>
|
|
35
39
|
|
|
36
40
|
<ConditionalWrapper
|
|
@@ -42,20 +46,20 @@
|
|
|
42
46
|
<div class={styles.label}>{@html label}</div>
|
|
43
47
|
{/if}
|
|
44
48
|
<ConditionalWrapper
|
|
45
|
-
condition={
|
|
49
|
+
condition={!!children}
|
|
46
50
|
element="div"
|
|
47
51
|
class={styles.wrapper}
|
|
48
52
|
>
|
|
49
|
-
|
|
53
|
+
{@render children?.()}
|
|
50
54
|
<input
|
|
51
|
-
class={classes}
|
|
52
55
|
bind:value
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
class={classes}
|
|
57
|
+
onchange={onChange}
|
|
58
|
+
onkeyup={onKeyUp}
|
|
59
|
+
oninput={onInput}
|
|
60
|
+
onclick={onClick}
|
|
57
61
|
{...{ type }}
|
|
58
|
-
{
|
|
62
|
+
{...rest}
|
|
59
63
|
/>
|
|
60
64
|
</ConditionalWrapper>
|
|
61
65
|
{#if subText}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
|
|
3
|
+
export type InputTarget = {
|
|
4
|
+
currentTarget: HTMLInputElement
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
export type InputProps = {
|
|
2
8
|
type?: 'text'
|
|
3
9
|
| 'email'
|
|
@@ -40,10 +46,11 @@ export type InputProps = {
|
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
export type SvelteInputProps = {
|
|
43
|
-
onChange?: (event: Event &
|
|
44
|
-
onKeyUp?: (event: KeyboardEvent &
|
|
49
|
+
onChange?: (event: Event & InputTarget) => void
|
|
50
|
+
onKeyUp?: (event: KeyboardEvent & InputTarget) => void
|
|
45
51
|
onInput?: (event: any) => void
|
|
46
|
-
onClick?: (event: MouseEvent &
|
|
52
|
+
onClick?: (event: MouseEvent & InputTarget) => void
|
|
53
|
+
children?: Snippet
|
|
47
54
|
} & InputProps
|
|
48
55
|
|
|
49
56
|
export type ReactInputProps = {
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { SvelteKbdProps } from './kbd'
|
|
3
3
|
import { keyMap } from './keyMap'
|
|
4
4
|
|
|
5
5
|
import { classNames } from '../../utils/classNames'
|
|
6
6
|
|
|
7
7
|
import styles from './kbd.module.scss'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const {
|
|
10
|
+
keys,
|
|
11
|
+
className,
|
|
12
|
+
children
|
|
13
|
+
}: SvelteKbdProps = $props()
|
|
11
14
|
|
|
12
15
|
const classes = classNames([
|
|
13
16
|
styles.kbd,
|
|
@@ -15,4 +18,4 @@
|
|
|
15
18
|
])
|
|
16
19
|
</script>
|
|
17
20
|
|
|
18
|
-
<kbd class={classes}>{keys?.map(key => keyMap[key]).join('')}
|
|
21
|
+
<kbd class={classes}>{keys?.map(key => keyMap[key]).join('')}{@render children?.()}</kbd>
|
package/components/Kbd/kbd.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
|
|
1
3
|
export type KbdProps = {
|
|
2
4
|
keys?: ('cmd'
|
|
3
5
|
| 'shift'
|
|
@@ -21,6 +23,10 @@ export type KbdProps = {
|
|
|
21
23
|
className?: string
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
export type SvelteKbdProps = {
|
|
27
|
+
children?: Snippet
|
|
28
|
+
} & KbdProps
|
|
29
|
+
|
|
24
30
|
export type ReactKbdProps = {
|
|
25
31
|
children?: React.ReactNode
|
|
26
32
|
} & KbdProps
|
|
@@ -93,77 +93,82 @@ const wrapperClasses = [
|
|
|
93
93
|
<script>
|
|
94
94
|
import { dispatch } from '../../utils/event'
|
|
95
95
|
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
96
|
+
const addEventListeners = () => {
|
|
97
|
+
const lists = document.querySelectorAll('[data-id="w-list"]')
|
|
98
|
+
const searchInputs = document.querySelectorAll('[data-id="w-list-search"]')
|
|
99
|
+
|
|
100
|
+
const handleClick = (list: Element, items: Element[], event: Event) => {
|
|
101
|
+
const target = event.target as HTMLElement
|
|
102
|
+
|
|
103
|
+
if (target.dataset.value && !target.dataset.disabled) {
|
|
104
|
+
dispatch('listOnSelect', {
|
|
105
|
+
value: target.dataset.value,
|
|
106
|
+
name: target.dataset.name,
|
|
107
|
+
list
|
|
108
|
+
})
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
items.forEach(item => item.removeAttribute('data-selected'))
|
|
111
|
+
target.dataset.selected = 'true'
|
|
112
|
+
}
|
|
111
113
|
}
|
|
112
|
-
}
|
|
113
114
|
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
Array.from(lists).forEach(list => {
|
|
116
|
+
const items = Array.from(list.children)
|
|
116
117
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
Array.from(searchInputs).forEach(element => {
|
|
126
|
-
element.addEventListener('input', event => {
|
|
127
|
-
const target = event.target as HTMLInputElement
|
|
128
|
-
const ul = target.closest('[data-id="w-list-wrapper"]')
|
|
129
|
-
?.querySelector('ul') as HTMLUListElement
|
|
130
|
-
|
|
131
|
-
const noResults = ul.querySelector('[data-id="w-no-results"]')
|
|
132
|
-
const items = Array.from(ul.children)
|
|
133
|
-
const value = target.value.toLowerCase()
|
|
134
|
-
|
|
135
|
-
items.forEach(item => {
|
|
136
|
-
const li = item as HTMLLIElement
|
|
137
|
-
const hideItem = (!li.dataset.value?.toLowerCase().includes(value)
|
|
138
|
-
&& !li.innerText.toLowerCase().includes(value))
|
|
139
|
-
|| li.dataset.id === 'w-list-title'
|
|
140
|
-
|| li.dataset.id === 'w-no-results'
|
|
141
|
-
|
|
142
|
-
if (hideItem) {
|
|
143
|
-
li.dataset.hidden = 'true'
|
|
144
|
-
} else if (li.dataset.id !== 'w-no-results') {
|
|
145
|
-
li.removeAttribute('data-hidden')
|
|
118
|
+
list.addEventListener('click', event => handleClick(list, items, event))
|
|
119
|
+
list.addEventListener('keyup', event => {
|
|
120
|
+
if ((event as KeyboardEvent).key === 'Enter') {
|
|
121
|
+
handleClick(list, items, event)
|
|
146
122
|
}
|
|
147
123
|
})
|
|
124
|
+
})
|
|
148
125
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
126
|
+
Array.from(searchInputs).forEach(element => {
|
|
127
|
+
element.addEventListener('input', event => {
|
|
128
|
+
const target = event.target as HTMLInputElement
|
|
129
|
+
const ul = target.closest('[data-id="w-list-wrapper"]')
|
|
130
|
+
?.querySelector('ul') as HTMLUListElement
|
|
153
131
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
132
|
+
const noResults = ul.querySelector('[data-id="w-no-results"]')
|
|
133
|
+
const items = Array.from(ul.children)
|
|
134
|
+
const value = target.value.toLowerCase()
|
|
157
135
|
|
|
158
|
-
if (!value) {
|
|
159
136
|
items.forEach(item => {
|
|
160
137
|
const li = item as HTMLLIElement
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
138
|
+
const hideItem = (!li.dataset.value?.toLowerCase().includes(value)
|
|
139
|
+
&& !li.innerText.toLowerCase().includes(value))
|
|
140
|
+
|| li.dataset.id === 'w-list-title'
|
|
141
|
+
|| li.dataset.id === 'w-no-results'
|
|
142
|
+
|
|
143
|
+
if (hideItem) {
|
|
144
|
+
li.dataset.hidden = 'true'
|
|
145
|
+
} else if (li.dataset.id !== 'w-no-results') {
|
|
146
|
+
li.removeAttribute('data-hidden')
|
|
147
|
+
}
|
|
165
148
|
})
|
|
166
|
-
|
|
149
|
+
|
|
150
|
+
const numberOfResults = items.filter(item => {
|
|
151
|
+
const li = item as HTMLLIElement
|
|
152
|
+
return li.dataset.name && !li.dataset.hidden
|
|
153
|
+
}).length
|
|
154
|
+
|
|
155
|
+
if (!numberOfResults) {
|
|
156
|
+
noResults?.removeAttribute('data-hidden')
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (!value) {
|
|
160
|
+
items.forEach(item => {
|
|
161
|
+
const li = item as HTMLLIElement
|
|
162
|
+
|
|
163
|
+
li.dataset.id === 'w-no-results'
|
|
164
|
+
? li.dataset.hidden = 'true'
|
|
165
|
+
: li.removeAttribute('data-hidden')
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
})
|
|
167
169
|
})
|
|
168
|
-
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
document.addEventListener('astro:after-swap', addEventListeners)
|
|
173
|
+
addEventListeners()
|
|
169
174
|
</script>
|