All files / src/configprovider ConfigContext.tsx

100% Statements 3/3
50% Branches 2/4
100% Functions 0/0
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29        64x   64x                                   64x        
import { createContext } from "react";
 
// 支持 webpack 注入
export const DEFAULT_CLASS_PREFIX =
  typeof TEA_CLASS_PREFIX !== "undefined" ? TEA_CLASS_PREFIX : "tea";
export const DEFAULT_LOCALE =
  typeof WEBPACK_BUILD_LOCALE !== "undefined" ? WEBPACK_BUILD_LOCALE : "zh";
 
export interface Config {
  /**
   * 组件类名前缀
   *
   * @default "tea"
   */
  classPrefix?: string;
 
  /**
   * 组件语言版本
   *
   * @default "zh"
   */
  locale?: "zh" | "en" | "ko" | "ja";
}
 
export const ConfigContext = createContext<Config>({
  classPrefix: DEFAULT_CLASS_PREFIX,
  locale: DEFAULT_LOCALE,
});