rn-css 1.9.1 → 1.9.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/cssToRN/index.js +13 -1
- package/dist/features.d.ts +16 -1
- package/dist/features.js +45 -1
- package/dist/index.d.ts +2720 -3
- package/dist/index.js +56 -172
- package/dist/styleComponent.d.ts +9 -2
- package/dist/styleComponent.js +30 -6
- package/dist/types.d.ts +2 -0
- package/package.json +2 -2
- package/src/features.tsx +4 -4
- package/src/styleComponent.tsx +13 -13
- package/dist/app.json +0 -4
- package/dist/src/convertStyle.d.ts +0 -5
- package/dist/src/convertStyle.js +0 -56
- package/dist/src/convertUnits.d.ts +0 -5
- package/dist/src/convertUnits.js +0 -71
- package/dist/src/cssToRN/convert.d.ts +0 -55
- package/dist/src/cssToRN/convert.js +0 -418
- package/dist/src/cssToRN/index.d.ts +0 -8
- package/dist/src/cssToRN/index.js +0 -140
- package/dist/src/cssToRN/maths.d.ts +0 -4
- package/dist/src/cssToRN/maths.js +0 -86
- package/dist/src/cssToRN/mediaQueries.d.ts +0 -7
- package/dist/src/cssToRN/mediaQueries.js +0 -161
- package/dist/src/features.d.ts +0 -43
- package/dist/src/features.js +0 -130
- package/dist/src/generateHash.d.ts +0 -2
- package/dist/src/generateHash.js +0 -8
- package/dist/src/index.d.ts +0 -2720
- package/dist/src/index.js +0 -60
- package/dist/src/polyfill.d.ts +0 -3
- package/dist/src/polyfill.js +0 -23
- package/dist/src/rnToCss.d.ts +0 -3
- package/dist/src/rnToCss.js +0 -8
- package/dist/src/styleComponent.d.ts +0 -50
- package/dist/src/styleComponent.js +0 -181
- package/dist/src/types.d.ts +0 -86
- package/dist/src/types.js +0 -2
- package/dist/src/useTheme.d.ts +0 -18
- package/dist/src/useTheme.js +0 -33
package/dist/cssToRN/index.js
CHANGED
|
@@ -32,7 +32,19 @@ function cssToStyle(css) {
|
|
|
32
32
|
result.hover = cssChunkToStyle(hoverInstructions);
|
|
33
33
|
return '';
|
|
34
34
|
});
|
|
35
|
-
|
|
35
|
+
// Find active (we don't support active within media queries) (We use [\s\S] instead of . because dotall flag (s) is not supported by react-native-windows)
|
|
36
|
+
const cssWithoutActive = cssWithoutHover.replace(/&:active\s*{([\s\S]*?)}/gmi, res => {
|
|
37
|
+
const activeInstructions = res.substring(0, res.length - 1).replace(/&:active\s*{/mi, ''); // We remove the `&:active {` and `}`
|
|
38
|
+
result.active = cssChunkToStyle(activeInstructions);
|
|
39
|
+
return '';
|
|
40
|
+
});
|
|
41
|
+
// Find focus (we don't support focus within media queries) (We use [\s\S] instead of . because dotall flag (s) is not supported by react-native-windows)
|
|
42
|
+
const cssWithoutFocus = cssWithoutActive.replace(/&:focus\s*{([\s\S]*?)}/gmi, res => {
|
|
43
|
+
const activeInstructions = res.substring(0, res.length - 1).replace(/&:focus\s*{/mi, ''); // We remove the `&:focus {` and `}`
|
|
44
|
+
result.focus = cssChunkToStyle(activeInstructions);
|
|
45
|
+
return '';
|
|
46
|
+
});
|
|
47
|
+
Object.assign(result, cssChunkToStyle(cssWithoutFocus));
|
|
36
48
|
return result;
|
|
37
49
|
}
|
|
38
50
|
function cssToRNStyle(css, units = {}) {
|
package/dist/features.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MouseEvent } from 'react';
|
|
2
2
|
import type { Style, Units, MediaQuery } from './types';
|
|
3
|
-
import { LayoutChangeEvent } from 'react-native';
|
|
3
|
+
import { LayoutChangeEvent, NativeSyntheticEvent, TargetedEvent, GestureResponderEvent } from 'react-native';
|
|
4
4
|
/** Hook that will apply the screen size to the styles defined with vmin, vmax, vw, vh units, and handle media queries constraints */
|
|
5
5
|
export declare const useScreenSize: () => {
|
|
6
6
|
vw: number;
|
|
@@ -14,6 +14,21 @@ export declare const useHover: (onMouseEnter: ((event: MouseEvent) => void) | un
|
|
|
14
14
|
onMouseEnter: ((event: MouseEvent) => void) | undefined;
|
|
15
15
|
onMouseLeave: ((event: MouseEvent) => void | undefined) | undefined;
|
|
16
16
|
};
|
|
17
|
+
/** Hook that will apply the style reserved for active state if needed */
|
|
18
|
+
export declare const useActive: (onPressIn: ((event: GestureResponderEvent) => void) | undefined, onPressOut: ((event: GestureResponderEvent) => void) | undefined, onResponderStart: ((event: GestureResponderEvent) => void) | undefined, onResponderRelease: ((event: GestureResponderEvent) => void) | undefined, onStartShouldSetResponder: ((event: GestureResponderEvent) => void) | undefined, needsTouch: boolean) => {
|
|
19
|
+
active: boolean;
|
|
20
|
+
onPressIn: ((event: GestureResponderEvent) => void) | undefined;
|
|
21
|
+
onPressOut: ((event: GestureResponderEvent) => void) | undefined;
|
|
22
|
+
onResponderStart: ((event: GestureResponderEvent) => void) | undefined;
|
|
23
|
+
onResponderRelease: ((event: GestureResponderEvent) => void) | undefined;
|
|
24
|
+
onStartShouldSetResponder: ((event: GestureResponderEvent) => void) | undefined;
|
|
25
|
+
};
|
|
26
|
+
/** Hook that will apply the style reserved for active state if needed */
|
|
27
|
+
export declare const useFocus: (onFocus: ((event: NativeSyntheticEvent<TargetedEvent>) => void) | undefined, onBlur: ((event: NativeSyntheticEvent<TargetedEvent>) => void | undefined) | undefined, needsFocus: boolean) => {
|
|
28
|
+
focused: boolean;
|
|
29
|
+
onFocus: ((event: NativeSyntheticEvent<TargetedEvent>) => void) | undefined;
|
|
30
|
+
onBlur: ((event: NativeSyntheticEvent<TargetedEvent>) => void | undefined) | undefined;
|
|
31
|
+
};
|
|
17
32
|
/** Hook that will apply the style provided in the media queries */
|
|
18
33
|
export declare const useMediaQuery: (media: undefined | MediaQuery[], units: Units) => Style | undefined;
|
|
19
34
|
/** Hook that will measure the layout to handle styles that use % units */
|
package/dist/features.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useFontSize = exports.useLayout = exports.useMediaQuery = exports.useHover = exports.useScreenSize = void 0;
|
|
6
|
+
exports.useFontSize = exports.useLayout = exports.useMediaQuery = exports.useFocus = exports.useActive = exports.useHover = exports.useScreenSize = void 0;
|
|
7
7
|
/* eslint-disable react/display-name */
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const react_native_1 = require("react-native");
|
|
@@ -33,6 +33,50 @@ const useHover = (onMouseEnter, onMouseLeave, needsHover) => {
|
|
|
33
33
|
return { hover, onMouseEnter: hoverStart || onMouseEnter, onMouseLeave: hoverStop || onMouseLeave };
|
|
34
34
|
};
|
|
35
35
|
exports.useHover = useHover;
|
|
36
|
+
/** Hook that will apply the style reserved for active state if needed */
|
|
37
|
+
const useActive = (onPressIn, onPressOut, onResponderStart, onResponderRelease, onStartShouldSetResponder, needsTouch) => {
|
|
38
|
+
const [active, setActive] = react_1.default.useState(false);
|
|
39
|
+
const touchStart = react_1.default.useMemo(() => needsTouch ? (event) => {
|
|
40
|
+
if (onPressIn)
|
|
41
|
+
onPressIn(event);
|
|
42
|
+
else if (onResponderStart)
|
|
43
|
+
onResponderStart(event);
|
|
44
|
+
setActive(true);
|
|
45
|
+
} : undefined, [needsTouch, onResponderStart, onPressIn]);
|
|
46
|
+
const touchEnd = react_1.default.useMemo(() => needsTouch ? (event) => {
|
|
47
|
+
if (onPressOut)
|
|
48
|
+
onPressOut(event);
|
|
49
|
+
else if (onResponderRelease)
|
|
50
|
+
onResponderRelease(event);
|
|
51
|
+
setActive(false);
|
|
52
|
+
} : undefined, [needsTouch, onResponderRelease, onPressOut]);
|
|
53
|
+
const grantTouch = react_1.default.useMemo(() => needsTouch ? onStartShouldSetResponder || (() => true) : undefined, [needsTouch, onStartShouldSetResponder]);
|
|
54
|
+
return {
|
|
55
|
+
active,
|
|
56
|
+
onPressIn: touchStart || onPressIn,
|
|
57
|
+
onPressOut: touchEnd || onPressOut,
|
|
58
|
+
onResponderStart: touchStart || onResponderStart,
|
|
59
|
+
onResponderRelease: touchEnd || onResponderRelease,
|
|
60
|
+
onStartShouldSetResponder: grantTouch || onStartShouldSetResponder
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
exports.useActive = useActive;
|
|
64
|
+
/** Hook that will apply the style reserved for active state if needed */
|
|
65
|
+
const useFocus = (onFocus, onBlur, needsFocus) => {
|
|
66
|
+
const [focused, setFocused] = react_1.default.useState(false);
|
|
67
|
+
const focusStart = react_1.default.useMemo(() => needsFocus ? (event) => {
|
|
68
|
+
if (onFocus)
|
|
69
|
+
onFocus(event);
|
|
70
|
+
setFocused(true);
|
|
71
|
+
} : undefined, [needsFocus, onFocus]);
|
|
72
|
+
const focusStop = react_1.default.useMemo(() => needsFocus ? (event) => {
|
|
73
|
+
if (onBlur)
|
|
74
|
+
onBlur(event);
|
|
75
|
+
setFocused(false);
|
|
76
|
+
} : undefined, [needsFocus, onBlur]);
|
|
77
|
+
return { focused, onFocus: focusStart || onFocus, onBlur: focusStop || onBlur };
|
|
78
|
+
};
|
|
79
|
+
exports.useFocus = useFocus;
|
|
36
80
|
/** Hook that will apply the style provided in the media queries */
|
|
37
81
|
const useMediaQuery = (media, units) => {
|
|
38
82
|
const mediaStyle = react_1.default.useMemo(() => {
|