rn-css 1.8.12 → 1.8.13
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/features.d.ts +2 -2
- package/dist/features.js +5 -5
- package/dist/styleComponent.js +3 -3
- package/package.json +1 -1
- package/src/features.tsx +4 -4
- package/src/styleComponent.tsx +3 -3
package/dist/features.d.ts
CHANGED
|
@@ -9,9 +9,9 @@ export declare const useScreenSize: () => {
|
|
|
9
9
|
vmax: number;
|
|
10
10
|
};
|
|
11
11
|
/** Hook that will apply the style reserved for hover state if needed */
|
|
12
|
-
export declare const useHover: (
|
|
12
|
+
export declare const useHover: (onMouseEnter: ((event: MouseEvent) => void) | undefined, onMouseLeave: ((event: MouseEvent) => void | undefined) | undefined, needsHover: boolean) => {
|
|
13
13
|
hover: boolean;
|
|
14
|
-
|
|
14
|
+
onMouseEnter: ((event: MouseEvent) => void) | undefined;
|
|
15
15
|
onMouseLeave: ((event: MouseEvent) => void | undefined) | undefined;
|
|
16
16
|
};
|
|
17
17
|
/** Hook that will apply the style provided in the media queries */
|
package/dist/features.js
CHANGED
|
@@ -18,19 +18,19 @@ const useScreenSize = () => {
|
|
|
18
18
|
};
|
|
19
19
|
exports.useScreenSize = useScreenSize;
|
|
20
20
|
/** Hook that will apply the style reserved for hover state if needed */
|
|
21
|
-
const useHover = (
|
|
21
|
+
const useHover = (onMouseEnter, onMouseLeave, needsHover) => {
|
|
22
22
|
const [hover, setHover] = react_1.default.useState(false);
|
|
23
23
|
const hoverStart = react_1.default.useMemo(() => needsHover ? (event) => {
|
|
24
|
-
if (
|
|
25
|
-
|
|
24
|
+
if (onMouseEnter)
|
|
25
|
+
onMouseEnter(event);
|
|
26
26
|
setHover(true);
|
|
27
|
-
} : undefined, [needsHover,
|
|
27
|
+
} : undefined, [needsHover, onMouseEnter]);
|
|
28
28
|
const hoverStop = react_1.default.useMemo(() => needsHover ? (event) => {
|
|
29
29
|
if (onMouseLeave)
|
|
30
30
|
onMouseLeave(event);
|
|
31
31
|
setHover(false);
|
|
32
32
|
} : undefined, [needsHover, onMouseLeave]);
|
|
33
|
-
return { hover,
|
|
33
|
+
return { hover, onMouseEnter: hoverStart || onMouseEnter, onMouseLeave: hoverStop || onMouseLeave };
|
|
34
34
|
};
|
|
35
35
|
exports.useHover = useHover;
|
|
36
36
|
/** Hook that will apply the style provided in the media queries */
|
package/dist/styleComponent.js
CHANGED
|
@@ -65,7 +65,7 @@ const styled = (Component) => {
|
|
|
65
65
|
needsHover: !!rnStyle.hover
|
|
66
66
|
}), [css, rnStyle.hover]);
|
|
67
67
|
// Handle hover
|
|
68
|
-
const {
|
|
68
|
+
const { onMouseEnter, onMouseLeave, hover } = (0, features_1.useHover)(props.onMouseEnter, props.onMouseLeave, needsHover);
|
|
69
69
|
const tempStyle = react_1.default.useMemo(() => {
|
|
70
70
|
const style = { ...rnStyle };
|
|
71
71
|
delete style.media;
|
|
@@ -111,12 +111,12 @@ const styled = (Component) => {
|
|
|
111
111
|
return { style: getStyle(hash, style), hash };
|
|
112
112
|
}, [finalStyle, units]);
|
|
113
113
|
const newProps = react_1.default.useMemo(() => {
|
|
114
|
-
const newProps = { style: [styleConvertedFromCSS, props.style],
|
|
114
|
+
const newProps = { style: [styleConvertedFromCSS, props.style], onMouseEnter, onMouseLeave, onLayout };
|
|
115
115
|
if (finalStyle.textOverflow === 'ellipsis') {
|
|
116
116
|
Object.assign(newProps, { numberOfLines: 1 });
|
|
117
117
|
}
|
|
118
118
|
return newProps;
|
|
119
|
-
}, [finalStyle.textOverflow, onLayout,
|
|
119
|
+
}, [finalStyle.textOverflow, onLayout, onMouseEnter, onMouseLeave, props.style, styleConvertedFromCSS]);
|
|
120
120
|
react_1.default.useEffect(() => () => removeStyle(hash), [hash]);
|
|
121
121
|
// em !== parentEm alone is a bit dangerous as the component would rerender when the font size change
|
|
122
122
|
if (em !== parentEm || finalStyle.fontSize !== undefined) {
|
package/package.json
CHANGED
package/src/features.tsx
CHANGED
|
@@ -14,17 +14,17 @@ export const useScreenSize = () => {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/** Hook that will apply the style reserved for hover state if needed */
|
|
17
|
-
export const useHover = (
|
|
17
|
+
export const useHover = (onMouseEnter: undefined | ((event: MouseEvent) => void), onMouseLeave: undefined | ((event: MouseEvent) => void | undefined), needsHover: boolean) => {
|
|
18
18
|
const [hover, setHover] = React.useState(false)
|
|
19
19
|
const hoverStart = React.useMemo(() => needsHover ? (event: MouseEvent) => {
|
|
20
|
-
if (
|
|
20
|
+
if (onMouseEnter) onMouseEnter(event)
|
|
21
21
|
setHover(true)
|
|
22
|
-
} : undefined, [needsHover,
|
|
22
|
+
} : undefined, [needsHover, onMouseEnter])
|
|
23
23
|
const hoverStop = React.useMemo(() => needsHover ? (event: MouseEvent) => {
|
|
24
24
|
if (onMouseLeave) onMouseLeave(event)
|
|
25
25
|
setHover(false)
|
|
26
26
|
} : undefined, [needsHover, onMouseLeave])
|
|
27
|
-
return { hover,
|
|
27
|
+
return { hover, onMouseEnter: hoverStart || onMouseEnter, onMouseLeave: hoverStop || onMouseLeave }
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/** Hook that will apply the style provided in the media queries */
|
package/src/styleComponent.tsx
CHANGED
|
@@ -78,7 +78,7 @@ const styled = <StyleType, InitialProps extends { style?: StyleProp<StyleType> }
|
|
|
78
78
|
}), [css, rnStyle.hover])
|
|
79
79
|
|
|
80
80
|
// Handle hover
|
|
81
|
-
const {
|
|
81
|
+
const { onMouseEnter, onMouseLeave, hover } = useHover(props.onMouseEnter, props.onMouseLeave, needsHover)
|
|
82
82
|
const tempStyle = React.useMemo<Style>(() => {
|
|
83
83
|
const style = { ...rnStyle }
|
|
84
84
|
delete style.media
|
|
@@ -127,12 +127,12 @@ const styled = <StyleType, InitialProps extends { style?: StyleProp<StyleType> }
|
|
|
127
127
|
return { style: getStyle<CompleteStyle>(hash, style), hash }
|
|
128
128
|
}, [finalStyle, units])
|
|
129
129
|
const newProps = React.useMemo(() => {
|
|
130
|
-
const newProps = { style: [styleConvertedFromCSS as StyleType, props.style],
|
|
130
|
+
const newProps = { style: [styleConvertedFromCSS as StyleType, props.style], onMouseEnter, onMouseLeave, onLayout }
|
|
131
131
|
if (finalStyle.textOverflow === 'ellipsis') {
|
|
132
132
|
Object.assign(newProps, { numberOfLines: 1 })
|
|
133
133
|
}
|
|
134
134
|
return newProps
|
|
135
|
-
}, [finalStyle.textOverflow, onLayout,
|
|
135
|
+
}, [finalStyle.textOverflow, onLayout, onMouseEnter, onMouseLeave, props.style, styleConvertedFromCSS])
|
|
136
136
|
|
|
137
137
|
React.useEffect(() => () => removeStyle(hash), [hash])
|
|
138
138
|
|