flowbite-svelte 0.27.5 → 0.27.6
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/CHANGELOG.md +15 -0
- package/breadcrumbs/BreadcrumbItem.svelte +37 -44
- package/breadcrumbs/BreadcrumbItem.svelte.d.ts +1 -0
- package/buttons/Button.svelte +2 -6
- package/buttons/Button.svelte.d.ts +2 -2
- package/cards/Card.svelte +12 -12
- package/cards/Card.svelte.d.ts +3 -2
- package/carousels/CarouselTransition.svelte +1 -1
- package/carousels/Thumbnail.svelte +9 -1
- package/darkmode/DarkMode.svelte +27 -24
- package/drawer/Drawer.svelte +26 -13
- package/drawer/Drawer.svelte.d.ts +1 -0
- package/forms/Checkbox.svelte +17 -18
- package/forms/FloatingLabelInput.svelte.d.ts +1 -1
- package/forms/Helper.svelte.d.ts +1 -1
- package/forms/Input.svelte +22 -20
- package/forms/Input.svelte.d.ts +7 -2
- package/forms/Label.svelte.d.ts +1 -1
- package/forms/NumberInput.svelte +7 -0
- package/forms/NumberInput.svelte.d.ts +16 -0
- package/forms/Toggle.svelte +4 -13
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/list-group/ListgroupItem.svelte +38 -40
- package/modals/Modal.svelte.d.ts +2 -1
- package/package.json +5 -4
- package/ratings/Rating.svelte +21 -20
- package/ratings/Rating.svelte.d.ts +1 -0
- package/tables/Table.svelte.d.ts +1 -1
- package/tables/TableSearch.svelte.d.ts +1 -1
- package/tooltips/Tooltip.svelte.d.ts +1 -1
- package/typography/P.svelte.d.ts +1 -1
- package/utils/Frame.svelte +1 -1
- package/utils/Frame.svelte.d.ts +1 -1
- package/utils/Popper.svelte +19 -16
- package/utils/focusTrap.js +15 -24
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.27.6](https://github.com/themesberg/flowbite-svelte/compare/v0.27.5...v0.27.6) (2022-10-09)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* card padding-x in mobile view ([#358](https://github.com/themesberg/flowbite-svelte/issues/358)) ([639457f](https://github.com/themesberg/flowbite-svelte/commit/639457f5efc54f38fda9288aa9cf017c2d0f883d))
|
|
11
|
+
* color flicker when changing theme using DarkMode ([#353](https://github.com/themesberg/flowbite-svelte/issues/353)) ([7e1daf1](https://github.com/themesberg/flowbite-svelte/commit/7e1daf14b1b91b0f3c0dac55c38e28fee42c4878))
|
|
12
|
+
* improved focustrap ([#354](https://github.com/themesberg/flowbite-svelte/issues/354)) ([fb17cd3](https://github.com/themesberg/flowbite-svelte/commit/fb17cd357e748df4b1d95060bcbecf7b406d3f03))
|
|
13
|
+
* input icons ([#350](https://github.com/themesberg/flowbite-svelte/issues/350)) ([7b72712](https://github.com/themesberg/flowbite-svelte/commit/7b727121b3b730eb552200c1de36f3cdc45f7977))
|
|
14
|
+
* input number workaround ([#351](https://github.com/themesberg/flowbite-svelte/issues/351)) ([e4cb012](https://github.com/themesberg/flowbite-svelte/commit/e4cb01221c3b4334a2c860aa32ccee06df2fe41d))
|
|
15
|
+
* remove // [@ts-ignore](https://github.com/ts-ignore) ([ea82a2b](https://github.com/themesberg/flowbite-svelte/commit/ea82a2bc22085bad26967a82d078d8ab86b2477d))
|
|
16
|
+
* remove package-lock, pnpm-lock and node_modules and reinstall ([a8985ea](https://github.com/themesberg/flowbite-svelte/commit/a8985ea2fdb7c18eb23e61dd163e65da98a53ae4))
|
|
17
|
+
* remove svelte-sidebar-menu ([2820488](https://github.com/themesberg/flowbite-svelte/commit/28204885bbefcb826e073a1e6b7127a0b488b752))
|
|
18
|
+
* ts types for Popper ([#362](https://github.com/themesberg/flowbite-svelte/issues/362)) ([4a22230](https://github.com/themesberg/flowbite-svelte/commit/4a22230d66d780cb2d5c189266f97c87c251b70a))
|
|
19
|
+
|
|
5
20
|
### [0.27.5](https://github.com/themesberg/flowbite-svelte/compare/v0.27.4...v0.27.5) (2022-10-01)
|
|
6
21
|
|
|
7
22
|
|
|
@@ -1,51 +1,44 @@
|
|
|
1
1
|
<script>export let home = false;
|
|
2
|
+
export let href = undefined;
|
|
2
3
|
export let linkClass = 'ml-1 text-sm font-medium text-gray-700 hover:text-gray-900 md:ml-2 dark:text-gray-400 dark:hover:text-white';
|
|
3
4
|
export let spanClass = 'ml-1 text-sm font-medium text-gray-500 md:ml-2 dark:text-gray-400';
|
|
4
5
|
export let homeClass = 'inline-flex items-center text-sm font-medium text-gray-700 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white';
|
|
5
6
|
</script>
|
|
6
7
|
|
|
7
|
-
<li class="inline-flex items-center" {...$$
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<slot />
|
|
44
|
-
</a>
|
|
45
|
-
{:else}
|
|
46
|
-
<span class={spanClass}>
|
|
47
|
-
<slot />
|
|
48
|
-
</span>
|
|
49
|
-
{/if}
|
|
50
|
-
{/if}
|
|
8
|
+
<li class="inline-flex items-center" {...$$restProps}>
|
|
9
|
+
{#if home}
|
|
10
|
+
<a class={homeClass} {href}>
|
|
11
|
+
{#if $$slots.icon}
|
|
12
|
+
<slot name="icon" />
|
|
13
|
+
{:else}
|
|
14
|
+
<svg class="w-4 h-4 mr-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
><path
|
|
16
|
+
d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z" /></svg>
|
|
17
|
+
{/if}
|
|
18
|
+
<slot />
|
|
19
|
+
</a>
|
|
20
|
+
{:else}
|
|
21
|
+
{#if $$slots.icon}
|
|
22
|
+
<slot name="icon" />
|
|
23
|
+
{:else}
|
|
24
|
+
<svg
|
|
25
|
+
class="w-6 h-6 text-gray-400"
|
|
26
|
+
fill="currentColor"
|
|
27
|
+
viewBox="0 0 20 20"
|
|
28
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
+
><path
|
|
30
|
+
fill-rule="evenodd"
|
|
31
|
+
d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
|
|
32
|
+
clip-rule="evenodd" /></svg>
|
|
33
|
+
{/if}
|
|
34
|
+
{#if href}
|
|
35
|
+
<a class={linkClass} {href}>
|
|
36
|
+
<slot />
|
|
37
|
+
</a>
|
|
38
|
+
{:else}
|
|
39
|
+
<span class={spanClass}>
|
|
40
|
+
<slot />
|
|
41
|
+
</span>
|
|
42
|
+
{/if}
|
|
43
|
+
{/if}
|
|
51
44
|
</li>
|
package/buttons/Button.svelte
CHANGED
|
@@ -76,16 +76,12 @@ const hasBorder = () => outline || color === 'alternative' || color === 'light';
|
|
|
76
76
|
let buttonClass;
|
|
77
77
|
$: buttonClass = btnClass
|
|
78
78
|
? btnClass
|
|
79
|
-
: classNames('text-center font-medium', group ? 'focus:ring-2' : 'focus:ring-4', group && 'focus:z-10', !group || color === 'alternative' || (outline && color === 'dark') || 'focus:outline-none', outline && gradient
|
|
80
|
-
? 'p-0.5'
|
|
81
|
-
: 'inline-flex items-center justify-center ' + sizeClasses[size], gradient ? gradientClasses[color] : outline ? outlineClasses[color] : colorClasses[color], color === 'alternative' &&
|
|
79
|
+
: classNames('text-center font-medium', group ? 'focus:ring-2' : 'focus:ring-4', group && 'focus:z-10', !group || color === 'alternative' || (outline && color === 'dark') || 'focus:outline-none', outline && gradient ? 'p-0.5' : 'inline-flex items-center justify-center ' + sizeClasses[size], gradient ? gradientClasses[color] : outline ? outlineClasses[color] : colorClasses[color], color === 'alternative' &&
|
|
82
80
|
(group
|
|
83
81
|
? 'dark:bg-gray-700 dark:text-white dark:border-gray-700 dark:hover:border-gray-600 dark:hover:bg-gray-600'
|
|
84
82
|
: 'dark:bg-transparent dark:border-gray-800 dark:hover:border-gray-700'), outline &&
|
|
85
83
|
color === 'dark' &&
|
|
86
|
-
(group
|
|
87
|
-
? 'dark:text-white dark:border-white'
|
|
88
|
-
: 'dark:text-gray-400 dark:border-gray-700'), hasBorder() && group && 'border-l-0 first:border-l', rounded(false), shadow && coloredShadowClasses[shadow], $$props.disabled && 'cursor-not-allowed opacity-50', $$props.class);
|
|
84
|
+
(group ? 'dark:text-white dark:border-white' : 'dark:text-gray-400 dark:border-gray-700'), hasBorder() && group && 'border-l-0 first:border-l', rounded(false), shadow && coloredShadowClasses[shadow], $$props.disabled && 'cursor-not-allowed opacity-50', $$props.class);
|
|
89
85
|
let gradientOutlineClass;
|
|
90
86
|
$: gradientOutlineClass = classNames('inline-flex items-center justify-center', sizeClasses[size], rounded(true), 'bg-white text-gray-900 dark:bg-gray-900 dark:text-white', // this is limitation - no transparency
|
|
91
87
|
'transition-all duration-75 ease-in group-hover:bg-opacity-0 group-hover:text-inherit');
|
|
@@ -10,8 +10,8 @@ declare const __propDef: {
|
|
|
10
10
|
href?: string | undefined;
|
|
11
11
|
btnClass?: string | undefined;
|
|
12
12
|
type?: ButtonType | undefined;
|
|
13
|
-
color?: "
|
|
14
|
-
shadow?: "
|
|
13
|
+
color?: "red" | "yellow" | "green" | "purple" | "pink" | "blue" | "light" | "dark" | "cyan" | "teal" | "lime" | "alternative" | "purpleToBlue" | "cyanToBlue" | "greenToBlue" | "purpleToPink" | "pinkToOrange" | "tealToLime" | "redToYellow" | undefined;
|
|
14
|
+
shadow?: "red" | "green" | "purple" | "pink" | "blue" | "cyan" | "teal" | "lime" | null | undefined;
|
|
15
15
|
};
|
|
16
16
|
events: {
|
|
17
17
|
click: MouseEvent;
|
package/cards/Card.svelte
CHANGED
|
@@ -8,10 +8,10 @@ export let padding = 'lg';
|
|
|
8
8
|
export let size = 'sm';
|
|
9
9
|
const paddings = {
|
|
10
10
|
none: 'p-0',
|
|
11
|
-
sm: 'p-4',
|
|
12
|
-
md: 'p-5',
|
|
13
|
-
lg: 'p-6',
|
|
14
|
-
xl: 'p-8'
|
|
11
|
+
sm: 'p-4 sm:p-6 md:p-8',
|
|
12
|
+
md: 'p-4 sm:p-5',
|
|
13
|
+
lg: 'p-4 sm:p-6',
|
|
14
|
+
xl: 'p-4 sm:p-8'
|
|
15
15
|
};
|
|
16
16
|
const sizes = {
|
|
17
17
|
xs: 'max-w-xs',
|
|
@@ -29,12 +29,12 @@ $: imgClass = classNames(reverse ? 'rounded-b-lg' : 'rounded-t-lg', horizontal &
|
|
|
29
29
|
</script>
|
|
30
30
|
|
|
31
31
|
<Frame tag={href ? 'a' : 'div'} rounded shadow border {href} class={cardClass}>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
{#if img}
|
|
33
|
+
<img class={imgClass} src={img} alt="" />
|
|
34
|
+
<div class={innerPdding}>
|
|
35
|
+
<slot />
|
|
36
|
+
</div>
|
|
37
|
+
{:else}
|
|
38
|
+
<slot />
|
|
39
|
+
{/if}
|
|
40
40
|
</Frame>
|
package/cards/Card.svelte.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { SizeType } from '../types';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
[x: string]: any;
|
|
@@ -6,8 +7,8 @@ declare const __propDef: {
|
|
|
6
7
|
horizontal?: boolean | undefined;
|
|
7
8
|
reverse?: boolean | undefined;
|
|
8
9
|
img?: string | undefined;
|
|
9
|
-
padding?: "sm" | "md" | "lg" | "
|
|
10
|
-
size?:
|
|
10
|
+
padding?: "none" | "sm" | "md" | "lg" | "xl" | undefined;
|
|
11
|
+
size?: SizeType | undefined;
|
|
11
12
|
};
|
|
12
13
|
events: {
|
|
13
14
|
[evt: string]: CustomEvent<any>;
|
|
@@ -34,7 +34,7 @@ const multiple = (node, params) => {
|
|
|
34
34
|
};
|
|
35
35
|
// Slide
|
|
36
36
|
// export let slideClass: string = 'hidden';
|
|
37
|
-
let imageShowingIndex =
|
|
37
|
+
let imageShowingIndex = 0;
|
|
38
38
|
// $: image = images[imageShowingIndex];
|
|
39
39
|
const nextSlide = () => {
|
|
40
40
|
if (imageShowingIndex === images.length - 1) {
|
|
@@ -6,7 +6,15 @@ export let thumbWidth;
|
|
|
6
6
|
export let selected = false;
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
|
-
<img
|
|
9
|
+
<img
|
|
10
|
+
class="opacity-40"
|
|
11
|
+
class:active={selected}
|
|
12
|
+
id={id.toString()}
|
|
13
|
+
src={thumbImg}
|
|
14
|
+
alt={altTag}
|
|
15
|
+
title="Image from {titleLink}"
|
|
16
|
+
on:click
|
|
17
|
+
width="{thumbWidth}%" />
|
|
10
18
|
|
|
11
19
|
<style>
|
|
12
20
|
.active {
|
package/darkmode/DarkMode.svelte
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
export let btnClass = 'text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 fixed left-0 top-8 z-50';
|
|
3
|
-
let dark = false;
|
|
1
|
+
<script>export let btnClass = 'text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 fixed left-0 top-8 z-50';
|
|
4
2
|
const toggleTheme = () => {
|
|
5
|
-
|
|
6
|
-
localStorage.setItem('color-theme',
|
|
3
|
+
const isDark = window.document.documentElement.classList.toggle('dark');
|
|
4
|
+
localStorage.setItem('color-theme', isDark ? 'dark' : 'light');
|
|
7
5
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<svelte:head>
|
|
9
|
+
<script>
|
|
10
|
+
if (window) {
|
|
11
|
+
localStorage.getItem('color-theme') === 'dark' ||
|
|
12
|
+
(!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
|
11
13
|
? window.document.documentElement.classList.add('dark')
|
|
12
14
|
: window.document.documentElement.classList.remove('dark');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
</
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
</svelte:head>
|
|
16
18
|
|
|
17
19
|
<button on:click={toggleTheme} aria-label="Dark mode" type="button" class={btnClass}>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
<span class="hidden dark:block">
|
|
21
|
+
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
|
22
|
+
<path
|
|
23
|
+
d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1
|
|
24
|
+
0 100-2H3a1 1 0 000 2h1z"
|
|
25
|
+
fill-rule="evenodd"
|
|
26
|
+
clip-rule="evenodd" />
|
|
27
|
+
</svg>
|
|
28
|
+
</span>
|
|
29
|
+
<span class="dark:hidden">
|
|
30
|
+
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
|
31
|
+
<path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z" />
|
|
32
|
+
</svg>
|
|
33
|
+
</span>
|
|
31
34
|
</button>
|
package/drawer/Drawer.svelte
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import classNames from 'classnames';
|
|
2
2
|
import { fly, slide, blur, fade } from 'svelte/transition';
|
|
3
3
|
import { clickOutside } from '../utils/clickOutside';
|
|
4
|
+
export let activateClickOutside = true;
|
|
4
5
|
export let hidden = true;
|
|
5
6
|
export let position = 'fixed';
|
|
6
7
|
export let leftOffset = 'inset-y-0 left-0';
|
|
@@ -36,24 +37,36 @@ const placements = {
|
|
|
36
37
|
};
|
|
37
38
|
const handleDrawer = () => {
|
|
38
39
|
hidden = !hidden;
|
|
39
|
-
console.log('clicked');
|
|
40
40
|
};
|
|
41
41
|
let backdropDivClass = classNames('fixed top-0 left-0 z-50 w-full h-full', backdrop && bgColor, backdrop && bgOpacity);
|
|
42
42
|
</script>
|
|
43
43
|
|
|
44
44
|
{#if !hidden}
|
|
45
|
-
{#if backdrop}
|
|
45
|
+
{#if backdrop && activateClickOutside}
|
|
46
46
|
<div class={backdropDivClass} on:click={() => !hidden && handleDrawer()} />
|
|
47
47
|
{/if}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
{#if activateClickOutside}
|
|
49
|
+
<div
|
|
50
|
+
use:clickOutside={() => !hidden && handleDrawer()}
|
|
51
|
+
{id}
|
|
52
|
+
{...$$restProps}
|
|
53
|
+
class={classNames(divClass, width, position, placements[placement], $$props.class)}
|
|
54
|
+
transition:multiple={transitionParams}
|
|
55
|
+
tabindex="-1"
|
|
56
|
+
aria-controls={id}
|
|
57
|
+
aria-labelledby={id}>
|
|
58
|
+
<slot {hidden} />
|
|
59
|
+
</div>
|
|
60
|
+
{:else}
|
|
61
|
+
<div
|
|
62
|
+
{id}
|
|
63
|
+
{...$$restProps}
|
|
64
|
+
class={classNames(divClass, width, position, placements[placement], $$props.class)}
|
|
65
|
+
transition:multiple={transitionParams}
|
|
66
|
+
tabindex="-1"
|
|
67
|
+
aria-controls={id}
|
|
68
|
+
aria-labelledby={id}>
|
|
69
|
+
<slot {hidden} />
|
|
70
|
+
</div>
|
|
71
|
+
{/if}
|
|
59
72
|
{/if}
|
|
@@ -3,6 +3,7 @@ import type { drawerTransitionParamTypes, drawerTransitionTypes } from '../types
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
[x: string]: any;
|
|
6
|
+
activateClickOutside?: boolean | undefined;
|
|
6
7
|
hidden?: boolean | undefined;
|
|
7
8
|
position?: "fixed" | "absolute" | undefined;
|
|
8
9
|
leftOffset?: string | undefined;
|
package/forms/Checkbox.svelte
CHANGED
|
@@ -7,7 +7,7 @@ export let custom = false;
|
|
|
7
7
|
export let inline = false;
|
|
8
8
|
export let group = [];
|
|
9
9
|
export let value = '';
|
|
10
|
-
export let checked =
|
|
10
|
+
export let checked = false;
|
|
11
11
|
// tinted if put in component having its own background
|
|
12
12
|
let background = getContext('background');
|
|
13
13
|
$: {
|
|
@@ -33,21 +33,20 @@ $: {
|
|
|
33
33
|
</script>
|
|
34
34
|
|
|
35
35
|
<Label class={labelClass(inline, $$props.class)} show={!!$$slots.default}>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/><slot />
|
|
36
|
+
<input
|
|
37
|
+
type="checkbox"
|
|
38
|
+
bind:checked
|
|
39
|
+
on:keyup
|
|
40
|
+
on:keydown
|
|
41
|
+
on:keypress
|
|
42
|
+
on:focus
|
|
43
|
+
on:blur
|
|
44
|
+
on:click
|
|
45
|
+
on:mouseover
|
|
46
|
+
on:mouseenter
|
|
47
|
+
on:mouseleave
|
|
48
|
+
on:paste
|
|
49
|
+
{value}
|
|
50
|
+
{...$$restProps}
|
|
51
|
+
class={inputClass(custom, color, true, background, $$slots.default || $$props.class)} /><slot />
|
|
53
52
|
</Label>
|
|
@@ -7,7 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
style?: "filled" | "outlined" | "standard" | undefined;
|
|
8
8
|
type?: InputType | undefined;
|
|
9
9
|
size?: "default" | "small" | undefined;
|
|
10
|
-
color?: "
|
|
10
|
+
color?: "red" | "green" | "base" | undefined;
|
|
11
11
|
value?: string | undefined;
|
|
12
12
|
label?: string | undefined;
|
|
13
13
|
};
|
package/forms/Helper.svelte.d.ts
CHANGED
package/forms/Input.svelte
CHANGED
|
@@ -50,31 +50,33 @@ $: {
|
|
|
50
50
|
const _color = color === 'base' && background ? 'tinted' : color;
|
|
51
51
|
inputClass = classNames(defaultClass, $$slots.left && leftPadding[_size], $$slots.right && rightPadding[_size], ringClasses[color], colorClasses[_color], borderClasses[_color], inputPadding[_size], textSizes[_size], group || 'rounded-lg', group && 'first:rounded-l-lg last:rounded-r-lg', group && 'border-l-0 first:border-l last:border-r', $$props.class);
|
|
52
52
|
}
|
|
53
|
-
let floatClass = 'flex absolute inset-y-0
|
|
53
|
+
let floatClass = 'flex absolute inset-y-0 items-center pointer-events-none text-gray-500 dark:text-gray-400';
|
|
54
54
|
</script>
|
|
55
55
|
|
|
56
56
|
<Wrapper class="relative w-full" show={$$slots.left || $$slots.right}>
|
|
57
57
|
{#if $$slots.left}
|
|
58
|
-
<div class="{floatClass} pl-
|
|
58
|
+
<div class="{floatClass} left-0 pl-2.5"><slot name="left" /></div>
|
|
59
59
|
{/if}
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
<slot props={{ ...$$restProps, class: inputClass }}>
|
|
61
|
+
<input
|
|
62
|
+
{...$$restProps}
|
|
63
|
+
bind:value
|
|
64
|
+
on:blur
|
|
65
|
+
on:change
|
|
66
|
+
on:click
|
|
67
|
+
on:focus
|
|
68
|
+
on:keydown
|
|
69
|
+
on:keypress
|
|
70
|
+
on:keyup
|
|
71
|
+
on:mouseover
|
|
72
|
+
on:mouseenter
|
|
73
|
+
on:mouseleave
|
|
74
|
+
on:paste
|
|
75
|
+
on:input
|
|
76
|
+
use:setType={type}
|
|
77
|
+
class={inputClass} />
|
|
78
|
+
</slot>
|
|
77
79
|
{#if $$slots.right}
|
|
78
|
-
<div class="{floatClass} pr-
|
|
80
|
+
<div class="{floatClass} right-0 pr-2.5"><slot name="right" /></div>
|
|
79
81
|
{/if}
|
|
80
82
|
</Wrapper>
|
package/forms/Input.svelte.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ declare const __propDef: {
|
|
|
6
6
|
props: {
|
|
7
7
|
[x: string]: any;
|
|
8
8
|
type?: InputType | undefined;
|
|
9
|
-
value?: string | undefined;
|
|
9
|
+
value?: string | number | undefined;
|
|
10
10
|
size?: FormSizeType | undefined;
|
|
11
11
|
defaultClass?: string | undefined;
|
|
12
|
-
color?: "
|
|
12
|
+
color?: "red" | "green" | "base" | undefined;
|
|
13
13
|
};
|
|
14
14
|
events: {
|
|
15
15
|
blur: FocusEvent;
|
|
@@ -29,6 +29,11 @@ declare const __propDef: {
|
|
|
29
29
|
};
|
|
30
30
|
slots: {
|
|
31
31
|
left: {};
|
|
32
|
+
default: {
|
|
33
|
+
props: {
|
|
34
|
+
class: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
32
37
|
right: {};
|
|
33
38
|
};
|
|
34
39
|
};
|
package/forms/Label.svelte.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
-
color?: "
|
|
5
|
+
color?: "gray" | "red" | "green" | "disabled" | undefined;
|
|
6
6
|
defaultClass?: string | undefined;
|
|
7
7
|
show?: boolean | undefined;
|
|
8
8
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
value?: number | undefined;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
};
|
|
11
|
+
export declare type NumberInputProps = typeof __propDef.props;
|
|
12
|
+
export declare type NumberInputEvents = typeof __propDef.events;
|
|
13
|
+
export declare type NumberInputSlots = typeof __propDef.slots;
|
|
14
|
+
export default class NumberInput extends SvelteComponentTyped<NumberInputProps, NumberInputEvents, NumberInputSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
package/forms/Toggle.svelte
CHANGED
|
@@ -4,7 +4,7 @@ import Checkbox from './Checkbox.svelte';
|
|
|
4
4
|
export let size = 'default';
|
|
5
5
|
export let group = [];
|
|
6
6
|
export let value = '';
|
|
7
|
-
export let checked =
|
|
7
|
+
export let checked = false;
|
|
8
8
|
// tinted if put in component having its own background
|
|
9
9
|
let background = getContext('background');
|
|
10
10
|
const common = "mr-3 bg-gray-200 rounded-full peer-focus:ring-4 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:bg-white after:border-gray-300 after:border after:rounded-full after:transition-all";
|
|
@@ -26,16 +26,7 @@ let divClass;
|
|
|
26
26
|
$: divClass = classNames(common, background ? 'dark:bg-gray-600 dark:border-gray-500' : 'dark:bg-gray-700 dark:border-gray-600', colors[$$restProps.color ?? 'blue'], sizes[size], 'relative');
|
|
27
27
|
</script>
|
|
28
28
|
|
|
29
|
-
<Checkbox
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class={$$props.class}
|
|
33
|
-
{value}
|
|
34
|
-
bind:checked
|
|
35
|
-
bind:group
|
|
36
|
-
on:click
|
|
37
|
-
on:change
|
|
38
|
-
>
|
|
39
|
-
<div class={divClass} />
|
|
40
|
-
<slot />
|
|
29
|
+
<Checkbox custom {...$$restProps} class={$$props.class} {value} bind:checked bind:group on:click on:change>
|
|
30
|
+
<span class={divClass} />
|
|
31
|
+
<slot />
|
|
41
32
|
</Checkbox>
|
package/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export { default as Iconinput } from './forms/Iconinput.svelte';
|
|
|
32
32
|
export { default as Input } from './forms/Input.svelte';
|
|
33
33
|
export { default as InputAddon } from './forms/InputAddon.svelte';
|
|
34
34
|
export { default as Label } from './forms/Label.svelte';
|
|
35
|
+
export { default as NumberInput } from './forms/NumberInput.svelte';
|
|
35
36
|
export { default as RadioInline } from './forms/RadioInline.svelte';
|
|
36
37
|
export { default as Radio } from './forms/Radio.svelte';
|
|
37
38
|
export { default as Range } from './forms/Range.svelte';
|
package/index.js
CHANGED
|
@@ -47,6 +47,7 @@ export { default as Iconinput } from './forms/Iconinput.svelte';
|
|
|
47
47
|
export { default as Input } from './forms/Input.svelte';
|
|
48
48
|
export { default as InputAddon } from './forms/InputAddon.svelte';
|
|
49
49
|
export { default as Label } from './forms/Label.svelte';
|
|
50
|
+
export { default as NumberInput } from './forms/NumberInput.svelte';
|
|
50
51
|
export { default as RadioInline } from './forms/RadioInline.svelte';
|
|
51
52
|
export { default as Radio } from './forms/Radio.svelte';
|
|
52
53
|
export { default as Range } from './forms/Range.svelte';
|
|
@@ -16,49 +16,47 @@ let hoverClass = 'hover:bg-gray-100 hover:text-blue-700 dark:hover:bg-gray-600 d
|
|
|
16
16
|
let state;
|
|
17
17
|
$: state = disabled ? 'disabled' : current ? 'current' : 'normal';
|
|
18
18
|
let itemClass;
|
|
19
|
-
$: itemClass = classNames('py-2 px-4 w-full text-sm font-medium', 'first:rounded-t-lg last:rounded-b-lg', states[state], active && state === 'disabled' && 'cursor-not-allowed', active && state === 'normal' && hoverClass, active && state === 'normal' && focusClass, $$props.class);
|
|
19
|
+
$: itemClass = classNames('py-2 px-0 sm:px-4 w-full text-sm font-medium', 'first:rounded-t-lg last:rounded-b-lg', states[state], active && state === 'disabled' && 'cursor-not-allowed', active && state === 'normal' && hoverClass, active && state === 'normal' && focusClass, $$props.class);
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
22
|
{#if !active}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
<li class={itemClass}>
|
|
24
|
+
<slot item={$$props} />
|
|
25
|
+
</li>
|
|
26
26
|
{:else if href}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
</a>
|
|
27
|
+
<a
|
|
28
|
+
{href}
|
|
29
|
+
class="block {itemClass}"
|
|
30
|
+
on:click={() => dispatch('click', $$props)}
|
|
31
|
+
aria-current={current}
|
|
32
|
+
on:blur
|
|
33
|
+
on:change
|
|
34
|
+
on:click
|
|
35
|
+
on:focus
|
|
36
|
+
on:keydown
|
|
37
|
+
on:keypress
|
|
38
|
+
on:keyup
|
|
39
|
+
on:mouseenter
|
|
40
|
+
on:mouseleave
|
|
41
|
+
on:mouseover>
|
|
42
|
+
<slot item={$$props} />
|
|
43
|
+
</a>
|
|
45
44
|
{:else}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
</button>
|
|
45
|
+
<button
|
|
46
|
+
class="inline-flex relative items-center text-left {itemClass}"
|
|
47
|
+
{disabled}
|
|
48
|
+
on:click={() => dispatch('click', $$props)}
|
|
49
|
+
on:blur
|
|
50
|
+
on:change
|
|
51
|
+
on:click
|
|
52
|
+
on:focus
|
|
53
|
+
on:keydown
|
|
54
|
+
on:keypress
|
|
55
|
+
on:keyup
|
|
56
|
+
on:mouseenter
|
|
57
|
+
on:mouseleave
|
|
58
|
+
on:mouseover
|
|
59
|
+
aria-current={current}>
|
|
60
|
+
<slot item={$$props} />
|
|
61
|
+
</button>
|
|
64
62
|
{/if}
|
package/modals/Modal.svelte.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { SizeType } from '../types';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
[x: string]: any;
|
|
5
6
|
open?: boolean | undefined;
|
|
6
7
|
title?: string | undefined;
|
|
7
|
-
size?:
|
|
8
|
+
size?: SizeType | undefined;
|
|
8
9
|
placement?: "top-left" | "top-center" | "top-right" | "center-left" | "center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right" | undefined;
|
|
9
10
|
autoclose?: boolean | undefined;
|
|
10
11
|
permanent?: boolean | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flowbite-svelte",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.6",
|
|
4
4
|
"description": "Flowbite components for Svelte",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@playwright/test": "^1.25.0",
|
|
16
|
-
"@sveltejs/adapter-auto": "next",
|
|
17
|
-
"@sveltejs/kit": "next",
|
|
16
|
+
"@sveltejs/adapter-auto": "1.0.0-next.75",
|
|
17
|
+
"@sveltejs/kit": "1.0.0-next.484",
|
|
18
18
|
"@sveltejs/package": "1.0.0-next.3",
|
|
19
19
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
|
20
20
|
"@typescript-eslint/parser": "^5.27.0",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"svelte": "^3.44.0",
|
|
34
34
|
"svelte-check": "^2.7.1",
|
|
35
35
|
"svelte-preprocess": "^4.10.7",
|
|
36
|
-
"svelte-sidebar-menu": "^0.9.11",
|
|
37
36
|
"svelte2tsx": "^0.5.18",
|
|
38
37
|
"tailwindcss": "^3.1.5",
|
|
39
38
|
"tslib": "^2.3.1",
|
|
@@ -101,6 +100,7 @@
|
|
|
101
100
|
],
|
|
102
101
|
"exports": {
|
|
103
102
|
"./package.json": "./package.json",
|
|
103
|
+
"./.DS_Store": "./.DS_Store",
|
|
104
104
|
"./accordions/Accordion.svelte": "./accordions/Accordion.svelte",
|
|
105
105
|
"./accordions/AccordionItem.svelte": "./accordions/AccordionItem.svelte",
|
|
106
106
|
"./alerts/Alert.svelte": "./alerts/Alert.svelte",
|
|
@@ -142,6 +142,7 @@
|
|
|
142
142
|
"./forms/Input.svelte": "./forms/Input.svelte",
|
|
143
143
|
"./forms/InputAddon.svelte": "./forms/InputAddon.svelte",
|
|
144
144
|
"./forms/Label.svelte": "./forms/Label.svelte",
|
|
145
|
+
"./forms/NumberInput.svelte": "./forms/NumberInput.svelte",
|
|
145
146
|
"./forms/Radio.svelte": "./forms/Radio.svelte",
|
|
146
147
|
"./forms/RadioInline.svelte": "./forms/RadioInline.svelte",
|
|
147
148
|
"./forms/Range.svelte": "./forms/Range.svelte",
|
package/ratings/Rating.svelte
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script>import Star from './Star.svelte';
|
|
2
|
+
import classNames from 'classnames';
|
|
2
3
|
export let divClass = 'flex items-center';
|
|
3
4
|
export let size = '24';
|
|
4
5
|
export let total = 5;
|
|
@@ -10,24 +11,24 @@ let roundedRating = ceil ? Math.ceil(rating) : Math.floor(rating);
|
|
|
10
11
|
let grayStars = total - roundedRating;
|
|
11
12
|
</script>
|
|
12
13
|
|
|
13
|
-
<div class={divClass}>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
<div class={classNames(divClass, $$props.class)}>
|
|
15
|
+
{#if count}
|
|
16
|
+
<Star variation="solid" {size} class="text-yellow-300 dark:text-yellow-200" />
|
|
17
|
+
<p class="ml-2 text-sm font-bold text-gray-900 dark:text-white">{rating}</p>
|
|
18
|
+
<slot />
|
|
19
|
+
{:else}
|
|
20
|
+
{#each Array(roundedRating) as _, star}
|
|
21
|
+
<slot name="ratingUp">
|
|
22
|
+
<Star variation="solid" {size} class="text-yellow-300 dark:text-yellow-200" />
|
|
23
|
+
</slot>
|
|
24
|
+
{/each}
|
|
25
|
+
{#each Array(grayStars) as _, star}
|
|
26
|
+
<slot name="ratingDown">
|
|
27
|
+
<Star {size} class="text-gray-300 dark:text-gray-500" />
|
|
28
|
+
</slot>
|
|
29
|
+
{/each}
|
|
30
|
+
{#if $$slots.text}
|
|
31
|
+
<slot name="text" />
|
|
32
|
+
{/if}
|
|
33
|
+
{/if}
|
|
33
34
|
</div>
|
package/tables/Table.svelte.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
hoverable?: boolean | undefined;
|
|
8
8
|
noborder?: boolean | undefined;
|
|
9
9
|
shadow?: boolean | undefined;
|
|
10
|
-
color?: "
|
|
10
|
+
color?: "red" | "yellow" | "green" | "default" | "purple" | "blue" | "custom" | undefined;
|
|
11
11
|
};
|
|
12
12
|
events: {
|
|
13
13
|
[evt: string]: CustomEvent<any>;
|
|
@@ -7,7 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
striped?: boolean | undefined;
|
|
8
8
|
hoverable?: boolean | undefined;
|
|
9
9
|
placeholder?: string | undefined;
|
|
10
|
-
color?: "
|
|
10
|
+
color?: "red" | "yellow" | "green" | "default" | "purple" | "blue" | "custom" | undefined;
|
|
11
11
|
};
|
|
12
12
|
events: {
|
|
13
13
|
[evt: string]: CustomEvent<any>;
|
|
@@ -2,7 +2,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
-
style?: "
|
|
5
|
+
style?: "light" | "dark" | "custom" | "auto" | undefined;
|
|
6
6
|
defaultClass?: string | undefined;
|
|
7
7
|
};
|
|
8
8
|
events: {
|
package/typography/P.svelte.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare const __propDef: {
|
|
|
13
13
|
whitespace?: "pre" | "normal" | "nowrap" | "preline" | "prewrap" | undefined;
|
|
14
14
|
size?: "xs" | "sm" | "lg" | "xl" | "base" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | undefined;
|
|
15
15
|
space: 'tighter' | 'tight' | 'normal' | 'wide' | 'wider' | 'widest';
|
|
16
|
-
weight?: "
|
|
16
|
+
weight?: "light" | "bold" | "normal" | "thin" | "extralight" | "medium" | "semibold" | "extrabold" | "black" | undefined;
|
|
17
17
|
};
|
|
18
18
|
events: {
|
|
19
19
|
[evt: string]: CustomEvent<any>;
|
package/utils/Frame.svelte
CHANGED
|
@@ -82,7 +82,7 @@ $: divClass = classNames(bgColors[color], textColors[color], rounded && (color =
|
|
|
82
82
|
this={tag}
|
|
83
83
|
use:use={options}
|
|
84
84
|
bind:this={node}
|
|
85
|
-
transition:transitionFunc={params}
|
|
85
|
+
transition:transitionFunc|local={params}
|
|
86
86
|
{...$$restProps}
|
|
87
87
|
class={divClass}
|
|
88
88
|
on:mouseenter
|
package/utils/Frame.svelte.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare const __propDef: {
|
|
|
5
5
|
props: {
|
|
6
6
|
[x: string]: any;
|
|
7
7
|
tag?: string | undefined;
|
|
8
|
-
color?:
|
|
8
|
+
color?: "gray" | "red" | "yellow" | "green" | "indigo" | "default" | "purple" | "pink" | "blue" | "light" | "dark" | "dropdown" | "navbar" | "navbarUl" | "form" | "none" | undefined;
|
|
9
9
|
rounded?: boolean | undefined;
|
|
10
10
|
border?: boolean | undefined;
|
|
11
11
|
shadow?: boolean | undefined;
|
package/utils/Popper.svelte
CHANGED
|
@@ -60,7 +60,7 @@ function init(node, _triggerEl) {
|
|
|
60
60
|
{
|
|
61
61
|
name: 'offset',
|
|
62
62
|
options: {
|
|
63
|
-
offset: ({
|
|
63
|
+
offset: ({ reference, popper }) => {
|
|
64
64
|
// for full screen mega menu
|
|
65
65
|
return [yOnly ? popper.width / 2 - reference.width / 2 - reference.x : 0, offset];
|
|
66
66
|
}
|
|
@@ -112,25 +112,28 @@ onMount(() => {
|
|
|
112
112
|
});
|
|
113
113
|
};
|
|
114
114
|
});
|
|
115
|
+
function optional(pred, func) {
|
|
116
|
+
return pred && func;
|
|
117
|
+
}
|
|
115
118
|
</script>
|
|
116
119
|
|
|
117
120
|
{#if !triggerEl}
|
|
118
|
-
|
|
121
|
+
<div bind:this={contentEl} />
|
|
119
122
|
{/if}
|
|
120
123
|
|
|
121
124
|
{#if open && triggerEl}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
125
|
+
<Frame
|
|
126
|
+
use={init}
|
|
127
|
+
options={triggerEl}
|
|
128
|
+
role="tooltip"
|
|
129
|
+
tabIndex={activeContent ? -1 : undefined}
|
|
130
|
+
on:focusin={optional(activeContent, showHandler)}
|
|
131
|
+
on:focusout={optional(activeContent, hideHandler)}
|
|
132
|
+
on:mouseenter={optional(activeContent && !clickable, showHandler)}
|
|
133
|
+
on:mouseleave={optional(activeContent && !clickable, hideHandler)}
|
|
134
|
+
{...$$restProps}
|
|
135
|
+
class={classNames('z-10 outline-none', $$props.class)}>
|
|
136
|
+
<slot />
|
|
137
|
+
{#if arrow}<div data-popper-arrow class="tooltip-arrow border dark:border-gray-100" />{/if}
|
|
138
|
+
</Frame>
|
|
136
139
|
{/if}
|
package/utils/focusTrap.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// Taken from github.com/carbon-design-system/carbon/packages/react/src/internal/keyboard/navigation.js
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// add all the elements inside modal which you want to make focusable
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
6
|
+
const selectorTabbable = `
|
|
7
|
+
a[href], area[href], input:not([disabled]):not([tabindex='-1']),
|
|
8
|
+
button:not([disabled]):not([tabindex='-1']),select:not([disabled]):not([tabindex='-1']),
|
|
9
|
+
textarea:not([disabled]):not([tabindex='-1']),
|
|
10
|
+
iframe, object, embed, *[tabindex]:not([tabindex='-1']):not([disabled]), *[contenteditable=true]
|
|
11
|
+
`;
|
|
13
12
|
|
|
14
13
|
export default function focusTrap(node) {
|
|
15
|
-
|
|
14
|
+
const tabbable = Array.from(node.querySelectorAll(selectorTabbable));
|
|
16
15
|
|
|
17
16
|
function handleFocusTrap(e) {
|
|
18
17
|
let isTabPressed = e.key === 'Tab' || e.keyCode === 9;
|
|
@@ -21,23 +20,15 @@ export default function focusTrap(node) {
|
|
|
21
20
|
return;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// if tab key is pressed
|
|
32
|
-
if (document.activeElement === lastFocusableElement) {
|
|
33
|
-
// if focused has reached to last focusable element then focus first focusable element after pressing tab
|
|
34
|
-
firstFocusableElement.focus(); // add focus for the first focusable element
|
|
35
|
-
e.preventDefault();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
23
|
+
let index = tabbable.indexOf(document.activeElement);
|
|
24
|
+
if (index === -1 && e.shiftKey) index = 0;
|
|
25
|
+
index += tabbable.length + (e.shiftKey ? -1 : 1);
|
|
26
|
+
index %= tabbable.length;
|
|
27
|
+
tabbable[index].focus();
|
|
28
|
+
|
|
29
|
+
e.preventDefault();
|
|
38
30
|
}
|
|
39
31
|
|
|
40
|
-
[firstFocusableElement, lastFocusableElement] = getFocusable(node);
|
|
41
32
|
document.addEventListener('keydown', handleFocusTrap, true);
|
|
42
33
|
|
|
43
34
|
return {
|