react-native-keyboard-controller 1.18.6 → 1.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -2
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt +8 -1
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/View.kt +41 -0
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +25 -5
  5. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/statusbar/StatusBarManagerCompatModuleImpl.kt +4 -4
  6. package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +2 -8
  7. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -2
  8. package/ios/KeyboardControllerModule.mm +3 -3
  9. package/ios/KeyboardControllerModuleImpl.swift +26 -16
  10. package/ios/delegates/KCTextInputCompositeDelegate.swift +13 -0
  11. package/ios/extensions/UITextInput.swift +5 -0
  12. package/ios/observers/movement/KeyboardTrackingView.swift +23 -11
  13. package/ios/views/KeyboardControllerView.mm +6 -1
  14. package/ios/views/KeyboardControllerViewManager.swift +2 -1
  15. package/ios/views/KeyboardExtenderContainerView.swift +1 -1
  16. package/ios/views/KeyboardExtenderManager.mm +1 -2
  17. package/lib/commonjs/animated.js +1 -2
  18. package/lib/commonjs/animated.js.map +1 -1
  19. package/lib/commonjs/components/KeyboardAvoidingView/index.js +1 -2
  20. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  21. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +1 -2
  22. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  23. package/lib/commonjs/components/KeyboardStickyView/index.js +1 -2
  24. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  25. package/lib/commonjs/components/KeyboardToolbar/Arrow.js +1 -2
  26. package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
  27. package/lib/commonjs/components/KeyboardToolbar/Button.js +1 -2
  28. package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
  29. package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js +13 -0
  30. package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
  31. package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js +25 -0
  32. package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
  33. package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js +61 -0
  34. package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
  35. package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js +52 -0
  36. package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
  37. package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js +52 -0
  38. package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
  39. package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js +42 -0
  40. package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js.map +1 -0
  41. package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js +6 -0
  42. package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js.map +1 -0
  43. package/lib/commonjs/components/KeyboardToolbar/compound/context.js +17 -0
  44. package/lib/commonjs/components/KeyboardToolbar/compound/context.js.map +1 -0
  45. package/lib/commonjs/components/KeyboardToolbar/index.js +76 -78
  46. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  47. package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -1
  48. package/lib/commonjs/components/index.js +1 -2
  49. package/lib/commonjs/components/index.js.map +1 -1
  50. package/lib/commonjs/hooks/useWindowDimensions/index.js +3 -3
  51. package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -1
  52. package/lib/commonjs/module.js +2 -1
  53. package/lib/commonjs/module.js.map +1 -1
  54. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
  55. package/lib/commonjs/types/module.js.map +1 -1
  56. package/lib/commonjs/views/OverKeyboardView/index.js +1 -2
  57. package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
  58. package/lib/module/components/KeyboardToolbar/compound/components/Background.js +6 -0
  59. package/lib/module/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
  60. package/lib/module/components/KeyboardToolbar/compound/components/Content.js +18 -0
  61. package/lib/module/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
  62. package/lib/module/components/KeyboardToolbar/compound/components/Done.js +54 -0
  63. package/lib/module/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
  64. package/lib/module/components/KeyboardToolbar/compound/components/Next.js +44 -0
  65. package/lib/module/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
  66. package/lib/module/components/KeyboardToolbar/compound/components/Prev.js +45 -0
  67. package/lib/module/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
  68. package/lib/module/components/KeyboardToolbar/compound/components/index.js +6 -0
  69. package/lib/module/components/KeyboardToolbar/compound/components/index.js.map +1 -0
  70. package/lib/module/components/KeyboardToolbar/compound/components/types.js +2 -0
  71. package/lib/module/components/KeyboardToolbar/compound/components/types.js.map +1 -0
  72. package/lib/module/components/KeyboardToolbar/compound/context.js +10 -0
  73. package/lib/module/components/KeyboardToolbar/compound/context.js.map +1 -0
  74. package/lib/module/components/KeyboardToolbar/index.js +78 -79
  75. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  76. package/lib/module/components/KeyboardToolbar/types.js.map +1 -1
  77. package/lib/module/hooks/useWindowDimensions/index.js +3 -3
  78. package/lib/module/hooks/useWindowDimensions/index.js.map +1 -1
  79. package/lib/module/module.js +2 -1
  80. package/lib/module/module.js.map +1 -1
  81. package/lib/module/specs/NativeKeyboardController.js.map +1 -1
  82. package/lib/module/types/module.js.map +1 -1
  83. package/lib/typescript/components/KeyboardToolbar/compound/components/Background.d.ts +6 -0
  84. package/lib/typescript/components/KeyboardToolbar/compound/components/Content.d.ts +7 -0
  85. package/lib/typescript/components/KeyboardToolbar/compound/components/Done.d.ts +7 -0
  86. package/lib/typescript/components/KeyboardToolbar/compound/components/Next.d.ts +4 -0
  87. package/lib/typescript/components/KeyboardToolbar/compound/components/Prev.d.ts +4 -0
  88. package/lib/typescript/components/KeyboardToolbar/compound/components/index.d.ts +5 -0
  89. package/lib/typescript/components/KeyboardToolbar/compound/components/types.d.ts +14 -0
  90. package/lib/typescript/components/KeyboardToolbar/compound/context.d.ts +9 -0
  91. package/lib/typescript/components/KeyboardToolbar/index.d.ts +13 -54
  92. package/lib/typescript/components/KeyboardToolbar/types.d.ts +92 -5
  93. package/lib/typescript/specs/NativeKeyboardController.d.ts +1 -1
  94. package/lib/typescript/types/module.d.ts +5 -1
  95. package/package.json +8 -8
  96. package/src/components/KeyboardToolbar/compound/components/Background.tsx +9 -0
  97. package/src/components/KeyboardToolbar/compound/components/Content.tsx +25 -0
  98. package/src/components/KeyboardToolbar/compound/components/Done.tsx +70 -0
  99. package/src/components/KeyboardToolbar/compound/components/Next.tsx +55 -0
  100. package/src/components/KeyboardToolbar/compound/components/Prev.tsx +56 -0
  101. package/src/components/KeyboardToolbar/compound/components/index.ts +5 -0
  102. package/src/components/KeyboardToolbar/compound/components/types.ts +15 -0
  103. package/src/components/KeyboardToolbar/compound/context.ts +25 -0
  104. package/src/components/KeyboardToolbar/index.tsx +105 -165
  105. package/src/components/KeyboardToolbar/types.ts +101 -5
  106. package/src/hooks/useWindowDimensions/index.ts +3 -3
  107. package/src/module.ts +3 -2
  108. package/src/specs/NativeKeyboardController.ts +1 -1
  109. package/src/types/module.ts +5 -1
@@ -0,0 +1,54 @@
1
+ import React from "react";
2
+ import { useCallback, useMemo } from "react";
3
+ import { StyleSheet, Text } from "react-native";
4
+ import { useKeyboardState } from "../../../../hooks";
5
+ import { KeyboardController } from "../../../../module";
6
+ import Button from "../../Button";
7
+ import { TEST_ID_KEYBOARD_TOOLBAR_DONE } from "../../constants";
8
+ import { useToolbarContext } from "../context";
9
+ const Done = ({
10
+ children,
11
+ onPress,
12
+ rippleRadius = 28,
13
+ text,
14
+ button: ButtonContainer = Button
15
+ }) => {
16
+ const colorScheme = useKeyboardState(state => state.appearance);
17
+ const context = useToolbarContext();
18
+ const {
19
+ theme
20
+ } = context;
21
+ const doneStyle = useMemo(() => [styles.doneButton, {
22
+ color: theme[colorScheme].primary
23
+ }], [colorScheme, theme]);
24
+ const onPressDone = useCallback(event => {
25
+ onPress === null || onPress === void 0 || onPress(event);
26
+ if (!event.isDefaultPrevented()) {
27
+ KeyboardController.dismiss();
28
+ }
29
+ }, [onPress]);
30
+ return /*#__PURE__*/React.createElement(ButtonContainer, {
31
+ accessibilityHint: "Closes the keyboard",
32
+ accessibilityLabel: "Done",
33
+ rippleRadius: rippleRadius,
34
+ style: styles.doneButtonContainer,
35
+ testID: TEST_ID_KEYBOARD_TOOLBAR_DONE,
36
+ theme: theme,
37
+ onPress: onPressDone
38
+ }, /*#__PURE__*/React.createElement(Text, {
39
+ maxFontSizeMultiplier: 1.3,
40
+ style: doneStyle
41
+ }, children ?? text ?? "Done"));
42
+ };
43
+ const styles = StyleSheet.create({
44
+ doneButton: {
45
+ fontWeight: "600",
46
+ fontSize: 15
47
+ },
48
+ doneButtonContainer: {
49
+ marginRight: 16,
50
+ marginLeft: 8
51
+ }
52
+ });
53
+ export default Done;
54
+ //# sourceMappingURL=Done.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useMemo","StyleSheet","Text","useKeyboardState","KeyboardController","Button","TEST_ID_KEYBOARD_TOOLBAR_DONE","useToolbarContext","Done","children","onPress","rippleRadius","text","button","ButtonContainer","colorScheme","state","appearance","context","theme","doneStyle","styles","doneButton","color","primary","onPressDone","event","isDefaultPrevented","dismiss","createElement","accessibilityHint","accessibilityLabel","style","doneButtonContainer","testID","maxFontSizeMultiplier","create","fontWeight","fontSize","marginRight","marginLeft"],"sources":["Done.tsx"],"sourcesContent":["import React from \"react\";\nimport { useCallback, useMemo } from \"react\";\nimport { StyleSheet, Text } from \"react-native\";\n\nimport { useKeyboardState } from \"../../../../hooks\";\nimport { KeyboardController } from \"../../../../module\";\nimport Button from \"../../Button\";\nimport { TEST_ID_KEYBOARD_TOOLBAR_DONE } from \"../../constants\";\nimport { useToolbarContext } from \"../context\";\n\nimport type { ButtonSubProps } from \"./types\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent } from \"react-native\";\n\nconst Done: React.FC<Omit<ButtonSubProps, \"icon\"> & { text?: ReactNode }> = ({\n children,\n onPress,\n rippleRadius = 28,\n text,\n button: ButtonContainer = Button,\n}) => {\n const colorScheme = useKeyboardState((state) => state.appearance);\n const context = useToolbarContext();\n const { theme } = context;\n\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onPress?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.dismiss();\n }\n },\n [onPress],\n );\n\n return (\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={rippleRadius}\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 {children ?? text ?? \"Done\"}\n </Text>\n </ButtonContainer>\n );\n};\n\nconst styles = StyleSheet.create({\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 16,\n marginLeft: 8,\n },\n});\n\nexport default Done;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC5C,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAE/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AAA,CAAC3B,IAAI;IAACiC,qBAAqB,EAAE,GAAI;IAACH,KAAK,EAAEZ;EAAU,GAChDX,QAAQ,IAAIG,IAAI,IAAI,MACjB,CACS,CAAC;AAEtB,CAAC;AAED,MAAMS,MAAM,GAAGpB,UAAU,CAACmC,MAAM,CAAC;EAC/Bd,UAAU,EAAE;IACVe,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDL,mBAAmB,EAAE;IACnBM,WAAW,EAAE,EAAE;IACfC,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF,eAAehC,IAAI","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ import React, { useCallback } from "react";
2
+ import { KeyboardController } from "../../../../module";
3
+ import Arrow from "../../Arrow";
4
+ import Button from "../../Button";
5
+ import { TEST_ID_KEYBOARD_TOOLBAR_NEXT } from "../../constants";
6
+ import { useToolbarContext } from "../context";
7
+ const Next = ({
8
+ children,
9
+ onPress,
10
+ disabled,
11
+ rippleRadius,
12
+ style,
13
+ button: ButtonContainer = Button,
14
+ icon: IconContainer = Arrow
15
+ }) => {
16
+ const context = useToolbarContext();
17
+ const {
18
+ theme,
19
+ isNextDisabled
20
+ } = context;
21
+ const isDisabled = disabled ?? isNextDisabled;
22
+ const onPressNext = useCallback(event => {
23
+ onPress === null || onPress === void 0 || onPress(event);
24
+ if (!event.isDefaultPrevented()) {
25
+ KeyboardController.setFocusTo("next");
26
+ }
27
+ }, [onPress]);
28
+ return /*#__PURE__*/React.createElement(ButtonContainer, {
29
+ accessibilityHint: "Moves focus to the next field",
30
+ accessibilityLabel: "Next",
31
+ disabled: isDisabled,
32
+ rippleRadius: rippleRadius,
33
+ style: style,
34
+ testID: TEST_ID_KEYBOARD_TOOLBAR_NEXT,
35
+ theme: theme,
36
+ onPress: onPressNext
37
+ }, children ?? /*#__PURE__*/React.createElement(IconContainer, {
38
+ disabled: isDisabled,
39
+ theme: theme,
40
+ type: "next"
41
+ }));
42
+ };
43
+ export default Next;
44
+ //# sourceMappingURL=Next.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","KeyboardController","Arrow","Button","TEST_ID_KEYBOARD_TOOLBAR_NEXT","useToolbarContext","Next","children","onPress","disabled","rippleRadius","style","button","ButtonContainer","icon","IconContainer","context","theme","isNextDisabled","isDisabled","onPressNext","event","isDefaultPrevented","setFocusTo","createElement","accessibilityHint","accessibilityLabel","testID","type"],"sources":["Next.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\n\nimport { KeyboardController } from \"../../../../module\";\nimport Arrow from \"../../Arrow\";\nimport Button from \"../../Button\";\nimport { TEST_ID_KEYBOARD_TOOLBAR_NEXT } from \"../../constants\";\nimport { useToolbarContext } from \"../context\";\n\nimport type { ButtonSubProps } from \"./types\";\nimport type { GestureResponderEvent } from \"react-native\";\n\nconst Next: React.FC<ButtonSubProps> = ({\n children,\n onPress,\n disabled,\n rippleRadius,\n style,\n button: ButtonContainer = Button,\n icon: IconContainer = Arrow,\n}) => {\n const context = useToolbarContext();\n const { theme, isNextDisabled } = context;\n\n const isDisabled = disabled ?? isNextDisabled;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onPress?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"next\");\n }\n },\n [onPress],\n );\n\n return (\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isDisabled}\n rippleRadius={rippleRadius}\n style={style}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n {children ?? (\n <IconContainer disabled={isDisabled} theme={theme} type=\"next\" />\n )}\n </ButtonContainer>\n );\n};\n\nexport default Next;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAE1C,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,OAAOC,KAAK,MAAM,aAAa;AAC/B,OAAOC,MAAM,MAAM,cAAc;AACjC,SAASC,6BAA6B,QAAQ,iBAAiB;AAC/D,SAASC,iBAAiB,QAAQ,YAAY;AAK9C,MAAMC,IAA8B,GAAGA,CAAC;EACtCC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,YAAY;EACZC,KAAK;EACLC,MAAM,EAAEC,eAAe,GAAGV,MAAM;EAChCW,IAAI,EAAEC,aAAa,GAAGb;AACxB,CAAC,KAAK;EACJ,MAAMc,OAAO,GAAGX,iBAAiB,CAAC,CAAC;EACnC,MAAM;IAAEY,KAAK;IAAEC;EAAe,CAAC,GAAGF,OAAO;EAEzC,MAAMG,UAAU,GAAGV,QAAQ,IAAIS,cAAc;EAE7C,MAAME,WAAW,GAAGpB,WAAW,CAC5BqB,KAA4B,IAAK;IAChCb,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAGa,KAAK,CAAC;IAEhB,IAAI,CAACA,KAAK,CAACC,kBAAkB,CAAC,CAAC,EAAE;MAC/BrB,kBAAkB,CAACsB,UAAU,CAAC,MAAM,CAAC;IACvC;EACF,CAAC,EACD,CAACf,OAAO,CACV,CAAC;EAED,oBACET,KAAA,CAAAyB,aAAA,CAACX,eAAe;IACdY,iBAAiB,EAAC,+BAA+B;IACjDC,kBAAkB,EAAC,MAAM;IACzBjB,QAAQ,EAAEU,UAAW;IACrBT,YAAY,EAAEA,YAAa;IAC3BC,KAAK,EAAEA,KAAM;IACbgB,MAAM,EAAEvB,6BAA8B;IACtCa,KAAK,EAAEA,KAAM;IACbT,OAAO,EAAEY;EAAY,GAEpBb,QAAQ,iBACPR,KAAA,CAAAyB,aAAA,CAACT,aAAa;IAACN,QAAQ,EAAEU,UAAW;IAACF,KAAK,EAAEA,KAAM;IAACW,IAAI,EAAC;EAAM,CAAE,CAEnD,CAAC;AAEtB,CAAC;AAED,eAAetB,IAAI","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ import React from "react";
2
+ import { useCallback } from "react";
3
+ import { KeyboardController } from "../../../../module";
4
+ import Arrow from "../../Arrow";
5
+ import Button from "../../Button";
6
+ import { TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS } from "../../constants";
7
+ import { useToolbarContext } from "../context";
8
+ const Prev = ({
9
+ children,
10
+ onPress: onPressCallback,
11
+ disabled,
12
+ rippleRadius,
13
+ style,
14
+ button: ButtonContainer = Button,
15
+ icon: IconContainer = Arrow
16
+ }) => {
17
+ const context = useToolbarContext();
18
+ const {
19
+ theme,
20
+ isPrevDisabled
21
+ } = context;
22
+ const isDisabled = disabled ?? isPrevDisabled;
23
+ const onPressPrev = useCallback(event => {
24
+ onPressCallback === null || onPressCallback === void 0 || onPressCallback(event);
25
+ if (!event.isDefaultPrevented()) {
26
+ KeyboardController.setFocusTo("prev");
27
+ }
28
+ }, [onPressCallback]);
29
+ return /*#__PURE__*/React.createElement(ButtonContainer, {
30
+ accessibilityHint: "Moves focus to the previous field",
31
+ accessibilityLabel: "Previous",
32
+ disabled: isDisabled,
33
+ rippleRadius: rippleRadius,
34
+ style: style,
35
+ testID: TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS,
36
+ theme: theme,
37
+ onPress: onPressPrev
38
+ }, children ?? /*#__PURE__*/React.createElement(IconContainer, {
39
+ disabled: isDisabled,
40
+ theme: theme,
41
+ type: "prev"
42
+ }));
43
+ };
44
+ export default Prev;
45
+ //# sourceMappingURL=Prev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","KeyboardController","Arrow","Button","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","useToolbarContext","Prev","children","onPress","onPressCallback","disabled","rippleRadius","style","button","ButtonContainer","icon","IconContainer","context","theme","isPrevDisabled","isDisabled","onPressPrev","event","isDefaultPrevented","setFocusTo","createElement","accessibilityHint","accessibilityLabel","testID","type"],"sources":["Prev.tsx"],"sourcesContent":["import React from \"react\";\nimport { useCallback } from \"react\";\n\nimport { KeyboardController } from \"../../../../module\";\nimport Arrow from \"../../Arrow\";\nimport Button from \"../../Button\";\nimport { TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS } from \"../../constants\";\nimport { useToolbarContext } from \"../context\";\n\nimport type { ButtonSubProps } from \"./types\";\nimport type { GestureResponderEvent } from \"react-native\";\n\nconst Prev: React.FC<ButtonSubProps> = ({\n children,\n onPress: onPressCallback,\n disabled,\n rippleRadius,\n style,\n button: ButtonContainer = Button,\n icon: IconContainer = Arrow,\n}) => {\n const context = useToolbarContext();\n const { theme, isPrevDisabled } = context;\n\n const isDisabled = disabled ?? isPrevDisabled;\n\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPressCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"prev\");\n }\n },\n [onPressCallback],\n );\n\n return (\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isDisabled}\n rippleRadius={rippleRadius}\n style={style}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n {children ?? (\n <IconContainer disabled={isDisabled} theme={theme} type=\"prev\" />\n )}\n </ButtonContainer>\n );\n};\n\nexport default Prev;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,QAAQ,OAAO;AAEnC,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,OAAOC,KAAK,MAAM,aAAa;AAC/B,OAAOC,MAAM,MAAM,cAAc;AACjC,SAASC,iCAAiC,QAAQ,iBAAiB;AACnE,SAASC,iBAAiB,QAAQ,YAAY;AAK9C,MAAMC,IAA8B,GAAGA,CAAC;EACtCC,QAAQ;EACRC,OAAO,EAAEC,eAAe;EACxBC,QAAQ;EACRC,YAAY;EACZC,KAAK;EACLC,MAAM,EAAEC,eAAe,GAAGX,MAAM;EAChCY,IAAI,EAAEC,aAAa,GAAGd;AACxB,CAAC,KAAK;EACJ,MAAMe,OAAO,GAAGZ,iBAAiB,CAAC,CAAC;EACnC,MAAM;IAAEa,KAAK;IAAEC;EAAe,CAAC,GAAGF,OAAO;EAEzC,MAAMG,UAAU,GAAGV,QAAQ,IAAIS,cAAc;EAE7C,MAAME,WAAW,GAAGrB,WAAW,CAC5BsB,KAA4B,IAAK;IAChCb,eAAe,aAAfA,eAAe,eAAfA,eAAe,CAAGa,KAAK,CAAC;IAExB,IAAI,CAACA,KAAK,CAACC,kBAAkB,CAAC,CAAC,EAAE;MAC/BtB,kBAAkB,CAACuB,UAAU,CAAC,MAAM,CAAC;IACvC;EACF,CAAC,EACD,CAACf,eAAe,CAClB,CAAC;EAED,oBACEV,KAAA,CAAA0B,aAAA,CAACX,eAAe;IACdY,iBAAiB,EAAC,mCAAmC;IACrDC,kBAAkB,EAAC,UAAU;IAC7BjB,QAAQ,EAAEU,UAAW;IACrBT,YAAY,EAAEA,YAAa;IAC3BC,KAAK,EAAEA,KAAM;IACbgB,MAAM,EAAExB,iCAAkC;IAC1Cc,KAAK,EAAEA,KAAM;IACbV,OAAO,EAAEa;EAAY,GAEpBd,QAAQ,iBACPR,KAAA,CAAA0B,aAAA,CAACT,aAAa;IAACN,QAAQ,EAAEU,UAAW;IAACF,KAAK,EAAEA,KAAM;IAACW,IAAI,EAAC;EAAM,CAAE,CAEnD,CAAC;AAEtB,CAAC;AAED,eAAevB,IAAI","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ export { default as Background } from "./Background";
2
+ export { default as Content } from "./Content";
3
+ export { default as Done } from "./Done";
4
+ export { default as Next } from "./Next";
5
+ export { default as Prev } from "./Prev";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","Background","Content","Done","Next","Prev"],"sources":["index.ts"],"sourcesContent":["export { default as Background } from \"./Background\";\nexport { default as Content } from \"./Content\";\nexport { default as Done } from \"./Done\";\nexport { default as Next } from \"./Next\";\nexport { default as Prev } from \"./Prev\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAAU,QAAQ,cAAc;AACpD,SAASD,OAAO,IAAIE,OAAO,QAAQ,WAAW;AAC9C,SAASF,OAAO,IAAIG,IAAI,QAAQ,QAAQ;AACxC,SAASH,OAAO,IAAII,IAAI,QAAQ,QAAQ;AACxC,SAASJ,OAAO,IAAIK,IAAI,QAAQ,QAAQ","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type Arrow from \"../../Arrow\";\nimport type Button from \"../../Button\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent, ViewStyle } from \"react-native\";\n\nexport type ButtonSubProps = {\n children?: ReactNode;\n onPress?: (event: GestureResponderEvent) => void;\n disabled?: boolean;\n testID?: string;\n rippleRadius?: number;\n style?: ViewStyle;\n button?: typeof Button;\n icon?: typeof Arrow;\n};\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import { createContext, useContext } from "react";
2
+ export const ToolbarContext = /*#__PURE__*/createContext(undefined);
3
+ export const useToolbarContext = () => {
4
+ const context = useContext(ToolbarContext);
5
+ if (!context) {
6
+ throw new Error("KeyboardToolbar.* component must be used inside <KeyboardToolbar>");
7
+ }
8
+ return context;
9
+ };
10
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","useContext","ToolbarContext","undefined","useToolbarContext","context","Error"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nimport type { KeyboardToolbarTheme } from \"../types\";\n\ntype ToolbarContextType = {\n theme: KeyboardToolbarTheme;\n isPrevDisabled: boolean;\n isNextDisabled: boolean;\n};\n\nexport const ToolbarContext = createContext<ToolbarContextType | undefined>(\n undefined,\n);\n\nexport const useToolbarContext = () => {\n const context = useContext(ToolbarContext);\n\n if (!context) {\n throw new Error(\n \"KeyboardToolbar.* component must be used inside <KeyboardToolbar>\",\n );\n }\n\n return context;\n};\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAUjD,OAAO,MAAMC,cAAc,gBAAGF,aAAa,CACzCG,SACF,CAAC;AAED,OAAO,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EACrC,MAAMC,OAAO,GAAGJ,UAAU,CAACC,cAAc,CAAC;EAE1C,IAAI,CAACG,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CACb,mEACF,CAAC;EACH;EAEA,OAAOD,OAAO;AAChB,CAAC","ignoreList":[]}
@@ -1,14 +1,15 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useEffect, useMemo, useState } from "react";
3
- import { StyleSheet, Text, View } from "react-native";
2
+ import React, { useEffect, useMemo, useState } from "react";
3
+ import { StyleSheet, View } from "react-native";
4
4
  import { FocusedInputEvents } from "../../bindings";
5
5
  import { useKeyboardState } from "../../hooks";
6
- import { KeyboardController } from "../../module";
7
6
  import KeyboardStickyView from "../KeyboardStickyView";
8
7
  import Arrow from "./Arrow";
9
8
  import Button from "./Button";
10
9
  import { colors } from "./colors";
11
- import { DEFAULT_OPACITY, KEYBOARD_HAS_ROUNDED_CORNERS, KEYBOARD_TOOLBAR_HEIGHT, OPENED_OFFSET, TEST_ID_KEYBOARD_TOOLBAR, TEST_ID_KEYBOARD_TOOLBAR_CONTENT, TEST_ID_KEYBOARD_TOOLBAR_DONE, TEST_ID_KEYBOARD_TOOLBAR_NEXT, TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS } from "./constants";
10
+ import { Background, Content, Done, Next, Prev } from "./compound/components";
11
+ import { ToolbarContext } from "./compound/context";
12
+ import { DEFAULT_OPACITY, KEYBOARD_HAS_ROUNDED_CORNERS, KEYBOARD_TOOLBAR_HEIGHT, OPENED_OFFSET, TEST_ID_KEYBOARD_TOOLBAR } from "./constants";
12
13
  /**
13
14
  * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` buttons from left and
14
15
  * `Done` button from the right (to dismiss the keyboard). Allows to add customizable content (yours UI elements) in the middle.
@@ -18,11 +19,14 @@ import { DEFAULT_OPACITY, KEYBOARD_HAS_ROUNDED_CORNERS, KEYBOARD_TOOLBAR_HEIGHT,
18
19
  * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-toolbar|Documentation} page for more details.
19
20
  * @example
20
21
  * ```tsx
21
- * <KeyboardToolbar doneText="Close" />
22
+ * <KeyboardToolbar>
23
+ * <KeyboardToolbar.Done text="Close" />
24
+ * </KeyboardToolbar>
22
25
  * ```
23
26
  */
24
27
  const KeyboardToolbar = props => {
25
28
  const {
29
+ children,
26
30
  content,
27
31
  theme = colors,
28
32
  doneText = "Done",
@@ -49,15 +53,14 @@ const KeyboardToolbar = props => {
49
53
  });
50
54
  const isPrevDisabled = inputs.current === 0;
51
55
  const isNextDisabled = inputs.current === inputs.count - 1;
56
+ const buttonContainer = button ?? Button;
57
+ const iconContainer = icon ?? Arrow;
52
58
  useEffect(() => {
53
59
  const subscription = FocusedInputEvents.addListener("focusDidSet", e => {
54
60
  setInputs(e);
55
61
  });
56
62
  return subscription.remove;
57
63
  }, []);
58
- const doneStyle = useMemo(() => [styles.doneButton, {
59
- color: theme[colorScheme].primary
60
- }], [colorScheme, theme]);
61
64
  const toolbarStyle = useMemo(() => [styles.toolbar, {
62
65
  backgroundColor: `${theme[colorScheme].background}${opacity}`
63
66
  }, !KEYBOARD_HAS_ROUNDED_CORNERS ? {
@@ -72,77 +75,76 @@ const KeyboardToolbar = props => {
72
75
  closed: closed + KEYBOARD_TOOLBAR_HEIGHT,
73
76
  opened: opened + OPENED_OFFSET
74
77
  }), [closed, opened]);
75
- const ButtonContainer = button || Button;
76
- const IconContainer = icon || Arrow;
77
- const onPressNext = useCallback(event => {
78
- onNextCallback === null || onNextCallback === void 0 || onNextCallback(event);
79
- if (!event.isDefaultPrevented()) {
80
- KeyboardController.setFocusTo("next");
81
- }
82
- }, [onNextCallback]);
83
- const onPressPrev = useCallback(event => {
84
- onPrevCallback === null || onPrevCallback === void 0 || onPrevCallback(event);
85
- if (!event.isDefaultPrevented()) {
86
- KeyboardController.setFocusTo("prev");
87
- }
88
- }, [onPrevCallback]);
89
- const onPressDone = useCallback(event => {
90
- onDoneCallback === null || onDoneCallback === void 0 || onDoneCallback(event);
91
- if (!event.isDefaultPrevented()) {
92
- KeyboardController.dismiss();
93
- }
94
- }, [onDoneCallback]);
95
- return /*#__PURE__*/React.createElement(KeyboardStickyView, {
78
+ let backgroundElement = null;
79
+ let arrowsElement = null;
80
+ let contentContainer = null;
81
+ let doneElement = null;
82
+ if (children) {
83
+ let prevChild = null;
84
+ let nextChild = null;
85
+ let contentChild = null;
86
+ let doneChild = null;
87
+ let backgroundChild = null;
88
+ React.Children.forEach(children, child => {
89
+ if (! /*#__PURE__*/React.isValidElement(child)) {
90
+ return;
91
+ }
92
+ const type = child.type;
93
+ if (type === Background) {
94
+ backgroundChild = child;
95
+ } else if (type === Content) {
96
+ contentChild = child;
97
+ } else if (type === Prev) {
98
+ prevChild = child;
99
+ } else if (type === Next) {
100
+ nextChild = child;
101
+ } else if (type === Done) {
102
+ doneChild = child;
103
+ }
104
+ });
105
+ backgroundElement = backgroundChild;
106
+ doneElement = doneChild;
107
+ arrowsElement = prevChild || nextChild ? /*#__PURE__*/React.createElement(View, {
108
+ style: styles.arrows
109
+ }, prevChild, nextChild) : null;
110
+ contentContainer = contentChild ?? /*#__PURE__*/React.createElement(Content, null, contentChild);
111
+ } else {
112
+ backgroundElement = blur;
113
+ arrowsElement = showArrows ? /*#__PURE__*/React.createElement(View, {
114
+ style: styles.arrows
115
+ }, /*#__PURE__*/React.createElement(Prev, {
116
+ button: buttonContainer,
117
+ icon: iconContainer,
118
+ onPress: onPrevCallback
119
+ }), /*#__PURE__*/React.createElement(Next, {
120
+ button: buttonContainer,
121
+ icon: iconContainer,
122
+ onPress: onNextCallback
123
+ })) : null;
124
+ contentContainer = /*#__PURE__*/React.createElement(Content, null, content);
125
+ doneElement = doneText ? /*#__PURE__*/React.createElement(Done, {
126
+ button: buttonContainer,
127
+ text: doneText,
128
+ onPress: onDoneCallback
129
+ }) : null;
130
+ }
131
+ const contextValue = useMemo(() => ({
132
+ theme,
133
+ isPrevDisabled,
134
+ isNextDisabled
135
+ }), [theme, isPrevDisabled, isNextDisabled]);
136
+ return /*#__PURE__*/React.createElement(ToolbarContext.Provider, {
137
+ value: contextValue
138
+ }, /*#__PURE__*/React.createElement(KeyboardStickyView, {
96
139
  enabled: enabled,
97
140
  offset: offset,
98
141
  style: containerStyle
99
142
  }, /*#__PURE__*/React.createElement(View, _extends({}, rest, {
100
143
  style: toolbarStyle,
101
144
  testID: TEST_ID_KEYBOARD_TOOLBAR
102
- }), blur, showArrows && /*#__PURE__*/React.createElement(View, {
103
- style: styles.arrows
104
- }, /*#__PURE__*/React.createElement(ButtonContainer, {
105
- accessibilityHint: "Moves focus to the previous field",
106
- accessibilityLabel: "Previous",
107
- disabled: isPrevDisabled,
108
- testID: TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS,
109
- theme: theme,
110
- onPress: onPressPrev
111
- }, /*#__PURE__*/React.createElement(IconContainer, {
112
- disabled: isPrevDisabled,
113
- theme: theme,
114
- type: "prev"
115
- })), /*#__PURE__*/React.createElement(ButtonContainer, {
116
- accessibilityHint: "Moves focus to the next field",
117
- accessibilityLabel: "Next",
118
- disabled: isNextDisabled,
119
- testID: TEST_ID_KEYBOARD_TOOLBAR_NEXT,
120
- theme: theme,
121
- onPress: onPressNext
122
- }, /*#__PURE__*/React.createElement(IconContainer, {
123
- disabled: isNextDisabled,
124
- theme: theme,
125
- type: "next"
126
- }))), /*#__PURE__*/React.createElement(View, {
127
- style: styles.flex,
128
- testID: TEST_ID_KEYBOARD_TOOLBAR_CONTENT
129
- }, content), doneText && /*#__PURE__*/React.createElement(ButtonContainer, {
130
- accessibilityHint: "Closes the keyboard",
131
- accessibilityLabel: "Done",
132
- rippleRadius: 28,
133
- style: styles.doneButtonContainer,
134
- testID: TEST_ID_KEYBOARD_TOOLBAR_DONE,
135
- theme: theme,
136
- onPress: onPressDone
137
- }, /*#__PURE__*/React.createElement(Text, {
138
- maxFontSizeMultiplier: 1.3,
139
- style: doneStyle
140
- }, doneText))));
145
+ }), backgroundElement, arrowsElement, contentContainer, doneElement)));
141
146
  };
142
147
  const styles = StyleSheet.create({
143
- flex: {
144
- flex: 1
145
- },
146
148
  toolbar: {
147
149
  position: "absolute",
148
150
  bottom: 0,
@@ -155,20 +157,17 @@ const styles = StyleSheet.create({
155
157
  flexDirection: "row",
156
158
  paddingLeft: 8
157
159
  },
158
- doneButton: {
159
- fontWeight: "600",
160
- fontSize: 15
161
- },
162
- doneButtonContainer: {
163
- marginRight: 16,
164
- marginLeft: 8
165
- },
166
160
  floating: {
167
161
  alignSelf: "center",
168
162
  borderRadius: 20,
169
163
  overflow: "hidden"
170
164
  }
171
165
  });
166
+ KeyboardToolbar.Background = Background;
167
+ KeyboardToolbar.Content = Content;
168
+ KeyboardToolbar.Prev = Prev;
169
+ KeyboardToolbar.Next = Next;
170
+ KeyboardToolbar.Done = Done;
172
171
  export { colors as DefaultKeyboardToolbarTheme };
173
172
  export default KeyboardToolbar;
174
173
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useCallback","useEffect","useMemo","useState","StyleSheet","Text","View","FocusedInputEvents","useKeyboardState","KeyboardController","KeyboardStickyView","Arrow","Button","colors","DEFAULT_OPACITY","KEYBOARD_HAS_ROUNDED_CORNERS","KEYBOARD_TOOLBAR_HEIGHT","OPENED_OFFSET","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","KeyboardToolbar","props","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","offset","closed","opened","enabled","insets","rest","colorScheme","state","appearance","inputs","setInputs","current","count","isPrevDisabled","isNextDisabled","subscription","addListener","e","remove","doneStyle","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","paddingLeft","left","paddingRight","right","floating","containerStyle","marginLeft","marginRight","ButtonContainer","IconContainer","onPressNext","event","isDefaultPrevented","setFocusTo","onPressPrev","onPressDone","dismiss","createElement","style","_extends","testID","arrows","accessibilityHint","accessibilityLabel","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","maxFontSizeMultiplier","create","position","bottom","alignItems","width","flexDirection","height","fontWeight","fontSize","alignSelf","borderRadius","overflow","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 { useKeyboardState } from \"../../hooks\";\nimport { KeyboardController } from \"../../module\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\nimport {\n DEFAULT_OPACITY,\n KEYBOARD_HAS_ROUNDED_CORNERS,\n KEYBOARD_TOOLBAR_HEIGHT,\n OPENED_OFFSET,\n TEST_ID_KEYBOARD_TOOLBAR,\n TEST_ID_KEYBOARD_TOOLBAR_CONTENT,\n TEST_ID_KEYBOARD_TOOLBAR_DONE,\n TEST_ID_KEYBOARD_TOOLBAR_NEXT,\n TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS,\n} from \"./constants\";\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 /**\n * A object containing `left`/`right` properties. Used to specify proper container padding in landscape mode.\n */\n insets?: SafeAreaInsets;\n} & Pick<KeyboardStickyViewProps, \"offset\" | \"enabled\">;\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` buttons from left and\n * `Done` button from the right (to dismiss the keyboard). Allows to add customizable content (yours UI elements) in the middle.\n *\n * @param props - Component props.\n * @returns A component that is shown above the keyboard with `Prev`/`Next` and `Done` buttons.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-toolbar|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardToolbar doneText=\"Close\" />\n * ```\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = (props) => {\n const {\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 } = props;\n const colorScheme = useKeyboardState((state) => state.appearance);\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 !KEYBOARD_HAS_ROUNDED_CORNERS\n ? {\n paddingLeft: insets?.left,\n paddingRight: insets?.right,\n }\n : null,\n KEYBOARD_HAS_ROUNDED_CORNERS ? styles.floating : null,\n ],\n [colorScheme, opacity, theme, insets],\n );\n const containerStyle = useMemo(\n () => [\n KEYBOARD_HAS_ROUNDED_CORNERS\n ? {\n marginLeft: (insets?.left ?? 0) + 16,\n marginRight: (insets?.right ?? 0) + 16,\n }\n : null,\n ],\n [insets],\n );\n const offset = useMemo(\n () => ({\n closed: closed + KEYBOARD_TOOLBAR_HEIGHT,\n opened: opened + OPENED_OFFSET,\n }),\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\n enabled={enabled}\n offset={offset}\n style={containerStyle}\n >\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 floating: {\n alignSelf: \"center\",\n borderRadius: 20,\n overflow: \"hidden\",\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,gBAAgB,QAAQ,aAAa;AAC9C,SAASC,kBAAkB,QAAQ,cAAc;AACjD,OAAOC,kBAAkB,MAAM,uBAAuB;AAEtD,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,MAAM,QAAQ,UAAU;AACjC,SACEC,eAAe,EACfC,4BAA4B,EAC5BC,uBAAuB,EACvBC,aAAa,EACbC,wBAAwB,EACxBC,gCAAgC,EAChCC,6BAA6B,EAC7BC,6BAA6B,EAC7BC,iCAAiC,QAC5B,aAAa;AAyDpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAA+C,GAAIC,KAAK,IAAK;EACjE,MAAM;IACJC,OAAO;IACPC,KAAK,GAAGb,MAAM;IACdc,QAAQ,GAAG,MAAM;IACjBC,MAAM;IACNC,IAAI;IACJC,UAAU,GAAG,IAAI;IACjBC,cAAc;IACdC,cAAc;IACdC,cAAc;IACdC,IAAI,GAAG,IAAI;IACXC,OAAO,GAAGrB,eAAe;IACzBsB,MAAM,EAAE;MAAEC,MAAM,GAAG,CAAC;MAAEC,MAAM,GAAG;IAAE,CAAC,GAAG,CAAC,CAAC;IACvCC,OAAO,GAAG,IAAI;IACdC,MAAM;IACN,GAAGC;EACL,CAAC,GAAGjB,KAAK;EACT,MAAMkB,WAAW,GAAGlC,gBAAg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F,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["React","useEffect","useMemo","useState","StyleSheet","View","FocusedInputEvents","useKeyboardState","KeyboardStickyView","Arrow","Button","colors","Background","Content","Done","Next","Prev","ToolbarContext","DEFAULT_OPACITY","KEYBOARD_HAS_ROUNDED_CORNERS","KEYBOARD_TOOLBAR_HEIGHT","OPENED_OFFSET","TEST_ID_KEYBOARD_TOOLBAR","KeyboardToolbar","props","children","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","offset","closed","opened","enabled","insets","rest","colorScheme","state","appearance","inputs","setInputs","current","count","isPrevDisabled","isNextDisabled","buttonContainer","iconContainer","subscription","addListener","e","remove","toolbarStyle","styles","toolbar","backgroundColor","background","paddingLeft","left","paddingRight","right","floating","containerStyle","marginLeft","marginRight","backgroundElement","arrowsElement","contentContainer","doneElement","prevChild","nextChild","contentChild","doneChild","backgroundChild","Children","forEach","child","isValidElement","type","createElement","style","arrows","onPress","text","contextValue","Provider","value","_extends","testID","create","position","bottom","alignItems","width","flexDirection","height","alignSelf","borderRadius","overflow","DefaultKeyboardToolbarTheme"],"sources":["index.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, View } from \"react-native\";\n\nimport { FocusedInputEvents } from \"../../bindings\";\nimport { useKeyboardState } from \"../../hooks\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\nimport { Background, Content, Done, Next, Prev } from \"./compound/components\";\nimport { ToolbarContext } from \"./compound/context\";\nimport {\n DEFAULT_OPACITY,\n KEYBOARD_HAS_ROUNDED_CORNERS,\n KEYBOARD_TOOLBAR_HEIGHT,\n OPENED_OFFSET,\n TEST_ID_KEYBOARD_TOOLBAR,\n} from \"./constants\";\n\nimport type { KeyboardToolbarProps } from \"./types\";\nimport type { ReactNode } from \"react\";\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` buttons from left and\n * `Done` button from the right (to dismiss the keyboard). Allows to add customizable content (yours UI elements) in the middle.\n *\n * @param props - Component props.\n * @returns A component that is shown above the keyboard with `Prev`/`Next` and `Done` buttons.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-toolbar|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardToolbar>\n * <KeyboardToolbar.Done text=\"Close\" />\n * </KeyboardToolbar>\n * ```\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> & {\n Background: typeof Background;\n Content: typeof Content;\n Prev: typeof Prev;\n Next: typeof Next;\n Done: typeof Done;\n} = (props) => {\n const {\n children,\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 } = props;\n const colorScheme = useKeyboardState((state) => state.appearance);\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 const buttonContainer = button ?? Button;\n const iconContainer = icon ?? Arrow;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n !KEYBOARD_HAS_ROUNDED_CORNERS\n ? {\n paddingLeft: insets?.left,\n paddingRight: insets?.right,\n }\n : null,\n KEYBOARD_HAS_ROUNDED_CORNERS ? styles.floating : null,\n ],\n [colorScheme, opacity, theme, insets],\n );\n const containerStyle = useMemo(\n () => [\n KEYBOARD_HAS_ROUNDED_CORNERS\n ? {\n marginLeft: (insets?.left ?? 0) + 16,\n marginRight: (insets?.right ?? 0) + 16,\n }\n : null,\n ],\n [insets],\n );\n const offset = useMemo(\n () => ({\n closed: closed + KEYBOARD_TOOLBAR_HEIGHT,\n opened: opened + OPENED_OFFSET,\n }),\n [closed, opened],\n );\n\n let backgroundElement: ReactNode = null;\n let arrowsElement: ReactNode = null;\n let contentContainer: ReactNode = null;\n let doneElement: ReactNode = null;\n\n if (children) {\n let prevChild: ReactNode = null;\n let nextChild: ReactNode = null;\n let contentChild: ReactNode = null;\n let doneChild: ReactNode = null;\n let backgroundChild: ReactNode = null;\n\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) {\n return;\n }\n const type = child.type;\n\n if (type === Background) {\n backgroundChild = child;\n } else if (type === Content) {\n contentChild = child;\n } else if (type === Prev) {\n prevChild = child;\n } else if (type === Next) {\n nextChild = child;\n } else if (type === Done) {\n doneChild = child;\n }\n });\n\n backgroundElement = backgroundChild;\n doneElement = doneChild;\n arrowsElement =\n prevChild || nextChild ? (\n <View style={styles.arrows}>\n {prevChild}\n {nextChild}\n </View>\n ) : null;\n contentContainer = contentChild ?? <Content>{contentChild}</Content>;\n } else {\n backgroundElement = blur;\n arrowsElement = showArrows ? (\n <View style={styles.arrows}>\n <Prev\n button={buttonContainer}\n icon={iconContainer}\n onPress={onPrevCallback}\n />\n <Next\n button={buttonContainer}\n icon={iconContainer}\n onPress={onNextCallback}\n />\n </View>\n ) : null;\n contentContainer = <Content>{content}</Content>;\n doneElement = doneText ? (\n <Done button={buttonContainer} text={doneText} onPress={onDoneCallback} />\n ) : null;\n }\n\n const contextValue = useMemo(\n () => ({\n theme,\n isPrevDisabled,\n isNextDisabled,\n }),\n [theme, isPrevDisabled, isNextDisabled],\n );\n\n return (\n <ToolbarContext.Provider value={contextValue}>\n <KeyboardStickyView\n enabled={enabled}\n offset={offset}\n style={containerStyle}\n >\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {backgroundElement}\n {arrowsElement}\n {contentContainer}\n {doneElement}\n </View>\n </KeyboardStickyView>\n </ToolbarContext.Provider>\n );\n};\n\nconst styles = StyleSheet.create({\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 floating: {\n alignSelf: \"center\",\n borderRadius: 20,\n overflow: \"hidden\",\n },\n});\n\nKeyboardToolbar.Background = Background;\nKeyboardToolbar.Content = Content;\nKeyboardToolbar.Prev = Prev;\nKeyboardToolbar.Next = Next;\nKeyboardToolbar.Done = Done;\n\nexport { colors as DefaultKeyboardToolbarTheme, KeyboardToolbarProps };\nexport default KeyboardToolbar;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAC3D,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAE/C,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,gBAAgB,QAAQ,aAAa;AAC9C,OAAOC,kBAAkB,MAAM,uBAAuB;AAEtD,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,MAAM,QAAQ,UAAU;AACjC,SAASC,UAAU,EAAEC,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAEC,IAAI,QAAQ,uBAAuB;AAC7E,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SACEC,eAAe,EACfC,4BAA4B,EAC5BC,uBAAuB,EACvBC,aAAa,EACbC,wBAAwB,QACnB,aAAa;AAKpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAML,GAAIC,KAAK,IAAK;EACb,MAAM;IACJC,QAAQ;IACRC,OAAO;IACPC,KAAK,GAAGhB,MAAM;IACdiB,QAAQ,GAAG,MAAM;IACjBC,MAAM;IACNC,IAAI;IACJC,UAAU,GAAG,IA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U;AACvCW,eAAe,CAACV,OAAO,GAAGA,OAAO;AACjCU,eAAe,CAACP,IAAI,GAAGA,IAAI;AAC3BO,eAAe,CAACR,IAAI,GAAGA,IAAI;AAC3BQ,eAAe,CAACT,IAAI,GAAGA,IAAI;AAE3B,SAASH,MAAM,IAAI8F,2BAA2B;AAC9C,eAAelF,eAAe","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ColorValue } from \"react-native\";\n\ntype Theme = {\n /** Color for arrow when it's enabled */\n primary: ColorValue;\n /** Color for arrow when it's disabled */\n disabled: ColorValue;\n /** Keyboard toolbar background color */\n background: string;\n /** Color for ripple effect (on button touch) on Android */\n ripple: ColorValue;\n};\nexport type KeyboardToolbarTheme = {\n light: Theme;\n dark: Theme;\n};\ntype HexSymbol =\n | \"0\"\n | \"1\"\n | \"2\"\n | \"3\"\n | \"4\"\n | \"5\"\n | \"6\"\n | \"7\"\n | \"8\"\n | \"9\"\n | \"A\"\n | \"B\"\n | \"C\"\n | \"D\"\n | \"E\"\n | \"F\"\n | \"a\"\n | \"b\"\n | \"c\"\n | \"d\"\n | \"e\"\n | \"f\";\nexport type HEX = `${HexSymbol}${HexSymbol}`;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type Arrow from \"./Arrow\";\nimport type Button from \"./Button\";\nimport type { KeyboardStickyViewProps } from \"../KeyboardStickyView\";\nimport type { ReactNode } from \"react\";\nimport type {\n ColorValue,\n GestureResponderEvent,\n ViewProps,\n} from \"react-native\";\n\ntype Theme = {\n /** Color for arrow when it's enabled. */\n primary: ColorValue;\n /** Color for arrow when it's disabled. */\n disabled: ColorValue;\n /** Keyboard toolbar background color. */\n background: string;\n /** Color for ripple effect (on button touch) on Android. */\n ripple: ColorValue;\n};\nexport type KeyboardToolbarTheme = {\n light: Theme;\n dark: Theme;\n};\ntype HexSymbol =\n | \"0\"\n | \"1\"\n | \"2\"\n | \"3\"\n | \"4\"\n | \"5\"\n | \"6\"\n | \"7\"\n | \"8\"\n | \"9\"\n | \"A\"\n | \"B\"\n | \"C\"\n | \"D\"\n | \"E\"\n | \"F\"\n | \"a\"\n | \"b\"\n | \"c\"\n | \"d\"\n | \"e\"\n | \"f\";\nexport type HEX = `${HexSymbol}${HexSymbol}`;\n\ntype SafeAreaInsets = {\n left: number;\n right: number;\n};\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n /**\n * An element that is shown in the middle of the toolbar.\n *\n * @deprecated Use compound API with `<KeyboardToolbar.Content />` component instead.\n */\n content?: React.JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /**\n * Custom text for done button.\n *\n * @deprecated Use compound API with `<KeyboardToolbar.Done />` component and `text` prop instead.\n */\n doneText?: ReactNode;\n /**\n * Custom touchable component for toolbar (used for prev/next/done buttons).\n *\n * @deprecated Use `button` property for corresponding element instead:\n * ```tsx\n * <KeyboardToolbar>\n * <KeyboardToolbar.Prev button={MyCustomButton} />\n * </KeyboardToolbar>\n * ```.\n */\n button?: typeof Button;\n /**\n * Custom icon component used to display next/prev buttons.\n *\n * @deprecated Use `icon` property for corresponding element instead:\n * ```tsx\n * <KeyboardToolbar>\n * <KeyboardToolbar.Prev icon={MyCustomIcon} />\n * </KeyboardToolbar>\n * ```.\n */\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 * @deprecated Use compound API and conditional rendering for `<KeyboardToolbar.Next />` and `<KeyboardToolbar.Prev />`.\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 * @deprecated Use compound API with `<KeyboardToolbar.Next />` and `onPress` callback instead.\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 * @deprecated Use compound API with `<KeyboardToolbar.Prev />` and `onPress` callback instead.\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 * @deprecated Use compound API with `<KeyboardToolbar.Done />` and `onPress` callback instead.\n */\n onDoneCallback?: (event: GestureResponderEvent) => void;\n /**\n * A component that applies blur effect to the toolbar.\n *\n * @deprecated Use compound API and `<KeyboardToolbar.Effect />` instead.\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 /**\n * A object containing `left`/`right` properties. Used to specify proper container padding in landscape mode.\n */\n insets?: SafeAreaInsets;\n /** JSX children in case if compound API is used. */\n children?: ReactNode;\n} & Pick<KeyboardStickyViewProps, \"offset\" | \"enabled\">;\n"],"mappings":"","ignoreList":[]}
@@ -1,10 +1,10 @@
1
1
  import { useEffect, useState } from "react";
2
2
  import { Dimensions } from "react-native";
3
3
  import { WindowDimensionsEvents } from "../../bindings";
4
- const screen = Dimensions.get("screen");
4
+ const window = Dimensions.get("window");
5
5
  let initialDimensions = {
6
- width: screen.width,
7
- height: screen.height
6
+ width: window.width,
7
+ height: window.height
8
8
  };
9
9
  WindowDimensionsEvents.addListener("windowDidResize", e => {
10
10
  initialDimensions = e;
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useState","Dimensions","WindowDimensionsEvents","screen","get","initialDimensions","width","height","addListener","e","useWindowDimensions","dimensions","setDimensions","subscription","remove"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { Dimensions } from \"react-native\";\n\nimport { WindowDimensionsEvents } from \"../../bindings\";\n\nimport type { WindowDimensionsEventData } from \"../../types\";\n\nconst screen = Dimensions.get(\"screen\");\n\nlet initialDimensions: WindowDimensionsEventData = {\n width: screen.width,\n height: screen.height,\n};\n\nWindowDimensionsEvents.addListener(\"windowDidResize\", (e) => {\n initialDimensions = e;\n});\n\nexport const useWindowDimensions = () => {\n const [dimensions, setDimensions] = useState(initialDimensions);\n\n useEffect(() => {\n const subscription = WindowDimensionsEvents.addListener(\n \"windowDidResize\",\n (e) => {\n setDimensions(e);\n },\n );\n\n // we might have missed an update between reading a value in render and\n // `addListener` in this handler, so we set it here. If there was\n // no change, React will filter out this update as a no-op.\n setDimensions(initialDimensions);\n\n return () => {\n subscription.remove();\n };\n }, []);\n\n return dimensions;\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,UAAU,QAAQ,cAAc;AAEzC,SAASC,sBAAsB,QAAQ,gBAAgB;AAIvD,MAAMC,MAAM,GAAGF,UAAU,CAACG,GAAG,CAAC,QAAQ,CAAC;AAEvC,IAAIC,iBAA4C,GAAG;EACjDC,KAAK,EAAEH,MAAM,CAACG,KAAK;EACnBC,MAAM,EAAEJ,MAAM,CAACI;AACjB,CAAC;AAEDL,sBAAsB,CAACM,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EAC3DJ,iBAAiB,GAAGI,CAAC;AACvB,CAAC,CAAC;AAEF,OAAO,MAAMC,mBAAmB,GAAGA,CAAA,KAAM;EACvC,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGZ,QAAQ,CAACK,iBAAiB,CAAC;EAE/DN,SAAS,CAAC,MAAM;IACd,MAAMc,YAAY,GAAGX,sBAAsB,CAACM,WAAW,CACrD,iBAAiB,EAChBC,CAAC,IAAK;MACLG,aAAa,CAACH,CAAC,CAAC;IAClB,CACF,CAAC;;IAED;IACA;IACA;IACAG,aAAa,CAACP,iBAAiB,CAAC;IAEhC,OAAO,MAAM;MACXQ,YAAY,CAACC,MAAM,CAAC,CAAC;IACvB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOH,UAAU;AACnB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useEffect","useState","Dimensions","WindowDimensionsEvents","window","get","initialDimensions","width","height","addListener","e","useWindowDimensions","dimensions","setDimensions","subscription","remove"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { Dimensions } from \"react-native\";\n\nimport { WindowDimensionsEvents } from \"../../bindings\";\n\nimport type { WindowDimensionsEventData } from \"../../types\";\n\nconst window = Dimensions.get(\"window\");\n\nlet initialDimensions: WindowDimensionsEventData = {\n width: window.width,\n height: window.height,\n};\n\nWindowDimensionsEvents.addListener(\"windowDidResize\", (e) => {\n initialDimensions = e;\n});\n\nexport const useWindowDimensions = () => {\n const [dimensions, setDimensions] = useState(initialDimensions);\n\n useEffect(() => {\n const subscription = WindowDimensionsEvents.addListener(\n \"windowDidResize\",\n (e) => {\n setDimensions(e);\n },\n );\n\n // we might have missed an update between reading a value in render and\n // `addListener` in this handler, so we set it here. If there was\n // no change, React will filter out this update as a no-op.\n setDimensions(initialDimensions);\n\n return () => {\n subscription.remove();\n };\n }, []);\n\n return dimensions;\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,UAAU,QAAQ,cAAc;AAEzC,SAASC,sBAAsB,QAAQ,gBAAgB;AAIvD,MAAMC,MAAM,GAAGF,UAAU,CAACG,GAAG,CAAC,QAAQ,CAAC;AAEvC,IAAIC,iBAA4C,GAAG;EACjDC,KAAK,EAAEH,MAAM,CAACG,KAAK;EACnBC,MAAM,EAAEJ,MAAM,CAACI;AACjB,CAAC;AAEDL,sBAAsB,CAACM,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EAC3DJ,iBAAiB,GAAGI,CAAC;AACvB,CAAC,CAAC;AAEF,OAAO,MAAMC,mBAAmB,GAAGA,CAAA,KAAM;EACvC,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGZ,QAAQ,CAACK,iBAAiB,CAAC;EAE/DN,SAAS,CAAC,MAAM;IACd,MAAMc,YAAY,GAAGX,sBAAsB,CAACM,WAAW,CACrD,iBAAiB,EAChBC,CAAC,IAAK;MACLG,aAAa,CAACH,CAAC,CAAC;IAClB,CACF,CAAC;;IAED;IACA;IACA;IACAG,aAAa,CAACP,iBAAiB,CAAC;IAEhC,OAAO,MAAM;MACXQ,YAAY,CAACC,MAAM,CAAC,CAAC;IACvB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOH,UAAU;AACnB,CAAC","ignoreList":[]}
@@ -18,6 +18,7 @@ KeyboardEvents.addListener("keyboardDidShow", e => {
18
18
  });
19
19
  const dismiss = async options => {
20
20
  const keepFocus = (options === null || options === void 0 ? void 0 : options.keepFocus) ?? false;
21
+ const animated = (options === null || options === void 0 ? void 0 : options.animated) ?? true;
21
22
  return new Promise(resolve => {
22
23
  if (isClosed) {
23
24
  resolve();
@@ -27,7 +28,7 @@ const dismiss = async options => {
27
28
  resolve(undefined);
28
29
  subscription.remove();
29
30
  });
30
- KeyboardControllerNative.dismiss(keepFocus);
31
+ KeyboardControllerNative.dismiss(keepFocus, animated);
31
32
  });
32
33
  };
33
34
  const isVisible = () => !isClosed;
@@ -1 +1 @@
1
- {"version":3,"names":["KeyboardControllerNative","KeyboardEvents","isClosed","lastState","height","duration","timestamp","Date","getTime","target","type","appearance","addListener","e","dismiss","options","keepFocus","Promise","resolve","subscription","undefined","remove","isVisible","state","KeyboardController","setDefaultMode","setInputMode","setFocusTo","preload"],"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 lastState: KeyboardEventData = {\n height: 0,\n duration: 0,\n timestamp: new Date().getTime(),\n target: -1,\n type: \"default\",\n appearance: \"light\",\n};\n\nKeyboardEvents.addListener(\"keyboardDidHide\", (e) => {\n isClosed = true;\n lastState = e;\n});\n\nKeyboardEvents.addListener(\"keyboardDidShow\", (e) => {\n isClosed = false;\n lastState = 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 = () => lastState;\n\n/**\n * KeyboardController module. Helps to perform imperative actions/checks with keyboard.\n */\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: KeyboardControllerNative.setDefaultMode,\n setInputMode: KeyboardControllerNative.setInputMode,\n setFocusTo: KeyboardControllerNative.setFocusTo,\n preload: KeyboardControllerNative.preload,\n dismiss,\n isVisible,\n state,\n};\n"],"mappings":"AAAA,SAASA,wBAAwB,EAAEC,cAAc,QAAQ,YAAY;AAQrE,IAAIC,QAAQ,GAAG,IAAI;AACnB,IAAIC,SAA4B,GAAG;EACjCC,MAAM,EAAE,CAAC;EACTC,QAAQ,EAAE,CAAC;EACXC,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;EAC/BC,MAAM,EAAE,CAAC,CAAC;EACVC,IAAI,EAAE,SAAS;EACfC,UAAU,EAAE;AACd,CAAC;AAEDV,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDX,QAAQ,GAAG,IAAI;EACfC,SAAS,GAAGU,CAAC;AACf,CAAC,CAAC;AAEFZ,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDX,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAGU,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,IAAIhB,QAAQ,EAAE;MACZgB,OAAO,CAAC,CAAC;MAET;IACF;IAEA,MAAMC,YAAY,GAAGlB,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAE,MAAM;MACvEM,OAAO,CAACE,SAAS,CAAC;MAClBD,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFrB,wBAAwB,CAACc,OAAO,CAACE,SAAS,CAAC;EAC7C,CAAC,CAAC;AACJ,CAAC;AACD,MAAMM,SAAS,GAAGA,CAAA,KAAM,CAACpB,QAAQ;AACjC,MAAMqB,KAAK,GAAGA,CAAA,KAAMpB,SAAS;;AAE7B;AACA;AACA;AACA,OAAO,MAAMqB,kBAA4C,GAAG;EAC1DC,cAAc,EAAEzB,wBAAwB,CAACyB,cAAc;EACvDC,YAAY,EAAE1B,wBAAwB,CAAC0B,YAAY;EACnDC,UAAU,EAAE3B,wBAAwB,CAAC2B,UAAU;EAC/CC,OAAO,EAAE5B,wBAAwB,CAAC4B,OAAO;EACzCd,OAAO;EACPQ,SAAS;EACTC;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["KeyboardControllerNative","KeyboardEvents","isClosed","lastState","height","duration","timestamp","Date","getTime","target","type","appearance","addListener","e","dismiss","options","keepFocus","animated","Promise","resolve","subscription","undefined","remove","isVisible","state","KeyboardController","setDefaultMode","setInputMode","setFocusTo","preload"],"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 lastState: KeyboardEventData = {\n height: 0,\n duration: 0,\n timestamp: new Date().getTime(),\n target: -1,\n type: \"default\",\n appearance: \"light\",\n};\n\nKeyboardEvents.addListener(\"keyboardDidHide\", (e) => {\n isClosed = true;\n lastState = e;\n});\n\nKeyboardEvents.addListener(\"keyboardDidShow\", (e) => {\n isClosed = false;\n lastState = e;\n});\n\nconst dismiss = async (options?: Partial<DismissOptions>): Promise<void> => {\n const keepFocus = options?.keepFocus ?? false;\n const animated = options?.animated ?? true;\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, animated);\n });\n};\nconst isVisible = () => !isClosed;\nconst state = () => lastState;\n\n/**\n * KeyboardController module. Helps to perform imperative actions/checks with keyboard.\n */\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: KeyboardControllerNative.setDefaultMode,\n setInputMode: KeyboardControllerNative.setInputMode,\n setFocusTo: KeyboardControllerNative.setFocusTo,\n preload: KeyboardControllerNative.preload,\n dismiss,\n isVisible,\n state,\n};\n"],"mappings":"AAAA,SAASA,wBAAwB,EAAEC,cAAc,QAAQ,YAAY;AAQrE,IAAIC,QAAQ,GAAG,IAAI;AACnB,IAAIC,SAA4B,GAAG;EACjCC,MAAM,EAAE,CAAC;EACTC,QAAQ,EAAE,CAAC;EACXC,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;EAC/BC,MAAM,EAAE,CAAC,CAAC;EACVC,IAAI,EAAE,SAAS;EACfC,UAAU,EAAE;AACd,CAAC;AAEDV,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDX,QAAQ,GAAG,IAAI;EACfC,SAAS,GAAGU,CAAC;AACf,CAAC,CAAC;AAEFZ,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDX,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAGU,CAAC;AACf,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,MAAOC,OAAiC,IAAoB;EAC1E,MAAMC,SAAS,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,SAAS,KAAI,KAAK;EAC7C,MAAMC,QAAQ,GAAG,CAAAF,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,QAAQ,KAAI,IAAI;EAE1C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,IAAIjB,QAAQ,EAAE;MACZiB,OAAO,CAAC,CAAC;MAET;IACF;IAEA,MAAMC,YAAY,GAAGnB,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAE,MAAM;MACvEO,OAAO,CAACE,SAAS,CAAC;MAClBD,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFtB,wBAAwB,CAACc,OAAO,CAACE,SAAS,EAAEC,QAAQ,CAAC;EACvD,CAAC,CAAC;AACJ,CAAC;AACD,MAAMM,SAAS,GAAGA,CAAA,KAAM,CAACrB,QAAQ;AACjC,MAAMsB,KAAK,GAAGA,CAAA,KAAMrB,SAAS;;AAE7B;AACA;AACA;AACA,OAAO,MAAMsB,kBAA4C,GAAG;EAC1DC,cAAc,EAAE1B,wBAAwB,CAAC0B,cAAc;EACvDC,YAAY,EAAE3B,wBAAwB,CAAC2B,YAAY;EACnDC,UAAU,EAAE5B,wBAAwB,CAAC4B,UAAU;EAC/CC,OAAO,EAAE7B,wBAAwB,CAAC6B,OAAO;EACzCf,OAAO;EACPS,SAAS;EACTC;AACF,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeKeyboardController.ts"],"sourcesContent":["import { TurboModuleRegistry } from \"react-native\";\n\nimport type { TurboModule } from \"react-native\";\n\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n // methods\n setInputMode(mode: number): void;\n setDefaultMode(): void;\n preload(): void;\n dismiss(keepFocus: boolean): void;\n setFocusTo(direction: string): void;\n\n // event emitter\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n\nexport default TurboModuleRegistry.get<Spec>(\"KeyboardController\");\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAmBlD,eAAeA,mBAAmB,CAACC,GAAG,CAAO,oBAAoB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeKeyboardController.ts"],"sourcesContent":["import { TurboModuleRegistry } from \"react-native\";\n\nimport type { TurboModule } from \"react-native\";\n\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n // methods\n setInputMode(mode: number): void;\n setDefaultMode(): void;\n preload(): void;\n dismiss(keepFocus: boolean, animated: boolean): void;\n setFocusTo(direction: string): void;\n\n // event emitter\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n\nexport default TurboModuleRegistry.get<Spec>(\"KeyboardController\");\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAmBlD,eAAeA,mBAAmB,CAACC,GAAG,CAAO,oBAAoB,CAAC","ignoreList":[]}