@codeandmoney/soelma 0.0.0-dev.0 → 0.0.0-dev.1
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/DefaultTheme.d.ts +2 -0
- package/DefaultTheme.js +1 -0
- package/appearance/consts.d.ts +1 -0
- package/appearance/index.d.ts +8 -0
- package/appearance/index.js +18 -0
- package/appearance/init.d.ts +1 -0
- package/{src/appearance/init.ts → appearance/init.js} +1 -6
- package/context.d.ts +4 -0
- package/context.js +3 -0
- package/createEventEmitter.d.ts +8 -0
- package/createEventEmitter.js +11 -0
- package/dark-mode/consts.d.ts +1 -0
- package/dark-mode/index.d.ts +7 -0
- package/dark-mode/index.js +16 -0
- package/dark-mode/init.d.ts +1 -0
- package/dark-mode/init.js +13 -0
- package/dark-mode/state.d.ts +3 -0
- package/{src/dark-mode/state.ts → dark-mode/state.js} +1 -2
- package/dependencyRegistry.d.ts +5 -0
- package/dependencyRegistry.js +12 -0
- package/dependencyUsage.d.ts +7 -0
- package/dependencyUsage.js +10 -0
- package/dimensions/consts.d.ts +2 -0
- package/dimensions/index.d.ts +4 -0
- package/dimensions/index.js +13 -0
- package/dimensions/init.d.ts +1 -0
- package/dimensions/init.js +21 -0
- package/dimensions/utils.d.ts +1 -0
- package/dimensions/utils.js +7 -0
- package/i18n.d.ts +7 -0
- package/i18n.js +9 -0
- package/index.js +5 -0
- package/{src/makeUseStyles → makeUseStyles}/index.d.ts +1 -1
- package/{src/makeUseStyles → makeUseStyles}/utils.js +4 -4
- package/media-query/base.d.ts +12 -0
- package/media-query/base.js +18 -0
- package/media-query/breakpoints.d.ts +18 -0
- package/media-query/breakpoints.js +60 -0
- package/media-query/index.d.ts +2 -0
- package/media-query/index.js +2 -0
- package/orientation.d.ts +7 -0
- package/orientation.js +7 -0
- package/package.json +6 -37
- package/safe-area/SafeAreaProvider.d.ts +3 -0
- package/safe-area/SafeAreaProvider.js +9 -0
- package/safe-area/StylexSaveAreaConsumer.d.ts +2 -0
- package/safe-area/StylexSaveAreaConsumer.js +15 -0
- package/safe-area/consts.d.ts +1 -0
- package/safe-area/eventEmitter.d.ts +1 -0
- package/{src/safe-area/eventEmitter.ts → safe-area/eventEmitter.js} +0 -1
- package/safe-area/index.d.ts +5 -0
- package/{src/safe-area/index.tsx → safe-area/index.js} +3 -9
- package/safe-area/init.d.ts +1 -0
- package/{src/safe-area/init.tsx → safe-area/init.js} +1 -3
- package/safe-area/state.d.ts +8 -0
- package/{src/safe-area/state.ts → safe-area/state.js} +5 -7
- package/safe-area/types.d.ts +9 -0
- package/safe-area/types.js +1 -0
- package/useColorTransition.d.ts +5 -0
- package/useColorTransition.js +38 -0
- package/useTheme.d.ts +2 -0
- package/useTheme.js +9 -0
- package/withStyles.d.ts +7 -0
- package/withStyles.js +13 -0
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -31
- package/.github/workflows/nodejs.yml +0 -33
- package/.size-limit.json +0 -6
- package/babel.config.js +0 -3
- package/docs/api.md +0 -103
- package/docs/appearance.md +0 -54
- package/docs/dark-mode.md +0 -46
- package/docs/dimensions.md +0 -29
- package/docs/i18n.md +0 -67
- package/docs/logo.png +0 -0
- package/docs/media-query.md +0 -274
- package/docs/orientation.md +0 -44
- package/docs/safe-area.md +0 -62
- package/docs/testting.md +0 -51
- package/docs/ts.md +0 -127
- package/example/AppStyleX/.watchmanconfig +0 -1
- package/example/AppStyleX/android/build.gradle +0 -26
- package/example/AppStyleX/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/AppStyleX/android/gradle/wrapper/gradle-wrapper.properties +0 -7
- package/example/AppStyleX/android/gradle.properties +0 -53
- package/example/AppStyleX/android/gradlew +0 -249
- package/example/AppStyleX/android/gradlew.bat +0 -92
- package/example/AppStyleX/android/settings.gradle +0 -12
- package/example/AppStyleX/app.json +0 -28
- package/example/AppStyleX/babel.config.js +0 -3
- package/example/AppStyleX/index.js +0 -9
- package/example/AppStyleX/ios/Podfile +0 -7
- package/example/AppStyleX/ios/Podfile.lock +0 -1252
- package/example/AppStyleX/metro.config.js +0 -54
- package/example/AppStyleX/package.json +0 -43
- package/example/AppStyleX/react-native.config.js +0 -23
- package/example/AppStyleX/src/App.tsx +0 -25
- package/example/AppStyleX/src/BottomNav/index.tsx +0 -32
- package/example/AppStyleX/src/BottomNav/styles.ts +0 -42
- package/example/AppStyleX/src/Circle/index.tsx +0 -53
- package/example/AppStyleX/src/Circle/styles.ts +0 -22
- package/example/AppStyleX/src/Root/index.tsx +0 -41
- package/example/AppStyleX/src/Root/styles.ts +0 -18
- package/example/AppStyleX/src/ToggleButton/index.tsx +0 -66
- package/example/AppStyleX/src/ToggleButton/styles.ts +0 -69
- package/example/AppStyleX/src/style-system/hooks/useAnimatedBgColor.ts +0 -5
- package/example/AppStyleX/src/style-system/hooks/useAnimatedTextColor.ts +0 -5
- package/example/AppStyleX/src/style-system/hooks/useIsDark.ts +0 -8
- package/example/AppStyleX/src/style-system/palette.ts +0 -11
- package/example/AppStyleX/src/style-system/theme.ts +0 -14
- package/example/AppStyleX/src/style-system/utils.ts +0 -11
- package/example/AppStyleX/src/stylex.d.ts +0 -6
- package/example/AppStyleX/tsconfig.json +0 -3
- package/example/AppStyleX/yarn.lock +0 -6767
- package/jest.config.js +0 -19
- package/src/DefaultTheme.ts +0 -4
- package/src/__tests__/createBreakpoints.test.ts +0 -152
- package/src/__tests__/createBreakpointsMatcher.test.ts +0 -188
- package/src/__tests__/createBreakpointsMatcher.types-test.ts +0 -81
- package/src/__tests__/createEventEmitter.test.ts +0 -37
- package/src/__tests__/dark-mode.test.ts +0 -56
- package/src/__tests__/dependencyRegistry.test.ts +0 -16
- package/src/__tests__/dependencyUsage.test.ts +0 -13
- package/src/__tests__/dimensions.test.ts +0 -36
- package/src/__tests__/makeUseStyles.types-test.ts +0 -69
- package/src/__tests__/media-query.test.ts +0 -204
- package/src/__tests__/orientation.test.ts +0 -61
- package/src/__tests__/useTheme.test.ts +0 -26
- package/src/__tests__/withStyles.types-test.tsx +0 -173
- package/src/appearance/index.ts +0 -37
- package/src/context.ts +0 -9
- package/src/createEventEmitter.ts +0 -26
- package/src/dark-mode/index.ts +0 -29
- package/src/dark-mode/init.ts +0 -19
- package/src/dependencyRegistry.ts +0 -21
- package/src/dependencyUsage.ts +0 -31
- package/src/dimensions/index.ts +0 -20
- package/src/dimensions/init.ts +0 -37
- package/src/dimensions/utils.ts +0 -11
- package/src/i18n.ts +0 -18
- package/src/makeUseStyles/createUseStylesTheme.test.js +0 -137
- package/src/makeUseStyles/createUseStylesWithoutTheme.test.js +0 -63
- package/src/makeUseStyles/index.test.js +0 -28
- package/src/media-query/base.ts +0 -43
- package/src/media-query/breakpoints.ts +0 -121
- package/src/media-query/index.ts +0 -12
- package/src/orientation.ts +0 -17
- package/src/safe-area/SafeAreaProvider.tsx +0 -17
- package/src/safe-area/StylexSaveAreaConsumer.ts +0 -23
- package/src/safe-area/types.ts +0 -10
- package/src/useColorTransition.ts +0 -50
- package/src/useTheme.ts +0 -16
- package/src/withStyles.tsx +0 -35
- package/tsconfig.json +0 -30
- /package/{src/appearance/consts.ts → appearance/consts.js} +0 -0
- /package/{src/dark-mode/consts.ts → dark-mode/consts.js} +0 -0
- /package/{src/dimensions/consts.ts → dimensions/consts.js} +0 -0
- /package/{src/index.ts → index.d.ts} +0 -0
- /package/{src/makeUseStyles → makeUseStyles}/createUseStylesTheme.js +0 -0
- /package/{src/makeUseStyles → makeUseStyles}/createUseStylesWithoutTheme.js +0 -0
- /package/{src/makeUseStyles → makeUseStyles}/index.js +0 -0
- /package/{src/makeUseStyles → makeUseStyles}/test-type.js +0 -0
- /package/{src/safe-area/consts.ts → safe-area/consts.js} +0 -0
package/jest.config.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const { resolve } = require("path");
|
|
2
|
-
const { name: displayName } = require("./package");
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
displayName,
|
|
6
|
-
testEnvironment: "node",
|
|
7
|
-
preset: "react-native",
|
|
8
|
-
cacheDirectory: resolve(__dirname, "./node_modules/.jestcache"),
|
|
9
|
-
moduleFileExtensions: ["ts", "tsx", "js"],
|
|
10
|
-
testRegex: "\\.test\\.(js|ts)x?$",
|
|
11
|
-
coveragePathIgnorePatterns: ["init.ts"],
|
|
12
|
-
coverageThreshold: {
|
|
13
|
-
global: {
|
|
14
|
-
branches: 100,
|
|
15
|
-
functions: 100,
|
|
16
|
-
statements: 100,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
package/src/DefaultTheme.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// This interface can be augmented by users to add default types for the theme when using react-native-stylex.
|
|
2
|
-
// Use module augmentation to append your own type definition in a your_custom_stylex_type.d.ts file.
|
|
3
|
-
// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
|
|
4
|
-
export interface DefaultTheme {}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { createBreakpoints } from "../media-query/breakpoints";
|
|
2
|
-
import { getWindowDimensions } from "../dimensions";
|
|
3
|
-
|
|
4
|
-
jest.mock("../dimensions", () => ({
|
|
5
|
-
getWindowDimensions: jest.fn(),
|
|
6
|
-
}));
|
|
7
|
-
|
|
8
|
-
const mockWindowWidth = (width: number) => {
|
|
9
|
-
const mockGetWindowDimensions = getWindowDimensions as jest.Mock;
|
|
10
|
-
mockGetWindowDimensions.mockReturnValue({ width });
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
describe("createBreakpoints", () => {
|
|
14
|
-
const config = {
|
|
15
|
-
xs: 360,
|
|
16
|
-
sm: 600,
|
|
17
|
-
md: 960,
|
|
18
|
-
lg: 1280,
|
|
19
|
-
xl: 1920,
|
|
20
|
-
};
|
|
21
|
-
const breakpoints = createBreakpoints(config);
|
|
22
|
-
|
|
23
|
-
describe("down", () => {
|
|
24
|
-
const getStyles = () => ({
|
|
25
|
-
fontSize: 16,
|
|
26
|
-
...breakpoints.down("lg", { fontSize: 18 }),
|
|
27
|
-
...breakpoints.down("sm", { fontSize: 20 }),
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("should return small variant", () => {
|
|
31
|
-
mockWindowWidth(0);
|
|
32
|
-
expect(getStyles()).toEqual({ fontSize: 20 });
|
|
33
|
-
mockWindowWidth(600);
|
|
34
|
-
expect(getStyles()).toEqual({ fontSize: 20 });
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should return large variant", () => {
|
|
38
|
-
mockWindowWidth(601);
|
|
39
|
-
expect(getStyles()).toEqual({ fontSize: 18 });
|
|
40
|
-
mockWindowWidth(1280);
|
|
41
|
-
expect(getStyles()).toEqual({ fontSize: 18 });
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("should return default variant", () => {
|
|
45
|
-
mockWindowWidth(1281);
|
|
46
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
47
|
-
mockWindowWidth(1920);
|
|
48
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
49
|
-
mockWindowWidth(1921);
|
|
50
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe("up", () => {
|
|
55
|
-
const getStyles = () => ({
|
|
56
|
-
fontSize: 20,
|
|
57
|
-
...breakpoints.up("sm", { fontSize: 18 }),
|
|
58
|
-
...breakpoints.up("lg", { fontSize: 16 }),
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("should return small variant", () => {
|
|
62
|
-
mockWindowWidth(0);
|
|
63
|
-
expect(getStyles()).toEqual({ fontSize: 20 });
|
|
64
|
-
mockWindowWidth(599);
|
|
65
|
-
expect(getStyles()).toEqual({ fontSize: 20 });
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("should return large variant", () => {
|
|
69
|
-
mockWindowWidth(600);
|
|
70
|
-
expect(getStyles()).toEqual({ fontSize: 18 });
|
|
71
|
-
mockWindowWidth(1279);
|
|
72
|
-
expect(getStyles()).toEqual({ fontSize: 18 });
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("should return default variant", () => {
|
|
76
|
-
mockWindowWidth(1280);
|
|
77
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
78
|
-
mockWindowWidth(1920);
|
|
79
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
80
|
-
mockWindowWidth(1921);
|
|
81
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe("only", () => {
|
|
86
|
-
it("should work properly", () => {
|
|
87
|
-
const getStyles = () => ({
|
|
88
|
-
fontSize: 16,
|
|
89
|
-
...breakpoints.only("md", { fontSize: 20 }),
|
|
90
|
-
});
|
|
91
|
-
// window width : 0...xs...sm...md...lg...xl...∞
|
|
92
|
-
// fontSize : .............[20...20]...........
|
|
93
|
-
|
|
94
|
-
mockWindowWidth(0);
|
|
95
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
96
|
-
mockWindowWidth(config.md - 0.5);
|
|
97
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
98
|
-
|
|
99
|
-
mockWindowWidth(config.md);
|
|
100
|
-
expect(getStyles()).toEqual({ fontSize: 20 });
|
|
101
|
-
mockWindowWidth(config.lg - 0.5);
|
|
102
|
-
expect(getStyles()).toEqual({ fontSize: 20 });
|
|
103
|
-
|
|
104
|
-
mockWindowWidth(config.lg);
|
|
105
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("should call up on last breakpoint", () => {
|
|
109
|
-
const getStyles = () => ({
|
|
110
|
-
fontSize: 16,
|
|
111
|
-
...breakpoints.only("xl", { fontSize: 20 }),
|
|
112
|
-
});
|
|
113
|
-
// window width : 0...xs...sm...md...lg...xl...∞
|
|
114
|
-
// fontSize : .......................[20.......
|
|
115
|
-
|
|
116
|
-
mockWindowWidth(config.xl - 0.5);
|
|
117
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
118
|
-
|
|
119
|
-
mockWindowWidth(config.xl);
|
|
120
|
-
expect(getStyles()).toEqual({ fontSize: 20 });
|
|
121
|
-
mockWindowWidth(config.xl + 0.5);
|
|
122
|
-
expect(getStyles()).toEqual({ fontSize: 20 });
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
describe("between", () => {
|
|
127
|
-
const getStyles = () => ({
|
|
128
|
-
fontSize: 16,
|
|
129
|
-
...breakpoints.between("sm", "lg", { fontSize: 20 }),
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("should work properly", () => {
|
|
133
|
-
// window width : 0...xs...sm...md...lg...xl...∞
|
|
134
|
-
// fontSize : ........[20........20]...........
|
|
135
|
-
|
|
136
|
-
mockWindowWidth(0);
|
|
137
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
138
|
-
mockWindowWidth(config.sm - 0.5);
|
|
139
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
140
|
-
|
|
141
|
-
mockWindowWidth(config.sm);
|
|
142
|
-
expect(getStyles()).toEqual({ fontSize: 20 });
|
|
143
|
-
mockWindowWidth(config.md);
|
|
144
|
-
expect(getStyles()).toEqual({ fontSize: 20 });
|
|
145
|
-
mockWindowWidth(config.lg - 0.5);
|
|
146
|
-
expect(getStyles()).toEqual({ fontSize: 20 });
|
|
147
|
-
|
|
148
|
-
mockWindowWidth(config.lg);
|
|
149
|
-
expect(getStyles()).toEqual({ fontSize: 16 });
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
});
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { createBreakpointsMatcher, maxWidth, minWidth } from "../media-query";
|
|
2
|
-
import { getWindowDimensions } from "../dimensions";
|
|
3
|
-
|
|
4
|
-
jest.mock("../dimensions", () => ({
|
|
5
|
-
getWindowDimensions: jest.fn(),
|
|
6
|
-
}));
|
|
7
|
-
|
|
8
|
-
const mockWindowWidth = (width: number) => {
|
|
9
|
-
const mockGetWindowDimensions = getWindowDimensions as jest.Mock;
|
|
10
|
-
mockGetWindowDimensions.mockReturnValue({ width });
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
* To debug use analog on CSS: https://codepen.io/retyui/pen/dyOzKzV
|
|
15
|
-
*/
|
|
16
|
-
describe("createBreakpointsMatcher", () => {
|
|
17
|
-
const config = {
|
|
18
|
-
xxs: 100,
|
|
19
|
-
xs: 200,
|
|
20
|
-
s: 300,
|
|
21
|
-
m: 400,
|
|
22
|
-
l: 500,
|
|
23
|
-
};
|
|
24
|
-
const breakpointsMaxWidth = createBreakpointsMatcher(config, maxWidth);
|
|
25
|
-
const breakpointsMinWidth = createBreakpointsMatcher(config);
|
|
26
|
-
|
|
27
|
-
const values = {
|
|
28
|
-
xxs: "xxs: 100",
|
|
29
|
-
xs: "xs: 200",
|
|
30
|
-
s: "s: 300",
|
|
31
|
-
m: "m: 400",
|
|
32
|
-
l: "l: 500",
|
|
33
|
-
default: "default",
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
it("should return boundary values", () => {
|
|
37
|
-
mockWindowWidth(600);
|
|
38
|
-
|
|
39
|
-
expect({
|
|
40
|
-
maxWidth: breakpointsMaxWidth(values),
|
|
41
|
-
minWidth: breakpointsMinWidth(values),
|
|
42
|
-
}).toEqual({
|
|
43
|
-
maxWidth: "default",
|
|
44
|
-
minWidth: "l: 500",
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
mockWindowWidth(50);
|
|
48
|
-
|
|
49
|
-
expect({
|
|
50
|
-
maxWidth: breakpointsMaxWidth(values),
|
|
51
|
-
minWidth: breakpointsMinWidth(values),
|
|
52
|
-
}).toEqual({
|
|
53
|
-
maxWidth: "xxs: 100",
|
|
54
|
-
minWidth: "default",
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("should work properly", () => {
|
|
59
|
-
mockWindowWidth(450);
|
|
60
|
-
|
|
61
|
-
expect({
|
|
62
|
-
maxWidth: breakpointsMaxWidth(values),
|
|
63
|
-
minWidth: breakpointsMinWidth(values),
|
|
64
|
-
}).toEqual({
|
|
65
|
-
maxWidth: "l: 500",
|
|
66
|
-
minWidth: "m: 400",
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
mockWindowWidth(401);
|
|
70
|
-
|
|
71
|
-
expect({
|
|
72
|
-
maxWidth: breakpointsMaxWidth(values),
|
|
73
|
-
minWidth: breakpointsMinWidth(values),
|
|
74
|
-
}).toEqual({
|
|
75
|
-
maxWidth: "l: 500",
|
|
76
|
-
minWidth: "m: 400",
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
mockWindowWidth(400);
|
|
80
|
-
|
|
81
|
-
expect({
|
|
82
|
-
maxWidth: breakpointsMaxWidth(values),
|
|
83
|
-
minWidth: breakpointsMinWidth(values),
|
|
84
|
-
}).toEqual({
|
|
85
|
-
maxWidth: "m: 400",
|
|
86
|
-
minWidth: "m: 400",
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
mockWindowWidth(399);
|
|
90
|
-
|
|
91
|
-
expect({
|
|
92
|
-
maxWidth: breakpointsMaxWidth(values),
|
|
93
|
-
minWidth: breakpointsMinWidth(values),
|
|
94
|
-
}).toEqual({
|
|
95
|
-
maxWidth: "m: 400",
|
|
96
|
-
minWidth: "s: 300",
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("should return null when no default and it pass boundary values", () => {
|
|
101
|
-
const { default: _, ...valuesWithoutDefault } = values;
|
|
102
|
-
mockWindowWidth(600);
|
|
103
|
-
|
|
104
|
-
expect({
|
|
105
|
-
maxWidth: breakpointsMaxWidth(valuesWithoutDefault),
|
|
106
|
-
minWidth: breakpointsMinWidth(valuesWithoutDefault),
|
|
107
|
-
}).toEqual({
|
|
108
|
-
maxWidth: null,
|
|
109
|
-
minWidth: "l: 500",
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
mockWindowWidth(50);
|
|
113
|
-
|
|
114
|
-
expect({
|
|
115
|
-
maxWidth: breakpointsMaxWidth(valuesWithoutDefault),
|
|
116
|
-
minWidth: breakpointsMinWidth(valuesWithoutDefault),
|
|
117
|
-
}).toEqual({
|
|
118
|
-
maxWidth: "xxs: 100",
|
|
119
|
-
minWidth: null,
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
describe("docs examples", () => {
|
|
125
|
-
const config = {
|
|
126
|
-
xxs: 320,
|
|
127
|
-
xs: 480,
|
|
128
|
-
s: 640,
|
|
129
|
-
m: 768,
|
|
130
|
-
l: 1024,
|
|
131
|
-
xl: 1200,
|
|
132
|
-
xxl: 1920,
|
|
133
|
-
};
|
|
134
|
-
describe("maxWidth", () => {
|
|
135
|
-
const applyBreakpoints = createBreakpointsMatcher(config, maxWidth);
|
|
136
|
-
|
|
137
|
-
it("should work properly", () => {
|
|
138
|
-
const values = { xxs: 20, xs: 18, default: 16 };
|
|
139
|
-
|
|
140
|
-
mockWindowWidth(0);
|
|
141
|
-
expect(applyBreakpoints(values)).toBe(20);
|
|
142
|
-
|
|
143
|
-
mockWindowWidth(320);
|
|
144
|
-
expect(applyBreakpoints(values)).toBe(20);
|
|
145
|
-
|
|
146
|
-
mockWindowWidth(321);
|
|
147
|
-
expect(applyBreakpoints(values)).toBe(18);
|
|
148
|
-
|
|
149
|
-
mockWindowWidth(480);
|
|
150
|
-
expect(applyBreakpoints(values)).toBe(18);
|
|
151
|
-
|
|
152
|
-
mockWindowWidth(481);
|
|
153
|
-
expect(applyBreakpoints(values)).toBe(16);
|
|
154
|
-
|
|
155
|
-
mockWindowWidth(999);
|
|
156
|
-
expect(applyBreakpoints(values)).toBe(16);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
describe("minWidth", () => {
|
|
161
|
-
const applyBreakpoints = createBreakpointsMatcher(config, minWidth);
|
|
162
|
-
|
|
163
|
-
it("should work properly", () => {
|
|
164
|
-
const values = { xxs: 18, xs: 16, default: 20 };
|
|
165
|
-
|
|
166
|
-
mockWindowWidth(0);
|
|
167
|
-
expect(applyBreakpoints(values)).toBe(20);
|
|
168
|
-
|
|
169
|
-
mockWindowWidth(319);
|
|
170
|
-
expect(applyBreakpoints(values)).toBe(20);
|
|
171
|
-
|
|
172
|
-
mockWindowWidth(320);
|
|
173
|
-
expect(applyBreakpoints(values)).toBe(18);
|
|
174
|
-
|
|
175
|
-
mockWindowWidth(479);
|
|
176
|
-
expect(applyBreakpoints(values)).toBe(18);
|
|
177
|
-
|
|
178
|
-
mockWindowWidth(480);
|
|
179
|
-
expect(applyBreakpoints(values)).toBe(16);
|
|
180
|
-
|
|
181
|
-
mockWindowWidth(481);
|
|
182
|
-
expect(applyBreakpoints(values)).toBe(16);
|
|
183
|
-
|
|
184
|
-
mockWindowWidth(999);
|
|
185
|
-
expect(applyBreakpoints(values)).toBe(16);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { makeUseStyles } from "../index";
|
|
2
|
-
import { createBreakpointsMatcher } from "../media-query";
|
|
3
|
-
|
|
4
|
-
{
|
|
5
|
-
const breakpoints = createBreakpointsMatcher({
|
|
6
|
-
s: 100,
|
|
7
|
-
m: 200,
|
|
8
|
-
l: 300,
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
makeUseStyles(() => ({
|
|
12
|
-
root: {
|
|
13
|
-
position: breakpoints({
|
|
14
|
-
l: "absolute",
|
|
15
|
-
default: "relative",
|
|
16
|
-
}),
|
|
17
|
-
|
|
18
|
-
// @ts-expect-error - 'invalid value' is wrong value
|
|
19
|
-
alignItems: breakpoints({
|
|
20
|
-
l: "invalid value",
|
|
21
|
-
}),
|
|
22
|
-
},
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
const breakpoints = createBreakpointsMatcher({
|
|
28
|
-
s: 100,
|
|
29
|
-
m: 200,
|
|
30
|
-
l: 300,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const a1: string | undefined = breakpoints({ s: "1" });
|
|
34
|
-
const a2: string | undefined = breakpoints({ s: "1", m: "2" });
|
|
35
|
-
const a3: string | undefined = breakpoints({ s: "1", m: "2", l: "3" });
|
|
36
|
-
const a4: string = breakpoints({
|
|
37
|
-
s: "1",
|
|
38
|
-
m: "2",
|
|
39
|
-
l: "3",
|
|
40
|
-
default: "0",
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
const breakpoints = createBreakpointsMatcher({
|
|
46
|
-
s: 100,
|
|
47
|
-
m: 200,
|
|
48
|
-
l: 300,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// @ts-expect-error - 'number' is not 'string'
|
|
52
|
-
const a1: string | undefined = breakpoints({ s: 1 });
|
|
53
|
-
const a2 = breakpoints({
|
|
54
|
-
s: 1,
|
|
55
|
-
// @ts-expect-error - 'string' is not 'number'
|
|
56
|
-
m: "2",
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
{
|
|
61
|
-
const breakpoints = createBreakpointsMatcher({
|
|
62
|
-
s: 100,
|
|
63
|
-
m: 200,
|
|
64
|
-
l: 300,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// @ts-expect-error - can be 'undefined'
|
|
68
|
-
const a1: string = breakpoints({ s: "1" });
|
|
69
|
-
// @ts-expect-error - can be 'undefined'
|
|
70
|
-
const a2: string = breakpoints({ s: "1", m: "2" });
|
|
71
|
-
// @ts-expect-error - can be 'undefined'
|
|
72
|
-
const a3: string = breakpoints({ s: "1", m: "2", l: "3" });
|
|
73
|
-
|
|
74
|
-
// @ts-expect-error - 'undefined' is not 'string'
|
|
75
|
-
const a4: undefined = breakpoints({
|
|
76
|
-
s: "1",
|
|
77
|
-
m: "2",
|
|
78
|
-
l: "3",
|
|
79
|
-
default: "0",
|
|
80
|
-
});
|
|
81
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { createEventEmitter } from "../createEventEmitter";
|
|
2
|
-
|
|
3
|
-
it("should call handler when invoke emit", () => {
|
|
4
|
-
const a = createEventEmitter("event");
|
|
5
|
-
const handler = jest.fn();
|
|
6
|
-
|
|
7
|
-
const unsub = a.on(handler);
|
|
8
|
-
|
|
9
|
-
expect(handler).toHaveBeenCalledTimes(0);
|
|
10
|
-
|
|
11
|
-
a.emit();
|
|
12
|
-
|
|
13
|
-
expect(handler).toHaveBeenCalledTimes(1);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("should not call handler when unsubscribe", () => {
|
|
17
|
-
const a = createEventEmitter("event");
|
|
18
|
-
const handler = jest.fn();
|
|
19
|
-
|
|
20
|
-
const unsub = a.on(handler);
|
|
21
|
-
|
|
22
|
-
a.emit();
|
|
23
|
-
|
|
24
|
-
expect(handler).toHaveBeenCalledTimes(1);
|
|
25
|
-
|
|
26
|
-
unsub();
|
|
27
|
-
|
|
28
|
-
a.emit();
|
|
29
|
-
|
|
30
|
-
expect(handler).toHaveBeenCalledTimes(1);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("should throw error when no subscribed functions", () => {
|
|
34
|
-
const a = createEventEmitter("test");
|
|
35
|
-
|
|
36
|
-
a.emit();
|
|
37
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { Mode } from "react-native-dark-mode";
|
|
2
|
-
|
|
3
|
-
import { darkUiMode, lightUiMode } from "../dark-mode";
|
|
4
|
-
import { state } from "../dark-mode/state";
|
|
5
|
-
|
|
6
|
-
jest.mock("react-native-dark-mode", () => ({
|
|
7
|
-
initialMode: "light",
|
|
8
|
-
eventEmitter: { on: jest.fn() },
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
const mockStyles = { color: "red" };
|
|
12
|
-
|
|
13
|
-
const mutateUiMode = (mode: Mode | null) => {
|
|
14
|
-
// @ts-expect-error: for test only add null
|
|
15
|
-
state.mode = mode;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
describe("darkUiMode", () => {
|
|
19
|
-
it("should return style when dark mode", () => {
|
|
20
|
-
mutateUiMode("dark");
|
|
21
|
-
|
|
22
|
-
expect(darkUiMode(mockStyles)).toEqual(mockStyles);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should return 'undefined' when light mode", () => {
|
|
26
|
-
mutateUiMode("light");
|
|
27
|
-
|
|
28
|
-
expect(darkUiMode(mockStyles)).toBeUndefined();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("should return 'undefined' when unknown mode", () => {
|
|
32
|
-
mutateUiMode(null);
|
|
33
|
-
|
|
34
|
-
expect(darkUiMode(mockStyles)).toBeUndefined();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("lightUiMode", () => {
|
|
39
|
-
it("should return style when light mode", () => {
|
|
40
|
-
mutateUiMode("light");
|
|
41
|
-
|
|
42
|
-
expect(lightUiMode(mockStyles)).toEqual(mockStyles);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("should return 'undefined' when dark mode", () => {
|
|
46
|
-
mutateUiMode("dark");
|
|
47
|
-
|
|
48
|
-
expect(lightUiMode(mockStyles)).toBeUndefined();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("should return 'undefined' when unknown mode", () => {
|
|
52
|
-
mutateUiMode(null);
|
|
53
|
-
|
|
54
|
-
expect(lightUiMode(mockStyles)).toBeUndefined();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { addDependency, getDependency } from "../dependencyRegistry";
|
|
2
|
-
|
|
3
|
-
it("should overwrite handler", () => {
|
|
4
|
-
const name = "dark-mode";
|
|
5
|
-
const handler = () => () => {};
|
|
6
|
-
|
|
7
|
-
addDependency(name, handler);
|
|
8
|
-
|
|
9
|
-
expect(getDependency(name)).toBe(handler);
|
|
10
|
-
|
|
11
|
-
const newHandler = () => () => {};
|
|
12
|
-
|
|
13
|
-
addDependency(name, newHandler);
|
|
14
|
-
|
|
15
|
-
expect(getDependency(name)).not.toBe(newHandler);
|
|
16
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { onUse, resetUsing, getUsing } from "../dependencyUsage";
|
|
2
|
-
|
|
3
|
-
it("should clear usage map", () => {
|
|
4
|
-
onUse("a");
|
|
5
|
-
onUse("a");
|
|
6
|
-
onUse("b");
|
|
7
|
-
|
|
8
|
-
expect(getUsing()).toEqual({ a: true, b: true });
|
|
9
|
-
|
|
10
|
-
resetUsing();
|
|
11
|
-
|
|
12
|
-
expect(getUsing()).toEqual({});
|
|
13
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WINDOW_DEPENDENCY_KEY,
|
|
3
|
-
SCREEN_DEPENDENCY_KEY,
|
|
4
|
-
} from "../dimensions/consts";
|
|
5
|
-
import { optimizeDependencies } from "../dimensions/utils";
|
|
6
|
-
|
|
7
|
-
describe("optimizeDependencies", () => {
|
|
8
|
-
it("should remove screen dependency when window dependency exist", () => {
|
|
9
|
-
expect(
|
|
10
|
-
optimizeDependencies({
|
|
11
|
-
[WINDOW_DEPENDENCY_KEY]: true,
|
|
12
|
-
[SCREEN_DEPENDENCY_KEY]: true,
|
|
13
|
-
})
|
|
14
|
-
).toEqual({
|
|
15
|
-
[WINDOW_DEPENDENCY_KEY]: true,
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("should skip removing", () => {
|
|
20
|
-
expect(
|
|
21
|
-
optimizeDependencies({
|
|
22
|
-
[WINDOW_DEPENDENCY_KEY]: true,
|
|
23
|
-
})
|
|
24
|
-
).toEqual({
|
|
25
|
-
[WINDOW_DEPENDENCY_KEY]: true,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
expect(
|
|
29
|
-
optimizeDependencies({
|
|
30
|
-
[SCREEN_DEPENDENCY_KEY]: true,
|
|
31
|
-
})
|
|
32
|
-
).toEqual({
|
|
33
|
-
[SCREEN_DEPENDENCY_KEY]: true,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { makeUseStyles } from "../makeUseStyles";
|
|
2
|
-
|
|
3
|
-
{
|
|
4
|
-
const useStyles = makeUseStyles(() => ({
|
|
5
|
-
root: {
|
|
6
|
-
textAlign: "center",
|
|
7
|
-
},
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
const a: "center" = useStyles().root.textAlign;
|
|
11
|
-
|
|
12
|
-
// @ts-expect-error: expect literal type
|
|
13
|
-
const b: "not center" = useStyles().root.textAlign;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
interface Theme {
|
|
18
|
-
color: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const useStyles = makeUseStyles(({ color }: Theme) => ({
|
|
22
|
-
root: {
|
|
23
|
-
color,
|
|
24
|
-
textAlign: "center",
|
|
25
|
-
},
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
const a: "center" = useStyles().root.textAlign;
|
|
29
|
-
|
|
30
|
-
// @ts-expect-error: expect literal type
|
|
31
|
-
const b: "not center" = useStyles().root.textAlign;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
const useStyles = makeUseStyles(() => ({
|
|
36
|
-
root: {
|
|
37
|
-
// @ts-expect-error: invalid color value
|
|
38
|
-
color: [],
|
|
39
|
-
},
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
const {
|
|
43
|
-
root,
|
|
44
|
-
// @ts-expect-error: 'otherProps' not exist
|
|
45
|
-
otherProp,
|
|
46
|
-
} = useStyles();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
interface MyTheme {
|
|
51
|
-
color: {
|
|
52
|
-
red: string;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const useStyles = makeUseStyles((theme: MyTheme) => ({
|
|
57
|
-
root: {
|
|
58
|
-
color: theme.color.red,
|
|
59
|
-
// @ts-expect-error: 'blue' not exist in passed theme
|
|
60
|
-
borderColor: theme.color.blue,
|
|
61
|
-
},
|
|
62
|
-
}));
|
|
63
|
-
|
|
64
|
-
const {
|
|
65
|
-
root,
|
|
66
|
-
// @ts-expect-error: 'otherProps' not exist
|
|
67
|
-
otherProp,
|
|
68
|
-
} = useStyles();
|
|
69
|
-
}
|