react-native-unistyles 2.0.0-alpha.9 → 2.0.0-beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. package/android/CMakeLists.txt +28 -0
  2. package/android/build.gradle +40 -0
  3. package/android/src/main/cxx/cpp-adapter.cpp +108 -0
  4. package/android/src/main/java/com/unistyles/UnistylesModule.kt +159 -0
  5. package/android/src/main/java/com/unistyles/UnistylesPackage.kt +18 -0
  6. package/cxx/UnistylesRuntime.cpp +55 -2
  7. package/cxx/UnistylesRuntime.h +15 -9
  8. package/ios/UnistylesModule.mm +12 -2
  9. package/lib/commonjs/common.js +30 -16
  10. package/lib/commonjs/common.js.map +1 -1
  11. package/lib/commonjs/core/UnistyleRegistry.js +65 -3
  12. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
  13. package/lib/commonjs/core/UnistylesRuntime.js +15 -16
  14. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
  15. package/lib/commonjs/createStyleSheet.js +1 -6
  16. package/lib/commonjs/createStyleSheet.js.map +1 -1
  17. package/lib/commonjs/hooks/index.js +7 -0
  18. package/lib/commonjs/hooks/index.js.map +1 -1
  19. package/lib/commonjs/hooks/useUnistyles.js +11 -8
  20. package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
  21. package/lib/commonjs/hooks/useVariants.js +14 -0
  22. package/lib/commonjs/hooks/useVariants.js.map +1 -0
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/plugins/index.js +38 -0
  25. package/lib/commonjs/plugins/index.js.map +1 -0
  26. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +12 -0
  27. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -0
  28. package/lib/commonjs/plugins/normalizer/index.js +32 -0
  29. package/lib/commonjs/plugins/normalizer/index.js.map +1 -0
  30. package/lib/commonjs/plugins/normalizer/module.d.js.map +1 -0
  31. package/lib/commonjs/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +5 -5
  32. package/lib/commonjs/plugins/normalizer/normalizeStyle.js.map +1 -0
  33. package/lib/commonjs/{utils → plugins/normalizer}/normalizer.js +1 -1
  34. package/lib/commonjs/plugins/normalizer/normalizer.js.map +1 -0
  35. package/lib/commonjs/types/{mq.js → plugin.js} +1 -1
  36. package/lib/commonjs/types/{mq.js.map → plugin.js.map} +1 -1
  37. package/lib/commonjs/types/stylesheet.js +6 -0
  38. package/lib/commonjs/types/stylesheet.js.map +1 -0
  39. package/lib/commonjs/types/variants.js +2 -0
  40. package/lib/commonjs/{utils/module.d.js.map → types/variants.js.map} +1 -1
  41. package/lib/commonjs/useStyles.js +10 -20
  42. package/lib/commonjs/useStyles.js.map +1 -1
  43. package/lib/commonjs/utils/breakpoints.js +13 -59
  44. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  45. package/lib/commonjs/utils/index.js +13 -51
  46. package/lib/commonjs/utils/index.js.map +1 -1
  47. package/lib/commonjs/utils/mq.js +36 -68
  48. package/lib/commonjs/utils/mq.js.map +1 -1
  49. package/lib/commonjs/utils/mqParser.js +4 -1
  50. package/lib/commonjs/utils/mqParser.js.map +1 -1
  51. package/lib/commonjs/utils/styles.js +35 -20
  52. package/lib/commonjs/utils/styles.js.map +1 -1
  53. package/lib/commonjs/utils/withPlugins.js +15 -0
  54. package/lib/commonjs/utils/withPlugins.js.map +1 -0
  55. package/lib/module/common.js +28 -17
  56. package/lib/module/common.js.map +1 -1
  57. package/lib/module/core/UnistyleRegistry.js +65 -3
  58. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  59. package/lib/module/core/UnistylesRuntime.js +15 -16
  60. package/lib/module/core/UnistylesRuntime.js.map +1 -1
  61. package/lib/module/createStyleSheet.js +1 -6
  62. package/lib/module/createStyleSheet.js.map +1 -1
  63. package/lib/module/hooks/index.js +1 -0
  64. package/lib/module/hooks/index.js.map +1 -1
  65. package/lib/module/hooks/useUnistyles.js +12 -9
  66. package/lib/module/hooks/useUnistyles.js.map +1 -1
  67. package/lib/module/hooks/useVariants.js +7 -0
  68. package/lib/module/hooks/useVariants.js.map +1 -0
  69. package/lib/module/index.js.map +1 -1
  70. package/lib/module/plugins/index.js +3 -0
  71. package/lib/module/plugins/index.js.map +1 -0
  72. package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
  73. package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
  74. package/lib/module/plugins/normalizer/index.js +3 -0
  75. package/lib/module/plugins/normalizer/index.js.map +1 -0
  76. package/lib/module/plugins/normalizer/module.d.js.map +1 -0
  77. package/lib/module/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +3 -3
  78. package/lib/module/plugins/normalizer/normalizeStyle.js.map +1 -0
  79. package/lib/module/{utils → plugins/normalizer}/normalizer.js +1 -1
  80. package/lib/module/plugins/normalizer/normalizer.js.map +1 -0
  81. package/lib/module/types/plugin.js +2 -0
  82. package/lib/module/types/{mq.js.map → plugin.js.map} +1 -1
  83. package/lib/module/types/stylesheet.js +2 -0
  84. package/lib/module/types/stylesheet.js.map +1 -0
  85. package/lib/module/types/variants.js +2 -0
  86. package/lib/module/{utils/module.d.js.map → types/variants.js.map} +1 -1
  87. package/lib/module/useStyles.js +12 -22
  88. package/lib/module/useStyles.js.map +1 -1
  89. package/lib/module/utils/breakpoints.js +12 -56
  90. package/lib/module/utils/breakpoints.js.map +1 -1
  91. package/lib/module/utils/index.js +4 -6
  92. package/lib/module/utils/index.js.map +1 -1
  93. package/lib/module/utils/mq.js +35 -67
  94. package/lib/module/utils/mq.js.map +1 -1
  95. package/lib/module/utils/mqParser.js +3 -3
  96. package/lib/module/utils/mqParser.js.map +1 -1
  97. package/lib/module/utils/styles.js +35 -20
  98. package/lib/module/utils/styles.js.map +1 -1
  99. package/lib/module/utils/withPlugins.js +8 -0
  100. package/lib/module/utils/withPlugins.js.map +1 -0
  101. package/lib/typescript/src/common.d.ts +23 -12
  102. package/lib/typescript/src/common.d.ts.map +1 -1
  103. package/lib/typescript/src/core/UnistyleRegistry.d.ts +45 -4
  104. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
  105. package/lib/typescript/src/core/UnistylesRuntime.d.ts +8 -9
  106. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
  107. package/lib/typescript/src/core/index.d.ts +1 -0
  108. package/lib/typescript/src/core/index.d.ts.map +1 -1
  109. package/lib/typescript/src/createStyleSheet.d.ts +2 -2
  110. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
  111. package/lib/typescript/src/global.d.ts.map +1 -1
  112. package/lib/typescript/src/hooks/index.d.ts +1 -0
  113. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  114. package/lib/typescript/src/hooks/useUnistyles.d.ts +2 -1
  115. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
  116. package/lib/typescript/src/hooks/useVariants.d.ts +3 -0
  117. package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -0
  118. package/lib/typescript/src/index.d.ts +51 -5
  119. package/lib/typescript/src/index.d.ts.map +1 -1
  120. package/lib/typescript/src/plugins/index.d.ts +3 -0
  121. package/lib/typescript/src/plugins/index.d.ts.map +1 -0
  122. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
  123. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
  124. package/lib/typescript/src/plugins/normalizer/index.d.ts +3 -0
  125. package/lib/typescript/src/plugins/normalizer/index.d.ts.map +1 -0
  126. package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts +3 -0
  127. package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts.map +1 -0
  128. package/lib/typescript/src/{utils → plugins/normalizer}/normalizer.d.ts +1 -1
  129. package/lib/typescript/src/plugins/normalizer/normalizer.d.ts.map +1 -0
  130. package/lib/typescript/src/types/breakpoints.d.ts +25 -12
  131. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  132. package/lib/typescript/src/types/core.d.ts +6 -27
  133. package/lib/typescript/src/types/core.d.ts.map +1 -1
  134. package/lib/typescript/src/types/index.d.ts +4 -2
  135. package/lib/typescript/src/types/index.d.ts.map +1 -1
  136. package/lib/typescript/src/types/plugin.d.ts +7 -0
  137. package/lib/typescript/src/types/plugin.d.ts.map +1 -0
  138. package/lib/typescript/src/types/stylesheet.d.ts +40 -0
  139. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -0
  140. package/lib/typescript/src/types/unistyles.d.ts +16 -11
  141. package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
  142. package/lib/typescript/src/types/variants.d.ts +14 -0
  143. package/lib/typescript/src/types/variants.d.ts.map +1 -0
  144. package/lib/typescript/src/useStyles.d.ts +3 -3
  145. package/lib/typescript/src/useStyles.d.ts.map +1 -1
  146. package/lib/typescript/src/utils/breakpoints.d.ts +2 -5
  147. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  148. package/lib/typescript/src/utils/index.d.ts +4 -6
  149. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  150. package/lib/typescript/src/utils/mq.d.ts +15 -14
  151. package/lib/typescript/src/utils/mq.d.ts.map +1 -1
  152. package/lib/typescript/src/utils/mqParser.d.ts +14 -2
  153. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
  154. package/lib/typescript/src/utils/styles.d.ts +3 -4
  155. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  156. package/lib/typescript/src/utils/withPlugins.d.ts +3 -0
  157. package/lib/typescript/src/utils/withPlugins.d.ts.map +1 -0
  158. package/package.json +19 -16
  159. package/src/__tests__/mocks.ts +24 -0
  160. package/src/common.ts +30 -14
  161. package/src/core/UnistyleRegistry.ts +66 -4
  162. package/src/core/UnistylesRuntime.ts +18 -20
  163. package/src/core/index.ts +1 -0
  164. package/src/createStyleSheet.ts +2 -8
  165. package/src/global.ts +1 -0
  166. package/src/hooks/index.ts +1 -0
  167. package/src/hooks/useUnistyles.ts +11 -9
  168. package/src/hooks/useVariants.ts +10 -0
  169. package/src/index.ts +3 -1
  170. package/src/plugins/index.ts +2 -0
  171. package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
  172. package/src/plugins/normalizer/index.ts +2 -0
  173. package/src/{utils/normalizeStyles.web.ts → plugins/normalizer/normalizeStyle.ts} +3 -3
  174. package/src/{utils → plugins/normalizer}/normalizer.ts +3 -3
  175. package/src/types/breakpoints.ts +57 -25
  176. package/src/types/core.ts +9 -43
  177. package/src/types/index.ts +11 -2
  178. package/src/types/plugin.ts +7 -0
  179. package/src/types/stylesheet.ts +49 -0
  180. package/src/types/unistyles.ts +18 -13
  181. package/src/types/variants.ts +19 -0
  182. package/src/useStyles.ts +18 -25
  183. package/src/utils/breakpoints.ts +11 -67
  184. package/src/utils/index.ts +4 -6
  185. package/src/utils/mq.ts +31 -84
  186. package/src/utils/mqParser.ts +5 -5
  187. package/src/utils/styles.ts +44 -50
  188. package/src/utils/withPlugins.ts +13 -0
  189. package/lib/commonjs/utils/common.js +0 -25
  190. package/lib/commonjs/utils/common.js.map +0 -1
  191. package/lib/commonjs/utils/normalizeStyles.js +0 -10
  192. package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
  193. package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
  194. package/lib/commonjs/utils/normalizer.js.map +0 -1
  195. package/lib/module/types/mq.js +0 -2
  196. package/lib/module/utils/common.js +0 -17
  197. package/lib/module/utils/common.js.map +0 -1
  198. package/lib/module/utils/normalizeStyles.js +0 -3
  199. package/lib/module/utils/normalizeStyles.js.map +0 -1
  200. package/lib/module/utils/normalizeStyles.web.js.map +0 -1
  201. package/lib/module/utils/normalizer.js.map +0 -1
  202. package/lib/typescript/src/types/mq.d.ts +0 -3
  203. package/lib/typescript/src/types/mq.d.ts.map +0 -1
  204. package/lib/typescript/src/utils/common.d.ts +0 -12
  205. package/lib/typescript/src/utils/common.d.ts.map +0 -1
  206. package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
  207. package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
  208. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
  209. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
  210. package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
  211. package/src/types/mq.ts +0 -3
  212. package/src/utils/common.ts +0 -20
  213. package/src/utils/normalizeStyles.ts +0 -2
  214. /package/lib/commonjs/{utils → plugins/normalizer}/module.d.js +0 -0
  215. /package/lib/module/{utils → plugins/normalizer}/module.d.js +0 -0
  216. /package/src/{utils → plugins/normalizer}/module.d.ts +0 -0
@@ -1,18 +1,21 @@
1
- import { CxxUnistylesEventTypes, ScreenOrientation } from '../common'
1
+ import { UnistylesEventType, ScreenOrientation } from '../common'
2
2
  import type { UnistylesThemes, UnistylesBreakpoints } from '../global'
3
- import type { NestedKeys, ScreenSize } from './core'
4
- import type { Optional } from './common'
3
+ import type { ScreenSize } from './core'
4
+ import type { UnistylesPlugin } from './plugin'
5
5
 
6
- export type ColorSchemeName = Optional<'light' | 'dark'>
6
+ export type ColorSchemeName = 'light' | 'dark' | 'unspecified'
7
7
 
8
8
  export type UnistylesConfig = {
9
- adaptiveThemes?: boolean
9
+ adaptiveThemes?: boolean,
10
+ experimentalPlugins?: Array<UnistylesPlugin>,
11
+ initialTheme?: keyof UnistylesThemes
10
12
  }
11
13
 
12
14
  export type UnistylesBridge = {
13
15
  // getters
14
16
  screenWidth: number,
15
17
  screenHeight: number,
18
+ enabledPlugins: Array<string>,
16
19
  hasAdaptiveThemes: boolean,
17
20
  themeName: keyof UnistylesThemes,
18
21
  breakpoint: keyof UnistylesBreakpoints,
@@ -23,27 +26,29 @@ export type UnistylesBridge = {
23
26
  themes: Array<keyof UnistylesThemes>,
24
27
  useBreakpoints(breakpoints: UnistylesBreakpoints): void,
25
28
  useTheme(name: keyof UnistylesThemes): void,
26
- useAdaptiveThemes(enable: boolean): void
29
+ useAdaptiveThemes(enable: boolean): void,
30
+ addPlugin(pluginName: string, notify: boolean): void,
31
+ removePlugin(pluginName: string): void
27
32
  }
28
33
 
29
34
  export type UnistylesThemeEvent = {
30
- type: CxxUnistylesEventTypes.Theme,
35
+ type: UnistylesEventType.Theme,
31
36
  payload: {
32
37
  themeName: keyof UnistylesThemes
33
38
  }
34
39
  }
35
40
 
36
41
  export type UnistylesMobileLayoutEvent = {
37
- type: CxxUnistylesEventTypes.Layout,
42
+ type: UnistylesEventType.Layout,
38
43
  payload: {
39
44
  screen: ScreenSize,
40
45
  breakpoint: keyof UnistylesBreakpoints,
41
- orientation: ScreenOrientation
46
+ orientation: typeof ScreenOrientation[keyof typeof ScreenOrientation]
42
47
  }
43
48
  }
44
49
 
45
- export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent
46
-
47
- export interface UnistylesEngine {
48
- didMatchMediaQuery(keys: NestedKeys): Optional<string>,
50
+ export type UnistylesPluginEvent = {
51
+ type: UnistylesEventType.Plugin
49
52
  }
53
+
54
+ export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent
@@ -0,0 +1,19 @@
1
+ export type ExtractVariantNames<T> = T extends (...args: any) => infer R
2
+ ? ExtractVariantKeys<R>
3
+ : ExtractVariantKeys<T>
4
+
5
+ type ExtractVariantKeys<T> = T extends object
6
+ ? ExtractVariant<T[keyof T]>
7
+ : never
8
+
9
+ type ExtractSubVariantKeys<T> = T extends object
10
+ ? keyof Omit<T, 'default'> | undefined
11
+ : never
12
+
13
+ type ExtractVariant<T> = T extends (...args: any) => infer R
14
+ ? R extends { variants: infer V }
15
+ ? { [key in keyof V]?: ExtractSubVariantKeys<V[key]> }
16
+ : never
17
+ : T extends { variants: infer V }
18
+ ? { [key in keyof V]?: ExtractSubVariantKeys<V[key]> }
19
+ : never
package/src/useStyles.ts CHANGED
@@ -1,53 +1,46 @@
1
1
  import { useMemo } from 'react'
2
2
  import { StyleSheet } from 'react-native'
3
- import { parseStyle, proxifyFunction } from './utils'
4
- import type { CreateStylesFactory, CustomNamedStyles, ReactNativeStyleSheet, UnistylesTheme } from './types'
5
- import { useUnistyles } from './hooks'
3
+ import { parseStyle, proxifyFunction, withPlugins } from './utils'
4
+ import { useUnistyles, useVariants } from './hooks'
6
5
  import type { UnistylesBreakpoints } from './global'
6
+ import type { ExtractVariantNames, ReactNativeStyleSheet, StyleSheetWithSuperPowers, UnistylesTheme } from './types'
7
7
 
8
- type ParsedStylesheet<ST extends CustomNamedStyles<ST>> = {
8
+ type ParsedStylesheet<ST extends StyleSheetWithSuperPowers> = {
9
9
  theme: UnistylesTheme,
10
10
  breakpoint: keyof UnistylesBreakpoints,
11
11
  styles: ReactNativeStyleSheet<ST>
12
12
  }
13
13
 
14
- export const useStyles = <ST extends CustomNamedStyles<ST>>(stylesheet?: ST | CreateStylesFactory<ST, UnistylesTheme>): ParsedStylesheet<ST> => {
15
- const { theme, layout } = useUnistyles()
16
- const { screenSize, breakpoint } = layout
17
-
18
- if (!stylesheet) {
19
- return {
20
- theme,
21
- breakpoint,
22
- styles: {} as ReactNativeStyleSheet<ST>
23
- }
24
- }
25
-
14
+ export const useStyles = <ST extends StyleSheetWithSuperPowers>(
15
+ stylesheet?: ST,
16
+ variantsMap?: ExtractVariantNames<typeof stylesheet>
17
+ ): ParsedStylesheet<ST> => {
18
+ const { theme, layout, plugins } = useUnistyles()
19
+ const variants = useVariants(variantsMap)
26
20
  const parsedStyles = useMemo(() => typeof stylesheet === 'function'
27
21
  ? stylesheet(theme)
28
- : stylesheet, [theme, stylesheet])
22
+ : stylesheet, [theme, stylesheet, layout])
29
23
 
30
24
  const dynamicStyleSheet = useMemo(() => Object
31
- .entries(parsedStyles)
25
+ .entries(parsedStyles || {})
32
26
  .reduce((acc, [key, value]) => {
33
- const style = value as CustomNamedStyles<ST>
34
-
35
27
  if (typeof value === 'function') {
36
28
  return {
37
29
  ...acc,
38
- [key]: proxifyFunction(value, breakpoint, screenSize)
30
+ [key]: proxifyFunction(key, value)
39
31
  }
40
32
  }
41
33
 
42
34
  return StyleSheet.create({
43
35
  ...acc,
44
- [key]: parseStyle<ST>(style, breakpoint, screenSize)
36
+ [key]: withPlugins(key, parseStyle(value, variants))
45
37
  })
46
- }, {} as ST), [breakpoint, screenSize, parsedStyles]) as ReactNativeStyleSheet<ST>
38
+ }, {}), [parsedStyles, variants, plugins]
39
+ )
47
40
 
48
41
  return {
49
42
  theme,
50
- breakpoint,
51
- styles: dynamicStyleSheet
43
+ breakpoint: layout.breakpoint,
44
+ styles: dynamicStyleSheet as ReactNativeStyleSheet<ST>
52
45
  }
53
46
  }
@@ -1,55 +1,12 @@
1
1
  import { unistyles } from '../core'
2
- import { isMobile, Orientation, throwError } from './common'
3
- import type { MediaQuery, NestedKeys } from '../types'
2
+ import type { Optional, RNValue } from '../types'
4
3
  import type { UnistylesBreakpoints } from '../global'
5
- import { ScreenOrientation } from '../common'
4
+ import { ScreenOrientation, isMobile } from '../common'
6
5
  import { getKeyForUnistylesMediaQuery } from './mqParser'
7
6
 
8
- export const sortAndValidateBreakpoints = (breakpoints: UnistylesBreakpoints): UnistylesBreakpoints => {
9
- const sortedPairs = Object
10
- .entries(breakpoints)
11
- .sort((breakpoint1, breakpoint2) => {
12
- const [, value1] = breakpoint1
13
- const [, value2] = breakpoint2
14
-
15
- return (value1 as number) - (value2 as number)
16
- })
17
-
18
- const sortedBreakpoints = Object.freeze(Object.fromEntries(sortedPairs)) as UnistylesBreakpoints
19
- const breakpointValues = Object.values(sortedBreakpoints)
20
- const [firstBreakpoint] = breakpointValues
21
-
22
- if (firstBreakpoint !== 0) {
23
- throwError('first breakpoint must start with 0')
24
- }
25
-
26
- if (breakpointValues.length !== new Set(breakpointValues).size) {
27
- throwError('breakpoint values are duplicated')
28
- }
29
-
30
- return sortedBreakpoints
31
- }
32
-
33
- export const getBreakpointFromScreenWidth = (width: number, breakpointEntries: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>): keyof UnistylesBreakpoints & string => {
34
- const [key] = breakpointEntries
35
- .find(([, value], index, otherBreakpoints) => {
36
- const minVal = value as number
37
- const maxVal = otherBreakpoints[index + 1]?.[1]
38
-
39
- if (!maxVal) {
40
- return true
41
- }
42
-
43
- return width >= minVal && width < maxVal
44
- }) as [keyof UnistylesBreakpoints & string, number]
45
-
46
- return key
47
- }
48
-
49
- export const getValueForBreakpoint = (value: Record<keyof UnistylesBreakpoints | MediaQuery, string | number | undefined>): string | number | undefined => {
50
- // the highest priority is for custom media queries
7
+ export const getValueForBreakpoint = (value: Record<string, RNValue>): Optional<RNValue> => {
51
8
  const customMediaQueryKey = getKeyForUnistylesMediaQuery(
52
- Object.entries(value) as NestedKeys,
9
+ Object.entries(value),
53
10
  unistyles.runtime.screen
54
11
  ) as keyof typeof value
55
12
 
@@ -57,44 +14,31 @@ export const getValueForBreakpoint = (value: Record<keyof UnistylesBreakpoints |
57
14
  return value[customMediaQueryKey]
58
15
  }
59
16
 
60
- // at this point user didn't use custom media queries (:w, :h)
61
- // check if user defined any breakpoints
62
- const hasBreakpoints = unistyles.runtime.sortedBreakpoints.length > 0
17
+ const hasBreakpoints = unistyles.registry.sortedBreakpointPairs.length > 0
63
18
 
64
- // if not then we can fall back to horizontal and portrait (mobile only)
65
- if (!hasBreakpoints && isMobile && (Orientation.Landscape in value || Orientation.Portrait in value)) {
66
- return value[
67
- unistyles.runtime.orientation === ScreenOrientation.Portrait
68
- ? Orientation.Portrait
69
- : Orientation.Landscape
70
- ]
19
+ if (!hasBreakpoints && isMobile && (ScreenOrientation.Landscape in value || ScreenOrientation.Portrait in value)) {
20
+ return value[unistyles.runtime.orientation]
71
21
  }
72
22
 
73
- // let's get the current breakpoint
74
23
  const breakpoint = unistyles.runtime.breakpoint
75
24
 
76
25
  if (!breakpoint) {
77
26
  return undefined
78
27
  }
79
28
 
80
- // if user defined breakpoints, then we look for the valid one
81
29
  const directBreakpoint = value[breakpoint]
82
30
 
83
- // if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
84
31
  if (directBreakpoint || (breakpoint in value)) {
85
32
  return directBreakpoint
86
33
  }
87
34
 
88
- // there is no direct hit for breakpoint nor media-query, let's simulate CSS cascading
89
- const breakpointPairs = unistyles.runtime.sortedBreakpoints
90
- const currentBreakpoint = breakpointPairs
35
+ const breakpointPairs = unistyles.registry.sortedBreakpointPairs
36
+ const currentBreakpointIndex = breakpointPairs
91
37
  .findIndex(([key]) => key === breakpoint)
92
38
 
93
39
  const availableBreakpoints = breakpointPairs
94
- .filter(([key], index) => index < currentBreakpoint && key && key in value)
40
+ .filter(([key], index) => index < currentBreakpointIndex && key in value)
95
41
  .map(([key]) => key)
96
42
 
97
- return breakpointPairs.length > 0
98
- ? value[availableBreakpoints[availableBreakpoints.length - 1] as keyof UnistylesBreakpoints & string]
99
- : undefined
43
+ return value[availableBreakpoints[availableBreakpoints.length - 1] as keyof UnistylesBreakpoints & string]
100
44
  }
@@ -1,7 +1,5 @@
1
- export { normalizeStyles } from './normalizeStyles'
2
- export * from './normalizer'
3
- export { mq, MQSymbol } from './mq'
4
- export { getKeyForUnistylesMediaQuery } from './mqParser'
5
- export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints'
1
+ export { mq } from './mq'
2
+ export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq } from './mqParser'
3
+ export { getValueForBreakpoint } from './breakpoints'
6
4
  export { proxifyFunction, parseStyle } from './styles'
7
- export { isServer, Orientation } from './common'
5
+ export { withPlugins } from './withPlugins'
package/src/utils/mq.ts CHANGED
@@ -1,38 +1,24 @@
1
- import type { MediaQuery, Nullable } from '../types'
1
+ import type { Nullable } from '../types'
2
2
  import type { UnistylesBreakpoints } from '../global'
3
3
  import { unistyles } from '../core'
4
4
 
5
- export const MQSymbol = Symbol('unistyles-mq')
6
-
7
5
  type MQValue = keyof UnistylesBreakpoints | number
8
6
 
9
7
  type MQHandler = {
10
- w(wMin?: Nullable<MQValue>, wMax?: MQValue): WidthHandler,
11
- width(wMin?: Nullable<MQValue>, wMax?: MQValue): WidthHandler,
12
- h(hMin?: Nullable<MQValue>, hMax?: MQValue): HeightHandler,
13
- height(hMin?: Nullable<MQValue>, hMax?: MQValue): HeightHandler
14
- }
15
-
16
- type HeightHandler = {
17
- w(wMin?: Nullable<MQValue>, wMax?: MQValue): MediaQuery,
18
- width(wMin?: Nullable<MQValue>, wMax?: MQValue): MediaQuery
19
- } & MediaQuery
20
-
21
- type WidthHandler = {
22
- h(hMin?: Nullable<MQValue>, hMax?: MQValue): MediaQuery,
23
- height(hMin?: Nullable<MQValue>, hMax?: MQValue): MediaQuery
24
- } & MediaQuery
25
-
26
- type FinalHandler = {
27
- [MQSymbol]: true
28
- }
29
-
30
- enum MQProp {
31
- toString = 'toString',
32
- width = 'width',
33
- height = 'height',
34
- shortW = 'w',
35
- shortH = 'h'
8
+ only: {
9
+ width(wMin?: Nullable<MQValue>, wMax?: MQValue): symbol,
10
+ height(hMin?: Nullable<MQValue>, hMax?: MQValue): symbol,
11
+ },
12
+ width(wMin?: Nullable<MQValue>, wMax?: MQValue): {
13
+ and: {
14
+ height(hMin?: Nullable<MQValue>, hMax?: MQValue): symbol
15
+ }
16
+ },
17
+ height(hMin?: Nullable<MQValue>, hMax?: MQValue): {
18
+ and: {
19
+ width(wMin?: Nullable<MQValue>, wMax?: MQValue): symbol
20
+ }
21
+ }
36
22
  }
37
23
 
38
24
  const getMQValue = (value: Nullable<MQValue>) => {
@@ -47,60 +33,21 @@ const getMQValue = (value: Nullable<MQValue>) => {
47
33
  return unistyles.registry.breakpoints[value] ?? 0
48
34
  }
49
35
 
50
- const widthHandler = (hMin: Nullable<MQValue> = 0, hMax: MQValue = Infinity) => new Proxy<HeightHandler>({} as HeightHandler, {
51
- get: (target, prop, receiver) => {
52
- if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
53
- return () => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
54
- }
55
-
56
- if (prop === MQProp.width || prop === MQProp.shortW) {
57
- return (wMin: MQValue = 0, wMax: MQValue = Infinity) => new Proxy<FinalHandler>({} as FinalHandler, {
58
- get: (target, prop, receiver) => {
59
- if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
60
- return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
61
- }
62
-
63
- return Reflect.get(target, prop, receiver)
64
- }
65
- })
66
- }
67
-
68
- return Reflect.get(target, prop, receiver)
69
- }
70
- })
71
-
72
- const heightHandler = (wMin: Nullable<MQValue> = 0, wMax: MQValue = Infinity) => new Proxy({} as WidthHandler, {
73
- get: (target, prop, receiver) => {
74
- if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
75
- return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`
76
- }
77
-
78
- if (prop === MQProp.height || prop === MQProp.shortH) {
79
- return (hMin: MQValue = 0, hMax: MQValue = Infinity) => new Proxy<FinalHandler>({} as FinalHandler, {
80
- get: (target, prop, receiver) => {
81
- if (prop === Symbol.toPrimitive || MQProp.toString) {
82
- return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
83
- }
84
-
85
- return Reflect.get(target, prop, receiver)
86
- }
87
- })
88
- }
89
-
90
- return Reflect.get(target, prop, receiver)
91
- }
92
- })
93
-
94
- export const mq = new Proxy({} as MQHandler, {
95
- get: (target, prop, receiver) => {
96
- if (prop === MQProp.shortW || prop === MQProp.width) {
97
- return heightHandler
36
+ export const mq: MQHandler = {
37
+ only: {
38
+ width: (wMin: Nullable<MQValue> = 0, wMax: MQValue = Infinity) => (`:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]` as unknown as symbol),
39
+ height: (hMin: Nullable<MQValue> = 0, hMax: MQValue = Infinity) => (`:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]` as unknown as symbol)
40
+ },
41
+ width: (wMin: Nullable<MQValue> = 0, wMax: MQValue = Infinity) => ({
42
+ and: {
43
+ height: (hMin: Nullable<MQValue> = 0, hMax: MQValue = Infinity) =>
44
+ (`:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]` as unknown as symbol)
98
45
  }
99
-
100
- if (prop === MQProp.shortH || prop === MQProp.height) {
101
- return widthHandler
46
+ }),
47
+ height: (hMin: Nullable<MQValue> = 0, hMax: MQValue = Infinity) => ({
48
+ and: {
49
+ width: (wMin: Nullable<MQValue> = 0, wMax: MQValue = Infinity) =>
50
+ (`:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]` as unknown as symbol)
102
51
  }
103
-
104
- return Reflect.get(target, prop, receiver)
105
- }
106
- })
52
+ })
53
+ }
@@ -1,4 +1,4 @@
1
- import type { NestedKeys, Optional, ScreenSize } from '../types'
1
+ import type { Optional, RNValue, ScreenSize } from '../types'
2
2
 
3
3
  const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/
4
4
  const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/
@@ -14,7 +14,7 @@ type UnistylesParsedMq = {
14
14
  height?: ParsedMqDimension
15
15
  }
16
16
 
17
- const parseMq = (mq: string): UnistylesParsedMq => {
17
+ export const parseMq = (mq: string): UnistylesParsedMq => {
18
18
  const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || []
19
19
  const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || []
20
20
 
@@ -32,7 +32,7 @@ const parseMq = (mq: string): UnistylesParsedMq => {
32
32
 
33
33
  const isUnistylesMq = (mq: string) => IS_UNISTYLES_REGEX.test(mq)
34
34
 
35
- const isValidMq = (parsedMq: UnistylesParsedMq) => {
35
+ export const isValidMq = (parsedMq: UnistylesParsedMq) => {
36
36
  const { width, height } = parsedMq
37
37
 
38
38
  if (width && height) {
@@ -50,7 +50,7 @@ const isValidMq = (parsedMq: UnistylesParsedMq) => {
50
50
  return false
51
51
  }
52
52
 
53
- const isWithinTheWidthAndHeight = (parsedMq: UnistylesParsedMq, screenSize: ScreenSize): boolean => {
53
+ export const isWithinTheWidthAndHeight = (parsedMq: UnistylesParsedMq, screenSize: ScreenSize): boolean => {
54
54
  const { width, height } = parsedMq
55
55
 
56
56
  if (width && height) {
@@ -80,7 +80,7 @@ const isWithinTheHeight = (height: UnistylesParsedMq['height'], screenHeight: nu
80
80
  return screenHeight >= from && screenHeight <= to
81
81
  }
82
82
 
83
- export const getKeyForUnistylesMediaQuery = (mediaQueries: NestedKeys, screenSize: ScreenSize) => {
83
+ export const getKeyForUnistylesMediaQuery = (mediaQueries: Array<[string, RNValue]>, screenSize: ScreenSize): Optional<string> => {
84
84
  const mq = mediaQueries.find(([key]) => {
85
85
  if (!isUnistylesMq(key as string)) {
86
86
  return false
@@ -1,15 +1,14 @@
1
- import type { CustomNamedStyles, ScreenSize, MediaQuery } from '../types'
1
+ import type { Optional, RNStyle, RNValue } from '../types'
2
2
  import { getValueForBreakpoint } from './breakpoints'
3
- import { normalizeStyles } from './normalizeStyles'
4
- import type { UnistylesBreakpoints } from '../global'
5
- import { isAndroid, isIOS, isWeb } from './common'
3
+ import { isAndroid, isIOS } from '../common'
4
+ import { withPlugins } from './withPlugins'
6
5
 
7
6
  export const proxifyFunction = (
8
- fn: Function, breakpoint: keyof UnistylesBreakpoints & string,
9
- screenSize: ScreenSize
7
+ key: string,
8
+ fn: Function,
9
+ variant?: Record<string, Optional<string>>
10
10
  ): Function => new Proxy(fn, {
11
- apply: (target, thisArg, argumentsList) =>
12
- parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize)
11
+ apply: (target, thisArg, argumentsList) => withPlugins(key, parseStyle(target.apply(thisArg, argumentsList), variant))
13
12
  })
14
13
 
15
14
  export const isPlatformColor = <T extends {}>(value: T): boolean => {
@@ -20,52 +19,47 @@ export const isPlatformColor = <T extends {}>(value: T): boolean => {
20
19
  return isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object'
21
20
  }
22
21
 
23
- export const parseStyle = <T>(
24
- style: CustomNamedStyles<T>,
25
- breakpoint: keyof UnistylesBreakpoints & string,
26
- screenSize: ScreenSize
27
- ): T => {
28
- const entries = Object.entries(style || {}) as [[
29
- keyof T,
30
- CustomNamedStyles<T> | Record<keyof UnistylesBreakpoints & string, string | number | undefined>]
31
- ]
22
+ export const parseStyle = <T extends RNStyle>(
23
+ style: T,
24
+ variant: Record<string, Optional<string>> = {}
25
+ ): T => Object
26
+ .entries(style || {})
27
+ .reduce((acc, [key, value]) => {
28
+ // nested objects
29
+ if (key === 'shadowOffset' || key === 'textShadowOffset') {
30
+ acc[key] = parseStyle(value, variant)
32
31
 
33
- const parsedStyles = Object
34
- .fromEntries(entries
35
- .map(([key, value]) => {
36
- const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset'
32
+ return acc
33
+ }
37
34
 
38
- if (hasNestedProperties) {
39
- return [
40
- key,
41
- parseStyle(value as CustomNamedStyles<T>, breakpoint, screenSize)
42
- ]
43
- }
35
+ // transforms
36
+ if (key === 'transform' && Array.isArray(value)) {
37
+ acc[key] = value.map(value => parseStyle(value, variant))
44
38
 
45
- const isTransform = key === 'transform'
39
+ return acc
40
+ }
46
41
 
47
- if (isTransform && Array.isArray(value)) {
48
- return [
49
- key,
50
- value.map(value => parseStyle(value, breakpoint, screenSize))
51
- ]
52
- }
42
+ // values or platform colors
43
+ if (typeof value !== 'object' || isPlatformColor(value)) {
44
+ acc[key as keyof T] = value
53
45
 
54
- const isDynamicFunction = typeof value === 'function'
55
- const isValidStyle = typeof value !== 'object' || isPlatformColor(value)
46
+ return acc
47
+ }
56
48
 
57
- if (isDynamicFunction || isValidStyle) {
58
- return [key, value]
59
- }
49
+ if (key === 'variants') {
50
+ return {
51
+ ...acc,
52
+ ...(Object
53
+ .keys(value) as Array<keyof typeof value>)
54
+ .reduce((acc, key) => ({
55
+ ...acc,
56
+ ...parseStyle((value)[key][variant[key as keyof typeof variant] || 'default'] ?? {})
57
+ }), {})
58
+ }
59
+ }
60
60
 
61
- return [
62
- key,
63
- getValueForBreakpoint(value as Record<keyof UnistylesBreakpoints | MediaQuery, string | number | undefined>)
64
- ]
65
- })
66
- )
67
-
68
- return isWeb
69
- ? normalizeStyles(parsedStyles)
70
- : parsedStyles
71
- }
61
+ return {
62
+ ...acc,
63
+ [key]: getValueForBreakpoint(value as Record<string, RNValue>)
64
+ }
65
+ }, {} as T)
@@ -0,0 +1,13 @@
1
+ import type { RNStyle } from '../types'
2
+ import { unistyles } from '../core'
3
+
4
+ export const withPlugins = (
5
+ key: string,
6
+ style: RNStyle
7
+ ) => unistyles.registry.plugins.reduce((acc, plugin) => {
8
+ if (plugin.onParsedStyle) {
9
+ return plugin.onParsedStyle(key, style, unistyles.runtime)
10
+ }
11
+
12
+ return acc
13
+ }, style)
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.warn = exports.throwError = exports.isWeb = exports.isServer = exports.isMobile = exports.isIOS = exports.isAndroid = exports.Orientation = void 0;
7
- var _reactNative = require("react-native");
8
- const throwError = message => {
9
- throw new Error(`🦄 [react-native-unistyles]: ${message}`);
10
- };
11
- exports.throwError = throwError;
12
- const warn = message => {
13
- console.warn(`🦄 [react-native-unistyles]: ${message}`);
14
- };
15
- exports.warn = warn;
16
- const isMobile = exports.isMobile = _reactNative.Platform.OS === 'android' || _reactNative.Platform.OS === 'ios';
17
- const isWeb = exports.isWeb = _reactNative.Platform.OS === 'web';
18
- const isIOS = exports.isIOS = _reactNative.Platform.OS === 'ios';
19
- const isAndroid = exports.isAndroid = _reactNative.Platform.OS === 'android';
20
- const isServer = exports.isServer = typeof window === 'undefined';
21
- const Orientation = exports.Orientation = {
22
- Landscape: 'landscape',
23
- Portrait: 'portrait'
24
- };
25
- //# sourceMappingURL=common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","throwError","message","Error","exports","warn","console","isMobile","Platform","OS","isWeb","isIOS","isAndroid","isServer","window","Orientation","Landscape","Portrait"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAAAE,OAAA,CAAAH,UAAA,GAAAA,UAAA;AAEM,MAAMI,IAAI,GAAIH,OAAe,IAAK;EACrCI,OAAO,CAACD,IAAI,CAAE,gCAA+BH,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAC,IAAA,GAAAA,IAAA;AAEM,MAAME,QAAQ,GAAAH,OAAA,CAAAG,QAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAID,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnE,MAAMC,KAAK,GAAAN,OAAA,CAAAM,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,KAAK,GAAAP,OAAA,CAAAO,KAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMG,SAAS,GAAAR,OAAA,CAAAQ,SAAA,GAAGJ,qBAAQ,CAACC,EAAE,KAAK,SAAS;AAC3C,MAAMI,QAAQ,GAAAT,OAAA,CAAAS,QAAA,GAAG,OAAOC,MAAM,KAAK,WAAW;AAE9C,MAAMC,WAAW,GAAAX,OAAA,CAAAW,WAAA,GAAG;EACvBC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.normalizeStyles = void 0;
7
- // nothing to do here
8
- const normalizeStyles = styles => styles;
9
- exports.normalizeStyles = normalizeStyles;
10
- //# sourceMappingURL=normalizeStyles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["normalizeStyles","styles","exports"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.ts"],"mappings":";;;;;;AAAA;AACO,MAAMA,eAAe,GAAOC,MAAS,IAAKA,MAAW;AAAAC,OAAA,CAAAF,eAAA,GAAAA,eAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_common","require","_normalizer","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","warn","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","preprocessor","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyles","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow","exports"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.web.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA,MAAME,kBAAkB,GAAyBC,KAAQ,IAA0B;EAC/E,MAAMC,2BAA2B,GAAG,CAChC,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,CACjB;EAED,IAAI,CAACA,2BAA2B,CAACC,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,KAAK,CAAC,EAAE;IAC3D,IAAAI,YAAI,EAAE,wEAAuEH,2BAA2B,CAACI,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAEtH,OAAO;MACHC,WAAW,EAAEC,SAAS;MACtBC,YAAY,EAAED,SAAS;MACvBE,aAAa,EAAEF,SAAS;MACxBG,YAAY,EAAEH;IAClB,CAAC;EACL;EAEA,OAAO;IACHI,SAAS,EAAEC,wBAAY,CAACC,oBAAoB,CAACb,KAAK,CAAC;IACnDM,WAAW,EAAEC,SAAS;IACtBC,YAAY,EAAED,SAAS;IACvBE,aAAa,EAAEF,SAAS;IACxBG,YAAY,EAAEH;EAClB,CAA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sB,mBAAmB;IACtB,GAAGK,mBAAmB;IACtB,GAAGC;EACP,CAAC;AACL,CAAC;AAAAC,OAAA,CAAAR,eAAA,GAAAA,eAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_normalizeColors","_interopRequireDefault","require","obj","__esModule","default","normalizeColor","color","opacity","arguments","length","undefined","integer","normalizeColors","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","exports","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["utils/normalizer.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAF5D;AACA;;AAUO,MAAMG,cAAc,GAAG,SAAAA,CAACC,KAAa,EAA0B;EAAA,IAAxBC,OAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAC7D;EACA,IAAID,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,MAAMK,OAAO,GAAG,IAAAC,wBAAe,EAACN,KAAK,CAAkB;;EAEvD;EACA,IAAIK,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOL,KAAK;EAChB;EAEA,MAAMO,GAAG,GAAGF,OAAO,CAACG,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACJ,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACO,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,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