@expo/ui 1.0.0-canary-20250306-d9d3e02 → 1.0.0-canary-20250320-7a205d3
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.
- package/CHANGELOG.md +5 -0
- package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +4 -0
- package/android/src/main/java/expo/modules/ui/PickerView.kt +3 -0
- package/android/src/main/java/expo/modules/ui/TextInputView.kt +75 -0
- package/android/src/main/java/expo/modules/ui/menu/ContextMenu.kt +7 -3
- package/build/components/BottomSheet/index.d.ts +9 -0
- package/build/components/BottomSheet/index.d.ts.map +1 -0
- package/build/components/BottomSheet/index.ios.d.ts +11 -0
- package/build/components/BottomSheet/index.ios.d.ts.map +1 -0
- package/build/components/Button/index.d.ts +1 -1
- package/build/components/ContextMenu/index.android.d.ts +23 -0
- package/build/components/ContextMenu/index.android.d.ts.map +1 -0
- package/build/components/ContextMenu/index.d.ts +54 -20
- package/build/components/ContextMenu/index.d.ts.map +1 -1
- package/build/components/DatePicker/index.d.ts +6 -6
- package/build/components/Picker/index.d.ts +8 -5
- package/build/components/Picker/index.d.ts.map +1 -1
- package/build/components/Progress/index.d.ts +1 -1
- package/build/components/Section/index.d.ts +6 -1
- package/build/components/Section/index.d.ts.map +1 -1
- package/build/components/Slider/index.d.ts +5 -2
- package/build/components/Slider/index.d.ts.map +1 -1
- package/build/components/Switch/index.d.ts +18 -36
- package/build/components/Switch/index.d.ts.map +1 -1
- package/build/components/TextInput/index.d.ts +24 -1
- package/build/components/TextInput/index.d.ts.map +1 -1
- package/build/src/types.d.ts +2 -2
- package/build/src/types.d.ts.map +1 -1
- package/components/BottomSheet/index.ios.tsx +34 -0
- package/components/BottomSheet/index.tsx +12 -0
- package/components/Button/index.tsx +1 -1
- package/components/ContextMenu/index.android.tsx +72 -0
- package/components/ContextMenu/index.tsx +67 -33
- package/components/DatePicker/index.tsx +6 -6
- package/components/Picker/index.tsx +8 -5
- package/components/Progress/index.tsx +1 -1
- package/components/Section/index.tsx +6 -1
- package/components/Slider/index.tsx +5 -2
- package/components/Switch/index.tsx +37 -54
- package/components/TextInput/index.tsx +30 -3
- package/ios/BottomSheetView.swift +82 -0
- package/ios/ContextMenu/ContextMenu.swift +65 -2
- package/ios/ContextMenu/ContextMenuRecords.swift +6 -0
- package/ios/ExpoUIModule.swift +3 -0
- package/ios/PickerView.swift +32 -27
- package/package.json +3 -4
- package/src/types.ts +2 -2
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
2
|
import { ViewEvent } from '../../src/types';
|
|
3
|
+
/**
|
|
4
|
+
* @hidden Not used anywhere yet.
|
|
5
|
+
*/
|
|
3
6
|
export type TextInputRole = 'default' | 'cancel' | 'destructive';
|
|
4
7
|
/**
|
|
5
8
|
* Props for the TextInput component.
|
|
@@ -30,6 +33,27 @@ export type TextInputProps = {
|
|
|
30
33
|
numberOfLines?: number;
|
|
31
34
|
/**
|
|
32
35
|
* Determines which keyboard to open, e.g., numeric.
|
|
36
|
+
*
|
|
37
|
+
* Types that work on both platforms:
|
|
38
|
+
* - default
|
|
39
|
+
* - numeric
|
|
40
|
+
* - email-address
|
|
41
|
+
* - phone-pad
|
|
42
|
+
* - decimal-pad
|
|
43
|
+
* - ascii-capable
|
|
44
|
+
* - url
|
|
45
|
+
*
|
|
46
|
+
* Types that only work on Android:
|
|
47
|
+
* - password
|
|
48
|
+
* - password-numeric
|
|
49
|
+
*
|
|
50
|
+
* Types that only work on iOS:
|
|
51
|
+
* - numbers-and-punctuation
|
|
52
|
+
* - name-phone-pad
|
|
53
|
+
* - twitter
|
|
54
|
+
* - web-search
|
|
55
|
+
* - ascii-capable-number-pad
|
|
56
|
+
*
|
|
33
57
|
* @default default
|
|
34
58
|
*/
|
|
35
59
|
keyboardType?: 'default' | 'email-address' | 'numeric' | 'phone-pad' | 'ascii-capable' | 'numbers-and-punctuation' | 'url' | 'name-phone-pad' | 'decimal-pad' | 'twitter' | 'web-search' | 'ascii-capable-number-pad';
|
|
@@ -41,7 +65,6 @@ export type TextInputProps = {
|
|
|
41
65
|
};
|
|
42
66
|
export type NativeTextInputProps = Omit<TextInputProps, 'onChangeText'> & {} & ViewEvent<'onValueChanged', {
|
|
43
67
|
value: string;
|
|
44
|
-
eventIndex: number;
|
|
45
68
|
}>;
|
|
46
69
|
export declare function TextInput(props: TextInputProps): import("react").JSX.Element;
|
|
47
70
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/TextInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/TextInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,YAAY,CAAC,EACT,SAAS,GACT,eAAe,GACf,SAAS,GACT,WAAW,GACX,eAAe,GACf,yBAAyB,GACzB,KAAK,GACL,gBAAgB,GAChB,aAAa,GACb,SAAS,GACT,YAAY,GACZ,0BAA0B,CAAC;IAC/B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,SAAS,CACpF,gBAAgB,EAChB;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAClB,CAAC;AAoBJ,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,+BAE9C"}
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type * from '../components/Switch';
|
|
2
|
-
export type * from '../components/Picker';
|
|
3
1
|
export type * from '../components/Button';
|
|
4
2
|
export type * from '../components/ContextMenu';
|
|
3
|
+
export type * from '../components/Picker';
|
|
5
4
|
export type * from '../components/Section';
|
|
6
5
|
export type * from '../components/Slider';
|
|
6
|
+
export type * from '../components/Switch';
|
|
7
7
|
/**
|
|
8
8
|
* @hidden
|
|
9
9
|
*/
|
package/build/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,2BAA2B,CAAC;AAC/C,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,uBAAuB,CAAC;AAC3C,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,sBAAsB,CAAC;AAE1C;;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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import { Dimensions, NativeSyntheticEvent, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { BottomSheetProps } from '.';
|
|
5
|
+
|
|
6
|
+
type NativeBottomSheetProps = Omit<BottomSheetProps, 'onIsOpenedChange'> & {
|
|
7
|
+
onIsOpenedChange: (event: NativeSyntheticEvent<{ isOpened: boolean }>) => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const BottomSheetNativeView: React.ComponentType<NativeBottomSheetProps> = requireNativeView(
|
|
11
|
+
'ExpoUI',
|
|
12
|
+
'BottomSheetView'
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export function transformBottomSheetProps(props: BottomSheetProps): NativeBottomSheetProps {
|
|
16
|
+
return {
|
|
17
|
+
...props,
|
|
18
|
+
onIsOpenedChange: ({ nativeEvent: { isOpened } }) => {
|
|
19
|
+
props?.onIsOpenedChange?.(isOpened);
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function BottomSheet(props: BottomSheetProps) {
|
|
25
|
+
const { width } = Dimensions.get('window');
|
|
26
|
+
return (
|
|
27
|
+
<View>
|
|
28
|
+
<BottomSheetNativeView
|
|
29
|
+
style={{ position: 'absolute', width }}
|
|
30
|
+
{...transformBottomSheetProps(props)}
|
|
31
|
+
/>
|
|
32
|
+
</View>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type BottomSheetProps = {
|
|
4
|
+
style?: StyleProp<ViewStyle>;
|
|
5
|
+
children: any;
|
|
6
|
+
isOpened: boolean;
|
|
7
|
+
onIsOpenedChange: (isOpened: boolean) => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function BottomSheet({ children }: BottomSheetProps) {
|
|
11
|
+
return children;
|
|
12
|
+
}
|
|
@@ -69,7 +69,7 @@ export type ButtonProps = {
|
|
|
69
69
|
onPress?: () => void;
|
|
70
70
|
/**
|
|
71
71
|
* A string describing the system image to display in the button.
|
|
72
|
-
* Uses
|
|
72
|
+
* Uses Material Icons on Android and SF Symbols on iOS.
|
|
73
73
|
*/
|
|
74
74
|
systemImage?: {
|
|
75
75
|
ios?: string;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import { Children, useMemo } from 'react';
|
|
3
|
+
import { NativeSyntheticEvent } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import { ContextMenuProps, EventHandlers, NativeMenuProps } from '.';
|
|
6
|
+
import { transformChildrenToElementArray } from './utils';
|
|
7
|
+
|
|
8
|
+
const MenuNativeView: React.ComponentType<NativeMenuProps> = requireNativeView(
|
|
9
|
+
'ExpoUI',
|
|
10
|
+
'ContextMenu'
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export function Submenu() {
|
|
14
|
+
return <></>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function Items() {
|
|
18
|
+
return <></>;
|
|
19
|
+
}
|
|
20
|
+
Items.tag = 'Items';
|
|
21
|
+
|
|
22
|
+
export function Trigger(props: { children: React.ReactNode }) {
|
|
23
|
+
return <></>;
|
|
24
|
+
}
|
|
25
|
+
Trigger.tag = 'Trigger';
|
|
26
|
+
|
|
27
|
+
export function Preview(props: { children: React.ReactNode }) {
|
|
28
|
+
return <></>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function ContextMenu(props: ContextMenuProps) {
|
|
32
|
+
const eventHandlersMap: EventHandlers = {};
|
|
33
|
+
const initialChildren = Children.map(
|
|
34
|
+
props.children as any,
|
|
35
|
+
(c: { type: { tag: string }; props: { children: React.ReactNode } }) =>
|
|
36
|
+
c.type.tag === Items.tag ? c.props.children : null
|
|
37
|
+
);
|
|
38
|
+
const processedElements = useMemo(
|
|
39
|
+
() => transformChildrenToElementArray(initialChildren, eventHandlersMap),
|
|
40
|
+
[initialChildren]
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const activationElement = Children.map(
|
|
44
|
+
props.children as any,
|
|
45
|
+
(c: { type: { tag: string }; props: { children: React.ReactNode } }) =>
|
|
46
|
+
c.type.tag === Trigger.tag ? c.props.children : null
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const createEventHandler =
|
|
50
|
+
(handlerType: string) => (e: NativeSyntheticEvent<{ contextMenuElementID: string }>) => {
|
|
51
|
+
const handler = eventHandlersMap[e.nativeEvent.contextMenuElementID]?.[handlerType];
|
|
52
|
+
handler?.(e);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<MenuNativeView
|
|
57
|
+
style={props.style}
|
|
58
|
+
elements={processedElements}
|
|
59
|
+
onContextMenuButtonPressed={createEventHandler('onPress')}
|
|
60
|
+
onContextMenuSwitchValueChanged={createEventHandler('onValueChange')}
|
|
61
|
+
onContextMenuPickerOptionSelected={createEventHandler('onOptionSelected')}
|
|
62
|
+
{...props}>
|
|
63
|
+
{activationElement}
|
|
64
|
+
</MenuNativeView>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
ContextMenu.Trigger = Trigger;
|
|
69
|
+
ContextMenu.Preview = Preview;
|
|
70
|
+
ContextMenu.Items = Items;
|
|
71
|
+
|
|
72
|
+
export { ContextMenu };
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { requireNativeView } from 'expo';
|
|
2
|
-
import { ReactElement, ReactNode, useMemo } from 'react';
|
|
2
|
+
import { ComponentType, Children, ReactElement, ReactNode, useMemo } from 'react';
|
|
3
3
|
import { NativeSyntheticEvent, StyleProp, ViewStyle } from 'react-native';
|
|
4
4
|
|
|
5
|
+
import { MenuElement, transformChildrenToElementArray } from './utils';
|
|
5
6
|
import { ButtonProps } from '../Button';
|
|
6
7
|
import { PickerProps } from '../Picker';
|
|
7
8
|
import { SwitchProps } from '../Switch';
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
const MenuNativeView: ComponentType<NativeMenuProps> = requireNativeView(
|
|
11
|
+
'ExpoUI',
|
|
12
|
+
'ContextMenu'
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const MenuNativeTriggerView: ComponentType<object> = requireNativeView(
|
|
16
|
+
'ExpoUI',
|
|
17
|
+
'ContextMenuActivationElement'
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const MenuNativePreviewView: ComponentType<object> = requireNativeView(
|
|
21
|
+
'ExpoUI',
|
|
22
|
+
'ContextMenuPreview'
|
|
23
|
+
);
|
|
9
24
|
|
|
10
25
|
type SubmenuElement =
|
|
11
26
|
| ReactElement<ButtonProps>
|
|
@@ -13,23 +28,17 @@ type SubmenuElement =
|
|
|
13
28
|
| ReactElement<PickerProps>
|
|
14
29
|
| ReactElement<SubmenuProps>;
|
|
15
30
|
|
|
16
|
-
type ContentChildren = SubmenuElement | SubmenuElement[];
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @hidden
|
|
20
|
-
*/
|
|
21
31
|
export type ContextMenuContentProps = {
|
|
22
|
-
children:
|
|
32
|
+
children: SubmenuElement | SubmenuElement[];
|
|
23
33
|
};
|
|
24
34
|
|
|
25
35
|
/**
|
|
26
36
|
* @hidden
|
|
27
37
|
*/
|
|
28
|
-
export type EventHandlers =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
38
|
+
export type EventHandlers = Record<
|
|
39
|
+
string,
|
|
40
|
+
Record<string, (event: NativeSyntheticEvent<any>) => void>
|
|
41
|
+
>;
|
|
33
42
|
|
|
34
43
|
/**
|
|
35
44
|
* @hidden
|
|
@@ -47,13 +56,6 @@ export type ActivationMethod = 'singlePress' | 'longPress';
|
|
|
47
56
|
* Props of the `ContextMenu` component.
|
|
48
57
|
*/
|
|
49
58
|
export type ContextMenuProps = {
|
|
50
|
-
/**
|
|
51
|
-
* Items visible inside the context menu. The items should be wrapped in a `React.Fragment`.
|
|
52
|
-
* `Button`, `Switch` and `Submenu` components are supported on both Android and iOS.
|
|
53
|
-
* The `Picker` component is supported only on iOS. Remember to use components from the `@expo/ui` library.
|
|
54
|
-
*/
|
|
55
|
-
Items: React.ReactElement<ContextMenuContentProps>;
|
|
56
|
-
|
|
57
59
|
/**
|
|
58
60
|
* Determines how the context menu will be activated.
|
|
59
61
|
*
|
|
@@ -87,14 +89,17 @@ export type SubmenuProps = {
|
|
|
87
89
|
/**
|
|
88
90
|
* 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.
|
|
89
91
|
*/
|
|
90
|
-
button:
|
|
92
|
+
button: ReactElement<ButtonProps>;
|
|
91
93
|
/**
|
|
92
94
|
* Children of the submenu. Only `Button`, `Switch`, `Picker` and `Submenu` elements should be used.
|
|
93
95
|
*/
|
|
94
|
-
children:
|
|
96
|
+
children: ReactNode;
|
|
95
97
|
};
|
|
96
98
|
|
|
97
|
-
|
|
99
|
+
/**
|
|
100
|
+
* @hidden
|
|
101
|
+
*/
|
|
102
|
+
export type NativeMenuProps = ContextMenuProps & {
|
|
98
103
|
elements: MenuElement[];
|
|
99
104
|
onContextMenuButtonPressed: (
|
|
100
105
|
event: NativeSyntheticEvent<{ contextMenuElementID: string }>
|
|
@@ -114,11 +119,6 @@ type NativeMenuProps = ContextMenuProps & {
|
|
|
114
119
|
) => void;
|
|
115
120
|
};
|
|
116
121
|
|
|
117
|
-
const MenuNativeView: React.ComponentType<NativeMenuProps> = requireNativeView(
|
|
118
|
-
'ExpoUI',
|
|
119
|
-
'ContextMenu'
|
|
120
|
-
);
|
|
121
|
-
|
|
122
122
|
/**
|
|
123
123
|
* The `Submenu` component is used to create a nested context menu. Submenus can be infinitely nested.
|
|
124
124
|
* Android does not support nesting in the context menu. All the submenus will be flat-mapped into a single level with multiple titled sections.
|
|
@@ -127,6 +127,30 @@ export function Submenu(props: SubmenuProps) {
|
|
|
127
127
|
return <></>;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Items visible inside the context menu. Pass input components as immidiate children of the tag.
|
|
132
|
+
* `Button`, `Switch` and `Submenu` components are supported on both Android and iOS.
|
|
133
|
+
* The `Picker` component is supported only on iOS. Remember to use components from the `@expo/ui` library.
|
|
134
|
+
*/
|
|
135
|
+
export function Items(props: { children: React.ReactNode }) {
|
|
136
|
+
return <></>;
|
|
137
|
+
}
|
|
138
|
+
Items.tag = 'Items';
|
|
139
|
+
/**
|
|
140
|
+
* The component visible all the time that triggers the menu when tapped or long-pressed.
|
|
141
|
+
*/
|
|
142
|
+
export function Trigger(props: { children: React.ReactNode }) {
|
|
143
|
+
return <MenuNativeTriggerView {...props} />;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The component visible above the menu when it is opened.
|
|
148
|
+
* @platform ios
|
|
149
|
+
*/
|
|
150
|
+
export function Preview(props: { children: React.ReactNode }) {
|
|
151
|
+
return <MenuNativePreviewView {...props} />;
|
|
152
|
+
}
|
|
153
|
+
|
|
130
154
|
/**
|
|
131
155
|
* `ContextMenu` allows you to create a context menu, which can be used to provide additional options to the user.
|
|
132
156
|
*
|
|
@@ -136,18 +160,22 @@ export function Submenu(props: SubmenuProps) {
|
|
|
136
160
|
* - 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.
|
|
137
161
|
* - Android does not support showing a `Picker` element in the context menu.
|
|
138
162
|
*/
|
|
139
|
-
|
|
163
|
+
function ContextMenu(props: ContextMenuProps) {
|
|
140
164
|
const eventHandlersMap: EventHandlers = {};
|
|
141
|
-
const initialChildren =
|
|
165
|
+
const initialChildren = Children.map(
|
|
166
|
+
props.children as any,
|
|
167
|
+
(c: { type: { tag: string }; props: { children: React.ReactNode } }) =>
|
|
168
|
+
c.type.tag === Items.tag ? c.props.children : null
|
|
169
|
+
);
|
|
142
170
|
const processedElements = useMemo(
|
|
143
171
|
() => transformChildrenToElementArray(initialChildren, eventHandlersMap),
|
|
144
172
|
[initialChildren]
|
|
145
173
|
);
|
|
146
174
|
|
|
147
175
|
const createEventHandler =
|
|
148
|
-
(handlerType: string) => (
|
|
149
|
-
const handler = eventHandlersMap[
|
|
150
|
-
handler?.(
|
|
176
|
+
(handlerType: string) => (event: NativeSyntheticEvent<{ contextMenuElementID: string }>) => {
|
|
177
|
+
const handler = eventHandlersMap[event.nativeEvent.contextMenuElementID]?.[handlerType];
|
|
178
|
+
handler?.(event);
|
|
151
179
|
};
|
|
152
180
|
|
|
153
181
|
return (
|
|
@@ -161,3 +189,9 @@ export function ContextMenu(props: ContextMenuProps) {
|
|
|
161
189
|
/>
|
|
162
190
|
);
|
|
163
191
|
}
|
|
192
|
+
|
|
193
|
+
ContextMenu.Trigger = Trigger;
|
|
194
|
+
ContextMenu.Preview = Preview;
|
|
195
|
+
ContextMenu.Items = Items;
|
|
196
|
+
|
|
197
|
+
export { ContextMenu };
|
|
@@ -15,12 +15,12 @@ type DisplayedComponents = 'date' | 'hourAndMinute' | 'dateAndTime';
|
|
|
15
15
|
*/
|
|
16
16
|
export type DatePickerProps = {
|
|
17
17
|
/**
|
|
18
|
-
* The
|
|
18
|
+
* The initial date to display on the picker.
|
|
19
19
|
*/
|
|
20
20
|
initialDate?: string | null;
|
|
21
21
|
/**
|
|
22
22
|
* A title displayed on the picker on iOS.
|
|
23
|
-
* @platform
|
|
23
|
+
* @platform ios
|
|
24
24
|
*/
|
|
25
25
|
title?: string;
|
|
26
26
|
/**
|
|
@@ -29,7 +29,7 @@ export type DatePickerProps = {
|
|
|
29
29
|
onDateSelected?: (date: Date) => void;
|
|
30
30
|
/**
|
|
31
31
|
* The variant of the picker, which determines its appearance and behavior.
|
|
32
|
-
* @platform
|
|
32
|
+
* @platform ios
|
|
33
33
|
* @default 'automatic'
|
|
34
34
|
*/
|
|
35
35
|
iosVariant?: IOSVariant;
|
|
@@ -42,15 +42,15 @@ export type DatePickerProps = {
|
|
|
42
42
|
/**
|
|
43
43
|
* Show to button to toggle between variants on Android.
|
|
44
44
|
* @platform android
|
|
45
|
-
* @default
|
|
45
|
+
* @default true
|
|
46
46
|
*/
|
|
47
47
|
showVariantToggle?: boolean;
|
|
48
48
|
/**
|
|
49
49
|
* The components that the picker should display.
|
|
50
|
-
* On iOS, you can have a picker that selects both date and time.
|
|
51
50
|
* On Android, you can have a picker that selects just the date or just the time.
|
|
52
51
|
* `dateAndTime` is only available on iOS and will result in a date picker on Android.
|
|
53
|
-
*
|
|
52
|
+
* On iOS, you can have a picker that selects both date and time.
|
|
53
|
+
* @default 'date'
|
|
54
54
|
*/
|
|
55
55
|
displayedComponents?: DisplayedComponents;
|
|
56
56
|
/**
|
|
@@ -33,8 +33,8 @@ export type PickerProps = {
|
|
|
33
33
|
*/
|
|
34
34
|
selectedIndex: number | null;
|
|
35
35
|
/**
|
|
36
|
-
* A label displayed on the picker when in `menu` variant inside a form section on iOS.
|
|
37
|
-
* @platform
|
|
36
|
+
* A label displayed on the picker when in `'menu'` variant inside a form section on iOS.
|
|
37
|
+
* @platform ios
|
|
38
38
|
*/
|
|
39
39
|
label?: string;
|
|
40
40
|
/**
|
|
@@ -43,10 +43,10 @@ export type PickerProps = {
|
|
|
43
43
|
onOptionSelected?: (event: { nativeEvent: { index: number; label: string } }) => void;
|
|
44
44
|
/**
|
|
45
45
|
* The variant of the picker, which determines its appearance and behavior.
|
|
46
|
-
* The 'wheel' and 'menu' variants are iOS only, the 'radio' variant is Android only.
|
|
46
|
+
* 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.
|
|
47
47
|
* @default 'segmented'
|
|
48
48
|
*/
|
|
49
|
-
variant?: 'wheel' | 'segmented' | 'menu' | 'radio';
|
|
49
|
+
variant?: 'wheel' | 'segmented' | 'menu' | 'radio' | 'inline' | 'palette';
|
|
50
50
|
/**
|
|
51
51
|
* Optional style to apply to the picker component.
|
|
52
52
|
*/
|
|
@@ -58,7 +58,7 @@ export type PickerProps = {
|
|
|
58
58
|
*/
|
|
59
59
|
elementColors?: PickerElementColors;
|
|
60
60
|
/**
|
|
61
|
-
* Picker color. On iOS it only applies to the `menu` variant.
|
|
61
|
+
* Picker color. On iOS it only applies to the `'menu'` variant.
|
|
62
62
|
*/
|
|
63
63
|
color?: string;
|
|
64
64
|
};
|
|
@@ -70,6 +70,9 @@ const PickerNativeView: React.ComponentType<PickerProps> = requireNativeView(
|
|
|
70
70
|
|
|
71
71
|
type NativePickerProps = PickerProps;
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @hidden
|
|
75
|
+
*/
|
|
73
76
|
export function transformPickerProps(props: PickerProps): NativePickerProps {
|
|
74
77
|
return {
|
|
75
78
|
...props,
|
|
@@ -16,7 +16,7 @@ export type ProgressProps = {
|
|
|
16
16
|
*/
|
|
17
17
|
style?: StyleProp<ViewStyle>;
|
|
18
18
|
/**
|
|
19
|
-
* The current progress value of the slider. This is a number between 0 and 1
|
|
19
|
+
* The current progress value of the slider. This is a number between `0` and `1`.
|
|
20
20
|
*/
|
|
21
21
|
progress?: number | null;
|
|
22
22
|
/**
|
|
@@ -2,10 +2,15 @@ import { StyleProp, ViewStyle } from 'react-native';
|
|
|
2
2
|
|
|
3
3
|
export type SectionProps = {
|
|
4
4
|
style?: StyleProp<ViewStyle>;
|
|
5
|
-
title
|
|
5
|
+
title?: string;
|
|
6
6
|
children: any;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Section component uses the native [Section](https://developer.apple.com/documentation/swiftui/section) component.
|
|
11
|
+
* It has no intrinsic dimensions, so it needs explicit height or flex set to display content (like ScrollView).
|
|
12
|
+
* @platform ios
|
|
13
|
+
*/
|
|
9
14
|
export function Section({ children }: SectionProps) {
|
|
10
15
|
return children;
|
|
11
16
|
}
|
|
@@ -26,12 +26,12 @@ export type SliderProps = {
|
|
|
26
26
|
*/
|
|
27
27
|
value?: number;
|
|
28
28
|
/**
|
|
29
|
-
* The number of steps between the minimum and maximum values
|
|
29
|
+
* The number of steps between the minimum and maximum values, `0` signifies infinite steps.
|
|
30
30
|
* @default 0
|
|
31
31
|
*/
|
|
32
32
|
steps?: number;
|
|
33
33
|
/**
|
|
34
|
-
* The
|
|
34
|
+
* The minimum value of the slider. Updating this value does not trigger callbacks if the current value is below `min`.
|
|
35
35
|
* @default 0
|
|
36
36
|
*/
|
|
37
37
|
min?: number;
|
|
@@ -63,6 +63,9 @@ const SliderNativeView: React.ComponentType<NativeSliderProps> = requireNativeVi
|
|
|
63
63
|
'SliderView'
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* @hidden
|
|
68
|
+
*/
|
|
66
69
|
export function transformSliderProps(props: SliderProps): NativeSliderProps {
|
|
67
70
|
return {
|
|
68
71
|
...props,
|
|
@@ -1,49 +1,27 @@
|
|
|
1
1
|
import { requireNativeView } from 'expo';
|
|
2
2
|
import { NativeSyntheticEvent, StyleProp, ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
|
+
// @docsMissing
|
|
5
|
+
/**
|
|
6
|
+
* Only for switch.
|
|
7
|
+
*/
|
|
4
8
|
type SwitchElementColors = {
|
|
5
|
-
/**
|
|
6
|
-
* Only for switch.
|
|
7
|
-
*/
|
|
8
9
|
checkedThumbColor?: string;
|
|
9
|
-
/**
|
|
10
|
-
* Only for switch.
|
|
11
|
-
*/
|
|
12
10
|
checkedTrackColor?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Only for switch.
|
|
15
|
-
*/
|
|
16
11
|
uncheckedThumbColor?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Only for switch.
|
|
19
|
-
*/
|
|
20
12
|
uncheckedTrackColor?: string;
|
|
21
13
|
};
|
|
22
14
|
|
|
15
|
+
// @docsMissing
|
|
16
|
+
/**
|
|
17
|
+
* Only for checkbox.
|
|
18
|
+
*/
|
|
23
19
|
type CheckboxElementColors = {
|
|
24
|
-
/**
|
|
25
|
-
* Only for checkbox.
|
|
26
|
-
*/
|
|
27
20
|
checkedColor?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Only for checkbox.
|
|
30
|
-
*/
|
|
31
21
|
disabledCheckedColor?: string;
|
|
32
|
-
/**
|
|
33
|
-
* Only for checkbox.
|
|
34
|
-
*/
|
|
35
22
|
uncheckedColor?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Only for checkbox.
|
|
38
|
-
*/
|
|
39
23
|
disabledUncheckedColor?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Only for checkbox.
|
|
42
|
-
*/
|
|
43
24
|
checkmarkColor?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Only for checkbox.
|
|
46
|
-
*/
|
|
47
25
|
disabledIndeterminateColor?: string;
|
|
48
26
|
};
|
|
49
27
|
|
|
@@ -61,7 +39,7 @@ export type SwitchProps = {
|
|
|
61
39
|
label?: string;
|
|
62
40
|
|
|
63
41
|
/**
|
|
64
|
-
* Type of the switch component. Can be 'checkbox'
|
|
42
|
+
* Type of the switch component. Can be `'checkbox'`, `'switch'`, or `'button'`. The `'button'` style is iOS only.
|
|
65
43
|
* @default 'switch'
|
|
66
44
|
*/
|
|
67
45
|
variant?: 'checkbox' | 'switch' | 'button';
|
|
@@ -74,31 +52,33 @@ export type SwitchProps = {
|
|
|
74
52
|
*/
|
|
75
53
|
style?: StyleProp<ViewStyle>;
|
|
76
54
|
/**
|
|
77
|
-
* Picker color. On iOS it only applies to the `menu` variant.
|
|
55
|
+
* Picker color. On iOS, it only applies to the `menu` variant.
|
|
78
56
|
*/
|
|
79
57
|
color?: string;
|
|
80
|
-
} & (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
58
|
+
} & (SwitchSwitchVariantProps | SwitchCheckboxVariantProps | SwitchButtonVariantProps);
|
|
59
|
+
|
|
60
|
+
export type SwitchSwitchVariantProps = {
|
|
61
|
+
variant?: 'switch';
|
|
62
|
+
/**
|
|
63
|
+
* Colors for switch's core elements.
|
|
64
|
+
* @platform android
|
|
65
|
+
*/
|
|
66
|
+
elementColors?: SwitchElementColors;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type SwitchCheckboxVariantProps = {
|
|
70
|
+
variant: 'checkbox';
|
|
71
|
+
/**
|
|
72
|
+
* Colors for checkbox core elements.
|
|
73
|
+
* @platform android
|
|
74
|
+
*/
|
|
75
|
+
elementColors?: CheckboxElementColors;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type SwitchButtonVariantProps = {
|
|
79
|
+
variant: 'button';
|
|
80
|
+
elementColors?: undefined;
|
|
81
|
+
};
|
|
102
82
|
|
|
103
83
|
type NativeSwitchProps = Omit<SwitchProps, 'onValueChange'> & {
|
|
104
84
|
onValueChange: (event: NativeSyntheticEvent<{ value: boolean }>) => void;
|
|
@@ -127,6 +107,9 @@ function getElementColors(props: SwitchProps) {
|
|
|
127
107
|
return props.elementColors;
|
|
128
108
|
}
|
|
129
109
|
|
|
110
|
+
/**
|
|
111
|
+
* @hidden
|
|
112
|
+
*/
|
|
130
113
|
export function transformSwitchProps(props: SwitchProps): NativeSwitchProps {
|
|
131
114
|
return {
|
|
132
115
|
...props,
|