@hobenakicoffee/libraries 3.4.1 → 4.0.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/LICENSE +21 -0
- package/README.md +119 -246
- package/package.json +22 -22
- package/src/App.tsx +192 -19
- package/src/index.css +0 -1
- package/src/utils/get-product-link.ts +1 -1
- package/src/components/turnstile-captcha.tsx +0 -47
- package/src/components/ui/button.tsx +0 -77
- package/src/components/ui/calendar.tsx +0 -235
- package/src/components/ui/spinner.tsx +0 -18
- package/src/constants/common.test.ts +0 -33
- package/src/constants/legal.test.ts +0 -72
- package/src/constants/payment.test.ts +0 -259
- package/src/constants/platforms.test.ts +0 -66
- package/src/constants/services.test.ts +0 -58
- package/src/lib/utils.ts +0 -6
- package/src/moderation/profanity-service.test.ts +0 -106
- package/src/providers/theme-provider.tsx +0 -73
- package/src/utils/check-moderation.test.ts +0 -321
- package/src/utils/format-amount.test.ts +0 -30
- package/src/utils/format-count.test.ts +0 -56
- package/src/utils/format-date.test.ts +0 -19
- package/src/utils/format-number.test.ts +0 -29
- package/src/utils/format-plain-text.test.ts +0 -36
- package/src/utils/get-newsletter-post-link.test.ts +0 -27
- package/src/utils/get-product-link.test.ts +0 -36
- package/src/utils/get-social-handle.test.ts +0 -32
- package/src/utils/get-social-link.test.ts +0 -63
- package/src/utils/get-user-name-initials.test.ts +0 -34
- package/src/utils/get-user-page-link.test.ts +0 -9
- package/src/utils/open-to-new-window.test.ts +0 -34
- package/src/utils/post-to-facebook.test.ts +0 -43
- package/src/utils/post-to-instagram.test.ts +0 -56
- package/src/utils/post-to-linkedin.test.ts +0 -43
- package/src/utils/post-to-x.test.ts +0 -45
- package/src/utils/qr-svg-utils.test.ts +0 -104
- package/src/utils/to-human-readable.test.ts +0 -25
- package/src/utils/validate-phone-number.test.ts +0 -28
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 হবে নাকি Coffee?
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @hobenakicoffee/libraries
|
|
2
2
|
|
|
3
|
-
Framework-agnostic shared constants, utilities, types,
|
|
3
|
+
Framework-agnostic shared constants, utilities, types, and moderation tools for "হবে নাকি Coffee?" projects.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -19,7 +19,7 @@ bun add @hobenakicoffee/libraries
|
|
|
19
19
|
This package exposes multiple entry points:
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
|
-
// Main entry - constants
|
|
22
|
+
// Main entry - constants
|
|
23
23
|
import { PaymentStatuses, ServiceTypes, Visibility } from "@hobenakicoffee/libraries";
|
|
24
24
|
|
|
25
25
|
// Constants only
|
|
@@ -29,31 +29,29 @@ import { SupporterPlatforms } from "@hobenakicoffee/libraries/constants";
|
|
|
29
29
|
import { formatAmount, formatDate, getUserPageLink } from "@hobenakicoffee/libraries/utils";
|
|
30
30
|
|
|
31
31
|
// Types only
|
|
32
|
-
import
|
|
32
|
+
import { Database, Tables } from "@hobenakicoffee/libraries/types";
|
|
33
33
|
|
|
34
34
|
// Moderation tools
|
|
35
35
|
import { moderateText } from "@hobenakicoffee/libraries/moderation";
|
|
36
36
|
|
|
37
|
-
//
|
|
38
|
-
import {
|
|
39
|
-
import { ThemeProvider, useTheme } from "@hobenakicoffee/libraries/providers/theme-provider";
|
|
37
|
+
// URL state management
|
|
38
|
+
import { parseAsSortOrder } from "@hobenakicoffee/libraries/nuqs";
|
|
40
39
|
|
|
41
|
-
//
|
|
42
|
-
import {
|
|
40
|
+
// Scripts
|
|
41
|
+
import { checkEnvEncryption } from "@hobenakicoffee/libraries/scripts";
|
|
43
42
|
```
|
|
44
43
|
|
|
45
44
|
## Entry Points Overview
|
|
46
45
|
|
|
47
46
|
| Entrypoint | Description |
|
|
48
47
|
| ---------- | ----------- |
|
|
49
|
-
| `@hobenakicoffee/libraries` | Main entry - re-exports constants
|
|
50
|
-
| `@hobenakicoffee/libraries/constants` |
|
|
48
|
+
| `@hobenakicoffee/libraries` | Main entry - re-exports constants |
|
|
49
|
+
| `@hobenakicoffee/libraries/constants` | All constants |
|
|
51
50
|
| `@hobenakicoffee/libraries/utils` | Utility functions |
|
|
52
|
-
| `@hobenakicoffee/libraries/types` | TypeScript types (Supabase) |
|
|
51
|
+
| `@hobenakicoffee/libraries/types` | TypeScript types (custom + Supabase) |
|
|
53
52
|
| `@hobenakicoffee/libraries/moderation` | Content moderation tools |
|
|
54
|
-
| `@hobenakicoffee/libraries/
|
|
55
|
-
| `@hobenakicoffee/libraries/
|
|
56
|
-
| `@hobenakicoffee/libraries/components/ui/*` | UI components |
|
|
53
|
+
| `@hobenakicoffee/libraries/nuqs` | URL state management parsers |
|
|
54
|
+
| `@hobenakicoffee/libraries/scripts` | Build/utility scripts |
|
|
57
55
|
|
|
58
56
|
---
|
|
59
57
|
|
|
@@ -174,9 +172,9 @@ SupporterPlatforms.DISCORD // "discord"
|
|
|
174
172
|
SupporterPlatforms.REDDIT // "reddit"
|
|
175
173
|
SupporterPlatforms.PINTEREST // "pinterest"
|
|
176
174
|
SupporterPlatformS.MEDIUM // "medium"
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
SupporterPlatformS.DEVTO // "devto"
|
|
176
|
+
SupporterPlatformS.BEHANCE // "behance"
|
|
177
|
+
SupporterPlatformS.DRIBBBLE // "dribbble"
|
|
180
178
|
```
|
|
181
179
|
|
|
182
180
|
### Service Types
|
|
@@ -209,6 +207,18 @@ formatSignedAmount(1000, "credit"); // "+ ৳1,000"
|
|
|
209
207
|
formatSignedAmount(500, "debit"); // "- ৳500"
|
|
210
208
|
```
|
|
211
209
|
|
|
210
|
+
### formatCount
|
|
211
|
+
|
|
212
|
+
Formats a count with appropriate suffixes (K, M, B).
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
import { formatCount } from "@hobenakicoffee/libraries/utils";
|
|
216
|
+
|
|
217
|
+
formatCount(500); // "500"
|
|
218
|
+
formatCount(1000); // "1K"
|
|
219
|
+
formatCount(1500000); // "1.5M"
|
|
220
|
+
```
|
|
221
|
+
|
|
212
222
|
### formatDate
|
|
213
223
|
|
|
214
224
|
Formats a date string to a readable format.
|
|
@@ -268,6 +278,34 @@ getUserPageLink("johndoe", "https://custom.com");
|
|
|
268
278
|
// "https://custom.com/@johndoe"
|
|
269
279
|
```
|
|
270
280
|
|
|
281
|
+
### getProductLink
|
|
282
|
+
|
|
283
|
+
Generates a product page URL.
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
import { getProductLink } from "@hobenakicoffee/libraries/utils";
|
|
287
|
+
|
|
288
|
+
getProductLink("johndoe", "my-product");
|
|
289
|
+
// "https://hobenakicoffee.com/@johndoe/shop/products/my-product"
|
|
290
|
+
|
|
291
|
+
getProductLink("johndoe", "my-product", "https://custom.com");
|
|
292
|
+
// "https://custom.com/@johndoe/shop/products/my-product"
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### getNewsletterPostLink
|
|
296
|
+
|
|
297
|
+
Generates a newsletter post URL.
|
|
298
|
+
|
|
299
|
+
```ts
|
|
300
|
+
import { getNewsletterPostLink } from "@hobenakicoffee/libraries/utils";
|
|
301
|
+
|
|
302
|
+
getNewsletterPostLink("johndoe", "my-post");
|
|
303
|
+
// "/@johndoe/posts/my-post"
|
|
304
|
+
|
|
305
|
+
getNewsletterPostLink("johndoe", "my-post", "https://hobenakicoffee.com");
|
|
306
|
+
// "https://hobenakicoffee.com/@johndoe/posts/my-post"
|
|
307
|
+
```
|
|
308
|
+
|
|
271
309
|
### getUserNameInitials
|
|
272
310
|
|
|
273
311
|
Extracts initials from a name.
|
|
@@ -298,20 +336,16 @@ getSocialLink("johndoe", SupporterPlatforms.GITHUB);
|
|
|
298
336
|
// "https://github.com/johndoe"
|
|
299
337
|
```
|
|
300
338
|
|
|
301
|
-
###
|
|
339
|
+
### getSocialHandle
|
|
302
340
|
|
|
303
|
-
|
|
341
|
+
Extracts the handle/username from a social media URL.
|
|
304
342
|
|
|
305
343
|
```ts
|
|
306
|
-
import {
|
|
307
|
-
|
|
308
|
-
// With our platform username
|
|
309
|
-
getSocialUrl("johndoe");
|
|
310
|
-
// "https://hobenakicoffee.com/@johndoe"
|
|
344
|
+
import { getSocialHandle } from "@hobenakicoffee/libraries/utils";
|
|
311
345
|
|
|
312
|
-
//
|
|
313
|
-
|
|
314
|
-
// "
|
|
346
|
+
getSocialHandle("https://twitter.com/johndoe"); // "johndoe"
|
|
347
|
+
getSocialHandle("@johndoe"); // "johndoe"
|
|
348
|
+
getSocialHandle("johndoe"); // "johndoe"
|
|
315
349
|
```
|
|
316
350
|
|
|
317
351
|
### openInNewWindow
|
|
@@ -468,12 +502,12 @@ normalizeUnicode("café"); // "cafe"
|
|
|
468
502
|
|
|
469
503
|
### banglaBadWords
|
|
470
504
|
|
|
471
|
-
Array of Bangla profanity words
|
|
505
|
+
Array of Bangla profanity words for content moderation.
|
|
472
506
|
|
|
473
507
|
```ts
|
|
474
508
|
import { banglaBadWords } from "@hobenakicoffee/libraries/moderation";
|
|
475
509
|
|
|
476
|
-
console.log(banglaBadWords.length); //
|
|
510
|
+
console.log(banglaBadWords.length); // word count
|
|
477
511
|
```
|
|
478
512
|
|
|
479
513
|
---
|
|
@@ -505,185 +539,61 @@ type PaymentStatus = Enums<"payment_status_enum">;
|
|
|
505
539
|
type SupporterPlatform = Enums<"supporter_platform_enum">;
|
|
506
540
|
```
|
|
507
541
|
|
|
508
|
-
###
|
|
509
|
-
|
|
510
|
-
- `activities` - User activity tracking
|
|
511
|
-
- `coffee_gifts` - Coffee gift transactions
|
|
512
|
-
- `conversation_participants` - Chat participants
|
|
513
|
-
- `conversations` - Chat conversations
|
|
514
|
-
- `follows` - User follow relationships
|
|
515
|
-
- `manager_role_permissions` - Manager role permissions
|
|
516
|
-
- `manager_user_roles` - Manager user role assignments
|
|
517
|
-
- `managers` - Manager profiles
|
|
518
|
-
- `messages` - Chat messages
|
|
519
|
-
- `messages_*` - Monthly partitioned message tables
|
|
520
|
-
- `payout_methods` - User payout methods
|
|
521
|
-
- `profiles` - User profiles
|
|
522
|
-
- `supporters` - Supporter records
|
|
523
|
-
- `transactions` - Payment transactions
|
|
524
|
-
- `wallets` - User wallets
|
|
525
|
-
- `withdrawal_requests` - Withdrawal requests
|
|
526
|
-
|
|
527
|
-
### Database Enums
|
|
528
|
-
|
|
529
|
-
- `manager_permission` - Manager permissions
|
|
530
|
-
- `manager_role` - Manager roles (super_admin, content_manager, etc.)
|
|
531
|
-
- `manager_status` - Manager account status
|
|
532
|
-
- `payment_status_enum` - Payment statuses
|
|
533
|
-
- `payout_provider` - Payout provider types
|
|
534
|
-
- `provider_enum` - Payment providers
|
|
535
|
-
- `reference_type_enum` - Transaction reference types
|
|
536
|
-
- `supporter_platform_enum` - Supporter platform types
|
|
537
|
-
- `transaction_direction_enum` - Debit/credit
|
|
538
|
-
- `user_role` - User roles
|
|
539
|
-
- `visibility_enum` - Public/private visibility
|
|
540
|
-
- `withdrawal_status` - Withdrawal request statuses
|
|
542
|
+
### Custom Types
|
|
541
543
|
|
|
542
|
-
|
|
544
|
+
The library also exports custom types for common data structures:
|
|
543
545
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
The library includes 30+ accessible UI components built on Radix UI.
|
|
547
|
-
|
|
548
|
-
### Importing Components
|
|
549
|
-
|
|
550
|
-
```ts
|
|
551
|
-
// Individual imports (recommended for tree-shaking)
|
|
552
|
-
import { Button } from "@hobenakicoffee/libraries/components/ui/button";
|
|
553
|
-
import { Card } from "@hobenakicoffee/libraries/components/ui/card";
|
|
554
|
-
import { Dialog } from "@hobenakicoffee/libraries/components/ui/dialog";
|
|
555
|
-
import { Input } from "@hobenakicoffee/libraries/components/ui/input";
|
|
556
|
-
|
|
557
|
-
// All components available:
|
|
558
|
-
import { Alert } from "@hobenakicoffee/libraries/components/ui/alert";
|
|
559
|
-
import { AlertDialog } from "@hobenakicoffee/libraries/components/ui/alert-dialog";
|
|
560
|
-
import { Avatar } from "@hobenakicoffee/libraries/components/ui/avatar";
|
|
561
|
-
import { Badge } from "@hobenakicoffee/libraries/components/ui/badge";
|
|
562
|
-
import { Breadcrumb } from "@hobenakicoffee/libraries/components/ui/breadcrumb";
|
|
563
|
-
import { Button, ButtonGroup } from "@hobenakicoffee/libraries/components/ui/button";
|
|
564
|
-
import { Calendar } from "@hobenakicoffee/libraries/components/ui/calendar";
|
|
565
|
-
import { Card, Chart } from "@hobenakicoffee/libraries/components/ui/card";
|
|
566
|
-
import { Checkbox } from "@hobenakicoffee/libraries/components/ui/checkbox";
|
|
567
|
-
import { Dialog } from "@hobenakicoffee/libraries/components/ui/dialog";
|
|
568
|
-
import { Drawer } from "@hobenakicoffee/libraries/components/ui/drawer";
|
|
569
|
-
import { DropdownMenu } from "@hobenakicoffee/libraries/components/ui/dropdown-menu";
|
|
570
|
-
import { Empty, EmptyMinimal } from "@hobenakicoffee/libraries/components/ui/empty";
|
|
571
|
-
import { Field, Input, InputGroup, InputOtp } from "@hobenakicoffee/libraries/components/ui/input";
|
|
572
|
-
import { Item } from "@hobenakicoffee/libraries/components/ui/item";
|
|
573
|
-
import { Label } from "@hobenakicoffee/libraries/components/ui/label";
|
|
574
|
-
import { Popover } from "@hobenakicoffee/libraries/components/ui/popover";
|
|
575
|
-
import { RadioGroup } from "@hobenakicoffee/libraries/components/ui/radio-group";
|
|
576
|
-
import { Select } from "@hobenakicoffee/libraries/components/ui/select";
|
|
577
|
-
import { Separator } from "@hobenakicoffee/libraries/components/ui/separator";
|
|
578
|
-
import { Sheet } from "@hobenakicoffee/libraries/components/ui/sheet";
|
|
579
|
-
import { Sidebar } from "@hobenakicoffee/libraries/components/ui/sidebar";
|
|
580
|
-
import { Skeleton } from "@hobenakicoffee/libraries/components/ui/skeleton";
|
|
581
|
-
import { Sonner } from "@hobenakicoffee/libraries/components/ui/sonner";
|
|
582
|
-
import { Spinner } from "@hobenakicoffee/libraries/components/ui/spinner";
|
|
583
|
-
import { Table } from "@hobenakicoffee/libraries/components/ui/table";
|
|
584
|
-
import { Tabs } from "@hobenakicoffee/libraries/components/ui/tabs";
|
|
585
|
-
import { Textarea } from "@hobenakicoffee/libraries/components/ui/textarea";
|
|
586
|
-
import { Toggle, ToggleGroup } from "@hobenakicoffee/libraries/components/ui/toggle";
|
|
587
|
-
import { Tooltip } from "@hobenakicoffee/libraries/components/ui/tooltip";
|
|
588
|
-
```
|
|
589
|
-
|
|
590
|
-
### Component Variants
|
|
591
|
-
|
|
592
|
-
Components use `cva` (class-variance-authority) for variants:
|
|
593
|
-
|
|
594
|
-
```ts
|
|
595
|
-
import { Button } from "@hobenakicoffee/libraries/components/ui/button";
|
|
596
|
-
import { Badge } from "@hobenakicoffee/libraries/components/ui/badge";
|
|
597
|
-
|
|
598
|
-
// Button variants
|
|
599
|
-
<Button variant="default" />
|
|
600
|
-
<Button variant="destructive" />
|
|
601
|
-
<Button variant="outline" />
|
|
602
|
-
<Button variant="secondary" />
|
|
603
|
-
<Button variant="ghost" />
|
|
604
|
-
<Button variant="link" />
|
|
605
|
-
|
|
606
|
-
// Button sizes
|
|
607
|
-
<Button size="default" />
|
|
608
|
-
<Button size="sm" />
|
|
609
|
-
<Button size="lg" />
|
|
610
|
-
<Button size="icon" />
|
|
611
|
-
|
|
612
|
-
// Badge variants
|
|
613
|
-
<Badge variant="default" />
|
|
614
|
-
<Badge variant="secondary" />
|
|
615
|
-
<Badge variant="destructive" />
|
|
616
|
-
<Badge variant="outline" />
|
|
617
|
-
```
|
|
618
|
-
|
|
619
|
-
### Turnstile Captcha
|
|
620
|
-
|
|
621
|
-
```ts
|
|
622
|
-
import { TurnstileCaptcha } from "@hobenakicoffee/libraries/components/turnstile-captcha";
|
|
623
|
-
|
|
624
|
-
<TurnstileCaptcha
|
|
625
|
-
siteKey="your-site-key"
|
|
626
|
-
onSuccess={(token) => console.log(token)}
|
|
627
|
-
onError={() => console.error("Error")}
|
|
628
|
-
theme="auto"
|
|
629
|
-
/>
|
|
546
|
+
```ts
|
|
547
|
+
import type { TransactionMetadata, ActivityMetadata, SupportersMetadata } from "@hobenakicoffee/libraries/types";
|
|
630
548
|
```
|
|
631
549
|
|
|
632
550
|
---
|
|
633
551
|
|
|
634
|
-
##
|
|
552
|
+
## Nuqs (`@hobenakicoffee/libraries/nuqs`)
|
|
635
553
|
|
|
636
|
-
|
|
554
|
+
URL state management parsers using nuqs and zod.
|
|
637
555
|
|
|
638
|
-
```
|
|
639
|
-
import {
|
|
556
|
+
```ts
|
|
557
|
+
import { parseAsSortOrder, parseAsDateRange, parseAsLastTimeRange } from "@hobenakicoffee/libraries/nuqs";
|
|
640
558
|
|
|
641
|
-
//
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
<ThemeProvider defaultTheme="system" storageKey="my-app-theme">
|
|
645
|
-
{children}
|
|
646
|
-
</ThemeProvider>
|
|
647
|
-
);
|
|
648
|
-
}
|
|
559
|
+
// Sort order
|
|
560
|
+
parseAsSortOrder.parse("asc"); // "asc"
|
|
561
|
+
parseAsSortOrder.parse("invalid"); // throws
|
|
649
562
|
|
|
650
|
-
//
|
|
651
|
-
|
|
652
|
-
const { theme, setTheme } = useTheme();
|
|
563
|
+
// Date range
|
|
564
|
+
parseAsDateRange.parse({ from: new Date(), to: new Date() });
|
|
653
565
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
566
|
+
// Last time range
|
|
567
|
+
parseAsLastTimeRange.parse("last_7_days");
|
|
568
|
+
parseAsLastTimeRange.parse("last_30_days");
|
|
569
|
+
parseAsLastTimeRange.parse("last_90_days");
|
|
570
|
+
parseAsLastTimeRange.parse("last_180_days");
|
|
571
|
+
parseAsLastTimeRange.parse("last_year");
|
|
660
572
|
```
|
|
661
573
|
|
|
662
|
-
Props:
|
|
663
|
-
- `children` - React nodes
|
|
664
|
-
- `defaultTheme` - "light" | "dark" | "system" (default: "system")
|
|
665
|
-
- `storageKey` - localStorage key (default: "hobenakicoffee-app-ui-themes")
|
|
666
|
-
|
|
667
574
|
---
|
|
668
575
|
|
|
669
|
-
##
|
|
576
|
+
## Hooks
|
|
670
577
|
|
|
671
|
-
###
|
|
578
|
+
### useIsMobile
|
|
672
579
|
|
|
673
|
-
|
|
580
|
+
React hook to detect if the viewport is mobile-sized.
|
|
674
581
|
|
|
675
582
|
```ts
|
|
676
|
-
import {
|
|
583
|
+
import { useIsMobile } from "@hobenakicoffee/libraries/hooks";
|
|
677
584
|
|
|
678
|
-
|
|
679
|
-
|
|
585
|
+
function MyComponent() {
|
|
586
|
+
const isMobile = useIsMobile();
|
|
587
|
+
|
|
588
|
+
return <div>{isMobile ? "Mobile" : "Desktop"}</div>;
|
|
589
|
+
}
|
|
680
590
|
```
|
|
681
591
|
|
|
682
592
|
---
|
|
683
593
|
|
|
684
594
|
## API Reference
|
|
685
595
|
|
|
686
|
-
### Constants
|
|
596
|
+
### Constants
|
|
687
597
|
|
|
688
598
|
| Export | Type | Description |
|
|
689
599
|
|--------|------|-------------|
|
|
@@ -714,14 +624,17 @@ cn("px-2 py-1", "bg-red-500", condition && "text-white");
|
|
|
714
624
|
|----------|-------------|
|
|
715
625
|
| `formatAmount` | Format number as ৳ currency |
|
|
716
626
|
| `formatSignedAmount` | Format with + or - sign |
|
|
627
|
+
| `formatCount` | Format count with K, M, B suffixes |
|
|
717
628
|
| `formatDate` | Format date string |
|
|
718
629
|
| `formatNumber` | Format with thousand separators |
|
|
719
630
|
| `formatToPlainText` | Convert value to plain text |
|
|
720
631
|
| `formatMetadataKey` | Format metadata key to readable text |
|
|
721
632
|
| `getUserPageLink` | Generate user profile URL |
|
|
633
|
+
| `getProductLink` | Generate product page URL |
|
|
634
|
+
| `getNewsletterPostLink` | Generate newsletter post URL |
|
|
722
635
|
| `getInitials` | Get name initials |
|
|
723
636
|
| `getSocialLink` | Generate social profile URL |
|
|
724
|
-
| `
|
|
637
|
+
| `getSocialHandle` | Extract handle from social URL |
|
|
725
638
|
| `openInNewWindow` | Open URL in new tab |
|
|
726
639
|
| `shareToFacebook` | Share to Facebook |
|
|
727
640
|
| `shareToInstagram` | Share to Instagram |
|
|
@@ -738,7 +651,6 @@ cn("px-2 py-1", "bg-red-500", condition && "text-white");
|
|
|
738
651
|
| Function | Description |
|
|
739
652
|
|----------|-------------|
|
|
740
653
|
| `moderateText` | Check text for profanity |
|
|
741
|
-
| `checkBanglaWords` | Check for Bangla bad words |
|
|
742
654
|
| `normalizeLeetspeak` | Convert leetspeak to normal |
|
|
743
655
|
| `normalizeUnicode` | Remove Unicode diacritics |
|
|
744
656
|
| `banglaBadWords` | Bangla profanity word list |
|
|
@@ -780,6 +692,9 @@ bun run format
|
|
|
780
692
|
# Check formatting
|
|
781
693
|
bun run format:check
|
|
782
694
|
|
|
695
|
+
# Check formatting issues
|
|
696
|
+
bun run format:doctor
|
|
697
|
+
|
|
783
698
|
# Clean build artifacts
|
|
784
699
|
bun run clean
|
|
785
700
|
```
|
|
@@ -790,7 +705,7 @@ bun run clean
|
|
|
790
705
|
|
|
791
706
|
```
|
|
792
707
|
src/
|
|
793
|
-
├── index.ts # Main entry
|
|
708
|
+
├── index.ts # Main entry (re-exports constants)
|
|
794
709
|
├── constants/
|
|
795
710
|
│ ├── common.ts # Visibility
|
|
796
711
|
│ ├── legal.ts # productInfo, companyInfo
|
|
@@ -801,9 +716,12 @@ src/
|
|
|
801
716
|
├── utils/
|
|
802
717
|
│ ├── check-moderation.ts
|
|
803
718
|
│ ├── format-amount.ts
|
|
719
|
+
│ ├── format-count.ts
|
|
804
720
|
│ ├── format-date.ts
|
|
805
721
|
│ ├── format-number.ts
|
|
806
722
|
│ ├── format-plain-text.ts
|
|
723
|
+
│ ├── get-newsletter-post-link.ts
|
|
724
|
+
│ ├── get-product-link.ts
|
|
807
725
|
│ ├── get-social-handle.ts
|
|
808
726
|
│ ├── get-social-link.ts
|
|
809
727
|
│ ├── get-user-name-initials.ts
|
|
@@ -819,58 +737,22 @@ src/
|
|
|
819
737
|
│ └── index.ts # Exports
|
|
820
738
|
├── moderation/
|
|
821
739
|
│ ├── datasets/
|
|
822
|
-
│ │ ├── bn.ts # Bangla bad words
|
|
740
|
+
│ │ ├── bn.ts # Bangla bad words
|
|
823
741
|
│ │ └── index.ts
|
|
824
|
-
│ ├── normalizer.ts
|
|
825
742
|
│ ├── profanity-service.ts
|
|
743
|
+
│ ├── normalizer.ts
|
|
826
744
|
│ └── index.ts # Exports
|
|
827
745
|
├── types/
|
|
828
746
|
│ ├── supabase.ts # Full Supabase types
|
|
829
|
-
│ └── index.ts
|
|
830
|
-
├──
|
|
831
|
-
│
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
└──
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
├── alert-dialog.tsx
|
|
839
|
-
├── avatar.tsx
|
|
840
|
-
├── badge.tsx
|
|
841
|
-
├── breadcrumb.tsx
|
|
842
|
-
├── button.tsx
|
|
843
|
-
├── button-group.tsx
|
|
844
|
-
├── calendar.tsx
|
|
845
|
-
├── card.tsx
|
|
846
|
-
├── chart.tsx
|
|
847
|
-
├── checkbox.tsx
|
|
848
|
-
├── dialog.tsx
|
|
849
|
-
├── drawer.tsx
|
|
850
|
-
├── dropdown-menu.tsx
|
|
851
|
-
├── empty.tsx
|
|
852
|
-
├── empty-minimal.tsx
|
|
853
|
-
├── field.tsx
|
|
854
|
-
├── input.tsx
|
|
855
|
-
├── input-group.tsx
|
|
856
|
-
├── input-otp.tsx
|
|
857
|
-
├── item.tsx
|
|
858
|
-
├── label.tsx
|
|
859
|
-
├── popover.tsx
|
|
860
|
-
├── radio-group.tsx
|
|
861
|
-
├── select.tsx
|
|
862
|
-
├── separator.tsx
|
|
863
|
-
├── sheet.tsx
|
|
864
|
-
├── sidebar.tsx
|
|
865
|
-
├── skeleton.tsx
|
|
866
|
-
├── sonner.tsx
|
|
867
|
-
├── spinner.tsx
|
|
868
|
-
├── table.tsx
|
|
869
|
-
├── tabs.tsx
|
|
870
|
-
├── textarea.tsx
|
|
871
|
-
├── toggle.tsx
|
|
872
|
-
├── toggle-group.tsx
|
|
873
|
-
└── tooltip.tsx
|
|
747
|
+
│ └── index.ts # Exports + custom types
|
|
748
|
+
├── nuqs/
|
|
749
|
+
│ ├── common.ts # URL state parsers
|
|
750
|
+
│ └── index.ts # Exports
|
|
751
|
+
├── hooks/
|
|
752
|
+
│ └── use-mobile.ts # Mobile detection hook
|
|
753
|
+
└── scripts/
|
|
754
|
+
├── check-env-encryption.ts
|
|
755
|
+
└── index.ts # Exports
|
|
874
756
|
```
|
|
875
757
|
|
|
876
758
|
---
|
|
@@ -880,25 +762,16 @@ src/
|
|
|
880
762
|
### Runtime
|
|
881
763
|
|
|
882
764
|
- `@fontsource-variable/noto-sans-bengali` - Bengali font
|
|
883
|
-
- `@hugeicons/core-free-icons` - Hugeicons
|
|
884
|
-
- `@hugeicons/react` - React icons
|
|
885
|
-
- `@marsidev/react-turnstile` - Turnstile captcha
|
|
886
|
-
- `@tailwindcss/vite` - Tailwind CSS
|
|
887
765
|
- `class-variance-authority` - Component variants
|
|
888
|
-
- `
|
|
889
|
-
- `
|
|
890
|
-
- `
|
|
766
|
+
- `clsx` - Class name utility
|
|
767
|
+
- `nuqs` - URL state management
|
|
768
|
+
- `obscenity` - Profanity detection
|
|
891
769
|
- `openai` - OpenAI API
|
|
892
|
-
- `radix-ui` - UI primitives
|
|
893
770
|
- `react` / `react-dom` - React
|
|
894
|
-
- `react-day-picker` - Calendar
|
|
895
|
-
- `recharts` - Charts
|
|
896
|
-
- `shadcn` - UI components
|
|
897
|
-
- `sonner` - Toast notifications
|
|
898
771
|
- `tailwind-merge` - Tailwind merge
|
|
899
772
|
- `tailwindcss` - Styling
|
|
900
773
|
- `tw-animate-css` - Animations
|
|
901
|
-
- `
|
|
774
|
+
- `zod` - Schema validation
|
|
902
775
|
|
|
903
776
|
### Dev
|
|
904
777
|
|
|
@@ -919,4 +792,4 @@ For local publish (if needed):
|
|
|
919
792
|
|
|
920
793
|
```bash
|
|
921
794
|
npm publish --access public
|
|
922
|
-
```
|
|
795
|
+
```
|
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hobenakicoffee/libraries",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "src/index.ts",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/hobenakicoffee/libraries"
|
|
9
|
+
},
|
|
6
10
|
"exports": {
|
|
7
11
|
".": "./src/index.ts",
|
|
8
|
-
"./components/turnstile-captcha": "./src/components/turnstile-captcha.tsx",
|
|
9
12
|
"./constants": "./src/constants/index.ts",
|
|
10
13
|
"./lib/utils": "./src/lib/utils.ts",
|
|
11
14
|
"./moderation": "./src/moderation/index.ts",
|
|
12
|
-
"./providers/theme-provider": "./src/providers/theme-provider.tsx",
|
|
13
15
|
"./types": "./src/types/index.ts",
|
|
14
16
|
"./utils": "./src/utils/index.ts",
|
|
15
17
|
"./nuqs": "./src/nuqs/index.ts",
|
|
@@ -17,13 +19,20 @@
|
|
|
17
19
|
},
|
|
18
20
|
"files": [
|
|
19
21
|
"src",
|
|
22
|
+
"!src/**/*.test.ts",
|
|
23
|
+
"!src/**/*.spec.ts",
|
|
20
24
|
"README.md",
|
|
21
25
|
"package.json"
|
|
22
26
|
],
|
|
23
27
|
"scripts": {
|
|
24
28
|
"dev": "vite",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
29
|
+
"dev:docs": "vitepress dev",
|
|
30
|
+
"build:app": "tsc -b && vite build",
|
|
31
|
+
"build:docs": "vitepress build",
|
|
32
|
+
"build": "bun run build:app && bun run build:docs && cp -r .vitepress/dist dist/docs",
|
|
33
|
+
"preview:app": "vite preview",
|
|
34
|
+
"preview:docs": "vitepress preview --port 8080",
|
|
35
|
+
"preview": "bun run preview:app",
|
|
27
36
|
"test": "bun test",
|
|
28
37
|
"test:watch": "bun test --watch",
|
|
29
38
|
"typecheck": "tsc --noEmit",
|
|
@@ -44,10 +53,11 @@
|
|
|
44
53
|
"@types/react": "^19.2.14",
|
|
45
54
|
"@types/react-dom": "^19.2.3",
|
|
46
55
|
"@vitejs/plugin-react": "^5.1.4",
|
|
47
|
-
"lefthook": "^2.1.
|
|
56
|
+
"lefthook": "^2.1.6",
|
|
48
57
|
"ultracite": "7.2.3",
|
|
49
58
|
"vite": "^7.3.1",
|
|
50
|
-
"vite-tsconfig-paths": "^6.1.1"
|
|
59
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
60
|
+
"vitepress": "^2.0.0-alpha.17"
|
|
51
61
|
},
|
|
52
62
|
"peerDependencies": {
|
|
53
63
|
"typescript": "^5.9.3"
|
|
@@ -57,29 +67,19 @@
|
|
|
57
67
|
},
|
|
58
68
|
"dependencies": {
|
|
59
69
|
"@fontsource-variable/noto-sans-bengali": "^5.2.11",
|
|
60
|
-
"@
|
|
61
|
-
"@hugeicons/react": "^1.1.5",
|
|
62
|
-
"@marsidev/react-turnstile": "^1.4.2",
|
|
63
|
-
"@tailwindcss/vite": "^4.2.1",
|
|
70
|
+
"@tailwindcss/vite": "^4.2.4",
|
|
64
71
|
"class-variance-authority": "^0.7.1",
|
|
65
72
|
"clsx": "^2.1.1",
|
|
66
|
-
"input-otp": "^1.4.2",
|
|
67
73
|
"install": "^0.13.0",
|
|
68
|
-
"next-themes": "^0.4.6",
|
|
69
74
|
"nuqs": "^2.8.9",
|
|
70
75
|
"obscenity": "^0.4.6",
|
|
71
|
-
"openai": "^6.
|
|
72
|
-
"
|
|
73
|
-
"react": "^19.2.
|
|
74
|
-
"react-day-picker": "^9.13.2",
|
|
75
|
-
"react-dom": "^19.2.4",
|
|
76
|
-
"recharts": "^2.15.4",
|
|
77
|
-
"shadcn": "^3.8.5",
|
|
76
|
+
"openai": "^6.34.0",
|
|
77
|
+
"react": "^19.2.5",
|
|
78
|
+
"react-dom": "^19.2.5",
|
|
78
79
|
"sonner": "^2.0.7",
|
|
79
80
|
"tailwind-merge": "^3.5.0",
|
|
80
|
-
"tailwindcss": "^4.2.
|
|
81
|
+
"tailwindcss": "^4.2.4",
|
|
81
82
|
"tw-animate-css": "^1.4.0",
|
|
82
|
-
"vaul": "^1.1.2",
|
|
83
83
|
"zod": "^4.3.6"
|
|
84
84
|
}
|
|
85
85
|
}
|