@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
- const requestedVarians = {};
36
- for (const key in variants) {
37
- const value = configVariants[key][variants[key]];
38
- Object.assign(requestedVarians, value);
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 { ...scope.style, ...StyleSheet.create({ variants: requestedVarians}) };
49
+ return scope.style;
42
50
  }
43
51
 
44
52
  return useStyles;
@@ -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: V,
10
+ variants?: V | undefined,
23
11
  ): <Variants extends { [Key in keyof V]: keyof V[Key] }>(
24
12
  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
- }
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
+ });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.0.0-dev.5",
6
+ "version": "0.0.0-dev.6",
7
7
  "private": false,
8
8
  "main": "index.js",
9
9
  "types": "index.d.ts",