@expo/ui 0.0.1 → 0.0.2
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 +18 -0
- package/android/build.gradle +5 -13
- package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +24 -1
- package/android/src/main/java/expo/modules/ui/PickerView.kt +108 -0
- package/android/src/main/java/expo/modules/ui/SliderView.kt +73 -0
- package/android/src/main/java/expo/modules/ui/SwitchView.kt +118 -0
- package/android/src/main/java/expo/modules/ui/Utils.kt +52 -0
- package/android/src/main/java/expo/modules/ui/button/Button.kt +140 -0
- package/android/src/main/java/expo/modules/ui/menu/ContextMenu.kt +160 -0
- package/android/src/main/java/expo/modules/ui/menu/ContextMenuRecords.kt +55 -0
- package/build/components/Button/index.d.ts +81 -0
- package/build/components/Button/index.d.ts.map +1 -0
- package/build/components/ContextMenu/index.d.ts +80 -0
- package/build/components/ContextMenu/index.d.ts.map +1 -0
- package/build/components/ContextMenu/utils.d.ts +24 -0
- package/build/components/ContextMenu/utils.d.ts.map +1 -0
- package/build/components/Picker/index.d.ts +65 -0
- package/build/components/Picker/index.d.ts.map +1 -0
- package/build/components/Section/index.d.ts +12 -0
- package/build/components/Section/index.d.ts.map +1 -0
- package/build/components/Section/index.ios.d.ts +8 -0
- package/build/components/Section/index.ios.d.ts.map +1 -0
- package/build/components/Slider/index.d.ts +54 -0
- package/build/components/Slider/index.d.ts.map +1 -0
- package/build/components/Switch/index.d.ts +101 -0
- package/build/components/Switch/index.d.ts.map +1 -0
- package/build/src/index.d.ts +13 -0
- package/build/src/index.d.ts.map +1 -0
- package/components/Button/index.tsx +132 -0
- package/components/ContextMenu/index.tsx +147 -0
- package/components/ContextMenu/utils.ts +139 -0
- package/components/Picker/index.tsx +83 -0
- package/components/Section/index.ios.tsx +58 -0
- package/components/Section/index.tsx +56 -0
- package/components/Slider/index.tsx +85 -0
- package/components/Switch/index.tsx +144 -0
- package/expo-module.config.json +3 -10
- package/ios/Button/Button.swift +54 -0
- package/ios/Button/ButtonProps.swift +43 -0
- package/ios/ContextMenu/ContextMenu.swift +106 -0
- package/ios/ContextMenu/ContextMenuRecords.swift +29 -0
- package/ios/ExpoUI.podspec +2 -1
- package/ios/ExpoUIModule.swift +6 -1
- package/ios/PickerView.swift +52 -0
- package/ios/SectionView.swift +27 -0
- package/ios/SliderView.swift +51 -0
- package/ios/SwitchView.swift +74 -0
- package/package.json +2 -2
- package/src/index.ts +22 -3
- package/tsconfig.json +1 -1
- package/android/src/main/java/expo/modules/ui/SingleChoiceSegmentedControlView.kt +0 -47
- package/build/ExpoUI.types.d.ts +0 -13
- package/build/ExpoUI.types.d.ts.map +0 -1
- package/build/ExpoUIModule.d.ts +0 -6
- package/build/ExpoUIModule.d.ts.map +0 -1
- package/build/ExpoUIView.d.ts +0 -4
- package/build/ExpoUIView.d.ts.map +0 -1
- package/build/index.d.ts +0 -4
- package/build/index.d.ts.map +0 -1
- package/ios/SingleChoiceSegmentedControlProps.swift +0 -10
- package/ios/SingleChoiceSegmentedControlView.swift +0 -29
- package/src/ExpoUI.types.ts +0 -8
- package/src/ExpoUIModule.ts +0 -5
- package/src/ExpoUIView.tsx +0 -10
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
package expo.modules.ui.menu
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.GestureDetector
|
|
5
|
+
import android.view.MotionEvent
|
|
6
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
7
|
+
import androidx.compose.foundation.layout.Box
|
|
8
|
+
import androidx.compose.foundation.layout.Row
|
|
9
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
10
|
+
import androidx.compose.foundation.layout.padding
|
|
11
|
+
import androidx.compose.foundation.layout.wrapContentSize
|
|
12
|
+
import androidx.compose.material3.Checkbox
|
|
13
|
+
import androidx.compose.material3.DropdownMenu
|
|
14
|
+
import androidx.compose.material3.DropdownMenuItem
|
|
15
|
+
import androidx.compose.material3.HorizontalDivider
|
|
16
|
+
import androidx.compose.material3.MaterialTheme
|
|
17
|
+
import androidx.compose.material3.Switch
|
|
18
|
+
import expo.modules.kotlin.views.ExpoComposeView
|
|
19
|
+
import androidx.compose.material3.Text
|
|
20
|
+
import androidx.compose.runtime.Composable
|
|
21
|
+
import androidx.compose.runtime.getValue
|
|
22
|
+
import androidx.compose.runtime.mutableStateOf
|
|
23
|
+
import androidx.compose.runtime.remember
|
|
24
|
+
import androidx.compose.ui.unit.dp
|
|
25
|
+
import expo.modules.kotlin.AppContext
|
|
26
|
+
import androidx.compose.runtime.setValue
|
|
27
|
+
import androidx.compose.ui.Alignment
|
|
28
|
+
import androidx.compose.ui.Modifier
|
|
29
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
30
|
+
import expo.modules.kotlin.viewevent.ViewEventCallback
|
|
31
|
+
|
|
32
|
+
@Composable
|
|
33
|
+
private fun SectionTitle(text: String) {
|
|
34
|
+
Text(
|
|
35
|
+
text = text,
|
|
36
|
+
style = MaterialTheme.typography.labelSmall,
|
|
37
|
+
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
38
|
+
modifier = Modifier
|
|
39
|
+
.fillMaxWidth()
|
|
40
|
+
.padding(start = 16.dp, top = 8.dp, end = 16.dp, bottom = 4.dp)
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Composable
|
|
45
|
+
fun FlatMenu(elements: Array<ContextMenuElement>, sectionTitle: String?, dispatchers: ContextMenuDispatchers) {
|
|
46
|
+
sectionTitle?.takeIf { !it.isEmpty() }?.let {
|
|
47
|
+
SectionTitle(it)
|
|
48
|
+
}
|
|
49
|
+
elements.forEachIndexed { index, element ->
|
|
50
|
+
val id = element.contextMenuElementID
|
|
51
|
+
element.button?.let {
|
|
52
|
+
DropdownMenuItem(
|
|
53
|
+
text = { Text(it.text) },
|
|
54
|
+
onClick = {
|
|
55
|
+
dispatchers.buttonPressed(ContextMenuButtonPressedEvent(id))
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
element.switch?.let {
|
|
61
|
+
DropdownMenuItem(
|
|
62
|
+
text = {
|
|
63
|
+
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
64
|
+
Text(it.label)
|
|
65
|
+
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
|
|
66
|
+
if (it.variant == "checkbox") {
|
|
67
|
+
Checkbox(
|
|
68
|
+
checked = it.value,
|
|
69
|
+
onCheckedChange = null,
|
|
70
|
+
modifier = Modifier
|
|
71
|
+
.padding(horizontal = 5.dp)
|
|
72
|
+
.wrapContentSize(Alignment.CenterEnd)
|
|
73
|
+
)
|
|
74
|
+
} else {
|
|
75
|
+
Switch(
|
|
76
|
+
checked = it.value,
|
|
77
|
+
onCheckedChange = null,
|
|
78
|
+
modifier = Modifier
|
|
79
|
+
.padding(start = 5.dp)
|
|
80
|
+
.wrapContentSize(Alignment.CenterEnd)
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
modifier = Modifier.wrapContentSize(Alignment.Center),
|
|
87
|
+
onClick = {
|
|
88
|
+
dispatchers.switchCheckedChanged(
|
|
89
|
+
ContextMenuSwitchValueChangeEvent(!it.value, id)
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
element.submenu?.let {
|
|
96
|
+
HorizontalDivider()
|
|
97
|
+
FlatMenu(it.elements, it.button.text, dispatchers)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
data class ContextMenuDispatchers(
|
|
103
|
+
val buttonPressed: ViewEventCallback<ContextMenuButtonPressedEvent>,
|
|
104
|
+
val switchCheckedChanged: ViewEventCallback<ContextMenuSwitchValueChangeEvent>
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
class ContextMenu(context: Context, appContext: AppContext) : ExpoComposeView<ContextMenuProps>(context, appContext) {
|
|
108
|
+
override val props = ContextMenuProps()
|
|
109
|
+
val expanded = mutableStateOf(false)
|
|
110
|
+
val onContextMenuButtonPressed by EventDispatcher<ContextMenuButtonPressedEvent>()
|
|
111
|
+
val onContextMenuSwitchValueChanged by EventDispatcher<ContextMenuSwitchValueChangeEvent>()
|
|
112
|
+
|
|
113
|
+
val gestureDetector = GestureDetector(
|
|
114
|
+
context,
|
|
115
|
+
object : GestureDetector.SimpleOnGestureListener() {
|
|
116
|
+
override fun onDown(e: MotionEvent): Boolean {
|
|
117
|
+
if (props.activationMethod.value == ActivationMethod.SINGLE_PRESS) {
|
|
118
|
+
expanded.value = !expanded.value
|
|
119
|
+
}
|
|
120
|
+
return super.onDown(e)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
override fun onLongPress(e: MotionEvent) {
|
|
124
|
+
if (props.activationMethod.value == ActivationMethod.LONG_PRESS) {
|
|
125
|
+
expanded.value = !expanded.value
|
|
126
|
+
}
|
|
127
|
+
return super.onLongPress(e)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
|
|
133
|
+
ev?.let {
|
|
134
|
+
gestureDetector.onTouchEvent(ev)
|
|
135
|
+
}
|
|
136
|
+
return super.dispatchTouchEvent(ev)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
init {
|
|
140
|
+
setContent {
|
|
141
|
+
var elements by remember { props.elements }
|
|
142
|
+
|
|
143
|
+
return@setContent Box {
|
|
144
|
+
DropdownMenu(
|
|
145
|
+
expanded = expanded.value,
|
|
146
|
+
onDismissRequest = { expanded.value = !expanded.value }
|
|
147
|
+
) {
|
|
148
|
+
FlatMenu(
|
|
149
|
+
elements,
|
|
150
|
+
null,
|
|
151
|
+
dispatchers = ContextMenuDispatchers(
|
|
152
|
+
buttonPressed = onContextMenuButtonPressed,
|
|
153
|
+
switchCheckedChanged = onContextMenuSwitchValueChanged
|
|
154
|
+
)
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
package expo.modules.ui.menu
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.MutableState
|
|
4
|
+
import androidx.compose.runtime.mutableStateOf
|
|
5
|
+
import expo.modules.kotlin.records.Field
|
|
6
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
7
|
+
import expo.modules.ui.button.ButtonVariant
|
|
8
|
+
import expo.modules.kotlin.records.Record
|
|
9
|
+
import expo.modules.kotlin.types.Enumerable
|
|
10
|
+
import expo.modules.ui.ValueChangeEvent
|
|
11
|
+
import expo.modules.ui.button.ButtonPressedEvent
|
|
12
|
+
import java.io.Serializable
|
|
13
|
+
|
|
14
|
+
enum class ActivationMethod(val value: String) : Enumerable {
|
|
15
|
+
SINGLE_PRESS("singlePress"),
|
|
16
|
+
LONG_PRESS("longPress")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
data class Submenu(
|
|
20
|
+
@Field val elements: Array<ContextMenuElement> = emptyArray(),
|
|
21
|
+
@Field val button: ContextMenuButtonProps
|
|
22
|
+
) : Record, Serializable
|
|
23
|
+
|
|
24
|
+
data class ContextMenuElement(
|
|
25
|
+
@Field var button: ContextMenuButtonProps? = null,
|
|
26
|
+
@Field var switch: ContextMenuSwitchProps? = null,
|
|
27
|
+
@Field var submenu: Submenu? = null,
|
|
28
|
+
@Field var contextMenuElementID: String
|
|
29
|
+
) : Record, Serializable
|
|
30
|
+
|
|
31
|
+
data class ContextMenuProps(
|
|
32
|
+
val text: MutableState<String> = mutableStateOf(""),
|
|
33
|
+
val elements: MutableState<Array<ContextMenuElement>> = mutableStateOf(emptyArray()),
|
|
34
|
+
val activationMethod: MutableState<ActivationMethod> = mutableStateOf(ActivationMethod.SINGLE_PRESS)
|
|
35
|
+
) : ComposeProps
|
|
36
|
+
|
|
37
|
+
class ContextMenuButtonProps(
|
|
38
|
+
@Field val text: String = "",
|
|
39
|
+
@Field val variant: ButtonVariant? = ButtonVariant.DEFAULT
|
|
40
|
+
) : Record, Serializable
|
|
41
|
+
|
|
42
|
+
class ContextMenuSwitchProps(
|
|
43
|
+
@Field val value: Boolean = false,
|
|
44
|
+
@Field val label: String = "",
|
|
45
|
+
@Field var variant: String = ""
|
|
46
|
+
) : Record, Serializable
|
|
47
|
+
|
|
48
|
+
open class ContextMenuButtonPressedEvent(
|
|
49
|
+
@Field val contextMenuElementID: String
|
|
50
|
+
) : ButtonPressedEvent()
|
|
51
|
+
|
|
52
|
+
class ContextMenuSwitchValueChangeEvent(
|
|
53
|
+
@Field override val value: Boolean = false,
|
|
54
|
+
@Field val contextMenuElementID: String
|
|
55
|
+
) : ValueChangeEvent()
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import { ViewEvent } from '../../src';
|
|
3
|
+
/**
|
|
4
|
+
* The role of the button.
|
|
5
|
+
* - `default` - The default button role.
|
|
6
|
+
* - `cancel` - A button that cancels the current operation.
|
|
7
|
+
* - `destructive` - A button that deletes data or performs a destructive action.
|
|
8
|
+
* @platform ios
|
|
9
|
+
*/
|
|
10
|
+
export type ButtonRole = 'default' | 'cancel' | 'destructive';
|
|
11
|
+
/**
|
|
12
|
+
* The built-in button styles available on iOS and Android.
|
|
13
|
+
* Common styles:
|
|
14
|
+
* - `default` - The default system button style.
|
|
15
|
+
* - `bordered` - A button with a light fill. On Android equivalent to `FilledTonalButton`.
|
|
16
|
+
* - `borderless` - A button with no background or border. On Android equivalent to `TextButton`.
|
|
17
|
+
* Apple-only styles:
|
|
18
|
+
* - `borderedProminent` - A bordered button with a prominent appearance.
|
|
19
|
+
* - `plain` - A button with no border or background and a less prominent text.
|
|
20
|
+
* MacOS-only styles:
|
|
21
|
+
* - `accessoryBar` - A button style for accessory bars.
|
|
22
|
+
* - `accessoryBarAction` - A button style for accessory bar actions.
|
|
23
|
+
* - `card` - A button style for cards.
|
|
24
|
+
* - `link` - A button style for links.
|
|
25
|
+
* Android-only styles:
|
|
26
|
+
* - `outlined` - A button with an outline.
|
|
27
|
+
* - `elevated` - A filled button with a shadow.
|
|
28
|
+
*
|
|
29
|
+
* @platform android
|
|
30
|
+
* @platform ios
|
|
31
|
+
*/
|
|
32
|
+
export type ButtonVariant = 'default' | 'bordered' | 'plain' | 'borderedProminent' | 'borderless' | 'accessoryBar' | 'accessoryBarAction' | 'card' | 'link' | 'outlined' | 'elevated';
|
|
33
|
+
export type ButtonProps = {
|
|
34
|
+
/**
|
|
35
|
+
* A callback that is called when the button is pressed.
|
|
36
|
+
*/
|
|
37
|
+
onPress?: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* A string describing the system image to display in the button.
|
|
40
|
+
* @platform ios
|
|
41
|
+
*/
|
|
42
|
+
systemImage?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Indicated the role of the button.
|
|
45
|
+
* @platform ios
|
|
46
|
+
*/
|
|
47
|
+
role?: ButtonRole;
|
|
48
|
+
/**
|
|
49
|
+
* The button variant.
|
|
50
|
+
*/
|
|
51
|
+
variant?: ButtonVariant;
|
|
52
|
+
/**
|
|
53
|
+
* Additional styles to apply to the button.
|
|
54
|
+
*/
|
|
55
|
+
style?: StyleProp<ViewStyle>;
|
|
56
|
+
/**
|
|
57
|
+
* The text to display inside the button.
|
|
58
|
+
*/
|
|
59
|
+
children: string;
|
|
60
|
+
/**
|
|
61
|
+
* Colors for button's core elements.
|
|
62
|
+
* @platform android
|
|
63
|
+
*/
|
|
64
|
+
elementColors?: {
|
|
65
|
+
containerColor?: string;
|
|
66
|
+
contentColor?: string;
|
|
67
|
+
disabledContainerColor?: string;
|
|
68
|
+
disabledContentColor?: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Button color.
|
|
72
|
+
*/
|
|
73
|
+
color?: string;
|
|
74
|
+
};
|
|
75
|
+
export type NativeButtonProps = Omit<ButtonProps, 'role' | 'onPress' | 'children'> & {
|
|
76
|
+
buttonRole?: ButtonRole;
|
|
77
|
+
text: string;
|
|
78
|
+
} & ViewEvent<'onButtonPressed', void>;
|
|
79
|
+
export declare function transformButtonProps(props: ButtonProps): NativeButtonProps;
|
|
80
|
+
export declare function Button(props: ButtonProps): import("react").JSX.Element;
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Button/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAc,SAAS,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,aAAa,GAErB,SAAS,GACT,UAAU,GACV,OAAO,GAEP,mBAAmB,GACnB,YAAY,GAEZ,cAAc,GACd,oBAAoB,GACpB,MAAM,GACN,MAAM,GAEN,UAAU,GACV,UAAU,CAAC;AAEf,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;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE;QACd,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAChC,oBAAoB,CAAC,EAAE,MAAM,CAAC;KAC/B,CAAC;IACF;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC,GAAG;IACnF,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,SAAS,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;AAQvC,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,iBAAiB,CAe1E;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,+BAQxC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { NativeSyntheticEvent, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { ButtonProps } from '../Button';
|
|
4
|
+
import { PickerProps } from '../Picker';
|
|
5
|
+
import { SwitchProps } from '../Switch';
|
|
6
|
+
type SubmenuElement = ReactElement<ButtonProps> | ReactElement<SwitchProps> | ReactElement<PickerProps> | ReactElement<SubmenuProps>;
|
|
7
|
+
type ContentChildren = SubmenuElement | SubmenuElement[];
|
|
8
|
+
export type ContextMenuContentProps = {
|
|
9
|
+
children: ContentChildren;
|
|
10
|
+
};
|
|
11
|
+
export type EventHandlers = {
|
|
12
|
+
[key: string]: {
|
|
13
|
+
[key: string]: (event: NativeSyntheticEvent<any>) => void;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type ContextMenuElementBase = {
|
|
17
|
+
contextMenuElementID: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Activation method of the context menu.
|
|
21
|
+
* - `singlePress`: The context menu is opened with a single tap. Does not isolate the content.
|
|
22
|
+
* - `longPress`: The context menu is opened with a long press. On iOS additionally Highlights the content by blurring the background.
|
|
23
|
+
*/
|
|
24
|
+
export type ActivationMethod = 'singlePress' | 'longPress';
|
|
25
|
+
/**
|
|
26
|
+
* Props of the `ContextMenu` component.
|
|
27
|
+
*/
|
|
28
|
+
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
|
+
/**
|
|
36
|
+
* Determines how the context menu will be activated.
|
|
37
|
+
*
|
|
38
|
+
* @platform ios
|
|
39
|
+
*/
|
|
40
|
+
activationMethod?: ActivationMethod;
|
|
41
|
+
/**
|
|
42
|
+
* The contents of the submenu are used as an anchor for the context menu.
|
|
43
|
+
* The children will be wrapped in a pressable element, which triggers opening of the context menu.
|
|
44
|
+
*/
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* Optional styles to apply to the `ContextMenu`
|
|
48
|
+
*/
|
|
49
|
+
style?: StyleProp<ViewStyle>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Props of the `Submenu` component.
|
|
53
|
+
*/
|
|
54
|
+
export type SubmenuProps = {
|
|
55
|
+
/**
|
|
56
|
+
* 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
|
+
*/
|
|
58
|
+
button: React.ReactElement<ButtonProps>;
|
|
59
|
+
/**
|
|
60
|
+
* Children of the submenu. Only `Button`, `Switch`, `Picker` and `Submenu` elements should be used.
|
|
61
|
+
*/
|
|
62
|
+
children: React.ReactNode;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The `Submenu` component is used to create a nested context menu. Submenus can be infinitely nested.
|
|
66
|
+
* 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
|
+
*/
|
|
68
|
+
export declare function Submenu(props: SubmenuProps): React.JSX.Element;
|
|
69
|
+
/**
|
|
70
|
+
* `ContextMenu` allows you to create a context menu, which can be used to provide additional options to the user.
|
|
71
|
+
*
|
|
72
|
+
* There are some platform-specific differences in the behavior of the context menu:
|
|
73
|
+
* - On Android the expansion of the context menu is controlled by the (`expanded`)[#expanded] prop, iOS does not allow for manual control of the expansion state.
|
|
74
|
+
* - On iOS the context menu can be triggered by a single press or a long press. The `activationMethod` prop allows you to choose between these two options.
|
|
75
|
+
* - 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
|
+
* - Android does not support showing a `Picker` element in the context menu.
|
|
77
|
+
*/
|
|
78
|
+
export declare function ContextMenu(props: ContextMenuProps): React.JSX.Element;
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/ContextMenu/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,KAAK,cAAc,GACf,YAAY,CAAC,WAAW,CAAC,GACzB,YAAY,CAAC,WAAW,CAAC,GACzB,YAAY,CAAC,WAAW,CAAC,GACzB,YAAY,CAAC,YAAY,CAAC,CAAC;AAE/B,KAAK,eAAe,GAAG,cAAc,GAAG,cAAc,EAAE,CAAC;AAEzD,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;KAC3D,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IAAE,oBAAoB,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,WAAW,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;OAIG;IACH,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,uBAAuB,CAAC,CAAC;IAEnD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACxC;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AA2BF;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,qBAE1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,qBAwBlD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ContextMenuElementBase, EventHandlers } from './index';
|
|
3
|
+
import { NativeButtonProps } from '../Button';
|
|
4
|
+
import { PickerProps } from '../Picker';
|
|
5
|
+
import { SwitchProps } from '../Switch';
|
|
6
|
+
type ButtonMenuElement = {
|
|
7
|
+
button: NativeButtonProps;
|
|
8
|
+
} & ContextMenuElementBase;
|
|
9
|
+
type SwitchMenuElement = {
|
|
10
|
+
switch: SwitchProps;
|
|
11
|
+
} & ContextMenuElementBase;
|
|
12
|
+
type PickerMenuElement = {
|
|
13
|
+
picker: PickerProps;
|
|
14
|
+
} & ContextMenuElementBase;
|
|
15
|
+
type SubmenuElement = {
|
|
16
|
+
submenu: {
|
|
17
|
+
elements: MenuElement[];
|
|
18
|
+
button: NativeButtonProps;
|
|
19
|
+
};
|
|
20
|
+
} & ContextMenuElementBase;
|
|
21
|
+
export type MenuElement = ButtonMenuElement | SwitchMenuElement | PickerMenuElement | SubmenuElement;
|
|
22
|
+
export declare function transformChildrenToElementArray(children: ReactNode, eventHandlersMap: EventHandlers): MenuElement[];
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../components/ContextMenu/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,SAAS,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,65 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the Picker component.
|
|
4
|
+
*/
|
|
5
|
+
export type PickerProps = {
|
|
6
|
+
/**
|
|
7
|
+
* An array of options to be displayed in the picker.
|
|
8
|
+
*/
|
|
9
|
+
options: string[];
|
|
10
|
+
/**
|
|
11
|
+
* The index of the currently selected option.
|
|
12
|
+
*/
|
|
13
|
+
selectedIndex: number | null;
|
|
14
|
+
/**
|
|
15
|
+
* A label displayed on the picker when in `menu` variant inside a form section on iOS.
|
|
16
|
+
* @platform iOS
|
|
17
|
+
*/
|
|
18
|
+
label?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Callback function that is called when an option is selected.
|
|
21
|
+
*/
|
|
22
|
+
onOptionSelected?: (event: {
|
|
23
|
+
nativeEvent: {
|
|
24
|
+
index: number;
|
|
25
|
+
label: string;
|
|
26
|
+
};
|
|
27
|
+
}) => void;
|
|
28
|
+
/**
|
|
29
|
+
* The variant of the picker, which determines its appearance and behavior.
|
|
30
|
+
* The 'wheel' and 'menu' variants are iOS only.
|
|
31
|
+
* @default 'segmented'
|
|
32
|
+
*/
|
|
33
|
+
variant?: 'wheel' | 'segmented' | 'menu';
|
|
34
|
+
/**
|
|
35
|
+
* Optional style to apply to the picker component.
|
|
36
|
+
*/
|
|
37
|
+
style?: StyleProp<ViewStyle>;
|
|
38
|
+
/**
|
|
39
|
+
* Colors for picker's core elements.
|
|
40
|
+
* @platform android
|
|
41
|
+
*/
|
|
42
|
+
elementColors?: {
|
|
43
|
+
activeBorderColor?: string;
|
|
44
|
+
activeContentColor?: string;
|
|
45
|
+
inactiveBorderColor?: string;
|
|
46
|
+
inactiveContentColor?: string;
|
|
47
|
+
disabledActiveBorderColor?: string;
|
|
48
|
+
disabledActiveContentColor?: string;
|
|
49
|
+
disabledInactiveBorderColor?: string;
|
|
50
|
+
disabledInactiveContentColor?: string;
|
|
51
|
+
activeContainerColor?: string;
|
|
52
|
+
inactiveContainerColor?: string;
|
|
53
|
+
disabledActiveContainerColor?: string;
|
|
54
|
+
disabledInactiveContainerColor?: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Picker color. On iOS it only applies to the `menu` variant.
|
|
58
|
+
*/
|
|
59
|
+
color?: string;
|
|
60
|
+
};
|
|
61
|
+
type NativePickerProps = PickerProps;
|
|
62
|
+
export declare function transformPickerProps(props: PickerProps): NativePickerProps;
|
|
63
|
+
export declare function Picker(props: PickerProps): import("react").JSX.Element;
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Picker/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD;;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,CAAC;IACzC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE;QACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,yBAAyB,CAAC,EAAE,MAAM,CAAC;QACnC,0BAA0B,CAAC,EAAE,MAAM,CAAC;QACpC,2BAA2B,CAAC,EAAE,MAAM,CAAC;QACrC,4BAA4B,CAAC,EAAE,MAAM,CAAC;QACtC,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAChC,4BAA4B,CAAC,EAAE,MAAM,CAAC;QACtC,8BAA8B,CAAC,EAAE,MAAM,CAAC;KACzC,CAAC;IACF;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAOF,KAAK,iBAAiB,GAAG,WAAW,CAAC;AAErC,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,iBAAiB,CAa1E;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,+BAExC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export type SectionProps = {
|
|
4
|
+
style?: StyleProp<ViewStyle>;
|
|
5
|
+
title: string;
|
|
6
|
+
children: any;
|
|
7
|
+
};
|
|
8
|
+
export declare function Section({ title, children }: {
|
|
9
|
+
title: string;
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}): React.JSX.Element;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Section/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAA0B,SAAS,EAAE,MAAM,cAAc,CAAC;AAE5E,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,GAAG,CAAC;CACf,CAAC;AAkBF,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,qBA8BxF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
export type SectionProps = {
|
|
3
|
+
title: string;
|
|
4
|
+
style?: StyleProp<ViewStyle>;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare function Section(props: SectionProps): import("react").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=index.ios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.ios.d.ts","sourceRoot":"","sources":["../../../components/Section/index.ios.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAWF,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,+BAsC1C"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import { ViewEvent } from '../../src';
|
|
3
|
+
export type SliderProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Custom styles for the slider component.
|
|
6
|
+
*/
|
|
7
|
+
style?: StyleProp<ViewStyle>;
|
|
8
|
+
/**
|
|
9
|
+
* The current value of the slider.
|
|
10
|
+
* @default 0
|
|
11
|
+
*/
|
|
12
|
+
value?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The number of steps between the minimum and maximum values. 0 signifies infinite steps.
|
|
15
|
+
* @default 0
|
|
16
|
+
*/
|
|
17
|
+
steps?: number;
|
|
18
|
+
/**
|
|
19
|
+
* The mininum value of the slider. Updating this value does not trigger callbacks if the current value is below `min`.
|
|
20
|
+
* @default 0
|
|
21
|
+
*/
|
|
22
|
+
min?: number;
|
|
23
|
+
/**
|
|
24
|
+
* The maximum value of the slider. Updating this value does not trigger callbacks if the current value is above `max`.
|
|
25
|
+
* @default 1
|
|
26
|
+
*/
|
|
27
|
+
max?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Colors for slider's core elements.
|
|
30
|
+
* @platform android
|
|
31
|
+
*/
|
|
32
|
+
elementColors?: {
|
|
33
|
+
thumbColor?: string;
|
|
34
|
+
activeTrackColor?: string;
|
|
35
|
+
inactiveTrackColor?: string;
|
|
36
|
+
activeTickColor?: string;
|
|
37
|
+
inactiveTickColor?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Slider color.
|
|
41
|
+
*/
|
|
42
|
+
color?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Callback triggered on dragging along the slider.
|
|
45
|
+
*/
|
|
46
|
+
onValueChange?: (value: number) => void;
|
|
47
|
+
};
|
|
48
|
+
type NativeSliderProps = Omit<SliderProps, 'onValueChange'> & ViewEvent<'onValueChanged', {
|
|
49
|
+
value: number;
|
|
50
|
+
}>;
|
|
51
|
+
export declare function transformSliderProps(props: SliderProps): NativeSliderProps;
|
|
52
|
+
export declare function Slider(props: SliderProps): import("react").JSX.Element;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Slider/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,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;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF;;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,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,iBAAiB,CAqB1E;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,+BAExC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { NativeSyntheticEvent, StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
type SwitchElementColors = {
|
|
3
|
+
/**
|
|
4
|
+
* Only for switch.
|
|
5
|
+
*/
|
|
6
|
+
checkedThumbColor?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Only for switch.
|
|
9
|
+
*/
|
|
10
|
+
checkedTrackColor?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Only for switch.
|
|
13
|
+
*/
|
|
14
|
+
uncheckedThumbColor?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Only for switch.
|
|
17
|
+
*/
|
|
18
|
+
uncheckedTrackColor?: string;
|
|
19
|
+
};
|
|
20
|
+
type CheckboxElementColors = {
|
|
21
|
+
/**
|
|
22
|
+
* Only for checkbox.
|
|
23
|
+
*/
|
|
24
|
+
checkedColor?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Only for checkbox.
|
|
27
|
+
*/
|
|
28
|
+
disabledCheckedColor?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Only for checkbox.
|
|
31
|
+
*/
|
|
32
|
+
uncheckedColor?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Only for checkbox.
|
|
35
|
+
*/
|
|
36
|
+
disabledUncheckedColor?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Only for checkbox.
|
|
39
|
+
*/
|
|
40
|
+
checkmarkColor?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Only for checkbox.
|
|
43
|
+
*/
|
|
44
|
+
disabledIndeterminateColor?: string;
|
|
45
|
+
};
|
|
46
|
+
export type SwitchProps = {
|
|
47
|
+
/**
|
|
48
|
+
* Indicates whether the switch is checked.
|
|
49
|
+
*/
|
|
50
|
+
value: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Label for the switch.
|
|
53
|
+
*
|
|
54
|
+
* > On Android the label has an effect only when the `Switch` is used inside a `ContextMenu`.
|
|
55
|
+
* @platform ios
|
|
56
|
+
*/
|
|
57
|
+
label?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Type of the switch component. Can be 'checkbox', 'switch', or 'button'. The 'button' style is iOS only.
|
|
60
|
+
* @default 'switch'
|
|
61
|
+
*/
|
|
62
|
+
variant?: 'checkbox' | 'switch' | 'button';
|
|
63
|
+
/**
|
|
64
|
+
* Callback function that is called when the checked state changes.
|
|
65
|
+
*/
|
|
66
|
+
onValueChange?: (value: boolean) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Optional style for the switch component.
|
|
69
|
+
*/
|
|
70
|
+
style?: StyleProp<ViewStyle>;
|
|
71
|
+
/**
|
|
72
|
+
* Picker color. On iOS it only applies to the `menu` variant.
|
|
73
|
+
*/
|
|
74
|
+
color?: string;
|
|
75
|
+
} & ({
|
|
76
|
+
variant?: 'switch';
|
|
77
|
+
/**
|
|
78
|
+
* Colors for switch's core elements.
|
|
79
|
+
* @platform android
|
|
80
|
+
*/
|
|
81
|
+
elementColors?: SwitchElementColors;
|
|
82
|
+
} | {
|
|
83
|
+
variant: 'checkbox';
|
|
84
|
+
/**
|
|
85
|
+
* Colors for checkbox core elements.
|
|
86
|
+
* @platform android
|
|
87
|
+
*/
|
|
88
|
+
elementColors?: CheckboxElementColors;
|
|
89
|
+
} | {
|
|
90
|
+
variant: 'button';
|
|
91
|
+
elementColors?: undefined;
|
|
92
|
+
});
|
|
93
|
+
type NativeSwitchProps = Omit<SwitchProps, 'onValueChange'> & {
|
|
94
|
+
onValueChange: (event: NativeSyntheticEvent<{
|
|
95
|
+
value: boolean;
|
|
96
|
+
}>) => void;
|
|
97
|
+
};
|
|
98
|
+
export declare function transformSwitchProps(props: SwitchProps): NativeSwitchProps;
|
|
99
|
+
export declare function Switch(props: SwitchProps): import("react").JSX.Element;
|
|
100
|
+
export {};
|
|
101
|
+
//# sourceMappingURL=index.d.ts.map
|