react-native-keyboard-controller 1.16.7 → 1.16.8
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/lib/commonjs/components/KeyboardToolbar/index.js +18 -8
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/module.js +1 -1
- package/lib/commonjs/module.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/index.js +18 -8
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/module.js +1 -1
- package/lib/module/module.js.map +1 -1
- package/lib/typescript/components/KeyboardToolbar/index.d.ts +5 -0
- package/package.json +1 -1
- package/src/components/KeyboardToolbar/index.tsx +36 -19
- package/src/module.ts +1 -1
|
@@ -38,7 +38,7 @@ const DEFAULT_OPACITY = "FF";
|
|
|
38
38
|
const KeyboardToolbar = ({
|
|
39
39
|
content,
|
|
40
40
|
theme = _colors.colors,
|
|
41
|
-
doneText,
|
|
41
|
+
doneText = "Done",
|
|
42
42
|
button,
|
|
43
43
|
icon,
|
|
44
44
|
showArrows = true,
|
|
@@ -52,6 +52,7 @@ const KeyboardToolbar = ({
|
|
|
52
52
|
opened = 0
|
|
53
53
|
} = {},
|
|
54
54
|
enabled = true,
|
|
55
|
+
insets,
|
|
55
56
|
...rest
|
|
56
57
|
}) => {
|
|
57
58
|
const colorScheme = (0, _useColorScheme.default)();
|
|
@@ -72,7 +73,10 @@ const KeyboardToolbar = ({
|
|
|
72
73
|
}], [colorScheme, theme]);
|
|
73
74
|
const toolbarStyle = (0, _react.useMemo)(() => [styles.toolbar, {
|
|
74
75
|
backgroundColor: `${theme[colorScheme].background}${opacity}`
|
|
75
|
-
}
|
|
76
|
+
}, {
|
|
77
|
+
paddingLeft: insets === null || insets === void 0 ? void 0 : insets.left,
|
|
78
|
+
paddingRight: insets === null || insets === void 0 ? void 0 : insets.right
|
|
79
|
+
}], [colorScheme, opacity, theme, insets]);
|
|
76
80
|
const offset = (0, _react.useMemo)(() => ({
|
|
77
81
|
closed: closed + KEYBOARD_TOOLBAR_HEIGHT,
|
|
78
82
|
opened
|
|
@@ -103,7 +107,9 @@ const KeyboardToolbar = ({
|
|
|
103
107
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({}, rest, {
|
|
104
108
|
style: toolbarStyle,
|
|
105
109
|
testID: TEST_ID_KEYBOARD_TOOLBAR
|
|
106
|
-
}), blur, showArrows && /*#__PURE__*/_react.default.createElement(
|
|
110
|
+
}), blur, showArrows && /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
111
|
+
style: styles.arrows
|
|
112
|
+
}, /*#__PURE__*/_react.default.createElement(ButtonContainer, {
|
|
107
113
|
accessibilityHint: "Moves focus to the previous field",
|
|
108
114
|
accessibilityLabel: "Previous",
|
|
109
115
|
disabled: isPrevDisabled,
|
|
@@ -128,7 +134,7 @@ const KeyboardToolbar = ({
|
|
|
128
134
|
}))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
129
135
|
style: styles.flex,
|
|
130
136
|
testID: TEST_ID_KEYBOARD_TOOLBAR_CONTENT
|
|
131
|
-
}, content), /*#__PURE__*/_react.default.createElement(ButtonContainer, {
|
|
137
|
+
}, content), doneText && /*#__PURE__*/_react.default.createElement(ButtonContainer, {
|
|
132
138
|
accessibilityHint: "Closes the keyboard",
|
|
133
139
|
accessibilityLabel: "Done",
|
|
134
140
|
rippleRadius: 28,
|
|
@@ -139,7 +145,7 @@ const KeyboardToolbar = ({
|
|
|
139
145
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
140
146
|
maxFontSizeMultiplier: 1.3,
|
|
141
147
|
style: doneStyle
|
|
142
|
-
}, doneText
|
|
148
|
+
}, doneText))));
|
|
143
149
|
};
|
|
144
150
|
const styles = _reactNative.StyleSheet.create({
|
|
145
151
|
flex: {
|
|
@@ -151,15 +157,19 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
151
157
|
alignItems: "center",
|
|
152
158
|
width: "100%",
|
|
153
159
|
flexDirection: "row",
|
|
154
|
-
height: KEYBOARD_TOOLBAR_HEIGHT
|
|
155
|
-
|
|
160
|
+
height: KEYBOARD_TOOLBAR_HEIGHT
|
|
161
|
+
},
|
|
162
|
+
arrows: {
|
|
163
|
+
flexDirection: "row",
|
|
164
|
+
paddingLeft: 8
|
|
156
165
|
},
|
|
157
166
|
doneButton: {
|
|
158
167
|
fontWeight: "600",
|
|
159
168
|
fontSize: 15
|
|
160
169
|
},
|
|
161
170
|
doneButtonContainer: {
|
|
162
|
-
marginRight:
|
|
171
|
+
marginRight: 16,
|
|
172
|
+
marginLeft: 8
|
|
163
173
|
}
|
|
164
174
|
});
|
|
165
175
|
var _default = exports.default = KeyboardToolbar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_bindings","_module","_useColorScheme","_interopRequireDefault","_KeyboardStickyView","_Arrow","_Button","_colors","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","DEFAULT_OPACITY","KeyboardToolbar","content","theme","colors","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","offset","closed","opened","enabled","rest","colorScheme","useColorScheme","inputs","setInputs","useState","current","count","isPrevDisabled","isNextDisabled","useEffect","subscription","FocusedInputEvents","addListener","remove","doneStyle","useMemo","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","ButtonContainer","Button","IconContainer","Arrow","onPressNext","useCallback","event","isDefaultPrevented","KeyboardController","setFocusTo","onPressPrev","onPressDone","dismiss","createElement","View","style","testID","Fragment","accessibilityHint","accessibilityLabel","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","Text","maxFontSizeMultiplier","StyleSheet","create","position","bottom","alignItems","width","flexDirection","height","paddingHorizontal","fontWeight","fontSize","marginRight","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport { FocusedInputEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\nimport useColorScheme from \"../hooks/useColorScheme\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\n\nimport type { HEX, KeyboardToolbarTheme } from \"./types\";\nimport type { KeyboardStickyViewProps } from \"../KeyboardStickyView\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent, ViewProps } from \"react-native\";\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n /** An element that is shown in the middle of the toolbar. */\n content?: React.JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /** Custom text for done button. */\n doneText?: ReactNode;\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\n button?: typeof Button;\n /** Custom icon component used to display next/prev buttons. */\n icon?: typeof Arrow;\n /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: (event: GestureResponderEvent) => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: React.JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\n} & Pick<KeyboardStickyViewProps, \"offset\" | \"enabled\">;\n\nconst TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\nconst TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\nconst TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\nconst TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\nconst TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\n\nconst KEYBOARD_TOOLBAR_HEIGHT = 42;\nconst DEFAULT_OPACITY: HEX = \"FF\";\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and\n * `Done` buttons.\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({\n content,\n theme = colors,\n doneText,\n button,\n icon,\n showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\n offset: { closed = 0, opened = 0 } = {},\n enabled = true,\n ...rest\n}) => {\n const colorScheme = useColorScheme();\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n ],\n [colorScheme, opacity, theme],\n );\n const offset = useMemo(\n () => ({ closed: closed + KEYBOARD_TOOLBAR_HEIGHT, opened }),\n [closed, opened],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onNextCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"next\");\n }\n },\n [onNextCallback],\n );\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPrevCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"prev\");\n }\n },\n [onPrevCallback],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onDoneCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.dismiss();\n }\n },\n [onDoneCallback],\n );\n\n return (\n <KeyboardStickyView enabled={enabled} offset={offset}>\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isPrevDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n <IconContainer\n disabled={isPrevDisabled}\n theme={theme}\n type=\"prev\"\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isNextDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n <IconContainer\n disabled={isNextDisabled}\n theme={theme}\n type=\"next\"\n />\n </ButtonContainer>\n </>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={28}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\n {doneText || \"Done\"}\n </Text>\n </ButtonContainer>\n </View>\n </KeyboardStickyView>\n );\n};\n\nconst styles = StyleSheet.create({\n flex: {\n flex: 1,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n paddingHorizontal: 8,\n },\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 8,\n },\n});\n\nexport { colors as DefaultKeyboardToolbarTheme };\nexport default KeyboardToolbar;\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAD,sBAAA,CAAAL,OAAA;AAEA,IAAAO,MAAA,GAAAF,sBAAA,CAAAL,OAAA;AACA,IAAAQ,OAAA,GAAAH,sBAAA,CAAAL,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AAAkC,SAAAK,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,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OAAA,GAGY+B,eAAe","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_bindings","_module","_useColorScheme","_interopRequireDefault","_KeyboardStickyView","_Arrow","_Button","_colors","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","DEFAULT_OPACITY","KeyboardToolbar","content","theme","colors","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","offset","closed","opened","enabled","insets","rest","colorScheme","useColorScheme","inputs","setInputs","useState","current","count","isPrevDisabled","isNextDisabled","useEffect","subscription","FocusedInputEvents","addListener","remove","doneStyle","useMemo","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","paddingLeft","left","paddingRight","right","ButtonContainer","Button","IconContainer","Arrow","onPressNext","useCallback","event","isDefaultPrevented","KeyboardController","setFocusTo","onPressPrev","onPressDone","dismiss","createElement","View","style","testID","arrows","accessibilityHint","accessibilityLabel","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","Text","maxFontSizeMultiplier","StyleSheet","create","position","bottom","alignItems","width","flexDirection","height","fontWeight","fontSize","marginRight","marginLeft","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport { FocusedInputEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\nimport useColorScheme from \"../hooks/useColorScheme\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\n\nimport type { HEX, KeyboardToolbarTheme } from \"./types\";\nimport type { KeyboardStickyViewProps } from \"../KeyboardStickyView\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent, ViewProps } from \"react-native\";\n\ntype SafeAreaInsets = {\n left: number;\n right: number;\n};\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n /** An element that is shown in the middle of the toolbar. */\n content?: React.JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /** Custom text for done button. */\n doneText?: ReactNode;\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\n button?: typeof Button;\n /** Custom icon component used to display next/prev buttons. */\n icon?: typeof Arrow;\n /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: (event: GestureResponderEvent) => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: React.JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\n insets?: SafeAreaInsets;\n} & Pick<KeyboardStickyViewProps, \"offset\" | \"enabled\">;\n\nconst TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\nconst TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\nconst TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\nconst TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\nconst TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\n\nconst KEYBOARD_TOOLBAR_HEIGHT = 42;\nconst DEFAULT_OPACITY: HEX = \"FF\";\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and\n * `Done` buttons.\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({\n content,\n theme = colors,\n doneText = \"Done\",\n button,\n icon,\n showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\n offset: { closed = 0, opened = 0 } = {},\n enabled = true,\n insets,\n ...rest\n}) => {\n const colorScheme = useColorScheme();\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n {\n paddingLeft: insets?.left,\n paddingRight: insets?.right,\n },\n ],\n [colorScheme, opacity, theme, insets],\n );\n const offset = useMemo(\n () => ({ closed: closed + KEYBOARD_TOOLBAR_HEIGHT, opened }),\n [closed, opened],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onNextCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"next\");\n }\n },\n [onNextCallback],\n );\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPrevCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"prev\");\n }\n },\n [onPrevCallback],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onDoneCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.dismiss();\n }\n },\n [onDoneCallback],\n );\n\n return (\n <KeyboardStickyView enabled={enabled} offset={offset}>\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <View style={styles.arrows}>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isPrevDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n <IconContainer\n disabled={isPrevDisabled}\n theme={theme}\n type=\"prev\"\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isNextDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n <IconContainer\n disabled={isNextDisabled}\n theme={theme}\n type=\"next\"\n />\n </ButtonContainer>\n </View>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n {doneText && (\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={28}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\n {doneText}\n </Text>\n </ButtonContainer>\n )}\n </View>\n </KeyboardStickyView>\n );\n};\n\nconst styles = StyleSheet.create({\n flex: {\n flex: 1,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n },\n arrows: {\n flexDirection: \"row\",\n paddingLeft: 8,\n },\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 16,\n marginLeft: 8,\n },\n});\n\nexport { colors as DefaultKeyboardToolbarTheme };\nexport default KeyboardToolbar;\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAD,sBAAA,CAAAL,OAAA;AAEA,IAAAO,MAAA,GAAAF,sBAAA,CAAAL,OAAA;AACA,IAAAQ,OAAA,GAAAH,sBAAA,CAAAL,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AAAkC,SAAAK,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAA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,GAAAC,OAAA,CAAAvH,OAAA,GAGY+B,eAAe","ignoreList":[]}
|
package/lib/commonjs/module.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.KeyboardController = void 0;
|
|
7
7
|
var _bindings = require("./bindings");
|
|
8
|
-
let isClosed =
|
|
8
|
+
let isClosed = true;
|
|
9
9
|
let lastEvent = null;
|
|
10
10
|
_bindings.KeyboardEvents.addListener("keyboardDidHide", e => {
|
|
11
11
|
isClosed = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_bindings","require","isClosed","lastEvent","KeyboardEvents","addListener","e","dismiss","options","keepFocus","Promise","resolve","subscription","undefined","remove","KeyboardControllerNative","isVisible","state","KeyboardController","exports","setDefaultMode","setInputMode","setFocusTo"],"sources":["module.ts"],"sourcesContent":["import { KeyboardControllerNative, KeyboardEvents } from \"./bindings\";\n\nimport type {\n DismissOptions,\n KeyboardControllerModule,\n KeyboardEventData,\n} from \"./types\";\n\nlet isClosed =
|
|
1
|
+
{"version":3,"names":["_bindings","require","isClosed","lastEvent","KeyboardEvents","addListener","e","dismiss","options","keepFocus","Promise","resolve","subscription","undefined","remove","KeyboardControllerNative","isVisible","state","KeyboardController","exports","setDefaultMode","setInputMode","setFocusTo"],"sources":["module.ts"],"sourcesContent":["import { KeyboardControllerNative, KeyboardEvents } from \"./bindings\";\n\nimport type {\n DismissOptions,\n KeyboardControllerModule,\n KeyboardEventData,\n} from \"./types\";\n\nlet isClosed = true;\nlet lastEvent: KeyboardEventData | null = null;\n\nKeyboardEvents.addListener(\"keyboardDidHide\", (e) => {\n isClosed = true;\n lastEvent = e;\n});\n\nKeyboardEvents.addListener(\"keyboardDidShow\", (e) => {\n isClosed = false;\n lastEvent = e;\n});\n\nconst dismiss = async (options?: DismissOptions): Promise<void> => {\n const keepFocus = options?.keepFocus ?? false;\n\n return new Promise((resolve) => {\n if (isClosed) {\n resolve();\n\n return;\n }\n\n const subscription = KeyboardEvents.addListener(\"keyboardDidHide\", () => {\n resolve(undefined);\n subscription.remove();\n });\n\n KeyboardControllerNative.dismiss(keepFocus);\n });\n};\nconst isVisible = () => !isClosed;\nconst state = () => lastEvent;\n\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: KeyboardControllerNative.setDefaultMode,\n setInputMode: KeyboardControllerNative.setInputMode,\n setFocusTo: KeyboardControllerNative.setFocusTo,\n dismiss,\n isVisible,\n state,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAQA,IAAIC,QAAQ,GAAG,IAAI;AACnB,IAAIC,SAAmC,GAAG,IAAI;AAE9CC,wBAAc,CAACC,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDJ,QAAQ,GAAG,IAAI;EACfC,SAAS,GAAGG,CAAC;AACf,CAAC,CAAC;AAEFF,wBAAc,CAACC,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDJ,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAGG,CAAC;AACf,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,MAAOC,OAAwB,IAAoB;EACjE,MAAMC,SAAS,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,SAAS,KAAI,KAAK;EAE7C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,IAAIT,QAAQ,EAAE;MACZS,OAAO,CAAC,CAAC;MAET;IACF;IAEA,MAAMC,YAAY,GAAGR,wBAAc,CAACC,WAAW,CAAC,iBAAiB,EAAE,MAAM;MACvEM,OAAO,CAACE,SAAS,CAAC;MAClBD,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFC,kCAAwB,CAACR,OAAO,CAACE,SAAS,CAAC;EAC7C,CAAC,CAAC;AACJ,CAAC;AACD,MAAMO,SAAS,GAAGA,CAAA,KAAM,CAACd,QAAQ;AACjC,MAAMe,KAAK,GAAGA,CAAA,KAAMd,SAAS;AAEtB,MAAMe,kBAA4C,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAC1DE,cAAc,EAAEL,kCAAwB,CAACK,cAAc;EACvDC,YAAY,EAAEN,kCAAwB,CAACM,YAAY;EACnDC,UAAU,EAAEP,kCAAwB,CAACO,UAAU;EAC/Cf,OAAO;EACPS,SAAS;EACTC;AACF,CAAC","ignoreList":[]}
|
|
@@ -23,7 +23,7 @@ const DEFAULT_OPACITY = "FF";
|
|
|
23
23
|
const KeyboardToolbar = ({
|
|
24
24
|
content,
|
|
25
25
|
theme = colors,
|
|
26
|
-
doneText,
|
|
26
|
+
doneText = "Done",
|
|
27
27
|
button,
|
|
28
28
|
icon,
|
|
29
29
|
showArrows = true,
|
|
@@ -37,6 +37,7 @@ const KeyboardToolbar = ({
|
|
|
37
37
|
opened = 0
|
|
38
38
|
} = {},
|
|
39
39
|
enabled = true,
|
|
40
|
+
insets,
|
|
40
41
|
...rest
|
|
41
42
|
}) => {
|
|
42
43
|
const colorScheme = useColorScheme();
|
|
@@ -57,7 +58,10 @@ const KeyboardToolbar = ({
|
|
|
57
58
|
}], [colorScheme, theme]);
|
|
58
59
|
const toolbarStyle = useMemo(() => [styles.toolbar, {
|
|
59
60
|
backgroundColor: `${theme[colorScheme].background}${opacity}`
|
|
60
|
-
}
|
|
61
|
+
}, {
|
|
62
|
+
paddingLeft: insets === null || insets === void 0 ? void 0 : insets.left,
|
|
63
|
+
paddingRight: insets === null || insets === void 0 ? void 0 : insets.right
|
|
64
|
+
}], [colorScheme, opacity, theme, insets]);
|
|
61
65
|
const offset = useMemo(() => ({
|
|
62
66
|
closed: closed + KEYBOARD_TOOLBAR_HEIGHT,
|
|
63
67
|
opened
|
|
@@ -88,7 +92,9 @@ const KeyboardToolbar = ({
|
|
|
88
92
|
}, /*#__PURE__*/React.createElement(View, _extends({}, rest, {
|
|
89
93
|
style: toolbarStyle,
|
|
90
94
|
testID: TEST_ID_KEYBOARD_TOOLBAR
|
|
91
|
-
}), blur, showArrows && /*#__PURE__*/React.createElement(
|
|
95
|
+
}), blur, showArrows && /*#__PURE__*/React.createElement(View, {
|
|
96
|
+
style: styles.arrows
|
|
97
|
+
}, /*#__PURE__*/React.createElement(ButtonContainer, {
|
|
92
98
|
accessibilityHint: "Moves focus to the previous field",
|
|
93
99
|
accessibilityLabel: "Previous",
|
|
94
100
|
disabled: isPrevDisabled,
|
|
@@ -113,7 +119,7 @@ const KeyboardToolbar = ({
|
|
|
113
119
|
}))), /*#__PURE__*/React.createElement(View, {
|
|
114
120
|
style: styles.flex,
|
|
115
121
|
testID: TEST_ID_KEYBOARD_TOOLBAR_CONTENT
|
|
116
|
-
}, content), /*#__PURE__*/React.createElement(ButtonContainer, {
|
|
122
|
+
}, content), doneText && /*#__PURE__*/React.createElement(ButtonContainer, {
|
|
117
123
|
accessibilityHint: "Closes the keyboard",
|
|
118
124
|
accessibilityLabel: "Done",
|
|
119
125
|
rippleRadius: 28,
|
|
@@ -124,7 +130,7 @@ const KeyboardToolbar = ({
|
|
|
124
130
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
125
131
|
maxFontSizeMultiplier: 1.3,
|
|
126
132
|
style: doneStyle
|
|
127
|
-
}, doneText
|
|
133
|
+
}, doneText))));
|
|
128
134
|
};
|
|
129
135
|
const styles = StyleSheet.create({
|
|
130
136
|
flex: {
|
|
@@ -136,15 +142,19 @@ const styles = StyleSheet.create({
|
|
|
136
142
|
alignItems: "center",
|
|
137
143
|
width: "100%",
|
|
138
144
|
flexDirection: "row",
|
|
139
|
-
height: KEYBOARD_TOOLBAR_HEIGHT
|
|
140
|
-
|
|
145
|
+
height: KEYBOARD_TOOLBAR_HEIGHT
|
|
146
|
+
},
|
|
147
|
+
arrows: {
|
|
148
|
+
flexDirection: "row",
|
|
149
|
+
paddingLeft: 8
|
|
141
150
|
},
|
|
142
151
|
doneButton: {
|
|
143
152
|
fontWeight: "600",
|
|
144
153
|
fontSize: 15
|
|
145
154
|
},
|
|
146
155
|
doneButtonContainer: {
|
|
147
|
-
marginRight:
|
|
156
|
+
marginRight: 16,
|
|
157
|
+
marginLeft: 8
|
|
148
158
|
}
|
|
149
159
|
});
|
|
150
160
|
export { colors as DefaultKeyboardToolbarTheme };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","useMemo","useState","StyleSheet","Text","View","FocusedInputEvents","KeyboardController","useColorScheme","KeyboardStickyView","Arrow","Button","colors","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","DEFAULT_OPACITY","KeyboardToolbar","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","offset","closed","opened","enabled","rest","colorScheme","inputs","setInputs","current","count","isPrevDisabled","isNextDisabled","subscription","addListener","e","remove","doneStyle","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","ButtonContainer","IconContainer","onPressNext","event","isDefaultPrevented","setFocusTo","onPressPrev","onPressDone","dismiss","createElement","_extends","style","testID","Fragment","accessibilityHint","accessibilityLabel","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","maxFontSizeMultiplier","create","position","bottom","alignItems","width","flexDirection","height","paddingHorizontal","fontWeight","fontSize","marginRight","DefaultKeyboardToolbarTheme"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport { FocusedInputEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\nimport useColorScheme from \"../hooks/useColorScheme\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\n\nimport type { HEX, KeyboardToolbarTheme } from \"./types\";\nimport type { KeyboardStickyViewProps } from \"../KeyboardStickyView\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent, ViewProps } from \"react-native\";\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n /** An element that is shown in the middle of the toolbar. */\n content?: React.JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /** Custom text for done button. */\n doneText?: ReactNode;\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\n button?: typeof Button;\n /** Custom icon component used to display next/prev buttons. */\n icon?: typeof Arrow;\n /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: (event: GestureResponderEvent) => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: React.JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\n} & Pick<KeyboardStickyViewProps, \"offset\" | \"enabled\">;\n\nconst TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\nconst TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\nconst TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\nconst TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\nconst TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\n\nconst KEYBOARD_TOOLBAR_HEIGHT = 42;\nconst DEFAULT_OPACITY: HEX = \"FF\";\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and\n * `Done` buttons.\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({\n content,\n theme = colors,\n doneText,\n button,\n icon,\n showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\n offset: { closed = 0, opened = 0 } = {},\n enabled = true,\n ...rest\n}) => {\n const colorScheme = useColorScheme();\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n ],\n [colorScheme, opacity, theme],\n );\n const offset = useMemo(\n () => ({ closed: closed + KEYBOARD_TOOLBAR_HEIGHT, opened }),\n [closed, opened],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onNextCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"next\");\n }\n },\n [onNextCallback],\n );\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPrevCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"prev\");\n }\n },\n [onPrevCallback],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onDoneCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.dismiss();\n }\n },\n [onDoneCallback],\n );\n\n return (\n <KeyboardStickyView enabled={enabled} offset={offset}>\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isPrevDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n <IconContainer\n disabled={isPrevDisabled}\n theme={theme}\n type=\"prev\"\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isNextDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n <IconContainer\n disabled={isNextDisabled}\n theme={theme}\n type=\"next\"\n />\n </ButtonContainer>\n </>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={28}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\n {doneText || \"Done\"}\n </Text>\n </ButtonContainer>\n </View>\n </KeyboardStickyView>\n );\n};\n\nconst styles = StyleSheet.create({\n flex: {\n flex: 1,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n paddingHorizontal: 8,\n },\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 8,\n },\n});\n\nexport { colors as DefaultKeyboardToolbarTheme };\nexport default KeyboardToolbar;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,O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,EAAE;IACVsC,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDX,mBAAmB,EAAE;IACnBY,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,SAAS9E,MAAM,IAAI+E,2BAA2B;AAC9C,eAAevE,eAAe","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useMemo","useState","StyleSheet","Text","View","FocusedInputEvents","KeyboardController","useColorScheme","KeyboardStickyView","Arrow","Button","colors","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","DEFAULT_OPACITY","KeyboardToolbar","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","offset","closed","opened","enabled","insets","rest","colorScheme","inputs","setInputs","current","count","isPrevDisabled","isNextDisabled","subscription","addListener","e","remove","doneStyle","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","paddingLeft","left","paddingRight","right","ButtonContainer","IconContainer","onPressNext","event","isDefaultPrevented","setFocusTo","onPressPrev","onPressDone","dismiss","createElement","_extends","style","testID","arrows","accessibilityHint","accessibilityLabel","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","maxFontSizeMultiplier","create","position","bottom","alignItems","width","flexDirection","height","fontWeight","fontSize","marginRight","marginLeft","DefaultKeyboardToolbarTheme"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport { FocusedInputEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\nimport useColorScheme from \"../hooks/useColorScheme\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\n\nimport type { HEX, KeyboardToolbarTheme } from \"./types\";\nimport type { KeyboardStickyViewProps } from \"../KeyboardStickyView\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent, ViewProps } from \"react-native\";\n\ntype SafeAreaInsets = {\n left: number;\n right: number;\n};\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n /** An element that is shown in the middle of the toolbar. */\n content?: React.JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /** Custom text for done button. */\n doneText?: ReactNode;\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\n button?: typeof Button;\n /** Custom icon component used to display next/prev buttons. */\n icon?: typeof Arrow;\n /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: (event: GestureResponderEvent) => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: React.JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\n insets?: SafeAreaInsets;\n} & Pick<KeyboardStickyViewProps, \"offset\" | \"enabled\">;\n\nconst TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\nconst TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\nconst TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\nconst TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\nconst TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\n\nconst KEYBOARD_TOOLBAR_HEIGHT = 42;\nconst DEFAULT_OPACITY: HEX = \"FF\";\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and\n * `Done` buttons.\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({\n content,\n theme = colors,\n doneText = \"Done\",\n button,\n icon,\n showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\n offset: { closed = 0, opened = 0 } = {},\n enabled = true,\n insets,\n ...rest\n}) => {\n const colorScheme = useColorScheme();\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n {\n paddingLeft: insets?.left,\n paddingRight: insets?.right,\n },\n ],\n [colorScheme, opacity, theme, insets],\n );\n const offset = useMemo(\n () => ({ closed: closed + KEYBOARD_TOOLBAR_HEIGHT, opened }),\n [closed, opened],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onNextCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"next\");\n }\n },\n [onNextCallback],\n );\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPrevCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"prev\");\n }\n },\n [onPrevCallback],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onDoneCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.dismiss();\n }\n },\n [onDoneCallback],\n );\n\n return (\n <KeyboardStickyView enabled={enabled} offset={offset}>\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <View style={styles.arrows}>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isPrevDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n <IconContainer\n disabled={isPrevDisabled}\n theme={theme}\n type=\"prev\"\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isNextDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n <IconContainer\n disabled={isNextDisabled}\n theme={theme}\n type=\"next\"\n />\n </ButtonContainer>\n </View>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n {doneText && (\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={28}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\n {doneText}\n </Text>\n </ButtonContainer>\n )}\n </View>\n </KeyboardStickyView>\n );\n};\n\nconst styles = StyleSheet.create({\n flex: {\n flex: 1,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n },\n arrows: {\n flexDirection: \"row\",\n paddingLeft: 8,\n },\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 16,\n marginLeft: 8,\n },\n});\n\nexport { colors as DefaultKeyboardToolbarTheme };\nexport default KeyboardToolbar;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACxE,SAASC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAErD,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,kBAAkB,QAAQ,cAAc;AACjD,OAAOC,cAAc,MAAM,yBAAyB;AACpD,OAAOC,kBAAkB,MAAM,uBAAuB;AAEtD,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,MAAM,QAAQ,UAAU;AAsDjC,MAAMC,wBAAwB,GAAG,kBAAkB;AACnD,MAAMC,iCAAiC,GAAG,GAAGD,wBAAwB,WAAW;AAChF,MAAME,6BAA6B,GAAG,GAAGF,wBAAwB,OAAO;AACxE,MAAMG,gCAAgC,GAAG,GAAGH,wBAAwB,UAAU;AAC9E,MAAMI,6BAA6B,GAAG,GAAGJ,wBAAwB,OAAO;AAExE,MAAMK,uBAAuB,GAAG,EAAE;AAClC,MAAMC,eAAoB,GAAG,IAAI;;AAEjC;AACA;AACA;AACA;AACA,MAAMC,eAA+C,GAAGA,CAAC;EACvDC,OAAO;EACPC,KAAK,GAAGV,MAAM;EACdW,QAAQ,GAAG,MAAM;EACjBC,MAAM;EACNC,IAAI;EACJC,UAAU,GAAG,IAAI;EACjBC,cAAc;EACdC,cAAc;EACdC,cAAc;EACdC,IAAI,GAAG,IAAI;EACXC,OAAO,GAAGZ,eAAe;EACzBa,MAAM,EAAE;IAAEC,MAAM,GAAG,CAAC;IAAEC,MAAM,GAAG;EAAE,CAAC,GAAG,CAAC,CAAC;EACvCC,OAAO,GAAG,IAAI;EACdC,MAAM;EACN,GAAGC;A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BAAqB,EAAE,GAAI;IAACX,KAAK,EAAExB;EAAU,GAChD1B,QACG,CACS,CAEf,CACY,CAAC;AAEzB,CAAC;AAED,MAAM2B,MAAM,GAAG/C,UAAU,CAACkF,MAAM,CAAC;EAC/BJ,IAAI,EAAE;IACJA,IAAI,EAAE;EACR,CAAC;EACD1B,OAAO,EAAE;IACP+B,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,CAAC;IACTC,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbC,aAAa,EAAE,KAAK;IACpBC,MAAM,EAAEzE;EACV,CAAC;EACDyD,MAAM,EAAE;IACNe,aAAa,EAAE,KAAK;IACpBhC,WAAW,EAAE;EACf,CAAC;EACDP,UAAU,EAAE;IACVyC,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDV,mBAAmB,EAAE;IACnBW,WAAW,EAAE,EAAE;IACfC,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF,SAASnF,MAAM,IAAIoF,2BAA2B;AAC9C,eAAe5E,eAAe","ignoreList":[]}
|
package/lib/module/module.js
CHANGED
package/lib/module/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardControllerNative","KeyboardEvents","isClosed","lastEvent","addListener","e","dismiss","options","keepFocus","Promise","resolve","subscription","undefined","remove","isVisible","state","KeyboardController","setDefaultMode","setInputMode","setFocusTo"],"sources":["module.ts"],"sourcesContent":["import { KeyboardControllerNative, KeyboardEvents } from \"./bindings\";\n\nimport type {\n DismissOptions,\n KeyboardControllerModule,\n KeyboardEventData,\n} from \"./types\";\n\nlet isClosed =
|
|
1
|
+
{"version":3,"names":["KeyboardControllerNative","KeyboardEvents","isClosed","lastEvent","addListener","e","dismiss","options","keepFocus","Promise","resolve","subscription","undefined","remove","isVisible","state","KeyboardController","setDefaultMode","setInputMode","setFocusTo"],"sources":["module.ts"],"sourcesContent":["import { KeyboardControllerNative, KeyboardEvents } from \"./bindings\";\n\nimport type {\n DismissOptions,\n KeyboardControllerModule,\n KeyboardEventData,\n} from \"./types\";\n\nlet isClosed = true;\nlet lastEvent: KeyboardEventData | null = null;\n\nKeyboardEvents.addListener(\"keyboardDidHide\", (e) => {\n isClosed = true;\n lastEvent = e;\n});\n\nKeyboardEvents.addListener(\"keyboardDidShow\", (e) => {\n isClosed = false;\n lastEvent = e;\n});\n\nconst dismiss = async (options?: DismissOptions): Promise<void> => {\n const keepFocus = options?.keepFocus ?? false;\n\n return new Promise((resolve) => {\n if (isClosed) {\n resolve();\n\n return;\n }\n\n const subscription = KeyboardEvents.addListener(\"keyboardDidHide\", () => {\n resolve(undefined);\n subscription.remove();\n });\n\n KeyboardControllerNative.dismiss(keepFocus);\n });\n};\nconst isVisible = () => !isClosed;\nconst state = () => lastEvent;\n\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: KeyboardControllerNative.setDefaultMode,\n setInputMode: KeyboardControllerNative.setInputMode,\n setFocusTo: KeyboardControllerNative.setFocusTo,\n dismiss,\n isVisible,\n state,\n};\n"],"mappings":"AAAA,SAASA,wBAAwB,EAAEC,cAAc,QAAQ,YAAY;AAQrE,IAAIC,QAAQ,GAAG,IAAI;AACnB,IAAIC,SAAmC,GAAG,IAAI;AAE9CF,cAAc,CAACG,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDH,QAAQ,GAAG,IAAI;EACfC,SAAS,GAAGE,CAAC;AACf,CAAC,CAAC;AAEFJ,cAAc,CAACG,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDH,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAGE,CAAC;AACf,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,MAAOC,OAAwB,IAAoB;EACjE,MAAMC,SAAS,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,SAAS,KAAI,KAAK;EAE7C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,IAAIR,QAAQ,EAAE;MACZQ,OAAO,CAAC,CAAC;MAET;IACF;IAEA,MAAMC,YAAY,GAAGV,cAAc,CAACG,WAAW,CAAC,iBAAiB,EAAE,MAAM;MACvEM,OAAO,CAACE,SAAS,CAAC;MAClBD,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFb,wBAAwB,CAACM,OAAO,CAACE,SAAS,CAAC;EAC7C,CAAC,CAAC;AACJ,CAAC;AACD,MAAMM,SAAS,GAAGA,CAAA,KAAM,CAACZ,QAAQ;AACjC,MAAMa,KAAK,GAAGA,CAAA,KAAMZ,SAAS;AAE7B,OAAO,MAAMa,kBAA4C,GAAG;EAC1DC,cAAc,EAAEjB,wBAAwB,CAACiB,cAAc;EACvDC,YAAY,EAAElB,wBAAwB,CAACkB,YAAY;EACnDC,UAAU,EAAEnB,wBAAwB,CAACmB,UAAU;EAC/Cb,OAAO;EACPQ,SAAS;EACTC;AACF,CAAC","ignoreList":[]}
|
|
@@ -6,6 +6,10 @@ import type { HEX, KeyboardToolbarTheme } from "./types";
|
|
|
6
6
|
import type { KeyboardStickyViewProps } from "../KeyboardStickyView";
|
|
7
7
|
import type { ReactNode } from "react";
|
|
8
8
|
import type { GestureResponderEvent, ViewProps } from "react-native";
|
|
9
|
+
type SafeAreaInsets = {
|
|
10
|
+
left: number;
|
|
11
|
+
right: number;
|
|
12
|
+
};
|
|
9
13
|
export type KeyboardToolbarProps = Omit<ViewProps, "style" | "testID" | "children"> & {
|
|
10
14
|
/** An element that is shown in the middle of the toolbar. */
|
|
11
15
|
content?: React.JSX.Element | null;
|
|
@@ -42,6 +46,7 @@ export type KeyboardToolbarProps = Omit<ViewProps, "style" | "testID" | "childre
|
|
|
42
46
|
* A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.
|
|
43
47
|
*/
|
|
44
48
|
opacity?: HEX;
|
|
49
|
+
insets?: SafeAreaInsets;
|
|
45
50
|
} & Pick<KeyboardStickyViewProps, "offset" | "enabled">;
|
|
46
51
|
/**
|
|
47
52
|
* `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and
|
package/package.json
CHANGED
|
@@ -15,6 +15,11 @@ import type { KeyboardStickyViewProps } from "../KeyboardStickyView";
|
|
|
15
15
|
import type { ReactNode } from "react";
|
|
16
16
|
import type { GestureResponderEvent, ViewProps } from "react-native";
|
|
17
17
|
|
|
18
|
+
type SafeAreaInsets = {
|
|
19
|
+
left: number;
|
|
20
|
+
right: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
18
23
|
export type KeyboardToolbarProps = Omit<
|
|
19
24
|
ViewProps,
|
|
20
25
|
"style" | "testID" | "children"
|
|
@@ -54,6 +59,7 @@ export type KeyboardToolbarProps = Omit<
|
|
|
54
59
|
* A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.
|
|
55
60
|
*/
|
|
56
61
|
opacity?: HEX;
|
|
62
|
+
insets?: SafeAreaInsets;
|
|
57
63
|
} & Pick<KeyboardStickyViewProps, "offset" | "enabled">;
|
|
58
64
|
|
|
59
65
|
const TEST_ID_KEYBOARD_TOOLBAR = "keyboard.toolbar";
|
|
@@ -72,7 +78,7 @@ const DEFAULT_OPACITY: HEX = "FF";
|
|
|
72
78
|
const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
73
79
|
content,
|
|
74
80
|
theme = colors,
|
|
75
|
-
doneText,
|
|
81
|
+
doneText = "Done",
|
|
76
82
|
button,
|
|
77
83
|
icon,
|
|
78
84
|
showArrows = true,
|
|
@@ -83,6 +89,7 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
83
89
|
opacity = DEFAULT_OPACITY,
|
|
84
90
|
offset: { closed = 0, opened = 0 } = {},
|
|
85
91
|
enabled = true,
|
|
92
|
+
insets,
|
|
86
93
|
...rest
|
|
87
94
|
}) => {
|
|
88
95
|
const colorScheme = useColorScheme();
|
|
@@ -110,8 +117,12 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
110
117
|
{
|
|
111
118
|
backgroundColor: `${theme[colorScheme].background}${opacity}`,
|
|
112
119
|
},
|
|
120
|
+
{
|
|
121
|
+
paddingLeft: insets?.left,
|
|
122
|
+
paddingRight: insets?.right,
|
|
123
|
+
},
|
|
113
124
|
],
|
|
114
|
-
[colorScheme, opacity, theme],
|
|
125
|
+
[colorScheme, opacity, theme, insets],
|
|
115
126
|
);
|
|
116
127
|
const offset = useMemo(
|
|
117
128
|
() => ({ closed: closed + KEYBOARD_TOOLBAR_HEIGHT, opened }),
|
|
@@ -156,7 +167,7 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
156
167
|
<View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>
|
|
157
168
|
{blur}
|
|
158
169
|
{showArrows && (
|
|
159
|
-
|
|
170
|
+
<View style={styles.arrows}>
|
|
160
171
|
<ButtonContainer
|
|
161
172
|
accessibilityHint="Moves focus to the previous field"
|
|
162
173
|
accessibilityLabel="Previous"
|
|
@@ -185,25 +196,27 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
185
196
|
type="next"
|
|
186
197
|
/>
|
|
187
198
|
</ButtonContainer>
|
|
188
|
-
|
|
199
|
+
</View>
|
|
189
200
|
)}
|
|
190
201
|
|
|
191
202
|
<View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>
|
|
192
203
|
{content}
|
|
193
204
|
</View>
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
{
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
{doneText && (
|
|
206
|
+
<ButtonContainer
|
|
207
|
+
accessibilityHint="Closes the keyboard"
|
|
208
|
+
accessibilityLabel="Done"
|
|
209
|
+
rippleRadius={28}
|
|
210
|
+
style={styles.doneButtonContainer}
|
|
211
|
+
testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}
|
|
212
|
+
theme={theme}
|
|
213
|
+
onPress={onPressDone}
|
|
214
|
+
>
|
|
215
|
+
<Text maxFontSizeMultiplier={1.3} style={doneStyle}>
|
|
216
|
+
{doneText}
|
|
217
|
+
</Text>
|
|
218
|
+
</ButtonContainer>
|
|
219
|
+
)}
|
|
207
220
|
</View>
|
|
208
221
|
</KeyboardStickyView>
|
|
209
222
|
);
|
|
@@ -220,14 +233,18 @@ const styles = StyleSheet.create({
|
|
|
220
233
|
width: "100%",
|
|
221
234
|
flexDirection: "row",
|
|
222
235
|
height: KEYBOARD_TOOLBAR_HEIGHT,
|
|
223
|
-
|
|
236
|
+
},
|
|
237
|
+
arrows: {
|
|
238
|
+
flexDirection: "row",
|
|
239
|
+
paddingLeft: 8,
|
|
224
240
|
},
|
|
225
241
|
doneButton: {
|
|
226
242
|
fontWeight: "600",
|
|
227
243
|
fontSize: 15,
|
|
228
244
|
},
|
|
229
245
|
doneButtonContainer: {
|
|
230
|
-
marginRight:
|
|
246
|
+
marginRight: 16,
|
|
247
|
+
marginLeft: 8,
|
|
231
248
|
},
|
|
232
249
|
});
|
|
233
250
|
|