webcoreui 0.5.0 → 0.6.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.
Files changed (74) hide show
  1. package/README.md +7 -0
  2. package/astro.d.ts +115 -68
  3. package/astro.js +8 -0
  4. package/components/Badge/Badge.astro +4 -0
  5. package/components/Badge/Badge.svelte +5 -1
  6. package/components/Badge/Badge.tsx +4 -0
  7. package/components/Badge/badge.module.scss +8 -0
  8. package/components/Badge/badge.ts +7 -3
  9. package/components/Breadcrumb/Breadcrumb.astro +51 -0
  10. package/components/Breadcrumb/Breadcrumb.svelte +45 -0
  11. package/components/Breadcrumb/Breadcrumb.tsx +51 -0
  12. package/components/Breadcrumb/breadcrumb.module.scss +26 -0
  13. package/components/Breadcrumb/breadcrumb.ts +12 -0
  14. package/components/Button/button.ts +13 -3
  15. package/components/Carousel/Carousel.astro +16 -7
  16. package/components/Carousel/Carousel.svelte +15 -5
  17. package/components/Carousel/Carousel.tsx +15 -5
  18. package/components/Carousel/carousel.module.scss +4 -1
  19. package/components/Carousel/carousel.ts +1 -1
  20. package/components/Checkbox/checkbox.ts +4 -2
  21. package/components/DataTable/DataTable.astro +2 -2
  22. package/components/DataTable/DataTable.tsx +287 -287
  23. package/components/Footer/Footer.astro +91 -0
  24. package/components/Footer/Footer.svelte +94 -0
  25. package/components/Footer/Footer.tsx +107 -0
  26. package/components/Footer/footer.module.scss +61 -0
  27. package/components/Footer/footer.ts +29 -0
  28. package/components/Icon/Icon.svelte +1 -1
  29. package/components/Icon/icon.ts +18 -1
  30. package/components/Icon/map.ts +8 -0
  31. package/components/List/list.ts +3 -1
  32. package/components/Masonry/Masonry.astro +54 -0
  33. package/components/Masonry/Masonry.svelte +54 -0
  34. package/components/Masonry/Masonry.tsx +62 -0
  35. package/components/Masonry/masonry.module.scss +18 -0
  36. package/components/Masonry/masonry.ts +36 -0
  37. package/components/Menu/Menu.astro +1 -1
  38. package/components/Menu/Menu.svelte +1 -1
  39. package/components/Menu/Menu.tsx +1 -1
  40. package/components/Menu/menu.ts +4 -2
  41. package/components/Modal/Modal.astro +2 -0
  42. package/components/Modal/Modal.svelte +2 -0
  43. package/components/Modal/Modal.tsx +2 -0
  44. package/components/Modal/modal.module.scss +29 -22
  45. package/components/Modal/modal.ts +1 -0
  46. package/components/Pagination/Pagination.astro +2 -0
  47. package/components/Pagination/Pagination.svelte +6 -3
  48. package/components/Pagination/Pagination.tsx +5 -3
  49. package/components/Pagination/pagination.ts +1 -0
  50. package/components/Rating/rating.ts +3 -1
  51. package/components/Sidebar/Sidebar.astro +61 -0
  52. package/components/Sidebar/Sidebar.svelte +50 -0
  53. package/components/Sidebar/Sidebar.tsx +58 -0
  54. package/components/Sidebar/sidebar.module.scss +43 -0
  55. package/components/Sidebar/sidebar.ts +21 -0
  56. package/components/Switch/switch.ts +4 -2
  57. package/icons/circle-close.svg +3 -0
  58. package/icons/components.svg +3 -0
  59. package/icons/file.svg +3 -0
  60. package/icons/home.svg +4 -0
  61. package/icons/sun.svg +1 -1
  62. package/icons.d.ts +4 -0
  63. package/icons.js +4 -0
  64. package/index.d.ts +8 -0
  65. package/index.js +1 -0
  66. package/package.json +9 -10
  67. package/react.d.ts +115 -68
  68. package/react.js +8 -0
  69. package/scss/config/typography.scss +3 -1
  70. package/scss/global/utility.scss +1 -1
  71. package/svelte.d.ts +116 -68
  72. package/svelte.js +8 -0
  73. package/utils/DOMUtils.ts +28 -0
  74. package/scss/global/elements.scss +0 -31
@@ -13,7 +13,7 @@ interface Props extends CarouselProps {}
13
13
 
14
14
  const {
15
15
  items,
16
- visibleItems = 1,
16
+ itemsPerSlide = 1,
17
17
  subText,
18
18
  scrollSnap = true,
19
19
  progress,
@@ -38,6 +38,7 @@ const containerClasses = [
38
38
  const wrapperClasses = [
39
39
  styles.wrapper,
40
40
  effect && styles[effect],
41
+ itemsPerSlide > 1 && styles['no-snap'],
41
42
  wrapperClassName
42
43
  ]
43
44
 
@@ -51,10 +52,10 @@ const paginationClasses = classNames([
51
52
  !subText && paginationClassName
52
53
  ])
53
54
 
54
- const totalPages = Math.ceil(items / visibleItems)
55
+ const totalPages = Math.ceil(items / itemsPerSlide)
55
56
  const subTextValue = subText?.match(/\{0\}|\{1\}/g) ? subText : undefined
56
- const style = visibleItems > 1
57
- ? `--w-slide-width: ${100 / visibleItems}%;`
57
+ const style = itemsPerSlide > 1
58
+ ? `--w-slide-width: calc(${100 / itemsPerSlide}% - 5px);`
58
59
  : null
59
60
  ---
60
61
 
@@ -67,7 +68,7 @@ const style = visibleItems > 1
67
68
  <ul
68
69
  class:list={wrapperClasses}
69
70
  style={style}
70
- data-visible-items={visibleItems > 1 ? visibleItems : null}
71
+ data-visible-items={itemsPerSlide > 1 ? itemsPerSlide : null}
71
72
  >
72
73
  <slot />
73
74
  </ul>
@@ -159,8 +160,16 @@ const style = visibleItems > 1
159
160
 
160
161
  const progress = target.closest('section').querySelector('.w-carousel-progress')
161
162
  const progressValue = (100 / (Number(target.dataset.totalPages) - 1))
162
- const visibleItems = Number(carousel.dataset.visibleItems) || 0
163
- const pageIndex = (event.page + visibleItems) - 1
163
+ const itemsPerSlide = Number(carousel.dataset.visibleItems) || 1
164
+ const totalItems = carousel.children.length
165
+ const indexes = Array.from({ length: Math.ceil(totalItems / itemsPerSlide) }, (_, i) => {
166
+ return Array.from({ length: itemsPerSlide }, (_, j) => (i * itemsPerSlide) + j)
167
+ .filter(index => index < totalItems)
168
+ })
169
+
170
+ const pageIndex = event.direction === 'prev'
171
+ ? indexes[event.page - 1][0]
172
+ : indexes[event.page - 1][indexes[event.page - 1].length - 1]
164
173
 
165
174
  const liElement = carousel.children[pageIndex]
166
175
  const subText = event.target.nextElementSibling
@@ -14,7 +14,7 @@
14
14
  import type { PaginationEventType } from '../Pagination/pagination'
15
15
 
16
16
  export let items: SvelteCarouselProps['items'] = 0
17
- export let visibleItems: SvelteCarouselProps['visibleItems'] = 1
17
+ export let itemsPerSlide: SvelteCarouselProps['itemsPerSlide'] = 1
18
18
  export let subText: SvelteCarouselProps['subText'] = ''
19
19
  export let scrollSnap: SvelteCarouselProps['scrollSnap'] = true
20
20
  export let progress: SvelteCarouselProps['progress'] = false
@@ -46,6 +46,7 @@
46
46
  const wrapperClasses = classNames([
47
47
  styles.wrapper,
48
48
  effect && styles[effect],
49
+ itemsPerSlide! > 1 && styles['no-snap'],
49
50
  wrapperClassName
50
51
  ])
51
52
 
@@ -59,10 +60,10 @@
59
60
  !subText && paginationClassName
60
61
  ])
61
62
 
62
- const totalPages = Math.ceil(items / visibleItems!)
63
+ const totalPages = Math.ceil(items / itemsPerSlide!)
63
64
  const subTextValue = subText?.match(/\{0\}|\{1\}/g) ? subText : undefined
64
- const style = visibleItems! > 1
65
- ? `--w-slide-width: ${100 / visibleItems!}%;`
65
+ const style = itemsPerSlide! > 1
66
+ ? `--w-slide-width: calc(${100 / itemsPerSlide!}% - 5px);`
66
67
  : null
67
68
 
68
69
  const updateValues = () => {
@@ -100,7 +101,16 @@
100
101
  }, debounce)
101
102
 
102
103
  const paginate = (event: PaginationEventType) => {
103
- const liElement = carouselItems[event.page - 1] as HTMLLIElement
104
+ const indexes = Array.from({ length: Math.ceil(items / itemsPerSlide!) }, (_, i) => {
105
+ return Array.from({ length: itemsPerSlide! }, (_, j) => (i * itemsPerSlide!) + j)
106
+ .filter(index => index < items)
107
+ })
108
+
109
+ const pageIndex = event.direction === 'prev'
110
+ ? indexes[event.page - 1][0]
111
+ : indexes[event.page - 1][indexes[event.page - 1].length - 1]
112
+
113
+ const liElement = carouselItems[pageIndex] as HTMLLIElement
104
114
 
105
115
  liElement.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
106
116
 
@@ -14,7 +14,7 @@ import type { PaginationEventType } from '../Pagination/pagination'
14
14
 
15
15
  const Carousel = ({
16
16
  items,
17
- visibleItems = 1,
17
+ itemsPerSlide = 1,
18
18
  subText,
19
19
  scrollSnap = true,
20
20
  progress,
@@ -49,6 +49,7 @@ const Carousel = ({
49
49
  const wrapperClasses = classNames([
50
50
  styles.wrapper,
51
51
  effect && styles[effect],
52
+ itemsPerSlide! > 1 && styles['no-snap'],
52
53
  wrapperClassName
53
54
  ])
54
55
 
@@ -62,10 +63,10 @@ const Carousel = ({
62
63
  !subText && paginationClassName
63
64
  ])
64
65
 
65
- const totalPages = Math.ceil(items / visibleItems!)
66
+ const totalPages = Math.ceil(items / itemsPerSlide!)
66
67
  const subTextValue = subText?.match(/\{0\}|\{1\}/g) ? subText : undefined
67
- const style = visibleItems > 1
68
- ? { '--w-slide-width': `${100 / visibleItems}%;` } as React.CSSProperties
68
+ const style = itemsPerSlide > 1
69
+ ? { '--w-slide-width': `calc(${100 / itemsPerSlide!}% - 5px);` } as React.CSSProperties
69
70
  : undefined
70
71
 
71
72
  const updateValues = (page: number) => {
@@ -105,7 +106,16 @@ const Carousel = ({
105
106
  }, debounce)
106
107
 
107
108
  const paginate = (event: PaginationEventType) => {
108
- const liElement = carouselItems.current[event.page - 1]
109
+ const indexes = Array.from({ length: Math.ceil(items / itemsPerSlide!) }, (_, i) => {
110
+ return Array.from({ length: itemsPerSlide! }, (_, j) => (i * itemsPerSlide!) + j)
111
+ .filter(index => index < items)
112
+ })
113
+
114
+ const pageIndex = event.direction === 'prev'
115
+ ? indexes[event.page - 1][0]
116
+ : indexes[event.page - 1][indexes[event.page - 1].length - 1]
117
+
118
+ const liElement = carouselItems.current[pageIndex]
109
119
 
110
120
  liElement.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
111
121
 
@@ -34,12 +34,15 @@ body {
34
34
  filter: saturate(0);
35
35
  }
36
36
 
37
+ &:not(.no-snap) li {
38
+ scroll-snap-align: center;
39
+ }
40
+
37
41
  li {
38
42
  @include transition();
39
43
  @include spacing(m0);
40
44
  @include layout(flex, h-center);
41
45
 
42
- scroll-snap-align: center;
43
46
  min-width: var(--w-slide-width);
44
47
  }
45
48
  }
@@ -2,7 +2,7 @@ import type { PaginationProps } from '../Pagination/pagination'
2
2
 
3
3
  export type CarouselProps = {
4
4
  items: number
5
- visibleItems?: number
5
+ itemsPerSlide?: number
6
6
  subText?: string
7
7
  autoplay?: boolean
8
8
  vertical?: boolean
@@ -1,3 +1,5 @@
1
+ import type { MouseEventHandler } from 'svelte/elements'
2
+
1
3
  export type CheckboxProps = {
2
4
  checked?: boolean
3
5
  label?: string
@@ -8,9 +10,9 @@ export type CheckboxProps = {
8
10
  }
9
11
 
10
12
  export type SvelteCheckboxProps = {
11
- onClick?: (key: any) => any
13
+ onClick?: MouseEventHandler<HTMLInputElement>
12
14
  } & CheckboxProps
13
15
 
14
16
  export type ReactCheckboxProps = {
15
- onClick?: (key: any) => any
17
+ onClick?: React.MouseEventHandler<HTMLInputElement>
16
18
  } & CheckboxProps
@@ -72,8 +72,8 @@ const columnToggleItems = [{
72
72
  }]
73
73
 
74
74
  const columnFilterItems = headings?.filter(heading => typeof heading !== 'string')
75
- .filter(heading => heading.filterable)
76
- .map(heading => heading.name)
75
+ .filter(heading => (heading as HeadingObject).filterable)
76
+ .map(heading => (heading as HeadingObject).name)
77
77
  .map(heading => getColumnName(heading))
78
78
 
79
79
  const hasPagination = data?.length && itemsPerPage