flowbite-svelte 0.22.28 → 0.23.0
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 +34 -0
- package/README.md +6 -0
- package/datepicker/Calender.svelte +12 -0
- package/datepicker/Calender.svelte.d.ts +19 -0
- package/datepicker/Datepicker.svelte +71 -0
- package/datepicker/Datepicker.svelte.d.ts +25 -0
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +3 -1
- package/tooltips/Tooltip.svelte +46 -40
- package/tooltips/Tooltip.svelte.d.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,40 @@
|
|
|
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.23.0](https://github.com/themesberg/flowbite-svelte/compare/v0.22.30...v0.23.0) (2022-08-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* add datepicker
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add datepicker ([a8b70e6](https://github.com/themesberg/flowbite-svelte/commit/a8b70e67b61e4e038520cc66238861e368716e60))
|
|
15
|
+
* add datepicker ([32f8889](https://github.com/themesberg/flowbite-svelte/commit/32f88899256bed9effe6b23b4d24cd8380ce2aff))
|
|
16
|
+
* add datepicker examples ([590ec66](https://github.com/themesberg/flowbite-svelte/commit/590ec660f27e43b18c588d44c0899aa16a3fc870))
|
|
17
|
+
* add datepicker examples ([68e2462](https://github.com/themesberg/flowbite-svelte/commit/68e2462567838816ef116c3ed5b389e8de52f643))
|
|
18
|
+
* working on datepicker ([4fedccf](https://github.com/themesberg/flowbite-svelte/commit/4fedccfc3f04308b53712cc87849098a7e502d2a))
|
|
19
|
+
|
|
20
|
+
### [0.22.30](https://github.com/themesberg/flowbite-svelte/compare/v0.22.29...v0.22.30) (2022-08-03)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* add Tooltip custom CSS ([1466d16](https://github.com/themesberg/flowbite-svelte/commit/1466d16fff312ccdb22e1c282f49b7b156121d57))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* revert Tooltip component ([9cedc68](https://github.com/themesberg/flowbite-svelte/commit/9cedc68014a7114c0e15691c26081bb9f5af88af))
|
|
31
|
+
|
|
32
|
+
### [0.22.29](https://github.com/themesberg/flowbite-svelte/compare/v0.22.28...v0.22.29) (2022-08-02)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* call updatePosition and floatingMiddleware functions in onMount ([b905101](https://github.com/themesberg/flowbite-svelte/commit/b905101f9cdfc9573e455200a2e28ad5766705e1))
|
|
38
|
+
|
|
5
39
|
### [0.22.28](https://github.com/themesberg/flowbite-svelte/compare/v0.22.27...v0.22.28) (2022-08-02)
|
|
6
40
|
|
|
7
41
|
|
package/README.md
CHANGED
|
@@ -302,6 +302,7 @@ For full documentation, visit [flowbite-svelte.com](https://flowbite-svelte.com/
|
|
|
302
302
|
</tr>
|
|
303
303
|
<tr>
|
|
304
304
|
<td width="33.3333%">Floating Label</td>
|
|
305
|
+
<td width="33.3333%">Datepicker</td>
|
|
305
306
|
</tr>
|
|
306
307
|
<tr>
|
|
307
308
|
<td width="33.3333%">
|
|
@@ -309,6 +310,11 @@ For full documentation, visit [flowbite-svelte.com](https://flowbite-svelte.com/
|
|
|
309
310
|
<img alt="Tailwind CSS Floating Label" src="https://flowbite.s3.amazonaws.com/github/floating-label.jpg">
|
|
310
311
|
</a>
|
|
311
312
|
</td>
|
|
313
|
+
<td width="33.3333%">
|
|
314
|
+
<a href="https://flowbite-svelte.com/datepicker/">
|
|
315
|
+
<img alt="Tailwind CSS Datepicker" src="https://flowbite.s3.amazonaws.com/github/datepicker.jpg">
|
|
316
|
+
</a>
|
|
317
|
+
</td>
|
|
312
318
|
</tr>
|
|
313
319
|
</table>
|
|
314
320
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg
|
|
2
|
+
aria-hidden="true"
|
|
3
|
+
class="w-5 h-5 text-gray-500 dark:text-gray-400"
|
|
4
|
+
fill="currentColor"
|
|
5
|
+
viewBox="0 0 20 20"
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
><path
|
|
8
|
+
fill-rule="evenodd"
|
|
9
|
+
d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z"
|
|
10
|
+
clip-rule="evenodd"
|
|
11
|
+
/></svg
|
|
12
|
+
>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} CalenderProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} CalenderEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} CalenderSlots */
|
|
4
|
+
export default class Calender extends SvelteComponentTyped<{}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> {
|
|
7
|
+
}
|
|
8
|
+
export type CalenderProps = typeof __propDef.props;
|
|
9
|
+
export type CalenderEvents = typeof __propDef.events;
|
|
10
|
+
export type CalenderSlots = typeof __propDef.slots;
|
|
11
|
+
import { SvelteComponentTyped } from "svelte";
|
|
12
|
+
declare const __propDef: {
|
|
13
|
+
props: {};
|
|
14
|
+
events: {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {};
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script>// import { onMount } from 'svelte';
|
|
2
|
+
import Calendar from './Calender.svelte';
|
|
3
|
+
export let range = false;
|
|
4
|
+
// autoHide not working
|
|
5
|
+
// export let autoHide: boolean = false;
|
|
6
|
+
export let datepickerButtons = false;
|
|
7
|
+
export let datepickerFormat = 'mm/dd/yyyy';
|
|
8
|
+
export let datepickerOrientation = 'bottom';
|
|
9
|
+
export let datepickerTitle = 'Flowbite datepicker';
|
|
10
|
+
export let attribute = '';
|
|
11
|
+
export let inputClass = 'bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 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';
|
|
12
|
+
$: setAttribute = (node, params) => {
|
|
13
|
+
node.setAttribute(params, '');
|
|
14
|
+
};
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<svelte:head>
|
|
18
|
+
<link rel="stylesheet" href="https://unpkg.com/flowbite@1.5.1/dist/flowbite.min.css" />
|
|
19
|
+
<script src="https://unpkg.com/flowbite@1.5.1/dist/datepicker.js"></script>
|
|
20
|
+
</svelte:head>
|
|
21
|
+
|
|
22
|
+
{#if range}
|
|
23
|
+
<div date-rangepicker class="flex items-center">
|
|
24
|
+
<div class="relative">
|
|
25
|
+
<div class="flex absolute inset-y-0 left-0 items-center pl-3 pointer-events-none">
|
|
26
|
+
<Calendar />
|
|
27
|
+
</div>
|
|
28
|
+
<input name="start" type="text" class={inputClass} placeholder="Select date start" />
|
|
29
|
+
</div>
|
|
30
|
+
<span class="mx-4 text-gray-500">to</span>
|
|
31
|
+
<div class="relative">
|
|
32
|
+
<div class="flex absolute inset-y-0 left-0 items-center pl-3 pointer-events-none">
|
|
33
|
+
<Calendar />
|
|
34
|
+
</div>
|
|
35
|
+
<input name="end" type="text" class={inputClass} placeholder="Select date end" />
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
{:else}
|
|
39
|
+
<div class="relative">
|
|
40
|
+
<div class="flex absolute inset-y-0 left-0 items-center pl-3 pointer-events-none">
|
|
41
|
+
<Calendar />
|
|
42
|
+
</div>
|
|
43
|
+
{#if datepickerButtons}
|
|
44
|
+
<input
|
|
45
|
+
{...$$restProps}
|
|
46
|
+
datepicker
|
|
47
|
+
datepicker-buttons
|
|
48
|
+
datepicker-format={datepickerFormat}
|
|
49
|
+
datepicker-orientation={datepickerOrientation}
|
|
50
|
+
datepicker-title={datepickerTitle}
|
|
51
|
+
use:setAttribute={attribute}
|
|
52
|
+
type="text"
|
|
53
|
+
class={inputClass}
|
|
54
|
+
placeholder="Select date"
|
|
55
|
+
/>
|
|
56
|
+
{:else}
|
|
57
|
+
<input
|
|
58
|
+
{...$$restProps}
|
|
59
|
+
datepicker
|
|
60
|
+
datepicker-format={datepickerFormat}
|
|
61
|
+
datepicker-orientation={datepickerOrientation}
|
|
62
|
+
datepicker-title={datepickerTitle}
|
|
63
|
+
use:setAttribute={attribute}
|
|
64
|
+
type="text"
|
|
65
|
+
class={inputClass}
|
|
66
|
+
placeholder="Select date"
|
|
67
|
+
/>
|
|
68
|
+
{/if}
|
|
69
|
+
<slot />
|
|
70
|
+
</div>
|
|
71
|
+
{/if}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
range?: boolean;
|
|
6
|
+
datepickerButtons?: boolean;
|
|
7
|
+
datepickerFormat?: string;
|
|
8
|
+
datepickerOrientation?: string;
|
|
9
|
+
datepickerTitle?: string;
|
|
10
|
+
attribute?: string;
|
|
11
|
+
inputClass?: string;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {
|
|
17
|
+
default: {};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare type DatepickerProps = typeof __propDef.props;
|
|
21
|
+
export declare type DatepickerEvents = typeof __propDef.events;
|
|
22
|
+
export declare type DatepickerSlots = typeof __propDef.slots;
|
|
23
|
+
export default class Datepicker extends SvelteComponentTyped<DatepickerProps, DatepickerEvents, DatepickerSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
package/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { default as SignInCard } from './cards/SignInCard.svelte';
|
|
|
14
14
|
export { default as Carousel } from './carousels/Carousel.svelte';
|
|
15
15
|
export { default as CarouselTransition } from './carousels/CarouselTransition.svelte';
|
|
16
16
|
export { default as DarkMode } from './darkmode/DarkMode.svelte';
|
|
17
|
+
export { default as Datepicker } from './datepicker/Datepicker.svelte';
|
|
17
18
|
export { default as Drawer } from './drawers/Drawer.svelte';
|
|
18
19
|
export { default as Dropdown } from './dropdowns/Dropdown.svelte';
|
|
19
20
|
export { default as DropdownDivider } from './dropdowns/DropdownDivider.svelte';
|
package/index.js
CHANGED
|
@@ -24,6 +24,8 @@ export { default as Carousel } from './carousels/Carousel.svelte';
|
|
|
24
24
|
export { default as CarouselTransition } from './carousels/CarouselTransition.svelte';
|
|
25
25
|
// Dark mode
|
|
26
26
|
export { default as DarkMode } from './darkmode/DarkMode.svelte';
|
|
27
|
+
// Datepicker
|
|
28
|
+
export { default as Datepicker } from './datepicker/Datepicker.svelte';
|
|
27
29
|
// Drawer
|
|
28
30
|
export { default as Drawer } from './drawers/Drawer.svelte';
|
|
29
31
|
// Dropdown
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flowbite-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Flowbite components for Svelte",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": {
|
|
@@ -119,6 +119,8 @@
|
|
|
119
119
|
"./carousels/Slide.svelte": "./carousels/Slide.svelte",
|
|
120
120
|
"./carousels/Thumbnail.svelte": "./carousels/Thumbnail.svelte",
|
|
121
121
|
"./darkmode/DarkMode.svelte": "./darkmode/DarkMode.svelte",
|
|
122
|
+
"./datepicker/Calender.svelte": "./datepicker/Calender.svelte",
|
|
123
|
+
"./datepicker/Datepicker.svelte": "./datepicker/Datepicker.svelte",
|
|
122
124
|
"./drawers/Drawer.svelte": "./drawers/Drawer.svelte",
|
|
123
125
|
"./dropdowns/Dropdown.svelte": "./dropdowns/Dropdown.svelte",
|
|
124
126
|
"./dropdowns/DropdownDivider.svelte": "./dropdowns/DropdownDivider.svelte",
|
package/tooltips/Tooltip.svelte
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
|
-
<script>import
|
|
2
|
-
import classNames from 'classnames';
|
|
1
|
+
<script>import classNames from 'classnames';
|
|
3
2
|
import { clickOutside } from '../utils/clickOutside';
|
|
4
3
|
import { computePosition, flip, shift, offset, autoPlacement, arrow as arrowFloat } from '@floating-ui/dom';
|
|
4
|
+
import { onDestroy } from 'svelte';
|
|
5
5
|
export let placement = 'top';
|
|
6
6
|
export let trigger = 'hover';
|
|
7
7
|
export let style = 'dark';
|
|
8
8
|
export let content = '';
|
|
9
9
|
export let animation = 'duration-300';
|
|
10
10
|
export let arrow = true;
|
|
11
|
+
export let tipClass = 'absolute inline-block rounded-lg py-2 px-3 text-sm font-medium shadow-sm';
|
|
12
|
+
export let tipColor = '';
|
|
13
|
+
const tipStyleClasses = {
|
|
14
|
+
dark: 'bg-gray-900 text-white dark:bg-gray-700',
|
|
15
|
+
light: 'border border-gray-200 bg-white text-gray-900',
|
|
16
|
+
auto: 'border border-gray-200 bg-white text-gray-900 dark:border-none dark:bg-gray-700 dark:text-white',
|
|
17
|
+
custom: tipColor
|
|
18
|
+
};
|
|
19
|
+
const arrowStyleClasses = {
|
|
20
|
+
dark: 'bg-gray-900 dark:bg-gray-700',
|
|
21
|
+
light: 'bg-white',
|
|
22
|
+
auto: 'bg-white dark:bg-gray-700',
|
|
23
|
+
custom: tipColor
|
|
24
|
+
};
|
|
25
|
+
let toolTipClass;
|
|
26
|
+
$: toolTipClass = classNames(tipClass, animation !== false && `transition-opacity ${animation}`, {
|
|
27
|
+
'invisible opacity-0': !open
|
|
28
|
+
}, tipStyleClasses[style], $$props.class);
|
|
11
29
|
let open = false;
|
|
12
30
|
const floatingPlacement = ({ placement }) => {
|
|
13
31
|
return placement === 'auto' ? undefined : placement;
|
|
@@ -23,26 +41,25 @@ const floatingArrowPlacement = ({ placement }) => {
|
|
|
23
41
|
left: 'right'
|
|
24
42
|
}[placement.split('-')[0]];
|
|
25
43
|
};
|
|
44
|
+
const floatingMiddleware = ({ arrowRef, placement }) => {
|
|
45
|
+
const middleware = [];
|
|
46
|
+
middleware.push(offset(8));
|
|
47
|
+
middleware.push(placement === 'auto' ? autoPlacement() : flip());
|
|
48
|
+
middleware.push(shift({ padding: 8 }));
|
|
49
|
+
if (arrowRef) {
|
|
50
|
+
middleware.push(arrowFloat({ element: arrowRef }));
|
|
51
|
+
}
|
|
52
|
+
return middleware;
|
|
53
|
+
};
|
|
26
54
|
let placementData;
|
|
27
55
|
let tooltipRef, triggerRef, arrowRef;
|
|
56
|
+
const updatePosition = () => computePosition(triggerRef, tooltipRef, {
|
|
57
|
+
middleware: floatingMiddleware({ arrowRef, placement }),
|
|
58
|
+
placement: floatingPlacement({ placement })
|
|
59
|
+
}).then((data) => (placementData = data));
|
|
28
60
|
let attachedScroll = false;
|
|
29
|
-
|
|
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
|
-
const updatePosition = () => computePosition(triggerRef, tooltipRef, {
|
|
42
|
-
middleware: floatingMiddleware({ arrowRef, placement }),
|
|
43
|
-
placement: floatingPlacement({ placement })
|
|
44
|
-
}).then((data) => (placementData = data));
|
|
45
|
-
tooltipRef && open && updatePosition();
|
|
61
|
+
$: tooltipRef && open && updatePosition();
|
|
62
|
+
$: {
|
|
46
63
|
if (open && !attachedScroll) {
|
|
47
64
|
attachedScroll = true;
|
|
48
65
|
window.addEventListener('scroll', updatePosition, true);
|
|
@@ -51,13 +68,17 @@ onMount(async () => {
|
|
|
51
68
|
attachedScroll = false;
|
|
52
69
|
window.removeEventListener('scroll', updatePosition, true);
|
|
53
70
|
}
|
|
54
|
-
|
|
55
|
-
|
|
71
|
+
}
|
|
72
|
+
onDestroy(() => {
|
|
73
|
+
if (attachedScroll) {
|
|
74
|
+
attachedScroll = false;
|
|
75
|
+
window.removeEventListener('scroll', updatePosition, true);
|
|
76
|
+
}
|
|
56
77
|
});
|
|
57
|
-
// console.log('placement', placement);
|
|
58
|
-
// console.log('floatingPlacement', floatingPlacement({ placement }));
|
|
59
78
|
</script>
|
|
60
79
|
|
|
80
|
+
<svelte:window on:resize={() => open && updatePosition()} />
|
|
81
|
+
|
|
61
82
|
<div
|
|
62
83
|
use:clickOutside={() => {
|
|
63
84
|
if (open) {
|
|
@@ -90,18 +111,7 @@ onMount(async () => {
|
|
|
90
111
|
<div
|
|
91
112
|
bind:this={tooltipRef}
|
|
92
113
|
data-testid="tooltip"
|
|
93
|
-
class={
|
|
94
|
-
'absolute inline-block rounded-lg py-2 px-3 text-sm font-medium shadow-sm',
|
|
95
|
-
animation !== false && `transition-opacity ${animation}`,
|
|
96
|
-
{
|
|
97
|
-
'invisible opacity-0': !open,
|
|
98
|
-
'bg-gray-900 text-white dark:bg-gray-700': style === 'dark',
|
|
99
|
-
'border border-gray-200 bg-white text-gray-900': style === 'light',
|
|
100
|
-
'border border-gray-200 bg-white text-gray-900 dark:border-none dark:bg-gray-700 dark:text-white':
|
|
101
|
-
style === 'auto'
|
|
102
|
-
},
|
|
103
|
-
$$props.class
|
|
104
|
-
)}
|
|
114
|
+
class={toolTipClass}
|
|
105
115
|
style={`left:${placementData?.x}px;top:${placementData?.y}px;position:${placementData?.strategy}`}
|
|
106
116
|
>
|
|
107
117
|
<div class="relative z-20">
|
|
@@ -111,11 +121,7 @@ onMount(async () => {
|
|
|
111
121
|
</div>
|
|
112
122
|
{#if arrow}
|
|
113
123
|
<div
|
|
114
|
-
class={classNames('absolute z-10 h-2 w-2 rotate-45',
|
|
115
|
-
'bg-gray-900 dark:bg-gray-700': style === 'dark',
|
|
116
|
-
'bg-white': style === 'light',
|
|
117
|
-
'bg-white dark:bg-gray-700': style === 'auto'
|
|
118
|
-
})}
|
|
124
|
+
class={classNames('absolute z-10 h-2 w-2 rotate-45', arrowStyleClasses[style])}
|
|
119
125
|
data-testid="tooltip-arrow"
|
|
120
126
|
style={`left:${placementData?.middlewareData.arrow?.x}px;top:${
|
|
121
127
|
placementData?.middlewareData.arrow?.y
|
|
@@ -5,10 +5,12 @@ declare const __propDef: {
|
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
placement?: 'auto' | Placement;
|
|
7
7
|
trigger?: 'hover' | 'click';
|
|
8
|
-
style?: 'dark' | 'light' | 'auto';
|
|
8
|
+
style?: 'dark' | 'light' | 'auto' | 'custom';
|
|
9
9
|
content?: string;
|
|
10
10
|
animation?: false | `duration-${number}`;
|
|
11
11
|
arrow?: boolean;
|
|
12
|
+
tipClass?: string;
|
|
13
|
+
tipColor?: string;
|
|
12
14
|
};
|
|
13
15
|
events: {
|
|
14
16
|
[evt: string]: CustomEvent<any>;
|