flowbite-svelte 1.11.6 → 1.11.8

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.
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { type CarouselProps, type State, Slide } from "..";
2
+ import { type CarouselProps, type CarouselState, Slide } from "..";
3
3
  import { getTheme, warnThemeDeprecation } from "../theme/themeUtils";
4
4
  import clsx from "clsx";
5
5
  import { onMount, setContext } from "svelte";
@@ -24,17 +24,17 @@
24
24
 
25
25
  if (n % images.length === _state.index) return;
26
26
 
27
- if (!canChangeSlide({ lastSlideChange: _state.lastSlideChange, slideDuration, slideDurationRatio: SLIDE_DURATION_RATIO })) return;
27
+ if (!canChangeSlide({ lastSlideChange: _state.lastSlideChange, slideDuration: _state.slideDuration, slideDurationRatio: SLIDE_DURATION_RATIO })) return;
28
28
 
29
29
  _state.forward = n >= _state.index;
30
30
  _state.index = (images.length + n) % images.length;
31
- _state.lastSlideChange = new Date();
31
+ _state.lastSlideChange = Date.now();
32
32
 
33
33
  index = _state.index; // Update the bindable index
34
34
  onchange?.(images[_state.index]);
35
35
  };
36
36
 
37
- const _state: State = $state({ images, index: index ?? 0, forward: true, slideDuration, lastSlideChange: new Date(), changeSlide });
37
+ const _state: CarouselState = $state({ images, index: index ?? 0, forward: true, slideDuration, lastSlideChange: Date.now(), changeSlide });
38
38
 
39
39
  setContext("state", _state);
40
40
 
@@ -44,18 +44,17 @@
44
44
  changeSlide(index);
45
45
  });
46
46
 
47
+ $effect(() => {
48
+ _state.slideDuration = slideDuration;
49
+ });
50
+
47
51
  onMount(() => {
48
52
  onchange?.(images[index]);
49
53
  initialized = true;
50
54
  });
51
55
 
52
- const nextSlide = () => {
53
- changeSlide(_state.index + 1);
54
- };
55
-
56
- const prevSlide = () => {
57
- changeSlide(_state.index - 1);
58
- };
56
+ const nextSlide = () => changeSlide(_state.index + 1);
57
+ const prevSlide = () => changeSlide(_state.index - 1);
59
58
 
60
59
  const loop = (node: HTMLElement) => {
61
60
  // loop timer
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { Indicator, type IndicatorsProps, type State } from "..";
2
+ import { Indicator, type IndicatorsProps, type CarouselState } from "..";
3
3
  import { getTheme } from "../theme/themeUtils";
4
4
  import clsx from "clsx";
5
5
  import { getContext } from "svelte";
@@ -9,7 +9,7 @@
9
9
 
10
10
  const theme = getTheme("carouselIndicators");
11
11
 
12
- const _state = getContext<State>("state");
12
+ const _state = getContext<CarouselState>("state");
13
13
  const { base, indicator } = $derived(carouselIndicators({ position }));
14
14
 
15
15
  function goToIndex(newIndex: number) {
@@ -1,5 +1,5 @@
1
1
  export declare const canChangeSlide: ({ lastSlideChange, slideDuration, slideDurationRatio }: {
2
- lastSlideChange: Date;
2
+ lastSlideChange: number;
3
3
  slideDuration: number;
4
4
  slideDurationRatio?: number;
5
5
  }) => boolean;
@@ -1,5 +1,5 @@
1
1
  export const canChangeSlide = ({ lastSlideChange, slideDuration, slideDurationRatio = 1 }) => {
2
- if (lastSlideChange && new Date().getTime() - lastSlideChange.getTime() < slideDuration * slideDurationRatio) {
2
+ if (lastSlideChange && Date.now() - lastSlideChange < slideDuration * slideDurationRatio) {
3
3
  console.warn("Can't change slide yet, too soon");
4
4
  return false;
5
5
  }
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { type ControlsProps, type State, ControlButton } from "..";
2
+ import { type ControlsProps, type CarouselState, ControlButton } from "..";
3
3
  import { getTheme } from "../theme/themeUtils";
4
4
  import clsx from "clsx";
5
5
  import { getContext } from "svelte";
@@ -8,7 +8,7 @@
8
8
 
9
9
  const theme = getTheme("controlButton");
10
10
 
11
- const _state = getContext<State>("state");
11
+ const _state = getContext<CarouselState>("state");
12
12
 
13
13
  function changeSlide(forward: boolean) {
14
14
  _state.changeSlide(forward ? _state.index + 1 : _state.index - 1);
@@ -1,12 +1,12 @@
1
1
  <script lang="ts">
2
- import { type SlideProps, type State } from "..";
2
+ import { type SlideProps, type CarouselState } from "..";
3
3
  import { getTheme } from "../theme/themeUtils";
4
4
  import clsx from "clsx";
5
5
  import { getContext } from "svelte";
6
6
  import { fly } from "svelte/transition";
7
7
  import { slide } from "./theme";
8
8
 
9
- const _state = getContext<State>("state");
9
+ const _state = getContext<CarouselState>("state");
10
10
 
11
11
  let { image, transition, fit, class: className, ...restProps }: SlideProps = $props();
12
12
 
@@ -28,7 +28,7 @@
28
28
  duration: _state.slideDuration
29
29
  });
30
30
 
31
- let imgClass = slide({ fit, class: clsx(theme, className) });
31
+ let imgClass = $derived(slide({ fit, class: clsx(theme, className) }));
32
32
  </script>
33
33
 
34
34
  {#if transition}
@@ -1,4 +1,3 @@
1
- import type { NavBrandProps } from "../types";
2
1
  /**
3
2
  * [Go to docs](https://flowbite-svelte.com/)
4
3
  * ## Type
@@ -8,6 +7,6 @@ import type { NavBrandProps } from "../types";
8
7
  * @prop class: className
9
8
  * @prop ...restProps
10
9
  */
11
- declare const NavBrand: import("svelte").Component<NavBrandProps, {}, "">;
10
+ declare const NavBrand: import("svelte").Component<import("svelte/elements").HTMLAnchorAttributes, {}, "">;
12
11
  type NavBrand = ReturnType<typeof NavBrand>;
13
12
  export default NavBrand;
package/dist/types.d.ts CHANGED
@@ -293,18 +293,17 @@ export interface ButtonToggleContext {
293
293
  toggleSelected: (toggleValue: string) => void;
294
294
  isSelected: (toggleValue: string) => boolean;
295
295
  }
296
- export interface CheckIconProps extends SVGAttributes<SVGSVGElement> {
297
- }
296
+ export type CheckIconProps = SVGAttributes<SVGSVGElement>;
298
297
  export type CardProps = Omit<CardVariants, "href"> & AnchorDivAttributes & {
299
298
  children: Snippet;
300
299
  img?: string;
301
300
  imgClass?: ClassValue;
302
301
  contentClass?: string;
303
302
  };
304
- export type State = {
303
+ export type CarouselState = {
305
304
  images: HTMLImgAttributes[];
306
305
  index: number;
307
- lastSlideChange: Date;
306
+ lastSlideChange: number;
308
307
  slideDuration: number;
309
308
  forward: boolean;
310
309
  changeSlide: (newIndex: number) => void;
@@ -499,8 +498,7 @@ export interface DropdownProps extends PopperProps {
499
498
  activeUrl?: string;
500
499
  isOpen?: boolean;
501
500
  }
502
- export interface DropdownDividerProps extends HTMLAttributes<HTMLDivElement> {
503
- }
501
+ export type DropdownDividerProps = HTMLAttributes<HTMLDivElement>;
504
502
  export interface DropdownHeaderProps extends HTMLAttributes<HTMLDivElement> {
505
503
  children: Snippet;
506
504
  }
@@ -945,8 +943,7 @@ export interface NavbarProps extends Omit<HTMLAttributes<HTMLDivElement>, "child
945
943
  closeOnClickOutside?: boolean;
946
944
  breakpoint?: NavbarBreakpoint;
947
945
  }
948
- export interface NavBrandProps extends HTMLAnchorAttributes {
949
- }
946
+ export type NavBrandProps = HTMLAnchorAttributes;
950
947
  export interface NavContainerProps extends HTMLAttributes<HTMLDivElement> {
951
948
  fluid?: boolean;
952
949
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowbite-svelte",
3
- "version": "1.11.6",
3
+ "version": "1.11.8",
4
4
  "description": "Flowbite components for Svelte",
5
5
  "main": "dist/index.js",
6
6
  "author": {