flowbite-svelte 0.25.1 → 0.25.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 +51 -0
- package/README.md +2 -1
- package/dropdowns/DropdownItem.svelte +0 -1
- package/forms/Iconinput.svelte +0 -1
- package/forms/Iconinput.svelte.d.ts +1 -2
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +8 -4
- package/popover/Popover.svelte +10 -0
- package/popover/Popover.svelte.d.ts +23 -0
- package/tables/Table.svelte +17 -3
- package/tables/Table.svelte.d.ts +3 -0
- package/tables/TableBodyCell.svelte +9 -2
- package/tables/TableBodyRow.svelte +33 -13
- package/tables/TableHead.svelte +30 -7
- package/tables/TableHead.svelte.d.ts +1 -0
- package/tables/TableSearch.svelte +12 -1
- package/tables/TableSearch.svelte.d.ts +1 -0
- package/tooltips/Tooltip.svelte +11 -133
- package/tooltips/Tooltip.svelte.d.ts +7 -9
- package/utils/Popper.svelte +81 -0
- package/utils/Popper.svelte.d.ts +29 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,57 @@
|
|
|
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.25.6](https://github.com/themesberg/flowbite-svelte/compare/v0.25.5...v0.25.6) (2022-08-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* fixing standard-version ([cd316e4](https://github.com/themesberg/flowbite-svelte/commit/cd316e412171689e04ec435dfc31abd89b7cbe1d))
|
|
11
|
+
|
|
12
|
+
### [0.25.5](https://github.com/themesberg/flowbite-svelte/compare/v0.25.4...v0.25.5) (2022-08-20)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* Iconinput has unused export property value when I install it ([b19afc9](https://github.com/themesberg/flowbite-svelte/commit/b19afc9284aa2c92c5a15b89de9dc9111652f0f7))
|
|
18
|
+
|
|
19
|
+
### [0.25.4](https://github.com/themesberg/flowbite-svelte/compare/v0.25.2...v0.25.4) (2022-08-20)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* add Table color hover and example ([b49c139](https://github.com/themesberg/flowbite-svelte/commit/b49c139c6d09a4563d462b35a5c49da605006d79))
|
|
25
|
+
|
|
26
|
+
### [0.25.2](https://github.com/themesberg/flowbite-svelte/compare/v0.25.1...v0.25.2) (2022-08-19)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* add popover related files ([8b5050b](https://github.com/themesberg/flowbite-svelte/commit/8b5050b0e9f6e45533b858c7aa392463cfb6cc91))
|
|
32
|
+
* popover ([c41ddc4](https://github.com/themesberg/flowbite-svelte/commit/c41ddc408f3696e05ee66de4922b95ee5cee1a08))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* change href=# to href=/ in popover page ([f885a92](https://github.com/themesberg/flowbite-svelte/commit/f885a924706e477349c975641fc6fba0b4df45e5))
|
|
38
|
+
* missing Popper ([ff4b0e7](https://github.com/themesberg/flowbite-svelte/commit/ff4b0e772e228f03c1024e222fcc91e63adc23ba))
|
|
39
|
+
|
|
40
|
+
### [0.25.1](https://github.com/themesberg/flowbite-svelte/compare/v0.25.0...v0.25.1) (2022-08-18)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Bug Fixes
|
|
44
|
+
|
|
45
|
+
* move @floating-ui/dom from dependencies to devDependencies ([6668ec8](https://github.com/themesberg/flowbite-svelte/commit/6668ec8ca1559366ad0cbc223c9c91e3337ceb22))
|
|
46
|
+
|
|
47
|
+
## [0.25.0](https://github.com/themesberg/flowbite-svelte/compare/v0.24.19...v0.25.0) (2022-08-18)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Bug Fixes
|
|
51
|
+
|
|
52
|
+
* [#226](https://github.com/themesberg/flowbite-svelte/issues/226) for double on:click in DropdownItem ([c125d2d](https://github.com/themesberg/flowbite-svelte/commit/c125d2d02e3818cedb83994e930ca5cc7075571c))
|
|
53
|
+
* migrate to sveltekit 1.0.0 ([434ec99](https://github.com/themesberg/flowbite-svelte/commit/434ec998e1f96ab5e35eda6c6c78f6db2279aa4e))
|
|
54
|
+
* update pnpm-lock ([4926a47](https://github.com/themesberg/flowbite-svelte/commit/4926a47bd529601b1a0709533fee2b5291e59eb8))
|
|
55
|
+
|
|
5
56
|
### [0.24.19](https://github.com/themesberg/flowbite-svelte/compare/v0.24.18...v0.24.19) (2022-08-17)
|
|
6
57
|
|
|
7
58
|
|
package/README.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/flowbite-svelte)
|
|
4
4
|
[](https://www.npmjs.com/package/flowbite-svelte)
|
|
5
|
-
[](https://www.npmjs.com/package/flowbite-svelte)
|
|
6
6
|
[](https://github.com/themesberg/flowbite-svelte/blob/main/LICENSE)
|
|
7
|
+
[](https://discord.com/invite/4eeurUVvTy)
|
|
7
8
|
|
|
8
9
|
**⚠️ Flowbite-Svelte is currently in early development and APIs and packages are likely to change quite often.**
|
|
9
10
|
|
package/forms/Iconinput.svelte
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { InputType } from '../types';
|
|
3
2
|
import type { SvelteComponent } from 'svelte';
|
|
3
|
+
import type { InputType } from '../types';
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
6
|
[x: string]: any;
|
|
7
7
|
type?: InputType;
|
|
8
|
-
value?: string;
|
|
9
8
|
size?: 'sm' | 'md' | 'lg';
|
|
10
9
|
icon: typeof SvelteComponent;
|
|
11
10
|
noBorder?: boolean;
|
package/index.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ export { default as Pagination } from './paginations/Pagination.svelte';
|
|
|
59
59
|
export { default as Previous } from './paginations/Previous.svelte';
|
|
60
60
|
export { default as Next } from './paginations/Next.svelte';
|
|
61
61
|
export { default as TableData } from './paginations/TableData.svelte';
|
|
62
|
+
export { default as Popover } from './popover/Popover.svelte';
|
|
62
63
|
export { default as Progressbar } from './progressbars/Progressbar.svelte';
|
|
63
64
|
export { default as Rating } from './ratings/Rating.svelte';
|
|
64
65
|
export { default as AdvancedRating } from './ratings/AdvancedRating.svelte';
|
package/index.js
CHANGED
|
@@ -80,6 +80,8 @@ export { default as Pagination } from './paginations/Pagination.svelte';
|
|
|
80
80
|
export { default as Previous } from './paginations/Previous.svelte';
|
|
81
81
|
export { default as Next } from './paginations/Next.svelte';
|
|
82
82
|
export { default as TableData } from './paginations/TableData.svelte';
|
|
83
|
+
// Popover
|
|
84
|
+
export { default as Popover } from './popover/Popover.svelte';
|
|
83
85
|
// Progressbar
|
|
84
86
|
export { default as Progressbar } from './progressbars/Progressbar.svelte';
|
|
85
87
|
// Rating
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flowbite-svelte",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.6",
|
|
4
4
|
"description": "Flowbite components for Svelte",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": {
|
|
@@ -14,11 +14,14 @@
|
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@floating-ui/dom": "^1.0.1",
|
|
16
16
|
"@playwright/test": "^1.25.0",
|
|
17
|
+
"@popperjs/core": "^2.11.6",
|
|
17
18
|
"@sveltejs/adapter-auto": "next",
|
|
18
|
-
"@sveltejs/kit": "next",
|
|
19
|
+
"@sveltejs/kit": "1.0.0-next.420",
|
|
20
|
+
"@sveltejs/package": "1.0.0-next.1",
|
|
19
21
|
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
|
20
22
|
"@typescript-eslint/parser": "^5.33.0",
|
|
21
23
|
"autoprefixer": "^10.4.8",
|
|
24
|
+
"classnames": "^2.3.1",
|
|
22
25
|
"createprops": "^0.4.9",
|
|
23
26
|
"eslint": "^8.21.0",
|
|
24
27
|
"eslint-config-prettier": "^8.5.0",
|
|
@@ -82,7 +85,6 @@
|
|
|
82
85
|
"url": "https://github.com/themesberg/flowbite-svelte"
|
|
83
86
|
},
|
|
84
87
|
"dependencies": {
|
|
85
|
-
"classnames": "^2.3.1",
|
|
86
88
|
"flowbite": "^1.5.2"
|
|
87
89
|
},
|
|
88
90
|
"engines": {
|
|
@@ -167,6 +169,7 @@
|
|
|
167
169
|
"./paginations/Pagination.svelte": "./paginations/Pagination.svelte",
|
|
168
170
|
"./paginations/Previous.svelte": "./paginations/Previous.svelte",
|
|
169
171
|
"./paginations/TableData.svelte": "./paginations/TableData.svelte",
|
|
172
|
+
"./popover/Popover.svelte": "./popover/Popover.svelte",
|
|
170
173
|
"./progressbars/Progressbar.svelte": "./progressbars/Progressbar.svelte",
|
|
171
174
|
"./ratings/AdvancedRating.svelte": "./ratings/AdvancedRating.svelte",
|
|
172
175
|
"./ratings/Rating.svelte": "./ratings/Rating.svelte",
|
|
@@ -220,9 +223,10 @@
|
|
|
220
223
|
"./tooltips/Tooltip.svelte": "./tooltips/Tooltip.svelte",
|
|
221
224
|
"./types": "./types.js",
|
|
222
225
|
"./utils/CloseButton.svelte": "./utils/CloseButton.svelte",
|
|
226
|
+
"./utils/Popper.svelte": "./utils/Popper.svelte",
|
|
223
227
|
"./utils/clickOutside": "./utils/clickOutside.js",
|
|
224
228
|
"./utils/focusTrap": "./utils/focusTrap.js",
|
|
225
229
|
"./utils/generateId": "./utils/generateId.js"
|
|
226
230
|
},
|
|
227
231
|
"svelte": "./index.js"
|
|
228
|
-
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script>import Popper from '../utils/Popper.svelte';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
let popoverClass;
|
|
4
|
+
$: popoverClass = classNames('border border-gray-200 rounded-lg dark:border-gray-700 bg-white dark:bg-gray-800', $$props.class);
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<Popper activeContent={true} {...$$restProps} class={popoverClass} on:show>
|
|
8
|
+
<slot name="trigger" slot="trigger" />
|
|
9
|
+
<slot />
|
|
10
|
+
</Popper>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
show: CustomEvent<any>;
|
|
8
|
+
} & {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {
|
|
12
|
+
trigger: {
|
|
13
|
+
slot: string;
|
|
14
|
+
};
|
|
15
|
+
default: {};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare type PopoverProps = typeof __propDef.props;
|
|
19
|
+
export declare type PopoverEvents = typeof __propDef.events;
|
|
20
|
+
export declare type PopoverSlots = typeof __propDef.slots;
|
|
21
|
+
export default class Popover extends SvelteComponentTyped<PopoverProps, PopoverEvents, PopoverSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
package/tables/Table.svelte
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
<script>import classNames from 'classnames';
|
|
2
2
|
import { setContext } from 'svelte';
|
|
3
|
-
export let divClass = 'relative overflow-x-auto
|
|
3
|
+
export let divClass = 'relative overflow-x-auto';
|
|
4
4
|
export let striped = false;
|
|
5
5
|
export let hoverable = false;
|
|
6
|
+
export let noborder = false;
|
|
7
|
+
export let shadow = false;
|
|
8
|
+
export let color = 'default';
|
|
9
|
+
const colors = {
|
|
10
|
+
default: 'text-gray-500 dark:text-gray-400',
|
|
11
|
+
blue: 'text-blue-100 dark:text-blue-100',
|
|
12
|
+
green: 'text-green-100 dark:text-green-100',
|
|
13
|
+
red: 'text-red-100 dark:text-red-100',
|
|
14
|
+
yellow: 'text-yellow-100 dark:text-yellow-100',
|
|
15
|
+
purple: 'text-purple-100 dark:text-purple-100',
|
|
16
|
+
custom: ''
|
|
17
|
+
};
|
|
6
18
|
$: setContext('striped', striped);
|
|
7
19
|
$: setContext('hoverable', hoverable);
|
|
20
|
+
$: setContext('noborder', noborder);
|
|
21
|
+
$: setContext('color', color);
|
|
8
22
|
</script>
|
|
9
23
|
|
|
10
|
-
<div class={divClass}>
|
|
24
|
+
<div class={classNames(divClass, shadow && 'shadow-md sm:rounded-lg')}>
|
|
11
25
|
<table
|
|
12
26
|
{...$$restProps}
|
|
13
|
-
class={classNames('w-full text-left text-sm
|
|
27
|
+
class={classNames('w-full text-left text-sm', colors[color], $$props.class)}
|
|
14
28
|
>
|
|
15
29
|
<slot />
|
|
16
30
|
</table>
|
package/tables/Table.svelte.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ declare const __propDef: {
|
|
|
5
5
|
divClass?: string;
|
|
6
6
|
striped?: boolean;
|
|
7
7
|
hoverable?: boolean;
|
|
8
|
+
noborder?: boolean;
|
|
9
|
+
shadow?: boolean;
|
|
10
|
+
color?: 'blue' | 'green' | 'red' | 'yellow' | 'purple' | 'default' | 'custom';
|
|
8
11
|
};
|
|
9
12
|
events: {
|
|
10
13
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
<script>import classNames from 'classnames';
|
|
2
|
-
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
export let tdClass = 'px-6 py-4 whitespace-nowrap font-medium ';
|
|
4
|
+
let color = 'default';
|
|
5
|
+
color = getContext('color');
|
|
6
|
+
let tdClassfinal;
|
|
7
|
+
$: tdClassfinal = classNames(tdClass, color === 'default'
|
|
8
|
+
? 'text-gray-900 dark:text-white'
|
|
9
|
+
: 'text-blue-50 whitespace-nowrap dark:text-blue-100', $$props.class);
|
|
3
10
|
</script>
|
|
4
11
|
|
|
5
|
-
<td {...$$restProps} class={
|
|
12
|
+
<td {...$$restProps} class={tdClassfinal}>
|
|
6
13
|
<slot />
|
|
7
14
|
</td>
|
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
<script>import classNames from 'classnames';
|
|
2
2
|
import { getContext } from 'svelte';
|
|
3
|
-
export let trClass = 'bg-white
|
|
3
|
+
export let trClass = 'bg-white';
|
|
4
|
+
const colors = {
|
|
5
|
+
default: 'dark:border-gray-700 dark:bg-gray-800',
|
|
6
|
+
blue: 'bg-blue-500 border-b border-blue-400',
|
|
7
|
+
green: 'bg-green-500 border-b border-green-400',
|
|
8
|
+
red: 'bg-red-500 border-b border-red-400',
|
|
9
|
+
yellow: 'bg-yellow-500 border-b border-yellow-400',
|
|
10
|
+
purple: 'bg-purple-500 border-b border-purple-400',
|
|
11
|
+
custom: ''
|
|
12
|
+
};
|
|
13
|
+
const hoverColors = {
|
|
14
|
+
default: 'hover:bg-gray-50 dark:hover:bg-gray-600',
|
|
15
|
+
blue: 'hover:bg-blue-400',
|
|
16
|
+
green: 'hover:bg-green-400',
|
|
17
|
+
red: 'hover:bg-red-400',
|
|
18
|
+
yellow: 'hover:bg-yellow-400',
|
|
19
|
+
purple: 'hover:bg-purple-400',
|
|
20
|
+
custom: ''
|
|
21
|
+
};
|
|
22
|
+
const stripColors = {
|
|
23
|
+
default: 'odd:bg-white even:bg-gray-50 odd:dark:bg-gray-800 even:dark:bg-gray-700',
|
|
24
|
+
blue: 'odd:bg-blue-800 even:bg-blue-700 odd:dark:bg-blue-800 even:dark:bg-blue-700',
|
|
25
|
+
green: 'odd:bg-green-800 even:bg-green-700 odd:dark:bg-green-800 even:dark:bg-green-700',
|
|
26
|
+
red: 'odd:bg-red-800 even:bg-red-700 odd:dark:bg-red-800 even:dark:bg-red-700',
|
|
27
|
+
yellow: 'odd:bg-yellow-800 even:bg-yellow-700 odd:dark:bg-yellow-800 even:dark:bg-yellow-700',
|
|
28
|
+
purple: 'odd:bg-purple-800 even:bg-purple-700 odd:dark:bg-purple-800 even:dark:bg-purple-700',
|
|
29
|
+
custom: ''
|
|
30
|
+
};
|
|
31
|
+
let color = 'default';
|
|
32
|
+
color = getContext('color');
|
|
33
|
+
let trClassfinal;
|
|
34
|
+
$: trClassfinal = classNames(getContext('noborder') ? 'bg-white dark:bg-gray-800' : trClass, colors[color], getContext('hoverable') && hoverColors[color], getContext('striped') && stripColors[color], $$props.class);
|
|
4
35
|
</script>
|
|
5
36
|
|
|
6
|
-
<tr
|
|
7
|
-
{...$$restProps}
|
|
8
|
-
class={classNames(
|
|
9
|
-
trClass,
|
|
10
|
-
{
|
|
11
|
-
'odd:bg-white even:bg-gray-50 odd:dark:bg-gray-800 even:dark:bg-gray-700':
|
|
12
|
-
getContext('striped') === true,
|
|
13
|
-
'hover:bg-gray-50 dark:hover:bg-gray-600': getContext('hoverable') === true
|
|
14
|
-
},
|
|
15
|
-
$$props.class
|
|
16
|
-
)}
|
|
17
|
-
>
|
|
37
|
+
<tr {...$$restProps} class={trClassfinal}>
|
|
18
38
|
<slot />
|
|
19
39
|
</tr>
|
package/tables/TableHead.svelte
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
<script>import classNames from 'classnames';
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
export let theadClass = 'text-xs uppercase';
|
|
4
|
+
let color;
|
|
5
|
+
color = getContext('color');
|
|
6
|
+
let noborder = getContext('noborder');
|
|
7
|
+
let striped = getContext('striped');
|
|
8
|
+
let defatultBgColor = noborder || striped ? '' : 'bg-gray-50 dark:bg-gray-700';
|
|
9
|
+
const bgColors = {
|
|
10
|
+
default: defatultBgColor,
|
|
11
|
+
blue: 'bg-blue-600',
|
|
12
|
+
green: 'bg-green-600',
|
|
13
|
+
red: 'bg-red-600',
|
|
14
|
+
yellow: 'bg-yellow-600',
|
|
15
|
+
purple: 'bg-purple-600',
|
|
16
|
+
custom: ''
|
|
17
|
+
};
|
|
18
|
+
let textColor = color === 'default'
|
|
19
|
+
? 'text-gray-700 dark:text-gray-400'
|
|
20
|
+
: color === 'custom'
|
|
21
|
+
? ''
|
|
22
|
+
: 'text-white dark:text-white';
|
|
23
|
+
let borderColors = striped
|
|
24
|
+
? ''
|
|
25
|
+
: color === 'default'
|
|
26
|
+
? 'border-gray-700'
|
|
27
|
+
: color === 'custom'
|
|
28
|
+
? ''
|
|
29
|
+
: `border-${color}-400`;
|
|
30
|
+
$: theadClassfinal = classNames(theadClass, textColor, striped && borderColors, bgColors[color], $$props.class);
|
|
2
31
|
</script>
|
|
3
32
|
|
|
4
|
-
<thead
|
|
5
|
-
{...$$restProps}
|
|
6
|
-
class={classNames(
|
|
7
|
-
'bg-gray-50 text-xs uppercase text-gray-700 dark:bg-gray-700 dark:text-gray-400',
|
|
8
|
-
$$props.class
|
|
9
|
-
)}
|
|
10
|
-
>
|
|
33
|
+
<thead {...$$restProps} class={theadClassfinal}>
|
|
11
34
|
<tr>
|
|
12
35
|
<slot />
|
|
13
36
|
</tr>
|
|
@@ -5,8 +5,19 @@ export let inputValue = '';
|
|
|
5
5
|
export let striped = false;
|
|
6
6
|
export let hoverable = false;
|
|
7
7
|
export let placeholder = 'Search';
|
|
8
|
+
export let color = 'default';
|
|
9
|
+
const colors = {
|
|
10
|
+
default: 'text-gray-500 dark:text-gray-400',
|
|
11
|
+
blue: 'text-blue-100 dark:text-blue-100',
|
|
12
|
+
green: 'text-green-100 dark:text-green-100',
|
|
13
|
+
red: 'text-red-100 dark:text-red-100',
|
|
14
|
+
yellow: 'text-yellow-100 dark:text-yellow-100',
|
|
15
|
+
purple: 'text-purple-100 dark:text-purple-100',
|
|
16
|
+
custom: ''
|
|
17
|
+
};
|
|
8
18
|
$: setContext('striped', striped);
|
|
9
19
|
$: setContext('hoverable', hoverable);
|
|
20
|
+
$: setContext('color', color);
|
|
10
21
|
</script>
|
|
11
22
|
|
|
12
23
|
<div class={divClass}>
|
|
@@ -37,7 +48,7 @@ $: setContext('hoverable', hoverable);
|
|
|
37
48
|
</div>
|
|
38
49
|
<table
|
|
39
50
|
{...$$restProps}
|
|
40
|
-
class={classNames('w-full text-left text-sm
|
|
51
|
+
class={classNames('w-full text-left text-sm', colors[color], $$props.class)}
|
|
41
52
|
>
|
|
42
53
|
<slot />
|
|
43
54
|
</table>
|
package/tooltips/Tooltip.svelte
CHANGED
|
@@ -1,142 +1,20 @@
|
|
|
1
|
-
<script>import
|
|
2
|
-
import
|
|
3
|
-
import { computePosition, flip, shift, offset, autoPlacement, arrow as arrowFloat } from '@floating-ui/dom';
|
|
4
|
-
import { onDestroy } from 'svelte';
|
|
5
|
-
export let placement = 'top';
|
|
6
|
-
export let trigger = 'hover';
|
|
7
|
-
export let style = 'dark';
|
|
1
|
+
<script>import Popper from '../utils/Popper.svelte';
|
|
2
|
+
import classNames from 'classnames';
|
|
8
3
|
export let content = '';
|
|
9
|
-
export let
|
|
10
|
-
export let arrow = true;
|
|
11
|
-
export let tipClass = 'absolute inline-block rounded-lg py-2 px-3 text-sm font-medium shadow-sm';
|
|
4
|
+
export let style = 'dark';
|
|
12
5
|
export let tipColor = '';
|
|
13
|
-
export let
|
|
6
|
+
export let tipClass = 'py-2 px-3 text-sm font-medium rounded-lg shadow-sm tooltip';
|
|
14
7
|
const tipStyleClasses = {
|
|
15
|
-
dark: 'bg-gray-900 text-white dark:bg-gray-700',
|
|
8
|
+
dark: 'border border-gray-800 bg-gray-900 text-white dark:bg-gray-700 dark:border-gray-600',
|
|
16
9
|
light: 'border border-gray-200 bg-white text-gray-900',
|
|
17
|
-
auto: 'border border-gray-200 bg-white text-gray-900 dark:
|
|
18
|
-
custom: tipColor
|
|
19
|
-
};
|
|
20
|
-
const arrowStyleClasses = {
|
|
21
|
-
dark: 'bg-gray-900 dark:bg-gray-700',
|
|
22
|
-
light: 'bg-white',
|
|
23
|
-
auto: 'bg-white dark:bg-gray-700',
|
|
10
|
+
auto: 'border border-gray-200 bg-white text-gray-900 dark:bg-gray-700 dark:text-white dark:border-gray-600 ',
|
|
24
11
|
custom: tipColor
|
|
25
12
|
};
|
|
26
13
|
let toolTipClass;
|
|
27
|
-
$: toolTipClass = classNames(tipClass,
|
|
28
|
-
const floatingPlacement = (placement) => {
|
|
29
|
-
return placement === 'auto' ? undefined : placement;
|
|
30
|
-
};
|
|
31
|
-
const floatingMiddleware = (arrowRef, placement) => {
|
|
32
|
-
const middleware = [];
|
|
33
|
-
middleware.push(offset(8));
|
|
34
|
-
middleware.push(placement === 'auto' ? autoPlacement() : flip());
|
|
35
|
-
middleware.push(shift({ padding: 8 }));
|
|
36
|
-
if (arrowRef) {
|
|
37
|
-
middleware.push(arrowFloat({ element: arrowRef }));
|
|
38
|
-
}
|
|
39
|
-
return middleware;
|
|
40
|
-
};
|
|
41
|
-
let placementData;
|
|
42
|
-
let tooltipRef, triggerRef, arrowRef;
|
|
43
|
-
const updatePosition = () => computePosition(triggerRef, tooltipRef, {
|
|
44
|
-
middleware: floatingMiddleware(arrowRef, placement),
|
|
45
|
-
placement: floatingPlacement(placement)
|
|
46
|
-
}).then((data) => (placementData = data));
|
|
47
|
-
let attachedScroll = false;
|
|
48
|
-
$: tooltipRef && open && updatePosition();
|
|
49
|
-
$: {
|
|
50
|
-
if (tooltipRef && triggerRef) {
|
|
51
|
-
if (open && !attachedScroll) {
|
|
52
|
-
attachedScroll = true;
|
|
53
|
-
window.addEventListener('scroll', updatePosition, true);
|
|
54
|
-
}
|
|
55
|
-
else if (!open && attachedScroll) {
|
|
56
|
-
attachedScroll = false;
|
|
57
|
-
window.removeEventListener('scroll', updatePosition, true);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
onDestroy(() => {
|
|
62
|
-
if (attachedScroll) {
|
|
63
|
-
attachedScroll = false;
|
|
64
|
-
window.removeEventListener('scroll', updatePosition, true);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
const arrPos = {
|
|
68
|
-
top: 'bottom',
|
|
69
|
-
right: 'left',
|
|
70
|
-
bottom: 'top',
|
|
71
|
-
left: 'right'
|
|
72
|
-
};
|
|
73
|
-
let floatingArrowPlacement;
|
|
74
|
-
$: {
|
|
75
|
-
if (placementData) {
|
|
76
|
-
const arrow = placementData.middlewareData.arrow;
|
|
77
|
-
const pos = arrPos[placementData?.placement?.split('-')[0]] ?? 'top';
|
|
78
|
-
if (pos === 'top' || pos === 'bottom')
|
|
79
|
-
floatingArrowPlacement = `${pos}: -4px; left: ${px(arrow?.x)}`;
|
|
80
|
-
else
|
|
81
|
-
floatingArrowPlacement = `${pos}: -4px; top: ${px(arrow?.y)}`;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const px = (x) => (x === undefined ? '' : x + 'px');
|
|
14
|
+
$: toolTipClass = classNames(tipClass, tipStyleClasses[style], $$props.class);
|
|
85
15
|
</script>
|
|
86
16
|
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
if (open) {
|
|
92
|
-
open = false;
|
|
93
|
-
}
|
|
94
|
-
}}
|
|
95
|
-
>
|
|
96
|
-
<div
|
|
97
|
-
class="w-fit"
|
|
98
|
-
bind:this={triggerRef}
|
|
99
|
-
on:mouseenter={() => {
|
|
100
|
-
if (trigger === 'hover') {
|
|
101
|
-
open = true;
|
|
102
|
-
}
|
|
103
|
-
}}
|
|
104
|
-
on:mouseleave={() => {
|
|
105
|
-
if (open && trigger === 'hover') {
|
|
106
|
-
open = false;
|
|
107
|
-
}
|
|
108
|
-
}}
|
|
109
|
-
on:click={() => {
|
|
110
|
-
if (trigger === 'click') {
|
|
111
|
-
open = !open;
|
|
112
|
-
}
|
|
113
|
-
}}
|
|
114
|
-
>
|
|
115
|
-
<slot />
|
|
116
|
-
</div>
|
|
117
|
-
|
|
118
|
-
<div
|
|
119
|
-
bind:this={tooltipRef}
|
|
120
|
-
data-testid="tooltip"
|
|
121
|
-
class={toolTipClass}
|
|
122
|
-
style:left={px(placementData?.x)}
|
|
123
|
-
style:top={px(placementData?.y)}
|
|
124
|
-
style:position={placementData?.strategy ?? ''}
|
|
125
|
-
>
|
|
126
|
-
<div class="relative z-20">
|
|
127
|
-
<slot name="content">
|
|
128
|
-
{content}
|
|
129
|
-
</slot>
|
|
130
|
-
</div>
|
|
131
|
-
{#if arrow}
|
|
132
|
-
<div
|
|
133
|
-
class={classNames('absolute z-10 h-2 w-2 rotate-45', arrowStyleClasses[style])}
|
|
134
|
-
data-testid="tooltip-arrow"
|
|
135
|
-
style={floatingArrowPlacement}
|
|
136
|
-
bind:this={arrowRef}
|
|
137
|
-
>
|
|
138
|
-
|
|
139
|
-
</div>
|
|
140
|
-
{/if}
|
|
141
|
-
</div>
|
|
142
|
-
</div>
|
|
17
|
+
<Popper activeContent={false} {...$$restProps} class={toolTipClass} on:show>
|
|
18
|
+
<slot slot="trigger" />
|
|
19
|
+
<slot name="content">{content}</slot>
|
|
20
|
+
</Popper>
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { Placement } from '@floating-ui/dom';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
[x: string]: any;
|
|
6
|
-
placement?: 'auto' | Placement;
|
|
7
|
-
trigger?: 'hover' | 'click';
|
|
8
|
-
style?: 'dark' | 'light' | 'auto' | 'custom';
|
|
9
5
|
content?: string;
|
|
10
|
-
|
|
11
|
-
arrow?: boolean;
|
|
12
|
-
tipClass?: string;
|
|
6
|
+
style?: 'dark' | 'light' | 'auto' | 'custom';
|
|
13
7
|
tipColor?: string;
|
|
14
|
-
|
|
8
|
+
tipClass?: string;
|
|
15
9
|
};
|
|
16
10
|
events: {
|
|
11
|
+
show: CustomEvent<any>;
|
|
12
|
+
} & {
|
|
17
13
|
[evt: string]: CustomEvent<any>;
|
|
18
14
|
};
|
|
19
15
|
slots: {
|
|
20
|
-
default: {
|
|
16
|
+
default: {
|
|
17
|
+
slot: string;
|
|
18
|
+
};
|
|
21
19
|
content: {};
|
|
22
20
|
};
|
|
23
21
|
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from 'svelte';
|
|
2
|
+
import { createPopper } from '@popperjs/core';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
|
+
export let open = false;
|
|
6
|
+
export let placement = 'top';
|
|
7
|
+
export let offset = 8;
|
|
8
|
+
export let trigger = 'hover';
|
|
9
|
+
export let arrow = true;
|
|
10
|
+
export let animation = 'duration-300';
|
|
11
|
+
export let activeContent;
|
|
12
|
+
let clickable;
|
|
13
|
+
$: clickable = trigger === 'click';
|
|
14
|
+
let triggerEl, contentEl, popper;
|
|
15
|
+
let _blocked = false; // managment of the race condition between focusin and click events
|
|
16
|
+
const block = () => ((_blocked = true), setTimeout(() => (_blocked = false), 500));
|
|
17
|
+
const showHandler = (ev) => {
|
|
18
|
+
if (clickable && ev.type === 'focusin' && !open)
|
|
19
|
+
block();
|
|
20
|
+
open = ev.type === 'click' && !_blocked ? !open : true;
|
|
21
|
+
};
|
|
22
|
+
const hideHandler = (ev) => {
|
|
23
|
+
if (activeContent)
|
|
24
|
+
setTimeout(() => triggerEl.matches(':hover') || contentEl.matches(':hover') || (open = false), 100);
|
|
25
|
+
else
|
|
26
|
+
open = false;
|
|
27
|
+
};
|
|
28
|
+
$: {
|
|
29
|
+
if (triggerEl && contentEl) {
|
|
30
|
+
popper = createPopper(triggerEl, contentEl, {
|
|
31
|
+
placement,
|
|
32
|
+
modifiers: [{ name: 'offset', options: { offset: [0, offset] } }]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function enableListeners(modifiers) {
|
|
37
|
+
const modifier = modifiers.find((x) => x.name === 'eventListeners');
|
|
38
|
+
if (!modifier)
|
|
39
|
+
return [...modifiers, { name: 'eventListeners', enabled: open }];
|
|
40
|
+
modifier.enabled = open;
|
|
41
|
+
return modifiers;
|
|
42
|
+
}
|
|
43
|
+
$: {
|
|
44
|
+
if (popper) {
|
|
45
|
+
// Enable the event listeners
|
|
46
|
+
popper.setOptions(({ modifiers, ...options }) => ({
|
|
47
|
+
...options,
|
|
48
|
+
modifiers: enableListeners(modifiers)
|
|
49
|
+
}));
|
|
50
|
+
open && popper.update(); // Update the position
|
|
51
|
+
dispatch('show', open);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
let divClass;
|
|
55
|
+
$: divClass = classNames('z-10', animation && `transition-opacity ${animation}`, open ? 'visible opacity-100' : 'invisible opacity-0', $$props.class);
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<span
|
|
59
|
+
bind:this={triggerEl}
|
|
60
|
+
on:focusin={showHandler}
|
|
61
|
+
on:focusout={hideHandler}
|
|
62
|
+
on:click={clickable ? showHandler : undefined}
|
|
63
|
+
on:mouseenter={clickable ? undefined : showHandler}
|
|
64
|
+
on:mouseleave={clickable ? undefined : hideHandler}
|
|
65
|
+
class="inline-block"
|
|
66
|
+
>
|
|
67
|
+
<slot name="trigger" />
|
|
68
|
+
</span>
|
|
69
|
+
<div
|
|
70
|
+
bind:this={contentEl}
|
|
71
|
+
role="tooltip"
|
|
72
|
+
tabindex={activeContent ? -1 : undefined}
|
|
73
|
+
class={divClass}
|
|
74
|
+
on:focus={activeContent ? showHandler : undefined}
|
|
75
|
+
on:blur={activeContent ? hideHandler : undefined}
|
|
76
|
+
on:mouseenter={activeContent && !clickable ? showHandler : undefined}
|
|
77
|
+
on:mouseleave={activeContent && !clickable ? hideHandler : undefined}
|
|
78
|
+
>
|
|
79
|
+
<slot />
|
|
80
|
+
{#if arrow}<div data-popper-arrow />{/if}
|
|
81
|
+
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Placement } from '@popperjs/core';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
open?: boolean;
|
|
7
|
+
placement?: Placement;
|
|
8
|
+
offset?: number;
|
|
9
|
+
trigger?: 'hover' | 'click';
|
|
10
|
+
arrow?: boolean;
|
|
11
|
+
animation?: false | `duration-${number}`;
|
|
12
|
+
activeContent: boolean;
|
|
13
|
+
};
|
|
14
|
+
events: {
|
|
15
|
+
show: CustomEvent<any>;
|
|
16
|
+
} & {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
};
|
|
19
|
+
slots: {
|
|
20
|
+
trigger: {};
|
|
21
|
+
default: {};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare type PopperProps = typeof __propDef.props;
|
|
25
|
+
export declare type PopperEvents = typeof __propDef.events;
|
|
26
|
+
export declare type PopperSlots = typeof __propDef.slots;
|
|
27
|
+
export default class Popper extends SvelteComponentTyped<PopperProps, PopperEvents, PopperSlots> {
|
|
28
|
+
}
|
|
29
|
+
export {};
|