react-native-unistyles 1.0.0-beta.5 → 1.0.0-rc.1

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.
Files changed (74) hide show
  1. package/README.md +6 -588
  2. package/lib/commonjs/createUnistyles.js +0 -9
  3. package/lib/commonjs/createUnistyles.js.map +1 -1
  4. package/lib/commonjs/types/breakpoints.js +6 -0
  5. package/lib/commonjs/types/breakpoints.js.map +1 -0
  6. package/lib/commonjs/{types.js → types/core.js} +1 -1
  7. package/lib/commonjs/types/core.js.map +1 -0
  8. package/lib/commonjs/types/index.js +2 -0
  9. package/lib/commonjs/types/index.js.map +1 -0
  10. package/lib/commonjs/types/mediaQueries.js.map +1 -0
  11. package/lib/commonjs/utils/index.js +43 -0
  12. package/lib/commonjs/utils/index.js.map +1 -1
  13. package/lib/module/createUnistyles.js +0 -9
  14. package/lib/module/createUnistyles.js.map +1 -1
  15. package/lib/module/types/breakpoints.js +2 -0
  16. package/lib/module/types/breakpoints.js.map +1 -0
  17. package/lib/module/types/core.js +2 -0
  18. package/lib/module/types/core.js.map +1 -0
  19. package/lib/module/types/index.js +2 -0
  20. package/lib/module/types/index.js.map +1 -0
  21. package/lib/module/types/mediaQueries.js.map +1 -0
  22. package/lib/module/utils/index.js +2 -1
  23. package/lib/module/utils/index.js.map +1 -1
  24. package/lib/typescript/src/createUnistyles.d.ts +1 -5
  25. package/lib/typescript/src/createUnistyles.d.ts.map +1 -1
  26. package/lib/typescript/src/types/breakpoints.d.ts +19 -0
  27. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -0
  28. package/lib/typescript/src/types/core.d.ts +32 -0
  29. package/lib/typescript/src/types/core.d.ts.map +1 -0
  30. package/lib/typescript/src/types/index.d.ts +3 -0
  31. package/lib/typescript/src/types/index.d.ts.map +1 -0
  32. package/lib/typescript/src/types/mediaQueries.d.ts +2 -0
  33. package/lib/typescript/src/types/mediaQueries.d.ts.map +1 -0
  34. package/lib/typescript/src/utils/index.d.ts +2 -1
  35. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  36. package/package.json +13 -10
  37. package/src/__tests__/createUnistyles.spec.tsx +158 -0
  38. package/src/createUnistyles.ts +0 -10
  39. package/src/types/breakpoints.ts +33 -0
  40. package/src/types/core.ts +73 -0
  41. package/src/types/index.ts +9 -0
  42. package/src/types/mediaQueries.ts +69 -0
  43. package/src/utils/index.ts +9 -1
  44. package/lib/commonjs/mediaQueries.js.map +0 -1
  45. package/lib/commonjs/types.js.map +0 -1
  46. package/lib/commonjs/utils/breakpoints.spec.js +0 -154
  47. package/lib/commonjs/utils/breakpoints.spec.js.map +0 -1
  48. package/lib/commonjs/utils/mediaQueries.spec.js +0 -220
  49. package/lib/commonjs/utils/mediaQueries.spec.js.map +0 -1
  50. package/lib/commonjs/utils/styles.spec.js +0 -174
  51. package/lib/commonjs/utils/styles.spec.js.map +0 -1
  52. package/lib/module/mediaQueries.js.map +0 -1
  53. package/lib/module/types.js +0 -2
  54. package/lib/module/types.js.map +0 -1
  55. package/lib/module/utils/breakpoints.spec.js +0 -152
  56. package/lib/module/utils/breakpoints.spec.js.map +0 -1
  57. package/lib/module/utils/mediaQueries.spec.js +0 -218
  58. package/lib/module/utils/mediaQueries.spec.js.map +0 -1
  59. package/lib/module/utils/styles.spec.js +0 -172
  60. package/lib/module/utils/styles.spec.js.map +0 -1
  61. package/lib/typescript/src/mediaQueries.d.ts +0 -2
  62. package/lib/typescript/src/mediaQueries.d.ts.map +0 -1
  63. package/lib/typescript/src/types.d.ts +0 -67
  64. package/lib/typescript/src/types.d.ts.map +0 -1
  65. package/lib/typescript/src/utils/breakpoints.spec.d.ts +0 -2
  66. package/lib/typescript/src/utils/breakpoints.spec.d.ts.map +0 -1
  67. package/lib/typescript/src/utils/mediaQueries.spec.d.ts +0 -2
  68. package/lib/typescript/src/utils/mediaQueries.spec.d.ts.map +0 -1
  69. package/lib/typescript/src/utils/styles.spec.d.ts +0 -2
  70. package/lib/typescript/src/utils/styles.spec.d.ts.map +0 -1
  71. package/src/mediaQueries.ts +0 -33
  72. package/src/types.ts +0 -123
  73. /package/lib/commonjs/{mediaQueries.js → types/mediaQueries.js} +0 -0
  74. /package/lib/module/{mediaQueries.js → types/mediaQueries.js} +0 -0
@@ -3,12 +3,54 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "extractValues", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _mediaQueries.extractValues;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
7
13
  enumerable: true,
8
14
  get: function () {
9
15
  return _breakpoints.getBreakpointFromScreenWidth;
10
16
  }
11
17
  });
18
+ Object.defineProperty(exports, "getKeyForCustomMediaQuery", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _mediaQueries.getKeyForCustomMediaQuery;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "getValueForBreakpoint", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _breakpoints.getValueForBreakpoint;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "isMediaQuery", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _mediaQueries.isMediaQuery;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "isWithinTheHeight", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _mediaQueries.isWithinTheHeight;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "isWithinTheWidth", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _mediaQueries.isWithinTheWidth;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _mediaQueries.isWithinTheWidthAndHeight;
52
+ }
53
+ });
12
54
  Object.defineProperty(exports, "normalizeStyles", {
13
55
  enumerable: true,
14
56
  get: function () {
@@ -36,4 +78,5 @@ Object.defineProperty(exports, "sortAndValidateBreakpoints", {
36
78
  var _normalizeStyles = require("./normalizeStyles");
37
79
  var _breakpoints = require("./breakpoints");
38
80
  var _styles = require("./styles");
81
+ var _mediaQueries = require("./mediaQueries");
39
82
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_normalizeStyles","require","_breakpoints","_styles"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA"}
1
+ {"version":3,"names":["_normalizeStyles","require","_breakpoints","_styles","_mediaQueries"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA"}
@@ -7,15 +7,6 @@ export const createUnistyles = breakpoints => {
7
7
  const sortedBreakpoints = sortAndValidateBreakpoints(breakpoints);
8
8
  const sortedBreakpointEntries = Object.entries(sortedBreakpoints);
9
9
  return {
10
- /**
11
- * @deprecated The method should not be used, proposed version by the community is createStyleSheet, will be removed in RC
12
- */
13
- createStyles: styles => {
14
- if (typeof styles === 'function') {
15
- return styles;
16
- }
17
- return styles;
18
- },
19
10
  createStyleSheet: styles => {
20
11
  if (typeof styles === 'function') {
21
12
  return styles;
@@ -1 +1 @@
1
- {"version":3,"names":["useContext","StyleSheet","UnistylesContext","useDimensions","getBreakpointFromScreenWidth","proxifyFunction","parseStyle","sortAndValidateBreakpoints","createUnistyles","breakpoints","sortedBreakpoints","sortedBreakpointEntries","Object","entries","createStyles","styles","createStyleSheet","useStyles","stylesheet","theme","screenSize","parsedStyles","breakpoint","width","dynamicStyleSheet","reduce","acc","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,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;QAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;QACtB,MAAMG,KAAK,GAAGD,KAAiC;QAE/C,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;UAC7B,OAAO;YACH,GAAGH,GAAG;YACN,CAACE,GAAG,GAAGvB,eAAe,CAAIwB,KAAK,EAAEP,UAAU,EAAEF,UAAU,EAAET,uBAAuB;UACpF,CAAC;QACL;QAEA,OAAOV,UAAU,CAAC8B,MAAM,CAAC;UACrB,GAAGL,GAAG;UACN,CAACE,GAAG,GAAGtB,UAAU,CAAQwB,KAAK,EAAER,UAAU,EAAEF,UAAU,EAAET,uBAAuB;QACnF,CAAC,CAAC;MACN,CAAC,EAAE,CAAC,CAAO,CAAC;MAEhB,OAAO;QACHQ,KAAK;QACLJ,MAAM,EAAES;MACZ,CAAC;IACL;EACJ,CAAC;AACL,CAAC"}
1
+ {"version":3,"names":["useContext","StyleSheet","UnistylesContext","useDimensions","getBreakpointFromScreenWidth","proxifyFunction","parseStyle","sortAndValidateBreakpoints","createUnistyles","breakpoints","sortedBreakpoints","sortedBreakpointEntries","Object","entries","createStyleSheet","styles","useStyles","stylesheet","theme","screenSize","parsedStyles","breakpoint","width","dynamicStyleSheet","reduce","acc","_ref","key","value","style","create"],"sourceRoot":"../../src","sources":["createUnistyles.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,UAAU,QAAQ,cAAc;AASzC,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,aAAa,QAAQ,SAAS;AACvC,SAASC,4BAA4B,EAAEC,eAAe,EAAEC,UAAU,EAAEC,0BAA0B,QAAQ,SAAS;AAE/G,OAAO,MAAMC,eAAe,GAAmCC,WAAc,IAAK;EAC9E,MAAMC,iBAAiB,GAAGH,0BAA0B,CAACE,WAAW,CAAC;EACjE,MAAME,uBAAuB,GAAGC,MAAM,CACjCC,OAAO,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;EACJ,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=breakpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/breakpoints.ts"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/core.ts"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/mediaQueries.ts"],"mappings":""}
@@ -1,4 +1,5 @@
1
1
  export { normalizeStyles } from './normalizeStyles';
2
- export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints } from './breakpoints';
2
+ export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
3
3
  export { proxifyFunction, parseStyle } from './styles';
4
+ export { extractValues, getKeyForCustomMediaQuery, isMediaQuery, isWithinTheHeight, isWithinTheWidth, isWithinTheWidthAndHeight } from './mediaQueries';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["normalizeStyles","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","proxifyFunction","parseStyle"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,4BAA4B,EAAEC,0BAA0B,QAAQ,eAAe;AACxF,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU"}
1
+ {"version":3,"names":["normalizeStyles","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","getValueForBreakpoint","proxifyFunction","parseStyle","extractValues","getKeyForCustomMediaQuery","isMediaQuery","isWithinTheHeight","isWithinTheWidth","isWithinTheWidthAndHeight"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,4BAA4B,EAAEC,0BAA0B,EAAEC,qBAAqB,QAAQ,eAAe;AAC/G,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SACIC,aAAa,EACbC,yBAAyB,EACzBC,YAAY,EACZC,iBAAiB,EACjBC,gBAAgB,EAChBC,yBAAyB,QACtB,gBAAgB"}
@@ -1,10 +1,6 @@
1
1
  import type { Breakpoints, CreateStylesFactory, CustomNamedStyles, ExtractBreakpoints, RemoveKeysWithPrefix } from './types';
2
2
  export declare const createUnistyles: <B extends Breakpoints, T = {}>(breakpoints: B) => {
3
- /**
4
- * @deprecated The method should not be used, proposed version by the community is createStyleSheet, will be removed in RC
5
- */
6
- createStyles: <S extends CustomNamedStyles<S, B>, X>(styles: S | X | CustomNamedStyles<S, B> | ((theme: T) => X | CustomNamedStyles<X, B>)) => S | X;
7
- createStyleSheet: <S_1 extends CustomNamedStyles<S_1, B>, X_1>(styles: S_1 | X_1 | CustomNamedStyles<S_1, B> | ((theme: T) => X_1 | CustomNamedStyles<X_1, B>)) => S_1 | X_1;
3
+ createStyleSheet: <S extends CustomNamedStyles<S, B>, X>(styles: S | X | CustomNamedStyles<S, B> | ((theme: T) => X | CustomNamedStyles<X, B>)) => S | X;
8
4
  useStyles: <ST extends CustomNamedStyles<ST, B>>(stylesheet?: ST | CreateStylesFactory<ST, T> | undefined) => {
9
5
  theme: T;
10
6
  styles: ExtractBreakpoints<RemoveKeysWithPrefix<ST, B>, B>;
@@ -1 +1 @@
1
- {"version":3,"file":"createUnistyles.d.ts","sourceRoot":"","sources":["../../../src/createUnistyles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EAEvB,MAAM,SAAS,CAAA;AAKhB,eAAO,MAAM,eAAe;IAMpB;;OAEG;;;;;;;CAuDV,CAAA"}
1
+ {"version":3,"file":"createUnistyles.d.ts","sourceRoot":"","sources":["../../../src/createUnistyles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EAEvB,MAAM,SAAS,CAAA;AAKhB,eAAO,MAAM,eAAe;;;;;;CAqD3B,CAAA"}
@@ -0,0 +1,19 @@
1
+ import type { MediaQueries } from './mediaQueries';
2
+ export type Breakpoints = Record<string, number>;
3
+ export type SortedBreakpointEntries<B extends Breakpoints> = [[keyof B & string, number]];
4
+ export type ScreenSize = {
5
+ width: number;
6
+ height: number;
7
+ };
8
+ export type CreateStylesFactory<ST, Theme> = (theme: Theme) => ST;
9
+ type WithEmptyObject<V> = keyof V extends never ? {} : V;
10
+ export type ExtractBreakpoints<T, B extends Breakpoints> = T extends Partial<Record<keyof B & string, infer V>> ? WithEmptyObject<V> : T extends (...args: infer A) => infer R ? (...args: A) => ExtractBreakpoints<R, B> : {
11
+ [K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => ExtractBreakpoints<R, B> : T[K] extends object ? ExtractBreakpoints<T[K], B> : T[K];
12
+ };
13
+ export type RemoveKeysWithPrefix<T, B extends Breakpoints> = T extends (...args: Array<any>) => infer R ? (...args: Parameters<T>) => RemoveKeysWithPrefix<R, B> : T extends object ? T extends Record<string, infer _V> ? {
14
+ [K in keyof T as K extends MediaQueries ? keyof B & string : K]: RemoveKeysWithPrefix<T[K], B>;
15
+ } : {
16
+ [K in keyof T]: RemoveKeysWithPrefix<T[K], B>;
17
+ } : T;
18
+ export {};
19
+ //# sourceMappingURL=breakpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/types/breakpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,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AC,SAAS,WAAW,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,GACjG,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,GACtD,CAAC,SAAS,MAAM,GACZ,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAC9B;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,YAAY,GAAG,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;CAAE,GAClG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;CAAE,GACrD,CAAC,CAAA"}
@@ -0,0 +1,32 @@
1
+ import type { MatrixTransform, PerpectiveTransform, RotateTransform, RotateXTransform, RotateYTransform, RotateZTransform, ScaleTransform, ScaleXTransform, ScaleYTransform, SkewXTransform, SkewYTransform, TranslateXTransform, TranslateYTransform } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
2
+ import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
3
+ import type { Breakpoints } from './breakpoints';
4
+ import type { MediaQueries } from './mediaQueries';
5
+ type ShadowOffset = {
6
+ width: number;
7
+ height: number;
8
+ };
9
+ type TransformStyles = PerpectiveTransform & RotateTransform & RotateXTransform & RotateYTransform & RotateZTransform & ScaleTransform & ScaleXTransform & ScaleYTransform & TranslateXTransform & TranslateYTransform & SkewXTransform & SkewYTransform & MatrixTransform;
10
+ type UnistyleNested<B> = {
11
+ shadowOffset?: DeepUniStyle<ShadowOffset, B>;
12
+ textShadowOffset?: DeepUniStyle<ShadowOffset, B>;
13
+ transform?: Array<DeepUniStyle<TransformStyles, B>>;
14
+ };
15
+ type UniStyle<V, B> = {
16
+ [innerKey in keyof B]?: V;
17
+ } | {
18
+ [innerKey in MediaQueries]?: V;
19
+ } | V;
20
+ type DeepUniStyle<T, B> = {
21
+ [K in keyof T]?: UniStyle<T[K], B>;
22
+ };
23
+ type NestedTypes = 'shadowOffset' | 'transform' | 'textShadowOffset';
24
+ type UnistyleView<B> = DeepUniStyle<Omit<ViewStyle, NestedTypes>, B>;
25
+ type UnistyleText<B> = DeepUniStyle<Omit<TextStyle, NestedTypes>, B>;
26
+ type UnistyleImage<B> = DeepUniStyle<Omit<ImageStyle, NestedTypes>, B>;
27
+ export type StaticStyles<B extends Breakpoints> = UnistyleView<B> | UnistyleText<B> | UnistyleImage<B> & UnistyleNested<B>;
28
+ export type CustomNamedStyles<T, B extends Breakpoints> = {
29
+ [K in keyof T]: T[K] extends (...args: infer A) => StaticStyles<B> ? (...args: A) => StaticStyles<B> : StaticStyles<B>;
30
+ };
31
+ export {};
32
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,KAAK,YAAY,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,KAAK,eAAe,GACd,mBAAmB,GACnB,eAAe,GACf,gBA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Y,CAAC,CAAC,CAAC,GACf,aAAa,CAAC,CAAC,CAAC,GAChB,cAAc,CAAC,CAAC,CAAC,CAAA;AAEvB,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,IAAI;KACrD,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,GAC5D,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,GAC/B,YAAY,CAAC,CAAC,CAAC;CACxB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export type { CustomNamedStyles } from './core';
2
+ export type { ScreenSize, Breakpoints, CreateStylesFactory, ExtractBreakpoints, RemoveKeysWithPrefix, SortedBreakpointEntries } from './breakpoints';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAC/C,YAAY,EACR,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EAC1B,MAAM,eAAe,CAAA"}
@@ -0,0 +1,2 @@
1
+ export type MediaQueries = `:w[${bigint}]` | `:w[,${bigint}]` | `:w[, ${bigint}]` | `:w[${bigint},${bigint}]` | `:w[${bigint}, ${bigint}]` | `:h[${bigint}]` | `:h[,${bigint}]` | `:h[, ${bigint}]` | `:h[${bigint},${bigint}]` | `:h[${bigint}, ${bigint}]` | `:w[${bigint}]:h[${bigint}]` | `:w[${bigint},${bigint}]:h[${bigint}]` | `:w[${bigint}, ${bigint}]:h[${bigint}]` | `:w[${bigint}]:h[${bigint},${bigint}]` | `:w[${bigint}]:h[${bigint}, ${bigint}]` | `:w[${bigint},${bigint}]:h[${bigint},${bigint}]` | `:w[${bigint}, ${bigint}]:h[${bigint},${bigint}]` | `:w[${bigint},${bigint}]:h[${bigint}, ${bigint}]` | `:w[${bigint}, ${bigint}]:h[${bigint}, ${bigint}]` | `:w[,${bigint}]:h[,${bigint}]` | `:w[, ${bigint}]:h[,${bigint}]` | `:w[,${bigint}]:h[, ${bigint}]` | `:w[, ${bigint}]:h[, ${bigint}]` | `:w[,${bigint}]:h[${bigint}]` | `:w[, ${bigint}]:h[${bigint}]` | `:w[${bigint}]:h[,${bigint}]` | `:w[${bigint}]:h[, ${bigint}]` | `:w[,${bigint}]:h[${bigint},${bigint}]` | `:w[, ${bigint}]:h[${bigint},${bigint}]` | `:w[,${bigint}]:h[${bigint}, ${bigint}]` | `:w[, ${bigint}]:h[${bigint}, ${bigint}]` | `:w[${bigint},${bigint}]:h[,${bigint}]` | `:w[${bigint}, ${bigint}]:h[,${bigint}]` | `:w[${bigint},${bigint}]:h[, ${bigint}]` | `:w[${bigint}, ${bigint}]:h[, ${bigint}]` | `:h[${bigint}]:w[${bigint}]` | `:h[${bigint},${bigint}]:w[${bigint}]` | `:h[${bigint}, ${bigint}]:w[${bigint}]` | `:h[${bigint}]:w[${bigint},${bigint}]` | `:h[${bigint}]:w[${bigint}, ${bigint}]` | `:h[${bigint},${bigint}]:w[${bigint},${bigint}]` | `:h[${bigint}, ${bigint}]:w[${bigint},${bigint}]` | `:h[${bigint},${bigint}]:w[${bigint}, ${bigint}]` | `:h[${bigint}, ${bigint}]:w[${bigint}, ${bigint}]` | `:h[,${bigint}]:w[,${bigint}]` | `:h[, ${bigint}]:w[,${bigint}]` | `:h[,${bigint}]:w[, ${bigint}]` | `:h[, ${bigint}]:w[, ${bigint}]` | `:h[,${bigint}]:w[${bigint}]` | `:h[, ${bigint}]:w[${bigint}]` | `:h[${bigint}]:w[,${bigint}]` | `:h[${bigint}]:w[, ${bigint}]` | `:h[,${bigint}]:w[${bigint},${bigint}]` | `:h[, ${bigint}]:w[${bigint},${bigint}]` | `:h[,${bigint}]:w[${bigint}, ${bigint}]` | `:h[, ${bigint}]:w[${bigint}, ${bigint}]` | `:h[${bigint},${bigint}]:w[,${bigint}]` | `:h[${bigint}, ${bigint}]:w[,${bigint}]` | `:h[${bigint},${bigint}]:w[, ${bigint}]` | `:h[${bigint}, ${bigint}]:w[, ${bigint}]`;
2
+ //# sourceMappingURL=mediaQueries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mediaQueries.d.ts","sourceRoot":"","sources":["../../../../src/types/mediaQueries.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,YAAY,GAExB,MAAM,MAAM,GAAG,GACf,OAAO,MAAM,GAAG,GAChB,QAAQ,MAAM,GAAG,GACjB,MAAM,MAAM,IAAI,MAAM,GAAG,GACzB,MAAM,MAAM,KAAK,MAAM,GAAG,GAG1B,MAAM,MAAM,GAAG,GACf,OAAO,MAAM,GAAG,GAChB,QAAQ,MAAM,GAAG,GACjB,MAAM,MAAM,IAAI,MAAM,GAAG,GACzB,MAAM,MAAM,KAAK,MAAM,GAAG,GAG1B,MAAM,MAAM,OAAO,MAAM,GAAG,GAC5B,MAAM,MAAM,IAAI,MAAM,OAAO,MAAM,GAAG,GACtC,MAAM,MAAM,KAAK,MAAM,OAAO,MAAM,GAAG,GACvC,MAAM,MAAM,OAAO,MAAM,IAAI,MAAM,GAAG,GACtC,MAAM,MAAM,OAAO,MAAM,KAAK,MAAM,GAAG,GACvC,MAAM,MAAM,IAAI,MAAM,OAAO,MAAM,IAAI,MAAM,GAAG,GAChD,MAAM,MAAM,KAAK,MAAM,OAAO,MAAM,IAAI,MAAM,GAAG,GACjD,MAAM,MAAM,IAAI,MAAM,OAAO,MAAM,KAAK,MAAM,GAAG,GACjD,MAAM,MAAM,KAAK,MAAM,OAAO,MAAM,KAAK,MAAM,GAAG,GAClD,OAAO,MAAM,QAAQ,MAAM,GAAG,GAC9B,QAAQ,MAAM,QAAQ,MAAM,GAAG,GAC/B,OAAO,MAAM,SAAS,MAAM,G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,MAAM,GAAG,GAC7B,QAAQ,MAAM,OAAO,MAAM,GAAG,GAC9B,MAAM,MAAM,QAAQ,MAAM,GAAG,GAC7B,MAAM,MAAM,SAAS,MAAM,GAAG,GAC9B,OAAO,MAAM,OAAO,MAAM,IAAI,MAAM,GAAG,GACvC,QAAQ,MAAM,OAAO,MAAM,IAAI,MAAM,GAAG,GACxC,OAAO,MAAM,OAAO,MAAM,KAAK,MAAM,GAAG,GACxC,QAAQ,MAAM,OAAO,MAAM,KAAK,MAAM,GAAG,GACzC,MAAM,MAAM,IAAI,MAAM,QAAQ,MAAM,GAAG,GACvC,MAAM,MAAM,KAAK,MAAM,QAAQ,MAAM,GAAG,GACxC,MAAM,MAAM,IAAI,MAAM,SAAS,MAAM,GAAG,GACxC,MAAM,MAAM,KAAK,MAAM,SAAS,MAAM,GAAG,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export { normalizeStyles } from './normalizeStyles';
2
- export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints } from './breakpoints';
2
+ export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
3
3
  export { proxifyFunction, parseStyle } from './styles';
4
+ export { extractValues, getKeyForCustomMediaQuery, isMediaQuery, isWithinTheHeight, isWithinTheWidth, isWithinTheWidthAndHeight } from './mediaQueries';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AACxF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC/G,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EACH,aAAa,EACb,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EAC5B,MAAM,gBAAgB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-rc.1",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -9,7 +9,7 @@
9
9
  "clean": "del-cli lib",
10
10
  "prepare": "husky install && bob build",
11
11
  "precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn test'",
12
- "release": "release-it patch --preRelease=beta"
12
+ "release": "release-it patch --preRelease=rc"
13
13
  },
14
14
  "main": "lib/commonjs/index",
15
15
  "module": "lib/module/index",
@@ -39,19 +39,19 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@commitlint/config-conventional": "17.7.0",
42
- "@evilmartians/lefthook": "1.5.0",
43
42
  "@react-native/eslint-config": "0.73.1",
44
43
  "@release-it/conventional-changelog": "5.1.1",
44
+ "@testing-library/react-hooks": "8.0.1",
45
45
  "@types/jest": "29.5.5",
46
- "@types/react": "18.2.24",
46
+ "@types/react": "18.2.28",
47
47
  "@types/react-native": "0.72.3",
48
- "@typescript-eslint/eslint-plugin": "6.7.4",
49
- "@typescript-eslint/eslint-plugin-tslint": "6.7.4",
50
- "@typescript-eslint/parser": "6.7.4",
48
+ "@typescript-eslint/eslint-plugin": "6.7.5",
49
+ "@typescript-eslint/eslint-plugin-tslint": "6.7.5",
50
+ "@typescript-eslint/parser": "6.7.5",
51
51
  "commitlint": "17.7.2",
52
52
  "concurrently": "8.2.1",
53
53
  "del-cli": "5.1.0",
54
- "eslint": "8.50.0",
54
+ "eslint": "8.51.0",
55
55
  "eslint-config-codemask": "1.1.7",
56
56
  "eslint-plugin-functional": "6.0.0",
57
57
  "eslint-plugin-import": "2.28.1",
@@ -67,8 +67,9 @@
67
67
  "jest": "29.7.0",
68
68
  "react": "18.2.0",
69
69
  "react-native": "0.72.5",
70
- "react-native-builder-bob": "0.23.0",
70
+ "react-native-builder-bob": "0.23.1",
71
71
  "react-native-web": "0.19.9",
72
+ "react-test-renderer": "18.2.0",
72
73
  "release-it": "16.2.1",
73
74
  "typescript": "5.2.2"
74
75
  },
@@ -83,7 +84,8 @@
83
84
  }
84
85
  },
85
86
  "workspaces": [
86
- "example"
87
+ "example",
88
+ "docs"
87
89
  ],
88
90
  "packageManager": "yarn@3.6.1",
89
91
  "engines": {
@@ -93,6 +95,7 @@
93
95
  "preset": "react-native",
94
96
  "modulePathIgnorePatterns": [
95
97
  "<rootDir>/example/node_modules",
98
+ "<rootDir>/docs/node_modules",
96
99
  "<rootDir>/lib/"
97
100
  ]
98
101
  },
@@ -0,0 +1,158 @@
1
+ import React from 'react'
2
+ import { StyleSheet } from 'react-native'
3
+ import type { ViewStyle } from 'react-native'
4
+ import { renderHook } from '@testing-library/react-hooks'
5
+ import { createUnistyles } from '../createUnistyles'
6
+ import { UnistylesTheme } from '../UnistylesTheme'
7
+ import type { CustomNamedStyles } from '../types'
8
+
9
+ jest.mock('../hooks', () => ({
10
+ useDimensions: jest.fn(() => ({
11
+ width: 500,
12
+ height: 1000
13
+ }))
14
+ }))
15
+
16
+ describe('createUnistyles', () => {
17
+ describe('createStyleSheet', () => {
18
+ it('should work exactly the same like StyleSheet.create', () => {
19
+ const breakpoints = {
20
+ xs: 0
21
+ }
22
+ const { createStyleSheet } = createUnistyles(breakpoints)
23
+
24
+ const styles = {
25
+ container: {
26
+ flex: 1,
27
+ justifyContent: 'center',
28
+ alignItems: 'center'
29
+ },
30
+ text: {
31
+ fontWeight: 'bold',
32
+ fontSize: 32
33
+ }
34
+ } as const
35
+
36
+ expect(createStyleSheet(styles)).toEqual(StyleSheet.create(styles))
37
+ })
38
+
39
+ it('should inject the theme to the createStyleSheet', () => {
40
+ const theme = {
41
+ colors: {
42
+ barbie: '#ff9ff3',
43
+ oak: '#1dd1a1',
44
+ sky: '#48dbfb',
45
+ fog: '#c8d6e5',
46
+ aloes: '#00d2d3'
47
+ }
48
+ }
49
+ const breakpoints = {
50
+ xs: 0
51
+ }
52
+ const { useStyles, createStyleSheet } = createUnistyles<typeof breakpoints, typeof theme>(breakpoints)
53
+ const stylesheet = createStyleSheet(theme => ({
54
+ container: {
55
+ backgroundColor: theme.colors.barbie
56
+ }
57
+ }))
58
+ const { result } = renderHook(() => useStyles(stylesheet), {
59
+ // @ts-ignore
60
+ wrapper: ({ children }) => (
61
+ <UnistylesTheme theme={theme}>
62
+ {children}
63
+ </UnistylesTheme>
64
+ )
65
+ })
66
+
67
+ expect(result.current.theme).toEqual(theme)
68
+ expect(result.current.styles).not.toBe(Function)
69
+ expect(result.current.styles.container.backgroundColor).toEqual(theme.colors.barbie)
70
+ })
71
+ })
72
+
73
+ describe('useStyles', () => {
74
+ it('should return empty object for optional stylesheet', () => {
75
+ const breakpoints = {
76
+ xs: 0
77
+ }
78
+ const { useStyles } = createUnistyles(breakpoints)
79
+ const { result } = renderHook(() => useStyles())
80
+
81
+ expect(result.current.styles).toEqual({})
82
+ expect(result.current.theme).toEqual({})
83
+ })
84
+
85
+ it ('should choose single value from breakpoints', () => {
86
+ const breakpoints = {
87
+ xs: 0,
88
+ sm: 200,
89
+ md: 500,
90
+ lg: 1000
91
+ }
92
+
93
+ const { useStyles, createStyleSheet } = createUnistyles(breakpoints)
94
+ const stylesheet = createStyleSheet({
95
+ container: {
96
+ flex: 1,
97
+ justifyContent: 'center',
98
+ alignItems: {
99
+ xs: 'row',
100
+ md: 'column'
101
+ }
102
+ }
103
+ })
104
+ const { result } = renderHook(() => useStyles(stylesheet))
105
+
106
+ expect(result.current.styles.container.alignItems).toEqual('column')
107
+ })
108
+
109
+ it ('should choose single value from media queries', () => {
110
+ const breakpoints = {
111
+ xs: 0
112
+ }
113
+
114
+ const { useStyles, createStyleSheet } = createUnistyles(breakpoints)
115
+ const stylesheet = createStyleSheet({
116
+ container: {
117
+ flex: 1,
118
+ justifyContent: 'center',
119
+ alignItems: {
120
+ xs: 'row',
121
+ ':w[300, 490]': 'column',
122
+ ':w[491]': 'row'
123
+ }
124
+ }
125
+ })
126
+ const { result } = renderHook(() => useStyles(stylesheet as CustomNamedStyles<typeof stylesheet, typeof breakpoints>))
127
+
128
+ expect(result.current.styles.container.alignItems).toEqual('row')
129
+ })
130
+
131
+ it ('should choose wrap dynamic functions in Proxy', () => {
132
+ const breakpoints = {
133
+ xs: 0
134
+ }
135
+
136
+ const { useStyles, createStyleSheet } = createUnistyles<typeof breakpoints, {}>(breakpoints)
137
+ const stylesheet = createStyleSheet({
138
+ container: (flex: number) => ({
139
+ flex,
140
+ justifyContent: 'center',
141
+ alignItems: {
142
+ xs: 'row',
143
+ ':w[300, 490]': 'column',
144
+ ':w[491]': 'row'
145
+ }
146
+ })
147
+ })
148
+ const { result } = renderHook(() => useStyles(stylesheet as CustomNamedStyles<typeof stylesheet, typeof breakpoints>))
149
+
150
+ expect(result.current.styles.container).toBeInstanceOf(Function)
151
+ expect((result.current.styles.container as (flex: number) => ViewStyle)(2)).toEqual({
152
+ flex: 2,
153
+ justifyContent: 'center',
154
+ alignItems: 'row'
155
+ })
156
+ })
157
+ })
158
+ })
@@ -18,16 +18,6 @@ export const createUnistyles = <B extends Breakpoints, T = {}>(breakpoints: B) =
18
18
  .entries(sortedBreakpoints) as SortedBreakpointEntries<B>
19
19
 
20
20
  return {
21
- /**
22
- * @deprecated The method should not be used, proposed version by the community is createStyleSheet, will be removed in RC
23
- */
24
- createStyles: <S extends CustomNamedStyles<S, B>, X>(styles: S | CustomNamedStyles<S, B> | X | ((theme: T) => X | CustomNamedStyles<X, B>)): S | X => {
25
- if (typeof styles === 'function') {
26
- return styles as X
27
- }
28
-
29
- return styles as S
30
- },
31
21
  createStyleSheet: <S extends CustomNamedStyles<S, B>, X>(styles: S | CustomNamedStyles<S, B> | X | ((theme: T) => X | CustomNamedStyles<X, B>)): S | X => {
32
22
  if (typeof styles === 'function') {
33
23
  return styles as X
@@ -0,0 +1,33 @@
1
+ import type { MediaQueries } from './mediaQueries'
2
+
3
+ export type Breakpoints = Record<string, number>
4
+ export type SortedBreakpointEntries<B extends Breakpoints> = [[keyof B & string, number]]
5
+
6
+ export type ScreenSize = {
7
+ width: number,
8
+ height: number
9
+ }
10
+
11
+ export type CreateStylesFactory<ST, Theme> = (theme: Theme) => ST
12
+
13
+ type WithEmptyObject<V> = keyof V extends never ? {} : V
14
+
15
+ export type ExtractBreakpoints<T, B extends Breakpoints> = T extends Partial<Record<keyof B & string, infer V>>
16
+ ? WithEmptyObject<V>
17
+ : T extends (...args: infer A) => infer R
18
+ ? (...args: A) => ExtractBreakpoints<R, B>
19
+ : {
20
+ [K in keyof T]: T[K] extends (...args: infer A) => infer R
21
+ ? (...args: A) => ExtractBreakpoints<R, B>
22
+ : T[K] extends object
23
+ ? ExtractBreakpoints<T[K], B>
24
+ : T[K]
25
+ }
26
+
27
+ export type RemoveKeysWithPrefix<T, B extends Breakpoints> = T extends (...args: Array<any>) => infer R
28
+ ? (...args: Parameters<T>) => RemoveKeysWithPrefix<R, B>
29
+ : T extends object
30
+ ? T extends Record<string, infer _V>
31
+ ? { [K in keyof T as K extends MediaQueries ? keyof B & string : K]: RemoveKeysWithPrefix<T[K], B> }
32
+ : { [K in keyof T]: RemoveKeysWithPrefix<T[K], B> }
33
+ : T
@@ -0,0 +1,73 @@
1
+ import type {
2
+ MatrixTransform,
3
+ PerpectiveTransform,
4
+ RotateTransform,
5
+ RotateXTransform,
6
+ RotateYTransform,
7
+ RotateZTransform,
8
+ ScaleTransform,
9
+ ScaleXTransform,
10
+ ScaleYTransform,
11
+ SkewXTransform,
12
+ SkewYTransform,
13
+ TranslateXTransform,
14
+ TranslateYTransform
15
+ } from 'react-native/Libraries/StyleSheet/StyleSheetTypes'
16
+ import type { ImageStyle, TextStyle, ViewStyle } from 'react-native'
17
+ import type { Breakpoints } from './breakpoints'
18
+ import type { MediaQueries } from './mediaQueries'
19
+
20
+ type ShadowOffset = {
21
+ width: number,
22
+ height: number
23
+ }
24
+
25
+ type TransformStyles =
26
+ & PerpectiveTransform
27
+ & RotateTransform
28
+ & RotateXTransform
29
+ & RotateYTransform
30
+ & RotateZTransform
31
+ & ScaleTransform
32
+ & ScaleXTransform
33
+ & ScaleYTransform
34
+ & TranslateXTransform
35
+ & TranslateYTransform
36
+ & SkewXTransform
37
+ & SkewYTransform
38
+ & MatrixTransform
39
+
40
+ type UnistyleNested<B> = {
41
+ shadowOffset?: DeepUniStyle<ShadowOffset, B>,
42
+ textShadowOffset?: DeepUniStyle<ShadowOffset, B>,
43
+ transform?: Array<DeepUniStyle<TransformStyles, B>>
44
+ }
45
+
46
+ type UniStyle<V, B> = {
47
+ [innerKey in keyof B]?: V
48
+ } | {
49
+ [innerKey in MediaQueries]?: V
50
+ } | V
51
+
52
+ type DeepUniStyle<T, B> = {
53
+ [K in keyof T]?: UniStyle<T[K], B>
54
+ }
55
+
56
+ // these props are treated differently to nest breakpoints and media queries
57
+ type NestedTypes = 'shadowOffset' | 'transform' | 'textShadowOffset'
58
+
59
+ type UnistyleView<B> = DeepUniStyle<Omit<ViewStyle, NestedTypes>, B>
60
+ type UnistyleText<B> = DeepUniStyle<Omit<TextStyle, NestedTypes>, B>
61
+ type UnistyleImage<B> = DeepUniStyle<Omit<ImageStyle, NestedTypes>, B>
62
+
63
+ export type StaticStyles<B extends Breakpoints> =
64
+ | UnistyleView<B>
65
+ | UnistyleText<B>
66
+ | UnistyleImage<B>
67
+ & UnistyleNested<B>
68
+
69
+ export type CustomNamedStyles<T, B extends Breakpoints> = {
70
+ [K in keyof T]: T[K] extends (...args: infer A) => StaticStyles<B>
71
+ ? (...args: A) => StaticStyles<B>
72
+ : StaticStyles<B>
73
+ }
@@ -0,0 +1,9 @@
1
+ export type { CustomNamedStyles } from './core'
2
+ export type {
3
+ ScreenSize,
4
+ Breakpoints,
5
+ CreateStylesFactory,
6
+ ExtractBreakpoints,
7
+ RemoveKeysWithPrefix,
8
+ SortedBreakpointEntries
9
+ } from './breakpoints'