@redsift/table 12.3.0 → 12.3.1-muiv6-alpha.2

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.
@@ -1,10 +1,14 @@
1
+ import { P as PropTypes, z as exactProp, x as useTheme$1, a as _extends, _ as _objectWithoutPropertiesLoose, T as THEME_ID } from './Portal.js';
1
2
  import * as React from 'react';
2
3
  import { useState, useEffect } from 'react';
3
- import { P as PropTypes, K as exactProp, L as useTheme$1, B as useId, M as useEnhancedEffect, N as GlobalStyles, R as RtlProvider, Q as DefaultPropsProvider, U as GlobalStyles$1, T as THEME_ID, j as createTheme, V as createTypography, e as styleFunctionSx } from './ServerSideControlledPagination.js';
4
4
  import { j as jsxRuntimeExports } from './jsx-runtime.js';
5
5
  import { ThemeContext as ThemeContext$2 } from '@emotion/react';
6
6
  import styled, { css } from 'styled-components';
7
7
 
8
+ /* eslint-disable */
9
+ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
10
+ var ponyfillGlobal = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
11
+
8
12
  const ThemeContext = /*#__PURE__*/React.createContext(null);
9
13
  if (process.env.NODE_ENV !== 'production') {
10
14
  ThemeContext.displayName = 'ThemeContext';
@@ -14,8 +18,7 @@ var ThemeContext$1 = ThemeContext;
14
18
  function useTheme() {
15
19
  const theme = React.useContext(ThemeContext$1);
16
20
  if (process.env.NODE_ENV !== 'production') {
17
- // TODO: uncomment once we enable eslint-plugin-react-compiler eslint-disable-next-line react-compiler/react-compiler
18
- // eslint-disable-next-line react-hooks/rules-of-hooks -- It's not required to run React.useDebugValue in production
21
+ // eslint-disable-next-line react-hooks/rules-of-hooks
19
22
  React.useDebugValue(theme);
20
23
  }
21
24
  return theme;
@@ -57,9 +60,7 @@ function ThemeProvider$2(props) {
57
60
  }
58
61
  }
59
62
  const theme = React.useMemo(() => {
60
- const output = outerTheme === null ? {
61
- ...localTheme
62
- } : mergeOuterLocalTheme(outerTheme, localTheme);
63
+ const output = outerTheme === null ? localTheme : mergeOuterLocalTheme(outerTheme, localTheme);
63
64
  if (output != null) {
64
65
  output[nested] = outerTheme !== null;
65
66
  }
@@ -84,58 +85,15 @@ if (process.env.NODE_ENV !== 'production') {
84
85
  process.env.NODE_ENV !== "production" ? ThemeProvider$2.propTypes = exactProp(ThemeProvider$2.propTypes) : void 0;
85
86
  }
86
87
 
87
- function useLayerOrder(theme) {
88
- const upperTheme = useTheme$1();
89
- const id = useId() || '';
90
- const {
91
- modularCssLayers
92
- } = theme;
93
- let layerOrder = 'mui.global, mui.components, mui.theme, mui.custom, mui.sx';
94
- if (!modularCssLayers || upperTheme !== null) {
95
- // skip this hook if upper theme exists.
96
- layerOrder = '';
97
- } else if (typeof modularCssLayers === 'string') {
98
- layerOrder = modularCssLayers.replace(/mui(?!\.)/g, layerOrder);
99
- } else {
100
- layerOrder = `@layer ${layerOrder};`;
101
- }
102
- useEnhancedEffect(() => {
103
- const head = document.querySelector('head');
104
- if (!head) {
105
- return;
106
- }
107
- const firstChild = head.firstChild;
108
- if (layerOrder) {
109
- // Only insert if first child doesn't have data-mui-layer-order attribute
110
- if (firstChild && firstChild.hasAttribute?.('data-mui-layer-order') && firstChild.getAttribute('data-mui-layer-order') === id) {
111
- return;
112
- }
113
- const styleElement = document.createElement('style');
114
- styleElement.setAttribute('data-mui-layer-order', id);
115
- styleElement.textContent = layerOrder;
116
- head.prepend(styleElement);
117
- } else {
118
- head.querySelector(`style[data-mui-layer-order="${id}"]`)?.remove();
119
- }
120
- }, [layerOrder, id]);
121
- if (!layerOrder) {
122
- return null;
123
- }
124
- return /*#__PURE__*/jsxRuntimeExports.jsx(GlobalStyles, {
125
- styles: layerOrder
126
- });
127
- }
128
-
129
88
  const EMPTY_THEME = {};
130
89
  function useThemeScoping(themeId, upperTheme, localTheme, isPrivate = false) {
131
90
  return React.useMemo(() => {
132
91
  const resolvedTheme = themeId ? upperTheme[themeId] || upperTheme : upperTheme;
133
92
  if (typeof localTheme === 'function') {
134
93
  const mergedTheme = localTheme(resolvedTheme);
135
- const result = themeId ? {
136
- ...upperTheme,
94
+ const result = themeId ? _extends({}, upperTheme, {
137
95
  [themeId]: mergedTheme
138
- } : mergedTheme;
96
+ }) : mergedTheme;
139
97
  // must return a function for the private theme to NOT merge with the upper theme.
140
98
  // see the test case "use provided theme from a callback" in ThemeProvider.test.js
141
99
  if (isPrivate) {
@@ -143,13 +101,9 @@ function useThemeScoping(themeId, upperTheme, localTheme, isPrivate = false) {
143
101
  }
144
102
  return result;
145
103
  }
146
- return themeId ? {
147
- ...upperTheme,
104
+ return themeId ? _extends({}, upperTheme, {
148
105
  [themeId]: localTheme
149
- } : {
150
- ...upperTheme,
151
- ...localTheme
152
- };
106
+ }) : _extends({}, upperTheme, localTheme);
153
107
  }, [themeId, upperTheme, localTheme, isPrivate]);
154
108
  }
155
109
 
@@ -175,27 +129,19 @@ function ThemeProvider$1(props) {
175
129
  }
176
130
  const engineTheme = useThemeScoping(themeId, upperTheme, localTheme);
177
131
  const privateTheme = useThemeScoping(themeId, upperPrivateTheme, localTheme, true);
178
- const rtlValue = (themeId ? engineTheme[themeId] : engineTheme).direction === 'rtl';
179
- const layerOrder = useLayerOrder(engineTheme);
180
132
  return /*#__PURE__*/jsxRuntimeExports.jsx(ThemeProvider$2, {
181
133
  theme: privateTheme,
182
134
  children: /*#__PURE__*/jsxRuntimeExports.jsx(ThemeContext$2.Provider, {
183
135
  value: engineTheme,
184
- children: /*#__PURE__*/jsxRuntimeExports.jsx(RtlProvider, {
185
- value: rtlValue,
186
- children: /*#__PURE__*/jsxRuntimeExports.jsxs(DefaultPropsProvider, {
187
- value: themeId ? engineTheme[themeId].components : engineTheme.components,
188
- children: [layerOrder, children]
189
- })
190
- })
136
+ children: children
191
137
  })
192
138
  });
193
139
  }
194
140
  process.env.NODE_ENV !== "production" ? ThemeProvider$1.propTypes /* remove-proptypes */ = {
195
- // ┌────────────────────────────── Warning ──────────────────────────────┐
196
- // These PropTypes are generated from the TypeScript type definitions.
197
- // To update them, edit the d.ts file and run `pnpm proptypes`.
198
- // └─────────────────────────────────────────────────────────────────────┘
141
+ // ----------------------------- Warning --------------------------------
142
+ // | These PropTypes are generated from the TypeScript type definitions |
143
+ // | To update them edit the d.ts file and run "yarn proptypes" |
144
+ // ----------------------------------------------------------------------
199
145
  /**
200
146
  * Your component tree.
201
147
  */
@@ -213,857 +159,41 @@ if (process.env.NODE_ENV !== 'production') {
213
159
  process.env.NODE_ENV !== "production" ? ThemeProvider$1.propTypes = exactProp(ThemeProvider$1.propTypes) : void 0;
214
160
  }
215
161
 
216
- const DEFAULT_MODE_STORAGE_KEY = 'mode';
217
- const DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'color-scheme';
218
- const DEFAULT_ATTRIBUTE = 'data-color-scheme';
219
- function InitColorSchemeScript(options) {
220
- const {
221
- defaultMode = 'system',
222
- defaultLightColorScheme = 'light',
223
- defaultDarkColorScheme = 'dark',
224
- modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
225
- colorSchemeStorageKey = DEFAULT_COLOR_SCHEME_STORAGE_KEY,
226
- attribute: initialAttribute = DEFAULT_ATTRIBUTE,
227
- colorSchemeNode = 'document.documentElement',
228
- nonce
229
- } = options || {};
230
- let setter = '';
231
- let attribute = initialAttribute;
232
- if (initialAttribute === 'class') {
233
- attribute = '.%s';
234
- }
235
- if (initialAttribute === 'data') {
236
- attribute = '[data-%s]';
237
- }
238
- if (attribute.startsWith('.')) {
239
- const selector = attribute.substring(1);
240
- setter += `${colorSchemeNode}.classList.remove('${selector}'.replace('%s', light), '${selector}'.replace('%s', dark));
241
- ${colorSchemeNode}.classList.add('${selector}'.replace('%s', colorScheme));`;
242
- }
243
- const matches = attribute.match(/\[([^[\]]+)\]/); // case [data-color-scheme='%s'] or [data-color-scheme]
244
- if (matches) {
245
- const [attr, value] = matches[1].split('=');
246
- if (!value) {
247
- setter += `${colorSchemeNode}.removeAttribute('${attr}'.replace('%s', light));
248
- ${colorSchemeNode}.removeAttribute('${attr}'.replace('%s', dark));`;
249
- }
250
- setter += `
251
- ${colorSchemeNode}.setAttribute('${attr}'.replace('%s', colorScheme), ${value ? `${value}.replace('%s', colorScheme)` : '""'});`;
252
- } else if (attribute !== '.%s') {
253
- setter += `${colorSchemeNode}.setAttribute('${attribute}', colorScheme);`;
254
- }
255
- return /*#__PURE__*/jsxRuntimeExports.jsx("script", {
256
- suppressHydrationWarning: true,
257
- nonce: typeof window === 'undefined' ? nonce : ''
258
- // eslint-disable-next-line react/no-danger
259
- ,
260
- dangerouslySetInnerHTML: {
261
- __html: `(function() {
262
- try {
263
- let colorScheme = '';
264
- const mode = localStorage.getItem('${modeStorageKey}') || '${defaultMode}';
265
- const dark = localStorage.getItem('${colorSchemeStorageKey}-dark') || '${defaultDarkColorScheme}';
266
- const light = localStorage.getItem('${colorSchemeStorageKey}-light') || '${defaultLightColorScheme}';
267
- if (mode === 'system') {
268
- // handle system mode
269
- const mql = window.matchMedia('(prefers-color-scheme: dark)');
270
- if (mql.matches) {
271
- colorScheme = dark
272
- } else {
273
- colorScheme = light
274
- }
275
- }
276
- if (mode === 'light') {
277
- colorScheme = light;
278
- }
279
- if (mode === 'dark') {
280
- colorScheme = dark;
281
- }
282
- if (colorScheme) {
283
- ${setter}
284
- }
285
- } catch(e){}})();`
286
- }
287
- }, "mui-color-scheme-init");
288
- }
289
-
290
- function noop$1() {}
291
- const localStorageManager = ({
292
- key,
293
- storageWindow
294
- }) => {
295
- if (!storageWindow && typeof window !== 'undefined') {
296
- storageWindow = window;
297
- }
298
- return {
299
- get(defaultValue) {
300
- if (typeof window === 'undefined') {
301
- return undefined;
302
- }
303
- if (!storageWindow) {
304
- return defaultValue;
305
- }
306
- let value;
307
- try {
308
- value = storageWindow.localStorage.getItem(key);
309
- } catch {
310
- // Unsupported
311
- }
312
- return value || defaultValue;
313
- },
314
- set: value => {
315
- if (storageWindow) {
316
- try {
317
- storageWindow.localStorage.setItem(key, value);
318
- } catch {
319
- // Unsupported
320
- }
321
- }
322
- },
323
- subscribe: handler => {
324
- if (!storageWindow) {
325
- return noop$1;
326
- }
327
- const listener = event => {
328
- const value = event.newValue;
329
- if (event.key === key) {
330
- handler(value);
331
- }
332
- };
333
- storageWindow.addEventListener('storage', listener);
334
- return () => {
335
- storageWindow.removeEventListener('storage', listener);
336
- };
337
- }
338
- };
339
- };
340
- var localStorageManager$1 = localStorageManager;
341
-
342
- function noop() {}
343
- function getSystemMode(mode) {
344
- if (typeof window !== 'undefined' && typeof window.matchMedia === 'function' && mode === 'system') {
345
- const mql = window.matchMedia('(prefers-color-scheme: dark)');
346
- if (mql.matches) {
347
- return 'dark';
348
- }
349
- return 'light';
350
- }
351
- return undefined;
352
- }
353
- function processState(state, callback) {
354
- if (state.mode === 'light' || state.mode === 'system' && state.systemMode === 'light') {
355
- return callback('light');
356
- }
357
- if (state.mode === 'dark' || state.mode === 'system' && state.systemMode === 'dark') {
358
- return callback('dark');
359
- }
360
- return undefined;
361
- }
362
- function getColorScheme(state) {
363
- return processState(state, mode => {
364
- if (mode === 'light') {
365
- return state.lightColorScheme;
366
- }
367
- if (mode === 'dark') {
368
- return state.darkColorScheme;
369
- }
370
- return undefined;
371
- });
372
- }
373
- function useCurrentColorScheme(options) {
374
- const {
375
- defaultMode = 'light',
376
- defaultLightColorScheme,
377
- defaultDarkColorScheme,
378
- supportedColorSchemes = [],
379
- modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
380
- colorSchemeStorageKey = DEFAULT_COLOR_SCHEME_STORAGE_KEY,
381
- storageWindow = typeof window === 'undefined' ? undefined : window,
382
- storageManager = localStorageManager$1,
383
- noSsr = false
384
- } = options;
385
- const joinedColorSchemes = supportedColorSchemes.join(',');
386
- const isMultiSchemes = supportedColorSchemes.length > 1;
387
- const modeStorage = React.useMemo(() => storageManager?.({
388
- key: modeStorageKey,
389
- storageWindow
390
- }), [storageManager, modeStorageKey, storageWindow]);
391
- const lightStorage = React.useMemo(() => storageManager?.({
392
- key: `${colorSchemeStorageKey}-light`,
393
- storageWindow
394
- }), [storageManager, colorSchemeStorageKey, storageWindow]);
395
- const darkStorage = React.useMemo(() => storageManager?.({
396
- key: `${colorSchemeStorageKey}-dark`,
397
- storageWindow
398
- }), [storageManager, colorSchemeStorageKey, storageWindow]);
399
- const [state, setState] = React.useState(() => {
400
- const initialMode = modeStorage?.get(defaultMode) || defaultMode;
401
- const lightColorScheme = lightStorage?.get(defaultLightColorScheme) || defaultLightColorScheme;
402
- const darkColorScheme = darkStorage?.get(defaultDarkColorScheme) || defaultDarkColorScheme;
403
- return {
404
- mode: initialMode,
405
- systemMode: getSystemMode(initialMode),
406
- lightColorScheme,
407
- darkColorScheme
408
- };
409
- });
410
- const [isClient, setIsClient] = React.useState(noSsr || !isMultiSchemes);
411
- React.useEffect(() => {
412
- setIsClient(true); // to rerender the component after hydration
413
- }, []);
414
- const colorScheme = getColorScheme(state);
415
- const setMode = React.useCallback(mode => {
416
- setState(currentState => {
417
- if (mode === currentState.mode) {
418
- // do nothing if mode does not change
419
- return currentState;
420
- }
421
- const newMode = mode ?? defaultMode;
422
- modeStorage?.set(newMode);
423
- return {
424
- ...currentState,
425
- mode: newMode,
426
- systemMode: getSystemMode(newMode)
427
- };
428
- });
429
- }, [modeStorage, defaultMode]);
430
- const setColorScheme = React.useCallback(value => {
431
- if (!value) {
432
- setState(currentState => {
433
- lightStorage?.set(defaultLightColorScheme);
434
- darkStorage?.set(defaultDarkColorScheme);
435
- return {
436
- ...currentState,
437
- lightColorScheme: defaultLightColorScheme,
438
- darkColorScheme: defaultDarkColorScheme
439
- };
440
- });
441
- } else if (typeof value === 'string') {
442
- if (value && !joinedColorSchemes.includes(value)) {
443
- console.error(`\`${value}\` does not exist in \`theme.colorSchemes\`.`);
444
- } else {
445
- setState(currentState => {
446
- const newState = {
447
- ...currentState
448
- };
449
- processState(currentState, mode => {
450
- if (mode === 'light') {
451
- lightStorage?.set(value);
452
- newState.lightColorScheme = value;
453
- }
454
- if (mode === 'dark') {
455
- darkStorage?.set(value);
456
- newState.darkColorScheme = value;
457
- }
458
- });
459
- return newState;
460
- });
461
- }
462
- } else {
463
- setState(currentState => {
464
- const newState = {
465
- ...currentState
466
- };
467
- const newLightColorScheme = value.light === null ? defaultLightColorScheme : value.light;
468
- const newDarkColorScheme = value.dark === null ? defaultDarkColorScheme : value.dark;
469
- if (newLightColorScheme) {
470
- if (!joinedColorSchemes.includes(newLightColorScheme)) {
471
- console.error(`\`${newLightColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
472
- } else {
473
- newState.lightColorScheme = newLightColorScheme;
474
- lightStorage?.set(newLightColorScheme);
475
- }
476
- }
477
- if (newDarkColorScheme) {
478
- if (!joinedColorSchemes.includes(newDarkColorScheme)) {
479
- console.error(`\`${newDarkColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
480
- } else {
481
- newState.darkColorScheme = newDarkColorScheme;
482
- darkStorage?.set(newDarkColorScheme);
483
- }
484
- }
485
- return newState;
486
- });
487
- }
488
- }, [joinedColorSchemes, lightStorage, darkStorage, defaultLightColorScheme, defaultDarkColorScheme]);
489
- const handleMediaQuery = React.useCallback(event => {
490
- if (state.mode === 'system') {
491
- setState(currentState => {
492
- const systemMode = event?.matches ? 'dark' : 'light';
493
-
494
- // Early exit, nothing changed.
495
- if (currentState.systemMode === systemMode) {
496
- return currentState;
497
- }
498
- return {
499
- ...currentState,
500
- systemMode
501
- };
502
- });
503
- }
504
- }, [state.mode]);
505
-
506
- // Ref hack to avoid adding handleMediaQuery as a dep
507
- const mediaListener = React.useRef(handleMediaQuery);
508
- mediaListener.current = handleMediaQuery;
509
- React.useEffect(() => {
510
- if (typeof window.matchMedia !== 'function' || !isMultiSchemes) {
511
- return undefined;
512
- }
513
- const handler = (...args) => mediaListener.current(...args);
514
-
515
- // Always listen to System preference
516
- const media = window.matchMedia('(prefers-color-scheme: dark)');
517
-
518
- // Intentionally use deprecated listener methods to support iOS & old browsers
519
- media.addListener(handler);
520
- handler(media);
521
- return () => {
522
- media.removeListener(handler);
523
- };
524
- }, [isMultiSchemes]);
525
-
526
- // Handle when localStorage has changed
527
- React.useEffect(() => {
528
- if (isMultiSchemes) {
529
- const unsubscribeMode = modeStorage?.subscribe(value => {
530
- if (!value || ['light', 'dark', 'system'].includes(value)) {
531
- setMode(value || defaultMode);
532
- }
533
- }) || noop;
534
- const unsubscribeLight = lightStorage?.subscribe(value => {
535
- if (!value || joinedColorSchemes.match(value)) {
536
- setColorScheme({
537
- light: value
538
- });
539
- }
540
- }) || noop;
541
- const unsubscribeDark = darkStorage?.subscribe(value => {
542
- if (!value || joinedColorSchemes.match(value)) {
543
- setColorScheme({
544
- dark: value
545
- });
546
- }
547
- }) || noop;
548
- return () => {
549
- unsubscribeMode();
550
- unsubscribeLight();
551
- unsubscribeDark();
552
- };
553
- }
554
- return undefined;
555
- }, [setColorScheme, setMode, joinedColorSchemes, defaultMode, storageWindow, isMultiSchemes, modeStorage, lightStorage, darkStorage]);
556
- return {
557
- ...state,
558
- mode: isClient ? state.mode : undefined,
559
- systemMode: isClient ? state.systemMode : undefined,
560
- colorScheme: isClient ? colorScheme : undefined,
561
- setMode,
562
- setColorScheme
563
- };
564
- }
565
-
566
- const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
567
- function createCssVarsProvider(options) {
568
- const {
569
- themeId,
570
- /**
571
- * This `theme` object needs to follow a certain structure to
572
- * be used correctly by the finel `CssVarsProvider`. It should have a
573
- * `colorSchemes` key with the light and dark (and any other) palette.
574
- * It should also ideally have a vars object created using `prepareCssVars`.
575
- */
576
- theme: defaultTheme = {},
577
- modeStorageKey: defaultModeStorageKey = DEFAULT_MODE_STORAGE_KEY,
578
- colorSchemeStorageKey: defaultColorSchemeStorageKey = DEFAULT_COLOR_SCHEME_STORAGE_KEY,
579
- disableTransitionOnChange: designSystemTransitionOnChange = false,
580
- defaultColorScheme,
581
- resolveTheme
582
- } = options;
583
- const defaultContext = {
584
- allColorSchemes: [],
585
- colorScheme: undefined,
586
- darkColorScheme: undefined,
587
- lightColorScheme: undefined,
588
- mode: undefined,
589
- setColorScheme: () => {},
590
- setMode: () => {},
591
- systemMode: undefined
592
- };
593
- const ColorSchemeContext = /*#__PURE__*/React.createContext(undefined);
594
- if (process.env.NODE_ENV !== 'production') {
595
- ColorSchemeContext.displayName = 'ColorSchemeContext';
596
- }
597
- const useColorScheme = () => React.useContext(ColorSchemeContext) || defaultContext;
598
- const defaultColorSchemes = {};
599
- const defaultComponents = {};
600
- function CssVarsProvider(props) {
601
- const {
602
- children,
603
- theme: themeProp,
604
- modeStorageKey = defaultModeStorageKey,
605
- colorSchemeStorageKey = defaultColorSchemeStorageKey,
606
- disableTransitionOnChange = designSystemTransitionOnChange,
607
- storageManager,
608
- storageWindow = typeof window === 'undefined' ? undefined : window,
609
- documentNode = typeof document === 'undefined' ? undefined : document,
610
- colorSchemeNode = typeof document === 'undefined' ? undefined : document.documentElement,
611
- disableNestedContext = false,
612
- disableStyleSheetGeneration = false,
613
- defaultMode: initialMode = 'system',
614
- forceThemeRerender = false,
615
- noSsr
616
- } = props;
617
- const hasMounted = React.useRef(false);
618
- const upperTheme = useTheme();
619
- const ctx = React.useContext(ColorSchemeContext);
620
- const nested = !!ctx && !disableNestedContext;
621
- const initialTheme = React.useMemo(() => {
622
- if (themeProp) {
623
- return themeProp;
624
- }
625
- return typeof defaultTheme === 'function' ? defaultTheme() : defaultTheme;
626
- }, [themeProp]);
627
- const scopedTheme = initialTheme[themeId];
628
- const restThemeProp = scopedTheme || initialTheme;
629
- const {
630
- colorSchemes = defaultColorSchemes,
631
- components = defaultComponents,
632
- cssVarPrefix
633
- } = restThemeProp;
634
- const joinedColorSchemes = Object.keys(colorSchemes).filter(k => !!colorSchemes[k]).join(',');
635
- const allColorSchemes = React.useMemo(() => joinedColorSchemes.split(','), [joinedColorSchemes]);
636
- const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
637
- const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
638
- const defaultMode = colorSchemes[defaultLightColorScheme] && colorSchemes[defaultDarkColorScheme] ? initialMode : colorSchemes[restThemeProp.defaultColorScheme]?.palette?.mode || restThemeProp.palette?.mode;
639
-
640
- // 1. Get the data about the `mode`, `colorScheme`, and setter functions.
641
- const {
642
- mode: stateMode,
643
- setMode,
644
- systemMode,
645
- lightColorScheme,
646
- darkColorScheme,
647
- colorScheme: stateColorScheme,
648
- setColorScheme
649
- } = useCurrentColorScheme({
650
- supportedColorSchemes: allColorSchemes,
651
- defaultLightColorScheme,
652
- defaultDarkColorScheme,
653
- modeStorageKey,
654
- colorSchemeStorageKey,
655
- defaultMode,
656
- storageManager,
657
- storageWindow,
658
- noSsr
659
- });
660
- let mode = stateMode;
661
- let colorScheme = stateColorScheme;
662
- if (nested) {
663
- mode = ctx.mode;
664
- colorScheme = ctx.colorScheme;
665
- }
666
- if (process.env.NODE_ENV !== 'production') {
667
- if (forceThemeRerender && !restThemeProp.vars) {
668
- console.warn(['MUI: The `forceThemeRerender` prop should only be used with CSS theme variables.', 'Note that it will slow down the app when changing between modes, so only do this when you cannot find a better solution.'].join('\n'));
669
- }
670
- }
671
-
672
- // `colorScheme` is undefined on the server and hydration phase
673
- let calculatedColorScheme = colorScheme || restThemeProp.defaultColorScheme;
674
- if (restThemeProp.vars && !forceThemeRerender) {
675
- calculatedColorScheme = restThemeProp.defaultColorScheme;
676
- }
677
- const memoTheme = React.useMemo(() => {
678
- // 2. get the `vars` object that refers to the CSS custom properties
679
- const themeVars = restThemeProp.generateThemeVars?.() || restThemeProp.vars;
680
-
681
- // 3. Start composing the theme object
682
- const theme = {
683
- ...restThemeProp,
684
- components,
685
- colorSchemes,
686
- cssVarPrefix,
687
- vars: themeVars
688
- };
689
- if (typeof theme.generateSpacing === 'function') {
690
- theme.spacing = theme.generateSpacing();
691
- }
692
-
693
- // 4. Resolve the color scheme and merge it to the theme
694
- if (calculatedColorScheme) {
695
- const scheme = colorSchemes[calculatedColorScheme];
696
- if (scheme && typeof scheme === 'object') {
697
- // 4.1 Merge the selected color scheme to the theme
698
- Object.keys(scheme).forEach(schemeKey => {
699
- if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
700
- // shallow merge the 1st level structure of the theme.
701
- theme[schemeKey] = {
702
- ...theme[schemeKey],
703
- ...scheme[schemeKey]
704
- };
705
- } else {
706
- theme[schemeKey] = scheme[schemeKey];
707
- }
708
- });
709
- }
710
- }
711
- return resolveTheme ? resolveTheme(theme) : theme;
712
- }, [restThemeProp, calculatedColorScheme, components, colorSchemes, cssVarPrefix]);
713
-
714
- // 5. Declaring effects
715
- // 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
716
- const colorSchemeSelector = restThemeProp.colorSchemeSelector;
717
- useEnhancedEffect(() => {
718
- if (colorScheme && colorSchemeNode && colorSchemeSelector && colorSchemeSelector !== 'media') {
719
- const selector = colorSchemeSelector;
720
- let rule = colorSchemeSelector;
721
- if (selector === 'class') {
722
- rule = `.%s`;
723
- }
724
- if (selector === 'data') {
725
- rule = `[data-%s]`;
726
- }
727
- if (selector?.startsWith('data-') && !selector.includes('%s')) {
728
- // 'data-mui-color-scheme' -> '[data-mui-color-scheme="%s"]'
729
- rule = `[${selector}="%s"]`;
730
- }
731
- if (rule.startsWith('.')) {
732
- colorSchemeNode.classList.remove(...allColorSchemes.map(scheme => rule.substring(1).replace('%s', scheme)));
733
- colorSchemeNode.classList.add(rule.substring(1).replace('%s', colorScheme));
734
- } else {
735
- const matches = rule.replace('%s', colorScheme).match(/\[([^\]]+)\]/);
736
- if (matches) {
737
- const [attr, value] = matches[1].split('=');
738
- if (!value) {
739
- // for attributes like `data-theme-dark`, `data-theme-light`
740
- // remove all the existing data attributes before setting the new one
741
- allColorSchemes.forEach(scheme => {
742
- colorSchemeNode.removeAttribute(attr.replace(colorScheme, scheme));
743
- });
744
- }
745
- colorSchemeNode.setAttribute(attr, value ? value.replace(/"|'/g, '') : '');
746
- } else {
747
- colorSchemeNode.setAttribute(rule, colorScheme);
748
- }
749
- }
750
- }
751
- }, [colorScheme, colorSchemeSelector, colorSchemeNode, allColorSchemes]);
752
-
753
- // 5.2 Remove the CSS transition when color scheme changes to create instant experience.
754
- // credit: https://github.com/pacocoursey/next-themes/blob/b5c2bad50de2d61ad7b52a9c5cdc801a78507d7a/index.tsx#L313
755
- React.useEffect(() => {
756
- let timer;
757
- if (disableTransitionOnChange && hasMounted.current && documentNode) {
758
- const css = documentNode.createElement('style');
759
- css.appendChild(documentNode.createTextNode(DISABLE_CSS_TRANSITION));
760
- documentNode.head.appendChild(css);
761
-
762
- // Force browser repaint
763
- (() => window.getComputedStyle(documentNode.body))();
764
- timer = setTimeout(() => {
765
- documentNode.head.removeChild(css);
766
- }, 1);
767
- }
768
- return () => {
769
- clearTimeout(timer);
770
- };
771
- }, [colorScheme, disableTransitionOnChange, documentNode]);
772
- React.useEffect(() => {
773
- hasMounted.current = true;
774
- return () => {
775
- hasMounted.current = false;
776
- };
777
- }, []);
778
- const contextValue = React.useMemo(() => ({
779
- allColorSchemes,
780
- colorScheme,
781
- darkColorScheme,
782
- lightColorScheme,
783
- mode,
784
- setColorScheme,
785
- setMode: process.env.NODE_ENV === 'production' ? setMode : newMode => {
786
- if (memoTheme.colorSchemeSelector === 'media') {
787
- console.error(['MUI: The `setMode` function has no effect if `colorSchemeSelector` is `media` (`media` is the default value).', 'To toggle the mode manually, please configure `colorSchemeSelector` to use a class or data attribute.', 'To learn more, visit https://mui.com/material-ui/customization/css-theme-variables/configuration/#toggling-dark-mode-manually'].join('\n'));
788
- }
789
- setMode(newMode);
790
- },
791
- systemMode
792
- }), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode, memoTheme.colorSchemeSelector]);
793
- let shouldGenerateStyleSheet = true;
794
- if (disableStyleSheetGeneration || restThemeProp.cssVariables === false || nested && upperTheme?.cssVarPrefix === cssVarPrefix) {
795
- shouldGenerateStyleSheet = false;
796
- }
797
- const element = /*#__PURE__*/jsxRuntimeExports.jsxs(React.Fragment, {
798
- children: [/*#__PURE__*/jsxRuntimeExports.jsx(ThemeProvider$1, {
799
- themeId: scopedTheme ? themeId : undefined,
800
- theme: memoTheme,
801
- children: children
802
- }), shouldGenerateStyleSheet && /*#__PURE__*/jsxRuntimeExports.jsx(GlobalStyles$1, {
803
- styles: memoTheme.generateStyleSheets?.() || []
804
- })]
805
- });
806
- if (nested) {
807
- return element;
808
- }
809
- return /*#__PURE__*/jsxRuntimeExports.jsx(ColorSchemeContext.Provider, {
810
- value: contextValue,
811
- children: element
812
- });
813
- }
814
- process.env.NODE_ENV !== "production" ? CssVarsProvider.propTypes = {
815
- /**
816
- * The component tree.
817
- */
818
- children: PropTypes.node,
819
- /**
820
- * The node used to attach the color-scheme attribute
821
- */
822
- colorSchemeNode: PropTypes.any,
823
- /**
824
- * localStorage key used to store `colorScheme`
825
- */
826
- colorSchemeStorageKey: PropTypes.string,
827
- /**
828
- * The default mode when the storage is empty,
829
- * require the theme to have `colorSchemes` with light and dark.
830
- */
831
- defaultMode: PropTypes.string,
832
- /**
833
- * If `true`, the provider creates its own context and generate stylesheet as if it is a root `CssVarsProvider`.
834
- */
835
- disableNestedContext: PropTypes.bool,
836
- /**
837
- * If `true`, the style sheet won't be generated.
838
- *
839
- * This is useful for controlling nested CssVarsProvider behavior.
840
- */
841
- disableStyleSheetGeneration: PropTypes.bool,
842
- /**
843
- * Disable CSS transitions when switching between modes or color schemes.
844
- */
845
- disableTransitionOnChange: PropTypes.bool,
846
- /**
847
- * The document to attach the attribute to.
848
- */
849
- documentNode: PropTypes.any,
850
- /**
851
- * If `true`, theme values are recalculated when the mode changes.
852
- */
853
- forceThemeRerender: PropTypes.bool,
854
- /**
855
- * The key in the local storage used to store current color scheme.
856
- */
857
- modeStorageKey: PropTypes.string,
858
- /**
859
- * If `true`, the mode will be the same value as the storage without an extra rerendering after the hydration.
860
- * You should use this option in conjunction with `InitColorSchemeScript` component.
861
- */
862
- noSsr: PropTypes.bool,
863
- /**
864
- * The storage manager to be used for storing the mode and color scheme
865
- * @default using `window.localStorage`
866
- */
867
- storageManager: PropTypes.func,
868
- /**
869
- * The window that attaches the 'storage' event listener.
870
- * @default window
871
- */
872
- storageWindow: PropTypes.any,
873
- /**
874
- * The calculated theme object that will be passed through context.
875
- */
876
- theme: PropTypes.object
877
- } : void 0;
878
- const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
879
- const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
880
- const getInitColorSchemeScript = params => InitColorSchemeScript({
881
- colorSchemeStorageKey: defaultColorSchemeStorageKey,
882
- defaultLightColorScheme,
883
- defaultDarkColorScheme,
884
- modeStorageKey: defaultModeStorageKey,
885
- ...params
886
- });
887
- return {
888
- CssVarsProvider,
889
- useColorScheme,
890
- getInitColorSchemeScript
891
- };
892
- }
893
-
894
- function ThemeProviderNoVars({
895
- theme: themeInput,
896
- ...props
897
- }) {
898
- const scopedTheme = THEME_ID in themeInput ? themeInput[THEME_ID] : undefined;
899
- return /*#__PURE__*/jsxRuntimeExports.jsx(ThemeProvider$1, {
900
- ...props,
162
+ const _excluded = ["theme"];
163
+ function ThemeProvider(_ref) {
164
+ let {
165
+ theme: themeInput
166
+ } = _ref,
167
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
168
+ const scopedTheme = themeInput[THEME_ID];
169
+ return /*#__PURE__*/jsxRuntimeExports.jsx(ThemeProvider$1, _extends({}, props, {
901
170
  themeId: scopedTheme ? THEME_ID : undefined,
902
171
  theme: scopedTheme || themeInput
903
- });
172
+ }));
904
173
  }
905
-
906
- const defaultConfig = {
907
- attribute: 'data-mui-color-scheme',
908
- colorSchemeStorageKey: 'mui-color-scheme',
909
- defaultLightColorScheme: 'light',
910
- defaultDarkColorScheme: 'dark',
911
- modeStorageKey: 'mui-mode'
912
- };
913
- process.env.NODE_ENV !== "production" ? {
914
- // ┌────────────────────────────── Warning ──────────────────────────────┐
915
- // │ These PropTypes are generated from the TypeScript type definitions. │
916
- // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
917
- // └─────────────────────────────────────────────────────────────────────┘
918
- /**
919
- * DOM attribute for applying a color scheme.
920
- * @default 'data-mui-color-scheme'
921
- * @example '.mode-%s' // for class based color scheme
922
- * @example '[data-mode-%s]' // for data-attribute without '='
923
- */
924
- attribute: PropTypes.string,
174
+ process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = {
925
175
  /**
926
- * The node (provided as string) used to attach the color-scheme attribute.
927
- * @default 'document.documentElement'
928
- */
929
- colorSchemeNode: PropTypes.string,
930
- /**
931
- * localStorage key used to store `colorScheme`.
932
- * @default 'mui-color-scheme'
933
- */
934
- colorSchemeStorageKey: PropTypes.string,
935
- /**
936
- * The default color scheme to be used in dark mode.
937
- * @default 'dark'
938
- */
939
- defaultDarkColorScheme: PropTypes.string,
940
- /**
941
- * The default color scheme to be used in light mode.
942
- * @default 'light'
943
- */
944
- defaultLightColorScheme: PropTypes.string,
945
- /**
946
- * The default mode when the storage is empty (user's first visit).
947
- * @default 'system'
948
- */
949
- defaultMode: PropTypes.oneOf(['dark', 'light', 'system']),
950
- /**
951
- * localStorage key used to store `mode`.
952
- * @default 'mui-mode'
176
+ * Your component tree.
953
177
  */
954
- modeStorageKey: PropTypes.string,
178
+ children: PropTypes.node,
955
179
  /**
956
- * Nonce string to pass to the inline script for CSP headers.
180
+ * A theme object. You can provide a function to extend the outer theme.
957
181
  */
958
- nonce: PropTypes.string
182
+ theme: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).isRequired
959
183
  } : void 0;
960
184
 
961
- const {
962
- CssVarsProvider: InternalCssVarsProvider,
963
- useColorScheme,
964
- getInitColorSchemeScript: deprecatedGetInitColorSchemeScript
965
- } = createCssVarsProvider({
966
- themeId: THEME_ID,
967
- // @ts-ignore ignore module augmentation tests
968
- theme: () => createTheme({
969
- cssVariables: true
970
- }),
971
- colorSchemeStorageKey: defaultConfig.colorSchemeStorageKey,
972
- modeStorageKey: defaultConfig.modeStorageKey,
973
- defaultColorScheme: {
974
- light: defaultConfig.defaultLightColorScheme,
975
- dark: defaultConfig.defaultDarkColorScheme
976
- },
977
- resolveTheme: theme => {
978
- const newTheme = {
979
- ...theme,
980
- typography: createTypography(theme.palette, theme.typography)
981
- };
982
- newTheme.unstable_sx = function sx(props) {
983
- return styleFunctionSx({
984
- sx: props,
985
- theme: this
986
- });
987
- };
988
- return newTheme;
989
- }
990
- });
991
-
992
- /**
993
- * TODO: remove this export in v7
994
- * @deprecated
995
- * The `CssVarsProvider` component has been deprecated and ported into `ThemeProvider`.
996
- *
997
- * You should use `ThemeProvider` and `createTheme()` instead:
998
- *
999
- * ```diff
1000
- * - import { CssVarsProvider, extendTheme } from '@mui/material/styles';
1001
- * + import { ThemeProvider, createTheme } from '@mui/material/styles';
1002
- *
1003
- * - const theme = extendTheme();
1004
- * + const theme = createTheme({
1005
- * + cssVariables: true,
1006
- * + colorSchemes: { light: true, dark: true },
1007
- * + });
1008
- *
1009
- * - <CssVarsProvider theme={theme}>
1010
- * + <ThemeProvider theme={theme}>
1011
- * ```
1012
- *
1013
- * To see the full documentation, check out https://mui.com/material-ui/customization/css-theme-variables/usage/.
1014
- */
1015
- const CssVarsProvider = InternalCssVarsProvider;
1016
-
1017
- function ThemeProvider({
1018
- theme,
1019
- ...props
1020
- }) {
1021
- const noVarsTheme = React.useMemo(() => {
1022
- if (typeof theme === 'function') {
1023
- return theme;
1024
- }
1025
- const muiTheme = THEME_ID in theme ? theme[THEME_ID] : theme;
1026
- if (!('colorSchemes' in muiTheme)) {
1027
- if (!('vars' in muiTheme)) {
1028
- // For non-CSS variables themes, set `vars` to null to prevent theme inheritance from the upper theme.
1029
- // The example use case is the docs demo that uses ThemeProvider to customize the theme while the upper theme is using CSS variables.
1030
- return {
1031
- ...theme,
1032
- vars: null
1033
- };
1034
- }
1035
- return theme;
1036
- }
1037
- return null;
1038
- }, [theme]);
1039
- if (noVarsTheme) {
1040
- return /*#__PURE__*/jsxRuntimeExports.jsx(ThemeProviderNoVars, {
1041
- theme: noVarsTheme,
1042
- ...props
1043
- });
1044
- }
1045
- return /*#__PURE__*/jsxRuntimeExports.jsx(CssVarsProvider, {
1046
- theme: theme,
1047
- ...props
1048
- });
1049
- }
1050
-
1051
- /**
1052
- * @ignore - do not document.
1053
- */
1054
-
1055
185
  // Store the license information in a global, so it can be shared
1056
186
  // when module duplication occurs. The duplication of the modules can happen
1057
187
  // if using multiple version of MUI X at the same time of the bundler
1058
188
  // decide to duplicate to improve the size of the chunks.
1059
189
  // eslint-disable-next-line no-underscore-dangle
1060
- globalThis.__MUI_LICENSE_INFO__ = globalThis.__MUI_LICENSE_INFO__ || {
190
+ ponyfillGlobal.__MUI_LICENSE_INFO__ = ponyfillGlobal.__MUI_LICENSE_INFO__ || {
1061
191
  key: undefined
1062
192
  };
1063
193
  class LicenseInfo {
1064
194
  static getLicenseInfo() {
1065
195
  // eslint-disable-next-line no-underscore-dangle
1066
- return globalThis.__MUI_LICENSE_INFO__;
196
+ return ponyfillGlobal.__MUI_LICENSE_INFO__;
1067
197
  }
1068
198
  static getLicenseKey() {
1069
199
  return LicenseInfo.getLicenseInfo().key;
@@ -1186,11 +316,11 @@ const useControlledDatagridState = _ref => {
1186
316
  useEffect(() => {
1187
317
  setPinnedColumns(propsPinnedColumns);
1188
318
  }, [propsPinnedColumns]);
1189
- const onPinnedColumnsChange = (pinnedColumns, details) => {
319
+ const onPinnedColumnsChange = (model, details) => {
1190
320
  if (propsOnPinnedColumnsChange) {
1191
- propsOnPinnedColumnsChange(pinnedColumns, details);
321
+ propsOnPinnedColumnsChange(model, details);
1192
322
  } else {
1193
- setPinnedColumns(pinnedColumns);
323
+ setPinnedColumns(model);
1194
324
  }
1195
325
  };
1196
326
  const [sortModel, setSortModel] = useState(propsSortModel);