@codecademy/variance 0.26.2-alpha.01c84d.0 → 0.26.2-alpha.030f51.0

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/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export { variance } from './core';
2
2
  export * from './createTheme';
3
3
  export * from './types/props';
4
- export type { Scale } from './types/config';
5
4
  export * from './transforms';
6
5
  export * from './scales/createScale';
7
6
  export * from './getPropertyMode';
@@ -15,6 +15,13 @@ export interface Prop extends BaseProperty {
15
15
  scale?: keyof Theme | MapScale | ArrayScale;
16
16
  transform?: (val: string | number, prop?: string, props?: AbstractProps) => string | number | CSSObject;
17
17
  resolveProperty?: (useLogicalProperties: boolean) => PropertyMode;
18
+ /**
19
+ * Keep the raw CSS-value escape hatch (arbitrary numbers, globals) available on a
20
+ * scale-backed prop, alongside the scale's token names. Without this a scale-backed prop
21
+ * is token-only. Runtime is unaffected — the parser already falls back to the raw value
22
+ * for anything that isn't a scale token; this only widens the accepted type.
23
+ */
24
+ allowRawValue?: boolean;
18
25
  }
19
26
  export interface AbstractPropTransformer extends Prop {
20
27
  prop: string;
@@ -27,10 +34,13 @@ export interface AbstractParser {
27
34
  }
28
35
  export type PropertyValues<Property extends keyof PropertyTypes, All extends boolean = false> = Exclude<PropertyTypes<All extends true ? DefaultCSSPropertyValue : never>[Property], All extends true ? never : object | any[]>;
29
36
  type BasePropertyKey<P> = P extends DirectionalProperty ? P['physical'] : P;
30
- export type ScaleValue<Config extends Prop> = Config['scale'] extends keyof Theme ? keyof Theme[Config['scale']] | PropertyValues<BasePropertyKey<Config['property']>> : Config['scale'] extends MapScale ? keyof Config['scale'] | PropertyValues<BasePropertyKey<Config['property']>> : Config['scale'] extends ArrayScale ? Config['scale'][number] | PropertyValues<BasePropertyKey<Config['property']>> : PropertyValues<BasePropertyKey<Config['property']>, true>;
37
+ type RawValueEscapeHatch<Config extends Prop> = Config extends {
38
+ allowRawValue: true;
39
+ } ? PropertyValues<BasePropertyKey<Config['property']>, true> : never;
40
+ export type ScaleValue<Config extends Prop> = Config['scale'] extends keyof Theme ? keyof Theme[Config['scale']] | PropertyValues<BasePropertyKey<Config['property']>> | RawValueEscapeHatch<Config> : Config['scale'] extends MapScale ? keyof Config['scale'] | PropertyValues<BasePropertyKey<Config['property']>> | RawValueEscapeHatch<Config> : Config['scale'] extends ArrayScale ? Config['scale'][number] | PropertyValues<BasePropertyKey<Config['property']>> | RawValueEscapeHatch<Config> : PropertyValues<BasePropertyKey<Config['property']>, true>;
31
41
  export type Scale<Config extends Prop> = ResponsiveProp<ScaleValue<Config> | ((theme: Theme) => ScaleValue<Config>)>;
32
42
  export interface TransformFn<P extends string, Config extends Prop> {
33
- (value: Scale<Config>, prop: P, props: ThemeProps<{
43
+ (value: Scale<Config> | Scale<Config>, prop: P, props: ThemeProps<{
34
44
  [K in P]?: Scale<Config>;
35
45
  }>): CSSObject;
36
46
  }
@@ -4,7 +4,7 @@ import { Breakpoints } from '../types/theme';
4
4
  /**
5
5
  * Destructures the themes breakpoints into an ordered structure to traverse
6
6
  */
7
- export declare const parseBreakpoints: (breakpoints?: Breakpoints) => BreakpointCache | null;
7
+ export declare const parseBreakpoints: (breakpoints?: Breakpoints | undefined) => BreakpointCache | null;
8
8
  export declare const isMediaArray: (val: unknown) => val is (string | number)[];
9
9
  export declare const isMediaMap: (val: object) => val is BreakpointMap<string | number>;
10
10
  interface ResponsiveParser<Bp extends BreakpointMap<string | number> | (string | number)[]> {
package/package.json CHANGED
@@ -1,19 +1,12 @@
1
1
  {
2
2
  "name": "@codecademy/variance",
3
3
  "description": "Constraint based CSS in JS for building scalable design systems",
4
- "version": "0.26.2-alpha.01c84d.0",
4
+ "version": "0.26.2-alpha.030f51.0",
5
5
  "author": "codecaaron <aaron@codecademy.com>",
6
6
  "dependencies": {
7
7
  "csstype": "^3.0.7",
8
8
  "lodash": "^4.17.23"
9
9
  },
10
- "exports": {
11
- ".": {
12
- "import": "./dist/index.js",
13
- "types": "./dist/index.d.ts",
14
- "default": "./dist/index.js"
15
- }
16
- },
17
10
  "files": [
18
11
  "dist"
19
12
  ],
@@ -26,6 +19,7 @@
26
19
  ],
27
20
  "license": "MIT",
28
21
  "main": "dist/index.js",
22
+ "module": "dist/index.js",
29
23
  "peerDependencies": {
30
24
  "@emotion/react": "*",
31
25
  "typescript": ">=4.3.5"
@@ -37,5 +31,5 @@
37
31
  "scripts": {
38
32
  "build": "nx build @codecademy/variance"
39
33
  },
40
- "type": "module"
34
+ "types": "dist/index.d.ts"
41
35
  }