@primer/styled-react 1.1.0-rc.e2fa16f13 → 1.1.0-rc.e5900155c

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 './useTheme.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,8 +1,12 @@
1
- import type React from 'react';
2
- import type { ThemeProviderProps as StyledThemeProviderProps } from './ThemeProvider';
3
- import type { BaseStylesProps as StyledBaseStylesProps } from './BaseStyles';
4
- export type ThemeProviderProps = StyledThemeProviderProps;
5
- export type BaseStylesProps = StyledBaseStylesProps;
6
- export declare const ThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderProps>>;
7
- 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 };
8
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;AAQ9B,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,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,35 +1,22 @@
1
- import { BaseStyles as BaseStyles$1, ThemeProvider as ThemeProvider$1 } from '@primer/react';
2
- import { useFeatureFlag } from '@primer/react/experimental';
3
- import { ThemeProvider as ThemeProvider$2 } from './ThemeProvider.js';
4
- import { BaseStyles as BaseStyles$2 } from './BaseStyles.js';
5
- import { jsx } from 'react/jsx-runtime';
6
-
7
- const ThemeProvider = ({
8
- children,
9
- ...props
10
- }) => {
11
- const enabled = useFeatureFlag('primer_react_styled_react_use_primer_theme_providers');
12
- if (enabled) {
13
- return /*#__PURE__*/jsx(ThemeProvider$1, {
14
- ...props,
15
- children: children
16
- });
17
- }
18
- return /*#__PURE__*/jsx(ThemeProvider$2, {
19
- ...props,
20
- children: children
21
- });
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
+ });
22
16
  };
23
- function BaseStyles(props) {
24
- const enabled = useFeatureFlag('primer_react_styled_react_use_primer_theme_providers');
25
- if (enabled) {
26
- return /*#__PURE__*/jsx(BaseStyles$1, {
27
- ...props
28
- });
29
- }
30
- return /*#__PURE__*/jsx(BaseStyles$2, {
31
- ...props
32
- });
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 });
33
20
  }
34
-
35
- export { BaseStyles, ThemeProvider };
21
+ //#endregion
22
+ export { BaseStyles$1 as BaseStyles, ThemeProvider$1 as ThemeProvider };
@@ -1,15 +1,19 @@
1
- import React from 'react';
2
- import type { ColorMode, ColorModeWithAuto, Theme } from './ThemeProvider';
3
- export declare const ThemeContext: React.Context<{
4
- theme?: Theme;
5
- colorScheme?: string;
6
- colorMode?: ColorModeWithAuto;
7
- resolvedColorMode?: ColorMode;
8
- resolvedColorScheme?: string;
9
- dayScheme?: string;
10
- nightScheme?: string;
11
- setColorMode: React.Dispatch<React.SetStateAction<ColorModeWithAuto>>;
12
- setDayScheme: React.Dispatch<React.SetStateAction<string>>;
13
- setNightScheme: React.Dispatch<React.SetStateAction<string>>;
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>>;
14
16
  }>;
17
+ //#endregion
18
+ export { ThemeContext };
15
19
  //# sourceMappingURL=ThemeContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../../src/components/ThemeContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAC,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAExE,eAAO,MAAM,YAAY;YACf,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;EAK5D,CAAA"}
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"}
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
-
3
- const ThemeContext = /*#__PURE__*/React.createContext({
4
- setColorMode: () => null,
5
- setDayScheme: () => null,
6
- setNightScheme: () => null
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
7
  });
8
-
8
+ //#endregion
9
9
  export { ThemeContext };
@@ -1,22 +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
- export 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;
8
+ type ColorMode = 'day' | 'night' | 'light' | 'dark';
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 default ThemeProvider;
22
+ declare const ThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderProps>>;
23
+ //#endregion
24
+ export { ColorMode, ColorModeWithAuto, Theme, ThemeProvider, ThemeProvider as default, ThemeProviderProps, defaultColorMode };
22
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;AAOzB,eAAO,MAAM,gBAAgB,QAAQ,CAAA;AAKrC,MAAM,MAAM,KAAK,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,CAAA;AACxC,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAA;AAC1D,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;AA6BD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAyE/E,CAAA;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,150 +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 { ThemeContext } from './ThemeContext.js';
6
- import { useTheme } from './useTheme.js';
7
- import { jsx, jsxs } from 'react/jsx-runtime';
8
-
9
- const defaultColorMode = 'day';
10
- const defaultDayScheme = 'light';
11
- const defaultNightScheme = 'dark';
12
-
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
-
15
- // inspired from __NEXT_DATA__, we use application/json to avoid CSRF policy with inline scripts
16
- 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();
17
11
  const emptyHandoff = {};
18
- const getServerHandoff = id => {
19
- if (typeof document === 'undefined') return emptyHandoff;
20
- const cached = serverHandoffCache.get(id);
21
- if (cached !== undefined) return cached;
22
- try {
23
- const serverData = document.getElementById(`__PRIMER_DATA_${id}__`)?.textContent;
24
- if (serverData) {
25
- const parsed = JSON.parse(serverData);
26
- serverHandoffCache.set(id, parsed);
27
- return parsed;
28
- }
29
- } catch (_error) {
30
- // if document/element does not exist or JSON is invalid, supress error
31
- }
32
- const empty = {};
33
- serverHandoffCache.set(id, empty);
34
- 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;
35
27
  };
36
28
  const emptySubscribe = () => () => {};
37
- const ThemeProvider = ({
38
- children,
39
- ...props
40
- }) => {
41
- // Get fallback values from parent ThemeProvider (if exists)
42
- const {
43
- theme: fallbackTheme,
44
- colorMode: fallbackColorMode,
45
- dayScheme: fallbackDayScheme,
46
- nightScheme: fallbackNightScheme
47
- } = useTheme();
48
-
49
- // Initialize state
50
- const theme$1 = props.theme ?? fallbackTheme ?? theme;
51
- const uniqueDataId = useId();
52
- const [colorMode, setColorMode] = useSyncedState(props.colorMode ?? fallbackColorMode ?? defaultColorMode);
53
- const [dayScheme, setDayScheme] = useSyncedState(props.dayScheme ?? fallbackDayScheme ?? defaultDayScheme);
54
- const [nightScheme, setNightScheme] = useSyncedState(props.nightScheme ?? fallbackNightScheme ?? defaultNightScheme);
55
- const systemColorMode = useSystemColorMode();
56
- const clientColorMode = resolveColorMode(colorMode, systemColorMode);
57
- // During SSR/hydration, use the server-rendered color mode from the handoff script tag
58
- // to avoid mismatches. After hydration, resolve from client state.
59
- const resolvedColorMode = React.useSyncExternalStore(emptySubscribe, () => clientColorMode, () => getServerHandoff(uniqueDataId).resolvedServerColorMode ?? clientColorMode);
60
- const colorScheme = chooseColorScheme(resolvedColorMode, dayScheme, nightScheme);
61
- const {
62
- resolvedTheme,
63
- resolvedColorScheme
64
- } = React.useMemo(() => applyColorScheme(theme$1, colorScheme), [theme$1, colorScheme]);
65
- const contextValue = React.useMemo(() => ({
66
- theme: resolvedTheme,
67
- colorScheme,
68
- colorMode,
69
- resolvedColorMode,
70
- resolvedColorScheme,
71
- dayScheme,
72
- nightScheme,
73
- setColorMode,
74
- setDayScheme,
75
- setNightScheme
76
- }), [resolvedTheme, colorScheme, colorMode, resolvedColorMode, resolvedColorScheme, dayScheme, nightScheme, setColorMode, setDayScheme, setNightScheme]);
77
- return /*#__PURE__*/jsx(ThemeContext.Provider, {
78
- value: contextValue,
79
- children: /*#__PURE__*/jsxs(ThemeProvider$1, {
80
- theme: resolvedTheme,
81
- children: [children, props.preventSSRMismatch ? /*#__PURE__*/jsx("script", {
82
- type: "application/json",
83
- id: `__PRIMER_DATA_${uniqueDataId}__`,
84
- dangerouslySetInnerHTML: {
85
- __html: JSON.stringify({
86
- resolvedServerColorMode: resolvedColorMode
87
- })
88
- }
89
- }) : null]
90
- })
91
- });
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
+ });
92
74
  };
93
75
  function subscribeToSystemColorMode(callback) {
94
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
95
- const media = window?.matchMedia?.('(prefers-color-scheme: dark)');
96
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
97
- media?.addEventListener('change', callback);
98
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
99
- 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);
100
79
  }
101
80
  function useSystemColorMode() {
102
- return React.useSyncExternalStore(subscribeToSystemColorMode, getSystemColorMode, () => 'day');
81
+ return React.useSyncExternalStore(subscribeToSystemColorMode, getSystemColorMode, () => "day");
103
82
  }
104
83
  function getSystemColorMode() {
105
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
106
- return window?.matchMedia?.('(prefers-color-scheme: dark)')?.matches ? 'night' : 'day';
84
+ return window?.matchMedia?.("(prefers-color-scheme: dark)")?.matches ? "night" : "day";
107
85
  }
108
86
  function resolveColorMode(colorMode, systemColorMode) {
109
- switch (colorMode) {
110
- case 'auto':
111
- return systemColorMode;
112
- default:
113
- return colorMode;
114
- }
87
+ switch (colorMode) {
88
+ case "auto": return systemColorMode;
89
+ default: return colorMode;
90
+ }
115
91
  }
116
92
  function chooseColorScheme(colorMode, dayScheme, nightScheme) {
117
- switch (colorMode) {
118
- case 'day':
119
- case 'light':
120
- return dayScheme;
121
- case 'dark':
122
- case 'night':
123
- return nightScheme;
124
- }
93
+ switch (colorMode) {
94
+ case "day":
95
+ case "light": return dayScheme;
96
+ case "dark":
97
+ case "night": return nightScheme;
98
+ }
125
99
  }
126
100
  function applyColorScheme(theme, colorScheme) {
127
- if (!theme.colorSchemes) {
128
- return {
129
- resolvedTheme: theme,
130
- resolvedColorScheme: undefined
131
- };
132
- }
133
- if (!theme.colorSchemes[colorScheme]) {
134
- // eslint-disable-next-line no-console
135
- console.error(`\`${colorScheme}\` scheme not defined in \`theme.colorSchemes\``);
136
-
137
- // Apply the first defined color scheme
138
- const defaultColorScheme = Object.keys(theme.colorSchemes)[0];
139
- return {
140
- resolvedTheme: deepmerge(theme, theme.colorSchemes[defaultColorScheme]),
141
- resolvedColorScheme: defaultColorScheme
142
- };
143
- }
144
- return {
145
- resolvedTheme: deepmerge(theme, theme.colorSchemes[colorScheme]),
146
- resolvedColorScheme: colorScheme
147
- };
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
+ };
148
117
  }
149
-
150
- export { ThemeProvider, defaultColorMode };
118
+ //#endregion
119
+ export { ThemeProvider$2 as ThemeProvider, ThemeProvider$2 as default };
@@ -1,4 +1,8 @@
1
- import { useTheme as primerUseTheme } from '@primer/react';
2
- export declare function useTheme(): ReturnType<typeof primerUseTheme>;
3
- export declare function useColorSchemeVar(values: Partial<Record<string, string>>, fallback: string): string;
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 };
4
8
  //# sourceMappingURL=useFeatureFlaggedTheme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFeatureFlaggedTheme.d.ts","sourceRoot":"","sources":["../../src/components/useFeatureFlaggedTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,QAAQ,IAAI,cAAc,EAAC,MAAM,eAAe,CAAA;AAItG,wBAAgB,QAAQ,IAAI,UAAU,CAAC,OAAO,cAAc,CAAC,CAQ5D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,UAK1F"}
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"}
@@ -1,21 +1,19 @@
1
- import { useColorSchemeVar as useColorSchemeVar$2, useTheme as useTheme$2 } from '@primer/react';
2
- import { useFeatureFlag } from '@primer/react/experimental';
3
- import { useColorSchemeVar as useColorSchemeVar$1, useTheme as useTheme$1 } from './useTheme.js';
4
-
5
- function useTheme() {
6
- const enabled = useFeatureFlag('primer_react_styled_react_use_primer_theme_providers');
7
- const styledTheme = useTheme$1();
8
- const primerTheme = useTheme$2();
9
- if (enabled) {
10
- return primerTheme;
11
- }
12
- return styledTheme;
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;
13
11
  }
14
- function useColorSchemeVar(values, fallback) {
15
- const enabled = useFeatureFlag('primer_react_styled_react_use_primer_theme_providers');
16
- const styledValue = useColorSchemeVar$1(values, fallback);
17
- const primerValue = useColorSchemeVar$2(values, fallback);
18
- return enabled ? primerValue : styledValue;
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;
19
17
  }
20
-
21
- export { useColorSchemeVar, useTheme };
18
+ //#endregion
19
+ export { useColorSchemeVar$1 as useColorSchemeVar, useTheme$1 as useTheme };
@@ -1,15 +1,20 @@
1
- import React from 'react';
2
- export declare function useTheme(): {
3
- theme?: import("./ThemeProvider").Theme;
4
- colorScheme?: string;
5
- colorMode?: import("./ThemeProvider").ColorModeWithAuto;
6
- resolvedColorMode?: import("./ThemeProvider").ColorMode;
7
- resolvedColorScheme?: string;
8
- dayScheme?: string;
9
- nightScheme?: string;
10
- setColorMode: React.Dispatch<React.SetStateAction<import("./ThemeProvider").ColorModeWithAuto>>;
11
- setDayScheme: React.Dispatch<React.SetStateAction<string>>;
12
- setNightScheme: React.Dispatch<React.SetStateAction<string>>;
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>>;
13
16
  };
14
- export declare function useColorSchemeVar(values: Partial<Record<string, string>>, fallback: string): string;
17
+ declare function useColorSchemeVar(values: Partial<Record<string, string>>, fallback: string): string;
18
+ //#endregion
19
+ export { useColorSchemeVar, useTheme };
15
20
  //# sourceMappingURL=useTheme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/components/useTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,wBAAgB,QAAQ;;;;;;;;;;;EAEvB;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,UAG1F"}
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"}
@@ -1,14 +1,12 @@
1
- import React from 'react';
2
- import { ThemeContext } from './ThemeContext.js';
3
-
1
+ import { ThemeContext } from "./ThemeContext.js";
2
+ import React from "react";
3
+ //#region src/components/useTheme.ts
4
4
  function useTheme() {
5
- return React.useContext(ThemeContext);
5
+ return React.useContext(ThemeContext);
6
6
  }
7
7
  function useColorSchemeVar(values, fallback) {
8
- const {
9
- colorScheme = ''
10
- } = useTheme();
11
- return values[colorScheme] ?? fallback;
8
+ const { colorScheme = "" } = useTheme();
9
+ return values[colorScheme] ?? fallback;
12
10
  }
13
-
11
+ //#endregion
14
12
  export { useColorSchemeVar, useTheme };
package/dist/index.d.ts CHANGED
@@ -1,68 +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
- type ThemeProviderProps, } from './components/FeatureFlaggedTheming';
12
- export {
13
- /**
14
- * @deprecated Theming in JavaScript is no longer supported. Prefer using
15
- * `@primer/primitives` and CSS Modules instead.
16
- */
17
- useTheme,
18
- /**
19
- * @deprecated Theming in JavaScript is no longer supported. Prefer using
20
- * `@primer/primitives` and CSS Modules instead.
21
- */
22
- useColorSchemeVar, } from './components/useFeatureFlaggedTheme';
23
- export {
24
- /**
25
- * @deprecated Usage of the `sx` prop with this component is no longer
26
- * supported. Use the component from `@primer/react` with CSS Modules instead.
27
- */
28
- BaseStyles,
29
- /**
30
- * @deprecated Usage of the `sx` prop with this component is no longer
31
- * supported. Use the component from `@primer/react` with CSS Modules instead.
32
- */
33
- type BaseStylesProps, } from './components/FeatureFlaggedTheming';
34
- export {
35
- /**
36
- * @deprecated Theming in JavaScript is no longer supported. Prefer using
37
- * `@primer/primitives` and CSS Modules instead.
38
- */
39
- theme, } from '@primer/react';
40
- export {
41
- /**
42
- * @deprecated Theming in JavaScript is no longer supported. Prefer using
43
- * `@primer/primitives` and CSS Modules instead.
44
- */
45
- get as themeGet, } from './theme-get';
46
- export {
47
- /**
48
- * @deprecated Theming in JavaScript is no longer supported. Prefer using
49
- * `@primer/primitives` and CSS Modules instead.
50
- */
51
- merge,
52
- /**
53
- * @deprecated Styling with the `sx` prop is no longer supported. Use CSS
54
- * Modules instead
55
- */
56
- sx,
57
- /**
58
- * @deprecated Styling with the `sx` prop is no longer supported. Use CSS
59
- * Modules instead
60
- */
61
- type SxProp, } from './sx';
62
- export {
63
- /**
64
- * @deprecated Styling with the `sx` prop is no longer supported. Use CSS
65
- * Modules instead
66
- */
67
- type BetterSystemStyleObject, } from './sx';
68
- //# 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 } from './components/FeatureFlaggedTheming.js';
3
- export { useColorSchemeVar, useTheme } from './components/useFeatureFlaggedTheme.js';
4
- export { theme } from '@primer/react';
5
- export { get as themeGet } from './theme-get.js';
6
- export { sx } from './sx.js';
7
- export { default as merge } from 'deepmerge';
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.e2fa16f13",
3
+ "version": "1.1.0-rc.e5900155c",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -44,8 +44,7 @@
44
44
  "@primer/primitives": "10.x || 11.x",
45
45
  "@primer/react": "^38.26.0",
46
46
  "@rolldown/plugin-babel": "^0.2.3",
47
- "@rollup/plugin-babel": "^6.1.0",
48
- "@storybook/react-vite": "^10.4.2",
47
+ "@storybook/react-vite": "^10.4.6",
49
48
  "@types/babel__core": "^7.20.5",
50
49
  "@types/react": "18.3.11",
51
50
  "@types/react-dom": "18.3.1",
@@ -59,8 +58,9 @@
59
58
  "react-compiler-runtime": "^1.0.0",
60
59
  "react-dom": "18.3.1",
61
60
  "rimraf": "^6.0.1",
62
- "rollup": "4.59.0",
63
- "rollup-plugin-typescript2": "^0.36.0",
61
+ "rolldown": "^1.1.2",
62
+ "rolldown-plugin-dts": "^0.26.0",
63
+ "rolldown-plugin-preserve-directives": "^0.0.0",
64
64
  "styled-components": "5.3.11",
65
65
  "typescript": "^6.0.3"
66
66
  },
@@ -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,KAAK,kBAAkB,GACxB,MAAM,oCAAoC,CAAA;AAE3C,OAAO;AACL;;;GAGG;AACH,QAAQ;AAER;;;GAGG;AACH,iBAAiB,GAClB,MAAM,qCAAqC,CAAA;AAE5C,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"}