@dashadmin/dash-admin 1.3.72 → 1.3.74-srcfree.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 (289) hide show
  1. package/dist/components/tenant/TenancyPlan.js +307 -0
  2. package/dist/systemResources.js +18 -2
  3. package/package.json +25 -22
  4. package/src/AppAsyncWrapper.tsx +0 -42
  5. package/src/AppWrapper.tsx +0 -45
  6. package/src/DASHAdmin.tsx +0 -502
  7. package/src/DASHAdmin.tsx.old +0 -456
  8. package/src/RoutingWrapper.tsx +0 -143
  9. package/src/classes/DASHStorageClass.tsx +0 -8
  10. package/src/components/Input/RichTextField.tsx +0 -27
  11. package/src/components/Redirect.tsx +0 -46
  12. package/src/components/avatar/Avatar.tsx +0 -71
  13. package/src/components/avatar/SingleImageUploader.tsx +0 -107
  14. package/src/components/currency/Format.tsx +0 -79
  15. package/src/components/custom/Redirect.tsx +0 -23
  16. package/src/components/error/Error.tsx +0 -168
  17. package/src/components/geocoding/GeocodingField.tsx +0 -167
  18. package/src/components/i18n/BridgedLocalesMenuButton.tsx +0 -160
  19. package/src/components/i18n/LangSwitcher.tsx +0 -204
  20. package/src/components/loader/GlobalLoader.tsx +0 -49
  21. package/src/components/logs/LogFile.tsx +0 -88
  22. package/src/components/logs/LogFileById.tsx +0 -68
  23. package/src/components/logs/LogViewer.tsx +0 -43
  24. package/src/components/menu/AppMenu.tsx +0 -22
  25. package/src/components/menu/CustomMenuItemLink.tsx +0 -61
  26. package/src/components/menu/DarkToggleMode.tsx +0 -65
  27. package/src/components/menu/LanguageToggleMode.tsx +0 -120
  28. package/src/components/misc/CustomImageInput.tsx +0 -62
  29. package/src/components/misc/DASHGlobalErrorHandler.tsx +0 -194
  30. package/src/components/misc/DarkModeSwitcher.tsx +0 -112
  31. package/src/components/misc/HorizontalScroller.tsx +0 -225
  32. package/src/components/misc/LanguageSwitcher.tsx +0 -199
  33. package/src/components/misc/MUIHtmlToolTip.tsx +0 -15
  34. package/src/components/misc/MuiSimpleJsonTable.tsx +0 -279
  35. package/src/components/misc/MultiLevelTable.tsx +0 -229
  36. package/src/components/misc/NoResults.tsx +0 -28
  37. package/src/components/misc/PDFViewer.tsx +0 -85
  38. package/src/components/navigation/Breadcrumbs.tsx +0 -220
  39. package/src/components/navigation/BreadcrumbsManager.tsx +0 -310
  40. package/src/components/navigation/index.tsx +0 -5
  41. package/src/components/panel/Error.tsx +0 -168
  42. package/src/components/permission/AvailablePermissionsContext.tsx +0 -173
  43. package/src/components/permission/PermissionsSelector.tsx +0 -834
  44. package/src/components/permission/PermissionsSelectorList.tsx +0 -473
  45. package/src/components/permission/tsx +0 -0
  46. package/src/components/racustombuttons/CustomRAButton.tsx +0 -87
  47. package/src/components/racustombuttons/QuickButton.tsx +0 -117
  48. package/src/components/racustombuttons/QuickEditButton.tsx +0 -115
  49. package/src/components/racustombuttons/QuickIconButton.tsx +0 -122
  50. package/src/components/scrollbar/Scrollbar.tsx +0 -31
  51. package/src/components/selects/MultiSelect.tsx +0 -53
  52. package/src/components/selects/RASearchableSelect.tsx +0 -282
  53. package/src/components/selects/RASearchableSelectChips.tsx +0 -308
  54. package/src/components/selects/SearchableSelect.tsx +0 -139
  55. package/src/components/serviceAccount/ApiKeyRevealDialog.tsx +0 -129
  56. package/src/components/serviceAccount/ServiceAccountStatusSwitch.tsx +0 -99
  57. package/src/components/subscription/BillingCycleSelectInput.tsx +0 -68
  58. package/src/components/subscription/PlanAddonsSettings.tsx +0 -563
  59. package/src/components/subscription/PlanAuditLog.tsx +0 -453
  60. package/src/components/subscription/PlanFeaturesSettings.tsx +0 -243
  61. package/src/components/subscription/PlanLimitsSettings.tsx +0 -230
  62. package/src/components/subscription/PlanMetadataSettings.tsx +0 -306
  63. package/src/components/subscription/PlanPricesSettings.tsx +0 -307
  64. package/src/components/subscription/index.ts +0 -7
  65. package/src/components/svgelements/SvgLoading.tsx +0 -229
  66. package/src/components/svgelements/SvgLogo.tsx +0 -53
  67. package/src/components/svgelements/SvgLogoMin.tsx +0 -64
  68. package/src/components/svgelements/SvgShipping.tsx +0 -673
  69. package/src/components/tenancy/GlobalTenantWrapper.tsx +0 -84
  70. package/src/components/tenancy/TenantSwitcher.tsx +0 -514
  71. package/src/components/tenant/AvailablePermissionsContext.tsx +0 -0
  72. package/src/components/tenant/SettingsSections.tsx +0 -151
  73. package/src/components/tenant/TenancySettings.tsx +0 -122
  74. package/src/components/tenant/TenantAttributes.tsx +0 -153
  75. package/src/components/tenant/TenantAttributesContext.tsx +0 -163
  76. package/src/components/tenant/TenantSelector.tsx +0 -142
  77. package/src/components/tenant/TenantSettings.tsx +0 -184
  78. package/src/components/tenant/TenantSettingsContext.tsx +0 -165
  79. package/src/components/tenant/TenantTheme.tsx +0 -172
  80. package/src/components/user/AvatarComponent.tsx +0 -317
  81. package/src/components/user/TenantAvatarComponent.tsx +0 -99
  82. package/src/components/user/UserPreferences.tsx +0 -677
  83. package/src/config/ACTIONS.tsx +0 -26
  84. package/src/config/ConstantsService.tsx +0 -44
  85. package/src/config/DASHAdminSystemConstants.tsx +0 -183
  86. package/src/config/PARSERS.tsx +0 -9
  87. package/src/contexts/DashQueryClientContext.tsx +0 -113
  88. package/src/contexts/DashResourceContext.tsx +0 -34
  89. package/src/contexts/I18nBridgeContext.tsx +0 -156
  90. package/src/contexts/I18nBridgeSetter.tsx +0 -39
  91. package/src/contexts/I18nReduxSync.tsx +0 -27
  92. package/src/contexts/SubscriptionPlanFormatsProvider.tsx +0 -217
  93. package/src/contexts/SystemRequestsCache.tsx +0 -215
  94. package/src/contexts/auth/AuthContext.tsx +0 -567
  95. package/src/contexts/auth/AuthContextLocalStorage.tsx +0 -140
  96. package/src/contexts/auth/DASHAuthenticationService.tsx +0 -915
  97. package/src/contexts/auth/WindowContext.tsx +0 -15
  98. package/src/contexts/auth/index.tsx +0 -3
  99. package/src/contexts/com/FCMContext.tsx +0 -415
  100. package/src/contexts/com/LaravelEchoContext.tsx +0 -41
  101. package/src/contexts/com/LaravelEchoMgr.tsx +0 -155
  102. package/src/contexts/com/components/DefaultNotificationComponent.tsx +0 -20
  103. package/src/contexts/com/components/EchoNotificationsCenter.tsx +0 -65
  104. package/src/contexts/com/components/NotificationAttributesTable.tsx +0 -54
  105. package/src/contexts/com/components/NotificationRenderer.tsx +0 -42
  106. package/src/contexts/com/components/NotificationsWidget.tsx +0 -182
  107. package/src/contexts/com/components/notificationFormats.tsx +0 -50
  108. package/src/contexts/com/useLaravelEcho.tsx +0 -432
  109. package/src/contexts/dictionary/DictionaryContext.tsx +0 -94
  110. package/src/declarations.d.ts +0 -17
  111. package/src/default-theme/DASHAppProviders.tsx +0 -117
  112. package/src/default-theme/DashThemeContext.tsx +0 -209
  113. package/src/default-theme/DashThemeContext.tsx.fast +0 -143
  114. package/src/default-theme/DashThemeContext.tsx.old +0 -306
  115. package/src/default-theme/DashThemeHelperProvider.tsx +0 -98
  116. package/src/default-theme/DomainAppLayout.tsx +0 -166
  117. package/src/default-theme/DomainHeader.tsx +0 -162
  118. package/src/default-theme/DomainTheme.tsx +0 -59
  119. package/src/default-theme/FullLayoutMarkup.tsx +0 -231
  120. package/src/default-theme/StaticLayout.tsx +0 -47
  121. package/src/default-theme/index.tsx +0 -11
  122. package/src/default-theme/menu/AppDashboardGrid.tsx +0 -279
  123. package/src/default-theme/menu/AppMaterialMenu.tsx +0 -546
  124. package/src/default-theme/menu/AppMenuComponents/SubmenuPortal.tsx +0 -61
  125. package/src/default-theme/menu/AppMenuComponents/collapsed/CollapsedSidebarItem.tsx +0 -264
  126. package/src/default-theme/menu/AppMenuComponents/collapsed/CollapsedSidebarItems.tsx +0 -31
  127. package/src/default-theme/menu/AppMenuComponents/expanded/CollapsableSidebarMenu.tsx +0 -293
  128. package/src/default-theme/menu/AppMenuComponents/expanded/SidebarItem.tsx +0 -92
  129. package/src/default-theme/menu/AppMenuComponents/getItem.tsx +0 -17
  130. package/src/default-theme/menu/AppMenuComponents/interfaces.tsx +0 -41
  131. package/src/default-theme/menu/AppMenuComponents/submenuConstants.ts +0 -90
  132. package/src/default-theme/menu/AppSidebarMaterial.tsx +0 -339
  133. package/src/default-theme/menu/SidebarActions.tsx +0 -84
  134. package/src/default-theme/updateDomCssVariables.tsx +0 -176
  135. package/src/helpers/checkRole.tsx +0 -66
  136. package/src/helpers/parseAxiosError.tsx +0 -41
  137. package/src/hooks/audio/useAudio.tsx +0 -39
  138. package/src/hooks/axios.tsx +0 -165
  139. package/src/hooks/data/useDashboardStats.tsx +0 -65
  140. package/src/hooks/data/usePackageByClientsStats.tsx +0 -44
  141. package/src/hooks/data/usePackageByCommunesStats.tsx +0 -44
  142. package/src/hooks/data/usePackageStats.tsx +0 -69
  143. package/src/hooks/data/usePackageWithdrawDetails.tsx +0 -61
  144. package/src/hooks/data/useStats.tsx +0 -86
  145. package/src/hooks/isCurrentPath.tsx +0 -22
  146. package/src/hooks/notifications/WSMessagesManager.tsx +0 -152
  147. package/src/hooks/notifications/WSPusherManager.tsx +0 -92
  148. package/src/hooks/useBreadcrumbs.tsx +0 -329
  149. package/src/hooks/useClickOutside.tsx +0 -57
  150. package/src/hooks/useFormPersistance.tsx +0 -150
  151. package/src/hooks/useGlobalErrorMediator.tsx +0 -43
  152. package/src/hooks/useGlobalLoaderMgr.tsx +0 -21
  153. package/src/hooks/useHash.tsx +0 -27
  154. package/src/hooks/useLocalStorage.tsx +0 -196
  155. package/src/hooks/usePolyglotTranslation.tsx +0 -62
  156. package/src/hooks/usePrevious.tsx +0 -9
  157. package/src/hooks/usePrintSelected.tsx +0 -37
  158. package/src/hooks/useVirtualHash.tsx +0 -33
  159. package/src/hooks/window/useWindowSize.tsx +0 -36
  160. package/src/index.tsx +0 -134
  161. package/src/interfaces/IAppResourceConfig.tsx +0 -20
  162. package/src/interfaces/Log.tsx +0 -16
  163. package/src/interfaces/Tenant.tsx +0 -25
  164. package/src/interfaces/communication/IActions.tsx +0 -5
  165. package/src/interfaces/communication/INotification.tsx +0 -21
  166. package/src/interfaces/communication/IPayload.tsx +0 -3
  167. package/src/interfaces/communication/IRequestAction.tsx +0 -10
  168. package/src/interfaces/communication/IRequestPayload.tsx +0 -7
  169. package/src/interfaces/communication/IResponseAction.tsx +0 -7
  170. package/src/interfaces/misc/IAny.tsx +0 -3
  171. package/src/interfaces/misc/IFlashMessage.tsx +0 -10
  172. package/src/interfaces/navigation/IAppMenu.ts +0 -14
  173. package/src/interfaces/navigation/ICollapsableSidebarMenu.ts +0 -12
  174. package/src/interfaces/navigation/IMenuItem.ts +0 -16
  175. package/src/interfaces/notifications/IModel.tsx +0 -6
  176. package/src/interfaces/notifications/IModelField.tsx +0 -8
  177. package/src/interfaces/notifications/IUserNotification.tsx +0 -12
  178. package/src/interfaces/notifications/IUserNotificationData.tsx +0 -13
  179. package/src/interfaces/notifications/IUserNotificationPayload.tsx +0 -8
  180. package/src/interfaces/user/IGetAuth.tsx +0 -92
  181. package/src/interfaces/user/ITenantSettings.tsx +0 -3
  182. package/src/interfaces/user/IUser.tsx +0 -60
  183. package/src/interfaces/user/IUserSettings.tsx +0 -43
  184. package/src/interfaces.tsx +0 -6
  185. package/src/layout/AppLayout.tsx +0 -112
  186. package/src/layout/ApplicationLayout.tsx +0 -197
  187. package/src/layout/MotionWrapper.original.tsx +0 -236
  188. package/src/layout/MotionWrapper.tsx +0 -236
  189. package/src/layout/ResourceMenu.tsx +0 -164
  190. package/src/layout/ResoureLayout.tsx +0 -105
  191. package/src/layout/TransitionWrapper.tsx +0 -125
  192. package/src/pages/ChangePassword.tsx +0 -179
  193. package/src/pages/DASHLanding.tsx +0 -22
  194. package/src/pages/DASHLightWeightLogin.tsx +0 -611
  195. package/src/pages/DASHSimpleLogin.tsx +0 -260
  196. package/src/pages/Login.tsx +0 -111
  197. package/src/pages/Profile.tsx +0 -357
  198. package/src/pages/RecoverPassword.tsx +0 -175
  199. package/src/pages/SingleImageUploader.tsx +0 -55
  200. package/src/pages/VerifyAccount.tsx +0 -128
  201. package/src/providers/authProvider.tsx +0 -217
  202. package/src/providers/dataProvider.tsx +0 -672
  203. package/src/providers/i18n/en.ts +0 -646
  204. package/src/providers/i18n/es.ts +0 -652
  205. package/src/providers/i18n/languages.tsx +0 -8
  206. package/src/providers/i18n/mergeTranslations.ts +0 -53
  207. package/src/providers/i18nProvider.tsx +0 -23
  208. package/src/react-admin-dash/RADashComponent.tsx +0 -240
  209. package/src/react-admin-dash/Resource.tsx +0 -77
  210. package/src/resources/Brand/BrandResource.tsx +0 -130
  211. package/src/resources/DASHResourceLoader.ts +0 -180
  212. package/src/resources/Log/LogResource.tsx +0 -73
  213. package/src/resources/Tenant/ImpersonateTenantResource.tsx +0 -113
  214. package/src/resources/Trash/TrashTemplate.tsx +0 -180
  215. package/src/resources/User/components/AvatarUploadField.tsx +0 -57
  216. package/src/resources/User/components/PasswordFields.tsx +0 -73
  217. package/src/resources/User/getProfileMenu.ts +0 -57
  218. package/src/resources/User/profileResource.tsx +0 -51
  219. package/src/resources/User/userLayout.tsx +0 -62
  220. package/src/resources/User/userResource.tsx +0 -111
  221. package/src/resources/User/userSchema.tsx +0 -213
  222. package/src/resources/User/usersFilters.tsx +0 -21
  223. package/src/resources.tsx +0 -280
  224. package/src/schemas/log.tsx +0 -45
  225. package/src/schemas/notification.tsx +0 -42
  226. package/src/schemas/permissions.tsx +0 -44
  227. package/src/schemas/roles.tsx +0 -48
  228. package/src/schemas/rolesDataGrid.tsx +0 -48
  229. package/src/schemas/subscription/components/SubscriptionActions.tsx +0 -153
  230. package/src/schemas/subscription/components/SubscriptionPaymentHistory.tsx +0 -127
  231. package/src/schemas/subscription/components/SubscriptionPlanFeatures.tsx +0 -162
  232. package/src/schemas/subscription/components/SubscriptionPlanPreview.tsx +0 -141
  233. package/src/schemas/subscription/components/SubscriptionPlanStats.tsx +0 -318
  234. package/src/schemas/subscription/components/SubscriptionStatusIndicator.tsx +0 -72
  235. package/src/schemas/subscription/subscriptionPlanSchema.tsx +0 -185
  236. package/src/schemas/subscription/subscriptionSchema.tsx +0 -152
  237. package/src/schemas/subscriptionPlan.ts +0 -422
  238. package/src/schemas/tenant.tsx +0 -129
  239. package/src/schemas/tenantUser.tsx +0 -96
  240. package/src/schemas/tenant_superadmin.tsx +0 -119
  241. package/src/schemas/user.tsx +0 -26
  242. package/src/systemResources.old.tsx +0 -928
  243. package/src/systemResources.tsx +0 -1369
  244. package/src/templates/ResourceTemplate.tsx +0 -240
  245. package/src/templates/ResourceTemplate.tsx.memoized_experiment +0 -350
  246. package/src/templates/ResourceTemplate.tsx.original +0 -396
  247. package/src/templates/ResourceTemplateCreate.tsx +0 -182
  248. package/src/templates/ResourceTemplateEdit.tsx +0 -176
  249. package/src/templates/ResourceTemplateFull.tsx +0 -581
  250. package/src/templates/ResourceTemplateList.tsx +0 -340
  251. package/src/templates/ResourceTemplateOld.tsx.bkup +0 -567
  252. package/src/templates/ResourceTemplateShow.tsx +0 -88
  253. package/src/templates/TrashTemplate.tsx +0 -179
  254. package/src/tenantResources.tsx +0 -223
  255. package/src/test_portal_bubbles.tsx +0 -40
  256. package/src/theme/AppHeader.tsx +0 -52
  257. package/src/theme/AppLayoutSetting.tsx +0 -33
  258. package/src/theme/AppLogo.tsx +0 -13
  259. package/src/theme/AppSidebar.tsx +0 -12
  260. package/src/theme/AppSidebarContent.tsx +0 -105
  261. package/src/theme/AppSidebarLogo.tsx +0 -48
  262. package/src/theme/components/PageTitle.tsx +0 -37
  263. package/src/utils/cache/CacheInvalidatorContext.tsx +0 -125
  264. package/src/utils/cache/CacheInvalidatorListenerComponent.tsx +0 -10
  265. package/src/utils/cache/useCacheInvalidatorListener.tsx +0 -27
  266. package/src/utils/convertFileToBase64.tsx +0 -9
  267. package/src/utils/convertToFile.tsx +0 -14
  268. package/src/utils/cookies.tsx +0 -33
  269. package/src/utils/dashDefaultQueryClient.tsx +0 -34
  270. package/src/utils/dataUrlToBlob.tsx +0 -30
  271. package/src/utils/deepReplace.tsx +0 -19
  272. package/src/utils/getProfileMenu.tsx +0 -41
  273. package/src/utils/getTenantSettings.tsx +0 -9
  274. package/src/utils/getType.tsx +0 -8
  275. package/src/utils/getUserSettings.tsx +0 -8
  276. package/src/utils/hasCode.tsx +0 -14
  277. package/src/utils/index.ts +0 -19
  278. package/src/utils/injectTenantStyles.ts +0 -28
  279. package/src/utils/isComponent.tsx +0 -45
  280. package/src/utils/navEvents.tsx +0 -91
  281. package/src/utils/prototypes.tsx +0 -5
  282. package/src/utils/regexp.tsx +0 -4
  283. package/src/utils/resolveObjectPath.tsx +0 -4
  284. package/src/utils/setNativeValue.tsx +0 -24
  285. package/src/utils/slugify.tsx +0 -11
  286. package/src/utils/validators/emailValidator.tsx +0 -6
  287. package/src/utils/validators/requiredValidator.tsx +0 -5
  288. package/src/utils/validators/rutValidator.tsx +0 -31
  289. package/src/utils/validators.tsx +0 -96
@@ -1,209 +0,0 @@
1
- import React, { createContext, useContext, useState, useEffect } from 'react';
2
- import { appTheme, getAntTheme } from 'dash-styles';
3
- import { AuthPersistenceService } from 'dash-auth';
4
- import { useSelector } from 'react-redux';
5
- import { IDASHAppState } from 'dash-admin-state';
6
- import { updateDomCssVariables } from 'dash-utils';
7
- import CssBaseline from '@mui/material/CssBaseline';
8
- import ConfigProvider from 'antd/es/config-provider';
9
-
10
-
11
- import {
12
- Theme,
13
- createTheme,
14
- ThemeProvider
15
- } from '@mui/material';
16
-
17
- interface DashThemeContextType {
18
- theme: Theme;
19
- themeOptions: ReturnType<typeof appTheme>;
20
- recreateTheme: (tenantSettings?: any) => void;
21
- currentMode: string;
22
- }
23
-
24
-
25
-
26
- const DashThemeContext = createContext<DashThemeContextType | null>(null);
27
-
28
- // Defensive patch for MUI v9: createThemeWithVars can produce a theme where
29
- // breakpoints.internal_mediaKeys is missing. Ensure it is always set so that
30
- // responsive `sx` props (e.g. `padding: { xs: 2, sm: 3 }`) do not crash.
31
- function patchThemeBreakpoints(theme: Theme): Theme {
32
- const bp = (theme as any).breakpoints;
33
- if (bp && !bp.internal_mediaKeys && bp.keys && bp.up) {
34
- bp.internal_mediaKeys = bp.keys.map((key: string) => bp.up(key));
35
- }
36
- return theme;
37
- }
38
-
39
- export const useDashThemeContext = () => {
40
- const context = useContext(DashThemeContext);
41
- if (!context) {
42
- throw new Error('useDashThemeContext must be used within a DashThemeProvider');
43
- }
44
- return context;
45
- };
46
-
47
- interface DashThemeProviderProps {
48
- children?: React.ReactNode;
49
- extendedOptions?: any;
50
- }
51
-
52
- export const DashThemeProvider: React.FC<DashThemeProviderProps> = ({ extendedOptions, children }) => {
53
- // Track current theme mode from data-theme attribute
54
- const [currentMode, setCurrentMode] = useState<string>(() => {
55
- return document.documentElement.getAttribute('data-theme') || 'dark';
56
- });
57
-
58
- const [themeOptions, setThemeOptions] = useState<ReturnType<typeof appTheme>>(() => {
59
- // Read persisted tenant settings on initialization to include tenant colors
60
- // in the initial theme, avoiding a flash of default colors.
61
- const initialTenantSettings = AuthPersistenceService.getTenantSettings();
62
- return appTheme(extendedOptions, {
63
- currentMode,
64
- colors: initialTenantSettings?.colors,
65
- tenantSettings: initialTenantSettings,
66
- });
67
- });
68
-
69
- const [theme, setTheme] = useState<Theme>(() => {
70
- const initialTenantSettings = AuthPersistenceService.getTenantSettings();
71
- /* @ts-ignore */
72
- return patchThemeBreakpoints(createTheme(appTheme(extendedOptions, {
73
- currentMode,
74
- colors: initialTenantSettings?.colors,
75
- tenantSettings: initialTenantSettings,
76
- })));
77
- });
78
-
79
-
80
- const [antTheme, setAntTheme] = useState<any>(() => {
81
- const initialTenantSettings = AuthPersistenceService.getTenantSettings();
82
-
83
- return getAntTheme({
84
- currentMode,
85
- colors: initialTenantSettings?.colors,
86
- tenantSettings: initialTenantSettings,
87
- });
88
- });
89
-
90
- const getTenantSettings = () => {
91
- const persistedTenantSettings = AuthPersistenceService.getTenantSettings();
92
- return persistedTenantSettings || null;
93
- };
94
-
95
- const recreateTheme = (tenantSettings?: any, mode?: string) => {
96
- const settings = tenantSettings || getTenantSettings();
97
- //const themeMode = mode || currentMode;
98
- const themeMode = mode || document.documentElement.getAttribute('data-theme') || 'dark';
99
-
100
- const newThemeOptions = appTheme(
101
- extendedOptions,
102
- {
103
- tenantSettings: settings,
104
- colors: settings?.colors,
105
- currentMode: themeMode,
106
- }
107
- );
108
- /* @ts-ignore */
109
- const newTheme = patchThemeBreakpoints(createTheme(newThemeOptions));
110
-
111
- setThemeOptions(newThemeOptions);
112
- setTheme(newTheme);
113
-
114
-
115
- setAntTheme(getAntTheme({
116
- tenantSettings: settings,
117
- colors: settings?.colors,
118
- currentMode: themeMode,
119
- }));
120
-
121
- updateDomCssVariables(themeMode, settings?.colors, settings?.values);
122
- /*if (settings?.colors || settings?.values) {
123
- updateDomCssVariables(themeMode, settings?.colors, settings?.values);
124
- }*/
125
- };
126
-
127
- // Observer for data-theme attribute changes
128
- useEffect(() => {
129
- const observer = new MutationObserver((mutations) => {
130
- mutations.forEach((mutation) => {
131
- if (mutation.type === 'attributes' && mutation.attributeName === 'data-theme') {
132
- const newMode = document.documentElement.getAttribute('data-theme') || 'dark';
133
- if (newMode !== currentMode) {
134
- setCurrentMode(newMode);
135
- const settings = getTenantSettings();
136
- updateDomCssVariables(newMode, settings?.colors, settings?.values);
137
- }
138
- }
139
- });
140
- });
141
-
142
- // Start observing
143
- observer.observe(document.documentElement, {
144
- attributes: true,
145
- attributeFilter: ['data-theme']
146
- });
147
-
148
- // Cleanup observer on unmount
149
- return () => observer.disconnect();
150
- }, [currentMode]);
151
-
152
- // React to mode changes
153
- useEffect(() => {
154
- const tenantSettings = getTenantSettings();
155
- recreateTheme(tenantSettings, currentMode);
156
- }, [currentMode]);
157
-
158
- // Initial setup
159
- useEffect(() => {
160
- const tenantSettings = getTenantSettings();
161
- if (tenantSettings) {
162
- recreateTheme(tenantSettings, currentMode);
163
- }
164
- }, []);
165
-
166
- // Listen for DASHTRefreshTheme CustomEvent to trigger theme recreation
167
- useEffect(() => {
168
- const handler = (event: Event) => {
169
- if (event.type === 'DASHTRefreshTheme') {
170
- const tenantSettings = getTenantSettings();
171
- recreateTheme(tenantSettings, currentMode);
172
- }
173
- };
174
- window.addEventListener('DASHTRefreshTheme', handler);
175
- return () => window.removeEventListener('DASHTRefreshTheme', handler);
176
- }, []);
177
-
178
- const contextValue: DashThemeContextType = {
179
- theme,
180
- themeOptions,
181
- recreateTheme,
182
- currentMode,
183
-
184
- };
185
-
186
- return (
187
- <ThemeProvider noSsr disableTransitionOnChange theme={theme}>
188
- <CssBaseline />
189
- <DashThemeContext.Provider value={contextValue}>
190
-
191
-
192
- <ConfigProvider
193
- theme={antTheme}
194
- >
195
-
196
- {children}
197
-
198
- </ConfigProvider>
199
-
200
-
201
-
202
-
203
-
204
- </DashThemeContext.Provider>
205
- </ThemeProvider>
206
- );
207
- };
208
-
209
- export default DashThemeContext;
@@ -1,143 +0,0 @@
1
- import React, { createContext, useContext, useState, useEffect } from 'react';
2
- //import { createTheme } from '@mui/material/styles';
3
- import { appTheme } from 'dash-styles';
4
- import { useColorScheme } from '@mui/material/styles';
5
- import { AuthPersistenceService } from 'dash-auth';
6
- import { useSelector } from 'react-redux';
7
- import { IDASHAppState } from 'dash-admin-state';
8
- import { updateDomCssVariables } from './updateDomCssVariables';
9
- import { Theme,createTheme } from '@mui/material';
10
-
11
- interface DashThemeContextType {
12
- theme: Theme;
13
- themeOptions: ReturnType<typeof appTheme>;
14
- updateFullTheme: (settings?: any) => void;
15
- recreateTheme: (tenantSettings?: any) => void;
16
- }
17
-
18
- // Create context with null as default - we'll check for this in the hook
19
- const DashThemeContext = createContext<DashThemeContextType | null>(null);
20
-
21
- // Custom hook that ensures context is used within provider
22
- export const useDashThemeContext = () => {
23
- const context = useContext(DashThemeContext);
24
- if (!context) {
25
- throw new Error('useDashThemeContext must be used within a DashThemeProvider');
26
- }
27
- return context;
28
- };
29
-
30
- interface DashThemeProviderProps {
31
- children?: React.ReactNode;
32
- extendedOptions?: any;
33
- }
34
-
35
- export const DashThemeProvider: React.FC<DashThemeProviderProps> = ({ extendedOptions, children }) => {
36
- const [themeOptions, setThemeOptions] = useState<ReturnType<typeof appTheme>>(() => appTheme(extendedOptions));
37
- const [theme, setTheme] = useState<Theme>(() => createTheme(appTheme(extendedOptions)));
38
- //const { auth, authenticated } = useAuthContext();
39
-
40
- const { mode } = useColorScheme();
41
- /*const dashThemeType = useSelector((state: IDASHAppState<any, any, any>) =>
42
- state.settings.themeType
43
- );*/
44
-
45
- // Helper function to get tenant settings
46
- const getTenantSettings = () => {
47
- const persistedTenantSettings = AuthPersistenceService.getTenantSettings();
48
-
49
- return persistedTenantSettings || null;
50
- };
51
-
52
- // Function to recreate the entire MUI theme with tenant settings
53
- const recreateTheme = (tenantSettings?: any) => {
54
- const settings = tenantSettings || getTenantSettings();
55
-
56
- console.log('Recreating MUI theme with tenant settings:', settings);
57
-
58
- // Create new theme options with tenant settings
59
- const newThemeOptions = appTheme(
60
- extendedOptions,
61
- {
62
- tenantSettings: settings,
63
- colors: settings?.colors,
64
- }
65
- // Add any other tenant-specific theme customizations here
66
- );
67
-
68
- // Create new MUI theme
69
- const newTheme = createTheme(newThemeOptions);
70
-
71
- // Update state
72
- setThemeOptions(newThemeOptions);
73
- setTheme(newTheme);
74
-
75
- // Also update CSS variables
76
- if (settings?.colors || settings?.values) {
77
- const currentTheme = mode || document.documentElement.getAttribute('data-theme') || 'light';
78
- updateDomCssVariables(currentTheme, settings?.colors, settings?.values);
79
- //document.documentElement.setAttribute('data-theme', currentTheme);
80
- }
81
- };
82
-
83
- // Function to update CSS variables (keep existing functionality)
84
- const updateFullTheme = (colors?: any) => {
85
- const tenantSettings = getTenantSettings();
86
- const colorsToUse = colors || tenantSettings?.colors || {};
87
- const valuesToUse = tenantSettings?.values || {};
88
- console.log('Updating custom CSS variables with colors:', colorsToUse);
89
-
90
- const currentTheme = mode || document.documentElement.getAttribute('data-theme') || 'light';
91
- updateDomCssVariables(currentTheme, colorsToUse, valuesToUse);
92
- //document.documentElement.setAttribute('data-theme', currentTheme);
93
- };
94
-
95
- // Recreate theme when user authenticates or tenant settings change
96
-
97
- useEffect(() => {
98
- //if(!auth || !authenticated) {
99
-
100
- const tenantSettings = getTenantSettings();
101
- if (tenantSettings) {
102
- console.log("recreating mui theme on mount")
103
- recreateTheme(tenantSettings);
104
- }
105
- // }
106
- }, []);
107
-
108
- // Handle theme mode changes
109
- useEffect(() => {
110
-
111
- //if (authenticated) {
112
- const tenantSettings = getTenantSettings();
113
- if (tenantSettings) {
114
-
115
- console.log("recreating mui theme on mode change")
116
- recreateTheme(tenantSettings);
117
- }
118
- //}
119
- }, [mode/*, dashThemeType*/]);
120
-
121
- // Create the context value object
122
- const contextValue: DashThemeContextType = {
123
- theme,
124
- themeOptions,
125
- updateFullTheme,
126
- recreateTheme
127
- };
128
-
129
- useEffect(() => {
130
- console.log("mui theme updated",themeOptions,theme);
131
- }, [themeOptions]);
132
-
133
- return (
134
- <DashThemeContext.Provider value={contextValue}>
135
-
136
-
137
- {children}
138
-
139
- </DashThemeContext.Provider>
140
- );
141
- };
142
-
143
- export default DashThemeContext;
@@ -1,306 +0,0 @@
1
- import React, { createContext, useContext, useState, useEffect } from 'react';
2
- import { Theme, createTheme } from '@mui/material/styles';
3
- import { appTheme } from 'dash-styles';
4
- import { useAuthContext } from 'dash-admin';
5
- import { useSelector } from 'react-redux';
6
- import { IDASHAppState, DASH_THEME_SETTINGS } from 'dash-admin-state';
7
- import { AuthPersistenceService } from 'dash-auth';
8
- interface DashThemeContextType {
9
- theme: Theme;
10
- themeOptions: ReturnType<typeof appTheme>; // Expose theme options
11
- updateFullTheme: (settings?: any) => void;
12
- }
13
-
14
- const defaultThemeOptions = appTheme();
15
- const defaultTheme = createTheme(defaultThemeOptions);
16
-
17
- const DashThemeContext = createContext<DashThemeContextType>({
18
- theme: defaultTheme,
19
- themeOptions: defaultThemeOptions,
20
- updateFullTheme: () => { }
21
- });
22
-
23
- let themeStyleElement: HTMLStyleElement | null = null;
24
- export const updateDomCssVariables = (theme: string, colors: { [x: string]: string }) => {
25
-
26
- const themeSuffix = `--${theme}`;
27
-
28
- if (!themeStyleElement) {
29
- themeStyleElement = document.createElement('style');
30
- themeStyleElement.id = 'dash-theme-variables';
31
- document.head.appendChild(themeStyleElement);
32
- }
33
-
34
-
35
- let styleString = '';
36
- Object.entries(colors).forEach(([key, value]) => {
37
- if (key.endsWith(themeSuffix)) {
38
- const baseKey = key.slice(0, -themeSuffix.length);
39
- styleString += `--${baseKey}: ${value}; `;
40
- }
41
- });
42
-
43
- themeStyleElement.textContent = `:root { ${styleString} }`;
44
-
45
- };
46
-
47
-
48
- export const useDashThemeContext = () => useContext(DashThemeContext);
49
-
50
- interface DashThemeProviderProps {
51
- children?: React.ReactNode;
52
- extendedOptions?: any;
53
- }
54
-
55
- export const DashThemeProvider: React.FC<DashThemeProviderProps> = ({ extendedOptions, children }) => {
56
- const [themeOptions, setThemeOptions] = useState<ReturnType<typeof appTheme>>(() => appTheme(extendedOptions));
57
- const [theme, setTheme] = useState<Theme>(() => createTheme(appTheme(extendedOptions)));
58
- const [cssVariablesCache, setCssVariablesCache] = useState<Record<string, string> | null>(null);
59
- const { auth, authenticated } = useAuthContext();
60
-
61
- // Get theme type from Redux state
62
- const themeType = useSelector((state: IDASHAppState<any, any, any>) =>
63
- state.settings.themeType
64
- );
65
-
66
- // Helper function to get tenant settings (prioritize persisted over auth)
67
- const getTenantSettings = () => {
68
- // First try to get persisted tenant settings
69
- const persistedTenantSettings = AuthPersistenceService.getTenantSettings();
70
- if (persistedTenantSettings) {
71
- return persistedTenantSettings;
72
- }
73
-
74
- // Fallback to auth tenant settings if no persisted data
75
- return auth?.tenantSettings || null;
76
- };
77
-
78
- const getAllCssVariablesFromStyleSheets = (selector: string) => {
79
- if (cssVariablesCache) {
80
- return cssVariablesCache;
81
- }
82
-
83
- const cssVariables = {};
84
-
85
- // Loop through all style sheets
86
- for (let i = 0; i < document.styleSheets.length; i++) {
87
- try {
88
- const styleSheet = document.styleSheets[i];
89
- // Skip if the stylesheet is from a different origin and can't be accessed
90
- if (!styleSheet.cssRules) continue;
91
-
92
- // Loop through all CSS rules in the stylesheet
93
- for (let j = 0; j < styleSheet.cssRules.length; j++) {
94
- const rule = styleSheet.cssRules[j];
95
-
96
- // Check if it's a style rule (type 1)
97
-
98
- /* @ts-ignore */
99
- if (rule.selectorText === selector) {
100
-
101
- /* @ts-ignore */
102
- const style = rule.style;
103
-
104
- // Loop through all style properties
105
- for (let k = 0; k < style.length; k++) {
106
- const prop = style[k];
107
- if (prop.startsWith('--')) {
108
- //console.log(prop,style.getPropertyValue(prop).trim());
109
- cssVariables[prop] = style.getPropertyValue(prop).trim();
110
- }
111
- }
112
- }
113
-
114
- }
115
- } catch (e) {
116
- // Skip cross-origin stylesheets that throw security errors
117
- console.warn('Could not access stylesheet:', e);
118
- }
119
- }
120
-
121
- setCssVariablesCache(cssVariables);
122
- return cssVariables;
123
- };
124
-
125
- // Function to update CSS variables based on tenant settings
126
- const updateCSSVariablesCopy = (themeType: string, settingsColors: { [x: string]: string }) => {
127
-
128
- const root = document.documentElement
129
-
130
- const _cssVars = getAllCssVariablesFromStyleSheets(":root");
131
-
132
- const cssVars = Object.keys(_cssVars).filter(prop => prop.endsWith(`--${themeType}`));
133
- cssVars.forEach(varName => {
134
- //console.log(varName);
135
- const baseVarName = varName.replace(`--${themeType}`, '');
136
- const value = _cssVars[varName];
137
- if (value) {
138
- //console.log("replaced",themeType,baseVarName,value)
139
- root.style.setProperty(baseVarName, value);
140
- }
141
- });
142
-
143
- if (!settingsColors) return;
144
- // Update CSS specific variables from backend config
145
-
146
- // Update any CSS variables that match the incoming settings
147
- Object.entries(settingsColors).forEach(([key, value]) => {
148
- const cssVar = `--${key}`;
149
- root.style.setProperty(cssVar, value);
150
- });
151
- };
152
-
153
- // TODO: this is too slow, setting properties one by one.
154
- const updateCSSVariables2 = (currentTheme, colors: { [x: string]: string }) => {
155
-
156
-
157
- const themeSuffix = `--${currentTheme}`;
158
-
159
- Object.entries(colors).forEach(([key, value]) => {
160
- if (key.endsWith(themeSuffix)) {
161
- const baseKey = key.slice(0, -themeSuffix.length);
162
- document.documentElement.style.setProperty(`--${baseKey}`, String(value));
163
- }
164
- });
165
-
166
-
167
-
168
- };
169
-
170
- // TODO: this method is faster, but still slow.
171
-
172
- const updateCSSVariables3 = (currentTheme, colors: { [x: string]: string }) => {
173
-
174
-
175
- const themeSuffix = `--${currentTheme}`;
176
-
177
- let styleString = '';
178
- Object.entries(colors).forEach(([key, value]) => {
179
- if (key.endsWith(themeSuffix)) {
180
- const baseKey = key.slice(0, -themeSuffix.length);
181
- styleString += `--${baseKey}: ${value}; `;
182
- }
183
- });
184
- document.documentElement.setAttribute('style', styleString);
185
-
186
-
187
-
188
- };
189
-
190
-
191
-
192
- const updateCSSVariables = (currentTheme: string, colors: { [x: string]: string }) => {
193
- const startTime = performance.now();
194
- const themeSuffix = `--${currentTheme}`;
195
-
196
- // Create or get existing style element
197
- if (!themeStyleElement) {
198
- themeStyleElement = document.createElement('style');
199
- themeStyleElement.id = 'dash-theme-variables';
200
- document.head.appendChild(themeStyleElement);
201
- }
202
-
203
- // Build CSS rule
204
- /*const cssVariables: string[] = [];
205
- Object.entries(colors).forEach(([key, value]) => {
206
- if (key.endsWith(themeSuffix)) {
207
- const baseKey = key.slice(0, -themeSuffix.length);
208
- cssVariables.push(`--${baseKey}: ${value}`);
209
- }
210
- });*/
211
-
212
- let styleString = '';
213
- Object.entries(colors).forEach(([key, value]) => {
214
- if (key.endsWith(themeSuffix)) {
215
- const baseKey = key.slice(0, -themeSuffix.length);
216
- styleString += `--${baseKey}: ${value}; `;
217
- }
218
- });
219
-
220
- // Update the style element content in one operation
221
- themeStyleElement.textContent = `:root { ${styleString} }`;
222
-
223
- //const endTime = performance.now();
224
- //console.log(`updateCSSVariables execution time: ${endTime - startTime}ms`);
225
- };
226
-
227
- // Function to recreate theme after CSS variables are updated
228
- const updateFullTheme = (colors?: any) => {
229
-
230
- // Get tenant settings from persisted data or auth
231
- const tenantSettings = getTenantSettings();
232
- const colorsToUse = colors || tenantSettings?.colors || {};
233
-
234
- console.log('Updating theme with colors:', colorsToUse);
235
- //console.log('Using tenant settings from:', tenantSettings ? 'persisted/auth data' : 'none available');
236
-
237
- updateCSSVariables(themeType, colorsToUse);
238
-
239
- /*
240
- DEPRECTATED AS USING CSS VARS FOR MODE SWITCHING
241
- // Determine which theme function to use based on theme type
242
- let themeFunction = () => appTheme(extendedOptions);
243
-
244
- // Recreate theme options with updated CSS variables and theme type
245
- const newThemeOptions = themeFunction();
246
- setThemeOptions(newThemeOptions);
247
-
248
- // Create actual theme from options
249
- const newTheme = createTheme(newThemeOptions);
250
- setTheme(newTheme);
251
- */
252
- };
253
-
254
- // Listen for tenant settings changes (both from auth and persisted)
255
- useEffect(() => {
256
- const tenantSettings = getTenantSettings();
257
-
258
- if (tenantSettings?.colors) {
259
- console.log('Tenant settings detected, updating theme');
260
- updateFullTheme(tenantSettings.colors);
261
- } else if (authenticated && auth) {
262
- // Fallback to auth tenant settings if available
263
- updateFullTheme(auth?.tenantSettings?.colors);
264
- } else {
265
- // Apply theme even without tenant settings (for theme type changes)
266
- updateFullTheme();
267
- }
268
- }, [auth, authenticated]); // Remove auth?.tenantSettings from dependency since we're using getTenantSettings()
269
-
270
- // Add this useEffect in the DashThemeProvider component:
271
- useEffect(() => {
272
- const handleThemeUpdate = (event: CustomEvent) => {
273
- console.log('Theme update event received:', event.detail);
274
- updateFullTheme(event.detail.colors);
275
- };
276
-
277
- window.addEventListener('dash-theme-update', handleThemeUpdate as EventListener);
278
-
279
- return () => {
280
- window.removeEventListener('dash-theme-update', handleThemeUpdate as EventListener);
281
- };
282
- }, [updateFullTheme]);
283
- // Listen for theme type changes
284
- useEffect(() => {
285
-
286
- const tenantSettings = getTenantSettings();
287
- updateFullTheme(tenantSettings?.colors);
288
- }, [themeType]);
289
-
290
- // Initialize theme on mount with persisted settings
291
- useEffect(() => {
292
- const tenantSettings = getTenantSettings();
293
- if (tenantSettings?.colors) {
294
- console.log('Initializing theme with persisted tenant settings');
295
- updateFullTheme(tenantSettings.colors);
296
- }
297
- }, []); // Run only on mount
298
-
299
- return (
300
- <DashThemeContext.Provider value={{ theme, themeOptions, updateFullTheme }}>
301
- {children}
302
- </DashThemeContext.Provider>
303
- );
304
- };
305
-
306
- export default DashThemeContext;