flowbite-svelte 0.22.9 → 0.22.12

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 CHANGED
@@ -2,6 +2,45 @@
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.22.12](https://github.com/themesberg/flowbite-svelte/compare/v0.22.11...v0.22.12) (2022-07-24)
6
+
7
+
8
+ ### Features
9
+
10
+ * megamenu - code skel ([d02c5c7](https://github.com/themesberg/flowbite-svelte/commit/d02c5c78a5360f623ffe3fb3659265d679e43426))
11
+ * megamenu - wip ([02bbabc](https://github.com/themesberg/flowbite-svelte/commit/02bbabcdda0f924aefa2829a94e3b822bdb0bbf6))
12
+ * megamenu + examples ([2f24a26](https://github.com/themesberg/flowbite-svelte/commit/2f24a268dfe474da45a654d6a4bd128f4175ae44))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * layout and index page ([7db0e00](https://github.com/themesberg/flowbite-svelte/commit/7db0e00d1094d4d03a7386fd96c13c5b2ee09f6f))
18
+ * layout logo ([1a78683](https://github.com/themesberg/flowbite-svelte/commit/1a78683e734bf0dae58fe704bd652fcef196dae9))
19
+ * layout width ([e17969e](https://github.com/themesberg/flowbite-svelte/commit/e17969ec2c6f2938ed1a7c7b8f083bd3da6801e8))
20
+ * position and classes ([caa1f13](https://github.com/themesberg/flowbite-svelte/commit/caa1f136e964503ff1976c7de7c006615038489b))
21
+ * removed console.log ([f0f7ee9](https://github.com/themesberg/flowbite-svelte/commit/f0f7ee96bc48310ed245c00678960ac9d2eaa05b))
22
+
23
+ ### [0.22.11](https://github.com/themesberg/flowbite-svelte/compare/v0.22.10...v0.22.11) (2022-07-23)
24
+
25
+
26
+ ### Features
27
+
28
+ * list group rewritten - API changed ([86c97dc](https://github.com/themesberg/flowbite-svelte/commit/86c97dc54581f634baed601c609e9d90c6c4611b))
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * background context added ([52c8dd5](https://github.com/themesberg/flowbite-svelte/commit/52c8dd5693f3d890e7b875ae1b0435c5a7313876))
34
+ * error fix for deployment ([be684a8](https://github.com/themesberg/flowbite-svelte/commit/be684a8057c08a7c07f3f6c370114d008dc2182e))
35
+ * field name change for ListGroupItemType ([da93d46](https://github.com/themesberg/flowbite-svelte/commit/da93d460c864e0a94f803420f73dbf976e185fee))
36
+
37
+ ### [0.22.10](https://github.com/themesberg/flowbite-svelte/compare/v0.22.9...v0.22.10) (2022-07-23)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * merge conflict fix with Hetarth02-main ([914c1f9](https://github.com/themesberg/flowbite-svelte/commit/914c1f95f80dfbd73542d68d39622d79bed1ea04))
43
+
5
44
  ### [0.22.9](https://github.com/themesberg/flowbite-svelte/compare/v0.22.8...v0.22.9) (2022-07-23)
6
45
 
7
46
 
package/index.d.ts CHANGED
@@ -51,6 +51,7 @@ export { default as ArrowKeyLeft } from './kbd/ArrowKeyLeft.svelte';
51
51
  export { default as ArrowKeyRight } from './kbd/ArrowKeyRight.svelte';
52
52
  export { default as ArrowKeyUp } from './kbd/ArrowKeyUp.svelte';
53
53
  export { default as List } from './list-group/List.svelte';
54
+ export { default as ListItem } from './list-group/ListItem.svelte';
54
55
  export { modalIdStore } from './modals/modalStores.js';
55
56
  export { default as ExtraLargeModal } from './modals/ExtraLargeModal.svelte';
56
57
  export { default as LargeModal } from './modals/LargeModal.svelte';
@@ -58,6 +59,7 @@ export { default as MediumModal } from './modals/MediumModal.svelte';
58
59
  export { default as ModalButton } from './modals/ModalButton.svelte';
59
60
  export { default as SignInModal } from './modals/SignInModal.svelte';
60
61
  export { default as SmallModal } from './modals/SmallModal.svelte';
62
+ export { default as MegaMenu } from './megamenu/MegaMenu.svelte';
61
63
  export { default as Navbar } from './navbar/Navbar.svelte';
62
64
  export { default as NavBrand } from './navbar/NavBrand.svelte';
63
65
  export { default as NavHamburger } from './navbar/NavHamburger.svelte';
package/index.js CHANGED
@@ -66,6 +66,7 @@ export { default as ArrowKeyRight } from './kbd/ArrowKeyRight.svelte';
66
66
  export { default as ArrowKeyUp } from './kbd/ArrowKeyUp.svelte';
67
67
  // List
68
68
  export { default as List } from './list-group/List.svelte';
69
+ export { default as ListItem } from './list-group/ListItem.svelte';
69
70
  // Modals
70
71
  export { modalIdStore } from './modals/modalStores.js';
71
72
  export { default as ExtraLargeModal } from './modals/ExtraLargeModal.svelte';
@@ -74,6 +75,8 @@ export { default as MediumModal } from './modals/MediumModal.svelte';
74
75
  export { default as ModalButton } from './modals/ModalButton.svelte';
75
76
  export { default as SignInModal } from './modals/SignInModal.svelte';
76
77
  export { default as SmallModal } from './modals/SmallModal.svelte';
78
+ // MegaMenu
79
+ export { default as MegaMenu } from './megamenu/MegaMenu.svelte';
77
80
  // Navbar
78
81
  export { default as Navbar } from './navbar/Navbar.svelte';
79
82
  export { default as NavBrand } from './navbar/NavBrand.svelte';
@@ -1,45 +1,18 @@
1
- <script>export let lists;
2
- const common = 'inline-flex relative items-center py-2 px-4 w-full text-sm font-medium hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-2 focus:ring-blue-700 focus:text-blue-700 dark:border-gray-600 dark:hover:bg-gray-600 dark:hover:text-white dark:focus:ring-gray-500 dark:focus:text-white';
3
- const topClass = `${common} rounded-t-lg border-b border-gray-200`;
4
- const bottomClass = `${common} rounded-b-lg`;
5
- const middleClass = `${common} border-b border-gray-200`;
1
+ <script>import { setContext } from 'svelte';
2
+ import classNames from 'classnames';
3
+ import ListItem from './ListItem.svelte';
4
+ export let items = [];
5
+ export let active = false;
6
+ setContext('background', true);
7
+ $: setContext('active', active);
8
+ let groupClass;
9
+ $: groupClass = classNames('rounded-lg border border-gray-200 dark:border-gray-600', 'divide-y divide-gray-200 dark:divide-gray-600', $$props.class);
6
10
  </script>
7
11
 
8
- <div class="w-48 text-gray-900 bg-white rounded-lg border border-gray-200 dark:bg-gray-700 dark:border-gray-600 dark:text-white">
9
- {#each lists as { name, icon, href, rel, iconClass, iconSize }, i}
10
- {#if i === 0}
11
- <button type="button" class={topClass}>
12
- {#if icon}
13
- <svelte:component this={icon} class="mr-2 {iconClass}" size={iconSize} />
14
- {/if}
15
- {#if href}
16
- <a {href} {rel}>{name}</a>
17
- {:else}
18
- {name} here
19
- {/if}
20
- </button>
21
- {:else if i === lists.length - 1}
22
- <button type="button" class={bottomClass}>
23
- {#if icon}
24
- <svelte:component this={icon} class="mr-2 {iconClass}" size={iconSize} />
25
- {/if}
26
- {#if href}
27
- <a {href} {rel}>{name}</a>
28
- {:else}
29
- {name}
30
- {/if}
31
- </button>
32
- {:else}
33
- <button type="button" class={middleClass}>
34
- {#if icon}
35
- <svelte:component this={icon} class="mr-2 {iconClass}" size={iconSize} />
36
- {/if}
37
- {#if href}
38
- <a {href} {rel}>{name}</a>
39
- {:else}
40
- {name}
41
- {/if}
42
- </button>
43
- {/if}
12
+ <svelte:element this={active ? 'div' : 'ul'} class={groupClass}>
13
+ {#each items as item, index}
14
+ <ListItem {active} {...item} {index} on:click><slot {item} {index} /></ListItem>
15
+ {:else}
16
+ <slot />
44
17
  {/each}
45
- </div>
18
+ </svelte:element>
@@ -1,13 +1,19 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { ButtonGroupType } from '../types';
2
+ import type { ListGroupItemType } from '../types';
3
3
  declare const __propDef: {
4
4
  props: {
5
- lists: ButtonGroupType[];
5
+ [x: string]: any;
6
+ items?: ListGroupItemType[];
7
+ active?: boolean;
6
8
  };
7
9
  events: {
10
+ click: CustomEvent<any>;
11
+ } & {
8
12
  [evt: string]: CustomEvent<any>;
9
13
  };
10
- slots: {};
14
+ slots: {
15
+ default: {};
16
+ };
11
17
  };
12
18
  export declare type ListProps = typeof __propDef.props;
13
19
  export declare type ListEvents = typeof __propDef.events;
@@ -0,0 +1,44 @@
1
+ <script>import { getContext } from 'svelte';
2
+ import classNames from 'classnames';
3
+ import { createEventDispatcher } from 'svelte';
4
+ export let active = getContext('active');
5
+ export let current = false;
6
+ export let disabled = false;
7
+ export let href = '';
8
+ let dispatch = createEventDispatcher();
9
+ const states = {
10
+ current: 'text-white bg-blue-700 dark:text-white dark:bg-gray-800',
11
+ normal: 'text-gray-900 bg-white dark:text-gray-200 dark:bg-gray-700',
12
+ disabled: 'text-gray-900 bg-gray-100 dark:bg-gray-600 dark:text-gray-400'
13
+ };
14
+ let focusClass = 'focus:z-40 focus:outline-none focus:ring-2 focus:ring-blue-700 focus:text-blue-700 dark:focus:ring-gray-500 dark:focus:text-white';
15
+ let hoverClass = 'hover:bg-gray-100 hover:text-blue-700 dark:hover:bg-gray-600 dark:hover:text-white';
16
+ let state;
17
+ $: state = disabled ? 'disabled' : current ? 'current' : 'normal';
18
+ let itemClass;
19
+ $: itemClass = classNames('py-2 px-4 w-full text-sm font-medium', 'first:rounded-t-lg last:rounded-b-lg', states[state], active && state === 'disabled' && 'cursor-not-allowed', active && state === 'normal' && hoverClass, active && state === 'normal' && focusClass, $$props.class);
20
+ </script>
21
+
22
+ {#if !active}
23
+ <li class={itemClass}>
24
+ <slot item={$$props} />
25
+ </li>
26
+ {:else if href}
27
+ <a
28
+ {href}
29
+ class="block {itemClass}"
30
+ on:click={() => dispatch('click', $$props)}
31
+ aria-current={current}
32
+ >
33
+ <slot item={$$props} />
34
+ </a>
35
+ {:else}
36
+ <button
37
+ class="inline-flex relative items-center text-left {itemClass}"
38
+ {disabled}
39
+ on:click={() => dispatch('click', $$props)}
40
+ aria-current={current}
41
+ >
42
+ <slot item={$$props} />
43
+ </button>
44
+ {/if}
@@ -0,0 +1,26 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ [x: string]: any;
5
+ active?: boolean;
6
+ current?: boolean;
7
+ disabled?: boolean;
8
+ href?: string;
9
+ };
10
+ events: {
11
+ click: CustomEvent<any>;
12
+ } & {
13
+ [evt: string]: CustomEvent<any>;
14
+ };
15
+ slots: {
16
+ default: {
17
+ item: SvelteAllProps;
18
+ };
19
+ };
20
+ };
21
+ export declare type ListItemProps = typeof __propDef.props;
22
+ export declare type ListItemEvents = typeof __propDef.events;
23
+ export declare type ListItemSlots = typeof __propDef.slots;
24
+ export default class ListItem extends SvelteComponentTyped<ListItemProps, ListItemEvents, ListItemSlots> {
25
+ }
26
+ export {};
@@ -0,0 +1,39 @@
1
+ <script>import { setContext, afterUpdate } from 'svelte';
2
+ import classNames from 'classnames';
3
+ export let items = [];
4
+ export let full = false;
5
+ setContext('background', true);
6
+ let wrapperClass;
7
+ $: wrapperClass = classNames('border-gray-100 shadow-md dark:border-gray-700', full ? 'border-y' : 'rounded-lg border', full ? 'bg-white dark:bg-gray-800' : 'bg-white dark:bg-gray-700', $$props.class);
8
+ let ulClass;
9
+ $: ulClass = classNames('grid grid-flow-row gap-y-4 md:gap-x-0 auto-col-max auto-row-max', full && $$slots.extra ? 'sm:grid-cols-2' : 'sm:grid-cols-2 md:grid-cols-3', 'text-sm font-medium', 'text-gray-500 dark:text-gray-400', full && $$slots.extra && 'md:w-2/3');
10
+ function init(node) {
11
+ if (full) {
12
+ node.parentElement.classList.add('inset-x-0');
13
+ }
14
+ }
15
+ let wrapper;
16
+ afterUpdate(() => {
17
+ if (wrapper) {
18
+ const width = wrapper.getBoundingClientRect();
19
+ // wrapper.style.marginLeft = '-50%';
20
+ // console.log('after', width);
21
+ // console.log(wrapper.clientWidth);
22
+ }
23
+ });
24
+ </script>
25
+
26
+ <div class={wrapperClass} use:init bind:this={wrapper}>
27
+ <div class="flex flex-col md:flex-row p-4 max-w-screen-xl justify-center mx-auto">
28
+ <ul class={ulClass}>
29
+ {#each items as item, index}
30
+ <li>
31
+ <slot {item} {index} />
32
+ </li>
33
+ {:else}
34
+ <slot />
35
+ {/each}
36
+ </ul>
37
+ {#if full && $$slots.extra}<div class="md:w-1/3 mt-4 md:mt-0"><slot name="extra" /></div>{/if}
38
+ </div>
39
+ </div>
@@ -0,0 +1,24 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { LinkType } from '../types';
3
+ declare const __propDef: {
4
+ props: {
5
+ [x: string]: any;
6
+ items?: (LinkType & {
7
+ [propName: string]: any;
8
+ })[];
9
+ full?: boolean;
10
+ };
11
+ events: {
12
+ [evt: string]: CustomEvent<any>;
13
+ };
14
+ slots: {
15
+ default: {};
16
+ extra: {};
17
+ };
18
+ };
19
+ export declare type MegaMenuProps = typeof __propDef.props;
20
+ export declare type MegaMenuEvents = typeof __propDef.events;
21
+ export declare type MegaMenuSlots = typeof __propDef.slots;
22
+ export default class MegaMenu extends SvelteComponentTyped<MegaMenuProps, MegaMenuEvents, MegaMenuSlots> {
23
+ }
24
+ export {};
@@ -1,18 +1,20 @@
1
- <script>export let liButtonClass;
1
+ <script>import { clickOutside } from '../utils/clickOutside';
2
+ export let liButtonClass = 'flex items-center';
2
3
  export let name;
4
+ export let child = [];
3
5
  let hidden = true;
4
6
  let block = false;
5
- export let child;
6
7
  const handleDropdown = () => {
7
8
  hidden = !hidden;
8
9
  block = !block;
9
10
  };
10
- export let dropdownDiv;
11
- export let dropdownLinkClassWithChild;
12
- export let rel;
11
+ export let dropdownDiv = '';
12
+ export let dropdownLinkClassWithChild = undefined;
13
+ export let rel = undefined;
14
+ let liClass = 'flex justify-center py-2 pr-4 pl-3 text-gray-700 border-b border-gray-100 hover:bg-gray-50 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-gray-400 md:dark:hover:text-white dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700';
13
15
  </script>
14
16
 
15
- <li>
17
+ <li use:clickOutside={() => !hidden && handleDropdown()} class={liClass}>
16
18
  <button on:click={() => handleDropdown()} class={liButtonClass}
17
19
  >{name}
18
20
  <svg
@@ -29,13 +31,15 @@ export let rel;
29
31
  >
30
32
 
31
33
  <!-- Dropdown menu -->
32
- <div class:hidden class:block class={dropdownDiv} style="position: absolute; margin: 0px;">
33
- <ul class="py-1" aria-labelledby="dropdownLargeButton">
34
- {#each child as item}
35
- <li>
36
- <a href={item.href} {rel} class={dropdownLinkClassWithChild}>{item.name}</a>
37
- </li>
38
- {/each}
39
- </ul>
34
+ <div class:hidden class="absolute {dropdownDiv} mt-8 z-10">
35
+ <slot>
36
+ <ul class="py-1" aria-labelledby="dropdownLargeButton">
37
+ {#each child as item}
38
+ <li>
39
+ <a href={item.href} {rel} class={dropdownLinkClassWithChild}>{item.name}</a>
40
+ </li>
41
+ {/each}
42
+ </ul>
43
+ </slot>
40
44
  </div>
41
45
  </li>
@@ -2,17 +2,19 @@ import { SvelteComponentTyped } from "svelte";
2
2
  import type { NavbarType } from '../types';
3
3
  declare const __propDef: {
4
4
  props: {
5
- liButtonClass: string;
5
+ liButtonClass?: string;
6
6
  name: string;
7
- child: NavbarType[];
8
- dropdownDiv: string;
9
- dropdownLinkClassWithChild: string;
10
- rel: string;
7
+ child?: NavbarType[];
8
+ dropdownDiv?: string;
9
+ dropdownLinkClassWithChild?: string;
10
+ rel?: string;
11
11
  };
12
12
  events: {
13
13
  [evt: string]: CustomEvent<any>;
14
14
  };
15
- slots: {};
15
+ slots: {
16
+ default: {};
17
+ };
16
18
  };
17
19
  export declare type NavDropdownProps = typeof __propDef.props;
18
20
  export declare type NavDropdownEvents = typeof __propDef.events;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowbite-svelte",
3
- "version": "0.22.9",
3
+ "version": "0.22.12",
4
4
  "description": "Flowbite components for Svelte",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -162,6 +162,8 @@
162
162
  "./kbd/ArrowKeyUp.svelte": "./kbd/ArrowKeyUp.svelte",
163
163
  "./kbd/Kbd.svelte": "./kbd/Kbd.svelte",
164
164
  "./list-group/List.svelte": "./list-group/List.svelte",
165
+ "./list-group/ListItem.svelte": "./list-group/ListItem.svelte",
166
+ "./megamenu/MegaMenu.svelte": "./megamenu/MegaMenu.svelte",
165
167
  "./modals/ExtraLargeModal.svelte": "./modals/ExtraLargeModal.svelte",
166
168
  "./modals/LargeModal.svelte": "./modals/LargeModal.svelte",
167
169
  "./modals/MediumModal.svelte": "./modals/MediumModal.svelte",
package/types.d.ts CHANGED
@@ -106,6 +106,12 @@ export interface InteractiveTabType {
106
106
  id: number;
107
107
  content: string | typeof SvelteComponent;
108
108
  }
109
+ export interface ListGroupItemType {
110
+ current?: boolean;
111
+ disabled?: boolean;
112
+ href?: string;
113
+ [propName: string]: any;
114
+ }
109
115
  export interface LinkType {
110
116
  name: string;
111
117
  href: string;