rn-css 1.8.2 → 1.8.3
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/dist/convertStyle.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { /* StyleSheet, */ Animated, TextStyle } from 'react-native';
|
|
1
2
|
import type { AnyStyle, PartialStyle, Units } from './types';
|
|
2
3
|
/** Mix the calculated RN style within the object style */
|
|
3
|
-
declare const convertStyle: <T extends AnyStyle = AnyStyle>(rnStyle: PartialStyle, units: Units) => T;
|
|
4
|
+
declare const convertStyle: <T extends AnyStyle | Animated.WithAnimatedObject<import("react-native").ViewStyle> | Animated.WithAnimatedObject<TextStyle> | Animated.WithAnimatedObject<import("react-native").ImageStyle> = AnyStyle>(rnStyle: PartialStyle, units: Units) => T;
|
|
4
5
|
export default convertStyle;
|
package/dist/styleComponent.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare type OptionalProps<T extends AnyStyle | Animated.WithAnimatedValue<AnySt
|
|
|
21
21
|
children?: React.ReactNode;
|
|
22
22
|
style?: StyleProp<T>;
|
|
23
23
|
};
|
|
24
|
-
declare const styled: <Props, StyleType extends AnyStyle = AnyStyle>(Component: React.ComponentType<Props>) => {
|
|
24
|
+
declare const styled: <Props, StyleType extends AnyStyle | Animated.WithAnimatedObject<import("react-native").ViewStyle> | Animated.WithAnimatedObject<import("react-native").TextStyle> | Animated.WithAnimatedObject<import("react-native").ImageStyle> = AnyStyle>(Component: React.ComponentType<Props>) => {
|
|
25
25
|
<S>(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & Props>)[]): React.ForwardRefExoticComponent<Props & S & OptionalProps<StyleType> & {
|
|
26
26
|
ref?: React.Ref<any> | undefined;
|
|
27
27
|
}>;
|
package/package.json
CHANGED
package/src/convertStyle.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable react/display-name */
|
|
2
|
-
import { /* StyleSheet, */ TextStyle } from 'react-native'
|
|
2
|
+
import { /* StyleSheet, */ Animated, TextStyle } from 'react-native'
|
|
3
3
|
import { convertValue } from './convertUnits'
|
|
4
4
|
import type { AnyStyle, CompleteStyle, PartialStyle, Units } from './types'
|
|
5
5
|
|
|
6
6
|
/** Mix the calculated RN style within the object style */
|
|
7
|
-
const convertStyle = <T extends AnyStyle = AnyStyle>(rnStyle: PartialStyle, units: Units) => {
|
|
7
|
+
const convertStyle = <T extends AnyStyle | Animated.WithAnimatedValue<AnyStyle> = AnyStyle>(rnStyle: PartialStyle, units: Units) => {
|
|
8
8
|
/** This is the result of the convertions from css style into RN style */
|
|
9
9
|
const convertedStyle: CompleteStyle = {};
|
|
10
10
|
// If width and height are specified, we can use those values for the first render
|
package/src/styleComponent.tsx
CHANGED
|
@@ -59,7 +59,7 @@ function removeStyle (hash: string) {
|
|
|
59
59
|
styleMap[hash].usage--
|
|
60
60
|
if (styleMap[hash].usage <= 0) delete styleMap[hash]
|
|
61
61
|
}
|
|
62
|
-
const styled = <Props, StyleType extends AnyStyle = AnyStyle>(Component: React.ComponentType<Props>) => {
|
|
62
|
+
const styled = <Props, StyleType extends AnyStyle | Animated.WithAnimatedValue<AnyStyle> = AnyStyle>(Component: React.ComponentType<Props>) => {
|
|
63
63
|
const styledComponent = <S, >(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & Props>)[]) => {
|
|
64
64
|
const ForwardRefComponent = React.forwardRef<React.ComponentType<S & Props & OptionalProps<StyleType>>, S & Props & OptionalProps<StyleType>>((props: S & Props & OptionalProps<StyleType>, ref) => {
|
|
65
65
|
const rem = React.useContext(RemContext)
|
|
@@ -120,13 +120,13 @@ const styled = <Props, StyleType extends AnyStyle = AnyStyle>(Component: React.C
|
|
|
120
120
|
const units = React.useMemo<Units>(() => ({ ...baseUnits, em }), [baseUnits, em])
|
|
121
121
|
|
|
122
122
|
const { style: styleConvertedFromCSS, hash } = React.useMemo(() => {
|
|
123
|
-
const style = convertStyle<
|
|
123
|
+
const style = convertStyle<CompleteStyle>(finalStyle, units)
|
|
124
124
|
delete (style as Style).textOverflow
|
|
125
125
|
const hash = generateHash(JSON.stringify(style))
|
|
126
|
-
return { style: getStyle<
|
|
126
|
+
return { style: getStyle<CompleteStyle>(hash, style), hash }
|
|
127
127
|
}, [finalStyle, units])
|
|
128
128
|
const newProps = React.useMemo(() => {
|
|
129
|
-
const newProps: OptionalProps<StyleType> = { style: [styleConvertedFromCSS, props.style], onMouseEnter, onMouseLeave, onLayout }
|
|
129
|
+
const newProps: OptionalProps<StyleType> = { style: [styleConvertedFromCSS as StyleType, props.style], onMouseEnter, onMouseLeave, onLayout }
|
|
130
130
|
if (finalStyle.textOverflow === 'ellipsis') {
|
|
131
131
|
Object.assign(newProps, { numberOfLines: 1 })
|
|
132
132
|
}
|