react-native-unistyles 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  [<img alt="react-native-unistyles" src="assets/banner.png">](https://reactnativeunistyles.vercel.app/)
2
2
 
3
3
  ![GitHub package.json version](https://img.shields.io/github/package-json/v/jpudysz/react-native-unistyles?style=for-the-badge)
4
+ [![npm downloads](https://img.shields.io/npm/dm/react-native-unistyles?style=for-the-badge)](https://www.npmjs.com/package/react-native-unistyles)
4
5
  [![npm downloads](https://img.shields.io/npm/dt/react-native-unistyles?style=for-the-badge)](https://www.npmjs.com/package/react-native-unistyles)
5
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-44CD11.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
6
7
  <br />
@@ -42,7 +42,7 @@ const parseStyle = (style, variant = {}, parseMediaQueries = true) => Object.ent
42
42
  ...Object.keys(value).reduce((acc, key) => ({
43
43
  ...acc,
44
44
  // this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
45
- ...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
45
+ ...parseStyle(value[key][variant[key]?.toString() || 'default'] ?? value[key].default ?? {})
46
46
  }), {})
47
47
  };
48
48
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_breakpoints","require","_common","_withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","withPlugins","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","parseMediaQueries","Object","entries","reduce","acc","Array","isArray","map","keys","default","getValueForBreakpoint"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAA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AQ,IAAID,eAAe,CAACC,KAAK,CAAC,EAAE;IACrDU,GAAG,CAACtB,GAAG,CAAY,GAAGY,KAAK;IAE3B,OAAOU,GAAG;EACd;EAEA,IAAItB,GAAG,KAAK,UAAU,EAAE;IACpB,OAAO;MACH,GAAGsB,GAAG;MACN,GAAIH,MAAM,CACLO,IAAI,CAACd,KAAK,CAAC,CACXS,MAAM,CAAC,CAACC,GAAG,EAAEtB,GAAG,MAAM;QACnB,GAAGsB,GAAG;QACN;QACA,GAAGb,UAAU,CAAEG,KAAK,CAAEZ,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAKY,KAAK,CAAEZ,GAAG,CAAC,CAAC2B,OAAO,IAAI,CAAC,CAAC;MAC/G,CAAC,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;EACL;;EAEA;EACA,IAAI,CAACT,iBAAiB,EAAE;IACpB,OAAO;MACH,GAAGI,GAAG;MACN,CAACtB,GAAG,GAAGY;IACX,CAAC;EACL;EAEA,OAAO;IACH,GAAGU,GAAG;IACN,CAACtB,GAAG,GAAG,IAAA4B,kCAAqB,EAAChB,KAAgC;EACjE,CAAC;AACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAAF,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
1
+ {"version":3,"names":["_breakpoints","require","_common","_withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","withPlugins","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","parseMediaQueries","Object","entries","reduce","acc","Array","isArray","map","keys","toString","default","getValueForBreakpoint"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC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V,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC,EAAE;IACrDU,GAAG,CAACtB,GAAG,CAAY,GAAGY,KAAK;IAE3B,OAAOU,GAAG;EACd;EAEA,IAAItB,GAAG,KAAK,UAAU,EAAE;IACpB,OAAO;MACH,GAAGsB,GAAG;MACN,GAAIH,MAAM,CACLO,IAAI,CAACd,KAAK,CAAC,CACXS,MAAM,CAAC,CAACC,GAAG,EAAEtB,GAAG,MAAM;QACnB,GAAGsB,GAAG;QACN;QACA,GAAGb,UAAU,CAAEG,KAAK,CAAEZ,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,EAAE2B,QAAQ,CAAC,CAAC,IAAI,SAAS,CAAC,IAAKf,KAAK,CAAEZ,GAAG,CAAC,CAAC4B,OAAO,IAAI,CAAC,CAAC;MAC3H,CAAC,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;EACL;;EAEA;EACA,IAAI,CAACV,iBAAiB,EAAE;IACpB,OAAO;MACH,GAAGI,GAAG;MACN,CAACtB,GAAG,GAAGY;IACX,CAAC;EACL;EAEA,OAAO;IACH,GAAGU,GAAG;IACN,CAACtB,GAAG,GAAG,IAAA6B,kCAAqB,EAACjB,KAAgC;EACjE,CAAC;AACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAAF,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
@@ -34,7 +34,7 @@ export const parseStyle = (style, variant = {}, parseMediaQueries = true) => Obj
34
34
  ...Object.keys(value).reduce((acc, key) => ({
35
35
  ...acc,
36
36
  // this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
37
- ...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
37
+ ...parseStyle(value[key][variant[key]?.toString() || 'default'] ?? value[key].default ?? {})
38
38
  }), {})
39
39
  };
40
40
  }
@@ -1 +1 @@
1
- {"version":3,"names":["getValueForBreakpoint","isAndroid","isIOS","withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","isPlatformColor","value","semantic","resource_paths","style","parseMediaQueries","Object","entries","reduce","acc","Array","isArray","map","keys","default"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,SAAS,EAAEC,KAAK,QAAQ,WAAW;AAC5C,SAASC,WAAW,QAAQ,eAAe;AAE3C,OAAO,MAAMC,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAKT,WAAW,CAACE,GAAG,EAAEQ,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEL,OAAO,CAAC;AACzH,CAAC,CAAC;AAEF,OAAO,MAAMO,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIb,KAAK,EAAE;IACP,OAAO,UAAU,IAAIa,KAAK,IAAI,OAAOA,KAAK,CAACC,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOf,SAAS,IAAI,gBAAgB,IAAIc,KAAK,IAAI,OAAOA,KAAK,CAACE,cAAc,KAAK,QAAQ;AAC7F,CAAC;AAED,OAAO,MAAMJ,UAAU,GAAGA,CACtBK,KAAQ,EACRX,OAAyC,GAAG,CAAC,CAAC,EAC9CY,iBAAiB,GAAG,IAAI,KACpBC,MAAM,CACTC,OAAO,CAACH,KAAK,IAAI,CAAC,CAAC,CAAC,CACpBI,MAAM,CAAC,CAACC,GAAG,EAAE,CAAClB,GAAG,EAAEU,KAAK,CAAC,KAAK;EAC3B;EACA,IAAIV,GAAG,KAAK,cAAc,IAAIA,GAAG,KAAM,kBAAkB,EAAE;IACvDkB,GAAG,CAAClB,GAAG,CAAC,GAAGQ,UAAU,CAACE,KAAK,EAAER,OAAO,CAAC;IAErC,OAAOgB,GAAG;EACd;;EAEA;EACA,IAAIlB,GAAG,KAAK,WAAW,IAAImB,KAAK,CAACC,OAAO,CAACV,KAAK,CAAC,EAAE;IAC7CQ,GAAG,CAAClB,GAAG,CAAC,GAAGU,KAAK,CAACW,GAAG,CAACX,KAAK,IAAIF,UAAU,CAACE,KAAK,EAAER,OAAO,CAAC,CAAC;IAEzD,OAAOgB,GAAG;EACd;;EAEA;EACA,IAAI,OAAOR,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC,EAAE;IACrDQ,GAAG,CAAClB,GAAG,CAAY,GAAGU,KAAK;IAE3B,OAAOQ,GAAG;EACd;EAEA,IAAIlB,GAAG,KAAK,UAAU,EAAE;IACpB,OAAO;MACH,GAAGkB,GAAG;MACN,GAAIH,MAAM,CACLO,IAAI,CAACZ,KAAK,CAAC,CACXO,MAAM,CAAC,CAACC,GAAG,EAAElB,GAAG,MAAM;QACnB,GAAGkB,GAAG;QACN;QACA,GAAGV,UAAU,CAAEE,KAAK,CAAEV,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAKU,KAAK,CAAEV,GAAG,CAAC,CAACuB,OAAO,IAAI,CAAC,CAAC;MAC/G,CAAC,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;EACL;;EAEA;EACA,IAAI,CAACT,iBAAiB,EAAE;IACpB,OAAO;MACH,GAAGI,GAAG;MACN,CAAClB,GAAG,GAAGU;IACX,CAAC;EACL;EAEA,OAAO;IACH,GAAGQ,GAAG;IACN,CAAClB,GAAG,GAAGL,qBAAqB,CAACe,KAAgC;EACjE,CAAC;AACL,CAAC,EAAE,CAAC,CAAM,CAAC"}
1
+ {"version":3,"names":["getValueForBreakpoint","isAndroid","isIOS","withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","isPlatformColor","value","semantic","resource_paths","style","parseMediaQueries","Object","entries","reduce","acc","Array","isArray","map","keys","toString","default"],"sourceRoot":"../../../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,CAAC,GAAGU,KAAK,CAACW,GAAG,CAACX,KAAK,IAAIF,UAAU,CAACE,KAAK,EAAER,OAAO,CAAC,CAAC;IAEzD,OAAOgB,GAAG;EACd;;EAEA;EACA,IAAI,OAAOR,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC,EAAE;IACrDQ,GAAG,CAAClB,GAAG,CAAY,GAAGU,KAAK;IAE3B,OAAOQ,GAAG;EACd;EAEA,IAAIlB,GAAG,KAAK,UAAU,EAAE;IACpB,OAAO;MACH,GAAGkB,GAAG;MACN,GAAIH,MAAM,CACLO,IAAI,CAACZ,KAAK,CAAC,CACXO,MAAM,CAAC,CAACC,GAAG,EAAElB,GAAG,MAAM;QACnB,GAAGkB,GAAG;QACN;QACA,GAAGV,UAAU,CAAEE,KAAK,CAAEV,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,EAAEuB,QAAQ,CAAC,CAAC,IAAI,SAAS,CAAC,IAAKb,KAAK,CAAEV,GAAG,CAAC,CAACwB,OAAO,IAAI,CAAC,CAAC;MAC3H,CAAC,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;EACL;;EAEA;EACA,IAAI,CAACV,iBAAiB,EAAE;IACpB,OAAO;MACH,GAAGI,GAAG;MACN,CAAClB,GAAG,GAAGU;IACX,CAAC;EACL;EAEA,OAAO;IACH,GAAGQ,GAAG;IACN,CAAClB,GAAG,GAAGL,qBAAqB,CAACe,KAAgC;EACjE,CAAC;AACL,CAAC,EAAE,CAAC,CAAM,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { mq } from './utils';
2
2
  import { useInitialTheme } from './hooks';
3
- import type { UnistylesPlugin } from './types';
3
+ import type { UnistylesPlugin, UnistylesValues } from './types';
4
4
  import type { UnistylesThemes, UnistylesBreakpoints } from './global';
5
5
  import { ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory } from './common';
6
6
  import { useStyles } from './useStyles';
@@ -73,5 +73,5 @@ declare const UnistylesRegistry: {
73
73
  };
74
74
  declare const UnistylesRuntime: import("./core").UnistylesRuntime;
75
75
  export { mq, useStyles, useInitialTheme, createStyleSheet, ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory, UnistylesRegistry, UnistylesRuntime };
76
- export type { UnistylesThemes, UnistylesBreakpoints, UnistylesPlugin };
76
+ export type { UnistylesThemes, UnistylesBreakpoints, UnistylesPlugin, UnistylesValues };
77
77
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAChG,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;GAGG;AACH,QAAA,MAAM,iBAAiB;IACnB;;;OAGG;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;CAEN,CAAA;AAED,QAAA,MAAM,gBAAgB,mCAAoB,CAAA;AAE1C,OAAO,EACH,EAAE,EACF,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EACnB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACpB,eAAe,EAClB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAChG,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;GAGG;AACH,QAAA,MAAM,iBAAiB;IACnB;;;OAGG;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;CAEN,CAAA;AAED,QAAA,MAAM,gBAAgB,mCAAoB,CAAA;AAE1C,OAAO,EACH,EAAE,EACF,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EACnB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,eAAe,EAClB,CAAA"}
@@ -2,7 +2,7 @@ export * from './normalizer';
2
2
  export * from './unistyles';
3
3
  export type { Optional, Nullable } from './common';
4
4
  export type { NestedStylePairs, UnistylesTheme, ScreenSize, NestedStyle, RNValue, RNStyle } from './core';
5
- export type { StyleSheetWithSuperPowers, StyleSheet, AllAvailableKeys } from './stylesheet';
5
+ export type { StyleSheetWithSuperPowers, StyleSheet, AllAvailableKeys, UnistylesValues } from './stylesheet';
6
6
  export type { ReactNativeStyleSheet } from './breakpoints';
7
7
  export type { ExtractVariantNames } from './variants';
8
8
  export type { UnistylesPlugin } from './plugin';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EACR,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACV,MAAM,QAAQ,CAAA;AACf,YAAY,EAAE,yBAAyB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC3F,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EACR,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACV,MAAM,QAAQ,CAAA;AACf,YAAY,EACR,yBAAyB,EACzB,UAAU,EACV,gBAAgB,EAChB,eAAe,EAClB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA"}
@@ -1,6 +1,8 @@
1
1
  export type ExtractVariantNames<T> = T extends (...args: any) => infer R ? ExtractVariantKeys<R> : ExtractVariantKeys<T>;
2
2
  type ExtractVariantKeys<T> = T extends object ? ExtractVariant<T[keyof T]> : never;
3
- type ExtractSubVariantKeys<T> = T extends object ? keyof Omit<T, 'default'> | undefined : never;
3
+ type HasTrue<T> = 'true' extends keyof T ? true : false;
4
+ type HasFalse<T> = 'false' extends keyof T ? true : false;
5
+ type ExtractSubVariantKeys<T> = T extends object ? [HasTrue<T>, HasFalse<T>] extends [true, true] ? keyof Omit<T, 'default'> | boolean | undefined : [HasTrue<T>] extends [true] ? keyof Omit<T, 'default'> | true | undefined : [HasFalse<T>] extends [true] ? keyof Omit<T, 'default'> | false | undefined : keyof Omit<T, 'default'> : never;
4
6
  type ExtractVariant<T> = T extends (...args: any) => infer R ? R extends {
5
7
  variants: infer V;
6
8
  } ? {
@@ -1 +1 @@
1
- {"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/types/variants.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,GAClE,kBAAkB,CAAC,CAAC,CAAC,GACrB,kBAAkB,CAAC,CAAC,CAAC,CAAA;AAE3B,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GACvC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAC1B,KAAK,CAAA;AAEX,KAAK,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC1C,MAAM,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,SAAS,GACpC,KAAK,CAAA;AAEX,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,GACtD,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;CAAE,GAC3B;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GACpD,KAAK,GACT,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;CAAE,GAC3B;KAAG,GAAG,IAAI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AC,GACpC,KAAK,CAAA;AAEX,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,GACtD,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;CAAE,GAC3B;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GACpD,KAAK,GACT,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;CAAE,GAC3B;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GACpD,KAAK,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { unistyles } from './core'
2
2
  import { mq } from './utils'
3
3
  import { useInitialTheme } from './hooks'
4
- import type { UnistylesPlugin } from './types'
4
+ import type { UnistylesPlugin, UnistylesValues } from './types'
5
5
  import type { UnistylesThemes, UnistylesBreakpoints } from './global'
6
6
  import { ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory } from './common'
7
7
  import { useStyles } from './useStyles'
@@ -46,5 +46,6 @@ export {
46
46
  export type {
47
47
  UnistylesThemes,
48
48
  UnistylesBreakpoints,
49
- UnistylesPlugin
49
+ UnistylesPlugin,
50
+ UnistylesValues
50
51
  }
@@ -9,7 +9,12 @@ export type {
9
9
  RNValue,
10
10
  RNStyle
11
11
  } from './core'
12
- export type { StyleSheetWithSuperPowers, StyleSheet, AllAvailableKeys } from './stylesheet'
12
+ export type {
13
+ StyleSheetWithSuperPowers,
14
+ StyleSheet,
15
+ AllAvailableKeys,
16
+ UnistylesValues
17
+ } from './stylesheet'
13
18
  export type { ReactNativeStyleSheet } from './breakpoints'
14
19
  export type { ExtractVariantNames } from './variants'
15
20
  export type { UnistylesPlugin } from './plugin'
@@ -6,8 +6,17 @@ type ExtractVariantKeys<T> = T extends object
6
6
  ? ExtractVariant<T[keyof T]>
7
7
  : never
8
8
 
9
+ type HasTrue<T> = 'true' extends keyof T ? true : false
10
+ type HasFalse<T> = 'false' extends keyof T ? true : false
11
+
9
12
  type ExtractSubVariantKeys<T> = T extends object
10
- ? keyof Omit<T, 'default'> | undefined
13
+ ? [HasTrue<T>, HasFalse<T>] extends [true, true]
14
+ ? keyof Omit<T, 'default'> | boolean | undefined
15
+ : [HasTrue<T>] extends [true]
16
+ ? keyof Omit<T, 'default'> | true | undefined
17
+ : [HasFalse<T>] extends [true]
18
+ ? keyof Omit<T, 'default'> | false | undefined
19
+ : keyof Omit<T, 'default'>
11
20
  : never
12
21
 
13
22
  type ExtractVariant<T> = T extends (...args: any) => infer R
@@ -55,7 +55,7 @@ export const parseStyle = <T extends RNStyle>(
55
55
  .reduce((acc, key) => ({
56
56
  ...acc,
57
57
  // this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
58
- ...parseStyle((value)[key][variant[key as keyof typeof variant] || 'default'] ?? (value)[key].default ?? {})
58
+ ...parseStyle((value)[key][variant[key as keyof typeof variant]?.toString() || 'default'] ?? (value)[key].default ?? {})
59
59
  }), {})
60
60
  }
61
61
  }