@primer/react 0.0.0-20260325190039 → 0.0.0-20260325212744
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 +11 -10
- package/dist/SelectPanel/SelectPanel.d.ts +2 -2
- package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
- package/dist/SelectPanel/SelectPanel.js +2 -0
- package/dist/ThemeProvider.d.ts.map +1 -1
- package/dist/ThemeProvider.js +104 -161
- package/generated/components.json +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20260325212744
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#7703](https://github.com/primer/react/pull/7703) [`42712b0`](https://github.com/primer/react/commit/42712b0d7c5a954ec061068f2fb18d6d3212634a) Thanks [@francinelucca](https://github.com/francinelucca)! - SelectPanel: Add `displayInViewport` prop
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Fake entry to force publishing
|
|
12
|
+
|
|
13
|
+
## 38.17.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
6
16
|
|
|
@@ -15,17 +25,8 @@
|
|
|
15
25
|
|
|
16
26
|
### Patch Changes
|
|
17
27
|
|
|
18
|
-
- Fake entry to force publishing
|
|
19
|
-
|
|
20
28
|
- [#7510](https://github.com/primer/react/pull/7510) [`8fa988b`](https://github.com/primer/react/commit/8fa988ba613117874657af722ef6de768b0e0eb8) Thanks [@francinelucca](https://github.com/francinelucca)! - chore: ensure max-height does not surpass viewport height in Overlay, ActionMenu under feature flag
|
|
21
29
|
|
|
22
|
-
- [#7695](https://github.com/primer/react/pull/7695) [`8cb69d1`](https://github.com/primer/react/commit/8cb69d13c85938f99a6daf52938fb30fc31a8ecb) Thanks [@mattcosta7](https://github.com/mattcosta7)! - perf(ThemeProvider): Reduce unnecessary renders and effect cascades
|
|
23
|
-
|
|
24
|
-
- Replace `useState` + `useEffect` SSR hydration handoff with `useSyncExternalStore` — eliminates post-hydration re-render
|
|
25
|
-
- Replace `useState` + `useEffect` in `useSystemColorMode` with `useSyncExternalStore` — eliminates effect gap and stale-then-update flicker
|
|
26
|
-
- Cache `getServerHandoff` DOM read + JSON.parse per ID (runs once, not on every call)
|
|
27
|
-
- Memoize context value object to prevent unnecessary re-renders of all consumers
|
|
28
|
-
|
|
29
30
|
- [#7682](https://github.com/primer/react/pull/7682) [`8aed331`](https://github.com/primer/react/commit/8aed331f9dcb8c51d86bf531f7e331a6ccd23d9a) Thanks [@llastflowers](https://github.com/llastflowers)! - Update CheckboxOrRadioGroup.tsx to add `required` announcement
|
|
30
31
|
|
|
31
32
|
## 38.16.0
|
|
@@ -63,8 +63,8 @@ type SelectPanelVariantProps = {
|
|
|
63
63
|
variant: 'modal';
|
|
64
64
|
onCancel: () => void;
|
|
65
65
|
};
|
|
66
|
-
export type SelectPanelProps = SelectPanelBaseProps & Omit<FilteredActionListProps, 'selectionVariant' | 'variant' | 'message'> & Pick<AnchoredOverlayProps, 'open' | 'height' | 'width' | 'align'> & AnchoredOverlayWrapperAnchorProps & (SelectPanelSingleSelection | SelectPanelMultiSelection) & SelectPanelVariantProps;
|
|
67
|
-
declare function Panel({ open, onOpenChange, renderAnchor, anchorRef: externalAnchorRef, placeholder, placeholderText, inputLabel, selected, title, subtitle, onSelectedChange, filterValue: externalFilterValue, onFilterChange: externalOnFilterChange, items, footer, textInputProps, overlayProps, loading, initialLoadingType, className, height, width, id, message, notice, onCancel, variant, secondaryAction, showSelectedOptionsFirst, disableFullscreenOnNarrow, align, showSelectAll, focusPrependedElements, virtualized, ...listProps }: SelectPanelProps): JSX.Element;
|
|
66
|
+
export type SelectPanelProps = SelectPanelBaseProps & Omit<FilteredActionListProps, 'selectionVariant' | 'variant' | 'message'> & Pick<AnchoredOverlayProps, 'open' | 'height' | 'width' | 'align' | 'displayInViewport'> & AnchoredOverlayWrapperAnchorProps & (SelectPanelSingleSelection | SelectPanelMultiSelection) & SelectPanelVariantProps;
|
|
67
|
+
declare function Panel({ open, onOpenChange, renderAnchor, anchorRef: externalAnchorRef, placeholder, placeholderText, inputLabel, selected, title, subtitle, onSelectedChange, filterValue: externalFilterValue, onFilterChange: externalOnFilterChange, items, footer, textInputProps, overlayProps, loading, initialLoadingType, className, height, width, id, message, notice, onCancel, variant, secondaryAction, showSelectedOptionsFirst, disableFullscreenOnNarrow, align, showSelectAll, focusPrependedElements, virtualized, displayInViewport, ...listProps }: SelectPanelProps): JSX.Element;
|
|
68
68
|
declare const SecondaryButton: React.FC<ButtonProps>;
|
|
69
69
|
declare const SecondaryLink: React.FC<LinkButtonProps & ButtonProps>;
|
|
70
70
|
export declare const SelectPanel: typeof Panel & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPanel.d.ts","sourceRoot":"","sources":["../../src/SelectPanel/SelectPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAC1F,OAAO,KAAK,EAAE,EAAoD,KAAK,GAAG,EAAC,MAAM,OAAO,CAAA;AACxF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAC,iCAAiC,EAAC,MAAM,oCAAoC,CAAA;AACzF,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,uBAAuB,CAAA;AAGlE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAY,SAAS,EAAC,MAAM,IAAI,CAAA;AAiB5C,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,iBAAiB,CAAA;AAkCjE,UAAU,0BAA0B;IAClC,QAAQ,EAAE,SAAS,GAAG,SAAS,CAAA;IAC/B,gBA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jC,CAAC,0BAA0B,GAAG,yBAAyB,CAAC,GACxD,uBAAuB,CAAA;AAkCzB,iBAAS,KAAK,CAAC,EACb,IAAI,EACJ,YAAY,EACZ,YAAkC,EAClC,SAAS,EAAE,iBAAiB,EAC5B,WAAW,EACX,eAAgC,EAChC,UAA4B,EAC5B,QAAQ,EACR,KAA0E,EAC1E,QAAQ,EACR,gBAAgB,EAChB,WAAW,EAAE,mBAAmB,EAChC,cAAc,EAAE,sBAAsB,EACtC,KAAK,EACL,MAAM,EACN,cAAc,EACd,YAAY,EACZ,OAAO,EACP,kBAA8B,EAC9B,SAAS,EACT,MAAM,EACN,KAAK,EACL,EAAE,EACF,OAAO,EACP,MAAM,EACN,QAAQ,EACR,OAAoB,EACpB,eAAe,EACf,wBAA+B,EAC/B,yBAAyB,EACzB,KAAK,EACL,aAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,iBAAiB,EACjB,GAAG,SAAS,EACb,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CA4yBhC;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAM1C,CAAA;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,GAAG,WAAW,CAM1D,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;CAItB,CAAA"}
|
|
@@ -113,6 +113,7 @@ function Panel({
|
|
|
113
113
|
showSelectAll = false,
|
|
114
114
|
focusPrependedElements,
|
|
115
115
|
virtualized,
|
|
116
|
+
displayInViewport,
|
|
116
117
|
...listProps
|
|
117
118
|
}) {
|
|
118
119
|
var _listProps$groupMetad;
|
|
@@ -678,6 +679,7 @@ function Panel({
|
|
|
678
679
|
className: classes.Overlay,
|
|
679
680
|
displayCloseButton: showXCloseIcon,
|
|
680
681
|
closeButtonProps: closeButtonProps,
|
|
682
|
+
displayInViewport: displayInViewport,
|
|
681
683
|
children: /*#__PURE__*/jsxs("div", {
|
|
682
684
|
className: classes.Wrapper,
|
|
683
685
|
"data-variant": variant,
|
|
@@ -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,113 +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
23
|
const getServerHandoff = id => {
|
|
24
|
-
const cached = serverHandoffCache.get(id);
|
|
25
|
-
if (cached !== undefined) return cached;
|
|
26
24
|
try {
|
|
27
25
|
var _document$getElementB;
|
|
28
26
|
const serverData = (_document$getElementB = document.getElementById(`__PRIMER_DATA_${id}__`)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.textContent;
|
|
29
|
-
if (serverData)
|
|
30
|
-
const parsed = JSON.parse(serverData);
|
|
31
|
-
serverHandoffCache.set(id, parsed);
|
|
32
|
-
return parsed;
|
|
33
|
-
}
|
|
27
|
+
if (serverData) return JSON.parse(serverData);
|
|
34
28
|
} catch (_error) {
|
|
35
29
|
// if document/element does not exist or JSON is invalid, suppress error
|
|
36
30
|
}
|
|
37
|
-
|
|
38
|
-
serverHandoffCache.set(id, empty);
|
|
39
|
-
return empty;
|
|
31
|
+
return {};
|
|
40
32
|
};
|
|
41
|
-
const
|
|
42
|
-
|
|
33
|
+
const ThemeProvider = ({
|
|
34
|
+
children,
|
|
35
|
+
...props
|
|
36
|
+
}) => {
|
|
43
37
|
var _ref, _props$colorMode, _ref2, _props$dayScheme, _ref3, _props$nightScheme;
|
|
44
|
-
|
|
45
|
-
let children;
|
|
46
|
-
let props;
|
|
47
|
-
if ($[0] !== t0) {
|
|
48
|
-
({
|
|
49
|
-
children,
|
|
50
|
-
...props
|
|
51
|
-
} = t0);
|
|
52
|
-
$[0] = t0;
|
|
53
|
-
$[1] = children;
|
|
54
|
-
$[2] = props;
|
|
55
|
-
} else {
|
|
56
|
-
children = $[1];
|
|
57
|
-
props = $[2];
|
|
58
|
-
}
|
|
38
|
+
// Get fallback values from parent ThemeProvider (if exists)
|
|
59
39
|
const {
|
|
60
40
|
theme: fallbackTheme,
|
|
61
41
|
colorMode: fallbackColorMode,
|
|
62
42
|
dayScheme: fallbackDayScheme,
|
|
63
43
|
nightScheme: fallbackNightScheme
|
|
64
44
|
} = useTheme();
|
|
45
|
+
|
|
46
|
+
// Initialize state
|
|
65
47
|
const theme$1 = fallbackTheme !== null && fallbackTheme !== void 0 ? fallbackTheme : theme;
|
|
66
48
|
const uniqueDataId = useId();
|
|
49
|
+
const {
|
|
50
|
+
resolvedServerColorMode
|
|
51
|
+
} = getServerHandoff(uniqueDataId);
|
|
52
|
+
const resolvedColorModePassthrough = React.useRef(resolvedServerColorMode);
|
|
67
53
|
const [colorMode, setColorMode] = useSyncedState((_ref = (_props$colorMode = props.colorMode) !== null && _props$colorMode !== void 0 ? _props$colorMode : fallbackColorMode) !== null && _ref !== void 0 ? _ref : defaultColorMode);
|
|
68
54
|
const [dayScheme, setDayScheme] = useSyncedState((_ref2 = (_props$dayScheme = props.dayScheme) !== null && _props$dayScheme !== void 0 ? _props$dayScheme : fallbackDayScheme) !== null && _ref2 !== void 0 ? _ref2 : defaultDayScheme);
|
|
69
55
|
const [nightScheme, setNightScheme] = useSyncedState((_ref3 = (_props$nightScheme = props.nightScheme) !== null && _props$nightScheme !== void 0 ? _props$nightScheme : fallbackNightScheme) !== null && _ref3 !== void 0 ? _ref3 : defaultNightScheme);
|
|
70
56
|
const systemColorMode = useSystemColorMode();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
$[3] = colorMode;
|
|
75
|
-
$[4] = systemColorMode;
|
|
76
|
-
$[5] = t1;
|
|
77
|
-
} else {
|
|
78
|
-
t1 = $[5];
|
|
79
|
-
}
|
|
80
|
-
const clientColorMode = t1;
|
|
81
|
-
let t2;
|
|
82
|
-
if ($[6] !== clientColorMode) {
|
|
83
|
-
t2 = () => clientColorMode;
|
|
84
|
-
$[6] = clientColorMode;
|
|
85
|
-
$[7] = t2;
|
|
86
|
-
} else {
|
|
87
|
-
t2 = $[7];
|
|
88
|
-
}
|
|
89
|
-
let t3;
|
|
90
|
-
if ($[8] !== clientColorMode || $[9] !== uniqueDataId) {
|
|
91
|
-
t3 = () => {
|
|
92
|
-
var _getServerHandoff$res;
|
|
93
|
-
return (_getServerHandoff$res = getServerHandoff(uniqueDataId).resolvedServerColorMode) !== null && _getServerHandoff$res !== void 0 ? _getServerHandoff$res : clientColorMode;
|
|
94
|
-
};
|
|
95
|
-
$[8] = clientColorMode;
|
|
96
|
-
$[9] = uniqueDataId;
|
|
97
|
-
$[10] = t3;
|
|
98
|
-
} else {
|
|
99
|
-
t3 = $[10];
|
|
100
|
-
}
|
|
101
|
-
const resolvedColorMode = React.useSyncExternalStore(emptySubscribe, t2, t3);
|
|
102
|
-
let t4;
|
|
103
|
-
if ($[11] !== dayScheme || $[12] !== nightScheme || $[13] !== resolvedColorMode) {
|
|
104
|
-
t4 = chooseColorScheme(resolvedColorMode, dayScheme, nightScheme);
|
|
105
|
-
$[11] = dayScheme;
|
|
106
|
-
$[12] = nightScheme;
|
|
107
|
-
$[13] = resolvedColorMode;
|
|
108
|
-
$[14] = t4;
|
|
109
|
-
} else {
|
|
110
|
-
t4 = $[14];
|
|
111
|
-
}
|
|
112
|
-
const colorScheme = t4;
|
|
113
|
-
let t5;
|
|
114
|
-
if ($[15] !== colorScheme || $[16] !== theme$1) {
|
|
115
|
-
t5 = applyColorScheme(theme$1, colorScheme);
|
|
116
|
-
$[15] = colorScheme;
|
|
117
|
-
$[16] = theme$1;
|
|
118
|
-
$[17] = t5;
|
|
119
|
-
} else {
|
|
120
|
-
t5 = $[17];
|
|
121
|
-
}
|
|
57
|
+
// eslint-disable-next-line react-hooks/refs
|
|
58
|
+
const resolvedColorMode = resolvedColorModePassthrough.current || resolveColorMode(colorMode, systemColorMode);
|
|
59
|
+
const colorScheme = chooseColorScheme(resolvedColorMode, dayScheme, nightScheme);
|
|
122
60
|
const {
|
|
123
61
|
resolvedTheme,
|
|
124
62
|
resolvedColorScheme
|
|
125
|
-
} =
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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: {
|
|
129
88
|
theme: resolvedTheme,
|
|
130
89
|
colorScheme,
|
|
131
90
|
colorMode,
|
|
@@ -136,72 +95,24 @@ const ThemeProvider = t0 => {
|
|
|
136
95
|
setColorMode,
|
|
137
96
|
setDayScheme,
|
|
138
97
|
setNightScheme
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
$[20] = dayScheme;
|
|
143
|
-
$[21] = nightScheme;
|
|
144
|
-
$[22] = resolvedColorMode;
|
|
145
|
-
$[23] = resolvedColorScheme;
|
|
146
|
-
$[24] = resolvedTheme;
|
|
147
|
-
$[25] = setColorMode;
|
|
148
|
-
$[26] = setDayScheme;
|
|
149
|
-
$[27] = setNightScheme;
|
|
150
|
-
$[28] = t6;
|
|
151
|
-
} else {
|
|
152
|
-
t6 = $[28];
|
|
153
|
-
}
|
|
154
|
-
const contextValue = t6;
|
|
155
|
-
const t7 = colorMode === "auto" ? "auto" : colorScheme.includes("dark") ? "dark" : "light";
|
|
156
|
-
let t8;
|
|
157
|
-
if ($[29] !== props.preventSSRMismatch || $[30] !== resolvedColorMode || $[31] !== uniqueDataId) {
|
|
158
|
-
t8 = props.preventSSRMismatch ? /*#__PURE__*/jsx("script", {
|
|
159
|
-
type: "application/json",
|
|
160
|
-
id: `__PRIMER_DATA_${uniqueDataId}__`,
|
|
161
|
-
dangerouslySetInnerHTML: {
|
|
162
|
-
__html: JSON.stringify({
|
|
163
|
-
resolvedServerColorMode: resolvedColorMode
|
|
164
|
-
})
|
|
165
|
-
}
|
|
166
|
-
}) : null;
|
|
167
|
-
$[29] = props.preventSSRMismatch;
|
|
168
|
-
$[30] = resolvedColorMode;
|
|
169
|
-
$[31] = uniqueDataId;
|
|
170
|
-
$[32] = t8;
|
|
171
|
-
} else {
|
|
172
|
-
t8 = $[32];
|
|
173
|
-
}
|
|
174
|
-
let t9;
|
|
175
|
-
if ($[33] !== children || $[34] !== dayScheme || $[35] !== nightScheme || $[36] !== t7 || $[37] !== t8) {
|
|
176
|
-
t9 = /*#__PURE__*/jsxs("div", {
|
|
177
|
-
"data-color-mode": t7,
|
|
98
|
+
},
|
|
99
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
100
|
+
"data-color-mode": colorMode === 'auto' ? 'auto' : colorScheme.includes('dark') ? 'dark' : 'light',
|
|
178
101
|
"data-light-theme": dayScheme,
|
|
179
102
|
"data-dark-theme": nightScheme,
|
|
180
|
-
children: [children,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
let t10;
|
|
192
|
-
if ($[39] !== contextValue || $[40] !== t9) {
|
|
193
|
-
t10 = /*#__PURE__*/jsx(ThemeContext.Provider, {
|
|
194
|
-
value: contextValue,
|
|
195
|
-
children: t9
|
|
196
|
-
});
|
|
197
|
-
$[39] = contextValue;
|
|
198
|
-
$[40] = t9;
|
|
199
|
-
$[41] = t10;
|
|
200
|
-
} else {
|
|
201
|
-
t10 = $[41];
|
|
202
|
-
}
|
|
203
|
-
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
|
+
});
|
|
204
114
|
};
|
|
115
|
+
ThemeProvider.displayName = "ThemeProvider";
|
|
205
116
|
function useTheme() {
|
|
206
117
|
return React.useContext(ThemeContext);
|
|
207
118
|
}
|
|
@@ -213,25 +124,57 @@ function useColorSchemeVar(values, fallback) {
|
|
|
213
124
|
const colorScheme = t0 === undefined ? "" : t0;
|
|
214
125
|
return (_values$colorScheme = values[colorScheme]) !== null && _values$colorScheme !== void 0 ? _values$colorScheme : fallback;
|
|
215
126
|
}
|
|
216
|
-
function subscribeToSystemColorMode(callback) {
|
|
217
|
-
var _window, _window$matchMedia;
|
|
218
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
219
|
-
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)');
|
|
220
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
221
|
-
media === null || media === void 0 ? void 0 : media.addEventListener('change', callback);
|
|
222
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
223
|
-
return () => media === null || media === void 0 ? void 0 : media.removeEventListener('change', callback);
|
|
224
|
-
}
|
|
225
127
|
function useSystemColorMode() {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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;
|
|
230
170
|
}
|
|
231
171
|
function getSystemColorMode() {
|
|
232
|
-
var
|
|
172
|
+
var _window$matchMedia2, _window2, _window$matchMedia2$c;
|
|
233
173
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
234
|
-
|
|
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';
|
|
235
178
|
}
|
|
236
179
|
function resolveColorMode(colorMode, systemColorMode) {
|
|
237
180
|
switch (colorMode) {
|
|
@@ -6430,6 +6430,12 @@
|
|
|
6430
6430
|
"type": "boolean",
|
|
6431
6431
|
"defaultValue": "false",
|
|
6432
6432
|
"description": "If true, enables client-side list virtualization. Only the visible items plus a small overscan buffer are rendered in the DOM, dramatically improving performance for large lists. Recommended for lists with more than 100 items. Has no effect when `groupMetadata` is provided."
|
|
6433
|
+
},
|
|
6434
|
+
{
|
|
6435
|
+
"name": "displayInViewport",
|
|
6436
|
+
"type": "boolean",
|
|
6437
|
+
"defaultValue": "false",
|
|
6438
|
+
"description": "If true, the panel will attempt to fit entirely into the visible viewport, without having to scroll."
|
|
6433
6439
|
}
|
|
6434
6440
|
],
|
|
6435
6441
|
"subcomponents": []
|
package/package.json
CHANGED