flowbite-svelte 0.26.7 → 0.26.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 CHANGED
@@ -2,6 +2,22 @@
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.26.8](https://github.com/themesberg/flowbite-svelte/compare/v0.26.7...v0.26.8) (2022-09-03)
6
+
7
+
8
+ ### Features
9
+
10
+ * dropdown button ([f6347f2](https://github.com/themesberg/flowbite-svelte/commit/f6347f280cbfc552d001aa22128026174b46a6f3))
11
+ * more Frame inheritance ([bb72d69](https://github.com/themesberg/flowbite-svelte/commit/bb72d6952386bd0f6dec4711795e3591a6837c02))
12
+ * popover finalization ([c71481e](https://github.com/themesberg/flowbite-svelte/commit/c71481ec18e2850488d86cfdb583587eae4a19b2))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * missing 683restProps ([0d52fd1](https://github.com/themesberg/flowbite-svelte/commit/0d52fd1b4168c8cc707c174dc2c18f532cf2e93c))
18
+ * no triggers error ([83075e1](https://github.com/themesberg/flowbite-svelte/commit/83075e1a969bdf93a520bd9e35b339e36bf4f325))
19
+ * remove unused imports ([acb58b9](https://github.com/themesberg/flowbite-svelte/commit/acb58b9144948feeb3c1c14b41a71d2122187340))
20
+
5
21
  ### [0.26.7](https://github.com/themesberg/flowbite-svelte/compare/v0.26.6...v0.26.7) (2022-09-03)
6
22
 
7
23
 
@@ -1,26 +1,13 @@
1
- <script>import Button from '../buttons/Button.svelte';
2
- import Frame from '../utils/Frame.svelte';
1
+ <script>import classNames from 'classnames';
2
+ import Button from '../buttons/Button.svelte';
3
3
  import Popper from '../utils/Popper.svelte';
4
- import classNames from 'classnames';
5
- import ChevronUp from '../utils/ChevronUp.svelte';
6
- import ChevronRight from '../utils/ChevronRight.svelte';
7
- import ChevronDown from '../utils/ChevronDown.svelte';
8
- import ChevronLeft from '../utils/ChevronLeft.svelte';
4
+ import Chevron from '../utils/Chevron.svelte';
9
5
  export let label = '';
10
6
  export let inline = false;
11
7
  export let arrowIcon = true;
12
8
  export let labelClass = 'flex items-center justify-between w-full py-2 pl-3 pr-4 font-medium 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 md:w-auto dark:text-gray-400 dark:hover:text-white dark:focus:text-white dark:border-gray-700 dark:hover:bg-gray-700 md:dark:hover:bg-transparent';
13
9
  export let placement = 'bottom';
14
10
  export let open = false;
15
- export let triggeredBy = undefined;
16
- const icons = {
17
- top: ChevronUp,
18
- right: ChevronRight,
19
- bottom: ChevronDown,
20
- left: ChevronLeft
21
- };
22
- // @ts-ignore
23
- $: icon = icons[placement.split('-')[0]];
24
11
  let popoverClass;
25
12
  $: popoverClass = classNames('outline-none', $$props.class);
26
13
  </script>
@@ -28,33 +15,40 @@ $: popoverClass = classNames('outline-none', $$props.class);
28
15
  {#if label}
29
16
  <slot name="trigger">
30
17
  {#if inline}
31
- <button class={labelClass} class:flex-row-reverse={icon == ChevronLeft}>
32
- <slot name="label">{label}</slot>
18
+ <button class={labelClass}>
33
19
  {#if arrowIcon}
34
- <svelte:component
35
- this={icon ?? ChevronDown}
36
- class={classNames('h-4 w-4', icon == ChevronLeft ? 'mr-2' : 'ml-2')} />
20
+ <Chevron {placement}><slot name="label">{label}</slot></Chevron>
21
+ {:else}
22
+ <slot name="label">{label}</slot>
37
23
  {/if}
38
24
  </button>
39
25
  {:else}
40
- <Button {...$$restProps} class={icon == ChevronLeft && 'flex-row-reverse'}>
41
- <slot name="label">{label}</slot>
26
+ <Button>
42
27
  {#if arrowIcon}
43
- <svelte:component
44
- this={icon ?? ChevronDown}
45
- class={classNames('h-4 w-4', icon == ChevronLeft ? 'mr-2' : 'ml-2')} />
28
+ <Chevron {placement}><slot name="label">{label}</slot></Chevron>
29
+ {:else}
30
+ <slot name="label">{label}</slot>
46
31
  {/if}
47
32
  </Button>
48
33
  {/if}
49
34
  </slot>
50
35
  {/if}
51
36
 
52
- <Popper activeContent={true} arrow={false} {placement} trigger="click" on:show bind:open {triggeredBy}>
53
- <Frame class={popoverClass} rounded border shadow>
54
- <slot name="content">
55
- <ul class="py-1">
56
- <slot />
57
- </ul>
58
- </slot>
59
- </Frame>
37
+ <Popper
38
+ rounded
39
+ border
40
+ shadow
41
+ activeContent
42
+ arrow={false}
43
+ {placement}
44
+ trigger="click"
45
+ {...$$restProps}
46
+ class={popoverClass}
47
+ on:show
48
+ bind:open>
49
+ <slot name="content">
50
+ <ul class="py-1">
51
+ <slot />
52
+ </ul>
53
+ </slot>
60
54
  </Popper>
@@ -7,9 +7,8 @@ declare const __propDef: {
7
7
  inline?: boolean;
8
8
  arrowIcon?: boolean;
9
9
  labelClass?: string;
10
- placement?: 'auto' | Placement;
10
+ placement?: Placement;
11
11
  open?: boolean;
12
- triggeredBy?: string;
13
12
  };
14
13
  events: {
15
14
  show: CustomEvent<any>;
@@ -1,6 +1,7 @@
1
1
  <script>import classNames from 'classnames';
2
2
  export let liClass = 'block font-medium cursor-pointer py-2 px-4 text-sm hover:bg-gray-100 dark:hover:bg-gray-600';
3
3
  export let color = 'default';
4
+ export let tabindex = 0;
4
5
  const colors = {
5
6
  default: 'text-gray-700 dark:text-gray-200 dark:hover:text-white',
6
7
  red: 'text-red-600 dark:text-red-500'
@@ -18,7 +19,6 @@ const colors = {
18
19
  on:blur
19
20
  on:mouseenter
20
21
  on:mouseleave
21
- tabindex="0"
22
- >
22
+ {tabindex}>
23
23
  <slot />
24
24
  </li>
@@ -4,6 +4,7 @@ declare const __propDef: {
4
4
  [x: string]: any;
5
5
  liClass?: string;
6
6
  color?: string;
7
+ tabindex?: number;
7
8
  };
8
9
  events: {
9
10
  click: MouseEvent;
@@ -7,7 +7,8 @@ $: aClass = active ? activeClass : nonActiveClass;
7
7
  </script>
8
8
 
9
9
  <li>
10
- <a
10
+ <svelte:element
11
+ this={href ? 'a' : 'div'}
11
12
  {href}
12
13
  {...$$restProps}
13
14
  on:blur
@@ -20,8 +21,7 @@ $: aClass = active ? activeClass : nonActiveClass;
20
21
  on:mouseenter
21
22
  on:mouseleave
22
23
  on:mouseover
23
- class={classNames(aClass, $$props.class)}
24
- >
24
+ class={classNames(aClass, $$props.class)}>
25
25
  <slot />
26
- </a>
26
+ </svelte:element>
27
27
  </li>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowbite-svelte",
3
- "version": "0.26.7",
3
+ "version": "0.26.8",
4
4
  "description": "Flowbite components for Svelte",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -233,6 +233,7 @@
233
233
  "./typography/Span.svelte": "./typography/Span.svelte",
234
234
  "./typography/Ul.svelte": "./typography/Ul.svelte",
235
235
  "./typography/Underline.svelte": "./typography/Underline.svelte",
236
+ "./utils/Chevron.svelte": "./utils/Chevron.svelte",
236
237
  "./utils/ChevronDown.svelte": "./utils/ChevronDown.svelte",
237
238
  "./utils/ChevronLeft.svelte": "./utils/ChevronLeft.svelte",
238
239
  "./utils/ChevronRight.svelte": "./utils/ChevronRight.svelte",
@@ -1,20 +1,18 @@
1
1
  <script>import Popper from '../utils/Popper.svelte';
2
- import classNames from 'classnames';
3
2
  export let title = '';
4
- let popoverClass;
5
- $: popoverClass = classNames('rounded-lg shadow-sm', 'bg-white dark:bg-gray-800', 'text-gray-500 dark:text-gray-400', 'border border-gray-200 dark:border-gray-700', $$props.class);
3
+ export let defaultClass = 'py-2 px-3';
6
4
  </script>
7
5
 
8
- <Popper activeContent={true} {...$$restProps} class={popoverClass} on:show>
9
- {#if $$slots.title || title}
10
- <div
11
- class="py-2 px-3 bg-gray-100 rounded-t-lg border-b border-gray-200 dark:border-gray-600 dark:bg-gray-700">
12
- <slot name="title">
13
- <h3 class="font-semibold text-gray-900 dark:text-white">{title}</h3>
14
- </slot>
15
- </div>
16
- {/if}
17
- <div class="py-2 px-3">
18
- <slot />
19
- </div>
6
+ <Popper activeContent border shadow rounded {...$$restProps} class={$$props.class} on:show>
7
+ {#if $$slots.title || title}
8
+ <div
9
+ class="py-2 px-3 bg-gray-100 rounded-t-lg border-b border-gray-200 dark:border-gray-600 dark:bg-gray-700">
10
+ <slot name="title">
11
+ <h3 class="font-semibold text-gray-900 dark:text-white">{title}</h3>
12
+ </slot>
13
+ </div>
14
+ {/if}
15
+ <div class={defaultClass}>
16
+ <slot />
17
+ </div>
20
18
  </Popper>
@@ -3,6 +3,7 @@ declare const __propDef: {
3
3
  props: {
4
4
  [x: string]: any;
5
5
  title?: string;
6
+ defaultClass?: string;
6
7
  };
7
8
  events: {
8
9
  show: CustomEvent<any>;
@@ -1,19 +1,24 @@
1
1
  <script>import Popper from '../utils/Popper.svelte';
2
2
  import classNames from 'classnames';
3
- export let color = '';
4
- export let style = 'dark';
5
- export let tipClass = 'py-2 px-3 text-sm font-medium rounded-lg shadow-sm tooltip';
6
- export let triggeredBy;
3
+ export let color = 'custom';
4
+ export let style = 'auto';
5
+ export let tipClass = 'py-2 px-3 text-sm font-medium';
7
6
  const colors = {
8
- dark: 'border border-gray-800 bg-gray-900 text-white dark:bg-gray-700 dark:border-gray-600',
9
- light: 'border border-gray-200 bg-white text-gray-900',
10
- auto: 'border border-gray-200 bg-white text-gray-900 dark:bg-gray-700 dark:text-white dark:border-gray-600 ',
11
- custom: color
7
+ dark: 'border-gray-800 bg-gray-900 text-white dark:bg-gray-700 dark:border-gray-600',
8
+ light: 'border-gray-200 bg-white text-gray-900',
9
+ auto: 'border-gray-200 bg-white text-gray-900 dark:bg-gray-700 dark:text-white dark:border-gray-600 '
12
10
  };
13
11
  let toolTipClass;
14
12
  $: toolTipClass = classNames(tipClass, colors[style], $$props.class);
15
13
  </script>
16
14
 
17
- <Popper activeContent={false} {triggeredBy} {...$$restProps} class={toolTipClass} on:show>
15
+ <Popper
16
+ rounded
17
+ border
18
+ shadow
19
+ color={style === 'custom' ? color : 'none'}
20
+ {...$$restProps}
21
+ class={toolTipClass}
22
+ on:show>
18
23
  <slot />
19
24
  </Popper>
@@ -5,7 +5,6 @@ declare const __propDef: {
5
5
  color?: string;
6
6
  style?: 'dark' | 'light' | 'auto' | 'custom';
7
7
  tipClass?: string;
8
- triggeredBy: string;
9
8
  };
10
9
  events: {
11
10
  show: CustomEvent<any>;
@@ -0,0 +1,23 @@
1
+ <script>import ChevronDown from './ChevronDown.svelte';
2
+ import ChevronLeft from './ChevronLeft.svelte';
3
+ import ChevronUp from './ChevronUp.svelte';
4
+ import ChevronRight from './ChevronRight.svelte';
5
+ export let placement = 'bottom';
6
+ const icons = {
7
+ top: ChevronUp,
8
+ right: ChevronRight,
9
+ bottom: ChevronDown,
10
+ left: ChevronLeft
11
+ };
12
+ // @ts-ignore
13
+ let icon;
14
+ $: icon = icons[placement.split('-')[0]] ?? ChevronDown;
15
+ </script>
16
+
17
+ {#if placement.split('-')[0] === 'left'}
18
+ <ChevronLeft class="h-4 w-4 mr-2" />
19
+ <slot />
20
+ {:else}
21
+ <slot />
22
+ <svelte:component this={icon} class="h-4 w-4 ml-2" />
23
+ {/if}
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Placement } from '@popperjs/core';
3
+ declare const __propDef: {
4
+ props: {
5
+ placement?: Placement;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export declare type ChevronProps = typeof __propDef.props;
15
+ export declare type ChevronEvents = typeof __propDef.events;
16
+ export declare type ChevronSlots = typeof __propDef.slots;
17
+ export default class Chevron extends SvelteComponentTyped<ChevronProps, ChevronEvents, ChevronSlots> {
18
+ }
19
+ export {};
@@ -1,6 +1,6 @@
1
1
  <script>import classNames from 'classnames';
2
2
  import { setContext } from 'svelte';
3
- import * as transitions from 'svelte/transition';
3
+ import { noop } from 'svelte/internal';
4
4
  setContext('background', true);
5
5
  $: setContext('color', color);
6
6
  export let tag = 'div';
@@ -8,10 +8,14 @@ export let color = 'default';
8
8
  export let rounded = false;
9
9
  export let border = false;
10
10
  export let shadow = false;
11
- // Export a prop through which you can set a desired transition
11
+ // Export a prop through which you can set a desired svelte transition
12
12
  export let transition = undefined;
13
13
  // Pass in extra transition params
14
14
  export let params = {};
15
+ // For components development
16
+ export let node = undefined;
17
+ export let use = noop;
18
+ export let options = {};
15
19
  // your script goes here
16
20
  const bgColors = {
17
21
  gray: 'bg-gray-100 dark:bg-gray-200 ',
@@ -57,17 +61,22 @@ const borderColors = {
57
61
  };
58
62
  // have a custom transition function that returns the desired transition
59
63
  let transitionFunc;
60
- $: transitionFunc = transitions[transition];
64
+ // $: transitionFunc = (node: Element) => (transition ? transition(node, params) : noop);
65
+ $: transitionFunc = transition ?? noop;
61
66
  let divClass;
62
67
  $: divClass = classNames(bgColors[color], textColors[color], rounded && 'rounded-lg ', border && 'border', borderColors[color], shadow && 'shadow-md', $$props.class);
63
68
  </script>
64
69
 
65
- {#if transitionFunc}
66
- <svelte:element this={tag} transition:transitionFunc={params} {...$$restProps} class={divClass}>
67
- <slot />
68
- </svelte:element>
69
- {:else}
70
- <svelte:element this={tag} {...$$restProps} class={divClass}>
71
- <slot />
72
- </svelte:element>
73
- {/if}
70
+ <svelte:element
71
+ this={tag}
72
+ use:use={options}
73
+ bind:this={node}
74
+ transition:transitionFunc={params}
75
+ {...$$restProps}
76
+ class={divClass}
77
+ on:mouseenter
78
+ on:mouseleave
79
+ on:focusin
80
+ on:focusout>
81
+ <slot />
82
+ </svelte:element>
@@ -1,17 +1,26 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { TransitionTypes, TransitionParamTypes } from '../types';
2
+ import type { Action } from 'svelte/action';
3
+ import type { TransitionConfig } from 'svelte/transition';
3
4
  declare const __propDef: {
4
5
  props: {
5
6
  [x: string]: any;
6
- tag?: string;
7
+ tag?: 'div' | 'a';
7
8
  color?: string;
8
9
  rounded?: boolean;
9
10
  border?: boolean;
10
11
  shadow?: boolean;
11
- transition?: TransitionTypes;
12
- params?: TransitionParamTypes;
12
+ transition?: (node: Element, params: object) => TransitionConfig;
13
+ params?: object;
14
+ node?: HTMLElement;
15
+ use?: Action;
16
+ options?: {};
13
17
  };
14
18
  events: {
19
+ mouseenter: MouseEvent;
20
+ mouseleave: MouseEvent;
21
+ focusin: FocusEvent;
22
+ focusout: FocusEvent;
23
+ } & {
15
24
  [evt: string]: CustomEvent<any>;
16
25
  };
17
26
  slots: {
@@ -1,10 +1,9 @@
1
1
  <script>import { onMount } from 'svelte';
2
- import { fade } from 'svelte/transition';
3
2
  import { createPopper } from '@popperjs/core';
4
3
  import classNames from 'classnames';
5
4
  import createEventDispatcher from './createEventDispatcher';
5
+ import Frame from './Frame.svelte';
6
6
  export let activeContent = false;
7
- export let animation = 100;
8
7
  export let arrow = true;
9
8
  export let offset = 8;
10
9
  export let placement = 'top';
@@ -77,12 +76,12 @@ onMount(() => {
77
76
  ['mouseenter', showHandler, !clickable],
78
77
  ['mouseleave', hideHandler, !clickable]
79
78
  ];
80
- triggerEls = [...document.querySelectorAll(triggeredBy)];
79
+ if (triggeredBy)
80
+ triggerEls = [...document.querySelectorAll(triggeredBy)];
81
+ else
82
+ triggerEls = contentEl.previousElementSibling ? [contentEl.previousElementSibling] : [];
81
83
  if (!triggerEls.length) {
82
- if (contentEl.previousElementSibling)
83
- triggerEls.push(contentEl.previousElementSibling);
84
- else
85
- console.error('No triggers found.');
84
+ console.error('No triggers found.');
86
85
  }
87
86
  triggerEls.forEach((element) => {
88
87
  if (element.tabIndex < 0)
@@ -108,18 +107,19 @@ onMount(() => {
108
107
  {/if}
109
108
 
110
109
  {#if open && triggerEl}
111
- <div
112
- use:init={triggerEl}
113
- transition:fade={{ duration: animation ? animation : 0 }}
110
+ <Frame
111
+ use={init}
112
+ options={triggerEl}
114
113
  role="tooltip"
115
114
  tabIndex={activeContent ? -1 : undefined}
116
- class={classNames('z-10', $$props.class)}
117
115
  on:focusin={activeContent ? showHandler : undefined}
118
116
  on:focusout={activeContent ? hideHandler : undefined}
119
- on:mouseenter={activeContent && !clickable ? showHandler : undefined}
117
+ on:mouseenter={showHandler}
120
118
  on:mouseleave={activeContent && !clickable ? hideHandler : undefined}
119
+ {...$$restProps}
120
+ class={classNames('z-10', $$props.class)}
121
121
  style="position: absolute;">
122
122
  <slot />
123
123
  {#if arrow}<div data-popper-arrow />{/if}
124
- </div>
124
+ </Frame>
125
125
  {/if}
@@ -4,7 +4,6 @@ declare const __propDef: {
4
4
  props: {
5
5
  [x: string]: any;
6
6
  activeContent?: boolean;
7
- animation?: false | number;
8
7
  arrow?: boolean;
9
8
  offset?: number;
10
9
  placement?: Placement;