deploy: v0.12 fix 存档key名

This commit is contained in:
2026-06-24 03:09:02 +00:00
parent 7a08d49fe3
commit e0a5281119
58743 changed files with 7297269 additions and 39505 deletions
+64
View File
@@ -0,0 +1,64 @@
# @stitches/core
**@stitches/core** is a framework-agnostic implementation of [stitches](https://stitches.dev), a CSS-in-JS library with a best-in-class developer experience.
<p><br /></p>
```sh
# with npm
npm install @stitches/core
# with yarn
yarn add @stitches/core
```
<p><br /></p>
<a href="https://codepen.io/embed/prefill?editable=true&default-tab=js%2Cresult&data=%7B%22js%22%3A%22import+%7B+css+%7D+from+%27https%3A%2F%2Fcdn.skypack.dev%2F%40stitches%2Fcore%27%3B%5Cn%5Cn%2F%2F+add+your+code+here%21%5Cn%2F%2F+see+https%3A%2F%2Fstitches.dev+for+documentation%22%7D"><img src="https://img.shields.io/badge/-open_in_codepen-2b354f?logo=codepen&style=flat-square" alt="open in codepen" valign="middle" align="right"></a>
<br />
```html
<script type="module">
import { css } from 'https://cdn.skypack.dev/@stitches/core'
</script>
```
<p><br /></p>
<a href="https://codepen.io/embed/prefill?editable=true&default-tab=js%2Cresult&data=%7B%22js%22%3A%22const+%7B+css+%7D+%3D+stitches%5Cn%5Cn%2F%2F+add+your+code+here%21%5Cn%2F%2F+see+https%3A%2F%2Fstitches.dev+for+documentation%22%2C%22js_external%22%3A%22https%3A%2F%2Funpkg.com%2F%40stitches%2Fcore%2Fdist%2Findex.global.js%22%7D"><img src="https://img.shields.io/badge/-open_in_codepen-2b354f?logo=codepen&style=flat-square" alt="open in codepen" valign="middle" align="right"></a>
<br />
```js
<script src="https://unpkg.com/@stitches/core/dist/index.global.js"></script>
<script>
const { css } = stitches
</script>
```
<p><br /></p>
## Documentation
For full documentation, visit [stitches.dev](https://stitches.dev).
## Contributing
Please follow our [contributing guidelines](./CONTRIBUTING.md).
## Authors
- Pedro Duarte ([@peduarte](https://twitter.com/peduarte)) - [Modulz](https://modulz.app)
- Abdulhadi Alhallak ([@hadi_hlk](https://twitter.com/hadi_hlk)) - [Modulz](https://modulz.app)
- Jonathan Neal ([@jon_neal](https://twitter.com/jon_neal)) - [Modulz](https://modulz.app)
## License
Licensed under the MIT License, Copyright © 2021-present Modulz.
See [LICENSE](./LICENSE.md) for more information.
+2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+7
View File
File diff suppressed because one or more lines are too long
+2
View File
File diff suppressed because one or more lines are too long
+82
View File
@@ -0,0 +1,82 @@
{
"name": "@stitches/core",
"version": "1.2.8",
"description": "The modern CSS-in-JS library",
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "types/index.d.ts",
"typesVersions": {
">= 4.1": {
"*": [
"types/index.d.ts"
]
}
},
"jsdelivr": "dist/index.global.js",
"unpkg": "dist/index.global.js",
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.mjs",
"types": "./types/index.d.ts"
},
"./global": "./dist/index.global.js"
},
"files": [
"dist/*.cjs",
"dist/*.js",
"dist/*.map",
"dist/*.mjs",
"types/*.d.ts"
],
"sideEffects": false,
"license": "MIT",
"repository": "modulz/stitches",
"homepage": "https://stitches.dev/",
"bugs": "https://github.com/modulz/stitches/issues",
"contributors": [
"Pedro Duarte <pedro@modulz.app>",
"Abdulhadi Alhallak <abdulhadi@modulz.app>",
"Jonathan Neal <jonathan@modulz.app>"
],
"publishConfig": {
"access": "public"
},
"keywords": [
"component",
"components",
"create",
"css",
"css-in-js",
"global",
"globals",
"javascript",
"js",
"nesting",
"object",
"object-oriented",
"oo",
"oocss",
"oriented",
"scope",
"scoped",
"style",
"styled",
"styles",
"stylesheet",
"stylesheets",
"theme",
"themes",
"theming",
"token",
"tokens",
"type",
"typed",
"types",
"transform",
"ts",
"variable",
"variables"
]
}
+210
View File
@@ -0,0 +1,210 @@
import type * as CSSUtil from './css-util'
import type Stitches from './stitches'
/** Configuration Interface */
declare namespace ConfigType {
/** Prefix interface. */
export type Prefix<T = ''> = T extends string ? T: string
/** Media interface. */
export type Media<T = {}> = {
[name in keyof T]: T[name] extends string ? T[name] : string
}
/** Theme interface. */
export type Theme<T = {}> = {
borderStyles?: { [token in number | string]: boolean | number | string }
borderWidths?: { [token in number | string]: boolean | number | string }
colors?: { [token in number | string]: boolean | number | string }
fonts?: { [token in number | string]: boolean | number | string }
fontSizes?: { [token in number | string]: boolean | number | string }
fontWeights?: { [token in number | string]: boolean | number | string }
letterSpacings?: { [token in number | string]: boolean | number | string }
lineHeights?: { [token in number | string]: boolean | number | string }
radii?: { [token in number | string]: boolean | number | string }
shadows?: { [token in number | string]: boolean | number | string }
sizes?: { [token in number | string]: boolean | number | string }
space?: { [token in number | string]: boolean | number | string }
transitions?: { [token in number | string]: boolean | number | string }
zIndices?: { [token in number | string]: boolean | number | string }
} & {
[Scale in keyof T]: {
[Token in keyof T[Scale]]: T[Scale][Token] extends (boolean | number | string) ? T[Scale][Token] : (boolean | number | string)
}
}
/** ThemeMap interface. */
export type ThemeMap<T = {}> = {
[Property in keyof T]: T[Property] extends string ? T[Property] : string
}
/** Utility interface. */
export type Utils<T = {}> = {
[Property in keyof T]: T[Property] extends (value: infer V) => {} ? T[Property] | ((value: V) => {
[K in keyof CSSUtil.CSSProperties]?: CSSUtil.CSSProperties[K] | V
}) : never
}
}
/** Default ThemeMap. */
export interface DefaultThemeMap {
gap: 'space'
gridGap: 'space'
columnGap: 'space'
gridColumnGap: 'space'
rowGap: 'space'
gridRowGap: 'space'
inset: 'space'
insetBlock: 'space'
insetBlockEnd: 'space'
insetBlockStart: 'space'
insetInline: 'space'
insetInlineEnd: 'space'
insetInlineStart: 'space'
margin: 'space'
marginTop: 'space'
marginRight: 'space'
marginBottom: 'space'
marginLeft: 'space'
marginBlock: 'space'
marginBlockEnd: 'space'
marginBlockStart: 'space'
marginInline: 'space'
marginInlineEnd: 'space'
marginInlineStart: 'space'
padding: 'space'
paddingTop: 'space'
paddingRight: 'space'
paddingBottom: 'space'
paddingLeft: 'space'
paddingBlock: 'space'
paddingBlockEnd: 'space'
paddingBlockStart: 'space'
paddingInline: 'space'
paddingInlineEnd: 'space'
paddingInlineStart: 'space'
scrollMargin: 'space'
scrollMarginTop: 'space'
scrollMarginRight: 'space'
scrollMarginBottom: 'space'
scrollMarginLeft: 'space'
scrollMarginBlock: 'space'
scrollMarginBlockEnd: 'space'
scrollMarginBlockStart: 'space'
scrollMarginInline: 'space'
scrollMarginInlineEnd: 'space'
scrollMarginInlineStart: 'space'
scrollPadding: 'space'
scrollPaddingTop: 'space'
scrollPaddingRight: 'space'
scrollPaddingBottom: 'space'
scrollPaddingLeft: 'space'
scrollPaddingBlock: 'space'
scrollPaddingBlockEnd: 'space'
scrollPaddingBlockStart: 'space'
scrollPaddingInline: 'space'
scrollPaddingInlineEnd: 'space'
scrollPaddingInlineStart: 'space'
top: 'space'
right: 'space'
bottom: 'space'
left: 'space'
fontSize: 'fontSizes'
background: 'colors'
backgroundColor: 'colors'
backgroundImage: 'colors'
borderImage: 'colors'
border: 'colors'
borderBlock: 'colors'
borderBlockEnd: 'colors'
borderBlockStart: 'colors'
borderBottom: 'colors'
borderBottomColor: 'colors'
borderColor: 'colors'
borderInline: 'colors'
borderInlineEnd: 'colors'
borderInlineStart: 'colors'
borderLeft: 'colors'
borderLeftColor: 'colors'
borderRight: 'colors'
borderRightColor: 'colors'
borderTop: 'colors'
borderTopColor: 'colors'
caretColor: 'colors'
color: 'colors'
columnRuleColor: 'colors'
outline: 'colors'
outlineColor: 'colors'
fill: 'colors'
stroke: 'colors'
textDecorationColor: 'colors'
fontFamily: 'fonts'
fontWeight: 'fontWeights'
lineHeight: 'lineHeights'
letterSpacing: 'letterSpacings'
blockSize: 'sizes'
minBlockSize: 'sizes'
maxBlockSize: 'sizes'
inlineSize: 'sizes'
minInlineSize: 'sizes'
maxInlineSize: 'sizes'
width: 'sizes'
minWidth: 'sizes'
maxWidth: 'sizes'
height: 'sizes'
minHeight: 'sizes'
maxHeight: 'sizes'
flexBasis: 'sizes'
gridTemplateColumns: 'sizes'
gridTemplateRows: 'sizes'
borderWidth: 'borderWidths'
borderTopWidth: 'borderWidths'
borderLeftWidth: 'borderWidths'
borderRightWidth: 'borderWidths'
borderBottomWidth: 'borderWidths'
borderStyle: 'borderStyles'
borderTopStyle: 'borderStyles'
borderLeftStyle: 'borderStyles'
borderRightStyle: 'borderStyles'
borderBottomStyle: 'borderStyles'
borderRadius: 'radii'
borderTopLeftRadius: 'radii'
borderTopRightRadius: 'radii'
borderBottomRightRadius: 'radii'
borderBottomLeftRadius: 'radii'
boxShadow: 'shadows'
textShadow: 'shadows'
transition: 'transitions'
zIndex: 'zIndices'
}
/** Returns a function used to create a new Stitches interface. */
export type CreateStitches = {
<
Prefix extends string = '',
Media extends {} = {},
Theme extends {} = {},
ThemeMap extends {} = DefaultThemeMap,
Utils extends {} = {}
>(
config?: {
prefix?: ConfigType.Prefix<Prefix>
media?: ConfigType.Media<Media>
theme?: ConfigType.Theme<Theme>
themeMap?: ConfigType.ThemeMap<ThemeMap>
utils?: ConfigType.Utils<Utils>
}
): Stitches<Prefix, Media, Theme, ThemeMap, Utils>
}
+119
View File
@@ -0,0 +1,119 @@
import type * as Native from './css'
import type * as Config from './config'
import type * as ThemeUtil from './theme'
import type * as Util from './util'
export { Native }
/** CSS style declaration object. */
export interface CSSProperties extends Native.StandardLonghandProperties, Native.StandardShorthandProperties, Native.SvgProperties {}
type ValueByPropertyName<PropertyName> = PropertyName extends keyof CSSProperties ? CSSProperties[PropertyName] : never
type TokenByPropertyName<PropertyName, Theme, ThemeMap> = PropertyName extends keyof ThemeMap ? TokenByScaleName<ThemeMap[PropertyName], Theme> : never
type TokenByScaleName<ScaleName, Theme> = ScaleName extends keyof Theme ? Util.Prefixed<'$', keyof Theme[ScaleName]> : never
/** Returns a Style interface, leveraging the given media and style map. */
export type CSS<
Media = {},
Theme = {},
ThemeMap = Config.DefaultThemeMap,
Utils = {},
> = (
// nested at-rule css styles
& {
[K in Util.Prefixed<'@', keyof Media>]?: CSS<Media, Theme, ThemeMap, Utils>
}
// known property styles
& {
[K in keyof CSSProperties]?: (
| ValueByPropertyName<K>
| TokenByPropertyName<K, Theme, ThemeMap>
| Native.Globals
| ThemeUtil.ScaleValue
| Util.Index
| undefined
)
}
// known utility styles
& {
[K in keyof Utils as K extends keyof CSSProperties ? never : K]?: Utils[K] extends (arg: infer P) => any
? (
| (
P extends any[]
? (
| (
$$PropertyValue extends keyof P[0]
? (
| ValueByPropertyName<P[0][$$PropertyValue]>
| TokenByPropertyName<P[0][$$PropertyValue], Theme, ThemeMap>
| Native.Globals
| ThemeUtil.ScaleValue
| undefined
)
: $$ScaleValue extends keyof P[0]
? (
| TokenByScaleName<P[0][$$ScaleValue], Theme>
| { scale: P[0][$$ScaleValue] }
| undefined
)
: never
)[]
| P
)
: $$PropertyValue extends keyof P
? (
| ValueByPropertyName<P[$$PropertyValue]>
| TokenByPropertyName<P[$$PropertyValue], Theme, ThemeMap>
| Native.Globals
| undefined
)
: $$ScaleValue extends keyof P
? (
| TokenByScaleName<P[$$ScaleValue], Theme>
| { scale: P[$$ScaleValue] }
| undefined
)
: never
)
| P
)
: never
}
// known theme styles
& {
[K in keyof ThemeMap as K extends keyof CSSProperties ? never : K extends keyof Utils ? never : K]?: (
| Native.Globals
| Util.Index
| undefined
)
}
// unknown css declaration styles
& {
/** Unknown property. */
[K: string]: (
| number
| string
| CSS<Media, Theme, ThemeMap, Utils>
| {}
| undefined
)
}
)
/** Unique symbol used to reference a property value. */
export declare const $$PropertyValue: unique symbol
/** Unique symbol used to reference a property value. */
export type $$PropertyValue = typeof $$PropertyValue
/** Unique symbol used to reference a token value. */
export declare const $$ScaleValue: unique symbol
/** Unique symbol used to reference a token value. */
export type $$ScaleValue = typeof $$ScaleValue
export declare const $$ThemeValue: unique symbol
export type $$ThemeValue = typeof $$ThemeValue
+9797
View File
File diff suppressed because it is too large Load Diff
+79
View File
@@ -0,0 +1,79 @@
import type Stitches from './stitches'
import type * as Config from './config'
import type * as CSSUtil from './css-util'
import type * as StyledComponent from './styled-component'
export { $$PropertyValue, $$ScaleValue, $$ThemeValue} from './css-util'
export type CreateStitches = Config.CreateStitches
export type CSSProperties = CSSUtil.CSSProperties
export type DefaultThemeMap = Config.DefaultThemeMap
/** Returns a Style interface from a configuration, leveraging the given media and style map. */
export type CSS<
Config extends {
media?: {}
theme?: {}
themeMap?: {}
utils?: {}
} = {
media: {},
theme: {},
themeMap: {},
utils: {}
}
> = CSSUtil.CSS<
Config['media'],
Config['theme'],
Config['themeMap'],
Config['utils']
>
/** Returns the properties, attributes, and children expected by a component. */
export type ComponentProps<Component> = Component extends ((...args: any[]) => any) ? Parameters<Component>[0] : never
/** Returns a type that expects a value to be a kind of CSS property value. */
export type PropertyValue<Property extends keyof CSSUtil.CSSProperties, Config = null> = (
Config extends null
? { readonly [K in CSSUtil.$$PropertyValue]: Property }
: Config extends { [K: string]: any }
? CSSUtil.CSS<
Config['media'],
Config['theme'],
Config['themeMap'],
Config['utils']
>[Property]
: never
)
/** Returns a type that expects a value to be a kind of theme scale value. */
export type ScaleValue<Scale, Config = null> = (
Config extends null
? { readonly [K in CSSUtil.$$ScaleValue]: Scale }
: Config extends { [K: string]: any }
? Scale extends keyof Config['theme']
? `$${string & keyof Config['theme'][Scale]}`
: never
: never
)
/** Returns a type that suggests variants from a component as possible prop values. */
export type VariantProps<Component extends {[key: symbol | string]: any}> = StyledComponent.TransformProps<Component[StyledComponent.$$StyledComponentProps], Component[StyledComponent.$$StyledComponentMedia]>
/** Map of CSS properties to token scales. */
export declare const defaultThemeMap: DefaultThemeMap
/** Returns a library used to create styles. */
export declare const createStitches: CreateStitches
/** Returns an object representing a theme. */
export declare const createTheme: Stitches['createTheme']
/** Returns a function that applies globalCss styles. */
export declare const globalCss: Stitches['globalCss']
/** Returns an object that applies `@keyframes` styles. */
export declare const keyframes: Stitches['keyframes']
/** Returns a function that applies styles and variants for a specific class. */
export declare const css: Stitches['css']
+214
View File
@@ -0,0 +1,214 @@
import type * as CSSUtil from './css-util'
import type * as StyledComponent from './styled-component'
import type * as ThemeUtil from './theme'
import type * as Util from './util'
/** Remove an index signature from a type */
export type RemoveIndex<T> = {[k in keyof T as string extends k ? never : number extends k ? never : k]: T[k]}
/** Stitches interface. */
export default interface Stitches<
Prefix extends string = '',
Media extends {} = {},
Theme extends {} = {},
ThemeMap extends {} = {},
Utils extends {} = {}
> {
config: {
prefix: Prefix
media: Media
theme: Theme
themeMap: ThemeMap
utils: Utils
},
prefix: Prefix
/** The **prefix** property defined.
*
* [Read Documentation](https://stitches.dev/docs/variants)
*/
globalCss: {
<Styles extends { [K: string]: any }>(
...styles: (
{
/** The **@import** CSS at-rule imports style rules from other style sheets. */
'@import'?: unknown
/** The **@font-face** CSS at-rule specifies a custom font with which to display text. */
'@font-face'?: unknown
}
& {
[K in keyof Styles]: (
K extends '@import'
? string | string[]
: K extends '@font-face'
? CSSUtil.Native.AtRule.FontFace | Array<CSSUtil.Native.AtRule.FontFace>
: K extends `@keyframes ${string}`
? {
[KeyFrame in string]: CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
}
: K extends `@property ${string}`
? CSSUtil.Native.AtRule.Property
: CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
)
}
)[]
): {
(): string
}
},
keyframes: {
(style: {
[offset: string]: CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
}): {
(): string
name: string
}
},
createTheme: {
<
Argument0 extends (
| string
| (
{
[Scale in keyof Theme]?: {
[Token in keyof Theme[Scale]]?: boolean | number | string
}
} & {
[scale in string]: {
[token in number | string]: boolean | number | string
}
}
)
),
Argument1 extends (
| string
| (
{
[Scale in keyof Theme]?: {
[Token in keyof Theme[Scale]]?: boolean | number | string
}
} & {
[scale in string]: {
[token in number | string]: boolean | number | string
}
}
)
)
>(
nameOrScalesArg0: Argument0,
nameOrScalesArg1?: Argument1
):
& string
& {
className: string
selector: string
}
& (
Argument0 extends string
? ThemeTokens<Argument1, Prefix>
: ThemeTokens<Argument0, Prefix>
)
}
theme:
string
& {
className: string
selector: string
}
& {
[Scale in keyof Theme]: {
[Token in keyof Theme[Scale]]: ThemeUtil.Token<
Extract<Token, string | number>,
string,
Extract<Scale, string | void>,
Extract<Prefix, string | void>
>
}
}
reset: {
(): void
}
getCssText: {
(): string
}
css: {
<
Composers extends (
| string
| Util.Function
| { [name: string]: unknown }
)[],
CSS = CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
>(
...composers: {
[K in keyof Composers]: (
// Strings and Functions can be skipped over
string extends Composers[K]
? Composers[K]
: Composers[K] extends string | Util.Function
? Composers[K]
: RemoveIndex<CSS> & {
/** The **variants** property lets you set a subclass of styles based on a key-value pair.
*
* [Read Documentation](https://stitches.dev/docs/variants)
*/
variants?: {
[Name in string]: {
[Pair in number | string]: CSS
}
}
/** The **compoundVariants** property lets you to set a subclass of styles based on a combination of active variants.
*
* [Read Documentation](https://stitches.dev/docs/variants#compound-variants)
*/
compoundVariants?: (
& (
'variants' extends keyof Composers[K]
? {
[Name in keyof Composers[K]['variants']]?: Util.Widen<keyof Composers[K]['variants'][Name]> | Util.String
}
: Util.WideObject
)
& {
css: CSS
}
)[]
/** The **defaultVariants** property allows you to predefine the active key-value pairs of variants.
*
* [Read Documentation](https://stitches.dev/docs/variants#default-variants)
*/
defaultVariants?: (
'variants' extends keyof Composers[K]
? {
[Name in keyof Composers[K]['variants']]?: Util.Widen<keyof Composers[K]['variants'][Name]> | Util.String
}
: Util.WideObject
)
} & CSS & {
[K2 in keyof Composers[K]]: K2 extends 'compoundVariants' | 'defaultVariants' | 'variants'
? unknown
: K2 extends keyof CSS
? CSS[K2]
: unknown
}
)
}
): StyledComponent.CssComponent<
StyledComponent.StyledComponentType<Composers>,
StyledComponent.StyledComponentProps<Composers>,
Media,
CSS
>
}
}
type ThemeTokens<Values, Prefix> = {
[Scale in keyof Values]: {
[Token in keyof Values[Scale]]: ThemeUtil.Token<
Extract<Token, number | string>,
Values[Scale][Token] & (string | number),
Extract<Scale, string | void>,
Extract<Prefix, string | void>
>
}
}
+96
View File
@@ -0,0 +1,96 @@
import type * as Util from './util'
/** Returns a new CSS Component. */
export interface CssComponent<
Type = 'span',
Props = {},
Media = {},
CSS = {}
> {
(
props?:
& TransformProps<Props, Media>
& {
css?: CSS
}
& {
[name in number | string]: any
}
): string & {
className: string
selector: string
props: {}
}
className: string
selector: string
[$$StyledComponentType]: Type
[$$StyledComponentProps]: Props
[$$StyledComponentMedia]: Media
}
export type TransformProps<Props, Media> = {
[K in keyof Props]: (
| Props[K]
| (
& {
[KMedia in Util.Prefixed<'@', 'initial' | keyof Media>]?: Props[K]
}
& {
[KMedia in string]: Props[K]
}
)
)
}
/** Unique symbol used to reference the type of a Styled Component. */
export declare const $$StyledComponentType: unique symbol
/** Unique symbol used to reference the type of a Styled Component. */
export type $$StyledComponentType = typeof $$StyledComponentType
/** Unique symbol used to reference the props of a Styled Component. */
export declare const $$StyledComponentProps: unique symbol
/** Unique symbol used to reference the props of a Styled Component. */
export type $$StyledComponentProps = typeof $$StyledComponentProps
/** Unique symbol used to reference the media passed into a Styled Component. */
export declare const $$StyledComponentMedia: unique symbol
/** Unique symbol used to reference the media passed into a Styled Component. */
export type $$StyledComponentMedia = typeof $$StyledComponentMedia
/** Returns the first Styled Component type from the given array of compositions. */
export type StyledComponentType<T extends any[]> = (
T[0] extends never
? 'span'
: T[0] extends string
? T[0]
: T[0] extends (props: any) => any
? T[0]
: T[0] extends { [$$StyledComponentType]: unknown }
? T[0][$$StyledComponentType]
: T extends [lead: any, ...tail: infer V]
? StyledComponentType<V>
: never
)
/** Returns the cumulative variants from the given array of compositions. */
export type StyledComponentProps<T extends any[]> = (
& (
$$StyledComponentProps extends keyof T[0]
? T[0][$$StyledComponentProps]
: T[0] extends { variants: { [name: string]: unknown } }
? {
[K in keyof T[0]['variants']]?: Util.Widen<keyof T[0]['variants'][K]>
}
: {}
)
& (
T extends [lead: any, ...tail: infer V]
? StyledComponentProps<V>
: {}
)
)
+43
View File
@@ -0,0 +1,43 @@
export interface ScaleValue {
token: number | string
value: number | string
scale: string
prefix: string
}
export interface Token<
/** Token name. */
NameType extends number | string = string,
/** Token value. */
ValueType extends number | string = string,
/** Token scale. */
ScaleType extends string | void = void,
/** Token prefix. */
PrefixType extends string | void = void,
> extends ScaleValue {
new (name: NameType, value: ValueType, scale?: ScaleType, prefix?: PrefixType): this
/** Name of the token. */
token: NameType
/** Value of the token. */
value: ValueType
/** Category of interface the token applies to. */
scale: ScaleType extends string ? ScaleType : ''
/** Prefix added before the serialized custom property. */
prefix: PrefixType extends string ? PrefixType : ''
/** Serialized custom property representing the token. */
variable: `--${this['prefix'] extends '' ? '' : `${this['prefix']}-`}${this['scale'] extends '' ? '' : `${this['scale']}-`}${this['token']}`
/** Serialized CSS var() representing the token. */
computedValue: `var(${this['variable']})`
/** Returns a serialized CSS var() representing the token. */
toString(): this['computedValue']
}
+32
View File
@@ -0,0 +1,32 @@
/* Utilities */
/* ========================================================================== */
/** Returns a string with the given prefix followed by the given values. */
export type Prefixed<K extends string, T> = `${K}${Extract<T, boolean | number | string>}`
/** Returns an object from the given object assigned with the values of another given object. */
export type Assign<T1 = {}, T2 = {}> = Omit<T1, keyof T2> & T2
/** Returns a widened value from the given value. */
export type Widen<T> =
T extends number
? `${T}` | T
: T extends 'true'
? boolean | T
: T extends 'false'
? boolean | T
: T extends `${number}`
? number | T
: T
/** Narrowed string. */
export type String = string & Record<never, never>
/** Narrowed number or string. */
export type Index = (number | string) & Record<never, never>
/** Narrowed function. */
export type Function = (...args: any[]) => unknown
/** Widened object. */
export type WideObject = { [name in number | string]: boolean | number | string | undefined | WideObject }