@mochi-inc-japan/react-native-stylex-sheet 1.0.0 → 1.0.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.
Files changed (49) hide show
  1. package/README.ja.md +61 -1
  2. package/README.md +129 -59
  3. package/lib/commonjs/index.js +6 -0
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/utils/base.js +5 -1
  6. package/lib/commonjs/utils/base.js.map +1 -1
  7. package/lib/commonjs/utils/hooks.js +7 -0
  8. package/lib/commonjs/utils/hooks.js.map +1 -1
  9. package/lib/commonjs/utils/types.js.map +1 -1
  10. package/lib/module/index.js +1 -1
  11. package/lib/module/index.js.map +1 -1
  12. package/lib/module/utils/base.js +3 -0
  13. package/lib/module/utils/base.js.map +1 -1
  14. package/lib/module/utils/hooks.js +8 -1
  15. package/lib/module/utils/hooks.js.map +1 -1
  16. package/lib/module/utils/types.js.map +1 -1
  17. package/lib/{types → typescript}/index.d.ts +1 -1
  18. package/lib/{types → typescript}/utils/base.d.ts +2 -1
  19. package/lib/{types → typescript}/utils/hooks.d.ts +2 -1
  20. package/lib/{types → typescript}/utils/types.d.ts +2 -0
  21. package/package.json +11 -5
  22. package/lib/commonjs/tests/index.test.js +0 -224
  23. package/lib/commonjs/tests/index.test.js.map +0 -1
  24. package/lib/commonjs/tests/media.test.js +0 -226
  25. package/lib/commonjs/tests/media.test.js.map +0 -1
  26. package/lib/commonjs/tests/mock.test.js +0 -54
  27. package/lib/commonjs/tests/mock.test.js.map +0 -1
  28. package/lib/commonjs/tests/test-utils.js +0 -60
  29. package/lib/commonjs/tests/test-utils.js.map +0 -1
  30. package/lib/module/tests/index.test.js +0 -220
  31. package/lib/module/tests/index.test.js.map +0 -1
  32. package/lib/module/tests/media.test.js +0 -222
  33. package/lib/module/tests/media.test.js.map +0 -1
  34. package/lib/module/tests/mock.test.js +0 -49
  35. package/lib/module/tests/mock.test.js.map +0 -1
  36. package/lib/module/tests/test-utils.js +0 -52
  37. package/lib/module/tests/test-utils.js.map +0 -1
  38. package/lib/types/tests/check-descriptor.test.d.ts +0 -0
  39. package/lib/types/tests/index.test.d.ts +0 -1
  40. package/lib/types/tests/media.test.d.ts +0 -1
  41. package/lib/types/tests/mock.test.d.ts +0 -1
  42. package/lib/types/tests/test-utils.d.ts +0 -7
  43. package/lib/types/tests/utils.d.ts +0 -6
  44. package/lib/types/utils/index.d.ts +0 -9
  45. package/lib/types/utils/utils.d.ts +0 -4
  46. /package/lib/{types → typescript}/utils/media.d.ts +0 -0
  47. /package/lib/{types → typescript}/utils/theme.d.ts +0 -0
  48. /package/lib/{types → typescript}/utils/tokens.d.ts +0 -0
  49. /package/lib/{types → typescript}/utils/variant.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["Children","createContext","createElement","useContext","useMemo","PixelRatio","useWindowDimensions","mix","props","detectMedia","RNStyleXContext","undefined","RNStyleXProvider","componentProps","_componentProps$windo","_componentProps$theme","width","correctedWidth","windowWidth","getPixelSizeForLayoutSize","theme","value","media","_len","arguments","length","args","Array","_key","sheets","map","v","isArray","arg","variants","config","Provider","only","children","useStylex","context","Error"],"sources":["hooks.ts"],"sourcesContent":["import {\n Children,\n createContext,\n createElement,\n useContext,\n useMemo,\n} from 'react';\nimport { PixelRatio, useWindowDimensions } from 'react-native';\nimport { mix, props } from './base';\nimport { RNStyle, VariantStyleSheet } from './types';\nimport { detectMedia } from './media';\n\ntype IApi = {\n props: typeof props;\n mix: typeof mix;\n};\n\ntype UserConfig = {\n windowWidth: number;\n theme: string;\n};\n\ntype ValueType = UserConfig & IApi;\n\nconst RNStyleXContext = createContext<ValueType | undefined>(undefined);\n\nexport const RNStyleXProvider = (\n componentProps: Partial<Pick<ValueType, 'windowWidth' | 'theme'>> & {\n media?: Record<string, string>;\n children: React.ReactNode;\n }\n) => {\n const { width } = useWindowDimensions();\n const correctedWidth =\n componentProps.windowWidth ?? PixelRatio.getPixelSizeForLayoutSize(width);\n const theme = componentProps.theme ?? 'default';\n\n const value = useMemo<ValueType>(() => {\n const media = componentProps.media && detectMedia(componentProps.media, correctedWidth);\n return {\n windowWidth: correctedWidth,\n theme,\n props(...args) {\n const sheets = args.map((v) =>\n Array.isArray(v)\n ? v\n : v && this.mix(v as VariantStyleSheet<string, RNStyle>)\n );\n return props(...sheets);\n },\n mix(arg, variants) {\n if (!arg) return [];\n const config = {\n theme,\n media: media ?? this.windowWidth,\n };\n if (Array.isArray(arg)) {\n return mix([arg[0], { ...config, ...arg[1] }], variants);\n }\n return mix([arg, config], variants);\n },\n };\n }, [correctedWidth, theme]);\n return createElement(\n RNStyleXContext.Provider,\n { value },\n Children.only(componentProps.children)\n );\n};\n\nexport const useStylex = () => {\n const context = useContext(RNStyleXContext);\n if (!context) {\n throw new Error('useStylex must be used within a RNStyleXProvider');\n }\n return context;\n};\n"],"mappings":"AAAA,SACEA,QAAQ,EACRC,aAAa,EACbC,aAAa,EACbC,UAAU,EACVC,OAAO,QACF,OAAO;AACd,SAASC,UAAU,EAAEC,mBAAmB,QAAQ,cAAc;AAC9D,SAASC,GAAG,EAAEC,KAAK,QAAQ,QAAQ;AAEnC,SAASC,WAAW,QAAQ,SAAS;AAcrC,MAAMC,eAAe,gBAAGT,aAAa,CAAwBU,SAAS,CAAC;AAEvE,OAAO,MAAMC,gBAAgB,GAC3BC,cAGC,IACE;EAAA,IAAAC,qBAAA,EAAAC,qBAAA;EACH,MAAM;IAAEC;EAAM,CAAC,GAAGV,mBAAmB,CAAC,CAAC;EACvC,MAAMW,cAAc,IAAAH,qBAAA,GAClBD,cAAc,CAACK,WAAW,cAAAJ,qBAAA,cAAAA,qBAAA,GAAIT,UAAU,CAACc,yBAAyB,CAACH,KAAK,CAAC;EAC3E,MAAMI,KAAK,IAAAL,qBAAA,GAAGF,cAAc,CAACO,KAAK,cAAAL,qBAAA,cAAAA,qBAAA,GAAI,SAAS;EAE/C,MAAMM,KAAK,GAAGjB,OAAO,CAAY,MAAM;IACrC,MAAMkB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;IAAEf;EAAM,CAAC,EACTrB,QAAQ,CAACqC,IAAI,CAACxB,cAAc,CAACyB,QAAQ,CACvC,CAAC;AACH,CAAC;AAED,OAAO,MAAMC,SAAS,GAAGA,CAAA,KAAM;EAC7B,MAAMC,OAAO,GAAGrC,UAAU,CAACO,eAAe,CAAC;EAC3C,IAAI,CAAC8B,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CAAC,kDAAkD,CAAC;EACrE;EACA,OAAOD,OAAO;AAChB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Children","createContext","createElement","useContext","useMemo","PixelRatio","useWindowDimensions","flatten","mix","props","detectMedia","RNStyleXContext","undefined","RNStyleXProvider","componentProps","_componentProps$windo","_componentProps$theme","width","correctedWidth","windowWidth","getPixelSizeForLayoutSize","theme","value","media","_len","arguments","length","args","Array","_key","sheets","map","v","isArray","_len2","_key2","arg","variants","config","Provider","only","children","useStylex","context","Error"],"sources":["hooks.ts"],"sourcesContent":["import {\n Children,\n createContext,\n createElement,\n useContext,\n useMemo,\n} from 'react';\nimport { PixelRatio, useWindowDimensions } from 'react-native';\nimport { flatten, mix, props } from './base';\nimport { RNStyle, VariantStyleSheet } from './types';\nimport { detectMedia } from './media';\n\ntype IApi = {\n props: typeof props;\n mix: typeof mix;\n flatten: typeof flatten;\n};\n\ntype UserConfig = {\n windowWidth: number;\n theme: string;\n};\n\ntype ValueType = UserConfig & IApi;\n\nconst RNStyleXContext = createContext<ValueType | undefined>(undefined);\n\nexport const RNStyleXProvider = (\n componentProps: Partial<Pick<ValueType, 'windowWidth' | 'theme'>> & {\n media?: Record<string, string>;\n children: React.ReactNode;\n }\n) => {\n const { width } = useWindowDimensions();\n const correctedWidth =\n componentProps.windowWidth ?? PixelRatio.getPixelSizeForLayoutSize(width);\n const theme = componentProps.theme ?? 'default';\n\n const value = useMemo<ValueType>(() => {\n const media = componentProps.media && detectMedia(componentProps.media, correctedWidth);\n return {\n windowWidth: correctedWidth,\n theme,\n props(...args) {\n const sheets = args.map((v) =>\n Array.isArray(v)\n ? v\n : v && this.mix(v as VariantStyleSheet<string, RNStyle>)\n );\n return props(...sheets);\n },\n flatten(...args) {\n const sheets = args.map((v) =>\n Array.isArray(v)\n ? v\n : v && this.mix(v as VariantStyleSheet<string, RNStyle>)\n );\n return flatten(...sheets);\n },\n mix(arg, variants) {\n if (!arg) return [];\n const config = {\n theme,\n media: media ?? this.windowWidth,\n };\n if (Array.isArray(arg)) {\n return mix([arg[0], { ...config, ...arg[1] }], variants);\n }\n return mix([arg, config], variants);\n },\n };\n }, [correctedWidth, theme]);\n return createElement(\n RNStyleXContext.Provider,\n { value },\n Children.only(componentProps.children)\n );\n};\n\nexport const useStylex = () => {\n const context = useContext(RNStyleXContext);\n if (!context) {\n throw new Error('useStylex must be used within a RNStyleXProvider');\n }\n return context;\n};\n"],"mappings":"AAAA,SACEA,QAAQ,EACRC,aAAa,EACbC,aAAa,EACbC,UAAU,EACVC,OAAO,QACF,OAAO;AACd,SAASC,UAAU,EAAEC,mBAAmB,QAAQ,cAAc;AAC9D,SAASC,OAAO,EAAEC,GAAG,EAAEC,KAAK,QAAQ,QAAQ;AAE5C,SAASC,WAAW,QAAQ,SAAS;AAerC,MAAMC,eAAe,gBAAGV,aAAa,CAAwBW,SAAS,CAAC;AAEvE,OAAO,MAAMC,gBAAgB,GAC3BC,cAGC,IACE;EAAA,IAAAC,qBAAA,EAAAC,qBAAA;EACH,MAAM;IAAEC;EAAM,CAAC,GAAGX,mBAAmB,CAAC,CAAC;EACvC,MAAMY,cAAc,IAAAH,qBAAA,GAClBD,cAAc,CAACK,WAAW,cAAAJ,qBAAA,cAAAA,qBAAA,GAAIV,UAAU,CAACe,yBAAyB,CAACH,KAAK,CAAC;EAC3E,MAAMI,KAAK,IAAAL,qBAAA,GAAGF,cAAc,CAACO,KAAK,cAAAL,qBAAA,cAAAA,qBAAA,GAAI,SAAS;EAE/C,MAAMM,KAAK,GAAGlB,OAAO,CAAY,MAAM;IACrC,MAAMm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A,KAAK,GAAI,IAAI,CAACJ;QACvB,CAAC;QACD,IAAIS,KAAK,CAACK,OAAO,CAACG,GAAG,CAAC,EAAE;UACtB,OAAO5B,GAAG,CAAC,CAAC4B,GAAG,CAAC,CAAC,CAAC,EAAE;YAAE,GAAGE,MAAM;YAAE,GAAGF,GAAG,CAAC,CAAC;UAAE,CAAC,CAAC,EAAEC,QAAQ,CAAC;QAC1D;QACA,OAAO7B,GAAG,CAAC,CAAC4B,GAAG,EAAEE,MAAM,CAAC,EAAED,QAAQ,CAAC;MACrC;IACF,CAAC;EACH,CAAC,EAAE,CAACnB,cAAc,EAAEG,KAAK,CAAC,CAAC;EAC3B,oBAAOnB,aAAa,CAClBS,eAAe,CAAC4B,QAAQ,EACxB;IAAEjB;EAAM,CAAC,EACTtB,QAAQ,CAACwC,IAAI,CAAC1B,cAAc,CAAC2B,QAAQ,CACvC,CAAC;AACH,CAAC;AAED,OAAO,MAAMC,SAAS,GAAGA,CAAA,KAAM;EAC7B,MAAMC,OAAO,GAAGxC,UAAU,CAACQ,eAAe,CAAC;EAC3C,IAAI,CAACgC,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CAAC,kDAAkD,CAAC;EACrE;EACA,OAAOD,OAAO;AAChB,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { StyleSheet } from 'react-native';\n\nexport type StyleObject = StyleSheet.NamedStyles<any>;\nexport type RNStyle = StyleObject[string];\n\nexport type VariantStyle<S> = { [key: string]: S };\nexport type VariantStyleSheet<Key extends string, S extends RNStyle> = {\n [key in Key]: S;\n};\n\nexport type XRNStyle<S extends RNStyle = RNStyle> = {\n [key in keyof S]: VariantStyle<S[key]> | S[key];\n};\n\ntype ExtractVariantKeys<\n X extends XRNStyle<S>,\n S extends RNStyle = RNStyle\n> = Extract<keyof Extract<X[keyof X], VariantStyle<any>>, string>;\n\nexport type NamedStyles<T = string, R extends RNStyle = RNStyle> = {\n [P in keyof T]: XRNStyle<R>;\n};\n\nexport type XRNStyleSheets<\n X extends NamedStyles<any, S>,\n S extends RNStyle = RNStyle\n> = {\n [key in keyof X]: VariantStyleSheet<ExtractVariantKeys<X[key]>, S>;\n};\n\ntype ExtractPostFix<T extends string> = T extends `@${string}_${infer PostFix}`\n ? PostFix\n : 'default';\n\n// NOTE: This map for keyof (X | Y) = (keyof X & keyof Y) != (keyof X | keyof Y).\n// different object value is composed to union type and keyof is applied later\n// without explicit individual object evaluation by this utility type.\ntype KeysOfUnion<T> = T extends T ? keyof T : never;\n\nexport type Variants<\n A extends Record<string, Record<string, Record<string, any>>>\n> = {\n [key in keyof A]?:\n | number\n | boolean\n | ExtractPostFix<Extract<KeysOfUnion<A[key][keyof A[key]]>, string>>;\n};\n\nexport type VariantValue<S extends RNStyle = RNStyle> = {\n [key in keyof S]: VariantStyle<S[key]>;\n}; // Style Fields\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { StyleSheet } from 'react-native';\n\nexport type StyleObject = StyleSheet.NamedStyles<any>;\nexport type RNStyle = StyleObject[string];\n\nexport type VariantStyle<S> = { [key: string]: S };\nexport type VariantStyleSheet<Key extends string, S extends RNStyle> = {\n [key in Key]: S;\n} & { default: S; };\n\nexport type XRNStyle<S extends RNStyle = RNStyle> = {\n [key in keyof S]: VariantStyle<S[key]> | S[key];\n};\n\ntype ExtractVariantKeys<\n X extends XRNStyle<S>,\n S extends RNStyle = RNStyle\n> = Extract<keyof Extract<X[keyof X], VariantStyle<any>>, string>;\n\nexport type NamedStyles<T = string, R extends RNStyle = RNStyle> = {\n [P in keyof T]: XRNStyle<R>;\n};\n\nexport type XRNStyleSheets<\n X extends NamedStyles<any, S>,\n S extends RNStyle = RNStyle\n> = {\n [key in keyof X]: VariantStyleSheet<ExtractVariantKeys<X[key]>, S>;\n};\n\ntype ExtractPostFix<T extends string> = T extends `@${string}_${infer PostFix}`\n ? PostFix\n : 'default';\n\n// NOTE: This map for keyof (X | Y) = (keyof X & keyof Y) != (keyof X | keyof Y).\n// different object value is composed to union type and keyof is applied later\n// without explicit individual object evaluation by this utility type.\ntype KeysOfUnion<T> = T extends T ? keyof T : never;\n\nexport type Variants<\n A extends Record<string, Record<string, Record<string, any>>>\n> = {\n [key in keyof A]?:\n | number\n | boolean\n | ExtractPostFix<Extract<KeysOfUnion<A[key][keyof A[key]]>, string>>;\n};\n\nexport type VariantValue<S extends RNStyle = RNStyle> = {\n [key in keyof S]: VariantStyle<S[key]>;\n}; // Style Fields\n"],"mappings":"","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- export { create, props, mix } from './utils/base';
1
+ export { create, props, mix, flatten } from './utils/base';
2
2
  export { createVariants } from './utils/variant';
3
3
  export { defineConsts, defineVars } from './utils/tokens';
4
4
  export { useStylex, RNStyleXProvider } from './utils/hooks';
@@ -1,11 +1,12 @@
1
1
  import { XRNStyleSheets, NamedStyles, RNStyle, VariantStyleSheet } from './types';
2
- export declare const create: <T extends NamedStyles<any, R>, R extends RNStyle>(args: T) => XRNStyleSheets<T, R>;
2
+ export declare const create: <const T extends NamedStyles<any, R>, R extends RNStyle>(args: T) => XRNStyleSheets<T, R>;
3
3
  export declare const mix: <Variants extends {
4
4
  [key: string]: string | number | boolean | undefined;
5
5
  }, Theme extends string = string, T extends VariantStyleSheet<string, RNStyle> = VariantStyleSheet<string, RNStyle>>(target?: T | [T, {
6
6
  theme?: Theme;
7
7
  media?: number | string;
8
8
  }], variantArgs?: Variants) => RNStyle[];
9
+ export declare const flatten: <T extends RNStyle>(...args: (PropValue | RNStyle[] | false | null | undefined)[]) => T;
9
10
  type PropValue = VariantStyleSheet<string, RNStyle> | RNStyle;
10
11
  export declare const props: <T extends RNStyle>(...args: (PropValue | RNStyle[] | false | null | undefined)[]) => {
11
12
  style: T[];
@@ -1,7 +1,8 @@
1
- import { mix, props } from './base';
1
+ import { flatten, mix, props } from './base';
2
2
  type IApi = {
3
3
  props: typeof props;
4
4
  mix: typeof mix;
5
+ flatten: typeof flatten;
5
6
  };
6
7
  type UserConfig = {
7
8
  windowWidth: number;
@@ -6,6 +6,8 @@ export type VariantStyle<S> = {
6
6
  };
7
7
  export type VariantStyleSheet<Key extends string, S extends RNStyle> = {
8
8
  [key in Key]: S;
9
+ } & {
10
+ default: S;
9
11
  };
10
12
  export type XRNStyle<S extends RNStyle = RNStyle> = {
11
13
  [key in keyof S]: VariantStyle<S[key]> | S[key];
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@mochi-inc-japan/react-native-stylex-sheet",
3
3
  "description": "The modern CSS-in-JS library for React Native",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "license": "MIT",
6
6
  "author": "Tkow",
7
7
  "repository": "https://github.com/MOCHI-inc-JAPAN/react-native-stylex-sheet",
8
8
  "main": "lib/commonjs/index.js",
9
9
  "module": "lib/module/index.js",
10
- "types": "lib/types/index.d.ts",
10
+ "types": "lib/typescript/index.d.ts",
11
11
  "exports": {
12
12
  "./package.json": "./package.json",
13
13
  ".": {
14
14
  "require": "./lib/commonjs/index.js",
15
15
  "import": "./lib/module/index.js",
16
- "types": "./lib/types/index.d.ts"
16
+ "types": "./lib/typescript/index.d.ts"
17
17
  }
18
18
  },
19
19
  "files": [
@@ -64,7 +64,13 @@
64
64
  "output": "lib",
65
65
  "targets": [
66
66
  "commonjs",
67
- "module"
67
+ "module",
68
+ [
69
+ "typescript",
70
+ {
71
+ "project": "tsconfig.build.json"
72
+ }
73
+ ]
68
74
  ]
69
75
  },
70
76
  "watch": {
@@ -122,7 +128,7 @@
122
128
  "tsx"
123
129
  ],
124
130
  "scripts": {
125
- "build": "bob build && tsc -p tsconfig.build.json",
131
+ "build": "bob build",
126
132
  "release": "np --any-branch",
127
133
  "watch": "npm-watch",
128
134
  "test": "jest",
@@ -1,224 +0,0 @@
1
- "use strict";
2
-
3
- var _reactNative = require("@testing-library/react-native");
4
- var _react = _interopRequireDefault(require("react"));
5
- var _reactNative2 = require("react-native");
6
- var stylex = _interopRequireWildcard(require("../"));
7
- var _testUtils = require("./test-utils");
8
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
9
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- // ---------------------------------------------------------------------------
12
- // Basic
13
- // ---------------------------------------------------------------------------
14
-
15
- describe('Basic', () => {
16
- it('create() + props() returns base styles', () => {
17
- const styles = stylex.create({
18
- view: {
19
- backgroundColor: 'red',
20
- height: 100,
21
- width: 100
22
- }
23
- });
24
- const {
25
- style
26
- } = stylex.props(styles.view);
27
- expect(style[0]).toMatchObject({
28
- backgroundColor: 'red',
29
- height: 100,
30
- width: 100
31
- });
32
- });
33
- it('stylex.props() renders base styles', () => {
34
- var _toJSON;
35
- const styles = stylex.create({
36
- view: {
37
- backgroundColor: 'red',
38
- height: 100,
39
- width: 100
40
- },
41
- view2: {
42
- height: 200,
43
- width: 200
44
- }
45
- });
46
- function Comp() {
47
- return /*#__PURE__*/_react.default.createElement(_reactNative2.View, stylex.props(styles.view, styles.view2));
48
- }
49
- const {
50
- toJSON
51
- } = (0, _reactNative.render)(/*#__PURE__*/_react.default.createElement(Comp, null));
52
- expect((_toJSON = toJSON()) === null || _toJSON === void 0 ? void 0 : _toJSON.props.style[1]).toMatchObject({
53
- height: 200,
54
- width: 200
55
- });
56
- });
57
- it('stylex.props() has backward compatibility on StyleSheet', () => {
58
- const sameArgs = {
59
- view: {
60
- backgroundColor: 'red',
61
- height: 100,
62
- width: 100
63
- },
64
- view2: {
65
- height: 200,
66
- width: 200
67
- }
68
- };
69
- const styles = stylex.create(sameArgs);
70
- const orgStyles = _reactNative2.StyleSheet.create(sameArgs);
71
- expect(stylex.props(styles.view, styles.view2).style).toMatchObject([orgStyles.view, orgStyles.view2]);
72
- });
73
- });
74
-
75
- // ---------------------------------------------------------------------------
76
- // Variants
77
- // ---------------------------------------------------------------------------
78
-
79
- describe('Variants', () => {
80
- it('variants are applied correctly', () => {
81
- const vars = stylex.defineVars({
82
- colors: {
83
- default: 'white',
84
- primary: 'red',
85
- secondary: 'blue'
86
- },
87
- sizes: {
88
- default: 10,
89
- small: 5,
90
- medium: 15
91
- }
92
- });
93
- const variants = stylex.createVariants({
94
- var1: {
95
- backgroundColor: vars.colors
96
- },
97
- var2: {
98
- width: vars.sizes
99
- }
100
- });
101
- const styles = stylex.create({
102
- view: {
103
- backgroundColor: variants.var1.backgroundColor,
104
- width: variants.var2.width
105
- }
106
- });
107
- expect(stylex.props(styles.view).style[0]).toMatchObject({
108
- backgroundColor: 'white',
109
- width: 10
110
- });
111
- expect(stylex.props(styles.view).style.length).toBe(1);
112
- expect(stylex.props(stylex.mix(styles.view, {
113
- var1: 'primary',
114
- var2: 'medium'
115
- })).style).toMatchObject([{
116
- backgroundColor: 'white',
117
- width: 10
118
- }, {
119
- backgroundColor: 'red'
120
- }, {
121
- width: 15
122
- }]);
123
- });
124
- it('multiple style have same variant value is applied correctly', () => {
125
- const variants = stylex.createVariants({
126
- shape: {
127
- borderRadius: {
128
- default: 4,
129
- round: 8,
130
- square: 0,
131
- test: 1
132
- },
133
- fontSize: {
134
- default: 14,
135
- round: 16,
136
- square: 18
137
- }
138
- }
139
- });
140
- const styles = stylex.create({
141
- view: {
142
- ...variants.shape
143
- }
144
- });
145
- expect((0, _testUtils.reduceStyles)(stylex.props(stylex.mix(styles.view, {
146
- shape: 'round'
147
- })).style)).toMatchObject({
148
- borderRadius: 8,
149
- fontSize: 16
150
- });
151
- expect((0, _testUtils.reduceStyles)(stylex.props(stylex.mix(styles.view, {
152
- shape: 'test'
153
- })).style)).toMatchObject({
154
- borderRadius: 1,
155
- fontSize: 14
156
- });
157
- });
158
- });
159
-
160
- // ---------------------------------------------------------------------------
161
- // Theme queries
162
- // ---------------------------------------------------------------------------
163
-
164
- describe('Theme', () => {
165
- it('theme usage implicitly', () => {
166
- const {
167
- themes
168
- } = stylex.createThemes(['light', 'dark']);
169
- const styles = stylex.create({
170
- view: {
171
- borderBlockColor: {
172
- default: 'black',
173
- [themes.light]: 'white',
174
- [themes.dark]: 'gray'
175
- }
176
- }
177
- });
178
- function Comp() {
179
- const sx = stylex.useStylex();
180
- return /*#__PURE__*/_react.default.createElement(_reactNative2.View, sx.props(styles.view));
181
- }
182
- const outputStyle = theme => {
183
- return (0, _testUtils.finalStyle)(/*#__PURE__*/_react.default.createElement(stylex.RNStyleXProvider, {
184
- theme: themes[theme]
185
- }, /*#__PURE__*/_react.default.createElement(Comp, null)));
186
- };
187
- expect(outputStyle('light')).toMatchObject({
188
- borderBlockColor: 'white'
189
- });
190
- expect(outputStyle('dark')).toMatchObject({
191
- borderBlockColor: 'gray'
192
- });
193
- });
194
- it('theme usage implicitly', () => {
195
- const {
196
- themes
197
- } = stylex.createThemes(['light', 'dark']);
198
- const styles = stylex.create({
199
- view: {
200
- borderBlockColor: {
201
- default: 'black',
202
- [themes.light]: 'white',
203
- [themes.dark]: 'gray'
204
- }
205
- }
206
- });
207
- function Comp() {
208
- const sx = stylex.useStylex();
209
- return /*#__PURE__*/_react.default.createElement(_reactNative2.View, sx.props(sx.mix(styles.view)));
210
- }
211
- const outputStyle = theme => {
212
- return (0, _testUtils.finalStyle)(/*#__PURE__*/_react.default.createElement(stylex.RNStyleXProvider, {
213
- theme: themes[theme]
214
- }, /*#__PURE__*/_react.default.createElement(Comp, null)));
215
- };
216
- expect(outputStyle('light')).toMatchObject({
217
- borderBlockColor: 'white'
218
- });
219
- expect(outputStyle('dark')).toMatchObject({
220
- borderBlockColor: 'gray'
221
- });
222
- });
223
- });
224
- //# sourceMappingURL=index.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","_react","_interopRequireDefault","_reactNative2","stylex","_interopRequireWildcard","_testUtils","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","describe","it","styles","create","view","backgroundColor","height","width","style","props","expect","toMatchObject","_toJSON","view2","Comp","createElement","View","toJSON","render","sameArgs","orgStyles","StyleSheet","vars","defineVars","colors","primary","secondary","sizes","small","medium","variants","createVariants","var1","var2","length","toBe","mix","shape","borderRadius","round","square","test","fontSize","reduceStyles","themes","createThemes","borderBlockColor","light","dark","sx","useStylex","outputStyle","theme","finalStyle","RNStyleXProvider"],"sources":["index.test.tsx"],"sourcesContent":["import { render } from '@testing-library/react-native';\nimport React from 'react';\nimport { StyleSheet, View } from 'react-native';\n\nimport * as stylex from '../';\nimport { Variants } from '../utils/types';\nimport { finalStyle, reduceStyles } from './test-utils';\n\n// ---------------------------------------------------------------------------\n// Basic\n// ---------------------------------------------------------------------------\n\ndescribe('Basic', () => {\n it('create() + props() returns base styles', () => {\n const styles = stylex.create({\n view: {\n backgroundColor: 'red',\n height: 100,\n width: 100,\n },\n });\n\n const { style } = stylex.props(styles.view);\n expect(style[0]).toMatchObject({\n backgroundColor: 'red',\n height: 100,\n width: 100,\n });\n });\n\n it('stylex.props() renders base styles', () => {\n const styles = stylex.create({\n view: { backgroundColor: 'red', height: 100, width: 100 },\n view2: { height: 200, width: 200 },\n });\n\n function Comp() {\n return <View {...stylex.props(styles.view, styles.view2)} />;\n }\n const { toJSON } = render(<Comp />);\n expect(toJSON()?.props.style[1]).toMatchObject({\n height: 200,\n width: 200,\n });\n });\n\n it('stylex.props() has backward compatibility on StyleSheet', () => {\n const sameArgs = {\n view: { backgroundColor: 'red', height: 100, width: 100 },\n view2: { height: 200, width: 200 },\n };\n const styles = stylex.create(sameArgs);\n\n const orgStyles = StyleSheet.create(sameArgs);\n\n expect(stylex.props(styles.view, styles.view2).style).toMatchObject([\n orgStyles.view,\n orgStyles.view2,\n ]);\n });\n});\n\n// ---------------------------------------------------------------------------\n// Variants\n// ---------------------------------------------------------------------------\n\ndescribe('Variants', () => {\n it('variants are applied correctly', () => {\n const vars = stylex.defineVars({\n colors: {\n default: 'white',\n primary: 'red',\n secondary: 'blue',\n },\n sizes: {\n default: 10,\n small: 5,\n medium: 15,\n },\n });\n\n const variants = stylex.createVariants({\n var1: {\n backgroundColor: vars.colors,\n },\n var2: {\n width: vars.sizes,\n },\n });\n\n const styles = stylex.create({\n view: {\n backgroundColor: variants.var1.backgroundColor,\n width: variants.var2.width,\n },\n });\n\n expect(stylex.props(styles.view).style[0]).toMatchObject({\n backgroundColor: 'white',\n width: 10,\n });\n\n expect(stylex.props(styles.view).style.length).toBe(1);\n\n expect(\n stylex.props(\n stylex.mix<Variants<typeof variants>>(styles.view, {\n var1: 'primary',\n var2: 'medium',\n })\n ).style\n ).toMatchObject([\n {\n backgroundColor: 'white',\n width: 10,\n },\n {\n backgroundColor: 'red',\n },\n {\n width: 15,\n },\n ]);\n });\n\n it('multiple style have same variant value is applied correctly', () => {\n const variants = stylex.createVariants({\n shape: {\n borderRadius: {\n default: 4,\n round: 8,\n square: 0,\n test: 1,\n },\n fontSize: {\n default: 14,\n round: 16,\n square: 18,\n },\n },\n });\n const styles = stylex.create({\n view: {\n ...variants.shape,\n },\n });\n\n expect(\n reduceStyles(\n stylex.props(\n stylex.mix<Variants<typeof variants>>(styles.view, {\n shape: 'round',\n })\n ).style\n )\n ).toMatchObject({ borderRadius: 8, fontSize: 16 });\n expect(\n reduceStyles(\n stylex.props(\n stylex.mix<Variants<typeof variants>>(styles.view, {\n shape: 'test',\n })\n ).style\n )\n ).toMatchObject({ borderRadius: 1, fontSize: 14 });\n });\n});\n\n// ---------------------------------------------------------------------------\n// Theme queries\n// ---------------------------------------------------------------------------\n\ndescribe('Theme', () => {\n it('theme usage implicitly', () => {\n const { themes } = stylex.createThemes(['light', 'dark']);\n const styles = stylex.create({\n view: {\n borderBlockColor: {\n default: 'black',\n [themes.light]: 'white',\n [themes.dark]: 'gray',\n },\n },\n });\n\n function Comp() {\n const sx = stylex.useStylex();\n return <View {...sx.props(styles.view)} />;\n }\n\n const outputStyle = (theme: keyof typeof themes) => {\n return finalStyle(\n <stylex.RNStyleXProvider theme={themes[theme]}>\n <Comp />\n </stylex.RNStyleXProvider>\n );\n };\n\n expect(outputStyle('light')).toMatchObject({\n borderBlockColor: 'white',\n });\n expect(outputStyle('dark')).toMatchObject({\n borderBlockColor: 'gray',\n });\n });\n\n it('theme usage implicitly', () => {\n const { themes } = stylex.createThemes(['light', 'dark']);\n const styles = stylex.create({\n view: {\n borderBlockColor: {\n default: 'black',\n [themes.light]: 'white',\n [themes.dark]: 'gray',\n },\n },\n });\n\n function Comp() {\n const sx = stylex.useStylex();\n return <View {...sx.props(sx.mix(styles.view))} />;\n }\n\n const outputStyle = (theme: keyof typeof themes) => {\n return finalStyle(\n <stylex.RNStyleXProvider theme={themes[theme]}>\n <Comp />\n </stylex.RNStyleXProvider>\n );\n };\n\n expect(outputStyle('light')).toMatchObject({\n borderBlockColor: 'white',\n });\n expect(outputStyle('dark')).toMatchObject({\n borderBlockColor: 'gray',\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAA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AC;IAEF,SAASlC,IAAIA,CAAA,EAAG;MACd,MAAMmC,EAAE,GAAG1E,MAAM,CAAC2E,SAAS,CAAC,CAAC;MAC7B,oBAAO9E,MAAA,CAAAa,OAAA,CAAA8B,aAAA,CAACzC,aAAA,CAAA0C,IAAI,EAAKiC,EAAE,CAACxC,KAAK,CAACwC,EAAE,CAACb,GAAG,CAAClC,MAAM,CAACE,IAAI,CAAC,CAAI,CAAC;IACpD;IAEA,MAAM+C,WAAW,GAAIC,KAA0B,IAAK;MAClD,OAAO,IAAAC,qBAAU,eACfjF,MAAA,CAAAa,OAAA,CAAA8B,aAAA,CAACxC,MAAM,CAAC+E,gBAAgB;QAACF,KAAK,EAAER,MAAM,CAACQ,KAAK;MAAE,gBAC5ChF,MAAA,CAAAa,OAAA,CAAA8B,aAAA,CAACD,IAAI,MAAE,CACgB,CAC3B,CAAC;IACH,CAAC;IAEDJ,MAAM,CAACyC,WAAW,CAAC,OAAO,CAAC,CAAC,CAACxC,aAAa,CAAC;MACzCmC,gBAAgB,EAAE;IACpB,CAAC,CAAC;IACFpC,MAAM,CAACyC,WAAW,CAAC,MAAM,CAAC,CAAC,CAACxC,aAAa,CAAC;MACxCmC,gBAAgB,EAAE;IACpB,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1,226 +0,0 @@
1
- "use strict";
2
-
3
- var _react = _interopRequireDefault(require("react"));
4
- var _reactNative = require("react-native");
5
- var stylex = _interopRequireWildcard(require("../"));
6
- var _testUtils = require("./test-utils");
7
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
8
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- // ---------------------------------------------------------------------------
11
- // Media queries
12
- // ---------------------------------------------------------------------------
13
-
14
- describe('Media', () => {
15
- it('single media queries default', () => {
16
- const media = stylex.defineConsts({
17
- md: '(width >= 750px)',
18
- lg: '(width >= 1080px)'
19
- });
20
- const styles = stylex.create({
21
- view: {
22
- backgroundColor: {
23
- default: 'yellow',
24
- [media.md]: 'blue',
25
- [media.lg]: 'green'
26
- }
27
- }
28
- });
29
- function Comp() {
30
- const sx = stylex.useStylex();
31
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, sx.props(sx.mix(styles.view)));
32
- }
33
- (0, _testUtils.mockDimensions)({
34
- width: 640
35
- });
36
- expect((0, _testUtils.finalStyle)(/*#__PURE__*/_react.default.createElement(stylex.RNStyleXProvider, null, /*#__PURE__*/_react.default.createElement(Comp, null)))).toMatchObject({
37
- backgroundColor: 'yellow'
38
- });
39
- });
40
- it('usage from hooks implicitly', () => {
41
- const media = stylex.defineConsts({
42
- md: '(width >= 750px)',
43
- lg: '(width >= 1080px)'
44
- });
45
- const styles = stylex.create({
46
- view: {
47
- backgroundColor: {
48
- default: 'yellow',
49
- [media.md]: 'blue',
50
- [media.lg]: 'green'
51
- }
52
- }
53
- });
54
- function Comp() {
55
- const sx = stylex.useStylex();
56
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, sx.props(styles.view));
57
- }
58
- (0, _testUtils.mockDimensions)({
59
- width: 750
60
- });
61
- expect((0, _testUtils.finalStyle)(/*#__PURE__*/_react.default.createElement(stylex.RNStyleXProvider, null, /*#__PURE__*/_react.default.createElement(Comp, null)))).toMatchObject({
62
- backgroundColor: 'blue'
63
- });
64
- });
65
- it('single media queries md', () => {
66
- const media = stylex.defineConsts({
67
- md: '(width >= 750px)',
68
- lg: '(width >= 1080px)'
69
- });
70
- const styles = stylex.create({
71
- view: {
72
- backgroundColor: {
73
- default: 'yellow',
74
- [media.md]: 'blue',
75
- [media.lg]: 'green'
76
- }
77
- }
78
- });
79
- function Comp() {
80
- const sx = stylex.useStylex();
81
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, sx.props(sx.mix(styles.view)));
82
- }
83
- (0, _testUtils.mockDimensions)({
84
- width: 750
85
- });
86
- expect((0, _testUtils.finalStyle)(/*#__PURE__*/_react.default.createElement(stylex.RNStyleXProvider, null, /*#__PURE__*/_react.default.createElement(Comp, null)))).toMatchObject({
87
- backgroundColor: 'blue'
88
- });
89
- });
90
- it('single media queries lg', () => {
91
- const media = stylex.defineConsts({
92
- md: '(width >= 750px)',
93
- lg: '(width >= 1080px)'
94
- });
95
- const styles = stylex.create({
96
- view: {
97
- backgroundColor: {
98
- default: 'yellow',
99
- [media.md]: 'blue',
100
- [media.lg]: 'green'
101
- }
102
- }
103
- });
104
- function Comp() {
105
- const sx = stylex.useStylex();
106
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, sx.props(sx.mix(styles.view)));
107
- }
108
- (0, _testUtils.mockDimensions)({
109
- width: 1080
110
- });
111
- expect((0, _testUtils.finalStyle)(/*#__PURE__*/_react.default.createElement(stylex.RNStyleXProvider, null, /*#__PURE__*/_react.default.createElement(Comp, null)))).toMatchObject({
112
- backgroundColor: 'green'
113
- });
114
- });
115
- it('multi-range media query matches width inside range', () => {
116
- const media = stylex.defineConsts({
117
- md: '(750px <= width < 1080px)',
118
- lg: '(width >= 1080px)'
119
- });
120
- const styles = stylex.create({
121
- view: {
122
- backgroundColor: {
123
- default: 'yellow',
124
- [media.md]: 'blue',
125
- [media.lg]: 'green'
126
- }
127
- }
128
- });
129
- function Comp() {
130
- const sx = stylex.useStylex();
131
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, sx.props(sx.mix(styles.view)));
132
- }
133
- (0, _testUtils.mockDimensions)({
134
- width: 900
135
- });
136
- expect((0, _testUtils.finalStyle)(/*#__PURE__*/_react.default.createElement(stylex.RNStyleXProvider, null, /*#__PURE__*/_react.default.createElement(Comp, null)))).toMatchObject({
137
- backgroundColor: 'blue'
138
- });
139
- });
140
- it('multi-range media query does not match width outside range', () => {
141
- const media = stylex.defineConsts({
142
- md: '(750px <= width < 1080px)',
143
- lg: '(width >= 1080px)'
144
- });
145
- const styles = stylex.create({
146
- view: {
147
- backgroundColor: {
148
- default: 'yellow',
149
- [media.md]: 'blue',
150
- [media.lg]: 'green'
151
- }
152
- }
153
- });
154
- function Comp() {
155
- const sx = stylex.useStylex();
156
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, sx.props(sx.mix(styles.view)));
157
- }
158
- (0, _testUtils.mockDimensions)({
159
- width: 1080
160
- });
161
- expect((0, _testUtils.finalStyle)(/*#__PURE__*/_react.default.createElement(stylex.RNStyleXProvider, null, /*#__PURE__*/_react.default.createElement(Comp, null)))).toMatchObject({
162
- backgroundColor: 'green'
163
- });
164
- });
165
- it('multiple properties each with independent breakpoints', () => {
166
- const media = stylex.defineConsts({
167
- md: '(width >= 750px)',
168
- lg: '(width >= 1080px)'
169
- });
170
- const styles = stylex.create({
171
- view: {
172
- backgroundColor: {
173
- default: 'yellow',
174
- [media.md]: 'blue',
175
- [media.lg]: 'green'
176
- },
177
- width: {
178
- default: 100,
179
- [media.md]: 200,
180
- [media.lg]: 300
181
- }
182
- }
183
- });
184
- function Comp() {
185
- const sx = stylex.useStylex();
186
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, sx.props(sx.mix(styles.view)));
187
- }
188
- (0, _testUtils.mockDimensions)({
189
- width: 750
190
- });
191
- expect((0, _testUtils.finalStyle)(/*#__PURE__*/_react.default.createElement(stylex.RNStyleXProvider, null, /*#__PURE__*/_react.default.createElement(Comp, null)))).toMatchObject({
192
- backgroundColor: 'blue',
193
- width: 200
194
- });
195
- });
196
- it('multiple style entries with media queries are merged in order', () => {
197
- const media = stylex.defineConsts({
198
- md: '(width >= 750px)'
199
- });
200
- const styles = stylex.create({
201
- base: {
202
- backgroundColor: {
203
- default: 'yellow'
204
- },
205
- height: 100
206
- },
207
- override: {
208
- backgroundColor: {
209
- [media.md]: 'purple'
210
- }
211
- }
212
- });
213
- function Comp() {
214
- const sx = stylex.useStylex();
215
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, sx.props(sx.mix(styles.base), sx.mix(styles.override)));
216
- }
217
- (0, _testUtils.mockDimensions)({
218
- width: 750
219
- });
220
- expect((0, _testUtils.finalStyle)(/*#__PURE__*/_react.default.createElement(stylex.RNStyleXProvider, null, /*#__PURE__*/_react.default.createElement(Comp, null)))).toMatchObject({
221
- backgroundColor: 'purple',
222
- height: 100
223
- });
224
- });
225
- });
226
- //# sourceMappingURL=media.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","stylex","_interopRequireWildcard","_testUtils","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","describe","it","media","defineConsts","md","lg","styles","create","view","backgroundColor","Comp","sx","useStylex","createElement","View","props","mix","mockDimensions","width","expect","finalStyle","RNStyleXProvider","toMatchObject","base","height","override"],"sources":["media.test.tsx"],"sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\n\nimport * as stylex from '../';\nimport { mockDimensions, finalStyle } from './test-utils';\n\n// ---------------------------------------------------------------------------\n// Media queries\n// ---------------------------------------------------------------------------\n\ndescribe('Media', () => {\n it('single media queries default', () => {\n const media = stylex.defineConsts({\n md: '(width >= 750px)',\n lg: '(width >= 1080px)',\n });\n\n const styles = stylex.create({\n view: {\n backgroundColor: {\n default: 'yellow',\n [media.md]: 'blue',\n [media.lg]: 'green',\n },\n },\n });\n\n function Comp() {\n const sx = stylex.useStylex();\n return <View {...sx.props(sx.mix(styles.view))} />;\n }\n\n mockDimensions({ width: 640 });\n expect(\n finalStyle(\n <stylex.RNStyleXProvider>\n <Comp />\n </stylex.RNStyleXProvider>\n )\n ).toMatchObject({\n backgroundColor: 'yellow',\n });\n });\n\n it('usage from hooks implicitly', () => {\n const media = stylex.defineConsts({\n md: '(width >= 750px)',\n lg: '(width >= 1080px)',\n });\n\n const styles = stylex.create({\n view: {\n backgroundColor: {\n default: 'yellow',\n [media.md]: 'blue',\n [media.lg]: 'green',\n },\n },\n });\n\n function Comp() {\n const sx = stylex.useStylex();\n return <View {...sx.props(styles.view)} />;\n }\n\n mockDimensions({ width: 750 });\n expect(\n finalStyle(\n <stylex.RNStyleXProvider>\n <Comp />\n </stylex.RNStyleXProvider>\n )\n ).toMatchObject({\n backgroundColor: 'blue',\n });\n });\n\n it('single media queries md', () => {\n const media = stylex.defineConsts({\n md: '(width >= 750px)',\n lg: '(width >= 1080px)',\n });\n\n const styles = stylex.create({\n view: {\n backgroundColor: {\n default: 'yellow',\n [media.md]: 'blue',\n [media.lg]: 'green',\n },\n },\n });\n\n function Comp() {\n const sx = stylex.useStylex();\n return <View {...sx.props(sx.mix(styles.view))} />;\n }\n\n mockDimensions({ width: 750 });\n expect(\n finalStyle(\n <stylex.RNStyleXProvider>\n <Comp />\n </stylex.RNStyleXProvider>\n )\n ).toMatchObject({\n backgroundColor: 'blue',\n });\n });\n\n it('single media queries lg', () => {\n const media = stylex.defineConsts({\n md: '(width >= 750px)',\n lg: '(width >= 1080px)',\n });\n\n const styles = stylex.create({\n view: {\n backgroundColor: {\n default: 'yellow',\n [media.md]: 'blue',\n [media.lg]: 'green',\n },\n },\n });\n\n function Comp() {\n const sx = stylex.useStylex();\n return <View {...sx.props(sx.mix(styles.view))} />;\n }\n\n mockDimensions({ width: 1080 });\n expect(\n finalStyle(\n <stylex.RNStyleXProvider>\n <Comp />\n </stylex.RNStyleXProvider>\n )\n ).toMatchObject({\n backgroundColor: 'green',\n });\n });\n\n it('multi-range media query matches width inside range', () => {\n const media = stylex.defineConsts({\n md: '(750px <= width < 1080px)',\n lg: '(width >= 1080px)',\n });\n\n const styles = stylex.create({\n view: {\n backgroundColor: {\n default: 'yellow',\n [media.md]: 'blue',\n [media.lg]: 'green',\n },\n },\n });\n\n function Comp() {\n const sx = stylex.useStylex();\n return <View {...sx.props(sx.mix(styles.view))} />;\n }\n\n mockDimensions({ width: 900 });\n expect(\n finalStyle(\n <stylex.RNStyleXProvider>\n <Comp />\n </stylex.RNStyleXProvider>\n )\n ).toMatchObject({\n backgroundColor: 'blue',\n });\n });\n\n it('multi-range media query does not match width outside range', () => {\n const media = stylex.defineConsts({\n md: '(750px <= width < 1080px)',\n lg: '(width >= 1080px)',\n });\n\n const styles = stylex.create({\n view: {\n backgroundColor: {\n default: 'yellow',\n [media.md]: 'blue',\n [media.lg]: 'green',\n },\n },\n });\n\n function Comp() {\n const sx = stylex.useStylex();\n return <View {...sx.props(sx.mix(styles.view))} />;\n }\n\n mockDimensions({ width: 1080 });\n expect(\n finalStyle(\n <stylex.RNStyleXProvider>\n <Comp />\n </stylex.RNStyleXProvider>\n )\n ).toMatchObject({\n backgroundColor: 'green',\n });\n });\n\n it('multiple properties each with independent breakpoints', () => {\n const media = stylex.defineConsts({\n md: '(width >= 750px)',\n lg: '(width >= 1080px)',\n });\n\n const styles = stylex.create({\n view: {\n backgroundColor: {\n default: 'yellow',\n [media.md]: 'blue',\n [media.lg]: 'green',\n },\n width: {\n default: 100,\n [media.md]: 200,\n [media.lg]: 300,\n },\n },\n });\n\n function Comp() {\n const sx = stylex.useStylex();\n return <View {...sx.props(sx.mix(styles.view))} />;\n }\n\n mockDimensions({ width: 750 });\n expect(\n finalStyle(\n <stylex.RNStyleXProvider>\n <Comp />\n </stylex.RNStyleXProvider>\n )\n ).toMatchObject({\n backgroundColor: 'blue',\n width: 200,\n });\n });\n\n it('multiple style entries with media queries are merged in order', () => {\n const media = stylex.defineConsts({\n md: '(width >= 750px)',\n });\n\n const styles = stylex.create({\n base: {\n backgroundColor: {\n default: 'yellow',\n },\n height: 100,\n },\n override: {\n backgroundColor: {\n [media.md]: 'purple',\n },\n },\n });\n\n function Comp() {\n const sx = stylex.useStylex();\n return (\n <View {...sx.props(sx.mix(styles.base), sx.mix(styles.override))} />\n );\n }\n\n mockDimensions({ width: 750 });\n expect(\n finalStyle(\n <stylex.RNStyleXProvider>\n <Comp />\n </stylex.RNStyleXProvider>\n )\n ).toMatchObject({\n backgroundColor: 'purple',\n height: 100,\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAA0D,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC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