rn-css 1.9.3 → 1.9.4

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.
@@ -1,5 +1,6 @@
1
1
  import React, { MouseEvent } from 'react';
2
2
  import { FlatListProps, SectionListProps, StyleProp, TouchableHighlightProps, ViewProps, VirtualizedListProps } from 'react-native';
3
+ import { FocusEventListener, BlurEventListener } from './features';
3
4
  import type { CompleteStyle, Units } from './types';
4
5
  export declare const defaultUnits: Units;
5
6
  export declare const RemContext: React.Context<number>;
@@ -15,8 +16,8 @@ declare type Functs<T> = (arg: T & {
15
16
  }) => Primitive;
16
17
  declare type OptionalProps = {
17
18
  rnCSS?: `${string};`;
18
- onFocus?: TouchableHighlightProps['onFocus'];
19
- onBlur?: TouchableHighlightProps['onBlur'];
19
+ onFocus?: FocusEventListener;
20
+ onBlur?: BlurEventListener;
20
21
  onPressIn?: TouchableHighlightProps['onPressIn'];
21
22
  onPressOut?: TouchableHighlightProps['onPressOut'];
22
23
  onResponderStart?: ViewProps['onResponderStart'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-css",
3
- "version": "1.9.3",
3
+ "version": "1.9.4",
4
4
  "scripts": {
5
5
  "test": "jest",
6
6
  "prepare": "rm -rf dist && tsc",
package/src/features.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react/display-name */
2
2
  import React, { MouseEvent } from 'react'
3
3
  import type { Style, Units, MediaQuery, PartialStyle } from './types'
4
- import { useWindowDimensions, LayoutChangeEvent, NativeSyntheticEvent, TargetedEvent, GestureResponderEvent } from 'react-native'
4
+ import { useWindowDimensions, LayoutChangeEvent, GestureResponderEvent, TouchableHighlightProps, TextInputProps } from 'react-native'
5
5
  import { parseValue } from './convertUnits'
6
6
  import { createContext } from './cssToRN/mediaQueries'
7
7
 
@@ -61,14 +61,16 @@ export const useActive = (
61
61
  }
62
62
  }
63
63
 
64
+ export type FocusEventListener = TouchableHighlightProps['onFocus'] | TextInputProps['onFocus']
65
+ export type BlurEventListener = TouchableHighlightProps['onBlur'] | TextInputProps['onBlur']
64
66
  /** Hook that will apply the style reserved for active state if needed */
65
- export const useFocus = (onFocus: undefined | ((event: NativeSyntheticEvent<TargetedEvent>) => void), onBlur: undefined | ((event: NativeSyntheticEvent<TargetedEvent>) => void | undefined), needsFocus: boolean) => {
67
+ export const useFocus = (onFocus: undefined | FocusEventListener, onBlur: undefined | BlurEventListener, needsFocus: boolean) => {
66
68
  const [focused, setFocused] = React.useState(false)
67
- const focusStart = React.useMemo(() => needsFocus ? (event: NativeSyntheticEvent<TargetedEvent>) => {
69
+ const focusStart = React.useMemo(() => needsFocus ? (event: any) => {
68
70
  if (onFocus) onFocus(event)
69
71
  setFocused(true)
70
72
  } : undefined, [needsFocus, onFocus])
71
- const focusStop = React.useMemo(() => needsFocus ? (event: NativeSyntheticEvent<TargetedEvent>) => {
73
+ const focusStop = React.useMemo(() => needsFocus ? (event: any) => {
72
74
  if (onBlur) onBlur(event)
73
75
  setFocused(false)
74
76
  } : undefined, [needsFocus, onBlur])
@@ -5,7 +5,7 @@ import React, { MouseEvent } from 'react'
5
5
  import { FlatList, FlatListProps, Platform, SectionList, SectionListProps, StyleProp, StyleSheet, TouchableHighlightProps, ViewProps, ViewStyle, VirtualizedList, VirtualizedListProps } from 'react-native'
6
6
  import convertStyle from './convertStyle'
7
7
  import cssToStyle from './cssToRN'
8
- import { useFontSize, useHover, useLayout, useScreenSize, useMediaQuery, useActive, useFocus } from './features'
8
+ import { useFontSize, useHover, useLayout, useScreenSize, useMediaQuery, useActive, useFocus, FocusEventListener, BlurEventListener } from './features'
9
9
  import type { AnyStyle, CompleteStyle, Style, Units } from './types'
10
10
  import generateHash from './generateHash'
11
11
  import rnToCSS from './rnToCss'
@@ -24,8 +24,8 @@ type Primitive = number | string | null | undefined | boolean | CompleteStyle
24
24
  type Functs<T> = (arg: T & { rnCSS?: string; shared: unknown, theme: DefaultTheme }) => Primitive
25
25
  type OptionalProps = {
26
26
  rnCSS?: `${string};`;
27
- onFocus?: TouchableHighlightProps['onFocus'];
28
- onBlur?: TouchableHighlightProps['onBlur'];
27
+ onFocus?: FocusEventListener;
28
+ onBlur?: BlurEventListener;
29
29
  onPressIn?: TouchableHighlightProps['onPressIn'];
30
30
  onPressOut?: TouchableHighlightProps['onPressOut'];
31
31
  onResponderStart?: ViewProps['onResponderStart'];