@pandacss/types
Advanced tools
Comparing version 0.0.0-dev-20230109182737 to 0.0.0-dev-20230110150257
@@ -0,6 +1,4 @@ | ||
import type { Recursive } from './shared' | ||
import type { CompositionStyleObject } from './system-types' | ||
import type { LiteralUnion, Recursive } from './shared' | ||
type Cond = Record<string, string> | ||
export type Token<Value = any> = { | ||
@@ -15,3 +13,3 @@ value: Value | ||
type TextStyleProperty = LiteralUnion< | ||
type TextStyleProperty = | ||
| 'fontSize' | ||
@@ -45,7 +43,6 @@ | 'fontSizeAdjust' | ||
| 'textRendering' | ||
> | ||
export type TextStyle<Conditions extends Cond = {}> = CompositionStyleObject<Conditions, TextStyleProperty> | ||
export type TextStyle = CompositionStyleObject<TextStyleProperty> | ||
export type TextStyles<T extends Cond = {}> = Recursive<Token<TextStyle<T>>> | ||
export type TextStyles = Recursive<Token<TextStyle>> | ||
@@ -74,3 +71,3 @@ /* ----------------------------------------------------------------------------- | ||
type LayerStyleProperty = LiteralUnion< | ||
type LayerStyleProperty = | ||
| 'background' | ||
@@ -104,5 +101,10 @@ | 'backgroundColor' | ||
| `padding${Placement}` | ||
> | ||
export type LayerStyle<Conditions extends Cond = {}> = CompositionStyleObject<Conditions, LayerStyleProperty> | ||
export type LayerStyles<Conditions extends Cond = {}> = Recursive<Token<LayerStyle<Conditions>>> | ||
export type LayerStyle = CompositionStyleObject<LayerStyleProperty> | ||
export type LayerStyles = Recursive<Token<LayerStyle>> | ||
export type CompositionStyles = { | ||
textStyles: TextStyles | ||
layerStyles: LayerStyles | ||
} |
@@ -0,1 +1,2 @@ | ||
import type { AnySelector, Selectors } from './selectors' | ||
import type { Dict, StringKeyOf } from './shared' | ||
@@ -14,2 +15,11 @@ | ||
export type ExtractConditions<Conditions extends Dict, Breakpoints extends Dict> = | ||
| StringKeyOf<Breakpoints> | ||
| StringKeyOf<Conditions> | ||
| 'base' | ||
/* ----------------------------------------------------------------------------- | ||
* Shadowed export (in CLI): DO NOT REMOVE | ||
* -----------------------------------------------------------------------------*/ | ||
export type Conditions = { | ||
@@ -19,9 +29,21 @@ [condition: string]: string | ||
export type RecursiveCondition<T extends string, C extends string> = | ||
| T | ||
| { [K in C]?: RecursiveCondition<T, Exclude<C, K>> } | ||
export type Condition = string | ||
export type ExtractConditions<Conditions extends Dict, Breakpoints extends Dict> = | ||
| StringKeyOf<Breakpoints> | ||
| StringKeyOf<Conditions> | ||
| 'base' | ||
export type Conditional<V> = | ||
| V | ||
| Array<V | null> | ||
| { | ||
[K in keyof Conditions]?: Conditional<V> | ||
} | ||
export type ConditionalValue<T> = Conditional<T> | ||
export type Nested<P> = | ||
| (P & { | ||
[K in Selectors]?: Nested<P> | ||
} & { | ||
[K in AnySelector]?: Nested<P> | ||
}) | ||
| { | ||
[K in Condition]?: Nested<P> | ||
} |
@@ -1,8 +0,8 @@ | ||
export type { ConditionDetails, ConditionType, Conditions, RawCondition, RecursiveCondition } from './conditions' | ||
export type { ConditionDetails, ConditionType, Conditions, RawCondition } from './conditions' | ||
export type { Config, UserConfig } from './config' | ||
export type { PropertyConfig, PropertyTransform, PropertyValues, UtilityConfig } from './utility' | ||
export type { StyleObject, CssKeyframes } from './system-types' | ||
export type { SystemStyleObject, CssKeyframes } from './system-types' | ||
export type { PatternConfig, PatternProperty, PatternHelpers } from './pattern' | ||
export type { RecipeConfig, RecipeVariant } from './recipe' | ||
export type { TextStyles, LayerStyles } from './composition' | ||
export type { TextStyles, LayerStyles, CompositionStyles } from './composition' | ||
export type { Token, TokenCategory, TokenDataTypes, Tokens, SemanticToken, SemanticTokens } from './tokens' | ||
@@ -9,0 +9,0 @@ export type { Dict, RequiredBy, AnyFunction } from './shared' |
@@ -1,2 +0,2 @@ | ||
import type { NativeCssProperty, StyleObject } from './system-types' | ||
import type { NativeCssProperty, SystemStyleObject } from './system-types' | ||
import type { TokenCategory } from './tokens' | ||
@@ -26,3 +26,3 @@ | ||
*/ | ||
transform?: (props: Record<string, any>, helpers: PatternHelpers) => StyleObject | ||
transform?: (props: Record<string, any>, helpers: PatternHelpers) => SystemStyleObject | ||
/** | ||
@@ -37,2 +37,7 @@ * The jsx element name this pattern will generate. | ||
strict?: boolean | ||
/** | ||
* @experimental | ||
* Disallow certain css properties for this pattern | ||
*/ | ||
blocklist?: NativeCssProperty[] | ||
} |
@@ -1,5 +0,5 @@ | ||
import type { StyleObject } from './system-types' | ||
import type { SystemStyleObject } from './system-types' | ||
export type RecipeVariant = { | ||
[variant: string]: StyleObject | ||
[variant: string]: SystemStyleObject | ||
} | ||
@@ -21,3 +21,3 @@ | ||
*/ | ||
base?: StyleObject | ||
base?: SystemStyleObject | ||
/** | ||
@@ -24,0 +24,0 @@ * The multi-variant styles of the recipe. |
@@ -1,62 +0,8 @@ | ||
import type * as CSS from './csstype' | ||
import type { Conditional, ConditionalValue, Conditions, Nested } from './conditions' | ||
import type { PropertiesFallback } from './csstype' | ||
import type { SystemProperties } from './style-props' | ||
type Dict = Record<string, unknown> | ||
type String = string & {} | ||
type Number = number & {} | ||
type AriaAttributes = | ||
| '[aria-disabled]' | ||
| '[aria-hidden]' | ||
| '[aria-invalid]' | ||
| '[aria-readonly]' | ||
| '[aria-required]' | ||
| '[aria-selected]' | ||
| '[aria-checked]' | ||
| '[aria-expanded]' | ||
| '[aria-pressed]' | ||
| `[aria-current=${'page' | 'step' | 'location' | 'date' | 'time'}]` | ||
| '[aria-invalid]' | ||
| `[aria-sort=${'ascending' | 'descending'}]` | ||
type DataAttributes = | ||
| '[data-selected]' | ||
| '[data-highlighted]' | ||
| '[data-hover]' | ||
| '[data-active]' | ||
| '[data-checked]' | ||
| '[data-disabled]' | ||
| '[data-readonly]' | ||
| '[data-focus]' | ||
| '[data-focus-visible]' | ||
| '[data-focus-visible-added]' | ||
| '[data-invalid]' | ||
| '[data-pressed]' | ||
| '[data-expanded]' | ||
| '[data-grabbed]' | ||
| '[data-dragged]' | ||
| '[data-orientation=horizontal]' | ||
| '[data-orientation=vertical]' | ||
| '[data-in-range]' | ||
| '[data-out-of-range]' | ||
| '[data-placeholder-shown]' | ||
| `[data-part=${string}]` | ||
| `[data-attr=${string}]` | ||
| `[data-placement=${string}]` | ||
| `[data-theme=${string}]` | ||
| `[data-size=${string}]` | ||
| `[data-state=${string}]` | ||
| '[data-empty]' | ||
| '[data-loading]' | ||
| '[data-loaded]' | ||
| '[data-enter]' | ||
| '[data-entering]' | ||
| '[data-exited]' | ||
| '[data-exiting]' | ||
type AttributeSelector = `&${CSS.Pseudos | DataAttributes | AriaAttributes}` | ||
type ParentSelector = `${DataAttributes | AriaAttributes} &` | ||
type AnySelector = `${string}&` | `&${string}` | ||
type Selectors = AttributeSelector | ParentSelector | ||
type ContainerProperties = { | ||
@@ -76,3 +22,3 @@ container?: string | ||
export type NativeCssProperties = CSS.PropertiesFallback<String | Number> & ContainerProperties & CssVarProperties | ||
export type NativeCssProperties = PropertiesFallback<String | Number> & ContainerProperties | ||
@@ -93,100 +39,34 @@ export type NativeCssProperty = keyof NativeCssProperties | ||
type Cond = Record<string, string> | ||
export type Conditional<C extends Cond, V> = | ||
| V | ||
| Array<V | null> | ||
| { | ||
[K in keyof C]?: Conditional<C, V> | ||
} | ||
type Nested<C extends Cond, P> = P & { | ||
[K in Selectors | keyof C]?: Nested<C, P> | ||
} & { | ||
[K in AnySelector]?: Nested<C, P> | ||
type MinimalNested<P> = { | ||
[K in keyof Conditions]?: Nested<P> | ||
} | ||
type MinimalNested<C extends Cond, P> = P & { | ||
[K in keyof C]?: Nested<C, P> | ||
type GenericProperties = { | ||
[key: string]: ConditionalValue<String | Number | boolean> | ||
} | ||
/* ----------------------------------------------------------------------------- | ||
* Mixed css properties (native + conditional + custom properties) | ||
C - condition record | ||
P - custom properties or utilities | ||
S - strict mode? true or false | ||
* Native css props | ||
* -----------------------------------------------------------------------------*/ | ||
type NativeCssValue<T> = T extends NativeCssProperty ? NativeCssProperties[T] : never | ||
export type NestedCssProperties = Nested<CssProperties> | ||
type NativeProperties<Conditions extends Cond, PropTypes extends Dict, Overrides extends Dict> = { | ||
[K in Exclude<NativeCssProperty, keyof PropTypes | keyof Overrides>]?: Conditional<Conditions, NativeCssProperties[K]> | ||
} | ||
export type SystemStyleObject = Nested<SystemProperties | GenericProperties> | ||
type CustomProperties< | ||
Conditions extends Cond, | ||
PropTypes extends Dict, | ||
StrictMode extends boolean, | ||
Overrides extends Dict, | ||
> = { | ||
[K in Exclude<keyof PropTypes, keyof Overrides>]?: Conditional< | ||
Conditions, | ||
true extends StrictMode ? PropTypes[K] : PropTypes[K] | NativeCssValue<K> | ||
> | ||
export type GlobalStyleObject = { | ||
[selector: string]: SystemStyleObject | ||
} | ||
type GenericProperties<Conditions extends Cond> = { | ||
[key: string]: Conditional<Conditions, boolean | String | Number | undefined> | ||
} | ||
export type CompositionStyleObject<Property extends string> = Nested<{ | ||
[K in Property]?: Conditional<K extends NativeCssProperty ? NativeCssProperties[K] : unknown> | ||
}> | ||
type MinimalCss<Conditions extends Cond, PropTypes extends Dict, StrictMode extends boolean, Overrides extends Dict> = | ||
| Partial<Overrides> & | ||
NativeProperties<Conditions, PropTypes, Overrides> & | ||
CustomProperties<Conditions, PropTypes, StrictMode, Overrides> | ||
type Css<Conditions extends Cond, PropTypes extends Dict, StrictMode extends boolean, Overrides extends Dict> = | ||
| MinimalCss<Conditions, PropTypes, StrictMode, Overrides> | ||
| GenericProperties<Conditions> | ||
/* ----------------------------------------------------------------------------- | ||
* Exported types | ||
* Jsx style props | ||
* -----------------------------------------------------------------------------*/ | ||
export type NestedCssProperties = Nested<{}, CssProperties> | ||
export type StyleObject< | ||
Conditions extends Cond = {}, | ||
PropTypes extends Dict = {}, | ||
StrictMode extends boolean = false, | ||
Overrides extends Dict = {}, | ||
> = Nested<Conditions, Css<Conditions, PropTypes, StrictMode, Overrides>> | ||
export type JsxStyleProps< | ||
Conditions extends Cond = {}, | ||
PropTypes extends Dict = {}, | ||
StrictMode extends boolean = false, | ||
Overrides extends Dict = {}, | ||
> = MinimalNested<Conditions, MinimalCss<Conditions, PropTypes, StrictMode, Overrides>> & { | ||
css?: StyleObject<Conditions, PropTypes, StrictMode, Overrides> | ||
sx?: StyleObject<Conditions, PropTypes, StrictMode, Overrides> | ||
} | ||
export type GlobalStyleObject< | ||
Conditions extends Cond = {}, | ||
PropTypes extends Dict = {}, | ||
StrictMode extends boolean = false, | ||
Overrides extends Dict = {}, | ||
> = { | ||
[selector: string]: StyleObject<Conditions, PropTypes, StrictMode, Overrides> | ||
} | ||
export type CompositionStyleObject<Conditions extends Cond, PropTypes> = Nested< | ||
Conditions, | ||
{ | ||
[K in Extract<PropTypes, string>]?: Conditional< | ||
Conditions, | ||
K extends NativeCssProperty ? NativeCssProperties[K] : unknown | ||
> | ||
export type JsxStyleProps = SystemProperties & | ||
MinimalNested<SystemStyleObject> & { | ||
css?: SystemStyleObject | ||
sx?: SystemStyleObject | ||
} | ||
> |
@@ -27,6 +27,18 @@ import type { Recursive } from './shared' | ||
type BorderStyle = | ||
| 'dashed' | ||
| 'dotted' | ||
| 'double' | ||
| 'groove' | ||
| 'hidden' | ||
| 'inset' | ||
| 'none' | ||
| 'outset' | ||
| 'ridge' | ||
| 'solid' | ||
type Border = { | ||
color: string | ||
width: string | number | ||
style: string | ||
style: BorderStyle | ||
} | ||
@@ -33,0 +45,0 @@ |
{ | ||
"name": "@pandacss/types", | ||
"version": "0.0.0-dev-20230109182737", | ||
"version": "0.0.0-dev-20230110150257", | ||
"description": "The types for css panda", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19
20478
880151