@codeandmoney/soelma 0.0.0-dev.1 → 0.0.0-dev.4
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/context.d.ts +0 -1
- package/makeUseStyles/createUseStylesWithoutTheme.js +10 -3
- package/makeUseStyles/index.d.ts +27 -1
- package/makeUseStyles/index.js +2 -2
- package/makeUseStyles/types.d.ts +0 -0
- package/makeUseStyles/types.js +39 -0
- package/makeUseStyles/types.ts +43 -0
- package/media-query/base.d.ts +1 -1
- package/media-query/breakpoints.d.ts +3 -3
- package/media-query/breakpoints.js +1 -1
- package/package.json +1 -1
- package/safe-area/SafeAreaProvider.d.ts +2 -2
- package/safe-area/StylexSaveAreaConsumer.d.ts +2 -2
- package/safe-area/state.d.ts +1 -6
- package/withStyles.d.ts +2 -2
- package/withStyles.js +1 -1
package/context.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { DefaultTheme } from "./DefaultTheme";
|
|
3
2
|
export declare const themeContext: import("react").Context<DefaultTheme | null>;
|
|
4
3
|
export declare const ThemeProvider: import("react").Provider<DefaultTheme | null>, ThemeConsumer: import("react").Consumer<DefaultTheme | null>;
|
|
@@ -2,9 +2,10 @@ import { StyleSheet } from "react-native";
|
|
|
2
2
|
import { resetUsing } from "../dependencyUsage";
|
|
3
3
|
import { getDependenciesKeys, subscribe, useForceUpdate } from "./utils";
|
|
4
4
|
|
|
5
|
-
export function createUseStylesWithoutTheme(getStyles) {
|
|
5
|
+
export function createUseStylesWithoutTheme(getStyles, configVariants) {
|
|
6
6
|
const scope = {
|
|
7
7
|
style: null,
|
|
8
|
+
variants: null,
|
|
8
9
|
forceUpdate: [],
|
|
9
10
|
unsubscribe: () => {},
|
|
10
11
|
};
|
|
@@ -28,10 +29,16 @@ export function createUseStylesWithoutTheme(getStyles) {
|
|
|
28
29
|
|
|
29
30
|
initStyle();
|
|
30
31
|
|
|
31
|
-
function useStyles() {
|
|
32
|
+
function useStyles(variants) {
|
|
32
33
|
useForceUpdate(scope);
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
const requestedVarians = {};
|
|
36
|
+
for (const key in variants) {
|
|
37
|
+
const value = configVariants[key][variants[key]];
|
|
38
|
+
Object.assign(requestedVarians, value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return { ...scope.style, ...StyleSheet.create(requestedVarians) };
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
return useStyles;
|
package/makeUseStyles/index.d.ts
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
2
|
import { DefaultTheme } from "../DefaultTheme";
|
|
3
3
|
|
|
4
|
+
// export function makeUseStyles<
|
|
5
|
+
// Theme extends DefaultTheme,
|
|
6
|
+
// T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>,
|
|
7
|
+
// V extends Record<
|
|
8
|
+
// string,
|
|
9
|
+
// StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>
|
|
10
|
+
// >,
|
|
11
|
+
// >(
|
|
12
|
+
// getStyles: (theme: Theme) => T | StyleSheet.NamedStyles<T>,
|
|
13
|
+
// variants: V,
|
|
14
|
+
// ): () => T;
|
|
15
|
+
|
|
4
16
|
export function makeUseStyles<
|
|
5
17
|
Theme extends DefaultTheme,
|
|
6
18
|
T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>,
|
|
7
|
-
|
|
19
|
+
V extends Record<string, StyleSheet.NamedStyles<any>>,
|
|
20
|
+
>(
|
|
21
|
+
getStyles: (theme: Theme) => T | StyleSheet.NamedStyles<T>,
|
|
22
|
+
variants: V,
|
|
23
|
+
): <Variants extends { [Key in keyof V]: keyof V[Key] }>(
|
|
24
|
+
variants?: Partial<Variants>,
|
|
25
|
+
) => T & {
|
|
26
|
+
variants: {
|
|
27
|
+
[VKey in keyof Variants]: VKey extends keyof V
|
|
28
|
+
? V[VKey][Variants[VKey]]
|
|
29
|
+
: never;
|
|
30
|
+
}[keyof Variants];
|
|
31
|
+
} {
|
|
32
|
+
return ((variants: any) => {}) as any;
|
|
33
|
+
}
|
package/makeUseStyles/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createUseStylesWithoutTheme } from "./createUseStylesWithoutTheme";
|
|
2
2
|
import { createUseStylesTheme } from "./createUseStylesTheme";
|
|
3
3
|
|
|
4
|
-
export function makeUseStyles(getStyles) {
|
|
4
|
+
export function makeUseStyles(getStyles, variants) {
|
|
5
5
|
const hasThemeDependency = getStyles.length === 1;
|
|
6
6
|
|
|
7
7
|
if (!hasThemeDependency) {
|
|
8
|
-
return createUseStylesWithoutTheme(getStyles);
|
|
8
|
+
return createUseStylesWithoutTheme(getStyles, variants);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
return createUseStylesTheme(getStyles);
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { StyleSheet } from "react-native";
|
|
3
|
+
// import { DefaultTheme } from "../DefaultTheme";
|
|
4
|
+
// // // Source - https://stackoverflow.com/a/50375286
|
|
5
|
+
// // // Posted by jcalz, modified by community. See post 'Timeline' for change history
|
|
6
|
+
// // // Retrieved 2026-01-07, License - CC BY-SA 4.0
|
|
7
|
+
// // type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (
|
|
8
|
+
// // x: infer I,
|
|
9
|
+
// // ) => void
|
|
10
|
+
// // ? I
|
|
11
|
+
// // : never;
|
|
12
|
+
// export function makeUseStyles<
|
|
13
|
+
// Theme extends DefaultTheme,
|
|
14
|
+
// T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>,
|
|
15
|
+
// V extends Record<string, StyleSheet.NamedStyles<any>>,
|
|
16
|
+
// >(
|
|
17
|
+
// getStyles: (theme: Theme) => T | StyleSheet.NamedStyles<T>,
|
|
18
|
+
// variants: V,
|
|
19
|
+
// ): <Variants extends { [Key in keyof V]: keyof V[Key] }>(
|
|
20
|
+
// variants?: Partial<Variants>,
|
|
21
|
+
// ) => T & {
|
|
22
|
+
// variants: {
|
|
23
|
+
// [VKey in keyof Variants]: VKey extends keyof V
|
|
24
|
+
// ? V[VKey][Variants[VKey]]
|
|
25
|
+
// : never;
|
|
26
|
+
// }[keyof Variants];
|
|
27
|
+
// } {
|
|
28
|
+
// return ((variants: any) => {}) as any;
|
|
29
|
+
// }
|
|
30
|
+
// const useStyles = makeUseStyles(() => ({ some: { alignContent: "center" } }), {
|
|
31
|
+
// other: {
|
|
32
|
+
// one: { alignContent: "flex-end", fontStyle: "italic", fontFamily: "Inter" },
|
|
33
|
+
// two: { alignContent: "flex-end" },
|
|
34
|
+
// },
|
|
35
|
+
// more: {
|
|
36
|
+
// lol: { color: "red", width: 123 },
|
|
37
|
+
// },
|
|
38
|
+
// });
|
|
39
|
+
// const res = useStyles({ more: "lol"});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// import { StyleSheet } from "react-native";
|
|
2
|
+
// import { DefaultTheme } from "../DefaultTheme";
|
|
3
|
+
|
|
4
|
+
// // // Source - https://stackoverflow.com/a/50375286
|
|
5
|
+
// // // Posted by jcalz, modified by community. See post 'Timeline' for change history
|
|
6
|
+
// // // Retrieved 2026-01-07, License - CC BY-SA 4.0
|
|
7
|
+
|
|
8
|
+
// // type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (
|
|
9
|
+
// // x: infer I,
|
|
10
|
+
// // ) => void
|
|
11
|
+
// // ? I
|
|
12
|
+
// // : never;
|
|
13
|
+
|
|
14
|
+
// export function makeUseStyles<
|
|
15
|
+
// Theme extends DefaultTheme,
|
|
16
|
+
// T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>,
|
|
17
|
+
// V extends Record<string, StyleSheet.NamedStyles<any>>,
|
|
18
|
+
// >(
|
|
19
|
+
// getStyles: (theme: Theme) => T | StyleSheet.NamedStyles<T>,
|
|
20
|
+
// variants: V,
|
|
21
|
+
// ): <Variants extends { [Key in keyof V]: keyof V[Key] }>(
|
|
22
|
+
// variants?: Partial<Variants>,
|
|
23
|
+
// ) => T & {
|
|
24
|
+
// variants: {
|
|
25
|
+
// [VKey in keyof Variants]: VKey extends keyof V
|
|
26
|
+
// ? V[VKey][Variants[VKey]]
|
|
27
|
+
// : never;
|
|
28
|
+
// }[keyof Variants];
|
|
29
|
+
// } {
|
|
30
|
+
// return ((variants: any) => {}) as any;
|
|
31
|
+
// }
|
|
32
|
+
|
|
33
|
+
// const useStyles = makeUseStyles(() => ({ some: { alignContent: "center" } }), {
|
|
34
|
+
// other: {
|
|
35
|
+
// one: { alignContent: "flex-end", fontStyle: "italic", fontFamily: "Inter" },
|
|
36
|
+
// two: { alignContent: "flex-end" },
|
|
37
|
+
// },
|
|
38
|
+
// more: {
|
|
39
|
+
// lol: { color: "red", width: 123 },
|
|
40
|
+
// },
|
|
41
|
+
// });
|
|
42
|
+
|
|
43
|
+
// const res = useStyles({ more: "lol"});
|
package/media-query/base.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ScaledSize } from "react-native";
|
|
|
2
2
|
export declare const createDimensionQueryHelper: <Value>(queryFunction: (options: {
|
|
3
3
|
value: Value;
|
|
4
4
|
dimensions: ScaledSize;
|
|
5
|
-
}) => boolean) => <T>(value: Value, styles: T) =>
|
|
5
|
+
}) => boolean) => <T>(value: Value, styles: T) => null | T;
|
|
6
6
|
export declare const maxHeight: <T>(value: number, styles: T) => T | null;
|
|
7
7
|
export declare const maxWidth: <T>(value: number, styles: T) => T | null;
|
|
8
8
|
export declare const minHeight: <T>(value: number, styles: T) => T | null;
|
|
@@ -11,8 +11,8 @@ interface BreakpointsMatcher<TBreakpoints> {
|
|
|
11
11
|
export declare function createBreakpointsMatcher<TBreakpoints extends Record<string, number>>(breakpoints: TBreakpoints, matchFunction?: <T>(value: number, styles: T) => T | null): BreakpointsMatcher<TBreakpoints>;
|
|
12
12
|
export declare function createBreakpoints<TBreakpoints extends Record<string, number>>(breakpoints: TBreakpoints): {
|
|
13
13
|
up: <T>(key: keyof TBreakpoints, value: T) => T | null;
|
|
14
|
-
down: <
|
|
15
|
-
only: <
|
|
16
|
-
between: <
|
|
14
|
+
down: <T>(key: keyof TBreakpoints, value: T) => T | null;
|
|
15
|
+
only: <T>(key: keyof TBreakpoints, value: T) => T | null;
|
|
16
|
+
between: <T>(start: keyof TBreakpoints, end: keyof TBreakpoints, value: T) => T | null;
|
|
17
17
|
};
|
|
18
18
|
export {};
|
|
@@ -15,7 +15,7 @@ const toOrderedBreakpointNames = (values, breakpoints, matchFunction) => {
|
|
|
15
15
|
export function createBreakpointsMatcher(breakpoints, matchFunction = minWidth) {
|
|
16
16
|
return function breakpointsMatcher(values) {
|
|
17
17
|
/* istanbul ignore next */
|
|
18
|
-
// @ts-expect-error
|
|
18
|
+
// @ts-expect-error
|
|
19
19
|
if (process.env.NODE_ENV !== "production") {
|
|
20
20
|
const invalidKeys = Object.keys(values).filter((key) => {
|
|
21
21
|
return key !== "default" && breakpoints[key] === undefined;
|
package/package.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { SafeAreaViewProps } from "./types";
|
|
3
|
-
export declare function SafeAreaProvider(props: SafeAreaViewProps): JSX.Element | null;
|
|
3
|
+
export declare function SafeAreaProvider(props: SafeAreaViewProps): React.JSX.Element | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function StylexSaveAreaConsumer(): JSX.Element | null;
|
|
1
|
+
import type React from "react";
|
|
2
|
+
export declare function StylexSaveAreaConsumer(): React.JSX.Element | null;
|
package/safe-area/state.d.ts
CHANGED
package/withStyles.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { ComponentType } from "react";
|
|
2
2
|
interface InjectedStyledProps<Styles> {
|
|
3
3
|
styles: Styles;
|
|
4
4
|
}
|
|
5
5
|
export type InferInjectedStyledProps<Fn extends (...args: any) => any> = InjectedStyledProps<ReturnType<Fn>>;
|
|
6
|
-
export declare function withStyles<Styles>(useStyles: () => Styles): <TComponent extends
|
|
6
|
+
export declare function withStyles<Styles>(useStyles: () => Styles): <TComponent extends ComponentType<any>>(Component: TComponent) => React.ForwardRefExoticComponent<React.PropsWithoutRef<React.ComponentProps<TComponent>> & React.RefAttributes<React.ComponentRef<TComponent>>>;
|
|
7
7
|
export {};
|
package/withStyles.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
import React, { forwardRef, } from "react";
|
|
3
2
|
export function withStyles(useStyles) {
|
|
4
3
|
function WithStyles(Component) {
|
|
@@ -7,6 +6,7 @@ export function withStyles(useStyles) {
|
|
|
7
6
|
// @ts-expect-error: 'ref' as never
|
|
8
7
|
return <Component {...props} ref={ref} styles={styles}/>;
|
|
9
8
|
};
|
|
9
|
+
// @ts-expect-error
|
|
10
10
|
return forwardRef(renderComponent);
|
|
11
11
|
}
|
|
12
12
|
return WithStyles;
|