@umber-style/react 0.1.0-alpha.2 → 0.1.0-rc.1
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/ProviderScope.cjs +1 -1
- package/dist/ProviderScope.mjs +1 -1
- package/dist/ThemeProvider.cjs +4 -3
- package/dist/ThemeProvider.mjs +4 -3
- package/dist/ThemeProvider.server.cjs +3 -3
- package/dist/ThemeProvider.server.mjs +3 -3
- package/dist/ThemeValue.cjs +6 -3
- package/dist/ThemeValue.mjs +6 -3
- package/dist/createStyle.cjs +1 -1
- package/dist/createStyle.mjs +1 -1
- package/dist/createStyle.server.cjs +4 -4
- package/dist/createStyle.server.mjs +4 -4
- package/dist/defaultStyle.cjs +2 -2
- package/dist/defaultStyle.mjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.server.d.cts +2 -2
- package/dist/index.server.d.mts +2 -2
- package/dist/styledParts.cjs +6 -5
- package/dist/styledParts.mjs +6 -5
- package/dist/types.d.cts +37 -12
- package/dist/types.d.mts +37 -12
- package/package.json +3 -3
package/dist/ProviderScope.cjs
CHANGED
|
@@ -151,7 +151,7 @@ function ProviderScope({ prefix, given, theme, children }) {
|
|
|
151
151
|
scope
|
|
152
152
|
]);
|
|
153
153
|
const { contexts, holder } = readPrefixStyle(prefix);
|
|
154
|
-
const outer = react.use(contexts.ThemeContext) ?? holder?.
|
|
154
|
+
const outer = react.use(contexts.ThemeContext) ?? holder?.givenTheme;
|
|
155
155
|
const merged = react.useMemo(() => (0, _umber_style_core.mergeTheme)(outer, given), [outer, given]);
|
|
156
156
|
const styles = react.useMemo(() => {
|
|
157
157
|
if (theme === void 0) return {
|
package/dist/ProviderScope.mjs
CHANGED
|
@@ -149,7 +149,7 @@ function ProviderScope({ prefix, given, theme, children }) {
|
|
|
149
149
|
scope
|
|
150
150
|
]);
|
|
151
151
|
const { contexts, holder } = readPrefixStyle(prefix);
|
|
152
|
-
const outer = React.use(contexts.ThemeContext) ?? holder?.
|
|
152
|
+
const outer = React.use(contexts.ThemeContext) ?? holder?.givenTheme;
|
|
153
153
|
const merged = React.useMemo(() => mergeTheme(outer, given), [outer, given]);
|
|
154
154
|
const styles = React.useMemo(() => {
|
|
155
155
|
if (theme === void 0) return {
|
package/dist/ThemeProvider.cjs
CHANGED
|
@@ -13,7 +13,8 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
13
13
|
* - The outermost provider (none above it) renders no element: its theme is declared on `:root`, written
|
|
14
14
|
* in an insertion effect in the browser (so a change of theme rewrites that rule and renders no styled
|
|
15
15
|
* component) and during the render where there is no document (a server render). It gives the engine
|
|
16
|
-
* its
|
|
16
|
+
* the shape of its tokens when it has none (`adoptTheme`), which is not a base theme that a tree with no
|
|
17
|
+
* provider reads.
|
|
17
18
|
* - A nested provider renders its wrapper: the theme class of the theme it was given (with the boundary
|
|
18
19
|
* and scheme markers that conditions use), the theme class of its merged theme (every variable, so that
|
|
19
20
|
* it is right where its element is not inside the wrapper of the provider above, in a portal), and the
|
|
@@ -41,11 +42,11 @@ function createThemeProvider({ engine: baseEngine, contexts: { ThemeContext, Vie
|
|
|
41
42
|
const marks = (0, react.use)(MarksContext);
|
|
42
43
|
const key = require_ThemeValue.readMarkKey(baseEngine, cache);
|
|
43
44
|
const above = marks.get(key);
|
|
44
|
-
const outer = (0, react.useContext)(ThemeContext) ?? engine.
|
|
45
|
+
const outer = (0, react.useContext)(ThemeContext) ?? engine.givenTheme;
|
|
45
46
|
const isOutermost = above === void 0 && !isRoot;
|
|
46
47
|
const isNested = above !== void 0 && !isRoot;
|
|
47
48
|
const given = (0, react.useMemo)(() => (0, _umber_style_core.resolveThemeInput)(theme, outer ?? _umber_style_core.EMPTY_THEME), [theme, outer]);
|
|
48
|
-
|
|
49
|
+
engine.adoptTheme(given);
|
|
49
50
|
const merged = (0, react.useMemo)(() => (0, _umber_style_core.mergeTheme)(outer, given), [outer, given]);
|
|
50
51
|
const wrapper = (0, react.useMemo)(() => {
|
|
51
52
|
if (!isNested) return void 0;
|
package/dist/ThemeProvider.mjs
CHANGED
|
@@ -13,7 +13,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
13
13
|
* - The outermost provider (none above it) renders no element: its theme is declared on `:root`, written
|
|
14
14
|
* in an insertion effect in the browser (so a change of theme rewrites that rule and renders no styled
|
|
15
15
|
* component) and during the render where there is no document (a server render). It gives the engine
|
|
16
|
-
* its
|
|
16
|
+
* the shape of its tokens when it has none (`adoptTheme`), which is not a base theme that a tree with no
|
|
17
|
+
* provider reads.
|
|
17
18
|
* - A nested provider renders its wrapper: the theme class of the theme it was given (with the boundary
|
|
18
19
|
* and scheme markers that conditions use), the theme class of its merged theme (every variable, so that
|
|
19
20
|
* it is right where its element is not inside the wrapper of the provider above, in a portal), and the
|
|
@@ -41,11 +42,11 @@ function createThemeProvider({ engine: baseEngine, contexts: { ThemeContext, Vie
|
|
|
41
42
|
const marks = use(MarksContext);
|
|
42
43
|
const key = readMarkKey(baseEngine, cache);
|
|
43
44
|
const above = marks.get(key);
|
|
44
|
-
const outer = useContext(ThemeContext) ?? engine.
|
|
45
|
+
const outer = useContext(ThemeContext) ?? engine.givenTheme;
|
|
45
46
|
const isOutermost = above === void 0 && !isRoot;
|
|
46
47
|
const isNested = above !== void 0 && !isRoot;
|
|
47
48
|
const given = useMemo(() => resolveThemeInput(theme, outer ?? EMPTY_THEME), [theme, outer]);
|
|
48
|
-
|
|
49
|
+
engine.adoptTheme(given);
|
|
49
50
|
const merged = useMemo(() => mergeTheme(outer, given), [outer, given]);
|
|
50
51
|
const wrapper = useMemo(() => {
|
|
51
52
|
if (!isNested) return void 0;
|
|
@@ -65,7 +65,7 @@ function createThemeProvider(engine, { readFirstSlot, readBaseTheme }) {
|
|
|
65
65
|
* outermost one of the page.
|
|
66
66
|
*/
|
|
67
67
|
const describe = (given, { colorScheme, className, as = "div" }, isFirst) => {
|
|
68
|
-
const { cache, baseTheme } = engine;
|
|
68
|
+
const { cache, givenTheme: baseTheme } = engine;
|
|
69
69
|
const text = engine.readThemeText(given);
|
|
70
70
|
const classId = (0, _umber_style_core.createThemeId)(prefix, text.declarations, colorScheme);
|
|
71
71
|
const own = text.declarations + (colorScheme ? `color-scheme:${colorScheme};` : "");
|
|
@@ -101,9 +101,9 @@ function createThemeProvider(engine, { readFirstSlot, readBaseTheme }) {
|
|
|
101
101
|
const known = described.get(given) ?? /* @__PURE__ */ new Map();
|
|
102
102
|
described.set(given, known);
|
|
103
103
|
let made = known.get(key);
|
|
104
|
-
if (made === void 0 || made.base !== engine.
|
|
104
|
+
if (made === void 0 || made.base !== engine.givenTheme) {
|
|
105
105
|
made = {
|
|
106
|
-
base: engine.
|
|
106
|
+
base: engine.givenTheme,
|
|
107
107
|
theme: describe(given, props, isFirst)
|
|
108
108
|
};
|
|
109
109
|
known.set(key, made);
|
|
@@ -65,7 +65,7 @@ function createThemeProvider(engine, { readFirstSlot, readBaseTheme }) {
|
|
|
65
65
|
* outermost one of the page.
|
|
66
66
|
*/
|
|
67
67
|
const describe = (given, { colorScheme, className, as = "div" }, isFirst) => {
|
|
68
|
-
const { cache, baseTheme } = engine;
|
|
68
|
+
const { cache, givenTheme: baseTheme } = engine;
|
|
69
69
|
const text = engine.readThemeText(given);
|
|
70
70
|
const classId = createThemeId(prefix, text.declarations, colorScheme);
|
|
71
71
|
const own = text.declarations + (colorScheme ? `color-scheme:${colorScheme};` : "");
|
|
@@ -101,9 +101,9 @@ function createThemeProvider(engine, { readFirstSlot, readBaseTheme }) {
|
|
|
101
101
|
const known = described.get(given) ?? /* @__PURE__ */ new Map();
|
|
102
102
|
described.set(given, known);
|
|
103
103
|
let made = known.get(key);
|
|
104
|
-
if (made === void 0 || made.base !== engine.
|
|
104
|
+
if (made === void 0 || made.base !== engine.givenTheme) {
|
|
105
105
|
made = {
|
|
106
|
-
base: engine.
|
|
106
|
+
base: engine.givenTheme,
|
|
107
107
|
theme: describe(given, props, isFirst)
|
|
108
108
|
};
|
|
109
109
|
known.set(key, made);
|
package/dist/ThemeValue.cjs
CHANGED
|
@@ -14,9 +14,12 @@ function readMarkKey(engine, cache) {
|
|
|
14
14
|
}
|
|
15
15
|
/** The hooks of one style, and `ThemeScope`, over its contexts. */
|
|
16
16
|
function createThemeValue(holder, { ThemeContext, ViewContext }) {
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The theme where no provider is above: the base theme given on purpose, or the empty theme. A theme
|
|
19
|
+
* that a provider gave the engine (`adoptTheme`) is not it: it would outlive that provider.
|
|
20
|
+
*/
|
|
21
|
+
const readOwnTheme = () => holder.givenTheme ?? _umber_style_core.EMPTY_THEME;
|
|
22
|
+
/** The real theme of the nearest provider, the given base theme, or an empty object. */
|
|
20
23
|
function useTheme() {
|
|
21
24
|
return (0, react.useContext)(ThemeContext) ?? readOwnTheme();
|
|
22
25
|
}
|
package/dist/ThemeValue.mjs
CHANGED
|
@@ -14,9 +14,12 @@ function readMarkKey(engine, cache) {
|
|
|
14
14
|
}
|
|
15
15
|
/** The hooks of one style, and `ThemeScope`, over its contexts. */
|
|
16
16
|
function createThemeValue(holder, { ThemeContext, ViewContext }) {
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The theme where no provider is above: the base theme given on purpose, or the empty theme. A theme
|
|
19
|
+
* that a provider gave the engine (`adoptTheme`) is not it: it would outlive that provider.
|
|
20
|
+
*/
|
|
21
|
+
const readOwnTheme = () => holder.givenTheme ?? EMPTY_THEME;
|
|
22
|
+
/** The real theme of the nearest provider, the given base theme, or an empty object. */
|
|
20
23
|
function useTheme() {
|
|
21
24
|
return useContext(ThemeContext) ?? readOwnTheme();
|
|
22
25
|
}
|
package/dist/createStyle.cjs
CHANGED
|
@@ -59,7 +59,7 @@ function bindEngine(engine, { hasServerStyleElements = true } = {}, contexts = r
|
|
|
59
59
|
/** Makes the React styling of one theme shape, apart from the default one: its own engine, or the one given. */
|
|
60
60
|
function createStyle(theme, options = {}) {
|
|
61
61
|
const engine = options.engine ?? (0, _umber_style_core.createEngine)(theme, options);
|
|
62
|
-
if (
|
|
62
|
+
if (engine.givenTheme === void 0) engine.setTheme(theme);
|
|
63
63
|
return bindEngine(engine, options);
|
|
64
64
|
}
|
|
65
65
|
exports.bindEngine = bindEngine;
|
package/dist/createStyle.mjs
CHANGED
|
@@ -59,7 +59,7 @@ function bindEngine(engine, { hasServerStyleElements = true } = {}, contexts = r
|
|
|
59
59
|
/** Makes the React styling of one theme shape, apart from the default one: its own engine, or the one given. */
|
|
60
60
|
function createStyle(theme, options = {}) {
|
|
61
61
|
const engine = options.engine ?? createEngine(theme, options);
|
|
62
|
-
if (
|
|
62
|
+
if (engine.givenTheme === void 0) engine.setTheme(theme);
|
|
63
63
|
return bindEngine(engine, options);
|
|
64
64
|
}
|
|
65
65
|
export { bindEngine, createStyle };
|
|
@@ -8,7 +8,7 @@ const require_ThemeProvider_server = require("./ThemeProvider.server.cjs");
|
|
|
8
8
|
function bindEngine(engine, cache) {
|
|
9
9
|
const readFirstSlot = require_serverContext.createRequestSlot(void 0, cache);
|
|
10
10
|
let hasWarned = false;
|
|
11
|
-
const readBaseTheme = () => engine.
|
|
11
|
+
const readBaseTheme = () => engine.givenTheme ?? _umber_style_core.EMPTY_THEME;
|
|
12
12
|
/**
|
|
13
13
|
* The base theme: the one given to `createStyle(theme)` or `configure({ theme })`, the same in every
|
|
14
14
|
* render of every request, whatever providers render. With none, an empty object, and one warning in
|
|
@@ -16,13 +16,13 @@ function bindEngine(engine, cache) {
|
|
|
16
16
|
* values is a client component, whose `useTheme()` reads them.
|
|
17
17
|
*/
|
|
18
18
|
const useTheme = () => {
|
|
19
|
-
if (engine.
|
|
19
|
+
if (engine.givenTheme === void 0 && !hasWarned && (0, _umber_style_core.isDevelopment)()) {
|
|
20
20
|
hasWarned = true;
|
|
21
21
|
console.warn(`[${engine.cache.prefix}] useTheme() in a server component returns the base theme, and there is none: give the theme to createStyle(theme) or configure({ theme }) to read it in server components. It returns an empty object.`);
|
|
22
22
|
}
|
|
23
23
|
return readBaseTheme();
|
|
24
24
|
};
|
|
25
|
-
const readViewTheme = () => engine.
|
|
25
|
+
const readViewTheme = () => engine.givenTheme ?? readFirstSlot().current ?? _umber_style_core.EMPTY_THEME;
|
|
26
26
|
const themeClass = (partial, colorScheme) => engine.themeClass(partial, colorScheme);
|
|
27
27
|
const useStyle = ((sheet) => (0, _umber_style_core.isThemedSheet)(sheet) ? sheet.resolve(engine.createThemeView(readViewTheme())) : sheet);
|
|
28
28
|
function create(styles) {
|
|
@@ -53,7 +53,7 @@ function bindEngine(engine, cache) {
|
|
|
53
53
|
/** Makes the styling for server components of one theme shape: its own engine, or the one given. */
|
|
54
54
|
function createStyle(theme, options = {}) {
|
|
55
55
|
const engine = options.engine ?? (0, _umber_style_core.createEngine)(theme, options);
|
|
56
|
-
if (
|
|
56
|
+
if (engine.givenTheme === void 0) engine.setTheme(theme);
|
|
57
57
|
return bindEngine(engine);
|
|
58
58
|
}
|
|
59
59
|
exports.bindEngine = bindEngine;
|
|
@@ -8,7 +8,7 @@ import { createThemeProvider } from "./ThemeProvider.server.mjs";
|
|
|
8
8
|
function bindEngine(engine, cache) {
|
|
9
9
|
const readFirstSlot = createRequestSlot(void 0, cache);
|
|
10
10
|
let hasWarned = false;
|
|
11
|
-
const readBaseTheme = () => engine.
|
|
11
|
+
const readBaseTheme = () => engine.givenTheme ?? EMPTY_THEME;
|
|
12
12
|
/**
|
|
13
13
|
* The base theme: the one given to `createStyle(theme)` or `configure({ theme })`, the same in every
|
|
14
14
|
* render of every request, whatever providers render. With none, an empty object, and one warning in
|
|
@@ -16,13 +16,13 @@ function bindEngine(engine, cache) {
|
|
|
16
16
|
* values is a client component, whose `useTheme()` reads them.
|
|
17
17
|
*/
|
|
18
18
|
const useTheme = () => {
|
|
19
|
-
if (engine.
|
|
19
|
+
if (engine.givenTheme === void 0 && !hasWarned && isDevelopment()) {
|
|
20
20
|
hasWarned = true;
|
|
21
21
|
console.warn(`[${engine.cache.prefix}] useTheme() in a server component returns the base theme, and there is none: give the theme to createStyle(theme) or configure({ theme }) to read it in server components. It returns an empty object.`);
|
|
22
22
|
}
|
|
23
23
|
return readBaseTheme();
|
|
24
24
|
};
|
|
25
|
-
const readViewTheme = () => engine.
|
|
25
|
+
const readViewTheme = () => engine.givenTheme ?? readFirstSlot().current ?? EMPTY_THEME;
|
|
26
26
|
const themeClass = (partial, colorScheme) => engine.themeClass(partial, colorScheme);
|
|
27
27
|
const useStyle = ((sheet) => isThemedSheet(sheet) ? sheet.resolve(engine.createThemeView(readViewTheme())) : sheet);
|
|
28
28
|
function create(styles) {
|
|
@@ -53,7 +53,7 @@ function bindEngine(engine, cache) {
|
|
|
53
53
|
/** Makes the styling for server components of one theme shape: its own engine, or the one given. */
|
|
54
54
|
function createStyle(theme, options = {}) {
|
|
55
55
|
const engine = options.engine ?? createEngine(theme, options);
|
|
56
|
-
if (
|
|
56
|
+
if (engine.givenTheme === void 0) engine.setTheme(theme);
|
|
57
57
|
return bindEngine(engine);
|
|
58
58
|
}
|
|
59
59
|
export { bindEngine, createStyle };
|
package/dist/defaultStyle.cjs
CHANGED
|
@@ -17,8 +17,8 @@ function createDefaultStyle() {
|
|
|
17
17
|
};
|
|
18
18
|
require_ProviderScope.claimPrefixStyle(() => bound?.cache.prefix ?? pending.engine?.cache.prefix ?? pending.cache?.prefix ?? pending.prefix ?? "css", {
|
|
19
19
|
contexts,
|
|
20
|
-
holder: { get
|
|
21
|
-
return bound?.engine.
|
|
20
|
+
holder: { get givenTheme() {
|
|
21
|
+
return bound?.engine.givenTheme ?? pending.theme ?? pending.engine?.givenTheme;
|
|
22
22
|
} }
|
|
23
23
|
});
|
|
24
24
|
/** Sets the options of the default engine, and gives it a base theme or an engine to share. Throws once the default style was used. */
|
package/dist/defaultStyle.mjs
CHANGED
|
@@ -17,8 +17,8 @@ function createDefaultStyle() {
|
|
|
17
17
|
};
|
|
18
18
|
claimPrefixStyle(() => bound?.cache.prefix ?? pending.engine?.cache.prefix ?? pending.cache?.prefix ?? pending.prefix ?? "css", {
|
|
19
19
|
contexts,
|
|
20
|
-
holder: { get
|
|
21
|
-
return bound?.engine.
|
|
20
|
+
holder: { get givenTheme() {
|
|
21
|
+
return bound?.engine.givenTheme ?? pending.theme ?? pending.engine?.givenTheme;
|
|
22
22
|
} }
|
|
23
23
|
});
|
|
24
24
|
/** Sets the options of the default engine, and gives it a base theme or an engine to share. Throws once the default style was used. */
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
|
|
2
|
-
import { AlphaColor, CSSObject, CacheProviderProps, ComponentSelector, CreateStyled, CreateStyledComponent, CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, GlobalInput, GlobalProps, GlobalStyleObject, GlobalStyles, Interpolation, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, PropsOf, SchemeKey, SchemeName, SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, StaticTemplateValue, Style, StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, TemplateValue, Theme, ThemeInput, ThemeKey, ThemeProviderProps, ThemeScopeProps, UmberCache, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.cjs";
|
|
2
|
+
import { AlphaColor, CSSObject, CacheProviderProps, ComponentSelector, CreateStyled, CreateStyledComponent, CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, GlobalInput, GlobalProps, GlobalStyleObject, GlobalStyles, Interpolation, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, PropsOf, SchemeKey, SchemeName, SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, StaticTemplateValue, Style, StyleObject, StyleOptions, StyleProp, StyleTypeOptions, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, TemplateValue, Theme, ThemeInput, ThemeKey, ThemeProviderProps, ThemeScopeProps, UmberCache, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.cjs";
|
|
3
3
|
import { CacheProvider } from "./CacheProvider.cjs";
|
|
4
4
|
import { MediaQueryOptions, useMediaQuery } from "./useMediaQuery.cjs";
|
|
5
5
|
import { bindEngine, createStyle } from "./createStyle.cjs";
|
|
@@ -25,4 +25,4 @@ export declare const configure: (options: DefaultStyleOptions) => void, getEngin
|
|
|
25
25
|
(template: TemplateStringsArray, ...values: import("@umber-style/core").TemplateValue<unknown, Theme>[]): import("@umber-style/core").GlobalStyles<Theme>;
|
|
26
26
|
(styles: import("@umber-style/core").GlobalStylesInput<Theme>): import("@umber-style/core").GlobalStyles<Theme>;
|
|
27
27
|
}, Global: (props: GlobalProps<Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
28
|
-
export { type AlphaColor, type CSSObject, CacheProvider, CacheProviderProps, type ComponentSelector, CreateStyled, CreateStyledComponent, type CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, type GlobalInput, GlobalProps, type GlobalStyleObject, type GlobalStyles, Interpolation, type InterpolationResult, type Keyframes, type KeyframesSteps, type MediaQueryOptions, type NestedKey, PropsOf, type SchemeKey, type SchemeName, type SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, type StaticTemplateValue, Style, type StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, type TemplateValue, Theme, type ThemeInput, type ThemeKey, ThemeProviderProps, ThemeScopeProps, type UmberCache, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract, useMediaQuery };
|
|
28
|
+
export { type AlphaColor, type CSSObject, CacheProvider, CacheProviderProps, type ComponentSelector, CreateStyled, CreateStyledComponent, type CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, type GlobalInput, GlobalProps, type GlobalStyleObject, type GlobalStyles, Interpolation, type InterpolationResult, type Keyframes, type KeyframesSteps, type MediaQueryOptions, type NestedKey, PropsOf, type SchemeKey, type SchemeName, type SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, type StaticTemplateValue, Style, type StyleObject, StyleOptions, StyleProp, type StyleTypeOptions, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, type TemplateValue, Theme, type ThemeInput, type ThemeKey, ThemeProviderProps, ThemeScopeProps, type UmberCache, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract, useMediaQuery };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlphaColor, CSSObject, CacheProviderProps, ComponentSelector, CreateStyled, CreateStyledComponent, CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, GlobalInput, GlobalProps, GlobalStyleObject, GlobalStyles, Interpolation, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, PropsOf, SchemeKey, SchemeName, SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, StaticTemplateValue, Style, StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, TemplateValue, Theme, ThemeInput, ThemeKey, ThemeProviderProps, ThemeScopeProps, UmberCache, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.mjs";
|
|
1
|
+
import { AlphaColor, CSSObject, CacheProviderProps, ComponentSelector, CreateStyled, CreateStyledComponent, CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, GlobalInput, GlobalProps, GlobalStyleObject, GlobalStyles, Interpolation, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, PropsOf, SchemeKey, SchemeName, SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, StaticTemplateValue, Style, StyleObject, StyleOptions, StyleProp, StyleTypeOptions, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, TemplateValue, Theme, ThemeInput, ThemeKey, ThemeProviderProps, ThemeScopeProps, UmberCache, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.mjs";
|
|
2
2
|
import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
|
|
3
3
|
import { CacheProvider } from "./CacheProvider.mjs";
|
|
4
4
|
import { MediaQueryOptions, useMediaQuery } from "./useMediaQuery.mjs";
|
|
@@ -25,4 +25,4 @@ export declare const configure: (options: DefaultStyleOptions) => void, getEngin
|
|
|
25
25
|
(template: TemplateStringsArray, ...values: import("@umber-style/core").TemplateValue<unknown, Theme>[]): import("@umber-style/core").GlobalStyles<Theme>;
|
|
26
26
|
(styles: import("@umber-style/core").GlobalStylesInput<Theme>): import("@umber-style/core").GlobalStyles<Theme>;
|
|
27
27
|
}, Global: (props: GlobalProps<Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
28
|
-
export { type AlphaColor, type CSSObject, CacheProvider, CacheProviderProps, type ComponentSelector, CreateStyled, CreateStyledComponent, type CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, type GlobalInput, GlobalProps, type GlobalStyleObject, type GlobalStyles, Interpolation, type InterpolationResult, type Keyframes, type KeyframesSteps, type MediaQueryOptions, type NestedKey, PropsOf, type SchemeKey, type SchemeName, type SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, type StaticTemplateValue, Style, type StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, type TemplateValue, Theme, type ThemeInput, type ThemeKey, ThemeProviderProps, ThemeScopeProps, type UmberCache, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract, useMediaQuery };
|
|
28
|
+
export { type AlphaColor, type CSSObject, CacheProvider, CacheProviderProps, type ComponentSelector, CreateStyled, CreateStyledComponent, type CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, type GlobalInput, GlobalProps, type GlobalStyleObject, type GlobalStyles, Interpolation, type InterpolationResult, type Keyframes, type KeyframesSteps, type MediaQueryOptions, type NestedKey, PropsOf, type SchemeKey, type SchemeName, type SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, type StaticTemplateValue, Style, type StyleObject, StyleOptions, StyleProp, type StyleTypeOptions, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, type TemplateValue, Theme, type ThemeInput, type ThemeKey, ThemeProviderProps, ThemeScopeProps, type UmberCache, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract, useMediaQuery };
|
package/dist/index.server.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
|
|
2
|
-
import { AlphaColor, CSSObject, CacheProviderProps, ComponentSelector, CreateStyled, CreateStyledComponent, CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, GlobalInput, GlobalProps, GlobalStyleObject, GlobalStyles, Interpolation, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, PropsOf, SchemeKey, SchemeName, SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, StaticTemplateValue, Style, StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, TemplateValue, Theme, ThemeInput, ThemeKey, ThemeProviderProps, ThemeScopeProps, UmberCache, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.cjs";
|
|
2
|
+
import { AlphaColor, CSSObject, CacheProviderProps, ComponentSelector, CreateStyled, CreateStyledComponent, CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, GlobalInput, GlobalProps, GlobalStyleObject, GlobalStyles, Interpolation, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, PropsOf, SchemeKey, SchemeName, SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, StaticTemplateValue, Style, StyleObject, StyleOptions, StyleProp, StyleTypeOptions, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, TemplateValue, Theme, ThemeInput, ThemeKey, ThemeProviderProps, ThemeScopeProps, UmberCache, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.cjs";
|
|
3
3
|
import { bindEngine, createStyle } from "./createStyle.server.cjs";
|
|
4
4
|
import { createDefaultStyle } from "./defaultStyle.server.cjs";
|
|
5
5
|
export declare const configure: (options: DefaultStyleOptions) => void, getEngine: () => import("@umber-style/core").Engine<Theme>, styled: Styled<Theme>, StyleSheet: {
|
|
@@ -23,4 +23,4 @@ export declare const configure: (options: DefaultStyleOptions) => void, getEngin
|
|
|
23
23
|
(template: TemplateStringsArray, ...values: import("@umber-style/core").TemplateValue<unknown, Theme>[]): import("@umber-style/core").GlobalStyles<Theme>;
|
|
24
24
|
(styles: import("@umber-style/core").GlobalStylesInput<Theme>): import("@umber-style/core").GlobalStyles<Theme>;
|
|
25
25
|
}, Global: (props: GlobalProps<Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
26
|
-
export { type AlphaColor, type CSSObject, CacheProviderProps, type ComponentSelector, CreateStyled, CreateStyledComponent, type CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, type GlobalInput, GlobalProps, type GlobalStyleObject, type GlobalStyles, Interpolation, type InterpolationResult, type Keyframes, type KeyframesSteps, type NestedKey, PropsOf, type SchemeKey, type SchemeName, type SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, type StaticTemplateValue, Style, type StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, type TemplateValue, Theme, type ThemeInput, type ThemeKey, ThemeProviderProps, ThemeScopeProps, type UmberCache, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract };
|
|
26
|
+
export { type AlphaColor, type CSSObject, CacheProviderProps, type ComponentSelector, CreateStyled, CreateStyledComponent, type CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, type GlobalInput, GlobalProps, type GlobalStyleObject, type GlobalStyles, Interpolation, type InterpolationResult, type Keyframes, type KeyframesSteps, type NestedKey, PropsOf, type SchemeKey, type SchemeName, type SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, type StaticTemplateValue, Style, type StyleObject, StyleOptions, StyleProp, type StyleTypeOptions, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, type TemplateValue, Theme, type ThemeInput, type ThemeKey, ThemeProviderProps, ThemeScopeProps, type UmberCache, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract };
|
package/dist/index.server.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlphaColor, CSSObject, CacheProviderProps, ComponentSelector, CreateStyled, CreateStyledComponent, CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, GlobalInput, GlobalProps, GlobalStyleObject, GlobalStyles, Interpolation, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, PropsOf, SchemeKey, SchemeName, SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, StaticTemplateValue, Style, StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, TemplateValue, Theme, ThemeInput, ThemeKey, ThemeProviderProps, ThemeScopeProps, UmberCache, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.mjs";
|
|
1
|
+
import { AlphaColor, CSSObject, CacheProviderProps, ComponentSelector, CreateStyled, CreateStyledComponent, CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, GlobalInput, GlobalProps, GlobalStyleObject, GlobalStyles, Interpolation, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, PropsOf, SchemeKey, SchemeName, SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, StaticTemplateValue, Style, StyleObject, StyleOptions, StyleProp, StyleTypeOptions, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, TemplateValue, Theme, ThemeInput, ThemeKey, ThemeProviderProps, ThemeScopeProps, UmberCache, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.mjs";
|
|
2
2
|
import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
|
|
3
3
|
import { bindEngine, createStyle } from "./createStyle.server.mjs";
|
|
4
4
|
import { createDefaultStyle } from "./defaultStyle.server.mjs";
|
|
@@ -23,4 +23,4 @@ export declare const configure: (options: DefaultStyleOptions) => void, getEngin
|
|
|
23
23
|
(template: TemplateStringsArray, ...values: import("@umber-style/core").TemplateValue<unknown, Theme>[]): import("@umber-style/core").GlobalStyles<Theme>;
|
|
24
24
|
(styles: import("@umber-style/core").GlobalStylesInput<Theme>): import("@umber-style/core").GlobalStyles<Theme>;
|
|
25
25
|
}, Global: (props: GlobalProps<Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
26
|
-
export { type AlphaColor, type CSSObject, CacheProviderProps, type ComponentSelector, CreateStyled, CreateStyledComponent, type CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, type GlobalInput, GlobalProps, type GlobalStyleObject, type GlobalStyles, Interpolation, type InterpolationResult, type Keyframes, type KeyframesSteps, type NestedKey, PropsOf, type SchemeKey, type SchemeName, type SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, type StaticTemplateValue, Style, type StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, type TemplateValue, Theme, type ThemeInput, type ThemeKey, ThemeProviderProps, ThemeScopeProps, type UmberCache, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract };
|
|
26
|
+
export { type AlphaColor, type CSSObject, CacheProviderProps, type ComponentSelector, CreateStyled, CreateStyledComponent, type CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, type GlobalInput, GlobalProps, type GlobalStyleObject, type GlobalStyles, Interpolation, type InterpolationResult, type Keyframes, type KeyframesSteps, type NestedKey, PropsOf, type SchemeKey, type SchemeName, type SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, type StaticTemplateValue, Style, type StyleObject, StyleOptions, StyleProp, type StyleTypeOptions, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, type TemplateValue, Theme, type ThemeInput, type ThemeKey, ThemeProviderProps, ThemeScopeProps, type UmberCache, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract };
|
package/dist/styledParts.cjs
CHANGED
|
@@ -5,16 +5,17 @@ const require_domProps = require("./domProps.cjs");
|
|
|
5
5
|
function isStyledComponent(tag) {
|
|
6
6
|
return typeof tag === "function" && "_styles" in tag;
|
|
7
7
|
}
|
|
8
|
-
/** The filter of the props of `element`: the one given, else for a string tag the attributes of HTML and SVG (a custom element, with a hyphen in its name, receives every prop)
|
|
8
|
+
/** The filter of the props of `element`: the one given, whatever the element is; else for a string tag the attributes of HTML and SVG (a custom element, with a hyphen in its name, receives every prop), and none for a component. */
|
|
9
9
|
function readFilter(element, given) {
|
|
10
|
-
if (typeof element !== "string") return
|
|
11
|
-
return
|
|
10
|
+
if (given || typeof element !== "string") return given;
|
|
11
|
+
return element.includes("-") ? void 0 : require_domProps.isDomProp;
|
|
12
12
|
}
|
|
13
13
|
/** What both builds of `styled` share: the styler, and the element and props that a component renders. */
|
|
14
14
|
function prepareStyled(engine, tag, options, styles) {
|
|
15
15
|
const inner = isStyledComponent(tag) ? tag : void 0;
|
|
16
16
|
const baseTag = inner?._tag ?? tag;
|
|
17
17
|
const shouldForward = options.shouldForwardProp ?? inner?._shouldForwardProp;
|
|
18
|
+
const isReplaced = typeof baseTag === "string" || shouldForward !== void 0 && !shouldForward("as");
|
|
18
19
|
const target = [inner?._target, options.target].filter(Boolean).join(" ") || void 0;
|
|
19
20
|
const styler = engine.createStyler(options, styles, inner?._styles);
|
|
20
21
|
const stylers = /* @__PURE__ */ new WeakMap();
|
|
@@ -40,10 +41,10 @@ function prepareStyled(engine, tag, options, styles) {
|
|
|
40
41
|
const held = canHold && props.style ? own.getHeldClass(props, extra, theme) : void 0;
|
|
41
42
|
let className = held ? held.className : own.getClassName(props, extra, theme);
|
|
42
43
|
if (target) className = className ? `${className} ${target}` : target;
|
|
43
|
-
const element = props.as ?? baseTag;
|
|
44
|
+
const element = isReplaced ? props.as ?? baseTag : baseTag;
|
|
44
45
|
const filter = readFilter(element, shouldForward);
|
|
45
46
|
const forwarded = {};
|
|
46
|
-
for (const [key, value] of Object.entries(props)) if (!(key === "as" || key === "theme" || key === "className" || key === "style") && (!filter || filter(key))) forwarded[key] = value;
|
|
47
|
+
for (const [key, value] of Object.entries(props)) if (!(isReplaced && key === "as" || key === "theme" || key === "className" || key === "style") && (!filter || filter(key))) forwarded[key] = value;
|
|
47
48
|
forwarded.className = className || void 0;
|
|
48
49
|
return {
|
|
49
50
|
element,
|
package/dist/styledParts.mjs
CHANGED
|
@@ -5,16 +5,17 @@ import { isDomProp } from "./domProps.mjs";
|
|
|
5
5
|
function isStyledComponent(tag) {
|
|
6
6
|
return typeof tag === "function" && "_styles" in tag;
|
|
7
7
|
}
|
|
8
|
-
/** The filter of the props of `element`: the one given, else for a string tag the attributes of HTML and SVG (a custom element, with a hyphen in its name, receives every prop)
|
|
8
|
+
/** The filter of the props of `element`: the one given, whatever the element is; else for a string tag the attributes of HTML and SVG (a custom element, with a hyphen in its name, receives every prop), and none for a component. */
|
|
9
9
|
function readFilter(element, given) {
|
|
10
|
-
if (typeof element !== "string") return
|
|
11
|
-
return
|
|
10
|
+
if (given || typeof element !== "string") return given;
|
|
11
|
+
return element.includes("-") ? void 0 : isDomProp;
|
|
12
12
|
}
|
|
13
13
|
/** What both builds of `styled` share: the styler, and the element and props that a component renders. */
|
|
14
14
|
function prepareStyled(engine, tag, options, styles) {
|
|
15
15
|
const inner = isStyledComponent(tag) ? tag : void 0;
|
|
16
16
|
const baseTag = inner?._tag ?? tag;
|
|
17
17
|
const shouldForward = options.shouldForwardProp ?? inner?._shouldForwardProp;
|
|
18
|
+
const isReplaced = typeof baseTag === "string" || shouldForward !== void 0 && !shouldForward("as");
|
|
18
19
|
const target = [inner?._target, options.target].filter(Boolean).join(" ") || void 0;
|
|
19
20
|
const styler = engine.createStyler(options, styles, inner?._styles);
|
|
20
21
|
const stylers = /* @__PURE__ */ new WeakMap();
|
|
@@ -40,10 +41,10 @@ function prepareStyled(engine, tag, options, styles) {
|
|
|
40
41
|
const held = canHold && props.style ? own.getHeldClass(props, extra, theme) : void 0;
|
|
41
42
|
let className = held ? held.className : own.getClassName(props, extra, theme);
|
|
42
43
|
if (target) className = className ? `${className} ${target}` : target;
|
|
43
|
-
const element = props.as ?? baseTag;
|
|
44
|
+
const element = isReplaced ? props.as ?? baseTag : baseTag;
|
|
44
45
|
const filter = readFilter(element, shouldForward);
|
|
45
46
|
const forwarded = {};
|
|
46
|
-
for (const [key, value] of Object.entries(props)) if (!(key === "as" || key === "theme" || key === "className" || key === "style") && (!filter || filter(key))) forwarded[key] = value;
|
|
47
|
+
for (const [key, value] of Object.entries(props)) if (!(isReplaced && key === "as" || key === "theme" || key === "className" || key === "style") && (!filter || filter(key))) forwarded[key] = value;
|
|
47
48
|
forwarded.className = className || void 0;
|
|
48
49
|
return {
|
|
49
50
|
element,
|
package/dist/types.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentProps, Context, ElementType, FunctionComponent, JSX, ReactElement, ReactNode } from "react";
|
|
2
|
-
import { AlphaColor, BindingOptions, CSSObject, Cache, ColorScheme, ComponentSelector, CssArgument, CssArgument as CssArgument$1, DeepPartial, Engine, GlobalInput, GlobalInput as GlobalInput$1, GlobalStyleObject, GlobalStyleObject as GlobalStyleObject$1, GlobalStyles, GlobalStyles as GlobalStyles$1, GlobalStylesInput, Interpolation as Interpolation$1, InterpolationResult, InterpolationResult as InterpolationResult$1, Keyframes, Keyframes as Keyframes$1, KeyframesInput, KeyframesOptions, KeyframesSteps, KeyframesSteps as KeyframesSteps$1, NestedKey, ObjectSheet, SchemeKey, SchemeKey as SchemeKey$1, SchemeName, SchemeName as SchemeName$1, SerializedStyles, SerializedStyles as SerializedStyles$1, SheetEntry, SheetEntry as SheetEntry$1, SheetStyles, StaticTemplateValue, StaticTemplateValue as StaticTemplateValue$1, StyleInput, StyleObject, StylerOptions, TemplateValue, TemplateValue as TemplateValue$1, Theme as Theme$1, ThemeInput, ThemeInput as ThemeInput$1, ThemeKey, ThemeKey as ThemeKey$1, UmberCache, WebNested, WebProperties, WebStyleObject, WebStyleObject as WebStyleObject$1 } from "@umber-style/core";
|
|
1
|
+
import { CSSProperties, ComponentProps, Context, ElementType, FunctionComponent, JSX, ReactElement, ReactNode } from "react";
|
|
2
|
+
import { AlphaColor, BindingOptions, CSSObject, Cache, ColorScheme, ComponentSelector, CssArgument, CssArgument as CssArgument$1, DeepPartial, Engine, GlobalInput, GlobalInput as GlobalInput$1, GlobalStyleObject, GlobalStyleObject as GlobalStyleObject$1, GlobalStyles, GlobalStyles as GlobalStyles$1, GlobalStylesInput, Interpolation as Interpolation$1, InterpolationResult, InterpolationResult as InterpolationResult$1, Keyframes, Keyframes as Keyframes$1, KeyframesInput, KeyframesOptions, KeyframesSteps, KeyframesSteps as KeyframesSteps$1, NestedKey, ObjectSheet, SchemeKey, SchemeKey as SchemeKey$1, SchemeName, SchemeName as SchemeName$1, SerializedStyles, SerializedStyles as SerializedStyles$1, SheetEntry, SheetEntry as SheetEntry$1, SheetStyles, StaticTemplateValue, StaticTemplateValue as StaticTemplateValue$1, StyleInput, StyleObject, StyleTypeOptions, StyleTypeOptions as StyleTypeOptions$1, StylerOptions, TemplateValue, TemplateValue as TemplateValue$1, Theme as Theme$1, ThemeInput, ThemeInput as ThemeInput$1, ThemeKey, ThemeKey as ThemeKey$1, UmberCache, WebNested, WebProperties, WebStyleObject, WebStyleObject as WebStyleObject$1 } from "@umber-style/core";
|
|
3
3
|
/** What only the client build of the React binding takes: it can render the style of its classes on a server. */
|
|
4
4
|
export interface ServerStyleOptions {
|
|
5
5
|
/**
|
|
@@ -42,10 +42,13 @@ export interface DefaultStyleOptions extends BindingOptions<Theme>, ServerStyleO
|
|
|
42
42
|
*/
|
|
43
43
|
export interface StyledOptions<_Props = unknown> extends StylerOptions {
|
|
44
44
|
/**
|
|
45
|
-
* Whether a prop is forwarded to
|
|
46
|
-
* of HTML and SVG (by their React names), `data-*`,
|
|
47
|
-
* every prop to a custom element (a tag with a
|
|
48
|
-
*
|
|
45
|
+
* Whether a prop is forwarded to the element or component that is rendered. It replaces the default,
|
|
46
|
+
* which forwards to a string tag the attributes of HTML and SVG (by their React names), `data-*`,
|
|
47
|
+
* `aria-*`, event handlers and React's own props, and every prop to a custom element (a tag with a
|
|
48
|
+
* hyphen) and to a component. `theme`, `className` and `style` are the component's own and are never
|
|
49
|
+
* forwarded, and so is `as` where it replaces what is rendered: `as` always replaces a string tag, and
|
|
50
|
+
* replaces a component that is not made by `styled` only when this filter returns false for `as`;
|
|
51
|
+
* without such a filter that component is rendered, and is given `as` as a prop.
|
|
49
52
|
*/
|
|
50
53
|
shouldForwardProp?: (prop: string) => boolean;
|
|
51
54
|
/**
|
|
@@ -60,7 +63,7 @@ export interface StyledOptions<_Props = unknown> extends StylerOptions {
|
|
|
60
63
|
* then takes are only the ones it names, `Forwarded`.
|
|
61
64
|
*/
|
|
62
65
|
export interface FilteringStyledOptions<Props = Record<string, unknown>, Forwarded extends keyof Props & string = keyof Props & string> extends StyledOptions<Props> {
|
|
63
|
-
/** A type guard of the props that are forwarded
|
|
66
|
+
/** A type guard of the props that are forwarded: the component takes only the props of the tag that it names. */
|
|
64
67
|
shouldForwardProp?: (prop: string) => prop is Forwarded;
|
|
65
68
|
}
|
|
66
69
|
/** The props of a component or a tag, as an element of it takes them. */
|
|
@@ -83,17 +86,39 @@ export interface StyledStatics {
|
|
|
83
86
|
* is merged, in order, into the one class of the element, after its own styles and before
|
|
84
87
|
* `className`. In the browser, a class made with a plain object is removed once no element uses it, so
|
|
85
88
|
* a value that changes often leaves no class behind; each new value still writes a rule. A string is
|
|
86
|
-
* an error.
|
|
89
|
+
* an error. By default it also takes React's `CSSProperties`, what the `style` of a plain element
|
|
90
|
+
* takes, so props spread from `HTMLAttributes` fit; with `isStrict` in `StyleTypeOptions` it does not.
|
|
87
91
|
*/
|
|
88
|
-
export type StyleProp = SheetEntry$1 | WebStyleObject$1 | false | null | undefined | readonly StyleProp[];
|
|
92
|
+
export type StyleProp = SheetEntry$1 | WebStyleObject$1 | ElementStyle | false | null | undefined | readonly StyleProp[];
|
|
93
|
+
/**
|
|
94
|
+
* React's `CSSProperties` by default: an interface, which has no index signature and so is not a
|
|
95
|
+
* `WebStyleObject` by itself. Nothing with the strict style types.
|
|
96
|
+
*/
|
|
97
|
+
type ElementStyle = StyleTypeOptions$1 extends {
|
|
98
|
+
isStrict: true;
|
|
99
|
+
} ? never : CSSProperties;
|
|
100
|
+
/**
|
|
101
|
+
* The `as` of a styled component whose tag takes the props `Base`: the type of the tag's own `as` when it
|
|
102
|
+
* has one (a component that is not made by `styled` is given `as` as a prop, unless `shouldForwardProp`
|
|
103
|
+
* keeps it off), else any element type.
|
|
104
|
+
*/
|
|
105
|
+
type AsProp<Base> = Base extends {
|
|
106
|
+
as?: infer As;
|
|
107
|
+
} ? unknown extends As ? ElementType : As : ElementType;
|
|
108
|
+
/**
|
|
109
|
+
* The component's own props `P` without a `style` of theirs (props that extend `HTMLAttributes` have
|
|
110
|
+
* one): the `style` of a styled component is `StyleProp`. Kept, `style` would be the intersection of
|
|
111
|
+
* the two, a union of intersections that every element of the component is compared with.
|
|
112
|
+
*/
|
|
113
|
+
type OwnProps<P extends object> = 'style' extends keyof P ? Omit<P, 'style'> : P;
|
|
89
114
|
/**
|
|
90
115
|
* A component made by `styled`: it takes the props of the tag (`Base`: all of them, unless a
|
|
91
116
|
* `shouldForwardProp` type guard named some), its own props `P`, `as` and `style`. As text it is a
|
|
92
117
|
* selector: `.` and a class that every element of it has (its `target`, else its class when none of its
|
|
93
118
|
* styles is a function).
|
|
94
119
|
*/
|
|
95
|
-
export type StyledComponent<C extends ElementType, P extends object, Base extends object = ComponentProps<C>> = FunctionComponent<Omit<Base, keyof P | 'as' | 'style'> & P & {
|
|
96
|
-
as?:
|
|
120
|
+
export type StyledComponent<C extends ElementType, P extends object, Base extends object = ComponentProps<C>> = FunctionComponent<Omit<Base, keyof P | 'as' | 'style'> & OwnProps<P> & {
|
|
121
|
+
as?: AsProp<Base>;
|
|
97
122
|
style?: StyleProp;
|
|
98
123
|
}> & StyledStatics;
|
|
99
124
|
/** The props that a function style reads: the props of the tag `Base`, with the component's own `P` over them. */
|
|
@@ -304,4 +329,4 @@ export interface WebStyle<T> extends Omit<Style<T, SheetEntry$1>, 'ThemeProvider
|
|
|
304
329
|
/** The cache of the engine, which holds the rules. */
|
|
305
330
|
cache: Cache;
|
|
306
331
|
}
|
|
307
|
-
export type { AlphaColor, CSSObject, ComponentSelector, CssArgument, GlobalInput, GlobalStyleObject, GlobalStyles, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, SchemeKey, SchemeName, SerializedStyles, SheetEntry, StaticTemplateValue, StyleObject, TemplateValue, ThemeInput, ThemeKey, UmberCache, WebNested, WebProperties, WebStyleObject };
|
|
332
|
+
export type { AlphaColor, CSSObject, ComponentSelector, CssArgument, GlobalInput, GlobalStyleObject, GlobalStyles, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, SchemeKey, SchemeName, SerializedStyles, SheetEntry, StaticTemplateValue, StyleObject, StyleTypeOptions, TemplateValue, ThemeInput, ThemeKey, UmberCache, WebNested, WebProperties, WebStyleObject };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentProps, Context, ElementType, FunctionComponent, JSX, ReactElement, ReactNode } from "react";
|
|
2
|
-
import { AlphaColor, BindingOptions, CSSObject, Cache, ColorScheme, ComponentSelector, CssArgument, CssArgument as CssArgument$1, DeepPartial, Engine, GlobalInput, GlobalInput as GlobalInput$1, GlobalStyleObject, GlobalStyleObject as GlobalStyleObject$1, GlobalStyles, GlobalStyles as GlobalStyles$1, GlobalStylesInput, Interpolation as Interpolation$1, InterpolationResult, InterpolationResult as InterpolationResult$1, Keyframes, Keyframes as Keyframes$1, KeyframesInput, KeyframesOptions, KeyframesSteps, KeyframesSteps as KeyframesSteps$1, NestedKey, ObjectSheet, SchemeKey, SchemeKey as SchemeKey$1, SchemeName, SchemeName as SchemeName$1, SerializedStyles, SerializedStyles as SerializedStyles$1, SheetEntry, SheetEntry as SheetEntry$1, SheetStyles, StaticTemplateValue, StaticTemplateValue as StaticTemplateValue$1, StyleInput, StyleObject, StylerOptions, TemplateValue, TemplateValue as TemplateValue$1, Theme as Theme$1, ThemeInput, ThemeInput as ThemeInput$1, ThemeKey, ThemeKey as ThemeKey$1, UmberCache, WebNested, WebProperties, WebStyleObject, WebStyleObject as WebStyleObject$1 } from "@umber-style/core";
|
|
1
|
+
import { CSSProperties, ComponentProps, Context, ElementType, FunctionComponent, JSX, ReactElement, ReactNode } from "react";
|
|
2
|
+
import { AlphaColor, BindingOptions, CSSObject, Cache, ColorScheme, ComponentSelector, CssArgument, CssArgument as CssArgument$1, DeepPartial, Engine, GlobalInput, GlobalInput as GlobalInput$1, GlobalStyleObject, GlobalStyleObject as GlobalStyleObject$1, GlobalStyles, GlobalStyles as GlobalStyles$1, GlobalStylesInput, Interpolation as Interpolation$1, InterpolationResult, InterpolationResult as InterpolationResult$1, Keyframes, Keyframes as Keyframes$1, KeyframesInput, KeyframesOptions, KeyframesSteps, KeyframesSteps as KeyframesSteps$1, NestedKey, ObjectSheet, SchemeKey, SchemeKey as SchemeKey$1, SchemeName, SchemeName as SchemeName$1, SerializedStyles, SerializedStyles as SerializedStyles$1, SheetEntry, SheetEntry as SheetEntry$1, SheetStyles, StaticTemplateValue, StaticTemplateValue as StaticTemplateValue$1, StyleInput, StyleObject, StyleTypeOptions, StyleTypeOptions as StyleTypeOptions$1, StylerOptions, TemplateValue, TemplateValue as TemplateValue$1, Theme as Theme$1, ThemeInput, ThemeInput as ThemeInput$1, ThemeKey, ThemeKey as ThemeKey$1, UmberCache, WebNested, WebProperties, WebStyleObject, WebStyleObject as WebStyleObject$1 } from "@umber-style/core";
|
|
3
3
|
/** What only the client build of the React binding takes: it can render the style of its classes on a server. */
|
|
4
4
|
export interface ServerStyleOptions {
|
|
5
5
|
/**
|
|
@@ -42,10 +42,13 @@ export interface DefaultStyleOptions extends BindingOptions<Theme>, ServerStyleO
|
|
|
42
42
|
*/
|
|
43
43
|
export interface StyledOptions<_Props = unknown> extends StylerOptions {
|
|
44
44
|
/**
|
|
45
|
-
* Whether a prop is forwarded to
|
|
46
|
-
* of HTML and SVG (by their React names), `data-*`,
|
|
47
|
-
* every prop to a custom element (a tag with a
|
|
48
|
-
*
|
|
45
|
+
* Whether a prop is forwarded to the element or component that is rendered. It replaces the default,
|
|
46
|
+
* which forwards to a string tag the attributes of HTML and SVG (by their React names), `data-*`,
|
|
47
|
+
* `aria-*`, event handlers and React's own props, and every prop to a custom element (a tag with a
|
|
48
|
+
* hyphen) and to a component. `theme`, `className` and `style` are the component's own and are never
|
|
49
|
+
* forwarded, and so is `as` where it replaces what is rendered: `as` always replaces a string tag, and
|
|
50
|
+
* replaces a component that is not made by `styled` only when this filter returns false for `as`;
|
|
51
|
+
* without such a filter that component is rendered, and is given `as` as a prop.
|
|
49
52
|
*/
|
|
50
53
|
shouldForwardProp?: (prop: string) => boolean;
|
|
51
54
|
/**
|
|
@@ -60,7 +63,7 @@ export interface StyledOptions<_Props = unknown> extends StylerOptions {
|
|
|
60
63
|
* then takes are only the ones it names, `Forwarded`.
|
|
61
64
|
*/
|
|
62
65
|
export interface FilteringStyledOptions<Props = Record<string, unknown>, Forwarded extends keyof Props & string = keyof Props & string> extends StyledOptions<Props> {
|
|
63
|
-
/** A type guard of the props that are forwarded
|
|
66
|
+
/** A type guard of the props that are forwarded: the component takes only the props of the tag that it names. */
|
|
64
67
|
shouldForwardProp?: (prop: string) => prop is Forwarded;
|
|
65
68
|
}
|
|
66
69
|
/** The props of a component or a tag, as an element of it takes them. */
|
|
@@ -83,17 +86,39 @@ export interface StyledStatics {
|
|
|
83
86
|
* is merged, in order, into the one class of the element, after its own styles and before
|
|
84
87
|
* `className`. In the browser, a class made with a plain object is removed once no element uses it, so
|
|
85
88
|
* a value that changes often leaves no class behind; each new value still writes a rule. A string is
|
|
86
|
-
* an error.
|
|
89
|
+
* an error. By default it also takes React's `CSSProperties`, what the `style` of a plain element
|
|
90
|
+
* takes, so props spread from `HTMLAttributes` fit; with `isStrict` in `StyleTypeOptions` it does not.
|
|
87
91
|
*/
|
|
88
|
-
export type StyleProp = SheetEntry$1 | WebStyleObject$1 | false | null | undefined | readonly StyleProp[];
|
|
92
|
+
export type StyleProp = SheetEntry$1 | WebStyleObject$1 | ElementStyle | false | null | undefined | readonly StyleProp[];
|
|
93
|
+
/**
|
|
94
|
+
* React's `CSSProperties` by default: an interface, which has no index signature and so is not a
|
|
95
|
+
* `WebStyleObject` by itself. Nothing with the strict style types.
|
|
96
|
+
*/
|
|
97
|
+
type ElementStyle = StyleTypeOptions$1 extends {
|
|
98
|
+
isStrict: true;
|
|
99
|
+
} ? never : CSSProperties;
|
|
100
|
+
/**
|
|
101
|
+
* The `as` of a styled component whose tag takes the props `Base`: the type of the tag's own `as` when it
|
|
102
|
+
* has one (a component that is not made by `styled` is given `as` as a prop, unless `shouldForwardProp`
|
|
103
|
+
* keeps it off), else any element type.
|
|
104
|
+
*/
|
|
105
|
+
type AsProp<Base> = Base extends {
|
|
106
|
+
as?: infer As;
|
|
107
|
+
} ? unknown extends As ? ElementType : As : ElementType;
|
|
108
|
+
/**
|
|
109
|
+
* The component's own props `P` without a `style` of theirs (props that extend `HTMLAttributes` have
|
|
110
|
+
* one): the `style` of a styled component is `StyleProp`. Kept, `style` would be the intersection of
|
|
111
|
+
* the two, a union of intersections that every element of the component is compared with.
|
|
112
|
+
*/
|
|
113
|
+
type OwnProps<P extends object> = 'style' extends keyof P ? Omit<P, 'style'> : P;
|
|
89
114
|
/**
|
|
90
115
|
* A component made by `styled`: it takes the props of the tag (`Base`: all of them, unless a
|
|
91
116
|
* `shouldForwardProp` type guard named some), its own props `P`, `as` and `style`. As text it is a
|
|
92
117
|
* selector: `.` and a class that every element of it has (its `target`, else its class when none of its
|
|
93
118
|
* styles is a function).
|
|
94
119
|
*/
|
|
95
|
-
export type StyledComponent<C extends ElementType, P extends object, Base extends object = ComponentProps<C>> = FunctionComponent<Omit<Base, keyof P | 'as' | 'style'> & P & {
|
|
96
|
-
as?:
|
|
120
|
+
export type StyledComponent<C extends ElementType, P extends object, Base extends object = ComponentProps<C>> = FunctionComponent<Omit<Base, keyof P | 'as' | 'style'> & OwnProps<P> & {
|
|
121
|
+
as?: AsProp<Base>;
|
|
97
122
|
style?: StyleProp;
|
|
98
123
|
}> & StyledStatics;
|
|
99
124
|
/** The props that a function style reads: the props of the tag `Base`, with the component's own `P` over them. */
|
|
@@ -304,4 +329,4 @@ export interface WebStyle<T> extends Omit<Style<T, SheetEntry$1>, 'ThemeProvider
|
|
|
304
329
|
/** The cache of the engine, which holds the rules. */
|
|
305
330
|
cache: Cache;
|
|
306
331
|
}
|
|
307
|
-
export type { AlphaColor, CSSObject, ComponentSelector, CssArgument, GlobalInput, GlobalStyleObject, GlobalStyles, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, SchemeKey, SchemeName, SerializedStyles, SheetEntry, StaticTemplateValue, StyleObject, TemplateValue, ThemeInput, ThemeKey, UmberCache, WebNested, WebProperties, WebStyleObject };
|
|
332
|
+
export type { AlphaColor, CSSObject, ComponentSelector, CssArgument, GlobalInput, GlobalStyleObject, GlobalStyles, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, SchemeKey, SchemeName, SerializedStyles, SheetEntry, StaticTemplateValue, StyleObject, StyleTypeOptions, TemplateValue, ThemeInput, ThemeKey, UmberCache, WebNested, WebProperties, WebStyleObject };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umber-style/react",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-rc.1",
|
|
4
4
|
"description": "UmberStyle for React: styled, ThemeProvider, useTheme, StyleSheet, useStyle and apply, with a server build for server components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"styling",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@umber-style/core": "0.1.0-
|
|
57
|
+
"@umber-style/core": "0.1.0-rc.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^19.2.8"
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"scripts": {
|
|
83
83
|
"build": "tsdown",
|
|
84
84
|
"lint": "oxlint --deny-warnings",
|
|
85
|
-
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.augmentation.json && tsc --noEmit -p tsconfig.server.json",
|
|
85
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.augmentation.json && tsc --noEmit -p tsconfig.server.json && tsc --noEmit -p tsconfig.strict.json",
|
|
86
86
|
"test": "vitest run",
|
|
87
87
|
"test:coverage": "vitest run --coverage",
|
|
88
88
|
"test:browser": "vitest run --config vitest.browser.config.ts"
|