webcoreui 1.4.0 → 1.5.0-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 (107) hide show
  1. package/README.md +15 -1
  2. package/components/Accordion/Accordion.svelte +3 -3
  3. package/components/Alert/Alert.svelte +3 -3
  4. package/components/AspectRatio/AspectRatio.svelte +22 -22
  5. package/components/Avatar/Avatar.svelte +4 -4
  6. package/components/Avatar/avatar.module.scss +3 -5
  7. package/components/Badge/Badge.svelte +2 -2
  8. package/components/Badge/badge.module.scss +5 -6
  9. package/components/Banner/Banner.svelte +4 -3
  10. package/components/Banner/banner.module.scss +4 -6
  11. package/components/BottomNavigation/BottomNavigation.svelte +4 -3
  12. package/components/BottomNavigation/bottomnavigation.module.scss +68 -70
  13. package/components/Breadcrumb/Breadcrumb.svelte +2 -2
  14. package/components/Button/Button.svelte +2 -2
  15. package/components/Button/button.module.scss +9 -12
  16. package/components/Card/Card.svelte +4 -4
  17. package/components/Card/card.module.scss +3 -7
  18. package/components/Carousel/Carousel.astro +2 -2
  19. package/components/Carousel/Carousel.svelte +16 -16
  20. package/components/Carousel/Carousel.tsx +2 -2
  21. package/components/Carousel/carousel.module.scss +3 -5
  22. package/components/Checkbox/Checkbox.svelte +4 -3
  23. package/components/Checkbox/checkbox.module.scss +4 -6
  24. package/components/Collapsible/Collapsible.svelte +4 -4
  25. package/components/Collapsible/collapsible.module.scss +5 -5
  26. package/components/ContextMenu/ContextMenu.svelte +8 -6
  27. package/components/Copy/Copy.svelte +2 -2
  28. package/components/Counter/Counter.svelte +6 -5
  29. package/components/Counter/counter.module.scss +3 -5
  30. package/components/DataTable/DataTable.svelte +15 -13
  31. package/components/Flex/Flex.svelte +4 -4
  32. package/components/Footer/Footer.svelte +6 -6
  33. package/components/Grid/Grid.svelte +4 -4
  34. package/components/Group/Group.svelte +2 -2
  35. package/components/Icon/Icon.svelte +13 -8
  36. package/components/Image/Image.svelte +51 -51
  37. package/components/ImageLoader/ImageLoader.svelte +2 -2
  38. package/components/Input/Input.svelte +5 -5
  39. package/components/Kbd/Kbd.svelte +2 -2
  40. package/components/List/List.svelte +7 -7
  41. package/components/List/List.tsx +2 -2
  42. package/components/Masonry/Masonry.svelte +7 -7
  43. package/components/Masonry/masonry.module.scss +4 -6
  44. package/components/Menu/Menu.svelte +6 -5
  45. package/components/Modal/Modal.svelte +4 -4
  46. package/components/Modal/modal.module.scss +5 -5
  47. package/components/OTPInput/OTPInput.svelte +4 -4
  48. package/components/OTPInput/otpinput.module.scss +0 -12
  49. package/components/Pagination/Pagination.svelte +2 -2
  50. package/components/Popover/Popover.svelte +2 -2
  51. package/components/Progress/Progress.svelte +5 -5
  52. package/components/Progress/progress.module.scss +15 -17
  53. package/components/Radio/Radio.astro +1 -0
  54. package/components/Radio/Radio.svelte +5 -3
  55. package/components/Radio/Radio.tsx +1 -0
  56. package/components/Radio/radio.module.scss +4 -6
  57. package/components/Radio/radio.ts +1 -0
  58. package/components/RangeSlider/RangeSlider.astro +4 -1
  59. package/components/RangeSlider/RangeSlider.svelte +14 -33
  60. package/components/RangeSlider/RangeSlider.tsx +4 -1
  61. package/components/RangeSlider/rangeslider.module.scss +14 -16
  62. package/components/RangeSlider/rangeslider.ts +1 -0
  63. package/components/Rating/Rating.svelte +7 -6
  64. package/components/Rating/rating.module.scss +13 -15
  65. package/components/Ribbon/Ribbon.svelte +2 -2
  66. package/components/Ribbon/ribbon.module.scss +9 -11
  67. package/components/Select/Select.astro +2 -0
  68. package/components/Select/Select.svelte +175 -172
  69. package/components/Select/Select.tsx +2 -0
  70. package/components/Select/select.ts +1 -0
  71. package/components/Sheet/Sheet.svelte +2 -2
  72. package/components/Sidebar/Sidebar.svelte +2 -2
  73. package/components/Skeleton/Skeleton.svelte +4 -4
  74. package/components/Skeleton/skeleton.module.scss +6 -9
  75. package/components/Slider/Slider.astro +6 -4
  76. package/components/Slider/Slider.svelte +10 -8
  77. package/components/Slider/Slider.tsx +6 -4
  78. package/components/Slider/slider.module.scss +12 -14
  79. package/components/Slider/slider.ts +3 -2
  80. package/components/SpeedDial/SpeedDial.svelte +3 -3
  81. package/components/SpeedDial/SpeedDial.tsx +1 -1
  82. package/components/SpeedDial/speeddial.module.scss +4 -6
  83. package/components/Spinner/Spinner.svelte +4 -4
  84. package/components/Spinner/spinner.module.scss +13 -14
  85. package/components/Spoiler/Spoiler.svelte +4 -3
  86. package/components/Spoiler/spoiler.module.scss +3 -5
  87. package/components/Stepper/Stepper.svelte +4 -4
  88. package/components/Stepper/stepper.defaults.scss +5 -0
  89. package/components/Stepper/stepper.module.scss +11 -13
  90. package/components/Switch/Switch.svelte +4 -4
  91. package/components/Switch/switch.module.scss +5 -7
  92. package/components/Table/Table.svelte +2 -2
  93. package/components/Tabs/Tabs.svelte +2 -2
  94. package/components/Textarea/Textarea.svelte +3 -3
  95. package/components/ThemeSwitcher/ThemeSwitcher.svelte +5 -5
  96. package/components/ThemeSwitcher/themeswitcher.module.scss +10 -12
  97. package/components/Timeline/Timeline.svelte +4 -4
  98. package/components/Timeline/timeline.module.scss +6 -8
  99. package/components/TimelineItem/TimelineItem.svelte +2 -2
  100. package/components/TimelineItem/timelineitem.module.scss +4 -4
  101. package/components/Toast/Toast.svelte +4 -4
  102. package/package.json +1 -1
  103. package/scss/config/functions.scss +41 -0
  104. package/scss/config/mixins.scss +65 -0
  105. package/scss/config.scss +1 -0
  106. package/scss/global/theme.scss +209 -194
  107. package/scss/setup.scss +6 -3
package/README.md CHANGED
@@ -123,6 +123,9 @@ export default defineConfig({
123
123
  })
124
124
  ```
125
125
 
126
+ > [!TIP]
127
+ > We also recommend adding [`astro-purgecss`](https://www.npmjs.com/package/astro-purgecss) to improve your CSS bundle size.
128
+
126
129
  Create an empty [`webcore.config.scss`](https://webcoreui.dev/docs/css-configuration#webcoreconfigscss) file at the root of your project to setup CSS configurations. Setup default styles and fonts by calling the following in your global SCSS file:
127
130
 
128
131
  ```scss
@@ -146,7 +149,9 @@ The `setup` mixin can also accept the following options:
146
149
  | `includeUtilities` | `true` | Adds utility classes for CSS. Read more about the available utility classes [here](https://webcoreui.dev/docs/layout). |
147
150
  | `includeTooltip` | `true` | Adds styles for using tooltips.
148
151
  | `includeScrollbarStyles` | `true` | Adds styles for scrollbars.
149
- | `includeBreakpoints` | `true` | Exposes breakpoint variables in CSS for JS. Used by components for responsiveness.
152
+ | `includeBreakpoints` | `true` | Exposes breakpoint variables in CSS for JS. Used by components for responsiveness. |
153
+ | `theme` | `dark` | Sets the default theme. Read more about available themes [here](https://webcoreui.dev/docs/themes). |
154
+ | `themes` | `()` | Pass a map to enable multiple themes. Values can be arbitrary CSS selectors that actives the theme. |
150
155
 
151
156
  Default component styles can be changed by overriding the following CSS variables:
152
157
 
@@ -253,6 +258,15 @@ html body {
253
258
  }
254
259
  ```
255
260
 
261
+ Depending on your installed blocks, you can also use the following variables to override default block styles:
262
+
263
+ ```scss
264
+ html body {
265
+ // Error page
266
+ --w-error-page-type-color: var(--w-color-info);
267
+ }
268
+ ```
269
+
256
270
  ### Using Components
257
271
 
258
272
  Start using Webcore components in your code by importing them:
@@ -15,7 +15,7 @@
15
15
  className
16
16
  }: AccordionProps = $props()
17
17
 
18
- let toggleState = $state(items.map(item => item.expanded ?? false))
18
+ let toggleState = $derived(items.map(item => item.expanded ?? false))
19
19
 
20
20
  const toggle = (index: number) => {
21
21
  toggleState = toggleState.map((_, i) => index === i
@@ -24,12 +24,12 @@
24
24
  )
25
25
  }
26
26
 
27
- const classes = classNames([
27
+ const classes = $derived(classNames([
28
28
  styles.accordion,
29
29
  reverse && styles.reverse,
30
30
  icon === 'plus' && styles.plus,
31
31
  className
32
- ])
32
+ ]))
33
33
  </script>
34
34
 
35
35
  <ul class={classes}>
@@ -30,14 +30,14 @@
30
30
  alert
31
31
  }
32
32
 
33
- const hasCustomIcon = icon
33
+ const hasCustomIcon = $derived(icon)
34
34
 
35
- const classes = [
35
+ const classes = $derived([
36
36
  styles['w-alert'],
37
37
  (!hasCustomIcon && !theme) && styles.col,
38
38
  theme && styles[theme],
39
39
  className
40
- ].filter(Boolean).join(' ')
40
+ ].filter(Boolean).join(' '))
41
41
  </script>
42
42
 
43
43
  <svelte:element this={element} class={classes} {...rest}>
@@ -1,22 +1,22 @@
1
- <script lang="ts">
2
- import type { SvelteAspectRatioProps } from './aspectratio'
3
-
4
- import { classNames } from '../../utils/classNames'
5
-
6
- import styles from './aspect-ratio.module.scss'
7
-
8
- const {
9
- ratio,
10
- className,
11
- children
12
- }: SvelteAspectRatioProps = $props()
13
-
14
- const classes = classNames([
15
- styles.ratio,
16
- className
17
- ])
18
- </script>
19
-
20
- <div class={classes} style={`aspect-ratio: ${ratio.replace(':', '/')};`}>
21
- {@render children?.()}
22
- </div>
1
+ <script lang="ts">
2
+ import type { SvelteAspectRatioProps } from './aspectratio'
3
+
4
+ import { classNames } from '../../utils/classNames'
5
+
6
+ import styles from './aspect-ratio.module.scss'
7
+
8
+ const {
9
+ ratio,
10
+ className,
11
+ children
12
+ }: SvelteAspectRatioProps = $props()
13
+
14
+ const classes = $derived(classNames([
15
+ styles.ratio,
16
+ className
17
+ ]))
18
+ </script>
19
+
20
+ <div class={classes} style={`aspect-ratio: ${ratio.replace(':', '/')};`}>
21
+ {@render children?.()}
22
+ </div>
@@ -19,17 +19,17 @@
19
19
  groupClassName
20
20
  }: AvatarProps = $props()
21
21
 
22
- const classes = classNames([
22
+ const classes = $derived(classNames([
23
23
  styles.avatar,
24
24
  borderless && styles.borderless,
25
25
  className
26
- ])
26
+ ]))
27
27
 
28
- const groupStyles = classNames([
28
+ const groupStyles = $derived(classNames([
29
29
  styles.group,
30
30
  reverse && styles.reverse,
31
31
  groupClassName
32
- ])
32
+ ]))
33
33
  </script>
34
34
 
35
35
  {#if Array.isArray(img)}
@@ -1,16 +1,14 @@
1
1
  @use '../../scss/config.scss' as *;
2
2
 
3
- body {
4
- --w-avatar-border: var(--w-color-primary-70);
5
- }
6
-
7
3
  .avatar {
4
+ --border: var(--w-avatar-border, var(--w-color-primary-70));
5
+
8
6
  @include border-radius(max);
9
7
 
10
8
  object-fit: cover;
11
9
 
12
10
  &:not(.borderless) {
13
- border: 3px solid var(--w-avatar-border);
11
+ border: 3px solid var(--border);
14
12
  }
15
13
  }
16
14
 
@@ -17,7 +17,7 @@
17
17
  ...rest
18
18
  }: SvelteBadgeProps = $props()
19
19
 
20
- const classes = classNames([
20
+ const classes = $derived(classNames([
21
21
  styles.badge,
22
22
  theme && styles[theme],
23
23
  (onClick || hover) && styles.hover,
@@ -25,7 +25,7 @@
25
25
  rounded && styles.round,
26
26
  transparent && styles.transparent,
27
27
  className
28
- ])
28
+ ]))
29
29
  </script>
30
30
 
31
31
  {#if onClick}
@@ -21,8 +21,7 @@
21
21
  }
22
22
 
23
23
  &.outline:hover {
24
- @include typography(primary);
25
- @include background(transparent);
24
+ @include background(primary-60);
26
25
  box-shadow: inset 0px 0px 0px 1px var(--w-color-primary);
27
26
  }
28
27
 
@@ -54,14 +53,14 @@
54
53
  }
55
54
 
56
55
  &.outline {
57
- @include typography(primary-20);
58
- @include background(primary-70);
59
- box-shadow: inset 0px 0px 0px 1px var(--w-color-primary-20);
56
+ @include typography(primary);
57
+ @include background(transparent);
58
+ box-shadow: inset 0px 0px 0px 1px var(--w-color-primary-40);
60
59
  }
61
60
 
62
61
  &.flat {
63
62
  @include typography(primary);
64
- @include background(primary-70);
63
+ @include background(transparent);
65
64
  }
66
65
 
67
66
  &.info {
@@ -19,17 +19,18 @@
19
19
  children
20
20
  }: SvelteBannerProps = $props()
21
21
 
22
- const classes = classNames([
22
+ const classes = $derived(classNames([
23
23
  styles.banner,
24
24
  bottom && styles.bottom,
25
25
  padded && styles.padded,
26
26
  !sticky && styles.relative,
27
27
  className
28
- ])
28
+ ]))
29
29
 
30
- const style = top
30
+ const style = $derived(top
31
31
  ? `--w-banner-top: ${top}px;`
32
32
  : null
33
+ )
33
34
 
34
35
  let visible = $state(true)
35
36
  </script>
@@ -1,24 +1,22 @@
1
1
  @use '../../scss/config.scss' as *;
2
2
 
3
- body {
4
- --w-banner-top: 0;
5
- }
6
-
7
3
  .banner {
4
+ --top: var(--w-banner-top, 0);
5
+
8
6
  @include background(primary-60);
9
7
  @include spacing(p-default);
10
8
  @include position(sticky);
11
9
  @include layer(top);
12
10
  @include typography(center);
13
11
 
14
- top: var(--w-banner-top);
12
+ top: var(--top);
15
13
 
16
14
  &.padded {
17
15
  @include border-radius();
18
16
  @include position(l20px);
19
17
 
20
18
  width: calc(100% - 40px);
21
- top: calc(var(--w-banner-top) + 20px);
19
+ top: calc(var(--top) + 20px);
22
20
 
23
21
  &.bottom {
24
22
  @include position(l20px, b20px);
@@ -13,17 +13,18 @@
13
13
  className
14
14
  }: BottomNavigationProps = $props()
15
15
 
16
- const classes = classNames([
16
+ const classes = $derived(classNames([
17
17
  styles.nav,
18
18
  separated && styles.separated,
19
19
  maxWidth && styles.bordered,
20
20
  floating && styles.floating,
21
21
  className
22
- ])
22
+ ]))
23
23
 
24
- const styleVariable = maxWidth
24
+ const styleVariable = $derived(maxWidth
25
25
  ? `--w-bottom-navigation-max-width: ${maxWidth};`
26
26
  : null
27
+ )
27
28
  </script>
28
29
 
29
30
  <nav class={classes} style={styleVariable}>
@@ -1,70 +1,68 @@
1
- @use '../../scss/config.scss' as *;
2
-
3
- body {
4
- --w-bottom-navigation-max-width: auto;
5
- }
6
-
7
- .nav {
8
- @include background(primary-60);
9
- @include position(fixed, b0, l0, r0);
10
- @include layer(header);
11
- @include border(top, primary-50);
12
-
13
- &.separated ul li:not(:last-child) {
14
- @include border(right, primary-50);
15
- }
16
-
17
- &.separated.bordered ul {
18
- @include border(left, primary-50);
19
- @include border(right, primary-50);
20
- }
21
-
22
- &.floating {
23
- @include position(l20px, r20px, b20px);
24
- @include border-radius(xl);
25
- @include border(0);
26
-
27
- &:not(.bordered) {
28
- li:first-child .item {
29
- @include border-radius(xl, left);
30
- }
31
-
32
- li:last-child .item {
33
- @include border-radius(xl, right);
34
- }
35
- }
36
- }
37
-
38
- ul {
39
- @include spacing(none-auto, p0);
40
- @include layout(flex, h-center);
41
-
42
- max-width: var(--w-bottom-navigation-max-width);
43
- list-style-type: none;
44
-
45
- li {
46
- @include spacing(mb-0);
47
-
48
- flex: 1;
49
-
50
- &.with-icon .item {
51
- @include spacing(pt-sm, pb-xs);
52
- }
53
-
54
- .item {
55
- @include layout(flex, column, center, xs);
56
- @include spacing(py-sm);
57
- @include size('h100%');
58
- @include transition(background);
59
- @include typography(md, primary-10, none);
60
-
61
- user-select: none;
62
- cursor: pointer;
63
-
64
- &:hover {
65
- @include background(primary-50);
66
- }
67
- }
68
- }
69
- }
70
- }
1
+ @use '../../scss/config.scss' as *;
2
+
3
+ .nav {
4
+ --width: var(--w-bottom-navigation-max-width, auto);
5
+
6
+ @include background(primary-60);
7
+ @include position(fixed, b0, l0, r0);
8
+ @include layer(header);
9
+ @include border(top, primary-50);
10
+
11
+ &.separated ul li:not(:last-child) {
12
+ @include border(right, primary-50);
13
+ }
14
+
15
+ &.separated.bordered ul {
16
+ @include border(left, primary-50);
17
+ @include border(right, primary-50);
18
+ }
19
+
20
+ &.floating {
21
+ @include position(l20px, r20px, b20px);
22
+ @include border-radius(xl);
23
+ @include border(0);
24
+
25
+ &:not(.bordered) {
26
+ li:first-child .item {
27
+ @include border-radius(xl, left);
28
+ }
29
+
30
+ li:last-child .item {
31
+ @include border-radius(xl, right);
32
+ }
33
+ }
34
+ }
35
+
36
+ ul {
37
+ @include spacing(none-auto, p0);
38
+ @include layout(flex, h-center);
39
+
40
+ max-width: var(--width);
41
+ list-style-type: none;
42
+
43
+ li {
44
+ @include spacing(mb-0);
45
+
46
+ flex: 1;
47
+
48
+ &.with-icon .item {
49
+ @include spacing(pt-sm, pb-xs);
50
+ }
51
+
52
+ .item {
53
+ @include layout(flex, column, center, xs);
54
+ @include spacing(py-sm);
55
+ @include size('h100%');
56
+ @include transition(background);
57
+ @include typography(md, primary-10, none);
58
+
59
+ user-select: none;
60
+ cursor: pointer;
61
+
62
+ &:hover {
63
+ @include background(primary-50);
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
@@ -15,10 +15,10 @@
15
15
  className
16
16
  }: BreadcrumbProps = $props()
17
17
 
18
- const classes = classNames([
18
+ const classes = $derived(classNames([
19
19
  styles.breadcrumb,
20
20
  className
21
- ])
21
+ ]))
22
22
  </script>
23
23
 
24
24
  <ul class={classes}>
@@ -14,11 +14,11 @@
14
14
  ...rest
15
15
  }: SvelteButtonProps = $props()
16
16
 
17
- const classes = classNames([
17
+ const classes = $derived(classNames([
18
18
  styles.button,
19
19
  theme && styles[theme],
20
20
  className
21
- ])
21
+ ]))
22
22
  </script>
23
23
 
24
24
 
@@ -12,14 +12,16 @@
12
12
  cursor: pointer;
13
13
 
14
14
  &[disabled] {
15
- cursor: no-drop;
16
- @include background(primary-20);
15
+ @include visibility(.5);
16
+
17
+ pointer-events: none;
18
+ cursor: not-allowed;
17
19
  }
18
20
 
19
21
  &:hover {
20
22
  @include background(primary-20);
21
23
  }
22
-
24
+
23
25
  &.secondary {
24
26
  @include typography(primary);
25
27
  @include background(primary-50);
@@ -30,19 +32,14 @@
30
32
  }
31
33
 
32
34
  &.outline {
33
- @include typography(primary-20);
35
+ @include typography(primary);
34
36
  @include background(transparent);
35
- box-shadow: inset 0px 0px 0px 1px var(--w-color-primary-20);
36
-
37
+ box-shadow: inset 0px 0px 0px 1px var(--w-color-primary-40);
38
+
37
39
  &:hover {
38
- @include typography(primary);
40
+ @include background(primary-60);
39
41
  box-shadow: inset 0px 0px 0px 1px var(--w-color-primary);
40
42
  }
41
-
42
- &[disabled] {
43
- @include typography(primary-30);
44
- box-shadow: inset 0px 0px 0px 1px var(--w-color-primary-30);
45
- }
46
43
  }
47
44
 
48
45
  &.flat {
@@ -17,17 +17,17 @@
17
17
  ...rest
18
18
  }: SvelteCardProps = $props()
19
19
 
20
- const classes = classNames([
20
+ const classes = $derived(classNames([
21
21
  styles.card,
22
22
  secondary && styles.secondary,
23
23
  className
24
- ])
24
+ ]))
25
25
 
26
- const bodyClasses = classNames([
26
+ const bodyClasses = $derived(classNames([
27
27
  styles.body,
28
28
  compact && styles.compact,
29
29
  bodyClassName
30
- ])
30
+ ]))
31
31
  </script>
32
32
 
33
33
  <svelte:element this={element} class={classes} {...rest}>
@@ -5,19 +5,16 @@
5
5
  @include border-radius(md);
6
6
  @include layout(flex, column);
7
7
  @include background(primary-70);
8
+ @include visibility(hidden);
8
9
 
9
- &.secondary {
10
+ &.secondary .body {
10
11
  @include background(primary-60);
11
-
12
- .title {
13
- @include background(primary-70);
14
- }
15
12
  }
16
13
 
17
14
  .title {
18
15
  @include spacing(p-default);
19
16
  @include border(primary-50, bottom);
20
- display: block;
17
+ @include visibility(block);
21
18
  }
22
19
 
23
20
  .body {
@@ -28,7 +25,6 @@
28
25
  &.compact {
29
26
  @include border(20px, primary-60);
30
27
  @include spacing(p-3xl);
31
- @include background(primary-70);
32
28
  }
33
29
  }
34
30
  }
@@ -59,7 +59,7 @@ const paginationClasses = classNames([
59
59
  const totalPages = Math.ceil(items / getItemsPerSlide())
60
60
  const subTextValue = subText?.match(/\{0\}|\{1\}/g) ? subText : undefined
61
61
  const style = getItemsPerSlide() > 1
62
- ? `--w-slide-width: calc(${100 / getItemsPerSlide()}% - 5px);`
62
+ ? `--width: calc(${100 / getItemsPerSlide()}% - 5px);`
63
63
  : null
64
64
  ---
65
65
 
@@ -172,7 +172,7 @@ const style = getItemsPerSlide() > 1
172
172
  carousel.dataset.currentBreakpoint = breakpoint
173
173
  carousel.dataset.visibleItems = itemsPerSlide
174
174
  carousel.children[0].scrollIntoView({ behavior: 'smooth', block: 'nearest' })
175
- carousel.style.setProperty('--w-slide-width', `calc(${100 / itemsPerSlide}% - 5px)`)
175
+ carousel.style.setProperty('--width', `calc(${100 / itemsPerSlide}% - 5px)`)
176
176
 
177
177
  pagination.dataset.totalPages = String(totalPages)
178
178
 
@@ -48,39 +48,39 @@
48
48
  let progressValue = $state(0)
49
49
  let paginated = false
50
50
  let currentPage = $state(1)
51
- let totalPages = $state(Math.ceil(items / getItemsPerSlide()))
51
+ let totalPages = $derived(Math.ceil(items / getItemsPerSlide()))
52
52
  let style = $state(getItemsPerSlide() > 1
53
- ? `--w-slide-width: calc(${100 / getItemsPerSlide()}% - 5px);`
53
+ ? `--width: calc(${100 / getItemsPerSlide()}% - 5px);`
54
54
  : null)
55
55
 
56
- const classes = classNames([
56
+ const classes = $derived(classNames([
57
57
  styles.carousel,
58
58
  className
59
- ])
59
+ ]))
60
60
 
61
- const containerClasses = classNames([
61
+ const containerClasses = $derived(classNames([
62
62
  styles.container,
63
63
  scrollSnap && styles.snap
64
- ])
64
+ ]))
65
65
 
66
- const wrapperClasses = classNames([
66
+ const wrapperClasses = $derived(classNames([
67
67
  styles.wrapper,
68
68
  effect && styles[effect],
69
69
  getItemsPerSlide() > 1 && styles['no-snap'],
70
70
  wrapperClassName
71
- ])
71
+ ]))
72
72
 
73
- const paginationWrapperClasses = classNames([
73
+ const paginationWrapperClasses = $derived(classNames([
74
74
  styles['pagination-wrapper'],
75
75
  paginationClassName
76
- ])
76
+ ]))
77
77
 
78
- const paginationClasses = classNames([
78
+ const paginationClasses = $derived(classNames([
79
79
  styles.pagination,
80
80
  !subText && paginationClassName
81
- ])
81
+ ]))
82
82
 
83
- const subTextValue = subText?.match(/\{0\}|\{1\}/g) ? subText : undefined
83
+ const subTextValue = $derived(subText?.match(/\{0\}|\{1\}/g) ? subText : undefined)
84
84
 
85
85
  const updateValues = () => {
86
86
  const activeElement = carouselItems[currentPage - 1] as HTMLLIElement
@@ -103,7 +103,7 @@
103
103
  onScroll?.(currentPage)
104
104
  }
105
105
 
106
- const scroll = debounceScroll((event: Event) => {
106
+ const scroll = $derived(debounceScroll((event: Event) => {
107
107
  if (!paginated) {
108
108
  const target = event.target as HTMLDivElement
109
109
  const scrollLeft = target.scrollLeft
@@ -114,7 +114,7 @@
114
114
 
115
115
  updateValues()
116
116
  }
117
- }, debounce)
117
+ }, debounce))
118
118
 
119
119
  const paginate = (event: PaginationEventType) => {
120
120
  const indexes = Array.from({ length: Math.ceil(items / getItemsPerSlide()) }, (_, i) => {
@@ -143,7 +143,7 @@
143
143
  currentPage = 1
144
144
  progressValue = 0
145
145
  totalPages = Math.ceil(items / getItemsPerSlide())
146
- style = `--w-slide-width: calc(${100 / getItemsPerSlide()}% - 5px);`
146
+ style = `--width: calc(${100 / getItemsPerSlide()}% - 5px);`
147
147
 
148
148
  if (subTextValue) {
149
149
  subText = subTextValue