@compiled/react 0.16.8 → 0.16.10

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.
@@ -28,4 +28,4 @@ import type { CSSProps, CssObject, CssFunction } from '../types';
28
28
  * ```
29
29
  */
30
30
  export default function css<TProps = unknown>(styles: TemplateStringsArray, ...interpolations: CssFunction<TProps>[]): CSSProps<TProps>;
31
- export default function css<T = unknown>(styles: CssObject<T> | CssObject<T>[]): CSSProps<T>;
31
+ export default function css<T = unknown>(styles: CssObject<T> | CssObject<T>[] | CSSProps<T> | CSSProps<T>[]): CSSProps<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAqClD,MAAM,CAAC,OAAO,UAAU,GAAG,CACzB,OAA6D,EAC7D,GAAG,eAA8B;IAEjC,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAuClD,MAAM,CAAC,OAAO,UAAU,GAAG,CACzB,OAA6D,EAC7D,GAAG,eAA8B;IAEjC,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC"}
@@ -41,6 +41,7 @@ type WithConditionalCSSProp<TProps> = 'className' extends keyof TProps ? string
41
41
  */
42
42
  css?: CssFunction<void> | CssFunction<void>[];
43
43
  } : {} : {};
44
+ type ReactJSXElementType = string | React.JSXElementConstructor<any>;
44
45
  type ReactJSXElement = JSX.Element;
45
46
  type ReactJSXElementClass = JSX.ElementClass;
46
47
  type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty;
@@ -50,6 +51,7 @@ type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes;
50
51
  type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>;
51
52
  type ReactJSXIntrinsicElements = JSX.IntrinsicElements;
52
53
  export declare namespace CompiledJSX {
54
+ type ElementType = ReactJSXElementType;
53
55
  type Element = ReactJSXElement;
54
56
  type ElementClass = ReactJSXElementClass;
55
57
  type ElementAttributesProperty = ReactJSXElementAttributesProperty;
@@ -28,4 +28,4 @@ import type { CSSProps, CssObject, CssFunction } from '../types';
28
28
  * ```
29
29
  */
30
30
  export default function css<TProps = unknown>(styles: TemplateStringsArray, ...interpolations: CssFunction<TProps>[]): CSSProps<TProps>;
31
- export default function css<T = unknown>(styles: CssObject<T> | CssObject<T>[]): CSSProps<T>;
31
+ export default function css<T = unknown>(styles: CssObject<T> | CssObject<T>[] | CSSProps<T> | CSSProps<T>[]): CSSProps<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;;AAGlC,0CAAkD;AAqClD,SAAwB,GAAG,CACzB,OAA6D,EAC7D,GAAG,eAA8B;IAEjC,MAAM,IAAA,wBAAgB,GAAE,CAAC;AAC3B,CAAC;AALD,sBAKC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;;AAGlC,0CAAkD;AAuClD,SAAwB,GAAG,CACzB,OAA6D,EAC7D,GAAG,eAA8B;IAEjC,MAAM,IAAA,wBAAgB,GAAE,CAAC;AAC3B,CAAC;AALD,sBAKC"}
@@ -41,6 +41,7 @@ type WithConditionalCSSProp<TProps> = 'className' extends keyof TProps ? string
41
41
  */
42
42
  css?: CssFunction<void> | CssFunction<void>[];
43
43
  } : {} : {};
44
+ type ReactJSXElementType = string | React.JSXElementConstructor<any>;
44
45
  type ReactJSXElement = JSX.Element;
45
46
  type ReactJSXElementClass = JSX.ElementClass;
46
47
  type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty;
@@ -50,6 +51,7 @@ type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes;
50
51
  type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>;
51
52
  type ReactJSXIntrinsicElements = JSX.IntrinsicElements;
52
53
  export declare namespace CompiledJSX {
54
+ type ElementType = ReactJSXElementType;
53
55
  type Element = ReactJSXElement;
54
56
  type ElementClass = ReactJSXElementClass;
55
57
  type ElementAttributesProperty = ReactJSXElementAttributesProperty;
@@ -28,4 +28,4 @@ import type { CSSProps, CssObject, CssFunction } from '../types';
28
28
  * ```
29
29
  */
30
30
  export default function css<TProps = unknown>(styles: TemplateStringsArray, ...interpolations: CssFunction<TProps>[]): CSSProps<TProps>;
31
- export default function css<T = unknown>(styles: CssObject<T> | CssObject<T>[]): CSSProps<T>;
31
+ export default function css<T = unknown>(styles: CssObject<T> | CssObject<T>[] | CSSProps<T> | CSSProps<T>[]): CSSProps<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAqClD,MAAM,CAAC,OAAO,UAAU,GAAG,CACzB,OAA6D,EAC7D,GAAG,eAA8B;IAEjC,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAuClD,MAAM,CAAC,OAAO,UAAU,GAAG,CACzB,OAA6D,EAC7D,GAAG,eAA8B;IAEjC,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC"}
@@ -41,6 +41,7 @@ type WithConditionalCSSProp<TProps> = 'className' extends keyof TProps ? string
41
41
  */
42
42
  css?: CssFunction<void> | CssFunction<void>[];
43
43
  } : {} : {};
44
+ type ReactJSXElementType = string | React.JSXElementConstructor<any>;
44
45
  type ReactJSXElement = JSX.Element;
45
46
  type ReactJSXElementClass = JSX.ElementClass;
46
47
  type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty;
@@ -50,6 +51,7 @@ type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes;
50
51
  type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>;
51
52
  type ReactJSXIntrinsicElements = JSX.IntrinsicElements;
52
53
  export declare namespace CompiledJSX {
54
+ type ElementType = ReactJSXElementType;
53
55
  type Element = ReactJSXElement;
54
56
  type ElementClass = ReactJSXElementClass;
55
57
  type ElementAttributesProperty = ReactJSXElementAttributesProperty;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compiled/react",
3
- "version": "0.16.8",
3
+ "version": "0.16.10",
4
4
  "description": "A familiar and performant compile time CSS-in-JS library for React.",
5
5
  "keywords": [
6
6
  "compiled",
@@ -0,0 +1,23 @@
1
+ /** @jsxImportSource @compiled/react */
2
+ // eslint-disable-next-line import/no-extraneous-dependencies
3
+ import { css } from '@compiled/react';
4
+ import { css as strictCSS } from '@fixture/strict-api-test';
5
+ import { render } from '@testing-library/react';
6
+
7
+ describe('strict api used with top level api', () => {
8
+ it('should mix styles together deterministically', () => {
9
+ const styles = strictCSS({
10
+ color: 'var(--ds-text)',
11
+ });
12
+ const otherStyles = css({
13
+ backgroundColor: 'red',
14
+ color: 'blue',
15
+ });
16
+
17
+ const { getByTestId } = render(<div css={[styles, otherStyles]} data-testid="div" />);
18
+
19
+ expect(getByTestId('div')).not.toHaveCompiledCss('color', 'var(--ds-text)');
20
+ expect(getByTestId('div')).toHaveCompiledCss('color', 'blue');
21
+ expect(getByTestId('div')).toHaveCompiledCss('backgroundColor', 'red');
22
+ });
23
+ });
package/src/css/index.ts CHANGED
@@ -36,7 +36,9 @@ export default function css<TProps = unknown>(
36
36
  ...interpolations: CssFunction<TProps>[]
37
37
  ): CSSProps<TProps>;
38
38
 
39
- export default function css<T = unknown>(styles: CssObject<T> | CssObject<T>[]): CSSProps<T>;
39
+ export default function css<T = unknown>(
40
+ styles: CssObject<T> | CssObject<T>[] | CSSProps<T> | CSSProps<T>[]
41
+ ): CSSProps<T>;
40
42
 
41
43
  export default function css<T = unknown>(
42
44
  _styles: TemplateStringsArray | CssObject<T> | CssObject<T>[],
@@ -49,6 +49,9 @@ type WithConditionalCSSProp<TProps> = 'className' extends keyof TProps
49
49
  {};
50
50
 
51
51
  // Unpack all here to avoid infinite self-referencing when defining our own JSX namespace
52
+ // Based on the code from @types/react@18.2.8 / @emotion-js
53
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3197efc097d522c4bf02b94e1a0766d007d6cdeb/types/react/index.d.ts#LL3204C13-L3204C13
54
+ type ReactJSXElementType = string | React.JSXElementConstructor<any>;
52
55
  type ReactJSXElement = JSX.Element;
53
56
  type ReactJSXElementClass = JSX.ElementClass;
54
57
  type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty;
@@ -59,6 +62,7 @@ type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>;
59
62
  type ReactJSXIntrinsicElements = JSX.IntrinsicElements;
60
63
 
61
64
  export namespace CompiledJSX {
65
+ export type ElementType = ReactJSXElementType;
62
66
  export type Element = ReactJSXElement;
63
67
  export type ElementClass = ReactJSXElementClass;
64
68
  export type ElementAttributesProperty = ReactJSXElementAttributesProperty;