@expo/ui 58.0.22 → 58.0.24

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 (234) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/ui/ComposeViews.kt +53 -29
  4. package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +6 -4
  5. package/android/src/main/java/expo/modules/ui/HostView.kt +85 -15
  6. package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +40 -12
  7. package/android/src/main/java/expo/modules/ui/RNHostView.kt +138 -2
  8. package/android/src/main/java/expo/modules/ui/SliderView.kt +5 -4
  9. package/android/src/main/java/expo/modules/ui/UniversalLayout.kt +610 -0
  10. package/android/src/main/java/expo/modules/ui/VerticalSliderView.kt +5 -4
  11. package/android/src/main/java/expo/modules/ui/state/ObservableState.kt +2 -0
  12. package/android/src/main/java/expo/modules/ui/state/WorkletCallback.kt +2 -0
  13. package/build/community/bottom-sheet/BottomSheet.android.js +2 -0
  14. package/build/community/bottom-sheet/BottomSheet.android.js.map +1 -1
  15. package/build/community/menu/MenuView.ios.js +2 -1
  16. package/build/community/menu/MenuView.ios.js.map +1 -1
  17. package/build/jetpack-compose/Column/index.d.ts +5 -0
  18. package/build/jetpack-compose/Column/index.js.map +1 -1
  19. package/build/jetpack-compose/Row/index.d.ts +5 -0
  20. package/build/jetpack-compose/Row/index.js.map +1 -1
  21. package/build/jetpack-compose/Text/index.js +5 -4
  22. package/build/jetpack-compose/Text/index.js.map +1 -1
  23. package/build/recycling/useRecycledRows.d.ts +2 -0
  24. package/build/recycling/useRecycledRows.js +1 -0
  25. package/build/recycling/useRecycledRows.js.map +1 -1
  26. package/build/swift-ui/ContentUnavailableView/index.d.ts +5 -0
  27. package/build/swift-ui/ContentUnavailableView/index.js +7 -2
  28. package/build/swift-ui/ContentUnavailableView/index.js.map +1 -1
  29. package/build/swift-ui/HStack/index.d.ts +6 -0
  30. package/build/swift-ui/HStack/index.js.map +1 -1
  31. package/build/swift-ui/RNHostView.d.ts +7 -1
  32. package/build/swift-ui/RNHostView.js +2 -1
  33. package/build/swift-ui/RNHostView.js.map +1 -1
  34. package/build/swift-ui/Text/index.js +2 -1
  35. package/build/swift-ui/Text/index.js.map +1 -1
  36. package/build/swift-ui/VStack/index.d.ts +6 -0
  37. package/build/swift-ui/VStack/index.js.map +1 -1
  38. package/build/swift-ui/modifiers/index.d.ts +18 -0
  39. package/build/swift-ui/modifiers/index.js +9 -0
  40. package/build/swift-ui/modifiers/index.js.map +1 -1
  41. package/build/universal/BottomSheet/index.android.js +5 -5
  42. package/build/universal/BottomSheet/index.android.js.map +1 -1
  43. package/build/universal/Button/index.android.js +3 -1
  44. package/build/universal/Button/index.android.js.map +1 -1
  45. package/build/universal/Button/index.ios.js +3 -1
  46. package/build/universal/Button/index.ios.js.map +1 -1
  47. package/build/universal/Collapsible/index.ios.js +1 -0
  48. package/build/universal/Collapsible/index.ios.js.map +1 -1
  49. package/build/universal/Column/index.android.js +4 -1
  50. package/build/universal/Column/index.android.js.map +1 -1
  51. package/build/universal/Column/index.ios.js +2 -0
  52. package/build/universal/Column/index.ios.js.map +1 -1
  53. package/build/universal/Column/index.js +13 -4
  54. package/build/universal/Column/index.js.map +1 -1
  55. package/build/universal/FieldGroup/FieldGroup.android.js +3 -1
  56. package/build/universal/FieldGroup/FieldGroup.android.js.map +1 -1
  57. package/build/universal/FieldGroup/FieldGroup.ios.js +3 -1
  58. package/build/universal/FieldGroup/FieldGroup.ios.js.map +1 -1
  59. package/build/universal/FieldGroup/FieldSection.android.js +13 -4
  60. package/build/universal/FieldGroup/FieldSection.android.js.map +1 -1
  61. package/build/universal/FieldGroup/FieldSection.ios.js +3 -1
  62. package/build/universal/FieldGroup/FieldSection.ios.js.map +1 -1
  63. package/build/universal/Icon/index.android.js +3 -1
  64. package/build/universal/Icon/index.android.js.map +1 -1
  65. package/build/universal/Icon/index.ios.js +3 -1
  66. package/build/universal/Icon/index.ios.js.map +1 -1
  67. package/build/universal/List/ListForEach.android.d.ts +7 -0
  68. package/build/universal/List/ListForEach.android.js +6 -0
  69. package/build/universal/List/ListForEach.android.js.map +1 -0
  70. package/build/universal/List/ListForEach.d.ts +5 -0
  71. package/build/universal/List/ListForEach.ios.d.ts +5 -0
  72. package/build/universal/List/ListForEach.ios.js +11 -0
  73. package/build/universal/List/ListForEach.ios.js.map +1 -0
  74. package/build/universal/List/ListForEach.js +263 -0
  75. package/build/universal/List/ListForEach.js.map +1 -0
  76. package/build/universal/List/ListScrollContext.d.ts +5 -0
  77. package/build/universal/List/ListScrollContext.js +6 -0
  78. package/build/universal/List/ListScrollContext.js.map +1 -0
  79. package/build/universal/List/index.android.d.ts +5 -0
  80. package/build/universal/List/index.android.js +3 -0
  81. package/build/universal/List/index.android.js.map +1 -1
  82. package/build/universal/List/index.d.ts +5 -0
  83. package/build/universal/List/index.ios.d.ts +5 -0
  84. package/build/universal/List/index.ios.js +3 -0
  85. package/build/universal/List/index.ios.js.map +1 -1
  86. package/build/universal/List/index.js +12 -1
  87. package/build/universal/List/index.js.map +1 -1
  88. package/build/universal/List/types.d.ts +42 -1
  89. package/build/universal/List/types.js +1 -3
  90. package/build/universal/List/types.js.map +1 -1
  91. package/build/universal/RNHostView/index.android.js +3 -1
  92. package/build/universal/RNHostView/index.android.js.map +1 -1
  93. package/build/universal/Row/index.android.js +4 -1
  94. package/build/universal/Row/index.android.js.map +1 -1
  95. package/build/universal/Row/index.ios.js +2 -0
  96. package/build/universal/Row/index.ios.js.map +1 -1
  97. package/build/universal/Row/index.js +13 -7
  98. package/build/universal/Row/index.js.map +1 -1
  99. package/build/universal/ScrollView/index.android.js +8 -1
  100. package/build/universal/ScrollView/index.android.js.map +1 -1
  101. package/build/universal/ScrollView/index.ios.js +3 -1
  102. package/build/universal/ScrollView/index.ios.js.map +1 -1
  103. package/build/universal/Spacer/index.android.js +3 -1
  104. package/build/universal/Spacer/index.android.js.map +1 -1
  105. package/build/universal/Spacer/index.ios.js +3 -1
  106. package/build/universal/Spacer/index.ios.js.map +1 -1
  107. package/build/universal/Text/index.android.js +3 -1
  108. package/build/universal/Text/index.android.js.map +1 -1
  109. package/build/universal/Text/index.ios.js +3 -1
  110. package/build/universal/Text/index.ios.js.map +1 -1
  111. package/build/universal/TextInput/index.android.js +22 -7
  112. package/build/universal/TextInput/index.android.js.map +1 -1
  113. package/build/universal/TextInput/index.ios.js +1 -0
  114. package/build/universal/TextInput/index.ios.js.map +1 -1
  115. package/build/universal/index.d.ts +1 -1
  116. package/build/universal/modifierUtils.d.ts +34 -1
  117. package/build/universal/modifierUtils.js +98 -2
  118. package/build/universal/modifierUtils.js.map +1 -1
  119. package/build/universal/stackAxis.d.ts +9 -0
  120. package/build/universal/stackAxis.js +11 -0
  121. package/build/universal/stackAxis.js.map +1 -0
  122. package/build/universal/transformStyle.android.d.ts +6 -2
  123. package/build/universal/transformStyle.android.js +18 -11
  124. package/build/universal/transformStyle.android.js.map +1 -1
  125. package/build/universal/transformStyle.ios.d.ts +5 -1
  126. package/build/universal/transformStyle.ios.js +29 -11
  127. package/build/universal/transformStyle.ios.js.map +1 -1
  128. package/build/universal/types.d.ts +26 -1
  129. package/build/universal/types.js.map +1 -1
  130. package/build/utils/flattenFragments.d.ts +7 -0
  131. package/build/utils/flattenFragments.js +17 -0
  132. package/build/utils/flattenFragments.js.map +1 -0
  133. package/ios/ContentUnavailableView.swift +9 -1
  134. package/ios/GroupView.swift +3 -0
  135. package/ios/HStackView.swift +26 -2
  136. package/ios/HostView.swift +21 -12
  137. package/ios/Modifiers/FontModifier.swift +27 -0
  138. package/ios/Modifiers/SectionIndexLabelModifier.swift +21 -0
  139. package/ios/Modifiers/ViewModifierRegistry.swift +26 -0
  140. package/ios/RNHostView.swift +4 -0
  141. package/ios/ScrollViewComponent.swift +20 -0
  142. package/ios/UIBaseView.swift +4 -1
  143. package/ios/UniversalLayout.swift +691 -0
  144. package/ios/VStackView.swift +26 -2
  145. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.22/expo.modules.ui-58.0.22-sources.jar → 58.0.24/expo.modules.ui-58.0.24-sources.jar} +0 -0
  146. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24-sources.jar.md5 +1 -0
  147. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24-sources.jar.sha1 +1 -0
  148. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24-sources.jar.sha256 +1 -0
  149. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24-sources.jar.sha512 +1 -0
  150. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.aar +0 -0
  151. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.aar.md5 +1 -0
  152. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.aar.sha1 +1 -0
  153. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.aar.sha256 +1 -0
  154. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.aar.sha512 +1 -0
  155. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.22/expo.modules.ui-58.0.22.module → 58.0.24/expo.modules.ui-58.0.24.module} +22 -22
  156. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.module.md5 +1 -0
  157. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.module.sha1 +1 -0
  158. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.module.sha256 +1 -0
  159. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.module.sha512 +1 -0
  160. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.22/expo.modules.ui-58.0.22.pom → 58.0.24/expo.modules.ui-58.0.24.pom} +1 -1
  161. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.pom.md5 +1 -0
  162. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.pom.sha1 +1 -0
  163. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.pom.sha256 +1 -0
  164. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.pom.sha512 +1 -0
  165. package/package.json +1 -1
  166. package/src/community/bottom-sheet/BottomSheet.android.tsx +2 -1
  167. package/src/community/menu/MenuView.ios.tsx +3 -2
  168. package/src/jetpack-compose/Column/index.tsx +5 -0
  169. package/src/jetpack-compose/Row/index.tsx +5 -0
  170. package/src/jetpack-compose/Text/index.tsx +5 -4
  171. package/src/recycling/useRecycledRows.tsx +3 -0
  172. package/src/swift-ui/ContentUnavailableView/index.tsx +19 -4
  173. package/src/swift-ui/HStack/index.tsx +6 -0
  174. package/src/swift-ui/RNHostView.tsx +8 -1
  175. package/src/swift-ui/Text/index.tsx +2 -1
  176. package/src/swift-ui/VStack/index.tsx +6 -0
  177. package/src/swift-ui/modifiers/index.ts +19 -0
  178. package/src/universal/BottomSheet/index.android.tsx +3 -1
  179. package/src/universal/Button/index.android.tsx +3 -1
  180. package/src/universal/Button/index.ios.tsx +2 -1
  181. package/src/universal/Collapsible/index.ios.tsx +4 -1
  182. package/src/universal/Column/index.android.tsx +3 -1
  183. package/src/universal/Column/index.ios.tsx +2 -1
  184. package/src/universal/Column/index.tsx +9 -4
  185. package/src/universal/FieldGroup/FieldGroup.android.tsx +8 -1
  186. package/src/universal/FieldGroup/FieldGroup.ios.tsx +2 -1
  187. package/src/universal/FieldGroup/FieldSection.android.tsx +17 -4
  188. package/src/universal/FieldGroup/FieldSection.ios.tsx +2 -1
  189. package/src/universal/Icon/index.android.tsx +2 -1
  190. package/src/universal/Icon/index.ios.tsx +2 -1
  191. package/src/universal/List/ListForEach.android.tsx +6 -0
  192. package/src/universal/List/ListForEach.ios.tsx +9 -0
  193. package/src/universal/List/ListForEach.tsx +246 -0
  194. package/src/universal/List/ListScrollContext.ts +6 -0
  195. package/src/universal/List/index.android.tsx +5 -0
  196. package/src/universal/List/index.ios.tsx +5 -0
  197. package/src/universal/List/index.tsx +11 -2
  198. package/src/universal/List/types.ts +45 -1
  199. package/src/universal/RNHostView/index.android.tsx +2 -1
  200. package/src/universal/Row/index.android.tsx +3 -1
  201. package/src/universal/Row/index.ios.tsx +2 -1
  202. package/src/universal/Row/index.tsx +9 -10
  203. package/src/universal/ScrollView/index.android.tsx +15 -3
  204. package/src/universal/ScrollView/index.ios.tsx +2 -1
  205. package/src/universal/Spacer/index.android.tsx +6 -4
  206. package/src/universal/Spacer/index.ios.tsx +2 -1
  207. package/src/universal/Text/index.android.tsx +2 -1
  208. package/src/universal/Text/index.ios.tsx +2 -1
  209. package/src/universal/TextInput/index.android.tsx +26 -5
  210. package/src/universal/TextInput/index.ios.tsx +1 -1
  211. package/src/universal/index.ts +6 -1
  212. package/src/universal/modifierUtils.ts +159 -2
  213. package/src/universal/stackAxis.ts +17 -0
  214. package/src/universal/transformStyle.android.ts +30 -12
  215. package/src/universal/transformStyle.ios.ts +41 -13
  216. package/src/universal/types.ts +27 -3
  217. package/src/utils/flattenFragments.ts +22 -0
  218. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22-sources.jar.md5 +0 -1
  219. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22-sources.jar.sha1 +0 -1
  220. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22-sources.jar.sha256 +0 -1
  221. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22-sources.jar.sha512 +0 -1
  222. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar +0 -0
  223. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar.md5 +0 -1
  224. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar.sha1 +0 -1
  225. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar.sha256 +0 -1
  226. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar.sha512 +0 -1
  227. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.module.md5 +0 -1
  228. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.module.sha1 +0 -1
  229. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.module.sha256 +0 -1
  230. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.module.sha512 +0 -1
  231. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.pom.md5 +0 -1
  232. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.pom.sha1 +0 -1
  233. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.pom.sha256 +0 -1
  234. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.pom.sha512 +0 -1
@@ -26,6 +26,17 @@ function mapReturnKeyType(value: ReturnKeyTypeOptions): TextFieldImeAction {
26
26
  return value as TextFieldImeAction;
27
27
  }
28
28
 
29
+ function mapSecureKeyboardType(value: KeyboardTypeOptions | undefined): TextFieldKeyboardType {
30
+ switch (value) {
31
+ case 'numeric':
32
+ case 'number-pad':
33
+ case 'decimal-pad':
34
+ return 'numberPassword';
35
+ default:
36
+ return 'password';
37
+ }
38
+ }
39
+
29
40
  function mapKeyboardType(value: KeyboardTypeOptions): TextFieldKeyboardType {
30
41
  switch (value) {
31
42
  case 'default':
@@ -133,12 +144,23 @@ export function TextInput({
133
144
  else onBlur?.();
134
145
  };
135
146
 
147
+ // `visualTransformation` only masks the text. The keyboard reads the keyboard type,
148
+ // so a secure field also needs a password type.
149
+ const resolvedKeyboardType = secureTextEntry
150
+ ? mapSecureKeyboardType(keyboardType)
151
+ : keyboardType
152
+ ? mapKeyboardType(keyboardType)
153
+ : undefined;
154
+ const resolvedAutoCorrect = secureTextEntry ? false : autoCorrect;
155
+
136
156
  const keyboardOptions =
137
- keyboardType || autoCapitalize || autoCorrect !== undefined || returnKeyType
157
+ resolvedKeyboardType || autoCapitalize || resolvedAutoCorrect !== undefined || returnKeyType
138
158
  ? {
139
- ...(keyboardType ? { keyboardType: mapKeyboardType(keyboardType) } : null),
159
+ ...(resolvedKeyboardType ? { keyboardType: resolvedKeyboardType } : null),
140
160
  ...(autoCapitalize ? { capitalization: autoCapitalize } : null),
141
- ...(autoCorrect !== undefined ? { autoCorrectEnabled: autoCorrect } : null),
161
+ ...(resolvedAutoCorrect !== undefined
162
+ ? { autoCorrectEnabled: resolvedAutoCorrect }
163
+ : null),
142
164
  ...(returnKeyType ? { imeAction: mapReturnKeyType(returnKeyType) } : null),
143
165
  }
144
166
  : undefined;
@@ -158,8 +180,7 @@ export function TextInput({
158
180
  <BasicTextField
159
181
  ref={innerRef}
160
182
  modifiers={[
161
- ...(userModifiers ?? []),
162
- ...transformToModifiers(style, {}),
183
+ ...transformToModifiers(style, {}, userModifiers, { componentName: 'TextInput' }),
163
184
  ...(testID ? [testIDModifier(testID)] : []),
164
185
  ...(autoComplete ? [semantics({ contentType: autoComplete })] : []),
165
186
  ...(onContentSizeChange ? [onSizeChanged(onContentSizeChange)] : []),
@@ -149,7 +149,7 @@ export function TextInput({
149
149
 
150
150
  const modifiers: ModifierConfig[] = [
151
151
  ...(userModifiers ?? []),
152
- ...transformToModifiers(style, {}, undefined, { textStyle }),
152
+ ...transformToModifiers(style, {}, undefined, { componentName: 'TextInput', textStyle }),
153
153
  ];
154
154
  if (editable === false) modifiers.push(disabledMod(true));
155
155
  if (keyboardType) modifiers.push(keyboardTypeMod(mapKeyboardType(keyboardType)));
@@ -19,4 +19,9 @@ export * from './Spacer';
19
19
  export * from './State';
20
20
  export { TextInput, type TextInputProps, type TextInputRef } from './TextInput';
21
21
 
22
- export type { UniversalStyle, UniversalAlignment, UniversalBaseProps } from './types';
22
+ export type {
23
+ UniversalStyle,
24
+ UniversalAlignment,
25
+ UniversalBaseProps,
26
+ UniversalDimension,
27
+ } from './types';
@@ -13,11 +13,168 @@ import type { ModifierConfig } from '../types';
13
13
  */
14
14
  export function omitUserOverridden<T extends { $type: string }>(
15
15
  derived: T[],
16
- userModifiers?: readonly ModifierConfig[]
16
+ userModifiers?: readonly ModifierConfig[],
17
+ preservedTypes?: ReadonlySet<string>
17
18
  ): T[] {
18
19
  if (!userModifiers?.length) {
19
20
  return derived;
20
21
  }
21
22
  const userTypes = new Set(userModifiers.map((modifier) => modifier.$type));
22
- return derived.filter((modifier) => !userTypes.has(modifier.$type));
23
+ return derived.filter(
24
+ (modifier) => preservedTypes?.has(modifier.$type) || !userTypes.has(modifier.$type)
25
+ );
26
+ }
27
+
28
+ /**
29
+ * A fixed size in density-independent pixels, or a percentage of the parent.
30
+ * `'50%'` is half of the parent's content size on that axis.
31
+ * @docsInline
32
+ */
33
+ export type UniversalDimension = number | `${number}%` | null;
34
+
35
+ export type SerializedUniversalDimensions = {
36
+ widthPoints?: number;
37
+ widthFraction?: number;
38
+ heightPoints?: number;
39
+ heightFraction?: number;
40
+ };
41
+
42
+ export type UniversalLayoutPlatform = 'android' | 'ios';
43
+
44
+ type UniversalDimensionStyle = {
45
+ width?: unknown;
46
+ height?: unknown;
47
+ };
48
+
49
+ type DimensionAxis = 'width' | 'height';
50
+
51
+ const PERCENTAGE_PATTERN = /^(?:\d+(?:\.\d+)?|\.\d+)%$/;
52
+ const warnedInvalidDimensions = new Set<string>();
53
+
54
+ function warnInvalidDimension(componentName: string, axis: DimensionAxis, value: unknown): void {
55
+ if (!__DEV__) return;
56
+
57
+ const warningKey = `${componentName}:${axis}`;
58
+ if (warnedInvalidDimensions.has(warningKey)) return;
59
+ warnedInvalidDimensions.add(warningKey);
60
+
61
+ console.warn(
62
+ `[Expo UI] Ignoring invalid ${axis} on ${componentName}: ${String(value)}. ` +
63
+ 'Expected a finite, non-negative number or percentage.'
64
+ );
65
+ }
66
+
67
+ function serializeDimension(
68
+ value: unknown,
69
+ componentName: string,
70
+ axis: DimensionAxis
71
+ ): { points?: number; fraction?: number } {
72
+ if (value == null) return {};
73
+
74
+ if (typeof value === 'number') {
75
+ if (Number.isFinite(value) && value >= 0) return { points: value };
76
+ warnInvalidDimension(componentName, axis, value);
77
+ return {};
78
+ }
79
+
80
+ if (typeof value === 'string' && PERCENTAGE_PATTERN.test(value)) {
81
+ const percentage = Number(value.slice(0, -1));
82
+ if (Number.isFinite(percentage) && percentage >= 0) {
83
+ return { fraction: percentage / 100 };
84
+ }
85
+ }
86
+
87
+ warnInvalidDimension(componentName, axis, value);
88
+ return {};
89
+ }
90
+
91
+ export function serializeUniversalDimensions(
92
+ style: UniversalDimensionStyle | undefined,
93
+ componentName = 'universal component'
94
+ ): SerializedUniversalDimensions {
95
+ const width = serializeDimension(style?.width, componentName, 'width');
96
+ const height = serializeDimension(style?.height, componentName, 'height');
97
+
98
+ return {
99
+ widthPoints: width.points,
100
+ widthFraction: width.fraction,
101
+ heightPoints: height.points,
102
+ heightFraction: height.fraction,
103
+ };
104
+ }
105
+
106
+ /**
107
+ * Which axes a user modifier already owns.
108
+ * `weight` applies to the parent's main axis, so the cross axis still comes from `style`.
109
+ * `defaultMinSize` only applies when the incoming constraint is 0, so it does not replace a size.
110
+ * A `frame` owns an axis only when it sets `width` or `height`.
111
+ * A minimum or maximum limits that size.
112
+ */
113
+ export function getUserSizingOverrides(
114
+ userModifiers: readonly ModifierConfig[] | undefined,
115
+ platform: UniversalLayoutPlatform
116
+ ): { width: boolean; height: boolean } {
117
+ let width = false;
118
+ let height = false;
119
+
120
+ for (const modifier of userModifiers ?? []) {
121
+ if (platform === 'android') {
122
+ if (modifier.$type === 'size' || modifier.$type === 'fillMaxSize') {
123
+ width = true;
124
+ height = true;
125
+ } else if (
126
+ modifier.$type === 'width' ||
127
+ modifier.$type === 'fillMaxWidth' ||
128
+ modifier.$type === 'wrapContentWidth'
129
+ ) {
130
+ width = true;
131
+ } else if (
132
+ modifier.$type === 'height' ||
133
+ modifier.$type === 'fillMaxHeight' ||
134
+ modifier.$type === 'wrapContentHeight'
135
+ ) {
136
+ height = true;
137
+ }
138
+ continue;
139
+ }
140
+
141
+ if (modifier.$type === 'frame') {
142
+ width ||= modifier.width != null;
143
+ height ||= modifier.height != null;
144
+ } else if (modifier.$type === 'containerRelativeFrame') {
145
+ width ||= modifier.axes === 'horizontal' || modifier.axes === 'both';
146
+ height ||= modifier.axes === 'vertical' || modifier.axes === 'both';
147
+ } else if (modifier.$type === 'fixedSize') {
148
+ const hasExplicitAxis = modifier.horizontal != null || modifier.vertical != null;
149
+ width ||= hasExplicitAxis ? modifier.horizontal === true : true;
150
+ height ||= hasExplicitAxis ? modifier.vertical === true : true;
151
+ }
152
+ }
153
+
154
+ return { width, height };
155
+ }
156
+
157
+ export function omitUserOverriddenDimensions(
158
+ dimensions: SerializedUniversalDimensions,
159
+ userModifiers: readonly ModifierConfig[] | undefined,
160
+ platform: UniversalLayoutPlatform
161
+ ): SerializedUniversalDimensions {
162
+ const overrides = getUserSizingOverrides(userModifiers, platform);
163
+ return {
164
+ widthPoints: overrides.width ? undefined : dimensions.widthPoints,
165
+ widthFraction: overrides.width ? undefined : dimensions.widthFraction,
166
+ heightPoints: overrides.height ? undefined : dimensions.heightPoints,
167
+ heightFraction: overrides.height ? undefined : dimensions.heightFraction,
168
+ };
169
+ }
170
+
171
+ export function createUniversalLayoutModifier(
172
+ dimensions: SerializedUniversalDimensions
173
+ ): ModifierConfig | undefined {
174
+ const hasDimension = Object.values(dimensions).some((value) => value != null);
175
+ return hasDimension ? { $type: 'universalLayout', ...dimensions } : undefined;
176
+ }
177
+
178
+ export function resetUniversalDimensionWarningsForTests(): void {
179
+ warnedInvalidDimensions.clear();
23
180
  }
@@ -0,0 +1,17 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ import type { UniversalStyle } from './types';
4
+
5
+ export type StackAxis = 'horizontal' | 'vertical';
6
+
7
+ /**
8
+ * Main axis of the nearest universal `Row` or `Column` on web.
9
+ * A plain view lays its children out vertically, so that is the default.
10
+ */
11
+ export const StackAxisContext = createContext<StackAxis>('vertical');
12
+
13
+ /** The size `style` sets on the parent's cross axis, if any. */
14
+ export function useCrossAxisSize(style: UniversalStyle | undefined) {
15
+ const parentAxis = useContext(StackAxisContext);
16
+ return parentAxis === 'horizontal' ? style?.height : style?.width;
17
+ }
@@ -14,7 +14,12 @@ import {
14
14
  type ModifierConfig,
15
15
  } from '@expo/ui/jetpack-compose/modifiers';
16
16
 
17
- import { omitUserOverridden } from './modifierUtils';
17
+ import {
18
+ createUniversalLayoutModifier,
19
+ omitUserOverridden,
20
+ omitUserOverriddenDimensions,
21
+ serializeUniversalDimensions,
22
+ } from './modifierUtils';
18
23
  import type { UniversalBaseProps, UniversalStyle } from './types';
19
24
 
20
25
  /**
@@ -23,29 +28,42 @@ import type { UniversalBaseProps, UniversalStyle } from './types';
23
28
  *
24
29
  * Compose modifiers apply outside-in (left to right). To match React Native's
25
30
  * box model where background includes the padding area and border is outermost:
26
- * sizing → border → clip → background → padding → opacity
31
+ * universal layout → fixed size → border → clip → background → padding → opacity
27
32
  * → events → behavior → user escape-hatch
28
33
  *
34
+ * Fixed sizes become `size`, `width`, or `height`.
35
+ * Percentages stay on `universalLayout` so the parent stack can resolve them.
29
36
  * Style-derived modifiers yield to user-supplied modifiers of the same
30
37
  * `$type`, so the escape hatch can override anything derived from props.
31
38
  */
32
39
  export function transformToModifiers(
33
40
  style: UniversalStyle | undefined,
34
41
  props: Pick<UniversalBaseProps, 'onPress' | 'disabled' | 'hidden' | 'testID'>,
35
- extraModifiers?: ModifierConfig[]
42
+ extraModifiers?: ModifierConfig[],
43
+ options?: { componentName?: string }
36
44
  ): ModifierConfig[] {
37
45
  let mods: ModifierConfig[] = [];
46
+ const dimensions = omitUserOverriddenDimensions(
47
+ serializeUniversalDimensions(style, options?.componentName),
48
+ extraModifiers,
49
+ 'android'
50
+ );
51
+ const fixedWidth = dimensions.widthPoints;
52
+ const fixedHeight = dimensions.heightPoints;
53
+ const universalLayoutModifier = createUniversalLayoutModifier(dimensions);
38
54
 
39
- if (style) {
40
- // Sizing (outermost)
41
- if (style.width != null && style.height != null) {
42
- mods.push(size(style.width as number, style.height as number));
43
- } else if (style.width != null) {
44
- mods.push(width(style.width as number));
45
- } else if (style.height != null) {
46
- mods.push(height(style.height as number));
47
- }
55
+ if (universalLayoutModifier) mods.push(universalLayoutModifier);
48
56
 
57
+ // Fixed sizing is applied directly. Percentages remain as parent data for
58
+ // the owning universal layout to resolve against its content box.
59
+ if (fixedWidth != null && fixedHeight != null) {
60
+ mods.push(size(fixedWidth, fixedHeight));
61
+ } else {
62
+ if (fixedWidth != null) mods.push(width(fixedWidth));
63
+ if (fixedHeight != null) mods.push(height(fixedHeight));
64
+ }
65
+
66
+ if (style) {
49
67
  // Border + background + borderRadius handling.
50
68
  // Compose's border() doesn't accept a shape, so when borderRadius is set
51
69
  // alongside border, we simulate a rounded border using layered backgrounds:
@@ -21,9 +21,18 @@ import {
21
21
  } from '@expo/ui/swift-ui/modifiers';
22
22
 
23
23
  import type { UniversalTextStyle } from './Text/types';
24
- import { omitUserOverridden } from './modifierUtils';
24
+ import {
25
+ createUniversalLayoutModifier,
26
+ omitUserOverridden,
27
+ omitUserOverriddenDimensions,
28
+ serializeUniversalDimensions,
29
+ } from './modifierUtils';
25
30
  import type { UniversalBaseProps, UniversalStyle } from './types';
26
31
 
32
+ // A user frame owns only the axes it sets. Keep a derived frame that still
33
+ // owns the other axis, and keep the layout value the parent stack reads.
34
+ const preservedSizingTypes = new Set(['frame', 'universalLayout']);
35
+
27
36
  const FONT_WEIGHT_MAP: Record<string, Parameters<typeof font>[0]['weight']> = {
28
37
  '100': 'ultraLight',
29
38
  '200': 'thin',
@@ -44,9 +53,11 @@ const FONT_WEIGHT_MAP: Record<string, Parameters<typeof font>[0]['weight']> = {
44
53
  *
45
54
  * SwiftUI modifiers apply inside-out (each modifier wraps the previous).
46
55
  * To match React Native's box model (background fills the full box):
47
- * padding → sizing → background → clip → border → opacity
56
+ * padding → fixed frame → universal layout → background → border → clip → opacity
48
57
  * → events → lifecycle → behavior → user escape-hatch
49
58
  *
59
+ * Fixed sizes become a `frame`.
60
+ * Percentages stay on `universalLayout` so the parent stack can resolve them.
50
61
  * Style-derived modifiers yield to user-supplied modifiers of the same
51
62
  * `$type`, so the escape hatch can override anything derived from props.
52
63
  */
@@ -58,6 +69,8 @@ export function transformToModifiers(
58
69
  >,
59
70
  extraModifiers?: ModifierConfig[],
60
71
  options?: {
72
+ /** Component name included in invalid-dimension development warnings. */
73
+ componentName?: string;
61
74
  /** Alignment for the frame modifier (used by Column/Row). */
62
75
  frameAlignment?: Parameters<typeof frame>[0]['alignment'];
63
76
  /** Text-styling props for text-rendering components. */
@@ -65,6 +78,13 @@ export function transformToModifiers(
65
78
  }
66
79
  ): ModifierConfig[] {
67
80
  let mods: ModifierConfig[] = [];
81
+ const dimensions = omitUserOverriddenDimensions(
82
+ serializeUniversalDimensions(style, options?.componentName),
83
+ extraModifiers,
84
+ 'ios'
85
+ );
86
+ const fixedWidth = dimensions.widthPoints;
87
+ const fixedHeight = dimensions.heightPoints;
68
88
 
69
89
  // Text styling (innermost — applies to text content before container modifiers)
70
90
  const textStyle = options?.textStyle;
@@ -119,18 +139,24 @@ export function transformToModifiers(
119
139
  })
120
140
  );
121
141
  }
142
+ }
122
143
 
123
- // Sizing (before background so background fills the frame)
124
- if (style.width != null || style.height != null) {
125
- mods.push(
126
- frame({
127
- width: style.width as number | undefined,
128
- height: style.height as number | undefined,
129
- alignment: options?.frameAlignment,
130
- })
131
- );
132
- }
144
+ // Fixed sizing is applied directly. Percentages remain as layout values for
145
+ // the owning universal layout to resolve against its content box.
146
+ if (fixedWidth != null || fixedHeight != null) {
147
+ mods.push(
148
+ frame({
149
+ width: fixedWidth,
150
+ height: fixedHeight,
151
+ alignment: options?.frameAlignment,
152
+ })
153
+ );
154
+ }
133
155
 
156
+ const universalLayoutModifier = createUniversalLayoutModifier(dimensions);
157
+ if (universalLayoutModifier) mods.push(universalLayoutModifier);
158
+
159
+ if (style) {
134
160
  // Background (fills the frame area including padding)
135
161
  if (style.backgroundColor) {
136
162
  mods.push(background(style.backgroundColor));
@@ -154,7 +180,9 @@ export function transformToModifiers(
154
180
 
155
181
  // A user-supplied modifier replaces any style-derived modifier of the same
156
182
  // type. The event, lifecycle, and behavior modifiers below are never dropped.
157
- mods = omitUserOverridden(mods, extraModifiers);
183
+ // Axis-aware sizing precedence has already removed only the dimensions set
184
+ // by a user frame. Preserve any derived frame that still owns the other axis.
185
+ mods = omitUserOverridden(mods, extraModifiers, preservedSizingTypes);
158
186
 
159
187
  // Events. SwiftUI only hit-tests drawn content, so the `contentShape` lets
160
188
  // taps on empty space (for example a `Spacer` in a `Row`) reach `onPress`.
@@ -1,10 +1,21 @@
1
1
  import type { ViewStyle } from 'react-native';
2
2
 
3
3
  import type { ModifierConfig } from '../types';
4
+ import type { UniversalDimension } from './modifierUtils';
5
+
6
+ export type { UniversalDimension } from './modifierUtils';
4
7
 
5
8
  /**
6
9
  * Subset of React Native `ViewStyle` that maps cleanly to both SwiftUI modifiers
7
10
  * and Jetpack Compose modifiers. On web, passes through to React Native StyleSheet.
11
+ *
12
+ * `width` and `height` also accept a percentage of the parent, such as `'50%'`.
13
+ * On Android and iOS, a percentage resolves when the parent is a universal `Row`, `Column`,
14
+ * or `Host` with a size on that axis.
15
+ * A universal `ScrollView` resolves the cross axis only.
16
+ * The scroll axis stays unbounded.
17
+ * On web, the value is passed through to the view style.
18
+ * A Jetpack Compose `Row` or `Column`, or a SwiftUI stack, does not resolve it.
8
19
  * @docsInline
9
20
  */
10
21
  export type UniversalStyle = Pick<
@@ -21,9 +32,22 @@ export type UniversalStyle = Pick<
21
32
  | 'borderWidth'
22
33
  | 'borderColor'
23
34
  | 'opacity'
24
- | 'width'
25
- | 'height'
26
- >;
35
+ > & {
36
+ /**
37
+ * Fixed size in density-independent pixels, or a percentage of the parent's content width.
38
+ * On Android and iOS, percentages resolve when the parent is a universal `Row`, `Column`,
39
+ * `ScrollView`, or `Host` with a defined width.
40
+ * A horizontal `ScrollView` leaves width unbounded.
41
+ */
42
+ width?: UniversalDimension;
43
+ /**
44
+ * Fixed size in density-independent pixels, or a percentage of the parent's content height.
45
+ * On Android and iOS, percentages resolve when the parent is a universal `Row`, `Column`,
46
+ * `ScrollView`, or `Host` with a defined height.
47
+ * A vertical `ScrollView` leaves height unbounded.
48
+ */
49
+ height?: UniversalDimension;
50
+ };
27
51
 
28
52
  /**
29
53
  * Base props inherited by all universal components.
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * Like `React.Children.toArray`, but also flattens `React.Fragment` children so
5
+ * their contents are treated as direct children. Keys of nested elements are
6
+ * prefixed with the fragment's key to stay unique.
7
+ */
8
+ export function flattenFragments(children: React.ReactNode): React.ReactNode[] {
9
+ return React.Children.toArray(children).flatMap((child) => {
10
+ if (
11
+ React.isValidElement<{ children?: React.ReactNode }>(child) &&
12
+ child.type === React.Fragment
13
+ ) {
14
+ return flattenFragments(child.props.children).map((nested) =>
15
+ React.isValidElement(nested)
16
+ ? React.cloneElement(nested, { key: `${child.key}${nested.key}` })
17
+ : nested
18
+ );
19
+ }
20
+ return child;
21
+ });
22
+ }
@@ -1 +0,0 @@
1
- a1628408f238e018286c0c9887ebb3cf9912577d
@@ -1 +0,0 @@
1
- 2487d657c68bf866e677ef379bc97b7de37edb41eb173b6d8d938b81bfcb2293
@@ -1 +0,0 @@
1
- 6c228c1dcbe9ee23cca52ba20eb724d39d18533e6c31ad738ab5738e5dfc64432b7c79363f7ff772f019f8bda955d0d38ccb3f4331d3236e4beddd70e6e426f4
@@ -1 +0,0 @@
1
- 7acd625f3cd50ad228fac699424fcff3c77942bb
@@ -1 +0,0 @@
1
- 59cc7013ee6674f030b4f81641fa80fb1829815d6ab5a7903f0e7479e6adb96e
@@ -1 +0,0 @@
1
- 0a89be2233ee1dd16b1cb671e0694d6d9a428f7f199e3e3efcdd621090c541d435478b39402a6da271373a70cbed690f989e938ebcbbcd35b740e1bf240dfb64
@@ -1 +0,0 @@
1
- 0ca2cbc2529c5570d31a5cbd827f2b9c58602e25
@@ -1 +0,0 @@
1
- 113bc88759a3cbbb991dc12571a1b53722855970232edf6508469dc52c822423
@@ -1 +0,0 @@
1
- ef4e3b199c2d69deab60d857ef81dc8c786f2bdc5a4321e9397111507d9f235c8575cd91289d8c612666b901cadd7aeca414aece1769dca15ec2088f5b8c0cb4
@@ -1 +0,0 @@
1
- 2a13240cd35aa73ed4d9787b4a70cbe0453431dd
@@ -1 +0,0 @@
1
- c15bb9d564da8ea75a501e89d3c855df5294966438d81168675388dab731e23e
@@ -1 +0,0 @@
1
- a1a75142fcd486afa2e7bd2f27cdc21e1997cb309fb762963b61e65c88fd6e5a62af5234f448b485b0a2f3081f74eb1c8664e9d08a1f1a445ca2c62639e7f3f1