@compiled/react 0.17.2 → 0.17.3

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.
@@ -1,4 +1,4 @@
1
- import { ac } from '../runtime';
1
+ import { ax } from '../runtime';
2
2
  /**
3
3
  * ## CX
4
4
  *
@@ -21,6 +21,6 @@ export const cx = (...styles) => {
21
21
  const actualStyles = styles;
22
22
  // The output should be a union type of passed in styles. This ensures the call
23
23
  // site of xcss prop can raise violations when disallowed styles have been passed.
24
- return ac(actualStyles);
24
+ return ax(actualStyles);
25
25
  };
26
26
  //# sourceMappingURL=index.js.map
@@ -24,7 +24,7 @@ const cx = (...styles) => {
24
24
  const actualStyles = styles;
25
25
  // The output should be a union type of passed in styles. This ensures the call
26
26
  // site of xcss prop can raise violations when disallowed styles have been passed.
27
- return (0, runtime_1.ac)(actualStyles);
27
+ return (0, runtime_1.ax)(actualStyles);
28
28
  };
29
29
  exports.cx = cx;
30
30
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { ac } from '../runtime';
1
+ import { ax } from '../runtime';
2
2
  /**
3
3
  * ## CX
4
4
  *
@@ -21,6 +21,6 @@ export const cx = (...styles) => {
21
21
  const actualStyles = styles;
22
22
  // The output should be a union type of passed in styles. This ensures the call
23
23
  // site of xcss prop can raise violations when disallowed styles have been passed.
24
- return ac(actualStyles);
24
+ return ax(actualStyles);
25
25
  };
26
26
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compiled/react",
3
- "version": "0.17.2",
3
+ "version": "0.17.3",
4
4
  "description": "A familiar and performant compile time CSS-in-JS library for React.",
5
5
  "keywords": [
6
6
  "compiled",
@@ -5,8 +5,8 @@ interface CSSPropertiesSchema {
5
5
  color: 'var(--ds-text-hover)';
6
6
  background: 'var(--ds-surface-hover)' | 'var(--ds-surface-sunken-hover)';
7
7
  };
8
- color: 'var(--ds-text)' | 'var(--ds-text-bold)';
9
- background: 'var(--ds-surface)' | 'var(--ds-surface-sunken)';
8
+ color: 'var(--ds-text)' | 'var(--ds-text-bold)' | 'var(--ds-text-error)';
9
+ background: 'var(--ds-surface)' | 'var(--ds-surface-sunken)' | 'var(--ds-surface-overlay)';
10
10
  bkgrnd: 'red' | 'green';
11
11
  }
12
12
 
@@ -0,0 +1,95 @@
1
+ /** @jsxImportSource @compiled/react */
2
+ import { render } from '@testing-library/react';
3
+
4
+ import { cssMap, type XCSSProp, cx } from './__fixtures__/strict-api';
5
+
6
+ const styles = cssMap({
7
+ rootNative: {
8
+ color: 'var(--ds-text)',
9
+ background: 'var(--ds-surface)',
10
+ },
11
+ rootComponent: {
12
+ color: 'var(--ds-text-error)',
13
+ background: 'var(--ds-surface-overlay)',
14
+ },
15
+ bold: {
16
+ color: 'var(--ds-text-bold)',
17
+ },
18
+ sunken: {
19
+ background: 'var(--ds-surface-sunken)',
20
+ },
21
+ });
22
+
23
+ function ComponentPassThrough({
24
+ xcss,
25
+ }: {
26
+ xcss?: ReturnType<typeof XCSSProp<'background' | 'color', '&:hover'>>;
27
+ }) {
28
+ return <NativePassThrough xcss={cx(styles.rootComponent, xcss)} />;
29
+ }
30
+
31
+ function NativePassThrough({
32
+ xcss,
33
+ }: {
34
+ xcss?: ReturnType<typeof XCSSProp<'background' | 'color', '&:hover'>>;
35
+ }) {
36
+ return <button data-testid="button" className={xcss} css={styles.rootNative} />;
37
+ }
38
+
39
+ describe('pass-through props.xcss directly to DOM', () => {
40
+ it('works with no props.xcss', () => {
41
+ const { getByTestId } = render(<NativePassThrough />);
42
+
43
+ expect(getByTestId('button')).toHaveCompiledCss({
44
+ color: 'var(--ds-text)',
45
+ background: 'var(--ds-surface)',
46
+ });
47
+ });
48
+
49
+ it('works with pass-through props.xcss', () => {
50
+ const { getByTestId } = render(<NativePassThrough xcss={styles.bold} />);
51
+
52
+ expect(getByTestId('button')).toHaveCompiledCss({
53
+ color: 'var(--ds-text-bold)',
54
+ background: 'var(--ds-surface)', // rootNative styles
55
+ });
56
+ });
57
+
58
+ it('works with pass-through multiple props.xcss via cx', () => {
59
+ const { getByTestId } = render(<NativePassThrough xcss={cx(styles.bold, styles.sunken)} />);
60
+
61
+ expect(getByTestId('button')).toHaveCompiledCss({
62
+ color: 'var(--ds-text-bold)',
63
+ background: 'var(--ds-surface-sunken)',
64
+ });
65
+ });
66
+ });
67
+
68
+ describe('pass-through props.xcss via another component', () => {
69
+ it('works with no props.xcss', () => {
70
+ const { getByTestId } = render(<ComponentPassThrough />);
71
+
72
+ expect(getByTestId('button')).toHaveCompiledCss({
73
+ color: 'var(--ds-text-error)',
74
+ background: 'var(--ds-surface-overlay)',
75
+ });
76
+ });
77
+
78
+ it('works with pass-through props.xcss', () => {
79
+ const { getByTestId } = render(<ComponentPassThrough xcss={styles.bold} />);
80
+
81
+ expect(getByTestId('button')).toHaveCompiledCss({
82
+ color: 'var(--ds-text-bold)',
83
+ background: 'var(--ds-surface-overlay)', // rootComponent styles
84
+ });
85
+ });
86
+
87
+ it('works with pass-through multiple props.xcss via cx', () => {
88
+ const { getByTestId } = render(<ComponentPassThrough xcss={cx(styles.bold, styles.sunken)} />);
89
+
90
+ expect(getByTestId('button')).toHaveCompiledCss({
91
+ color: 'var(--ds-text-bold)',
92
+ background: 'var(--ds-surface-sunken)',
93
+ });
94
+ });
95
+ });
@@ -1,7 +1,7 @@
1
1
  import type * as CSS from 'csstype';
2
2
 
3
3
  import type { ApplySchemaValue } from '../create-strict-api/types';
4
- import { ac } from '../runtime';
4
+ import { ax } from '../runtime';
5
5
  import type { CSSPseudos, CSSPseudoClasses, CSSProperties, StrictCSSProperties } from '../types';
6
6
 
7
7
  type MarkAsRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
@@ -208,5 +208,5 @@ export const cx = <TStyles extends [...XCSSProp<any, any>[]]>(
208
208
 
209
209
  // The output should be a union type of passed in styles. This ensures the call
210
210
  // site of xcss prop can raise violations when disallowed styles have been passed.
211
- return ac(actualStyles) as TStyles[number];
211
+ return ax(actualStyles) as TStyles[number];
212
212
  };