react-native-keyboard-controller 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/android/gradle.properties +1 -1
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +5 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputLayoutChangedEvent.kt +41 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +9 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/View.kt +7 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputLayoutObserver.kt +93 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/{KeyboardAnimationCallback.kt → listeners/KeyboardAnimationCallback.kt} +86 -55
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +6 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +120 -50
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +5 -0
- package/ios/Extensions.swift +7 -0
- package/ios/KeyboardController.xcodeproj/project.pbxproj +41 -7
- package/ios/events/FocusedInputLayoutChangedEvent.h +16 -0
- package/ios/events/FocusedInputLayoutChangedEvent.m +75 -0
- package/ios/observers/FocusedInputLayoutObserver.swift +136 -0
- package/ios/{KeyboardControllerView.mm → views/KeyboardControllerView.mm} +54 -3
- package/ios/{KeyboardControllerViewManager.mm → views/KeyboardControllerViewManager.mm} +7 -0
- package/ios/{KeyboardControllerViewManager.swift → views/KeyboardControllerViewManager.swift} +25 -1
- package/jest/index.js +16 -0
- package/lib/commonjs/animated.js +34 -6
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +9 -1
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +7 -4
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardStickyView/index.js +44 -0
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -0
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/context.js +9 -4
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks.js +16 -1
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/index.js +8 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/monkey-patch.android.js +32 -20
- package/lib/commonjs/monkey-patch.android.js.map +1 -1
- package/lib/commonjs/monkey-patch.js +11 -1
- package/lib/commonjs/monkey-patch.js.map +1 -1
- package/lib/commonjs/reanimated.js +5 -2
- package/lib/commonjs/reanimated.js.map +1 -1
- package/lib/commonjs/reanimated.native.js +18 -1
- package/lib/commonjs/reanimated.native.js.map +1 -1
- package/lib/commonjs/replicas.js +1 -1
- package/lib/commonjs/replicas.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/animated.js +37 -9
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +1 -1
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/hooks.js +9 -1
- package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +9 -6
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardStickyView/index.js +35 -0
- package/lib/module/components/KeyboardStickyView/index.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/constants.js.map +1 -1
- package/lib/module/context.js +9 -4
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks.js +14 -1
- package/lib/module/hooks.js.map +1 -1
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js.map +1 -1
- package/lib/module/monkey-patch.android.js +26 -20
- package/lib/module/monkey-patch.android.js.map +1 -1
- package/lib/module/monkey-patch.js +3 -0
- package/lib/module/monkey-patch.js.map +1 -1
- package/lib/module/reanimated.js +3 -1
- package/lib/module/reanimated.js.map +1 -1
- package/lib/module/reanimated.native.js +16 -0
- package/lib/module/reanimated.native.js.map +1 -1
- package/lib/module/replicas.js +2 -2
- package/lib/module/replicas.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/module/specs/NativeKeyboardController.js.map +1 -1
- package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/animated.d.ts +8 -1
- package/lib/typescript/components/KeyboardAvoidingView/hooks.d.ts +1 -0
- package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +2 -1
- package/lib/typescript/components/KeyboardStickyView/index.d.ts +20 -0
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/context.d.ts +6 -3
- package/lib/typescript/hooks.d.ts +9 -2
- package/lib/typescript/index.d.ts +1 -2
- package/lib/typescript/internal.d.ts +1 -1
- package/lib/typescript/monkey-patch.android.d.ts +2 -1
- package/lib/typescript/monkey-patch.d.ts +2 -0
- package/lib/typescript/reanimated.d.ts +2 -1
- package/lib/typescript/reanimated.native.d.ts +2 -1
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +13 -0
- package/lib/typescript/types.d.ts +17 -0
- package/package.json +9 -28
- package/src/animated.tsx +53 -9
- package/src/bindings.native.ts +1 -1
- package/src/bindings.ts +3 -1
- package/src/components/KeyboardAvoidingView/hooks.ts +9 -1
- package/src/components/KeyboardAvoidingView/index.tsx +15 -13
- package/src/components/KeyboardStickyView/index.tsx +63 -0
- package/src/components/index.ts +1 -0
- package/src/constants.ts +2 -0
- package/src/context.ts +16 -5
- package/src/hooks.ts +16 -6
- package/src/index.ts +1 -3
- package/src/internal.ts +3 -1
- package/src/monkey-patch.android.ts +27 -21
- package/src/monkey-patch.ts +3 -0
- package/src/reanimated.native.ts +30 -1
- package/src/reanimated.ts +13 -2
- package/src/replicas.ts +2 -2
- package/src/specs/KeyboardControllerViewNativeComponent.ts +16 -1
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +2 -1
- package/src/specs/NativeKeyboardController.ts +2 -1
- package/src/specs/NativeStatusBarManagerCompat.ts +2 -1
- package/src/types.ts +28 -1
- /package/ios/{KeyboardMoveEvent.h → events/KeyboardMoveEvent.h} +0 -0
- /package/ios/{KeyboardMoveEvent.m → events/KeyboardMoveEvent.m} +0 -0
- /package/ios/{KeyboardMovementObserver.swift → observers/KeyboardMovementObserver.swift} +0 -0
- /package/ios/{KeyboardControllerView.h → views/KeyboardControllerView.h} +0 -0
package/lib/module/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","
|
|
1
|
+
{"version":3,"names":["useEffect","KeyboardController","AndroidSoftInputModes","useKeyboardContext","uuid","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","key","setHandlers","undefined","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout"],"sources":["hooks.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { KeyboardController } from './bindings';\nimport { AndroidSoftInputModes } from './constants';\nimport { useKeyboardContext } from './context';\nimport { uuid } from './utils';\n\nimport type { AnimatedContext, ReanimatedContext } from './context';\nimport type { KeyboardHandler } from './types';\nimport type { DependencyList } from 'react';\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.reanimated;\n};\n\nexport function useGenericKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList\n) {\n const context = useKeyboardContext();\n\n useEffect(() => {\n const key = uuid();\n\n context.setHandlers({ [key]: handler });\n\n return () => {\n context.setHandlers({ [key]: undefined });\n };\n }, deps);\n}\n\nexport function useKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList\n) {\n useResizeMode();\n useGenericKeyboardHandler(handler, deps);\n}\n\nexport function useKeyboardController() {\n const context = useKeyboardContext();\n\n return { setEnabled: context.setEnabled, enabled: context.enabled };\n}\n\nexport function useReanimatedFocusedInput() {\n const context = useKeyboardContext();\n\n return { input: context.layout };\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,SAASC,qBAAqB,QAAQ,aAAa;AACnD,SAASC,kBAAkB,QAAQ,WAAW;AAC9C,SAASC,IAAI,QAAQ,SAAS;AAM9B,OAAO,MAAMC,aAAa,GAAG,MAAM;EACjCL,SAAS,CAAC,MAAM;IACdC,kBAAkB,CAACK,YAAY,CAC7BJ,qBAAqB,CAACK,wBAAwB,CAC/C;IAED,OAAO,MAAMN,kBAAkB,CAACO,cAAc,EAAE;EAClD,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;AAED,OAAO,MAAMC,oBAAoB,GAAG,MAAuB;EACzDJ,aAAa,EAAE;EACf,MAAMK,OAAO,GAAGP,kBAAkB,EAAE;EAEpC,OAAOO,OAAO,CAACC,QAAQ;AACzB,CAAC;AAED,OAAO,MAAMC,8BAA8B,GAAG,MAAyB;EACrEP,aAAa,EAAE;EACf,MAAMK,OAAO,GAAGP,kBAAkB,EAAE;EAEpC,OAAOO,OAAO,CAACG,UAAU;AAC3B,CAAC;AAED,OAAO,SAASC,yBAAyB,CACvCC,OAAwB,EACxBC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,EAAE;EAEpCH,SAAS,CAAC,MAAM;IACd,MAAMiB,GAAG,GAAGb,IAAI,EAAE;IAElBM,OAAO,CAACQ,WAAW,CAAC;MAAE,CAACD,GAAG,GAAGF;IAAQ,CAAC,CAAC;IAEvC,OAAO,MAAM;MACXL,OAAO,CAACQ,WAAW,CAAC;QAAE,CAACD,GAAG,GAAGE;MAAU,CAAC,CAAC;IAC3C,CAAC;EACH,CAAC,EAAEH,IAAI,CAAC;AACV;AAEA,OAAO,SAASI,kBAAkB,CAChCL,OAAwB,EACxBC,IAAqB,EACrB;EACAX,aAAa,EAAE;EACfS,yBAAyB,CAACC,OAAO,EAAEC,IAAI,CAAC;AAC1C;AAEA,OAAO,SAASK,qBAAqB,GAAG;EACtC,MAAMX,OAAO,GAAGP,kBAAkB,EAAE;EAEpC,OAAO;IAAEmB,UAAU,EAAEZ,OAAO,CAACY,UAAU;IAAEC,OAAO,EAAEb,OAAO,CAACa;EAAQ,CAAC;AACrE;AAEA,OAAO,SAASC,yBAAyB,GAAG;EAC1C,MAAMd,OAAO,GAAGP,kBAAkB,EAAE;EAEpC,OAAO;IAAEsB,KAAK,EAAEf,OAAO,CAACgB;EAAO,CAAC;AAClC"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import './monkey-patch';
|
|
2
1
|
export * from './bindings';
|
|
3
2
|
export * from './animated';
|
|
4
3
|
export * from './replicas';
|
|
@@ -6,5 +5,5 @@ export * from './context';
|
|
|
6
5
|
export * from './hooks';
|
|
7
6
|
export * from './constants';
|
|
8
7
|
export * from './types';
|
|
9
|
-
export { KeyboardAvoidingView } from './components';
|
|
8
|
+
export { KeyboardAvoidingView, KeyboardStickyView } from './components';
|
|
10
9
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardAvoidingView"],"sources":["index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":["KeyboardAvoidingView","KeyboardStickyView"],"sources":["index.ts"],"sourcesContent":["export * from './bindings';\nexport * from './animated';\nexport * from './replicas';\nexport * from './context';\nexport * from './hooks';\nexport * from './constants';\nexport * from './types';\n\nexport { KeyboardAvoidingView, KeyboardStickyView } from './components';\n"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,SAAS;AAEvB,SAASA,oBAAoB,EAAEC,kBAAkB,QAAQ,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useRef","Animated","useSharedValue","useSharedHandlers","handlers","jsHandlers","updateSharedHandlers","value","current","setHandlers","handler","broadcast","type","event","Object","keys","forEach","key","useAnimatedValue","initialValue","config","ref","Value"],"sources":["internal.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport { useSharedValue } from 'react-native-reanimated';\n\nimport type { Handlers, NativeEvent } from './types';\n\n/**\n * Hook for storing worklet handlers (objects with keys, where values are worklets).\n * Returns methods for setting handlers and broadcasting events in them.\n *\n * T is a generic that looks like:\n * @example\n * {\n * onEvent: () => {},\n * onEvent2: () => {},\n * }\n */\nexport function useSharedHandlers
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","Animated","useSharedValue","useSharedHandlers","handlers","jsHandlers","updateSharedHandlers","value","current","setHandlers","handler","broadcast","type","event","Object","keys","forEach","key","useAnimatedValue","initialValue","config","ref","Value"],"sources":["internal.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport { useSharedValue } from 'react-native-reanimated';\n\nimport type { Handlers, NativeEvent } from './types';\n\n/**\n * Hook for storing worklet handlers (objects with keys, where values are worklets).\n * Returns methods for setting handlers and broadcasting events in them.\n *\n * T is a generic that looks like:\n * @example\n * {\n * onEvent: () => {},\n * onEvent2: () => {},\n * }\n */\nexport function useSharedHandlers<\n T extends Record<string, (event: NativeEvent) => void>\n>() {\n const handlers = useSharedValue<Handlers<T>>({});\n const jsHandlers = useRef<Handlers<T>>({});\n\n // since js -> worklet -> js call is asynchronous, we can not write handlers\n // straight into shared variable (using current shared value as a previous result),\n // since there may be a race condition in a call, and closure may have out-of-dated\n // values. As a result, some of handlers may be not written to \"all handlers\" object.\n // Below we are writing all handlers to `ref` and afterwards synchronize them with\n // shared value (since `refs` are not referring to actual value in worklets).\n // This approach allow us to update synchronously handlers in js thread (and it assures,\n // that it will have all of them) and then update them in worklet thread (calls are\n // happening in FIFO order, so we will always have actual value).\n const updateSharedHandlers = () => {\n handlers.value = jsHandlers.current;\n };\n const setHandlers = useCallback((handler: Handlers<T>) => {\n jsHandlers.current = {\n ...jsHandlers.current,\n ...handler,\n };\n updateSharedHandlers();\n }, []);\n const broadcast = (type: keyof T, event: NativeEvent) => {\n 'worklet';\n\n Object.keys(handlers.value).forEach((key) =>\n handlers.value[key]?.[type]?.(event)\n );\n };\n\n return { setHandlers, broadcast };\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current == null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAC3C,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,cAAc,QAAQ,yBAAyB;AAIxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiB,GAE7B;EACF,MAAMC,QAAQ,GAAGF,cAAc,CAAc,CAAC,CAAC,CAAC;EAChD,MAAMG,UAAU,GAAGL,MAAM,CAAc,CAAC,CAAC,CAAC;;EAE1C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAMM,oBAAoB,GAAG,MAAM;IACjCF,QAAQ,CAACG,KAAK,GAAGF,UAAU,CAACG,OAAO;EACrC,CAAC;EACD,MAAMC,WAAW,GAAGV,WAAW,CAAEW,OAAoB,IAAK;IACxDL,UAAU,CAACG,OAAO,GAAG;MACnB,GAAGH,UAAU,CAACG,OAAO;MACrB,GAAGE;IACL,CAAC;IACDJ,oBAAoB,EAAE;EACxB,CAAC,EAAE,EAAE,CAAC;EACN,MAAMK,SAAS,GAAG,CAACC,IAAa,EAAEC,KAAkB,KAAK;IACvD,SAAS;;IAETC,MAAM,CAACC,IAAI,CAACX,QAAQ,CAACG,KAAK,CAAC,CAACS,OAAO,CAAEC,GAAG;MAAA;MAAA,8BACtCb,QAAQ,CAACG,KAAK,CAACU,GAAG,CAAC,iFAAnB,oBAAsBL,IAAI,CAAC,0DAA3B,gDAA8BC,KAAK,CAAC;IAAA,EACrC;EACH,CAAC;EAED,OAAO;IAAEJ,WAAW;IAAEE;EAAU,CAAC;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,gBAAgB,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAGrB,MAAM,CAAwB,IAAI,CAAC;EAE/C,IAAIqB,GAAG,CAACb,OAAO,IAAI,IAAI,EAAE;IACvBa,GAAG,CAACb,OAAO,GAAG,IAAIP,QAAQ,CAACqB,KAAK,CAACH,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAACb,OAAO;AACpB"}
|
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
// @ts-expect-error because there is no corresponding type definition
|
|
2
2
|
import * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';
|
|
3
|
+
const DefaultNativeAndroidManager = NativeAndroidManager.default;
|
|
3
4
|
const getConstants = NativeAndroidManager.default.getConstants;
|
|
5
|
+
const RCTStatusBarManagerCompat = require('./specs/NativeStatusBarManagerCompat').default;
|
|
4
6
|
|
|
5
7
|
// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
|
|
6
8
|
// in order to use library on all available platforms we have to monkey patch
|
|
7
9
|
// default RN implementation and use modern `WindowInsetsControllerCompat`.
|
|
8
|
-
const
|
|
9
|
-
NativeAndroidManager.default = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
export const applyMonkeyPatch = () => {
|
|
11
|
+
NativeAndroidManager.default = {
|
|
12
|
+
getConstants,
|
|
13
|
+
setColor(color, animated) {
|
|
14
|
+
RCTStatusBarManagerCompat.setColor(color, animated);
|
|
15
|
+
},
|
|
16
|
+
setTranslucent(translucent) {
|
|
17
|
+
RCTStatusBarManagerCompat.setTranslucent(translucent);
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* - statusBarStyles can be:
|
|
21
|
+
* - 'default'
|
|
22
|
+
* - 'dark-content'
|
|
23
|
+
*/
|
|
24
|
+
setStyle(statusBarStyle) {
|
|
25
|
+
RCTStatusBarManagerCompat.setStyle(statusBarStyle);
|
|
26
|
+
},
|
|
27
|
+
setHidden(hidden) {
|
|
28
|
+
RCTStatusBarManagerCompat.setHidden(hidden);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export const revertMonkeyPatch = () => {
|
|
33
|
+
NativeAndroidManager.default = DefaultNativeAndroidManager;
|
|
28
34
|
};
|
|
29
35
|
//# sourceMappingURL=monkey-patch.android.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeAndroidManager","
|
|
1
|
+
{"version":3,"names":["NativeAndroidManager","DefaultNativeAndroidManager","default","getConstants","RCTStatusBarManagerCompat","require","applyMonkeyPatch","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden","revertMonkeyPatch"],"sources":["monkey-patch.android.ts"],"sourcesContent":["// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';\n\nconst DefaultNativeAndroidManager = NativeAndroidManager.default;\nconst getConstants = NativeAndroidManager.default.getConstants;\nconst RCTStatusBarManagerCompat =\n require('./specs/NativeStatusBarManagerCompat').default;\n\n// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so\n// in order to use library on all available platforms we have to monkey patch\n// default RN implementation and use modern `WindowInsetsControllerCompat`.\nexport const applyMonkeyPatch = () => {\n NativeAndroidManager.default = {\n getConstants,\n setColor(color: number, animated: boolean): void {\n RCTStatusBarManagerCompat.setColor(color, animated);\n },\n\n setTranslucent(translucent: boolean): void {\n RCTStatusBarManagerCompat.setTranslucent(translucent);\n },\n\n /**\n * - statusBarStyles can be:\n * - 'default'\n * - 'dark-content'\n */\n setStyle(statusBarStyle?: string): void {\n RCTStatusBarManagerCompat.setStyle(statusBarStyle);\n },\n\n setHidden(hidden: boolean): void {\n RCTStatusBarManagerCompat.setHidden(hidden);\n },\n };\n};\nexport const revertMonkeyPatch = () => {\n NativeAndroidManager.default = DefaultNativeAndroidManager;\n};\n"],"mappings":"AAAA;AACA,OAAO,KAAKA,oBAAoB,MAAM,2EAA2E;AAEjH,MAAMC,2BAA2B,GAAGD,oBAAoB,CAACE,OAAO;AAChE,MAAMC,YAAY,GAAGH,oBAAoB,CAACE,OAAO,CAACC,YAAY;AAC9D,MAAMC,yBAAyB,GAC7BC,OAAO,CAAC,sCAAsC,CAAC,CAACH,OAAO;;AAEzD;AACA;AACA;AACA,OAAO,MAAMI,gBAAgB,GAAG,MAAM;EACpCN,oBAAoB,CAACE,OAAO,GAAG;IAC7BC,YAAY;IACZI,QAAQ,CAACC,KAAa,EAAEC,QAAiB,EAAQ;MAC/CL,yBAAyB,CAACG,QAAQ,CAACC,KAAK,EAAEC,QAAQ,CAAC;IACrD,CAAC;IAEDC,cAAc,CAACC,WAAoB,EAAQ;MACzCP,yBAAyB,CAACM,cAAc,CAACC,WAAW,CAAC;IACvD,CAAC;IAED;AACJ;AACA;AACA;AACA;IACIC,QAAQ,CAACC,cAAuB,EAAQ;MACtCT,yBAAyB,CAACQ,QAAQ,CAACC,cAAc,CAAC;IACpD,CAAC;IAEDC,SAAS,CAACC,MAAe,EAAQ;MAC/BX,yBAAyB,CAACU,SAAS,CAACC,MAAM,CAAC;IAC7C;EACF,CAAC;AACH,CAAC;AACD,OAAO,MAAMC,iBAAiB,GAAG,MAAM;EACrChB,oBAAoB,CAACE,OAAO,GAAGD,2BAA2B;AAC5D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["monkey-patch.ts"],"sourcesContent":["// stub for all platforms\n"],"mappings":"AAAA"}
|
|
1
|
+
{"version":3,"names":["NOOP","applyMonkeyPatch","revertMonkeyPatch"],"sources":["monkey-patch.ts"],"sourcesContent":["// stub for all platforms\nconst NOOP = () => {};\nexport const applyMonkeyPatch = NOOP;\nexport const revertMonkeyPatch = NOOP;\n"],"mappings":"AAAA;AACA,MAAMA,IAAI,GAAG,MAAM,CAAC,CAAC;AACrB,OAAO,MAAMC,gBAAgB,GAAGD,IAAI;AACpC,OAAO,MAAME,iBAAiB,GAAGF,IAAI"}
|
package/lib/module/reanimated.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useAnimatedKeyboardHandler"],"sources":["reanimated.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":["NOOP","useAnimatedKeyboardHandler","useFocusedInputHandler"],"sources":["reanimated.ts"],"sourcesContent":["import type {\n EventWithName,\n FocusedInputHandlerHook,\n FocusedInputLayoutChangedEvent,\n KeyboardHandlerHook,\n NativeEvent,\n} from './types';\n\nconst NOOP = () => () => {};\nexport const useAnimatedKeyboardHandler: KeyboardHandlerHook<\n Record<string, unknown>,\n EventWithName<NativeEvent>\n> = NOOP;\nexport const useFocusedInputHandler: FocusedInputHandlerHook<\n Record<string, unknown>,\n EventWithName<FocusedInputLayoutChangedEvent>\n> = NOOP;\n"],"mappings":"AAQA,MAAMA,IAAI,GAAG,MAAM,MAAM,CAAC,CAAC;AAC3B,OAAO,MAAMC,0BAGZ,GAAGD,IAAI;AACR,OAAO,MAAME,sBAGZ,GAAGF,IAAI"}
|
|
@@ -27,4 +27,20 @@ export const useAnimatedKeyboardHandler = (handlers, dependencies) => {
|
|
|
27
27
|
}
|
|
28
28
|
}, ['onKeyboardMoveStart', 'onKeyboardMove', 'onKeyboardMoveEnd', 'onKeyboardMoveInteractive'], doDependenciesDiffer);
|
|
29
29
|
};
|
|
30
|
+
export const useFocusedInputHandler = (handlers, dependencies) => {
|
|
31
|
+
const {
|
|
32
|
+
context,
|
|
33
|
+
doDependenciesDiffer
|
|
34
|
+
} = useHandler(handlers, dependencies);
|
|
35
|
+
return useEvent(event => {
|
|
36
|
+
'worklet';
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
onFocusedInputLayoutChanged
|
|
40
|
+
} = handlers;
|
|
41
|
+
if (onFocusedInputLayoutChanged && event.eventName.endsWith('onFocusedInputLayoutChanged')) {
|
|
42
|
+
onFocusedInputLayoutChanged(event, context);
|
|
43
|
+
}
|
|
44
|
+
}, ['onFocusedInputLayoutChanged'], doDependenciesDiffer);
|
|
45
|
+
};
|
|
30
46
|
//# sourceMappingURL=reanimated.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEvent","useHandler","useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","event","onKeyboardMoveStart","onKeyboardMove","onKeyboardMoveEnd","onKeyboardMoveInteractive","eventName","endsWith"],"sources":["reanimated.native.ts"],"sourcesContent":["import { useEvent, useHandler } from 'react-native-reanimated';\n\nimport type {
|
|
1
|
+
{"version":3,"names":["useEvent","useHandler","useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","event","onKeyboardMoveStart","onKeyboardMove","onKeyboardMoveEnd","onKeyboardMoveInteractive","eventName","endsWith","useFocusedInputHandler","onFocusedInputLayoutChanged"],"sources":["reanimated.native.ts"],"sourcesContent":["import { useEvent, useHandler } from 'react-native-reanimated';\n\nimport type {\n EventWithName,\n FocusedInputHandlerHook,\n FocusedInputLayoutChangedEvent,\n KeyboardHandlerHook,\n NativeEvent,\n} from './types';\n\nexport const useAnimatedKeyboardHandler: KeyboardHandlerHook<\n Record<string, unknown>,\n EventWithName<NativeEvent>\n> = (handlers, dependencies) => {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event) => {\n 'worklet';\n const {\n onKeyboardMoveStart,\n onKeyboardMove,\n onKeyboardMoveEnd,\n onKeyboardMoveInteractive,\n } = handlers;\n\n if (\n onKeyboardMoveStart &&\n event.eventName.endsWith('onKeyboardMoveStart')\n ) {\n onKeyboardMoveStart(event, context);\n }\n\n if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {\n onKeyboardMove(event, context);\n }\n\n if (onKeyboardMoveEnd && event.eventName.endsWith('onKeyboardMoveEnd')) {\n onKeyboardMoveEnd(event, context);\n }\n\n if (\n onKeyboardMoveInteractive &&\n event.eventName.endsWith('onKeyboardMoveInteractive')\n ) {\n onKeyboardMoveInteractive(event, context);\n }\n },\n [\n 'onKeyboardMoveStart',\n 'onKeyboardMove',\n 'onKeyboardMoveEnd',\n 'onKeyboardMoveInteractive',\n ],\n doDependenciesDiffer\n );\n};\n\nexport const useFocusedInputHandler: FocusedInputHandlerHook<\n Record<string, unknown>,\n EventWithName<FocusedInputLayoutChangedEvent>\n> = (handlers, dependencies) => {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event) => {\n 'worklet';\n const { onFocusedInputLayoutChanged } = handlers;\n\n if (\n onFocusedInputLayoutChanged &&\n event.eventName.endsWith('onFocusedInputLayoutChanged')\n ) {\n onFocusedInputLayoutChanged(event, context);\n }\n },\n ['onFocusedInputLayoutChanged'],\n doDependenciesDiffer\n );\n};\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,UAAU,QAAQ,yBAAyB;AAU9D,OAAO,MAAMC,0BAGZ,GAAG,CAACC,QAAQ,EAAEC,YAAY,KAAK;EAC9B,MAAM;IAAEC,OAAO;IAAEC;EAAqB,CAAC,GAAGL,UAAU,CAACE,QAAQ,EAAEC,YAAY,CAAC;EAE5E,OAAOJ,QAAQ,CACZO,KAAK,IAAK;IACT,SAAS;;IACT,MAAM;MACJC,mBAAmB;MACnBC,cAAc;MACdC,iBAAiB;MACjBC;IACF,CAAC,GAAGR,QAAQ;IAEZ,IACEK,mBAAmB,IACnBD,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,qBAAqB,CAAC,EAC/C;MACAL,mBAAmB,CAACD,KAAK,EAAEF,OAAO,CAAC;IACrC;IAEA,IAAII,cAAc,IAAIF,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;MAChEJ,cAAc,CAACF,KAAK,EAAEF,OAAO,CAAC;IAChC;IAEA,IAAIK,iBAAiB,IAAIH,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,mBAAmB,CAAC,EAAE;MACtEH,iBAAiB,CAACH,KAAK,EAAEF,OAAO,CAAC;IACnC;IAEA,IACEM,yBAAyB,IACzBJ,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,2BAA2B,CAAC,EACrD;MACAF,yBAAyB,CAACJ,KAAK,EAAEF,OAAO,CAAC;IAC3C;EACF,CAAC,EACD,CACE,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,2BAA2B,CAC5B,EACDC,oBAAoB,CACrB;AACH,CAAC;AAED,OAAO,MAAMQ,sBAGZ,GAAG,CAACX,QAAQ,EAAEC,YAAY,KAAK;EAC9B,MAAM;IAAEC,OAAO;IAAEC;EAAqB,CAAC,GAAGL,UAAU,CAACE,QAAQ,EAAEC,YAAY,CAAC;EAE5E,OAAOJ,QAAQ,CACZO,KAAK,IAAK;IACT,SAAS;;IACT,MAAM;MAAEQ;IAA4B,CAAC,GAAGZ,QAAQ;IAEhD,IACEY,2BAA2B,IAC3BR,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,6BAA6B,CAAC,EACvD;MACAE,2BAA2B,CAACR,KAAK,EAAEF,OAAO,CAAC;IAC7C;EACF,CAAC,EACD,CAAC,6BAA6B,CAAC,EAC/BC,oBAAoB,CACrB;AACH,CAAC"}
|
package/lib/module/replicas.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { Animated, Easing, Keyboard, Platform } from 'react-native';
|
|
3
3
|
import { runOnUI, useAnimatedReaction, useDerivedValue, useSharedValue, useWorkletCallback, withSpring } from 'react-native-reanimated';
|
|
4
|
-
import { useReanimatedKeyboardAnimation } from './hooks';
|
|
5
4
|
import { KeyboardController } from './bindings';
|
|
6
5
|
import { AndroidSoftInputModes } from './constants';
|
|
6
|
+
import { useReanimatedKeyboardAnimation } from './hooks';
|
|
7
7
|
const availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did';
|
|
8
8
|
|
|
9
9
|
// cubic-bezier(.17,.67,.34,.94)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useEffect","useMemo","useRef","Animated","Easing","Keyboard","Platform","runOnUI","useAnimatedReaction","useDerivedValue","useSharedValue","useWorkletCallback","withSpring","KeyboardController","AndroidSoftInputModes","useReanimatedKeyboardAnimation","availableOSEventType","OS","defaultAndroidEasing","bezier","useKeyboardAnimationReplica","height","Value","progress","animation","current","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","listener","addListener","e","timing","toValue","endCoordinates","duration","easing","useNativeDriver","start","remove","IOS_SPRING_CONFIG","damping","stiffness","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","useReanimatedKeyboardAnimationReplica","heightEvent","value","handler","_height","_keyboardHeight","result","_previousResult","_previousKeyboardHeight","show","hide","useGradualKeyboardAnimation"],"sources":["replicas.ts"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react';\nimport { Animated, Easing, Keyboard, Platform } from 'react-native';\nimport {\n runOnUI,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n useWorkletCallback,\n withSpring,\n} from 'react-native-reanimated';\n\nimport { KeyboardController } from './bindings';\nimport { AndroidSoftInputModes } from './constants';\nimport { useReanimatedKeyboardAnimation } from './hooks';\n\nconst availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did';\n\n// cubic-bezier(.17,.67,.34,.94)\nexport const defaultAndroidEasing = Easing.bezier(0.4, 0.0, 0.2, 1);\ntype KeyboardAnimation = {\n progress: Animated.Value;\n height: Animated.Value;\n};\n\n/**\n * An experimental implementation of tracing keyboard appearance.\n * Switch an input mode to adjust resize mode. In this case all did* events\n * are triggering before keyboard appears, and using some approximations\n * it tries to mimicries a native transition.\n *\n * @returns {Animated.Value}\n */\nexport const useKeyboardAnimationReplica = (): KeyboardAnimation => {\n const height = useRef(new Animated.Value(0));\n const progress = useRef(new Animated.Value(0));\n const animation = useMemo(\n () => ({\n height: height.current,\n progress: progress.current,\n }),\n []\n );\n\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Show`,\n (e) => {\n Animated.timing(height.current, {\n toValue: -e.endCoordinates.height,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Hide`,\n (e) => {\n Animated.timing(height.current, {\n toValue: 0,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n\n return animation;\n};\n\nconst IOS_SPRING_CONFIG = {\n damping: 500,\n stiffness: 1000,\n mass: 3,\n overshootClamping: true,\n restDisplacementThreshold: 10,\n restSpeedThreshold: 10,\n};\n\n/**\n * A close replica to native iOS keyboard animation. The problem is that\n * iOS (unlike Android) can not fire events for each keyboard frame movement.\n * As a result we can not get gradual values (for example, for progress it always\n * will be 1 or 0). So if you want to rely on gradual values you will need to use\n * this replica.\n *\n * The transition is hardcoded and may vary from one to another OS versions. But it\n * seems like last time it has been changed in iOS 7. Since RN supports at least iOS\n * 11 it doesn't make sense to replicate iOS 7 behavior. If it changes in next OS\n * versions, then this implementation should be revisited and reflect necessary changes.\n *\n * @returns {height, progress} - animated values\n */\nexport const useReanimatedKeyboardAnimationReplica = () => {\n const height = useSharedValue(0);\n const heightEvent = useSharedValue(0);\n\n const progress = useDerivedValue(() => height.value / heightEvent.value);\n\n const handler = useWorkletCallback((_height: number) => {\n heightEvent.value = _height;\n }, []);\n\n useAnimatedReaction(\n () => ({\n _keyboardHeight: heightEvent.value,\n }),\n (result, _previousResult) => {\n const { _keyboardHeight } = result;\n const _previousKeyboardHeight = _previousResult?._keyboardHeight;\n\n if (_keyboardHeight !== _previousKeyboardHeight) {\n height.value = withSpring(_keyboardHeight, IOS_SPRING_CONFIG);\n }\n },\n []\n );\n\n useEffect(() => {\n const show = Keyboard.addListener('keyboardWillShow', (e) => {\n runOnUI(handler)(-e.endCoordinates.height);\n });\n const hide = Keyboard.addListener('keyboardWillHide', () => {\n runOnUI(handler)(0);\n });\n\n return () => {\n show.remove();\n hide.remove();\n };\n }, []);\n\n return { height, progress };\n};\n\nexport const useGradualKeyboardAnimation =\n Platform.OS === 'ios'\n ? useReanimatedKeyboardAnimationReplica\n : useReanimatedKeyboardAnimation;\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import type { HostComponent } from 'react-native';\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type {\n DirectEventHandler,\n Double,\n Int32,\n} from 'react-native/Libraries/Types/CodegenTypes';\
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\n\nimport type { HostComponent } from 'react-native';\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type {\n DirectEventHandler,\n Double,\n Int32,\n} from 'react-native/Libraries/Types/CodegenTypes';\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n duration: Int32;\n target: Int32;\n}>;\n\ntype FocusedInputLayoutChangedEvent = Readonly<{\n target: Int32;\n layout: {\n x: Double;\n y: Double;\n width: Double;\n height: Double;\n absoluteX: Double;\n absoluteY: Double;\n };\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n enabled?: boolean;\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n // callbacks\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n onFocusedInputLayoutChanged?: DirectEventHandler<FocusedInputLayoutChangedEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n 'KeyboardControllerView'\n) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AA0C5F,eAAeA,sBAAsB,CACnC,wBAAwB,CACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent","excludedPlatforms"],"sources":["KeyboardGestureAreaNativeComponent.ts"],"sourcesContent":["import type { HostComponent } from 'react-native';\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';\
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent","excludedPlatforms"],"sources":["KeyboardGestureAreaNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\n\nimport type { HostComponent } from 'react-native';\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';\n\nexport interface NativeProps extends ViewProps {\n interpolator?: WithDefault<'linear' | 'ios', 'linear'>;\n showOnSwipeUp?: boolean;\n enableSwipeToDismiss?: boolean;\n}\n\nexport default codegenNativeComponent<NativeProps>('KeyboardGestureArea', {\n excludedPlatforms: ['iOS'],\n}) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAY5F,eAAeA,sBAAsB,CAAc,qBAAqB,EAAE;EACxEC,iBAAiB,EAAE,CAAC,KAAK;AAC3B,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeKeyboardController.ts"],"sourcesContent":["import
|
|
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\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;AAgBlD,eAAeA,mBAAmB,CAACC,GAAG,CAAO,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeStatusBarManagerCompat.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeStatusBarManagerCompat.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 setHidden(hidden: boolean): void;\n setColor(color: number, animated: boolean): void;\n setTranslucent(translucent: boolean): void;\n setStyle(style: string): void;\n}\n\nexport default TurboModuleRegistry.get<Spec>('StatusBarManagerCompat');\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAalD,eAAeA,mBAAmB,CAACC,GAAG,CAAO,wBAAwB,CAAC"}
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n EmitterSubscription,\n NativeSyntheticEvent,\n ViewProps,\n} from 'react-native';\n\n// DirectEventHandler events declaration\nexport type NativeEvent = {\n progress: number;\n height: number;\n duration: number;\n target: number;\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n onKeyboardMoveStart?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n onKeyboardMove?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n onKeyboardMoveEnd?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n onKeyboardMoveInteractive?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n // fake
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n EmitterSubscription,\n NativeSyntheticEvent,\n ViewProps,\n} from 'react-native';\n\n// DirectEventHandler events declaration\nexport type NativeEvent = {\n progress: number;\n height: number;\n duration: number;\n target: number;\n};\nexport type FocusedInputLayoutChangedEvent = {\n target: number;\n layout: {\n x: number;\n y: number;\n width: number;\n height: number;\n absoluteX: number;\n absoluteY: number;\n };\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n enabled?: boolean;\n onKeyboardMoveStart?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n onKeyboardMove?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n onKeyboardMoveEnd?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n onKeyboardMoveInteractive?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n onFocusedInputLayoutChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>\n ) => void;\n // fake props used to activate reanimated bindings\n onKeyboardMoveReanimated?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n onFocusedInputLayoutChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>\n ) => void;\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n} & ViewProps;\n\nexport type KeyboardGestureAreaProps = {\n interpolator: 'ios' | 'linear';\n /**\n * Whether to allow to show a keyboard from dismissed state by swipe up.\n * Default to `false`.\n */\n showOnSwipeUp?: boolean;\n /**\n * Whether to allow to control a keyboard by gestures. The strategy how\n * it should be controlled is determined by `interpolator` property.\n * Defaults to `true`.\n */\n enableSwipeToDismiss?: boolean;\n} & ViewProps;\n\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | 'keyboardWillShow'\n | 'keyboardDidShow'\n | 'keyboardWillHide'\n | 'keyboardDidHide';\nexport type KeyboardEventData = {\n height: number;\n duration: number;\n timestamp: number;\n target: number;\n};\nexport type KeyboardEventsModule = {\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void\n ) => EmitterSubscription;\n};\n\n// reanimated hook declaration\nexport type KeyboardHandlerHook<TContext, Event> = (\n handlers: {\n onKeyboardMoveStart?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveEnd?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveInteractive?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: unknown[]\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputLayoutChanged?: (\n e: FocusedInputLayoutChangedEvent,\n context: TContext\n ) => void;\n },\n dependencies?: unknown[]\n) => (e: NativeSyntheticEvent<Event>) => void;\n\n// package types\nexport type Handlers<T> = Record<string, T | undefined>;\nexport type KeyboardHandler = Partial<{\n onStart: (e: NativeEvent) => void;\n onMove: (e: NativeEvent) => void;\n onEnd: (e: NativeEvent) => void;\n onInteractive: (e: NativeEvent) => void;\n}>;\nexport type KeyboardHandlers = Handlers<KeyboardHandler>;\n"],"mappings":""}
|
|
@@ -19,6 +19,13 @@ type KeyboardProviderProps = {
|
|
|
19
19
|
* @platform android
|
|
20
20
|
*/
|
|
21
21
|
navigationBarTranslucent?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* A boolean prop indicating whether the module is enabled. It indicate only initial state,
|
|
24
|
+
* i. e. if you try to change this prop after component mount it will not have any effect.
|
|
25
|
+
* To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.
|
|
26
|
+
* Defaults to `true`.
|
|
27
|
+
*/
|
|
28
|
+
enabled?: boolean;
|
|
22
29
|
};
|
|
23
|
-
export declare const KeyboardProvider: ({ children, statusBarTranslucent, navigationBarTranslucent, }: KeyboardProviderProps) => JSX.Element;
|
|
30
|
+
export declare const KeyboardProvider: ({ children, statusBarTranslucent, navigationBarTranslucent, enabled: initiallyEnabled, }: KeyboardProviderProps) => JSX.Element;
|
|
24
31
|
export {};
|
|
@@ -2,4 +2,5 @@ export declare const useKeyboardAnimation: () => {
|
|
|
2
2
|
height: import("react-native-reanimated").SharedValue<number>;
|
|
3
3
|
progress: import("react-native-reanimated").SharedValue<number>;
|
|
4
4
|
heightWhenOpened: import("react-native-reanimated").SharedValue<number>;
|
|
5
|
+
isClosed: import("react-native-reanimated").SharedValue<boolean>;
|
|
5
6
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import type { ViewProps } from 'react-native';
|
|
3
4
|
/**
|
|
4
5
|
* View that moves out of the way when the keyboard appears by automatically
|
|
5
6
|
* adjusting its height, position, or bottom padding.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { View, ViewProps } from 'react-native';
|
|
3
|
+
declare const KeyboardStickyView: React.ForwardRefExoticComponent<{
|
|
4
|
+
/**
|
|
5
|
+
* Specify additional offset to the view for given keyboard state.
|
|
6
|
+
*/
|
|
7
|
+
offset?: {
|
|
8
|
+
/**
|
|
9
|
+
* Adds additional `translateY` when keyboard is close. By default `0`.
|
|
10
|
+
*/
|
|
11
|
+
closed?: number | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Adds additional `translateY` when keyboard is open. By default `0`.
|
|
14
|
+
*/
|
|
15
|
+
opened?: number | undefined;
|
|
16
|
+
} | undefined;
|
|
17
|
+
} & ViewProps & {
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
} & React.RefAttributes<View>>;
|
|
20
|
+
export default KeyboardStickyView;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { Animated } from 'react-native';
|
|
2
|
+
import type { FocusedInputLayoutChangedEvent, KeyboardHandlers } from './types';
|
|
3
|
+
import type React from 'react';
|
|
3
4
|
import type { SharedValue } from 'react-native-reanimated';
|
|
4
|
-
import type { KeyboardHandlers } from './types';
|
|
5
5
|
export type AnimatedContext = {
|
|
6
6
|
progress: Animated.Value;
|
|
7
7
|
height: Animated.AnimatedMultiplication<number>;
|
|
@@ -11,9 +11,12 @@ export type ReanimatedContext = {
|
|
|
11
11
|
height: SharedValue<number>;
|
|
12
12
|
};
|
|
13
13
|
export type KeyboardAnimationContext = {
|
|
14
|
+
enabled: boolean;
|
|
14
15
|
animated: AnimatedContext;
|
|
15
16
|
reanimated: ReanimatedContext;
|
|
17
|
+
layout: SharedValue<FocusedInputLayoutChangedEvent | null>;
|
|
16
18
|
setHandlers: (handlers: KeyboardHandlers) => void;
|
|
19
|
+
setEnabled: React.Dispatch<React.SetStateAction<boolean>>;
|
|
17
20
|
};
|
|
18
|
-
export declare const KeyboardContext:
|
|
21
|
+
export declare const KeyboardContext: React.Context<KeyboardAnimationContext>;
|
|
19
22
|
export declare const useKeyboardContext: () => KeyboardAnimationContext;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AnimatedContext, ReanimatedContext } from './context';
|
|
1
|
+
import type { AnimatedContext, ReanimatedContext } from './context';
|
|
3
2
|
import type { KeyboardHandler } from './types';
|
|
3
|
+
import type { DependencyList } from 'react';
|
|
4
4
|
export declare const useResizeMode: () => void;
|
|
5
5
|
export declare const useKeyboardAnimation: () => AnimatedContext;
|
|
6
6
|
export declare const useReanimatedKeyboardAnimation: () => ReanimatedContext;
|
|
7
7
|
export declare function useGenericKeyboardHandler(handler: KeyboardHandler, deps?: DependencyList): void;
|
|
8
8
|
export declare function useKeyboardHandler(handler: KeyboardHandler, deps?: DependencyList): void;
|
|
9
|
+
export declare function useKeyboardController(): {
|
|
10
|
+
setEnabled: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function useReanimatedFocusedInput(): {
|
|
14
|
+
input: import("react-native-reanimated").SharedValue<import("./types").FocusedInputLayoutChangedEvent | null>;
|
|
15
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import './monkey-patch';
|
|
2
1
|
export * from './bindings';
|
|
3
2
|
export * from './animated';
|
|
4
3
|
export * from './replicas';
|
|
@@ -6,4 +5,4 @@ export * from './context';
|
|
|
6
5
|
export * from './hooks';
|
|
7
6
|
export * from './constants';
|
|
8
7
|
export * from './types';
|
|
9
|
-
export { KeyboardAvoidingView } from './components';
|
|
8
|
+
export { KeyboardAvoidingView, KeyboardStickyView } from './components';
|
|
@@ -11,7 +11,7 @@ import type { Handlers, NativeEvent } from './types';
|
|
|
11
11
|
* onEvent2: () => {},
|
|
12
12
|
* }
|
|
13
13
|
*/
|
|
14
|
-
export declare function useSharedHandlers<T extends Record<string,
|
|
14
|
+
export declare function useSharedHandlers<T extends Record<string, (event: NativeEvent) => void>>(): {
|
|
15
15
|
setHandlers: (handler: Handlers<T>) => void;
|
|
16
16
|
broadcast: (type: keyof T, event: NativeEvent) => void;
|
|
17
17
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const applyMonkeyPatch: () => void;
|
|
2
|
+
export declare const revertMonkeyPatch: () => void;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type { EventWithName, KeyboardHandlerHook, NativeEvent } from './types';
|
|
1
|
+
import type { EventWithName, FocusedInputHandlerHook, FocusedInputLayoutChangedEvent, KeyboardHandlerHook, NativeEvent } from './types';
|
|
2
2
|
export declare const useAnimatedKeyboardHandler: KeyboardHandlerHook<Record<string, unknown>, EventWithName<NativeEvent>>;
|
|
3
|
+
export declare const useFocusedInputHandler: FocusedInputHandlerHook<Record<string, unknown>, EventWithName<FocusedInputLayoutChangedEvent>>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type { EventWithName, KeyboardHandlerHook, NativeEvent } from './types';
|
|
1
|
+
import type { EventWithName, FocusedInputHandlerHook, FocusedInputLayoutChangedEvent, KeyboardHandlerHook, NativeEvent } from './types';
|
|
2
2
|
export declare const useAnimatedKeyboardHandler: KeyboardHandlerHook<Record<string, unknown>, EventWithName<NativeEvent>>;
|
|
3
|
+
export declare const useFocusedInputHandler: FocusedInputHandlerHook<Record<string, unknown>, EventWithName<FocusedInputLayoutChangedEvent>>;
|
|
@@ -7,13 +7,26 @@ type KeyboardMoveEvent = Readonly<{
|
|
|
7
7
|
duration: Int32;
|
|
8
8
|
target: Int32;
|
|
9
9
|
}>;
|
|
10
|
+
type FocusedInputLayoutChangedEvent = Readonly<{
|
|
11
|
+
target: Int32;
|
|
12
|
+
layout: {
|
|
13
|
+
x: Double;
|
|
14
|
+
y: Double;
|
|
15
|
+
width: Double;
|
|
16
|
+
height: Double;
|
|
17
|
+
absoluteX: Double;
|
|
18
|
+
absoluteY: Double;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
10
21
|
export interface NativeProps extends ViewProps {
|
|
22
|
+
enabled?: boolean;
|
|
11
23
|
statusBarTranslucent?: boolean;
|
|
12
24
|
navigationBarTranslucent?: boolean;
|
|
13
25
|
onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;
|
|
14
26
|
onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;
|
|
15
27
|
onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;
|
|
16
28
|
onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;
|
|
29
|
+
onFocusedInputLayoutChanged?: DirectEventHandler<FocusedInputLayoutChangedEvent>;
|
|
17
30
|
}
|
|
18
31
|
declare const _default: HostComponent<NativeProps>;
|
|
19
32
|
export default _default;
|
|
@@ -5,15 +5,29 @@ export type NativeEvent = {
|
|
|
5
5
|
duration: number;
|
|
6
6
|
target: number;
|
|
7
7
|
};
|
|
8
|
+
export type FocusedInputLayoutChangedEvent = {
|
|
9
|
+
target: number;
|
|
10
|
+
layout: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
absoluteX: number;
|
|
16
|
+
absoluteY: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
8
19
|
export type EventWithName<T> = {
|
|
9
20
|
eventName: string;
|
|
10
21
|
} & T;
|
|
11
22
|
export type KeyboardControllerProps = {
|
|
23
|
+
enabled?: boolean;
|
|
12
24
|
onKeyboardMoveStart?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
13
25
|
onKeyboardMove?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
14
26
|
onKeyboardMoveEnd?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
15
27
|
onKeyboardMoveInteractive?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
28
|
+
onFocusedInputLayoutChanged?: (e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>) => void;
|
|
16
29
|
onKeyboardMoveReanimated?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
30
|
+
onFocusedInputLayoutChangedReanimated?: (e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>) => void;
|
|
17
31
|
statusBarTranslucent?: boolean;
|
|
18
32
|
navigationBarTranslucent?: boolean;
|
|
19
33
|
} & ViewProps;
|
|
@@ -53,6 +67,9 @@ export type KeyboardHandlerHook<TContext, Event> = (handlers: {
|
|
|
53
67
|
onKeyboardMoveEnd?: (e: NativeEvent, context: TContext) => void;
|
|
54
68
|
onKeyboardMoveInteractive?: (e: NativeEvent, context: TContext) => void;
|
|
55
69
|
}, dependencies?: unknown[]) => (e: NativeSyntheticEvent<Event>) => void;
|
|
70
|
+
export type FocusedInputHandlerHook<TContext, Event> = (handlers: {
|
|
71
|
+
onFocusedInputLayoutChanged?: (e: FocusedInputLayoutChangedEvent, context: TContext) => void;
|
|
72
|
+
}, dependencies?: unknown[]) => (e: NativeSyntheticEvent<Event>) => void;
|
|
56
73
|
export type Handlers<T> = Record<string, T | undefined>;
|
|
57
74
|
export type KeyboardHandler = Partial<{
|
|
58
75
|
onStart: (e: NativeEvent) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-keyboard-controller",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Keyboard manager which works in identical way on both iOS and Android",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -41,6 +41,9 @@
|
|
|
41
41
|
"react-native",
|
|
42
42
|
"keyboard",
|
|
43
43
|
"animation",
|
|
44
|
+
"focused input",
|
|
45
|
+
"avoiding view",
|
|
46
|
+
"sticky view",
|
|
44
47
|
"ios",
|
|
45
48
|
"android"
|
|
46
49
|
],
|
|
@@ -60,10 +63,15 @@
|
|
|
60
63
|
"@release-it/conventional-changelog": "^2.0.0",
|
|
61
64
|
"@types/jest": "^29.2.1",
|
|
62
65
|
"@types/react": "^18.0.24",
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
|
67
|
+
"@typescript-eslint/parser": "^6.7.4",
|
|
63
68
|
"clang-format": "^1.8.0",
|
|
64
69
|
"commitlint": "^11.0.0",
|
|
65
70
|
"eslint": "^8.19.0",
|
|
66
71
|
"eslint-config-prettier": "^7.0.0",
|
|
72
|
+
"eslint-import-resolver-typescript": "^3.6.1",
|
|
73
|
+
"eslint-plugin-import": "^2.28.1",
|
|
74
|
+
"eslint-plugin-jest": "^27.4.2",
|
|
67
75
|
"eslint-plugin-prettier": "^3.1.3",
|
|
68
76
|
"husky": "^6.0.0",
|
|
69
77
|
"jest": "^29.2.1",
|
|
@@ -110,33 +118,6 @@
|
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
120
|
},
|
|
113
|
-
"eslintConfig": {
|
|
114
|
-
"root": true,
|
|
115
|
-
"extends": [
|
|
116
|
-
"@react-native",
|
|
117
|
-
"prettier"
|
|
118
|
-
],
|
|
119
|
-
"rules": {
|
|
120
|
-
"prettier/prettier": [
|
|
121
|
-
"error",
|
|
122
|
-
{
|
|
123
|
-
"quoteProps": "consistent",
|
|
124
|
-
"singleQuote": true,
|
|
125
|
-
"tabWidth": 2,
|
|
126
|
-
"trailingComma": "es5",
|
|
127
|
-
"useTabs": false
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
"react-hooks/exhaustive-deps": "warn"
|
|
131
|
-
},
|
|
132
|
-
"globals": {
|
|
133
|
-
"jest": "readonly"
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
"eslintIgnore": [
|
|
137
|
-
"node_modules/",
|
|
138
|
-
"lib/"
|
|
139
|
-
],
|
|
140
121
|
"prettier": {
|
|
141
122
|
"quoteProps": "consistent",
|
|
142
123
|
"singleQuote": true,
|