flowbite-svelte 0.46.16 → 0.46.17
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/dist/cards/Card.svelte.d.ts +1 -0
- package/dist/carousel/Thumbnail.svelte +6 -4
- package/dist/carousel/Thumbnail.svelte.d.ts +10 -8
- package/dist/forms/Input.svelte +20 -6
- package/dist/forms/Input.svelte.d.ts +3 -1
- package/dist/forms/MultiSelect.svelte +2 -2
- package/dist/forms/Search.svelte.d.ts +1 -1
- package/dist/list-group/Listgroup.svelte +2 -2
- package/dist/list-group/Listgroup.svelte.d.ts +12 -12
- package/dist/progress/Progressbar.svelte +5 -3
- package/dist/progress/Progressbar.svelte.d.ts +2 -0
- package/dist/rating/Rating.svelte +19 -15
- package/dist/rating/Rating.svelte.d.ts +20 -16
- package/dist/table/Table.svelte +47 -1
- package/dist/table/Table.svelte.d.ts +28 -9
- package/dist/table/TableBody.svelte +11 -1
- package/dist/table/TableBody.svelte.d.ts +12 -9
- package/dist/table/TableHeadCell.svelte +34 -1
- package/dist/table/TableHeadCell.svelte.d.ts +17 -9
- package/dist/timeline/GroupItem.svelte +4 -0
- package/dist/timeline/GroupItem.svelte.d.ts +2 -0
- package/dist/utils/Popper.svelte +18 -17
- package/package.json +1 -1
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
<script>import { twMerge } from "tailwind-merge";
|
|
2
2
|
export let selected = false;
|
|
3
|
+
export let alt = "";
|
|
3
4
|
export let activeClass = "opacity-100";
|
|
4
5
|
export let inactiveClass = "opacity-60";
|
|
5
6
|
</script>
|
|
6
7
|
|
|
7
|
-
<img
|
|
8
|
+
<img {...$$restProps} {alt} class={twMerge(selected ? activeClass : inactiveClass, $$props.class)} />
|
|
8
9
|
|
|
9
10
|
<!--
|
|
10
11
|
@component
|
|
11
12
|
[Go to docs](https://flowbite-svelte.com/)
|
|
12
13
|
## Props
|
|
13
|
-
@prop export let selected:
|
|
14
|
-
@prop export let
|
|
15
|
-
@prop export let
|
|
14
|
+
@prop export let selected: $$Props['selected'] = false;
|
|
15
|
+
@prop export let alt: $$Props['alt'] = '';
|
|
16
|
+
@prop export let activeClass: $$Props['activeClass'] = 'opacity-100';
|
|
17
|
+
@prop export let inactiveClass: $$Props['inactiveClass'] = 'opacity-60';
|
|
16
18
|
-->
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { HTMLImgAttributes } from 'svelte/elements';
|
|
2
3
|
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
activeClass?: string
|
|
7
|
-
inactiveClass?: string
|
|
4
|
+
props: HTMLImgAttributes & {
|
|
5
|
+
selected?: boolean;
|
|
6
|
+
alt?: string;
|
|
7
|
+
activeClass?: string;
|
|
8
|
+
inactiveClass?: string;
|
|
8
9
|
};
|
|
9
10
|
events: {
|
|
10
11
|
[evt: string]: CustomEvent<any>;
|
|
@@ -17,9 +18,10 @@ export type ThumbnailSlots = typeof __propDef.slots;
|
|
|
17
18
|
/**
|
|
18
19
|
* [Go to docs](https://flowbite-svelte.com/)
|
|
19
20
|
* ## Props
|
|
20
|
-
* @prop export let selected:
|
|
21
|
-
* @prop export let
|
|
22
|
-
* @prop export let
|
|
21
|
+
* @prop export let selected: $$Props['selected'] = false;
|
|
22
|
+
* @prop export let alt: $$Props['alt'] = '';
|
|
23
|
+
* @prop export let activeClass: $$Props['activeClass'] = 'opacity-100';
|
|
24
|
+
* @prop export let inactiveClass: $$Props['inactiveClass'] = 'opacity-60';
|
|
23
25
|
*/
|
|
24
26
|
export default class Thumbnail extends SvelteComponentTyped<ThumbnailProps, ThumbnailEvents, ThumbnailSlots> {
|
|
25
27
|
}
|
package/dist/forms/Input.svelte
CHANGED
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
<script>import Wrapper from "../utils/Wrapper.svelte";
|
|
7
7
|
import { twMerge } from "tailwind-merge";
|
|
8
|
-
import { getContext } from "svelte";
|
|
8
|
+
import { createEventDispatcher, getContext } from "svelte";
|
|
9
|
+
import CloseButton from "../utils/CloseButton.svelte";
|
|
10
|
+
const dispatcher = createEventDispatcher();
|
|
9
11
|
export let type = "text";
|
|
10
12
|
export let value = void 0;
|
|
11
13
|
export let size = void 0;
|
|
14
|
+
export let clearable = false;
|
|
12
15
|
export let defaultClass = "block w-full disabled:cursor-not-allowed disabled:opacity-50 rtl:text-right";
|
|
13
16
|
export let color = "base";
|
|
14
17
|
export let floatClass = "flex absolute inset-y-0 items-center text-gray-500 dark:text-gray-400";
|
|
@@ -39,11 +42,16 @@ $: _size = size || clampSize(group?.size) || "md";
|
|
|
39
42
|
let inputClass;
|
|
40
43
|
$: {
|
|
41
44
|
const _color = color === "base" && background ? "tinted" : color;
|
|
42
|
-
inputClass = twMerge([defaultClass, inputPadding[_size], $$slots.left && leftPadding[_size] || $$slots.right && rightPadding[_size], ringClasses[color], colorClasses[_color], borderClasses[_color], textSizes[_size], group || "rounded-lg", group && "first:rounded-s-lg last:rounded-e-lg", group && "[&:not(:first-child)]:-ms-px", $$props.class]);
|
|
45
|
+
inputClass = twMerge([defaultClass, inputPadding[_size], $$slots.left && leftPadding[_size] || (clearable || $$slots.right) && rightPadding[_size], ringClasses[color], colorClasses[_color], borderClasses[_color], textSizes[_size], group || "rounded-lg", group && "first:rounded-s-lg last:rounded-e-lg", group && "[&:not(:first-child)]:-ms-px", $$props.class]);
|
|
43
46
|
}
|
|
47
|
+
const clearAll = (e) => {
|
|
48
|
+
e.stopPropagation();
|
|
49
|
+
value = void 0;
|
|
50
|
+
dispatcher("change");
|
|
51
|
+
};
|
|
44
52
|
</script>
|
|
45
53
|
|
|
46
|
-
<Wrapper class="relative w-full" show
|
|
54
|
+
<Wrapper class="relative w-full" show>
|
|
47
55
|
{#if $$slots.left}
|
|
48
56
|
<div class="{twMerge(floatClass, $$props.classLeft)} start-0 ps-2.5 pointer-events-none">
|
|
49
57
|
<slot name="left" />
|
|
@@ -52,9 +60,14 @@ $: {
|
|
|
52
60
|
<slot props={{ ...$$restProps, class: inputClass }}>
|
|
53
61
|
<input {...$$restProps} bind:value on:blur on:change on:click on:contextmenu on:focus on:keydown on:keypress on:keyup on:mouseover on:mouseenter on:mouseleave on:paste on:input {...{ type }} class={inputClass} />
|
|
54
62
|
</slot>
|
|
55
|
-
{
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
<div class="{twMerge(floatClass, $$props.classRight)} end-0 pe-2.5">
|
|
64
|
+
{#if $$slots.right}
|
|
65
|
+
<slot name="right"></slot>
|
|
66
|
+
{/if}
|
|
67
|
+
{#if clearable && value && `${value}`.length > 0}
|
|
68
|
+
<CloseButton {size} on:click={clearAll} color="none" class="p-0 focus:ring-gray-400 dark:text-white" />
|
|
69
|
+
{/if}
|
|
70
|
+
</div>
|
|
58
71
|
</Wrapper>
|
|
59
72
|
|
|
60
73
|
<!--
|
|
@@ -64,6 +77,7 @@ $: {
|
|
|
64
77
|
@prop export let type: InputType = 'text';
|
|
65
78
|
@prop export let value: any = undefined;
|
|
66
79
|
@prop export let size: FormSizeType | undefined = undefined;
|
|
80
|
+
@prop export let clearable = false;
|
|
67
81
|
@prop export let defaultClass: string = 'block w-full disabled:cursor-not-allowed disabled:opacity-50 rtl:text-right';
|
|
68
82
|
@prop export let color: 'base' | 'green' | 'red' = 'base';
|
|
69
83
|
@prop export let floatClass: string = 'flex absolute inset-y-0 items-center text-gray-500 dark:text-gray-400';
|
|
@@ -8,13 +8,14 @@ declare const __propDef: {
|
|
|
8
8
|
type?: InputType | undefined;
|
|
9
9
|
value?: any;
|
|
10
10
|
size?: FormSizeType | undefined;
|
|
11
|
+
clearable?: boolean | undefined;
|
|
11
12
|
defaultClass?: string | undefined;
|
|
12
13
|
color?: ("base" | "green" | "red") | undefined;
|
|
13
14
|
floatClass?: string | undefined;
|
|
14
15
|
};
|
|
15
16
|
events: {
|
|
16
17
|
blur: FocusEvent;
|
|
17
|
-
change:
|
|
18
|
+
change: CustomEvent<any>;
|
|
18
19
|
click: MouseEvent;
|
|
19
20
|
contextmenu: MouseEvent;
|
|
20
21
|
focus: FocusEvent;
|
|
@@ -48,6 +49,7 @@ export type InputSlots = typeof __propDef.slots;
|
|
|
48
49
|
* @prop export let type: InputType = 'text';
|
|
49
50
|
* @prop export let value: any = undefined;
|
|
50
51
|
* @prop export let size: FormSizeType | undefined = undefined;
|
|
52
|
+
* @prop export let clearable = false;
|
|
51
53
|
* @prop export let defaultClass: string = 'block w-full disabled:cursor-not-allowed disabled:opacity-50 rtl:text-right';
|
|
52
54
|
* @prop export let color: 'base' | 'green' | 'red' = 'base';
|
|
53
55
|
* @prop export let floatClass: string = 'flex absolute inset-y-0 items-center text-gray-500 dark:text-gray-400';
|
|
@@ -97,7 +97,7 @@ function handleKeyDown(event) {
|
|
|
97
97
|
{/each}
|
|
98
98
|
</select>
|
|
99
99
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
100
|
-
<div on:click={() => (show = !show)} on:focusout={() => (show = false)} on:keydown={handleKeyDown} tabindex="0" role="listbox" class={twMerge(multiSelectClass, sizes[size], $$props.class)}>
|
|
100
|
+
<div on:click|self={() => (show = !show)} on:focusout={() => (show = false)} on:keydown={handleKeyDown} tabindex="0" role="listbox" class={twMerge(multiSelectClass, sizes[size], $$props.class)}>
|
|
101
101
|
{#if !selectItems.length}
|
|
102
102
|
<span class="text-gray-400">{placeholder}</span>
|
|
103
103
|
{/if}
|
|
@@ -117,7 +117,7 @@ function handleKeyDown(event) {
|
|
|
117
117
|
<CloseButton {size} on:click={clearAll} color="none" class="p-0 focus:ring-gray-400 dark:text-white" />
|
|
118
118
|
{/if}
|
|
119
119
|
<div class="w-[1px] bg-gray-300 dark:bg-gray-600"></div>
|
|
120
|
-
<svg class="cursor-pointer h-3 w-3 ms-1 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
|
|
120
|
+
<svg on:click|self={() => (show = !show)} class="cursor-pointer h-3 w-3 ms-1 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
|
|
121
121
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d={show ? 'm1 5 4-4 4 4' : 'm9 1-4 4-4-4'} />
|
|
122
122
|
</svg>
|
|
123
123
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import { createEventDispatcher, setContext } from "svelte";
|
|
1
|
+
<script generics="T extends ListGroupItemType | string">import { createEventDispatcher, setContext } from "svelte";
|
|
2
2
|
import { twMerge } from "tailwind-merge";
|
|
3
3
|
import Frame from "../utils/Frame.svelte";
|
|
4
4
|
import ListgroupItem from "./ListgroupItem.svelte";
|
|
@@ -28,7 +28,7 @@ $: groupClass = twMerge(defaultClass, $$props.class);
|
|
|
28
28
|
@component
|
|
29
29
|
[Go to docs](https://flowbite-svelte.com/)
|
|
30
30
|
## Props
|
|
31
|
-
@prop export let items:
|
|
31
|
+
@prop export let items: T[] = [];
|
|
32
32
|
@prop export let active: boolean = false;
|
|
33
33
|
@prop export let defaultClass: string = 'divide-y divide-gray-200 dark:divide-gray-600';
|
|
34
34
|
-->
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { ListGroupItemType } from '../types';
|
|
3
|
-
declare
|
|
4
|
-
props: import("svelte/elements").HTMLAnchorAttributes & {
|
|
3
|
+
declare class __sveltets_Render<T extends ListGroupItemType | string> {
|
|
4
|
+
props(): import("svelte/elements").HTMLAnchorAttributes & {
|
|
5
5
|
tag?: string;
|
|
6
6
|
color?: import("../utils/Frame.svelte").FrameColor;
|
|
7
7
|
rounded?: boolean;
|
|
@@ -16,31 +16,31 @@ declare const __propDef: {
|
|
|
16
16
|
transition?: (node: HTMLElement, params: any) => import("svelte/transition").TransitionConfig;
|
|
17
17
|
params?: any;
|
|
18
18
|
} & {
|
|
19
|
-
items?:
|
|
19
|
+
items?: T[] | undefined;
|
|
20
20
|
active?: boolean;
|
|
21
21
|
};
|
|
22
|
-
events: {
|
|
22
|
+
events(): {
|
|
23
23
|
click: CustomEvent<any>;
|
|
24
24
|
} & {
|
|
25
25
|
[evt: string]: CustomEvent<any>;
|
|
26
26
|
};
|
|
27
|
-
slots: {
|
|
27
|
+
slots(): {
|
|
28
28
|
default: {
|
|
29
|
-
item:
|
|
29
|
+
item: T;
|
|
30
30
|
index: number;
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
|
-
}
|
|
34
|
-
export type ListgroupProps =
|
|
35
|
-
export type ListgroupEvents =
|
|
36
|
-
export type ListgroupSlots =
|
|
33
|
+
}
|
|
34
|
+
export type ListgroupProps<T extends ListGroupItemType | string> = ReturnType<__sveltets_Render<T>['props']>;
|
|
35
|
+
export type ListgroupEvents<T extends ListGroupItemType | string> = ReturnType<__sveltets_Render<T>['events']>;
|
|
36
|
+
export type ListgroupSlots<T extends ListGroupItemType | string> = ReturnType<__sveltets_Render<T>['slots']>;
|
|
37
37
|
/**
|
|
38
38
|
* [Go to docs](https://flowbite-svelte.com/)
|
|
39
39
|
* ## Props
|
|
40
|
-
* @prop export let items:
|
|
40
|
+
* @prop export let items: T[] = [];
|
|
41
41
|
* @prop export let active: boolean = false;
|
|
42
42
|
* @prop export let defaultClass: string = 'divide-y divide-gray-200 dark:divide-gray-600';
|
|
43
43
|
*/
|
|
44
|
-
export default class Listgroup extends SvelteComponentTyped<ListgroupProps
|
|
44
|
+
export default class Listgroup<T extends ListGroupItemType | string> extends SvelteComponentTyped<ListgroupProps<T>, ListgroupEvents<T>, ListgroupSlots<T>> {
|
|
45
45
|
}
|
|
46
46
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { cubicOut } from "svelte/easing";
|
|
2
2
|
import { tweened } from "svelte/motion";
|
|
3
|
-
import { twMerge
|
|
3
|
+
import { twMerge } from "tailwind-merge";
|
|
4
4
|
export let progress = "45";
|
|
5
5
|
export let precision = 0;
|
|
6
6
|
export let tweenDuration = 400;
|
|
@@ -12,6 +12,7 @@ export let easing = cubicOut;
|
|
|
12
12
|
export let color = "primary";
|
|
13
13
|
export let labelInsideClass = "text-primary-100 text-xs font-medium text-center p-0.5 leading-none rounded-full";
|
|
14
14
|
export let divClass = "w-full bg-gray-200 rounded-full dark:bg-gray-700";
|
|
15
|
+
export let progressClass;
|
|
15
16
|
const _progress = tweened(0, {
|
|
16
17
|
duration: animate ? tweenDuration : 0,
|
|
17
18
|
easing
|
|
@@ -37,11 +38,11 @@ $: _progress.set(Number(progress));
|
|
|
37
38
|
{/if}
|
|
38
39
|
<div class={twMerge(divClass, size, $$props.class)}>
|
|
39
40
|
{#if labelInside}
|
|
40
|
-
<div class={
|
|
41
|
+
<div class={twMerge(barColors[color], labelInsideClass)} style="width: {$_progress}%">
|
|
41
42
|
{$_progress.toFixed(precision)}%
|
|
42
43
|
</div>
|
|
43
44
|
{:else}
|
|
44
|
-
<div class={
|
|
45
|
+
<div class={twMerge(barColors[color], size, 'rounded-full', progressClass)} style="width: {$_progress}%"></div>
|
|
45
46
|
{/if}
|
|
46
47
|
</div>
|
|
47
48
|
|
|
@@ -60,4 +61,5 @@ $: _progress.set(Number(progress));
|
|
|
60
61
|
@prop export let color: 'primary' | 'blue' | 'gray' | 'red' | 'green' | 'yellow' | 'purple' | 'indigo' = 'primary';
|
|
61
62
|
@prop export let labelInsideClass: string = 'text-primary-100 text-xs font-medium text-center p-0.5 leading-none rounded-full';
|
|
62
63
|
@prop export let divClass: string = 'w-full bg-gray-200 rounded-full dark:bg-gray-700';
|
|
64
|
+
@prop export let progressClass: string;
|
|
63
65
|
-->
|
|
@@ -14,6 +14,7 @@ declare const __propDef: {
|
|
|
14
14
|
color?: ("primary" | "blue" | "gray" | "red" | "green" | "yellow" | "purple" | "indigo") | undefined;
|
|
15
15
|
labelInsideClass?: string | undefined;
|
|
16
16
|
divClass?: string | undefined;
|
|
17
|
+
progressClass: string;
|
|
17
18
|
};
|
|
18
19
|
events: {
|
|
19
20
|
[evt: string]: CustomEvent<any>;
|
|
@@ -37,6 +38,7 @@ export type ProgressbarSlots = typeof __propDef.slots;
|
|
|
37
38
|
* @prop export let color: 'primary' | 'blue' | 'gray' | 'red' | 'green' | 'yellow' | 'purple' | 'indigo' = 'primary';
|
|
38
39
|
* @prop export let labelInsideClass: string = 'text-primary-100 text-xs font-medium text-center p-0.5 leading-none rounded-full';
|
|
39
40
|
* @prop export let divClass: string = 'w-full bg-gray-200 rounded-full dark:bg-gray-700';
|
|
41
|
+
* @prop export let progressClass: string;
|
|
40
42
|
*/
|
|
41
43
|
export default class Progressbar extends SvelteComponentTyped<ProgressbarProps, ProgressbarEvents, ProgressbarSlots> {
|
|
42
44
|
}
|
|
@@ -8,28 +8,30 @@ export let rating = 4;
|
|
|
8
8
|
export let partialId = "partialStar" + generateId();
|
|
9
9
|
export let icon = Star;
|
|
10
10
|
export let count = false;
|
|
11
|
+
export let iconFillColor;
|
|
12
|
+
export let iconStrokeColor;
|
|
11
13
|
const fullStarId = generateId();
|
|
12
14
|
const grayStarId = generateId();
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
$: fullStars = Math.floor(rating);
|
|
16
|
+
$: rateDiffence = rating - fullStars;
|
|
17
|
+
$: percentRating = Math.round(rateDiffence * 100);
|
|
18
|
+
$: grayStars = total - (fullStars + Math.ceil(rateDiffence));
|
|
17
19
|
</script>
|
|
18
20
|
|
|
19
21
|
<div class={twMerge(divClass, $$props.class)}>
|
|
20
22
|
{#if count}
|
|
21
|
-
<svelte:component this={icon} fillPercent={100} {size} />
|
|
23
|
+
<svelte:component this={icon} fillColor={iconFillColor} strokeColor={iconStrokeColor} fillPercent={100} {size} />
|
|
22
24
|
<p class="ms-2 text-sm font-bold text-gray-900 dark:text-white">{rating}</p>
|
|
23
25
|
<slot />
|
|
24
26
|
{:else}
|
|
25
27
|
{#each Array(fullStars) as star}
|
|
26
|
-
<svelte:component this={icon} {size} fillPercent={100} id={fullStarId} />
|
|
28
|
+
<svelte:component this={icon} fillColor={iconFillColor} strokeColor={iconStrokeColor} {size} fillPercent={100} id={fullStarId} />
|
|
27
29
|
{/each}
|
|
28
30
|
{#if percentRating}
|
|
29
|
-
<svelte:component this={icon} {size} fillPercent={percentRating} id={partialId} />
|
|
31
|
+
<svelte:component this={icon} fillColor={iconFillColor} strokeColor={iconStrokeColor} {size} fillPercent={percentRating} id={partialId} />
|
|
30
32
|
{/if}
|
|
31
33
|
{#each Array(grayStars) as star}
|
|
32
|
-
<svelte:component this={icon} {size} fillPercent={0} id={grayStarId} />
|
|
34
|
+
<svelte:component this={icon} fillColor={iconFillColor} strokeColor={iconStrokeColor} {size} fillPercent={0} id={grayStarId} />
|
|
33
35
|
{/each}
|
|
34
36
|
{#if $$slots.text}
|
|
35
37
|
<slot name="text" />
|
|
@@ -41,11 +43,13 @@ let grayStars = total - (fullStars + Math.ceil(rateDiffence));
|
|
|
41
43
|
@component
|
|
42
44
|
[Go to docs](https://flowbite-svelte.com/)
|
|
43
45
|
## Props
|
|
44
|
-
@prop export let divClass:
|
|
45
|
-
@prop export let size:
|
|
46
|
-
@prop export let total:
|
|
47
|
-
@prop export let rating:
|
|
48
|
-
@prop export let partialId:
|
|
49
|
-
@prop export let icon:
|
|
50
|
-
@prop export let count:
|
|
46
|
+
@prop export let divClass: $$Props['divClass'] = 'flex items-center';
|
|
47
|
+
@prop export let size: $$Props['size'] = 24;
|
|
48
|
+
@prop export let total: NonNullable<$$Props['total']> = 5;
|
|
49
|
+
@prop export let rating: $$Props['rating'] = 4;
|
|
50
|
+
@prop export let partialId: $$Props['partialId'] = 'partialStar' + generateId();
|
|
51
|
+
@prop export let icon: $$Props['icon'] = Star;
|
|
52
|
+
@prop export let count: $$Props['count'] = false;
|
|
53
|
+
@prop export let iconFillColor: $$Props['iconFillColor'];
|
|
54
|
+
@prop export let iconStrokeColor: $$Props['iconStrokeColor'];
|
|
51
55
|
-->
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { ComponentType } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
4
|
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
props: HTMLAttributes<HTMLDivElement> & {
|
|
6
|
+
divClass?: string;
|
|
7
|
+
size?: number;
|
|
8
|
+
total?: number;
|
|
9
|
+
rating: number;
|
|
10
|
+
partialId?: string;
|
|
11
|
+
icon?: ComponentType;
|
|
12
|
+
count?: boolean;
|
|
13
|
+
iconFillColor?: string;
|
|
14
|
+
iconStrokeColor?: string;
|
|
13
15
|
};
|
|
14
16
|
events: {
|
|
15
17
|
[evt: string]: CustomEvent<any>;
|
|
@@ -25,13 +27,15 @@ export type RatingSlots = typeof __propDef.slots;
|
|
|
25
27
|
/**
|
|
26
28
|
* [Go to docs](https://flowbite-svelte.com/)
|
|
27
29
|
* ## Props
|
|
28
|
-
* @prop export let divClass:
|
|
29
|
-
* @prop export let size:
|
|
30
|
-
* @prop export let total:
|
|
31
|
-
* @prop export let rating:
|
|
32
|
-
* @prop export let partialId:
|
|
33
|
-
* @prop export let icon:
|
|
34
|
-
* @prop export let count:
|
|
30
|
+
* @prop export let divClass: $$Props['divClass'] = 'flex items-center';
|
|
31
|
+
* @prop export let size: $$Props['size'] = 24;
|
|
32
|
+
* @prop export let total: NonNullable<$$Props['total']> = 5;
|
|
33
|
+
* @prop export let rating: $$Props['rating'] = 4;
|
|
34
|
+
* @prop export let partialId: $$Props['partialId'] = 'partialStar' + generateId();
|
|
35
|
+
* @prop export let icon: $$Props['icon'] = Star;
|
|
36
|
+
* @prop export let count: $$Props['count'] = false;
|
|
37
|
+
* @prop export let iconFillColor: $$Props['iconFillColor'];
|
|
38
|
+
* @prop export let iconStrokeColor: $$Props['iconStrokeColor'];
|
|
35
39
|
*/
|
|
36
40
|
export default class Rating extends SvelteComponentTyped<RatingProps, RatingEvents, RatingSlots> {
|
|
37
41
|
}
|
package/dist/table/Table.svelte
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script generics="T">import { writable } from "svelte/store";
|
|
2
|
+
import { twMerge, twJoin } from "tailwind-merge";
|
|
2
3
|
import { setContext } from "svelte";
|
|
3
4
|
export let divClass = "relative overflow-x-auto";
|
|
4
5
|
export let striped = false;
|
|
@@ -7,6 +8,17 @@ export let noborder = false;
|
|
|
7
8
|
export let shadow = false;
|
|
8
9
|
export let color = "default";
|
|
9
10
|
export let customeColor = "";
|
|
11
|
+
export let items = [];
|
|
12
|
+
export let filter = null;
|
|
13
|
+
export let placeholder = "Search";
|
|
14
|
+
export let innerDivClass = "p-4";
|
|
15
|
+
export let searchClass = "relative mt-1";
|
|
16
|
+
export let svgDivClass = "absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none";
|
|
17
|
+
export let svgClass = "w-5 h-5 text-gray-500 dark:text-gray-400";
|
|
18
|
+
export let inputClass = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-80 p-2.5 ps-10 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500";
|
|
19
|
+
let searchTerm = "";
|
|
20
|
+
let inputCls = twMerge(inputClass, $$props.classInput);
|
|
21
|
+
let svgDivCls = twMerge(svgDivClass, $$props.classSvgDiv);
|
|
10
22
|
const colors = {
|
|
11
23
|
default: "text-gray-500 dark:text-gray-400",
|
|
12
24
|
blue: "text-blue-100 dark:text-blue-100",
|
|
@@ -22,9 +34,35 @@ $: setContext("striped", striped);
|
|
|
22
34
|
$: setContext("hoverable", hoverable);
|
|
23
35
|
$: setContext("noborder", noborder);
|
|
24
36
|
$: setContext("color", color);
|
|
37
|
+
$: setContext("items", items);
|
|
38
|
+
const searchTermStore = writable(searchTerm);
|
|
39
|
+
const filterStore = writable(filter);
|
|
40
|
+
setContext("searchTerm", searchTermStore);
|
|
41
|
+
setContext("filter", filterStore);
|
|
42
|
+
$: searchTermStore.set(searchTerm);
|
|
43
|
+
$: filterStore.set(filter);
|
|
44
|
+
setContext("sorter", writable(null));
|
|
25
45
|
</script>
|
|
26
46
|
|
|
27
47
|
<div class={twJoin(divClass, shadow && 'shadow-md sm:rounded-lg')}>
|
|
48
|
+
{#if filter}
|
|
49
|
+
<slot name="search">
|
|
50
|
+
<div class={innerDivClass}>
|
|
51
|
+
<label for="table-search" class="sr-only">Search</label>
|
|
52
|
+
<div class={searchClass}>
|
|
53
|
+
<div class={svgDivCls}>
|
|
54
|
+
<slot name="svgSearch">
|
|
55
|
+
<svg class={svgClass} fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
|
56
|
+
<path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" />
|
|
57
|
+
</svg>
|
|
58
|
+
</slot>
|
|
59
|
+
</div>
|
|
60
|
+
<input bind:value={searchTerm} type="text" id="table-search" class={inputCls} {placeholder} />
|
|
61
|
+
</div>
|
|
62
|
+
<slot name="header" />
|
|
63
|
+
</div>
|
|
64
|
+
</slot>
|
|
65
|
+
{/if}
|
|
28
66
|
<table {...$$restProps} class={twMerge('w-full text-left text-sm', colors[color], $$props.class)}>
|
|
29
67
|
<slot />
|
|
30
68
|
</table>
|
|
@@ -41,4 +79,12 @@ $: setContext("color", color);
|
|
|
41
79
|
@prop export let shadow: boolean = false;
|
|
42
80
|
@prop export let color: TableColorType = 'default';
|
|
43
81
|
@prop export let customeColor: string = '';
|
|
82
|
+
@prop export let items: T[] = [];
|
|
83
|
+
@prop export let filter: ((t: T, term: string) => boolean) | null = null;
|
|
84
|
+
@prop export let placeholder: string = 'Search';
|
|
85
|
+
@prop export let innerDivClass: string = 'p-4';
|
|
86
|
+
@prop export let searchClass: string = 'relative mt-1';
|
|
87
|
+
@prop export let svgDivClass: string = 'absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none';
|
|
88
|
+
@prop export let svgClass: string = 'w-5 h-5 text-gray-500 dark:text-gray-400';
|
|
89
|
+
@prop export let inputClass: string = 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-80 p-2.5 ps-10 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500';
|
|
44
90
|
-->
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { TableColorType } from '../types';
|
|
3
|
-
declare
|
|
4
|
-
props: {
|
|
3
|
+
declare class __sveltets_Render<T> {
|
|
4
|
+
props(): {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
divClass?: string | undefined;
|
|
7
7
|
striped?: boolean | undefined;
|
|
@@ -10,17 +10,28 @@ declare const __propDef: {
|
|
|
10
10
|
shadow?: boolean | undefined;
|
|
11
11
|
color?: TableColorType | undefined;
|
|
12
12
|
customeColor?: string | undefined;
|
|
13
|
+
items?: T[] | undefined;
|
|
14
|
+
filter?: ((t: T, term: string) => boolean) | null | undefined;
|
|
15
|
+
placeholder?: string | undefined;
|
|
16
|
+
innerDivClass?: string | undefined;
|
|
17
|
+
searchClass?: string | undefined;
|
|
18
|
+
svgDivClass?: string | undefined;
|
|
19
|
+
svgClass?: string | undefined;
|
|
20
|
+
inputClass?: string | undefined;
|
|
13
21
|
};
|
|
14
|
-
events: {
|
|
22
|
+
events(): {} & {
|
|
15
23
|
[evt: string]: CustomEvent<any>;
|
|
16
24
|
};
|
|
17
|
-
slots: {
|
|
25
|
+
slots(): {
|
|
26
|
+
search: {};
|
|
27
|
+
svgSearch: {};
|
|
28
|
+
header: {};
|
|
18
29
|
default: {};
|
|
19
30
|
};
|
|
20
|
-
}
|
|
21
|
-
export type TableProps =
|
|
22
|
-
export type TableEvents =
|
|
23
|
-
export type TableSlots =
|
|
31
|
+
}
|
|
32
|
+
export type TableProps<T> = ReturnType<__sveltets_Render<T>['props']>;
|
|
33
|
+
export type TableEvents<T> = ReturnType<__sveltets_Render<T>['events']>;
|
|
34
|
+
export type TableSlots<T> = ReturnType<__sveltets_Render<T>['slots']>;
|
|
24
35
|
/**
|
|
25
36
|
* [Go to docs](https://flowbite-svelte.com/)
|
|
26
37
|
* ## Props
|
|
@@ -31,7 +42,15 @@ export type TableSlots = typeof __propDef.slots;
|
|
|
31
42
|
* @prop export let shadow: boolean = false;
|
|
32
43
|
* @prop export let color: TableColorType = 'default';
|
|
33
44
|
* @prop export let customeColor: string = '';
|
|
45
|
+
* @prop export let items: T[] = [];
|
|
46
|
+
* @prop export let filter: ((t: T, term: string) => boolean) | null = null;
|
|
47
|
+
* @prop export let placeholder: string = 'Search';
|
|
48
|
+
* @prop export let innerDivClass: string = 'p-4';
|
|
49
|
+
* @prop export let searchClass: string = 'relative mt-1';
|
|
50
|
+
* @prop export let svgDivClass: string = 'absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none';
|
|
51
|
+
* @prop export let svgClass: string = 'w-5 h-5 text-gray-500 dark:text-gray-400';
|
|
52
|
+
* @prop export let inputClass: string = 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-80 p-2.5 ps-10 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500';
|
|
34
53
|
*/
|
|
35
|
-
export default class Table extends SvelteComponentTyped<TableProps
|
|
54
|
+
export default class Table<T> extends SvelteComponentTyped<TableProps<T>, TableEvents<T>, TableSlots<T>> {
|
|
36
55
|
}
|
|
37
56
|
export {};
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script generics="T">import { getContext } from "svelte";
|
|
2
|
+
export let tableBodyClass = void 0;
|
|
3
|
+
$: items = getContext("items") || [];
|
|
4
|
+
let filter = getContext("filter");
|
|
5
|
+
let searchTerm = getContext("searchTerm");
|
|
6
|
+
$: filtered = $filter ? items.filter((item) => $filter(item, $searchTerm)) : items;
|
|
7
|
+
let sorter = getContext("sorter");
|
|
8
|
+
$: sorted = $sorter ? filtered.toSorted((a, b) => $sorter.sortDirection * $sorter.sort(a, b)) : filtered;
|
|
2
9
|
</script>
|
|
3
10
|
|
|
4
11
|
<tbody class={tableBodyClass}>
|
|
5
12
|
<slot />
|
|
13
|
+
{#each sorted as item}
|
|
14
|
+
<slot name="row" {item} />
|
|
15
|
+
{/each}
|
|
6
16
|
</tbody>
|
|
7
17
|
|
|
8
18
|
<!--
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare
|
|
3
|
-
props: {
|
|
2
|
+
declare class __sveltets_Render<T> {
|
|
3
|
+
props(): {
|
|
4
4
|
tableBodyClass?: string | undefined;
|
|
5
5
|
};
|
|
6
|
-
events: {
|
|
6
|
+
events(): {} & {
|
|
7
7
|
[evt: string]: CustomEvent<any>;
|
|
8
8
|
};
|
|
9
|
-
slots: {
|
|
9
|
+
slots(): {
|
|
10
10
|
default: {};
|
|
11
|
+
row: {
|
|
12
|
+
item: T;
|
|
13
|
+
};
|
|
11
14
|
};
|
|
12
|
-
}
|
|
13
|
-
export type TableBodyProps =
|
|
14
|
-
export type TableBodyEvents =
|
|
15
|
-
export type TableBodySlots =
|
|
15
|
+
}
|
|
16
|
+
export type TableBodyProps<T> = ReturnType<__sveltets_Render<T>['props']>;
|
|
17
|
+
export type TableBodyEvents<T> = ReturnType<__sveltets_Render<T>['events']>;
|
|
18
|
+
export type TableBodySlots<T> = ReturnType<__sveltets_Render<T>['slots']>;
|
|
16
19
|
/**
|
|
17
20
|
* [Go to docs](https://flowbite-svelte.com/)
|
|
18
21
|
* ## Props
|
|
19
22
|
* @prop export let tableBodyClass: string | undefined = undefined;
|
|
20
23
|
*/
|
|
21
|
-
export default class TableBody extends SvelteComponentTyped<TableBodyProps
|
|
24
|
+
export default class TableBody<T> extends SvelteComponentTyped<TableBodyProps<T>, TableBodyEvents<T>, TableBodySlots<T>> {
|
|
22
25
|
}
|
|
23
26
|
export {};
|
|
@@ -1,14 +1,47 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script generics="T">import { getContext } from "svelte";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
2
3
|
export let padding = "px-6 py-3";
|
|
4
|
+
export let sort = null;
|
|
5
|
+
export let defaultDirection = "asc";
|
|
6
|
+
export let defaultSort = false;
|
|
7
|
+
export let direction = defaultSort ? defaultDirection : null;
|
|
8
|
+
let sorter = getContext("sorter");
|
|
9
|
+
let sortId = Math.random().toString(36).substring(2);
|
|
10
|
+
$: direction = $sorter?.id === sortId ? $sorter.sortDirection === 1 ? "asc" : "desc" : null;
|
|
11
|
+
if (defaultSort) {
|
|
12
|
+
sortItems();
|
|
13
|
+
}
|
|
14
|
+
function sortItems() {
|
|
15
|
+
if (!sort || !sorter) return;
|
|
16
|
+
sorter.update((sorter2) => {
|
|
17
|
+
return {
|
|
18
|
+
id: sortId,
|
|
19
|
+
sort,
|
|
20
|
+
sortDirection: sorter2?.id === sortId ? -sorter2.sortDirection : defaultDirection === "asc" ? 1 : -1
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
3
24
|
</script>
|
|
4
25
|
|
|
26
|
+
{#if sort && sorter}
|
|
27
|
+
<th {...$$restProps} class={$$props.class} on:click on:focus on:keydown on:keypress on:keyup on:mouseenter on:mouseleave on:mouseover aria-sort={direction ? `${direction}ending` : undefined}>
|
|
28
|
+
<button class={twMerge('w-full text-left', 'after:absolute after:pl-3', direction === 'asc' && 'after:content-["▲"]', direction === 'desc' && 'after:content-["▼"]', padding)} on:click={sortItems}>
|
|
29
|
+
<slot />
|
|
30
|
+
</button>
|
|
31
|
+
</th>
|
|
32
|
+
{:else}
|
|
5
33
|
<th {...$$restProps} class={twMerge(padding, $$props.class)} on:click on:focus on:keydown on:keypress on:keyup on:mouseenter on:mouseleave on:mouseover>
|
|
6
34
|
<slot />
|
|
7
35
|
</th>
|
|
36
|
+
{/if}
|
|
8
37
|
|
|
9
38
|
<!--
|
|
10
39
|
@component
|
|
11
40
|
[Go to docs](https://flowbite-svelte.com/)
|
|
12
41
|
## Props
|
|
13
42
|
@prop export let padding: string = 'px-6 py-3';
|
|
43
|
+
@prop export let sort: ((a: T, b: T) => number) | null = null;
|
|
44
|
+
@prop export let defaultDirection: 'asc' | 'desc' = 'asc';
|
|
45
|
+
@prop export let defaultSort: boolean = false;
|
|
46
|
+
@prop export let direction: 'asc' | 'desc' | null = defaultSort ? defaultDirection : null;
|
|
14
47
|
-->
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare
|
|
3
|
-
props: {
|
|
2
|
+
declare class __sveltets_Render<T> {
|
|
3
|
+
props(): {
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
padding?: string | undefined;
|
|
6
|
+
sort?: ((a: T, b: T) => number) | null | undefined;
|
|
7
|
+
defaultDirection?: ("asc" | "desc") | undefined;
|
|
8
|
+
defaultSort?: boolean | undefined;
|
|
9
|
+
direction?: ("asc" | "desc" | null) | undefined;
|
|
6
10
|
};
|
|
7
|
-
events: {
|
|
11
|
+
events(): {
|
|
8
12
|
click: MouseEvent;
|
|
9
13
|
focus: FocusEvent;
|
|
10
14
|
keydown: KeyboardEvent;
|
|
@@ -16,18 +20,22 @@ declare const __propDef: {
|
|
|
16
20
|
} & {
|
|
17
21
|
[evt: string]: CustomEvent<any>;
|
|
18
22
|
};
|
|
19
|
-
slots: {
|
|
23
|
+
slots(): {
|
|
20
24
|
default: {};
|
|
21
25
|
};
|
|
22
|
-
}
|
|
23
|
-
export type TableHeadCellProps =
|
|
24
|
-
export type TableHeadCellEvents =
|
|
25
|
-
export type TableHeadCellSlots =
|
|
26
|
+
}
|
|
27
|
+
export type TableHeadCellProps<T> = ReturnType<__sveltets_Render<T>['props']>;
|
|
28
|
+
export type TableHeadCellEvents<T> = ReturnType<__sveltets_Render<T>['events']>;
|
|
29
|
+
export type TableHeadCellSlots<T> = ReturnType<__sveltets_Render<T>['slots']>;
|
|
26
30
|
/**
|
|
27
31
|
* [Go to docs](https://flowbite-svelte.com/)
|
|
28
32
|
* ## Props
|
|
29
33
|
* @prop export let padding: string = 'px-6 py-3';
|
|
34
|
+
* @prop export let sort: ((a: T, b: T) => number) | null = null;
|
|
35
|
+
* @prop export let defaultDirection: 'asc' | 'desc' = 'asc';
|
|
36
|
+
* @prop export let defaultSort: boolean = false;
|
|
37
|
+
* @prop export let direction: 'asc' | 'desc' | null = defaultSort ? defaultDirection : null;
|
|
30
38
|
*/
|
|
31
|
-
export default class TableHeadCell extends SvelteComponentTyped<TableHeadCellProps
|
|
39
|
+
export default class TableHeadCell<T> extends SvelteComponentTyped<TableHeadCellProps<T>, TableHeadCellEvents<T>, TableHeadCellSlots<T>> {
|
|
32
40
|
}
|
|
33
41
|
export {};
|
|
@@ -5,6 +5,7 @@ export let imgClass = "me-3 mb-3 w-12 h-12 rounded-full sm:mb-0";
|
|
|
5
5
|
export let divClass = "text-gray-600 dark:text-gray-400";
|
|
6
6
|
export let titleClass = "text-base font-normal";
|
|
7
7
|
export let spanClass = "inline-flex items-center text-xs font-normal text-gray-500 dark:text-gray-400";
|
|
8
|
+
export let isPrivacy = true;
|
|
8
9
|
let aCls = twMerge(aClass, $$props.classA);
|
|
9
10
|
let imgCls = twMerge(imgClass, $$props.classImg);
|
|
10
11
|
let divCls = twMerge(divClass, $$props.classDiv);
|
|
@@ -23,6 +24,7 @@ let spanCls = twMerge(spanClass, $$props.classSpan);
|
|
|
23
24
|
{#if comment}
|
|
24
25
|
<div class="text-sm font-normal">{comment}</div>
|
|
25
26
|
{/if}
|
|
27
|
+
{#if isPrivacy}
|
|
26
28
|
<span class={spanCls}>
|
|
27
29
|
{#if isPrivate}
|
|
28
30
|
<svg class="me-1 w-3 h-3" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -37,6 +39,7 @@ let spanCls = twMerge(spanClass, $$props.classSpan);
|
|
|
37
39
|
Public
|
|
38
40
|
{/if}
|
|
39
41
|
</span>
|
|
42
|
+
{/if}
|
|
40
43
|
</div>
|
|
41
44
|
</a>
|
|
42
45
|
</li>
|
|
@@ -52,4 +55,5 @@ let spanCls = twMerge(spanClass, $$props.classSpan);
|
|
|
52
55
|
@prop export let divClass: string = 'text-gray-600 dark:text-gray-400';
|
|
53
56
|
@prop export let titleClass: string = 'text-base font-normal';
|
|
54
57
|
@prop export let spanClass: string = 'inline-flex items-center text-xs font-normal text-gray-500 dark:text-gray-400';
|
|
58
|
+
@prop export let isPrivacy: boolean = true;
|
|
55
59
|
-->
|
|
@@ -9,6 +9,7 @@ declare const __propDef: {
|
|
|
9
9
|
divClass?: string | undefined;
|
|
10
10
|
titleClass?: string | undefined;
|
|
11
11
|
spanClass?: string | undefined;
|
|
12
|
+
isPrivacy?: boolean | undefined;
|
|
12
13
|
};
|
|
13
14
|
events: {
|
|
14
15
|
[evt: string]: CustomEvent<any>;
|
|
@@ -27,6 +28,7 @@ export type GroupItemSlots = typeof __propDef.slots;
|
|
|
27
28
|
* @prop export let divClass: string = 'text-gray-600 dark:text-gray-400';
|
|
28
29
|
* @prop export let titleClass: string = 'text-base font-normal';
|
|
29
30
|
* @prop export let spanClass: string = 'inline-flex items-center text-xs font-normal text-gray-500 dark:text-gray-400';
|
|
31
|
+
* @prop export let isPrivacy: boolean = true;
|
|
30
32
|
*/
|
|
31
33
|
export default class GroupItem extends SvelteComponentTyped<GroupItemProps, GroupItemEvents, GroupItemSlots> {
|
|
32
34
|
}
|
package/dist/utils/Popper.svelte
CHANGED
|
@@ -14,6 +14,8 @@ export let open = false;
|
|
|
14
14
|
export let yOnly = false;
|
|
15
15
|
export let middlewares = [dom.flip(), dom.shift()];
|
|
16
16
|
const dispatch = createEventDispatcher();
|
|
17
|
+
let focusable;
|
|
18
|
+
$: focusable = trigger === "focus";
|
|
17
19
|
let clickable;
|
|
18
20
|
$: clickable = trigger === "click";
|
|
19
21
|
let hoverable;
|
|
@@ -25,29 +27,28 @@ let floatingEl;
|
|
|
25
27
|
let arrowEl;
|
|
26
28
|
let contentEl;
|
|
27
29
|
let triggerEls = [];
|
|
28
|
-
let _blocked = false;
|
|
29
|
-
const block = () => (_blocked = true, setTimeout(() => _blocked = false, 250));
|
|
30
30
|
const showHandler = (ev) => {
|
|
31
31
|
if (referenceEl === void 0) console.error("trigger undefined");
|
|
32
32
|
if (!reference && triggerEls.includes(ev.target) && referenceEl !== ev.target) {
|
|
33
33
|
referenceEl = ev.target;
|
|
34
|
-
|
|
34
|
+
if (open) return;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
open = clickable && ev.type === "click" && !_blocked ? !open : true;
|
|
36
|
+
open = ev.type === "click" ? !open : true;
|
|
38
37
|
};
|
|
39
38
|
const hasHover = (el) => el.matches(":hover");
|
|
40
39
|
const hasFocus = (el) => el.contains(document.activeElement);
|
|
41
|
-
const px = (n) => n
|
|
40
|
+
const px = (n) => n ? `${n}px` : "";
|
|
42
41
|
const hideHandler = (ev) => {
|
|
43
|
-
if (activeContent) {
|
|
42
|
+
if (activeContent && hoverable) {
|
|
43
|
+
const elements = [referenceEl, floatingEl, ...triggerEls].filter(Boolean);
|
|
44
44
|
setTimeout(() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
open = false;
|
|
45
|
+
if (ev.type === "mouseleave" && !elements.some(hasHover)) {
|
|
46
|
+
open = false;
|
|
47
|
+
}
|
|
49
48
|
}, 100);
|
|
50
|
-
} else
|
|
49
|
+
} else {
|
|
50
|
+
open = false;
|
|
51
|
+
}
|
|
51
52
|
};
|
|
52
53
|
let arrowSide;
|
|
53
54
|
const oppositeSideMap = {
|
|
@@ -85,8 +86,8 @@ function init(node, _referenceEl) {
|
|
|
85
86
|
}
|
|
86
87
|
onMount(() => {
|
|
87
88
|
const events = [
|
|
88
|
-
["focusin", showHandler,
|
|
89
|
-
["focusout", hideHandler,
|
|
89
|
+
["focusin", showHandler, focusable],
|
|
90
|
+
["focusout", hideHandler, focusable],
|
|
90
91
|
["click", showHandler, clickable],
|
|
91
92
|
["mouseenter", showHandler, hoverable],
|
|
92
93
|
["mouseleave", hideHandler, hoverable]
|
|
@@ -105,13 +106,13 @@ onMount(() => {
|
|
|
105
106
|
if (referenceEl === document.body) {
|
|
106
107
|
console.error(`Popup reference not found: '${reference}'`);
|
|
107
108
|
} else {
|
|
108
|
-
referenceEl.addEventListener("focusout", hideHandler);
|
|
109
|
+
if (focusable) referenceEl.addEventListener("focusout", hideHandler);
|
|
109
110
|
if (hoverable) referenceEl.addEventListener("mouseleave", hideHandler);
|
|
110
111
|
}
|
|
111
112
|
} else {
|
|
112
113
|
referenceEl = triggerEls[0];
|
|
113
114
|
}
|
|
114
|
-
document.addEventListener("click", closeOnClickOutside);
|
|
115
|
+
if (clickable) document.addEventListener("click", closeOnClickOutside);
|
|
115
116
|
return () => {
|
|
116
117
|
triggerEls.forEach((element) => {
|
|
117
118
|
if (element) {
|
|
@@ -152,7 +153,7 @@ function initArrow(node) {
|
|
|
152
153
|
{/if}
|
|
153
154
|
|
|
154
155
|
{#if referenceEl}
|
|
155
|
-
<Frame use={init} options={referenceEl} bind:open role="tooltip" tabindex={activeContent ? -1 : undefined} on:focusin={optional(activeContent, showHandler)} on:focusout={optional(activeContent, hideHandler)} on:mouseenter={optional(activeContent && hoverable, showHandler)} on:mouseleave={optional(activeContent && hoverable, hideHandler)} {...$$restProps}>
|
|
156
|
+
<Frame use={init} options={referenceEl} bind:open role="tooltip" tabindex={activeContent ? -1 : undefined} on:focusin={optional(activeContent && focusable, showHandler)} on:focusout={optional(activeContent && focusable, hideHandler)} on:mouseenter={optional(activeContent && hoverable, showHandler)} on:mouseleave={optional(activeContent && hoverable, hideHandler)} {...$$restProps}>
|
|
156
157
|
<slot></slot>
|
|
157
158
|
{#if arrow}<div use:initArrow class={arrowClass}></div>{/if}
|
|
158
159
|
</Frame>
|