@primer/react 0.0.0-20260330174802 → 0.0.0-20260330175610
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.
- package/CHANGELOG.md +7 -28
- package/dist/ActionBar/ActionBar.js +3 -3
- package/dist/ActionList/Heading.js +16 -17
- package/dist/AnchoredOverlay/AnchoredOverlay-0f6f45b5.css +2 -0
- package/dist/AnchoredOverlay/AnchoredOverlay-0f6f45b5.css.map +1 -0
- package/dist/AnchoredOverlay/AnchoredOverlay.d.ts.map +1 -1
- package/dist/AnchoredOverlay/AnchoredOverlay.js +10 -50
- package/dist/AnchoredOverlay/AnchoredOverlay.module.css.js +2 -2
- package/dist/Autocomplete/AutocompleteInput.js +3 -3
- package/dist/Autocomplete/AutocompleteOverlay.js +3 -3
- package/dist/Button/ButtonBase.d.ts.map +1 -1
- package/dist/Button/ButtonBase.js +4 -3
- package/dist/Dialog/{Dialog-f9bb927a.css → Dialog-b577691f.css} +2 -2
- package/dist/Dialog/Dialog-b577691f.css.map +1 -0
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +21 -9
- package/dist/Dialog/Dialog.module.css.js +2 -2
- package/dist/FeatureFlags/DefaultFeatureFlags.d.ts.map +1 -1
- package/dist/FeatureFlags/DefaultFeatureFlags.js +1 -0
- package/dist/FeatureFlags/FeatureFlags.d.ts +6 -0
- package/dist/FeatureFlags/FeatureFlags.d.ts.map +1 -1
- package/dist/FeatureFlags/FeatureFlags.js +41 -32
- package/dist/Heading/Heading.js +3 -3
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +4 -3
- package/dist/Overlay/Overlay.d.ts +0 -1
- package/dist/Overlay/Overlay.d.ts.map +1 -1
- package/dist/Overlay/Overlay.js +84 -89
- package/dist/PageLayout/PageLayout.js +5 -5
- package/dist/StateLabel/{StateLabel-cd51ae39.css → StateLabel-056eec66.css} +2 -2
- package/dist/StateLabel/StateLabel-056eec66.css.map +1 -0
- package/dist/StateLabel/StateLabel.d.ts +0 -1
- package/dist/StateLabel/StateLabel.d.ts.map +1 -1
- package/dist/StateLabel/StateLabel.js +2 -4
- package/dist/StateLabel/StateLabel.module.css.js +1 -1
- package/dist/TextInputWithTokens/TextInputWithTokens.js +90 -91
- package/dist/ThemeProvider.d.ts.map +1 -1
- package/dist/ThemeProvider.js +104 -163
- package/dist/deprecated/DialogV1/Dialog.js +9 -10
- package/dist/hooks/useMergedRefs.d.ts +4 -4
- package/dist/hooks/useMergedRefs.js +4 -4
- package/generated/components.json +1 -5
- package/package.json +7 -8
- package/dist/AnchoredOverlay/AnchoredOverlay-647c7065.css +0 -2
- package/dist/AnchoredOverlay/AnchoredOverlay-647c7065.css.map +0 -1
- package/dist/Dialog/Dialog-f9bb927a.css.map +0 -1
- package/dist/StateLabel/StateLabel-cd51ae39.css.map +0 -1
|
@@ -3,7 +3,7 @@ import { FocusKeys } from '@primer/behaviors';
|
|
|
3
3
|
import { isFocusable } from '@primer/behaviors/utils';
|
|
4
4
|
import React, { useRef, useState } from 'react';
|
|
5
5
|
import { isValidElementType } from 'react-is';
|
|
6
|
-
import {
|
|
6
|
+
import { useRefObjectAsForwardedRef } from '../hooks/useRefObjectAsForwardedRef.js';
|
|
7
7
|
import { useFocusZone } from '../hooks/useFocusZone.js';
|
|
8
8
|
import { useId } from '../hooks/useId.js';
|
|
9
9
|
import Token from '../Token/Token.js';
|
|
@@ -25,7 +25,7 @@ const overflowCountClassMap = {
|
|
|
25
25
|
|
|
26
26
|
// using forwardRef is important so that other components (ex. Autocomplete) can use the ref
|
|
27
27
|
function TextInputWithTokensInnerComponent(t0, forwardedRef) {
|
|
28
|
-
const $ = c(
|
|
28
|
+
const $ = c(151);
|
|
29
29
|
let IconComponent;
|
|
30
30
|
let LeadingVisual;
|
|
31
31
|
let TrailingVisual;
|
|
@@ -165,7 +165,7 @@ function TextInputWithTokensInnerComponent(t0, forwardedRef) {
|
|
|
165
165
|
}
|
|
166
166
|
const ref = useRef(null);
|
|
167
167
|
const selectedValuesDescriptionId = useId();
|
|
168
|
-
|
|
168
|
+
useRefObjectAsForwardedRef(forwardedRef, ref);
|
|
169
169
|
const [selectedTokenIndex, setSelectedTokenIndex] = useState();
|
|
170
170
|
const [tokensAreTruncated, setTokensAreTruncated] = useState(Boolean(visibleTokenCount));
|
|
171
171
|
let t6;
|
|
@@ -455,9 +455,9 @@ function TextInputWithTokensInnerComponent(t0, forwardedRef) {
|
|
|
455
455
|
const t32 = validationStatus === "error" ? "true" : "false";
|
|
456
456
|
const t33 = ariaDescribedBy || undefined;
|
|
457
457
|
let t34;
|
|
458
|
-
if ($[80] !== disabled || $[81] !== handleInputBlur || $[82] !== handleInputFocus || $[83] !== handleInputKeyDown || $[84] !== inputPropsRest || $[85] !==
|
|
458
|
+
if ($[80] !== disabled || $[81] !== handleInputBlur || $[82] !== handleInputFocus || $[83] !== handleInputKeyDown || $[84] !== inputPropsRest || $[85] !== role || $[86] !== t32 || $[87] !== t33) {
|
|
459
459
|
t34 = /*#__PURE__*/jsx(UnstyledTextInput, {
|
|
460
|
-
ref:
|
|
460
|
+
ref: ref,
|
|
461
461
|
disabled: disabled,
|
|
462
462
|
onFocus: handleInputFocus,
|
|
463
463
|
onBlur: handleInputBlur,
|
|
@@ -474,43 +474,42 @@ function TextInputWithTokensInnerComponent(t0, forwardedRef) {
|
|
|
474
474
|
$[82] = handleInputFocus;
|
|
475
475
|
$[83] = handleInputKeyDown;
|
|
476
476
|
$[84] = inputPropsRest;
|
|
477
|
-
$[85] =
|
|
478
|
-
$[86] =
|
|
479
|
-
$[87] =
|
|
480
|
-
$[88] =
|
|
481
|
-
$[89] = t34;
|
|
477
|
+
$[85] = role;
|
|
478
|
+
$[86] = t32;
|
|
479
|
+
$[87] = t33;
|
|
480
|
+
$[88] = t34;
|
|
482
481
|
} else {
|
|
483
|
-
t34 = $[
|
|
482
|
+
t34 = $[88];
|
|
484
483
|
}
|
|
485
484
|
let t35;
|
|
486
|
-
if ($[
|
|
485
|
+
if ($[89] !== selectedValuesDescription || $[90] !== selectedValuesDescriptionId || $[91] !== shouldExposeSelectedValuesDescription) {
|
|
487
486
|
t35 = shouldExposeSelectedValuesDescription ? /*#__PURE__*/jsx(VisuallyHidden, {
|
|
488
487
|
id: selectedValuesDescriptionId,
|
|
489
488
|
children: selectedValuesDescription
|
|
490
489
|
}) : null;
|
|
491
|
-
$[
|
|
492
|
-
$[
|
|
493
|
-
$[
|
|
494
|
-
$[
|
|
490
|
+
$[89] = selectedValuesDescription;
|
|
491
|
+
$[90] = selectedValuesDescriptionId;
|
|
492
|
+
$[91] = shouldExposeSelectedValuesDescription;
|
|
493
|
+
$[92] = t35;
|
|
495
494
|
} else {
|
|
496
|
-
t35 = $[
|
|
495
|
+
t35 = $[92];
|
|
497
496
|
}
|
|
498
497
|
let t36;
|
|
499
|
-
if ($[
|
|
498
|
+
if ($[93] !== t34 || $[94] !== t35) {
|
|
500
499
|
t36 = /*#__PURE__*/jsxs("div", {
|
|
501
500
|
className: styles.InputWrapper,
|
|
502
501
|
children: [t34, t35]
|
|
503
502
|
});
|
|
504
|
-
$[
|
|
505
|
-
$[
|
|
506
|
-
$[
|
|
503
|
+
$[93] = t34;
|
|
504
|
+
$[94] = t35;
|
|
505
|
+
$[95] = t36;
|
|
507
506
|
} else {
|
|
508
|
-
t36 = $[
|
|
507
|
+
t36 = $[95];
|
|
509
508
|
}
|
|
510
509
|
let t37;
|
|
511
|
-
if ($[
|
|
510
|
+
if ($[96] !== TokenComponent || $[97] !== disabled || $[98] !== handleTokenBlur || $[99] !== handleTokenFocus || $[100] !== handleTokenRemove || $[101] !== hideTokenRemoveButtons || $[102] !== selectedTokenIndex || $[103] !== size || $[104] !== visibleTokens) {
|
|
512
511
|
let t38;
|
|
513
|
-
if ($[
|
|
512
|
+
if ($[106] !== TokenComponent || $[107] !== disabled || $[108] !== handleTokenBlur || $[109] !== handleTokenFocus || $[110] !== handleTokenRemove || $[111] !== hideTokenRemoveButtons || $[112] !== selectedTokenIndex || $[113] !== size) {
|
|
514
513
|
t38 = (t39, i) => {
|
|
515
514
|
const {
|
|
516
515
|
id,
|
|
@@ -532,89 +531,89 @@ function TextInputWithTokensInnerComponent(t0, forwardedRef) {
|
|
|
532
531
|
...tokenRest
|
|
533
532
|
}, id);
|
|
534
533
|
};
|
|
535
|
-
$[
|
|
536
|
-
$[
|
|
537
|
-
$[
|
|
538
|
-
$[
|
|
539
|
-
$[
|
|
540
|
-
$[
|
|
541
|
-
$[
|
|
542
|
-
$[
|
|
543
|
-
$[
|
|
534
|
+
$[106] = TokenComponent;
|
|
535
|
+
$[107] = disabled;
|
|
536
|
+
$[108] = handleTokenBlur;
|
|
537
|
+
$[109] = handleTokenFocus;
|
|
538
|
+
$[110] = handleTokenRemove;
|
|
539
|
+
$[111] = hideTokenRemoveButtons;
|
|
540
|
+
$[112] = selectedTokenIndex;
|
|
541
|
+
$[113] = size;
|
|
542
|
+
$[114] = t38;
|
|
544
543
|
} else {
|
|
545
|
-
t38 = $[
|
|
544
|
+
t38 = $[114];
|
|
546
545
|
}
|
|
547
546
|
t37 = visibleTokens.map(t38);
|
|
548
|
-
$[
|
|
549
|
-
$[
|
|
550
|
-
$[
|
|
551
|
-
$[
|
|
552
|
-
$[
|
|
553
|
-
$[
|
|
554
|
-
$[
|
|
555
|
-
$[
|
|
556
|
-
$[
|
|
557
|
-
$[
|
|
547
|
+
$[96] = TokenComponent;
|
|
548
|
+
$[97] = disabled;
|
|
549
|
+
$[98] = handleTokenBlur;
|
|
550
|
+
$[99] = handleTokenFocus;
|
|
551
|
+
$[100] = handleTokenRemove;
|
|
552
|
+
$[101] = hideTokenRemoveButtons;
|
|
553
|
+
$[102] = selectedTokenIndex;
|
|
554
|
+
$[103] = size;
|
|
555
|
+
$[104] = visibleTokens;
|
|
556
|
+
$[105] = t37;
|
|
558
557
|
} else {
|
|
559
|
-
t37 = $[
|
|
558
|
+
t37 = $[105];
|
|
560
559
|
}
|
|
561
560
|
let t38;
|
|
562
|
-
if ($[
|
|
561
|
+
if ($[115] !== size || $[116] !== tokens.length || $[117] !== tokensAreTruncated || $[118] !== visibleTokens.length) {
|
|
563
562
|
t38 = tokensAreTruncated && tokens.length - visibleTokens.length ? /*#__PURE__*/jsxs(Text, {
|
|
564
563
|
className: overflowCountClassMap[size],
|
|
565
564
|
children: ["+", tokens.length - visibleTokens.length]
|
|
566
565
|
}) : null;
|
|
567
|
-
$[
|
|
568
|
-
$[
|
|
569
|
-
$[
|
|
570
|
-
$[
|
|
571
|
-
$[
|
|
566
|
+
$[115] = size;
|
|
567
|
+
$[116] = tokens.length;
|
|
568
|
+
$[117] = tokensAreTruncated;
|
|
569
|
+
$[118] = visibleTokens.length;
|
|
570
|
+
$[119] = t38;
|
|
572
571
|
} else {
|
|
573
|
-
t38 = $[
|
|
572
|
+
t38 = $[119];
|
|
574
573
|
}
|
|
575
574
|
let t39;
|
|
576
|
-
if ($[
|
|
575
|
+
if ($[120] !== preventTokenWrapping || $[121] !== t31 || $[122] !== t36 || $[123] !== t37 || $[124] !== t38) {
|
|
577
576
|
t39 = /*#__PURE__*/jsxs("div", {
|
|
578
577
|
ref: t31,
|
|
579
578
|
className: styles.Container,
|
|
580
579
|
"data-prevent-token-wrapping": preventTokenWrapping,
|
|
581
580
|
children: [t36, t37, t38]
|
|
582
581
|
});
|
|
583
|
-
$[
|
|
584
|
-
$[
|
|
585
|
-
$[
|
|
586
|
-
$[
|
|
587
|
-
$[
|
|
588
|
-
$[
|
|
582
|
+
$[120] = preventTokenWrapping;
|
|
583
|
+
$[121] = t31;
|
|
584
|
+
$[122] = t36;
|
|
585
|
+
$[123] = t37;
|
|
586
|
+
$[124] = t38;
|
|
587
|
+
$[125] = t39;
|
|
589
588
|
} else {
|
|
590
|
-
t39 = $[
|
|
589
|
+
t39 = $[125];
|
|
591
590
|
}
|
|
592
591
|
const t40 = typeof loading === "boolean";
|
|
593
592
|
let t41;
|
|
594
|
-
if ($[
|
|
593
|
+
if ($[126] !== TrailingVisual) {
|
|
595
594
|
t41 = typeof TrailingVisual !== "string" && isValidElementType(TrailingVisual) ? /*#__PURE__*/jsx(TrailingVisual, {}) : TrailingVisual;
|
|
596
|
-
$[
|
|
597
|
-
$[
|
|
595
|
+
$[126] = TrailingVisual;
|
|
596
|
+
$[127] = t41;
|
|
598
597
|
} else {
|
|
599
|
-
t41 = $[
|
|
598
|
+
t41 = $[127];
|
|
600
599
|
}
|
|
601
600
|
let t42;
|
|
602
|
-
if ($[
|
|
601
|
+
if ($[128] !== showTrailingLoadingIndicator || $[129] !== t40 || $[130] !== t41) {
|
|
603
602
|
t42 = /*#__PURE__*/jsx(TextInputInnerVisualSlot, {
|
|
604
603
|
hasLoadingIndicator: t40,
|
|
605
604
|
visualPosition: "trailing",
|
|
606
605
|
showLoadingIndicator: showTrailingLoadingIndicator,
|
|
607
606
|
children: t41
|
|
608
607
|
});
|
|
609
|
-
$[
|
|
610
|
-
$[
|
|
611
|
-
$[
|
|
612
|
-
$[
|
|
608
|
+
$[128] = showTrailingLoadingIndicator;
|
|
609
|
+
$[129] = t40;
|
|
610
|
+
$[130] = t41;
|
|
611
|
+
$[131] = t42;
|
|
613
612
|
} else {
|
|
614
|
-
t42 = $[
|
|
613
|
+
t42 = $[131];
|
|
615
614
|
}
|
|
616
615
|
let t43;
|
|
617
|
-
if ($[
|
|
616
|
+
if ($[132] !== block || $[133] !== contrast || $[134] !== disabled || $[135] !== maxWidthProp || $[136] !== minWidthProp || $[137] !== t21 || $[138] !== t22 || $[139] !== t23 || $[140] !== t24 || $[141] !== t25 || $[142] !== t26 || $[143] !== t27 || $[144] !== t30 || $[145] !== t39 || $[146] !== t42 || $[147] !== validationStatus || $[148] !== variantProp || $[149] !== widthProp) {
|
|
618
617
|
t43 = /*#__PURE__*/jsxs(TextInputWrapper, {
|
|
619
618
|
block: block,
|
|
620
619
|
contrast: contrast,
|
|
@@ -633,27 +632,27 @@ function TextInputWithTokensInnerComponent(t0, forwardedRef) {
|
|
|
633
632
|
style: t26,
|
|
634
633
|
children: [t27, t30, t39, t42]
|
|
635
634
|
});
|
|
636
|
-
$[
|
|
637
|
-
$[
|
|
638
|
-
$[
|
|
639
|
-
$[
|
|
640
|
-
$[
|
|
641
|
-
$[
|
|
642
|
-
$[
|
|
643
|
-
$[
|
|
644
|
-
$[
|
|
645
|
-
$[
|
|
646
|
-
$[
|
|
647
|
-
$[
|
|
648
|
-
$[
|
|
649
|
-
$[
|
|
650
|
-
$[
|
|
651
|
-
$[
|
|
652
|
-
$[
|
|
653
|
-
$[
|
|
654
|
-
$[
|
|
635
|
+
$[132] = block;
|
|
636
|
+
$[133] = contrast;
|
|
637
|
+
$[134] = disabled;
|
|
638
|
+
$[135] = maxWidthProp;
|
|
639
|
+
$[136] = minWidthProp;
|
|
640
|
+
$[137] = t21;
|
|
641
|
+
$[138] = t22;
|
|
642
|
+
$[139] = t23;
|
|
643
|
+
$[140] = t24;
|
|
644
|
+
$[141] = t25;
|
|
645
|
+
$[142] = t26;
|
|
646
|
+
$[143] = t27;
|
|
647
|
+
$[144] = t30;
|
|
648
|
+
$[145] = t39;
|
|
649
|
+
$[146] = t42;
|
|
650
|
+
$[147] = validationStatus;
|
|
651
|
+
$[148] = variantProp;
|
|
652
|
+
$[149] = widthProp;
|
|
653
|
+
$[150] = t43;
|
|
655
654
|
} else {
|
|
656
|
-
t43 = $[
|
|
655
|
+
t43 = $[150];
|
|
657
656
|
}
|
|
658
657
|
return t43;
|
|
659
658
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,eAAO,MAAM,gBAAgB,QAAQ,CAAA;AAKrC,MAAM,MAAM,KAAK,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,CAAA;AACxC,KAAK,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAA;AACnD,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,MAAM,CAAA;AAElD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,CAAC,EAAE,iBAAiB,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AA8BD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAsF/E,CAAA;AAED,wBAAgB,QAAQ;YAnHd,KAAK;kBACC,MAAM;gBACR,iBAAiB;wBACT,SAAS;0BACP,MAAM;gBAChB,MAAM;kBACJ,MAAM;kBACN,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;kBACvD,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;oBAC1C,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;EA4G7D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,UAG1F;AAqGD,eAAe,aAAa,CAAA"}
|
package/dist/ThemeProvider.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { c } from 'react-compiler-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
3
4
|
import theme from './theme.js';
|
|
4
5
|
import deepmerge from 'deepmerge';
|
|
5
6
|
import { useSyncedState } from './hooks/useSyncedState.js';
|
|
@@ -19,115 +20,71 @@ const ThemeContext = /*#__PURE__*/React.createContext({
|
|
|
19
20
|
});
|
|
20
21
|
|
|
21
22
|
// inspired from __NEXT_DATA__, we use application/json to avoid CSRF policy with inline scripts
|
|
22
|
-
const serverHandoffCache = new Map();
|
|
23
|
-
const emptyHandoff = {};
|
|
24
23
|
const getServerHandoff = id => {
|
|
25
|
-
if (typeof document === 'undefined') return emptyHandoff;
|
|
26
|
-
const cached = serverHandoffCache.get(id);
|
|
27
|
-
if (cached !== undefined) return cached;
|
|
28
24
|
try {
|
|
29
25
|
var _document$getElementB;
|
|
30
26
|
const serverData = (_document$getElementB = document.getElementById(`__PRIMER_DATA_${id}__`)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.textContent;
|
|
31
|
-
if (serverData)
|
|
32
|
-
const parsed = JSON.parse(serverData);
|
|
33
|
-
serverHandoffCache.set(id, parsed);
|
|
34
|
-
return parsed;
|
|
35
|
-
}
|
|
27
|
+
if (serverData) return JSON.parse(serverData);
|
|
36
28
|
} catch (_error) {
|
|
37
29
|
// if document/element does not exist or JSON is invalid, suppress error
|
|
38
30
|
}
|
|
39
|
-
|
|
40
|
-
serverHandoffCache.set(id, empty);
|
|
41
|
-
return empty;
|
|
31
|
+
return {};
|
|
42
32
|
};
|
|
43
|
-
const
|
|
44
|
-
|
|
33
|
+
const ThemeProvider = ({
|
|
34
|
+
children,
|
|
35
|
+
...props
|
|
36
|
+
}) => {
|
|
45
37
|
var _ref, _props$colorMode, _ref2, _props$dayScheme, _ref3, _props$nightScheme;
|
|
46
|
-
|
|
47
|
-
let children;
|
|
48
|
-
let props;
|
|
49
|
-
if ($[0] !== t0) {
|
|
50
|
-
({
|
|
51
|
-
children,
|
|
52
|
-
...props
|
|
53
|
-
} = t0);
|
|
54
|
-
$[0] = t0;
|
|
55
|
-
$[1] = children;
|
|
56
|
-
$[2] = props;
|
|
57
|
-
} else {
|
|
58
|
-
children = $[1];
|
|
59
|
-
props = $[2];
|
|
60
|
-
}
|
|
38
|
+
// Get fallback values from parent ThemeProvider (if exists)
|
|
61
39
|
const {
|
|
62
40
|
theme: fallbackTheme,
|
|
63
41
|
colorMode: fallbackColorMode,
|
|
64
42
|
dayScheme: fallbackDayScheme,
|
|
65
43
|
nightScheme: fallbackNightScheme
|
|
66
44
|
} = useTheme();
|
|
45
|
+
|
|
46
|
+
// Initialize state
|
|
67
47
|
const theme$1 = fallbackTheme !== null && fallbackTheme !== void 0 ? fallbackTheme : theme;
|
|
68
48
|
const uniqueDataId = useId();
|
|
49
|
+
const {
|
|
50
|
+
resolvedServerColorMode
|
|
51
|
+
} = getServerHandoff(uniqueDataId);
|
|
52
|
+
const resolvedColorModePassthrough = React.useRef(resolvedServerColorMode);
|
|
69
53
|
const [colorMode, setColorMode] = useSyncedState((_ref = (_props$colorMode = props.colorMode) !== null && _props$colorMode !== void 0 ? _props$colorMode : fallbackColorMode) !== null && _ref !== void 0 ? _ref : defaultColorMode);
|
|
70
54
|
const [dayScheme, setDayScheme] = useSyncedState((_ref2 = (_props$dayScheme = props.dayScheme) !== null && _props$dayScheme !== void 0 ? _props$dayScheme : fallbackDayScheme) !== null && _ref2 !== void 0 ? _ref2 : defaultDayScheme);
|
|
71
55
|
const [nightScheme, setNightScheme] = useSyncedState((_ref3 = (_props$nightScheme = props.nightScheme) !== null && _props$nightScheme !== void 0 ? _props$nightScheme : fallbackNightScheme) !== null && _ref3 !== void 0 ? _ref3 : defaultNightScheme);
|
|
72
56
|
const systemColorMode = useSystemColorMode();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
$[3] = colorMode;
|
|
77
|
-
$[4] = systemColorMode;
|
|
78
|
-
$[5] = t1;
|
|
79
|
-
} else {
|
|
80
|
-
t1 = $[5];
|
|
81
|
-
}
|
|
82
|
-
const clientColorMode = t1;
|
|
83
|
-
let t2;
|
|
84
|
-
if ($[6] !== clientColorMode) {
|
|
85
|
-
t2 = () => clientColorMode;
|
|
86
|
-
$[6] = clientColorMode;
|
|
87
|
-
$[7] = t2;
|
|
88
|
-
} else {
|
|
89
|
-
t2 = $[7];
|
|
90
|
-
}
|
|
91
|
-
let t3;
|
|
92
|
-
if ($[8] !== clientColorMode || $[9] !== uniqueDataId) {
|
|
93
|
-
t3 = () => {
|
|
94
|
-
var _getServerHandoff$res;
|
|
95
|
-
return (_getServerHandoff$res = getServerHandoff(uniqueDataId).resolvedServerColorMode) !== null && _getServerHandoff$res !== void 0 ? _getServerHandoff$res : clientColorMode;
|
|
96
|
-
};
|
|
97
|
-
$[8] = clientColorMode;
|
|
98
|
-
$[9] = uniqueDataId;
|
|
99
|
-
$[10] = t3;
|
|
100
|
-
} else {
|
|
101
|
-
t3 = $[10];
|
|
102
|
-
}
|
|
103
|
-
const resolvedColorMode = React.useSyncExternalStore(emptySubscribe, t2, t3);
|
|
104
|
-
let t4;
|
|
105
|
-
if ($[11] !== dayScheme || $[12] !== nightScheme || $[13] !== resolvedColorMode) {
|
|
106
|
-
t4 = chooseColorScheme(resolvedColorMode, dayScheme, nightScheme);
|
|
107
|
-
$[11] = dayScheme;
|
|
108
|
-
$[12] = nightScheme;
|
|
109
|
-
$[13] = resolvedColorMode;
|
|
110
|
-
$[14] = t4;
|
|
111
|
-
} else {
|
|
112
|
-
t4 = $[14];
|
|
113
|
-
}
|
|
114
|
-
const colorScheme = t4;
|
|
115
|
-
let t5;
|
|
116
|
-
if ($[15] !== colorScheme || $[16] !== theme$1) {
|
|
117
|
-
t5 = applyColorScheme(theme$1, colorScheme);
|
|
118
|
-
$[15] = colorScheme;
|
|
119
|
-
$[16] = theme$1;
|
|
120
|
-
$[17] = t5;
|
|
121
|
-
} else {
|
|
122
|
-
t5 = $[17];
|
|
123
|
-
}
|
|
57
|
+
// eslint-disable-next-line react-hooks/refs
|
|
58
|
+
const resolvedColorMode = resolvedColorModePassthrough.current || resolveColorMode(colorMode, systemColorMode);
|
|
59
|
+
const colorScheme = chooseColorScheme(resolvedColorMode, dayScheme, nightScheme);
|
|
124
60
|
const {
|
|
125
61
|
resolvedTheme,
|
|
126
62
|
resolvedColorScheme
|
|
127
|
-
} =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
63
|
+
} = React.useMemo(() => applyColorScheme(theme$1, colorScheme), [theme$1, colorScheme]);
|
|
64
|
+
|
|
65
|
+
// this effect will only run on client
|
|
66
|
+
React.useEffect(function updateColorModeAfterServerPassthrough() {
|
|
67
|
+
const resolvedColorModeOnClient = resolveColorMode(colorMode, systemColorMode);
|
|
68
|
+
if (resolvedColorModePassthrough.current) {
|
|
69
|
+
// if the resolved color mode passed on from the server is not the resolved color mode on client, change it!
|
|
70
|
+
if (resolvedColorModePassthrough.current !== resolvedColorModeOnClient) {
|
|
71
|
+
window.setTimeout(() => {
|
|
72
|
+
// use ReactDOM.flushSync to prevent automatic batching of state updates since React 18
|
|
73
|
+
// ref: https://github.com/reactwg/react-18/discussions/21
|
|
74
|
+
ReactDOM.flushSync(() => {
|
|
75
|
+
// override colorMode to whatever is resolved on the client to get a re-render
|
|
76
|
+
setColorMode(resolvedColorModeOnClient);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// immediately after that, set the colorMode to what the user passed to respond to system color mode changes
|
|
80
|
+
setColorMode(colorMode);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
resolvedColorModePassthrough.current = null;
|
|
84
|
+
}
|
|
85
|
+
}, [colorMode, systemColorMode, setColorMode]);
|
|
86
|
+
return /*#__PURE__*/jsx(ThemeContext.Provider, {
|
|
87
|
+
value: {
|
|
131
88
|
theme: resolvedTheme,
|
|
132
89
|
colorScheme,
|
|
133
90
|
colorMode,
|
|
@@ -138,72 +95,24 @@ const ThemeProvider = t0 => {
|
|
|
138
95
|
setColorMode,
|
|
139
96
|
setDayScheme,
|
|
140
97
|
setNightScheme
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
$[20] = dayScheme;
|
|
145
|
-
$[21] = nightScheme;
|
|
146
|
-
$[22] = resolvedColorMode;
|
|
147
|
-
$[23] = resolvedColorScheme;
|
|
148
|
-
$[24] = resolvedTheme;
|
|
149
|
-
$[25] = setColorMode;
|
|
150
|
-
$[26] = setDayScheme;
|
|
151
|
-
$[27] = setNightScheme;
|
|
152
|
-
$[28] = t6;
|
|
153
|
-
} else {
|
|
154
|
-
t6 = $[28];
|
|
155
|
-
}
|
|
156
|
-
const contextValue = t6;
|
|
157
|
-
const t7 = colorMode === "auto" ? "auto" : colorScheme.includes("dark") ? "dark" : "light";
|
|
158
|
-
let t8;
|
|
159
|
-
if ($[29] !== props.preventSSRMismatch || $[30] !== resolvedColorMode || $[31] !== uniqueDataId) {
|
|
160
|
-
t8 = props.preventSSRMismatch ? /*#__PURE__*/jsx("script", {
|
|
161
|
-
type: "application/json",
|
|
162
|
-
id: `__PRIMER_DATA_${uniqueDataId}__`,
|
|
163
|
-
dangerouslySetInnerHTML: {
|
|
164
|
-
__html: JSON.stringify({
|
|
165
|
-
resolvedServerColorMode: resolvedColorMode
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
}) : null;
|
|
169
|
-
$[29] = props.preventSSRMismatch;
|
|
170
|
-
$[30] = resolvedColorMode;
|
|
171
|
-
$[31] = uniqueDataId;
|
|
172
|
-
$[32] = t8;
|
|
173
|
-
} else {
|
|
174
|
-
t8 = $[32];
|
|
175
|
-
}
|
|
176
|
-
let t9;
|
|
177
|
-
if ($[33] !== children || $[34] !== dayScheme || $[35] !== nightScheme || $[36] !== t7 || $[37] !== t8) {
|
|
178
|
-
t9 = /*#__PURE__*/jsxs("div", {
|
|
179
|
-
"data-color-mode": t7,
|
|
98
|
+
},
|
|
99
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
100
|
+
"data-color-mode": colorMode === 'auto' ? 'auto' : colorScheme.includes('dark') ? 'dark' : 'light',
|
|
180
101
|
"data-light-theme": dayScheme,
|
|
181
102
|
"data-dark-theme": nightScheme,
|
|
182
|
-
children: [children,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
let t10;
|
|
194
|
-
if ($[39] !== contextValue || $[40] !== t9) {
|
|
195
|
-
t10 = /*#__PURE__*/jsx(ThemeContext.Provider, {
|
|
196
|
-
value: contextValue,
|
|
197
|
-
children: t9
|
|
198
|
-
});
|
|
199
|
-
$[39] = contextValue;
|
|
200
|
-
$[40] = t9;
|
|
201
|
-
$[41] = t10;
|
|
202
|
-
} else {
|
|
203
|
-
t10 = $[41];
|
|
204
|
-
}
|
|
205
|
-
return t10;
|
|
103
|
+
children: [children, props.preventSSRMismatch ? /*#__PURE__*/jsx("script", {
|
|
104
|
+
type: "application/json",
|
|
105
|
+
id: `__PRIMER_DATA_${uniqueDataId}__`,
|
|
106
|
+
dangerouslySetInnerHTML: {
|
|
107
|
+
__html: JSON.stringify({
|
|
108
|
+
resolvedServerColorMode: resolvedColorMode
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
}) : null]
|
|
112
|
+
})
|
|
113
|
+
});
|
|
206
114
|
};
|
|
115
|
+
ThemeProvider.displayName = "ThemeProvider";
|
|
207
116
|
function useTheme() {
|
|
208
117
|
return React.useContext(ThemeContext);
|
|
209
118
|
}
|
|
@@ -215,25 +124,57 @@ function useColorSchemeVar(values, fallback) {
|
|
|
215
124
|
const colorScheme = t0 === undefined ? "" : t0;
|
|
216
125
|
return (_values$colorScheme = values[colorScheme]) !== null && _values$colorScheme !== void 0 ? _values$colorScheme : fallback;
|
|
217
126
|
}
|
|
218
|
-
function subscribeToSystemColorMode(callback) {
|
|
219
|
-
var _window, _window$matchMedia;
|
|
220
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
221
|
-
const media = (_window = window) === null || _window === void 0 ? void 0 : (_window$matchMedia = _window.matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, '(prefers-color-scheme: dark)');
|
|
222
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
223
|
-
media === null || media === void 0 ? void 0 : media.addEventListener('change', callback);
|
|
224
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
225
|
-
return () => media === null || media === void 0 ? void 0 : media.removeEventListener('change', callback);
|
|
226
|
-
}
|
|
227
127
|
function useSystemColorMode() {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
128
|
+
const $ = c(2);
|
|
129
|
+
const [systemColorMode, setSystemColorMode] = React.useState(getSystemColorMode);
|
|
130
|
+
let t0;
|
|
131
|
+
let t1;
|
|
132
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
133
|
+
t0 = () => {
|
|
134
|
+
var _window, _window$matchMedia;
|
|
135
|
+
const media = (_window = window) === null || _window === void 0 ? void 0 : (_window$matchMedia = _window.matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, "(prefers-color-scheme: dark)");
|
|
136
|
+
const matchesMediaToColorMode = function matchesMediaToColorMode(matches) {
|
|
137
|
+
return matches ? "night" : "day";
|
|
138
|
+
};
|
|
139
|
+
const handleChange = function handleChange(event) {
|
|
140
|
+
const isNight = event.matches;
|
|
141
|
+
setSystemColorMode(matchesMediaToColorMode(isNight));
|
|
142
|
+
};
|
|
143
|
+
if (media) {
|
|
144
|
+
const isNight_0 = media.matches;
|
|
145
|
+
setSystemColorMode(matchesMediaToColorMode(isNight_0));
|
|
146
|
+
if (media.addEventListener !== undefined) {
|
|
147
|
+
media.addEventListener("change", handleChange);
|
|
148
|
+
return function cleanup() {
|
|
149
|
+
media.removeEventListener("change", handleChange);
|
|
150
|
+
};
|
|
151
|
+
} else {
|
|
152
|
+
if (media.addListener !== undefined) {
|
|
153
|
+
media.addListener(handleChange);
|
|
154
|
+
return function cleanup() {
|
|
155
|
+
media.removeListener(handleChange);
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
t1 = [];
|
|
162
|
+
$[0] = t0;
|
|
163
|
+
$[1] = t1;
|
|
164
|
+
} else {
|
|
165
|
+
t0 = $[0];
|
|
166
|
+
t1 = $[1];
|
|
167
|
+
}
|
|
168
|
+
React.useEffect(t0, t1);
|
|
169
|
+
return systemColorMode;
|
|
232
170
|
}
|
|
233
171
|
function getSystemColorMode() {
|
|
234
|
-
var
|
|
172
|
+
var _window$matchMedia2, _window2, _window$matchMedia2$c;
|
|
235
173
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
236
|
-
|
|
174
|
+
if (typeof window !== 'undefined' && (_window$matchMedia2 = (_window2 = window).matchMedia) !== null && _window$matchMedia2 !== void 0 && (_window$matchMedia2$c = _window$matchMedia2.call(_window2, '(prefers-color-scheme: dark)')) !== null && _window$matchMedia2$c !== void 0 && _window$matchMedia2$c.matches) {
|
|
175
|
+
return 'night';
|
|
176
|
+
}
|
|
177
|
+
return 'day';
|
|
237
178
|
}
|
|
238
179
|
function resolveColorMode(colorMode, systemColorMode) {
|
|
239
180
|
switch (colorMode) {
|