@expo/ui 0.0.2 → 0.1.0-alpha.0

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 (93) hide show
  1. package/BottomSheet/index.ios.tsx +34 -0
  2. package/BottomSheet/index.tsx +12 -0
  3. package/{components/Button → Button}/index.tsx +47 -16
  4. package/Button/types.ts +54 -0
  5. package/CHANGELOG.md +40 -0
  6. package/ColorPicker/index.tsx +54 -0
  7. package/ContextMenu/index.android.tsx +72 -0
  8. package/{components/ContextMenu → ContextMenu}/index.tsx +80 -30
  9. package/{components/ContextMenu → ContextMenu}/utils.ts +4 -0
  10. package/DatePicker/index.tsx +97 -0
  11. package/Gauge/index.tsx +73 -0
  12. package/Label/index.ios.tsx +16 -0
  13. package/Label/index.tsx +34 -0
  14. package/List/index.ios.tsx +35 -0
  15. package/List/index.tsx +99 -0
  16. package/{components/Picker → Picker}/index.tsx +32 -19
  17. package/Progress/index.tsx +48 -0
  18. package/Section/index.ios.tsx +12 -0
  19. package/Section/index.tsx +19 -0
  20. package/{components/Slider → Slider}/index.tsx +19 -10
  21. package/{components/Switch → Switch}/index.tsx +37 -54
  22. package/TextInput/index.tsx +108 -0
  23. package/android/build.gradle +2 -2
  24. package/android/src/main/java/expo/modules/ui/DatePickerView.kt +160 -0
  25. package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +10 -0
  26. package/android/src/main/java/expo/modules/ui/PickerView.kt +93 -31
  27. package/android/src/main/java/expo/modules/ui/ProgressView.kt +83 -0
  28. package/android/src/main/java/expo/modules/ui/SwitchView.kt +56 -39
  29. package/android/src/main/java/expo/modules/ui/TextInputView.kt +75 -0
  30. package/android/src/main/java/expo/modules/ui/Utils.kt +17 -0
  31. package/android/src/main/java/expo/modules/ui/button/Button.kt +33 -4
  32. package/android/src/main/java/expo/modules/ui/menu/ContextMenu.kt +49 -32
  33. package/android/src/main/java/expo/modules/ui/menu/ContextMenuRecords.kt +10 -3
  34. package/build/{components/Button → Button}/index.d.ts +36 -13
  35. package/build/Button/index.d.ts.map +1 -0
  36. package/build/Button/types.d.ts +5 -0
  37. package/build/Button/types.d.ts.map +1 -0
  38. package/build/{components/ContextMenu → ContextMenu}/index.d.ts +68 -19
  39. package/build/ContextMenu/index.d.ts.map +1 -0
  40. package/build/ContextMenu/utils.d.ts.map +1 -0
  41. package/build/Label/index.d.ts +28 -0
  42. package/build/Label/index.d.ts.map +1 -0
  43. package/build/List/index.d.ts +87 -0
  44. package/build/List/index.d.ts.map +1 -0
  45. package/build/Picker/index.d.ts +76 -0
  46. package/build/Picker/index.d.ts.map +1 -0
  47. package/build/Section/index.d.ts +16 -0
  48. package/build/Section/index.d.ts.map +1 -0
  49. package/build/{components/Slider → Slider}/index.d.ts +18 -10
  50. package/build/Slider/index.d.ts.map +1 -0
  51. package/build/{components/Switch → Switch}/index.d.ts +18 -36
  52. package/build/Switch/index.d.ts.map +1 -0
  53. package/build/src/types.d.ts +15 -0
  54. package/build/src/types.d.ts.map +1 -0
  55. package/expo-module.config.json +3 -3
  56. package/ios/BottomSheetView.swift +86 -0
  57. package/ios/Button/Button.swift +52 -44
  58. package/ios/Button/ButtonProps.swift +1 -0
  59. package/ios/ColorPickerView.swift +54 -0
  60. package/ios/ContextMenu/ContextMenu.swift +71 -8
  61. package/ios/ContextMenu/ContextMenuRecords.swift +6 -0
  62. package/ios/DateTimePickerView.swift +85 -0
  63. package/ios/ExpoUIModule.swift +10 -0
  64. package/ios/Gauge/Gauge.swift +49 -0
  65. package/ios/Gauge/GaugeProps.swift +28 -0
  66. package/ios/Label.swift +29 -0
  67. package/ios/List.swift +127 -0
  68. package/ios/PickerView.swift +38 -29
  69. package/ios/ProgressView.swift +40 -0
  70. package/ios/SectionView.swift +12 -5
  71. package/ios/SliderView.swift +6 -2
  72. package/ios/SwitchView.swift +6 -3
  73. package/ios/TextInput/TextInputView.swift +83 -0
  74. package/package.json +4 -6
  75. package/src/types.ts +18 -0
  76. package/tsconfig.json +1 -1
  77. package/build/components/Button/index.d.ts.map +0 -1
  78. package/build/components/ContextMenu/index.d.ts.map +0 -1
  79. package/build/components/ContextMenu/utils.d.ts.map +0 -1
  80. package/build/components/Picker/index.d.ts +0 -65
  81. package/build/components/Picker/index.d.ts.map +0 -1
  82. package/build/components/Section/index.d.ts +0 -12
  83. package/build/components/Section/index.d.ts.map +0 -1
  84. package/build/components/Section/index.ios.d.ts +0 -8
  85. package/build/components/Section/index.ios.d.ts.map +0 -1
  86. package/build/components/Slider/index.d.ts.map +0 -1
  87. package/build/components/Switch/index.d.ts.map +0 -1
  88. package/build/src/index.d.ts +0 -13
  89. package/build/src/index.d.ts.map +0 -1
  90. package/components/Section/index.ios.tsx +0 -58
  91. package/components/Section/index.tsx +0 -56
  92. package/src/index.ts +0 -22
  93. /package/build/{components/ContextMenu → ContextMenu}/utils.d.ts +0 -0
@@ -1,18 +1,20 @@
1
- import React, { ReactElement, ReactNode } from 'react';
1
+ import { ReactElement, ReactNode } from 'react';
2
2
  import { NativeSyntheticEvent, StyleProp, ViewStyle } from 'react-native';
3
+ import { MenuElement } from './utils';
3
4
  import { ButtonProps } from '../Button';
4
5
  import { PickerProps } from '../Picker';
5
6
  import { SwitchProps } from '../Switch';
6
7
  type SubmenuElement = ReactElement<ButtonProps> | ReactElement<SwitchProps> | ReactElement<PickerProps> | ReactElement<SubmenuProps>;
7
- type ContentChildren = SubmenuElement | SubmenuElement[];
8
8
  export type ContextMenuContentProps = {
9
- children: ContentChildren;
10
- };
11
- export type EventHandlers = {
12
- [key: string]: {
13
- [key: string]: (event: NativeSyntheticEvent<any>) => void;
14
- };
9
+ children: SubmenuElement | SubmenuElement[];
15
10
  };
11
+ /**
12
+ * @hidden
13
+ */
14
+ export type EventHandlers = Record<string, Record<string, (event: NativeSyntheticEvent<any>) => void>>;
15
+ /**
16
+ * @hidden
17
+ */
16
18
  export type ContextMenuElementBase = {
17
19
  contextMenuElementID: string;
18
20
  };
@@ -26,12 +28,6 @@ export type ActivationMethod = 'singlePress' | 'longPress';
26
28
  * Props of the `ContextMenu` component.
27
29
  */
28
30
  export type ContextMenuProps = {
29
- /**
30
- * Items visible inside the context menu. The items should be wrapped in a `React.Fragment`.
31
- * `Button`, `Switch` and `Submenu` components are supported on both Android and iOS.
32
- * The `Picker` component is supported only on iOS. Remember to use components from the `@expo/ui` library.
33
- */
34
- Items: React.ReactElement<ContextMenuContentProps>;
35
31
  /**
36
32
  * Determines how the context menu will be activated.
37
33
  *
@@ -43,6 +39,12 @@ export type ContextMenuProps = {
43
39
  * The children will be wrapped in a pressable element, which triggers opening of the context menu.
44
40
  */
45
41
  children: ReactNode;
42
+ /**
43
+ * The color of the container holding the context menu items.
44
+ *
45
+ * @platform android
46
+ */
47
+ color?: string;
46
48
  /**
47
49
  * Optional styles to apply to the `ContextMenu`
48
50
  */
@@ -55,17 +57,59 @@ export type SubmenuProps = {
55
57
  /**
56
58
  * The button that will be used to expand the submenu. On Android the `text` prop of the `Button` will be used as a section title.
57
59
  */
58
- button: React.ReactElement<ButtonProps>;
60
+ button: ReactElement<ButtonProps>;
59
61
  /**
60
62
  * Children of the submenu. Only `Button`, `Switch`, `Picker` and `Submenu` elements should be used.
61
63
  */
62
- children: React.ReactNode;
64
+ children: ReactNode;
65
+ };
66
+ /**
67
+ * @hidden
68
+ */
69
+ export type NativeMenuProps = ContextMenuProps & {
70
+ elements: MenuElement[];
71
+ onContextMenuButtonPressed: (event: NativeSyntheticEvent<{
72
+ contextMenuElementID: string;
73
+ }>) => void;
74
+ onContextMenuSwitchValueChanged: (event: NativeSyntheticEvent<{
75
+ contextMenuElementID: string;
76
+ value: boolean;
77
+ }>) => void;
78
+ onContextMenuPickerOptionSelected: (event: NativeSyntheticEvent<{
79
+ index: number;
80
+ label: string;
81
+ contextMenuElementID: string;
82
+ }>) => void;
63
83
  };
64
84
  /**
65
85
  * The `Submenu` component is used to create a nested context menu. Submenus can be infinitely nested.
66
86
  * Android does not support nesting in the context menu. All the submenus will be flat-mapped into a single level with multiple titled sections.
67
87
  */
68
- export declare function Submenu(props: SubmenuProps): React.JSX.Element;
88
+ export declare function Submenu(props: SubmenuProps): import("react").JSX.Element;
89
+ /**
90
+ * Items visible inside the context menu. Pass input components as immidiate children of the tag.
91
+ * `Button`, `Switch` and `Submenu` components are supported on both Android and iOS.
92
+ * The `Picker` component is supported only on iOS. Remember to use components from the `@expo/ui` library.
93
+ */
94
+ export declare function Items(props: {
95
+ children: React.ReactNode;
96
+ }): import("react").JSX.Element;
97
+ export declare namespace Items {
98
+ var tag: string;
99
+ }
100
+ /**
101
+ * The component visible all the time that triggers the menu when tapped or long-pressed.
102
+ */
103
+ export declare function Trigger(props: {
104
+ children: React.ReactNode;
105
+ }): import("react").JSX.Element;
106
+ /**
107
+ * The component visible above the menu when it is opened.
108
+ * @platform ios
109
+ */
110
+ export declare function Preview(props: {
111
+ children: React.ReactNode;
112
+ }): import("react").JSX.Element;
69
113
  /**
70
114
  * `ContextMenu` allows you to create a context menu, which can be used to provide additional options to the user.
71
115
  *
@@ -75,6 +119,11 @@ export declare function Submenu(props: SubmenuProps): React.JSX.Element;
75
119
  * - Android does not support nesting in the context menu. All the submenus will be flat-mapped into a single level with multiple sections. The `title` prop of the `Button`, which opens the submenu on iOS will be used as a section title.
76
120
  * - Android does not support showing a `Picker` element in the context menu.
77
121
  */
78
- export declare function ContextMenu(props: ContextMenuProps): React.JSX.Element;
79
- export {};
122
+ declare function ContextMenu(props: ContextMenuProps): import("react").JSX.Element;
123
+ declare namespace ContextMenu {
124
+ var Trigger: typeof import(".").Trigger;
125
+ var Preview: typeof import(".").Preview;
126
+ var Items: typeof import(".").Items;
127
+ }
128
+ export { ContextMenu };
80
129
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ContextMenu/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAA2B,YAAY,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AAClF,OAAO,EA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EAAE,MAAM,OAAO,CAAC;AAG1E,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAyB,MAAM,SAAS,CAAC;AACvF,OAAO,EAAuB,iBAAiB,EAAwB,MAAM,WAAW,CAAC;AACzF,OAAO,EAAU,WAAW,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAU,WAAW,EAAE,MAAM,WAAW,CAAC;AAGhD,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,GAAG,sBAAsB,CAAC;AAE3B,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,WAAW,CAAC;CACrB,GAAG,sBAAsB,CAAC;AAE3B,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,WAAW,CAAC;CACrB,GAAG,sBAAsB,CAAC;AAE3B,KAAK,cAAc,GAAG;IACpB,OAAO,EAAE;QACP,QAAQ,EAAE,WAAW,EAAE,CAAC;QACxB,MAAM,EAAE,iBAAiB,CAAC;KAC3B,CAAC;CACH,GAAG,sBAAsB,CAAC;AAE3B,MAAM,MAAM,WAAW,GACnB,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,cAAc,CAAC;AAInB,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,SAAS,EACnB,gBAAgB,EAAE,aAAa,GAC9B,WAAW,EAAE,CAIf"}
@@ -0,0 +1,28 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
2
+ export type LabelProps = {
3
+ /**
4
+ * The title text to be displayed in the label.
5
+ */
6
+ title?: string;
7
+ /**
8
+ * The name of the SFSymbol to be displayed in the label.
9
+ */
10
+ systemImage?: string;
11
+ /**
12
+ * The color of the label icon.
13
+ */
14
+ color?: string;
15
+ /**
16
+ * Additional styles to apply to the label.
17
+ */
18
+ style?: StyleProp<ViewStyle>;
19
+ };
20
+ /**
21
+ * Renders a native label view, which could be used in a list or section.
22
+ *
23
+ * @param {LabelProps} props - The properties passed to the Label component.
24
+ * @returns {JSX.Element} The rendered native Label component.
25
+ * @platform ios
26
+ */
27
+ export declare function Label(props: LabelProps): import("react").JSX.Element;
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Label/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAQ,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,+BAEtC"}
@@ -0,0 +1,87 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
2
+ import { ViewEvent } from '../src/types';
3
+ export type ListStyle = 'automatic' | 'plain' | 'inset' | 'insetGrouped' | 'grouped' | 'sidebar';
4
+ export interface ListProps {
5
+ /**
6
+ * Custom style for the container wrapping the list.
7
+ */
8
+ style?: StyleProp<ViewStyle>;
9
+ /**
10
+ * One of the predefined ListStyle types in SwiftUI.
11
+ * @default 'automatic'
12
+ */
13
+ listStyle?: ListStyle;
14
+ /**
15
+ * Allows the selection of list items.
16
+ * @default false
17
+ */
18
+ selectEnabled?: boolean;
19
+ /**
20
+ * Enables reordering of list items.
21
+ * @default false
22
+ */
23
+ moveEnabled?: boolean;
24
+ /**
25
+ * Allows the deletion of list items.
26
+ * @default false
27
+ */
28
+ deleteEnabled?: boolean;
29
+ /**
30
+ * Makes the list scrollable.
31
+ * @default true
32
+ * @platform ios 16.0+
33
+ */
34
+ scrollEnabled?: boolean;
35
+ /**
36
+ * Enables SwiftUI edit mode.
37
+ * @default false
38
+ */
39
+ editModeEnabled?: boolean;
40
+ /**
41
+ * The children elements to be rendered inside the list.
42
+ */
43
+ children: React.ReactNode;
44
+ /**
45
+ * Callback triggered when an item is deleted from the list.
46
+ */
47
+ onDeleteItem?: (index: number) => void;
48
+ /**
49
+ * Callback triggered when an item is moved in the list.
50
+ */
51
+ onMoveItem?: (from: number, to: number) => void;
52
+ /**
53
+ * Callback triggered when the selection changes in a list.
54
+ */
55
+ onSelectionChange?: (selection: number[]) => void;
56
+ }
57
+ /**
58
+ * DeleteItemEvent represents an event triggered when an item is deleted from the list.
59
+ */
60
+ type DeleteItemEvent = ViewEvent<'onDeleteItem', {
61
+ index: number;
62
+ }>;
63
+ /**
64
+ * MoveItemEvent represents an event triggered when an item is moved in the list.
65
+ */
66
+ type MoveItemEvent = ViewEvent<'onMoveItem', {
67
+ from: number;
68
+ to: number;
69
+ }>;
70
+ /**
71
+ * SelectItemEvent represents an event triggered when the selection changes in a list.
72
+ */
73
+ type SelectItemEvent = ViewEvent<'onSelectionChange', {
74
+ selection: number[];
75
+ }>;
76
+ export type NativeListProps = Omit<ListProps, 'onDeleteItem' | 'onMoveItem' | 'onSelectionChange'> & DeleteItemEvent & MoveItemEvent & SelectItemEvent & {
77
+ children: React.ReactNode;
78
+ };
79
+ /**
80
+ * A list component that renders its children using a native SwiftUI list.
81
+ * @param {ListProps} props - The properties for the list component.
82
+ * @returns {JSX.Element | null} The rendered list with its children or null if the platform is unsupported.
83
+ * @platform ios
84
+ */
85
+ export declare function List({ children }: ListProps): import("react").ReactNode;
86
+ export {};
87
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../List/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,OAAO,GAA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,GACf,aAAa,GACb,eAAe,GAAG;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEJ;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,SAAS,6BAE3C"}
@@ -0,0 +1,76 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
2
+ /**
3
+ * Colors for picker's core elements.
4
+ * @platform android
5
+ */
6
+ export type PickerElementColors = {
7
+ activeBorderColor?: string;
8
+ activeContentColor?: string;
9
+ inactiveBorderColor?: string;
10
+ inactiveContentColor?: string;
11
+ disabledActiveBorderColor?: string;
12
+ disabledActiveContentColor?: string;
13
+ disabledInactiveBorderColor?: string;
14
+ disabledInactiveContentColor?: string;
15
+ activeContainerColor?: string;
16
+ inactiveContainerColor?: string;
17
+ disabledActiveContainerColor?: string;
18
+ disabledInactiveContainerColor?: string;
19
+ };
20
+ /**
21
+ * Props for the Picker component.
22
+ */
23
+ export type PickerProps = {
24
+ /**
25
+ * An array of options to be displayed in the picker.
26
+ */
27
+ options: string[];
28
+ /**
29
+ * The index of the currently selected option.
30
+ */
31
+ selectedIndex: number | null;
32
+ /**
33
+ * A label displayed on the picker when in `'menu'` variant inside a form section on iOS.
34
+ * @platform ios
35
+ */
36
+ label?: string;
37
+ /**
38
+ * Callback function that is called when an option is selected.
39
+ */
40
+ onOptionSelected?: (event: {
41
+ nativeEvent: {
42
+ index: number;
43
+ label: string;
44
+ };
45
+ }) => void;
46
+ /**
47
+ * The variant of the picker, which determines its appearance and behavior.
48
+ * The `'wheel'`, `'inline'`, `'palette'` and `'menu'` variants are iOS only, the `'radio'` variant is Android only. The `'inline'` variant can only be used inside sections or lists. The `'palette'` variant displays differently inside menus.
49
+ * @default 'segmented'
50
+ */
51
+ variant?: 'wheel' | 'segmented' | 'menu' | 'radio' | 'inline' | 'palette';
52
+ /**
53
+ * Optional style to apply to the picker component.
54
+ */
55
+ style?: StyleProp<ViewStyle>;
56
+ /**
57
+ * Colors for picker's core elements.
58
+ * @platform android
59
+ */
60
+ elementColors?: PickerElementColors;
61
+ /**
62
+ * Picker color. On iOS it only applies to the `'menu'` variant.
63
+ */
64
+ color?: string;
65
+ };
66
+ type NativePickerProps = PickerProps;
67
+ /**
68
+ * @hidden
69
+ */
70
+ export declare function transformPickerProps(props: PickerProps): NativePickerProps;
71
+ /**
72
+ * Displays a native picker component. Depending on the variant it can be a segmented button, an inline picker, a list of choices or a radio button.
73
+ */
74
+ export declare function Picker(props: PickerProps): import("react").JSX.Element;
75
+ export {};
76
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Picker/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;OAEG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,KAAK,IAAI,CAAC;IACtF;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC1E;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAE7B;;;OAGG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAOF,KAAK,iBAAiB,GAAG,WAAW,CAAC;AAErC;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,iBAAiB,CAa1E;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,+BAExC"}
@@ -0,0 +1,16 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
2
+ export type SectionProps = {
3
+ /**
4
+ * On iOS, section titles are usually capitalized for consistency with platform conventions.
5
+ */
6
+ title?: string;
7
+ children: any;
8
+ style?: StyleProp<ViewStyle>;
9
+ };
10
+ /**
11
+ * Section component uses the native [Section](https://developer.apple.com/documentation/swiftui/section) component.
12
+ * It has no intrinsic dimensions, so it needs explicit height or flex set to display content (like ScrollView).
13
+ * @platform ios
14
+ */
15
+ export declare function Section({ children }: SectionProps): any;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Section/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE,YAAY,OAEjD"}
@@ -1,5 +1,16 @@
1
1
  import { StyleProp, ViewStyle } from 'react-native';
2
- import { ViewEvent } from '../../src';
2
+ import { ViewEvent } from '../src/types';
3
+ /**
4
+ * Colors for slider's core elements.
5
+ * @platform android
6
+ */
7
+ export type SliderElementColors = {
8
+ thumbColor?: string;
9
+ activeTrackColor?: string;
10
+ inactiveTrackColor?: string;
11
+ activeTickColor?: string;
12
+ inactiveTickColor?: string;
13
+ };
3
14
  export type SliderProps = {
4
15
  /**
5
16
  * Custom styles for the slider component.
@@ -11,12 +22,12 @@ export type SliderProps = {
11
22
  */
12
23
  value?: number;
13
24
  /**
14
- * The number of steps between the minimum and maximum values. 0 signifies infinite steps.
25
+ * The number of steps between the minimum and maximum values, `0` signifies infinite steps.
15
26
  * @default 0
16
27
  */
17
28
  steps?: number;
18
29
  /**
19
- * The mininum value of the slider. Updating this value does not trigger callbacks if the current value is below `min`.
30
+ * The minimum value of the slider. Updating this value does not trigger callbacks if the current value is below `min`.
20
31
  * @default 0
21
32
  */
22
33
  min?: number;
@@ -29,13 +40,7 @@ export type SliderProps = {
29
40
  * Colors for slider's core elements.
30
41
  * @platform android
31
42
  */
32
- elementColors?: {
33
- thumbColor?: string;
34
- activeTrackColor?: string;
35
- inactiveTrackColor?: string;
36
- activeTickColor?: string;
37
- inactiveTickColor?: string;
38
- };
43
+ elementColors?: SliderElementColors;
39
44
  /**
40
45
  * Slider color.
41
46
  */
@@ -48,6 +53,9 @@ export type SliderProps = {
48
53
  type NativeSliderProps = Omit<SliderProps, 'onValueChange'> & ViewEvent<'onValueChanged', {
49
54
  value: number;
50
55
  }>;
56
+ /**
57
+ * @hidden
58
+ */
51
59
  export declare function transformSliderProps(props: SliderProps): NativeSliderProps;
52
60
  export declare function Slider(props: SliderProps): import("react").JSX.Element;
53
61
  export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Slider/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF,KAAK,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,GACzD,SAAS,CAAC,gBAAgB,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAOjD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,iBAAiB,CAqB1E;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,+BAExC"}
@@ -1,46 +1,22 @@
1
1
  import { NativeSyntheticEvent, StyleProp, ViewStyle } from 'react-native';
2
+ /**
3
+ * Only for switch.
4
+ */
2
5
  type SwitchElementColors = {
3
- /**
4
- * Only for switch.
5
- */
6
6
  checkedThumbColor?: string;
7
- /**
8
- * Only for switch.
9
- */
10
7
  checkedTrackColor?: string;
11
- /**
12
- * Only for switch.
13
- */
14
8
  uncheckedThumbColor?: string;
15
- /**
16
- * Only for switch.
17
- */
18
9
  uncheckedTrackColor?: string;
19
10
  };
11
+ /**
12
+ * Only for checkbox.
13
+ */
20
14
  type CheckboxElementColors = {
21
- /**
22
- * Only for checkbox.
23
- */
24
15
  checkedColor?: string;
25
- /**
26
- * Only for checkbox.
27
- */
28
16
  disabledCheckedColor?: string;
29
- /**
30
- * Only for checkbox.
31
- */
32
17
  uncheckedColor?: string;
33
- /**
34
- * Only for checkbox.
35
- */
36
18
  disabledUncheckedColor?: string;
37
- /**
38
- * Only for checkbox.
39
- */
40
19
  checkmarkColor?: string;
41
- /**
42
- * Only for checkbox.
43
- */
44
20
  disabledIndeterminateColor?: string;
45
21
  };
46
22
  export type SwitchProps = {
@@ -56,7 +32,7 @@ export type SwitchProps = {
56
32
  */
57
33
  label?: string;
58
34
  /**
59
- * Type of the switch component. Can be 'checkbox', 'switch', or 'button'. The 'button' style is iOS only.
35
+ * Type of the switch component. Can be `'checkbox'`, `'switch'`, or `'button'`. The `'button'` style is iOS only.
60
36
  * @default 'switch'
61
37
  */
62
38
  variant?: 'checkbox' | 'switch' | 'button';
@@ -69,32 +45,38 @@ export type SwitchProps = {
69
45
  */
70
46
  style?: StyleProp<ViewStyle>;
71
47
  /**
72
- * Picker color. On iOS it only applies to the `menu` variant.
48
+ * Picker color. On iOS, it only applies to the `menu` variant.
73
49
  */
74
50
  color?: string;
75
- } & ({
51
+ } & (SwitchSwitchVariantProps | SwitchCheckboxVariantProps | SwitchButtonVariantProps);
52
+ export type SwitchSwitchVariantProps = {
76
53
  variant?: 'switch';
77
54
  /**
78
55
  * Colors for switch's core elements.
79
56
  * @platform android
80
57
  */
81
58
  elementColors?: SwitchElementColors;
82
- } | {
59
+ };
60
+ export type SwitchCheckboxVariantProps = {
83
61
  variant: 'checkbox';
84
62
  /**
85
63
  * Colors for checkbox core elements.
86
64
  * @platform android
87
65
  */
88
66
  elementColors?: CheckboxElementColors;
89
- } | {
67
+ };
68
+ export type SwitchButtonVariantProps = {
90
69
  variant: 'button';
91
70
  elementColors?: undefined;
92
- });
71
+ };
93
72
  type NativeSwitchProps = Omit<SwitchProps, 'onValueChange'> & {
94
73
  onValueChange: (event: NativeSyntheticEvent<{
95
74
  value: boolean;
96
75
  }>) => void;
97
76
  };
77
+ /**
78
+ * @hidden
79
+ */
98
80
  export declare function transformSwitchProps(props: SwitchProps): NativeSwitchProps;
99
81
  export declare function Switch(props: SwitchProps): import("react").JSX.Element;
100
82
  export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Switch/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG1E;;GAEG;AACH,KAAK,mBAAmB,GAAG;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAGF;;GAEG;AACH,KAAK,qBAAqB,GAAG;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0BAA0B,CAAC,EAAE,MAAM,CAA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u';
3
+ export type * from '../Picker';
4
+ export type * from '../Section';
5
+ export type * from '../Slider';
6
+ export type * from '../Switch';
7
+ export type * from '../Label';
8
+ export type * from '../List';
9
+ /**
10
+ * @hidden
11
+ */
12
+ export type ViewEvent<Name extends string, Data> = Record<Name, Data extends object ? ((event: {
13
+ nativeEvent: Data;
14
+ }) => void) | undefined : (() => void) | undefined>;
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,SAAS,CAAC;AAE7B;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,IAAI,SAAS,MAAM,EAAE,IAAI,IAAI,MAAM,CACvD,IAAI,EACJ,IAAI,SAAS,MAAM,GACf,CAAC,CAAC,KAAK,EAAE;IAAE,WAAW,EAAE,IAAI,CAAA;CAAE,KAAK,IAAI,CAAC,GAAG,SAAS,GACpD,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAC7B,CAAC"}
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "platforms": ["apple", "android"],
3
- "android": {
4
- "modules": ["expo.modules.ui.ExpoUIModule"]
5
- },
6
3
  "apple": {
7
4
  "modules": ["ExpoUIModule"]
5
+ },
6
+ "android": {
7
+ "modules": ["expo.modules.ui.ExpoUIModule"]
8
8
  }
9
9
  }
@@ -0,0 +1,86 @@
1
+ // Copyright 2025-present 650 Industries. All rights reserved.
2
+
3
+ import SwiftUI
4
+ import ExpoModulesCore
5
+
6
+ class BottomSheetProps: ExpoSwiftUI.ViewProps {
7
+ @Field var isOpened: Bool = false
8
+ var onIsOpenedChange = EventDispatcher()
9
+ }
10
+
11
+ struct HeightPreferenceKey: PreferenceKey {
12
+ static var defaultValue: CGFloat?
13
+
14
+ static func reduce(value: inout CGFloat?, nextValue: () -> CGFloat?) {
15
+ guard let nextValue = nextValue() else {
16
+ return
17
+ }
18
+ value = nextValue
19
+ }
20
+ }
21
+
22
+ private struct ReadHeightModifier: ViewModifier {
23
+ private var sizeView: some View {
24
+ GeometryReader { geometry in
25
+ Color.clear.preference(key: HeightPreferenceKey.self, value: geometry.size.height)
26
+ }
27
+ }
28
+
29
+ func body(content: Content) -> some View {
30
+ content.background(sizeView)
31
+ }
32
+ }
33
+
34
+ struct BottomSheetView: ExpoSwiftUI.View, ExpoSwiftUI.WithHostingView {
35
+ @ObservedObject var props: BottomSheetProps
36
+
37
+ @State private var isOpened = true
38
+ @State var height: CGFloat = 0
39
+
40
+ init(props: BottomSheetProps) {
41
+ self.props = props
42
+ }
43
+
44
+ var body: some View {
45
+ if #available(iOS 16.0, tvOS 16.0, *) {
46
+ Rectangle().hidden()
47
+ .modifier(ReadHeightModifier())
48
+ .onPreferenceChange(HeightPreferenceKey.self) { height in
49
+ if let height {
50
+ self.height = height
51
+ }
52
+ }
53
+ .sheet(isPresented: $isOpened) {
54
+ Children()
55
+ .presentationDetents([.height(self.height)])
56
+ }
57
+ .onChange(of: isOpened, perform: { newIsOpened in
58
+ if props.isOpened == newIsOpened {
59
+ return
60
+ }
61
+ props.onIsOpenedChange([
62
+ "isOpened": newIsOpened
63
+ ])
64
+ })
65
+ .onReceive(props.objectWillChange, perform: {
66
+ isOpened = props.isOpened
67
+ })
68
+ } else {
69
+ Rectangle().hidden()
70
+ .sheet(isPresented: $isOpened) {
71
+ Children()
72
+ }
73
+ .onChange(of: isOpened, perform: { newIsOpened in
74
+ if props.isOpened == newIsOpened {
75
+ return
76
+ }
77
+ props.onIsOpenedChange([
78
+ "isOpened": newIsOpened
79
+ ])
80
+ })
81
+ .onReceive(props.objectWillChange, perform: {
82
+ isOpened = props.isOpened
83
+ })
84
+ }
85
+ }
86
+ }