react-native-css 3.0.0-nightly.61014be → 3.0.0-nightly.df0f885

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.
Files changed (131) hide show
  1. package/dist/commonjs/compiler/attributes.test.js +1 -1
  2. package/dist/commonjs/compiler/attributes.test.js.map +1 -1
  3. package/dist/commonjs/compiler/compiler.js +25 -14
  4. package/dist/commonjs/compiler/compiler.js.map +1 -1
  5. package/dist/commonjs/compiler/declarations.js +31 -7
  6. package/dist/commonjs/compiler/declarations.js.map +1 -1
  7. package/dist/commonjs/compiler/inheritance.test.js +3 -3
  8. package/dist/commonjs/compiler/inheritance.test.js.map +1 -1
  9. package/dist/commonjs/compiler/stylesheet.js +53 -19
  10. package/dist/commonjs/compiler/stylesheet.js.map +1 -1
  11. package/dist/commonjs/jest/index.js +23 -7
  12. package/dist/commonjs/jest/index.js.map +1 -1
  13. package/dist/commonjs/poison.pill.js +4 -1
  14. package/dist/commonjs/poison.pill.js.map +1 -1
  15. package/dist/commonjs/runtime/native/conditions/container-query.js +21 -21
  16. package/dist/commonjs/runtime/native/conditions/container-query.js.map +1 -1
  17. package/dist/commonjs/runtime/native/conditions/guards.js.map +1 -1
  18. package/dist/commonjs/runtime/native/conditions/index.js +8 -8
  19. package/dist/commonjs/runtime/native/conditions/index.js.map +1 -1
  20. package/dist/commonjs/runtime/native/conditions/media-query.js +16 -16
  21. package/dist/commonjs/runtime/native/conditions/media-query.js.map +1 -1
  22. package/dist/commonjs/runtime/native/react/interaction.js +10 -10
  23. package/dist/commonjs/runtime/native/react/interaction.js.map +1 -1
  24. package/dist/commonjs/runtime/native/react/rules.js +9 -9
  25. package/dist/commonjs/runtime/native/react/rules.js.map +1 -1
  26. package/dist/commonjs/runtime/native/react/useNativeCss.js +1 -0
  27. package/dist/commonjs/runtime/native/react/useNativeCss.js.map +1 -1
  28. package/dist/commonjs/runtime/native/reactivity.js +15 -6
  29. package/dist/commonjs/runtime/native/reactivity.js.map +1 -1
  30. package/dist/commonjs/runtime/native/styles/index.js +12 -12
  31. package/dist/commonjs/runtime/native/styles/index.js.map +1 -1
  32. package/dist/module/compiler/attributes.test.js +1 -1
  33. package/dist/module/compiler/attributes.test.js.map +1 -1
  34. package/dist/module/compiler/compiler.js +25 -14
  35. package/dist/module/compiler/compiler.js.map +1 -1
  36. package/dist/module/compiler/compiler.types.js.map +1 -1
  37. package/dist/module/compiler/declarations.js +30 -7
  38. package/dist/module/compiler/declarations.js.map +1 -1
  39. package/dist/module/compiler/inheritance.test.js +3 -3
  40. package/dist/module/compiler/inheritance.test.js.map +1 -1
  41. package/dist/module/compiler/stylesheet.js +53 -19
  42. package/dist/module/compiler/stylesheet.js.map +1 -1
  43. package/dist/module/jest/index.js +23 -7
  44. package/dist/module/jest/index.js.map +1 -1
  45. package/dist/module/poison.pill.js +4 -1
  46. package/dist/module/poison.pill.js.map +1 -1
  47. package/dist/module/runtime/native/conditions/container-query.js +21 -21
  48. package/dist/module/runtime/native/conditions/container-query.js.map +1 -1
  49. package/dist/module/runtime/native/conditions/guards.js.map +1 -1
  50. package/dist/module/runtime/native/conditions/index.js +8 -8
  51. package/dist/module/runtime/native/conditions/index.js.map +1 -1
  52. package/dist/module/runtime/native/conditions/media-query.js +16 -16
  53. package/dist/module/runtime/native/conditions/media-query.js.map +1 -1
  54. package/dist/module/runtime/native/react/interaction.js +10 -10
  55. package/dist/module/runtime/native/react/interaction.js.map +1 -1
  56. package/dist/module/runtime/native/react/rules.js +9 -9
  57. package/dist/module/runtime/native/react/rules.js.map +1 -1
  58. package/dist/module/runtime/native/react/useNativeCss.js +1 -0
  59. package/dist/module/runtime/native/react/useNativeCss.js.map +1 -1
  60. package/dist/module/runtime/native/reactivity.js +15 -6
  61. package/dist/module/runtime/native/reactivity.js.map +1 -1
  62. package/dist/module/runtime/native/styles/index.js +12 -12
  63. package/dist/module/runtime/native/styles/index.js.map +1 -1
  64. package/dist/typescript/commonjs/src/compiler/compiler.d.ts +9 -2
  65. package/dist/typescript/commonjs/src/compiler/compiler.d.ts.map +1 -1
  66. package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts +5 -4
  67. package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts.map +1 -1
  68. package/dist/typescript/commonjs/src/compiler/declarations.d.ts +2 -1
  69. package/dist/typescript/commonjs/src/compiler/declarations.d.ts.map +1 -1
  70. package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts +12 -2
  71. package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -1
  72. package/dist/typescript/commonjs/src/jest/index.d.ts +10 -3
  73. package/dist/typescript/commonjs/src/jest/index.d.ts.map +1 -1
  74. package/dist/typescript/commonjs/src/poison.pill.d.ts.map +1 -1
  75. package/dist/typescript/commonjs/src/runtime/native/conditions/container-query.d.ts +3 -3
  76. package/dist/typescript/commonjs/src/runtime/native/conditions/container-query.d.ts.map +1 -1
  77. package/dist/typescript/commonjs/src/runtime/native/conditions/guards.d.ts +2 -2
  78. package/dist/typescript/commonjs/src/runtime/native/conditions/guards.d.ts.map +1 -1
  79. package/dist/typescript/commonjs/src/runtime/native/conditions/index.d.ts +2 -2
  80. package/dist/typescript/commonjs/src/runtime/native/conditions/index.d.ts.map +1 -1
  81. package/dist/typescript/commonjs/src/runtime/native/conditions/media-query.d.ts +2 -2
  82. package/dist/typescript/commonjs/src/runtime/native/conditions/media-query.d.ts.map +1 -1
  83. package/dist/typescript/commonjs/src/runtime/native/react/interaction.d.ts +2 -2
  84. package/dist/typescript/commonjs/src/runtime/native/react/interaction.d.ts.map +1 -1
  85. package/dist/typescript/commonjs/src/runtime/native/react/useNativeCss.d.ts +2 -1
  86. package/dist/typescript/commonjs/src/runtime/native/react/useNativeCss.d.ts.map +1 -1
  87. package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts +4 -4
  88. package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts.map +1 -1
  89. package/dist/typescript/module/src/compiler/compiler.d.ts +9 -2
  90. package/dist/typescript/module/src/compiler/compiler.d.ts.map +1 -1
  91. package/dist/typescript/module/src/compiler/compiler.types.d.ts +5 -4
  92. package/dist/typescript/module/src/compiler/compiler.types.d.ts.map +1 -1
  93. package/dist/typescript/module/src/compiler/declarations.d.ts +2 -1
  94. package/dist/typescript/module/src/compiler/declarations.d.ts.map +1 -1
  95. package/dist/typescript/module/src/compiler/stylesheet.d.ts +12 -2
  96. package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -1
  97. package/dist/typescript/module/src/jest/index.d.ts +10 -3
  98. package/dist/typescript/module/src/jest/index.d.ts.map +1 -1
  99. package/dist/typescript/module/src/poison.pill.d.ts.map +1 -1
  100. package/dist/typescript/module/src/runtime/native/conditions/container-query.d.ts +3 -3
  101. package/dist/typescript/module/src/runtime/native/conditions/container-query.d.ts.map +1 -1
  102. package/dist/typescript/module/src/runtime/native/conditions/guards.d.ts +2 -2
  103. package/dist/typescript/module/src/runtime/native/conditions/guards.d.ts.map +1 -1
  104. package/dist/typescript/module/src/runtime/native/conditions/index.d.ts +2 -2
  105. package/dist/typescript/module/src/runtime/native/conditions/index.d.ts.map +1 -1
  106. package/dist/typescript/module/src/runtime/native/conditions/media-query.d.ts +2 -2
  107. package/dist/typescript/module/src/runtime/native/conditions/media-query.d.ts.map +1 -1
  108. package/dist/typescript/module/src/runtime/native/react/interaction.d.ts +2 -2
  109. package/dist/typescript/module/src/runtime/native/react/interaction.d.ts.map +1 -1
  110. package/dist/typescript/module/src/runtime/native/react/useNativeCss.d.ts +2 -1
  111. package/dist/typescript/module/src/runtime/native/react/useNativeCss.d.ts.map +1 -1
  112. package/dist/typescript/module/src/runtime/native/reactivity.d.ts +4 -4
  113. package/dist/typescript/module/src/runtime/native/reactivity.d.ts.map +1 -1
  114. package/package.json +4 -3
  115. package/src/compiler/attributes.test.ts +1 -1
  116. package/src/compiler/compiler.ts +29 -24
  117. package/src/compiler/compiler.types.ts +7 -5
  118. package/src/compiler/declarations.ts +52 -8
  119. package/src/compiler/inheritance.test.ts +3 -3
  120. package/src/compiler/stylesheet.ts +67 -20
  121. package/src/jest/index.ts +30 -6
  122. package/src/poison.pill.ts +5 -1
  123. package/src/runtime/native/conditions/container-query.ts +22 -22
  124. package/src/runtime/native/conditions/guards.ts +1 -2
  125. package/src/runtime/native/conditions/index.ts +9 -9
  126. package/src/runtime/native/conditions/media-query.ts +17 -19
  127. package/src/runtime/native/react/interaction.ts +12 -12
  128. package/src/runtime/native/react/rules.ts +9 -9
  129. package/src/runtime/native/react/useNativeCss.ts +3 -0
  130. package/src/runtime/native/reactivity.ts +22 -13
  131. package/src/runtime/native/styles/index.ts +12 -12
@@ -17,6 +17,7 @@ import {
17
17
  VariableContext,
18
18
  type ContainerContextValue,
19
19
  type Effect,
20
+ type Getter,
20
21
  type VariableContextValue,
21
22
  } from "../reactivity";
22
23
  import { getStyledProps, stylesFamily } from "../styles";
@@ -35,6 +36,7 @@ export type ComponentState = {
35
36
 
36
37
  /** Reactive tracking */
37
38
  ruleEffect: Effect;
39
+ ruleEffectGetter: Getter;
38
40
  styleEffect: Effect;
39
41
 
40
42
  /** The components props */
@@ -94,6 +96,7 @@ export function useNativeCss(
94
96
  return updateRules(
95
97
  {
96
98
  ruleEffect,
99
+ ruleEffectGetter: (observable) => observable.get(ruleEffect),
97
100
  styleEffect,
98
101
  configs,
99
102
  inheritedContainers,
@@ -7,7 +7,8 @@ import {
7
7
  type LayoutRectangle,
8
8
  } from "react-native";
9
9
 
10
- import type { LightDarkVariable, StyleDescriptor } from "../../compiler";
10
+ import type { StyleDescriptor, VariableValue } from "../../compiler";
11
+ import { testMediaQuery } from "./conditions/media-query";
11
12
 
12
13
  export type Effect = {
13
14
  observers: Set<Effect>;
@@ -189,24 +190,32 @@ export const VariableContext = createContext<VariableContextValue>({
189
190
  [VAR_SYMBOL]: true,
190
191
  });
191
192
 
192
- const lightDarkFamily = () => {
193
- return family<string, Observable<StyleDescriptor, LightDarkVariable>>(() => {
194
- const obs = observable<StyleDescriptor, LightDarkVariable>(
195
- (read, lightDark = [undefined, undefined]) => {
196
- const colorSchemeName =
197
- read(colorScheme) ?? Appearance.getColorScheme() ?? "light";
193
+ const rootVariableFamily = () => {
194
+ return family<string, Observable<StyleDescriptor, VariableValue[]>>(() => {
195
+ const obs = observable<StyleDescriptor, VariableValue[]>(
196
+ (read, variableValue) => {
197
+ if (!variableValue) return undefined;
198
198
 
199
- return colorSchemeName === "dark"
200
- ? (lightDark[1] ?? lightDark[0])
201
- : lightDark[0];
199
+ for (const [value, mediaQuery] of variableValue) {
200
+ if (!mediaQuery) {
201
+ return value;
202
+ }
203
+
204
+ if (testMediaQuery(mediaQuery, read)) {
205
+ return value;
206
+ }
207
+ }
208
+
209
+ return undefined;
202
210
  },
203
211
  );
204
212
 
205
213
  return obs;
206
214
  });
207
215
  };
208
- export const rootVariables = lightDarkFamily();
209
- export const universalVariables = lightDarkFamily();
216
+
217
+ export const rootVariables = rootVariableFamily();
218
+ export const universalVariables = rootVariableFamily();
210
219
 
211
220
  /** Units *********************************************************************/
212
221
 
@@ -237,7 +246,7 @@ Appearance.addChangeListener((event) => colorScheme.set(event.colorScheme));
237
246
 
238
247
  /** Containers ****************************************************************/
239
248
 
240
- export type ContainerContextValue = Record<string, Effect>;
249
+ export type ContainerContextValue = Record<string, WeakKey>;
241
250
  export const ContainerContext = createContext<ContainerContextValue>({});
242
251
 
243
252
  export const containerLayoutFamily = weakFamily(() => {
@@ -55,57 +55,57 @@ export function getStyledProps(
55
55
  }
56
56
 
57
57
  // Apply the handlers
58
- if (hoverFamily.has(state.ruleEffect)) {
58
+ if (hoverFamily.has(state.ruleEffectGetter)) {
59
59
  result ??= {};
60
60
  result.onHoverIn = getInteractionHandler(
61
- state.ruleEffect,
61
+ state.ruleEffectGetter,
62
62
  "onHoverIn",
63
63
  inline?.onHoverIn,
64
64
  );
65
65
  result.onHoverOut = getInteractionHandler(
66
- state.ruleEffect,
66
+ state.ruleEffectGetter,
67
67
  "onHoverOut",
68
68
  inline?.onHoverOut,
69
69
  );
70
70
  }
71
71
 
72
- if (activeFamily.has(state.ruleEffect)) {
72
+ if (activeFamily.has(state.ruleEffectGetter)) {
73
73
  result ??= {};
74
74
  result.onPress = getInteractionHandler(
75
- state.ruleEffect,
75
+ state.ruleEffectGetter,
76
76
  "onPress",
77
77
  inline?.onPress,
78
78
  );
79
79
  result.onPressIn = getInteractionHandler(
80
- state.ruleEffect,
80
+ state.ruleEffectGetter,
81
81
  "onPressIn",
82
82
  inline?.onPressIn,
83
83
  );
84
84
  result.onPressOut = getInteractionHandler(
85
- state.ruleEffect,
85
+ state.ruleEffectGetter,
86
86
  "onPressOut",
87
87
  inline?.onPressOut,
88
88
  );
89
89
  }
90
90
 
91
- if (focusFamily.has(state.ruleEffect)) {
91
+ if (focusFamily.has(state.ruleEffectGetter)) {
92
92
  result ??= {};
93
93
  result.onBlur = getInteractionHandler(
94
- state.ruleEffect,
94
+ state.ruleEffectGetter,
95
95
  "onBlur",
96
96
  inline?.onBlur,
97
97
  );
98
98
  result.onFocus = getInteractionHandler(
99
- state.ruleEffect,
99
+ state.ruleEffectGetter,
100
100
  "onFocus",
101
101
  inline?.onFocus,
102
102
  );
103
103
  }
104
104
 
105
- if (containerLayoutFamily.has(state.ruleEffect)) {
105
+ if (containerLayoutFamily.has(state.ruleEffectGetter)) {
106
106
  result ??= {};
107
107
  result.onLayout = getInteractionHandler(
108
- state.ruleEffect,
108
+ state.ruleEffectGetter,
109
109
  "onLayout",
110
110
  inline?.onLayout,
111
111
  );