flowbite-svelte 0.27.1 → 0.27.3

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,23 @@
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.27.3](https://github.com/themesberg/flowbite-svelte/compare/v0.27.2...v0.27.3) (2022-09-26)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * change a to A component ([33a8015](https://github.com/themesberg/flowbite-svelte/commit/33a8015ae3e7b3969359bcd67ba47bb53c7f7dad))
11
+ * correction in using style and color ([7ebbc5f](https://github.com/themesberg/flowbite-svelte/commit/7ebbc5fcac75fea0f9c19c51b6ea5dc8dfb241c8))
12
+ * remove workflows/release-please.yml ([30a3682](https://github.com/themesberg/flowbite-svelte/commit/30a3682d3652e779e5e4325edbf7b66ad02a8428))
13
+ * style for links ([040ff2e](https://github.com/themesberg/flowbite-svelte/commit/040ff2ea183d21836e8f3e5dddb5879cf9324a69))
14
+
15
+ ### [0.27.2](https://github.com/themesberg/flowbite-svelte/compare/v0.27.1...v0.27.2) (2022-09-26)
16
+
17
+
18
+ ### Features
19
+
20
+ * permanent option ([cceeb1b](https://github.com/themesberg/flowbite-svelte/commit/cceeb1b21995e4b386e61fa90256c7b3a304326e))
21
+
5
22
  ### [0.27.1](https://github.com/themesberg/flowbite-svelte/compare/v0.27.0...v0.27.1) (2022-09-24)
6
23
 
7
24
 
@@ -8,45 +8,12 @@ export let title = '';
8
8
  export let size = 'md';
9
9
  export let placement = 'center';
10
10
  export let autoclose = true;
11
+ export let permanent = false;
11
12
  export let backdropClasses = 'bg-gray-900 bg-opacity-50 dark:bg-opacity-80';
12
13
  const dispatch = createEventDispatcher();
13
- function blockEvent(e) {
14
- e.preventDefault();
15
- e.stopPropagation();
16
- return false;
17
- }
18
- function contentInit(node) {
19
- function keydownHandler(e) {
20
- if (open && e.key === 'Escape')
21
- return hide();
22
- const target = e.target;
23
- if (node.contains(target))
24
- return true;
25
- if (e.key === 'ArrowDown' || e.key === 'ArrowUp')
26
- return blockEvent(e);
27
- return true;
28
- }
29
- document.addEventListener('keydown', keydownHandler, { passive: false });
14
+ $: dispatch(open ? 'open' : 'hide');
15
+ function grabFocus(node) {
30
16
  node.focus();
31
- return {
32
- destroy() {
33
- document.removeEventListener('keydown', keydownHandler);
34
- }
35
- };
36
- }
37
- function init(node) {
38
- function preventScroll(e) {
39
- if (e.target === node)
40
- return blockEvent(e);
41
- }
42
- node.addEventListener('wheel', preventScroll, { passive: false });
43
- dispatch('show', node);
44
- return {
45
- destroy() {
46
- node.removeEventListener('wheel', preventScroll);
47
- dispatch('hide', node);
48
- }
49
- };
50
17
  }
51
18
  const getPlacementClasses = () => {
52
19
  switch (placement) {
@@ -85,23 +52,45 @@ const sizes = {
85
52
  const onAutoClose = (e) => {
86
53
  const target = e.target;
87
54
  if (autoclose && target?.tagName === 'BUTTON')
88
- open = !open;
55
+ open = false;
89
56
  };
90
57
  const hide = () => {
91
58
  open = false;
92
59
  };
93
60
  let mainClass;
94
- $: mainClass = classNames('flex overflow-hidden fixed top-0 right-0 left-0 z-50 w-full md:inset-0 h-modal md:h-full', backdropClasses, getPlacementClasses().join(' '), $$props.class);
61
+ $: mainClass = classNames('flex overflow-hidden fixed top-0 right-0 left-0 z-50 w-full md:inset-0 h-modal md:h-full', backdropClasses, ...getPlacementClasses(), $$props.class);
62
+ const isScrollable = (e) => [
63
+ e.scrollWidth > e.clientWidth && ['scroll', 'auto'].indexOf(getComputedStyle(e).overflowX) >= 0,
64
+ e.scrollHeight > e.clientHeight && ['scroll', 'auto'].indexOf(getComputedStyle(e).overflowY) >= 0
65
+ ];
66
+ const isArrowKey = (e, x, y) => (x && ['ArrowLeft', 'ArrowRight'].includes(e.key)) || (y && ['ArrowDown', 'ArrowUp'].includes(e.key));
67
+ function preventWheelDefault(e) {
68
+ // @ts-ignore
69
+ const [x, y] = isScrollable(this);
70
+ return x || y || e.preventDefault();
71
+ }
72
+ function stopArrowsPropagation(e) {
73
+ // @ts-ignore
74
+ const [x, y] = isScrollable(this);
75
+ if (isArrowKey(e, x, y))
76
+ e.stopPropagation();
77
+ }
78
+ function handleKeys(e) {
79
+ if (e.key === 'Escape' && !permanent)
80
+ return hide();
81
+ return isArrowKey(e, true, true) ? e.preventDefault() : true;
82
+ }
95
83
  </script>
96
84
 
97
- <!-- Main modal -->
98
85
  {#if open}
99
86
  <div
100
87
  tabindex="-1"
101
88
  class={mainClass}
102
89
  aria-modal="true"
103
90
  role="dialog"
104
- use:init
91
+ on:keydown={handleKeys}
92
+ on:wheel|preventDefault
93
+ use:grabFocus
105
94
  use:focusTrap
106
95
  on:click={autoclose ? onAutoClose : null}>
107
96
  <div class="flex p-4 w-full {sizes[size]} h-full md:h-auto max-h-screen">
@@ -109,23 +98,22 @@ $: mainClass = classNames('flex overflow-hidden fixed top-0 right-0 left-0 z-50
109
98
  <Frame rounded shadow class="relative flex flex-col w-full h-full md:h-auto">
110
99
  <!-- Modal header -->
111
100
  {#if $$slots.header || title}
112
- <div
113
- class="flex justify-between items-center p-4 rounded-t border-b dark:border-gray-600">
101
+ <div class="flex justify-between items-center p-4 rounded-t border-b dark:border-gray-600">
114
102
  <slot name="header">
115
103
  <h3 class="text-xl font-semibold text-gray-900 dark:text-white p-0">
116
104
  {title}
117
105
  </h3>
118
106
  </slot>
119
- <CloseButton name="Close modal" on:click={hide} />
107
+ {#if !permanent}<CloseButton name="Close modal" on:click={hide} />{/if}
120
108
  </div>
121
- {:else}
109
+ {:else if !permanent}
122
110
  <CloseButton name="Close modal" class="absolute top-3 right-2.5" on:click={hide} />
123
111
  {/if}
124
112
  <!-- Modal body -->
125
113
  <div
126
114
  class="p-6 space-y-6 flex-1 overflow-y-auto overscroll-contain"
127
- tabindex="0"
128
- use:contentInit>
115
+ on:keydown={stopArrowsPropagation}
116
+ on:wheel|stopPropagation={preventWheelDefault}>
129
117
  <slot />
130
118
  </div>
131
119
  <!-- Modal footer -->
@@ -1,17 +1,18 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
+ import type { Size } from '../types';
2
3
  declare const __propDef: {
3
4
  props: {
4
5
  [x: string]: any;
5
6
  open?: boolean | undefined;
6
7
  title?: string | undefined;
7
- size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
8
+ size?: Size | undefined;
8
9
  placement?: "top-left" | "top-center" | "top-right" | "center-left" | "center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right" | undefined;
9
10
  autoclose?: boolean | undefined;
11
+ permanent?: boolean | undefined;
10
12
  backdropClasses?: string | undefined;
11
13
  };
12
14
  events: {
13
- show: CustomEvent<any>;
14
- hide: CustomEvent<any>;
15
+ wheel: WheelEvent;
15
16
  } & {
16
17
  [evt: string]: CustomEvent<any>;
17
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowbite-svelte",
3
- "version": "0.27.1",
3
+ "version": "0.27.3",
4
4
  "description": "Flowbite components for Svelte",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -1,26 +1,24 @@
1
1
  <script>import Popper from '../utils/Popper.svelte';
2
2
  import classNames from 'classnames';
3
- export let customColor = '';
4
3
  export let style = 'auto';
5
- export let tipClass = 'py-2 px-3 text-sm font-medium';
6
- const colors = {
4
+ export let defaultClass = 'py-2 px-3 text-sm font-medium';
5
+ const styles = {
7
6
  dark: 'border-gray-800 bg-gray-900 text-white dark:bg-gray-700 dark:border-gray-600',
8
7
  light: 'border-gray-200 bg-white text-gray-900',
9
8
  auto: 'border-gray-200 bg-white text-gray-900 dark:bg-gray-700 dark:text-white dark:border-gray-600',
10
- custom: customColor
9
+ custom: ''
11
10
  };
12
11
  let toolTipClass;
13
- $: toolTipClass = classNames('tooltip', tipClass, colors[style], $$props.class);
12
+ $: {
13
+ $$restProps.color || (style = 'custom');
14
+ if ($$restProps.color)
15
+ style = 'custom';
16
+ else
17
+ $$restProps.color = 'none';
18
+ toolTipClass = classNames('tooltip', defaultClass, styles[style], $$props.class);
19
+ }
14
20
  </script>
15
21
 
16
- <Popper
17
- data-tooltip
18
- rounded
19
- border
20
- shadow
21
- customColor
22
- {...$$restProps}
23
- class={toolTipClass}
24
- on:show>
22
+ <Popper data-tooltip rounded border shadow {...$$restProps} class={toolTipClass} on:show>
25
23
  <slot />
26
24
  </Popper>
@@ -2,9 +2,8 @@ import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  [x: string]: any;
5
- customColor?: string | undefined;
6
5
  style?: "dark" | "light" | "custom" | "auto" | undefined;
7
- tipClass?: string | undefined;
6
+ defaultClass?: string | undefined;
8
7
  };
9
8
  events: {
10
9
  show: CustomEvent<any>;
package/types.d.ts CHANGED
@@ -147,6 +147,12 @@ export interface PageType {
147
147
  pageNum: number;
148
148
  href: string;
149
149
  }
150
+ export declare const xs = "xs";
151
+ export declare const sm = "sm";
152
+ export declare const md = "md";
153
+ export declare const lg = "lg";
154
+ export declare const xl = "xl";
155
+ export declare type Size = typeof xs | typeof sm | typeof md | typeof lg | typeof xl;
150
156
  export interface PillTabType {
151
157
  name: string;
152
158
  selected: boolean;