uibee 2.5.10 → 2.6.0

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.
@@ -1,7 +1,7 @@
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) {
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useState } from 'react';
4
- import { getCookie, setCookie } from '../../utils/cookies/cookies';
4
+ import { getCookie, setCookie } from 'utilbee/utils';
5
5
  import { useRouter } from 'next/navigation';
6
6
  import { Globe } from 'lucide-react';
7
7
  export default function LanguageToggle({ language }) {
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useState } from 'react';
4
- import { getCookie, setCookie } from '../../utils/cookies/cookies';
4
+ import { getCookie, setCookie } from 'utilbee/utils';
5
5
  import { useRouter } from 'next/navigation';
6
6
  export default function ThemeToggle({ className }) {
7
7
  const router = useRouter();
@@ -1,4 +1,4 @@
1
- /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */
1
+ /*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */
2
2
  @layer properties;
3
3
  @layer theme, base, components, utilities;
4
4
  @layer theme {
@@ -1,6 +1,3 @@
1
- export { default as alertSlowQuery } from './sql/alertSlowQuery';
2
- export { default as discordAlert } from './discord/discordAlert';
3
- export { getCookie, setCookie, removeCookie } from './cookies/cookies';
4
1
  export { LogoConsoleOutput } from './LogoConsoleOutput/LogoConsoleOutput';
5
2
  export { default as authLogin } from './auth/login';
6
3
  export { default as authCallback } from './auth/callback';
@@ -1,6 +1,3 @@
1
- export { default as alertSlowQuery } from './sql/alertSlowQuery';
2
- export { default as discordAlert } from './discord/discordAlert';
3
- export { getCookie, setCookie, removeCookie } from './cookies/cookies';
4
1
  export { LogoConsoleOutput } from './LogoConsoleOutput/LogoConsoleOutput';
5
2
  // Auth
6
3
  export { default as authLogin } from './auth/login';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uibee",
3
- "version": "2.5.10",
3
+ "version": "2.6.0",
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": {
@@ -51,6 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "lucide-react": "^0.562.0",
54
- "react-dom": "19.2.3"
54
+ "react-dom": "19.2.3",
55
+ "utilbee": "^1.1.0"
55
56
  }
56
57
  }
@@ -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
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
 
3
3
  import { useEffect, useState } from 'react'
4
- import { getCookie, setCookie } from '@utils/cookies/cookies'
4
+ import { getCookie, setCookie } from 'utilbee/utils'
5
5
  import { useRouter } from 'next/navigation'
6
6
  import { Language } from 'uibee/components'
7
7
  import { Globe } from 'lucide-react'
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
 
3
3
  import { useEffect, useState } from 'react'
4
- import { getCookie, setCookie } from '@utils/cookies/cookies'
4
+ import { getCookie, setCookie } from 'utilbee/utils'
5
5
  import { useRouter } from 'next/navigation'
6
6
 
7
7
  export default function ThemeToggle({className}: {className?: string}) {
@@ -1,36 +1,6 @@
1
1
  /* eslint-disable @stylistic/semi */
2
2
  import { NextRequest } from 'next/server'
3
-
4
3
  declare module 'uibee/utils' {
5
- export interface SlowQueryProps {
6
- application: string
7
- duration: number
8
- name: string
9
- cacheTTL: number
10
- webhookURL: string
11
- criticalRole: string
12
- }
13
- export interface Embed {
14
- title: string
15
- description: string
16
- color: number
17
- timestamp: string
18
- }
19
-
20
- export interface Data {
21
- content?: string
22
- embeds: Embed[]
23
- }
24
-
25
- export interface DiscordAlertProps {
26
- application: string
27
- description: string
28
- type: 'get' | 'post' | ''
29
- ping: boolean
30
- criticalRole: string
31
- webhookURL: string
32
- }
33
-
34
4
  export interface AuthLoginProps {
35
5
  clientID: string
36
6
  redirectURL: string
@@ -58,8 +28,6 @@ declare module 'uibee/utils' {
58
28
  frontendURL: string
59
29
  }
60
30
 
61
- export default async function alertSlowQuery(props: SlowQueryProps): Promise<void>;
62
- export default async function discordAlert(props: DiscordAlertProps): Promise<number>;
63
31
  export default async function authLogin(props: AuthLoginProps): Promise<Response>;
64
32
  export default async function authCallback(props: AuthCallbackProps): Promise<Response>;
65
33
  export default async function authToken(props: AuthTokenProps): Promise<Response>;
@@ -1,6 +1,3 @@
1
- export { default as alertSlowQuery } from './sql/alertSlowQuery'
2
- export { default as discordAlert } from './discord/discordAlert'
3
- export { getCookie, setCookie, removeCookie } from './cookies/cookies'
4
1
  export { LogoConsoleOutput } from './LogoConsoleOutput/LogoConsoleOutput'
5
2
 
6
3
  // Auth
@@ -1,4 +0,0 @@
1
- export declare function getCookie(name: string): string | null;
2
- export declare function setCookie(name: string, value: string, days?: number): void;
3
- export declare function removeCookie(name: string): void;
4
- export declare function removeCookies(...cookies: string[]): void;
@@ -1,36 +0,0 @@
1
- export function getCookie(name) {
2
- if (typeof document === 'undefined')
3
- return null;
4
- const matches = document.cookie.match(new RegExp('(?:^|; )' +
5
- name.replace(/([.$?*|{}()[\]/\\+^])/g, '\\$1') +
6
- '=([^;]*)'));
7
- return matches ? decodeURIComponent(matches[1]) : null;
8
- }
9
- export function setCookie(name, value, days) {
10
- if (typeof document === 'undefined')
11
- return;
12
- let expires = '';
13
- if (!value) {
14
- return;
15
- }
16
- if (days) {
17
- const date = new Date();
18
- date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
19
- expires = `expires=${date.toUTCString()};`;
20
- }
21
- document.cookie =
22
- `${name}=${encodeURIComponent(value)}; ` +
23
- `${expires} path=/; SameSite=Lax`;
24
- }
25
- export function removeCookie(name) {
26
- if (typeof document === 'undefined')
27
- return;
28
- document.cookie =
29
- `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; ` +
30
- 'path=/; SameSite=Lax';
31
- }
32
- export function removeCookies(...cookies) {
33
- for (const cookie of cookies) {
34
- removeCookie(cookie);
35
- }
36
- }
@@ -1,2 +0,0 @@
1
- import { DiscordAlertProps } from 'uibee/utils';
2
- export default function discordAlert({ application, description, type, ping, criticalRole, webhookURL }: DiscordAlertProps): Promise<number>;
@@ -1,32 +0,0 @@
1
- export default async function discordAlert({ application, description, type = '', ping = false, criticalRole, webhookURL }) {
2
- try {
3
- const data = {
4
- embeds: [
5
- {
6
- title: `🐝 ${application} ${`${type.toUpperCase()} `}🐝`,
7
- description: description,
8
- color: 0xff0000,
9
- timestamp: new Date().toISOString()
10
- }
11
- ]
12
- };
13
- if (ping) {
14
- data.content = `🚨 <@&${criticalRole}> 🚨`;
15
- }
16
- const response = await fetch(webhookURL ?? '', {
17
- method: 'POST',
18
- headers: {
19
- 'Content-Type': 'application/json'
20
- },
21
- body: JSON.stringify(data)
22
- });
23
- if (!response.ok) {
24
- throw new Error(await response.text());
25
- }
26
- return response.status;
27
- }
28
- catch (error) {
29
- console.log(error);
30
- return 500;
31
- }
32
- }
@@ -1,2 +0,0 @@
1
- import { SlowQueryProps } from 'uibee/utils';
2
- export default function alertSlowQuery({ application, duration, name, cacheTTL, webhookURL, criticalRole }: SlowQueryProps): Promise<void>;
@@ -1,25 +0,0 @@
1
- export default async function alertSlowQuery({ application, duration, name, cacheTTL, webhookURL, criticalRole }) {
2
- const lowerCaseName = name.toLowerCase();
3
- const firstUpperCaseName = `${name.slice(0, 1).toUpperCase()}${name.slice(1).toLowerCase()}`;
4
- if (duration > cacheTTL / 2 && webhookURL) {
5
- const data = {
6
- embeds: [
7
- {
8
- title: `🐝 ${application} ${firstUpperCaseName} Query Timing 🐝`,
9
- description: `🐝 Slow ${lowerCaseName} query detected: ${duration.toFixed(2)}s`,
10
- color: 0xff0000,
11
- timestamp: new Date().toISOString()
12
- }
13
- ]
14
- };
15
- if (duration > (cacheTTL - 1)) {
16
- data.content = `🚨 <@&${criticalRole}> 🚨`;
17
- }
18
- console.warn(`${firstUpperCaseName} query exceeded half of cache TTL: ${duration.toFixed(2)}s`);
19
- await fetch(webhookURL, {
20
- method: 'POST',
21
- headers: { 'Content-Type': 'application/json' },
22
- body: JSON.stringify(data)
23
- });
24
- }
25
- }
@@ -1,43 +0,0 @@
1
- export function getCookie(name: string): string | null {
2
- if (typeof document === 'undefined') return null
3
- const matches = document.cookie.match(
4
- new RegExp(
5
- '(?:^|; )' +
6
- name.replace(/([.$?*|{}()[\]/\\+^])/g, '\\$1') +
7
- '=([^;]*)'
8
- )
9
- )
10
- return matches ? decodeURIComponent(matches[1]) : null
11
- }
12
-
13
- export function setCookie(name: string, value: string, days?: number) {
14
- if (typeof document === 'undefined') return
15
- let expires = ''
16
-
17
- if (!value) {
18
- return
19
- }
20
-
21
- if (days) {
22
- const date = new Date()
23
- date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)
24
- expires = `expires=${date.toUTCString()};`
25
- }
26
-
27
- document.cookie =
28
- `${name}=${encodeURIComponent(value)}; ` +
29
- `${expires} path=/; SameSite=Lax`
30
- }
31
-
32
- export function removeCookie(name: string) {
33
- if (typeof document === 'undefined') return
34
- document.cookie =
35
- `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; ` +
36
- 'path=/; SameSite=Lax'
37
- }
38
-
39
- export function removeCookies(...cookies: string[]) {
40
- for (const cookie of cookies) {
41
- removeCookie(cookie)
42
- }
43
- }
@@ -1,44 +0,0 @@
1
- import { Data, DiscordAlertProps } from 'uibee/utils'
2
-
3
- export default async function discordAlert({
4
- application,
5
- description,
6
- type = '',
7
- ping = false,
8
- criticalRole,
9
- webhookURL
10
- }: DiscordAlertProps): Promise<number> {
11
- try {
12
- const data: Data = {
13
- embeds: [
14
- {
15
- title: `🐝 ${application} ${`${type.toUpperCase()} `}🐝`,
16
- description: description,
17
- color: 0xff0000,
18
- timestamp: new Date().toISOString()
19
- }
20
- ]
21
- }
22
-
23
- if (ping) {
24
- data.content = `🚨 <@&${criticalRole}> 🚨`
25
- }
26
-
27
- const response = await fetch(webhookURL ?? '', {
28
- method: 'POST',
29
- headers: {
30
- 'Content-Type': 'application/json'
31
- },
32
- body: JSON.stringify(data)
33
- })
34
-
35
- if (!response.ok) {
36
- throw new Error(await response.text())
37
- }
38
-
39
- return response.status
40
- } catch (error) {
41
- console.log(error)
42
- return 500
43
- }
44
- }
@@ -1,37 +0,0 @@
1
- import { Data, SlowQueryProps } from 'uibee/utils'
2
-
3
- export default async function alertSlowQuery({
4
- application,
5
- duration,
6
- name,
7
- cacheTTL,
8
- webhookURL,
9
- criticalRole
10
- }: SlowQueryProps): Promise<void> {
11
- const lowerCaseName = name.toLowerCase()
12
- const firstUpperCaseName = `${name.slice(0, 1).toUpperCase()}${name.slice(1).toLowerCase()}`
13
- if (duration > cacheTTL / 2 && webhookURL) {
14
- const data: Data = {
15
- embeds: [
16
- {
17
- title: `🐝 ${application} ${firstUpperCaseName} Query Timing 🐝`,
18
- description: `🐝 Slow ${lowerCaseName} query detected: ${duration.toFixed(2)}s`,
19
- color: 0xff0000,
20
- timestamp: new Date().toISOString()
21
- }
22
- ]
23
- }
24
-
25
- if (duration > (cacheTTL - 1)) {
26
- data.content = `🚨 <@&${criticalRole}> 🚨`
27
- }
28
-
29
- console.warn(`${firstUpperCaseName} query exceeded half of cache TTL: ${duration.toFixed(2)}s`)
30
-
31
- await fetch(webhookURL, {
32
- method: 'POST',
33
- headers: { 'Content-Type': 'application/json' },
34
- body: JSON.stringify(data)
35
- })
36
- }
37
- }