@umber-style/react 0.1.0-rc.0 → 0.1.0-rc.2

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.
@@ -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?.baseTheme;
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 {
@@ -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?.baseTheme;
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 {
@@ -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 base theme when it has none.
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.baseTheme;
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
- if (!engine.hasTheme) engine.setTheme(given);
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;
@@ -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 base theme when it has none.
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.baseTheme;
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
- if (!engine.hasTheme) engine.setTheme(given);
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.baseTheme) {
104
+ if (made === void 0 || made.base !== engine.givenTheme) {
105
105
  made = {
106
- base: engine.baseTheme,
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.baseTheme) {
104
+ if (made === void 0 || made.base !== engine.givenTheme) {
105
105
  made = {
106
- base: engine.baseTheme,
106
+ base: engine.givenTheme,
107
107
  theme: describe(given, props, isFirst)
108
108
  };
109
109
  known.set(key, made);
@@ -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
- /** The theme where no provider is above: the base theme, or the empty theme. */
18
- const readOwnTheme = () => holder.baseTheme ?? _umber_style_core.EMPTY_THEME;
19
- /** The real theme of the nearest provider, the base theme, or an empty object. */
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
  }
@@ -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
- /** The theme where no provider is above: the base theme, or the empty theme. */
18
- const readOwnTheme = () => holder.baseTheme ?? EMPTY_THEME;
19
- /** The real theme of the nearest provider, the base theme, or an empty object. */
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
  }
@@ -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 (!engine.hasTheme) engine.setTheme(theme);
62
+ if (engine.givenTheme === void 0) engine.setTheme(theme);
63
63
  return bindEngine(engine, options);
64
64
  }
65
65
  exports.bindEngine = bindEngine;
@@ -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 (!engine.hasTheme) engine.setTheme(theme);
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.baseTheme ?? _umber_style_core.EMPTY_THEME;
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.baseTheme === void 0 && !hasWarned && (0, _umber_style_core.isDevelopment)()) {
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.baseTheme ?? readFirstSlot().current ?? _umber_style_core.EMPTY_THEME;
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 (!engine.hasTheme) engine.setTheme(theme);
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.baseTheme ?? EMPTY_THEME;
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.baseTheme === void 0 && !hasWarned && isDevelopment()) {
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.baseTheme ?? readFirstSlot().current ?? EMPTY_THEME;
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 (!engine.hasTheme) engine.setTheme(theme);
56
+ if (engine.givenTheme === void 0) engine.setTheme(theme);
57
57
  return bindEngine(engine);
58
58
  }
59
59
  export { bindEngine, createStyle };
@@ -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 baseTheme() {
21
- return bound?.engine.baseTheme ?? pending.theme ?? pending.engine?.baseTheme;
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. */
@@ -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 baseTheme() {
21
- return bound?.engine.baseTheme ?? pending.theme ?? pending.engine?.baseTheme;
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 };
@@ -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 };
@@ -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 };
@@ -14,8 +14,8 @@ function readFilter(element, given) {
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
- const isTag = typeof baseTag === "string";
18
17
  const shouldForward = options.shouldForwardProp ?? inner?._shouldForwardProp;
18
+ const isReplaced = typeof baseTag === "string" || shouldForward !== void 0 && !shouldForward("as");
19
19
  const target = [inner?._target, options.target].filter(Boolean).join(" ") || void 0;
20
20
  const styler = engine.createStyler(options, styles, inner?._styles);
21
21
  const stylers = /* @__PURE__ */ new WeakMap();
@@ -41,10 +41,10 @@ function prepareStyled(engine, tag, options, styles) {
41
41
  const held = canHold && props.style ? own.getHeldClass(props, extra, theme) : void 0;
42
42
  let className = held ? held.className : own.getClassName(props, extra, theme);
43
43
  if (target) className = className ? `${className} ${target}` : target;
44
- const element = isTag ? props.as ?? baseTag : baseTag;
44
+ const element = isReplaced ? props.as ?? baseTag : baseTag;
45
45
  const filter = readFilter(element, shouldForward);
46
46
  const forwarded = {};
47
- for (const [key, value] of Object.entries(props)) if (!(isTag && 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;
48
48
  forwarded.className = className || void 0;
49
49
  return {
50
50
  element,
@@ -14,8 +14,8 @@ function readFilter(element, given) {
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
- const isTag = typeof baseTag === "string";
18
17
  const shouldForward = options.shouldForwardProp ?? inner?._shouldForwardProp;
18
+ const isReplaced = typeof baseTag === "string" || shouldForward !== void 0 && !shouldForward("as");
19
19
  const target = [inner?._target, options.target].filter(Boolean).join(" ") || void 0;
20
20
  const styler = engine.createStyler(options, styles, inner?._styles);
21
21
  const stylers = /* @__PURE__ */ new WeakMap();
@@ -41,10 +41,10 @@ function prepareStyled(engine, tag, options, styles) {
41
41
  const held = canHold && props.style ? own.getHeldClass(props, extra, theme) : void 0;
42
42
  let className = held ? held.className : own.getClassName(props, extra, theme);
43
43
  if (target) className = className ? `${className} ${target}` : target;
44
- const element = isTag ? props.as ?? baseTag : baseTag;
44
+ const element = isReplaced ? props.as ?? baseTag : baseTag;
45
45
  const filter = readFilter(element, shouldForward);
46
46
  const forwarded = {};
47
- for (const [key, value] of Object.entries(props)) if (!(isTag && 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;
48
48
  forwarded.className = className || void 0;
49
49
  return {
50
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
  /**
@@ -46,8 +46,9 @@ export interface StyledOptions<_Props = unknown> extends StylerOptions {
46
46
  * which forwards to a string tag the attributes of HTML and SVG (by their React names), `data-*`,
47
47
  * `aria-*`, event handlers and React's own props, and every prop to a custom element (a tag with a
48
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 a string tag; a component that is not made by `styled`
50
- * is always rendered, and is given `as` as a prop.
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.
51
52
  */
52
53
  shouldForwardProp?: (prop: string) => boolean;
53
54
  /**
@@ -85,23 +86,38 @@ export interface StyledStatics {
85
86
  * is merged, in order, into the one class of the element, after its own styles and before
86
87
  * `className`. In the browser, a class made with a plain object is removed once no element uses it, so
87
88
  * a value that changes often leaves no class behind; each new value still writes a rule. A string is
88
- * 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.
89
91
  */
90
- 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;
91
100
  /**
92
101
  * The `as` of a styled component whose tag takes the props `Base`: the type of the tag's own `as` when it
93
- * has one (a component that is not made by `styled` is given `as` as a prop), else any element type.
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.
94
104
  */
95
105
  type AsProp<Base> = Base extends {
96
106
  as?: infer As;
97
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;
98
114
  /**
99
115
  * A component made by `styled`: it takes the props of the tag (`Base`: all of them, unless a
100
116
  * `shouldForwardProp` type guard named some), its own props `P`, `as` and `style`. As text it is a
101
117
  * selector: `.` and a class that every element of it has (its `target`, else its class when none of its
102
118
  * styles is a function).
103
119
  */
104
- export type StyledComponent<C extends ElementType, P extends object, Base extends object = ComponentProps<C>> = FunctionComponent<Omit<Base, keyof P | 'as' | 'style'> & P & {
120
+ export type StyledComponent<C extends ElementType, P extends object, Base extends object = ComponentProps<C>> = FunctionComponent<Omit<Base, keyof P | 'as' | 'style'> & OwnProps<P> & {
105
121
  as?: AsProp<Base>;
106
122
  style?: StyleProp;
107
123
  }> & StyledStatics;
@@ -313,4 +329,4 @@ export interface WebStyle<T> extends Omit<Style<T, SheetEntry$1>, 'ThemeProvider
313
329
  /** The cache of the engine, which holds the rules. */
314
330
  cache: Cache;
315
331
  }
316
- 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
  /**
@@ -46,8 +46,9 @@ export interface StyledOptions<_Props = unknown> extends StylerOptions {
46
46
  * which forwards to a string tag the attributes of HTML and SVG (by their React names), `data-*`,
47
47
  * `aria-*`, event handlers and React's own props, and every prop to a custom element (a tag with a
48
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 a string tag; a component that is not made by `styled`
50
- * is always rendered, and is given `as` as a prop.
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.
51
52
  */
52
53
  shouldForwardProp?: (prop: string) => boolean;
53
54
  /**
@@ -85,23 +86,38 @@ export interface StyledStatics {
85
86
  * is merged, in order, into the one class of the element, after its own styles and before
86
87
  * `className`. In the browser, a class made with a plain object is removed once no element uses it, so
87
88
  * a value that changes often leaves no class behind; each new value still writes a rule. A string is
88
- * 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.
89
91
  */
90
- 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;
91
100
  /**
92
101
  * The `as` of a styled component whose tag takes the props `Base`: the type of the tag's own `as` when it
93
- * has one (a component that is not made by `styled` is given `as` as a prop), else any element type.
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.
94
104
  */
95
105
  type AsProp<Base> = Base extends {
96
106
  as?: infer As;
97
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;
98
114
  /**
99
115
  * A component made by `styled`: it takes the props of the tag (`Base`: all of them, unless a
100
116
  * `shouldForwardProp` type guard named some), its own props `P`, `as` and `style`. As text it is a
101
117
  * selector: `.` and a class that every element of it has (its `target`, else its class when none of its
102
118
  * styles is a function).
103
119
  */
104
- export type StyledComponent<C extends ElementType, P extends object, Base extends object = ComponentProps<C>> = FunctionComponent<Omit<Base, keyof P | 'as' | 'style'> & P & {
120
+ export type StyledComponent<C extends ElementType, P extends object, Base extends object = ComponentProps<C>> = FunctionComponent<Omit<Base, keyof P | 'as' | 'style'> & OwnProps<P> & {
105
121
  as?: AsProp<Base>;
106
122
  style?: StyleProp;
107
123
  }> & StyledStatics;
@@ -313,4 +329,4 @@ export interface WebStyle<T> extends Omit<Style<T, SheetEntry$1>, 'ThemeProvider
313
329
  /** The cache of the engine, which holds the rules. */
314
330
  cache: Cache;
315
331
  }
316
- 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-rc.0",
3
+ "version": "0.1.0-rc.2",
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-rc.0"
57
+ "@umber-style/core": "0.1.0-rc.2"
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"