@umituz/web-dashboard 1.0.7 → 2.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 (45) hide show
  1. package/dist/components/BrandLogo.d.ts +18 -0
  2. package/dist/components/BrandLogo.js +88 -0
  3. package/dist/components/BrandLogo.js.map +1 -0
  4. package/dist/components/DashboardHeader.d.ts +36 -0
  5. package/dist/components/DashboardHeader.js +225 -0
  6. package/dist/components/DashboardHeader.js.map +1 -0
  7. package/dist/components/DashboardLayout.d.ts +45 -0
  8. package/dist/{index.js → components/DashboardLayout.js} +3 -254
  9. package/dist/components/DashboardLayout.js.map +1 -0
  10. package/dist/components/DashboardSidebar.d.ts +29 -0
  11. package/dist/components/DashboardSidebar.js +189 -0
  12. package/dist/components/DashboardSidebar.js.map +1 -0
  13. package/dist/hooks/dashboard.d.ts +35 -0
  14. package/dist/hooks/dashboard.js +57 -0
  15. package/dist/hooks/dashboard.js.map +1 -0
  16. package/dist/theme/default.d.ts +18 -0
  17. package/dist/theme/default.js +52 -0
  18. package/dist/theme/default.js.map +1 -0
  19. package/dist/theme/presets.d.ts +14 -0
  20. package/dist/theme/presets.js +137 -0
  21. package/dist/theme/presets.js.map +1 -0
  22. package/dist/theme/utils.d.ts +22 -0
  23. package/dist/theme/utils.js +181 -0
  24. package/dist/theme/utils.js.map +1 -0
  25. package/dist/types/layout.d.ts +45 -0
  26. package/dist/types/layout.js +2 -0
  27. package/dist/types/layout.js.map +1 -0
  28. package/dist/types/notification.d.ts +20 -0
  29. package/dist/types/notification.js +2 -0
  30. package/dist/types/notification.js.map +1 -0
  31. package/dist/types/sidebar.d.ts +36 -0
  32. package/dist/types/sidebar.js +2 -0
  33. package/dist/types/sidebar.js.map +1 -0
  34. package/dist/types/theme.d.ts +64 -0
  35. package/dist/types/theme.js +2 -0
  36. package/dist/types/theme.js.map +1 -0
  37. package/dist/types/user.d.ts +37 -0
  38. package/dist/types/user.js +2 -0
  39. package/dist/types/user.js.map +1 -0
  40. package/dist/utils/dashboard.d.ts +57 -0
  41. package/dist/utils/dashboard.js +44 -0
  42. package/dist/utils/dashboard.js.map +1 -0
  43. package/package.json +51 -23
  44. package/dist/index.d.ts +0 -403
  45. package/dist/index.js.map +0 -1
@@ -0,0 +1,36 @@
1
+ import { LucideIcon } from 'lucide-react';
2
+
3
+ /**
4
+ * Dashboard Types - Sidebar
5
+ *
6
+ * Type definitions for sidebar components
7
+ */
8
+
9
+ /**
10
+ * Single sidebar menu item
11
+ */
12
+ interface SidebarItem {
13
+ /** Display label (can be i18n key) */
14
+ label: string;
15
+ /** Icon from lucide-react */
16
+ icon: LucideIcon;
17
+ /** Route path */
18
+ path: string;
19
+ /** Filter by app type (optional) */
20
+ requiredApp?: 'mobile' | 'web';
21
+ /** Enable/disable this item (default: true) */
22
+ enabled?: boolean;
23
+ }
24
+ /**
25
+ * Group of sidebar items with a title
26
+ */
27
+ interface SidebarGroup {
28
+ /** Group title (can be i18n key) */
29
+ title: string;
30
+ /** Items in this group */
31
+ items: SidebarItem[];
32
+ /** Optional: Route to title mapping for page headers */
33
+ titleMap?: Record<string, string>;
34
+ }
35
+
36
+ export type { SidebarGroup, SidebarItem };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ //# sourceMappingURL=sidebar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Dashboard Types - Theme
3
+ *
4
+ * Type definitions for theme system
5
+ */
6
+ /**
7
+ * Dashboard theme configuration
8
+ * Extends CSS variables for customization
9
+ */
10
+ interface DashboardTheme {
11
+ /** Primary color (CSS variable compatible) */
12
+ primary?: string;
13
+ /** Secondary color */
14
+ secondary?: string;
15
+ /** Sidebar background */
16
+ sidebarBackground?: string;
17
+ /** Sidebar foreground */
18
+ sidebarForeground?: string;
19
+ /** Sidebar border */
20
+ sidebarBorder?: string;
21
+ /** Header background */
22
+ headerBackground?: string;
23
+ /** Background color */
24
+ background?: string;
25
+ /** Foreground color */
26
+ foreground?: string;
27
+ /** Border color */
28
+ border?: string;
29
+ /** Accent color */
30
+ accent?: string;
31
+ /** Accent foreground */
32
+ accentForeground?: string;
33
+ /** Destructive color */
34
+ destructive?: string;
35
+ /** Destructive foreground */
36
+ destructiveForeground?: string;
37
+ /** Muted background */
38
+ muted?: string;
39
+ /** Muted foreground */
40
+ mutedForeground?: string;
41
+ /** Card background */
42
+ card?: string;
43
+ /** Card foreground */
44
+ cardForeground?: string;
45
+ /** Popover background */
46
+ popover?: string;
47
+ /** Popover foreground */
48
+ popoverForeground?: string;
49
+ /** Radius (border-radius) */
50
+ radius?: string;
51
+ }
52
+ /**
53
+ * Theme preset for quick setup
54
+ */
55
+ interface DashboardThemePreset {
56
+ /** Preset name */
57
+ name: string;
58
+ /** Theme configuration */
59
+ theme: DashboardTheme;
60
+ /** Whether this is a dark theme */
61
+ dark?: boolean;
62
+ }
63
+
64
+ export type { DashboardTheme, DashboardThemePreset };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Dashboard Types - User
3
+ *
4
+ * Type definitions for user profile
5
+ */
6
+ /**
7
+ * User profile info for header
8
+ */
9
+ interface DashboardUser {
10
+ /** User ID */
11
+ id: string;
12
+ /** Display name */
13
+ name?: string;
14
+ /** Email address */
15
+ email?: string;
16
+ /** Avatar URL */
17
+ avatar?: string;
18
+ /** Whether user has mobile app access */
19
+ hasMobileApp?: boolean;
20
+ /** Whether user has web app access */
21
+ hasWebApp?: boolean;
22
+ }
23
+ /**
24
+ * Navigation item for user menu
25
+ */
26
+ interface UserNavMenuItem {
27
+ /** Display label */
28
+ label: string;
29
+ /** Icon component */
30
+ icon: React.ComponentType<{
31
+ className?: string;
32
+ }>;
33
+ /** Route path */
34
+ path: string;
35
+ }
36
+
37
+ export type { DashboardUser, UserNavMenuItem };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ //# sourceMappingURL=user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Dashboard Utilities
3
+ *
4
+ * Utility functions for dashboard operations
5
+ */
6
+ /**
7
+ * Format notification timestamp to relative time
8
+ *
9
+ * @param createdAt - Notification creation timestamp
10
+ * @param t - i18n translation function
11
+ * @returns Formatted time string
12
+ */
13
+ declare function formatNotificationTime(createdAt: Date | string | number, t: (key: string, params?: Record<string, unknown>) => string): string;
14
+ /**
15
+ * Check if a path is active
16
+ *
17
+ * @param currentPath - Current location pathname
18
+ * @param targetPath - Target path to check
19
+ * @returns True if paths match
20
+ */
21
+ declare function isPathActive(currentPath: string, targetPath: string): boolean;
22
+ /**
23
+ * Get page title from sidebar configuration
24
+ *
25
+ * @param pathname - Current pathname
26
+ * @param sidebarGroups - Sidebar groups configuration
27
+ * @param extraTitleMap - Extra title mappings
28
+ * @returns Page title or null
29
+ */
30
+ declare function getPageTitle(pathname: string, sidebarGroups: Array<{
31
+ items: Array<{
32
+ path: string;
33
+ label: string;
34
+ }>;
35
+ }>, extraTitleMap?: Record<string, string>): string | null;
36
+ /**
37
+ * Filter sidebar items by app type and enabled status
38
+ *
39
+ * @param items - Sidebar items to filter
40
+ * @param user - Current user object
41
+ * @returns Filtered items
42
+ */
43
+ declare function filterSidebarItems<T extends {
44
+ enabled?: boolean;
45
+ requiredApp?: "mobile" | "web";
46
+ }>(items: T[], user?: {
47
+ hasMobileApp?: boolean;
48
+ hasWebApp?: boolean;
49
+ }): T[];
50
+ /**
51
+ * Generate notification ID
52
+ *
53
+ * @returns Unique notification ID
54
+ */
55
+ declare function generateNotificationId(): string;
56
+
57
+ export { filterSidebarItems, formatNotificationTime, generateNotificationId, getPageTitle, isPathActive };
@@ -0,0 +1,44 @@
1
+ "use client";
2
+
3
+ // src/domains/layouts/utils/dashboard.ts
4
+ function formatNotificationTime(createdAt, t) {
5
+ const date = new Date(createdAt);
6
+ const secs = Math.floor((Date.now() - date.getTime()) / 1e3);
7
+ if (secs < 60) return t("dashboard.activityFeed.times.justNow");
8
+ if (secs < 3600) return t("dashboard.activityFeed.times.minutesAgo", { val: Math.floor(secs / 60) });
9
+ if (secs < 86400) return t("dashboard.activityFeed.times.hoursAgo", { val: Math.floor(secs / 3600) });
10
+ return t("dashboard.activityFeed.times.daysAgo", { val: Math.floor(secs / 86400) });
11
+ }
12
+ function isPathActive(currentPath, targetPath) {
13
+ return currentPath === targetPath;
14
+ }
15
+ function getPageTitle(pathname, sidebarGroups, extraTitleMap) {
16
+ for (const group of sidebarGroups) {
17
+ const item = group.items.find((i) => i.path === pathname);
18
+ if (item) return item.label;
19
+ }
20
+ if (extraTitleMap?.[pathname]) {
21
+ return extraTitleMap[pathname];
22
+ }
23
+ return null;
24
+ }
25
+ function filterSidebarItems(items, user) {
26
+ return items.filter((item) => {
27
+ if (item.enabled === false) return false;
28
+ if (!item.requiredApp) return true;
29
+ if (item.requiredApp === "mobile") return user?.hasMobileApp ?? false;
30
+ if (item.requiredApp === "web") return user?.hasWebApp ?? false;
31
+ return true;
32
+ });
33
+ }
34
+ function generateNotificationId() {
35
+ return crypto.randomUUID();
36
+ }
37
+ export {
38
+ filterSidebarItems,
39
+ formatNotificationTime,
40
+ generateNotificationId,
41
+ getPageTitle,
42
+ isPathActive
43
+ };
44
+ //# sourceMappingURL=dashboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/domains/layouts/utils/dashboard.ts"],"sourcesContent":["/**\n * Dashboard Utilities\n *\n * Utility functions for dashboard operations\n */\n\n/**\n * Format notification timestamp to relative time\n *\n * @param createdAt - Notification creation timestamp\n * @param t - i18n translation function\n * @returns Formatted time string\n */\nexport function formatNotificationTime(\n createdAt: Date | string | number,\n t: (key: string, params?: Record<string, unknown>) => string\n): string {\n const date = new Date(createdAt);\n const secs = Math.floor((Date.now() - date.getTime()) / 1000);\n\n if (secs < 60) return t(\"dashboard.activityFeed.times.justNow\");\n if (secs < 3600) return t(\"dashboard.activityFeed.times.minutesAgo\", { val: Math.floor(secs / 60) });\n if (secs < 86400) return t(\"dashboard.activityFeed.times.hoursAgo\", { val: Math.floor(secs / 3600) });\n return t(\"dashboard.activityFeed.times.daysAgo\", { val: Math.floor(secs / 86400) });\n}\n\n/**\n * Check if a path is active\n *\n * @param currentPath - Current location pathname\n * @param targetPath - Target path to check\n * @returns True if paths match\n */\nexport function isPathActive(currentPath: string, targetPath: string): boolean {\n return currentPath === targetPath;\n}\n\n/**\n * Get page title from sidebar configuration\n *\n * @param pathname - Current pathname\n * @param sidebarGroups - Sidebar groups configuration\n * @param extraTitleMap - Extra title mappings\n * @returns Page title or null\n */\nexport function getPageTitle(\n pathname: string,\n sidebarGroups: Array<{ items: Array<{ path: string; label: string }> }>,\n extraTitleMap?: Record<string, string>\n): string | null {\n // Search in sidebar groups\n for (const group of sidebarGroups) {\n const item = group.items.find((i) => i.path === pathname);\n if (item) return item.label;\n }\n\n // Search in extra title map\n if (extraTitleMap?.[pathname]) {\n return extraTitleMap[pathname];\n }\n\n return null;\n}\n\n/**\n * Filter sidebar items by app type and enabled status\n *\n * @param items - Sidebar items to filter\n * @param user - Current user object\n * @returns Filtered items\n */\nexport function filterSidebarItems<T extends { enabled?: boolean; requiredApp?: \"mobile\" | \"web\" }>(\n items: T[],\n user?: { hasMobileApp?: boolean; hasWebApp?: boolean }\n): T[] {\n return items.filter((item) => {\n // Skip disabled items\n if (item.enabled === false) return false;\n\n // Skip items that require specific app types\n if (!item.requiredApp) return true;\n if (item.requiredApp === \"mobile\") return user?.hasMobileApp ?? false;\n if (item.requiredApp === \"web\") return user?.hasWebApp ?? false;\n\n return true;\n });\n}\n\n/**\n * Generate notification ID\n *\n * @returns Unique notification ID\n */\nexport function generateNotificationId(): string {\n return crypto.randomUUID();\n}\n"],"mappings":";;;AAaO,SAAS,uBACd,WACA,GACQ;AACR,QAAM,OAAO,IAAI,KAAK,SAAS;AAC/B,QAAM,OAAO,KAAK,OAAO,KAAK,IAAI,IAAI,KAAK,QAAQ,KAAK,GAAI;AAE5D,MAAI,OAAO,GAAI,QAAO,EAAE,sCAAsC;AAC9D,MAAI,OAAO,KAAM,QAAO,EAAE,2CAA2C,EAAE,KAAK,KAAK,MAAM,OAAO,EAAE,EAAE,CAAC;AACnG,MAAI,OAAO,MAAO,QAAO,EAAE,yCAAyC,EAAE,KAAK,KAAK,MAAM,OAAO,IAAI,EAAE,CAAC;AACpG,SAAO,EAAE,wCAAwC,EAAE,KAAK,KAAK,MAAM,OAAO,KAAK,EAAE,CAAC;AACpF;AASO,SAAS,aAAa,aAAqB,YAA6B;AAC7E,SAAO,gBAAgB;AACzB;AAUO,SAAS,aACd,UACA,eACA,eACe;AAEf,aAAW,SAAS,eAAe;AACjC,UAAM,OAAO,MAAM,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,QAAQ;AACxD,QAAI,KAAM,QAAO,KAAK;AAAA,EACxB;AAGA,MAAI,gBAAgB,QAAQ,GAAG;AAC7B,WAAO,cAAc,QAAQ;AAAA,EAC/B;AAEA,SAAO;AACT;AASO,SAAS,mBACd,OACA,MACK;AACL,SAAO,MAAM,OAAO,CAAC,SAAS;AAE5B,QAAI,KAAK,YAAY,MAAO,QAAO;AAGnC,QAAI,CAAC,KAAK,YAAa,QAAO;AAC9B,QAAI,KAAK,gBAAgB,SAAU,QAAO,MAAM,gBAAgB;AAChE,QAAI,KAAK,gBAAgB,MAAO,QAAO,MAAM,aAAa;AAE1D,WAAO;AAAA,EACT,CAAC;AACH;AAOO,SAAS,yBAAiC;AAC/C,SAAO,OAAO,WAAW;AAC3B;","names":[]}
package/package.json CHANGED
@@ -1,36 +1,64 @@
1
1
  {
2
2
  "name": "@umituz/web-dashboard",
3
- "version": "1.0.7",
3
+ "version": "2.0.0",
4
4
  "description": "Dashboard Layout System - Customizable, themeable dashboard layouts",
5
5
  "type": "module",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
6
  "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
7
+ "./layouts/components/DashboardLayout": {
8
+ "types": "./dist/domains/layouts/components/DashboardLayout.d.ts",
9
+ "import": "./dist/domains/layouts/components/DashboardLayout.js"
14
10
  },
15
- "./components": {
16
- "types": "./dist/components/index.d.ts",
17
- "import": "./dist/components/index.js"
11
+ "./layouts/components/DashboardHeader": {
12
+ "types": "./dist/domains/layouts/components/DashboardHeader.d.ts",
13
+ "import": "./dist/domains/layouts/components/DashboardHeader.js"
18
14
  },
19
- "./types": {
20
- "types": "./dist/types/index.d.ts",
21
- "import": "./dist/types/index.js"
15
+ "./layouts/components/DashboardSidebar": {
16
+ "types": "./dist/domains/layouts/components/DashboardSidebar.d.ts",
17
+ "import": "./dist/domains/layouts/components/DashboardSidebar.js"
22
18
  },
23
- "./theme": {
24
- "types": "./dist/theme/index.d.ts",
25
- "import": "./dist/theme/index.js"
19
+ "./layouts/components/BrandLogo": {
20
+ "types": "./dist/domains/layouts/components/BrandLogo.d.ts",
21
+ "import": "./dist/domains/layouts/components/BrandLogo.js"
26
22
  },
27
- "./hooks": {
28
- "types": "./dist/hooks/index.d.ts",
29
- "import": "./dist/hooks/index.js"
23
+ "./layouts/hooks/dashboard": {
24
+ "types": "./dist/domains/layouts/hooks/dashboard.d.ts",
25
+ "import": "./dist/domains/layouts/hooks/dashboard.js"
30
26
  },
31
- "./utils": {
32
- "types": "./dist/utils/index.d.ts",
33
- "import": "./dist/utils/index.js"
27
+ "./layouts/utils/dashboard": {
28
+ "types": "./dist/domains/layouts/utils/dashboard.d.ts",
29
+ "import": "./dist/domains/layouts/utils/dashboard.js"
30
+ },
31
+ "./layouts/types/sidebar": {
32
+ "types": "./dist/domains/layouts/types/sidebar.d.ts",
33
+ "import": "./dist/domains/layouts/types/sidebar.js"
34
+ },
35
+ "./layouts/types/layout": {
36
+ "types": "./dist/domains/layouts/types/layout.d.ts",
37
+ "import": "./dist/domains/layouts/types/layout.js"
38
+ },
39
+ "./layouts/types/theme": {
40
+ "types": "./dist/domains/layouts/types/theme.d.ts",
41
+ "import": "./dist/domains/layouts/types/theme.js"
42
+ },
43
+ "./layouts/types/notification": {
44
+ "types": "./dist/domains/layouts/types/notification.d.ts",
45
+ "import": "./dist/domains/layouts/types/notification.js"
46
+ },
47
+ "./layouts/types/user": {
48
+ "types": "./dist/domains/layouts/types/user.d.ts",
49
+ "import": "./dist/domains/layouts/types/user.js"
50
+ },
51
+ "./layouts/theme/default": {
52
+ "types": "./dist/domains/layouts/theme/default.d.ts",
53
+ "import": "./dist/domains/layouts/theme/default.js"
54
+ },
55
+ "./layouts/theme/presets": {
56
+ "types": "./dist/domains/layouts/theme/presets.d.ts",
57
+ "import": "./dist/domains/layouts/theme/presets.js"
58
+ },
59
+ "./layouts/theme/utils": {
60
+ "types": "./dist/domains/layouts/theme/utils.d.ts",
61
+ "import": "./dist/domains/layouts/theme/utils.js"
34
62
  },
35
63
  "./package.json": "./package.json"
36
64
  },