react-native-unistyles 1.0.0-beta.6 → 1.0.0-rc.2
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/README.md +12 -589
- package/lib/commonjs/createUnistyles.js +6 -13
- package/lib/commonjs/createUnistyles.js.map +1 -1
- package/lib/commonjs/hooks/useDimensions.js +1 -10
- package/lib/commonjs/hooks/useDimensions.js.map +1 -1
- package/lib/commonjs/utils/index.js +43 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/createUnistyles.js +7 -14
- package/lib/module/createUnistyles.js.map +1 -1
- package/lib/module/hooks/useDimensions.js +1 -10
- package/lib/module/hooks/useDimensions.js.map +1 -1
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/src/createUnistyles.d.ts +2 -5
- package/lib/typescript/src/createUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useDimensions.d.ts.map +1 -1
- package/lib/typescript/src/types/mediaQueries.d.ts +7 -1
- package/lib/typescript/src/types/mediaQueries.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +2 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/package.json +13 -10
- package/src/__tests__/createUnistyles.spec.tsx +192 -0
- package/src/createUnistyles.ts +8 -16
- package/src/hooks/useDimensions.ts +1 -8
- package/src/types/mediaQueries.ts +8 -67
- package/src/utils/index.ts +9 -1
- package/lib/commonjs/utils/breakpoints.spec.js +0 -154
- package/lib/commonjs/utils/breakpoints.spec.js.map +0 -1
- package/lib/commonjs/utils/mediaQueries.spec.js +0 -220
- package/lib/commonjs/utils/mediaQueries.spec.js.map +0 -1
- package/lib/commonjs/utils/styles.spec.js +0 -174
- package/lib/commonjs/utils/styles.spec.js.map +0 -1
- package/lib/module/utils/breakpoints.spec.js +0 -152
- package/lib/module/utils/breakpoints.spec.js.map +0 -1
- package/lib/module/utils/mediaQueries.spec.js +0 -218
- package/lib/module/utils/mediaQueries.spec.js.map +0 -1
- package/lib/module/utils/styles.spec.js +0 -172
- package/lib/module/utils/styles.spec.js.map +0 -1
- package/lib/typescript/src/utils/breakpoints.spec.d.ts +0 -2
- package/lib/typescript/src/utils/breakpoints.spec.d.ts.map +0 -1
- package/lib/typescript/src/utils/mediaQueries.spec.d.ts +0 -2
- package/lib/typescript/src/utils/mediaQueries.spec.d.ts.map +0 -1
- package/lib/typescript/src/utils/styles.spec.d.ts +0 -2
- package/lib/typescript/src/utils/styles.spec.d.ts.map +0 -1
| @@ -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":" | 
| 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"}
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            import { useContext } from 'react';
         | 
| 1 | 
            +
            import { useContext, useMemo } from 'react';
         | 
| 2 2 | 
             
            import { StyleSheet } from 'react-native';
         | 
| 3 3 | 
             
            import { UnistylesContext } from './UnistylesTheme';
         | 
| 4 4 | 
             
            import { useDimensions } from './hooks';
         | 
| @@ -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;
         | 
| @@ -25,15 +16,16 @@ export const createUnistyles = breakpoints => { | |
| 25 16 | 
             
                useStyles: stylesheet => {
         | 
| 26 17 | 
             
                  const theme = useContext(UnistylesContext);
         | 
| 27 18 | 
             
                  const screenSize = useDimensions();
         | 
| 19 | 
            +
                  const breakpoint = getBreakpointFromScreenWidth(screenSize.width, sortedBreakpointEntries);
         | 
| 28 20 | 
             
                  if (!stylesheet) {
         | 
| 29 21 | 
             
                    return {
         | 
| 30 22 | 
             
                      theme,
         | 
| 23 | 
            +
                      breakpoint,
         | 
| 31 24 | 
             
                      styles: {}
         | 
| 32 25 | 
             
                    };
         | 
| 33 26 | 
             
                  }
         | 
| 34 | 
            -
                  const parsedStyles = typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet;
         | 
| 35 | 
            -
                  const  | 
| 36 | 
            -
                  const dynamicStyleSheet = Object.entries(parsedStyles).reduce((acc, _ref) => {
         | 
| 27 | 
            +
                  const parsedStyles = useMemo(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet]);
         | 
| 28 | 
            +
                  const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
         | 
| 37 29 | 
             
                    let [key, value] = _ref;
         | 
| 38 30 | 
             
                    const style = value;
         | 
| 39 31 | 
             
                    if (typeof value === 'function') {
         | 
| @@ -46,9 +38,10 @@ export const createUnistyles = breakpoints => { | |
| 46 38 | 
             
                      ...acc,
         | 
| 47 39 | 
             
                      [key]: parseStyle(style, breakpoint, screenSize, sortedBreakpointEntries)
         | 
| 48 40 | 
             
                    });
         | 
| 49 | 
            -
                  }, {});
         | 
| 41 | 
            +
                  }, {}), [breakpoint, screenSize, parsedStyles]);
         | 
| 50 42 | 
             
                  return {
         | 
| 51 43 | 
             
                    theme,
         | 
| 44 | 
            +
                    breakpoint,
         | 
| 52 45 | 
             
                    styles: dynamicStyleSheet
         | 
| 53 46 | 
             
                  };
         | 
| 54 47 | 
             
                }
         | 
| @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"names":["useContext","StyleSheet","UnistylesContext","useDimensions","getBreakpointFromScreenWidth","proxifyFunction","parseStyle","sortAndValidateBreakpoints","createUnistyles","breakpoints","sortedBreakpoints","sortedBreakpointEntries","Object","entries"," | 
| 1 | 
            +
            {"version":3,"names":["useContext","useMemo","StyleSheet","UnistylesContext","useDimensions","getBreakpointFromScreenWidth","proxifyFunction","parseStyle","sortAndValidateBreakpoints","createUnistyles","breakpoints","sortedBreakpoints","sortedBreakpointEntries","Object","entries","createStyleSheet","styles","useStyles","stylesheet","theme","screenSize","breakpoint","width","parsedStyles","dynamicStyleSheet","reduce","acc","_ref","key","value","style","create"],"sourceRoot":"../../src","sources":["createUnistyles.ts"],"mappings":"AAAA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,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,CAACH,iBAAiB,CAA+B;EAE7D,OAAO;IACHI,gBAAgB,EAAyCC,MAAqF,IAAY;MACtJ,IAAI,OAAOA,MAAM,KAAK,UAAU,EAAE;QAC9B,OAAOA,MAAM;MACjB;MAEA,OAAOA,MAAM;IACjB,CAAC;IACDC,SAAS,EAAwCC,UAA4C,IAAK;MAC9F,MAAMC,KAAK,GAAGnB,UAAU,CAACG,gBAAgB,CAAM;MAC/C,MAAMiB,UAAU,GAAGhB,aAAa,CAAC,CAAC;MAClC,MAAMiB,UAAU,GAAGhB,4BAA4B,CAAIe,UAAU,CAACE,KAAK,EAAEV,uBAAuB,CAAC;MAE7F,IAAI,CAACM,UAAU,EAAE;QACb,OAAO;UACHC,KAAK;UACLE,UAAU;UACVL,MAAM,EAAE,CAAC;QACb,CAAC;MACL;MAEA,MAAMO,YAAY,GAAGtB,OAAO,CAAC,MAAM,OAAOiB,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACC,KAAK,CAAC,GACjBD,UAAU,EAAE,CAACC,KAAK,EAAED,UAAU,CAAC,CAAC;MAEtC,MAAMM,iBAAiB,GAAGvB,OAAO,CAAC,MAAMY,MAAM,CACzCC,OAAO,CAACS,YAAY,CAAC,CACrBE,MAAM,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,GAAGtB,eAAe,CAAIuB,KAAK,EAAER,UAAU,EAAED,UAAU,EAAER,uBAAuB;UACpF,CAAC;QACL;QAEA,OAAOV,UAAU,CAAC6B,MAAM,CAAC;UACrB,GAAGL,GAAG;UACN,CAACE,GAAG,GAAGrB,UAAU,CAAQuB,KAAK,EAAET,UAAU,EAAED,UAAU,EAAER,uBAAuB;QACnF,CAAC,CAAC;MACN,CAAC,EAAE,CAAC,CAAO,CAAC,EAAE,CAACS,UAAU,EAAED,UAAU,EAAEG,YAAY,CAAC,CAAC;MAEzD,OAAO;QACHJ,KAAK;QACLE,UAAU;QACVL,MAAM,EAAEQ;MACZ,CAAC;IACL;EACJ,CAAC;AACL,CAAC"}
         | 
| @@ -1,12 +1,3 @@ | |
| 1 1 | 
             
            import { useWindowDimensions } from 'react-native';
         | 
| 2 | 
            -
            export const useDimensions = () =>  | 
| 3 | 
            -
              const {
         | 
| 4 | 
            -
                width,
         | 
| 5 | 
            -
                height
         | 
| 6 | 
            -
              } = useWindowDimensions();
         | 
| 7 | 
            -
              return {
         | 
| 8 | 
            -
                width,
         | 
| 9 | 
            -
                height
         | 
| 10 | 
            -
              };
         | 
| 11 | 
            -
            };
         | 
| 2 | 
            +
            export const useDimensions = () => useWindowDimensions();
         | 
| 12 3 | 
             
            //# sourceMappingURL=useDimensions.js.map
         | 
| @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"names":["useWindowDimensions","useDimensions" | 
| 1 | 
            +
            {"version":3,"names":["useWindowDimensions","useDimensions"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.ts"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAGlD,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAkBD,mBAAmB,CAAC,CAAC"}
         | 
| @@ -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; | 
| 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,12 +1,9 @@ | |
| 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;
         | 
| 6 | 
            +
                    breakpoint: keyof B & string;
         | 
| 10 7 | 
             
                    styles: ExtractBreakpoints<RemoveKeysWithPrefix<ST, B>, B>;
         | 
| 11 8 | 
             
                };
         | 
| 12 9 | 
             
            };
         | 
| @@ -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 | 
| 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;;;;;;;CAuD3B,CAAA"}
         | 
| @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"useDimensions.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDimensions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,eAAO,MAAM,aAAa,QAAO, | 
| 1 | 
            +
            {"version":3,"file":"useDimensions.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDimensions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,eAAO,MAAM,aAAa,QAAO,UAAmC,CAAA"}
         | 
| @@ -1,2 +1,8 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            type Optional<TOptional extends string> = TOptional | '';
         | 
| 2 | 
            +
            type Separator = ',' | ', ';
         | 
| 3 | 
            +
            type MediaQuery = `[${Separator}${bigint}]` | `[${bigint}${Optional<`${Separator}${bigint}`>}]`;
         | 
| 4 | 
            +
            type WidthMediaQuery = `:w${MediaQuery}`;
         | 
| 5 | 
            +
            type HeightMediaQuery = `:h${MediaQuery}`;
         | 
| 6 | 
            +
            export type MediaQueries = `${WidthMediaQuery}${Optional<HeightMediaQuery>}` | `${HeightMediaQuery}${Optional<WidthMediaQuery>}`;
         | 
| 7 | 
            +
            export {};
         | 
| 2 8 | 
             
            //# sourceMappingURL=mediaQueries.d.ts.map
         | 
| @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"mediaQueries.d.ts","sourceRoot":"","sources":["../../../../src/types/mediaQueries.ts"],"names":[],"mappings":" | 
| 1 | 
            +
            {"version":3,"file":"mediaQueries.d.ts","sourceRoot":"","sources":["../../../../src/types/mediaQueries.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,CAAC,SAAS,SAAS,MAAM,IAAI,SAAS,GAAG,EAAE,CAAA;AACxD,KAAK,SAAS,GAAG,GAAG,GAAG,IAAI,CAAA;AAE3B,KAAK,UAAU,GAAG,IAAI,SAAS,GAAG,MAAM,GAAG,GAAG,IAAI,MAAM,GAAG,QAAQ,CAAC,GAAG,SAAS,GAAG,MAAM,EAAE,CAAC,GAAG,CAAA;AAC/F,KAAK,eAAe,GAAG,KAAK,UAAU,EAAE,CAAA;AACxC,KAAK,gBAAgB,GAAG,KAAK,UAAU,EAAE,CAAA;AAEzC,MAAM,MAAM,YAAY,GAClB,GAAG,eAAe,GAAG,QAAQ,CAAC,gBAAgB,CAAC,EAAE,GACjD,GAAG,gBAAgB,GAAG,QAAQ,CAAC,eAAe,CAAC,EAAE,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; | 
| 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- | 
| 3 | 
            +
              "version": "1.0.0-rc.2",
         | 
| 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= | 
| 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. | 
| 46 | 
            +
                "@types/react": "18.2.28",
         | 
| 47 47 | 
             
                "@types/react-native": "0.72.3",
         | 
| 48 | 
            -
                "@typescript-eslint/eslint-plugin": "6.7. | 
| 49 | 
            -
                "@typescript-eslint/eslint-plugin-tslint": "6.7. | 
| 50 | 
            -
                "@typescript-eslint/parser": "6.7. | 
| 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. | 
| 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. | 
| 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,192 @@ | |
| 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 | 
            +
                    it ('should return breakpoint even if no stylesheet has been provided', () => {
         | 
| 159 | 
            +
                        const breakpoints = {
         | 
| 160 | 
            +
                            xs: 0,
         | 
| 161 | 
            +
                            sm: 200,
         | 
| 162 | 
            +
                            md: 500,
         | 
| 163 | 
            +
                            lg: 1000
         | 
| 164 | 
            +
                        }
         | 
| 165 | 
            +
             | 
| 166 | 
            +
                        const { useStyles } = createUnistyles<typeof breakpoints, {}>(breakpoints)
         | 
| 167 | 
            +
                        const { result } = renderHook(() => useStyles())
         | 
| 168 | 
            +
             | 
| 169 | 
            +
                        expect(result.current.breakpoint).toEqual('md')
         | 
| 170 | 
            +
                    })
         | 
| 171 | 
            +
             | 
| 172 | 
            +
                    it ('should return breakpoint for stylesheet', () => {
         | 
| 173 | 
            +
                        const breakpoints = {
         | 
| 174 | 
            +
                            xs: 0,
         | 
| 175 | 
            +
                            sm: 200,
         | 
| 176 | 
            +
                            lg: 1000
         | 
| 177 | 
            +
                        }
         | 
| 178 | 
            +
             | 
| 179 | 
            +
                        const { useStyles, createStyleSheet } = createUnistyles<typeof breakpoints, {}>(breakpoints)
         | 
| 180 | 
            +
                        const stylesheet = createStyleSheet({
         | 
| 181 | 
            +
                            container: {
         | 
| 182 | 
            +
                                flex: 1,
         | 
| 183 | 
            +
                                justifyContent: 'center',
         | 
| 184 | 
            +
                                alignItems: 'center'
         | 
| 185 | 
            +
                            }
         | 
| 186 | 
            +
                        })
         | 
| 187 | 
            +
                        const { result } = renderHook(() => useStyles(stylesheet as CustomNamedStyles<typeof stylesheet, typeof breakpoints>))
         | 
| 188 | 
            +
             | 
| 189 | 
            +
                        expect(result.current.breakpoint).toEqual('sm')
         | 
| 190 | 
            +
                    })
         | 
| 191 | 
            +
                })
         | 
| 192 | 
            +
            })
         | 
    
        package/src/createUnistyles.ts
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            import { useContext } from 'react'
         | 
| 1 | 
            +
            import { useContext, useMemo } from 'react'
         | 
| 2 2 | 
             
            import { StyleSheet } from 'react-native'
         | 
| 3 3 | 
             
            import type {
         | 
| 4 4 | 
             
                Breakpoints,
         | 
| @@ -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
         | 
| @@ -38,20 +28,21 @@ export const createUnistyles = <B extends Breakpoints, T = {}>(breakpoints: B) = | |
| 38 28 | 
             
                    useStyles: <ST extends CustomNamedStyles<ST, B>>(stylesheet?: ST | CreateStylesFactory<ST, T>) => {
         | 
| 39 29 | 
             
                        const theme = useContext(UnistylesContext) as T
         | 
| 40 30 | 
             
                        const screenSize = useDimensions()
         | 
| 31 | 
            +
                        const breakpoint = getBreakpointFromScreenWidth<B>(screenSize.width, sortedBreakpointEntries)
         | 
| 41 32 |  | 
| 42 33 | 
             
                        if (!stylesheet) {
         | 
| 43 34 | 
             
                            return {
         | 
| 44 35 | 
             
                                theme,
         | 
| 36 | 
            +
                                breakpoint,
         | 
| 45 37 | 
             
                                styles: {} as ExtractBreakpoints<RemoveKeysWithPrefix<ST, B>, B>
         | 
| 46 38 | 
             
                            }
         | 
| 47 39 | 
             
                        }
         | 
| 48 40 |  | 
| 49 | 
            -
                        const parsedStyles = typeof stylesheet === 'function'
         | 
| 41 | 
            +
                        const parsedStyles = useMemo(() => typeof stylesheet === 'function'
         | 
| 50 42 | 
             
                            ? stylesheet(theme)
         | 
| 51 | 
            -
                            : stylesheet
         | 
| 52 | 
            -
                        const breakpoint = getBreakpointFromScreenWidth<B>(screenSize.width, sortedBreakpointEntries)
         | 
| 43 | 
            +
                            : stylesheet, [theme, stylesheet])
         | 
| 53 44 |  | 
| 54 | 
            -
                        const dynamicStyleSheet = Object
         | 
| 45 | 
            +
                        const dynamicStyleSheet = useMemo(() => Object
         | 
| 55 46 | 
             
                            .entries(parsedStyles)
         | 
| 56 47 | 
             
                            .reduce((acc, [key, value]) => {
         | 
| 57 48 | 
             
                                const style = value as CustomNamedStyles<ST, B>
         | 
| @@ -67,10 +58,11 @@ export const createUnistyles = <B extends Breakpoints, T = {}>(breakpoints: B) = | |
| 67 58 | 
             
                                    ...acc,
         | 
| 68 59 | 
             
                                    [key]: parseStyle<ST, B>(style, breakpoint, screenSize, sortedBreakpointEntries)
         | 
| 69 60 | 
             
                                })
         | 
| 70 | 
            -
                            }, {} as ST)
         | 
| 61 | 
            +
                            }, {} as ST), [breakpoint, screenSize, parsedStyles])
         | 
| 71 62 |  | 
| 72 63 | 
             
                        return {
         | 
| 73 64 | 
             
                            theme,
         | 
| 65 | 
            +
                            breakpoint,
         | 
| 74 66 | 
             
                            styles: dynamicStyleSheet as ExtractBreakpoints<RemoveKeysWithPrefix<ST, B>, B>
         | 
| 75 67 | 
             
                        }
         | 
| 76 68 | 
             
                    }
         | 
| @@ -1,11 +1,4 @@ | |
| 1 1 | 
             
            import { useWindowDimensions } from 'react-native'
         | 
| 2 2 | 
             
            import type { ScreenSize } from '../types'
         | 
| 3 3 |  | 
| 4 | 
            -
            export const useDimensions = (): ScreenSize =>  | 
| 5 | 
            -
                const { width, height } = useWindowDimensions()
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                return {
         | 
| 8 | 
            -
                    width,
         | 
| 9 | 
            -
                    height
         | 
| 10 | 
            -
                }
         | 
| 11 | 
            -
            }
         | 
| 4 | 
            +
            export const useDimensions = (): ScreenSize => useWindowDimensions()
         | 
| @@ -1,69 +1,10 @@ | |
| 1 | 
            +
            type Optional<TOptional extends string> = TOptional | ''
         | 
| 2 | 
            +
            type Separator = ',' | ', '
         | 
| 1 3 | 
             
            // this is super weird, but number passes empty string and bigint does not
         | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
            `: | 
| 5 | 
            -
            `:w[,${bigint}]` |
         | 
| 6 | 
            -
            `:w[, ${bigint}]` |
         | 
| 7 | 
            -
            `:w[${bigint},${bigint}]` |
         | 
| 8 | 
            -
            `:w[${bigint}, ${bigint}]` |
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            // For :h
         | 
| 11 | 
            -
            `:h[${bigint}]` |
         | 
| 12 | 
            -
            `:h[,${bigint}]` |
         | 
| 13 | 
            -
            `:h[, ${bigint}]` |
         | 
| 14 | 
            -
            `:h[${bigint},${bigint}]` |
         | 
| 15 | 
            -
            `:h[${bigint}, ${bigint}]` |
         | 
| 4 | 
            +
            type MediaQuery = `[${Separator}${bigint}]` | `[${bigint}${Optional<`${Separator}${bigint}`>}]`
         | 
| 5 | 
            +
            type WidthMediaQuery = `:w${MediaQuery}`
         | 
| 6 | 
            +
            type HeightMediaQuery = `:h${MediaQuery}`
         | 
| 16 7 |  | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
            `:w[${bigint}, ${bigint}]:h[${bigint}]` |
         | 
| 21 | 
            -
            `:w[${bigint}]:h[${bigint},${bigint}]` |
         | 
| 22 | 
            -
            `:w[${bigint}]:h[${bigint}, ${bigint}]` |
         | 
| 23 | 
            -
            `:w[${bigint},${bigint}]:h[${bigint},${bigint}]` |
         | 
| 24 | 
            -
            `:w[${bigint}, ${bigint}]:h[${bigint},${bigint}]` |
         | 
| 25 | 
            -
            `:w[${bigint},${bigint}]:h[${bigint}, ${bigint}]` |
         | 
| 26 | 
            -
            `:w[${bigint}, ${bigint}]:h[${bigint}, ${bigint}]` |
         | 
| 27 | 
            -
            `:w[,${bigint}]:h[,${bigint}]` |
         | 
| 28 | 
            -
            `:w[, ${bigint}]:h[,${bigint}]` |
         | 
| 29 | 
            -
            `:w[,${bigint}]:h[, ${bigint}]` |
         | 
| 30 | 
            -
            `:w[, ${bigint}]:h[, ${bigint}]` |
         | 
| 31 | 
            -
            `:w[,${bigint}]:h[${bigint}]` |
         | 
| 32 | 
            -
            `:w[, ${bigint}]:h[${bigint}]` |
         | 
| 33 | 
            -
            `:w[${bigint}]:h[,${bigint}]` |
         | 
| 34 | 
            -
            `:w[${bigint}]:h[, ${bigint}]` |
         | 
| 35 | 
            -
            `:w[,${bigint}]:h[${bigint},${bigint}]` |
         | 
| 36 | 
            -
            `:w[, ${bigint}]:h[${bigint},${bigint}]` |
         | 
| 37 | 
            -
            `:w[,${bigint}]:h[${bigint}, ${bigint}]` |
         | 
| 38 | 
            -
            `:w[, ${bigint}]:h[${bigint}, ${bigint}]` |
         | 
| 39 | 
            -
            `:w[${bigint},${bigint}]:h[,${bigint}]` |
         | 
| 40 | 
            -
            `:w[${bigint}, ${bigint}]:h[,${bigint}]` |
         | 
| 41 | 
            -
            `:w[${bigint},${bigint}]:h[, ${bigint}]` |
         | 
| 42 | 
            -
            `:w[${bigint}, ${bigint}]:h[, ${bigint}]` |
         | 
| 43 | 
            -
             | 
| 44 | 
            -
            // Combinations of :h and :w
         | 
| 45 | 
            -
            `:h[${bigint}]:w[${bigint}]` |
         | 
| 46 | 
            -
            `:h[${bigint},${bigint}]:w[${bigint}]` |
         | 
| 47 | 
            -
            `:h[${bigint}, ${bigint}]:w[${bigint}]` |
         | 
| 48 | 
            -
            `:h[${bigint}]:w[${bigint},${bigint}]` |
         | 
| 49 | 
            -
            `:h[${bigint}]:w[${bigint}, ${bigint}]` |
         | 
| 50 | 
            -
            `:h[${bigint},${bigint}]:w[${bigint},${bigint}]` |
         | 
| 51 | 
            -
            `:h[${bigint}, ${bigint}]:w[${bigint},${bigint}]` |
         | 
| 52 | 
            -
            `:h[${bigint},${bigint}]:w[${bigint}, ${bigint}]` |
         | 
| 53 | 
            -
            `:h[${bigint}, ${bigint}]:w[${bigint}, ${bigint}]` |
         | 
| 54 | 
            -
            `:h[,${bigint}]:w[,${bigint}]` |
         | 
| 55 | 
            -
            `:h[, ${bigint}]:w[,${bigint}]` |
         | 
| 56 | 
            -
            `:h[,${bigint}]:w[, ${bigint}]` |
         | 
| 57 | 
            -
            `:h[, ${bigint}]:w[, ${bigint}]` |
         | 
| 58 | 
            -
            `:h[,${bigint}]:w[${bigint}]` |
         | 
| 59 | 
            -
            `:h[, ${bigint}]:w[${bigint}]` |
         | 
| 60 | 
            -
            `:h[${bigint}]:w[,${bigint}]` |
         | 
| 61 | 
            -
            `:h[${bigint}]:w[, ${bigint}]` |
         | 
| 62 | 
            -
            `:h[,${bigint}]:w[${bigint},${bigint}]` |
         | 
| 63 | 
            -
            `:h[, ${bigint}]:w[${bigint},${bigint}]` |
         | 
| 64 | 
            -
            `:h[,${bigint}]:w[${bigint}, ${bigint}]` |
         | 
| 65 | 
            -
            `:h[, ${bigint}]:w[${bigint}, ${bigint}]` |
         | 
| 66 | 
            -
            `:h[${bigint},${bigint}]:w[,${bigint}]` |
         | 
| 67 | 
            -
            `:h[${bigint}, ${bigint}]:w[,${bigint}]` |
         | 
| 68 | 
            -
            `:h[${bigint},${bigint}]:w[, ${bigint}]` |
         | 
| 69 | 
            -
            `:h[${bigint}, ${bigint}]:w[, ${bigint}]`
         | 
| 8 | 
            +
            export type MediaQueries =
         | 
| 9 | 
            +
                | `${WidthMediaQuery}${Optional<HeightMediaQuery>}`
         | 
| 10 | 
            +
                | `${HeightMediaQuery}${Optional<WidthMediaQuery>}`
         |