@umituz/web-dashboard 1.0.7 → 2.0.1

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 (61) 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/components/DashboardLayout.js +501 -0
  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/components/index.d.ts +10 -0
  14. package/dist/components/index.js +502 -0
  15. package/dist/components/index.js.map +1 -0
  16. package/dist/hooks/dashboard.d.ts +35 -0
  17. package/dist/hooks/dashboard.js +57 -0
  18. package/dist/hooks/dashboard.js.map +1 -0
  19. package/dist/hooks/index.d.ts +3 -0
  20. package/dist/hooks/index.js +57 -0
  21. package/dist/hooks/index.js.map +1 -0
  22. package/dist/index.d.ts +17 -403
  23. package/dist/index.js +56 -52
  24. package/dist/index.js.map +1 -1
  25. package/dist/theme/default.d.ts +18 -0
  26. package/dist/theme/default.js +52 -0
  27. package/dist/theme/default.js.map +1 -0
  28. package/dist/theme/index.d.ts +4 -0
  29. package/dist/theme/index.js +184 -0
  30. package/dist/theme/index.js.map +1 -0
  31. package/dist/theme/presets.d.ts +14 -0
  32. package/dist/theme/presets.js +137 -0
  33. package/dist/theme/presets.js.map +1 -0
  34. package/dist/theme/utils.d.ts +22 -0
  35. package/dist/theme/utils.js +181 -0
  36. package/dist/theme/utils.js.map +1 -0
  37. package/dist/types/index.d.ts +6 -0
  38. package/dist/types/index.js +2 -0
  39. package/dist/types/index.js.map +1 -0
  40. package/dist/types/layout.d.ts +45 -0
  41. package/dist/types/layout.js +2 -0
  42. package/dist/types/layout.js.map +1 -0
  43. package/dist/types/notification.d.ts +20 -0
  44. package/dist/types/notification.js +2 -0
  45. package/dist/types/notification.js.map +1 -0
  46. package/dist/types/sidebar.d.ts +36 -0
  47. package/dist/types/sidebar.js +2 -0
  48. package/dist/types/sidebar.js.map +1 -0
  49. package/dist/types/theme.d.ts +64 -0
  50. package/dist/types/theme.js +2 -0
  51. package/dist/types/theme.js.map +1 -0
  52. package/dist/types/user.d.ts +37 -0
  53. package/dist/types/user.js +2 -0
  54. package/dist/types/user.js.map +1 -0
  55. package/dist/utils/dashboard.d.ts +57 -0
  56. package/dist/utils/dashboard.js +44 -0
  57. package/dist/utils/dashboard.js.map +1 -0
  58. package/dist/utils/index.d.ts +1 -0
  59. package/dist/utils/index.js +44 -0
  60. package/dist/utils/index.js.map +1 -0
  61. package/package.json +19 -23
@@ -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":[]}
@@ -0,0 +1 @@
1
+ export { filterSidebarItems, formatNotificationTime, generateNotificationId, getPageTitle, isPathActive } from './dashboard.js';
@@ -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=index.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,32 @@
1
1
  {
2
2
  "name": "@umituz/web-dashboard",
3
- "version": "1.0.7",
3
+ "version": "2.0.1",
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": {
8
+ "types": "./dist/domains/layouts/index.d.ts",
9
+ "import": "./dist/domains/layouts/index.js"
14
10
  },
15
- "./components": {
16
- "types": "./dist/components/index.d.ts",
17
- "import": "./dist/components/index.js"
11
+ "./layouts/components": {
12
+ "types": "./dist/domains/layouts/components/index.d.ts",
13
+ "import": "./dist/domains/layouts/components/index.js"
18
14
  },
19
- "./types": {
20
- "types": "./dist/types/index.d.ts",
21
- "import": "./dist/types/index.js"
15
+ "./layouts/hooks": {
16
+ "types": "./dist/domains/layouts/hooks/index.d.ts",
17
+ "import": "./dist/domains/layouts/hooks/index.js"
22
18
  },
23
- "./theme": {
24
- "types": "./dist/theme/index.d.ts",
25
- "import": "./dist/theme/index.js"
19
+ "./layouts/utils": {
20
+ "types": "./dist/domains/layouts/utils/index.d.ts",
21
+ "import": "./dist/domains/layouts/utils/index.js"
26
22
  },
27
- "./hooks": {
28
- "types": "./dist/hooks/index.d.ts",
29
- "import": "./dist/hooks/index.js"
23
+ "./layouts/types": {
24
+ "types": "./dist/domains/layouts/types/index.d.ts",
25
+ "import": "./dist/domains/layouts/types/index.js"
30
26
  },
31
- "./utils": {
32
- "types": "./dist/utils/index.d.ts",
33
- "import": "./dist/utils/index.js"
27
+ "./layouts/theme": {
28
+ "types": "./dist/domains/layouts/theme/index.d.ts",
29
+ "import": "./dist/domains/layouts/theme/index.js"
34
30
  },
35
31
  "./package.json": "./package.json"
36
32
  },