@stylexjs/stylex 0.2.0-beta.11 → 0.2.0-beta.13

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.
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import type { Theme } from './StyleXTypes';
11
+ type SheetOptions = Readonly<{
12
+ rootDarkTheme?: Theme;
13
+ rootTheme?: Theme;
14
+ supportsVariables?: boolean;
15
+ }>;
16
+ /**
17
+ * This class manages the CSS stylesheet for the page and the injection of new
18
+ * CSS rules.
19
+ */
20
+ export declare class StyleXSheet {
21
+ static LIGHT_MODE_CLASS_NAME: string;
22
+ static DARK_MODE_CLASS_NAME: string;
23
+ constructor(opts: SheetOptions);
24
+ rootTheme: null | undefined | Theme;
25
+ rootDarkTheme: null | undefined | Theme;
26
+ supportsVariables: boolean;
27
+ rules: Array<string>;
28
+ injected: boolean;
29
+ tag: null | undefined | HTMLStyleElement;
30
+ ruleForPriority: Map<number, string>;
31
+ getVariableMatch(): RegExp;
32
+ isHeadless(): boolean;
33
+ getTag(): HTMLStyleElement;
34
+ getCSS(): string;
35
+ getRulePosition(rule: string): number;
36
+ getRuleCount(): number;
37
+ inject(): void;
38
+ injectTheme(): void;
39
+ __injectCustomThemeForTesting(selector: string, theme: Theme): void;
40
+ delete(rule: string): void;
41
+ normalizeRule(rule: string): string;
42
+ getInsertPositionForPriority(priority: number): number;
43
+ insert(
44
+ rawLTRRule: string,
45
+ priority: number,
46
+ rawRTLRule: null | undefined | string
47
+ ): void;
48
+ }
49
+ export declare var styleSheet: StyleXSheet;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import type { Theme } from './StyleXTypes';
11
+
12
+ // Stylesheet options
13
+ type SheetOptions = $ReadOnly<{
14
+ rootDarkTheme?: Theme,
15
+ rootTheme?: Theme,
16
+ supportsVariables?: boolean,
17
+ }>;
18
+
19
+ /**
20
+ * This class manages the CSS stylesheet for the page and the injection of new
21
+ * CSS rules.
22
+ */
23
+ declare export class StyleXSheet {
24
+ static LIGHT_MODE_CLASS_NAME: string;
25
+ static DARK_MODE_CLASS_NAME: string;
26
+ constructor(opts: SheetOptions): void;
27
+ rootTheme: ?Theme;
28
+ rootDarkTheme: ?Theme;
29
+ supportsVariables: boolean;
30
+ rules: Array<string>;
31
+ injected: boolean;
32
+ tag: ?HTMLStyleElement;
33
+ ruleForPriority: Map<number, string>;
34
+ getVariableMatch(): RegExp;
35
+ isHeadless(): boolean;
36
+ getTag(): HTMLStyleElement;
37
+ getCSS(): string;
38
+ getRulePosition(rule: string): number;
39
+ getRuleCount(): number;
40
+ inject(): void;
41
+ injectTheme(): void;
42
+ __injectCustomThemeForTesting(selector: string, theme: Theme): void;
43
+ delete(rule: string): void;
44
+ normalizeRule(rule: string): string;
45
+ getInsertPositionForPriority(priority: number): number;
46
+ insert(rawLTRRule: string, priority: number, rawRTLRule: ?string): void;
47
+ }
48
+
49
+ declare export var styleSheet: StyleXSheet;
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import type { CSSProperties } from './StyleXCSSTypes';
11
+ export declare type StyleXClassNameFor<_K, _V> = string;
12
+ export type StyleXClassNameForValue<V> = StyleXClassNameFor<unknown, V>;
13
+ export type StyleXClassNameForKey<K> = StyleXClassNameFor<K, unknown>;
14
+ export type StyleXClassName = StyleXClassNameFor<unknown, unknown>;
15
+ export type StyleXArray<T> = T | ReadonlyArray<StyleXArray<T>>;
16
+ type CSSPropTypes = Readonly</**
17
+ * > 21 | type CSSPropTypes = $ReadOnly<$ObjMap<CSSProperties, () => StyleXClassName>>;
18
+ * | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "$ObjMap" is currently not supported.
19
+ **/
20
+ any>;
21
+ export type NestedCSSPropTypes = Readonly<
22
+ Omit<
23
+ CSSPropTypes,
24
+ keyof ({
25
+ ':active'?: StyleXClassName;
26
+ ':focus'?: StyleXClassName;
27
+ ':focus-visible'?: StyleXClassName;
28
+ ':hover'?: StyleXClassName;
29
+ ':disabled'?: StyleXClassName;
30
+ ':empty'?: StyleXClassName;
31
+ ':first-child'?: StyleXClassName;
32
+ ':last-child'?: StyleXClassName;
33
+ '::before'?: StyleXClassName;
34
+ '::after'?: StyleXClassName;
35
+ '::placeholder'?: StyleXClassName;
36
+ '::-webkit-scrollbar'?: StyleXClassName;
37
+ '@media (max-width: 564px)'?: StyleXClassName;
38
+ '@media (min-height: 700px)'?: StyleXClassName;
39
+ '@media (min-height: 700px) and (max-height: 789px)'?: StyleXClassName;
40
+ '@media (min-height: 753px) and (max-height: 789px)'?: StyleXClassName;
41
+ '@media (min-height: 790px)'?: StyleXClassName;
42
+ '@media (max-width: 648px)'?: StyleXClassName;
43
+ '@media (max-width: 899px)'?: StyleXClassName;
44
+ '@media (max-width: 900px)'?: StyleXClassName;
45
+ '@media (min-width: 900px)'?: StyleXClassName;
46
+ '@media (min-width: 900px) and (max-width: 1259px)'?: StyleXClassName;
47
+ '@media (max-width: 1099px)'?: StyleXClassName;
48
+ '@media (max-width: 1199px)'?: StyleXClassName;
49
+ '@media (max-width: 1259px)'?: StyleXClassName;
50
+ '@media (min-width: 1290px)'?: StyleXClassName;
51
+ '@media (max-width: 420px)'?: StyleXClassName;
52
+ '@media (max-width: 500px)'?: StyleXClassName;
53
+ '@media (pointer: coarse)'?: StyleXClassName;
54
+ '@media (-webkit-min-device-pixel-ratio: 0)'?: StyleXClassName;
55
+ '@media print'?: StyleXClassName;
56
+ '@media (max-width: 767px)'?: StyleXClassName;
57
+ '@media (min-width: 768px)'?: StyleXClassName;
58
+ '@media (min-width: 768px) and (max-width: 1024px)'?: StyleXClassName;
59
+ '@media (max-width: 1024px)'?: StyleXClassName;
60
+ '@media (min-width: 1025px)'?: StyleXClassName;
61
+ '@media (min-width: 1025px) and (max-width: 1920px)'?: StyleXClassName;
62
+ '@media (max-width: 1920px)'?: StyleXClassName;
63
+ '@media (min-width: 1921px)'?: StyleXClassName;
64
+ '@media (min-width: 1500px)'?: StyleXClassName;
65
+ '@media (min-width: 1800px)'?: StyleXClassName;
66
+ '@media (min-width: 2250px)'?: StyleXClassName;
67
+ '::-webkit-search-decoration'?: StyleXClassName;
68
+ '::-webkit-search-cancel-button'?: StyleXClassName;
69
+ '::-webkit-search-results-button'?: StyleXClassName;
70
+ '::-webkit-search-results-decoration'?: StyleXClassName;
71
+ '@media (min-width: 950px)'?: StyleXClassName;
72
+ '@media (min-width: 1440px)'?: StyleXClassName;
73
+ '@media (min-width: 1920px)'?: StyleXClassName;
74
+ '@media (min-width: 800px)'?: StyleXClassName;
75
+ '@media (max-width: 1024px) and (min-width: 501px)'?: StyleXClassName;
76
+ })
77
+ > & {
78
+ ':active'?: StyleXClassName;
79
+ ':focus'?: StyleXClassName;
80
+ ':focus-visible'?: StyleXClassName;
81
+ ':hover'?: StyleXClassName;
82
+ ':disabled'?: StyleXClassName;
83
+ ':empty'?: StyleXClassName;
84
+ ':first-child'?: StyleXClassName;
85
+ ':last-child'?: StyleXClassName;
86
+ '::before'?: StyleXClassName;
87
+ '::after'?: StyleXClassName;
88
+ '::placeholder'?: StyleXClassName;
89
+ '::-webkit-scrollbar'?: StyleXClassName;
90
+ '@media (max-width: 564px)'?: StyleXClassName;
91
+ '@media (min-height: 700px)'?: StyleXClassName;
92
+ '@media (min-height: 700px) and (max-height: 789px)'?: StyleXClassName;
93
+ '@media (min-height: 753px) and (max-height: 789px)'?: StyleXClassName;
94
+ '@media (min-height: 790px)'?: StyleXClassName;
95
+ '@media (max-width: 648px)'?: StyleXClassName;
96
+ '@media (max-width: 899px)'?: StyleXClassName;
97
+ '@media (max-width: 900px)'?: StyleXClassName;
98
+ '@media (min-width: 900px)'?: StyleXClassName;
99
+ '@media (min-width: 900px) and (max-width: 1259px)'?: StyleXClassName;
100
+ '@media (max-width: 1099px)'?: StyleXClassName;
101
+ '@media (max-width: 1199px)'?: StyleXClassName;
102
+ '@media (max-width: 1259px)'?: StyleXClassName;
103
+ '@media (min-width: 1290px)'?: StyleXClassName;
104
+ '@media (max-width: 420px)'?: StyleXClassName;
105
+ '@media (max-width: 500px)'?: StyleXClassName;
106
+ '@media (pointer: coarse)'?: StyleXClassName;
107
+ '@media (-webkit-min-device-pixel-ratio: 0)'?: StyleXClassName;
108
+ '@media print'?: StyleXClassName;
109
+ '@media (max-width: 767px)'?: StyleXClassName;
110
+ '@media (min-width: 768px)'?: StyleXClassName;
111
+ '@media (min-width: 768px) and (max-width: 1024px)'?: StyleXClassName;
112
+ '@media (max-width: 1024px)'?: StyleXClassName;
113
+ '@media (min-width: 1025px)'?: StyleXClassName;
114
+ '@media (min-width: 1025px) and (max-width: 1920px)'?: StyleXClassName;
115
+ '@media (max-width: 1920px)'?: StyleXClassName;
116
+ '@media (min-width: 1921px)'?: StyleXClassName;
117
+ '@media (min-width: 1500px)'?: StyleXClassName;
118
+ '@media (min-width: 1800px)'?: StyleXClassName;
119
+ '@media (min-width: 2250px)'?: StyleXClassName;
120
+ '::-webkit-search-decoration'?: StyleXClassName;
121
+ '::-webkit-search-cancel-button'?: StyleXClassName;
122
+ '::-webkit-search-results-button'?: StyleXClassName;
123
+ '::-webkit-search-results-decoration'?: StyleXClassName;
124
+ '@media (min-width: 950px)'?: StyleXClassName;
125
+ '@media (min-width: 1440px)'?: StyleXClassName;
126
+ '@media (min-width: 1920px)'?: StyleXClassName;
127
+ '@media (min-width: 800px)'?: StyleXClassName;
128
+ '@media (max-width: 1024px) and (min-width: 501px)'?: StyleXClassName;
129
+ }
130
+ >;
131
+ export type StyleXSingleStyle = false | (null | undefined | NestedCSSPropTypes);
132
+ export type XStyle<T = NestedCSSPropTypes> = StyleXArray<
133
+ false | (null | undefined | T)
134
+ >;
135
+ export type XStyleWithout<T extends { [$$Key$$: string]: void }> = XStyle<
136
+ Readonly<Pick<NestedCSSPropTypes, Exclude<keyof NestedCSSPropTypes, keyof T>>>
137
+ >;
138
+ export type Styles = Readonly<{ [namespace: string]: Style }>;
139
+ export type Style = Readonly</**
140
+ * > 95 | export type Style = $ReadOnly<{
141
+ * | ^
142
+ * > 96 | [pseudo: string]: CSSProperties,
143
+ * | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144
+ * > 97 | ...CSSProperties,
145
+ * | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
146
+ * > 98 | ...
147
+ * | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
148
+ * > 99 | }>;
149
+ * | ^^ Unsupported feature: Translating "object types with spreads, indexers and/or call properties at the same time" is currently not supported.
150
+ **/
151
+ any>;
152
+ export type Rules = Style | CSSProperties;
153
+ export type Keyframes = Readonly<{ [name: string]: CSSProperties }>;
154
+ export type Theme = Readonly<{ [constantName: string]: string }>;
155
+ type MapCSSValueToClassName = <K, V>(
156
+ $$PARAM_0$$: K,
157
+ $$PARAM_1$$: V
158
+ ) => StyleXClassNameFor<K, V>;
159
+ export type MapNamespace<CSS extends {}> =
160
+ /**
161
+ * > 110 | export type MapNamespace<CSS: { ... }> = $ObjMapi<CSS, MapCSSValueToClassName>;
162
+ * | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "$ObjMapi" is currently not supported.
163
+ **/
164
+ any;
165
+ export type MapNamespaces = <CSS extends {}>(
166
+ $$PARAM_0$$: CSS
167
+ ) => MapNamespace<CSS>;
168
+ export type Stylex$Create = <S extends {}>(
169
+ styles: S
170
+ ) => Readonly</**
171
+ * > 121 | ) => $ReadOnly<$ObjMap<S, MapNamespaces>>;
172
+ * | ^^^^^^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "$ObjMap" is currently not supported.
173
+ **/
174
+ any>;
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import type { CSSProperties } from './StyleXCSSTypes';
11
+
12
+ // Using an opaque type to declare ClassNames generated by stylex.
13
+ declare export opaque type StyleXClassNameFor<+_K, +_V>: string;
14
+ export type StyleXClassNameForValue<+V> = StyleXClassNameFor<mixed, V>;
15
+ export type StyleXClassNameForKey<+K> = StyleXClassNameFor<K, mixed>;
16
+ export type StyleXClassName = StyleXClassNameFor<mixed, mixed>;
17
+
18
+ // Type for arbitrarily nested Array.
19
+ export type StyleXArray<+T> = T | $ReadOnlyArray<StyleXArray<T>>;
20
+
21
+ type CSSPropTypes = $ReadOnly<$ObjMap<CSSProperties, () => StyleXClassName>>;
22
+ export type NestedCSSPropTypes = $ReadOnly<{
23
+ ...$Exact<CSSPropTypes>,
24
+ // NOTE: the actual type should be nested objects.
25
+ // fix after the types in stylex.js are fixed.
26
+ ':active'?: StyleXClassName,
27
+ ':focus'?: StyleXClassName,
28
+ ':focus-visible'?: StyleXClassName,
29
+ ':hover'?: StyleXClassName,
30
+ ':disabled'?: StyleXClassName,
31
+ ':empty'?: StyleXClassName,
32
+ ':first-child'?: StyleXClassName,
33
+ ':last-child'?: StyleXClassName,
34
+ '::before'?: StyleXClassName,
35
+ '::after'?: StyleXClassName,
36
+ '::placeholder'?: StyleXClassName,
37
+ '::-webkit-scrollbar'?: StyleXClassName,
38
+ // Find a better way to do this. Being forced to add every media query.
39
+ '@media (max-width: 564px)'?: StyleXClassName,
40
+ '@media (min-height: 700px)'?: StyleXClassName,
41
+ '@media (min-height: 700px) and (max-height: 789px)'?: StyleXClassName,
42
+ '@media (min-height: 753px) and (max-height: 789px)'?: StyleXClassName,
43
+ '@media (min-height: 790px)'?: StyleXClassName,
44
+ '@media (max-width: 648px)'?: StyleXClassName,
45
+ '@media (max-width: 899px)'?: StyleXClassName,
46
+ '@media (max-width: 900px)'?: StyleXClassName,
47
+ '@media (min-width: 900px)'?: StyleXClassName,
48
+ '@media (min-width: 900px) and (max-width: 1259px)'?: StyleXClassName,
49
+ '@media (max-width: 1099px)'?: StyleXClassName,
50
+ '@media (max-width: 1199px)'?: StyleXClassName,
51
+ '@media (max-width: 1259px)'?: StyleXClassName,
52
+ '@media (min-width: 1290px)'?: StyleXClassName,
53
+ '@media (max-width: 420px)'?: StyleXClassName,
54
+ '@media (max-width: 500px)'?: StyleXClassName,
55
+ '@media (pointer: coarse)'?: StyleXClassName,
56
+ '@media (-webkit-min-device-pixel-ratio: 0)'?: StyleXClassName,
57
+ '@media print'?: StyleXClassName,
58
+ // Media queries used for Oculus Web Design Systems (OCDS components).
59
+ '@media (max-width: 767px)'?: StyleXClassName,
60
+ '@media (min-width: 768px)'?: StyleXClassName,
61
+ '@media (min-width: 768px) and (max-width: 1024px)'?: StyleXClassName,
62
+ '@media (max-width: 1024px)'?: StyleXClassName,
63
+ '@media (min-width: 1025px)'?: StyleXClassName,
64
+ '@media (min-width: 1025px) and (max-width: 1920px)'?: StyleXClassName,
65
+ '@media (max-width: 1920px)'?: StyleXClassName,
66
+ '@media (min-width: 1921px)'?: StyleXClassName,
67
+ // Media queries used for Intern Data Products
68
+ '@media (min-width: 1500px)'?: StyleXClassName,
69
+ '@media (min-width: 1800px)'?: StyleXClassName,
70
+ '@media (min-width: 2250px)'?: StyleXClassName,
71
+ // webkit styles used for Search in Safari
72
+ '::-webkit-search-decoration'?: StyleXClassName,
73
+ '::-webkit-search-cancel-button'?: StyleXClassName,
74
+ '::-webkit-search-results-button'?: StyleXClassName,
75
+ '::-webkit-search-results-decoration'?: StyleXClassName,
76
+ // Media queries used for the logged out header
77
+ '@media (min-width: 950px)'?: StyleXClassName,
78
+ // Media queries used for bizweb
79
+ '@media (min-width: 1440px)'?: StyleXClassName,
80
+ '@media (min-width: 1920px)'?: StyleXClassName,
81
+ // Media queries used for fbai
82
+ '@media (min-width: 800px)'?: StyleXClassName,
83
+ // Media queries used for messengerkidsdotcom
84
+ '@media (max-width: 1024px) and (min-width: 501px)'?: StyleXClassName,
85
+ }>;
86
+
87
+ export type StyleXSingleStyle = false | ?NestedCSSPropTypes;
88
+ export type XStyle<+T = NestedCSSPropTypes> = StyleXArray<false | ?T>;
89
+ export type XStyleWithout<+T: { [string]: void, ... }> = XStyle<
90
+ $ReadOnly<$Rest<NestedCSSPropTypes, $Exact<T>>>
91
+ >;
92
+
93
+ export type Styles = $ReadOnly<{ [namespace: string]: Style, ... }>;
94
+
95
+ export type Style = $ReadOnly<{
96
+ [pseudo: string]: CSSProperties,
97
+ ...CSSProperties,
98
+ ...
99
+ }>;
100
+
101
+ export type Rules = Style | CSSProperties;
102
+
103
+ export type Keyframes = $ReadOnly<{ [name: string]: CSSProperties, ... }>;
104
+
105
+ export type Theme = $ReadOnly<{ [constantName: string]: string, ... }>;
106
+
107
+ // type CSSValue = string | number | $ReadOnlyArray<mixed>;
108
+ type MapCSSValueToClassName = <K, V>(K, V) => StyleXClassNameFor<K, V>;
109
+
110
+ export type MapNamespace<CSS: { ... }> = $ObjMapi<CSS, MapCSSValueToClassName>;
111
+ // NOTE: Flow was confused by nested ObjMap so for now, nested styles
112
+ // are typed incorrectly to be a string. This won't matter for the time being.
113
+ // type MapStyleToClassName = (<Rule: {}>(
114
+ // Rule,
115
+ // ) => $ObjMap<Rule, MapCSSValueToClassName>) &
116
+ // MapCSSValueToClassName;
117
+ export type MapNamespaces = <CSS: { ... }>(CSS) => MapNamespace<CSS>;
118
+
119
+ export type Stylex$Create = <S: { ... }>(
120
+ styles: S
121
+ ) => $ReadOnly<$ObjMap<S, MapNamespaces>>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ export declare function isCustomPropertyValue(value: unknown): boolean;
11
+ export declare class CSSCustomPropertyValue {
12
+ name: string;
13
+ constructor(value: string);
14
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ declare export function isCustomPropertyValue(value: mixed): boolean;
11
+
12
+ declare export class CSSCustomPropertyValue {
13
+ name: string;
14
+ constructor(value: string): void;
15
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ type CSSLengthUnitType = 'em' | 'px' | 'rem' | 'vh' | 'vmax' | 'vmin' | 'vw';
11
+ export declare class CSSLengthUnitValue {
12
+ static parse(inp: string): CSSLengthUnitValue | null;
13
+ value: number;
14
+ unit: CSSLengthUnitType;
15
+ constructor(value: number, unit: CSSLengthUnitType);
16
+ resolvePixelValue(
17
+ viewportWidth: number,
18
+ viewportHeight: number,
19
+ fontScale: number,
20
+ inheritedFontSize: null | undefined | number
21
+ ): number;
22
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ type CSSLengthUnitType = 'em' | 'px' | 'rem' | 'vh' | 'vmax' | 'vmin' | 'vw';
11
+
12
+ // TODO: this only works on simple values
13
+ declare export class CSSLengthUnitValue {
14
+ static parse(inp: string): CSSLengthUnitValue | null;
15
+ value: number;
16
+ unit: CSSLengthUnitType;
17
+ constructor(value: number, unit: CSSLengthUnitType): void;
18
+ resolvePixelValue(
19
+ viewportWidth: number,
20
+ viewportHeight: number,
21
+ fontScale: number,
22
+ inheritedFontSize: ?number
23
+ ): number;
24
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ export type MatchObject = {
11
+ width: number;
12
+ height: number;
13
+ direction: 'ltr' | 'rtl';
14
+ };
15
+ export declare class CSSMediaQuery {
16
+ static isMediaQueryString(inp: string): boolean;
17
+ static resolveMediaQueries(
18
+ styleObj: { readonly [$$Key$$: string]: unknown },
19
+ matchObj: MatchObject
20
+ ): { [$$Key$$: string]: unknown };
21
+ query: string;
22
+ matchedStyle: { [$$Key$$: string]: unknown };
23
+ constructor(query: string, matchedStyle: { [$$Key$$: string]: unknown });
24
+ resolve(matchObject: MatchObject): { [$$Key$$: string]: unknown };
25
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ export type MatchObject = {
11
+ width: number,
12
+ height: number,
13
+ direction: 'ltr' | 'rtl',
14
+ };
15
+
16
+ declare export class CSSMediaQuery {
17
+ static isMediaQueryString(inp: string): boolean;
18
+ static resolveMediaQueries(
19
+ styleObj: { +[string]: mixed },
20
+ matchObj: MatchObject
21
+ ): { [string]: mixed };
22
+ query: string;
23
+ matchedStyle: { [string]: mixed };
24
+ constructor(query: string, matchedStyle: { [string]: mixed }): void;
25
+ resolve(matchObject: MatchObject): { [string]: mixed };
26
+ }
@@ -365,6 +365,16 @@ exports[`styles vertical-align: top 1`] = `
365
365
  }
366
366
  `;
367
367
 
368
+ exports[`unsupported style properties "filter" 1`] = `{}`;
369
+
370
+ exports[`unsupported style properties "transitionProperty" passthrough 1`] = `
371
+ {
372
+ "style": {
373
+ "transitionProperty": "opacity",
374
+ },
375
+ }
376
+ `;
377
+
368
378
  exports[`unsupported style values calc 1`] = `{}`;
369
379
 
370
380
  exports[`unsupported style values inherit 1`] = `{}`;
@@ -409,6 +409,40 @@ describe('media queries', () => {
409
409
  });
410
410
  });
411
411
  });
412
+ describe('unsupported style properties', () => {
413
+ beforeEach(() => {
414
+ jest.spyOn(console, 'error');
415
+ console.error.mockImplementation(() => {});
416
+ });
417
+ afterEach(() => {
418
+ console.error.mockRestore();
419
+ });
420
+ test('"filter"', () => {
421
+ const {
422
+ underTest
423
+ } = _stylex.stylex.create({
424
+ underTest: {
425
+ filter: 'blur(1px)'
426
+ }
427
+ });
428
+ expect(_stylex.stylex.spread(underTest, mockOptions)).toMatchSnapshot();
429
+ expect(console.error).toHaveBeenCalled();
430
+ });
431
+ test('"transitionProperty" passthrough', () => {
432
+ const {
433
+ underTest
434
+ } = _stylex.stylex.create({
435
+ underTest: {
436
+ transitionProperty: 'opacity'
437
+ }
438
+ });
439
+ expect(_stylex.stylex.spread(underTest, {
440
+ ...mockOptions,
441
+ passthroughProperties: ['transitionProperty']
442
+ })).toMatchSnapshot();
443
+ expect(console.error).not.toHaveBeenCalled();
444
+ });
445
+ });
412
446
  describe('unsupported style values', () => {
413
447
  beforeEach(() => {
414
448
  jest.spyOn(console, 'error');
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ export declare function errorMsg(msg: string): void;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ declare export function errorMsg(msg: string): void;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ type InlineStyle = { [key: string]: unknown };
11
+ type StylesArray<T> = T | ReadonlyArray<StylesArray<T>>;
12
+ type Styles = StylesArray<InlineStyle | false | void | null>;
13
+ export declare function flattenStyle(...styles: Array<Styles>): {
14
+ [key: string]: any;
15
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow
8
+ */
9
+
10
+ type InlineStyle = {
11
+ [key: string]: mixed,
12
+ };
13
+
14
+ type StylesArray<+T> = T | $ReadOnlyArray<StylesArray<T>>;
15
+
16
+ type Styles = StylesArray<InlineStyle | false | void | null>;
17
+
18
+ declare export function flattenStyle(...styles: Array<Styles>): {
19
+ [key: string]: any,
20
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ type ParsedShadow = {
11
+ inset: boolean;
12
+ offsetX: number | string;
13
+ offsetY: number | string;
14
+ blurRadius: number | string;
15
+ spreadRadius: number | string;
16
+ color: string | null;
17
+ };
18
+ export declare function parseShadow(str: string): Array<ParsedShadow>;