@catalystsoftware/ui 1.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.
Files changed (157) hide show
  1. package/README.md +7 -0
  2. package/components/catalyst-ui/buttons/burger.tsx +207 -0
  3. package/components/catalyst-ui/core/data-display/timeline.tsx +210 -0
  4. package/components/catalyst-ui/core/feedback/alert.tsx +491 -0
  5. package/components/catalyst-ui/core/feedback/spinner-1.tsx +65 -0
  6. package/components/catalyst-ui/core/feedback/toast.tsx +1857 -0
  7. package/components/catalyst-ui/core/navigation/menu.tsx +164 -0
  8. package/components/catalyst-ui/forms/toggle-class.tsx +176 -0
  9. package/components/catalyst-ui/hooks/use-copy-to-clipboard.tsx +419 -0
  10. package/components/catalyst-ui/hooks/use-counter.tsx +13 -0
  11. package/components/catalyst-ui/hooks/use-event-listener.tsx +23 -0
  12. package/components/catalyst-ui/hooks/use-export-markdown.tsx +47 -0
  13. package/components/catalyst-ui/hooks/use-focus.tsx +17 -0
  14. package/components/catalyst-ui/hooks/use-interval.tsx +23 -0
  15. package/components/catalyst-ui/hooks/use-is-client.tsx +16 -0
  16. package/components/catalyst-ui/hooks/use-media-query.tsx +19 -0
  17. package/components/catalyst-ui/hooks/use-mobile.tsx +19 -0
  18. package/components/catalyst-ui/hooks/use-resize-observer.tsx +81 -0
  19. package/components/catalyst-ui/hooks/use-timeout.tsx +21 -0
  20. package/components/catalyst-ui/hooks/use-timer.tsx +209 -0
  21. package/components/catalyst-ui/hooks/use-toggle.tsx +12 -0
  22. package/components/catalyst-ui/media/image.tsx +13 -0
  23. package/components/catalyst-ui/overlays/dual-sidebar.tsx +4142 -0
  24. package/components/catalyst-ui/overlays/sidebar-original.tsx +726 -0
  25. package/components/catalyst-ui/primitives/accordion.tsx +250 -0
  26. package/components/catalyst-ui/primitives/alert-dialog.tsx +126 -0
  27. package/components/catalyst-ui/primitives/aspect-ratio.tsx +9 -0
  28. package/components/catalyst-ui/primitives/avatar.tsx +296 -0
  29. package/components/catalyst-ui/primitives/badge.tsx +57 -0
  30. package/components/catalyst-ui/primitives/breadcrumb.tsx +101 -0
  31. package/components/catalyst-ui/primitives/button.tsx +265 -0
  32. package/components/catalyst-ui/primitives/calendar-v4.tsx +208 -0
  33. package/components/catalyst-ui/primitives/calendar.tsx +295 -0
  34. package/components/catalyst-ui/primitives/card.tsx +618 -0
  35. package/components/catalyst-ui/primitives/carousel.tsx +238 -0
  36. package/components/catalyst-ui/primitives/chart.tsx +347 -0
  37. package/components/catalyst-ui/primitives/checkbox.tsx +225 -0
  38. package/components/catalyst-ui/primitives/collapsible.tsx +212 -0
  39. package/components/catalyst-ui/primitives/command.tsx +393 -0
  40. package/components/catalyst-ui/primitives/context-menu.tsx +236 -0
  41. package/components/catalyst-ui/primitives/dialog.tsx +471 -0
  42. package/components/catalyst-ui/primitives/drawer.tsx +761 -0
  43. package/components/catalyst-ui/primitives/dropdown-menu.tsx +290 -0
  44. package/components/catalyst-ui/primitives/empty.tsx +104 -0
  45. package/components/catalyst-ui/primitives/field.tsx +244 -0
  46. package/components/catalyst-ui/primitives/hover-card.tsx +124 -0
  47. package/components/catalyst-ui/primitives/input-otp.tsx +76 -0
  48. package/components/catalyst-ui/primitives/input.tsx +64 -0
  49. package/components/catalyst-ui/primitives/item.tsx +196 -0
  50. package/components/catalyst-ui/primitives/kbd.tsx +75 -0
  51. package/components/catalyst-ui/primitives/label.tsx +24 -0
  52. package/components/catalyst-ui/primitives/navigation-menu.tsx +150 -0
  53. package/components/catalyst-ui/primitives/pagination.tsx +198 -0
  54. package/components/catalyst-ui/primitives/popover.tsx +232 -0
  55. package/components/catalyst-ui/primitives/progress.tsx +34 -0
  56. package/components/catalyst-ui/primitives/radio-group.tsx +43 -0
  57. package/components/catalyst-ui/primitives/resizable.tsx +56 -0
  58. package/components/catalyst-ui/primitives/select.tsx +155 -0
  59. package/components/catalyst-ui/primitives/separator.tsx +74 -0
  60. package/components/catalyst-ui/primitives/sheet.tsx +126 -0
  61. package/components/catalyst-ui/primitives/skeleton.tsx +15 -0
  62. package/components/catalyst-ui/primitives/slider.tsx +27 -0
  63. package/components/catalyst-ui/primitives/switch.tsx +187 -0
  64. package/components/catalyst-ui/primitives/tabs.tsx +335 -0
  65. package/components/catalyst-ui/primitives/textarea.tsx +24 -0
  66. package/components/catalyst-ui/primitives/toggle-group.tsx +55 -0
  67. package/components/catalyst-ui/primitives/toggle.tsx +42 -0
  68. package/components/catalyst-ui/primitives/tooltip.tsx +116 -0
  69. package/components/catalyst-ui/utils/basic-auth.tsx +40 -0
  70. package/components/catalyst-ui/utils/context-storage.tsx +19 -0
  71. package/components/catalyst-ui/utils/cors-middleware.tsx +71 -0
  72. package/components/catalyst-ui/utils/deferred-content.tsx +595 -0
  73. package/components/catalyst-ui/utils/honeypot-middleware.tsx +38 -0
  74. package/components/catalyst-ui/utils/incId.tsx +75 -0
  75. package/components/catalyst-ui/utils/jwk-auth.tsx +36 -0
  76. package/components/catalyst-ui/utils/request-id.tsx +14 -0
  77. package/components/catalyst-ui/utils/secure-headers.tsx +37 -0
  78. package/components/catalyst-ui/utils/server-timing.tsx +23 -0
  79. package/components/catalyst-ui/utils/utils.ts +43 -0
  80. package/components/catalyst-ui/utils/with-cookie.tsx +43 -0
  81. package/components/catalyst-ui/x/accordian-x.tsx +428 -0
  82. package/components/catalyst-ui/x/alert-x.tsx +413 -0
  83. package/components/catalyst-ui/x/animated-text-x.tsx +2242 -0
  84. package/components/catalyst-ui/x/avatar-x.tsx +515 -0
  85. package/components/catalyst-ui/x/badge-x.tsx +670 -0
  86. package/components/catalyst-ui/x/button-X.tsx +2857 -0
  87. package/components/catalyst-ui/x/button-group-x.tsx +847 -0
  88. package/components/catalyst-ui/x/calendar-x.tsx +1910 -0
  89. package/components/catalyst-ui/x/card-x.tsx +2597 -0
  90. package/components/catalyst-ui/x/checkbox-x.tsx +656 -0
  91. package/components/catalyst-ui/x/collapsible-x.tsx +1360 -0
  92. package/components/catalyst-ui/x/combobox-x.tsx +911 -0
  93. package/components/catalyst-ui/x/data-table-x.tsx +1753 -0
  94. package/components/catalyst-ui/x/date-picker-x.tsx +648 -0
  95. package/components/catalyst-ui/x/dialog-x.tsx +659 -0
  96. package/components/catalyst-ui/x/dropdown-menu-x.tsx +612 -0
  97. package/components/catalyst-ui/x/hover-card-x.tsx +375 -0
  98. package/components/catalyst-ui/x/icon-x.tsx +840 -0
  99. package/components/catalyst-ui/x/input-mask-x.tsx +981 -0
  100. package/components/catalyst-ui/x/input-otp-x.tsx +659 -0
  101. package/components/catalyst-ui/x/loader-x.tsx +1757 -0
  102. package/components/catalyst-ui/x/pagination-x.tsx +622 -0
  103. package/components/catalyst-ui/x/popover-x.tsx +744 -0
  104. package/components/catalyst-ui/x/radio-group-x.tsx +499 -0
  105. package/components/catalyst-ui/x/select-x.tsx +1127 -0
  106. package/components/catalyst-ui/x/sheet-x.tsx +668 -0
  107. package/components/catalyst-ui/x/switch-x.tsx +681 -0
  108. package/components/catalyst-ui/x/table-x.tsx +574 -0
  109. package/components/catalyst-ui/x/tabs-x.tsx +839 -0
  110. package/components/catalyst-ui/x/textarea-x.tsx +1263 -0
  111. package/components/catalyst-ui/x/tooltip-x.tsx +396 -0
  112. package/components/catalyst-ui/x/tracker-x.tsx +560 -0
  113. package/data/bg-data.tsx +901 -0
  114. package/data/buttons-data.tsx +2327 -0
  115. package/data/charts-data.tsx +102 -0
  116. package/data/chat-data.tsx +83 -0
  117. package/data/code-data.tsx +1040 -0
  118. package/data/comboboxes-data.tsx +1843 -0
  119. package/data/command-data.tsx +1381 -0
  120. package/data/core-data.tsx +15953 -0
  121. package/data/crm-data.tsx +47 -0
  122. package/data/data.tsx +159 -0
  123. package/data/date-and-time-data.tsx +554 -0
  124. package/data/dependencies.tsx +7 -0
  125. package/data/ecommerce-data.tsx +1387 -0
  126. package/data/forms-data.tsx +7890 -0
  127. package/data/hooks-data.tsx +5487 -0
  128. package/data/index.ts +34 -0
  129. package/data/inputs-data.tsx +557 -0
  130. package/data/interactive-data.tsx +5394 -0
  131. package/data/lofi-data.tsx +18295 -0
  132. package/data/marketing-data.tsx +2546 -0
  133. package/data/media-data.tsx +1510 -0
  134. package/data/motion-data.tsx +5801 -0
  135. package/data/overlay-data.tsx +4136 -0
  136. package/data/pdf-data.tsx +124 -0
  137. package/data/pos-data.tsx +213 -0
  138. package/data/postcss.config.js +6 -0
  139. package/data/primitive-data.tsx +5170 -0
  140. package/data/prompt-data.tsx +1226 -0
  141. package/data/requiredLibs.ts +4 -0
  142. package/data/sandbox-data.tsx +1 -0
  143. package/data/sidebars-data.tsx +5421 -0
  144. package/data/stacks-data.tsx +32 -0
  145. package/data/table-data.tsx +706 -0
  146. package/data/tailwind.config.js +3830 -0
  147. package/data/tailwind.config.ngin.js +3830 -0
  148. package/data/tailwind.css +431 -0
  149. package/data/tools-data.tsx +6910 -0
  150. package/data/typography-data.tsx +2050 -0
  151. package/data/utils-data.tsx +6500 -0
  152. package/data/x-data.tsx +1171 -0
  153. package/dist/index.d.ts +3 -0
  154. package/dist/index.d.ts.map +1 -0
  155. package/dist/index.js +30245 -0
  156. package/dist/index.js.map +362 -0
  157. package/package.json +50 -0
@@ -0,0 +1,75 @@
1
+ import { prisma } from "~/modules/libs/prisma";
2
+
3
+ export async function IncId({ type }) {
4
+ // const dealerId = await IncId({ type: "Client" });
5
+ // Client, PO, PO Inv, Sales, WO, Unit, FinanceTradeUnit, ServiceUnit, Service, ServicePackages, Dealer
6
+ let oldId;
7
+ let newId;
8
+ switch (type) {
9
+ case "Client":
10
+ const lastClient = await prisma.clientfile.findFirst({
11
+ orderBy: { createdAt: "desc" }, // Get the last created item
12
+ select: { dealerId: true },
13
+ });
14
+ oldId = lastClient?.dealerId || "CLIENT_0"; // Default to "CLIENT-0" if no items exist
15
+ newId = incrementId(oldId, "CLIENT");
16
+ break;
17
+ case "Order":
18
+ const lastPAC = await prisma.accOrder.findFirst({
19
+ orderBy: { createdAt: "desc" },
20
+ select: { dealerId: true },
21
+ });
22
+ oldId = lastPAC?.dealerId || "PO_0";
23
+ newId = incrementId(oldId, "PO");
24
+ break;
25
+ case "Acc Inv":
26
+ const lastAcc = await prisma.accessories.findFirst({
27
+ orderBy: { createdAt: "desc" },
28
+ select: { dealerId: true },
29
+ });
30
+ oldId = lastAcc?.dealerId || "INV_0";
31
+ newId = incrementId(oldId, "INV");
32
+ break;
33
+ case "Ticket":
34
+ const lastTicket = await prisma.clientTickets.findFirst({
35
+ orderBy: { createdAt: "desc" },
36
+ select: { dealerId: true },
37
+ });
38
+ oldId = lastTicket?.dealerId || "TICKET_0";
39
+ newId = incrementId(oldId, "TICKET");
40
+ break;
41
+ case "Receipt":
42
+ const lastPayment = await prisma.payment.findFirst({
43
+ orderBy: { createdAt: "desc" },
44
+ select: { dealerId: true },
45
+ });
46
+ oldId = lastPayment?.dealerId || "RECEIPT_0";
47
+ newId = incrementId(oldId, "RECEIPT");
48
+ break;
49
+ case "User":
50
+ const lastUser = await prisma.user.findFirst({
51
+ orderBy: { createdAt: "desc" },
52
+ select: { dealerId: true },
53
+ });
54
+ oldId = lastUser?.dealerId || "USER_0";
55
+ newId = incrementId(oldId, "USER");
56
+ break;
57
+ default:
58
+ throw new Error("Invalid type");
59
+ }
60
+ return newId;
61
+ }
62
+ function incrementId(oldId, prefix) {
63
+ // Extract the numeric part using a regular expression
64
+ const numericMatch = oldId.match(/\d+/);
65
+
66
+ // If no numeric part is found, default to 0
67
+ const numericPart = numericMatch ? parseInt(numericMatch[0], 10) : 0;
68
+
69
+ // Increment the numeric part
70
+ const newNumericPart = numericPart + 1;
71
+
72
+ // Return the new ID in the format "PREFIX_{incrementedNumber}"
73
+ const result = prefix+"_"+newNumericPart
74
+ return result
75
+ }
@@ -0,0 +1,36 @@
1
+ import { useState, useEffect, useCallback, useRef } from "react";
2
+
3
+
4
+ export function JWKAuthMiddleware() {
5
+ const validateJWT = useCallback(async (
6
+ token: string,
7
+ options: JWKAuthOptions
8
+ ): Promise<any> => {
9
+ try {
10
+ return { valid: true, payload: { sub: 'user123' } };
11
+ } catch (error) {
12
+ return null;
13
+ }
14
+ }, []);
15
+
16
+ const requireJWTAuth = useCallback(async (
17
+ request: Request,
18
+ options: JWKAuthOptions
19
+ ) => {
20
+ const authHeader = request.headers.get('authorization');
21
+ if (!authHeader?.startsWith('Bearer ')) {
22
+ return new Response('Unauthorized', { status: 401 });
23
+ }
24
+
25
+ const token = authHeader.slice(7);
26
+ const validation = await validateJWT(token, options);
27
+
28
+ if (!validation) {
29
+ return new Response('Invalid token', { status: 401 });
30
+ }
31
+
32
+ return null;
33
+ }, [validateJWT]);
34
+
35
+ return { validateJWT, requireJWTAuth };
36
+ }
@@ -0,0 +1,14 @@
1
+ import { useState, useEffect, useCallback, useRef } from "react";
2
+
3
+ export function RequestIDMiddleware() {
4
+ const generateRequestId = useCallback(() => {
5
+ return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
6
+ }, []);
7
+
8
+ const addRequestId = useCallback((request: Request): string => {
9
+ const existingId = request.headers.get('x-request-id');
10
+ return existingId || generateRequestId();
11
+ }, [generateRequestId]);
12
+
13
+ return { addRequestId, generateRequestId };
14
+ }
@@ -0,0 +1,37 @@
1
+ import { useState, useEffect, useCallback, useRef } from "react";
2
+
3
+ export function SecureHeadersMiddleware() {
4
+ const addSecurityHeaders = useCallback((
5
+ response: Response,
6
+ options: SecurityHeaders
7
+ ): Response => {
8
+ const headers = new Headers(response.headers);
9
+
10
+ if (options.contentTypeOptions) {
11
+ headers.set('X-Content-Type-Options', 'nosniff');
12
+ }
13
+
14
+ if (options.frameOptions) {
15
+ headers.set('X-Frame-Options', options.frameOptions);
16
+ }
17
+
18
+ if (options.xssProtection) {
19
+ headers.set('X-XSS-Protection', '1; mode=block');
20
+ }
21
+
22
+ if (options.hsts) {
23
+ const hstsValue = `max-age=${options.hsts.maxAge}${
24
+ options.hsts.includeSubDomains ? '; includeSubDomains' : ''
25
+ }`;
26
+ headers.set('Strict-Transport-Security', hstsValue);
27
+ }
28
+
29
+ return new Response(response.body, {
30
+ status: response.status,
31
+ statusText: response.statusText,
32
+ headers,
33
+ });
34
+ }, []);
35
+
36
+ return { addSecurityHeaders };
37
+ }
@@ -0,0 +1,23 @@
1
+ import { useState, useEffect, useCallback, useRef } from "react";
2
+
3
+
4
+
5
+ export function ServerTimingMiddleware() {
6
+ const addServerTiming = useCallback((name: string, duration: number, description?: string) => {
7
+ const timing = description
8
+ ? `${name};dur=${duration};desc="${description}"`
9
+ : `${name};dur=${duration}`;
10
+
11
+ return (response: Response) => {
12
+ const existingTiming = response.headers.get('Server-Timing') || '';
13
+ const newTiming = existingTiming
14
+ ? `${existingTiming}, ${timing}`
15
+ : timing;
16
+
17
+ response.headers.set('Server-Timing', newTiming);
18
+ return response;
19
+ };
20
+ }, []);
21
+
22
+ return { addServerTiming };
23
+ }
@@ -0,0 +1,43 @@
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
7
+
8
+ export const focusInput = [
9
+ // base
10
+ 'focus:ring-2',
11
+ // ring color
12
+ 'focus:ring-blue-200 focus:dark:ring-blue-700/30',
13
+ // border color
14
+ 'focus:border-blue-500 focus:dark:border-blue-700',
15
+ ];
16
+
17
+ // Tremor focusRing [v0.0.1]
18
+
19
+ export const focusRing = [
20
+ // base
21
+ 'outline outline-offset-2 outline-0 focus-visible:outline-2',
22
+ // outline color
23
+ 'outline-blue-500 dark:outline-blue-500',
24
+ ];
25
+
26
+ // Tremor hasErrorInput [v0.0.1]
27
+
28
+ export const hasErrorInput = [
29
+ // base
30
+ 'ring-2',
31
+ // border color
32
+ 'border-red-500 dark:border-red-700',
33
+ // ring color
34
+ 'ring-red-200 dark:ring-red-700/30',
35
+ ];
36
+
37
+ export const formatDate = (date: Date): string => {
38
+ return date.toLocaleDateString("en-US", {
39
+ year: "numeric",
40
+ month: "long",
41
+ day: "numeric",
42
+ })
43
+ }
@@ -0,0 +1,43 @@
1
+ import { useState, useEffect, useCallback, useRef } from "react";
2
+
3
+ export function WithCookieMiddleware() {
4
+ const getCookie = useCallback((request: Request, name: string): string | null => {
5
+ const cookieHeader = request.headers.get('cookie');
6
+ if (!cookieHeader) return null;
7
+
8
+ const cookies = cookieHeader.split(';').map(c => c.trim());
9
+ const targetCookie = cookies.find(c => c.startsWith(`${name}=`));
10
+
11
+ return targetCookie ? targetCookie.split('=')[1] : null;
12
+ }, []);
13
+
14
+ const setCookie = useCallback((
15
+ response: Response,
16
+ name: string,
17
+ value: string,
18
+ options: {
19
+ maxAge?: number;
20
+ expires?: Date;
21
+ path?: string;
22
+ domain?: string;
23
+ secure?: boolean;
24
+ httpOnly?: boolean;
25
+ sameSite?: 'strict' | 'lax' | 'none';
26
+ } = {}
27
+ ): Response => {
28
+ const cookieParts = [`${name}=${value}`];
29
+
30
+ if (options.maxAge) cookieParts.push(`Max-Age=${options.maxAge}`);
31
+ if (options.expires) cookieParts.push(`Expires=${options.expires.toUTCString()}`);
32
+ if (options.path) cookieParts.push(`Path=${options.path}`);
33
+ if (options.domain) cookieParts.push(`Domain=${options.domain}`);
34
+ if (options.secure) cookieParts.push('Secure');
35
+ if (options.httpOnly) cookieParts.push('HttpOnly');
36
+ if (options.sameSite) cookieParts.push(`SameSite=${options.sameSite}`);
37
+
38
+ response.headers.set('Set-Cookie', cookieParts.join('; '));
39
+ return response;
40
+ }, []);
41
+
42
+ return { getCookie, setCookie };
43
+ }