flowbite-svelte 0.19.11 → 0.19.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,8 @@
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.19.12](https://github.com/themesberg/flowbite-svelte/compare/v0.19.11...v0.19.12) (2022-06-30)
6
+
5
7
  ### [0.19.11](https://github.com/themesberg/flowbite-svelte/compare/v0.19.10...v0.19.11) (2022-06-30)
6
8
 
7
9
 
@@ -1,6 +1,6 @@
1
1
  <script>import { ChevronRight } from 'svelte-heros';
2
2
  export let icon = null;
3
- export let variation;
3
+ export let variation = null;
4
4
  export let iconSize = 20;
5
5
  export let iconClass = 'mr-2';
6
6
  </script>
@@ -4,7 +4,7 @@ declare const __propDef: {
4
4
  props: {
5
5
  [x: string]: any;
6
6
  icon?: typeof SvelteComponent | null;
7
- variation: 'solid' | null;
7
+ variation?: 'solid' | null;
8
8
  iconSize?: number;
9
9
  iconClass?: string;
10
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowbite-svelte",
3
- "version": "0.19.11",
3
+ "version": "0.19.12",
4
4
  "description": "Flowbite components for Svelte",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -208,6 +208,7 @@
208
208
  "./toasts/Toast.svelte": "./toasts/Toast.svelte",
209
209
  "./tooltips/Tooltip.svelte": "./tooltips/Tooltip.svelte",
210
210
  "./types": "./types.js",
211
+ "./utils/CloseButton.svelte": "./utils/CloseButton.svelte",
211
212
  "./utils/clickOutside": "./utils/clickOutside.js",
212
213
  "./utils/generateId": "./utils/generateId.js"
213
214
  },
@@ -1,65 +1,46 @@
1
- <script>import { fade, blur, fly, slide } from 'svelte/transition';
1
+ <script>import classNames from 'classnames';
2
+ import * as transitions from 'svelte/transition';
3
+ import CloseButton from '../utils/CloseButton.svelte';
4
+ export let color = 'blue';
5
+ export let simple = false;
6
+ // Export a prop through which you can set a desired transition
7
+ export let transition = 'fade';
8
+ // Pass in extra transition params
9
+ export let params = {};
2
10
  let visible = true;
3
- const handleHide = () => {
4
- visible = !visible;
11
+ const colors = {
12
+ blue: 'text-blue-500 bg-blue-100 dark:bg-blue-800 dark:text-blue-200',
13
+ green: 'text-green-500 bg-green-100 dark:bg-green-800 dark:text-green-200',
14
+ red: 'text-red-500 bg-red-100 dark:bg-red-800 dark:text-red-200',
15
+ gray: 'text-gray-500 bg-gray-100 dark:bg-gray-800 dark:text-gray-200',
16
+ purple: 'text-purple-500 bg-purple-100 dark:bg-purple-800 dark:text-purple-200',
17
+ indigo: 'text-indigo-500 bg-indigo-100 dark:bg-indigo-800 dark:text-indigo-200',
18
+ yellow: 'text-yellow-500 bg-yellow-100 dark:bg-yellow-800 dark:text-yellow-200'
5
19
  };
6
- export let iconColor = 'blue';
7
- // Export a prop through which you can set a desired transition
8
- export let transitionType = 'fade';
9
- // Pass in params
10
- export let transitionParams = {};
11
- let iconDivClass;
12
- export let divClass = 'flex items-center w-full max-w-xs p-4 text-gray-500 bg-white rounded-lg shadow dark:text-gray-400 dark:bg-gray-800';
13
- export let textClass = 'ml-3 text-sm font-normal';
14
- export let btnClass = 'ml-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2 focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex h-8 w-8 dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700';
15
- if (iconColor === 'blue') {
16
- iconDivClass = 'inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-blue-500 bg-blue-100 rounded-lg dark:bg-blue-800 dark:text-blue-200';
17
- }
18
- else if (iconColor === 'green') {
19
- iconDivClass = 'inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-green-500 bg-green-100 rounded-lg dark:bg-green-800 dark:text-green-200';
20
- }
21
- else if (iconColor === 'red') {
22
- iconDivClass = 'inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-red-500 bg-red-100 rounded-lg dark:bg-red-800 dark:text-red-200';
23
- }
24
- else if (iconColor === 'gray') {
25
- iconDivClass = 'inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-gray-500 bg-gray-100 rounded-lg dark:bg-gray-800 dark:text-gray-200';
26
- }
27
- else if (iconColor === 'purple') {
28
- iconDivClass = 'inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-purple-500 bg-purple-100 rounded-lg dark:bg-purple-800 dark:text-purple-200';
29
- }
30
- else if (iconColor === 'indigo') {
31
- iconDivClass = 'inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-indigo-500 bg-indigo-100 rounded-lg dark:bg-indigo-800 dark:text-indigo-200';
32
- }
33
- else if (iconColor === 'yellow') {
34
- iconDivClass = 'inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-yellow-500 bg-yellow-100 rounded-lg dark:bg-yellow-800 dark:text-yellow-200';
35
- }
36
- else {
37
- iconDivClass = 'inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-blue-500 bg-blue-100 rounded-lg dark:bg-blue-800 dark:text-blue-200';
38
- }
39
20
  // have a custom transition function that returns the desired transition
40
- function multiple(node, params) {
41
- switch (transitionType) {
42
- case 'slide':
43
- return slide(node, params);
44
- case 'blur':
45
- return blur(node, params);
46
- case 'fly':
47
- return fly(node, params);
48
- case 'fade':
49
- return fade(node, params);
50
- }
51
- }
21
+ let transitionFunc;
22
+ $: transitionFunc = transitions[transition] ?? transitions.fade;
23
+ let divClass;
24
+ $: divClass = classNames('w-full max-w-xs p-4 text-gray-500 bg-white rounded-lg shadow dark:text-gray-400 dark:bg-gray-800', $$props.class);
25
+ let iconClass;
26
+ $: iconClass = classNames('inline-flex items-center justify-center flex-shrink-0 rounded-lg w-8 h-8 mr-3', colors[color]);
52
27
  </script>
53
28
 
54
29
  {#if visible}
55
- <div transition:multiple={transitionParams} class={divClass} role="alert">
56
- <div class={iconDivClass}>
57
- <slot name="icon" />
30
+ <div transition:transitionFunc={params} class={divClass} role="alert">
31
+ <div class="flex items-center w-full">
32
+ {#if $$slots.icon}
33
+ <div class={iconClass}>
34
+ <slot name="icon" />
35
+ </div>
36
+ {/if}
37
+
38
+ <div class="text-sm font-normal"><slot /></div>
39
+
40
+ {#if !simple}
41
+ <CloseButton on:click={() => (visible = false)} />
42
+ {/if}
58
43
  </div>
59
- <div class={textClass}><slot name="text" /></div>
60
- <button type="button" class={btnClass} on:click={handleHide} aria-label="Close">
61
- <span class="sr-only">Close</span>
62
- <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd" /></svg>
63
- </button>
44
+ <slot name="extra" />
64
45
  </div>
65
46
  {/if}
@@ -2,19 +2,19 @@ import { SvelteComponentTyped } from "svelte";
2
2
  import type { Colors, TransitionTypes, TransitionParamTypes } from '../types';
3
3
  declare const __propDef: {
4
4
  props: {
5
- iconColor?: Colors;
6
- transitionType?: TransitionTypes;
7
- transitionParams?: TransitionParamTypes;
8
- divClass?: string;
9
- textClass?: string;
10
- btnClass?: string;
5
+ [x: string]: any;
6
+ color?: Colors;
7
+ simple?: boolean;
8
+ transition?: TransitionTypes;
9
+ params?: TransitionParamTypes;
11
10
  };
12
11
  events: {
13
12
  [evt: string]: CustomEvent<any>;
14
13
  };
15
14
  slots: {
16
15
  icon: {};
17
- text: {};
16
+ default: {};
17
+ extra: {};
18
18
  };
19
19
  };
20
20
  export declare type ToastProps = typeof __propDef.props;
@@ -0,0 +1,27 @@
1
+ <script>import classNames from 'classnames';
2
+ export let color = 'default';
3
+ const colors = {
4
+ gray: 'bg-gray-100 text-gray-500 focus:ring-gray-400 hover:bg-gray-200 dark:bg-gray-200 dark:text-gray-600 dark:hover:bg-gray-300',
5
+ red: 'bg-red-100 text-red-500 focus:ring-red-400 hover:bg-red-200 dark:bg-red-200 dark:text-red-600 dark:hover:bg-red-300',
6
+ yellow: 'bg-yellow-100 text-yellow-500 focus:ring-yellow-400 hover:bg-yellow-200 dark:bg-yellow-200 dark:text-yellow-600 dark:hover:bg-yellow-300',
7
+ green: 'bg-green-100 text-green-500 focus:ring-green-400 hover:bg-green-200 dark:bg-green-200 dark:text-green-600 dark:hover:bg-green-300',
8
+ indigo: 'bg-indigo-100 text-indigo-500 focus:ring-indigo-400 hover:bg-indigo-200 dark:bg-indigo-200 dark:text-indigo-600 dark:hover:bg-indigo-300',
9
+ purple: 'bg-purple-100 text-purple-500 focus:ring-purple-400 hover:bg-purple-200 dark:bg-purple-200 dark:text-purple-600 dark:hover:bg-purple-300',
10
+ pink: 'bg-pink-100 text-pink-500 focus:ring-pink-400 hover:bg-pink-200 dark:bg-pink-200 dark:text-pink-600 dark:hover:bg-pink-300',
11
+ blue: 'bg-blue-100 text-blue-500 focus:ring-blue-400 hover:bg-blue-200 dark:bg-blue-200 dark:text-blue-600 dark:hover:bg-blue-300',
12
+ default: 'bg-white text-gray-400 hover:text-gray-900 focus:ring-gray-300 hover:bg-gray-100 dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700'
13
+ };
14
+ let buttonClass = '';
15
+ $: buttonClass = classNames('ml-auto -mx-1 -my-1.5 rounded-lg focus:ring-2 p-1.5 inline-flex h-8 w-8', colors[color] ?? colors.blue, $$props.class);
16
+ </script>
17
+
18
+ <button on:click type="button" class={buttonClass} aria-label="Close">
19
+ <span class="sr-only">Close</span>
20
+ <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"
21
+ ><path
22
+ fill-rule="evenodd"
23
+ d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
24
+ clip-rule="evenodd"
25
+ /></svg
26
+ >
27
+ </button>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ [x: string]: any;
5
+ color?: string;
6
+ };
7
+ events: {
8
+ click: MouseEvent;
9
+ } & {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {};
13
+ };
14
+ export declare type CloseButtonProps = typeof __propDef.props;
15
+ export declare type CloseButtonEvents = typeof __propDef.events;
16
+ export declare type CloseButtonSlots = typeof __propDef.slots;
17
+ export default class CloseButton extends SvelteComponentTyped<CloseButtonProps, CloseButtonEvents, CloseButtonSlots> {
18
+ }
19
+ export {};