react-native-unistyles 2.0.0-alpha.5 → 2.0.0-alpha.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/cxx/UnistylesRuntime.cpp +262 -0
  2. package/cxx/UnistylesRuntime.h +61 -0
  3. package/lib/commonjs/Unistyles.js +1 -1
  4. package/lib/commonjs/Unistyles.js.map +1 -1
  5. package/lib/commonjs/UnistylesEngine.js +9 -5
  6. package/lib/commonjs/UnistylesEngine.js.map +1 -1
  7. package/lib/commonjs/createStyleSheet.js.map +1 -1
  8. package/lib/commonjs/index.js +7 -0
  9. package/lib/commonjs/index.js.map +1 -1
  10. package/lib/commonjs/types/cxx.js.map +1 -1
  11. package/lib/commonjs/useStyles.js +0 -2
  12. package/lib/commonjs/useStyles.js.map +1 -1
  13. package/lib/commonjs/useUnistyles.js.map +1 -1
  14. package/lib/commonjs/utils/breakpoints.js +11 -68
  15. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  16. package/lib/commonjs/utils/common.js +3 -1
  17. package/lib/commonjs/utils/common.js.map +1 -1
  18. package/lib/commonjs/utils/index.js +8 -0
  19. package/lib/commonjs/utils/index.js.map +1 -1
  20. package/lib/commonjs/utils/mediaQueries.js +57 -155
  21. package/lib/commonjs/utils/mediaQueries.js.map +1 -1
  22. package/lib/commonjs/utils/mq.js +75 -0
  23. package/lib/commonjs/utils/mq.js.map +1 -0
  24. package/lib/commonjs/utils/styles.js +11 -51
  25. package/lib/commonjs/utils/styles.js.map +1 -1
  26. package/lib/module/Unistyles.js +2 -2
  27. package/lib/module/Unistyles.js.map +1 -1
  28. package/lib/module/UnistylesEngine.js +7 -3
  29. package/lib/module/UnistylesEngine.js.map +1 -1
  30. package/lib/module/createStyleSheet.js.map +1 -1
  31. package/lib/module/index.js +1 -0
  32. package/lib/module/index.js.map +1 -1
  33. package/lib/module/types/cxx.js.map +1 -1
  34. package/lib/module/useStyles.js +0 -3
  35. package/lib/module/useStyles.js.map +1 -1
  36. package/lib/module/useUnistyles.js.map +1 -1
  37. package/lib/module/utils/breakpoints.js +11 -68
  38. package/lib/module/utils/breakpoints.js.map +1 -1
  39. package/lib/module/utils/common.js +2 -0
  40. package/lib/module/utils/common.js.map +1 -1
  41. package/lib/module/utils/index.js +1 -0
  42. package/lib/module/utils/index.js.map +1 -1
  43. package/lib/module/utils/mediaQueries.js +57 -155
  44. package/lib/module/utils/mediaQueries.js.map +1 -1
  45. package/lib/module/utils/mq.js +69 -0
  46. package/lib/module/utils/mq.js.map +1 -0
  47. package/lib/module/utils/styles.js +10 -51
  48. package/lib/module/utils/styles.js.map +1 -1
  49. package/lib/typescript/src/Unistyles.d.ts +2 -2
  50. package/lib/typescript/src/Unistyles.d.ts.map +1 -1
  51. package/lib/typescript/src/UnistylesEngine.d.ts +4 -1
  52. package/lib/typescript/src/UnistylesEngine.d.ts.map +1 -1
  53. package/lib/typescript/src/createStyleSheet.d.ts +2 -5
  54. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
  55. package/lib/typescript/src/index.d.ts +1 -0
  56. package/lib/typescript/src/index.d.ts.map +1 -1
  57. package/lib/typescript/src/types/breakpoints.d.ts +2 -1
  58. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  59. package/lib/typescript/src/types/core.d.ts +18 -16
  60. package/lib/typescript/src/types/core.d.ts.map +1 -1
  61. package/lib/typescript/src/types/cxx.d.ts +7 -1
  62. package/lib/typescript/src/types/cxx.d.ts.map +1 -1
  63. package/lib/typescript/src/types/index.d.ts +1 -1
  64. package/lib/typescript/src/types/index.d.ts.map +1 -1
  65. package/lib/typescript/src/types/mediaQueries.d.ts +5 -3
  66. package/lib/typescript/src/types/mediaQueries.d.ts.map +1 -1
  67. package/lib/typescript/src/useStyles.d.ts +2 -4
  68. package/lib/typescript/src/useStyles.d.ts.map +1 -1
  69. package/lib/typescript/src/useUnistyles.d.ts +4 -5
  70. package/lib/typescript/src/useUnistyles.d.ts.map +1 -1
  71. package/lib/typescript/src/utils/breakpoints.d.ts +2 -60
  72. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  73. package/lib/typescript/src/utils/common.d.ts +2 -0
  74. package/lib/typescript/src/utils/common.d.ts.map +1 -1
  75. package/lib/typescript/src/utils/index.d.ts +1 -0
  76. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  77. package/lib/typescript/src/utils/mediaQueries.d.ts +8 -127
  78. package/lib/typescript/src/utils/mediaQueries.d.ts.map +1 -1
  79. package/lib/typescript/src/utils/mq.d.ts +15 -0
  80. package/lib/typescript/src/utils/mq.d.ts.map +1 -0
  81. package/lib/typescript/src/utils/styles.d.ts +1 -46
  82. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  83. package/package.json +10 -1
  84. package/src/Unistyles.ts +3 -3
  85. package/src/UnistylesEngine.ts +12 -3
  86. package/src/createStyleSheet.ts +2 -5
  87. package/src/index.ts +1 -0
  88. package/src/types/breakpoints.ts +6 -3
  89. package/src/types/core.ts +25 -22
  90. package/src/types/cxx.ts +8 -1
  91. package/src/types/index.ts +1 -1
  92. package/src/types/mediaQueries.ts +9 -4
  93. package/src/useStyles.ts +3 -6
  94. package/src/useUnistyles.ts +11 -4
  95. package/src/utils/breakpoints.ts +14 -71
  96. package/src/utils/common.ts +2 -0
  97. package/src/utils/index.ts +1 -0
  98. package/src/utils/mediaQueries.ts +102 -163
  99. package/src/utils/mq.ts +77 -0
  100. package/src/utils/styles.ts +13 -55
@@ -1,26 +1,6 @@
1
1
  import { unistyles } from '../Unistyles';
2
2
  import { isMobile, Orientation, throwError } from './common';
3
3
  import { ScreenOrientation } from '../types';
4
- import { getKeyForCustomMediaQuery, isMediaQuery } from './mediaQueries';
5
- /**
6
- * Sorts the breakpoints object based on its numeric values in ascending order and validates them.
7
- *
8
- * This function takes an object where keys represent breakpoint names and values are numeric.
9
- * It returns a new object with the same keys but sorted based on their corresponding numeric values.
10
- * Additionally, it validates that:
11
- * 1. The first breakpoint starts with a value of 0.
12
- * 2. No duplicate breakpoint values exist.
13
- *
14
- * If the validation fails, appropriate error messages are logged to the console.
15
- *
16
- * @template B - An object type where keys are strings and values are numbers.
17
- * @param {B} breakpoints - The breakpoints object to be sorted and validated.
18
- * @returns {B} A new object with sorted and validated breakpoints.
19
- *
20
- * @example
21
- * const input = { md: 768, lg: 1024, sm: 0 }
22
- * sortAndValidateBreakpoints(input) // returns { sm: 0, md: 768, lg: 1024 }
23
- */
24
4
  export const sortAndValidateBreakpoints = breakpoints => {
25
5
  const sortedPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
26
6
  const [, value1] = breakpoint1;
@@ -38,22 +18,6 @@ export const sortAndValidateBreakpoints = breakpoints => {
38
18
  }
39
19
  return sortedBreakpoints;
40
20
  };
41
-
42
- /**
43
- * Determines the appropriate breakpoint key for a given screen width based on provided breakpoints.
44
- *
45
- * This function takes a screen width and an object of breakpoints. It returns the key of the breakpoint
46
- * that the screen width falls into. The breakpoints are assumed to be sorted in ascending order.
47
- *
48
- * @template B - An object type where keys are strings and values are numbers representing screen widths.
49
- * @param {number} width - The screen width to determine the breakpoint for.
50
- * @param breakpointEntries - sorted pairs of breakpoints
51
- * @returns {keyof B & string} The key of the breakpoint that the screen width falls into.
52
- *
53
- * @example
54
- * const breakpoints = { sm: 0, md: 768, lg: 1024 }
55
- * getBreakpointFromScreenWidth(800, breakpoints) // returns 'md'
56
- */
57
21
  export const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
58
22
  const [key] = breakpointEntries.find((_ref, index, otherBreakpoints) => {
59
23
  let [, value] = _ref;
@@ -66,38 +30,14 @@ export const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
66
30
  });
67
31
  return key;
68
32
  };
69
-
70
- /**
71
- * Retrieves the value associated with a given breakpoint or custom media query based on the provided screen size.
72
- *
73
- * The function first checks for custom media queries. If a matching custom media query is found, its associated value is returned.
74
- * If no custom media query matches, the function then checks for a direct breakpoint match.
75
- * If there's no direct breakpoint match, the function simulates CSS cascading to find the closest matching breakpoint.
76
- *
77
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
78
- *
79
- * @param {Record<keyof B & string, string | number>} value - An object containing values associated with breakpoints or custom media queries.
80
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
81
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
82
- * @param breakpointPairs - sorted pairs of breakpoints
83
- *
84
- * @returns {string | number | undefined} Returns the value associated with the matching breakpoint or custom media query, or `undefined` if no match is found.
85
- *
86
- * @example
87
- *
88
- * const values = { ':w[200]': 'value1', sm: 'value2', md: 'value3' }
89
- * const screenSize = { width: 250, height: 400 }
90
- * const breakpoints = { sm: 300, md: 600, lg: 900 }
91
- *
92
- * getValueForBreakpoint(values, 'sm', screenSize, breakpoints); // 'value1'
93
- */
94
- export const getValueForBreakpoint = (value, breakpoint, screenSize) => {
33
+ export const getValueForBreakpoint = value => {
95
34
  // the highest priority is for custom media queries
96
35
  const customMediaQueries = Object.entries(value).filter(_ref2 => {
97
36
  let [key] = _ref2;
98
- return isMediaQuery(key);
37
+ return unistyles.engine.isMediaQuery(key);
99
38
  });
100
- const customMediaQueryKey = getKeyForCustomMediaQuery(customMediaQueries, screenSize);
39
+ // const customMediaQueryKey = getKeyForCustomMediaQuery(customMediaQueries, screenSize) as keyof typeof value
40
+ const customMediaQueryKey = unistyles.engine.didMatchMediaQuery(customMediaQueries);
101
41
  if (customMediaQueryKey && customMediaQueryKey in value) {
102
42
  return value[customMediaQueryKey];
103
43
  }
@@ -110,13 +50,16 @@ export const getValueForBreakpoint = (value, breakpoint, screenSize) => {
110
50
  if (!hasBreakpoints && isMobile && (Orientation.Landscape in value || Orientation.Portrait in value)) {
111
51
  return value[unistyles.runtime.orientation === ScreenOrientation.Portrait ? Orientation.Portrait : Orientation.Landscape];
112
52
  }
53
+ const breakpoint = unistyles.runtime.breakpoint;
54
+ if (!breakpoint) {
55
+ return undefined;
56
+ }
113
57
 
114
58
  // if user defined breakpoints, then we look for the valid one
115
- const unifiedKey = breakpoint?.toLowerCase();
116
- const directBreakpoint = value[unifiedKey];
59
+ const directBreakpoint = value[breakpoint];
117
60
 
118
61
  // if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
119
- if (directBreakpoint || unifiedKey in value) {
62
+ if (directBreakpoint || breakpoint in value) {
120
63
  return directBreakpoint;
121
64
  }
122
65
 
@@ -124,7 +67,7 @@ export const getValueForBreakpoint = (value, breakpoint, screenSize) => {
124
67
  const breakpointPairs = unistyles.runtime.sortedBreakpoints;
125
68
  const currentBreakpoint = breakpointPairs.findIndex(_ref3 => {
126
69
  let [key] = _ref3;
127
- return key === unifiedKey;
70
+ return key === breakpoint;
128
71
  });
129
72
  const availableBreakpoints = breakpointPairs.filter((_ref4, index) => {
130
73
  let [key] = _ref4;
@@ -1 +1 @@
1
- {"version":3,"names":["unistyles","isMobile","Orientation","throwError","ScreenOrientation","getKeyForCustomMediaQuery","isMediaQuery","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","length","Set","size","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","customMediaQueries","filter","_ref2","customMediaQueryKey","hasBreakpoints","runtime","Landscape","Portrait","orientation","unifiedKey","toLowerCase","directBreakpoint","breakpointPairs","currentBreakpoint","findIndex","_ref3","availableBreakpoints","_ref4","map","_ref5","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,QAAQ,EAAEC,WAAW,EAAEC,UAAU,QAAQ,UAAU;AAE5D,SAASC,iBAAiB,QAAQ,UAAU;AAC5C,SAASC,yBAAyB,EAAEC,YAAY,QAAQ,gBAAgB;AAGxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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,gBAAgB,IAAKF,UAAU,IAAIf,KAAM,EAAE;IAC3C,OAAOiB,gBAAgB;EAC3B;;EAEA;EACA,MAAMC,eAAe,GAAGpD,SAAS,CAAC6C,OAAO,CAAC5B,iBAAiB;EAC3D,MAAMoC,iBAAiB,GAAGD,eAAe,CACpCE,SAAS,CAACC,KAAA;IAAA,IAAC,CAAC1B,GAAG,CAAC,GAAA0B,KAAA;IAAA,OAAK1B,GAAG,KAAKoB,UAAU;EAAA,EAAC;EAE7C,MAAMO,oBAAoB,GAAGJ,eAAe,CACvCX,MAAM,CAAC,CAAAgB,KAAA,EAAQzB,KAAK;IAAA,IAAZ,CAACH,GAAG,CAAC,GAAA4B,KAAA;IAAA,OAAYzB,KAAK,GAAGqB,iBAAiB,IAAIxB,GAAG,IAAIA,GAAG,IAAIK,KAAK;EAAA,EAAC,CAC1EwB,GAAG,CAACC,KAAA;IAAA,IAAC,CAAC9B,GAAG,CAAC,GAAA8B,KAAA;IAAA,OAAK9B,GAAG;EAAA,EAAC;EAExB,OAAOuB,eAAe,CAAC7B,MAAM,GAAG,CAAC,GAC3BW,KAAK,CAACsB,oBAAoB,CAACA,oBAAoB,CAACjC,MAAM,GAAG,CAAC,CAAC,CAAwC,GACnGqC,SAAS;AACnB,CAAC"}
1
+ {"version":3,"names":["unistyles","isMobile","Orientation","throwError","ScreenOrientation","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","length","Set","size","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","customMediaQueries","filter","_ref2","engine","isMediaQuery","customMediaQueryKey","didMatchMediaQuery","hasBreakpoints","runtime","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpoint","findIndex","_ref3","availableBreakpoints","_ref4","map","_ref5"],"sourceRoot":"../../../src","sources":["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,CAAC;;EAE1C;EACA,IAAIE,gBAAgB,IAAKF,UAAU,IAAIhB,KAAM,EAAE;IAC3C,OAAOkB,gBAAgB;EAC3B;;EAEA;EACA,MAAMC,eAAe,GAAGnD,SAAS,CAAC4C,OAAO,CAAC7B,iBAAiB;EAC3D,MAAMqC,iBAAiB,GAAGD,eAAe,CACpCE,SAAS,CAACC,KAAA;IAAA,IAAC,CAAC3B,GAAG,CAAC,GAAA2B,KAAA;IAAA,OAAK3B,GAAG,KAAKqB,UAAU;EAAA,EAAC;EAE7C,MAAMO,oBAAoB,GAAGJ,eAAe,CACvCd,MAAM,CAAC,CAAAmB,KAAA,EAAQ1B,KAAK;IAAA,IAAZ,CAACH,GAAG,CAAC,GAAA6B,KAAA;IAAA,OAAY1B,KAAK,GAAGsB,iBAAiB,IAAIzB,GAAG,IAAIA,GAAG,IAAIK,KAAK;EAAA,EAAC,CAC1EyB,GAAG,CAACC,KAAA;IAAA,IAAC,CAAC/B,GAAG,CAAC,GAAA+B,KAAA;IAAA,OAAK/B,GAAG;EAAA,EAAC;EAExB,OAAOwB,eAAe,CAAC9B,MAAM,GAAG,CAAC,GAC3BW,KAAK,CAACuB,oBAAoB,CAACA,oBAAoB,CAAClC,MAAM,GAAG,CAAC,CAAC,CAAwC,GACnG4B,SAAS;AACnB,CAAC"}
@@ -7,6 +7,8 @@ export const warn = message => {
7
7
  };
8
8
  export const isMobile = Platform.OS === 'android' || Platform.OS === 'ios';
9
9
  export const isWeb = Platform.OS === 'web';
10
+ export const isIOS = Platform.OS === 'ios';
11
+ export const isAndroid = Platform.OS === 'android';
10
12
  export const isServer = typeof window === 'undefined';
11
13
  export const Orientation = {
12
14
  Landscape: 'landscape',
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","throwError","message","Error","warn","console","isMobile","OS","isWeb","isServer","window","Orientation","Landscape","Portrait"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAED,OAAO,MAAME,IAAI,GAAIF,OAAe,IAAK;EACrCG,OAAO,CAACD,IAAI,CAAE,gCAA+BF,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAMI,QAAQ,GAAGN,QAAQ,CAACO,EAAE,KAAK,SAAS,IAAIP,QAAQ,CAACO,EAAE,KAAK,KAAK;AAC1E,OAAO,MAAMC,KAAK,GAAGR,QAAQ,CAACO,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW;AAErD,OAAO,MAAMC,WAAW,GAAG;EACvBC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU"}
1
+ {"version":3,"names":["Platform","throwError","message","Error","warn","console","isMobile","OS","isWeb","isIOS","isAndroid","isServer","window","Orientation","Landscape","Portrait"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAED,OAAO,MAAME,IAAI,GAAIF,OAAe,IAAK;EACrCG,OAAO,CAACD,IAAI,CAAE,gCAA+BF,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAMI,QAAQ,GAAGN,QAAQ,CAACO,EAAE,KAAK,SAAS,IAAIP,QAAQ,CAACO,EAAE,KAAK,KAAK;AAC1E,OAAO,MAAMC,KAAK,GAAGR,QAAQ,CAACO,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,KAAK,GAAGT,QAAQ,CAACO,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMG,SAAS,GAAGV,QAAQ,CAACO,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMI,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW;AAErD,OAAO,MAAMC,WAAW,GAAG;EACvBC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU"}
@@ -1,5 +1,6 @@
1
1
  export { normalizeStyles } from './normalizeStyles';
2
2
  export * from './normalizer';
3
+ export { mq } from './mq';
3
4
  export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
4
5
  export { proxifyFunction, parseStyle } from './styles';
5
6
  export { isServer, Orientation } from './common';
@@ -1 +1 @@
1
- {"version":3,"names":["normalizeStyles","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","getValueForBreakpoint","proxifyFunction","parseStyle","isServer","Orientation","extractValues","getKeyForCustomMediaQuery","isMediaQuery","isWithinTheHeight","isWithinTheWidth","isWithinTheWidthAndHeight"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,cAAc,cAAc;AAC5B,SAASC,4BAA4B,EAAEC,0BAA0B,EAAEC,qBAAqB,QAAQ,eAAe;AAC/G,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SAASC,QAAQ,EAAEC,WAAW,QAAQ,UAAU;AAChD,SACIC,aAAa,EACbC,yBAAyB,EACzBC,YAAY,EACZC,iBAAiB,EACjBC,gBAAgB,EAChBC,yBAAyB,QACtB,gBAAgB"}
1
+ {"version":3,"names":["normalizeStyles","mq","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","getValueForBreakpoint","proxifyFunction","parseStyle","isServer","Orientation","extractValues","getKeyForCustomMediaQuery","isMediaQuery","isWithinTheHeight","isWithinTheWidth","isWithinTheWidthAndHeight"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,cAAc,cAAc;AAC5B,SAASC,EAAE,QAAQ,MAAM;AACzB,SAASC,4BAA4B,EAAEC,0BAA0B,EAAEC,qBAAqB,QAAQ,eAAe;AAC/G,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SAASC,QAAQ,EAAEC,WAAW,QAAQ,UAAU;AAChD,SACIC,aAAa,EACbC,yBAAyB,EACzBC,YAAY,EACZC,iBAAiB,EACjBC,gBAAgB,EAChBC,yBAAyB,QACtB,gBAAgB"}
@@ -1,182 +1,84 @@
1
- /**
2
- * Extracts numeric values from a coded string.
3
- *
4
- * The function is designed to process strings that have a format like "w[100,200]" or "h[300]".
5
- * It removes characters 'w', 'h', '[', and ']' from the input string and then extracts the numbers.
6
- *
7
- * @param {string} codedValue - The input string to extract values from.
8
- * @returns {Array<number>} An array of extracted numbers. Can contain one or two numbers based on the input format.
9
- *
10
- * @example
11
- * extractValues("w[100,200]") // returns [100, 200]
12
- * extractValues("h[300]") // returns [300]
13
- * extractValues("h[,300]") // returns [0,300]
14
- * extractValues("h[100,]") // returns [100]
15
- */
16
- export const extractValues = codedValue => {
17
- const cleanedValue = codedValue.replace(/[wh ]/g, '');
18
- const [left, right] = cleanedValue.split(',');
19
- if (!right) {
20
- const lh = left.startsWith('[') ? Number(left.replace(/[[\]()]/g, '')) : Number(left.replace(/[[\]()]/g, '')) + 1;
21
- return [lh];
1
+ const parseLhs = (lhs, breakpoints, hasRhs) => {
2
+ const matches = lhs.match(/([([])|([^[\]()]+)|([\])])/g);
3
+ if (!hasRhs) {
4
+ const [openBracket, value, closeBracket] = matches;
5
+ const spacelessValue = value?.trim();
6
+ const parsedNumber = Number(spacelessValue);
7
+ const parsedValue = isNaN(parsedNumber) ? breakpoints[spacelessValue] : parsedNumber;
8
+ return [Number(openBracket === '('), closeBracket === ')' ? parsedValue - 1 : parsedValue];
22
9
  }
23
- const lh = left.startsWith('[') ? Number(left.replace('[', '')) : Number(left.replace('(', '')) + 1;
24
- const rh = right.endsWith(']') ? Number(right.replace(']', '')) : Number(right.replace(')', '')) - 1;
25
- return [lh, rh];
10
+ const [openBracket, value] = matches;
11
+ if (!value) {
12
+ return [Number(openBracket === '(')];
13
+ }
14
+ const spacelessValue = value?.trim();
15
+ const parsedNumber = Number(spacelessValue);
16
+ const parsedValue = isNaN(parsedNumber) ? breakpoints[spacelessValue] : parsedNumber;
17
+ return openBracket === '(' ? [parsedValue - 1] : [parsedValue];
18
+ };
19
+ const parseRhs = (rhs, breakpoints) => {
20
+ const matches = rhs.match(/([([])|([^[\]()]+)|([\])])/g);
21
+ const [value, closeBrackets] = matches;
22
+ const spacelessValue = value.trim();
23
+ const parsedNumber = Number(spacelessValue);
24
+ const parsedValue = isNaN(parsedNumber) ? breakpoints[spacelessValue] : parsedNumber;
25
+ return [closeBrackets === ')' ? parsedValue - 1 : parsedValue];
26
+ };
27
+ export const extractValues = (pattern, breakpoints) => {
28
+ const [lhs, rhs] = pattern.replace(/(:w|:h)/g, '').split(',');
29
+ if (!rhs) {
30
+ return parseLhs(lhs, breakpoints, false);
31
+ }
32
+ const [parsedLhs] = parseLhs(lhs, breakpoints, true);
33
+ if (parsedLhs === undefined || isNaN(parsedLhs)) {
34
+ return [];
35
+ }
36
+ const [parsedRhs] = parseRhs(rhs, breakpoints);
37
+ if (parsedRhs === undefined || isNaN(parsedRhs)) {
38
+ return [];
39
+ }
40
+ return [parsedLhs, parsedRhs];
26
41
  };
27
-
28
- /**
29
- * Determines if the given screen size matches the specified breakpoint query.
30
- *
31
- * The function checks if the screen size (width and/or height) falls within the range
32
- * specified by the breakpoint query. The query can specify width (using 'w'), height (using 'h'),
33
- * or both.
34
- *
35
- * @param {string} query - The breakpoint query string. Examples: 'w[100,200]', 'h[300]', 'w[100,200]h[300,400]'.
36
- * @param {ScreenSize} screenSize - The screen size to check against the breakpoint query.
37
- * @returns {boolean} True if the screen size matches the breakpoint query, false otherwise.
38
- *
39
- * @example
40
- * const screenSize = { width: 150, height: 350 }
41
- * isWithinBreakpoint('w[100,200]', screenSize) // returns true
42
- * isWithinBreakpoint('h[400]', screenSize) // returns false
43
- */
44
- export const isWithinBreakpoint = (query, screenSize) => {
45
- if (query.includes('w') && query.includes('h')) {
46
- return isWithinTheWidthAndHeight(query, screenSize);
42
+ export const isWithinBreakpoint = (query, screenSize, breakpoints) => {
43
+ const hasWidthBreakpoint = query.includes(':w');
44
+ const hasHeightBreakpoint = query.includes(':h');
45
+ if (hasWidthBreakpoint && hasHeightBreakpoint) {
46
+ return isWithinTheWidthAndHeight(query, screenSize, breakpoints);
47
47
  }
48
- if (query.charAt(0) === 'w') {
49
- return isWithinTheWidth(query, screenSize.width);
48
+ if (hasWidthBreakpoint) {
49
+ return isWithinTheWidth(query, screenSize.width, breakpoints);
50
50
  }
51
- if (query.charAt(0) === 'h') {
52
- return isWithinTheHeight(query, screenSize.height);
51
+ if (hasHeightBreakpoint) {
52
+ return isWithinTheHeight(query, screenSize.height, breakpoints);
53
53
  }
54
54
  return false;
55
55
  };
56
-
57
- /**
58
- * Determines if the given width matches the specified width range in the query.
59
- *
60
- * The function checks if the provided width falls within the range specified by the query.
61
- * The query specifies a width range using a format like 'w[100,200]'. If only one value is provided,
62
- * it's treated as a minimum width.
63
- *
64
- * @param {string} query - The width query string. Examples: 'w[100,200]' or 'w[100]'.
65
- * @param {number} width - The width to check against the query.
66
- * @returns {boolean} True if the width matches the query range, false otherwise.
67
- *
68
- * @example
69
- * isWithinTheWidth('w[100,200]', 150) // returns true
70
- * isWithinTheWidth('w[100]', 50) // returns false
71
- * isWithinTheWidth('w[100]', 150) // returns true
72
- */
73
- export const isWithinTheWidth = (query, width) => {
74
- const [minWidth, maxWidth] = extractValues(query);
56
+ export const isWithinTheWidth = (query, width, breakpoints) => {
57
+ const [minWidth, maxWidth] = extractValues(query, breakpoints);
75
58
  if (maxWidth && width >= minWidth && width <= maxWidth) {
76
59
  return true;
77
60
  }
78
61
  return !maxWidth && width >= minWidth;
79
62
  };
80
-
81
- /**
82
- * Determines if the given height matches the specified height range in the query.
83
- *
84
- * The function checks if the provided height falls within the range specified by the query.
85
- * The query specifies a height range using a format like 'h[100,200]'. If only one value is provided,
86
- * it's treated as a minimum height.
87
- *
88
- * @param {string} query - The height query string. Examples: 'h[100,200]' or 'h[100]'.
89
- * @param {number} height - The height to check against the query.
90
- * @returns {boolean} True if the height matches the query range, false otherwise.
91
- *
92
- * @example
93
- * isWithinTheHeight('h[100,200]', 150) // returns true
94
- * isWithinTheHeight('h[100]', 50) // returns false
95
- * isWithinTheHeight('h[100]', 150) // returns true
96
- */
97
- export const isWithinTheHeight = (query, height) => {
98
- const [minHeight, maxHeight] = extractValues(query);
63
+ export const isWithinTheHeight = (query, height, breakpoints) => {
64
+ const [minHeight, maxHeight] = extractValues(query, breakpoints);
99
65
  if (maxHeight && height >= minHeight && height <= maxHeight) {
100
66
  return true;
101
67
  }
102
68
  return !maxHeight && height >= minHeight;
103
69
  };
104
-
105
- /**
106
- * Determines if the given screen size matches both the specified width and height ranges in the query.
107
- *
108
- * The function checks if the provided screen size (both width and height) falls within the ranges
109
- * specified by the query. The query can specify both width and height using a format like 'w[100,200]:h[300,400]'.
110
- *
111
- * @param {string} query - The combined width and height query string. Example: 'w[100,200]:h[300,400]'.
112
- * @param {ScreenSize} screenSize - The screen size to check against the query.
113
- * @returns {boolean} True if the screen size matches both the width and height ranges in the query, false otherwise.
114
- *
115
- * @example
116
- * const screenSize = { width: 150, height: 350 }
117
- * isWithinTheWidthAndHeight('w[100,200]:h[300,400]', screenSize) // returns true
118
- * isWithinTheWidthAndHeight('w[100,200]:h[400,500]', screenSize) // returns false
119
- */
120
- export const isWithinTheWidthAndHeight = (query, screenSize) => {
121
- const result = query.split(':').filter(Boolean).map(q => isWithinBreakpoint(q, screenSize)).filter(Boolean);
70
+ export const isWithinTheWidthAndHeight = (query, screenSize, breakpoints) => {
71
+ const result = query.split(':').filter(Boolean).map(q => isWithinBreakpoint(`:${q}`, screenSize, breakpoints)).filter(Boolean);
122
72
  return result.length === 2;
123
73
  };
124
-
125
- /**
126
- * Checks if the given query string is a valid custom media query.
127
- *
128
- * The valid custom media query formats include:
129
- * - :w[200]
130
- * - :w[0, 200]
131
- * - :w[, 300]
132
- * - :h[200]
133
- * - :h[0, 500]
134
- * - :h[,200]
135
- * - :w[100, 300]:h[200,500]
136
- * - :h[200,500]:w[100, 300]
137
- *
138
- * @param {string} query - The query string to be checked.
139
- * @returns {boolean} Returns `true` if the query is a valid custom media query, otherwise `false`.
140
- * @example
141
- *
142
- * isMediaQuery(':w[200]') // true
143
- * isMediaQuery(':w100]') // false
144
- */
145
74
  export const isMediaQuery = query => {
146
- const regex = /^(?:(:w\[\d*(?:,\s?\d+)?])?(:h\[\d*(?:,\s?\d+)?])?|(:h\[\d*(?:,\s?\d+)?])?(:w\[\d*(?:,\s?\d+)?])?)$/;
75
+ const regex = /(:w|:h)/;
147
76
  return query.length > 0 && regex.test(query);
148
77
  };
149
-
150
- /**
151
- * Retrieves the first matching custom media query key based on the provided screen size.
152
- *
153
- * The function processes an array of media queries and returns the first query that matches
154
- * the given screen size. The media queries can be in formats like:
155
- * - w[200]
156
- * - w[0, 200]
157
- * - w[, 300]
158
- * - h[200]
159
- * - h[0, 500]
160
- * - h[,200]
161
- * - w[100, 300]:h[200,500]
162
- * - h[200,500]:w[100, 300]
163
- *
164
- * @param {Array<[string, string | number]>} mediaQueries - An array of tuples containing media query keys and associated values.
165
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
166
- * @returns {string | undefined} Returns the first matching media query key or `undefined` if no match is found.
167
- * @example
168
- *
169
- * const queries = [[':w[200]', 'value1'], [':h[300,500]', 'value2']]
170
- * const size = { width: 250, height: 400 }
171
- * getKeyForCustomMediaQuery(queries, size) // ':w[200]
172
- */
173
- export const getKeyForCustomMediaQuery = (mediaQueries, screenSize) => {
78
+ export const getKeyForCustomMediaQuery = (mediaQueries, screenSize, breakpoints) => {
174
79
  const [matchedQuery] = mediaQueries.flatMap(_ref => {
175
80
  let [key] = _ref;
176
- if (key.includes('w') && key.includes('h')) {
177
- return isWithinBreakpoint(key, screenSize) ? key : undefined;
178
- }
179
- return key.split(':').filter(Boolean).map(query => isWithinBreakpoint(query, screenSize) ? key : undefined);
81
+ return isWithinBreakpoint(key, screenSize, breakpoints) ? key : undefined;
180
82
  }).filter(Boolean);
181
83
  return matchedQuery;
182
84
  };
@@ -1 +1 @@
1
- {"version":3,"names":["extractValues","codedValue","cleanedValue","replace","left","right","split","lh","startsWith","Number","rh","endsWith","isWithinBreakpoint","query","screenSize","includes","isWithinTheWidthAndHeight","charAt","isWithinTheWidth","width","isWithinTheHeight","height","minWidth","maxWidth","minHeight","maxHeight","result","filter","Boolean","map","q","length","isMediaQuery","regex","test","getKeyForCustomMediaQuery","mediaQueries","matchedQuery","flatMap","_ref","key","undefined"],"sourceRoot":"../../../src","sources":["utils/mediaQueries.ts"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,aAAa,GAAIC,UAAkB,IAAoB;EAChE,MAAMC,YAAY,GAAGD,UAAU,CAACE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;EACrD,MAAM,CAACC,IAAI,EAAEC,KAAK,CAAC,GAAGH,YAAY,CAACI,KAAK,CAAC,GAAG,CAAiC;EAE7E,IAAI,CAACD,KAAK,EAAE;IACR,MAAME,EAAE,GAAGH,IAAI,CAACI,UAAU,CAAC,GAAG,CAAC,GACzBC,MAAM,CAACL,IAAI,CAACD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,GACpCM,MAAM,CAACL,IAAI,CAACD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;IAE9C,OAAO,CAACI,EAAE,CAAC;EACf;EAEA,MAAMA,EAAE,GAAGH,IAAI,CAACI,UAAU,CAAC,GAAG,CAAC,GACzBC,MAAM,CAACL,IAAI,CAACD,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAC7BM,MAAM,CAACL,IAAI,CAAC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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMsB,yBAAyB,GAAGA,CAACC,YAA0D,EAAEtB,UAAsB,KAAyB;EACjJ,MAAM,CAACuB,YAAY,CAAC,GAAGD,YAAY,CAC9BE,OAAO,CAACC,IAAA,IAAW;IAAA,IAAV,CAACC,GAAG,CAAC,GAAAD,IAAA;IACX,IAAIC,GAAG,CAACzB,QAAQ,CAAC,GAAG,CAAC,IAAIyB,GAAG,CAACzB,QAAQ,CAAC,GAAG,CAAC,EAAE;MACxC,OAAOH,kBAAkB,CAAC4B,GAAG,EAAE1B,UAAU,CAAC,GAAG0B,GAAG,GAAGC,SAAS;IAChE;IAEA,OAAOD,GAAG,CACLlC,KAAK,CAAC,GAAG,CAAC,CACVqB,MAAM,CAACC,OAAO,CAAC,CACfC,GAAG,CAAChB,KAAK,IAAID,kBAAkB,CAACC,KAAK,EAAEC,UAAU,CAAC,GAAG0B,GAAG,GAAGC,SAAS,CAAC;EAC9E,CAAC,CAAC,CACDd,MAAM,CAACC,OAAO,CAAC;EAEpB,OAAOS,YAAY;AACvB,CAAC"}
1
+ {"version":3,"names":["parseLhs","lhs","breakpoints","hasRhs","matches","match","openBracket","value","closeBracket","spacelessValue","trim","parsedNumber","Number","parsedValue","isNaN","parseRhs","rhs","closeBrackets","extractValues","pattern","replace","split","parsedLhs","undefined","parsedRhs","isWithinBreakpoint","query","screenSize","hasWidthBreakpoint","includes","hasHeightBreakpoint","isWithinTheWidthAndHeight","isWithinTheWidth","width","isWithinTheHeight","height","minWidth","maxWidth","minHeight","maxHeight","result","filter","Boolean","map","q","length","isMediaQuery","regex","test","getKeyForCustomMediaQuery","mediaQueries","matchedQuery","flatMap","_ref","key"],"sourceRoot":"../../../src","sources":["utils/mediaQueries.ts"],"mappings":"AAIA,MAAMA,QAAQ,GAAGA,CAACC,GAAW,EAAEC,WAAiC,EAAEC,MAAe,KAAK;EAClF,MAAMC,OAAO,G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,CAAC,CAC9DuC,MAAM,CAACC,OAAO,CAAC;EAEpB,OAAOF,MAAM,CAACK,MAAM,KAAK,CAAC;AAC9B,CAAC;AAED,OAAO,MAAMC,YAAY,GAAIpB,KAAa,IAAc;EACpD,MAAMqB,KAAK,GAAG,SAAS;EAEvB,OAAOrB,KAAK,CAACmB,MAAM,GAAG,CAAC,IAAIE,KAAK,CAACC,IAAI,CAACtB,KAAK,CAAC;AAChD,CAAC;AAED,OAAO,MAAMuB,yBAAyB,GAAGA,CACrCC,YAA6F,EAC7FvB,UAAsB,EACtBzB,WAAiC,KACZ;EACrB,MAAM,CAACiD,YAAY,CAAC,GAAGD,YAAY,CAC9BE,OAAO,CAACC,IAAA;IAAA,IAAC,CAACC,GAAG,CAAC,GAAAD,IAAA;IAAA,OAAK5B,kBAAkB,CAAC6B,GAAG,EAAE3B,UAAU,EAAEzB,WAAW,CAAC,GAAGoD,GAAG,GAAG/B,SAAS;EAAA,EAAC,CACtFkB,MAAM,CAACC,OAAO,CAAC;EAEpB,OAAOS,YAAY;AACvB,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { unistyles } from '../Unistyles';
2
+ const MQSymbol = Symbol('unistyles-mq');
3
+ var MQProp = /*#__PURE__*/function (MQProp) {
4
+ MQProp["toString"] = "toString";
5
+ MQProp["width"] = "width";
6
+ MQProp["height"] = "height";
7
+ return MQProp;
8
+ }(MQProp || {});
9
+ const getMQValue = value => {
10
+ if (typeof value === 'number') {
11
+ return value;
12
+ }
13
+ return unistyles.registry.breakpoints[value] ?? 0;
14
+ };
15
+ export const mq = {
16
+ height: function () {
17
+ let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
18
+ let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
19
+ return new Proxy({}, {
20
+ get: (target, prop, receiver) => {
21
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
22
+ return () => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
23
+ }
24
+ if (prop === MQProp.width) {
25
+ return function () {
26
+ let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
27
+ let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
28
+ return new Proxy({}, {
29
+ get: (target, prop, receiver) => {
30
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
31
+ return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
32
+ }
33
+ return Reflect.get(target, prop, receiver);
34
+ }
35
+ });
36
+ };
37
+ }
38
+ return Reflect.get(target, prop, receiver);
39
+ }
40
+ });
41
+ },
42
+ width: function () {
43
+ let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
44
+ let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
45
+ return new Proxy({}, {
46
+ get: (target, prop, receiver) => {
47
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
48
+ return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
49
+ }
50
+ if (prop === MQProp.height) {
51
+ return function () {
52
+ let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
53
+ let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
54
+ return new Proxy({}, {
55
+ get: (target, prop, receiver) => {
56
+ if (prop === Symbol.toPrimitive || MQProp.toString) {
57
+ return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
58
+ }
59
+ return Reflect.get(target, prop, receiver);
60
+ }
61
+ });
62
+ };
63
+ }
64
+ return Reflect.get(target, prop, receiver);
65
+ }
66
+ });
67
+ }
68
+ };
69
+ //# sourceMappingURL=mq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["unistyles","MQSymbol","Symbol","MQProp","getMQValue","value","registry","breakpoints","mq","height","hMin","arguments","length","undefined","hMax","Infinity","Proxy","get","target","prop","receiver","toPrimitive","toString","width","wMin","wMax","Reflect"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":"AACA,SAASA,SAAS,QAAQ,cAAc;AAExC,MAAMC,QAAQ,GAAGC,MAAM,CAAC,cAAc,CAAC;AAAA,IAgBlCC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA,EAANA,MAAM;AAMX,MAAMC,UAAU,GAAIC,KAAc,IAAK;EACnC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,OAAOL,SAAS,CAACM,QAAQ,CAACC,WAAW,CAACF,KAAK,CAAC,IAAI,CAAC;AACrD,CAAC;AAED,OAAO,MAAMG,EAAE,GAAG;EACdC,MAAM,EAAE,SAAAA,CAAA;IAAA,IAACC,IAAa,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;IAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;IAAA,OAAK,IAAIC,KAAK,CAAgB,CAAC,CAAC,EAAmB;MACnGC,GAAG,EAAEA,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,KAAK;QAC7B,IAAID,IAAI,KAAKjB,MAAM,CAACmB,WAAW,IAAIF,IAAI,KAAKhB,MAAM,CAACmB,QAAQ,EAAE;UACzD,OAAO,MAAO,MAAKlB,UAAU,CAACM,IAAI,CAAE,KAAIN,UAAU,CAACU,IAAI,CAAE,GAAE;QAC/D;QAEA,IAAIK,IAAI,KAAKhB,MAAM,CAACoB,KAAK,EAAE;UACvB,OAAO;YAAA,IAACC,IAAa,GAAAb,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;YAAA,IAAEc,IAAa,GAAAd,S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AKhB,MAAM,CAACM,MAAM,EAAE;UACxB,OAAO;YAAA,IAACC,IAAa,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;YAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;YAAA,OAAK,IAAIC,KAAK,CAAe,CAAC,CAAC,EAAkB;cAChGC,GAAG,EAAEA,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,KAAK;gBAC7B,IAAID,IAAI,KAAKjB,MAAM,CAACmB,WAAW,IAAIlB,MAAM,CAACmB,QAAQ,EAAE;kBAChD,OAAO,MAAO,MAAKlB,UAAU,CAACoB,IAAI,CAAE,KAAIpB,UAAU,CAACqB,IAAI,CAAE,OAAMrB,UAAU,CAACM,IAAI,CAAE,KAAIN,UAAU,CAACU,IAAI,CAAE,GAAE;gBAC3G;gBAEA,OAAOY,OAAO,CAACT,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;cAC9C;YACJ,CAAC,CAAC;UAAA;QACN;QAEA,OAAOM,OAAO,CAACT,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;MAC9C;IACJ,CAAC,CAAC;EAAA;AACN,CAAC"}
@@ -1,58 +1,17 @@
1
1
  import { getValueForBreakpoint } from './breakpoints';
2
2
  import { normalizeStyles } from './normalizeStyles';
3
- import { isWeb } from './common';
4
- /**
5
- * Proxies a function to parse its return value for custom media queries or breakpoints.
6
- *
7
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
8
- *
9
- * @param {Function} fn - The function to be proxified.
10
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
11
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
12
- * @param breakpointPairs - sorted pairs of breakpoints
13
- *
14
- * @returns {Function} Returns the proxified function
15
- *
16
- * @example
17
- *
18
- * const myFunction = () => ({ ':w[200]': 'value1', sm: 'value2' })
19
- * const screenSize = { width: 250, height: 400 }
20
- * const breakpoints = { sm: 300, md: 600 }
21
- *
22
- * const proxifiedFunction = proxifyFunction(myFunction, 'sm', screenSize, breakpoints)
23
- * proxifiedFunction() // parsed style based on screenSize and breakpoints
24
- */
3
+ import { isAndroid, isIOS, isWeb } from './common';
25
4
  export const proxifyFunction = (fn, breakpoint, screenSize) => new Proxy(fn, {
26
5
  apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize)
27
6
  });
28
-
29
- /**
30
- * Parses a style object to resolve custom media queries or breakpoints based on the provided screen size and breakpoints.
31
- *
32
- * The function processes each key-value pair in the style object. If the value is a function or a valid style (not an object or a 'transform' key),
33
- * it is returned as-is. Otherwise, the function attempts to resolve the value based on the provided breakpoint, screen size, and defined breakpoints.
34
- *
35
- * @template T - The type of the style object.
36
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
37
- *
38
- * @param {CustomNamedStyles<T, B>} style - The style object to be parsed.
39
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
40
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
41
- * @param breakpointPairs - sorted pairs of breakpoints
42
- *
43
- * @returns {Record<string, string | number | Function>} Returns the parsed style object with resolved custom media queries or breakpoints.
44
- *
45
- * @example
46
- *
47
- * const style = { fontSize: { sm: '12px', md: '16px' } }
48
- * const screenSize = { width: 300, height: 400 }
49
- * const breakpoints = { xs: 0, sm: 300, md: 600 }
50
- *
51
- * const parsedStyle = parseStyle(style, 'sm', screenSize, breakpoints)
52
- * // { fontSize: '12px' }
53
- */
7
+ export const isPlatformColor = value => {
8
+ if (isIOS) {
9
+ return 'semantic' in value && typeof value.semantic === 'object';
10
+ }
11
+ return isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
12
+ };
54
13
  export const parseStyle = (style, breakpoint, screenSize) => {
55
- const entries = Object.entries(style);
14
+ const entries = Object.entries(style || {});
56
15
  const parsedStyles = Object.fromEntries(entries.map(_ref => {
57
16
  let [key, value] = _ref;
58
17
  const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset';
@@ -64,11 +23,11 @@ export const parseStyle = (style, breakpoint, screenSize) => {
64
23
  return [key, value.map(value => parseStyle(value, breakpoint, screenSize))];
65
24
  }
66
25
  const isDynamicFunction = typeof value === 'function';
67
- const isValidStyle = typeof value !== 'object';
26
+ const isValidStyle = typeof value !== 'object' || isPlatformColor(value);
68
27
  if (isDynamicFunction || isValidStyle) {
69
28
  return [key, value];
70
29
  }
71
- return [key, getValueForBreakpoint(value, breakpoint, screenSize)];
30
+ return [key, getValueForBreakpoint(value)];
72
31
  }));
73
32
  return isWeb ? normalizeStyles(parsedStyles) : parsedStyles;
74
33
  };
@@ -1 +1 @@
1
- {"version":3,"names":["getValueForBreakpoint","normalizeStyles","isWeb","proxifyFunction","fn","breakpoint","screenSize","Proxy","apply","target","thisArg","argumentsList","parseStyle","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","value","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,KAAK,QAAQ,UAAU;AAGhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGA,CAC3BC,EAAY,EAAEC,UAA+C,EAC7DC,UAAsB,KACX,IAAIC,KAAK,CAACH,EAAE,EAAE;EACzBI,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEN,UAAU,EAAEC,UAAU;AAC/E,CAAC,CAAC;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YAAY;AACtB,CAAC"}
1
+ {"version":3,"names":["getValueForBreakpoint","normalizeStyles","isAndroid","isIOS","isWeb","proxifyFunction","fn","breakpoint","screenSize","Proxy","apply","target","thisArg","argumentsList","parseStyle","isPlatformColor","value","semantic","resource_paths","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,SAAS,EAAEC,KAAK,EAAEC,KAAK,QAAQ,UAAU;AAElD,OAAO,MAAMC,eAAe,GAAGA,CAC3BC,EAAY,EAAEC,UAA+C,EAC7DC,UAAsB,KACX,IAAIC,KAAK,CAACH,EAAE,EAAE;EACzBI,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEN,UAAU,EAAEC,UAAU;AAC/E,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,KAA2B,EAC3BZ,UAA+C,EAC/CC,UAAsB,KAClB;EACJ,MAAMY,OAAO,GAAGC,MAAM,CAACD,OAAO,CAACD,KAAK,IAAI,CAAC,CAAC,CAGzC;EAED,MAAMG,YAAY,GAAGD,MAAM,CACtBE,WAAW,CAACH,OAAO,CACfI,GAAG,CAACC,IAAA,IAAkB;IAAA,IAAjB,CAACC,GAA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