@compiled/react 0.18.1 → 0.18.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.
- package/dist/browser/keyframes/index.d.ts +3 -1
- package/dist/browser/keyframes/index.js.map +1 -1
- package/dist/browser/types.d.ts +1 -1
- package/dist/cjs/keyframes/index.d.ts +3 -1
- package/dist/cjs/keyframes/index.js.map +1 -1
- package/dist/cjs/types.d.ts +1 -1
- package/dist/esm/keyframes/index.d.ts +3 -1
- package/dist/esm/keyframes/index.js.map +1 -1
- package/dist/esm/types.d.ts +1 -1
- package/package.json +4 -4
- package/src/create-strict-api/__tests__/generics.test.tsx +6 -6
- package/src/keyframes/__tests__/index.test.tsx +27 -1
- package/src/keyframes/index.ts +9 -1
- package/src/types.ts +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BasicTemplateInterpolations, CSSProps } from '../types';
|
|
2
|
-
export type KeyframeSteps = string | Record<string, CSSProps<void
|
|
2
|
+
export type KeyframeSteps = string | Record<'from' | 'to' | string, CSSProps<void> | {
|
|
3
|
+
[key: `--${string}`]: CSSProps<void>[keyof CSSProps<void>];
|
|
4
|
+
}>;
|
|
3
5
|
/**
|
|
4
6
|
* ## Keyframes
|
|
5
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keyframes/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keyframes/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AA0DlD,MAAM,UAAU,SAAS,CACvB,eAAqD,EACrD,GAAG,eAA8C;IAEjD,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC"}
|
package/dist/browser/types.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export type CSSPseudos = CSSPseudoElements | CSSPseudoClasses;
|
|
|
27
27
|
* excess property check doesn't enable makers to circumvent the
|
|
28
28
|
* system and pass in values they shouldn't.
|
|
29
29
|
*/
|
|
30
|
-
export type CSSProperties = Readonly<CSS.Properties<(string &
|
|
30
|
+
export type CSSProperties = Readonly<CSS.Properties<(string & NonNullable<unknown>) | number>>;
|
|
31
31
|
/**
|
|
32
32
|
* A stricter subset of the {@link CSSProperties} type that excludes
|
|
33
33
|
* vendor and obsolete properties.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BasicTemplateInterpolations, CSSProps } from '../types';
|
|
2
|
-
export type KeyframeSteps = string | Record<string, CSSProps<void
|
|
2
|
+
export type KeyframeSteps = string | Record<'from' | 'to' | string, CSSProps<void> | {
|
|
3
|
+
[key: `--${string}`]: CSSProps<void>[keyof CSSProps<void>];
|
|
4
|
+
}>;
|
|
3
5
|
/**
|
|
4
6
|
* ## Keyframes
|
|
5
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keyframes/index.ts"],"names":[],"mappings":";;;AACA,0CAAkD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keyframes/index.ts"],"names":[],"mappings":";;;AACA,0CAAkD;AA0DlD,SAAgB,SAAS,CACvB,eAAqD,EACrD,GAAG,eAA8C;IAEjD,MAAM,IAAA,wBAAgB,GAAE,CAAC;AAC3B,CAAC;AALD,8BAKC"}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export type CSSPseudos = CSSPseudoElements | CSSPseudoClasses;
|
|
|
27
27
|
* excess property check doesn't enable makers to circumvent the
|
|
28
28
|
* system and pass in values they shouldn't.
|
|
29
29
|
*/
|
|
30
|
-
export type CSSProperties = Readonly<CSS.Properties<(string &
|
|
30
|
+
export type CSSProperties = Readonly<CSS.Properties<(string & NonNullable<unknown>) | number>>;
|
|
31
31
|
/**
|
|
32
32
|
* A stricter subset of the {@link CSSProperties} type that excludes
|
|
33
33
|
* vendor and obsolete properties.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BasicTemplateInterpolations, CSSProps } from '../types';
|
|
2
|
-
export type KeyframeSteps = string | Record<string, CSSProps<void
|
|
2
|
+
export type KeyframeSteps = string | Record<'from' | 'to' | string, CSSProps<void> | {
|
|
3
|
+
[key: `--${string}`]: CSSProps<void>[keyof CSSProps<void>];
|
|
4
|
+
}>;
|
|
3
5
|
/**
|
|
4
6
|
* ## Keyframes
|
|
5
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keyframes/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keyframes/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AA0DlD,MAAM,UAAU,SAAS,CACvB,eAAqD,EACrD,GAAG,eAA8C;IAEjD,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export type CSSPseudos = CSSPseudoElements | CSSPseudoClasses;
|
|
|
27
27
|
* excess property check doesn't enable makers to circumvent the
|
|
28
28
|
* system and pass in values they shouldn't.
|
|
29
29
|
*/
|
|
30
|
-
export type CSSProperties = Readonly<CSS.Properties<(string &
|
|
30
|
+
export type CSSProperties = Readonly<CSS.Properties<(string & NonNullable<unknown>) | number>>;
|
|
31
31
|
/**
|
|
32
32
|
* A stricter subset of the {@link CSSProperties} type that excludes
|
|
33
33
|
* vendor and obsolete properties.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compiled/react",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.3",
|
|
4
4
|
"description": "A familiar and performant compile time CSS-in-JS library for React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiled",
|
|
@@ -72,16 +72,16 @@
|
|
|
72
72
|
"jsx-dev-runtime"
|
|
73
73
|
],
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"csstype": "^3.1.
|
|
75
|
+
"csstype": "^3.1.3"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@compiled/benchmark": "^1.1.0",
|
|
79
|
-
"@compiled/utils": "^0.
|
|
79
|
+
"@compiled/utils": "^0.13.0",
|
|
80
80
|
"@fixture/strict-api-test": "*",
|
|
81
81
|
"@testing-library/react": "^12.1.5",
|
|
82
82
|
"@types/jsdom": "^16.2.15",
|
|
83
83
|
"@types/react-dom": "^17.0.22",
|
|
84
|
-
"expect-type": "^0.
|
|
84
|
+
"expect-type": "^0.20.0",
|
|
85
85
|
"jsdom": "^19.0.0",
|
|
86
86
|
"react": "^17.0.2",
|
|
87
87
|
"react-dom": "^17.0.2"
|
|
@@ -19,7 +19,7 @@ describe('createStrictAPI()', () => {
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
it('should mark all styles as optional in cssMap()', () => {
|
|
22
|
-
const
|
|
22
|
+
const stylesMap = cssMap({
|
|
23
23
|
nested: {
|
|
24
24
|
'&:hover': {},
|
|
25
25
|
'&:active': {},
|
|
@@ -28,7 +28,7 @@ describe('createStrictAPI()', () => {
|
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
const { getByTestId } = render(<div css={
|
|
31
|
+
const { getByTestId } = render(<div css={stylesMap.nested} data-testid="div" />);
|
|
32
32
|
|
|
33
33
|
expect(getByTestId('div')).toBeDefined();
|
|
34
34
|
});
|
|
@@ -96,7 +96,7 @@ describe('createStrictAPI()', () => {
|
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
it('should violate types for cssMap()', () => {
|
|
99
|
-
const
|
|
99
|
+
const stylesMap = cssMap({
|
|
100
100
|
primary: {
|
|
101
101
|
// @ts-expect-error — Type '""' is not assignable to type ...
|
|
102
102
|
color: '',
|
|
@@ -129,7 +129,7 @@ describe('createStrictAPI()', () => {
|
|
|
129
129
|
},
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
const { getByTestId } = render(<div css={
|
|
132
|
+
const { getByTestId } = render(<div css={stylesMap.primary} data-testid="div" />);
|
|
133
133
|
|
|
134
134
|
expect(getByTestId('div')).toBeDefined();
|
|
135
135
|
});
|
|
@@ -224,7 +224,7 @@ describe('createStrictAPI()', () => {
|
|
|
224
224
|
});
|
|
225
225
|
|
|
226
226
|
it('should pass type check for cssMap()', () => {
|
|
227
|
-
const
|
|
227
|
+
const stylesMap = cssMap({
|
|
228
228
|
primary: {
|
|
229
229
|
color: 'var(--ds-text)',
|
|
230
230
|
backgroundColor: 'var(--ds-bold)',
|
|
@@ -258,7 +258,7 @@ describe('createStrictAPI()', () => {
|
|
|
258
258
|
},
|
|
259
259
|
});
|
|
260
260
|
|
|
261
|
-
const { getByTestId } = render(<div css={
|
|
261
|
+
const { getByTestId } = render(<div css={stylesMap.primary} data-testid="div" />);
|
|
262
262
|
|
|
263
263
|
expect(getByTestId('div')).toHaveCompiledCss('color', 'var(--ds-text)');
|
|
264
264
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsxImportSource @compiled/react */
|
|
2
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
|
-
import { keyframes, styled } from '@compiled/react';
|
|
3
|
+
import { keyframes, styled, css } from '@compiled/react';
|
|
4
4
|
import { render } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
import defaultFadeOut, { namedFadeOut, fadeOut as shadowedFadeOut } from '../__fixtures__';
|
|
@@ -180,6 +180,32 @@ describe('keyframes', () => {
|
|
|
180
180
|
`"@keyframes korwhog{0%{opacity:1}to{opacity:0}}"`
|
|
181
181
|
);
|
|
182
182
|
});
|
|
183
|
+
|
|
184
|
+
it('containing css variables', () => {
|
|
185
|
+
const variable = '--opacity';
|
|
186
|
+
const fadeOut = keyframes({
|
|
187
|
+
from: {
|
|
188
|
+
[variable]: 1,
|
|
189
|
+
},
|
|
190
|
+
to: {
|
|
191
|
+
'--opacity': 0,
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
const styles = css({
|
|
195
|
+
animationName: fadeOut,
|
|
196
|
+
opacity: `var(${variable})`,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const { getByText } = render(<div css={styles}>hello world</div>);
|
|
200
|
+
|
|
201
|
+
expect(getByText('hello world')).toHaveCompiledCss({
|
|
202
|
+
animationName: 'k1sm7npi',
|
|
203
|
+
opacity: 'var(--opacity)',
|
|
204
|
+
});
|
|
205
|
+
expect(getKeyframe('k1sm7npi')).toMatchInlineSnapshot(
|
|
206
|
+
`"@keyframes k1sm7npi{0%{--opacity:1px}to{--opacity:0}}"`
|
|
207
|
+
);
|
|
208
|
+
});
|
|
183
209
|
});
|
|
184
210
|
});
|
|
185
211
|
|
package/src/keyframes/index.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { BasicTemplateInterpolations, CSSProps } from '../types';
|
|
2
2
|
import { createSetupError } from '../utils/error';
|
|
3
3
|
|
|
4
|
-
export type KeyframeSteps =
|
|
4
|
+
export type KeyframeSteps =
|
|
5
|
+
// `string` would just be an arbitrary CSS-like string such as `keyframes('from{opacity:1;}to{opacity:0;}')`
|
|
6
|
+
| string
|
|
7
|
+
| Record<
|
|
8
|
+
'from' | 'to' | string,
|
|
9
|
+
// We allow basically all CSSProperties here and CSS Variables mapping to their values.
|
|
10
|
+
// eg. `{ display: 'block', '--var': 'block' }` — but likely it just becomes `'--var': any`
|
|
11
|
+
CSSProps<void> | { [key: `--${string}`]: CSSProps<void>[keyof CSSProps<void>] }
|
|
12
|
+
>;
|
|
5
13
|
|
|
6
14
|
/**
|
|
7
15
|
* ## Keyframes
|
package/src/types.ts
CHANGED
|
@@ -104,7 +104,7 @@ export type CSSPseudos = CSSPseudoElements | CSSPseudoClasses;
|
|
|
104
104
|
* excess property check doesn't enable makers to circumvent the
|
|
105
105
|
* system and pass in values they shouldn't.
|
|
106
106
|
*/
|
|
107
|
-
export type CSSProperties = Readonly<CSS.Properties<(string &
|
|
107
|
+
export type CSSProperties = Readonly<CSS.Properties<(string & NonNullable<unknown>) | number>>;
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* A stricter subset of the {@link CSSProperties} type that excludes
|