uibee 2.5.9 → 2.5.11

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.
@@ -17,9 +17,10 @@ export { default as NavDropdown } from './navbar/navbarDropdown';
17
17
  // Containers
18
18
  export { default as PageContainer } from './container/page';
19
19
  export { default as Highlight } from './container/highlight';
20
- // Other components
20
+ // Login
21
21
  export { default as VersionTag } from './version/version';
22
22
  export { default as LoginPage } from './login/loginPage';
23
+ // Toasts
23
24
  export { default as Toaster, toast } from './toast/toaster';
24
25
  // Buttons
25
26
  export { default as Button } from './buttons/button';
@@ -1,3 +1,9 @@
1
1
  import type { ToastType } from 'uibee/components';
2
2
  export declare function toast(message: string, type: ToastType, duration?: number): void;
3
+ export declare namespace toast {
4
+ var info: (message: string, duration?: number) => void;
5
+ var success: (message: string, duration?: number) => void;
6
+ var warning: (message: string, duration?: number) => void;
7
+ var error: (message: string, duration?: number) => void;
8
+ }
3
9
  export default function Toaster(): import("react/jsx-runtime").JSX.Element;
@@ -1,13 +1,17 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useState, useEffect, useMemo } from 'react';
4
- import ToastItem from 'toastItem';
4
+ import ToastItem from './toastItem';
5
5
  const listeners = new Set();
6
6
  let idCounter = 0;
7
7
  export function toast(message, type, duration = 4000) {
8
8
  const id = ++idCounter;
9
9
  listeners.forEach(listener => listener({ id, message, type, expiresAt: Date.now() + duration }));
10
10
  }
11
+ toast.info = (message, duration) => toast(message, 'info', duration);
12
+ toast.success = (message, duration) => toast(message, 'success', duration);
13
+ toast.warning = (message, duration) => toast(message, 'warning', duration);
14
+ toast.error = (message, duration) => toast(message, 'error', duration);
11
15
  export default function Toaster() {
12
16
  const [toasts, setToasts] = useState([]);
13
17
  const [expanded, setExpanded] = useState(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uibee",
3
- "version": "2.5.9",
3
+ "version": "2.5.11",
4
4
  "description": "Shared components, functions and hooks for reuse across Login projects",
5
5
  "homepage": "https://github.com/Login-Linjeforening-for-IT/uibee#readme",
6
6
  "bugs": {
@@ -22,9 +22,11 @@ export { default as NavDropdown } from './navbar/navbarDropdown'
22
22
  export { default as PageContainer} from './container/page'
23
23
  export { default as Highlight } from './container/highlight'
24
24
 
25
- // Other components
25
+ // Login
26
26
  export { default as VersionTag } from './version/version'
27
27
  export { default as LoginPage } from './login/loginPage'
28
+
29
+ // Toasts
28
30
  export { default as Toaster, toast } from './toast/toaster'
29
31
 
30
32
  // Buttons
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { useState, useEffect, useMemo } from 'react'
4
4
  import type { Toast, ToastType } from 'uibee/components'
5
- import ToastItem from '@components/toast/toastItem'
5
+ import ToastItem from './toastItem'
6
6
 
7
7
  const listeners = new Set<(toast: Toast) => void>()
8
8
  let idCounter = 0
@@ -12,6 +12,11 @@ export function toast(message: string, type: ToastType, duration = 4000) {
12
12
  listeners.forEach(listener => listener({ id, message, type, expiresAt: Date.now() + duration }))
13
13
  }
14
14
 
15
+ toast.info = (message: string, duration?: number) => toast(message, 'info', duration)
16
+ toast.success = (message: string, duration?: number) => toast(message, 'success', duration)
17
+ toast.warning = (message: string, duration?: number) => toast(message, 'warning', duration)
18
+ toast.error = (message: string, duration?: number) => toast(message, 'error', duration)
19
+
15
20
  export default function Toaster() {
16
21
  const [toasts, setToasts] = useState<Toast[]>([])
17
22
  const [expanded, setExpanded] = useState(false)
@@ -33,8 +33,14 @@ declare module 'uibee/components' {
33
33
  export type Language = 'no' | 'en'
34
34
 
35
35
  export default function LoginPage(props: LoginPageProps): JSX.Element;
36
- export default function Toaster(): JSX.Element;
37
- export default function toast(message: string, type: ToastType, duration?: number): void;
36
+ export function Toaster(): JSX.Element;
37
+ export function toast(message: string, type: ToastType, duration?: number): void;
38
+ export namespace toast {
39
+ export function info(message: string, duration?: number): void;
40
+ export function success(message: string, duration?: number): void;
41
+ export function warning(message: string, duration?: number): void;
42
+ export function error(message: string, duration?: number): void;
43
+ }
38
44
  export default function LanguageToggle(props: { lang: Language }): JSX.Element;
39
45
  export default function ThemeSwitch(props: { className?: string }): JSX.Element;
40
46
  }