@dashadmin/dash-styles 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 (61) hide show
  1. package/README.md +31 -1
  2. package/dist/index.cjs +979 -0
  3. package/dist/index.d.cts +1181 -0
  4. package/dist/index.d.ts +1181 -0
  5. package/dist/index.js +193 -166
  6. package/package.json +42 -41
  7. package/{dist → src}/dash-css-transformer.less +5 -2
  8. package/src/helpers/getAllCssVariablesFromStyleSheets.tsx +46 -0
  9. package/src/index.tsx +1052 -0
  10. package/{dist → src}/styles/header.less +3 -0
  11. package/{dist → src}/styles/tabs.less +7 -0
  12. package/{dist → src}/variables/breakpoints.less +1 -1
  13. package/dist/helpers/getAllCssVariablesFromStyleSheets.js +0 -1
  14. /package/{dist → src}/assets/fonts/Montserrat-Black.ttf +0 -0
  15. /package/{dist → src}/assets/fonts/Montserrat-Bold.ttf +0 -0
  16. /package/{dist → src}/assets/fonts/Montserrat-Medium.ttf +0 -0
  17. /package/{dist → src}/assets/fonts/Montserrat-Regular.ttf +0 -0
  18. /package/{dist → src}/assets/fonts/Montserrat-SemiBold.ttf +0 -0
  19. /package/{dist → src}/dash-variables.less +0 -0
  20. /package/{dist → src}/dash.less +0 -0
  21. /package/{dist → src}/index.tsx.suffixed +0 -0
  22. /package/{dist → src}/styles/button.less +0 -0
  23. /package/{dist → src}/styles/buttons.less +0 -0
  24. /package/{dist → src}/styles/card.less +0 -0
  25. /package/{dist → src}/styles/common.less +0 -0
  26. /package/{dist → src}/styles/components/notfound.less +0 -0
  27. /package/{dist → src}/styles/extra.less +0 -0
  28. /package/{dist → src}/styles/filters.less +0 -0
  29. /package/{dist → src}/styles/forms.less +0 -0
  30. /package/{dist → src}/styles/framed.less +0 -0
  31. /package/{dist → src}/styles/input.copy.less +0 -0
  32. /package/{dist → src}/styles/input.less +0 -0
  33. /package/{dist → src}/styles/layout.less +0 -0
  34. /package/{dist → src}/styles/links.less +0 -0
  35. /package/{dist → src}/styles/loader.less +0 -0
  36. /package/{dist → src}/styles/login.less +0 -0
  37. /package/{dist → src}/styles/modal.less +0 -0
  38. /package/{dist → src}/styles/module.less +0 -0
  39. /package/{dist → src}/styles/mui-overrides.less +0 -0
  40. /package/{dist → src}/styles/notification.less +0 -0
  41. /package/{dist → src}/styles/pages/profile.less +0 -0
  42. /package/{dist → src}/styles/pagination.less +0 -0
  43. /package/{dist → src}/styles/popover.less +0 -0
  44. /package/{dist → src}/styles/react-admin/common.less +0 -0
  45. /package/{dist → src}/styles/react-admin/toolbar.less +0 -0
  46. /package/{dist → src}/styles/root.less +0 -0
  47. /package/{dist → src}/styles/sidebar.less +0 -0
  48. /package/{dist → src}/styles/splash.less +0 -0
  49. /package/{dist → src}/styles/static.less +0 -0
  50. /package/{dist → src}/styles/stats.less +0 -0
  51. /package/{dist → src}/styles/svg.less +0 -0
  52. /package/{dist → src}/styles/switch.less +0 -0
  53. /package/{dist → src}/styles/table.less +0 -0
  54. /package/{dist → src}/styles/tags.less +0 -0
  55. /package/{dist → src}/styles/toast.less +0 -0
  56. /package/{dist → src}/styles/toolbar.less +0 -0
  57. /package/{dist → src}/styles/transition.less +0 -0
  58. /package/{dist → src}/styles/uploader.less +0 -0
  59. /package/{dist → src}/variables/colors.less +0 -0
  60. /package/{dist → src}/variables/dash-colors.less +0 -0
  61. /package/{dist → src}/variables/sizes.less +0 -0
package/src/index.tsx ADDED
@@ -0,0 +1,1052 @@
1
+ import { defaultTheme } from 'react-admin';
2
+ import { deepmerge } from '@mui/utils';
3
+ import { theme as antdTheme } from 'antd';
4
+
5
+ const getAllCssVariablesFromStyleSheets = (selector: string) => {
6
+ const cssVariables = {};
7
+
8
+ for (let i = 0; i < document.styleSheets.length; i++) {
9
+ try {
10
+ const styleSheet = document.styleSheets[i];
11
+ // Skip our dynamic theme style element to read only compiled/static defaults.
12
+ // This ensures _color() fallback reads from compiled LESS CSS, not stale tenant values.
13
+ if ((styleSheet.ownerNode as HTMLElement)?.id === 'dash-theme-variables') continue;
14
+ if (!styleSheet.cssRules) continue;
15
+
16
+ for (let j = 0; j < styleSheet.cssRules.length; j++) {
17
+ const rule = styleSheet.cssRules[j];
18
+
19
+ /* @ts-ignore */
20
+ if (rule.selectorText === selector) {
21
+ /* @ts-ignore */
22
+ const style = rule.style;
23
+
24
+ for (let k = 0; k < style.length; k++) {
25
+ const prop = style[k];
26
+ if (prop.startsWith('--')) {
27
+ cssVariables[prop] = style.getPropertyValue(prop).trim();
28
+ }
29
+ }
30
+ }
31
+ }
32
+ } catch (e) {
33
+ console.warn('Could not access stylesheet:', e);
34
+ }
35
+ }
36
+
37
+ return cssVariables;
38
+ };
39
+
40
+ export const defaultOptions = (options) => {
41
+ const { tenantSettings, colors, ...otherOptions } = options || {};
42
+ const currentTheme = document.documentElement.getAttribute('data-theme') || 'dark';
43
+ const cssVars = getAllCssVariablesFromStyleSheets(":root");
44
+
45
+ const _color = (key, colorKey, mode = null) => {
46
+ if (colors) {
47
+ const colorValue = colors[`${colorKey}--${mode || currentTheme}`];
48
+ return colorValue ? { [key]: colorValue } : {};
49
+ } else if (cssVars[`--${colorKey}--${mode || currentTheme}`]) {
50
+ const cssVarValue = cssVars[`--${colorKey}--${mode || currentTheme}`];
51
+ return cssVarValue ? { [key]: cssVarValue } : {};
52
+ } else {
53
+ return {};
54
+ }
55
+ };
56
+
57
+ const createPalette = (mode = 'light') => {
58
+
59
+ const palette = {
60
+ mode,
61
+ background: {
62
+ ..._color('default', 'module-bg', mode),
63
+ ..._color('paper', 'module-bg', mode)
64
+ },
65
+ primary: {
66
+ //..._color('main', 'primary-color', mode),
67
+ //..._color('main', 'highlight-color', mode),
68
+ ..._color('main', 'btn-bg', mode),
69
+ ..._color('contrastText', 'primary-contrast', mode)
70
+ },
71
+ secondary: {
72
+ ..._color('main', 'secondary-color', mode)
73
+ },
74
+ text: {
75
+ ..._color('primary', 'text-color', mode),
76
+ ..._color('secondary', 'text-light', mode),
77
+ ..._color('disabled', 'disabled-color', mode)
78
+ },
79
+ action: {
80
+ ..._color('active', 'component-active-bg', mode),
81
+ ..._color('hover', 'component-hover-bg', mode),
82
+ ..._color('disabled', 'disabled-color', mode),
83
+ ..._color('disabledBackground', 'disabled-bg', mode)
84
+ },
85
+ //..._color('divider', 'component-border-split', mode),
86
+ ..._color('border', 'border-color', mode),
87
+ error: {
88
+ ..._color('main', 'alert-error-bg', mode),
89
+ ..._color('contrastText', 'alert-error-title', mode)
90
+ },
91
+ warning: {
92
+ ..._color('main', 'alert-warning-bg', mode),
93
+ ..._color('contrastText', 'alert-warning-title', mode)
94
+ },
95
+ info: {
96
+ ..._color('main', 'alert-info-bg', mode),
97
+ ..._color('contrastText', 'alert-info-title', mode)
98
+ },
99
+ success: {
100
+ ..._color('main', 'alert-success-bg', mode),
101
+ ..._color('contrastText', 'alert-success-title', mode)
102
+ },
103
+ common: {
104
+ ..._color('black', 'text-color', mode),
105
+ ..._color('white', 'text-contrast', mode)
106
+ },
107
+ variant: {
108
+ ..._color('containedBg', 'btn-bg', mode),
109
+
110
+ }
111
+ };
112
+
113
+ // Filter out empty objects and undefined values
114
+ return Object.fromEntries(
115
+ Object.entries(palette).filter(([_, value]) => {
116
+ if (typeof value === 'object' && value !== null) {
117
+ return Object.keys(value).length > 0;
118
+ }
119
+ return value !== undefined;
120
+ })
121
+ );
122
+ };
123
+
124
+ return {
125
+ cssVariables: {
126
+ cssVarPrefix: 'dash', // Your custom prefix
127
+ colorSchemeSelector: 'data-theme', // Tell MUI to use data attributes
128
+ colorSchemeStorageKey: 'theme', // Use same key as dashStorage for consistency
129
+ },
130
+ // Enable both light and dark color schemes - NO 'system' to force light/dark only
131
+ colorSchemes: {
132
+ light: {
133
+ palette: createPalette('light')
134
+ },
135
+ dark: {
136
+ palette: createPalette('dark')
137
+ },
138
+ },
139
+
140
+ defaultColorScheme: currentTheme || 'dark',
141
+
142
+
143
+ palette: createPalette(currentTheme),
144
+
145
+
146
+ // Don't put your custom CSS variables in the palette
147
+ // Instead, use them directly in component overrides
148
+ typography: {
149
+ allVariants: {
150
+ //color: 'var(--text-color)', // Keep using your CSS variables here
151
+ },
152
+ },
153
+ components: {
154
+ // Override ALL color usage in component overrides
155
+ MuiCssBaseline: {
156
+ styleOverrides: {
157
+ body: {
158
+ //background: 'linear-gradient(to bottom, var(--bodybg-primary), var(--bodybg-secondary))',
159
+ //color: 'var(--text-color)',
160
+ },
161
+ },
162
+ },
163
+
164
+
165
+ /* MuiIconButton: {
166
+ styleOverrides: {
167
+ root: {
168
+ backgroundColor: 'var(--btn-bg)',
169
+ color: 'var(--btn-color)',
170
+
171
+ '&.MuiIconButton-containedPrimary': {
172
+ backgroundColor: 'var(--primary-color)',
173
+ color: 'var(--btn-color)',
174
+ '&:hover': {
175
+ backgroundColor: 'var(--highlight-color)',
176
+ },
177
+ },
178
+ '&.MuiIconButton-containedSecondary': {
179
+ backgroundColor: 'var(--secondary-color)',
180
+ color: 'var(--btn-color)',
181
+ '&:hover': {
182
+ backgroundColor: 'var(--highlight-color)',
183
+ },
184
+ },
185
+ '&.MuiIconButton-outlinedPrimary': {
186
+ backgroundColor: 'inherit',
187
+ borderColor: 'var(--primary-color)',
188
+ color: 'var(--text-color)',
189
+ '&:hover': {
190
+ borderColor: 'var(--highlight-color)',
191
+ },
192
+ },
193
+ '&.MuiIconButton-outlinedSecondary': {
194
+ backgroundColor: 'inherit',
195
+ borderColor: 'var(--primary-color)',
196
+ color: 'var(--text-color)',
197
+ '&:hover': {
198
+ borderColor: 'var(--highlight-color)',
199
+ },
200
+ },
201
+ },
202
+ },
203
+ },*/
204
+
205
+
206
+ /*MuiToolbar: {
207
+ styleOverrides: {
208
+ root: {
209
+ backgroundColor: 'var(--table-header-bg)',
210
+ }
211
+ }
212
+ },*/
213
+
214
+
215
+ /*MuiButtonBase: {
216
+ styleOverrides: {
217
+ root: {
218
+ backgroundColor: 'var(--btn-bg)',
219
+ color: 'var(--btn-color)',
220
+
221
+ '&.MuiButton-containedPrimary': {
222
+ backgroundColor: 'var(--btn-primary-bg)',
223
+ color: 'var(--btn-primary-color)',
224
+ '&:hover': {
225
+ backgroundColor: 'var(--highlight-color)',
226
+ },
227
+ },
228
+ '&.MuiButton-containedSecondary': {
229
+ backgroundColor: 'var(--btn-secondary-bg)',
230
+ color: 'var(--btn-secondary-color)',
231
+ '&:hover': {
232
+ backgroundColor: 'var(--btn-secondary-color)',
233
+ },
234
+ },
235
+ '&.MuiButton-outlinedPrimary': {
236
+ backgroundColor: 'inherit',
237
+ borderColor: 'var(--btn-primary-bg)',
238
+ color: 'var(--text-color)',
239
+ '&:hover': {
240
+ borderColor: 'var(--highlight-color)',
241
+ color: 'var(--highlight-color-contrast)',
242
+ },
243
+ },
244
+ '&.MuiButton-outlinedSecondary': {
245
+ backgroundColor: 'inherit',
246
+ borderColor: 'var(--btn-primary-bg)',
247
+ color: 'var(--text-color)',
248
+ '&:hover': {
249
+ borderColor: 'var(--highlight-color)',
250
+ color: 'var(--highlight-color-contrast)',
251
+ },
252
+ },
253
+ '&.MuiButton-textPrimary': {
254
+ color: 'var(--link-color)',
255
+ background: 'none',
256
+ '&:hover': {
257
+ color: 'var(--highlight-color)',
258
+ textDecoration: 'underline',
259
+ background: 'none',
260
+ },
261
+ },
262
+ '&.MuiButton-textSecondary': {
263
+ color: 'var(--text-light)',
264
+ background: 'none',
265
+ '&:hover': {
266
+ color: 'var(--text-color)',
267
+ textDecoration: 'underline',
268
+ background: 'none',
269
+ },
270
+ },
271
+ },
272
+ },
273
+ },*/
274
+
275
+
276
+ MuiButton: {
277
+ styleOverrides: {
278
+ root: {
279
+ backgroundColor: 'var(--btn-bg)',
280
+ color: 'var(--btn-color)',
281
+
282
+ '&.MuiButton-containedPrimary': {
283
+ backgroundColor: 'var(--btn-primary-bg)',
284
+ color: 'var(--btn-primary-color)',
285
+ '&:hover': {
286
+ backgroundColor: 'var(--highlight-color)',
287
+ },
288
+ },
289
+ '&.MuiButton-containedSecondary': {
290
+ backgroundColor: 'var(--btn-secondary-bg)',
291
+ color: 'var(--btn-secondary-color)',
292
+ '&:hover': {
293
+ backgroundColor: 'var(--btn-secondary-color)',
294
+ },
295
+ },
296
+ '&.MuiButton-outlinedPrimary': {
297
+ backgroundColor: 'inherit',
298
+ borderColor: 'var(--btn-primary-bg)',
299
+ color: 'var(--text-color)',
300
+ '&:hover': {
301
+ borderColor: 'var(--highlight-color)',
302
+ color: 'var(--highlight-color-contrast)',
303
+ },
304
+ },
305
+ '&.MuiButton-outlinedSecondary': {
306
+ backgroundColor: 'inherit',
307
+ borderColor: 'var(--btn-primary-bg)',
308
+ color: 'var(--text-color)',
309
+ '&:hover': {
310
+ borderColor: 'var(--highlight-color)',
311
+ color: 'var(--highlight-color-contrast)',
312
+ },
313
+ },
314
+ '&.MuiButton-textPrimary': {
315
+ color: 'var(--link-color)',
316
+ background: 'none',
317
+ '&:hover': {
318
+ color: 'var(--highlight-color)',
319
+ textDecoration: 'underline',
320
+ background: 'none',
321
+ },
322
+ },
323
+ '&.MuiButton-textSecondary': {
324
+ color: 'var(--text-light)',
325
+ background: 'none',
326
+ '&:hover': {
327
+ color: 'var(--text-color)',
328
+ textDecoration: 'underline',
329
+ background: 'none',
330
+ },
331
+ },
332
+ },
333
+ },
334
+ },
335
+ MuiDialog: {
336
+ styleOverrides: {
337
+ root: {
338
+ zIndex: 100
339
+ }
340
+ }
341
+ },
342
+ MuiDialogTitle: {
343
+ styleOverrides: {
344
+ root: {
345
+
346
+ '& svg': {
347
+ color: 'var(--text-color)',
348
+ },
349
+ }
350
+ }
351
+ },
352
+ MuiTooltip: {
353
+ styleOverrides: {
354
+ tooltip: {
355
+ backgroundColor: 'var(--module-bg)',
356
+ color: 'var(--text-color)',
357
+ border: '1px solid var(--border-color)',
358
+ fontSize: '0.75rem',
359
+ maxWidth: 300,
360
+ '& .MuiTooltip-arrow': {
361
+ color: 'var(--module-bg)',
362
+ '&::before': {
363
+ border: '1px solid var(--border-color)',
364
+ },
365
+ },
366
+ },
367
+ popper: {
368
+ '&[data-popper-placement*="bottom"] .MuiTooltip-tooltip': {
369
+ marginTop: '8px',
370
+ },
371
+ '&[data-popper-placement*="top"] .MuiTooltip-tooltip': {
372
+ marginBottom: '8px',
373
+ },
374
+ '&[data-popper-placement*="right"] .MuiTooltip-tooltip': {
375
+ marginLeft: '8px',
376
+ },
377
+ '&[data-popper-placement*="left"] .MuiTooltip-tooltip': {
378
+ marginRight: '8px',
379
+ },
380
+ },
381
+ },
382
+ },
383
+ MuiTabs: {
384
+ styleOverrides: {
385
+ indicator: {
386
+ backgroundColor: 'var(--highlight-color)',
387
+ },
388
+ },
389
+ },
390
+
391
+ MuiListItemIcon: {
392
+ styleOverrides: {
393
+ root: {
394
+ color: 'var(--sidebar-icon)',
395
+ '& svg': {
396
+ color: 'var(--sidebar-icon)',
397
+ },
398
+ },
399
+ },
400
+
401
+ },
402
+
403
+ RaReferenceField: {
404
+ styleOverrides: {
405
+ root: {
406
+ '& .RaReferenceField-link>*': {
407
+ color: 'var(--text-color)',
408
+ },
409
+ },
410
+ },
411
+ },
412
+ RaSingleFieldList: {
413
+ styleOverrides: {
414
+ root: {
415
+ '& .RaSingleFieldList-link>*': {
416
+ color: 'var(--text-color)',
417
+ },
418
+ },
419
+ },
420
+ },
421
+ /*MuiInputAdornment: {
422
+ styleOverrides: {
423
+ root: {
424
+ '& svg': {
425
+ color: 'var(--highlight-color)',
426
+ },
427
+ },
428
+ },
429
+ },*/
430
+ MuiTab: {
431
+ styleOverrides: {
432
+ root: {
433
+ '&.MuiButtonBase-root': {
434
+ '&.Mui-selected': {
435
+ color: 'var(--highlight-color)',
436
+ backgroundColor: 'var(--tab-selected-bg)',
437
+ },
438
+ '&.MuiTab-textColorPrimary': {
439
+ color: 'var(--table-color)',
440
+ },
441
+ },
442
+ },
443
+ },
444
+ },
445
+ MuiAlert: {
446
+ styleOverrides: {
447
+ root: {
448
+ '&.MuiAlert-standardInfo': {
449
+ backgroundColor: 'var(--module-bg)',
450
+ color: 'var(--text-color)',
451
+ '& .MuiAlert-icon': {
452
+ color: 'var(--highlight-color)',
453
+ },
454
+ '& .MuiAlertTitle-root': {
455
+ color: 'var(--text-color)',
456
+ },
457
+ },
458
+ '&.MuiAlert-standardError': {
459
+ backgroundColor: 'var(--dash-alert-error-bg)',
460
+ color: 'var(--dash-alert-error-title)',
461
+ },
462
+ '&.MuiAlert-standardWarning': {
463
+ backgroundColor: 'var(--dash-alert-warning-bg)',
464
+ color: 'var(--dash-alert-warning-title)',
465
+ },
466
+ '&.MuiAlert-standardSuccess': {
467
+ backgroundColor: 'var(--dash-alert-success-bg)',
468
+ color: 'var(--dash-alert-success-title)',
469
+ },
470
+ },
471
+ },
472
+ },
473
+ MuiAccordion: {
474
+ styleOverrides: {
475
+ root: {
476
+ backgroundColor: 'var(--module-bg)',
477
+ '&.MuiPaper-root': {
478
+ backgroundColor: 'var(--module-bg)',
479
+ },
480
+ },
481
+ },
482
+ },
483
+ MuiAccordionSummary: {
484
+ styleOverrides: {
485
+ expandIconWrapper: {
486
+ color: 'inherit',
487
+ '& .MuiSvgIcon-root': {
488
+ color: 'inherit',
489
+ },
490
+ },
491
+ },
492
+ },
493
+ MuiBox: {
494
+ styleOverrides: {
495
+ root: {
496
+ display: 'flex !important',
497
+ },
498
+ },
499
+ },
500
+
501
+
502
+ /* MuiCard: {
503
+ styleOverrides: {
504
+ root: {
505
+ backgroundColor: 'var(--module-bg)',
506
+ },
507
+ },
508
+ },
509
+ MuiPaper: {
510
+ styleOverrides: {
511
+ root: {
512
+ marginBottom: 8,
513
+ backgroundColor: 'var(--module-bg)', // Use the correct variable name
514
+ color: 'var(--text-color)',
515
+ },
516
+ },
517
+ },
518
+ */
519
+ MuiAppBar: {
520
+ styleOverrides: {
521
+ root: {
522
+ backgroundColor: 'var(--primary-color)',
523
+ color: 'var(--text-contrast-color)',
524
+ },
525
+ },
526
+ },
527
+ /*MuiChip: {
528
+ styleOverrides: {
529
+ root: {
530
+ '&.MuiChip-colorPrimary': {
531
+ backgroundColor: 'var(--primary-color)',
532
+ color: 'var(--text-light-color)',
533
+ },
534
+ '&.MuiChip-colorSecondary': {
535
+ backgroundColor: 'var(--secondary-color)',
536
+ color: 'var(--text-light-color)',
537
+ },
538
+ },
539
+ },
540
+ },*/
541
+
542
+
543
+ MuiInputBase: {
544
+ styleOverrides: {
545
+ input: {
546
+ '& .MuiOutlinedInput-root': {
547
+
548
+ border: 1,
549
+ },
550
+ },
551
+
552
+ /*input: {
553
+ '&::placeholder': {
554
+ color: 'var(--highlight-color)',
555
+ opacity: 1,
556
+ },
557
+ // For WebKit browsers
558
+ '&::-webkit-input-placeholder': {
559
+ color: 'var(--highlight-color)',
560
+ opacity: 1,
561
+ },
562
+ },*/
563
+ colorPrimary: {
564
+ color: 'var(--text-color)',
565
+ },
566
+ },
567
+ },
568
+ MuiOutlinedInput: {
569
+ styleOverrides: {
570
+ root: {
571
+ color: 'var(--text-color)',
572
+ '& .MuiOutlinedInput-notchedOutline': {
573
+ borderColor: 'var(--border-color)',
574
+ },
575
+ '&:hover .MuiOutlinedInput-notchedOutline': {
576
+ borderColor: 'var(--primary-color)',
577
+ },
578
+ '&.Mui-focused .MuiOutlinedInput-notchedOutline': {
579
+ borderColor: 'var(--primary-color)',
580
+ },
581
+ },
582
+ },
583
+ },
584
+ MuiInputLabel: {
585
+ styleOverrides: {
586
+ root: {
587
+ color: 'var(--text-color)',
588
+ '&.Mui-focused': {
589
+ color: 'var(--primary-color)',
590
+ },
591
+ },
592
+ },
593
+ },
594
+ MuiSelect: {
595
+ styleOverrides: {
596
+ select: {
597
+ color: 'var(--text-color)',
598
+ },
599
+ icon: {
600
+ color: 'var(--text-color)',
601
+ },
602
+ },
603
+ },
604
+ MuiTextField: {
605
+ styleOverrides: {
606
+ root: {
607
+ '& .MuiOutlinedInput-root': {
608
+ '& fieldset': {
609
+ borderColor: 'var(--border-color)',
610
+ },
611
+ '&:hover fieldset': {
612
+ borderColor: 'var(--primary-color)',
613
+ },
614
+ '&.Mui-focused fieldset': {
615
+ borderColor: 'var(--primary-color)',
616
+ },
617
+ },
618
+ '& .MuiInputLabel-root': {
619
+ color: 'var(--text-light-color)',
620
+ '&.Mui-focused': {
621
+ color: 'var(--primary-color)',
622
+ },
623
+ },
624
+ /* '& .MuiInputBase-input': {
625
+ color: 'var(--text-color)',
626
+ // Add placeholder styling here
627
+ '&::placeholder': {
628
+ color: 'var(--highlight-color)',
629
+ opacity: 0.7,
630
+ },
631
+ '&::-webkit-input-placeholder': {
632
+ color: 'var(--highlight-color)',
633
+ opacity: 0.7,
634
+ },
635
+ '&::-moz-placeholder': {
636
+ color: 'var(--highlight-color)',
637
+ opacity: 0.7,
638
+ },
639
+ '&:-ms-input-placeholder': {
640
+ color: 'var(--highlight-color)',
641
+ opacity: 0.7,
642
+ },
643
+ '&:-moz-placeholder': {
644
+ color: 'var(--highlight-color)',
645
+ opacity: 0.7,
646
+ },
647
+ },*/
648
+ },
649
+ },
650
+ },
651
+ // Add more component overrides as needed for other elements that use primary/secondary colors
652
+ MuiIconButton: {
653
+ styleOverrides: {
654
+ root: {
655
+ height: 30,
656
+ width: 30,
657
+ color: 'var(--text-color)',
658
+ backgroundColor: 'var(--secondary-color)',
659
+ '&:hover': {
660
+ '& svg': {
661
+ color: 'var(--highlight-color-contrast)',
662
+ fill: 'var(--highlight-color-contrast)',
663
+ },
664
+ color: 'var(--highlight-color-contrast)',
665
+ backgroundColor: 'var(--highlight-color)',
666
+ },
667
+ },
668
+ },
669
+ },
670
+ MuiAvatar: {
671
+ styleOverrides: {
672
+ root: {
673
+
674
+ color: 'var(--text-color)',
675
+ backgroundColor: 'var(--secondary-color)',
676
+ '&:hover': {
677
+ '& svg': {
678
+ color: 'var(--highlight-color-contrast)',
679
+ fill: 'var(--highlight-color-contrast)',
680
+ },
681
+ color: 'var(--highlight-color-contrast)',
682
+ backgroundColor: 'var(--highlight-color)',
683
+ },
684
+ },
685
+ },
686
+ },
687
+ MuiTable: {
688
+ styleOverrides: {
689
+ root: {
690
+ backgroundColor: 'var(--component-bg)',
691
+ color: 'var(--text-color)',
692
+ },
693
+ },
694
+ },
695
+
696
+ MuiTableHead: {
697
+ styleOverrides: {
698
+ root: {
699
+ backgroundColor: 'var(--table-header-bg) !important',
700
+ color: 'var(--table-header-color) !important',
701
+ },
702
+ },
703
+ },
704
+ MuiTableRow: {
705
+ styleOverrides: {
706
+ root: {
707
+ '&:hover': {
708
+ backgroundColor: 'var(--component-hover-bg)',
709
+ },
710
+ '&.MuiTableRow-head': {
711
+ backgroundColor: 'var(--table-header-bg) !important',
712
+ color: 'var(--table-header-color) !important',
713
+ },
714
+ },
715
+ },
716
+ },
717
+ MuiTableCell: {
718
+ styleOverrides: {
719
+ root: {
720
+ textWrapMode: 'nowrap',
721
+ borderColor: 'var(--border-color-split)',
722
+ color: 'var(--text-color)',
723
+ //borderBottom: '1px solid var(--border-color)',
724
+ '& .MuiTableSortLabel-root, & .MuiTableSortLabel-icon': {
725
+ color: 'var(--table-header-color) !important',
726
+ },
727
+ },
728
+ head: {
729
+ fontWeight: 600,
730
+ color: 'var(--table-header-color) !important',
731
+ backgroundColor: 'var(--table-header-bg) !important',
732
+ },
733
+ },
734
+ },
735
+ MuiDataGrid: {
736
+ styleOverrides: {
737
+ root: {
738
+
739
+ backgroundColor: 'var(--component-bg)',
740
+ color: 'var(--text-color)',
741
+ border: '1px solid var(--border-color)',
742
+ '& .MuiDataGrid-main': {
743
+ backgroundColor: 'var(--component-bg)',
744
+ },
745
+ '& .MuiDataGrid-overlay': {
746
+ backgroundColor: 'var(--component-bg)',
747
+ color: 'var(--text-color)',
748
+ },
749
+ // Add this to target the header row specifically
750
+ '& .MuiDataGrid-columnHeaderRow': {
751
+ color: 'var(--table-header-color) !important',
752
+ backgroundColor: 'var(--table-header-bg) !important',
753
+ },
754
+ // Also target the container that holds the header
755
+ '& .MuiDataGrid-container--top [role=row]': {
756
+ color: 'var(--table-header-color) !important',
757
+ backgroundColor: 'var(--table-header-bg) !important',
758
+ },
759
+ },
760
+ columnHeader: {
761
+ color: 'var(--table-header-color) !important',
762
+ backgroundColor: 'var(--table-header-bg) !important',
763
+ '& .MuiSvgIcon-root': {
764
+ color: 'var(--highlight-color) !important',
765
+
766
+ },
767
+
768
+ },
769
+ columnHeaders: {
770
+ backgroundColor: 'var(--primary-contrast)',
771
+ color: 'var(--btn-primary-color)',
772
+ borderBottom: '1px solid var(--border-color)',
773
+ '& .MuiDataGrid-columnHeaderTitle': {
774
+ color: 'var(--btn-primary-color)',
775
+ fontWeight: 600,
776
+ },
777
+ '& .MuiDataGrid-iconSeparator': {
778
+ color: 'var(--btn-primary-color)',
779
+ },
780
+ '& .MuiDataGrid-sortIcon': {
781
+ color: 'var(--btn-primary-color)',
782
+ },
783
+ '& .MuiDataGrid-menuIcon': {
784
+ color: 'var(--btn-primary-color)',
785
+ },
786
+ },
787
+ // Add this new selector for the column header row
788
+ columnHeaderRow: {
789
+ color: 'var(--table-header-color) !important',
790
+ backgroundColor: 'var(--table-header-bg) !important',
791
+ },
792
+ cell: {
793
+ borderBottom: '1px solid var(--border-color)',
794
+ color: 'var(--text-color)',
795
+ '&:focus': {
796
+ outline: '1px solid var(--primary-color)',
797
+ },
798
+ '&.MuiDataGrid-cell--editing': {
799
+ backgroundColor: 'var(--component-active-bg)',
800
+ },
801
+ },
802
+ row: {
803
+ backgroundColor: 'var(--component-bg)',
804
+ '&:hover': {
805
+ backgroundColor: 'var(--component-hover-bg)',
806
+ },
807
+ '&.Mui-selected': {
808
+ backgroundColor: 'var(--component-active-bg)',
809
+ '&:hover': {
810
+ backgroundColor: 'var(--component-hover-bg)',
811
+ },
812
+ },
813
+ '&.MuiDataGrid-row': {
814
+ backgroundColor: 'var(--bodybg-primary)',
815
+ },
816
+ '&.MuiDataGrid-row--odd': {
817
+ backgroundColor: 'var(--bodybg-secondary)',
818
+ },
819
+ },
820
+ footerContainer: {
821
+ backgroundColor: 'var(--component-bg)',
822
+ borderTop: '1px solid var(--border-color-split)',
823
+ color: 'var(--text-color)',
824
+ },
825
+ toolbarContainer: {
826
+ backgroundColor: 'var(--component-bg)',
827
+ borderBottom: '1px solid var(--border-color-split)',
828
+ color: 'var(--text-color)',
829
+ '& .MuiButton-root': {
830
+ color: 'var(--btn-color)',
831
+ '&:hover': {
832
+ backgroundColor: 'var(--btn-hover-bg)',
833
+ },
834
+ },
835
+ },
836
+ filterForm: {
837
+ backgroundColor: 'var(--component-bg)',
838
+ color: 'var(--text-color)',
839
+ },
840
+ panel: {
841
+ backgroundColor: 'var(--component-bg)',
842
+ color: 'var(--text-color)',
843
+ border: '1px solid var(--border-color)',
844
+ },
845
+ panelHeader: {
846
+ backgroundColor: 'var(--primary-contrast)',
847
+ borderBottom: '1px solid var(--border-color-split)',
848
+ },
849
+ panelContent: {
850
+ backgroundColor: 'var(--component-bg)',
851
+ },
852
+ columnMenu: {
853
+ backgroundColor: 'var(--component-bg)',
854
+ color: 'var(--text-color)',
855
+ '& .MuiMenuItem-root': {
856
+ color: 'var(--text-color)',
857
+ '&:hover': {
858
+ backgroundColor: 'var(--component-hover-bg)',
859
+ },
860
+ },
861
+ },
862
+ },
863
+ },
864
+ },
865
+ };
866
+
867
+
868
+ };
869
+
870
+ /**
871
+ * Returns only the static component/typography overrides from defaultOptions.
872
+ * These use CSS var() references that resolve at runtime, so they are
873
+ * theme-agnostic and safe to memoize once (no stale palette values).
874
+ *
875
+ * Use this in the public app's DashThemeProviderLight to avoid
876
+ * passing stale palette/colorSchemes that would overwrite the fresh
877
+ * palette computed by the provider on theme switch.
878
+ */
879
+ export const defaultComponentOverrides = (options?: any) => {
880
+ const full = defaultOptions(options || {});
881
+ // Extract only the keys that are safe to memoize (no palette/colorSchemes)
882
+ const { palette, colorSchemes, defaultColorScheme, cssVariables, ...safeOptions } = full;
883
+ return safeOptions;
884
+ };
885
+
886
+ export const appTheme = (muiThemeOptions?: any, options?: {
887
+ tenantSettings?: any;
888
+ colors?: any;
889
+ [key: string]: any;
890
+ }) => {
891
+ const { tenantSettings, colors, ...otherOptions } = options || {};
892
+
893
+ const baseTheme = {
894
+ cssVariables: true,
895
+ ...defaultOptions(options),
896
+ };
897
+
898
+ const theme = muiThemeOptions
899
+ ? deepmerge(deepmerge(defaultTheme, baseTheme), muiThemeOptions)
900
+ : deepmerge(defaultTheme, baseTheme);
901
+
902
+ return theme;
903
+ };
904
+
905
+ export const getAntTheme = (options?: {
906
+ tenantSettings?: any;
907
+ colors?: any;
908
+ [key: string]: any;
909
+ }) => {
910
+ const { colors } = options || {};
911
+ const currentTheme =
912
+ document.documentElement.getAttribute('data-theme') || 'dark';
913
+ const cssVars = getAllCssVariablesFromStyleSheets(':root');
914
+
915
+
916
+ // Resolve a CSS variable key to its computed hex value for the current theme.
917
+ // Mirrors the _color() helper used by defaultOptions() for MUI palette.
918
+ const resolve = (colorKey: string): string | undefined => {
919
+ const suffixed = `--${colorKey}--${currentTheme}`;
920
+ // 1. Tenant color overrides take priority
921
+ if (colors?.[`${colorKey}--${currentTheme}`]) {
922
+ return colors[`${colorKey}--${currentTheme}`];
923
+ }
924
+ // 2. Compiled LESS defaults from stylesheets
925
+ if (cssVars[suffixed]) {
926
+ return cssVars[suffixed];
927
+ }
928
+ // 3. Try the base key (no suffix) as last resort
929
+ if (cssVars[`--${colorKey}`]) {
930
+ return cssVars[`--${colorKey}`];
931
+ }
932
+ return undefined;
933
+ };
934
+
935
+ // Build a token object, filtering out undefined values
936
+ const token: Record<string, any> = {
937
+ // Core
938
+ colorPrimary: resolve('btn-bg'),
939
+ colorSuccess: resolve('alert-success-bg'),
940
+ colorWarning: resolve('alert-warning-bg'),
941
+ colorError: resolve('alert-error-bg'),
942
+ colorInfo: resolve('alert-info-bg'),
943
+
944
+ // Text
945
+ colorText: resolve('text-color'),
946
+ colorTextSecondary: resolve('text-light-color'),
947
+ colorTextDisabled: resolve('disabled-color'),
948
+
949
+ // Background
950
+ colorBgBase: resolve('bodybg-primary'),
951
+ colorBgContainer: resolve('component-bg'),
952
+ colorBgElevated: resolve('module-bg'),
953
+ colorBgLayout: resolve('body-bg'),
954
+
955
+ // Borders
956
+ colorBorder: resolve('border-color'),
957
+ colorSplit: resolve('border-color-split'),
958
+
959
+ // Typography
960
+ fontSize: 14,
961
+ borderRadius: 6,
962
+ };
963
+
964
+ // Remove undefined entries so antd uses its own defaults for missing values
965
+ Object.keys(token).forEach(k => { if (token[k] === undefined) delete token[k]; });
966
+
967
+
968
+ return {
969
+ cssVar: true,
970
+ hashed: false,
971
+ algorithm: currentTheme === 'dark' ? antdTheme.darkAlgorithm : antdTheme.defaultAlgorithm,
972
+
973
+ token,
974
+
975
+ components: {
976
+ Table: {
977
+ headerBg: resolve('table-header-bg'),
978
+ headerColor: resolve('table-header-color'),
979
+ rowHoverBg: resolve('component-hover-bg'),
980
+ rowSelectedBg: resolve('component-active-bg'),
981
+ borderColor: resolve('border-color'),
982
+ footerBg: resolve('component-bg'),
983
+ },
984
+
985
+ Button: {
986
+ colorPrimary: resolve('btn-bg'),
987
+ colorPrimaryHover: resolve('highlight-color'),
988
+ colorPrimaryActive: resolve('btn-active-bg'),
989
+ defaultBg: resolve('secondary-color'),
990
+ defaultColor: resolve('text-color'),
991
+ defaultBorderColor: resolve('border-color'),
992
+ },
993
+
994
+ Input: {
995
+ colorBgContainer: resolve('component-bg'),
996
+ colorBorder: resolve('border-color'),
997
+ colorText: resolve('text-color'),
998
+ activeBorderColor: resolve('primary-color'),
999
+ hoverBorderColor: resolve('primary-color'),
1000
+ },
1001
+
1002
+ Select: {
1003
+ colorBgContainer: resolve('component-bg'),
1004
+ colorBorder: resolve('border-color'),
1005
+ colorText: resolve('text-color'),
1006
+ },
1007
+
1008
+ Dropdown: {
1009
+ colorBgElevated: resolve('component-bg'),
1010
+ colorText: resolve('text-color'),
1011
+ },
1012
+
1013
+ Modal: {
1014
+ contentBg: resolve('component-bg'),
1015
+ headerBg: resolve('component-bg'),
1016
+ titleColor: resolve('text-color'),
1017
+ },
1018
+
1019
+ Layout: {
1020
+ headerBg: resolve('primary-color'),
1021
+ bodyBg: resolve('bodybg-primary'),
1022
+ siderBg: resolve('sidebar-bg'),
1023
+ },
1024
+
1025
+ Menu: {
1026
+ itemBg: 'transparent',
1027
+ itemColor: resolve('text-color'),
1028
+ itemHoverBg: resolve('component-hover-bg'),
1029
+ itemSelectedBg: resolve('component-active-bg'),
1030
+ itemSelectedColor: resolve('highlight-color'),
1031
+ },
1032
+
1033
+ Card: {
1034
+ colorBgContainer: resolve('component-bg'),
1035
+ colorBorderSecondary: resolve('border-color'),
1036
+ },
1037
+
1038
+ Tooltip: {
1039
+ colorBgSpotlight: resolve('module-bg'),
1040
+ colorTextLightSolid: resolve('text-color'),
1041
+ },
1042
+
1043
+ Tabs: {
1044
+ itemColor: resolve('text-color'),
1045
+ itemSelectedColor: resolve('highlight-color'),
1046
+ inkBarColor: resolve('highlight-color'),
1047
+ },
1048
+ },
1049
+ };
1050
+ };
1051
+
1052
+ export default appTheme;