webcoreui 0.4.1 → 0.5.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.
Files changed (47) hide show
  1. package/README.md +230 -227
  2. package/astro.d.ts +6 -0
  3. package/astro.js +6 -0
  4. package/components/Avatar/Avatar.astro +9 -2
  5. package/components/Avatar/Avatar.svelte +3 -1
  6. package/components/Avatar/Avatar.tsx +4 -2
  7. package/components/Avatar/avatar.ts +1 -0
  8. package/components/Button/button.module.scss +6 -1
  9. package/components/Button/button.ts +2 -2
  10. package/components/Carousel/Carousel.astro +198 -0
  11. package/components/Carousel/Carousel.svelte +161 -0
  12. package/components/Carousel/Carousel.tsx +172 -0
  13. package/components/Carousel/carousel.module.scss +58 -0
  14. package/components/Carousel/carousel.ts +26 -0
  15. package/components/DataTable/DataTable.astro +332 -0
  16. package/components/DataTable/DataTable.svelte +272 -0
  17. package/components/DataTable/DataTable.tsx +287 -0
  18. package/components/DataTable/datatable.module.scss +102 -0
  19. package/components/DataTable/datatable.ts +41 -0
  20. package/components/Icon/map.ts +6 -0
  21. package/components/Input/input.module.scss +6 -0
  22. package/components/List/List.astro +1 -1
  23. package/components/List/List.svelte +1 -1
  24. package/components/List/List.tsx +1 -2
  25. package/components/Pagination/Pagination.astro +189 -0
  26. package/components/Pagination/Pagination.svelte +144 -0
  27. package/components/Pagination/Pagination.tsx +162 -0
  28. package/components/Pagination/pagination.module.scss +49 -0
  29. package/components/Pagination/pagination.ts +35 -0
  30. package/components/Select/Select.astro +8 -4
  31. package/components/Select/Select.svelte +15 -6
  32. package/components/Select/Select.tsx +15 -8
  33. package/components/Select/select.ts +7 -2
  34. package/components/Table/Table.svelte +1 -1
  35. package/components/Table/table.ts +1 -1
  36. package/icons/arrow-left.svg +3 -0
  37. package/icons/arrow-right.svg +3 -0
  38. package/icons/order.svg +3 -0
  39. package/icons.d.ts +3 -0
  40. package/icons.js +3 -0
  41. package/index.d.ts +6 -6
  42. package/package.json +1 -1
  43. package/react.d.ts +6 -0
  44. package/react.js +6 -0
  45. package/scss/resets.scss +27 -1
  46. package/svelte.d.ts +6 -0
  47. package/svelte.js +6 -0
@@ -0,0 +1,189 @@
1
+ ---
2
+ import type { PaginationProps } from './pagination'
3
+
4
+ import Button from '../Button/Button.astro'
5
+
6
+ import ArrowLeft from '../../icons/arrow-left.svg?raw'
7
+ import ArrowRight from '../../icons/arrow-right.svg?raw'
8
+
9
+ import styles from './pagination.module.scss'
10
+
11
+ interface Props extends PaginationProps {}
12
+
13
+ const {
14
+ type,
15
+ showChevrons,
16
+ showDots,
17
+ disablePrevious,
18
+ disableNext,
19
+ previousLink,
20
+ nextLink,
21
+ previousPageLabel = 'Previous',
22
+ nextPageLabel = 'Next',
23
+ pages,
24
+ theme = 'outline',
25
+ totalPages,
26
+ currentPage,
27
+ className
28
+ } = Astro.props
29
+
30
+ const classes = [
31
+ styles.pagination,
32
+ theme !== 'outline' && (theme === null ? styles.primary : styles[theme]),
33
+ type === 'dots' && styles.dots,
34
+ className
35
+ ]
36
+
37
+ const calculatedCurrentPage = currentPage
38
+ || (pages?.findIndex(page => page.active) || -1) + 1
39
+ || 1
40
+
41
+ const calculatedTotalPages = totalPages
42
+ || pages?.length
43
+ || 0
44
+
45
+ const generatedPages = pages?.length
46
+ ? pages
47
+ : Array(totalPages || 0).fill(0).map((_, index) => ({
48
+ ...(index === 0 && { active: true }),
49
+ label: index + 1
50
+ }))
51
+ ---
52
+
53
+ <ul
54
+ class:list={classes}
55
+ data-id="w-pagination"
56
+ data-total-pages={calculatedTotalPages}
57
+ data-current-page={calculatedCurrentPage}
58
+ >
59
+ {type === 'dots' ? (
60
+ <Fragment>
61
+ {generatedPages?.map(page => (
62
+ <li>
63
+ <button
64
+ data-active={page.active ? 'true' : undefined}
65
+ data-page={page.label}
66
+ />
67
+ </li>
68
+ ))}
69
+ </Fragment>
70
+ ) : (
71
+ <li>
72
+ <Button
73
+ disabled={disablePrevious || (calculatedCurrentPage === 1 && !previousLink)}
74
+ href={!disablePrevious ? previousLink : undefined}
75
+ theme={theme}
76
+ data-page="prev"
77
+ >
78
+ {(showChevrons || type === 'arrows') && <Fragment set:html={ArrowLeft} />}
79
+ {type !== 'arrows' && previousPageLabel}
80
+ </Button>
81
+ </li>
82
+ <Fragment>
83
+ {type !== 'arrows' && pages?.slice(0, calculatedTotalPages)?.map((page, index) =>
84
+ <li>
85
+ <Button
86
+ href={page.link}
87
+ data-active={calculatedCurrentPage === index + 1 ? 'true' : null}
88
+ theme={theme}
89
+ data-page={page.label}
90
+ >
91
+ {page.label}
92
+ </Button>
93
+ </li>
94
+ )}
95
+ {showDots && (
96
+ <li>
97
+ <Button theme={theme} className={styles.inactive}>
98
+ ...
99
+ </Button>
100
+ </li>
101
+ )}
102
+ </Fragment>
103
+ <li>
104
+ <Button
105
+ disabled={disableNext || (calculatedCurrentPage === calculatedTotalPages && !nextLink)}
106
+ href={!disableNext ? nextLink : undefined}
107
+ theme={theme}
108
+ data-page="next"
109
+ >
110
+ {type !== 'arrows' && nextPageLabel}
111
+ {(showChevrons || type === 'arrows') && <Fragment set:html={ArrowRight} />}
112
+ </Button>
113
+ </li>
114
+ )}
115
+ </ul>
116
+
117
+ <script>
118
+ import { dispatch } from '../../utils/event'
119
+
120
+ const getCurrentPage = (pageElements: Element[], current: number, next: string) => {
121
+ if (next === 'prev') {
122
+ return current - 1
123
+ }
124
+
125
+ if (next === 'next') {
126
+ return current + 1
127
+ }
128
+
129
+ return pageElements?.findIndex(child => {
130
+ const button = child.children[0] as HTMLButtonElement
131
+
132
+ return button.dataset.page === next
133
+ }) + 1
134
+ }
135
+
136
+ const paginations = document.querySelectorAll('[data-id="w-pagination"]')
137
+
138
+ Array.from(paginations).forEach(element => {
139
+ const pagination = element as HTMLUListElement
140
+ const totalPages = Number(pagination.dataset.totalPages)
141
+ let currentPage = Number(pagination.dataset.currentPage)
142
+
143
+ element.addEventListener('click', event => {
144
+ const target = event.target as HTMLButtonElement
145
+ const navigated = target.nodeName === 'BUTTON'
146
+ && !target.dataset.active
147
+ && !target.disabled
148
+
149
+ if (navigated) {
150
+ const prevPageButton = element.querySelector('[data-page="prev"]') as HTMLButtonElement
151
+ const nextPageButton = element.querySelector('[data-page="next"]') as HTMLButtonElement
152
+ const currentPageButton = element.querySelector('[data-active]') as HTMLButtonElement
153
+
154
+ const pageElements = Array
155
+ .from(pagination.children)
156
+ .filter(child => {
157
+ const button = child.children[0] as HTMLButtonElement
158
+
159
+ return button.dataset.page && !['prev', 'next'].includes(button.dataset.page)
160
+ })
161
+
162
+ currentPage = getCurrentPage(pageElements, currentPage, target.dataset.page || '')
163
+ currentPageButton?.removeAttribute('data-active')
164
+
165
+ pagination.dataset.currentPage = String(currentPage)
166
+
167
+ const activeButton = pageElements
168
+ .find((_, index) => index + 1 === currentPage)
169
+ ?.children[0] as HTMLButtonElement
170
+
171
+ if (activeButton) {
172
+ activeButton.dataset.active = 'true'
173
+ }
174
+
175
+ if (prevPageButton && nextPageButton) {
176
+ prevPageButton.disabled = currentPage === 1
177
+ nextPageButton.disabled = currentPage === totalPages
178
+ }
179
+
180
+ dispatch('paginate', {
181
+ page: currentPage,
182
+ ...(activeButton?.dataset.page && { label: activeButton?.dataset.page }),
183
+ target: element,
184
+ trusted: event.isTrusted
185
+ })
186
+ }
187
+ })
188
+ })
189
+ </script>
@@ -0,0 +1,144 @@
1
+ <script lang="ts">
2
+ import type { SveltePaginationProps } from './pagination'
3
+
4
+ import Button from '../Button/Button.svelte'
5
+
6
+ import { classNames } from '../../utils/classNames'
7
+
8
+ import ArrowLeft from '../../icons/arrow-left.svg?raw'
9
+ import ArrowRight from '../../icons/arrow-right.svg?raw'
10
+
11
+ import styles from './pagination.module.scss'
12
+
13
+ export let type: SveltePaginationProps['type'] = null
14
+ export let showChevrons: SveltePaginationProps['showChevrons'] = false
15
+ export let showDots: SveltePaginationProps['showDots'] = false
16
+ export let disablePrevious: SveltePaginationProps['disablePrevious'] = false
17
+ export let disableNext: SveltePaginationProps['disableNext'] = false
18
+ export let previousLink: SveltePaginationProps['previousLink'] = ''
19
+ export let nextLink: SveltePaginationProps['nextLink'] = ''
20
+ export let previousPageLabel: SveltePaginationProps['previousPageLabel'] = 'Previous'
21
+ export let nextPageLabel: SveltePaginationProps['nextPageLabel'] = 'Next'
22
+ export let pages: SveltePaginationProps['pages'] = []
23
+ export let theme: SveltePaginationProps['theme'] = 'outline'
24
+ export let totalPages: SveltePaginationProps['totalPages'] = null
25
+ export let currentPage: SveltePaginationProps['currentPage'] = null
26
+ export let className: SveltePaginationProps['className'] = ''
27
+ export let onChange: SveltePaginationProps['onChange'] = () => {}
28
+
29
+ const classes = classNames([
30
+ styles.pagination,
31
+ theme !== 'outline' && (theme === null || theme === undefined ? styles.primary : styles[theme]),
32
+ type === 'dots' && styles.dots,
33
+ className
34
+ ])
35
+
36
+ const calculatedTotalPages = totalPages
37
+ || pages?.length
38
+ || 0
39
+
40
+ const generatedPages = pages?.length
41
+ ? pages
42
+ : Array(totalPages || 0).fill(0).map((_, index) => ({
43
+ ...(index === 0 && { active: true }),
44
+ label: index + 1
45
+ }))
46
+
47
+ const paginate = (to: string | number) => {
48
+ if (to === 'prev') {
49
+ calculatedCurrentPage = calculatedCurrentPage - 1
50
+ } else if (to === 'next') {
51
+ calculatedCurrentPage = calculatedCurrentPage + 1
52
+ } else {
53
+ calculatedCurrentPage = to as number
54
+ }
55
+
56
+ const label = pages?.[calculatedCurrentPage - 1]?.label
57
+
58
+ onChange?.({
59
+ page: calculatedCurrentPage,
60
+ ...(label && { label })
61
+ })
62
+ }
63
+
64
+ $: calculatedCurrentPage = currentPage
65
+ || (pages?.findIndex(page => page.active) || -1) + 1
66
+ || 1
67
+ </script>
68
+
69
+ <ul class={classes}>
70
+ {#if type === 'dots' && generatedPages?.length}
71
+ {#each generatedPages as _, index}
72
+ <li>
73
+ <button
74
+ data-active={calculatedCurrentPage === index + 1 ? 'true' : null}
75
+ on:click={calculatedCurrentPage !== index + 1
76
+ ? () => paginate(index + 1)
77
+ : null
78
+ }
79
+ />
80
+ </li>
81
+ {/each}
82
+ {:else}
83
+ <li>
84
+ <Button
85
+ disabled={(disablePrevious || (calculatedCurrentPage === 1 && !previousLink)) ? true : null}
86
+ href={!disablePrevious ? previousLink : undefined}
87
+ theme={theme}
88
+ onClick={!(disablePrevious || (calculatedCurrentPage === 1 && !previousLink))
89
+ ? () => paginate('prev')
90
+ : null
91
+ }
92
+ >
93
+ {#if showChevrons || type === 'arrows'}
94
+ {@html ArrowLeft}
95
+ {/if}
96
+ {#if type !== 'arrows'}
97
+ {previousPageLabel}
98
+ {/if}
99
+ </Button>
100
+ </li>
101
+ {#if type !== 'arrows' && pages?.length}
102
+ {#each pages?.slice(0, calculatedTotalPages) as page, index}
103
+ <li>
104
+ <Button
105
+ href={page.link}
106
+ data-active={calculatedCurrentPage === index + 1 ? 'true' : null}
107
+ theme={theme}
108
+ onClick={calculatedCurrentPage !== index + 1
109
+ ? () => paginate(index + 1)
110
+ : null
111
+ }
112
+ >
113
+ {page.label}
114
+ </Button>
115
+ </li>
116
+ {/each}
117
+ {/if}
118
+ {#if showDots}
119
+ <li>
120
+ <Button theme={theme} className={styles.inactive}>
121
+ ...
122
+ </Button>
123
+ </li>
124
+ {/if}
125
+ <li>
126
+ <Button
127
+ disabled={(disableNext || calculatedCurrentPage === calculatedTotalPages) ? true : null}
128
+ href={!disableNext ? nextLink : undefined}
129
+ theme={theme}
130
+ onClick={!disableNext
131
+ ? () => paginate('next')
132
+ : null
133
+ }
134
+ >
135
+ {#if type !== 'arrows'}
136
+ {nextPageLabel}
137
+ {/if}
138
+ {#if showChevrons || type === 'arrows'}
139
+ {@html ArrowRight}
140
+ {/if}
141
+ </Button>
142
+ </li>
143
+ {/if}
144
+ </ul>
@@ -0,0 +1,162 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import type { ReactPaginationProps } from './pagination'
3
+
4
+ import Button from '../Button/Button.tsx'
5
+
6
+ import { classNames } from '../../utils/classNames'
7
+
8
+ import ArrowLeft from '../../icons/arrow-left.svg?raw'
9
+ import ArrowRight from '../../icons/arrow-right.svg?raw'
10
+
11
+ import styles from './pagination.module.scss'
12
+
13
+ // eslint-disable-next-line complexity
14
+ const Pagination = ({
15
+ type,
16
+ showChevrons,
17
+ showDots,
18
+ disablePrevious,
19
+ disableNext,
20
+ previousLink,
21
+ nextLink,
22
+ previousPageLabel = 'Previous',
23
+ nextPageLabel = 'Next',
24
+ pages,
25
+ theme = 'outline',
26
+ totalPages,
27
+ currentPage,
28
+ onChange,
29
+ className
30
+ }: ReactPaginationProps) => {
31
+ const [calculatedCurrentPage, setCalculatedCurrentPage] = useState(
32
+ currentPage
33
+ || (pages?.findIndex(page => page.active) || -1) + 1
34
+ || 1
35
+ )
36
+
37
+ const classes = classNames([
38
+ styles.pagination,
39
+ theme !== 'outline' && (theme === null || theme === undefined ? styles.primary : styles[theme]),
40
+ type === 'dots' && styles.dots,
41
+ className
42
+ ])
43
+
44
+ const calculatedTotalPages = totalPages
45
+ || pages?.length
46
+ || 0
47
+
48
+ const generatedPages = pages?.length
49
+ ? pages
50
+ : Array(totalPages || 0).fill(0).map((_, index) => ({
51
+ ...(index === 0 && { active: true }),
52
+ label: index + 1
53
+ }))
54
+
55
+ const paginate = (to: string | number) => {
56
+ let currentPage = calculatedCurrentPage
57
+
58
+ if (to === 'prev') {
59
+ currentPage = calculatedCurrentPage - 1
60
+ } else if (to === 'next') {
61
+ currentPage = calculatedCurrentPage + 1
62
+ } else {
63
+ currentPage = to as number
64
+ }
65
+
66
+ const label = pages?.[currentPage - 1]?.label
67
+
68
+ setCalculatedCurrentPage(currentPage)
69
+
70
+ onChange?.({
71
+ page: currentPage,
72
+ ...(label && { label })
73
+ })
74
+ }
75
+
76
+ useEffect(() => {
77
+ if (currentPage) {
78
+ setCalculatedCurrentPage(currentPage)
79
+ }
80
+ }, [currentPage])
81
+
82
+ return (
83
+ <ul className={classes}>
84
+ {type === 'dots' ? (
85
+ <React.Fragment>
86
+ {generatedPages?.map((_, index) => (
87
+ <li key={index}>
88
+ <button
89
+ data-active={calculatedCurrentPage === index + 1 ? 'true' : null}
90
+ onClick={calculatedCurrentPage !== index + 1
91
+ ? () => paginate(index + 1)
92
+ : undefined
93
+ }
94
+ />
95
+ </li>
96
+ ))}
97
+ </React.Fragment>
98
+ ) : (
99
+ <React.Fragment>
100
+ <li>
101
+ <Button
102
+ disabled={disablePrevious || (calculatedCurrentPage === 1 && !previousLink)}
103
+ href={!disablePrevious ? previousLink : undefined}
104
+ theme={theme}
105
+ onClick={!(disablePrevious || (calculatedCurrentPage === 1 && !previousLink))
106
+ ? () => paginate('prev')
107
+ : null
108
+ }
109
+ >
110
+ {(showChevrons || type === 'arrows') && (
111
+ <span dangerouslySetInnerHTML={{ __html: ArrowLeft }} />
112
+ )}
113
+ {type !== 'arrows' && previousPageLabel}
114
+ </Button>
115
+ </li>
116
+ <React.Fragment>
117
+ {type !== 'arrows' && pages?.slice(0, calculatedTotalPages)?.map((page, index) =>
118
+ <li key={index}>
119
+ <Button
120
+ href={page.link}
121
+ data-active={calculatedCurrentPage === index + 1 ? 'true' : null}
122
+ theme={theme}
123
+ onClick={calculatedCurrentPage !== index + 1
124
+ ? () => paginate(index + 1)
125
+ : null
126
+ }
127
+ >
128
+ {page.label}
129
+ </Button>
130
+ </li>
131
+ )}
132
+ {showDots && (
133
+ <li>
134
+ <Button theme={theme} className={styles.inactive}>
135
+ ...
136
+ </Button>
137
+ </li>
138
+ )}
139
+ </React.Fragment>
140
+ <li>
141
+ <Button
142
+ disabled={disableNext || calculatedCurrentPage === calculatedTotalPages}
143
+ href={!disableNext ? nextLink : undefined}
144
+ theme={theme}
145
+ onClick={!disableNext
146
+ ? () => paginate('next')
147
+ : null
148
+ }
149
+ >
150
+ {type !== 'arrows' && nextPageLabel}
151
+ {(showChevrons || type === 'arrows') && (
152
+ <span dangerouslySetInnerHTML={{ __html: ArrowRight }} />
153
+ )}
154
+ </Button>
155
+ </li>
156
+ </React.Fragment>
157
+ )}
158
+ </ul>
159
+ )
160
+ }
161
+
162
+ export default Pagination
@@ -0,0 +1,49 @@
1
+ @import '../../scss/config.scss';
2
+
3
+ .pagination {
4
+ @include layout(flex, xs, wrap);
5
+ @include spacing(0);
6
+
7
+ list-style-type: none;
8
+
9
+ &.primary [data-active] {
10
+ @include typography(primary-70);
11
+ @include background(primary-20);
12
+ }
13
+
14
+ &.dots button {
15
+ @include transition();
16
+ @include border-radius(max);
17
+ @include size(12px);
18
+ @include border(0);
19
+ @include spacing(p0);
20
+ @include background(primary-30);
21
+
22
+ cursor: pointer;
23
+
24
+ &[data-active] {
25
+ @include background(primary);
26
+ @include size(w20px);
27
+ @include border-radius(lg);
28
+ }
29
+ }
30
+
31
+ li {
32
+ @include spacing(m0);
33
+ }
34
+
35
+ svg {
36
+ @include size(10px);
37
+ pointer-events: none;
38
+ }
39
+
40
+ [data-active] {
41
+ @include typography(primary);
42
+ box-shadow: inset 0px 0px 0px 1px var(--w-color-primary);
43
+ }
44
+
45
+ .inactive {
46
+ pointer-events: none;
47
+ box-shadow: none;
48
+ }
49
+ }
@@ -0,0 +1,35 @@
1
+ import type { ButtonProps } from '../Button/button'
2
+
3
+ export type PaginationEventType = {
4
+ page: number
5
+ label?: string | number | undefined
6
+ }
7
+
8
+ export type PaginationProps = {
9
+ type?: 'arrows' | 'dots' | null
10
+ showChevrons?: boolean
11
+ showDots?: boolean
12
+ disablePrevious?: boolean
13
+ disableNext?: boolean
14
+ previousLink?: string
15
+ nextLink?: string
16
+ previousPageLabel?: string
17
+ nextPageLabel?: string
18
+ className?: string
19
+ theme?: ButtonProps['theme']
20
+ totalPages?: number | null
21
+ currentPage?: number | null
22
+ pages?: {
23
+ label: number | string
24
+ active?: boolean
25
+ link?: string
26
+ }[]
27
+ }
28
+
29
+ export type SveltePaginationProps = {
30
+ onChange?: (event: PaginationEventType) => void
31
+ } & PaginationProps
32
+
33
+ export type ReactPaginationProps = {
34
+ onChange?: (event: PaginationEventType) => void
35
+ } & PaginationProps
@@ -21,8 +21,9 @@ const {
21
21
  label,
22
22
  subText,
23
23
  disabled,
24
- className,
25
24
  position,
25
+ updateValue = true,
26
+ className,
26
27
  ...rest
27
28
  } = Astro.props
28
29
 
@@ -42,6 +43,7 @@ const classes = classNames([
42
43
  label={label}
43
44
  subText={subText}
44
45
  data-id={`w-select-${name}`}
46
+ data-no-update={!updateValue ? 'true' : undefined}
45
47
  data-position={position}
46
48
  labelClassName={classes}
47
49
  >
@@ -125,11 +127,13 @@ const classes = classNames([
125
127
 
126
128
  closePopover(`[data-id="${popoverId}"]`)
127
129
 
128
- selectElement.value = name
130
+ if (!selectElement.dataset.noUpdate) {
131
+ selectElement.value = name
132
+ }
129
133
 
130
134
  dispatch('selectOnChange', {
131
- select: selectName,
132
- ...payload
135
+ ...payload,
136
+ select: selectName
133
137
  })
134
138
  })
135
139
  </script>
@@ -16,14 +16,17 @@
16
16
 
17
17
  import styles from './select.module.scss'
18
18
 
19
+ import type { ListEventType } from '../List/list'
20
+
19
21
  export let name: SvelteSelectProps['name'] = ''
20
22
  export let value: SvelteSelectProps['value'] = ''
21
23
  export let placeholder: SvelteSelectProps['placeholder'] = ''
22
24
  export let label: SvelteSelectProps['label'] = ''
23
25
  export let subText: SvelteSelectProps['subText'] = ''
24
26
  export let disabled: SvelteSelectProps['disabled'] = false
25
- export let className: SvelteSelectProps['className'] = ''
27
+ export let updateValue: SvelteSelectProps['updateValue'] = true
26
28
  export let position: SvelteSelectProps['position'] = 'bottom'
29
+ export let className: SvelteSelectProps['className'] = ''
27
30
  export let onChange: SvelteSelectProps['onChange'] = () => {}
28
31
 
29
32
  let popoverInstance: any
@@ -39,18 +42,22 @@
39
42
  styles.popover
40
43
  ])
41
44
 
42
- const select = (payload: any) => {
45
+ const select = (event: ListEventType) => {
43
46
  closePopover(`.w-options-${name}`)
44
47
 
45
- value = payload.name
48
+ if (updateValue) {
49
+ value = event.name
50
+ }
46
51
 
47
52
  onChange?.({
48
- select: name,
49
- ...payload
53
+ ...event,
54
+ select: name
50
55
  })
51
56
  }
52
57
 
53
58
  onMount(() => {
59
+ let observer: ResizeObserver | undefined
60
+
54
61
  if (position === 'modal') {
55
62
  modal({
56
63
  trigger: `.w-select-${name}`,
@@ -73,7 +80,8 @@
73
80
  dialogElement.style.width = `${width}px`
74
81
  })
75
82
 
76
- new ResizeObserver(() => resize()).observe(document.body)
83
+ observer = new ResizeObserver(() => resize())
84
+ observer.observe(document.body)
77
85
 
78
86
  popoverInstance = popover({
79
87
  trigger: `.w-select-${name}`,
@@ -91,6 +99,7 @@
91
99
 
92
100
  return () => {
93
101
  popoverInstance?.remove()
102
+ observer?.unobserve(document.body)
94
103
  }
95
104
  })
96
105
  </script>