@primer/styled-react 1.1.0-rc.aaa3a8993 → 1.1.0-rc.b8979ee01

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,17 +1,26 @@
1
- import type React from 'react';
2
- import { type CSSProperties, type PropsWithChildren, type JSX } from 'react';
3
- import type * as styledSystem from 'styled-system';
4
- import 'focus-visible';
5
- export interface SystemCommonProps extends styledSystem.ColorProps, styledSystem.SpaceProps, styledSystem.DisplayProps {
1
+ import React, { CSSProperties, JSX, PropsWithChildren } from "react";
2
+ import * as styledSystem from "styled-system";
3
+ //#region src/components/BaseStyles.d.ts
4
+ interface SystemCommonProps extends styledSystem.ColorProps, styledSystem.SpaceProps, styledSystem.DisplayProps {}
5
+ interface SystemTypographyProps extends styledSystem.TypographyProps {
6
+ whiteSpace?: 'normal' | 'nowrap' | 'pre' | 'pre-wrap' | 'pre-line';
6
7
  }
7
- export interface SystemTypographyProps extends styledSystem.TypographyProps {
8
- whiteSpace?: 'normal' | 'nowrap' | 'pre' | 'pre-wrap' | 'pre-line';
9
- }
10
- export type BaseStylesProps = PropsWithChildren & {
11
- as?: React.ComponentType<any> | keyof JSX.IntrinsicElements;
12
- className?: string;
13
- style?: CSSProperties;
14
- color?: string;
8
+ type BaseStylesProps = PropsWithChildren & {
9
+ as?: React.ComponentType<any> | keyof JSX.IntrinsicElements;
10
+ className?: string;
11
+ style?: CSSProperties;
12
+ color?: string;
15
13
  } & SystemTypographyProps & SystemCommonProps;
16
- export declare function BaseStyles({ children, color, fontFamily, lineHeight, className, as: Component, style, ...rest }: BaseStylesProps): JSX.Element;
14
+ declare function BaseStyles({
15
+ children,
16
+ color,
17
+ fontFamily,
18
+ lineHeight,
19
+ className,
20
+ as: Component,
21
+ style,
22
+ ...rest
23
+ }: BaseStylesProps): JSX.Element;
24
+ //#endregion
25
+ export { BaseStyles, BaseStylesProps, SystemCommonProps, SystemTypographyProps };
17
26
  //# sourceMappingURL=BaseStyles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseStyles.d.ts","sourceRoot":"","sources":["../../src/components/BaseStyles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,KAAK,GAAG,EAAC,MAAM,OAAO,CAAA;AAG1E,OAAO,KAAK,KAAK,YAAY,MAAM,eAAe,CAAA;AAGlD,OAAO,eAAe,CAAA;AAGtB,MAAM,WAAW,iBACf,SAAQ,YAAY,CAAC,UAAU,EAC7B,YAAY,CAAC,UAAU,EACvB,YAAY,CAAC,YAAY;CAAG;AAEhC,MAAM,WAAW,qBAAsB,SAAQ,YAAY,CAAC,eAAe;IACzE,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,CAAA;CACnE;AA8ED,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG;IAEhD,EAAE,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC,iBAAiB,CAAA;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,qBAAqB,GACvB,iBAAiB,CAAA;AAEnB,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,KAAK,EACL,UAAU,EACV,UAAU,EACV,SAAS,EACT,EAAE,EAAE,SAAiB,EACrB,KAAK,EACL,GAAG,IAAI,EACR,EAAE,eAAe,eA+BjB"}
1
+ {"version":3,"file":"BaseStyles.d.ts","names":[],"sources":["../../src/components/BaseStyles.tsx"],"mappings":";;;UAUiB,iBAAA,SACP,YAAA,CAAa,UAAA,EACnB,YAAA,CAAa,UAAA,EACb,YAAA,CAAa,YAAA;AAAA,UAEA,qBAAA,SAA8B,YAAA,CAAa,eAAe;EACzE,UAAA;AAAA;AAAA,KA+EU,eAAA,GAAkB,iBAAA;EAE5B,EAAA,GAAK,KAAA,CAAM,aAAA,cAA2B,GAAA,CAAI,iBAAA;EAC1C,SAAA;EACA,KAAA,GAAQ,aAAA;EACR,KAAA;AAAA,IACE,qBAAA,GACF,iBAAA;AAAA,iBAEc,UAAA;EACd,QAAA;EACA,KAAA;EACA,UAAA;EACA,UAAA;EACA,SAAA;EACA,EAAA,EAAI,SAAA;EACJ,KAAA;EAAA,GACG;AAAA,GACF,eAAA,GAAe,GAAA,CAAA,OAAA"}
@@ -1,51 +1,30 @@
1
- import { clsx } from 'clsx';
2
- import { useTheme } from './ThemeProvider.js';
3
- import 'focus-visible';
4
- import { createGlobalStyle } from 'styled-components';
5
- import { jsxs, jsx } from 'react/jsx-runtime';
6
-
1
+ import { useTheme } from "./useTheme.js";
2
+ import { createGlobalStyle } from "styled-components";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { clsx } from "clsx";
5
+ import "focus-visible";
6
+ //#region src/components/BaseStyles.tsx
7
7
  const GlobalStyle = createGlobalStyle(["*{box-sizing:border-box;}body{margin:0;}table{border-collapse:collapse;}[data-color-mode='light'] input{color-scheme:light;}[data-color-mode='dark'] input{color-scheme:dark;}@media (prefers-color-scheme:light){[data-color-mode='auto'][data-light-theme*='light']{color-scheme:light;}}@media (prefers-color-scheme:dark){[data-color-mode='auto'][data-dark-theme*='dark']{color-scheme:dark;}}[role='button']:focus:not(:focus-visible):not(:global(.focus-visible)),[role='tabpanel'][tabindex='0']:focus:not(:focus-visible):not(:global(.focus-visible)),button:focus:not(:focus-visible):not(:global(.focus-visible)),summary:focus:not(:focus-visible):not(:global(.focus-visible)),a:focus:not(:focus-visible):not(:global(.focus-visible)){outline:none;box-shadow:none;}[tabindex='0']:focus:not(:focus-visible):not(:global(.focus-visible)),details-dialog:focus:not(:focus-visible):not(:global(.focus-visible)){outline:none;}.BaseStyles{font-family:var(--BaseStyles-fontFamily,var(--fontStack-system));line-height:var(--BaseStyles-lineHeight,1.5);color:var(--BaseStyles-fgColor,var(--fgColor-default));:where(a:not([class*='prc-']):not([class*='PRC-']):not([class*='Primer_Brand__'])){color:var(--fgColor-accent,var(--color-accent-fg));text-decoration:none;&:hover{text-decoration:underline;}}}"]);
8
- function BaseStyles({
9
- children,
10
- color,
11
- fontFamily,
12
- lineHeight,
13
- className,
14
- as: Component = 'div',
15
- style,
16
- ...rest
17
- }) {
18
- const {
19
- colorMode,
20
- colorScheme,
21
- dayScheme,
22
- nightScheme
23
- } = useTheme();
24
- const baseStyles = {
25
- ['--BaseStyles-fgColor']: color,
26
- ['--BaseStyles-fontFamily']: fontFamily,
27
- ['--BaseStyles-lineHeight']: lineHeight
28
- };
29
- return /*#__PURE__*/jsxs(Component, {
30
- className: clsx('BaseStyles', className),
31
- "data-portal-root": true
32
- /**
33
- * We need to map valid primer/react color modes onto valid color modes for primer/primitives
34
- * valid color modes for primer/primitives: auto | light | dark
35
- * valid color modes for primer/primer: auto | day | night | light | dark
36
- */,
37
- "data-color-mode": colorMode === 'auto' ? 'auto' : colorScheme?.includes('dark') ? 'dark' : 'light',
38
- "data-light-theme": dayScheme,
39
- "data-dark-theme": nightScheme,
40
- style: {
41
- ...baseStyles,
42
- ...style
43
- },
44
- ...rest,
45
- children: [/*#__PURE__*/jsx(GlobalStyle, {
46
- colorScheme: colorScheme?.includes('dark') ? 'dark' : 'light'
47
- }), children]
48
- });
8
+ function BaseStyles({ children, color, fontFamily, lineHeight, className, as: Component = "div", style, ...rest }) {
9
+ const { colorMode, colorScheme, dayScheme, nightScheme } = useTheme();
10
+ const baseStyles = {
11
+ ["--BaseStyles-fgColor"]: color,
12
+ ["--BaseStyles-fontFamily"]: fontFamily,
13
+ ["--BaseStyles-lineHeight"]: lineHeight
14
+ };
15
+ return /*#__PURE__*/ jsxs(Component, {
16
+ className: clsx("BaseStyles", className),
17
+ "data-portal-root": true,
18
+ "data-color-mode": colorMode === "auto" ? "auto" : colorScheme?.includes("dark") ? "dark" : "light",
19
+ "data-light-theme": dayScheme,
20
+ "data-dark-theme": nightScheme,
21
+ style: {
22
+ ...baseStyles,
23
+ ...style
24
+ },
25
+ ...rest,
26
+ children: [/*#__PURE__*/ jsx(GlobalStyle, { colorScheme: colorScheme?.includes("dark") ? "dark" : "light" }), children]
27
+ });
49
28
  }
50
-
29
+ //#endregion
51
30
  export { BaseStyles };
@@ -1,12 +1,12 @@
1
- import type React from 'react';
2
- import { useTheme as primerUseTheme } from '@primer/react';
3
- import { useColorSchemeVar } from './ThemeProvider';
4
- import type { ThemeProviderProps as StyledThemeProviderProps } from './ThemeProvider';
5
- import type { BaseStylesProps as StyledBaseStylesProps } from './BaseStyles';
6
- export type ThemeProviderProps = StyledThemeProviderProps;
7
- export type BaseStylesProps = StyledBaseStylesProps;
8
- export declare const ThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderProps>>;
9
- export declare function useTheme(): ReturnType<typeof primerUseTheme>;
10
- export { useColorSchemeVar };
11
- export declare function BaseStyles(props: BaseStylesProps): React.JSX.Element;
1
+ import { BaseStylesProps as BaseStylesProps$1 } from "./BaseStyles.js";
2
+ import { ThemeProviderProps as ThemeProviderProps$1 } from "./ThemeProvider.js";
3
+ import React from "react";
4
+
5
+ //#region src/components/FeatureFlaggedTheming.d.ts
6
+ type ThemeProviderProps = ThemeProviderProps$1;
7
+ type BaseStylesProps = BaseStylesProps$1;
8
+ declare const ThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderProps>>;
9
+ declare function BaseStyles(props: BaseStylesProps): React.JSX.Element;
10
+ //#endregion
11
+ export { BaseStyles, BaseStylesProps, ThemeProvider, ThemeProviderProps };
12
12
  //# sourceMappingURL=FeatureFlaggedTheming.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureFlaggedTheming.d.ts","sourceRoot":"","sources":["../../src/components/FeatureFlaggedTheming.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAEL,QAAQ,IAAI,cAAc,EAE3B,MAAM,eAAe,CAAA;AAMtB,OAAO,EAAmE,iBAAiB,EAAC,MAAM,iBAAiB,CAAA;AACnH,OAAO,KAAK,EAAC,kBAAkB,IAAI,wBAAwB,EAAC,MAAM,iBAAiB,CAAA;AAEnF,OAAO,KAAK,EAAC,eAAe,IAAI,qBAAqB,EAAC,MAAM,cAAc,CAAA;AAE1E,MAAM,MAAM,kBAAkB,GAAG,wBAAwB,CAAA;AAEzD,MAAM,MAAM,eAAe,GAAG,qBAAqB,CAAA;AAEnD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAM/E,CAAA;AAED,wBAAgB,QAAQ,IAAI,UAAU,CAAC,OAAO,cAAc,CAAC,CAQ5D;AAED,OAAO,EAAC,iBAAiB,EAAC,CAAA;AAE1B,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,qBAMhD"}
1
+ {"version":3,"file":"FeatureFlaggedTheming.d.ts","names":[],"sources":["../../src/components/FeatureFlaggedTheming.tsx"],"mappings":";;;;;KAYY,kBAAA,GAAqB,oBAAwB;AAAA,KAE7C,eAAA,GAAkB,iBAAqB;AAAA,cAEtC,aAAA,EAAe,KAAA,CAAM,EAAA,CAAG,KAAA,CAAM,iBAAA,CAAkB,kBAAA;AAAA,iBAQ7C,UAAA,CAAW,KAAA,EAAO,eAAA,GAAe,KAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -1,45 +1,22 @@
1
- import { BaseStyles as BaseStyles$1, ThemeProvider as ThemeProvider$1, useTheme as useTheme$2 } from '@primer/react';
2
- import { useFeatureFlag } from '@primer/react/experimental';
3
- import { ThemeProvider as ThemeProvider$2, useTheme as useTheme$1 } from './ThemeProvider.js';
4
- export { useColorSchemeVar } from './ThemeProvider.js';
5
- import { BaseStyles as BaseStyles$2 } from './BaseStyles.js';
6
- import { jsx } from 'react/jsx-runtime';
7
-
8
- const ThemeProvider = ({
9
- children,
10
- ...props
11
- }) => {
12
- const enabled = useFeatureFlag('primer_react_styled_react_use_primer_theme_providers');
13
- if (enabled) {
14
- return /*#__PURE__*/jsx(ThemeProvider$1, {
15
- ...props,
16
- children: children
17
- });
18
- }
19
- return /*#__PURE__*/jsx(ThemeProvider$2, {
20
- ...props,
21
- children: children
22
- });
1
+ import { ThemeProvider as ThemeProvider$2 } from "./ThemeProvider.js";
2
+ import { BaseStyles as BaseStyles$2 } from "./BaseStyles.js";
3
+ import { BaseStyles, ThemeProvider } from "@primer/react";
4
+ import { useFeatureFlag } from "@primer/react/experimental";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/components/FeatureFlaggedTheming.tsx
7
+ const ThemeProvider$1 = ({ children, ...props }) => {
8
+ if (useFeatureFlag("primer_react_styled_react_use_primer_theme_providers")) return /*#__PURE__*/ jsx(ThemeProvider, {
9
+ ...props,
10
+ children
11
+ });
12
+ return /*#__PURE__*/ jsx(ThemeProvider$2, {
13
+ ...props,
14
+ children
15
+ });
23
16
  };
24
- function useTheme() {
25
- const enabled = useFeatureFlag('primer_react_styled_react_use_primer_theme_providers');
26
- const styledTheme = useTheme$1();
27
- const primerTheme = useTheme$2();
28
- if (enabled) {
29
- return primerTheme;
30
- }
31
- return styledTheme;
17
+ function BaseStyles$1(props) {
18
+ if (useFeatureFlag("primer_react_styled_react_use_primer_theme_providers")) return /*#__PURE__*/ jsx(BaseStyles, { ...props });
19
+ return /*#__PURE__*/ jsx(BaseStyles$2, { ...props });
32
20
  }
33
- function BaseStyles(props) {
34
- const enabled = useFeatureFlag('primer_react_styled_react_use_primer_theme_providers');
35
- if (enabled) {
36
- return /*#__PURE__*/jsx(BaseStyles$1, {
37
- ...props
38
- });
39
- }
40
- return /*#__PURE__*/jsx(BaseStyles$2, {
41
- ...props
42
- });
43
- }
44
-
45
- export { BaseStyles, ThemeProvider, useTheme };
21
+ //#endregion
22
+ export { BaseStyles$1 as BaseStyles, ThemeProvider$1 as ThemeProvider };
@@ -0,0 +1,19 @@
1
+ import { ColorMode, ColorModeWithAuto, Theme } from "./ThemeProvider.js";
2
+ import React from "react";
3
+
4
+ //#region src/components/ThemeContext.d.ts
5
+ declare const ThemeContext: React.Context<{
6
+ theme?: Theme;
7
+ colorScheme?: string;
8
+ colorMode?: ColorModeWithAuto;
9
+ resolvedColorMode?: ColorMode;
10
+ resolvedColorScheme?: string;
11
+ dayScheme?: string;
12
+ nightScheme?: string;
13
+ setColorMode: React.Dispatch<React.SetStateAction<ColorModeWithAuto>>;
14
+ setDayScheme: React.Dispatch<React.SetStateAction<string>>;
15
+ setNightScheme: React.Dispatch<React.SetStateAction<string>>;
16
+ }>;
17
+ //#endregion
18
+ export { ThemeContext };
19
+ //# sourceMappingURL=ThemeContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeContext.d.ts","names":[],"sources":["../../src/components/ThemeContext.ts"],"mappings":";;;;cAGa,YAAA,EAAY,KAAA,CAAA,OAAA;UACf,KAAA;;cAEI,iBAAA;sBACQ,SAAA;;;;gBAIN,KAAA,CAAM,QAAA,CAAS,KAAA,CAAM,cAAA,CAAe,iBAAA;gBACpC,KAAA,CAAM,QAAA,CAAS,KAAA,CAAM,cAAA;kBACnB,KAAA,CAAM,QAAA,CAAS,KAAA,CAAM,cAAA;AAAA"}
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ //#region src/components/ThemeContext.ts
3
+ const ThemeContext = /*#__PURE__*/ React.createContext({
4
+ setColorMode: () => null,
5
+ setDayScheme: () => null,
6
+ setNightScheme: () => null
7
+ });
8
+ //#endregion
9
+ export { ThemeContext };
@@ -1,35 +1,25 @@
1
- import React from 'react';
2
- export declare const defaultColorMode = "day";
3
- export type Theme = {
4
- [key: string]: any;
1
+ import React from "react";
2
+
3
+ //#region src/components/ThemeProvider.d.ts
4
+ declare const defaultColorMode = "day";
5
+ type Theme = {
6
+ [key: string]: any;
5
7
  };
6
8
  type ColorMode = 'day' | 'night' | 'light' | 'dark';
7
- export type ColorModeWithAuto = ColorMode | 'auto';
8
- export type ThemeProviderProps = {
9
- theme?: Theme;
10
- colorMode?: ColorModeWithAuto;
11
- dayScheme?: string;
12
- nightScheme?: string;
13
- preventSSRMismatch?: boolean;
14
- /**
15
- * No-op. Exists solely to match @primer/react's ThemeProvider API.
16
- * @default false
17
- */
18
- contextOnly?: boolean;
9
+ type ColorModeWithAuto = ColorMode | 'auto';
10
+ type ThemeProviderProps = {
11
+ theme?: Theme;
12
+ colorMode?: ColorModeWithAuto;
13
+ dayScheme?: string;
14
+ nightScheme?: string;
15
+ preventSSRMismatch?: boolean;
16
+ /**
17
+ * No-op. Exists solely to match @primer/react's ThemeProvider API.
18
+ * @default false
19
+ */
20
+ contextOnly?: boolean;
19
21
  };
20
- export declare const ThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderProps>>;
21
- export declare function useTheme(): {
22
- theme?: Theme;
23
- colorScheme?: string;
24
- colorMode?: ColorModeWithAuto;
25
- resolvedColorMode?: ColorMode;
26
- resolvedColorScheme?: string;
27
- dayScheme?: string;
28
- nightScheme?: string;
29
- setColorMode: React.Dispatch<React.SetStateAction<ColorModeWithAuto>>;
30
- setDayScheme: React.Dispatch<React.SetStateAction<string>>;
31
- setNightScheme: React.Dispatch<React.SetStateAction<string>>;
32
- };
33
- export declare function useColorSchemeVar(values: Partial<Record<string, string>>, fallback: string): string;
34
- export default ThemeProvider;
22
+ declare const ThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderProps>>;
23
+ //#endregion
24
+ export { ColorMode, ColorModeWithAuto, Theme, ThemeProvider, ThemeProvider as default, ThemeProviderProps, defaultColorMode };
35
25
  //# sourceMappingURL=ThemeProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../src/components/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,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,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,SAAS,CAAC,EAAE,iBAAiB,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AA8CD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAyE/E,CAAA;AAED,wBAAgB,QAAQ;YAtHd,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;EA+G7D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,UAG1F;AAqED,eAAe,aAAa,CAAA"}
1
+ {"version":3,"file":"ThemeProvider.d.ts","names":[],"sources":["../../src/components/ThemeProvider.tsx"],"mappings":";;;cAOa,gBAAA;AAAA,KAKD,KAAA;EAAA,CAAU,GAAW;AAAA;AAAA,KACrB,SAAA;AAAA,KACA,iBAAA,GAAoB,SAAS;AAAA,KAE7B,kBAAA;EACV,KAAA,GAAQ,KAAA;EACR,SAAA,GAAY,iBAAiB;EAC7B,SAAA;EACA,WAAA;EACA,kBAAA;EARU;;;;EAaV,WAAA;AAAA;AAAA,cA8BW,aAAA,EAAe,KAAA,CAAM,EAAA,CAAG,KAAA,CAAM,iBAAA,CAAkB,kBAAA"}
@@ -1,163 +1,119 @@
1
- import React from 'react';
2
- import { ThemeProvider as ThemeProvider$1 } from 'styled-components';
3
- import { theme, useId, useSyncedState } from '@primer/react';
4
- import deepmerge from 'deepmerge';
5
- import { jsx, jsxs } from 'react/jsx-runtime';
6
-
7
- const defaultColorMode = 'day';
8
- const defaultDayScheme = 'light';
9
- const defaultNightScheme = 'dark';
10
-
11
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
-
13
- const ThemeContext = /*#__PURE__*/React.createContext({
14
- setColorMode: () => null,
15
- setDayScheme: () => null,
16
- setNightScheme: () => null
17
- });
18
-
19
- // inspired from __NEXT_DATA__, we use application/json to avoid CSRF policy with inline scripts
20
- const serverHandoffCache = new Map();
1
+ import { ThemeContext } from "./ThemeContext.js";
2
+ import { useTheme as useTheme$1 } from "./useTheme.js";
3
+ import { theme, useId, useSyncedState } from "@primer/react";
4
+ import React from "react";
5
+ import { ThemeProvider as ThemeProvider$1 } from "styled-components";
6
+ import deepmerge from "deepmerge";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ const defaultDayScheme = "light";
9
+ const defaultNightScheme = "dark";
10
+ const serverHandoffCache = /* @__PURE__ */ new Map();
21
11
  const emptyHandoff = {};
22
- const getServerHandoff = id => {
23
- if (typeof document === 'undefined') return emptyHandoff;
24
- const cached = serverHandoffCache.get(id);
25
- if (cached !== undefined) return cached;
26
- try {
27
- const serverData = document.getElementById(`__PRIMER_DATA_${id}__`)?.textContent;
28
- if (serverData) {
29
- const parsed = JSON.parse(serverData);
30
- serverHandoffCache.set(id, parsed);
31
- return parsed;
32
- }
33
- } catch (_error) {
34
- // if document/element does not exist or JSON is invalid, supress error
35
- }
36
- const empty = {};
37
- serverHandoffCache.set(id, empty);
38
- return empty;
12
+ const getServerHandoff = (id) => {
13
+ if (typeof document === "undefined") return emptyHandoff;
14
+ const cached = serverHandoffCache.get(id);
15
+ if (cached !== void 0) return cached;
16
+ try {
17
+ const serverData = document.getElementById(`__PRIMER_DATA_${id}__`)?.textContent;
18
+ if (serverData) {
19
+ const parsed = JSON.parse(serverData);
20
+ serverHandoffCache.set(id, parsed);
21
+ return parsed;
22
+ }
23
+ } catch (_error) {}
24
+ const empty = {};
25
+ serverHandoffCache.set(id, empty);
26
+ return empty;
39
27
  };
40
28
  const emptySubscribe = () => () => {};
41
- const ThemeProvider = ({
42
- children,
43
- ...props
44
- }) => {
45
- // Get fallback values from parent ThemeProvider (if exists)
46
- const {
47
- theme: fallbackTheme,
48
- colorMode: fallbackColorMode,
49
- dayScheme: fallbackDayScheme,
50
- nightScheme: fallbackNightScheme
51
- } = useTheme();
52
-
53
- // Initialize state
54
- const theme$1 = props.theme ?? fallbackTheme ?? theme;
55
- const uniqueDataId = useId();
56
- const [colorMode, setColorMode] = useSyncedState(props.colorMode ?? fallbackColorMode ?? defaultColorMode);
57
- const [dayScheme, setDayScheme] = useSyncedState(props.dayScheme ?? fallbackDayScheme ?? defaultDayScheme);
58
- const [nightScheme, setNightScheme] = useSyncedState(props.nightScheme ?? fallbackNightScheme ?? defaultNightScheme);
59
- const systemColorMode = useSystemColorMode();
60
- const clientColorMode = resolveColorMode(colorMode, systemColorMode);
61
- // During SSR/hydration, use the server-rendered color mode from the handoff script tag
62
- // to avoid mismatches. After hydration, resolve from client state.
63
- const resolvedColorMode = React.useSyncExternalStore(emptySubscribe, () => clientColorMode, () => getServerHandoff(uniqueDataId).resolvedServerColorMode ?? clientColorMode);
64
- const colorScheme = chooseColorScheme(resolvedColorMode, dayScheme, nightScheme);
65
- const {
66
- resolvedTheme,
67
- resolvedColorScheme
68
- } = React.useMemo(() => applyColorScheme(theme$1, colorScheme), [theme$1, colorScheme]);
69
- const contextValue = React.useMemo(() => ({
70
- theme: resolvedTheme,
71
- colorScheme,
72
- colorMode,
73
- resolvedColorMode,
74
- resolvedColorScheme,
75
- dayScheme,
76
- nightScheme,
77
- setColorMode,
78
- setDayScheme,
79
- setNightScheme
80
- }), [resolvedTheme, colorScheme, colorMode, resolvedColorMode, resolvedColorScheme, dayScheme, nightScheme, setColorMode, setDayScheme, setNightScheme]);
81
- return /*#__PURE__*/jsx(ThemeContext.Provider, {
82
- value: contextValue,
83
- children: /*#__PURE__*/jsxs(ThemeProvider$1, {
84
- theme: resolvedTheme,
85
- children: [children, props.preventSSRMismatch ? /*#__PURE__*/jsx("script", {
86
- type: "application/json",
87
- id: `__PRIMER_DATA_${uniqueDataId}__`,
88
- dangerouslySetInnerHTML: {
89
- __html: JSON.stringify({
90
- resolvedServerColorMode: resolvedColorMode
91
- })
92
- }
93
- }) : null]
94
- })
95
- });
29
+ const ThemeProvider$2 = ({ children, ...props }) => {
30
+ const { theme: fallbackTheme, colorMode: fallbackColorMode, dayScheme: fallbackDayScheme, nightScheme: fallbackNightScheme } = useTheme$1();
31
+ const theme$1 = props.theme ?? fallbackTheme ?? theme;
32
+ const uniqueDataId = useId();
33
+ const [colorMode, setColorMode] = useSyncedState(props.colorMode ?? fallbackColorMode ?? "day");
34
+ const [dayScheme, setDayScheme] = useSyncedState(props.dayScheme ?? fallbackDayScheme ?? defaultDayScheme);
35
+ const [nightScheme, setNightScheme] = useSyncedState(props.nightScheme ?? fallbackNightScheme ?? defaultNightScheme);
36
+ const clientColorMode = resolveColorMode(colorMode, useSystemColorMode());
37
+ const resolvedColorMode = React.useSyncExternalStore(emptySubscribe, () => clientColorMode, () => getServerHandoff(uniqueDataId).resolvedServerColorMode ?? clientColorMode);
38
+ const colorScheme = chooseColorScheme(resolvedColorMode, dayScheme, nightScheme);
39
+ const { resolvedTheme, resolvedColorScheme } = React.useMemo(() => applyColorScheme(theme$1, colorScheme), [theme$1, colorScheme]);
40
+ const contextValue = React.useMemo(() => ({
41
+ theme: resolvedTheme,
42
+ colorScheme,
43
+ colorMode,
44
+ resolvedColorMode,
45
+ resolvedColorScheme,
46
+ dayScheme,
47
+ nightScheme,
48
+ setColorMode,
49
+ setDayScheme,
50
+ setNightScheme
51
+ }), [
52
+ resolvedTheme,
53
+ colorScheme,
54
+ colorMode,
55
+ resolvedColorMode,
56
+ resolvedColorScheme,
57
+ dayScheme,
58
+ nightScheme,
59
+ setColorMode,
60
+ setDayScheme,
61
+ setNightScheme
62
+ ]);
63
+ return /*#__PURE__*/ jsx(ThemeContext.Provider, {
64
+ value: contextValue,
65
+ children: /*#__PURE__*/ jsxs(ThemeProvider$1, {
66
+ theme: resolvedTheme,
67
+ children: [children, props.preventSSRMismatch ? /*#__PURE__*/ jsx("script", {
68
+ type: "application/json",
69
+ id: `__PRIMER_DATA_${uniqueDataId}__`,
70
+ dangerouslySetInnerHTML: { __html: JSON.stringify({ resolvedServerColorMode: resolvedColorMode }) }
71
+ }) : null]
72
+ })
73
+ });
96
74
  };
97
- function useTheme() {
98
- return React.useContext(ThemeContext);
99
- }
100
- function useColorSchemeVar(values, fallback) {
101
- const {
102
- colorScheme = ''
103
- } = useTheme();
104
- return values[colorScheme] ?? fallback;
105
- }
106
75
  function subscribeToSystemColorMode(callback) {
107
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
108
- const media = window?.matchMedia?.('(prefers-color-scheme: dark)');
109
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
110
- media?.addEventListener('change', callback);
111
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
112
- return () => media?.removeEventListener('change', callback);
76
+ const media = window?.matchMedia?.("(prefers-color-scheme: dark)");
77
+ media?.addEventListener("change", callback);
78
+ return () => media?.removeEventListener("change", callback);
113
79
  }
114
80
  function useSystemColorMode() {
115
- return React.useSyncExternalStore(subscribeToSystemColorMode, getSystemColorMode, () => 'day');
81
+ return React.useSyncExternalStore(subscribeToSystemColorMode, getSystemColorMode, () => "day");
116
82
  }
117
83
  function getSystemColorMode() {
118
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
119
- return window?.matchMedia?.('(prefers-color-scheme: dark)')?.matches ? 'night' : 'day';
84
+ return window?.matchMedia?.("(prefers-color-scheme: dark)")?.matches ? "night" : "day";
120
85
  }
121
86
  function resolveColorMode(colorMode, systemColorMode) {
122
- switch (colorMode) {
123
- case 'auto':
124
- return systemColorMode;
125
- default:
126
- return colorMode;
127
- }
87
+ switch (colorMode) {
88
+ case "auto": return systemColorMode;
89
+ default: return colorMode;
90
+ }
128
91
  }
129
92
  function chooseColorScheme(colorMode, dayScheme, nightScheme) {
130
- switch (colorMode) {
131
- case 'day':
132
- case 'light':
133
- return dayScheme;
134
- case 'dark':
135
- case 'night':
136
- return nightScheme;
137
- }
93
+ switch (colorMode) {
94
+ case "day":
95
+ case "light": return dayScheme;
96
+ case "dark":
97
+ case "night": return nightScheme;
98
+ }
138
99
  }
139
100
  function applyColorScheme(theme, colorScheme) {
140
- if (!theme.colorSchemes) {
141
- return {
142
- resolvedTheme: theme,
143
- resolvedColorScheme: undefined
144
- };
145
- }
146
- if (!theme.colorSchemes[colorScheme]) {
147
- // eslint-disable-next-line no-console
148
- console.error(`\`${colorScheme}\` scheme not defined in \`theme.colorSchemes\``);
149
-
150
- // Apply the first defined color scheme
151
- const defaultColorScheme = Object.keys(theme.colorSchemes)[0];
152
- return {
153
- resolvedTheme: deepmerge(theme, theme.colorSchemes[defaultColorScheme]),
154
- resolvedColorScheme: defaultColorScheme
155
- };
156
- }
157
- return {
158
- resolvedTheme: deepmerge(theme, theme.colorSchemes[colorScheme]),
159
- resolvedColorScheme: colorScheme
160
- };
101
+ if (!theme.colorSchemes) return {
102
+ resolvedTheme: theme,
103
+ resolvedColorScheme: void 0
104
+ };
105
+ if (!theme.colorSchemes[colorScheme]) {
106
+ console.error(`\`${colorScheme}\` scheme not defined in \`theme.colorSchemes\``);
107
+ const defaultColorScheme = Object.keys(theme.colorSchemes)[0];
108
+ return {
109
+ resolvedTheme: deepmerge(theme, theme.colorSchemes[defaultColorScheme]),
110
+ resolvedColorScheme: defaultColorScheme
111
+ };
112
+ }
113
+ return {
114
+ resolvedTheme: deepmerge(theme, theme.colorSchemes[colorScheme]),
115
+ resolvedColorScheme: colorScheme
116
+ };
161
117
  }
162
-
163
- export { ThemeProvider, defaultColorMode, useColorSchemeVar, useTheme };
118
+ //#endregion
119
+ export { ThemeProvider$2 as ThemeProvider, ThemeProvider$2 as default };
@@ -0,0 +1,8 @@
1
+ import { useTheme as useTheme$1 } from "@primer/react";
2
+
3
+ //#region src/components/useFeatureFlaggedTheme.d.ts
4
+ declare function useTheme(): ReturnType<typeof useTheme$1>;
5
+ declare function useColorSchemeVar(values: Partial<Record<string, string>>, fallback: string): string;
6
+ //#endregion
7
+ export { useColorSchemeVar, useTheme };
8
+ //# sourceMappingURL=useFeatureFlaggedTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFeatureFlaggedTheme.d.ts","names":[],"sources":["../../src/components/useFeatureFlaggedTheme.ts"],"mappings":";;;iBAIgB,QAAA,IAAY,UAAU,QAAQ,UAAA;AAAA,iBAU9B,iBAAA,CAAkB,MAAA,EAAQ,OAAO,CAAC,MAAA,mBAAyB,QAAA"}
@@ -0,0 +1,19 @@
1
+ import { useColorSchemeVar as useColorSchemeVar$2, useTheme as useTheme$2 } from "./useTheme.js";
2
+ import { useColorSchemeVar, useTheme } from "@primer/react";
3
+ import { useFeatureFlag } from "@primer/react/experimental";
4
+ //#region src/components/useFeatureFlaggedTheme.ts
5
+ function useTheme$1() {
6
+ const enabled = useFeatureFlag("primer_react_styled_react_use_primer_theme_providers");
7
+ const styledTheme = useTheme$2();
8
+ const primerTheme = useTheme();
9
+ if (enabled) return primerTheme;
10
+ return styledTheme;
11
+ }
12
+ function useColorSchemeVar$1(values, fallback) {
13
+ const enabled = useFeatureFlag("primer_react_styled_react_use_primer_theme_providers");
14
+ const styledValue = useColorSchemeVar$2(values, fallback);
15
+ const primerValue = useColorSchemeVar(values, fallback);
16
+ return enabled ? primerValue : styledValue;
17
+ }
18
+ //#endregion
19
+ export { useColorSchemeVar$1 as useColorSchemeVar, useTheme$1 as useTheme };
@@ -0,0 +1,20 @@
1
+ import { ColorMode, ColorModeWithAuto, Theme } from "./ThemeProvider.js";
2
+ import React from "react";
3
+
4
+ //#region src/components/useTheme.d.ts
5
+ declare function useTheme(): {
6
+ theme?: Theme;
7
+ colorScheme?: string;
8
+ colorMode?: ColorModeWithAuto;
9
+ resolvedColorMode?: ColorMode;
10
+ resolvedColorScheme?: string;
11
+ dayScheme?: string;
12
+ nightScheme?: string;
13
+ setColorMode: React.Dispatch<React.SetStateAction<ColorModeWithAuto>>;
14
+ setDayScheme: React.Dispatch<React.SetStateAction<string>>;
15
+ setNightScheme: React.Dispatch<React.SetStateAction<string>>;
16
+ };
17
+ declare function useColorSchemeVar(values: Partial<Record<string, string>>, fallback: string): string;
18
+ //#endregion
19
+ export { useColorSchemeVar, useTheme };
20
+ //# sourceMappingURL=useTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTheme.d.ts","names":[],"sources":["../../src/components/useTheme.ts"],"mappings":";;;;iBAGgB,QAAA;UAAQ,KAAA;;;;;;;;;;;iBAIR,iBAAA,CAAkB,MAAA,EAAQ,OAAO,CAAC,MAAA,mBAAyB,QAAA"}
@@ -0,0 +1,12 @@
1
+ import { ThemeContext } from "./ThemeContext.js";
2
+ import React from "react";
3
+ //#region src/components/useTheme.ts
4
+ function useTheme() {
5
+ return React.useContext(ThemeContext);
6
+ }
7
+ function useColorSchemeVar(values, fallback) {
8
+ const { colorScheme = "" } = useTheme();
9
+ return values[colorScheme] ?? fallback;
10
+ }
11
+ //#endregion
12
+ export { useColorSchemeVar, useTheme };
package/dist/index.d.ts CHANGED
@@ -1,67 +1,6 @@
1
- export {
2
- /**
3
- * @deprecated Theming in JavaScript is no longer supported. Prefer using
4
- * `@primer/primitives` and CSS Modules instead.
5
- */
6
- ThemeProvider,
7
- /**
8
- * @deprecated Theming in JavaScript is no longer supported. Prefer using
9
- * `@primer/primitives` and CSS Modules instead.
10
- */
11
- useTheme,
12
- /**
13
- * @deprecated Theming in JavaScript is no longer supported. Prefer using
14
- * `@primer/primitives` and CSS Modules instead.
15
- */
16
- useColorSchemeVar,
17
- /**
18
- * @deprecated Theming in JavaScript is no longer supported. Prefer using
19
- * `@primer/primitives` and CSS Modules instead.
20
- */
21
- type ThemeProviderProps, } from './components/FeatureFlaggedTheming';
22
- export {
23
- /**
24
- * @deprecated Usage of the `sx` prop with this component is no longer
25
- * supported. Use the component from `@primer/react` with CSS Modules instead.
26
- */
27
- BaseStyles,
28
- /**
29
- * @deprecated Usage of the `sx` prop with this component is no longer
30
- * supported. Use the component from `@primer/react` with CSS Modules instead.
31
- */
32
- type BaseStylesProps, } from './components/FeatureFlaggedTheming';
33
- export {
34
- /**
35
- * @deprecated Theming in JavaScript is no longer supported. Prefer using
36
- * `@primer/primitives` and CSS Modules instead.
37
- */
38
- theme, } from '@primer/react';
39
- export {
40
- /**
41
- * @deprecated Theming in JavaScript is no longer supported. Prefer using
42
- * `@primer/primitives` and CSS Modules instead.
43
- */
44
- get as themeGet, } from './theme-get';
45
- export {
46
- /**
47
- * @deprecated Theming in JavaScript is no longer supported. Prefer using
48
- * `@primer/primitives` and CSS Modules instead.
49
- */
50
- merge,
51
- /**
52
- * @deprecated Styling with the `sx` prop is no longer supported. Use CSS
53
- * Modules instead
54
- */
55
- sx,
56
- /**
57
- * @deprecated Styling with the `sx` prop is no longer supported. Use CSS
58
- * Modules instead
59
- */
60
- type SxProp, } from './sx';
61
- export {
62
- /**
63
- * @deprecated Styling with the `sx` prop is no longer supported. Use CSS
64
- * Modules instead
65
- */
66
- type BetterSystemStyleObject, } from './sx';
67
- //# sourceMappingURL=index.d.ts.map
1
+ import { BaseStyles, BaseStylesProps, ThemeProvider, ThemeProviderProps } from "./components/FeatureFlaggedTheming.js";
2
+ import { useColorSchemeVar, useTheme } from "./components/useFeatureFlaggedTheme.js";
3
+ import { get } from "./theme-get.js";
4
+ import sx, { BetterSystemStyleObject, SxProp, merge } from "./sx.js";
5
+ import { theme } from "@primer/react";
6
+ export { BaseStyles, type BaseStylesProps, type BetterSystemStyleObject, type SxProp, ThemeProvider, type ThemeProviderProps, merge, sx, theme, get as themeGet, useColorSchemeVar, useTheme };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- export { BaseStyles, ThemeProvider, useTheme } from './components/FeatureFlaggedTheming.js';
3
- export { theme } from '@primer/react';
4
- export { get as themeGet } from './theme-get.js';
5
- export { sx } from './sx.js';
6
- export { default as merge } from 'deepmerge';
7
- export { useColorSchemeVar } from './components/ThemeProvider.js';
2
+ import { BaseStyles, ThemeProvider } from "./components/FeatureFlaggedTheming.js";
3
+ import { useColorSchemeVar, useTheme } from "./components/useFeatureFlaggedTheme.js";
4
+ import { get } from "./theme-get.js";
5
+ import sx, { merge } from "./sx.js";
6
+ import { theme } from "@primer/react";
7
+ export { BaseStyles, ThemeProvider, merge, sx, theme, get as themeGet, useColorSchemeVar, useTheme };
@@ -1,11 +1,7 @@
1
- /**
2
- * This file is originally from `@radix-ui/react-polymorphic` before the package
3
- * was deprecated. The original source for this lived in the URL below.
4
- *
5
- * @see https://github.com/radix-ui/primitives/blob/17ffcb7aaa42cbd36b3c210ba86d7d73d218e5be/packages/react/polymorphic/src/polymorphic.ts
6
- */
7
- import * as React from 'react';
8
- import type { JSX } from 'react';
1
+ import * as React$1 from "react";
2
+ import { JSX } from "react";
3
+
4
+ //#region src/polymorphic.d.ts
9
5
  type Merge<P1 = {}, P2 = {}> = Omit<P1, keyof P2> & P2;
10
6
  /**
11
7
  * Infers the OwnProps if E is a ForwardRefExoticComponentWithAs
@@ -15,25 +11,26 @@ type OwnProps<E> = E extends ForwardRefComponent<any, infer P> ? P : {};
15
11
  * Infers the JSX.IntrinsicElement if E is a ForwardRefExoticComponentWithAs
16
12
  */
17
13
  type IntrinsicElement<E> = E extends ForwardRefComponent<infer I, any> ? I : never;
18
- type ForwardRefExoticComponent<E, OwnProps> = React.ForwardRefExoticComponent<Merge<E extends React.ElementType ? React.ComponentPropsWithRef<E> : never, OwnProps & {
19
- as?: E;
14
+ type ForwardRefExoticComponent<E, OwnProps> = React$1.ForwardRefExoticComponent<Merge<E extends React$1.ElementType ? React$1.ComponentPropsWithRef<E> : never, OwnProps & {
15
+ as?: E;
20
16
  }>>;
21
17
  interface ForwardRefComponent<IntrinsicElementString, OwnProps = {}> extends ForwardRefExoticComponent<IntrinsicElementString, OwnProps> {
22
- /**
23
- * When `as` prop is passed, use this overload.
24
- * Merges original own props (without DOM props) and the inferred props
25
- * from `as` element with the own props taking precedence.
26
- *
27
- * We explicitly avoid `React.ElementType` and manually narrow the prop types
28
- * so that events are typed when using JSX.IntrinsicElements.
29
- */
30
- <As = IntrinsicElementString>(props: As extends '' ? {
31
- as: keyof JSX.IntrinsicElements;
32
- } : As extends React.ComponentType<infer P> ? Merge<P, OwnProps & {
33
- as: As;
34
- }> : As extends keyof JSX.IntrinsicElements ? Merge<JSX.IntrinsicElements[As], OwnProps & {
35
- as: As;
36
- }> : never): React.ReactElement | null;
18
+ /**
19
+ * When `as` prop is passed, use this overload.
20
+ * Merges original own props (without DOM props) and the inferred props
21
+ * from `as` element with the own props taking precedence.
22
+ *
23
+ * We explicitly avoid `React.ElementType` and manually narrow the prop types
24
+ * so that events are typed when using JSX.IntrinsicElements.
25
+ */
26
+ <As = IntrinsicElementString>(props: As extends '' ? {
27
+ as: keyof JSX.IntrinsicElements;
28
+ } : As extends React$1.ComponentType<infer P> ? Merge<P, OwnProps & {
29
+ as: As;
30
+ }> : As extends keyof JSX.IntrinsicElements ? Merge<JSX.IntrinsicElements[As], OwnProps & {
31
+ as: As;
32
+ }> : never): React$1.ReactElement | null;
37
33
  }
38
- export type { ForwardRefComponent, OwnProps, IntrinsicElement, Merge };
34
+ //#endregion
35
+ export type { ForwardRefComponent, IntrinsicElement, Merge, OwnProps };
39
36
  //# sourceMappingURL=polymorphic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"polymorphic.d.ts","sourceRoot":"","sources":["../src/polymorphic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,OAAO,CAAA;AAK9B,KAAK,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,CAAA;AAEtD;;GAEG;AACH,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;AAEvE;;GAEG;AACH,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,mBAAmB,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAElF,KAAK,yBAAyB,CAAC,CAAC,EAAE,QAAQ,IAAI,KAAK,CAAC,yBAAyB,CAC3E,KAAK,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,QAAQ,GAAG;IAAC,EAAE,CAAC,EAAE,CAAC,CAAA;CAAC,CAAC,CACjG,CAAA;AAMD,UAAU,mBAAmB,CAC3B,sBAAsB,EACtB,QAAQ,GAAG,EAAE,CAKb,SAAQ,yBAAyB,CAAC,sBAAsB,EAAE,QAAQ,CAAC;IACnE;;;;;;;OAOG;IACH,CAAC,EAAE,GAAG,sBAAsB,EAC1B,KAAK,EAAE,EAAE,SAAS,EAAE,GAChB;QAAC,EAAE,EAAE,MAAM,GAAG,CAAC,iBAAiB,CAAA;KAAC,GACjC,EAAE,SAAS,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GACrC,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG;QAAC,EAAE,EAAE,EAAE,CAAA;KAAC,CAAC,GAC7B,EAAE,SAAS,MAAM,GAAG,CAAC,iBAAiB,GACpC,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC,EAAE,QAAQ,GAAG;QAAC,EAAE,EAAE,EAAE,CAAA;KAAC,CAAC,GACrD,KAAK,GACZ,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CAC7B;AAED,YAAY,EAAC,mBAAmB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAC,CAAA"}
1
+ {"version":3,"file":"polymorphic.d.ts","names":[],"sources":["../src/polymorphic.ts"],"mappings":";;;;KAaK,KAAA,qBAA0B,IAAA,CAAK,EAAA,QAAU,EAAA,IAAM,EAAA;;;;KAK/C,QAAA,MAAc,CAAA,SAAU,mBAAmB,iBAAiB,CAAA;;;;KAK5D,gBAAA,MAAsB,CAAA,SAAU,mBAAmB,iBAAiB,CAAA;AAAA,KAEpE,yBAAA,gBAAyC,OAAA,CAAM,yBAAA,CAClD,KAAA,CAAM,CAAA,SAAU,OAAA,CAAM,WAAA,GAAc,OAAA,CAAM,qBAAA,CAAsB,CAAA,WAAY,QAAA;EAAY,EAAA,GAAK,CAAA;AAAA;AAAA,UAOrF,mBAAA,gDAOA,yBAAA,CAA0B,sBAAA,EAAwB,QAAA;EAtBvD;;;;;;;;EAAA,MA+BG,sBAAA,EACJ,KAAA,EAAO,EAAA;IACF,EAAA,QAAU,GAAA,CAAI,iBAAA;EAAA,IACf,EAAA,SAAW,OAAA,CAAM,aAAA,YACf,KAAA,CAAM,CAAA,EAAG,QAAA;IAAY,EAAA,EAAI,EAAA;EAAA,KACzB,EAAA,eAAiB,GAAA,CAAI,iBAAA,GACnB,KAAA,CAAM,GAAA,CAAI,iBAAA,CAAkB,EAAA,GAAK,QAAA;IAAY,EAAA,EAAI,EAAA;EAAA,aAExD,OAAA,CAAM,YAAA;AAAA"}
@@ -1,4 +1,8 @@
1
- import type { BackgroundProps, BorderProps, ColorProps, FlexboxProps, GridProps, LayoutProps, PositionProps, ShadowProps, SpaceProps, TypographyProps } from 'styled-system';
2
- import type { SxProp } from './sx';
3
- export type StyledProps = SxProp & SpaceProps & ColorProps & TypographyProps & LayoutProps & FlexboxProps & GridProps & BackgroundProps & BorderProps & PositionProps & ShadowProps;
1
+ import { SxProp } from "./sx.js";
2
+ import { BackgroundProps, BorderProps, ColorProps, FlexboxProps, GridProps, LayoutProps, PositionProps, ShadowProps, SpaceProps, TypographyProps } from "styled-system";
3
+
4
+ //#region src/styled-props.d.ts
5
+ type StyledProps = SxProp & SpaceProps & ColorProps & TypographyProps & LayoutProps & FlexboxProps & GridProps & BackgroundProps & BorderProps & PositionProps & ShadowProps;
6
+ //#endregion
7
+ export { StyledProps };
4
8
  //# sourceMappingURL=styled-props.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styled-props.d.ts","sourceRoot":"","sources":["../src/styled-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,UAAU,EACV,YAAY,EACZ,SAAS,EACT,WAAW,EACX,aAAa,EACb,WAAW,EACX,UAAU,EACV,eAAe,EAChB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,MAAM,CAAA;AAEhC,MAAM,MAAM,WAAW,GAAG,MAAM,GAC9B,UAAU,GACV,UAAU,GACV,eAAe,GACf,WAAW,GACX,YAAY,GACZ,SAAS,GACT,eAAe,GACf,WAAW,GACX,aAAa,GACb,WAAW,CAAA"}
1
+ {"version":3,"file":"styled-props.d.ts","names":[],"sources":["../src/styled-props.ts"],"mappings":";;;;KAcY,WAAA,GAAc,MAAA,GACxB,UAAA,GACA,UAAA,GACA,eAAA,GACA,WAAA,GACA,YAAA,GACA,SAAA,GACA,eAAA,GACA,WAAA,GACA,aAAA,GACA,WAAA"}
package/dist/sx.d.ts CHANGED
@@ -1,26 +1,26 @@
1
- import type { SystemCssProperties, SystemStyleObject } from '@styled-system/css';
2
- import type { ThemeColorPaths, ThemeShadowPaths } from '@primer/react';
3
- import type { ColorProps, BorderColorProps, ShadowProps } from 'styled-system';
4
- import merge from 'deepmerge';
5
- export type BetterCssProperties = {
6
- [K in keyof SystemCssProperties]: K extends keyof ColorProps ? ThemeColorPaths | SystemCssProperties[K] : K extends keyof BorderColorProps ? ThemeColorPaths | SystemCssProperties[K] : K extends keyof ShadowProps ? ThemeShadowPaths | SystemCssProperties[K] : SystemCssProperties[K];
7
- };
8
- export type CSSCustomProperties = {
9
- [key: `--${string}`]: string | number;
1
+ import { BorderColorProps, ColorProps, ShadowProps } from "styled-system";
2
+ import { ThemeColorPaths, ThemeShadowPaths } from "@primer/react";
3
+ import { SystemCssProperties, SystemStyleObject } from "@styled-system/css";
4
+ import merge from "deepmerge";
5
+
6
+ //#region src/sx.d.ts
7
+ type BetterCssProperties = { [K in keyof SystemCssProperties]: K extends keyof ColorProps ? ThemeColorPaths | SystemCssProperties[K] : K extends keyof BorderColorProps ? ThemeColorPaths | SystemCssProperties[K] : K extends keyof ShadowProps ? ThemeShadowPaths | SystemCssProperties[K] : SystemCssProperties[K] };
8
+ type CSSCustomProperties = {
9
+ [key: `--${string}`]: string | number;
10
10
  };
11
11
  type CSSSelectorObject = {
12
- [cssSelector: string]: SystemStyleObject | CSSCustomProperties;
12
+ [cssSelector: string]: SystemStyleObject | CSSCustomProperties;
13
13
  };
14
- export type BetterSystemStyleObject = BetterCssProperties | SystemStyleObject | CSSCustomProperties | CSSSelectorObject;
15
- export interface SxProp {
16
- /**
17
- * @deprecated The `sx` prop is deprecated. Replace with a `div` or
18
- * appropriate HTML element instead, with a CSS class for styling.
19
- * @see https://github.com/primer/react/blob/main/contributor-docs/migration-from-box.md
20
- * */
21
- sx?: BetterSystemStyleObject;
14
+ type BetterSystemStyleObject = BetterCssProperties | SystemStyleObject | CSSCustomProperties | CSSSelectorObject;
15
+ interface SxProp {
16
+ /**
17
+ * @deprecated The `sx` prop is deprecated. Replace with a `div` or
18
+ * appropriate HTML element instead, with a CSS class for styling.
19
+ * @see https://github.com/primer/react/blob/main/contributor-docs/migration-from-box.md
20
+ * */
21
+ sx?: BetterSystemStyleObject;
22
22
  }
23
23
  declare const sx: (props: SxProp) => import("@styled-system/css").CssFunctionReturnType;
24
- export default sx;
25
- export { merge, sx };
24
+ //#endregion
25
+ export { BetterCssProperties, BetterSystemStyleObject, CSSCustomProperties, SxProp, sx as default, sx, merge };
26
26
  //# sourceMappingURL=sx.d.ts.map
package/dist/sx.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sx.d.ts","sourceRoot":"","sources":["../src/sx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,mBAAmB,EAAE,iBAAiB,EAAC,MAAM,oBAAoB,CAAA;AAE9E,OAAO,KAAK,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAA;AACpE,OAAO,KAAK,EAAC,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAC,MAAM,eAAe,CAAA;AAC5E,OAAO,KAAK,MAAM,WAAW,CAAA;AAE7B,MAAM,MAAM,mBAAmB,GAAG;KAC/B,CAAC,IAAI,MAAM,mBAAmB,GAAG,CAAC,SAAS,MAAM,UAAU,GACxD,eAAe,GAAG,mBAAmB,CAAC,CAAC,CAAC,GACxC,CAAC,SAAS,MAAM,gBAAgB,GAC9B,eAAe,GAAG,mBAAmB,CAAC,CAAC,CAAC,GACxC,CAAC,SAAS,MAAM,WAAW,GACzB,gBAAgB,GAAG,mBAAmB,CAAC,CAAC,CAAC,GACzC,mBAAmB,CAAC,CAAC,CAAC;CAC/B,CAAA;AAGD,MAAM,MAAM,mBAAmB,GAAG;IAChC,CAAC,GAAG,EAAE,KAAK,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAAA;CACtC,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,GAAG,mBAAmB,CAAA;CAC/D,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,iBAAiB,CAAA;AAEvH,MAAM,WAAW,MAAM;IACrB;;;;SAIK;IACL,EAAE,CAAC,EAAE,uBAAuB,CAAA;CAC7B;AAED,QAAA,MAAM,EAAE,GAAI,OAAO,MAAM,uDAAkB,CAAA;AAE3C,eAAe,EAAE,CAAA;AAEjB,OAAO,EAAC,KAAK,EAAE,EAAE,EAAC,CAAA"}
1
+ {"version":3,"file":"sx.d.ts","names":[],"sources":["../src/sx.ts"],"mappings":";;;;;;KAMY,mBAAA,iBACE,mBAAA,GAAsB,CAAA,eAAgB,UAAA,GAC9C,eAAA,GAAkB,mBAAA,CAAoB,CAAA,IACtC,CAAA,eAAgB,gBAAA,GACd,eAAA,GAAkB,mBAAA,CAAoB,CAAA,IACtC,CAAA,eAAgB,WAAA,GACd,gBAAA,GAAmB,mBAAA,CAAoB,CAAA,IACvC,mBAAA,CAAoB,CAAA;AAAA,KAIlB,mBAAA;EAAA,CACT,GAAkB;AAAA;AAAA,KAGhB,iBAAA;EAAA,CACF,WAAA,WAAsB,iBAAA,GAAoB,mBAAmB;AAAA;AAAA,KAGpD,uBAAA,GAA0B,mBAAA,GAAsB,iBAAA,GAAoB,mBAAA,GAAsB,iBAAA;AAAA,UAErF,MAAA;EAlBX;;;;;EAwBJ,EAAA,GAAK,uBAAuB;AAAA;AAAA,cAGxB,EAAA,GAAM,KAAA,EAAO,MAAM,kCAAA,qBAAA"}
package/dist/sx.js CHANGED
@@ -1,8 +1,6 @@
1
- import css from '@styled-system/css';
2
- export { default as merge } from 'deepmerge';
3
-
4
- // Support CSS custom properties in the `sx` prop
5
-
6
- const sx = props => css(props.sx);
7
-
8
- export { sx };
1
+ import merge from "deepmerge";
2
+ import css from "@styled-system/css";
3
+ //#region src/sx.ts
4
+ const sx = (props) => css(props.sx);
5
+ //#endregion
6
+ export { sx as default, sx, merge };
@@ -1,2 +1,5 @@
1
- export declare const get: (key: string) => (props: any) => any;
1
+ //#region src/theme-get.d.ts
2
+ declare const get: (key: string) => (props: any) => any;
3
+ //#endregion
4
+ export { get };
2
5
  //# sourceMappingURL=theme-get.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme-get.d.ts","sourceRoot":"","sources":["../src/theme-get.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,GAAG,GAAI,KAAK,MAAM,wBAAsC,CAAA"}
1
+ {"version":3,"file":"theme-get.d.ts","names":[],"sources":["../src/theme-get.ts"],"mappings":";cAOa,GAAA,GAAO,GAAA,cAAW,KAAA"}
package/dist/theme-get.js CHANGED
@@ -1,10 +1,8 @@
1
- import { themeGet } from '@styled-system/theme-get';
2
- import * as styledSystem from 'styled-system';
3
- import { theme } from '@primer/react';
4
-
5
- const {
6
- get: getKey
7
- } = styledSystem;
8
- const get = key => themeGet(key, getKey(theme, key));
9
-
1
+ import { theme } from "@primer/react";
2
+ import { themeGet } from "@styled-system/theme-get";
3
+ import * as styledSystem from "styled-system";
4
+ //#region src/theme-get.ts
5
+ const { get: getKey } = styledSystem;
6
+ const get = (key) => themeGet(key, getKey(theme, key));
7
+ //#endregion
10
8
  export { get };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/styled-react",
3
- "version": "1.1.0-rc.aaa3a8993",
3
+ "version": "1.1.0-rc.b8979ee01",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -38,16 +38,18 @@
38
38
  "styled-system": "^5.1.5"
39
39
  },
40
40
  "devDependencies": {
41
+ "@babel/core": "^7.29.7",
41
42
  "@babel/preset-react": "^7.28.5",
42
43
  "@babel/preset-typescript": "^7.28.5",
43
44
  "@primer/primitives": "10.x || 11.x",
44
45
  "@primer/react": "^38.26.0",
45
- "@rollup/plugin-babel": "^6.1.0",
46
- "@storybook/react-vite": "^10.3.3",
46
+ "@rolldown/plugin-babel": "^0.2.3",
47
+ "@storybook/react-vite": "^10.4.2",
48
+ "@types/babel__core": "^7.20.5",
47
49
  "@types/react": "18.3.11",
48
50
  "@types/react-dom": "18.3.1",
49
51
  "@types/styled-components": "^5.1.26",
50
- "@vitejs/plugin-react": "^4.3.3",
52
+ "@vitejs/plugin-react": "^6.0.2",
51
53
  "babel-plugin-react-compiler": "^1.0.0",
52
54
  "babel-plugin-styled-components": "2.1.4",
53
55
  "postcss-preset-primer": "^0.0.0",
@@ -56,8 +58,8 @@
56
58
  "react-compiler-runtime": "^1.0.0",
57
59
  "react-dom": "18.3.1",
58
60
  "rimraf": "^6.0.1",
59
- "rollup": "4.59.0",
60
- "rollup-plugin-typescript2": "^0.36.0",
61
+ "rolldown": "^1.1.2",
62
+ "rolldown-plugin-dts": "^0.26.0",
61
63
  "styled-components": "5.3.11",
62
64
  "typescript": "^6.0.3"
63
65
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO;AACL;;;GAGG;AACH,aAAa;AAEb;;;GAGG;AACH,QAAQ;AAER;;;GAGG;AACH,iBAAiB;AAEjB;;;GAGG;AACH,KAAK,kBAAkB,GACxB,MAAM,oCAAoC,CAAA;AAE3C,OAAO;AACL;;;GAGG;AACH,UAAU;AAEV;;;GAGG;AACH,KAAK,eAAe,GACrB,MAAM,oCAAoC,CAAA;AAE3C,OAAO;AACL;;;GAGG;AACH,KAAK,GACN,MAAM,eAAe,CAAA;AAEtB,OAAO;AACL;;;GAGG;AACH,GAAG,IAAI,QAAQ,GAChB,MAAM,aAAa,CAAA;AAEpB,OAAO;AACL;;;GAGG;AACH,KAAK;AAEL;;;GAGG;AACH,EAAE;AAEF;;;GAGG;AACH,KAAK,MAAM,GACZ,MAAM,MAAM,CAAA;AAEb,OAAO;AACL;;;GAGG;AACH,KAAK,uBAAuB,GAC7B,MAAM,MAAM,CAAA"}