@dashadmin/dash-app-common 1.3.25 → 1.3.28

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 (166) hide show
  1. package/README.md +35 -0
  2. package/dist/DashApp.js +176 -1
  3. package/dist/DashAppLoader.js +348 -3
  4. package/dist/DashDefaultResources.js +10 -1
  5. package/dist/components/DashDefaultPrivateApp.js +150 -1
  6. package/dist/components/DashDefaultPrivateResources.js +10 -1
  7. package/dist/components/DashDefaultPublicApp.js +20 -1
  8. package/dist/components/DashResourceLoader.js +245 -1
  9. package/dist/defaults/extensions/bootstrap/DashDefaultErrorBoundary.js +78 -1
  10. package/dist/defaults/extensions/bootstrap/dashDefaultInitializeApp.js +59 -1
  11. package/dist/defaults/extensions/bootstrap/index.js +24 -1
  12. package/dist/defaults/extensions/components/DashDefaultLoader.js +43 -2
  13. package/dist/defaults/extensions/components/dashDefaultAutoAdminComponents.js +67 -1
  14. package/dist/defaults/extensions/components/dashDefaultNotification.js +28 -1
  15. package/dist/defaults/extensions/components/dashDefaultStaticComponents.js +15 -1
  16. package/dist/defaults/extensions/components/index.js +13 -1
  17. package/dist/defaults/extensions/electron/dashDefaultIpcListeners.js +38 -1
  18. package/dist/defaults/extensions/electron/index.js +5 -1
  19. package/dist/defaults/extensions/hooks/index.js +12 -1
  20. package/dist/defaults/extensions/hooks/useDashDefaultLazyAutoAdminComponents.js +17 -1
  21. package/dist/defaults/extensions/hooks/useDashDefaultLazyI18nProvider.js +51 -1
  22. package/dist/defaults/extensions/hooks/useDashDefaultLazyResources.js +19 -1
  23. package/dist/defaults/extensions/hooks/useDashDefaultMountTracker.js +22 -1
  24. package/dist/defaults/extensions/hooks/useDashDefaultRoutePath.js +17 -1
  25. package/dist/defaults/extensions/i18n/dashDefaultI18nProvider.js +44 -1
  26. package/dist/defaults/extensions/i18n/dashDefaultTranslations.js +87 -1
  27. package/dist/defaults/extensions/i18n/index.js +24 -1
  28. package/dist/defaults/extensions/index.js +190 -1
  29. package/dist/defaults/extensions/layout/dashDefaultDomainAppLayout.js +58 -1
  30. package/dist/defaults/extensions/layout/index.js +12 -1
  31. package/dist/defaults/extensions/managers/DashDefaultWSMessagesManager.js +84 -1
  32. package/dist/defaults/extensions/managers/index.js +5 -1
  33. package/dist/defaults/extensions/providers/dashDefaultAuthProvider.js +220 -1
  34. package/dist/defaults/extensions/providers/dashDefaultDataProvider.js +395 -1
  35. package/dist/defaults/extensions/providers/index.js +24 -1
  36. package/dist/defaults/extensions/router/DashDefaultLanding.js +46 -1
  37. package/dist/defaults/extensions/router/dashDefaultPrivateRoutes.js +38 -1
  38. package/dist/defaults/extensions/router/dashDefaultPublicRoutes.js +65 -1
  39. package/dist/defaults/extensions/router/dashDefaultRouter.js +39 -1
  40. package/dist/defaults/extensions/router/dashDefaultSharedRoutes.js +40 -1
  41. package/dist/defaults/extensions/router/index.js +12 -1
  42. package/dist/defaults/extensions/state/dashDefaultAppCommon.js +57 -1
  43. package/dist/defaults/extensions/state/dashDefaultAppSettings.js +38 -1
  44. package/dist/defaults/extensions/state/dashDefaultInitialAppState.js +31 -1
  45. package/dist/defaults/extensions/state/dashDefaultLayoutSettings.js +48 -1
  46. package/dist/defaults/extensions/state/dashDefaultQueryClient.js +58 -1
  47. package/dist/defaults/extensions/state/dashDefaultResourcesIcons.js +24 -1
  48. package/dist/defaults/extensions/state/index.js +29 -1
  49. package/dist/defaults/extensions/styles/index.js +2 -1
  50. package/dist/defaults/extensions/theme/dashDefaultThemeOptions.js +74 -1
  51. package/dist/defaults/extensions/theme/index.js +6 -1
  52. package/dist/defaults/extensions/utils/IPCMessageBrokerContext.js +12 -1
  53. package/dist/defaults/extensions/utils/dashDefaultAuthProviderUtils.js +29 -1
  54. package/dist/defaults/extensions/utils/dashDefaultDataProviderUtils.js +37 -1
  55. package/dist/defaults/extensions/utils/dashDefaultNotificationsProcessor.js +149 -1
  56. package/dist/defaults/extensions/utils/index.js +44 -1
  57. package/dist/defaults/filters/demo/dashDefaultDemoFilters.js +36 -1
  58. package/dist/defaults/filters/demo/index.js +4 -1
  59. package/dist/defaults/filters/index.js +5 -1
  60. package/dist/defaults/index.js +14 -1
  61. package/dist/defaults/pages/Account/DashDefaultRegister.js +282 -1
  62. package/dist/defaults/pages/Account/DashDefaultSignUp.js +420 -1
  63. package/dist/defaults/pages/Account/DashDefaultSignUpSuccess.js +101 -1
  64. package/dist/defaults/pages/Account/index.js +8 -1
  65. package/dist/defaults/pages/DashDefaultLogin.js +218 -1
  66. package/dist/defaults/pages/Misc/DashDefaultNotFound.js +74 -1
  67. package/dist/defaults/pages/Misc/DashDefaultServerError.js +79 -1
  68. package/dist/defaults/pages/Misc/DashDefaultUnauthorized.js +90 -1
  69. package/dist/defaults/pages/Misc/index.js +8 -1
  70. package/dist/defaults/pages/Static/DashDefaultPrivacyPage.js +48 -1
  71. package/dist/defaults/pages/Static/DashDefaultStaticPage.js +55 -1
  72. package/dist/defaults/pages/Static/DashDefaultTermsPage.js +52 -1
  73. package/dist/defaults/pages/Static/index.js +8 -1
  74. package/dist/defaults/pages/index.js +25 -1
  75. package/dist/defaults/schemas/dashDefaultSchema.js +14 -1
  76. package/dist/defaults/schemas/demo/dashDefaultTodoSchema.js +24 -1
  77. package/dist/defaults/schemas/demo/index.js +4 -1
  78. package/dist/defaults/schemas/index.js +7 -1
  79. package/dist/filters/demo/todoFilters.js +36 -1
  80. package/dist/index.js +56 -5975
  81. package/dist/resources/demo/todoResource.js +58 -1
  82. package/dist/schemas/defaultSchema.js +14 -1
  83. package/dist/schemas/demo/todoSchema.js +24 -1
  84. package/package.json +132 -77
  85. package/src/DashApp.tsx +294 -0
  86. package/src/DashAppLoader.tsx +717 -0
  87. package/src/DashDefaultResources.tsx +10 -0
  88. package/src/components/DashDefaultPrivateApp.tsx +358 -0
  89. package/src/components/DashDefaultPrivateResources.tsx +10 -0
  90. package/src/components/DashDefaultPublicApp.tsx +40 -0
  91. package/src/components/DashResourceLoader.tsx +564 -0
  92. package/src/defaults/extensions/bootstrap/DashDefaultErrorBoundary.tsx +113 -0
  93. package/src/defaults/extensions/bootstrap/dashDefaultInitializeApp.ts +81 -0
  94. package/src/defaults/extensions/bootstrap/index.ts +32 -0
  95. package/src/defaults/extensions/components/DashDefaultLoader.tsx +59 -0
  96. package/src/defaults/extensions/components/dashDefaultAutoAdminComponents.tsx +49 -0
  97. package/src/defaults/extensions/components/dashDefaultNotification.tsx +37 -0
  98. package/src/defaults/extensions/components/dashDefaultStaticComponents.tsx +34 -0
  99. package/src/defaults/extensions/components/index.ts +17 -0
  100. package/src/defaults/extensions/electron/dashDefaultIpcListeners.ts +62 -0
  101. package/src/defaults/extensions/electron/index.ts +7 -0
  102. package/src/defaults/extensions/hooks/index.ts +11 -0
  103. package/src/defaults/extensions/hooks/useDashDefaultLazyAutoAdminComponents.ts +25 -0
  104. package/src/defaults/extensions/hooks/useDashDefaultLazyI18nProvider.ts +38 -0
  105. package/src/defaults/extensions/hooks/useDashDefaultLazyResources.ts +29 -0
  106. package/src/defaults/extensions/hooks/useDashDefaultMountTracker.ts +28 -0
  107. package/src/defaults/extensions/hooks/useDashDefaultRoutePath.ts +27 -0
  108. package/src/defaults/extensions/i18n/dashDefaultI18nProvider.ts +66 -0
  109. package/src/defaults/extensions/i18n/dashDefaultTranslations.ts +82 -0
  110. package/src/defaults/extensions/i18n/index.ts +22 -0
  111. package/src/defaults/extensions/index.ts +177 -0
  112. package/src/defaults/extensions/layout/dashDefaultDomainAppLayout.tsx +126 -0
  113. package/src/defaults/extensions/layout/index.ts +12 -0
  114. package/src/defaults/extensions/managers/DashDefaultWSMessagesManager.tsx +99 -0
  115. package/src/defaults/extensions/managers/index.ts +7 -0
  116. package/src/defaults/extensions/providers/dashDefaultAuthProvider.ts +256 -0
  117. package/src/defaults/extensions/providers/dashDefaultDataProvider.ts +513 -0
  118. package/src/defaults/extensions/providers/index.ts +25 -0
  119. package/src/defaults/extensions/router/DashDefaultLanding.tsx +51 -0
  120. package/src/defaults/extensions/router/dashDefaultPrivateRoutes.tsx +50 -0
  121. package/src/defaults/extensions/router/dashDefaultPublicRoutes.tsx +86 -0
  122. package/src/defaults/extensions/router/dashDefaultRouter.tsx +54 -0
  123. package/src/defaults/extensions/router/dashDefaultSharedRoutes.tsx +56 -0
  124. package/src/defaults/extensions/router/index.ts +13 -0
  125. package/src/defaults/extensions/state/dashDefaultAppCommon.ts +54 -0
  126. package/src/defaults/extensions/state/dashDefaultAppSettings.ts +29 -0
  127. package/src/defaults/extensions/state/dashDefaultInitialAppState.ts +75 -0
  128. package/src/defaults/extensions/state/dashDefaultLayoutSettings.ts +59 -0
  129. package/src/defaults/extensions/state/dashDefaultQueryClient.ts +59 -0
  130. package/src/defaults/extensions/state/dashDefaultResourcesIcons.tsx +23 -0
  131. package/src/defaults/extensions/state/index.ts +29 -0
  132. package/src/defaults/extensions/styles/index.ts +17 -0
  133. package/src/defaults/extensions/theme/dashDefaultThemeOptions.ts +89 -0
  134. package/src/defaults/extensions/theme/index.ts +7 -0
  135. package/src/defaults/extensions/utils/IPCMessageBrokerContext.tsx +22 -0
  136. package/src/defaults/extensions/utils/dashDefaultAuthProviderUtils.ts +36 -0
  137. package/src/defaults/extensions/utils/dashDefaultDataProviderUtils.ts +46 -0
  138. package/src/defaults/extensions/utils/dashDefaultNotificationsProcessor.tsx +208 -0
  139. package/src/defaults/extensions/utils/index.ts +42 -0
  140. package/src/defaults/filters/demo/dashDefaultDemoFilters.tsx +50 -0
  141. package/src/defaults/filters/demo/index.ts +6 -0
  142. package/src/defaults/filters/index.ts +11 -0
  143. package/src/defaults/index.ts +27 -0
  144. package/src/defaults/pages/Account/DashDefaultRegister.tsx +281 -0
  145. package/src/defaults/pages/Account/DashDefaultSignUp.tsx +492 -0
  146. package/src/defaults/pages/Account/DashDefaultSignUpSuccess.tsx +113 -0
  147. package/src/defaults/pages/Account/index.ts +8 -0
  148. package/src/defaults/pages/DashDefaultLogin.tsx +224 -0
  149. package/src/defaults/pages/Misc/DashDefaultNotFound.tsx +96 -0
  150. package/src/defaults/pages/Misc/DashDefaultServerError.tsx +102 -0
  151. package/src/defaults/pages/Misc/DashDefaultUnauthorized.tsx +116 -0
  152. package/src/defaults/pages/Misc/index.ts +8 -0
  153. package/src/defaults/pages/Static/DashDefaultPrivacyPage.tsx +85 -0
  154. package/src/defaults/pages/Static/DashDefaultStaticPage.tsx +75 -0
  155. package/src/defaults/pages/Static/DashDefaultTermsPage.tsx +69 -0
  156. package/src/defaults/pages/Static/index.ts +8 -0
  157. package/src/defaults/pages/index.ts +28 -0
  158. package/src/defaults/schemas/dashDefaultSchema.tsx +25 -0
  159. package/src/defaults/schemas/demo/dashDefaultTodoSchema.tsx +39 -0
  160. package/src/defaults/schemas/demo/index.ts +6 -0
  161. package/src/defaults/schemas/index.ts +14 -0
  162. package/src/filters/demo/todoFilters.tsx +39 -0
  163. package/src/index.ts +131 -0
  164. package/src/resources/demo/todoResource.tsx +68 -0
  165. package/src/schemas/defaultSchema.tsx +14 -0
  166. package/src/schemas/demo/todoSchema.tsx +27 -0
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Default App Initialization
3
+ *
4
+ * Default bootstrap utilities that wrap the core dash-utils bootstrap.
5
+ * Add app-specific initialization logic here.
6
+ */
7
+ import {
8
+ dashInitializeApp,
9
+ dashBootstrapApp,
10
+ type DashInitializeAppConfig
11
+ } from 'dash-utils';
12
+ import { injectTenantStyles } from 'dash-admin/src/utils/injectTenantStyles';
13
+
14
+ // Re-export the config type for convenience
15
+ export type DashDefaultInitializeAppConfig = DashInitializeAppConfig & {
16
+ /** Default theme for tenant styles injection */
17
+ defaultTheme?: string;
18
+ };
19
+
20
+ /**
21
+ * Dash Default Initialize the application
22
+ * Wraps dashInitializeApp from dash-utils and adds app-specific initialization.
23
+ *
24
+ * @param config - Optional configuration for initialization steps
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * // With default settings
29
+ * await dashDefaultInitializeApp();
30
+ *
31
+ * // With default configuration
32
+ * await dashDefaultInitializeApp({
33
+ * defaultTheme: 'dark',
34
+ * requestNotifications: false
35
+ * });
36
+ * ```
37
+ */
38
+ export const dashDefaultInitializeApp = async (config: DashDefaultInitializeAppConfig = {}): Promise<void> => {
39
+ const { defaultTheme, ...restConfig } = config;
40
+
41
+ // Run the core dash bootstrap
42
+ await dashInitializeApp(restConfig);
43
+
44
+ // Inject tenant styles if theme provided
45
+ if (defaultTheme) {
46
+ injectTenantStyles(defaultTheme);
47
+ }
48
+
49
+ // Add any default app-specific initialization here
50
+ // Example: Initialize analytics, default logging, etc.
51
+ };
52
+
53
+ /**
54
+ * Dash Default synchronous bootstrap sequence for immediate execution
55
+ * Wraps dashBootstrapApp from dash-utils and adds app-specific bootstrap logic.
56
+ *
57
+ * @param defaultTheme - Optional default theme for tenant styles
58
+ *
59
+ * @example
60
+ * ```tsx
61
+ * // In main.tsx before React renders
62
+ * dashDefaultBootstrapApp('dark');
63
+ *
64
+ * // Then render React
65
+ * root.render(<App />);
66
+ * ```
67
+ */
68
+ export const dashDefaultBootstrapApp = (defaultTheme?: string): void => {
69
+ // Run the core dash bootstrap
70
+ dashBootstrapApp();
71
+
72
+ // Inject tenant styles if theme provided
73
+ if (defaultTheme) {
74
+ injectTenantStyles(defaultTheme);
75
+ }
76
+
77
+ // Add any default app-specific bootstrap here
78
+ // Example: Initialize default services, set up listeners, etc.
79
+ };
80
+
81
+ export default dashDefaultInitializeApp;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Default Bootstrap Extensions Index
3
+ *
4
+ * Exports all bootstrap-related utilities for app initialization.
5
+ */
6
+
7
+ // Default Initialization utilities
8
+ export {
9
+ dashDefaultInitializeApp,
10
+ dashDefaultBootstrapApp,
11
+ type DashDefaultInitializeAppConfig
12
+ } from './dashDefaultInitializeApp';
13
+
14
+ // Default UI Components
15
+ export {
16
+ DashDefaultLoader,
17
+ type DashDefaultLoaderProps
18
+ } from '../components/DashDefaultLoader';
19
+
20
+ export {
21
+ DashDefaultErrorBoundary,
22
+ type DashDefaultErrorBoundaryProps,
23
+ type DashDefaultErrorBoundaryState
24
+ } from './DashDefaultErrorBoundary';
25
+
26
+ // Re-export lazy app loader from dash-utils for convenience
27
+ export {
28
+ createLazyAppComponent,
29
+ createSimpleLazyApp,
30
+ DefaultLoadFailedComponent,
31
+ type LazyAppLoaderConfig
32
+ } from 'dash-utils';
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Default Initial Loader Component
3
+ *
4
+ * Displayed during app lazy loading while the main application bundle is being fetched.
5
+ */
6
+ import React from 'react';
7
+
8
+ export interface DashDefaultLoaderProps {
9
+ /** Custom loading message */
10
+ message?: string;
11
+ /** Custom background color (CSS variable or color value) */
12
+ background?: string;
13
+ /** Custom text color (CSS variable or color value) */
14
+ textColor?: string;
15
+ }
16
+
17
+ /**
18
+ * Dash Default loader component shown during app lazy loading
19
+ */
20
+ export const DashDefaultLoader: React.FC<DashDefaultLoaderProps> = ({
21
+ message = 'Loading...',
22
+ background = 'linear-gradient(to bottom, var(--bodybg-primary), var(--bodybg-secondary))',
23
+ textColor = 'var(--text-color, @text-color--dark)'
24
+ }) => (
25
+ <div
26
+ style={{
27
+ display: 'flex',
28
+ flexDirection: 'column',
29
+ justifyContent: 'center',
30
+ alignItems: 'center',
31
+ minHeight: '100vh',
32
+ gap: '16px',
33
+ background,
34
+ color: textColor
35
+ }}
36
+ >
37
+ <div
38
+ style={{
39
+ width: '60px',
40
+ height: '60px',
41
+ border: '4px solid rgba(255, 255, 255, 0.3)',
42
+ borderTop: '4px solid #ffffff',
43
+ borderRadius: '50%',
44
+ animation: 'spin 1s linear infinite'
45
+ }}
46
+ />
47
+ <div style={{ fontSize: '16px' }}>
48
+ {message}
49
+ </div>
50
+ <style>{`
51
+ @keyframes spin {
52
+ 0% { transform: rotate(0deg); }
53
+ 100% { transform: rotate(360deg); }
54
+ }
55
+ `}</style>
56
+ </div>
57
+ );
58
+
59
+ export default DashDefaultLoader;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Dash Default Auto Admin Components Extension
3
+ *
4
+ * Default components that can be dynamically rendered in auto-admin forms.
5
+ * These are registered with the DashAutoAdmin system and can be referenced
6
+ * by name in resource schemas.
7
+ */
8
+ import React from 'react';
9
+ import { IDashAutoAdminCustomFieldComponent } from 'dash-auto-admin';
10
+
11
+ /**
12
+ * Dash default auto admin components
13
+ * Use this for components that are already imported
14
+ */
15
+ export const dashDefaultAutoAdminComponents: Record<string, React.FC<IDashAutoAdminCustomFieldComponent>> = {
16
+ // Add default components here
17
+ };
18
+
19
+ /**
20
+ * Load dash default auto admin components asynchronously
21
+ * This function is used by DASHLazyAdminApp to register default components
22
+ */
23
+ export const loadDashDefaultAutoAdminComponents = async (): Promise<Record<string, React.ComponentType<any>>> => {
24
+ try {
25
+ const [
26
+ JsonComp,
27
+ JsonColorSelectorComp,
28
+ JsonCssVarValuesComp
29
+ ] = await Promise.all([
30
+ import('dash-components').then(module => ({ default: module.Json })),
31
+ import('dash-components').then(module => ({ default: module.JsonColorSelectorEnhanced })),
32
+ import('dash-components').then(module => ({ default: module.JsonCssVarValues }))
33
+ ]);
34
+
35
+ return {
36
+ // Dash components
37
+ Json: JsonComp.default,
38
+ JsonColorSelector: JsonColorSelectorComp.default,
39
+ JsonCssVarValues: JsonCssVarValuesComp.default,
40
+ // App-specific components
41
+ ...dashDefaultAutoAdminComponents,
42
+ };
43
+ } catch (error) {
44
+ console.error('Failed to load dash default auto admin components:', error);
45
+ return dashDefaultAutoAdminComponents;
46
+ }
47
+ };
48
+
49
+ export default loadDashDefaultAutoAdminComponents;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Dash Default Notification Extension
3
+ *
4
+ * Default React-Admin notification component configuration.
5
+ */
6
+ import React from 'react';
7
+ import { Notification } from 'react-admin';
8
+
9
+ /**
10
+ * Dash Default React-Admin Notification component
11
+ * Configured for top-right positioning with 8 second auto-hide
12
+ */
13
+ export const DashDefaultReactAdminNotification = (): React.JSX.Element => {
14
+ return (
15
+ <Notification
16
+ className="dash-notification"
17
+ autoHideDuration={8000}
18
+ multiLine={true}
19
+ anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
20
+ />
21
+ );
22
+ };
23
+
24
+ /**
25
+ * Dash default notification configuration options
26
+ */
27
+ export const dashDefaultNotificationConfig = {
28
+ autoHideDuration: 8000,
29
+ multiLine: true,
30
+ anchorOrigin: {
31
+ vertical: 'top' as const,
32
+ horizontal: 'right' as const
33
+ },
34
+ className: 'dash-notification',
35
+ };
36
+
37
+ export default DashDefaultReactAdminNotification;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Dash Default Static Components Extension
3
+ *
4
+ * Static/memoized components used throughout the application.
5
+ */
6
+ import React from 'react';
7
+
8
+ // Lazy load password pages from dash-admin
9
+ const RecoverPassword = React.lazy(() => import('dash-admin/src/pages/RecoverPassword'));
10
+ const ChangePassword = React.lazy(() => import('dash-admin/src/pages/ChangePassword'));
11
+
12
+ /**
13
+ * Dash default static components configuration
14
+ * These are pre-rendered components that don't need to be recreated
15
+ */
16
+ export const dashDefaultStaticComponents = {
17
+ defaultRecoverPassword: (
18
+ <React.Suspense fallback={<div>Loading...</div>}>
19
+ <RecoverPassword />
20
+ </React.Suspense>
21
+ ),
22
+ defaultChangePassword: (
23
+ <React.Suspense fallback={<div>Loading...</div>}>
24
+ <ChangePassword />
25
+ </React.Suspense>
26
+ ),
27
+ };
28
+
29
+ /**
30
+ * Get dash default static components - useful for memoization
31
+ */
32
+ export const getDashDefaultStaticComponents = () => dashDefaultStaticComponents;
33
+
34
+ export default dashDefaultStaticComponents;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Components Extensions Index
3
+ *
4
+ * Component-related extensions and configurations.
5
+ */
6
+
7
+ // Default Auto Admin Components
8
+ export { loadDashDefaultAutoAdminComponents, dashDefaultAutoAdminComponents } from './dashDefaultAutoAdminComponents';
9
+
10
+ // Default Static Components
11
+ export { dashDefaultStaticComponents, getDashDefaultStaticComponents } from './dashDefaultStaticComponents';
12
+
13
+ // Default Notification
14
+ export { DashDefaultReactAdminNotification, dashDefaultNotificationConfig } from './dashDefaultNotification';
15
+
16
+ // Default Loading Components
17
+ export { DashDefaultLoader, type DashDefaultLoaderProps } from './DashDefaultLoader';
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Dash Default IPC Listeners Extension
3
+ *
4
+ * Electron IPC listener setup and configuration.
5
+ */
6
+ import { useEffect } from 'react';
7
+ import { getDashIPCService, onIPCStdout } from 'dash-utils';
8
+
9
+ /**
10
+ * Hook to set up dash default IPC listeners
11
+ * Listens for Electron IPC events when running in Electron
12
+ */
13
+ export const useDashDefaultIPCListeners = (options?: {
14
+ onStdout?: (data: any) => void;
15
+ enableLogging?: boolean;
16
+ }) => {
17
+ const { onStdout, enableLogging = true } = options || {};
18
+
19
+ useEffect(() => {
20
+ const ipcService = getDashIPCService();
21
+ if (ipcService) {
22
+ // Listen for all stdout events
23
+ onIPCStdout((data) => {
24
+ if (enableLogging) {
25
+ console.log('[DashDefault IPC Stdout]:', data);
26
+ }
27
+ onStdout?.(data);
28
+ });
29
+ }
30
+
31
+ return () => {
32
+ // Clean up listeners if needed
33
+ };
34
+ }, [onStdout, enableLogging]);
35
+ };
36
+
37
+ /**
38
+ * Set up dash default IPC listeners imperatively (non-hook version)
39
+ */
40
+ export const setupDashDefaultIPCListeners = (options?: {
41
+ onStdout?: (data: any) => void;
42
+ enableLogging?: boolean;
43
+ }): (() => void) => {
44
+ const { onStdout, enableLogging = true } = options || {};
45
+
46
+ const ipcService = getDashIPCService();
47
+ if (ipcService) {
48
+ onIPCStdout((data) => {
49
+ if (enableLogging) {
50
+ console.log('[DashDefault IPC Stdout]:', data);
51
+ }
52
+ onStdout?.(data);
53
+ });
54
+ }
55
+
56
+ // Return cleanup function
57
+ return () => {
58
+ // Cleanup if needed
59
+ };
60
+ };
61
+
62
+ export default useDashDefaultIPCListeners;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Electron Extensions Index
3
+ *
4
+ * Electron-specific configurations and hooks.
5
+ */
6
+
7
+ export { useDashDefaultIPCListeners, setupDashDefaultIPCListeners } from './dashDefaultIpcListeners';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Hooks Extensions Index
3
+ *
4
+ * Default React hooks for the application.
5
+ */
6
+
7
+ export { useDashDefaultMountTracker } from './useDashDefaultMountTracker';
8
+ export { useDashDefaultRoutePath } from './useDashDefaultRoutePath';
9
+ export { useDashDefaultLazyI18nProvider } from './useDashDefaultLazyI18nProvider';
10
+ export { useDashDefaultLazyAutoAdminComponents } from './useDashDefaultLazyAutoAdminComponents';
11
+ export { useDashDefaultLazyResources } from './useDashDefaultLazyResources';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * useDashDefaultLazyAutoAdminComponents Hook
3
+ *
4
+ * Hook to load dash default auto admin components asynchronously
5
+ */
6
+ import { useState, useEffect } from 'react';
7
+ import loadDashDefaultAutoAdminComponents from '../components/dashDefaultAutoAdminComponents';
8
+
9
+
10
+ export const useDashDefaultLazyAutoAdminComponents = () => {
11
+ const [components, setComponents] = useState<Record<string, React.ComponentType<any>> | null>(null);
12
+
13
+ useEffect(() => {
14
+ loadDashDefaultAutoAdminComponents()
15
+ .then(setComponents)
16
+ .catch((error) => {
17
+ console.error('Failed to load dash default auto admin components:', error);
18
+ setComponents({});
19
+ });
20
+ }, []);
21
+
22
+ return components;
23
+ };
24
+
25
+ export default useDashDefaultLazyAutoAdminComponents;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * useDashDefaultLazyI18nProvider Hook
3
+ *
4
+ * Hook to load i18n provider asynchronously
5
+ */
6
+ import { useState, useEffect } from 'react';
7
+ import { useSelector } from 'react-redux';
8
+ import { loadDashDefaultTranslationsAsync, createDashDefaultI18nProviderAsync } from '../i18n/dashDefaultI18nProvider';
9
+ import { fromPairs } from 'lodash';
10
+
11
+ export const useDashDefaultLazyI18nProvider = () => {
12
+ const [translations, setTranslations] = useState<any>(null);
13
+ const [i18nProvider, setI18nProvider] = useState<any>(null);
14
+ const settings = useSelector((state: any) => state.settings);
15
+
16
+ useEffect(() => {
17
+ const load = async () => {
18
+ try {
19
+ const translationsData = await loadDashDefaultTranslationsAsync();
20
+ setTranslations(translationsData);
21
+
22
+ const provider = await createDashDefaultI18nProviderAsync(
23
+ settings?.locale || 'en',
24
+ settings?.availableLocales?.map(({ locale, name }: { locale: string; name: string }) => ({ locale, name }))
25
+ );
26
+ setI18nProvider(provider);
27
+ } catch (error) {
28
+ console.error('Failed to load translations:', error);
29
+ }
30
+ };
31
+
32
+ load();
33
+ }, [settings?.locale, settings?.availableLocales]);
34
+
35
+ return { translations, i18nProvider };
36
+ };
37
+
38
+ export default useDashDefaultLazyI18nProvider;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * useDashDefaultLazyResources Hook
3
+ *
4
+ * Hook to lazy load resources
5
+ */
6
+ import { useState, useEffect } from 'react';
7
+ import { IDashAutoAdminResourceConfig } from 'dash-auto-admin';
8
+ import { getDASHResources } from 'dash-admin';
9
+
10
+ export const useDashDefaultLazyResources = (customResources: IDashAutoAdminResourceConfig[] | null) => {
11
+ const [loadedResources, setLoadedResources] = useState<IDashAutoAdminResourceConfig[] | null>(null);
12
+
13
+ useEffect(() => {
14
+ // Only load default resources if no custom resources are provided
15
+ if (!customResources) {
16
+ getDASHResources()
17
+ .then(setLoadedResources)
18
+ .catch((error) => {
19
+ console.error('Failed to load DASHResources:', error);
20
+ setLoadedResources([]);
21
+ });
22
+ }
23
+ }, [customResources]);
24
+
25
+ // Return custom resources if provided, otherwise loaded resources
26
+ return customResources || loadedResources;
27
+ };
28
+
29
+ export default useDashDefaultLazyResources;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * useDashDefaultMountTracker Hook
3
+ *
4
+ * Hook to track mount count for workaround with re-render issues
5
+ */
6
+ import { useState, useEffect } from 'react';
7
+ import { dashStorage } from 'dash-utils';
8
+
9
+ export const useDashDefaultMountTracker = (expectedMounts: number | null) => {
10
+ const [fullyLoaded, setFullyLoaded] = useState<boolean>(false);
11
+
12
+ useEffect(() => {
13
+ const currentValue = parseInt(dashStorage.getItem("tmp"), 10) || 0;
14
+ dashStorage.setItem("tmp", String(currentValue + 1));
15
+ }, []);
16
+
17
+ useEffect(() => {
18
+ if (!expectedMounts) {
19
+ setFullyLoaded(true);
20
+ } else if (parseInt(dashStorage.getItem("tmp"), 10) >= expectedMounts) {
21
+ setFullyLoaded(true);
22
+ }
23
+ }, [expectedMounts]);
24
+
25
+ return fullyLoaded;
26
+ };
27
+
28
+ export default useDashDefaultMountTracker;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * useDashDefaultRoutePath Hook
3
+ *
4
+ * Hook to calculate and track route path
5
+ *
6
+ * @deprecated The currentAppPath storage logic has been removed to fix path duplication issues.
7
+ * This hook now only returns the route path without storing it.
8
+ */
9
+ import { useState, useEffect } from 'react';
10
+ import { DASHAdminSystemConstants } from 'dash-constants';
11
+
12
+ export const useDashDefaultRoutePath = (appPath: string | null, commonAppPath?: string) => {
13
+ const [routePath, setRoutePath] = useState<string>('');
14
+
15
+ useEffect(() => {
16
+ const path = appPath || (commonAppPath || DASHAdminSystemConstants.system.URL_PREFIX);
17
+ const cleanPath = path.replace(/\/\*$/, '');
18
+ // @deprecated - removed currentAppPath storage that caused path duplication
19
+ // dashStorage.setItem('currentAppPath', cleanPath);
20
+ console.log('ROUTE-BASE-PATH:', cleanPath);
21
+ setRoutePath(path);
22
+ }, [appPath, commonAppPath]);
23
+
24
+ return routePath;
25
+ };
26
+
27
+ export default useDashDefaultRoutePath;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Dash Default i18n Provider Extension
3
+ *
4
+ * Internationalization provider configuration with memoization support.
5
+ */
6
+ import { useMemo } from 'react';
7
+ import polyglotI18nProvider from 'ra-i18n-polyglot';
8
+ import { dashDefaultTranslations, dashDefaultAvailableLocales, dashDefaultLocale } from './dashDefaultTranslations';
9
+
10
+ // Re-export dash default translations
11
+ export { dashDefaultTranslations, dashDefaultAvailableLocales, dashDefaultLocale } from './dashDefaultTranslations';
12
+ export { loadDashDefaultTranslationsAsync, createDashDefaultI18nProviderAsync } from './dashDefaultTranslations';
13
+ /**
14
+ * Create dash default i18n provider with settings state
15
+ */
16
+ export const createDashDefaultI18nProviderWithSettings = (settings: {
17
+ locale?: string;
18
+ availableLocales?: Array<{ locale: string; name: string }>;
19
+ }) => {
20
+ const locale = settings.locale || dashDefaultLocale;
21
+ const locales = settings.availableLocales || dashDefaultAvailableLocales;
22
+
23
+ return polyglotI18nProvider(
24
+ (loc) => dashDefaultTranslations[loc as keyof typeof dashDefaultTranslations] || dashDefaultTranslations.en,
25
+ locale,
26
+ locales
27
+ );
28
+ };
29
+
30
+ /**
31
+ * Hook to create memoized dash default i18n provider
32
+ * Prevents recreation on every render
33
+ */
34
+ export const useDashDefaultI18nProvider = (settings?: {
35
+ locale?: string;
36
+ availableLocales?: Array<{ locale: string; name: string }>;
37
+ }) => {
38
+ return useMemo(() => {
39
+ const locale = settings?.locale || dashDefaultLocale;
40
+ const locales = settings?.availableLocales || dashDefaultAvailableLocales;
41
+
42
+ return polyglotI18nProvider(
43
+ (loc) => dashDefaultTranslations[loc as keyof typeof dashDefaultTranslations] || dashDefaultTranslations.en,
44
+ locale,
45
+ locales.map(({ locale, name }) => ({ locale, name }))
46
+ );
47
+ }, [settings?.locale, settings?.availableLocales]);
48
+ };
49
+
50
+ /**
51
+ * Create dash default i18n provider from INITIAL_APP_STATE settings
52
+ */
53
+ export const createDashDefaultI18nProviderFromAppState = (appState: {
54
+ settings: {
55
+ locale: string;
56
+ availableLocales: Array<{ locale: string; name: string }>;
57
+ };
58
+ }) => {
59
+ return polyglotI18nProvider(
60
+ (loc) => dashDefaultTranslations[loc as keyof typeof dashDefaultTranslations] || dashDefaultTranslations.en,
61
+ appState.settings.locale,
62
+ appState.settings.availableLocales.map(({ locale, name }) => ({ locale, name }))
63
+ );
64
+ };
65
+
66
+ export default useDashDefaultI18nProvider;