@primer/styled-react 1.1.0-rc.c2875a86b → 1.1.0-rc.cadbf849a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/BaseStyles.d.ts +23 -14
- package/dist/components/BaseStyles.d.ts.map +1 -1
- package/dist/components/BaseStyles.js +27 -48
- package/dist/components/FeatureFlaggedTheming.d.ts +11 -7
- package/dist/components/FeatureFlaggedTheming.d.ts.map +1 -1
- package/dist/components/FeatureFlaggedTheming.js +20 -33
- package/dist/components/ThemeContext.d.ts +17 -13
- package/dist/components/ThemeContext.d.ts.map +1 -1
- package/dist/components/ThemeContext.js +7 -7
- package/dist/components/ThemeProvider.d.ts +22 -19
- package/dist/components/ThemeProvider.d.ts.map +1 -1
- package/dist/components/ThemeProvider.js +103 -134
- package/dist/components/useFeatureFlaggedTheme.d.ts +7 -3
- package/dist/components/useFeatureFlaggedTheme.d.ts.map +1 -1
- package/dist/components/useFeatureFlaggedTheme.js +17 -19
- package/dist/components/useTheme.d.ts +18 -13
- package/dist/components/useTheme.d.ts.map +1 -1
- package/dist/components/useTheme.js +7 -9
- package/dist/index.d.ts +6 -68
- package/dist/index.js +6 -6
- package/dist/polymorphic.d.ts +23 -26
- package/dist/polymorphic.d.ts.map +1 -1
- package/dist/styled-props.d.ts +7 -3
- package/dist/styled-props.d.ts.map +1 -1
- package/dist/sx.d.ts +20 -20
- package/dist/sx.d.ts.map +1 -1
- package/dist/sx.js +6 -8
- package/dist/theme-get.d.ts +4 -1
- package/dist/theme-get.d.ts.map +1 -1
- package/dist/theme-get.js +7 -9
- package/package.json +5 -5
- package/dist/index.d.ts.map +0 -1
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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","
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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","
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { jsx } from
|
|
6
|
-
|
|
7
|
-
const ThemeProvider = ({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
25
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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","
|
|
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
|
|
2
|
-
|
|
3
|
-
const ThemeContext = /*#__PURE__*/React.createContext({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
21
|
-
|
|
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","
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import { theme, useId, useSyncedState } from
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { jsx, jsxs } from
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
81
|
+
return React.useSyncExternalStore(subscribeToSystemColorMode, getSystemColorMode, () => "day");
|
|
103
82
|
}
|
|
104
83
|
function getSystemColorMode() {
|
|
105
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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,
|
|
118
|
+
//#endregion
|
|
119
|
+
export { ThemeProvider$2 as ThemeProvider, ThemeProvider$2 as default };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { useTheme as
|
|
2
|
-
|
|
3
|
-
|
|
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","
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
function useTheme() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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","
|
|
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
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { ThemeContext } from "./ThemeContext.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
//#region src/components/useTheme.ts
|
|
4
4
|
function useTheme() {
|
|
5
|
-
|
|
5
|
+
return React.useContext(ThemeContext);
|
|
6
6
|
}
|
|
7
7
|
function useColorSchemeVar(values, fallback) {
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {
|
|
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 };
|
package/dist/polymorphic.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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","
|
|
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"}
|
package/dist/styled-props.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
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","
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import merge from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
12
|
+
[cssSelector: string]: SystemStyleObject | CSSCustomProperties;
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
25
|
-
export {
|
|
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","
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 };
|
package/dist/theme-get.d.ts
CHANGED
package/dist/theme-get.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-get.d.ts","
|
|
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 {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
|
|
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.
|
|
3
|
+
"version": "1.1.0-rc.cadbf849a",
|
|
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
|
-
"@
|
|
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
|
-
"
|
|
63
|
-
"
|
|
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
|
},
|
package/dist/index.d.ts.map
DELETED
|
@@ -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"}
|