@codeandmoney/soelma 0.0.0-dev.5 → 0.0.0-dev.6
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.
|
@@ -32,13 +32,21 @@ export function createUseStylesWithoutTheme(getStyles, configVariants) {
|
|
|
32
32
|
function useStyles(variants) {
|
|
33
33
|
useForceUpdate(scope);
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
if (configVariants) {
|
|
36
|
+
const requestedVarians = {};
|
|
37
|
+
|
|
38
|
+
for (const key in variants) {
|
|
39
|
+
const value = configVariants[key][variants[key]];
|
|
40
|
+
Object.assign(requestedVarians, value);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
...scope.style,
|
|
45
|
+
...StyleSheet.create({ variants: requestedVarians }),
|
|
46
|
+
};
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
return
|
|
49
|
+
return scope.style;
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
return useStyles;
|
package/makeUseStyles/index.d.ts
CHANGED
|
@@ -1,33 +1,22 @@
|
|
|
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
|
-
|
|
16
4
|
export function makeUseStyles<
|
|
17
5
|
Theme extends DefaultTheme,
|
|
18
6
|
T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>,
|
|
19
|
-
V extends Record<string, StyleSheet.NamedStyles<any
|
|
7
|
+
V extends Record<string, StyleSheet.NamedStyles<any>> | undefined,
|
|
20
8
|
>(
|
|
21
9
|
getStyles: (theme: Theme) => T | StyleSheet.NamedStyles<T>,
|
|
22
|
-
variants
|
|
10
|
+
variants?: V | undefined,
|
|
23
11
|
): <Variants extends { [Key in keyof V]: keyof V[Key] }>(
|
|
24
12
|
variants?: Partial<Variants>,
|
|
25
|
-
) => T &
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
13
|
+
) => T &
|
|
14
|
+
(V extends undefined
|
|
15
|
+
? {}
|
|
16
|
+
: {
|
|
17
|
+
variants: {
|
|
18
|
+
[VKey in keyof Variants]: VKey extends keyof V
|
|
19
|
+
? V[VKey][Variants[VKey]]
|
|
20
|
+
: never;
|
|
21
|
+
}[keyof Variants];
|
|
22
|
+
});
|