flowbite-svelte 2.0.0-next.8 → 2.0.0-next.9

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.
@@ -7,7 +7,7 @@
7
7
  import { createSingleSelectionContext } from "../utils/singleselection.svelte";
8
8
  import { untrack } from "svelte";
9
9
 
10
- let { children, flush, multiple = false, class: className, transitionType, respectReducedMotion = true, classes, ...restProps }: AccordionProps = $props();
10
+ let { children, flush, multiple = false, class: className, transition, respectReducedMotion = true, classes, ...restProps }: AccordionProps = $props();
11
11
 
12
12
  const theme = $derived(getTheme("accordion"));
13
13
 
@@ -16,8 +16,8 @@
16
16
  get flush() {
17
17
  return flush;
18
18
  },
19
- get transitionType() {
20
- return transitionType;
19
+ get transition() {
20
+ return transition;
21
21
  },
22
22
  get respectReducedMotion() {
23
23
  return respectReducedMotion;
@@ -51,7 +51,7 @@
51
51
  @prop flush
52
52
  @prop multiple = false
53
53
  @prop class: className
54
- @prop transitionType
54
+ @prop transition
55
55
  @prop respectReducedMotion = true
56
56
  @prop classes
57
57
  @prop ...restProps
@@ -8,7 +8,7 @@ import type { AccordionProps } from "../types";
8
8
  * @prop flush
9
9
  * @prop multiple = false
10
10
  * @prop class: className
11
- * @prop transitionType
11
+ * @prop transition
12
12
  * @prop respectReducedMotion = true
13
13
  * @prop classes
14
14
  * @prop ...restProps
@@ -8,7 +8,7 @@
8
8
  import { prefersReducedMotion } from "svelte/motion";
9
9
  import { accordionItem } from "./theme";
10
10
 
11
- let { children, header, arrowup, arrowdown, open = $bindable(false), transitionType = slide, transitionParams, class: className, classes }: AccordionItemProps = $props();
11
+ let { children, header, arrowup, arrowdown, open = $bindable(false), transition = slide, transitionParams, class: className, classes }: AccordionItemProps = $props();
12
12
 
13
13
  // Get context - it will be undefined if used outside Accordion
14
14
  const ctx = getAccordionContext();
@@ -22,9 +22,9 @@
22
22
  inactive: classes?.inactive || ctx?.classes?.inactive
23
23
  });
24
24
 
25
- const ctxTransitionType = $derived(ctx?.transitionType ?? transitionType);
26
- // Check if transitionType is explicitly set to undefined in props
27
- const useTransition = $derived(transitionType === "none" ? false : ctxTransitionType === "none" ? false : true);
25
+ const ctxTransitionType = $derived(ctx?.transition ?? transition);
26
+ // Check if transition is explicitly set to undefined in props
27
+ const useTransition = $derived(transition === "none" ? false : ctxTransitionType === "none" ? false : true);
28
28
 
29
29
  // Get respectReducedMotion from context (defaults to true)
30
30
  const ctxRespectReducedMotion = $derived(ctx?.respectReducedMotion ?? true);
@@ -81,8 +81,8 @@
81
81
  </h2>
82
82
 
83
83
  {#if useTransition}
84
- {#if open && transitionType !== "none"}
85
- <div data-part="content-wrapper" class={contentWrapperCls} transition:transitionType={effectiveTransitionParams as ParamsType}>
84
+ {#if open && transition !== "none"}
85
+ <div data-part="content-wrapper" class={contentWrapperCls} transition:transition={effectiveTransitionParams as ParamsType}>
86
86
  <div data-part="content" class={content({ class: clsx(theme?.content, finalClasses.content) })}>
87
87
  {@render children()}
88
88
  </div>
@@ -107,7 +107,7 @@
107
107
  @prop arrowup
108
108
  @prop arrowdown
109
109
  @prop open = $bindable(false)
110
- @prop transitionType = slide
110
+ @prop transition = slide
111
111
  @prop transitionParams
112
112
  @prop class: className
113
113
  @prop classes
@@ -9,7 +9,7 @@ import type { AccordionItemProps } from "..";
9
9
  * @prop arrowup
10
10
  * @prop arrowdown
11
11
  * @prop open = $bindable(false)
12
- * @prop transitionType = slide
12
+ * @prop transition = slide
13
13
  * @prop transitionParams
14
14
  * @prop class: className
15
15
  * @prop classes
@@ -19,7 +19,7 @@
19
19
  class: className,
20
20
  dismissable,
21
21
  transition = fade,
22
- params,
22
+ transitionParams,
23
23
  listContent,
24
24
  borderAccent,
25
25
  closeButtonProps,
@@ -46,7 +46,7 @@
46
46
  const isBrowser = typeof window !== "undefined";
47
47
 
48
48
  // Respect reduced motion preference by setting duration to 0
49
- const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...params, duration: 0 } : params);
49
+ const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...transitionParams, duration: 0 } : transitionParams);
50
50
 
51
51
  let ref: HTMLDivElement | undefined = $state(undefined);
52
52
 
@@ -111,7 +111,7 @@
111
111
  @prop class: className
112
112
  @prop dismissable
113
113
  @prop transition = fade
114
- @prop params
114
+ @prop transitionParams
115
115
  @prop listContent
116
116
  @prop borderAccent
117
117
  @prop closeButtonProps
@@ -14,7 +14,7 @@ import { type AlertProps } from "..";
14
14
  * @prop class: className
15
15
  * @prop dismissable
16
16
  * @prop transition = fade
17
- * @prop params
17
+ * @prop transitionParams
18
18
  * @prop listContent
19
19
  * @prop borderAccent
20
20
  * @prop closeButtonProps
@@ -22,7 +22,7 @@
22
22
  target,
23
23
  rounded,
24
24
  transition = fade,
25
- params,
25
+ transitionParams,
26
26
  closeButtonProps,
27
27
  ...restProps
28
28
  }: BadgeProps = $props();
@@ -49,7 +49,7 @@
49
49
  const isBrowser = typeof window !== "undefined";
50
50
 
51
51
  // Respect reduced motion preference by setting duration to 0
52
- const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...params, duration: 0 } : params);
52
+ const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...transitionParams, duration: 0 } : transitionParams);
53
53
 
54
54
  let ref: HTMLDivElement | undefined = $state(undefined);
55
55
 
@@ -103,7 +103,7 @@
103
103
  @prop target
104
104
  @prop rounded
105
105
  @prop transition = fade
106
- @prop params
106
+ @prop transitionParams
107
107
  @prop closeButtonProps
108
108
  @prop ...restProps
109
109
  -->
@@ -17,7 +17,7 @@ import { type BadgeProps } from "..";
17
17
  * @prop target
18
18
  * @prop rounded
19
19
  * @prop transition = fade
20
- * @prop params
20
+ * @prop transitionParams
21
21
  * @prop closeButtonProps
22
22
  * @prop ...restProps
23
23
  */
@@ -18,7 +18,7 @@
18
18
  class: className,
19
19
  classes,
20
20
  transition = fade,
21
- params,
21
+ transitionParams,
22
22
  onclose,
23
23
  closeButtonProps,
24
24
  ...restProps
@@ -35,7 +35,7 @@
35
35
  const isBrowser = typeof window !== "undefined";
36
36
 
37
37
  // Respect reduced motion preference by setting duration to 0
38
- const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...params, duration: 0 } : params);
38
+ const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...transitionParams, duration: 0 } : transitionParams);
39
39
 
40
40
  let ref: HTMLDivElement | undefined = $state(undefined);
41
41
  function close(event: MouseEvent) {
@@ -86,7 +86,7 @@
86
86
  @prop class: className
87
87
  @prop classes
88
88
  @prop transition = fade
89
- @prop params
89
+ @prop transitionParams
90
90
  @prop onclose
91
91
  @prop closeButtonProps
92
92
  @prop ...restProps
@@ -13,7 +13,7 @@ import { type BannerProps } from "..";
13
13
  * @prop class: className
14
14
  * @prop classes
15
15
  * @prop transition = fade
16
- * @prop params
16
+ * @prop transitionParams
17
17
  * @prop onclose
18
18
  * @prop closeButtonProps
19
19
  * @prop ...restProps
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { innerWidth, innerHeight } from "svelte/reactivity/window";
2
3
  import type { DrawerProps } from "..";
3
4
  import Dialog from "../dialog/Dialog.svelte";
4
5
  import { getTheme } from "../theme-provider/themeUtils";
@@ -71,12 +72,14 @@
71
72
 
72
73
  // set the values for transition start position
73
74
  const dlg = ev.currentTarget;
74
- const { innerWidth = 0, innerHeight = 0 } = dlg.ownerDocument.defaultView ?? {};
75
-
76
75
  const rect = dlg.getBoundingClientRect();
77
76
 
78
- x = placement === "left" ? rect.left : placement === "right" ? rect.right - innerWidth : undefined;
79
- y = placement === "top" ? rect.top : placement === "bottom" ? rect.bottom - innerHeight : undefined;
77
+ const vw = innerWidth.current ?? 0;
78
+ const vh = innerHeight.current ?? 0;
79
+
80
+ x = placement === "left" ? rect.left : placement === "right" ? rect.right - vw : undefined;
81
+
82
+ y = placement === "top" ? rect.top : placement === "bottom" ? rect.bottom - vh : undefined;
80
83
 
81
84
  await tick(); // let transition start
82
85
 
@@ -236,7 +236,14 @@
236
236
  {#if children}
237
237
  {@render children({ item, clear: () => clearThisOption(item) })}
238
238
  {:else}
239
- <Badge color="gray" large={size === "lg"} dismissable params={{ duration: 100 }} onclose={() => clearThisOption(item)} class={["mx-0.5 px-2 py-0", disabled && "pointer-events-none"]}>
239
+ <Badge
240
+ color="gray"
241
+ large={size === "lg"}
242
+ dismissable
243
+ transitionParams={{ duration: 100 }}
244
+ onclose={() => clearThisOption(item)}
245
+ class={["mx-0.5 px-2 py-0", disabled && "pointer-events-none"]}
246
+ >
240
247
  {item.name}
241
248
  </Badge>
242
249
  {/if}
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { innerWidth } from "svelte/reactivity/window";
2
3
  import type { Attachment } from "svelte/attachments";
3
4
  import type { SidebarContextType, SidebarProps } from "../types";
4
5
  import { getTheme } from "../theme-provider/themeUtils";
@@ -21,7 +22,7 @@
21
22
  activateClickOutside = true,
22
23
  backdrop = true,
23
24
  transition = fly,
24
- params,
25
+ transitionParams,
25
26
  ariaLabel,
26
27
  activeUrl = "",
27
28
  class: className,
@@ -42,8 +43,7 @@
42
43
  "2xl": 1536
43
44
  };
44
45
 
45
- let innerWidth: number = $state(-1);
46
- let isLargeScreen = $derived(disableBreakpoints ? false : alwaysOpen || innerWidth >= breakpointValues[breakpoint]);
46
+ let isLargeScreen = $derived(disableBreakpoints ? false : alwaysOpen || (innerWidth.current ?? 0) >= breakpointValues[breakpoint]);
47
47
 
48
48
  // Create reactive context for activeUrl using getter
49
49
  const activeUrlContext = {
@@ -79,9 +79,9 @@
79
79
 
80
80
  const isBrowser = typeof window !== "undefined";
81
81
 
82
- let transitionParams = $derived(
83
- isBrowser && prefersReducedMotion.current ? { ...(params ? params : { x: -320, duration: 200, easing: sineIn }), duration: 0 } : params ? params : { x: -320, duration: 200, easing: sineIn }
84
- );
82
+ const defaultTransitionParams = { x: -320, duration: 200, easing: sineIn };
83
+
84
+ let finalTransitionParams = $derived(isBrowser && prefersReducedMotion.current ? { ...(transitionParams ?? defaultTransitionParams), duration: 0 } : (transitionParams ?? defaultTransitionParams));
85
85
 
86
86
  setSidebarContext(sidebarCtx);
87
87
 
@@ -134,8 +134,6 @@
134
134
  };
135
135
  </script>
136
136
 
137
- <svelte:window bind:innerWidth />
138
-
139
137
  {#if !disableBreakpoints}
140
138
  {#if isOpen || isLargeScreen}
141
139
  {#if isOpen && !alwaysOpen}
@@ -151,7 +149,7 @@
151
149
  {/if}
152
150
  <aside
153
151
  {@attach trapFocusAttachment}
154
- transition:transition={!alwaysOpen ? transitionParams : undefined}
152
+ transition:transition={!alwaysOpen ? finalTransitionParams : undefined}
155
153
  {...restProps}
156
154
  data-scope="sidebar"
157
155
  data-part="base"
@@ -187,7 +185,7 @@
187
185
  @prop activateClickOutside = true
188
186
  @prop backdrop = true
189
187
  @prop transition = fly
190
- @prop params
188
+ @prop transitionParams
191
189
  @prop ariaLabel
192
190
  @prop activeUrl = ""
193
191
  @prop class: className
@@ -14,7 +14,7 @@ import type { SidebarProps } from "../types";
14
14
  * @prop activateClickOutside = true
15
15
  * @prop backdrop = true
16
16
  * @prop transition = fly
17
- * @prop params
17
+ * @prop transitionParams
18
18
  * @prop ariaLabel
19
19
  * @prop activeUrl = ""
20
20
  * @prop class: className
@@ -8,7 +8,20 @@
8
8
  import { slide } from "svelte/transition";
9
9
  import { sidebarDropdownWrapper } from "./theme";
10
10
 
11
- let { children, arrowup, arrowdown, icon, isOpen = $bindable(), label, transition = slide, params, class: className, classes, onclick, ...restProps }: SidebarDropdownWrapperProps = $props();
11
+ let {
12
+ children,
13
+ arrowup,
14
+ arrowdown,
15
+ icon,
16
+ isOpen = $bindable(),
17
+ label,
18
+ transition = slide,
19
+ transitionParams,
20
+ class: className,
21
+ classes,
22
+ onclick,
23
+ ...restProps
24
+ }: SidebarDropdownWrapperProps = $props();
12
25
 
13
26
  const styling = $derived(classes);
14
27
 
@@ -18,7 +31,7 @@
18
31
 
19
32
  const isBrowser = typeof window !== "undefined";
20
33
 
21
- const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...(params as ParamsType), duration: 0 } : (params as ParamsType));
34
+ const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...(transitionParams as ParamsType), duration: 0 } : (transitionParams as ParamsType));
22
35
 
23
36
  let ctx = getSidebarContext() || { isSingle: false };
24
37
 
@@ -88,7 +101,7 @@
88
101
  @prop isOpen = $bindable()
89
102
  @prop label
90
103
  @prop transition = slide
91
- @prop params
104
+ @prop transitionParams
92
105
  @prop class: className
93
106
  @prop classes
94
107
  @prop onclick
@@ -11,7 +11,7 @@ import type { SidebarDropdownWrapperProps } from "../types";
11
11
  * @prop isOpen = $bindable()
12
12
  * @prop label
13
13
  * @prop transition = slide
14
- * @prop params
14
+ * @prop transitionParams
15
15
  * @prop class: className
16
16
  * @prop classes
17
17
  * @prop onclick
@@ -16,7 +16,7 @@
16
16
  color = "primary",
17
17
  position,
18
18
  align = true,
19
- params,
19
+ transitionParams,
20
20
  transition = fly,
21
21
  class: className,
22
22
  classes,
@@ -34,7 +34,7 @@
34
34
  const isBrowser = typeof window !== "undefined";
35
35
 
36
36
  // Respect reduced motion preference by setting duration to 0
37
- const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...params, duration: 0 } : params);
37
+ const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...transitionParams, duration: 0 } : transitionParams);
38
38
 
39
39
  let ref: HTMLDivElement | undefined = $state(undefined);
40
40
 
@@ -88,7 +88,7 @@
88
88
  @prop color = "primary"
89
89
  @prop position
90
90
  @prop align = true
91
- @prop params
91
+ @prop transitionParams
92
92
  @prop transition = fly
93
93
  @prop class: className
94
94
  @prop classes
@@ -11,7 +11,7 @@ import type { ToastProps } from "../types";
11
11
  * @prop color = "primary"
12
12
  * @prop position
13
13
  * @prop align = true
14
- * @prop params
14
+ * @prop transitionParams
15
15
  * @prop transition = fly
16
16
  * @prop class: className
17
17
  * @prop classes
package/dist/types.d.ts CHANGED
@@ -160,7 +160,7 @@ export type AnchorButtonDivAttributes = ({
160
160
  export interface AccordionProps extends AccordionVariants, Omit<HTMLAttributes<HTMLDivElement>, "color"> {
161
161
  children: Snippet;
162
162
  multiple?: boolean;
163
- transitionType?: TransitionFunc | "none";
163
+ transition?: TransitionFunc | "none";
164
164
  respectReducedMotion?: boolean;
165
165
  classes?: Partial<{
166
166
  button?: ClassValue;
@@ -175,7 +175,7 @@ export interface AccordionItemProps extends AccordionItemVariants, HTMLAttribute
175
175
  header?: Snippet;
176
176
  arrowup?: Snippet;
177
177
  arrowdown?: Snippet;
178
- transitionType?: TransitionFunc | "none";
178
+ transition?: TransitionFunc | "none";
179
179
  transitionParams?: ParamsType;
180
180
  }
181
181
  export interface AlertProps extends Omit<AlertVariants, "icon">, Omit<HTMLAttributes<HTMLDivElement>, "color"> {
@@ -184,7 +184,7 @@ export interface AlertProps extends Omit<AlertVariants, "icon">, Omit<HTMLAttrib
184
184
  alertStatus?: boolean;
185
185
  closeIcon?: Component;
186
186
  transition?: TransitionFunc;
187
- params?: ParamsType;
187
+ transitionParams?: ParamsType;
188
188
  onclick?: () => void;
189
189
  listContent?: boolean;
190
190
  borderAccent?: boolean;
@@ -209,7 +209,7 @@ export interface BadgeProps extends Omit<BadgeVariants, "href">, Omit<HTMLAttrib
209
209
  href?: HTMLAnchorAttributes["href"];
210
210
  target?: HTMLAnchorAttributes["target"];
211
211
  transition?: TransitionFunc;
212
- params?: ParamsType;
212
+ transitionParams?: ParamsType;
213
213
  closeButtonProps?: CloseButtonConfig;
214
214
  }
215
215
  export interface BannerProps extends BannerVariants, Omit<HTMLAttributes<HTMLDivElement>, "color" | "onclose"> {
@@ -217,7 +217,7 @@ export interface BannerProps extends BannerVariants, Omit<HTMLAttributes<HTMLDiv
217
217
  open?: boolean;
218
218
  dismissable?: boolean;
219
219
  transition?: TransitionFunc;
220
- params?: ParamsType;
220
+ transitionParams?: ParamsType;
221
221
  onclose?: (ev: MouseEvent) => void;
222
222
  closeButtonProps?: CloseButtonConfig;
223
223
  }
@@ -270,7 +270,7 @@ export interface GradientButtonProps extends GradientButtonVariants, HTMLButtonO
270
270
  }
271
271
  export interface AccordionContextType {
272
272
  flush?: boolean;
273
- transitionType?: TransitionFunc | "none";
273
+ transition?: TransitionFunc | "none";
274
274
  respectReducedMotion?: boolean;
275
275
  classes?: Partial<{
276
276
  button?: ClassValue;
@@ -984,8 +984,8 @@ export interface PaginationProps extends PaginationVariants, HTMLLiAttributes {
984
984
  export interface PopoverProps extends PopoverVariants, Omit<PopperProps, "title"> {
985
985
  title?: Snippet | string;
986
986
  color?: PopoverVariants["color"];
987
- params?: ParamsType;
988
987
  transition?: TransitionFunc;
988
+ transitionParams?: ParamsType;
989
989
  isOpen?: boolean;
990
990
  }
991
991
  export interface ProgressbarProps extends ProgressbarVariants, Omit<HTMLAttributes<HTMLDivElement>, "color"> {
@@ -1118,8 +1118,8 @@ export interface SidebarProps extends SidebarVariants, HTMLAttributes<HTMLElemen
1118
1118
  activateClickOutside?: boolean;
1119
1119
  isSingle?: boolean;
1120
1120
  ariaLabel?: string;
1121
- params?: ParamsType;
1122
1121
  transition?: TransitionFunc;
1122
+ transitionParams?: ParamsType;
1123
1123
  backdrop?: boolean;
1124
1124
  activeUrl?: string;
1125
1125
  alwaysOpen?: boolean;
@@ -1151,8 +1151,8 @@ export interface SidebarDropdownWrapperProps extends SidebarDropdownWrapperVaria
1151
1151
  icon?: Snippet;
1152
1152
  isOpen?: boolean;
1153
1153
  label?: string;
1154
- params?: ParamsType;
1155
1154
  transition?: TransitionFunc;
1155
+ transitionParams?: ParamsType;
1156
1156
  onclick?: () => void;
1157
1157
  isSingle?: boolean;
1158
1158
  }
@@ -1529,8 +1529,8 @@ export interface ToastProps extends ToastVaraints, HTMLAttributes<HTMLDivElement
1529
1529
  color?: ToastVaraints["color"];
1530
1530
  position?: ToastVaraints["position"];
1531
1531
  align?: boolean;
1532
- params?: ParamsType;
1533
1532
  transition?: TransitionFunc;
1533
+ transitionParams?: ParamsType;
1534
1534
  class?: string;
1535
1535
  closeButtonProps?: CloseButtonConfig;
1536
1536
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowbite-svelte",
3
- "version": "2.0.0-next.8",
3
+ "version": "2.0.0-next.9",
4
4
  "description": "Flowbite components for Svelte",
5
5
  "author": {
6
6
  "name": "Shinichi Okada",