Typography.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import _extends from "@babel/runtime/helpers/esm/extends";
  3. import { createVNode as _createVNode } from "vue";
  4. var __rest = this && this.__rest || function (s, e) {
  5. var t = {};
  6. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  7. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  8. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  9. }
  10. return t;
  11. };
  12. import { defineComponent } from 'vue';
  13. import useConfigInject from '../config-provider/hooks/useConfigInject';
  14. import classNames from '../_util/classNames';
  15. // CSSINJS
  16. import useStyle from './style';
  17. export const typographyProps = () => ({
  18. prefixCls: String,
  19. direction: String,
  20. // Form Internal use
  21. component: String
  22. });
  23. const Typography = defineComponent({
  24. name: 'ATypography',
  25. inheritAttrs: false,
  26. props: typographyProps(),
  27. setup(props, _ref) {
  28. let {
  29. slots,
  30. attrs
  31. } = _ref;
  32. const {
  33. prefixCls,
  34. direction
  35. } = useConfigInject('typography', props);
  36. // Style
  37. const [wrapSSR, hashId] = useStyle(prefixCls);
  38. return () => {
  39. var _a;
  40. const _b = _extends(_extends({}, props), attrs),
  41. {
  42. prefixCls: _prefixCls,
  43. direction: _direction,
  44. component: Component = 'article'
  45. } = _b,
  46. restProps = __rest(_b, ["prefixCls", "direction", "component"]);
  47. return wrapSSR(_createVNode(Component, _objectSpread(_objectSpread({}, restProps), {}, {
  48. "class": classNames(prefixCls.value, {
  49. [`${prefixCls.value}-rtl`]: direction.value === 'rtl'
  50. }, attrs.class, hashId.value)
  51. }), {
  52. default: () => [(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)]
  53. }));
  54. };
  55. }
  56. });
  57. export default Typography;