@reshape-biotech/design-system 1.2.0 → 1.2.1
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/dist/components/notifications/Notifications.svelte +1 -1
- package/dist/components/toast/Toast.svelte +1 -1
- package/dist/components/toast/Toast.svelte.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/notifications.d.ts +22 -0
- package/dist/notifications.js +27 -0
- package/package.json +2 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { flip } from 'svelte/animate';
|
|
3
3
|
import { fly } from 'svelte/transition';
|
|
4
|
-
import { notifications } from '
|
|
4
|
+
import { notifications } from '../../notifications';
|
|
5
5
|
import { type IconColor } from '../icons';
|
|
6
6
|
import { tokens } from '../../tokens';
|
|
7
7
|
import Toast from '../toast/Toast.svelte';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { type Notification, notifications } from '
|
|
2
|
+
import { type Notification, notifications } from '../../notifications';
|
|
3
3
|
import Icon from '../icons/Icon.svelte';
|
|
4
4
|
import { type IconColor } from '../icons';
|
|
5
5
|
import { tokens } from '../../tokens';
|
package/dist/index.d.ts
CHANGED
|
@@ -46,5 +46,5 @@ export * from './components/toggle/';
|
|
|
46
46
|
export * from './components/checkbox/';
|
|
47
47
|
export * from './components/sjsf-wrappers/';
|
|
48
48
|
export { tokens } from './tokens';
|
|
49
|
-
export { notifications } from '
|
|
49
|
+
export { notifications } from './notifications';
|
|
50
50
|
import './app.css';
|
package/dist/index.js
CHANGED
|
@@ -48,5 +48,5 @@ export * from './components/checkbox/';
|
|
|
48
48
|
export * from './components/sjsf-wrappers/';
|
|
49
49
|
// Styles and Tokens
|
|
50
50
|
export { tokens } from './tokens';
|
|
51
|
-
export { notifications } from '
|
|
51
|
+
export { notifications } from './notifications';
|
|
52
52
|
import './app.css';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IconName } from './';
|
|
2
|
+
export type NotificationType = 'info' | 'success' | 'warning' | 'danger' | 'default';
|
|
3
|
+
export interface Notification {
|
|
4
|
+
id: string;
|
|
5
|
+
type: NotificationType;
|
|
6
|
+
message: string;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
icon?: IconName;
|
|
9
|
+
dismissable: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const notifications: {
|
|
12
|
+
subscribe: {
|
|
13
|
+
(this: void, run: import("svelte/store").Subscriber<Notification[]>, invalidate?: (() => void) | undefined): import("svelte/store").Unsubscriber;
|
|
14
|
+
(this: void, run: import("svelte/store").Subscriber<Notification[]>, invalidate?: (() => void) | undefined): import("svelte/store").Unsubscriber;
|
|
15
|
+
};
|
|
16
|
+
dismiss: (id: string) => void;
|
|
17
|
+
default: (message: string, icon?: IconName, dismissable?: boolean, timeout?: number) => void;
|
|
18
|
+
danger: (message: string, icon?: IconName, dismissable?: boolean, timeout?: number) => void;
|
|
19
|
+
warning: (message: string, icon?: IconName, dismissable?: boolean, timeout?: number) => void;
|
|
20
|
+
info: (message: string, icon?: IconName, dismissable?: boolean, timeout?: number) => void;
|
|
21
|
+
success: (message: string, icon?: IconName, dismissable?: boolean, timeout?: number) => void;
|
|
22
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
const TIMEOUT = 3000;
|
|
3
|
+
const createNotificationStore = () => {
|
|
4
|
+
const { subscribe, update } = writable([]);
|
|
5
|
+
const send = (message, type = 'default', iconName, dismissable = false, timeout = 3000) => {
|
|
6
|
+
const notification = { id: id(), type, message, timeout, icon: iconName, dismissable };
|
|
7
|
+
update((state) => [...state, notification]);
|
|
8
|
+
setTimeout(() => {
|
|
9
|
+
update((state) => state.filter((n) => n.id !== notification.id));
|
|
10
|
+
}, timeout);
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
subscribe,
|
|
14
|
+
dismiss: (id) => {
|
|
15
|
+
update((state) => state.filter((n) => n.id !== id));
|
|
16
|
+
},
|
|
17
|
+
default: (message, icon, dismissable = false, timeout = TIMEOUT) => send(message, 'default', icon, dismissable, timeout),
|
|
18
|
+
danger: (message, icon, dismissable = false, timeout = TIMEOUT) => send(message, 'danger', icon, dismissable, timeout),
|
|
19
|
+
warning: (message, icon, dismissable = false, timeout = TIMEOUT) => send(message, 'warning', icon, dismissable, timeout),
|
|
20
|
+
info: (message, icon, dismissable = false, timeout = TIMEOUT) => send(message, 'info', icon, dismissable, timeout),
|
|
21
|
+
success: (message, icon, dismissable = false, timeout = TIMEOUT) => send(message, 'success', icon, dismissable, timeout)
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const id = () => {
|
|
25
|
+
return crypto.randomUUID();
|
|
26
|
+
};
|
|
27
|
+
export const notifications = createNotificationStore();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reshape-biotech/design-system",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite dev",
|
|
6
6
|
"build": "vite build",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"default": "./dist/index.js"
|
|
29
29
|
},
|
|
30
30
|
"./tokens": "./dist/tokens.js",
|
|
31
|
+
"./notifications": "./dist/notifications.js",
|
|
31
32
|
"./styles": "./dist/app.css",
|
|
32
33
|
"./tailwind": "./dist/tailwind.preset.js",
|
|
33
34
|
"./tailwind-safelist": "./dist/tailwind-safelist.js"
|