@expo/ui 0.1.1-alpha.8 → 0.1.1-alpha.9

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 (51) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/android/build.gradle +2 -2
  3. package/build/swift-ui/Button/index.d.ts +5 -4
  4. package/build/swift-ui/Button/index.d.ts.map +1 -1
  5. package/build/swift-ui/Button/index.js +10 -5
  6. package/build/swift-ui/Button/index.js.map +1 -1
  7. package/build/swift-ui/ContextMenu/utils.js +8 -2
  8. package/build/swift-ui/ContextMenu/utils.js.map +1 -1
  9. package/expo-module.config.json +1 -1
  10. package/ios/Button/Button.swift +7 -3
  11. package/ios/Button/ButtonProps.swift +1 -1
  12. package/ios/DisclosureGroupView.swift +4 -0
  13. package/ios/FormView.swift +1 -1
  14. package/ios/Modifiers/View+GestureModifiers.swift +9 -7
  15. package/ios/SliderView.swift +1 -1
  16. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.module → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.module} +7 -7
  17. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.module.md5 +1 -0
  18. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.module.sha1 +1 -0
  19. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.module.sha256 +1 -0
  20. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.module.sha512 +1 -0
  21. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.pom → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.pom} +1 -1
  22. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.pom.md5 +1 -0
  23. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.pom.sha1 +1 -0
  24. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.pom.sha256 +1 -0
  25. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.pom.sha512 +1 -0
  26. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml +4 -4
  27. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.md5 +1 -1
  28. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha1 +1 -1
  29. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha256 +1 -1
  30. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha512 +1 -1
  31. package/package.json +2 -2
  32. package/src/swift-ui/Button/index.tsx +17 -8
  33. package/src/swift-ui/ContextMenu/utils.ts +8 -3
  34. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.module.md5 +0 -1
  35. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.module.sha1 +0 -1
  36. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.module.sha256 +0 -1
  37. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.module.sha512 +0 -1
  38. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.pom.md5 +0 -1
  39. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.pom.sha1 +0 -1
  40. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.pom.sha256 +0 -1
  41. package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.pom.sha512 +0 -1
  42. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8-sources.jar → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9-sources.jar} +0 -0
  43. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8-sources.jar.md5 → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9-sources.jar.md5} +0 -0
  44. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8-sources.jar.sha1 → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9-sources.jar.sha1} +0 -0
  45. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8-sources.jar.sha256 → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9-sources.jar.sha256} +0 -0
  46. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8-sources.jar.sha512 → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9-sources.jar.sha512} +0 -0
  47. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.aar → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.aar} +0 -0
  48. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.aar.md5 → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.aar.md5} +0 -0
  49. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.aar.sha1 → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.aar.sha1} +0 -0
  50. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.aar.sha256 → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.aar.sha256} +0 -0
  51. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.8/expo.modules.ui-0.1.1-alpha.8.aar.sha512 → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.aar.sha512} +0 -0
package/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.1.1-alpha.9 — 2025-06-08
14
+
15
+ ### 🎉 New features
16
+
17
+ - Allowed custom children in SwiftUI Button. ([#37136](https://github.com/expo/expo/pull/37136) by [@kudo](https://github.com/kudo))
18
+
13
19
  ## 0.1.1-alpha.8 — 2025-06-04
14
20
 
15
21
  ### 🎉 New features
@@ -12,13 +12,13 @@ apply plugin: 'expo-module-gradle-plugin'
12
12
  apply plugin: 'org.jetbrains.kotlin.plugin.compose'
13
13
 
14
14
  group = 'expo.modules.ui'
15
- version = '0.1.1-alpha.8'
15
+ version = '0.1.1-alpha.9'
16
16
 
17
17
  android {
18
18
  namespace "expo.modules.ui"
19
19
  defaultConfig {
20
20
  versionCode 1
21
- versionName "0.1.1-alpha.8"
21
+ versionName "0.1.1-alpha.9"
22
22
  }
23
23
  buildFeatures {
24
24
  compose true
@@ -30,6 +30,7 @@ export type ButtonProps = {
30
30
  onPress?: () => void;
31
31
  /**
32
32
  * A string describing the system image to display in the button.
33
+ * This is only used if `children` is a string.
33
34
  * Uses Material Icons on Android and SF Symbols on iOS.
34
35
  */
35
36
  systemImage?: string;
@@ -43,9 +44,9 @@ export type ButtonProps = {
43
44
  */
44
45
  variant?: ButtonVariant;
45
46
  /**
46
- * The text to display inside the button.
47
+ * The text or React node to display inside the button.
47
48
  */
48
- children: string;
49
+ children: string | React.ReactNode;
49
50
  /**
50
51
  * Button color.
51
52
  */
@@ -60,13 +61,13 @@ export type ButtonProps = {
60
61
  */
61
62
  export type NativeButtonProps = Omit<ButtonProps, 'role' | 'onPress' | 'children' | 'systemImage'> & {
62
63
  buttonRole?: ButtonRole;
63
- text: string;
64
+ text: string | undefined;
64
65
  systemImage?: string;
65
66
  } & ViewEvent<'onButtonPressed', void>;
66
67
  /**
67
68
  * @hidden
68
69
  */
69
- export declare function transformButtonProps(props: ButtonProps): NativeButtonProps;
70
+ export declare function transformButtonProps(props: Omit<ButtonProps, 'children'>, text: string | undefined): NativeButtonProps;
70
71
  /**
71
72
  * `<Button>` component without a host view.
72
73
  * You should use this with a `Host` component in ancestor.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/swift-ui/Button/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,aAAa,GAErB,SAAS,GACT,UAAU,GACV,OAAO,GAEP,mBAAmB,GACnB,YAAY,GAEZ,cAAc,GACd,oBAAoB,GACpB,MAAM,GACN,MAAM,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;OAE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,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IACnC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,WAAW,EACX,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,CAChD,GAAG;IACF,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,SAAS,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;AAQvC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,EACpC,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,iBAAiB,CASnB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,+BAOjD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG;IAAE,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,+BAO3E"}
@@ -5,13 +5,13 @@ const ButtonNativeView = requireNativeView('ExpoUI', 'Button');
5
5
  /**
6
6
  * @hidden
7
7
  */
8
- export function transformButtonProps(props) {
9
- const { role, children, onPress, systemImage, ...restProps } = props;
8
+ export function transformButtonProps(props, text) {
9
+ const { role, onPress, systemImage, ...restProps } = props;
10
10
  return {
11
11
  ...restProps,
12
- text: children ?? '',
13
- buttonRole: role,
12
+ text,
14
13
  systemImage,
14
+ buttonRole: role,
15
15
  onButtonPressed: onPress,
16
16
  };
17
17
  }
@@ -20,7 +20,12 @@ export function transformButtonProps(props) {
20
20
  * You should use this with a `Host` component in ancestor.
21
21
  */
22
22
  export function ButtonPrimitive(props) {
23
- return <ButtonNativeView {...transformButtonProps(props)}/>;
23
+ const { children, ...restProps } = props;
24
+ const text = typeof children === 'string' ? children : undefined;
25
+ if (text !== undefined) {
26
+ return <ButtonNativeView {...transformButtonProps(restProps, text)}/>;
27
+ }
28
+ return <ButtonNativeView {...transformButtonProps(restProps, text)}>{children}</ButtonNativeView>;
24
29
  }
25
30
  /**
26
31
  * Displays a native button component.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/swift-ui/Button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAIzC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAoF/B,wFAAwF;AACxF,MAAM,gBAAgB,GAA2C,iBAAiB,CAChF,QAAQ,EACR,QAAQ,CACT,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAkB;IACrD,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACrE,OAAO;QACL,GAAG,SAAS;QACZ,IAAI,EAAE,QAAQ,IAAI,EAAE;QACpB,UAAU,EAAE,IAAI;QAChB,WAAW;QACX,eAAe,EAAE,OAAO;KACzB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAkB;IAChD,OAAO,CAAC,gBAAgB,CAAC,IAAI,oBAAoB,CAAC,KAAK,CAAC,CAAC,EAAG,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,KAAqD;IAC1E,MAAM,0BAA0B,GAAG,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC;IACvD,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,0BAA0B,CAAC,CAAC,0BAA0B,CAAC,CAC7F;MAAA,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,EAC7B;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport { StyleProp, ViewStyle } from 'react-native';\n\nimport { ViewEvent } from '../../types';\nimport { Host } from '../Host';\n\n/**\n * The role of the button.\n * - `default` - The default button role.\n * - `cancel` - A button that cancels the current operation.\n * - `destructive` - A button that deletes data or performs a destructive action.\n */\nexport type ButtonRole = 'default' | 'cancel' | 'destructive';\n\n/**\n * The built-in button styles available on iOS.\n *\n * Common styles:\n * - `default` - The default system button style.\n * - `bordered` - A button with a light fill. On Android, equivalent to `FilledTonalButton`.\n * - `borderless` - A button with no background or border. On Android, equivalent to `TextButton`.\n * - `borderedProminent` - A bordered button with a prominent appearance.\n * - `plain` - A button with no border or background and a less prominent text.\n * macOS-only styles:\n * - `accessoryBar` - A button style for accessory bars.\n * - `accessoryBarAction` - A button style for accessory bar actions.\n * - `card` - A button style for cards.\n * - `link` - A button style for links.\n */\nexport type ButtonVariant =\n // Common\n | 'default'\n | 'bordered'\n | 'plain'\n // Apple-only\n | 'borderedProminent'\n | 'borderless'\n // MacOS-only;\n | 'accessoryBar'\n | 'accessoryBarAction'\n | 'card'\n | 'link';\n\nexport type ButtonProps = {\n /**\n * A callback that is called when the button is pressed.\n */\n onPress?: () => void;\n /**\n * A string describing the system image to display in the button.\n * Uses Material Icons on Android and SF Symbols on iOS.\n */\n systemImage?: string;\n /**\n * Indicated the role of the button.\n * @platform ios\n */\n role?: ButtonRole;\n /**\n * The button variant.\n */\n variant?: ButtonVariant;\n /**\n * The text to display inside the button.\n */\n children: string;\n /**\n * Button color.\n */\n color?: string;\n /**\n * Disabled state of the button.\n */\n disabled?: boolean;\n};\n\n/**\n * @hidden\n */\nexport type NativeButtonProps = Omit<\n ButtonProps,\n 'role' | 'onPress' | 'children' | 'systemImage'\n> & {\n buttonRole?: ButtonRole;\n text: string;\n systemImage?: string;\n} & ViewEvent<'onButtonPressed', void>;\n\n// We have to work around the `role` and `onPress` props being reserved by React Native.\nconst ButtonNativeView: React.ComponentType<NativeButtonProps> = requireNativeView(\n 'ExpoUI',\n 'Button'\n);\n\n/**\n * @hidden\n */\nexport function transformButtonProps(props: ButtonProps): NativeButtonProps {\n const { role, children, onPress, systemImage, ...restProps } = props;\n return {\n ...restProps,\n text: children ?? '',\n buttonRole: role,\n systemImage,\n onButtonPressed: onPress,\n };\n}\n\n/**\n * `<Button>` component without a host view.\n * You should use this with a `Host` component in ancestor.\n */\nexport function ButtonPrimitive(props: ButtonProps) {\n return <ButtonNativeView {...transformButtonProps(props)} />;\n}\n\n/**\n * Displays a native button component.\n */\nexport function Button(props: ButtonProps & { style?: StyleProp<ViewStyle> }) {\n const useViewportSizeMeasurement = props.style == null;\n return (\n <Host style={props.style} matchContents useViewportSizeMeasurement={useViewportSizeMeasurement}>\n <ButtonPrimitive {...props} />\n </Host>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/swift-ui/Button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAIzC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAqF/B,wFAAwF;AACxF,MAAM,gBAAgB,GAA2C,iBAAiB,CAChF,QAAQ,EACR,QAAQ,CACT,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAoC,EACpC,IAAwB;IAExB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAC3D,OAAO;QACL,GAAG,SAAS;QACZ,IAAI;QACJ,WAAW;QACX,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,OAAO;KACzB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAkB;IAChD,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACzC,MAAM,IAAI,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,CAAC,gBAAgB,CAAC,IAAI,oBAAoB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,EAAG,CAAC;IACzE,CAAC;IACD,OAAO,CAAC,gBAAgB,CAAC,IAAI,oBAAoB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,CAAC;AACpG,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,KAAqD;IAC1E,MAAM,0BAA0B,GAAG,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC;IACvD,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,0BAA0B,CAAC,CAAC,0BAA0B,CAAC,CAC7F;MAAA,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,EAC7B;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport { StyleProp, ViewStyle } from 'react-native';\n\nimport { ViewEvent } from '../../types';\nimport { Host } from '../Host';\n\n/**\n * The role of the button.\n * - `default` - The default button role.\n * - `cancel` - A button that cancels the current operation.\n * - `destructive` - A button that deletes data or performs a destructive action.\n */\nexport type ButtonRole = 'default' | 'cancel' | 'destructive';\n\n/**\n * The built-in button styles available on iOS.\n *\n * Common styles:\n * - `default` - The default system button style.\n * - `bordered` - A button with a light fill. On Android, equivalent to `FilledTonalButton`.\n * - `borderless` - A button with no background or border. On Android, equivalent to `TextButton`.\n * - `borderedProminent` - A bordered button with a prominent appearance.\n * - `plain` - A button with no border or background and a less prominent text.\n * macOS-only styles:\n * - `accessoryBar` - A button style for accessory bars.\n * - `accessoryBarAction` - A button style for accessory bar actions.\n * - `card` - A button style for cards.\n * - `link` - A button style for links.\n */\nexport type ButtonVariant =\n // Common\n | 'default'\n | 'bordered'\n | 'plain'\n // Apple-only\n | 'borderedProminent'\n | 'borderless'\n // MacOS-only;\n | 'accessoryBar'\n | 'accessoryBarAction'\n | 'card'\n | 'link';\n\nexport type ButtonProps = {\n /**\n * A callback that is called when the button is pressed.\n */\n onPress?: () => void;\n /**\n * A string describing the system image to display in the button.\n * This is only used if `children` is a string.\n * Uses Material Icons on Android and SF Symbols on iOS.\n */\n systemImage?: string;\n /**\n * Indicated the role of the button.\n * @platform ios\n */\n role?: ButtonRole;\n /**\n * The button variant.\n */\n variant?: ButtonVariant;\n /**\n * The text or React node to display inside the button.\n */\n children: string | React.ReactNode;\n /**\n * Button color.\n */\n color?: string;\n /**\n * Disabled state of the button.\n */\n disabled?: boolean;\n};\n\n/**\n * @hidden\n */\nexport type NativeButtonProps = Omit<\n ButtonProps,\n 'role' | 'onPress' | 'children' | 'systemImage'\n> & {\n buttonRole?: ButtonRole;\n text: string | undefined;\n systemImage?: string;\n} & ViewEvent<'onButtonPressed', void>;\n\n// We have to work around the `role` and `onPress` props being reserved by React Native.\nconst ButtonNativeView: React.ComponentType<NativeButtonProps> = requireNativeView(\n 'ExpoUI',\n 'Button'\n);\n\n/**\n * @hidden\n */\nexport function transformButtonProps(\n props: Omit<ButtonProps, 'children'>,\n text: string | undefined\n): NativeButtonProps {\n const { role, onPress, systemImage, ...restProps } = props;\n return {\n ...restProps,\n text,\n systemImage,\n buttonRole: role,\n onButtonPressed: onPress,\n };\n}\n\n/**\n * `<Button>` component without a host view.\n * You should use this with a `Host` component in ancestor.\n */\nexport function ButtonPrimitive(props: ButtonProps) {\n const { children, ...restProps } = props;\n const text = typeof children === 'string' ? children : undefined;\n if (text !== undefined) {\n return <ButtonNativeView {...transformButtonProps(restProps, text)} />;\n }\n return <ButtonNativeView {...transformButtonProps(restProps, text)}>{children}</ButtonNativeView>;\n}\n\n/**\n * Displays a native button component.\n */\nexport function Button(props: ButtonProps & { style?: StyleProp<ViewStyle> }) {\n const useViewportSizeMeasurement = props.style == null;\n return (\n <Host style={props.style} matchContents useViewportSizeMeasurement={useViewportSizeMeasurement}>\n <ButtonPrimitive {...props} />\n </Host>\n );\n}\n"]}
@@ -37,9 +37,12 @@ function createButtonElement(uuid, props, handlers) {
37
37
  if (props.onPress) {
38
38
  handlers[uuid] = { onPress: props.onPress };
39
39
  }
40
+ if (typeof props.children !== 'string') {
41
+ throw new Error('ContextMenu Button only supports string children');
42
+ }
40
43
  return {
41
44
  contextMenuElementID: uuid,
42
- button: transformButtonProps(props),
45
+ button: transformButtonProps(props, props.children),
43
46
  };
44
47
  }
45
48
  function createSwitchElement(uuid, props, handlers) {
@@ -65,10 +68,13 @@ function createPickerElement(uuid, props, handlers) {
65
68
  };
66
69
  }
67
70
  function createSubmenuElement(uuid, props, handlers) {
71
+ if (typeof props.button.props.children !== 'string') {
72
+ throw new Error('ContextMenu Submenu Button only supports string children');
73
+ }
68
74
  return {
69
75
  contextMenuElementID: uuid,
70
76
  submenu: {
71
- button: transformButtonProps(props.button.props),
77
+ button: transformButtonProps(props.button.props, props.button.props.children),
72
78
  elements: transformChildrenToElementArray(props.children, handlers),
73
79
  },
74
80
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/swift-ui/ContextMenu/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAA2B,MAAM,OAAO,CAAC;AAG1E,OAAO,EAAyC,OAAO,EAAgB,MAAM,SAAS,CAAC;AACvF,OAAO,EACL,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AAO;QACL,oBAAoB,EAAE,IAAI;QAC1B,MAAM,EAAE,KAAK;KACd,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,IAAY,EACZ,KAAmB,EACnB,QAAuB;IAEvB,OAAO;QACL,oBAAoB,EAAE,IAAI;QAC1B,OAAO,EAAE;YACP,MAAM,EAAE,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;YAChD,QAAQ,EAAE,+BAA+B,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC;SACpE;KACF,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAmB;IAC7C,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;AACtD,CAAC","sourcesContent":["import { Children, isValidElement, ReactElement, ReactNode } from 'react';\nimport { NativeSyntheticEvent } from 'react-native';\n\nimport { ContextMenuElementBase, EventHandlers, Submenu, SubmenuProps } from './index';\nimport {\n Button,\n ButtonPrimitive,\n ButtonProps,\n NativeButtonProps,\n transformButtonProps,\n} from '../Button';\nimport { Picker, PickerPrimitive, PickerProps } from '../Picker';\nimport { Switch, SwitchPrimitive, SwitchProps } from '../Switch';\n\n// We use this slightly odd typing for the elements to make unpacking the elements easier on the native side\ntype ButtonMenuElement = {\n button: NativeButtonProps;\n} & ContextMenuElementBase;\n\ntype SwitchMenuElement = {\n switch: SwitchProps;\n} & ContextMenuElementBase;\n\ntype PickerMenuElement = {\n picker: PickerProps;\n} & ContextMenuElementBase;\n\ntype SubmenuElement = {\n submenu: {\n elements: MenuElement[];\n button: NativeButtonProps;\n };\n} & ContextMenuElementBase;\n\nexport type MenuElement =\n | ButtonMenuElement\n | SwitchMenuElement\n | PickerMenuElement\n | SubmenuElement;\n\n// Maps the react children to NativeMenuElement[] which is used to render out the native menu\n// TODO: Ideally we want to pass the children directly to the native side without having to do this\nexport function transformChildrenToElementArray(\n children: ReactNode,\n eventHandlersMap: EventHandlers\n): MenuElement[] {\n return Children.toArray(children)\n .map((child) => processChildElement(child, eventHandlersMap))\n .filter((el): el is MenuElement => el !== null);\n}\n\nfunction processChildElement(\n child: ReactNode,\n eventHandlersMap: EventHandlers\n): MenuElement | null {\n if (!isValidElement(child)) return null;\n\n const uuid = expo.uuidv4();\n\n if (child.type === Button || child.type === ButtonPrimitive) {\n // @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps\n return createButtonElement(uuid, child.props, eventHandlersMap);\n }\n\n if (child.type === Switch || child.type === SwitchPrimitive) {\n // @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps\n return createSwitchElement(uuid, child.props, eventHandlersMap);\n }\n\n if (child.type === Picker || child.type === PickerPrimitive) {\n // @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps\n return createPickerElement(uuid, child.props, eventHandlersMap);\n }\n\n if (isSubmenuComponent(child)) {\n // @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps\n return createSubmenuElement(uuid, child.props, eventHandlersMap);\n }\n\n console.warn('Unsupported child type in Menu: ', child.type);\n return null;\n}\n\nfunction createButtonElement(\n uuid: string,\n props: ButtonProps,\n handlers: EventHandlers\n): MenuElement {\n if (props.onPress) {\n handlers[uuid] = { onPress: props.onPress };\n }\n\n return {\n contextMenuElementID: uuid,\n button: transformButtonProps(props),\n };\n}\n\nfunction createSwitchElement(\n uuid: string,\n props: SwitchProps,\n handlers: EventHandlers\n): MenuElement {\n if (props.onValueChange) {\n handlers[uuid] = {\n onValueChange: ({ nativeEvent: { value } }: NativeSyntheticEvent<{ value: boolean }>) => {\n props.onValueChange?.(value);\n },\n };\n }\n\n return {\n contextMenuElementID: uuid,\n switch: props,\n };\n}\n\nfunction createPickerElement(\n uuid: string,\n props: PickerProps,\n handlers: EventHandlers\n): MenuElement {\n if (props.onOptionSelected) {\n handlers[uuid] = { onOptionSelected: props.onOptionSelected };\n }\n\n return {\n contextMenuElementID: uuid,\n picker: props,\n };\n}\n\nfunction createSubmenuElement(\n uuid: string,\n props: SubmenuProps,\n handlers: EventHandlers\n): MenuElement {\n return {\n contextMenuElementID: uuid,\n submenu: {\n button: transformButtonProps(props.button.props),\n elements: transformChildrenToElementArray(props.children, handlers),\n },\n };\n}\n\nfunction isSubmenuComponent(child: ReactElement): boolean {\n return child.type.toString() === Submenu.toString();\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/swift-ui/ContextMenu/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAA2B,MAAM,OAAO,CAAC;AAG1E,OAAO,EAAyC,OAAO,EAAgB,MAAM,SAAS,CAAC;AACvF,OAAO,EACL,MAAM,EACN,eAAe,EAGf,oBAAoB,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AA4BjE,6FAA6F;AAC7F,mGAAmG;AACnG,MAAM,UAAU,+BAA+B,CAC7C,QAAmB,EACnB,gBAA+B;IAE/B,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;SAC9B,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;SAC5D,MAAM,CAAC,CAAC,EAAE,EAAqB,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,mBAAmB,CAC1B,KAAgB,EAChB,gBAA+B;IAE/B,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAExC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAE3B,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,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C7C,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;AACtD,CAAC","sourcesContent":["import { Children, isValidElement, ReactElement, ReactNode } from 'react';\nimport { NativeSyntheticEvent } from 'react-native';\n\nimport { ContextMenuElementBase, EventHandlers, Submenu, SubmenuProps } from './index';\nimport {\n Button,\n ButtonPrimitive,\n ButtonProps,\n NativeButtonProps,\n transformButtonProps,\n} from '../Button';\nimport { Picker, PickerPrimitive, PickerProps } from '../Picker';\nimport { Switch, SwitchPrimitive, SwitchProps } from '../Switch';\n\n// We use this slightly odd typing for the elements to make unpacking the elements easier on the native side\ntype ButtonMenuElement = {\n button: NativeButtonProps;\n} & ContextMenuElementBase;\n\ntype SwitchMenuElement = {\n switch: SwitchProps;\n} & ContextMenuElementBase;\n\ntype PickerMenuElement = {\n picker: PickerProps;\n} & ContextMenuElementBase;\n\ntype SubmenuElement = {\n submenu: {\n elements: MenuElement[];\n button: NativeButtonProps;\n };\n} & ContextMenuElementBase;\n\nexport type MenuElement =\n | ButtonMenuElement\n | SwitchMenuElement\n | PickerMenuElement\n | SubmenuElement;\n\n// Maps the react children to NativeMenuElement[] which is used to render out the native menu\n// TODO: Ideally we want to pass the children directly to the native side without having to do this\nexport function transformChildrenToElementArray(\n children: ReactNode,\n eventHandlersMap: EventHandlers\n): MenuElement[] {\n return Children.toArray(children)\n .map((child) => processChildElement(child, eventHandlersMap))\n .filter((el): el is MenuElement => el !== null);\n}\n\nfunction processChildElement(\n child: ReactNode,\n eventHandlersMap: EventHandlers\n): MenuElement | null {\n if (!isValidElement(child)) return null;\n\n const uuid = expo.uuidv4();\n\n if (child.type === Button || child.type === ButtonPrimitive) {\n // @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps\n return createButtonElement(uuid, child.props, eventHandlersMap);\n }\n\n if (child.type === Switch || child.type === SwitchPrimitive) {\n // @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps\n return createSwitchElement(uuid, child.props, eventHandlersMap);\n }\n\n if (child.type === Picker || child.type === PickerPrimitive) {\n // @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps\n return createPickerElement(uuid, child.props, eventHandlersMap);\n }\n\n if (isSubmenuComponent(child)) {\n // @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps\n return createSubmenuElement(uuid, child.props, eventHandlersMap);\n }\n\n console.warn('Unsupported child type in Menu: ', child.type);\n return null;\n}\n\nfunction createButtonElement(\n uuid: string,\n props: ButtonProps,\n handlers: EventHandlers\n): MenuElement {\n if (props.onPress) {\n handlers[uuid] = { onPress: props.onPress };\n }\n if (typeof props.children !== 'string') {\n throw new Error('ContextMenu Button only supports string children');\n }\n return {\n contextMenuElementID: uuid,\n button: transformButtonProps(props, props.children),\n };\n}\n\nfunction createSwitchElement(\n uuid: string,\n props: SwitchProps,\n handlers: EventHandlers\n): MenuElement {\n if (props.onValueChange) {\n handlers[uuid] = {\n onValueChange: ({ nativeEvent: { value } }: NativeSyntheticEvent<{ value: boolean }>) => {\n props.onValueChange?.(value);\n },\n };\n }\n\n return {\n contextMenuElementID: uuid,\n switch: props,\n };\n}\n\nfunction createPickerElement(\n uuid: string,\n props: PickerProps,\n handlers: EventHandlers\n): MenuElement {\n if (props.onOptionSelected) {\n handlers[uuid] = { onOptionSelected: props.onOptionSelected };\n }\n\n return {\n contextMenuElementID: uuid,\n picker: props,\n };\n}\n\nfunction createSubmenuElement(\n uuid: string,\n props: SubmenuProps,\n handlers: EventHandlers\n): MenuElement {\n if (typeof props.button.props.children !== 'string') {\n throw new Error('ContextMenu Submenu Button only supports string children');\n }\n return {\n contextMenuElementID: uuid,\n submenu: {\n button: transformButtonProps(props.button.props, props.button.props.children),\n elements: transformChildrenToElementArray(props.children, handlers),\n },\n };\n}\n\nfunction isSubmenuComponent(child: ReactElement): boolean {\n return child.type.toString() === Submenu.toString();\n}\n"]}
@@ -9,7 +9,7 @@
9
9
  "publication": {
10
10
  "groupId": "expo.modules.ui",
11
11
  "artifactId": "expo.modules.ui",
12
- "version": "0.1.1-alpha.8",
12
+ "version": "0.1.1-alpha.9",
13
13
  "repository": "local-maven-repo"
14
14
  }
15
15
  }
@@ -13,10 +13,14 @@ struct Button: ExpoSwiftUI.View {
13
13
  props.onButtonPressed()
14
14
  },
15
15
  label: {
16
- if let systemImage = props.systemImage {
17
- Label(props.text, systemImage: systemImage)
16
+ if let text = props.text {
17
+ if let systemImage = props.systemImage {
18
+ Label(text, systemImage: systemImage)
19
+ } else {
20
+ Text(text)
21
+ }
18
22
  } else {
19
- Text(props.text)
23
+ Children()
20
24
  }
21
25
  })
22
26
  .disabled(props.disabled)
@@ -34,7 +34,7 @@ internal enum ButtonVariant: String, Enumerable {
34
34
 
35
35
  final class ButtonProps: ExpoSwiftUI.ViewProps, Observable {
36
36
  required init() {}
37
- @Field var text: String = ""
37
+ @Field var text: String?
38
38
  @Field var systemImage: String?
39
39
  @Field var color: Color?
40
40
  @Field var buttonRole: ButtonRole? = .default
@@ -14,9 +14,13 @@ internal struct DisclosureGroupView: ExpoSwiftUI.View {
14
14
  @ObservedObject var props: DisclosureGroupViewProps
15
15
 
16
16
  var body: some View {
17
+ #if os(tvOS)
18
+ Text("DisclosureGroupView is not supported on tvOS")
19
+ #else
17
20
  DisclosureGroup(props.label) {
18
21
  Children()
19
22
  }
20
23
  .modifier(CommonViewModifiers(props: props))
24
+ #endif
21
25
  }
22
26
  }
@@ -19,7 +19,7 @@ internal struct FormView: ExpoSwiftUI.View {
19
19
  }
20
20
  .modifier(CommonViewModifiers(props: props))
21
21
 
22
- if #available(iOS 16.0, *) {
22
+ if #available(iOS 16.0, tvOS 16.0, *) {
23
23
  form.scrollDisabled(!props.scrollEnabled)
24
24
  } else {
25
25
  form
@@ -7,13 +7,15 @@ internal extension View {
7
7
  @ViewBuilder
8
8
  func applyOnTapGesture(useTapGesture: Bool?, eventDispatcher: EventDispatcher, useContentShape: Bool = false) -> some View {
9
9
  if useTapGesture == true {
10
- self
11
- .if(useContentShape) {
12
- $0.contentShape(Rectangle())
13
- }
14
- .onTapGesture {
15
- eventDispatcher()
16
- }
10
+ if #available(iOS 13.0, macOS 10.13, tvOS 16.0, *) {
11
+ self
12
+ .if(useContentShape) {
13
+ $0.contentShape(Rectangle())
14
+ }
15
+ .onTapGesture {
16
+ eventDispatcher()
17
+ }
18
+ }
17
19
  } else {
18
20
  self
19
21
  }
@@ -49,7 +49,7 @@ struct SliderView: ExpoSwiftUI.View {
49
49
  value = sliderValue
50
50
  })
51
51
  #else
52
- Text("Slider not supported on this platform")
52
+ Text("Slider is not supported on tvOS")
53
53
  #endif
54
54
  }
55
55
  }
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "expo.modules.ui",
5
5
  "module": "expo.modules.ui",
6
- "version": "0.1.1-alpha.8",
6
+ "version": "0.1.1-alpha.9",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "files": [
26
26
  {
27
- "name": "expo.modules.ui-0.1.1-alpha.8.aar",
28
- "url": "expo.modules.ui-0.1.1-alpha.8.aar",
27
+ "name": "expo.modules.ui-0.1.1-alpha.9.aar",
28
+ "url": "expo.modules.ui-0.1.1-alpha.9.aar",
29
29
  "size": 186114,
30
30
  "sha512": "ecc8ec9455298d16ec7a602b4cfb56e0f1c03040e300f45a87fe0fd0a41273e742b595b07e4ede01c724d16a3f11a3d2e65c6814b3d8d8d156d41f13989182ee",
31
31
  "sha256": "abe2d92b3e81e64b0d3b4d8e276c6ff4347b1846dcd2417f53d40a99fd4f0da0",
@@ -102,8 +102,8 @@
102
102
  ],
103
103
  "files": [
104
104
  {
105
- "name": "expo.modules.ui-0.1.1-alpha.8.aar",
106
- "url": "expo.modules.ui-0.1.1-alpha.8.aar",
105
+ "name": "expo.modules.ui-0.1.1-alpha.9.aar",
106
+ "url": "expo.modules.ui-0.1.1-alpha.9.aar",
107
107
  "size": 186114,
108
108
  "sha512": "ecc8ec9455298d16ec7a602b4cfb56e0f1c03040e300f45a87fe0fd0a41273e742b595b07e4ede01c724d16a3f11a3d2e65c6814b3d8d8d156d41f13989182ee",
109
109
  "sha256": "abe2d92b3e81e64b0d3b4d8e276c6ff4347b1846dcd2417f53d40a99fd4f0da0",
@@ -122,8 +122,8 @@
122
122
  },
123
123
  "files": [
124
124
  {
125
- "name": "expo.modules.ui-0.1.1-alpha.8-sources.jar",
126
- "url": "expo.modules.ui-0.1.1-alpha.8-sources.jar",
125
+ "name": "expo.modules.ui-0.1.1-alpha.9-sources.jar",
126
+ "url": "expo.modules.ui-0.1.1-alpha.9-sources.jar",
127
127
  "size": 14626,
128
128
  "sha512": "d5bc1af7c33732fcf29123ea132de19ed9cf5deeb034540970198f637d519a01ad470c3e2d3be3758ce3d7808a3ee7023413050d62847e04222ae3ebf8c7595f",
129
129
  "sha256": "103d283232c7a8c9b6b101e74947ae87f2e4b7df60c348931584239fa6619a99",
@@ -0,0 +1 @@
1
+ b9d541f4a8ce0ea4652226cb4be98c61d656f7d3c3c0eb79e604efd074346d46
@@ -0,0 +1 @@
1
+ d94cc312e2f216f4eac47d70b49368b1bb00ce13e6b99390178aafbc901a0b81c3b95f7411402163dc6c88942405c637fec1aa8df26d9e8b3a8c3d1b1dc9cdef
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>expo.modules.ui</groupId>
11
11
  <artifactId>expo.modules.ui</artifactId>
12
- <version>0.1.1-alpha.8</version>
12
+ <version>0.1.1-alpha.9</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.ui</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ 7975c2dc70fea34465b0a4e1805aecfc65d478ef5a0055fba9b39277ef653841
@@ -0,0 +1 @@
1
+ 30f77f356482e503d38e2feb7c5a6d7674076a3003bf5297fc242ab5e7e8b19829db2981b7d8e5f6de3cbdf733bd85b8a7e2b6e72c918c443665fe4db7ef8dd9
@@ -3,11 +3,11 @@
3
3
  <groupId>expo.modules.ui</groupId>
4
4
  <artifactId>expo.modules.ui</artifactId>
5
5
  <versioning>
6
- <latest>0.1.1-alpha.8</latest>
7
- <release>0.1.1-alpha.8</release>
6
+ <latest>0.1.1-alpha.9</latest>
7
+ <release>0.1.1-alpha.9</release>
8
8
  <versions>
9
- <version>0.1.1-alpha.8</version>
9
+ <version>0.1.1-alpha.9</version>
10
10
  </versions>
11
- <lastUpdated>20250604230414</lastUpdated>
11
+ <lastUpdated>20250608044924</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- b1139a862e142d606c470d623a3f153e
1
+ a8819a022d7b0c14beffcbbed1ab71ad
@@ -1 +1 @@
1
- 758f8be3c64b76cc4a990542e00877e924587234
1
+ 236220b47a2adab66d23c36f2d99c2af4c01781a
@@ -1 +1 @@
1
- 01836af63215ed4b29b2fc4b4e8e05e06c48651fadba33f75135702b7ffdfb1c
1
+ 3eb430cfa8bc0618015df11a98da2b503d7a465e3e58df08f37b56f2678764aa
@@ -1 +1 @@
1
- c0edbc0c41ef138e28abcc6d2b5e8dd62d8d558c6d762226956fe491cf6767521946c3d75e32ef700c12de1a7fbf2680d78207ff62350d0b9e6a8375e654b4f1
1
+ cb8e043acbd311c01c0b545dcbea03ea2ccd8ed11ef3d9d45cf7a89efc033aad067f02549aec5db14ca46b945373b02836fbd54c7ca7145116f9824d287b1ef8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/ui",
3
- "version": "0.1.1-alpha.8",
3
+ "version": "0.1.1-alpha.9",
4
4
  "description": "A collection of UI components",
5
5
  "scripts": {
6
6
  "build": "expo-module build",
@@ -34,5 +34,5 @@
34
34
  "react": "*",
35
35
  "react-native": "*"
36
36
  },
37
- "gitHead": "7638c800b57fe78f57cc7f129022f58e84a523c5"
37
+ "gitHead": "38da2aaf6aa32f64f9063419054a6ad71dceddea"
38
38
  }
@@ -48,6 +48,7 @@ export type ButtonProps = {
48
48
  onPress?: () => void;
49
49
  /**
50
50
  * A string describing the system image to display in the button.
51
+ * This is only used if `children` is a string.
51
52
  * Uses Material Icons on Android and SF Symbols on iOS.
52
53
  */
53
54
  systemImage?: string;
@@ -61,9 +62,9 @@ export type ButtonProps = {
61
62
  */
62
63
  variant?: ButtonVariant;
63
64
  /**
64
- * The text to display inside the button.
65
+ * The text or React node to display inside the button.
65
66
  */
66
- children: string;
67
+ children: string | React.ReactNode;
67
68
  /**
68
69
  * Button color.
69
70
  */
@@ -82,7 +83,7 @@ export type NativeButtonProps = Omit<
82
83
  'role' | 'onPress' | 'children' | 'systemImage'
83
84
  > & {
84
85
  buttonRole?: ButtonRole;
85
- text: string;
86
+ text: string | undefined;
86
87
  systemImage?: string;
87
88
  } & ViewEvent<'onButtonPressed', void>;
88
89
 
@@ -95,13 +96,16 @@ const ButtonNativeView: React.ComponentType<NativeButtonProps> = requireNativeVi
95
96
  /**
96
97
  * @hidden
97
98
  */
98
- export function transformButtonProps(props: ButtonProps): NativeButtonProps {
99
- const { role, children, onPress, systemImage, ...restProps } = props;
99
+ export function transformButtonProps(
100
+ props: Omit<ButtonProps, 'children'>,
101
+ text: string | undefined
102
+ ): NativeButtonProps {
103
+ const { role, onPress, systemImage, ...restProps } = props;
100
104
  return {
101
105
  ...restProps,
102
- text: children ?? '',
103
- buttonRole: role,
106
+ text,
104
107
  systemImage,
108
+ buttonRole: role,
105
109
  onButtonPressed: onPress,
106
110
  };
107
111
  }
@@ -111,7 +115,12 @@ export function transformButtonProps(props: ButtonProps): NativeButtonProps {
111
115
  * You should use this with a `Host` component in ancestor.
112
116
  */
113
117
  export function ButtonPrimitive(props: ButtonProps) {
114
- return <ButtonNativeView {...transformButtonProps(props)} />;
118
+ const { children, ...restProps } = props;
119
+ const text = typeof children === 'string' ? children : undefined;
120
+ if (text !== undefined) {
121
+ return <ButtonNativeView {...transformButtonProps(restProps, text)} />;
122
+ }
123
+ return <ButtonNativeView {...transformButtonProps(restProps, text)}>{children}</ButtonNativeView>;
115
124
  }
116
125
 
117
126
  /**
@@ -89,10 +89,12 @@ function createButtonElement(
89
89
  if (props.onPress) {
90
90
  handlers[uuid] = { onPress: props.onPress };
91
91
  }
92
-
92
+ if (typeof props.children !== 'string') {
93
+ throw new Error('ContextMenu Button only supports string children');
94
+ }
93
95
  return {
94
96
  contextMenuElementID: uuid,
95
- button: transformButtonProps(props),
97
+ button: transformButtonProps(props, props.children),
96
98
  };
97
99
  }
98
100
 
@@ -135,10 +137,13 @@ function createSubmenuElement(
135
137
  props: SubmenuProps,
136
138
  handlers: EventHandlers
137
139
  ): MenuElement {
140
+ if (typeof props.button.props.children !== 'string') {
141
+ throw new Error('ContextMenu Submenu Button only supports string children');
142
+ }
138
143
  return {
139
144
  contextMenuElementID: uuid,
140
145
  submenu: {
141
- button: transformButtonProps(props.button.props),
146
+ button: transformButtonProps(props.button.props, props.button.props.children),
142
147
  elements: transformChildrenToElementArray(props.children, handlers),
143
148
  },
144
149
  };
@@ -1 +0,0 @@
1
- adfd05d143129305c5422f655e6ea77382475d6b97251886e1ad523db4b16916
@@ -1 +0,0 @@
1
- db29cc67497560eb0866b9767942427f3437a32d4a5ef419bea60adb9cad79088dafd051a53c4b80d816122449215ffce1d09adabe14be5d5f3371585ea96a82
@@ -1 +0,0 @@
1
- cbe1f06ec3c38ffbb90cdd57d7d32f498fe599a39538394c22f3c4a111bf90c2
@@ -1 +0,0 @@
1
- 7a6cc59d6a5c251662c6d92a1c48ef5410ef4567e9984f3cec48545423980a26cd6b791cf88e9312d5e09d9727ee31793030ec327a263a8494b342a057d770ab