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,172 +1,180 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { onMount } from 'svelte'
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
import Input from '../Input/Input.svelte'
|
|
6
|
-
import List from '../List/List.svelte'
|
|
7
|
-
import Modal from '../Modal/Modal.svelte'
|
|
8
|
-
import Popover from '../Popover/Popover.svelte'
|
|
9
|
-
|
|
10
|
-
import { classNames } from '../../utils/classNames'
|
|
11
|
-
import { debounce } from '../../utils/debounce'
|
|
12
|
-
import { on } from '../../utils/DOMUtils'
|
|
13
|
-
import { modal } from '../../utils/modal'
|
|
14
|
-
import { closePopover, popover, type PopoverPosition } from '../../utils/popover'
|
|
15
|
-
|
|
16
|
-
import ChevronDown from '../../icons/chevron-down.svg?raw'
|
|
17
|
-
|
|
18
|
-
import styles from './select.module.scss'
|
|
19
|
-
|
|
20
|
-
import type { ListEventType, ListProps } from '../List/list'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
placeholder,
|
|
26
|
-
label,
|
|
27
|
-
subText,
|
|
28
|
-
disabled,
|
|
29
|
-
updateValue = true,
|
|
30
|
-
position = 'bottom',
|
|
31
|
-
className,
|
|
32
|
-
onChange,
|
|
33
|
-
onClose,
|
|
34
|
-
...rest
|
|
35
|
-
}: SvelteSelectProps = $props()
|
|
36
|
-
|
|
37
|
-
let popoverInstance: any
|
|
38
|
-
let val: string | undefined = $state('')
|
|
39
|
-
let focusByTab = false
|
|
40
|
-
|
|
41
|
-
const classes = classNames([
|
|
42
|
-
styles.select,
|
|
43
|
-
disabled && styles.disabled,
|
|
44
|
-
className
|
|
45
|
-
])
|
|
46
|
-
|
|
47
|
-
const popoverClasses = classNames([
|
|
48
|
-
`w-options-${name}`,
|
|
49
|
-
styles.popover
|
|
50
|
-
])
|
|
51
|
-
|
|
52
|
-
const inferredValue = rest.itemGroups
|
|
53
|
-
.map((group: ListProps['itemGroups'][0]) => group.items)
|
|
54
|
-
.flat()
|
|
55
|
-
.find((item: ListProps['itemGroups'][0]['items'][0]) => item.value === value)?.name
|
|
56
|
-
|
|
57
|
-
val = (value && inferredValue) ? inferredValue : value
|
|
58
|
-
|
|
59
|
-
const inputRestProps = Object.fromEntries(
|
|
60
|
-
Object.entries(rest).filter(([key]) => key.includes('data'))
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
const select = (event: ListEventType) => {
|
|
64
|
-
closePopover(`.w-options-${name}`)
|
|
65
|
-
|
|
66
|
-
if (updateValue) {
|
|
67
|
-
val = event.name
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
onChange?.({
|
|
71
|
-
...event,
|
|
72
|
-
select: name
|
|
73
|
-
})
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
import type { SelectEventType, SelectProps } from './select'
|
|
4
|
+
|
|
5
|
+
import Input from '../Input/Input.svelte'
|
|
6
|
+
import List from '../List/List.svelte'
|
|
7
|
+
import Modal from '../Modal/Modal.svelte'
|
|
8
|
+
import Popover from '../Popover/Popover.svelte'
|
|
9
|
+
|
|
10
|
+
import { classNames } from '../../utils/classNames'
|
|
11
|
+
import { debounce } from '../../utils/debounce'
|
|
12
|
+
import { on } from '../../utils/DOMUtils'
|
|
13
|
+
import { modal, type ModalCallback } from '../../utils/modal'
|
|
14
|
+
import { closePopover, popover, type PopoverCallback, type PopoverPosition } from '../../utils/popover'
|
|
15
|
+
|
|
16
|
+
import ChevronDown from '../../icons/chevron-down.svg?raw'
|
|
17
|
+
|
|
18
|
+
import styles from './select.module.scss'
|
|
19
|
+
|
|
20
|
+
import type { ListEventType, ListProps } from '../List/list'
|
|
21
|
+
|
|
22
|
+
export type Props = SelectProps & {
|
|
23
|
+
onChange?: (event: SelectEventType) => void
|
|
24
|
+
onClose?: (event: ModalCallback | PopoverCallback) => void
|
|
74
25
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
name,
|
|
29
|
+
value,
|
|
30
|
+
placeholder,
|
|
31
|
+
label,
|
|
32
|
+
subText,
|
|
33
|
+
disabled,
|
|
34
|
+
required,
|
|
35
|
+
updateValue = true,
|
|
36
|
+
position = 'bottom',
|
|
37
|
+
className,
|
|
38
|
+
onChange,
|
|
39
|
+
onClose,
|
|
40
|
+
...rest
|
|
41
|
+
}: Props = $props()
|
|
42
|
+
|
|
43
|
+
let popoverInstance: any
|
|
44
|
+
let focusByTab = false
|
|
45
|
+
|
|
46
|
+
const classes = $derived(classNames([
|
|
47
|
+
styles.select,
|
|
48
|
+
disabled && styles.disabled,
|
|
49
|
+
className
|
|
50
|
+
]))
|
|
51
|
+
|
|
52
|
+
const popoverClasses = $derived(classNames([
|
|
53
|
+
`w-options-${name}`,
|
|
54
|
+
styles.popover
|
|
55
|
+
]))
|
|
56
|
+
|
|
57
|
+
const inferredValue = $derived(rest.itemGroups
|
|
58
|
+
.map((group: ListProps['itemGroups'][0]) => group.items)
|
|
59
|
+
.flat()
|
|
60
|
+
.find((item: ListProps['itemGroups'][0]['items'][0]) => item.value === value)?.name)
|
|
61
|
+
|
|
62
|
+
let val = $derived((value && inferredValue) ? inferredValue : value)
|
|
63
|
+
|
|
64
|
+
const inputRestProps = $derived(
|
|
65
|
+
Object.fromEntries(
|
|
66
|
+
Object.entries(rest).filter(([key]) => key.includes('data'))
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
const select = (event: ListEventType) => {
|
|
71
|
+
closePopover(`.w-options-${name}`)
|
|
72
|
+
|
|
73
|
+
if (updateValue) {
|
|
74
|
+
val = event.name
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
onChange?.({
|
|
78
|
+
...event,
|
|
79
|
+
select: name
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
onMount(() => {
|
|
84
|
+
let observer: ResizeObserver | undefined
|
|
85
|
+
|
|
86
|
+
on(document, 'keydown', (event: KeyboardEvent) => {
|
|
87
|
+
if (event.key === 'Tab') {
|
|
88
|
+
focusByTab = true
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
on(document, 'mousedown', () => focusByTab = false)
|
|
93
|
+
|
|
94
|
+
if (position === 'modal') {
|
|
95
|
+
modal({
|
|
96
|
+
trigger: `.w-select-${name}`,
|
|
97
|
+
modal: `.w-options-${name}`,
|
|
98
|
+
onOpen: ({ modal }) => {
|
|
99
|
+
const search = modal.querySelector('input')
|
|
100
|
+
|
|
101
|
+
if (search) {
|
|
102
|
+
search.focus()
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
onClose(event) {
|
|
106
|
+
onClose?.(event)
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
} else {
|
|
110
|
+
const resize = debounce(() => {
|
|
111
|
+
const selectElement = document.querySelector(`.w-select-${name}`) as HTMLInputElement
|
|
112
|
+
|
|
113
|
+
if (selectElement) {
|
|
114
|
+
const { width } = selectElement.getBoundingClientRect()
|
|
115
|
+
const dialogElement = document.querySelector(`.w-options-${name}`) as HTMLDialogElement
|
|
116
|
+
|
|
117
|
+
dialogElement.style.width = `${width}px`
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
observer = new ResizeObserver(() => resize())
|
|
122
|
+
observer.observe(document.body)
|
|
123
|
+
|
|
124
|
+
popoverInstance = popover({
|
|
125
|
+
trigger: `.w-select-${name}`,
|
|
126
|
+
popover: `.w-options-${name}`,
|
|
127
|
+
position: position as PopoverPosition,
|
|
128
|
+
onOpen({ popover }) {
|
|
129
|
+
const search = popover.querySelector('input')
|
|
130
|
+
|
|
131
|
+
if (search) {
|
|
132
|
+
search.focus()
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
onClose(event) {
|
|
136
|
+
onClose?.(event)
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
on(`.w-select-${name}`, 'focus', (event: Event) => {
|
|
142
|
+
if (focusByTab) {
|
|
143
|
+
(event.currentTarget as HTMLInputElement).click()
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
return () => {
|
|
148
|
+
popoverInstance?.remove()
|
|
149
|
+
observer?.unobserve(document.body)
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
</script>
|
|
153
|
+
|
|
154
|
+
<Input
|
|
155
|
+
type="text"
|
|
156
|
+
value={val}
|
|
157
|
+
readonly={true}
|
|
158
|
+
disabled={disabled}
|
|
159
|
+
required={required}
|
|
160
|
+
placeholder={placeholder}
|
|
161
|
+
label={label}
|
|
162
|
+
subText={subText}
|
|
163
|
+
className={`w-select-${name}`}
|
|
164
|
+
labelClassName={classes}
|
|
165
|
+
{...inputRestProps}
|
|
166
|
+
>
|
|
167
|
+
{@html ChevronDown}
|
|
168
|
+
</Input>
|
|
169
|
+
{#if position === 'modal'}
|
|
170
|
+
<Modal
|
|
171
|
+
className={popoverClasses}
|
|
172
|
+
showCloseIcon={false}
|
|
173
|
+
>
|
|
174
|
+
<List onSelect={select} {...rest} />
|
|
175
|
+
</Modal>
|
|
176
|
+
{:else}
|
|
177
|
+
<Popover className={popoverClasses}>
|
|
178
|
+
<List onSelect={select} {...rest} />
|
|
179
|
+
</Popover>
|
|
180
|
+
{/if}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect,useState } from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { SelectEventType, SelectProps } from './select'
|
|
3
3
|
|
|
4
4
|
import Input from '../Input/Input.tsx'
|
|
5
5
|
import List from '../List/List.tsx'
|
|
@@ -9,8 +9,8 @@ import Popover from '../Popover/Popover.tsx'
|
|
|
9
9
|
import { classNames } from '../../utils/classNames'
|
|
10
10
|
import { debounce } from '../../utils/debounce'
|
|
11
11
|
import { on } from '../../utils/DOMUtils'
|
|
12
|
-
import { modal } from '../../utils/modal'
|
|
13
|
-
import { closePopover, popover, type PopoverPosition } from '../../utils/popover'
|
|
12
|
+
import { modal, type ModalCallback } from '../../utils/modal'
|
|
13
|
+
import { closePopover, popover, type PopoverCallback, type PopoverPosition } from '../../utils/popover'
|
|
14
14
|
|
|
15
15
|
import ChevronDown from '../../icons/chevron-down.svg?raw'
|
|
16
16
|
|
|
@@ -18,6 +18,11 @@ import styles from './select.module.scss'
|
|
|
18
18
|
|
|
19
19
|
import type { ListEventType } from '../List/list'
|
|
20
20
|
|
|
21
|
+
export type Props = SelectProps & {
|
|
22
|
+
onChange?: (event: SelectEventType) => void
|
|
23
|
+
onClose?: (event: ModalCallback | PopoverCallback) => void
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
const Select = ({
|
|
22
27
|
name,
|
|
23
28
|
value,
|
|
@@ -25,13 +30,14 @@ const Select = ({
|
|
|
25
30
|
label,
|
|
26
31
|
subText,
|
|
27
32
|
disabled,
|
|
33
|
+
required,
|
|
28
34
|
updateValue = true,
|
|
29
35
|
position = 'bottom',
|
|
30
36
|
className,
|
|
31
37
|
onChange,
|
|
32
38
|
onClose,
|
|
33
39
|
...rest
|
|
34
|
-
}:
|
|
40
|
+
}: Props) => {
|
|
35
41
|
const inferredValue = rest.itemGroups.map(group => group.items)
|
|
36
42
|
.flat()
|
|
37
43
|
.find(item => item.value === value)?.name
|
|
@@ -147,6 +153,7 @@ const Select = ({
|
|
|
147
153
|
value={val}
|
|
148
154
|
readOnly={true}
|
|
149
155
|
disabled={disabled}
|
|
156
|
+
required={required}
|
|
150
157
|
placeholder={placeholder}
|
|
151
158
|
label={label}
|
|
152
159
|
subText={subText}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { PopoverCallback, PopoverPosition } from '../../utils/popover'
|
|
1
|
+
import type { PopoverPosition } from '../../utils/popover'
|
|
3
2
|
|
|
4
3
|
import type { ListEventType, ListProps } from '../List/list'
|
|
5
4
|
|
|
@@ -14,16 +13,7 @@ export type SelectProps = {
|
|
|
14
13
|
label?: string
|
|
15
14
|
subText?: string
|
|
16
15
|
disabled?: boolean
|
|
16
|
+
required?: boolean
|
|
17
17
|
updateValue?: boolean
|
|
18
18
|
position?: PopoverPosition | 'modal'
|
|
19
19
|
} & ListProps
|
|
20
|
-
|
|
21
|
-
export type SvelteSelectProps = {
|
|
22
|
-
onChange?: (event: SelectEventType) => void
|
|
23
|
-
onClose?: (event: ModalCallback | PopoverCallback) => void
|
|
24
|
-
} & SelectProps
|
|
25
|
-
|
|
26
|
-
export type ReactSelectProps = {
|
|
27
|
-
onChange?: (event: SelectEventType) => void
|
|
28
|
-
onClose?: (event: ModalCallback | PopoverCallback) => void
|
|
29
|
-
} & SelectProps
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
2
3
|
import type { SheetProps } from './sheet'
|
|
3
4
|
|
|
4
5
|
import Modal from '../Modal/Modal.astro'
|
|
@@ -7,7 +8,7 @@ import { classNames } from '../../utils/classNames'
|
|
|
7
8
|
|
|
8
9
|
import styles from './sheet.module.scss'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
export type Props = SheetProps<HTMLAttributes<'dialog'>>
|
|
11
12
|
|
|
12
13
|
const {
|
|
13
14
|
position,
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { SheetProps } from './sheet'
|
|
3
3
|
|
|
4
|
-
import Modal from '../Modal/Modal.svelte'
|
|
4
|
+
import Modal, { type Props as ModalProps } from '../Modal/Modal.svelte'
|
|
5
5
|
|
|
6
6
|
import { classNames } from '../../utils/classNames'
|
|
7
7
|
|
|
8
8
|
import styles from './sheet.module.scss'
|
|
9
9
|
|
|
10
|
+
export type Props = SheetProps & ModalProps
|
|
11
|
+
|
|
10
12
|
const {
|
|
11
13
|
position,
|
|
12
14
|
className,
|
|
13
15
|
children,
|
|
14
16
|
...rest
|
|
15
|
-
}:
|
|
17
|
+
}: Props = $props()
|
|
16
18
|
|
|
17
|
-
const classes = classNames([
|
|
19
|
+
const classes = $derived(classNames([
|
|
18
20
|
styles.sheet,
|
|
19
21
|
position && styles[position],
|
|
20
22
|
className
|
|
21
|
-
])
|
|
23
|
+
]))
|
|
22
24
|
</script>
|
|
23
25
|
|
|
24
26
|
<Modal
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ReactSheetProps } from './sheet'
|
|
1
|
+
import type { SheetProps } from './sheet'
|
|
3
2
|
|
|
4
|
-
import Modal from '../Modal/Modal.tsx'
|
|
3
|
+
import Modal, { type Props as ModalProps } from '../Modal/Modal.tsx'
|
|
5
4
|
|
|
6
5
|
import { classNames } from '../../utils/classNames'
|
|
7
6
|
|
|
8
7
|
import styles from './sheet.module.scss'
|
|
9
8
|
|
|
9
|
+
export type Props = SheetProps & ModalProps
|
|
10
|
+
|
|
10
11
|
const Sheet = ({
|
|
11
12
|
position,
|
|
12
13
|
className,
|
|
13
14
|
children,
|
|
14
15
|
...rest
|
|
15
|
-
}:
|
|
16
|
+
}: Props) => {
|
|
16
17
|
const classes = classNames([
|
|
17
18
|
styles.sheet,
|
|
18
19
|
position && styles[position],
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ModalProps,
|
|
3
|
-
ReactModalProps,
|
|
4
|
-
SvelteModalProps
|
|
5
|
-
} from '../Modal/modal'
|
|
1
|
+
import type { ModalProps } from '../Modal/modal'
|
|
6
2
|
|
|
7
|
-
export type SheetProps = {
|
|
3
|
+
export type SheetProps<T extends object = object> = {
|
|
8
4
|
position?: 'left'
|
|
9
5
|
| 'top'
|
|
10
6
|
| 'bottom'
|
|
11
|
-
} & ModalProps
|
|
12
|
-
|
|
13
|
-
export type SvelteSheetProps = SheetProps & SvelteModalProps
|
|
14
|
-
export type ReactSheetProps = SheetProps & ReactModalProps
|
|
7
|
+
} & ModalProps<T>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { SidebarProps } from './sidebar'
|
|
3
4
|
|
|
4
5
|
import Badge from '../Badge/Badge.svelte'
|
|
5
6
|
|
|
@@ -7,16 +8,20 @@
|
|
|
7
8
|
|
|
8
9
|
import styles from './sidebar.module.scss'
|
|
9
10
|
|
|
11
|
+
export type Props = SidebarProps & {
|
|
12
|
+
children?: Snippet
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
const {
|
|
11
16
|
groups,
|
|
12
17
|
children,
|
|
13
18
|
className
|
|
14
|
-
}:
|
|
19
|
+
}: Props = $props()
|
|
15
20
|
|
|
16
|
-
const classes = classNames([
|
|
21
|
+
const classes = $derived(classNames([
|
|
17
22
|
styles.sidebar,
|
|
18
23
|
className
|
|
19
|
-
])
|
|
24
|
+
]))
|
|
20
25
|
</script>
|
|
21
26
|
|
|
22
27
|
<aside class={classes}>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { SidebarProps } from './sidebar'
|
|
3
3
|
|
|
4
4
|
import Badge from '../Badge/Badge.tsx'
|
|
5
5
|
|
|
@@ -7,11 +7,15 @@ import { classNames } from '../../utils/classNames'
|
|
|
7
7
|
|
|
8
8
|
import styles from './sidebar.module.scss'
|
|
9
9
|
|
|
10
|
+
export type Props = SidebarProps & {
|
|
11
|
+
children?: React.ReactNode
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
const Sidebar = ({
|
|
11
15
|
groups,
|
|
12
16
|
children,
|
|
13
17
|
className
|
|
14
|
-
}:
|
|
18
|
+
}: Props) => {
|
|
15
19
|
const classes = classNames([
|
|
16
20
|
styles.sidebar,
|
|
17
21
|
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 SidebarProps = {
|
|
@@ -17,11 +15,3 @@ export type SidebarProps = {
|
|
|
17
15
|
}[]
|
|
18
16
|
className?: string
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
export type SvelteSidebarProps = {
|
|
22
|
-
children?: Snippet
|
|
23
|
-
} & SidebarProps
|
|
24
|
-
|
|
25
|
-
export type ReactSidebarProps = {
|
|
26
|
-
children?: React.ReactNode
|
|
27
|
-
} & SidebarProps
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import styles from './skeleton.module.scss'
|
|
7
7
|
|
|
8
|
+
export type Props = SkeletonProps
|
|
9
|
+
|
|
8
10
|
const {
|
|
9
11
|
animate = 'wave',
|
|
10
12
|
type = 'rounded',
|
|
@@ -13,21 +15,21 @@
|
|
|
13
15
|
color,
|
|
14
16
|
waveColor,
|
|
15
17
|
className
|
|
16
|
-
}:
|
|
18
|
+
}: Props = $props()
|
|
17
19
|
|
|
18
|
-
const classes = classNames([
|
|
20
|
+
const classes = $derived(classNames([
|
|
19
21
|
animate && styles[animate],
|
|
20
22
|
styles[type!],
|
|
21
23
|
styles.skeleton,
|
|
22
24
|
className
|
|
23
|
-
])
|
|
25
|
+
]))
|
|
24
26
|
|
|
25
|
-
const styleVariables = classNames([
|
|
27
|
+
const styleVariables = $derived(classNames([
|
|
26
28
|
width && `max-width: ${width}px;`,
|
|
27
29
|
height && `max-height: ${height}px;`,
|
|
28
30
|
color && `--w-skeleton-color: ${color};`,
|
|
29
31
|
waveColor && `--w-skeleton-wave-color: ${waveColor};`
|
|
30
|
-
])
|
|
32
|
+
]))
|
|
31
33
|
</script>
|
|
32
34
|
|
|
33
35
|
<div class={classes} style={styleVariables}> </div>
|
|
@@ -5,6 +5,8 @@ import { classNames } from '../../utils/classNames'
|
|
|
5
5
|
|
|
6
6
|
import styles from './skeleton.module.scss'
|
|
7
7
|
|
|
8
|
+
export type Props = SkeletonProps
|
|
9
|
+
|
|
8
10
|
const Skeleton = ({
|
|
9
11
|
animate = 'wave',
|
|
10
12
|
type = 'rounded',
|
|
@@ -13,7 +15,7 @@ const Skeleton = ({
|
|
|
13
15
|
color,
|
|
14
16
|
waveColor,
|
|
15
17
|
className
|
|
16
|
-
}:
|
|
18
|
+
}: Props) => {
|
|
17
19
|
const classes = classNames([
|
|
18
20
|
animate && styles[animate],
|
|
19
21
|
styles[type],
|