odj-svelte-ui 0.2.1 → 0.2.2
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.
- package/README.md +2 -2
- package/dist/dropdown/Dropdown.svelte +51 -13
- package/dist/dropdown/Dropdown.svelte.d.ts +6 -5
- package/dist/dropdown/theme.d.ts +0 -8
- package/dist/dropdown/theme.js +1 -2
- package/dist/dropdown/type.d.ts +9 -5
- package/dist/tooltip/Tooltip.svelte +25 -34
- package/dist/tooltip/Tooltip.svelte.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,6 @@ This is a fork from [Flowbite for Svelte 5 with Runes](https://svelte-5-ui-lib.c
|
|
|
15
15
|
- `Textarea` is fixed;
|
|
16
16
|
- `Pagination` respect max-width;
|
|
17
17
|
- `Modal` title has a better size, improved default animations with control of backdrop's animations and removed the outdated divider;
|
|
18
|
-
- `Label` now has `space-y-1` by default, a new default color and the `disabled` prop;
|
|
19
18
|
- `Input:Search` has a better X button for Chromium browsers;
|
|
20
19
|
- `Radio` has a new design and it's animated;
|
|
21
20
|
- `Header` has blur, some small design tweaks and a fixed design for the menu on mobile;
|
|
@@ -26,8 +25,9 @@ This is a fork from [Flowbite for Svelte 5 with Runes](https://svelte-5-ui-lib.c
|
|
|
26
25
|
- The `Tooltip` component received a rework;
|
|
27
26
|
- `Modal` has <kbd>Esc</kbd> to close again;
|
|
28
27
|
- `Button` has now a built-in loading state and can be controlled by the `loading` prop;
|
|
28
|
+
- `Label` now has `space-y-1` by default, a new default color and the `disabled` prop;
|
|
29
29
|
- `Textarea` can autoexpand as user type, control this by `autoexpand` and `maxRows` props;
|
|
30
|
-
- `Dropdown` now locks the page scroll and you can
|
|
30
|
+
- `Dropdown` now locks the page scroll and you can enable this default behaviour setting `lock` to `true`. Also, it uses a new strategy instead of `uiHelpers`;
|
|
31
31
|
- `Avatar` supports a `fallback` snippet to show when the image is loading or can't be loaded;
|
|
32
32
|
- `Sidebar` can not be opened or closed anymore. If you want this behaviour, this component should be inside the `Drawer` component. On mobile, `Sidebar` will look like tabs;
|
|
33
33
|
- `SidebarButton` has been removed. Please use the `Drawer` component to maintain the old sidebar behaviour;
|
|
@@ -1,13 +1,51 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { type DropdownProps as Props, dropdown } from "./";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { autoUpdate, flip, offset as floatingUIOffset, useClick, useDismiss, useFloating, useInteractions, useRole } from "@skeletonlabs/floating-ui-svelte";
|
|
4
|
+
import { fade, fly } from "svelte/transition";
|
|
5
5
|
import { setContext } from "svelte";
|
|
6
6
|
import { writable } from "svelte/store";
|
|
7
7
|
|
|
8
|
-
let { children,
|
|
8
|
+
let { children, open = $bindable(false), triggeredBy, position: placement = "bottom", offset = 8, class: className, transitionIn = fade, transitionInParams = { duration: 200 }, transitionOut = fly, transitionOutParams = { y: -5 }, activeUrl = "", lock = false, ...restProps }: Props = $props();
|
|
9
9
|
|
|
10
|
-
const { base
|
|
10
|
+
const { base } = $derived(dropdown());
|
|
11
|
+
|
|
12
|
+
// Use Floating
|
|
13
|
+
let floating = $derived(
|
|
14
|
+
useFloating({
|
|
15
|
+
get open() {
|
|
16
|
+
return open;
|
|
17
|
+
},
|
|
18
|
+
onOpenChange: (v) => {
|
|
19
|
+
open = v;
|
|
20
|
+
},
|
|
21
|
+
whileElementsMounted: autoUpdate,
|
|
22
|
+
placement,
|
|
23
|
+
get middleware() {
|
|
24
|
+
return [floatingUIOffset(offset), flip()];
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// Interactions
|
|
30
|
+
let role = $derived(useRole(floating.context));
|
|
31
|
+
let behaviour = $derived(useClick(floating.context));
|
|
32
|
+
let dismiss = $derived(useDismiss(floating.context));
|
|
33
|
+
let interactions = $derived(useInteractions([role, behaviour, dismiss]));
|
|
34
|
+
|
|
35
|
+
// Get elements
|
|
36
|
+
$effect(() => {
|
|
37
|
+
let triggerElement = document.querySelector(triggeredBy);
|
|
38
|
+
if (!triggerElement) return;
|
|
39
|
+
|
|
40
|
+
floating.elements.reference = triggerElement;
|
|
41
|
+
|
|
42
|
+
// Assign the props to the element
|
|
43
|
+
Object.entries(interactions.getReferenceProps()).forEach(([key, value]) => {
|
|
44
|
+
(triggerElement as any)[key] = value;
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Active URL
|
|
11
49
|
const activeUrlStore = writable("");
|
|
12
50
|
setContext("activeUrl", activeUrlStore);
|
|
13
51
|
|
|
@@ -15,8 +53,9 @@
|
|
|
15
53
|
activeUrlStore.set(activeUrl ?? "");
|
|
16
54
|
});
|
|
17
55
|
|
|
56
|
+
// Lock scroll system
|
|
18
57
|
$effect(() => {
|
|
19
|
-
if (
|
|
58
|
+
if (open && lock) {
|
|
20
59
|
const scrollWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
21
60
|
document.body.style.overflow = "hidden";
|
|
22
61
|
document.body.style.paddingRight = `${scrollWidth}px`;
|
|
@@ -28,23 +67,22 @@
|
|
|
28
67
|
</script>
|
|
29
68
|
|
|
30
69
|
<!-- Dropdown menu -->
|
|
31
|
-
{#if
|
|
32
|
-
<div {...
|
|
70
|
+
{#if open}
|
|
71
|
+
<div bind:this={floating.elements.floating} style={floating.floatingStyles} {...interactions.getFloatingProps()} class={base({ class: className })} in:transitionIn={transitionInParams} out:transitionOut={transitionOutParams} {...restProps}>
|
|
33
72
|
{@render children()}
|
|
34
73
|
</div>
|
|
35
|
-
|
|
36
|
-
<div role="presentation" class={backdrop({ class: backdropClass })} onclick={closeDropdown}></div>
|
|
37
74
|
{/if}
|
|
38
75
|
|
|
39
76
|
<!--
|
|
40
77
|
@component
|
|
41
78
|
[Go to docs](https://svelte-5-ui-lib.codewithshin.com/)
|
|
42
79
|
## Props
|
|
43
|
-
@props:
|
|
44
|
-
@props:
|
|
45
|
-
@props:
|
|
80
|
+
@props:children: any;
|
|
81
|
+
@props:open: any = $bindable();
|
|
82
|
+
@props:triggeredBy: any;
|
|
83
|
+
@props:position: string;
|
|
84
|
+
@props:offset: number;
|
|
46
85
|
@props:class: string;
|
|
47
|
-
@props:backdropClass: any;
|
|
48
86
|
@props:params: any;
|
|
49
87
|
@props:transition: any = fly;
|
|
50
88
|
@props:activeUrl: any = "";
|
|
@@ -2,15 +2,16 @@ import { type DropdownProps as Props } from "./";
|
|
|
2
2
|
/**
|
|
3
3
|
* [Go to docs](https://svelte-5-ui-lib.codewithshin.com/)
|
|
4
4
|
* ## Props
|
|
5
|
-
* @props:
|
|
6
|
-
* @props:
|
|
7
|
-
* @props:
|
|
5
|
+
* @props:children: any;
|
|
6
|
+
* @props:open: any = $bindable();
|
|
7
|
+
* @props:triggeredBy: any;
|
|
8
|
+
* @props:position: string;
|
|
9
|
+
* @props:offset: number;
|
|
8
10
|
* @props:class: string;
|
|
9
|
-
* @props:backdropClass: any;
|
|
10
11
|
* @props:params: any;
|
|
11
12
|
* @props:transition: any = fly;
|
|
12
13
|
* @props:activeUrl: any = "";
|
|
13
14
|
*/
|
|
14
|
-
declare const Dropdown: import("svelte").Component<Props, {}, "
|
|
15
|
+
declare const Dropdown: import("svelte").Component<Props, {}, "open">;
|
|
15
16
|
type Dropdown = ReturnType<typeof Dropdown>;
|
|
16
17
|
export default Dropdown;
|
package/dist/dropdown/theme.d.ts
CHANGED
|
@@ -2,44 +2,36 @@ export declare const dropdown: import("tailwind-variants").TVReturnType<{
|
|
|
2
2
|
[key: string]: {
|
|
3
3
|
[key: string]: import("tailwind-variants").ClassValue | {
|
|
4
4
|
base?: import("tailwind-variants").ClassValue;
|
|
5
|
-
backdrop?: import("tailwind-variants").ClassValue;
|
|
6
5
|
};
|
|
7
6
|
};
|
|
8
7
|
} | {
|
|
9
8
|
[x: string]: {
|
|
10
9
|
[x: string]: import("tailwind-variants").ClassValue | {
|
|
11
10
|
base?: import("tailwind-variants").ClassValue;
|
|
12
|
-
backdrop?: import("tailwind-variants").ClassValue;
|
|
13
11
|
};
|
|
14
12
|
};
|
|
15
13
|
} | {}, {
|
|
16
14
|
base: string;
|
|
17
|
-
backdrop: string;
|
|
18
15
|
}, undefined, import("tailwind-variants/dist/config").TVConfig<unknown, {
|
|
19
16
|
[key: string]: {
|
|
20
17
|
[key: string]: import("tailwind-variants").ClassValue | {
|
|
21
18
|
base?: import("tailwind-variants").ClassValue;
|
|
22
|
-
backdrop?: import("tailwind-variants").ClassValue;
|
|
23
19
|
};
|
|
24
20
|
};
|
|
25
21
|
} | {}>, {
|
|
26
22
|
[key: string]: {
|
|
27
23
|
[key: string]: import("tailwind-variants").ClassValue | {
|
|
28
24
|
base?: import("tailwind-variants").ClassValue;
|
|
29
|
-
backdrop?: import("tailwind-variants").ClassValue;
|
|
30
25
|
};
|
|
31
26
|
};
|
|
32
27
|
} | {}, {
|
|
33
28
|
base: string;
|
|
34
|
-
backdrop: string;
|
|
35
29
|
}, import("tailwind-variants").TVReturnType<unknown, {
|
|
36
30
|
base: string;
|
|
37
|
-
backdrop: string;
|
|
38
31
|
}, undefined, import("tailwind-variants/dist/config").TVConfig<unknown, {
|
|
39
32
|
[key: string]: {
|
|
40
33
|
[key: string]: import("tailwind-variants").ClassValue | {
|
|
41
34
|
base?: import("tailwind-variants").ClassValue;
|
|
42
|
-
backdrop?: import("tailwind-variants").ClassValue;
|
|
43
35
|
};
|
|
44
36
|
};
|
|
45
37
|
} | {}>, unknown, unknown, undefined>>;
|
package/dist/dropdown/theme.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { tv } from "tailwind-variants";
|
|
2
2
|
export const dropdown = tv({
|
|
3
3
|
slots: {
|
|
4
|
-
base: "z-10 w-max
|
|
5
|
-
backdrop: "fixed top-0 start-0 w-full h-full"
|
|
4
|
+
base: "z-10 w-max rounded-xl shadow-lg bg-white dark:bg-dark-surface-700 text-light-surface-700 dark:text-dark-surface-200 border border-light-surface-200 dark:border-dark-surface-600 divide-y divide-light-surface-100 dark:divide-dark-surface-600 overflow-hidden"
|
|
6
5
|
}
|
|
7
6
|
});
|
|
8
7
|
export const dropdowndivider = tv({
|
package/dist/dropdown/type.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import type { Snippet } from "svelte";
|
|
2
2
|
import type { ParamsType, TransitionFunc } from "../types";
|
|
3
3
|
import type { HTMLAttributes, HTMLAnchorAttributes } from "svelte/elements";
|
|
4
|
+
type Placement = "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end" | undefined;
|
|
4
5
|
interface DropdownProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
6
|
children: Snippet;
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
open: boolean;
|
|
8
|
+
triggeredBy: string;
|
|
9
|
+
position?: Placement;
|
|
10
|
+
offset?: number;
|
|
8
11
|
divClass?: string;
|
|
9
12
|
footerClass?: string;
|
|
10
13
|
headerClass?: string;
|
|
11
14
|
ulClass?: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
transitionIn?: TransitionFunc;
|
|
16
|
+
transitionInParams?: ParamsType;
|
|
17
|
+
transitionOut?: TransitionFunc;
|
|
18
|
+
transitionOutParams?: ParamsType;
|
|
15
19
|
activeUrl?: string;
|
|
16
20
|
lock?: boolean;
|
|
17
21
|
}
|
|
@@ -1,43 +1,34 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { tooltip } from "./theme";
|
|
3
3
|
import type { TooltipProps } from ".";
|
|
4
|
-
import {
|
|
5
|
-
FloatingArrow,
|
|
6
|
-
arrow,
|
|
7
|
-
autoUpdate,
|
|
8
|
-
flip,
|
|
9
|
-
offset as floatingUIOffset,
|
|
10
|
-
useDismiss,
|
|
11
|
-
useFloating,
|
|
12
|
-
useHover,
|
|
13
|
-
useInteractions,
|
|
14
|
-
useRole,
|
|
15
|
-
} from "@skeletonlabs/floating-ui-svelte";
|
|
4
|
+
import { FloatingArrow, arrow, autoUpdate, flip, offset as floatingUIOffset, useDismiss, useFloating, useHover, useInteractions, useRole } from "@skeletonlabs/floating-ui-svelte";
|
|
16
5
|
import { fade } from "svelte/transition";
|
|
17
6
|
|
|
18
|
-
let { children, color = "default", arrow: showArrow = false, offset = 8, triggeredBy, position = "top", class: className, arrowClass, open = $bindable(false), transition = fade, transitionOptions = { duration: 200 }, ...restProps }: TooltipProps = $props();
|
|
7
|
+
let { children, color = "default", arrow: showArrow = false, offset = 8, triggeredBy, position: placement = "top", class: className, arrowClass, open = $bindable(false), transition = fade, transitionOptions = { duration: 200 }, ...restProps }: TooltipProps = $props();
|
|
19
8
|
|
|
20
9
|
let arrowElement: HTMLElement | null = $state(null);
|
|
21
10
|
|
|
22
11
|
let { base, arrowBase } = $derived(tooltip({ color }));
|
|
23
|
-
|
|
12
|
+
|
|
24
13
|
// State
|
|
25
14
|
let elemArrow: HTMLElement | null = $state(null);
|
|
26
15
|
|
|
27
16
|
// Use Floating
|
|
28
|
-
let floating = $derived(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
17
|
+
let floating = $derived(
|
|
18
|
+
useFloating({
|
|
19
|
+
whileElementsMounted: autoUpdate,
|
|
20
|
+
get open() {
|
|
21
|
+
return open;
|
|
22
|
+
},
|
|
23
|
+
onOpenChange: (v) => {
|
|
24
|
+
open = v;
|
|
25
|
+
},
|
|
26
|
+
placement,
|
|
27
|
+
get middleware() {
|
|
28
|
+
return [floatingUIOffset(offset), flip(), elemArrow && arrow({ element: elemArrow })];
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
);
|
|
41
32
|
|
|
42
33
|
// Interactions
|
|
43
34
|
let role = $derived(useRole(floating.context, { role: "tooltip" }));
|
|
@@ -48,22 +39,22 @@
|
|
|
48
39
|
// Get elements
|
|
49
40
|
$effect(() => {
|
|
50
41
|
let triggerElement = document.querySelector(triggeredBy);
|
|
51
|
-
if (!triggerElement) return;
|
|
42
|
+
if (!triggerElement) return;
|
|
52
43
|
|
|
53
44
|
floating.elements.reference = triggerElement;
|
|
54
|
-
|
|
45
|
+
|
|
55
46
|
// Assign the props to the element
|
|
56
47
|
Object.entries(interactions.getReferenceProps()).forEach(([key, value]) => {
|
|
57
|
-
triggerElement[key] = value;
|
|
48
|
+
(triggerElement as any)[key] = value;
|
|
58
49
|
});
|
|
59
|
-
})
|
|
50
|
+
});
|
|
60
51
|
</script>
|
|
61
52
|
|
|
62
53
|
{#if open}
|
|
63
54
|
<div role="tooltip" bind:this={floating.elements.floating} style={floating.floatingStyles} {...interactions.getFloatingProps()} transition:transition={transitionOptions} {...restProps} class={base({ className })}>
|
|
64
55
|
{@render children()}
|
|
65
56
|
{#if showArrow}
|
|
66
|
-
<FloatingArrow bind:ref={arrowElement} context={floating.context} class={arrowBase({className: arrowClass})}/>
|
|
57
|
+
<FloatingArrow bind:ref={arrowElement} context={floating.context} class={arrowBase({ className: arrowClass })} />
|
|
67
58
|
{/if}
|
|
68
59
|
</div>
|
|
69
60
|
{/if}
|
|
@@ -75,7 +66,7 @@
|
|
|
75
66
|
@props:children: any;
|
|
76
67
|
@props:color: any = "default";
|
|
77
68
|
@props:arrow: any = false;
|
|
78
|
-
@props:offset:
|
|
69
|
+
@props:offset: number = 8;
|
|
79
70
|
@props:triggeredBy: any;
|
|
80
71
|
@props:position: string = "top";
|
|
81
72
|
@props:class: string;
|
|
@@ -83,4 +74,4 @@
|
|
|
83
74
|
@props:open: boolean = false;
|
|
84
75
|
@props:transition: any = "fade";
|
|
85
76
|
@props:transitionOptions: object = { duration: 200 };
|
|
86
|
-
-->
|
|
77
|
+
-->
|
|
@@ -5,7 +5,7 @@ import type { TooltipProps } from ".";
|
|
|
5
5
|
* @props:children: any;
|
|
6
6
|
* @props:color: any = "default";
|
|
7
7
|
* @props:arrow: any = false;
|
|
8
|
-
* @props:offset:
|
|
8
|
+
* @props:offset: number = 8;
|
|
9
9
|
* @props:triggeredBy: any;
|
|
10
10
|
* @props:position: string = "top";
|
|
11
11
|
* @props:class: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odj-svelte-ui",
|
|
3
3
|
"author": "orbitadajogatina",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"description": "This is a fork from Flowbite Svelte 5 with Runes. I just made some changes that fits better my taste.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|