@hopper-ui/styled-system 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/StyledSystemProvider.css +132 -1
- package/dist/StyledSystemProvider.d.ts +42 -4
- package/dist/StyledSystemProvider.js +26 -26
- package/dist/chunk-3YM73BQP.js +6 -0
- package/dist/chunk-7KCN3W6N.js +11 -0
- package/dist/chunk-AHDDZ2BQ.js +28 -0
- package/dist/chunk-BEEGWFNF.js +32 -0
- package/dist/chunk-GRF2SIQE.js +59 -0
- package/dist/chunk-GYREQTEK.js +30 -0
- package/dist/chunk-I37Y2R7V.js +4 -0
- package/dist/chunk-J4KAMS5Q.js +270 -0
- package/dist/chunk-JFESGV6Z.js +26 -0
- package/dist/chunk-JM7JTLPS.js +84 -0
- package/dist/chunk-KUUJ37DW.js +96 -0
- package/dist/chunk-LU33LZMJ.js +55 -0
- package/dist/chunk-O7PTTVQH.js +715 -0
- package/dist/chunk-Q3NLRNZN.js +881 -0
- package/dist/chunk-QWLE5PCU.js +29 -0
- package/dist/chunk-RIORU7JO.js +28 -0
- package/dist/chunk-S33PIM5T.js +41 -0
- package/dist/chunk-STEDL5VQ.js +25 -0
- package/dist/chunk-U3SI5QXV.js +911 -0
- package/dist/chunk-U5R6ZXH3.js +46 -0
- package/dist/chunk-V7X6ANEM.js +14 -0
- package/dist/chunk-X5OXC6DN.js +9 -0
- package/dist/chunk-XTX4KVWI.js +19 -0
- package/dist/chunk-XUHDFZZL.js +10 -0
- package/dist/chunk-YPIK2HRL.js +6 -0
- package/dist/chunk-ZFDLWGCR.js +39 -0
- package/dist/chunk-ZUVKM5DV.js +13 -0
- package/dist/color-scheme/ColorSchemeContext.d.ts +12 -0
- package/dist/color-scheme/ColorSchemeContext.js +2 -0
- package/dist/color-scheme/useColorScheme.d.ts +6 -0
- package/dist/color-scheme/useColorScheme.js +3 -0
- package/dist/color-scheme/useColorSchemeValue.d.ts +3 -0
- package/dist/color-scheme/useColorSchemeValue.js +3 -0
- package/dist/global-styles/BodyStyleProvider.d.ts +5 -0
- package/dist/global-styles/BodyStyleProvider.js +9 -0
- package/dist/html-wrappers/html.css +132 -0
- package/dist/{StyledSystemProvider-173b78af.d.ts → html-wrappers/html.d.ts} +8 -53
- package/dist/html-wrappers/html.js +11 -0
- package/dist/html-wrappers/htmlElement.css +132 -0
- package/dist/html-wrappers/htmlElement.d.ts +12 -0
- package/dist/html-wrappers/htmlElement.js +10 -0
- package/dist/index.css +132 -1
- package/dist/index.d.ts +23 -2385
- package/dist/index.js +27 -26
- package/dist/responsive/BreakpointContext.d.ts +10 -0
- package/dist/responsive/BreakpointContext.js +3 -0
- package/dist/responsive/BreakpointProvider.d.ts +12 -0
- package/dist/responsive/BreakpointProvider.js +6 -0
- package/dist/responsive/Breakpoints.d.ts +10 -0
- package/dist/responsive/Breakpoints.js +2 -0
- package/dist/responsive/useResponsiveValue.d.ts +11 -0
- package/dist/responsive/useResponsiveValue.js +5 -0
- package/dist/styled-system-props.d.ts +1246 -3
- package/dist/styled-system-props.js +2 -3
- package/dist/styled-system-root-css-class.js +2 -3
- package/dist/tokens/TokenProvider.d.ts +20 -0
- package/dist/tokens/TokenProvider.js +9 -0
- package/dist/tokens/generated/dark-semantic-tokens.d.ts +272 -0
- package/dist/tokens/generated/dark-semantic-tokens.js +2 -0
- package/dist/tokens/generated/light-semantic-tokens.d.ts +883 -0
- package/dist/tokens/generated/light-semantic-tokens.js +2 -0
- package/dist/tokens/generated/styled-system-to-token-mappings.d.ts +913 -0
- package/dist/tokens/generated/styled-system-to-token-mappings.js +2 -0
- package/dist/{styled-system-props-1c231c50.d.ts → tokens/token-mappings.d.ts} +2 -1258
- package/dist/tokens/token-mappings.js +7 -0
- package/dist/tokens/tokens.d.ts +1154 -0
- package/dist/tokens/tokens.js +4 -0
- package/dist/useStyledSystem.css +125 -1
- package/dist/useStyledSystem.d.ts +4 -1
- package/dist/useStyledSystem.js +9 -5
- package/dist/utils/assertion.d.ts +15 -0
- package/dist/utils/assertion.js +2 -0
- package/dist/utils/useInsertStyleElement.d.ts +6 -0
- package/dist/utils/useInsertStyleElement.js +4 -0
- package/dist/utils/useIsomorphicInsertionEffect.d.ts +16 -0
- package/dist/utils/useIsomorphicInsertionEffect.js +2 -0
- package/dist/utils/useIsomorphicLayoutEffect.d.ts +16 -0
- package/dist/utils/useIsomorphicLayoutEffect.js +2 -0
- package/dist/utils/useMediaQuery.d.ts +4 -0
- package/dist/utils/useMediaQuery.js +2 -0
- package/dist/utils/useThemeComputedStyle.d.ts +14 -0
- package/dist/utils/useThemeComputedStyle.js +3 -0
- package/package.json +2 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useStyledSystem } from './chunk-O7PTTVQH.js';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// css-module:./htmlElement.module.css#css-module
|
|
7
|
+
var htmlElement_module_default = { "html-element": "htmlElement-module__html-element___JSyz-" };
|
|
8
|
+
function htmlElement(elementType) {
|
|
9
|
+
return forwardRef((props, ref) => {
|
|
10
|
+
const { className, children, ...rest } = useStyledSystem(props);
|
|
11
|
+
const As = elementType;
|
|
12
|
+
const classNames = clsx(
|
|
13
|
+
className,
|
|
14
|
+
htmlElement_module_default["html-element"],
|
|
15
|
+
`hop-html-${elementType}`
|
|
16
|
+
// this selector is not used, but could be used as a selector for the element type wrapper
|
|
17
|
+
);
|
|
18
|
+
return (
|
|
19
|
+
// It's too hard for typescript, a generic elementType, with generic props.
|
|
20
|
+
// Basically, the interface is HTMLProps of the elementType + styled system props.
|
|
21
|
+
// useStyledSystem removes the styled system props, so what is remaining is valid for the elementType.
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
/* @__PURE__ */ jsx(As, { ref, className: classNames, ...rest, children })
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { htmlElement };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useIsomorphicInsertionEffect } from './chunk-YPIK2HRL.js';
|
|
2
|
+
import { isNil } from './chunk-U5R6ZXH3.js';
|
|
3
|
+
|
|
4
|
+
// src/utils/useInsertStyleElement.ts
|
|
5
|
+
function useInsertStyleElement(elementId, cssContent, allowUpdates = true) {
|
|
6
|
+
useIsomorphicInsertionEffect(() => {
|
|
7
|
+
let element = document.getElementById(elementId);
|
|
8
|
+
if (isNil(element)) {
|
|
9
|
+
if (!isNil(cssContent)) {
|
|
10
|
+
element = document.createElement("style");
|
|
11
|
+
element.id = elementId;
|
|
12
|
+
document.head.appendChild(element);
|
|
13
|
+
element.innerText = formatInlineCss(cssContent);
|
|
14
|
+
return () => {
|
|
15
|
+
element == null ? void 0 : element.remove();
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
} else if (allowUpdates) {
|
|
19
|
+
element.innerText = formatInlineCss(cssContent);
|
|
20
|
+
}
|
|
21
|
+
}, [elementId, cssContent]);
|
|
22
|
+
}
|
|
23
|
+
function formatInlineCss(str) {
|
|
24
|
+
var _a;
|
|
25
|
+
return (_a = str == null ? void 0 : str.replace(/(\r\n|\n|\r|\s\s)/gm, "")) != null ? _a : "";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { useInsertStyleElement };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Div } from './chunk-ZFDLWGCR.js';
|
|
2
|
+
import { BodyStyleProvider } from './chunk-GRF2SIQE.js';
|
|
3
|
+
import { BreakpointProvider, DefaultUnsupportedMatchMediaBreakpoint } from './chunk-LU33LZMJ.js';
|
|
4
|
+
import { TokenProvider } from './chunk-BEEGWFNF.js';
|
|
5
|
+
import { HopperRootCssClass, StyledSystemRootCssClass } from './chunk-JM7JTLPS.js';
|
|
6
|
+
import { useColorScheme } from './chunk-XTX4KVWI.js';
|
|
7
|
+
import { ColorSchemeContext } from './chunk-V7X6ANEM.js';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import { useState, useCallback } from 'react';
|
|
10
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
function StyledSystemProvider({ children, withBodyStyle = false, withCssVariables = true, colorScheme = "light", defaultColorScheme = "light", unsupportedMatchMediaBreakpoint = DefaultUnsupportedMatchMediaBreakpoint, className, ...rest }) {
|
|
13
|
+
const [remoteColorScheme, setRemoteColorScheme] = useState();
|
|
14
|
+
const computedColorScheme = useColorScheme(remoteColorScheme != null ? remoteColorScheme : colorScheme, defaultColorScheme);
|
|
15
|
+
const setColorScheme = useCallback((newColorScheme) => {
|
|
16
|
+
setRemoteColorScheme(newColorScheme);
|
|
17
|
+
}, [setRemoteColorScheme]);
|
|
18
|
+
const classNames = clsx(
|
|
19
|
+
HopperRootCssClass,
|
|
20
|
+
`${HopperRootCssClass}-${computedColorScheme}`,
|
|
21
|
+
StyledSystemRootCssClass,
|
|
22
|
+
`${StyledSystemRootCssClass}-${computedColorScheme}`,
|
|
23
|
+
className
|
|
24
|
+
);
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
ColorSchemeContext.Provider,
|
|
27
|
+
{
|
|
28
|
+
value: {
|
|
29
|
+
colorScheme: computedColorScheme,
|
|
30
|
+
setColorScheme
|
|
31
|
+
},
|
|
32
|
+
children: /* @__PURE__ */ jsx(BreakpointProvider, { unsupportedMatchMediaBreakpoint, children: /* @__PURE__ */ jsxs(Div, { className: classNames, ...rest, children: [
|
|
33
|
+
withBodyStyle && /* @__PURE__ */ jsx(BodyStyleProvider, {}),
|
|
34
|
+
withCssVariables && /* @__PURE__ */ jsx(TokenProvider, {}),
|
|
35
|
+
children
|
|
36
|
+
] }) })
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { StyledSystemProvider };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useIsSSR } from 'react-aria';
|
|
3
|
+
|
|
4
|
+
// src/utils/useMediaQuery.ts
|
|
5
|
+
var supportsMatchMedia = typeof window !== "undefined" && typeof window.matchMedia === "function";
|
|
6
|
+
function useMediaQuery(query) {
|
|
7
|
+
const [matches, setMatches] = useState(() => supportsMatchMedia ? window.matchMedia(query).matches : false);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!supportsMatchMedia) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const mediaQueryList = window.matchMedia(query);
|
|
13
|
+
const onChange = (event) => {
|
|
14
|
+
setMatches(event.matches);
|
|
15
|
+
};
|
|
16
|
+
mediaQueryList.addEventListener("change", onChange);
|
|
17
|
+
return () => {
|
|
18
|
+
mediaQueryList.removeEventListener("change", onChange);
|
|
19
|
+
};
|
|
20
|
+
}, [query]);
|
|
21
|
+
const isSSR = useIsSSR();
|
|
22
|
+
return isSSR ? false : matches;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { supportsMatchMedia, useMediaQuery };
|