import { TRAITS } from '../../../config/index'; import { WithArbitraryString, ArrayElement } from './utils'; /** * config/index.ts から TRAITS の型を取得 * objDeepMerge の DeepMergeResult 型により literal types が保持される */ type TraitsConfig = typeof TRAITS; /** preset を持つ Trait の値の型を抽出 */ type PresetElement = T extends { preset: readonly unknown[]; } ? ArrayElement : never; /** * Trait 設定から Props の値の型を抽出するユーティリティ型 */ type ExtractTraitValue = T extends string ? boolean : T extends { preset: readonly unknown[]; } ? WithArbitraryString> | boolean : never; /** * config/index.ts の TRAITS から自動生成される Trait Props の型 * config/index.ts の TRAITS に新しいトレイトを追加すると自動的に反映される */ export type TraitProps = { [K in keyof TraitsConfig]?: ExtractTraitValue; }; /** set prop で使われるプリセット値(エディタ補完用) */ type SetPreset = 'gutter' | 'shadow' | 'hov' | 'transition' | 'mask' | 'plain' | 'innerRs'; /** * set prop の値の型。プリセット値がサジェストされつつ、任意の文字列も受け付ける。 * * - 値はスペース区切りで複数指定可能 * - 先頭に `-` を付けると、その識別子を除外する(例: `set="card -bd"`) * - 文字列配列も受け付けるが、これは内部 API 用途(lism-ui など)であり、 * ユーザー向けドキュメントでは紹介していない */ export type SetPropValue = WithArbitraryString | WithArbitraryString[]; /** util prop で使われるプリセット値(既知の `u--` クラス名・エディタ補完用) */ type UtilPreset = 'cbox' | 'trim' | 'trimChildren' | 'srOnly' | 'clipText' | 'collapseGrid' | 'snap'; /** * util prop の値の型。既知の `u--` クラス名がサジェストされつつ、任意の文字列も受け付ける。 * * - 値はスペース区切りで複数指定可能 * - 先頭に `-` を付けると、その識別子を除外する(例: `util="cbox -trim"`) * - 文字列配列も受け付けるが、これは内部 API 用途であり、 * ユーザー向けドキュメントでは紹介していない */ export type UtilPropValue = WithArbitraryString | WithArbitraryString[]; export {};