index.d.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import type * as CSS from 'csstype';
  2. import type { Theme, Transformer } from '../..';
  3. import type Cache from '../../Cache';
  4. import type Keyframes from '../../Keyframes';
  5. import type { Linter } from '../../linters';
  6. import type { HashPriority } from '../../StyleContext';
  7. import type { Ref } from 'vue';
  8. import type { VueNode } from '../../../type';
  9. declare const SKIP_CHECK = "_skip_check_";
  10. declare const MULTI_VALUE = "_multi_value_";
  11. export type CSSProperties = Omit<CSS.PropertiesFallback<number | string>, 'animationName'> & {
  12. animationName?: CSS.PropertiesFallback<number | string>['animationName'] | Keyframes;
  13. };
  14. export type CSSPropertiesWithMultiValues = {
  15. [K in keyof CSSProperties]: CSSProperties[K] | readonly Extract<CSSProperties[K], string>[] | {
  16. [SKIP_CHECK]?: boolean;
  17. [MULTI_VALUE]?: boolean;
  18. value: CSSProperties[K] | CSSProperties[K][];
  19. };
  20. };
  21. export type CSSPseudos = {
  22. [K in CSS.Pseudos]?: CSSObject;
  23. };
  24. type ArrayCSSInterpolation = readonly CSSInterpolation[];
  25. export type InterpolationPrimitive = null | undefined | boolean | number | string | CSSObject;
  26. export type CSSInterpolation = InterpolationPrimitive | ArrayCSSInterpolation | Keyframes;
  27. export type CSSOthersObject = Record<string, CSSInterpolation>;
  28. export interface CSSObject extends CSSPropertiesWithMultiValues, CSSPseudos, CSSOthersObject {
  29. }
  30. export declare function normalizeStyle(styleStr: string): string;
  31. export interface ParseConfig {
  32. hashId?: string;
  33. hashPriority?: HashPriority;
  34. layer?: string;
  35. path?: string;
  36. transformers?: Transformer[];
  37. linters?: Linter[];
  38. }
  39. export interface ParseInfo {
  40. root?: boolean;
  41. injectHash?: boolean;
  42. parentSelectors: string[];
  43. }
  44. /**
  45. * @private Test only. Clear the global effect style keys.
  46. */
  47. export declare const _cf: () => void;
  48. export declare const parseStyle: (interpolation: CSSInterpolation, config?: ParseConfig, { root, injectHash, parentSelectors }?: ParseInfo) => [parsedStr: string, effectStyle: Record<string, string>];
  49. /**
  50. * Register a style to the global style sheet.
  51. */
  52. export default function useStyleRegister(info: Ref<{
  53. theme: Theme<any, any>;
  54. token: any;
  55. path: string[];
  56. hashId?: string;
  57. layer?: string;
  58. nonce?: string | (() => string);
  59. clientOnly?: boolean;
  60. /**
  61. * Tell cssinjs the insert order of style.
  62. * It's useful when you need to insert style
  63. * before other style to overwrite for the same selector priority.
  64. */
  65. order?: number;
  66. }>, styleFn: () => CSSInterpolation): (node: VueNode) => VueNode;
  67. export declare function extractStyle(cache: Cache, plain?: boolean): string;
  68. export {};