flowbite-svelte 0.27.5 → 0.27.8
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 +28 -0
- package/README.md +1 -1
- package/accordions/Accordion.svelte +2 -2
- package/accordions/Accordion.svelte.d.ts +1 -1
- package/accordions/AccordionItem.svelte +3 -1
- 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 +13 -13
- package/cards/Card.svelte.d.ts +3 -2
- package/carousels/CarouselTransition.svelte +1 -1
- package/carousels/Thumbnail.svelte +10 -1
- package/darkmode/DarkMode.svelte +27 -24
- package/drawer/Drawer.svelte +27 -14
- 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 +3 -4
- package/index.js +3 -4
- package/list-group/ListgroupItem.svelte +38 -40
- package/modals/Modal.svelte +15 -12
- package/modals/Modal.svelte.d.ts +2 -1
- package/package.json +7 -6
- 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/tabs/TabHead.svelte +4 -3
- package/tabs/TabHeadItem.svelte +3 -0
- package/tabs/TabItem.svelte +53 -0
- package/tabs/TabItem.svelte.d.ts +34 -0
- package/tabs/Tabs.svelte +50 -0
- package/tabs/Tabs.svelte.d.ts +33 -0
- package/tooltips/Tooltip.svelte.d.ts +1 -1
- package/typography/P.svelte.d.ts +1 -1
- package/utils/Frame.svelte.d.ts +1 -1
- package/utils/Popper.svelte +19 -16
- package/utils/focusTrap.js +15 -24
- package/tabs/TabContentItem.svelte +0 -10
- package/tabs/TabContentItem.svelte.d.ts +0 -20
- package/tabs/TabWrapper.svelte +0 -8
- package/tabs/TabWrapper.svelte.d.ts +0 -22
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 {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<script>export let activeTabValue;
|
|
2
|
-
export let id;
|
|
3
|
-
export let contentDivClass = 'p-4 bg-gray-50 rounded-lg dark:bg-gray-800';
|
|
4
|
-
</script>
|
|
5
|
-
|
|
6
|
-
{#if activeTabValue === id}
|
|
7
|
-
<div class={contentDivClass} id="{id}-tabitem" role="tabpanel" aria-labelledby="{id}-tab">
|
|
8
|
-
<slot />
|
|
9
|
-
</div>
|
|
10
|
-
{/if}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
activeTabValue: number;
|
|
5
|
-
id: number;
|
|
6
|
-
contentDivClass?: string | undefined;
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {
|
|
12
|
-
default: {};
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export declare type TabContentItemProps = typeof __propDef.props;
|
|
16
|
-
export declare type TabContentItemEvents = typeof __propDef.events;
|
|
17
|
-
export declare type TabContentItemSlots = typeof __propDef.slots;
|
|
18
|
-
export default class TabContentItem extends SvelteComponentTyped<TabContentItemProps, TabContentItemEvents, TabContentItemSlots> {
|
|
19
|
-
}
|
|
20
|
-
export {};
|
package/tabs/TabWrapper.svelte
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
divClass?: string | undefined;
|
|
6
|
-
tabStyle?: "default" | "icon" | "custom" | "pill" | "underline" | "full" | undefined;
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {
|
|
12
|
-
default: {
|
|
13
|
-
tabStyle: "default" | "icon" | "custom" | "pill" | "underline" | "full";
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export declare type TabWrapperProps = typeof __propDef.props;
|
|
18
|
-
export declare type TabWrapperEvents = typeof __propDef.events;
|
|
19
|
-
export declare type TabWrapperSlots = typeof __propDef.slots;
|
|
20
|
-
export default class TabWrapper extends SvelteComponentTyped<TabWrapperProps, TabWrapperEvents, TabWrapperSlots> {
|
|
21
|
-
}
|
|
22
|
-
export {};
|