StyleContext.d.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import * as React from 'react';
  2. import CacheEntity from './Cache';
  3. import type { Linter } from './linters/interface';
  4. import type { Transformer } from './transformers/interface';
  5. export declare const ATTR_TOKEN = "data-token-hash";
  6. export declare const ATTR_MARK = "data-css-hash";
  7. export declare const ATTR_CACHE_PATH = "data-cache-path";
  8. export declare const CSS_IN_JS_INSTANCE = "__cssinjs_instance__";
  9. export declare function createCache(): CacheEntity;
  10. export type HashPriority = 'low' | 'high';
  11. export interface StyleContextProps {
  12. autoClear?: boolean;
  13. /** @private Test only. Not work in production. */
  14. mock?: 'server' | 'client';
  15. /**
  16. * Only set when you need ssr to extract style on you own.
  17. * If not provided, it will auto create <style /> on the end of Provider in server side.
  18. */
  19. cache: CacheEntity;
  20. /** Tell children that this context is default generated context */
  21. defaultCache: boolean;
  22. /** Use `:where` selector to reduce hashId css selector priority */
  23. hashPriority?: HashPriority;
  24. /** Tell cssinjs where to inject style in */
  25. container?: Element | ShadowRoot;
  26. /** Component wil render inline `<style />` for fallback in SSR. Not recommend. */
  27. ssrInline?: boolean;
  28. /** Transform css before inject in document. Please note that `transformers` do not support dynamic update */
  29. transformers?: Transformer[];
  30. /**
  31. * Linters to lint css before inject in document.
  32. * Styles will be linted after transforming.
  33. * Please note that `linters` do not support dynamic update.
  34. */
  35. linters?: Linter[];
  36. /** Wrap css in a layer to avoid global style conflict */
  37. layer?: boolean;
  38. }
  39. declare const StyleContext: React.Context<StyleContextProps>;
  40. export type StyleProviderProps = Partial<StyleContextProps> & {
  41. children?: React.ReactNode;
  42. };
  43. export declare const StyleProvider: React.FC<StyleProviderProps>;
  44. export default StyleContext;