@primer/react 38.35.1-rc.f5a561aea → 38.36.0-rc.3fb350b1f

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.
@@ -43,10 +43,11 @@ const responsiveButtonSizes = {
43
43
  const Panel = ({ title, description, variant: propsVariant, selectionVariant = "multiple", id, defaultOpen = false, open: propsOpen, anchorRef: providedAnchorRef, anchoredPositionSettings, onCancel: propsOnCancel, onClearSelection: propsOnClearSelection, onSubmit: propsOnSubmit, width = "medium", maxHeight = "large", className, ...props }) => {
44
44
  var _position$top, _position$left, _slots$header;
45
45
  const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
46
- const currentVariant = useResponsiveValue(Object.assign({
46
+ const responsiveVariants = Object.assign({
47
47
  regular: "anchored",
48
48
  narrow: "full-screen"
49
- }, typeof propsVariant === "string" ? { regular: propsVariant } : propsVariant), "anchored");
49
+ }, typeof propsVariant === "string" ? { regular: propsVariant } : propsVariant);
50
+ const currentVariant = useResponsiveValue(responsiveVariants, "anchored");
50
51
  if (propsOpen !== void 0 && internalOpen !== propsOpen) setInternalOpen(propsOpen);
51
52
  let Anchor;
52
53
  const anchorRef = useProvidedRefOrCreate(providedAnchorRef);
@@ -348,18 +349,20 @@ const SelectPanelFooter = ({ ...props }) => {
348
349
  SelectPanelFooter.displayName = "SelectPanelFooter";
349
350
  SelectPanelFooter.__SLOT__ = Symbol("SelectPanel.Footer");
350
351
  const SecondaryButton = (props) => {
352
+ const size = useResponsiveValue(responsiveButtonSizes, "small");
351
353
  return /*#__PURE__*/ jsx(ButtonComponent, {
352
354
  type: "button",
353
- size: useResponsiveValue(responsiveButtonSizes, "small"),
355
+ size,
354
356
  block: true,
355
357
  ...props
356
358
  });
357
359
  };
358
360
  SecondaryButton.displayName = "SecondaryButton";
359
361
  const SecondaryLink = ({ className, ...props }) => {
362
+ const size = useResponsiveValue(responsiveButtonSizes, "small");
360
363
  return /*#__PURE__*/ jsx(ButtonComponent, {
361
364
  as: Link,
362
- size: useResponsiveValue(responsiveButtonSizes, "small"),
365
+ size,
363
366
  variant: "invisible",
364
367
  block: true,
365
368
  ...props,
@@ -5,7 +5,8 @@ import { FocusKeys as FocusKeys$1, focusZone } from "@primer/behaviors";
5
5
  function useFocusZone(settings = {}, dependencies = []) {
6
6
  const containerRef = useProvidedRefOrCreate(settings.containerRef);
7
7
  const useActiveDescendant = !!settings.activeDescendantFocus;
8
- const activeDescendantControlRef = useProvidedRefOrCreate(typeof settings.activeDescendantFocus === "boolean" || !settings.activeDescendantFocus ? void 0 : settings.activeDescendantFocus);
8
+ const passedActiveDescendantRef = typeof settings.activeDescendantFocus === "boolean" || !settings.activeDescendantFocus ? void 0 : settings.activeDescendantFocus;
9
+ const activeDescendantControlRef = useProvidedRefOrCreate(passedActiveDescendantRef);
9
10
  const disabled = settings.disabled;
10
11
  const abortController = React.useRef();
11
12
  useEffect(() => {
@@ -0,0 +1,50 @@
1
+ import { ThemeContext } from "../../ThemeContext.js";
2
+ import { c } from "react-compiler-runtime";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region src/internal/components/ThemeProviderBase.tsx
5
+ const ThemeProviderBase = (t0) => {
6
+ const $ = c(11);
7
+ const { children, contextOnly, value } = t0;
8
+ if (contextOnly) {
9
+ let t1;
10
+ if ($[0] !== children || $[1] !== value) {
11
+ t1 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
12
+ value,
13
+ children
14
+ });
15
+ $[0] = children;
16
+ $[1] = value;
17
+ $[2] = t1;
18
+ } else t1 = $[2];
19
+ return t1;
20
+ }
21
+ const t1 = value.colorMode === "auto" ? "auto" : value.colorScheme.includes("dark") ? "dark" : "light";
22
+ let t2;
23
+ if ($[3] !== children || $[4] !== t1 || $[5] !== value.dayScheme || $[6] !== value.nightScheme) {
24
+ t2 = /*#__PURE__*/ jsx("div", {
25
+ "data-component": "ThemeProvider",
26
+ "data-color-mode": t1,
27
+ "data-light-theme": value.dayScheme,
28
+ "data-dark-theme": value.nightScheme,
29
+ children
30
+ });
31
+ $[3] = children;
32
+ $[4] = t1;
33
+ $[5] = value.dayScheme;
34
+ $[6] = value.nightScheme;
35
+ $[7] = t2;
36
+ } else t2 = $[7];
37
+ let t3;
38
+ if ($[8] !== t2 || $[9] !== value) {
39
+ t3 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
40
+ value,
41
+ children: t2
42
+ });
43
+ $[8] = t2;
44
+ $[9] = value;
45
+ $[10] = t3;
46
+ } else t3 = $[10];
47
+ return t3;
48
+ };
49
+ //#endregion
50
+ export { ThemeProviderBase };
@@ -0,0 +1,71 @@
1
+ import { useSyncedState } from "../../hooks/useSyncedState.js";
2
+ import { useTheme } from "../../useTheme.js";
3
+ import { c } from "react-compiler-runtime";
4
+ import React from "react";
5
+ //#region src/internal/hooks/useThemeProvider.ts
6
+ const defaultColorMode = "day";
7
+ const defaultDayScheme = "light";
8
+ const defaultNightScheme = "dark";
9
+ function useThemeProvider(props) {
10
+ var _ref, _props$colorMode, _ref2, _props$dayScheme, _ref3, _props$nightScheme;
11
+ const $ = c(12);
12
+ const parentValue = useTheme();
13
+ const [colorMode, setColorMode] = useSyncedState((_ref = (_props$colorMode = props.colorMode) !== null && _props$colorMode !== void 0 ? _props$colorMode : parentValue.colorMode) !== null && _ref !== void 0 ? _ref : defaultColorMode);
14
+ const [dayScheme, setDayScheme] = useSyncedState((_ref2 = (_props$dayScheme = props.dayScheme) !== null && _props$dayScheme !== void 0 ? _props$dayScheme : parentValue.dayScheme) !== null && _ref2 !== void 0 ? _ref2 : defaultDayScheme);
15
+ const [nightScheme, setNightScheme] = useSyncedState((_ref3 = (_props$nightScheme = props.nightScheme) !== null && _props$nightScheme !== void 0 ? _props$nightScheme : parentValue.nightScheme) !== null && _ref3 !== void 0 ? _ref3 : defaultNightScheme);
16
+ const systemColorMode = useSystemColorMode();
17
+ const resolvedColorMode = colorMode === "auto" ? systemColorMode : colorMode;
18
+ const colorScheme = resolvedColorMode === "day" || resolvedColorMode === "light" ? dayScheme : nightScheme;
19
+ let t0;
20
+ if ($[0] !== colorMode || $[1] !== colorScheme || $[2] !== dayScheme || $[3] !== nightScheme || $[4] !== resolvedColorMode || $[5] !== setColorMode || $[6] !== setDayScheme || $[7] !== setNightScheme) {
21
+ t0 = {
22
+ colorScheme,
23
+ colorMode,
24
+ resolvedColorMode,
25
+ dayScheme,
26
+ nightScheme,
27
+ setColorMode,
28
+ setDayScheme,
29
+ setNightScheme
30
+ };
31
+ $[0] = colorMode;
32
+ $[1] = colorScheme;
33
+ $[2] = dayScheme;
34
+ $[3] = nightScheme;
35
+ $[4] = resolvedColorMode;
36
+ $[5] = setColorMode;
37
+ $[6] = setDayScheme;
38
+ $[7] = setNightScheme;
39
+ $[8] = t0;
40
+ } else t0 = $[8];
41
+ const value = t0;
42
+ let t1;
43
+ if ($[9] !== parentValue || $[10] !== value) {
44
+ t1 = {
45
+ parentValue,
46
+ value
47
+ };
48
+ $[9] = parentValue;
49
+ $[10] = value;
50
+ $[11] = t1;
51
+ } else t1 = $[11];
52
+ return t1;
53
+ }
54
+ function subscribeToSystemColorMode(callback) {
55
+ var _window, _window$matchMedia;
56
+ 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)");
57
+ media === null || media === void 0 || media.addEventListener("change", callback);
58
+ return () => media === null || media === void 0 ? void 0 : media.removeEventListener("change", callback);
59
+ }
60
+ function useSystemColorMode() {
61
+ return React.useSyncExternalStore(subscribeToSystemColorMode, getSystemColorMode, _temp);
62
+ }
63
+ function _temp() {
64
+ return "day";
65
+ }
66
+ function getSystemColorMode() {
67
+ var _window2, _window2$matchMedia, _window2$matchMedia$c;
68
+ return (_window2 = window) !== null && _window2 !== void 0 && (_window2$matchMedia = _window2.matchMedia) !== null && _window2$matchMedia !== void 0 && (_window2$matchMedia$c = _window2$matchMedia.call(_window2, "(prefers-color-scheme: dark)")) !== null && _window2$matchMedia$c !== void 0 && _window2$matchMedia$c.matches ? "night" : "day";
69
+ }
70
+ //#endregion
71
+ export { useThemeProvider };