genStyleUtils.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "use strict";
  2. var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.genSubStyleComponent = exports.genStyleHooks = exports.genComponentStyleHook = void 0;
  7. var _react = require("react");
  8. var _cssinjsUtils = require("@ant-design/cssinjs-utils");
  9. var _context = require("../../config-provider/context");
  10. var _style = require("../../style");
  11. var _useToken = _interopRequireWildcard(require("../useToken"));
  12. const {
  13. genStyleHooks,
  14. genComponentStyleHook,
  15. genSubStyleComponent
  16. } = (0, _cssinjsUtils.genStyleUtils)({
  17. usePrefix: () => {
  18. const {
  19. getPrefixCls,
  20. iconPrefixCls
  21. } = (0, _react.useContext)(_context.ConfigContext);
  22. const rootPrefixCls = getPrefixCls();
  23. return {
  24. rootPrefixCls,
  25. iconPrefixCls
  26. };
  27. },
  28. useToken: () => {
  29. const [theme, realToken, hashId, token, cssVar] = (0, _useToken.default)();
  30. return {
  31. theme,
  32. realToken,
  33. hashId,
  34. token,
  35. cssVar
  36. };
  37. },
  38. useCSP: () => {
  39. const {
  40. csp
  41. } = (0, _react.useContext)(_context.ConfigContext);
  42. return csp !== null && csp !== void 0 ? csp : {};
  43. },
  44. getResetStyles: (token, config) => {
  45. var _a;
  46. const linkStyle = (0, _style.genLinkStyle)(token);
  47. return [linkStyle, {
  48. '&': linkStyle
  49. }, (0, _style.genIconStyle)((_a = config === null || config === void 0 ? void 0 : config.prefix.iconPrefixCls) !== null && _a !== void 0 ? _a : _context.defaultIconPrefixCls)];
  50. },
  51. getCommonStyle: _style.genCommonStyle,
  52. getCompUnitless: () => _useToken.unitless
  53. });
  54. exports.genSubStyleComponent = genSubStyleComponent;
  55. exports.genComponentStyleHook = genComponentStyleHook;
  56. exports.genStyleHooks = genStyleHooks;