@compiled/react 0.16.10 → 0.17.1

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 (63) hide show
  1. package/dist/browser/create-strict-api/index.d.ts +19 -22
  2. package/dist/browser/create-strict-api/index.js +6 -4
  3. package/dist/browser/create-strict-api/index.js.map +1 -1
  4. package/dist/browser/create-strict-api/types.d.ts +28 -0
  5. package/dist/browser/create-strict-api/types.js +2 -0
  6. package/dist/browser/create-strict-api/types.js.map +1 -0
  7. package/dist/browser/css/index.d.ts +2 -0
  8. package/dist/browser/css/index.js.map +1 -1
  9. package/dist/browser/css-map/index.d.ts +15 -2
  10. package/dist/browser/css-map/index.js.map +1 -1
  11. package/dist/browser/index.d.ts +3 -2
  12. package/dist/browser/index.js +1 -1
  13. package/dist/browser/index.js.map +1 -1
  14. package/dist/browser/types.d.ts +4 -2
  15. package/dist/browser/xcss-prop/index.d.ts +17 -14
  16. package/dist/browser/xcss-prop/index.js.map +1 -1
  17. package/dist/cjs/create-strict-api/index.d.ts +19 -22
  18. package/dist/cjs/create-strict-api/index.js +6 -4
  19. package/dist/cjs/create-strict-api/index.js.map +1 -1
  20. package/dist/cjs/create-strict-api/types.d.ts +28 -0
  21. package/dist/cjs/create-strict-api/types.js +3 -0
  22. package/dist/cjs/create-strict-api/types.js.map +1 -0
  23. package/dist/cjs/css/index.d.ts +2 -0
  24. package/dist/cjs/css/index.js.map +1 -1
  25. package/dist/cjs/css-map/index.d.ts +15 -2
  26. package/dist/cjs/css-map/index.js.map +1 -1
  27. package/dist/cjs/index.d.ts +3 -2
  28. package/dist/cjs/index.js.map +1 -1
  29. package/dist/cjs/types.d.ts +4 -2
  30. package/dist/cjs/xcss-prop/index.d.ts +17 -14
  31. package/dist/cjs/xcss-prop/index.js.map +1 -1
  32. package/dist/esm/create-strict-api/index.d.ts +19 -22
  33. package/dist/esm/create-strict-api/index.js +6 -4
  34. package/dist/esm/create-strict-api/index.js.map +1 -1
  35. package/dist/esm/create-strict-api/types.d.ts +28 -0
  36. package/dist/esm/create-strict-api/types.js +2 -0
  37. package/dist/esm/create-strict-api/types.js.map +1 -0
  38. package/dist/esm/css/index.d.ts +2 -0
  39. package/dist/esm/css/index.js.map +1 -1
  40. package/dist/esm/css-map/index.d.ts +15 -2
  41. package/dist/esm/css-map/index.js.map +1 -1
  42. package/dist/esm/index.d.ts +3 -2
  43. package/dist/esm/index.js +1 -1
  44. package/dist/esm/index.js.map +1 -1
  45. package/dist/esm/types.d.ts +4 -2
  46. package/dist/esm/xcss-prop/index.d.ts +17 -14
  47. package/dist/esm/xcss-prop/index.js.map +1 -1
  48. package/package.json +1 -1
  49. package/src/create-strict-api/__tests__/__fixtures__/strict-api-recursive.ts +6 -6
  50. package/src/create-strict-api/__tests__/__fixtures__/strict-api.ts +14 -3
  51. package/src/create-strict-api/__tests__/css-func.test.tsx +49 -0
  52. package/src/create-strict-api/__tests__/generics.test.tsx +26 -5
  53. package/src/create-strict-api/__tests__/index.test.tsx +198 -32
  54. package/src/create-strict-api/index.ts +41 -34
  55. package/src/create-strict-api/types.ts +69 -0
  56. package/src/css/index.ts +2 -0
  57. package/src/css-map/index.ts +20 -2
  58. package/src/index.ts +16 -2
  59. package/src/types.ts +14 -10
  60. package/src/xcss-prop/__tests__/media-query-strict.test.tsx +179 -0
  61. package/src/xcss-prop/__tests__/media-query.test.tsx +53 -0
  62. package/src/xcss-prop/__tests__/xcss-prop.test.tsx +3 -34
  63. package/src/xcss-prop/index.ts +47 -28
@@ -1,20 +1,18 @@
1
- import type { StrictCSSProperties, CSSPseudos } from '../types';
1
+ import type { StrictCSSProperties, CSSPseudos, CSSProps } from '../types';
2
2
  import { type CompiledStyles, cx, type Internal$XCSSProp } from '../xcss-prop';
3
- type PseudosDeclarations = {
4
- [Q in CSSPseudos]?: StrictCSSProperties;
5
- };
6
- type EnforceSchema<TSchema> = {
7
- [P in keyof TSchema]?: P extends keyof CompiledSchema ? TSchema[P] extends Record<string, any> ? EnforceSchema<TSchema[P]> : TSchema[P] : never;
8
- };
9
- type CSSStyles<TSchema extends CompiledSchema> = StrictCSSProperties & PseudosDeclarations & EnforceSchema<TSchema>;
10
- type CSSMapStyles<TSchema extends CompiledSchema> = Record<string, CSSStyles<TSchema>>;
11
- interface CompiledAPI<TSchema extends CompiledSchema> {
3
+ import type { AllowedStyles, ApplySchema, ApplySchemaMap, CompiledSchemaShape } from './types';
4
+ export interface StrictOptions {
5
+ media: string;
6
+ }
7
+ export interface CompiledAPI<TSchema extends CompiledSchemaShape, TAllowedMediaQueries extends string> {
12
8
  /**
13
9
  * ## CSS
14
10
  *
15
11
  * Creates styles that are statically typed and useable with other Compiled APIs.
16
12
  * For further details [read the documentation](https://compiledcssinjs.com/docs/api-css).
17
13
  *
14
+ * This API does not currently work with XCSS prop.
15
+ *
18
16
  * @example
19
17
  * ```
20
18
  * const redText = css({
@@ -24,7 +22,7 @@ interface CompiledAPI<TSchema extends CompiledSchema> {
24
22
  * <div css={redText} />
25
23
  * ```
26
24
  */
27
- css(styles: CSSStyles<TSchema>): StrictCSSProperties;
25
+ css<TStyles extends ApplySchema<TStyles, TSchema>>(styles: AllowedStyles<TAllowedMediaQueries> & TStyles): CSSProps<unknown>;
28
26
  /**
29
27
  * ## CSS Map
30
28
  *
@@ -41,7 +39,7 @@ interface CompiledAPI<TSchema extends CompiledSchema> {
41
39
  * <div css={styles.solid} />
42
40
  * ```
43
41
  */
44
- cssMap<TStylesMap extends CSSMapStyles<TSchema>>(styles: CSSMapStyles<TSchema> & TStylesMap): {
42
+ cssMap<TObject extends Record<string, AllowedStyles<TAllowedMediaQueries>>, TStylesMap extends ApplySchemaMap<TObject, TSchema>>(styles: Record<string, AllowedStyles<TAllowedMediaQueries>> & TStylesMap): {
45
43
  readonly [P in keyof TStylesMap]: CompiledStyles<TStylesMap[P]>;
46
44
  };
47
45
  /**
@@ -99,7 +97,7 @@ interface CompiledAPI<TSchema extends CompiledSchema> {
99
97
  * typeof XCSSProp<
100
98
  * XCSSAllProperties,
101
99
  * '&:hover',
102
- * { requiredProperties: 'color', requiredPseudos: never }
100
+ * { requiredProperties: 'color' }
103
101
  * >
104
102
  * >;
105
103
  * }
@@ -124,10 +122,8 @@ interface CompiledAPI<TSchema extends CompiledSchema> {
124
122
  */
125
123
  XCSSProp<TAllowedProperties extends keyof StrictCSSProperties, TAllowedPseudos extends CSSPseudos, TRequiredProperties extends {
126
124
  requiredProperties: TAllowedProperties;
127
- requiredPseudos: TAllowedPseudos;
128
- } = never>(): Internal$XCSSProp<TAllowedProperties, TAllowedPseudos, TSchema, TRequiredProperties>;
125
+ } = never>(): Internal$XCSSProp<TAllowedProperties, TAllowedPseudos, TAllowedMediaQueries, TSchema, TRequiredProperties, 'strict'>;
129
126
  }
130
- type CompiledSchema = StrictCSSProperties & PseudosDeclarations;
131
127
  /**
132
128
  * ## Create Strict API
133
129
  *
@@ -142,17 +138,19 @@ type CompiledSchema = StrictCSSProperties & PseudosDeclarations;
142
138
  *
143
139
  * To set up:
144
140
  *
145
- * 1. Declare the API in a module (either local or in a package):
141
+ * 1. Declare the API in a module (either local or in a package), optionally declaring accepted media queries.
146
142
  *
147
143
  * @example
148
144
  * ```tsx
149
145
  * // ./foo.ts
150
- * const { css } = createStrictAPI<{
146
+ * interface Schema {
151
147
  * color: 'var(--ds-text)',
152
148
  * '&:hover': { color: 'var(--ds-text-hover)' }
153
- * }>();
149
+ * }
150
+ *
151
+ * const { css, cssMap, XCSSProp, cx } = createStrictAPI<Schema, { media: '(min-width: 30rem)' }>();
154
152
  *
155
- * export { css };
153
+ * export { css, cssMap, XCSSProp, cx };
156
154
  * ```
157
155
  *
158
156
  * 2. Configure Compiled to pick up this module:
@@ -176,5 +174,4 @@ type CompiledSchema = StrictCSSProperties & PseudosDeclarations;
176
174
  * <div css={styles} />
177
175
  * ```
178
176
  */
179
- export declare function createStrictAPI<TSchema extends CompiledSchema>(): CompiledAPI<TSchema>;
180
- export {};
177
+ export declare function createStrictAPI<TSchema extends CompiledSchemaShape, TCreateStrictAPIOptions extends StrictOptions = never>(): CompiledAPI<TSchema, TCreateStrictAPIOptions['media']>;
@@ -14,17 +14,19 @@ import { cx } from '../xcss-prop';
14
14
  *
15
15
  * To set up:
16
16
  *
17
- * 1. Declare the API in a module (either local or in a package):
17
+ * 1. Declare the API in a module (either local or in a package), optionally declaring accepted media queries.
18
18
  *
19
19
  * @example
20
20
  * ```tsx
21
21
  * // ./foo.ts
22
- * const { css } = createStrictAPI<{
22
+ * interface Schema {
23
23
  * color: 'var(--ds-text)',
24
24
  * '&:hover': { color: 'var(--ds-text-hover)' }
25
- * }>();
25
+ * }
26
+ *
27
+ * const { css, cssMap, XCSSProp, cx } = createStrictAPI<Schema, { media: '(min-width: 30rem)' }>();
26
28
  *
27
- * export { css };
29
+ * export { css, cssMap, XCSSProp, cx };
28
30
  * ```
29
31
  *
30
32
  * 2. Configure Compiled to pick up this module:
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/create-strict-api/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAuB,EAAE,EAA0B,MAAM,cAAc,CAAC;AAuJ/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO;QACL,GAAG;YACD,MAAM,sBAAsB,EAAE,CAAC;QACjC,CAAC;QACD,MAAM;YACJ,MAAM,sBAAsB,EAAE,CAAC;QACjC,CAAC;QACD,EAAE;QACF,QAAQ;YACN,MAAM,sBAAsB,EAAE,CAAC;QACjC,CAAC;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/create-strict-api/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAuB,EAAE,EAA0B,MAAM,cAAc,CAAC;AAyJ/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,UAAU,eAAe;IAI7B,OAAO;QACL,GAAG;YACD,MAAM,sBAAsB,EAAE,CAAC;QACjC,CAAC;QACD,MAAM;YACJ,MAAM,sBAAsB,EAAE,CAAC;QACjC,CAAC;QACD,EAAE;QACF,QAAQ;YACN,MAAM,sBAAsB,EAAE,CAAC;QACjC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { StrictCSSProperties, CSSPseudoClasses, CSSPseudoElements, CSSPseudos } from '../types';
2
+ /**
3
+ * This is the shape of the generic object that `createStrictAPI()` takes.
4
+ * It's deliberately a subset of `AllowedStyles` and does not take at rules
5
+ * and pseudo elements.
6
+ */
7
+ export type CompiledSchemaShape = StrictCSSProperties & {
8
+ [Q in CSSPseudoClasses]?: StrictCSSProperties;
9
+ };
10
+ export type PseudosDeclarations = {
11
+ [Q in CSSPseudos]?: StrictCSSProperties;
12
+ };
13
+ export type MediaQueries<TMediaQuery extends string> = {
14
+ [Q in `@media ${TMediaQuery}`]?: StrictCSSProperties & PseudosDeclarations;
15
+ };
16
+ export type AllowedStyles<TMediaQuery extends string> = StrictCSSProperties & PseudosDeclarations & MediaQueries<TMediaQuery>;
17
+ export type ApplySchemaValue<TSchema, TKey extends keyof StrictCSSProperties, TPseudoKey extends CSSPseudoClasses | ''> = TKey extends keyof TSchema ? TPseudoKey extends keyof TSchema ? TKey extends keyof TSchema[TPseudoKey] ? TSchema[TPseudoKey][TKey] : TSchema[TKey] : TSchema[TKey] : StrictCSSProperties[TKey];
18
+ /**
19
+ * Recursively maps over object properties to resolve them to either a {@link TSchema}
20
+ * value if present, else fallback to its value from {@link StrictCSSProperties}. If
21
+ * the property isn't a known property its value will be resolved to `never`.
22
+ */
23
+ export type ApplySchema<TObject, TSchema, TPseudoKey extends CSSPseudoClasses | '' = ''> = {
24
+ [TKey in keyof TObject]?: TKey extends keyof StrictCSSProperties ? ApplySchemaValue<TSchema, TKey, TPseudoKey> : TKey extends CSSPseudoClasses ? ApplySchema<TObject[TKey], TSchema, TKey> : TKey extends `@${string}` | CSSPseudoElements ? ApplySchema<TObject[TKey], TSchema> : never;
25
+ };
26
+ export type ApplySchemaMap<TStylesMap, TSchema> = {
27
+ [P in keyof TStylesMap]: ApplySchema<TStylesMap[P], TSchema>;
28
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/create-strict-api/types.ts"],"names":[],"mappings":""}
@@ -5,6 +5,8 @@ import type { CSSProps, CssObject, CssFunction } from '../types';
5
5
  * Create styles that are statically typed and useable with other Compiled APIs.
6
6
  * For further details [read the documentation](https://compiledcssinjs.com/docs/api-css).
7
7
  *
8
+ * This API does not currently work with XCSS prop.
9
+ *
8
10
  * ### Style with objects
9
11
  *
10
12
  * @example
@@ -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;AAuClD,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;AAyClD,MAAM,CAAC,OAAO,UAAU,GAAG,CACzB,OAA6D,EAC7D,GAAG,eAA8B;IAEjC,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC"}
@@ -77,6 +77,19 @@ type ExtendedSelectors = {
77
77
  */
78
78
  selectors?: ExtendedSelector;
79
79
  };
80
+ type LooseMediaQueries = Record<`@media ${string}`, CSSProperties & AllPseudos>;
81
+ /**
82
+ * We remap media query keys to `"@media"` so it's blocked inside the strict APIs.
83
+ * This is done as it's currently impossible to ensure type safety end-to-end — when
84
+ * passing in unknown media queries from the loose API into the strict API you end up
85
+ * being also able to pass any styles you want, which makes the whole point of the strict
86
+ * API meaningless.
87
+ *
88
+ * Sorry folks!
89
+ */
90
+ type RemapMedia<TStyles> = {
91
+ [Q in keyof TStyles as Q extends `@media ${string}` ? '@media [loose]' : Q]: TStyles[Q];
92
+ };
80
93
  /**
81
94
  * ## CSS Map
82
95
  *
@@ -93,7 +106,7 @@ type ExtendedSelectors = {
93
106
  * <div css={styles.solid} />
94
107
  * ```
95
108
  */
96
- export default function cssMap<TStyles extends Record<string, CSSProperties & WhitelistedSelector & ExtendedSelectors>>(_styles: TStyles): {
97
- readonly [P in keyof TStyles]: CompiledStyles<TStyles[P]>;
109
+ export default function cssMap<TStyles extends Record<string, CSSProperties & WhitelistedSelector & ExtendedSelectors & LooseMediaQueries>>(_styles: TStyles): {
110
+ readonly [P in keyof TStyles]: CompiledStyles<RemapMedia<TStyles[P]>>;
98
111
  };
99
112
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css-map/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAkFlD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAG5B,OAAgB;IAIhB,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css-map/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAiGlD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAM5B,OAAgB;IAIhB,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC"}
@@ -2,12 +2,13 @@ import { createElement } from 'react';
2
2
  import type { CompiledJSX } from './jsx/jsx-local-namespace';
3
3
  export { ClassNames } from './class-names';
4
4
  export { createStrictAPI } from './create-strict-api';
5
+ export type { PseudosDeclarations, MediaQueries, AllowedStyles, ApplySchema, ApplySchemaMap, } from './create-strict-api/types';
5
6
  export { default as css } from './css';
6
7
  export { default as cssMap } from './css-map';
7
8
  export { keyframes } from './keyframes';
8
- export { styled } from './styled';
9
+ export { styled, StyledProps } from './styled';
9
10
  export type { CSSProperties, CSSProps, CSSPseudos, CssFunction, CssType, StrictCSSProperties, } from './types';
10
- export { type XCSSAllProperties, type XCSSAllPseudos, type XCSSProp, cx } from './xcss-prop';
11
+ export { type XCSSAllProperties, type XCSSAllPseudos, type XCSSProp, type CompiledStyles, type Internal$XCSSProp, cx, } from './xcss-prop';
11
12
  export declare const jsx: typeof createElement;
12
13
  export declare namespace jsx {
13
14
  namespace JSX {
@@ -5,7 +5,7 @@ export { default as css } from './css';
5
5
  export { default as cssMap } from './css-map';
6
6
  export { keyframes } from './keyframes';
7
7
  export { styled } from './styled';
8
- export { cx } from './xcss-prop';
8
+ export { cx, } from './xcss-prop';
9
9
  // Pass through the (classic) jsx runtime.
10
10
  // Compiled currently doesn't define its own and uses this purely to enable a local jsx namespace.
11
11
  export const jsx = createElement;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AASlC,OAAO,EAA8D,EAAE,EAAE,MAAM,aAAa,CAAC;AAE7F,0CAA0C;AAC1C,kGAAkG;AAClG,MAAM,CAAC,MAAM,GAAG,GAAG,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQtD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAe,MAAM,UAAU,CAAC;AAS/C,OAAO,EAML,EAAE,GACH,MAAM,aAAa,CAAC;AAErB,0CAA0C;AAC1C,kGAAkG;AAClG,MAAM,CAAC,MAAM,GAAG,GAAG,aAAa,CAAC"}
@@ -18,14 +18,16 @@ export type CssObject<TProps> = Readonly<{
18
18
  [key: string]: CssFunction<TProps>;
19
19
  }>;
20
20
  export type CssFunction<TProps = unknown> = CssType<TProps> | BasicTemplateInterpolations | null | boolean | undefined;
21
- export type CSSPseudos = '&::after' | '&::backdrop' | '&::before' | '&::cue' | '&::cue-region' | '&::first-letter' | '&::first-line' | '&::grammar-error' | '&::marker' | '&::placeholder' | '&::selection' | '&::spelling-error' | '&::target-text' | '&::view-transition' | '&:active' | '&:autofill' | '&:blank' | '&:checked' | '&:default' | '&:defined' | '&:disabled' | '&:empty' | '&:enabled' | '&:first' | '&:focus' | '&:focus-visible' | '&:focus-within' | '&:fullscreen' | '&:hover' | '&:in-range' | '&:indeterminate' | '&:invalid' | '&:left' | '&:link' | '&:local-link' | '&:optional' | '&:out-of-range' | '&:paused' | '&:picture-in-picture' | '&:placeholder-shown' | '&:playing' | '&:read-only' | '&:read-write' | '&:required' | '&:right' | '&:target' | '&:user-invalid' | '&:user-valid' | '&:valid' | '&:visited';
21
+ export type CSSPseudoElements = '&::after' | '&::backdrop' | '&::before' | '&::cue' | '&::cue-region' | '&::first-letter' | '&::first-line' | '&::grammar-error' | '&::marker' | '&::placeholder' | '&::selection' | '&::spelling-error' | '&::target-text' | '&::view-transition';
22
+ export type CSSPseudoClasses = '&:active' | '&:autofill' | '&:blank' | '&:checked' | '&:default' | '&:defined' | '&:disabled' | '&:empty' | '&:enabled' | '&:first' | '&:focus' | '&:focus-visible' | '&:focus-within' | '&:fullscreen' | '&:hover' | '&:in-range' | '&:indeterminate' | '&:invalid' | '&:left' | '&:link' | '&:local-link' | '&:optional' | '&:out-of-range' | '&:paused' | '&:picture-in-picture' | '&:placeholder-shown' | '&:playing' | '&:read-only' | '&:read-write' | '&:required' | '&:right' | '&:target' | '&:user-invalid' | '&:user-valid' | '&:valid' | '&:visited';
23
+ export type CSSPseudos = CSSPseudoElements | CSSPseudoClasses;
22
24
  /**
23
25
  * The XCSSProp must be given all known available properties even
24
26
  * if it takes a subset of them. This ensures the (lack-of an)
25
27
  * excess property check doesn't enable makers to circumvent the
26
28
  * system and pass in values they shouldn't.
27
29
  */
28
- export type CSSProperties = Readonly<CSS.Properties<string | number>>;
30
+ export type CSSProperties = Readonly<CSS.Properties<(string & object) | number>>;
29
31
  /**
30
32
  * A stricter subset of the {@link CSSProperties} type that excludes
31
33
  * vendor and obsolete properties.
@@ -1,22 +1,27 @@
1
1
  import type * as CSS from 'csstype';
2
- import type { CSSPseudos, CSSProperties, StrictCSSProperties } from '../types';
2
+ import type { ApplySchemaValue } from '../create-strict-api/types';
3
+ import type { CSSPseudos, CSSPseudoClasses, CSSProperties, StrictCSSProperties } from '../types';
3
4
  type MarkAsRequired<T, K extends keyof T> = T & {
4
5
  [P in K]-?: T[P];
5
6
  };
6
- type XCSSItem<TStyleDecl extends keyof CSSProperties, TSchema> = {
7
- [Q in keyof CSSProperties]: Q extends TStyleDecl ? CompiledPropertyDeclarationReference | (Q extends keyof TSchema ? TSchema[Q] : CSSProperties[Q]) : never;
7
+ type XCSSValue<TStyleDecl extends keyof CSSProperties, TSchema, TPseudoKey extends CSSPseudoClasses | ''> = {
8
+ [Q in keyof StrictCSSProperties]: Q extends TStyleDecl ? ApplySchemaValue<TSchema, Q, TPseudoKey> : never;
8
9
  };
9
- type XCSSPseudos<TAllowedProperties extends keyof CSSProperties, TAllowedPseudos extends CSSPseudos, TRequiredProperties extends {
10
+ type XCSSPseudo<TAllowedProperties extends keyof StrictCSSProperties, TAllowedPseudos extends CSSPseudos, TRequiredProperties extends {
10
11
  requiredProperties: TAllowedProperties;
11
12
  }, TSchema> = {
12
- [Q in CSSPseudos]?: Q extends TAllowedPseudos ? MarkAsRequired<XCSSItem<TAllowedProperties, Q extends keyof TSchema ? TSchema[Q] : object>, TRequiredProperties['requiredProperties']> : never;
13
+ [Q in CSSPseudos]?: Q extends TAllowedPseudos ? MarkAsRequired<XCSSValue<TAllowedProperties, TSchema, Q extends CSSPseudoClasses ? Q : ''>, TRequiredProperties['requiredProperties']> : never;
14
+ };
15
+ type XCSSMediaQuery<TAllowedProperties extends keyof StrictCSSProperties, TAllowedPseudos extends CSSPseudos, TAllowedMediaQueries extends string, TSchema> = {
16
+ [Q in `@media ${TAllowedMediaQueries}`]?: XCSSValue<TAllowedProperties, TSchema, ''> | XCSSPseudo<TAllowedProperties, TAllowedPseudos, never, TSchema>;
13
17
  };
14
18
  /**
15
19
  * These APIs we don't want to allow to be passed through the `xcss` prop but we also
16
20
  * must declare them so the (lack-of a) excess property check doesn't bite us and allow
17
21
  * unexpected values through.
18
22
  */
19
- type BlockedRules = {
23
+ type BlockedRules<TMode extends 'loose' | 'strict'> = {
24
+ '@media [loose]'?: TMode extends 'loose' ? any : never;
20
25
  selectors?: never;
21
26
  } & {
22
27
  [Q in CSS.AtRules]?: never;
@@ -30,7 +35,7 @@ type CompiledPropertyDeclarationReference = {
30
35
  * take Compiled generated styles and not some arbitrary object.
31
36
  */
32
37
  export type CompiledStyles<TObject> = {
33
- [Q in keyof TObject]: TObject[Q] extends Record<string, unknown> ? CompiledStyles<TObject[Q]> : CompiledPropertyDeclarationReference;
38
+ [Q in keyof TObject]: TObject[Q] extends Record<string, unknown> ? CompiledStyles<TObject[Q]> : CompiledPropertyDeclarationReference & TObject[Q];
34
39
  };
35
40
  /**
36
41
  * Please think twice before using this type, you're better off declaring explicitly
@@ -84,7 +89,7 @@ export type XCSSAllPseudos = CSSPseudos;
84
89
  * xcss?: XCSSProp<XCSSAllProperties, '&:hover'>;
85
90
  *
86
91
  * // The xcss prop is required as well as the color property. No pseudos are required.
87
- * xcss: XCSSProp<XCSSAllProperties, '&:hover', { requiredProperties: 'color', requiredPseudos: never }>;
92
+ * xcss: XCSSProp<XCSSAllProperties, '&:hover', { requiredProperties: 'color' }>;
88
93
  * }
89
94
  *
90
95
  * function MyComponent({ xcss }: MyComponentProps) {
@@ -106,14 +111,12 @@ export type XCSSAllPseudos = CSSPseudos;
106
111
  *
107
112
  * To concatenate and conditonally apply styles use the {@link cssMap} {@link cx} functions.
108
113
  */
109
- export type XCSSProp<TAllowedProperties extends keyof CSSProperties, TAllowedPseudos extends CSSPseudos, TRequiredProperties extends {
114
+ export type XCSSProp<TAllowedProperties extends keyof StrictCSSProperties, TAllowedPseudos extends CSSPseudos, TRequiredProperties extends {
110
115
  requiredProperties: TAllowedProperties;
111
- requiredPseudos: TAllowedPseudos;
112
- } = never> = Internal$XCSSProp<TAllowedProperties, TAllowedPseudos, object, TRequiredProperties>;
113
- export type Internal$XCSSProp<TAllowedProperties extends keyof CSSProperties, TAllowedPseudos extends CSSPseudos, TSchema, TRequiredProperties extends {
116
+ } = never> = Internal$XCSSProp<TAllowedProperties, TAllowedPseudos, string, object, TRequiredProperties, 'loose'>;
117
+ export type Internal$XCSSProp<TAllowedProperties extends keyof StrictCSSProperties, TAllowedPseudos extends CSSPseudos, TAllowedMediaQueries extends string, TSchema, TRequiredProperties extends {
114
118
  requiredProperties: TAllowedProperties;
115
- requiredPseudos: TAllowedPseudos;
116
- }> = (MarkAsRequired<XCSSItem<TAllowedProperties, TSchema>, TRequiredProperties['requiredProperties']> & MarkAsRequired<XCSSPseudos<TAllowedProperties, TAllowedPseudos, TRequiredProperties, TSchema>, TRequiredProperties['requiredPseudos']> & BlockedRules) | false | null | undefined;
119
+ }, TMode extends 'loose' | 'strict'> = (MarkAsRequired<XCSSValue<TAllowedProperties, TSchema, ''>, TRequiredProperties['requiredProperties']> & XCSSPseudo<TAllowedProperties, TAllowedPseudos, TRequiredProperties, TSchema> & XCSSMediaQuery<TAllowedProperties, TAllowedPseudos, TAllowedMediaQueries, TSchema> & BlockedRules<TMode>) | false | null | undefined;
117
120
  /**
118
121
  * ## CX
119
122
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/xcss-prop/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAoKhC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,CAChB,GAAG,MAAe,EACD,EAAE;IACnB,2EAA2E;IAC3E,sDAAsD;IACtD,MAAM,YAAY,GAAG,MAA6B,CAAC;IAEnD,+EAA+E;IAC/E,kFAAkF;IAClF,OAAO,EAAE,CAAC,YAAY,CAAoB,CAAC;AAC7C,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/xcss-prop/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAsLhC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,CAChB,GAAG,MAAe,EACD,EAAE;IACnB,2EAA2E;IAC3E,sDAAsD;IACtD,MAAM,YAAY,GAAG,MAA6B,CAAC;IAEnD,+EAA+E;IAC/E,kFAAkF;IAClF,OAAO,EAAE,CAAC,YAAY,CAAoB,CAAC;AAC7C,CAAC,CAAC"}
@@ -1,20 +1,18 @@
1
- import type { StrictCSSProperties, CSSPseudos } from '../types';
1
+ import type { StrictCSSProperties, CSSPseudos, CSSProps } from '../types';
2
2
  import { type CompiledStyles, cx, type Internal$XCSSProp } from '../xcss-prop';
3
- type PseudosDeclarations = {
4
- [Q in CSSPseudos]?: StrictCSSProperties;
5
- };
6
- type EnforceSchema<TSchema> = {
7
- [P in keyof TSchema]?: P extends keyof CompiledSchema ? TSchema[P] extends Record<string, any> ? EnforceSchema<TSchema[P]> : TSchema[P] : never;
8
- };
9
- type CSSStyles<TSchema extends CompiledSchema> = StrictCSSProperties & PseudosDeclarations & EnforceSchema<TSchema>;
10
- type CSSMapStyles<TSchema extends CompiledSchema> = Record<string, CSSStyles<TSchema>>;
11
- interface CompiledAPI<TSchema extends CompiledSchema> {
3
+ import type { AllowedStyles, ApplySchema, ApplySchemaMap, CompiledSchemaShape } from './types';
4
+ export interface StrictOptions {
5
+ media: string;
6
+ }
7
+ export interface CompiledAPI<TSchema extends CompiledSchemaShape, TAllowedMediaQueries extends string> {
12
8
  /**
13
9
  * ## CSS
14
10
  *
15
11
  * Creates styles that are statically typed and useable with other Compiled APIs.
16
12
  * For further details [read the documentation](https://compiledcssinjs.com/docs/api-css).
17
13
  *
14
+ * This API does not currently work with XCSS prop.
15
+ *
18
16
  * @example
19
17
  * ```
20
18
  * const redText = css({
@@ -24,7 +22,7 @@ interface CompiledAPI<TSchema extends CompiledSchema> {
24
22
  * <div css={redText} />
25
23
  * ```
26
24
  */
27
- css(styles: CSSStyles<TSchema>): StrictCSSProperties;
25
+ css<TStyles extends ApplySchema<TStyles, TSchema>>(styles: AllowedStyles<TAllowedMediaQueries> & TStyles): CSSProps<unknown>;
28
26
  /**
29
27
  * ## CSS Map
30
28
  *
@@ -41,7 +39,7 @@ interface CompiledAPI<TSchema extends CompiledSchema> {
41
39
  * <div css={styles.solid} />
42
40
  * ```
43
41
  */
44
- cssMap<TStylesMap extends CSSMapStyles<TSchema>>(styles: CSSMapStyles<TSchema> & TStylesMap): {
42
+ cssMap<TObject extends Record<string, AllowedStyles<TAllowedMediaQueries>>, TStylesMap extends ApplySchemaMap<TObject, TSchema>>(styles: Record<string, AllowedStyles<TAllowedMediaQueries>> & TStylesMap): {
45
43
  readonly [P in keyof TStylesMap]: CompiledStyles<TStylesMap[P]>;
46
44
  };
47
45
  /**
@@ -99,7 +97,7 @@ interface CompiledAPI<TSchema extends CompiledSchema> {
99
97
  * typeof XCSSProp<
100
98
  * XCSSAllProperties,
101
99
  * '&:hover',
102
- * { requiredProperties: 'color', requiredPseudos: never }
100
+ * { requiredProperties: 'color' }
103
101
  * >
104
102
  * >;
105
103
  * }
@@ -124,10 +122,8 @@ interface CompiledAPI<TSchema extends CompiledSchema> {
124
122
  */
125
123
  XCSSProp<TAllowedProperties extends keyof StrictCSSProperties, TAllowedPseudos extends CSSPseudos, TRequiredProperties extends {
126
124
  requiredProperties: TAllowedProperties;
127
- requiredPseudos: TAllowedPseudos;
128
- } = never>(): Internal$XCSSProp<TAllowedProperties, TAllowedPseudos, TSchema, TRequiredProperties>;
125
+ } = never>(): Internal$XCSSProp<TAllowedProperties, TAllowedPseudos, TAllowedMediaQueries, TSchema, TRequiredProperties, 'strict'>;
129
126
  }
130
- type CompiledSchema = StrictCSSProperties & PseudosDeclarations;
131
127
  /**
132
128
  * ## Create Strict API
133
129
  *
@@ -142,17 +138,19 @@ type CompiledSchema = StrictCSSProperties & PseudosDeclarations;
142
138
  *
143
139
  * To set up:
144
140
  *
145
- * 1. Declare the API in a module (either local or in a package):
141
+ * 1. Declare the API in a module (either local or in a package), optionally declaring accepted media queries.
146
142
  *
147
143
  * @example
148
144
  * ```tsx
149
145
  * // ./foo.ts
150
- * const { css } = createStrictAPI<{
146
+ * interface Schema {
151
147
  * color: 'var(--ds-text)',
152
148
  * '&:hover': { color: 'var(--ds-text-hover)' }
153
- * }>();
149
+ * }
150
+ *
151
+ * const { css, cssMap, XCSSProp, cx } = createStrictAPI<Schema, { media: '(min-width: 30rem)' }>();
154
152
  *
155
- * export { css };
153
+ * export { css, cssMap, XCSSProp, cx };
156
154
  * ```
157
155
  *
158
156
  * 2. Configure Compiled to pick up this module:
@@ -176,5 +174,4 @@ type CompiledSchema = StrictCSSProperties & PseudosDeclarations;
176
174
  * <div css={styles} />
177
175
  * ```
178
176
  */
179
- export declare function createStrictAPI<TSchema extends CompiledSchema>(): CompiledAPI<TSchema>;
180
- export {};
177
+ export declare function createStrictAPI<TSchema extends CompiledSchemaShape, TCreateStrictAPIOptions extends StrictOptions = never>(): CompiledAPI<TSchema, TCreateStrictAPIOptions['media']>;
@@ -17,17 +17,19 @@ const xcss_prop_1 = require("../xcss-prop");
17
17
  *
18
18
  * To set up:
19
19
  *
20
- * 1. Declare the API in a module (either local or in a package):
20
+ * 1. Declare the API in a module (either local or in a package), optionally declaring accepted media queries.
21
21
  *
22
22
  * @example
23
23
  * ```tsx
24
24
  * // ./foo.ts
25
- * const { css } = createStrictAPI<{
25
+ * interface Schema {
26
26
  * color: 'var(--ds-text)',
27
27
  * '&:hover': { color: 'var(--ds-text-hover)' }
28
- * }>();
28
+ * }
29
+ *
30
+ * const { css, cssMap, XCSSProp, cx } = createStrictAPI<Schema, { media: '(min-width: 30rem)' }>();
29
31
  *
30
- * export { css };
32
+ * export { css, cssMap, XCSSProp, cx };
31
33
  * ```
32
34
  *
33
35
  * 2. Configure Compiled to pick up this module:
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/create-strict-api/index.ts"],"names":[],"mappings":";;;AACA,0CAAwD;AACxD,4CAA+E;AAuJ/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,SAAgB,eAAe;IAC7B,OAAO;QACL,GAAG;YACD,MAAM,IAAA,8BAAsB,GAAE,CAAC;QACjC,CAAC;QACD,MAAM;YACJ,MAAM,IAAA,8BAAsB,GAAE,CAAC;QACjC,CAAC;QACD,EAAE,EAAF,cAAE;QACF,QAAQ;YACN,MAAM,IAAA,8BAAsB,GAAE,CAAC;QACjC,CAAC;KACF,CAAC;AACJ,CAAC;AAbD,0CAaC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/create-strict-api/index.ts"],"names":[],"mappings":";;;AACA,0CAAwD;AACxD,4CAA+E;AAyJ/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,SAAgB,eAAe;IAI7B,OAAO;QACL,GAAG;YACD,MAAM,IAAA,8BAAsB,GAAE,CAAC;QACjC,CAAC;QACD,MAAM;YACJ,MAAM,IAAA,8BAAsB,GAAE,CAAC;QACjC,CAAC;QACD,EAAE,EAAF,cAAE;QACF,QAAQ;YACN,MAAM,IAAA,8BAAsB,GAAE,CAAC;QACjC,CAAC;KACF,CAAC;AACJ,CAAC;AAhBD,0CAgBC"}
@@ -0,0 +1,28 @@
1
+ import type { StrictCSSProperties, CSSPseudoClasses, CSSPseudoElements, CSSPseudos } from '../types';
2
+ /**
3
+ * This is the shape of the generic object that `createStrictAPI()` takes.
4
+ * It's deliberately a subset of `AllowedStyles` and does not take at rules
5
+ * and pseudo elements.
6
+ */
7
+ export type CompiledSchemaShape = StrictCSSProperties & {
8
+ [Q in CSSPseudoClasses]?: StrictCSSProperties;
9
+ };
10
+ export type PseudosDeclarations = {
11
+ [Q in CSSPseudos]?: StrictCSSProperties;
12
+ };
13
+ export type MediaQueries<TMediaQuery extends string> = {
14
+ [Q in `@media ${TMediaQuery}`]?: StrictCSSProperties & PseudosDeclarations;
15
+ };
16
+ export type AllowedStyles<TMediaQuery extends string> = StrictCSSProperties & PseudosDeclarations & MediaQueries<TMediaQuery>;
17
+ export type ApplySchemaValue<TSchema, TKey extends keyof StrictCSSProperties, TPseudoKey extends CSSPseudoClasses | ''> = TKey extends keyof TSchema ? TPseudoKey extends keyof TSchema ? TKey extends keyof TSchema[TPseudoKey] ? TSchema[TPseudoKey][TKey] : TSchema[TKey] : TSchema[TKey] : StrictCSSProperties[TKey];
18
+ /**
19
+ * Recursively maps over object properties to resolve them to either a {@link TSchema}
20
+ * value if present, else fallback to its value from {@link StrictCSSProperties}. If
21
+ * the property isn't a known property its value will be resolved to `never`.
22
+ */
23
+ export type ApplySchema<TObject, TSchema, TPseudoKey extends CSSPseudoClasses | '' = ''> = {
24
+ [TKey in keyof TObject]?: TKey extends keyof StrictCSSProperties ? ApplySchemaValue<TSchema, TKey, TPseudoKey> : TKey extends CSSPseudoClasses ? ApplySchema<TObject[TKey], TSchema, TKey> : TKey extends `@${string}` | CSSPseudoElements ? ApplySchema<TObject[TKey], TSchema> : never;
25
+ };
26
+ export type ApplySchemaMap<TStylesMap, TSchema> = {
27
+ [P in keyof TStylesMap]: ApplySchema<TStylesMap[P], TSchema>;
28
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/create-strict-api/types.ts"],"names":[],"mappings":""}
@@ -5,6 +5,8 @@ import type { CSSProps, CssObject, CssFunction } from '../types';
5
5
  * Create styles that are statically typed and useable with other Compiled APIs.
6
6
  * For further details [read the documentation](https://compiledcssinjs.com/docs/api-css).
7
7
  *
8
+ * This API does not currently work with XCSS prop.
9
+ *
8
10
  * ### Style with objects
9
11
  *
10
12
  * @example
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;;AAGlC,0CAAkD;AAyClD,SAAwB,GAAG,CACzB,OAA6D,EAC7D,GAAG,eAA8B;IAEjC,MAAM,IAAA,wBAAgB,GAAE,CAAC;AAC3B,CAAC;AALD,sBAKC"}
@@ -77,6 +77,19 @@ type ExtendedSelectors = {
77
77
  */
78
78
  selectors?: ExtendedSelector;
79
79
  };
80
+ type LooseMediaQueries = Record<`@media ${string}`, CSSProperties & AllPseudos>;
81
+ /**
82
+ * We remap media query keys to `"@media"` so it's blocked inside the strict APIs.
83
+ * This is done as it's currently impossible to ensure type safety end-to-end — when
84
+ * passing in unknown media queries from the loose API into the strict API you end up
85
+ * being also able to pass any styles you want, which makes the whole point of the strict
86
+ * API meaningless.
87
+ *
88
+ * Sorry folks!
89
+ */
90
+ type RemapMedia<TStyles> = {
91
+ [Q in keyof TStyles as Q extends `@media ${string}` ? '@media [loose]' : Q]: TStyles[Q];
92
+ };
80
93
  /**
81
94
  * ## CSS Map
82
95
  *
@@ -93,7 +106,7 @@ type ExtendedSelectors = {
93
106
  * <div css={styles.solid} />
94
107
  * ```
95
108
  */
96
- export default function cssMap<TStyles extends Record<string, CSSProperties & WhitelistedSelector & ExtendedSelectors>>(_styles: TStyles): {
97
- readonly [P in keyof TStyles]: CompiledStyles<TStyles[P]>;
109
+ export default function cssMap<TStyles extends Record<string, CSSProperties & WhitelistedSelector & ExtendedSelectors & LooseMediaQueries>>(_styles: TStyles): {
110
+ readonly [P in keyof TStyles]: CompiledStyles<RemapMedia<TStyles[P]>>;
98
111
  };
99
112
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css-map/index.ts"],"names":[],"mappings":";;AAGA,0CAAkD;AAkFlD;;;;;;;;;;;;;;;GAeG;AACH,SAAwB,MAAM,CAG5B,OAAgB;IAIhB,MAAM,IAAA,wBAAgB,GAAE,CAAC;AAC3B,CAAC;AARD,yBAQC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css-map/index.ts"],"names":[],"mappings":";;AAGA,0CAAkD;AAiGlD;;;;;;;;;;;;;;;GAeG;AACH,SAAwB,MAAM,CAM5B,OAAgB;IAIhB,MAAM,IAAA,wBAAgB,GAAE,CAAC;AAC3B,CAAC;AAXD,yBAWC"}
@@ -2,12 +2,13 @@ import { createElement } from 'react';
2
2
  import type { CompiledJSX } from './jsx/jsx-local-namespace';
3
3
  export { ClassNames } from './class-names';
4
4
  export { createStrictAPI } from './create-strict-api';
5
+ export type { PseudosDeclarations, MediaQueries, AllowedStyles, ApplySchema, ApplySchemaMap, } from './create-strict-api/types';
5
6
  export { default as css } from './css';
6
7
  export { default as cssMap } from './css-map';
7
8
  export { keyframes } from './keyframes';
8
- export { styled } from './styled';
9
+ export { styled, StyledProps } from './styled';
9
10
  export type { CSSProperties, CSSProps, CSSPseudos, CssFunction, CssType, StrictCSSProperties, } from './types';
10
- export { type XCSSAllProperties, type XCSSAllPseudos, type XCSSProp, cx } from './xcss-prop';
11
+ export { type XCSSAllProperties, type XCSSAllPseudos, type XCSSProp, type CompiledStyles, type Internal$XCSSProp, cx, } from './xcss-prop';
11
12
  export declare const jsx: typeof createElement;
12
13
  export declare namespace jsx {
13
14
  namespace JSX {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,iCAAsC;AAItC,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,yDAAsD;AAA7C,oHAAA,eAAe,OAAA;AACxB,6BAAuC;AAA9B,2GAAA,OAAO,OAAO;AACvB,qCAA8C;AAArC,kHAAA,OAAO,OAAU;AAC1B,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AASf,yCAA6F;AAAxB,+FAAA,EAAE,OAAA;AAEvE,0CAA0C;AAC1C,kGAAkG;AACrF,QAAA,GAAG,GAAG,qBAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,iCAAsC;AAItC,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,yDAAsD;AAA7C,oHAAA,eAAe,OAAA;AAQxB,6BAAuC;AAA9B,2GAAA,OAAO,OAAO;AACvB,qCAA8C;AAArC,kHAAA,OAAO,OAAU;AAC1B,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,mCAA+C;AAAtC,gGAAA,MAAM,OAAA;AASf,yCAOqB;AADnB,+FAAA,EAAE,OAAA;AAGJ,0CAA0C;AAC1C,kGAAkG;AACrF,QAAA,GAAG,GAAG,qBAAa,CAAC"}
@@ -18,14 +18,16 @@ export type CssObject<TProps> = Readonly<{
18
18
  [key: string]: CssFunction<TProps>;
19
19
  }>;
20
20
  export type CssFunction<TProps = unknown> = CssType<TProps> | BasicTemplateInterpolations | null | boolean | undefined;
21
- export type CSSPseudos = '&::after' | '&::backdrop' | '&::before' | '&::cue' | '&::cue-region' | '&::first-letter' | '&::first-line' | '&::grammar-error' | '&::marker' | '&::placeholder' | '&::selection' | '&::spelling-error' | '&::target-text' | '&::view-transition' | '&:active' | '&:autofill' | '&:blank' | '&:checked' | '&:default' | '&:defined' | '&:disabled' | '&:empty' | '&:enabled' | '&:first' | '&:focus' | '&:focus-visible' | '&:focus-within' | '&:fullscreen' | '&:hover' | '&:in-range' | '&:indeterminate' | '&:invalid' | '&:left' | '&:link' | '&:local-link' | '&:optional' | '&:out-of-range' | '&:paused' | '&:picture-in-picture' | '&:placeholder-shown' | '&:playing' | '&:read-only' | '&:read-write' | '&:required' | '&:right' | '&:target' | '&:user-invalid' | '&:user-valid' | '&:valid' | '&:visited';
21
+ export type CSSPseudoElements = '&::after' | '&::backdrop' | '&::before' | '&::cue' | '&::cue-region' | '&::first-letter' | '&::first-line' | '&::grammar-error' | '&::marker' | '&::placeholder' | '&::selection' | '&::spelling-error' | '&::target-text' | '&::view-transition';
22
+ export type CSSPseudoClasses = '&:active' | '&:autofill' | '&:blank' | '&:checked' | '&:default' | '&:defined' | '&:disabled' | '&:empty' | '&:enabled' | '&:first' | '&:focus' | '&:focus-visible' | '&:focus-within' | '&:fullscreen' | '&:hover' | '&:in-range' | '&:indeterminate' | '&:invalid' | '&:left' | '&:link' | '&:local-link' | '&:optional' | '&:out-of-range' | '&:paused' | '&:picture-in-picture' | '&:placeholder-shown' | '&:playing' | '&:read-only' | '&:read-write' | '&:required' | '&:right' | '&:target' | '&:user-invalid' | '&:user-valid' | '&:valid' | '&:visited';
23
+ export type CSSPseudos = CSSPseudoElements | CSSPseudoClasses;
22
24
  /**
23
25
  * The XCSSProp must be given all known available properties even
24
26
  * if it takes a subset of them. This ensures the (lack-of an)
25
27
  * excess property check doesn't enable makers to circumvent the
26
28
  * system and pass in values they shouldn't.
27
29
  */
28
- export type CSSProperties = Readonly<CSS.Properties<string | number>>;
30
+ export type CSSProperties = Readonly<CSS.Properties<(string & object) | number>>;
29
31
  /**
30
32
  * A stricter subset of the {@link CSSProperties} type that excludes
31
33
  * vendor and obsolete properties.