@hobenakicoffee/libraries 1.11.0 → 1.13.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.
- package/README.md +25 -4
- package/package.json +84 -9
- package/src/App.tsx +28 -0
- package/src/components/turnstile-captcha.tsx +47 -0
- package/src/components/ui/alert-dialog.tsx +196 -0
- package/src/components/ui/alert.tsx +76 -0
- package/src/components/ui/avatar.tsx +110 -0
- package/src/components/ui/badge.tsx +49 -0
- package/src/components/ui/breadcrumb.tsx +122 -0
- package/src/components/ui/button-group.tsx +82 -0
- package/src/components/ui/button.tsx +77 -0
- package/src/components/ui/calendar.tsx +235 -0
- package/src/components/ui/card.tsx +100 -0
- package/src/components/ui/chart.tsx +364 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/dialog.tsx +162 -0
- package/src/components/ui/drawer.tsx +126 -0
- package/src/components/ui/dropdown-menu.tsx +267 -0
- package/src/components/ui/empty-minimal.tsx +20 -0
- package/src/components/ui/empty.tsx +101 -0
- package/src/components/ui/field.tsx +235 -0
- package/src/components/ui/input-group.tsx +170 -0
- package/src/components/ui/input-otp.tsx +84 -0
- package/src/components/ui/input.tsx +37 -0
- package/src/components/ui/item.tsx +196 -0
- package/src/components/ui/label.tsx +19 -0
- package/src/components/ui/popover.tsx +87 -0
- package/src/components/ui/radio-group.tsx +47 -0
- package/src/components/ui/select.tsx +205 -0
- package/src/components/ui/separator.tsx +26 -0
- package/src/components/ui/sheet.tsx +141 -0
- package/src/components/ui/sidebar.tsx +699 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/sonner.tsx +74 -0
- package/src/components/ui/spinner.tsx +18 -0
- package/src/components/ui/table.tsx +114 -0
- package/src/components/ui/tabs.tsx +88 -0
- package/src/components/ui/textarea.tsx +35 -0
- package/src/components/ui/toggle-group.tsx +91 -0
- package/src/components/ui/toggle.tsx +44 -0
- package/src/components/ui/tooltip.tsx +59 -0
- package/src/constants/common.test.ts +1 -1
- package/src/constants/legal.test.ts +1 -1
- package/src/constants/payment.test.ts +9 -9
- package/src/constants/platforms.test.ts +1 -1
- package/src/constants/services.test.ts +1 -1
- package/src/hooks/use-mobile.ts +19 -0
- package/src/index.css +135 -0
- package/src/lib/utils.ts +6 -0
- package/src/main.tsx +16 -0
- package/src/moderation/datasets/bn.ts +708 -708
- package/src/moderation/normalizer.test.ts +1 -1
- package/src/moderation/normalizer.ts +16 -16
- package/src/moderation/profanity-service.test.ts +3 -3
- package/src/providers/theme-provider.tsx +73 -0
- package/src/types/supabase.ts +751 -647
- package/src/utils/check-moderation.test.ts +12 -12
- package/src/utils/format-number.test.ts +1 -1
- package/src/utils/format-plain-text.test.ts +1 -1
- package/src/utils/get-social-handle.test.ts +3 -3
- package/src/utils/get-social-link.test.ts +9 -9
- package/src/utils/get-social-link.ts +5 -3
- package/src/utils/get-user-name-initials.test.ts +1 -1
- package/src/utils/get-user-name-initials.ts +4 -4
- package/src/utils/get-user-page-link.ts +1 -1
- package/src/utils/index.ts +5 -5
- package/src/utils/open-to-new-window.ts +3 -1
- package/src/utils/post-to-facebook.test.ts +1 -1
- package/src/utils/post-to-facebook.ts +9 -3
- package/src/utils/post-to-instagram.test.ts +1 -1
- package/src/utils/post-to-linkedin.test.ts +1 -1
- package/src/utils/post-to-linkedin.ts +9 -3
- package/src/utils/post-to-x.test.ts +1 -1
- package/src/utils/post-to-x.ts +12 -4
- package/src/utils/to-human-readable.ts +6 -2
- package/src/utils/validate-phone-number.test.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { normalizeLeetspeak, normalizeUnicode
|
|
2
|
+
import { compact, normalizeLeetspeak, normalizeUnicode } from "./normalizer";
|
|
3
3
|
|
|
4
4
|
describe("normalizeLeetspeak", () => {
|
|
5
5
|
test("converts number 0 to letter o", () => {
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
export function normalizeLeetspeak(text: string): string {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
const map: Record<string, string> = {
|
|
3
|
+
"0": "o",
|
|
4
|
+
"1": "i",
|
|
5
|
+
"3": "e",
|
|
6
|
+
"4": "a",
|
|
7
|
+
"5": "s",
|
|
8
|
+
"7": "t",
|
|
9
|
+
"@": "a",
|
|
10
|
+
$: "s",
|
|
11
|
+
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
return text
|
|
14
|
+
.split("")
|
|
15
|
+
.map((c) => map[c] ?? c)
|
|
16
|
+
.join("");
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export function normalizeUnicode(text: string): string {
|
|
20
|
-
|
|
20
|
+
return text.normalize("NFKD").replace(/[\u0300-\u036f]/g, "");
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function compact(text: string): string {
|
|
24
|
-
|
|
24
|
+
return text.replace(/[\s\W_]+/g, "");
|
|
25
25
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { describe, expect,
|
|
1
|
+
import { describe, expect, mock, test } from "bun:test";
|
|
2
2
|
import { checkBanglaWords, moderateText } from "./profanity-service";
|
|
3
3
|
|
|
4
4
|
// Mock the glin-profanity module
|
|
5
5
|
mock.module("glin-profanity", () => ({
|
|
6
|
-
checkProfanity: (text: string
|
|
6
|
+
checkProfanity: (text: string) => {
|
|
7
7
|
// Simple mock that detects common profane words
|
|
8
8
|
const profaneWords = ["badword", "profanity", "curse"];
|
|
9
9
|
const foundWords = profaneWords.filter((word) => text.includes(word));
|
|
@@ -142,7 +142,7 @@ describe("moderateText", () => {
|
|
|
142
142
|
});
|
|
143
143
|
|
|
144
144
|
test("handles very long text", () => {
|
|
145
|
-
const longText =
|
|
145
|
+
const longText = `clean text ${"word ".repeat(1000)}`;
|
|
146
146
|
const result = moderateText(longText);
|
|
147
147
|
expect(result).toHaveProperty("isAllowed");
|
|
148
148
|
expect(result).toHaveProperty("matched");
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
type Theme = "dark" | "light" | "system";
|
|
4
|
+
|
|
5
|
+
type ThemeProviderProps = {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
defaultTheme?: Theme;
|
|
8
|
+
storageKey?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type ThemeProviderState = {
|
|
12
|
+
theme: Theme;
|
|
13
|
+
setTheme: (theme: Theme) => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const initialState: ThemeProviderState = {
|
|
17
|
+
theme: "system",
|
|
18
|
+
setTheme: () => null,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const ThemeProviderContext = createContext<ThemeProviderState>(initialState);
|
|
22
|
+
|
|
23
|
+
export function ThemeProvider({
|
|
24
|
+
children,
|
|
25
|
+
defaultTheme = "system",
|
|
26
|
+
storageKey = "hobenakicoffee-app-ui-themes",
|
|
27
|
+
...props
|
|
28
|
+
}: ThemeProviderProps) {
|
|
29
|
+
const [theme, setTheme] = useState<Theme>(
|
|
30
|
+
() => (localStorage.getItem(storageKey) as Theme) || defaultTheme
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const root = window.document.documentElement;
|
|
35
|
+
|
|
36
|
+
root.classList.remove("light", "dark");
|
|
37
|
+
|
|
38
|
+
if (theme === "system") {
|
|
39
|
+
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)")
|
|
40
|
+
.matches
|
|
41
|
+
? "dark"
|
|
42
|
+
: "light";
|
|
43
|
+
|
|
44
|
+
root.classList.add(systemTheme);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
root.classList.add(theme);
|
|
49
|
+
}, [theme]);
|
|
50
|
+
|
|
51
|
+
const value = {
|
|
52
|
+
theme,
|
|
53
|
+
setTheme: (theme: Theme) => {
|
|
54
|
+
localStorage.setItem(storageKey, theme);
|
|
55
|
+
setTheme(theme);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<ThemeProviderContext.Provider {...props} value={value}>
|
|
61
|
+
{children}
|
|
62
|
+
</ThemeProviderContext.Provider>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const useTheme = () => {
|
|
67
|
+
const context = useContext(ThemeProviderContext);
|
|
68
|
+
|
|
69
|
+
if (context === undefined)
|
|
70
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
71
|
+
|
|
72
|
+
return context;
|
|
73
|
+
};
|