@codeandmoney/soelma 0.0.0-dev.0 → 0.0.0-dev.10
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/.eslintrc.js +1 -5
- package/biome.jsonc +73 -0
- package/example/AppStyleX/app.json +4 -16
- package/example/AppStyleX/babel.config.js +1 -1
- package/example/AppStyleX/index.js +3 -3
- package/example/AppStyleX/metro.config.js +1 -4
- package/example/AppStyleX/src/App.tsx +7 -10
- package/example/AppStyleX/src/BottomNav/index.tsx +9 -15
- package/example/AppStyleX/src/Circle/index.tsx +6 -6
- package/example/AppStyleX/src/Circle/styles.ts +4 -4
- package/example/AppStyleX/src/Root/index.tsx +12 -18
- package/example/AppStyleX/src/Root/styles.ts +5 -5
- package/example/AppStyleX/src/ToggleButton/index.tsx +10 -24
- package/example/AppStyleX/src/ToggleButton/styles.ts +13 -15
- package/example/AppStyleX/src/style-system/hooks/useAnimatedBgColor.ts +2 -2
- package/example/AppStyleX/src/style-system/hooks/useAnimatedTextColor.ts +2 -2
- package/example/AppStyleX/src/style-system/hooks/useIsDark.ts +2 -2
- package/example/AppStyleX/src/style-system/palette.ts +6 -6
- package/example/AppStyleX/src/style-system/theme.ts +2 -2
- package/example/AppStyleX/src/style-system/utils.ts +4 -7
- package/example/AppStyleX/src/stylex.d.ts +3 -3
- package/package.json +15 -11
- package/src/appearance/index.ts +5 -12
- package/src/appearance/init.ts +2 -2
- package/src/context.ts +2 -5
- package/src/dark-mode/index.ts +2 -5
- package/src/dark-mode/init.ts +2 -2
- package/src/{dependencyUsage.ts → dependency-usage.ts} +0 -10
- package/src/dimensions/index.ts +1 -1
- package/src/dimensions/init.ts +5 -10
- package/src/dimensions/utils.ts +1 -3
- package/src/i18n.ts +1 -4
- package/src/index.ts +6 -6
- package/src/{makeUseStyles/createUseStylesTheme.js → make-use-styles/create-use-styles-theme.js} +23 -6
- package/src/{makeUseStyles/createUseStylesTheme.test.js → make-use-styles/create-use-styles-theme.test.js} +1 -1
- package/src/{makeUseStyles/createUseStylesWithoutTheme.js → make-use-styles/create-use-styles-without-theme.js} +20 -4
- package/src/make-use-styles/index.d.ts +20 -0
- package/src/make-use-styles/index.js +12 -0
- package/src/make-use-styles/types.ts +43 -0
- package/src/{makeUseStyles → make-use-styles}/utils.js +7 -12
- package/src/media-query/base.ts +19 -30
- package/src/media-query/breakpoints.ts +12 -37
- package/src/orientation.ts +3 -7
- package/src/safe-area/{eventEmitter.ts → event-emitter.ts} +1 -1
- package/src/safe-area/index.tsx +3 -3
- package/src/safe-area/init.tsx +2 -2
- package/src/safe-area/safe-area-provider.tsx +18 -0
- package/src/safe-area/{StylexSaveAreaConsumer.ts → stylex-save-area-consumer.ts} +4 -5
- package/src/safe-area/types.ts +2 -2
- package/src/{__tests__ → tests}/createEventEmitter.test.ts +1 -1
- package/src/{__tests__ → tests}/dependencyRegistry.test.ts +1 -1
- package/src/{__tests__ → tests}/dependencyUsage.test.ts +1 -1
- package/src/{__tests__ → tests}/dimensions.test.ts +4 -7
- package/src/{__tests__ → tests}/makeUseStyles.types-test.ts +1 -1
- package/src/{__tests__ → tests}/media-query.test.ts +1 -9
- package/src/{__tests__ → tests}/useTheme.test.ts +1 -1
- package/src/{__tests__ → tests}/withStyles.types-test.tsx +7 -8
- package/src/{useColorTransition.ts → use-color-transition.ts} +3 -3
- package/src/{useTheme.ts → use-theme.ts} +2 -4
- package/src/with-styles.tsx +22 -0
- package/tsconfig.build.json +31 -0
- package/src/makeUseStyles/index.d.ts +0 -7
- package/src/makeUseStyles/index.js +0 -12
- package/src/safe-area/SafeAreaProvider.tsx +0 -17
- package/src/withStyles.tsx +0 -35
- /package/src/{createEventEmitter.ts → create-event-emitter.ts} +0 -0
- /package/src/{DefaultTheme.ts → default-theme.ts} +0 -0
- /package/src/{dependencyRegistry.ts → dependency-registry.ts} +0 -0
- /package/src/{makeUseStyles/createUseStylesWithoutTheme.test.js → make-use-styles/create-use-styles-without-theme.test.js} +0 -0
- /package/src/{makeUseStyles → make-use-styles}/index.test.js +0 -0
- /package/src/{makeUseStyles → make-use-styles}/test-type.js +0 -0
- /package/src/{__tests__ → tests}/createBreakpoints.test.ts +0 -0
- /package/src/{__tests__ → tests}/createBreakpointsMatcher.test.ts +0 -0
- /package/src/{__tests__ → tests}/createBreakpointsMatcher.types-test.ts +0 -0
- /package/src/{__tests__ → tests}/dark-mode.test.ts +0 -0
- /package/src/{__tests__ → tests}/orientation.test.ts +0 -0
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WINDOW_DEPENDENCY_KEY,
|
|
3
|
-
SCREEN_DEPENDENCY_KEY,
|
|
4
|
-
} from "../dimensions/consts";
|
|
1
|
+
import { WINDOW_DEPENDENCY_KEY, SCREEN_DEPENDENCY_KEY } from "../dimensions/consts";
|
|
5
2
|
import { optimizeDependencies } from "../dimensions/utils";
|
|
6
3
|
|
|
7
4
|
describe("optimizeDependencies", () => {
|
|
@@ -10,7 +7,7 @@ describe("optimizeDependencies", () => {
|
|
|
10
7
|
optimizeDependencies({
|
|
11
8
|
[WINDOW_DEPENDENCY_KEY]: true,
|
|
12
9
|
[SCREEN_DEPENDENCY_KEY]: true,
|
|
13
|
-
})
|
|
10
|
+
}),
|
|
14
11
|
).toEqual({
|
|
15
12
|
[WINDOW_DEPENDENCY_KEY]: true,
|
|
16
13
|
});
|
|
@@ -20,7 +17,7 @@ describe("optimizeDependencies", () => {
|
|
|
20
17
|
expect(
|
|
21
18
|
optimizeDependencies({
|
|
22
19
|
[WINDOW_DEPENDENCY_KEY]: true,
|
|
23
|
-
})
|
|
20
|
+
}),
|
|
24
21
|
).toEqual({
|
|
25
22
|
[WINDOW_DEPENDENCY_KEY]: true,
|
|
26
23
|
});
|
|
@@ -28,7 +25,7 @@ describe("optimizeDependencies", () => {
|
|
|
28
25
|
expect(
|
|
29
26
|
optimizeDependencies({
|
|
30
27
|
[SCREEN_DEPENDENCY_KEY]: true,
|
|
31
|
-
})
|
|
28
|
+
}),
|
|
32
29
|
).toEqual({
|
|
33
30
|
[SCREEN_DEPENDENCY_KEY]: true,
|
|
34
31
|
});
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { Dimensions } from "react-native";
|
|
2
|
-
import {
|
|
3
|
-
maxHeight,
|
|
4
|
-
maxWidth,
|
|
5
|
-
minHeight,
|
|
6
|
-
minWidth,
|
|
7
|
-
aspectRatio,
|
|
8
|
-
minAspectRatio,
|
|
9
|
-
maxAspectRatio,
|
|
10
|
-
} from "../media-query";
|
|
2
|
+
import { maxHeight, maxWidth, minHeight, minWidth, aspectRatio, minAspectRatio, maxAspectRatio } from "../media-query";
|
|
11
3
|
|
|
12
4
|
const mockStyle = { color: "black" };
|
|
13
5
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
import { FC, forwardRef } from "react";
|
|
2
4
|
import { TextInput } from "react-native";
|
|
3
|
-
import { InferInjectedStyledProps, withStyles } from "../
|
|
4
|
-
import { makeUseStyles } from "../
|
|
5
|
+
import { InferInjectedStyledProps, withStyles } from "../with-styles";
|
|
6
|
+
import { makeUseStyles } from "../make-use-styles";
|
|
5
7
|
|
|
6
8
|
{
|
|
7
9
|
const useStyles = makeUseStyles(() => ({
|
|
@@ -14,7 +16,7 @@ import { makeUseStyles } from "../makeUseStyles";
|
|
|
14
16
|
a: boolean;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
function Component(props: Props): JSX.Element | null {
|
|
19
|
+
function Component(props: Props): React.JSX.Element | null {
|
|
18
20
|
props.styles.root.color = "";
|
|
19
21
|
|
|
20
22
|
// @ts-expect-error 'a' not exists
|
|
@@ -59,10 +61,7 @@ import { makeUseStyles } from "../makeUseStyles";
|
|
|
59
61
|
a: boolean;
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
const WithRef = forwardRef<TextInput, Props>(function Component(
|
|
63
|
-
props,
|
|
64
|
-
ref
|
|
65
|
-
): JSX.Element | null {
|
|
64
|
+
const WithRef = forwardRef<TextInput, Props>(function Component(props, ref): React.JSX.Element | null {
|
|
66
65
|
props.styles.root.color = "";
|
|
67
66
|
|
|
68
67
|
// @ts-expect-error 'a' not exists
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef } from "react";
|
|
2
2
|
import { Animated } from "react-native";
|
|
3
|
-
import { DefaultTheme } from "./
|
|
4
|
-
import { useTheme } from "./
|
|
3
|
+
import { DefaultTheme } from "./default-theme";
|
|
4
|
+
import { useTheme } from "./use-theme";
|
|
5
5
|
|
|
6
6
|
const { Value, timing } = Animated;
|
|
7
7
|
|
|
@@ -10,7 +10,7 @@ const defaultOptions = { duration: 250 };
|
|
|
10
10
|
|
|
11
11
|
export function useColorTransition<Theme = DefaultTheme>(
|
|
12
12
|
colorGetterFn: (theme: Theme) => string,
|
|
13
|
-
options = defaultOptions
|
|
13
|
+
options = defaultOptions,
|
|
14
14
|
): Animated.AnimatedInterpolation<string> {
|
|
15
15
|
const theme = useTheme<Theme>();
|
|
16
16
|
const currentColor = colorGetterFn(theme);
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
2
|
|
|
3
3
|
import { themeContext } from "./context";
|
|
4
|
-
import type { DefaultTheme } from "./
|
|
4
|
+
import type { DefaultTheme } from "./default-theme";
|
|
5
5
|
|
|
6
6
|
export const useTheme = <Theme = DefaultTheme>(): Theme => {
|
|
7
7
|
const contextValue = useContext(themeContext);
|
|
8
8
|
|
|
9
9
|
if (!contextValue) {
|
|
10
|
-
throw new Error(
|
|
11
|
-
"[react-native-stylex]: Please make sure that you wrapped your component with <ThemeProvider/>."
|
|
12
|
-
);
|
|
10
|
+
throw new Error("[react-native-stylex]: Please make sure that you wrapped your component with <ThemeProvider/>.");
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
return contextValue as Theme;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { ComponentProps, ComponentType, forwardRef, Ref, ComponentRef } from "react";
|
|
2
|
+
|
|
3
|
+
interface InjectedStyledProps<Styles> {
|
|
4
|
+
styles: Styles;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type InferInjectedStyledProps<Fn extends (...args: any) => any> = InjectedStyledProps<ReturnType<Fn>>;
|
|
8
|
+
|
|
9
|
+
export function withStyles<Styles>(useStyles: () => Styles) {
|
|
10
|
+
function WithStyles<TComponent extends ComponentType<any>>(Component: TComponent) {
|
|
11
|
+
const renderComponent = (props: Omit<ComponentProps<TComponent>, "styles">, ref: Ref<ComponentRef<TComponent>>) => {
|
|
12
|
+
const styles = useStyles();
|
|
13
|
+
// @ts-expect-error: 'ref' as never
|
|
14
|
+
return <Component {...props} ref={ref} styles={styles} />;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// @ts-expect-error
|
|
18
|
+
return forwardRef(renderComponent);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return WithStyles;
|
|
22
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "ESNext",
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"lib": ["ESNext"],
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"jsx": "react-native",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"noImplicitAny": true,
|
|
14
|
+
"strictNullChecks": true,
|
|
15
|
+
"strictFunctionTypes": true,
|
|
16
|
+
"strictBindCallApply": true,
|
|
17
|
+
"strictPropertyInitialization": true,
|
|
18
|
+
"noImplicitThis": true,
|
|
19
|
+
"alwaysStrict": true,
|
|
20
|
+
"noUnusedLocals": false,
|
|
21
|
+
"noUnusedParameters": true,
|
|
22
|
+
"noImplicitReturns": true,
|
|
23
|
+
"noFallthroughCasesInSwitch": true,
|
|
24
|
+
"noUncheckedIndexedAccess": true,
|
|
25
|
+
"forceConsistentCasingInFileNames": true,
|
|
26
|
+
"moduleResolution": "node",
|
|
27
|
+
"outDir": "./lib"
|
|
28
|
+
},
|
|
29
|
+
"include": ["./src"],
|
|
30
|
+
"exclude": ["./src/tests"]
|
|
31
|
+
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from "react-native";
|
|
2
|
-
import { DefaultTheme } from "../DefaultTheme";
|
|
3
|
-
|
|
4
|
-
export function makeUseStyles<
|
|
5
|
-
Theme extends DefaultTheme,
|
|
6
|
-
T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>
|
|
7
|
-
>(getStyles: (theme: Theme) => T | StyleSheet.NamedStyles<T>): () => T;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createUseStylesWithoutTheme } from "./createUseStylesWithoutTheme";
|
|
2
|
-
import { createUseStylesTheme } from "./createUseStylesTheme";
|
|
3
|
-
|
|
4
|
-
export function makeUseStyles(getStyles) {
|
|
5
|
-
const hasThemeDependency = getStyles.length === 1;
|
|
6
|
-
|
|
7
|
-
if (!hasThemeDependency) {
|
|
8
|
-
return createUseStylesWithoutTheme(getStyles);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return createUseStylesTheme(getStyles);
|
|
12
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { SafeAreaProvider as CoreSafeAreaProvider, initialWindowMetrics,initialWindowSafeAreaInsets } from "react-native-safe-area-context";
|
|
3
|
-
|
|
4
|
-
import { StylexSaveAreaConsumer } from "./StylexSaveAreaConsumer";
|
|
5
|
-
import { SafeAreaViewProps } from "./types";
|
|
6
|
-
|
|
7
|
-
export function SafeAreaProvider(props: SafeAreaViewProps): JSX.Element | null {
|
|
8
|
-
return (
|
|
9
|
-
<CoreSafeAreaProvider
|
|
10
|
-
initialSafeAreaInsets={props.initialSafeAreaInsets || initialWindowSafeAreaInsets}
|
|
11
|
-
initialMetrics={props.initialMetrics || initialWindowMetrics}
|
|
12
|
-
{...props}>
|
|
13
|
-
{props.children}
|
|
14
|
-
<StylexSaveAreaConsumer />
|
|
15
|
-
</CoreSafeAreaProvider>
|
|
16
|
-
);
|
|
17
|
-
}
|
package/src/withStyles.tsx
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import React, {
|
|
3
|
-
ComponentProps,
|
|
4
|
-
ComponentType,
|
|
5
|
-
forwardRef,
|
|
6
|
-
Ref,
|
|
7
|
-
ElementRef
|
|
8
|
-
} from "react";
|
|
9
|
-
|
|
10
|
-
interface InjectedStyledProps<Styles> {
|
|
11
|
-
styles: Styles;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type InferInjectedStyledProps<
|
|
15
|
-
Fn extends (...args: any) => any
|
|
16
|
-
> = InjectedStyledProps<ReturnType<Fn>>;
|
|
17
|
-
|
|
18
|
-
export function withStyles<Styles>(useStyles: () => Styles) {
|
|
19
|
-
function WithStyles<TComponent extends ComponentType<any>>(
|
|
20
|
-
Component: TComponent
|
|
21
|
-
) {
|
|
22
|
-
const renderComponent = (
|
|
23
|
-
props: Omit<ComponentProps<TComponent>, "styles">,
|
|
24
|
-
ref: Ref<ElementRef<TComponent>>
|
|
25
|
-
) => {
|
|
26
|
-
const styles = useStyles();
|
|
27
|
-
// @ts-expect-error: 'ref' as never
|
|
28
|
-
return <Component {...props} ref={ref} styles={styles} />;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return forwardRef(renderComponent);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return WithStyles;
|
|
35
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|