@codecademy/variance
0.26.10.26.2-alpha.a75830.0
~
Modified (2 files)
Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,8 +1,8 @@
{
"name": "@codecademy/variance",
"description": "Constraint based CSS in JS for building scalable design systems",
- "version": "0.26.1",
+ "version": "0.26.2-alpha.a75830.0",
"author": "codecaaron <[email protected]>",
"dependencies": {
"csstype": "^3.0.7",
"lodash": "^4.17.23" Index: package/dist/types/config.d.ts
===================================================================
--- package/dist/types/config.d.ts
+++ package/dist/types/config.d.ts
@@ -14,8 +14,15 @@
export interface Prop extends BaseProperty {
scale?: keyof Theme | MapScale | ArrayScale;
transform?: (val: string | number, prop?: string, props?: AbstractProps) => string | number | CSSObject;
resolveProperty?: (useLogicalProperties: boolean) => PropertyMode;
+ /**
+ * Keep the raw CSS-value escape hatch (arbitrary numbers, globals) available on a
+ * scale-backed prop, alongside the scale's token names. Without this a scale-backed prop
+ * is token-only. Runtime is unaffected — the parser already falls back to the raw value
+ * for anything that isn't a scale token; this only widens the accepted type.
+ */
+ allowRawValue?: boolean;
}
export interface AbstractPropTransformer extends Prop {
prop: string;
styleFn: (value: unknown, prop: string, props: AbstractProps) => CSSObject;
@@ -26,9 +33,12 @@
config: Record<string, AbstractPropTransformer>;
}
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[]>;
type BasePropertyKey<P> = P extends DirectionalProperty ? P['physical'] : P;
-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>;
+type RawValueEscapeHatch<Config extends Prop> = Config extends {
+ allowRawValue: true;
+} ? PropertyValues<BasePropertyKey<Config['property']>, true> : never;
+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>;
export type Scale<Config extends Prop> = ResponsiveProp<ScaleValue<Config> | ((theme: Theme) => ScaleValue<Config>)>;
export interface TransformFn<P extends string, Config extends Prop> {
(value: Scale<Config> | Scale<Config>, prop: P, props: ThemeProps<{
[K in P]?: Scale<Config>;