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.
Files changed (50) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +1 -1
  3. package/accordions/Accordion.svelte +2 -2
  4. package/accordions/Accordion.svelte.d.ts +1 -1
  5. package/accordions/AccordionItem.svelte +3 -1
  6. package/breadcrumbs/BreadcrumbItem.svelte +37 -44
  7. package/breadcrumbs/BreadcrumbItem.svelte.d.ts +1 -0
  8. package/buttons/Button.svelte +2 -6
  9. package/buttons/Button.svelte.d.ts +2 -2
  10. package/cards/Card.svelte +13 -13
  11. package/cards/Card.svelte.d.ts +3 -2
  12. package/carousels/CarouselTransition.svelte +1 -1
  13. package/carousels/Thumbnail.svelte +10 -1
  14. package/darkmode/DarkMode.svelte +27 -24
  15. package/drawer/Drawer.svelte +27 -14
  16. package/drawer/Drawer.svelte.d.ts +1 -0
  17. package/forms/Checkbox.svelte +17 -18
  18. package/forms/FloatingLabelInput.svelte.d.ts +1 -1
  19. package/forms/Helper.svelte.d.ts +1 -1
  20. package/forms/Input.svelte +22 -20
  21. package/forms/Input.svelte.d.ts +7 -2
  22. package/forms/Label.svelte.d.ts +1 -1
  23. package/forms/NumberInput.svelte +7 -0
  24. package/forms/NumberInput.svelte.d.ts +16 -0
  25. package/forms/Toggle.svelte +4 -13
  26. package/index.d.ts +3 -4
  27. package/index.js +3 -4
  28. package/list-group/ListgroupItem.svelte +38 -40
  29. package/modals/Modal.svelte +15 -12
  30. package/modals/Modal.svelte.d.ts +2 -1
  31. package/package.json +7 -6
  32. package/ratings/Rating.svelte +21 -20
  33. package/ratings/Rating.svelte.d.ts +1 -0
  34. package/tables/Table.svelte.d.ts +1 -1
  35. package/tables/TableSearch.svelte.d.ts +1 -1
  36. package/tabs/TabHead.svelte +4 -3
  37. package/tabs/TabHeadItem.svelte +3 -0
  38. package/tabs/TabItem.svelte +53 -0
  39. package/tabs/TabItem.svelte.d.ts +34 -0
  40. package/tabs/Tabs.svelte +50 -0
  41. package/tabs/Tabs.svelte.d.ts +33 -0
  42. package/tooltips/Tooltip.svelte.d.ts +1 -1
  43. package/typography/P.svelte.d.ts +1 -1
  44. package/utils/Frame.svelte.d.ts +1 -1
  45. package/utils/Popper.svelte +19 -16
  46. package/utils/focusTrap.js +15 -24
  47. package/tabs/TabContentItem.svelte +0 -10
  48. package/tabs/TabContentItem.svelte.d.ts +0 -20
  49. package/tabs/TabWrapper.svelte +0 -8
  50. package/tabs/TabWrapper.svelte.d.ts +0 -22
@@ -60,7 +60,7 @@ function init(node, _triggerEl) {
60
60
  {
61
61
  name: 'offset',
62
62
  options: {
63
- offset: ({ placement, reference, popper }) => {
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
- <div id="empty" bind:this={contentEl} />
121
+ <div bind:this={contentEl} />
119
122
  {/if}
120
123
 
121
124
  {#if open && triggerEl}
122
- <Frame
123
- use={init}
124
- options={triggerEl}
125
- role="tooltip"
126
- tabIndex={activeContent ? -1 : undefined}
127
- on:focusin={activeContent ? showHandler : undefined}
128
- on:focusout={activeContent ? hideHandler : undefined}
129
- on:mouseenter={activeContent && !clickable ? showHandler : undefined}
130
- on:mouseleave={activeContent && !clickable ? hideHandler : undefined}
131
- {...$$restProps}
132
- class={classNames('z-10 outline-none', $$props.class)}>
133
- <slot />
134
- {#if arrow}<div data-popper-arrow class="tooltip-arrow"/>{/if}
135
- </Frame>
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}
@@ -1,18 +1,17 @@
1
1
  //
2
- // Focus trap copied from https://uxdesign.cc/how-to-trap-focus-inside-modal-to-make-it-ada-compliant-6a50f9a70700
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 focusableElements =
7
- 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
8
-
9
- function getFocusable(node) {
10
- const focusableContent = node.querySelectorAll(focusableElements);
11
- return [focusableContent[0], focusableContent[focusableContent.length - 1]];
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
- let firstFocusableElement, lastFocusableElement; // first and last element to be focused inside modal
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
- if (e.shiftKey) {
25
- // if shift key pressed for shift + tab combination
26
- if (document.activeElement === firstFocusableElement) {
27
- lastFocusableElement.focus(); // add focus for the last focusable element
28
- e.preventDefault();
29
- }
30
- } else {
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 {};
@@ -1,8 +0,0 @@
1
- <script>import classNames from 'classnames';
2
- export let divClass = 'w-full';
3
- export let tabStyle = 'default';
4
- </script>
5
-
6
- <div class={classNames(divClass, $$props.class)}>
7
- <slot {tabStyle} />
8
- </div>
@@ -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 {};