@umber-style/react-native 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.
@@ -25,14 +25,13 @@ function createThemeValue(holder, convert, ThemeContext = (0, react.createContex
25
25
  }
26
26
  return native;
27
27
  };
28
- /** The theme where no provider is above: the base theme, or the empty theme. */
28
+ /** The theme where no provider is above: the base theme given by the app, or the empty theme. */
29
29
  const readOwnTheme = () => holder.baseTheme ?? _umber_style_core.EMPTY_THEME;
30
30
  function ThemeValueProvider({ theme, colorScheme, children }) {
31
31
  const above = (0, react.useContext)(ThemeContext);
32
32
  const outer = above === void 0 ? holder.baseTheme : themeByNative.get(above) ?? above;
33
33
  const outerScheme = (0, react.useContext)(ConditionContext)?.colorScheme;
34
34
  const given = (0, react.useMemo)(() => (0, _umber_style_core.resolveThemeInput)(theme, outer ?? _umber_style_core.EMPTY_THEME), [theme, outer]);
35
- holder.baseTheme ??= given;
36
35
  const value = (0, react.useMemo)(() => toNative((0, _umber_style_core.mergeTheme)(outer, given)), [outer, given]);
37
36
  const scheme = require_conditions.readSchemeName(colorScheme) ?? outerScheme;
38
37
  const condition = (0, react.useMemo)(() => ({
@@ -25,14 +25,13 @@ function createThemeValue(holder, convert, ThemeContext = createContext(void 0))
25
25
  }
26
26
  return native;
27
27
  };
28
- /** The theme where no provider is above: the base theme, or the empty theme. */
28
+ /** The theme where no provider is above: the base theme given by the app, or the empty theme. */
29
29
  const readOwnTheme = () => holder.baseTheme ?? EMPTY_THEME;
30
30
  function ThemeValueProvider({ theme, colorScheme, children }) {
31
31
  const above = useContext(ThemeContext);
32
32
  const outer = above === void 0 ? holder.baseTheme : themeByNative.get(above) ?? above;
33
33
  const outerScheme = useContext(ConditionContext)?.colorScheme;
34
34
  const given = useMemo(() => resolveThemeInput(theme, outer ?? EMPTY_THEME), [theme, outer]);
35
- holder.baseTheme ??= given;
36
35
  const value = useMemo(() => toNative(mergeTheme(outer, given)), [outer, given]);
37
36
  const scheme = readSchemeName(colorScheme) ?? outerScheme;
38
37
  const condition = useMemo(() => ({
@@ -6,6 +6,7 @@ const require_nativeTheme = require("./nativeTheme.cjs");
6
6
  const require_styled = require("./styled.cjs");
7
7
  const require_toNativeStyle = require("./toNativeStyle.cjs");
8
8
  const require_windowState = require("./windowState.cjs");
9
+ const require_warnStyle = require("./warnStyle.cjs");
9
10
  let react_native = require("react-native");
10
11
  // src/createStyle.ts
11
12
  const NO_QUERIES = [];
@@ -109,6 +110,7 @@ function useThemeClass() {}
109
110
  */
110
111
  function bindHolder(holder, context, options = {}) {
111
112
  const { remBase = 16, lengthKeys = require_nativeTheme.DEFAULT_LENGTH_KEYS } = options;
113
+ require_warnStyle.warnAboutIgnoredOptions(options);
112
114
  const { ThemeContext, ThemeValueProvider, useTheme, useCondition } = require_ThemeValue.createThemeValue(holder, (theme) => require_nativeTheme.toNativeTheme(theme, lengthKeys, remBase), context);
113
115
  function ThemeProvider({ theme, colorScheme, children }) {
114
116
  return (0, react.createElement)(ThemeValueProvider, {
@@ -7,6 +7,7 @@ import { createStyled } from "./styled.mjs";
7
7
  import { platformStyleSheet } from "./platform.mjs";
8
8
  import { collectKeys, toNativeStyle } from "./toNativeStyle.mjs";
9
9
  import { readMediaKey, readWindowState, useMediaKey } from "./windowState.mjs";
10
+ import { warnAboutIgnoredOptions } from "./warnStyle.mjs";
10
11
  // src/createStyle.ts
11
12
  const NO_QUERIES = [];
12
13
  const NO_KEYS = {
@@ -109,6 +110,7 @@ function useThemeClass() {}
109
110
  */
110
111
  function bindHolder(holder, context, options = {}) {
111
112
  const { remBase = 16, lengthKeys = DEFAULT_LENGTH_KEYS } = options;
113
+ warnAboutIgnoredOptions(options);
112
114
  const { ThemeContext, ThemeValueProvider, useTheme, useCondition } = createThemeValue(holder, (theme) => toNativeTheme(theme, lengthKeys, remBase), context);
113
115
  function ThemeProvider({ theme, colorScheme, children }) {
114
116
  return createElement(ThemeValueProvider, {
@@ -92,6 +92,20 @@ function warnAboutQuery(query, problem) {
92
92
  if (!isDevelopment()) return;
93
93
  warnOnce(`useMediaQuery("${query}") is false: React Native does not evaluate ${problem}.`, void 0);
94
94
  }
95
+ /** The options of `createStyle` and `configure` that React Native uses; every other option is for the web. */
96
+ const NATIVE_OPTIONS = /* @__PURE__ */ new Set([
97
+ "theme",
98
+ "remBase",
99
+ "lengthKeys"
100
+ ]);
101
+ /** In development, warns (once) about the options of `createStyle` or `configure` that React Native does not use, by name. */
102
+ function warnAboutIgnoredOptions(options) {
103
+ if (!isDevelopment()) return;
104
+ const ignored = Object.entries(options).filter(([name, value]) => value !== void 0 && !NATIVE_OPTIONS.has(name)).map(([name]) => name);
105
+ if (ignored.length === 0) return;
106
+ warnOnce(`the options ${ignored.join(", ")} are for the web, and React Native does not use them: they are ignored. Only theme, remBase and lengthKeys are read.`, void 0);
107
+ }
95
108
  exports.warnAboutDroppedKey = warnAboutDroppedKey;
109
+ exports.warnAboutIgnoredOptions = warnAboutIgnoredOptions;
96
110
  exports.warnAboutQuery = warnAboutQuery;
97
111
  exports.warnAboutValues = warnAboutValues;
@@ -92,4 +92,17 @@ function warnAboutQuery(query, problem) {
92
92
  if (!isDevelopment()) return;
93
93
  warnOnce(`useMediaQuery("${query}") is false: React Native does not evaluate ${problem}.`, void 0);
94
94
  }
95
- export { warnAboutDroppedKey, warnAboutQuery, warnAboutValues };
95
+ /** The options of `createStyle` and `configure` that React Native uses; every other option is for the web. */
96
+ const NATIVE_OPTIONS = /* @__PURE__ */ new Set([
97
+ "theme",
98
+ "remBase",
99
+ "lengthKeys"
100
+ ]);
101
+ /** In development, warns (once) about the options of `createStyle` or `configure` that React Native does not use, by name. */
102
+ function warnAboutIgnoredOptions(options) {
103
+ if (!isDevelopment()) return;
104
+ const ignored = Object.entries(options).filter(([name, value]) => value !== void 0 && !NATIVE_OPTIONS.has(name)).map(([name]) => name);
105
+ if (ignored.length === 0) return;
106
+ warnOnce(`the options ${ignored.join(", ")} are for the web, and React Native does not use them: they are ignored. Only theme, remBase and lengthKeys are read.`, void 0);
107
+ }
108
+ export { warnAboutDroppedKey, warnAboutIgnoredOptions, warnAboutQuery, warnAboutValues };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umber-style/react-native",
3
- "version": "0.1.0-rc.0",
3
+ "version": "0.1.0-rc.2",
4
4
  "description": "UmberStyle for React Native: the same names as the React binding, over the real theme values.",
5
5
  "keywords": [
6
6
  "styling",
@@ -41,7 +41,7 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "@umber-style/core": "0.1.0-rc.0"
44
+ "@umber-style/core": "0.1.0-rc.2"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": "^19.2.8",