@compiled/react 0.16.1 → 0.16.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.
Files changed (56) hide show
  1. package/dist/browser/class-names/index.d.ts +1 -1
  2. package/dist/browser/create-strict-api/index.d.ts +181 -0
  3. package/dist/browser/create-strict-api/index.js +65 -0
  4. package/dist/browser/create-strict-api/index.js.map +1 -0
  5. package/dist/browser/css/index.d.ts +1 -1
  6. package/dist/browser/css-map/index.d.ts +3 -5
  7. package/dist/browser/css-map/index.js +3 -5
  8. package/dist/browser/css-map/index.js.map +1 -1
  9. package/dist/browser/index.d.ts +1 -0
  10. package/dist/browser/index.js +1 -0
  11. package/dist/browser/index.js.map +1 -1
  12. package/dist/browser/types.d.ts +7 -2
  13. package/dist/browser/xcss-prop/index.d.ts +14 -10
  14. package/dist/browser/xcss-prop/index.js +1 -1
  15. package/dist/browser/xcss-prop/index.js.map +1 -1
  16. package/dist/cjs/class-names/index.d.ts +1 -1
  17. package/dist/cjs/create-strict-api/index.d.ts +181 -0
  18. package/dist/cjs/create-strict-api/index.js +69 -0
  19. package/dist/cjs/create-strict-api/index.js.map +1 -0
  20. package/dist/cjs/css/index.d.ts +1 -1
  21. package/dist/cjs/css-map/index.d.ts +3 -5
  22. package/dist/cjs/css-map/index.js +3 -5
  23. package/dist/cjs/css-map/index.js.map +1 -1
  24. package/dist/cjs/index.d.ts +1 -0
  25. package/dist/cjs/index.js +3 -1
  26. package/dist/cjs/index.js.map +1 -1
  27. package/dist/cjs/types.d.ts +7 -2
  28. package/dist/cjs/xcss-prop/index.d.ts +14 -10
  29. package/dist/cjs/xcss-prop/index.js +1 -1
  30. package/dist/cjs/xcss-prop/index.js.map +1 -1
  31. package/dist/esm/class-names/index.d.ts +1 -1
  32. package/dist/esm/create-strict-api/index.d.ts +181 -0
  33. package/dist/esm/create-strict-api/index.js +65 -0
  34. package/dist/esm/create-strict-api/index.js.map +1 -0
  35. package/dist/esm/css/index.d.ts +1 -1
  36. package/dist/esm/css-map/index.d.ts +3 -5
  37. package/dist/esm/css-map/index.js +3 -5
  38. package/dist/esm/css-map/index.js.map +1 -1
  39. package/dist/esm/index.d.ts +1 -0
  40. package/dist/esm/index.js +1 -0
  41. package/dist/esm/index.js.map +1 -1
  42. package/dist/esm/types.d.ts +7 -2
  43. package/dist/esm/xcss-prop/index.d.ts +14 -10
  44. package/dist/esm/xcss-prop/index.js +1 -1
  45. package/dist/esm/xcss-prop/index.js.map +1 -1
  46. package/package.json +2 -1
  47. package/src/class-names/index.ts +1 -1
  48. package/src/create-strict-api/__tests__/__fixtures__/strict-api.ts +13 -0
  49. package/src/create-strict-api/__tests__/index.test.tsx +312 -0
  50. package/src/create-strict-api/__tests__/package.test.tsx +21 -0
  51. package/src/create-strict-api/index.ts +223 -0
  52. package/src/css/index.ts +1 -1
  53. package/src/css-map/index.ts +3 -5
  54. package/src/index.ts +1 -0
  55. package/src/types.ts +8 -2
  56. package/src/xcss-prop/index.ts +33 -10
@@ -84,9 +84,9 @@ type ExtendedSelectors = {
84
84
  };
85
85
 
86
86
  /**
87
- * ## cssMap
87
+ * ## CSS Map
88
88
  *
89
- * Creates a collection of named CSS rules that are statically typed and useable with other Compiled APIs.
89
+ * Creates a collection of named styles that are statically typed and useable with other Compiled APIs.
90
90
  * For further details [read the documentation](https://compiledcssinjs.com/docs/api-cssmap).
91
91
  *
92
92
  * @example
@@ -96,9 +96,7 @@ type ExtendedSelectors = {
96
96
  * solid: { borderStyle: 'solid' },
97
97
  * });
98
98
  *
99
- * const Component = ({ borderStyle }) => <div css={styles[borderStyle]} />
100
- *
101
- * <Component borderStyle="solid" />
99
+ * <div css={styles.solid} />
102
100
  * ```
103
101
  */
104
102
  export default function cssMap<
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ export { styled } from './styled';
10
10
  export { ClassNames } from './class-names';
11
11
  export { default as css } from './css';
12
12
  export { default as cssMap } from './css-map';
13
+ export { createStrictAPI } from './create-strict-api';
13
14
  export { type XCSSAllProperties, type XCSSAllPseudos, type XCSSProp, cx } from './xcss-prop';
14
15
 
15
16
  // Pass through the (classic) jsx runtime.
package/src/types.ts CHANGED
@@ -95,9 +95,15 @@ export type CSSPseudos =
95
95
  | '&:visited';
96
96
 
97
97
  /**
98
- * The xcss prop must be given all known available properties even
99
- * if it takes a subset of them. This is ensure the (lack-of an)
98
+ * The XCSSProp must be given all known available properties even
99
+ * if it takes a subset of them. This ensures the (lack-of an)
100
100
  * excess property check doesn't enable makers to circumvent the
101
101
  * system and pass in values they shouldn't.
102
102
  */
103
103
  export type CSSProperties = Readonly<CSS.Properties<string | number>>;
104
+
105
+ /**
106
+ * A stricter subset of the {@link CSSProperties} type that excludes
107
+ * vendor and obsolete properties.
108
+ */
109
+ export type StrictCSSProperties = Readonly<CSS.StandardProperties & CSS.SvgProperties>;
@@ -3,19 +3,30 @@ import type * as CSS from 'csstype';
3
3
  import { ac } from '../runtime';
4
4
  import type { CSSPseudos, CSSProperties } from '../types';
5
5
 
6
- type XCSSItem<TStyleDecl extends keyof CSSProperties> = {
6
+ type MarkAsRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
7
+
8
+ type XCSSItem<TStyleDecl extends keyof CSSProperties, TCompiledTypedProperty> = {
7
9
  [Q in keyof CSSProperties]: Q extends TStyleDecl
8
- ? CompiledPropertyDeclarationReference | string | number
10
+ ?
11
+ | CompiledPropertyDeclarationReference
12
+ | (Q extends keyof TCompiledTypedProperty ? TCompiledTypedProperty[Q] : CSSProperties[Q])
9
13
  : never;
10
14
  };
11
15
 
12
16
  type XCSSPseudos<
13
17
  TAllowedProperties extends keyof CSSProperties,
14
18
  TAllowedPseudos extends CSSPseudos,
15
- TRequiredProperties extends { requiredProperties: TAllowedProperties }
19
+ TRequiredProperties extends { requiredProperties: TAllowedProperties },
20
+ TCompiledTypedPseudo
16
21
  > = {
17
22
  [Q in CSSPseudos]?: Q extends TAllowedPseudos
18
- ? MarkAsRequired<XCSSItem<TAllowedProperties>, TRequiredProperties['requiredProperties']>
23
+ ? MarkAsRequired<
24
+ XCSSItem<
25
+ TAllowedProperties,
26
+ Q extends keyof TCompiledTypedPseudo ? TCompiledTypedPseudo[Q] : object
27
+ >,
28
+ TRequiredProperties['requiredProperties']
29
+ >
19
30
  : never;
20
31
  };
21
32
 
@@ -69,7 +80,7 @@ export type XCSSAllProperties = keyof CSSProperties;
69
80
  export type XCSSAllPseudos = CSSPseudos;
70
81
 
71
82
  /**
72
- * ## xcss prop
83
+ * ## XCSSProp
73
84
  *
74
85
  * Declare styles your component takes with all other styles marked as violations
75
86
  * by the TypeScript compiler. There are two primary use cases for xcss prop:
@@ -132,10 +143,24 @@ export type XCSSProp<
132
143
  requiredProperties: TAllowedProperties;
133
144
  requiredPseudos: TAllowedPseudos;
134
145
  } = never
146
+ > = Internal$XCSSProp<TAllowedProperties, TAllowedPseudos, object, object, TRequiredProperties>;
147
+
148
+ export type Internal$XCSSProp<
149
+ TAllowedProperties extends keyof CSSProperties,
150
+ TAllowedPseudos extends CSSPseudos,
151
+ TCompiledTypedProperty,
152
+ TCompiledTypedPseudo,
153
+ TRequiredProperties extends {
154
+ requiredProperties: TAllowedProperties;
155
+ requiredPseudos: TAllowedPseudos;
156
+ }
135
157
  > =
136
- | (MarkAsRequired<XCSSItem<TAllowedProperties>, TRequiredProperties['requiredProperties']> &
158
+ | (MarkAsRequired<
159
+ XCSSItem<TAllowedProperties, TCompiledTypedProperty>,
160
+ TRequiredProperties['requiredProperties']
161
+ > &
137
162
  MarkAsRequired<
138
- XCSSPseudos<TAllowedProperties, TAllowedPseudos, TRequiredProperties>,
163
+ XCSSPseudos<TAllowedProperties, TAllowedPseudos, TRequiredProperties, TCompiledTypedPseudo>,
139
164
  TRequiredProperties['requiredPseudos']
140
165
  > &
141
166
  BlockedRules)
@@ -143,10 +168,8 @@ export type XCSSProp<
143
168
  | null
144
169
  | undefined;
145
170
 
146
- type MarkAsRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
147
-
148
171
  /**
149
- * ## cx
172
+ * ## CX
150
173
  *
151
174
  * Use in conjunction with the {@link XCSSProp} to concatenate and conditionally apply
152
175
  * declared styles. Can only be used with the `cssMap()` and {@link XCSSProp} APIs.