BreadcrumbItem.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
  3. var _excluded = ["class", "style"];
  4. import { createVNode as _createVNode } from "vue";
  5. import { defineComponent } from 'vue';
  6. import PropTypes from '../_util/vue-types';
  7. import { getPropsSlot } from '../_util/props-util';
  8. import DropDown from '../dropdown/dropdown';
  9. import DownOutlined from "@ant-design/icons-vue/es/icons/DownOutlined";
  10. import useConfigInject from '../_util/hooks/useConfigInject';
  11. export var breadcrumbItemProps = function breadcrumbItemProps() {
  12. return {
  13. prefixCls: String,
  14. href: String,
  15. separator: PropTypes.any,
  16. overlay: PropTypes.any,
  17. onClick: Function
  18. };
  19. };
  20. export default defineComponent({
  21. compatConfig: {
  22. MODE: 3
  23. },
  24. name: 'ABreadcrumbItem',
  25. inheritAttrs: false,
  26. __ANT_BREADCRUMB_ITEM: true,
  27. props: breadcrumbItemProps(),
  28. // emits: ['click'],
  29. slots: ['separator', 'overlay'],
  30. setup: function setup(props, _ref) {
  31. var slots = _ref.slots,
  32. attrs = _ref.attrs;
  33. var _useConfigInject = useConfigInject('breadcrumb', props),
  34. prefixCls = _useConfigInject.prefixCls;
  35. /**
  36. * if overlay is have
  37. * Wrap a DropDown
  38. */
  39. var renderBreadcrumbNode = function renderBreadcrumbNode(breadcrumbItem, prefixCls) {
  40. var overlay = getPropsSlot(slots, props, 'overlay');
  41. if (overlay) {
  42. return _createVNode(DropDown, {
  43. "overlay": overlay,
  44. "placement": "bottom"
  45. }, {
  46. default: function _default() {
  47. return [_createVNode("span", {
  48. "class": "".concat(prefixCls, "-overlay-link")
  49. }, [breadcrumbItem, _createVNode(DownOutlined, null, null)])];
  50. }
  51. });
  52. }
  53. return breadcrumbItem;
  54. };
  55. return function () {
  56. var _getPropsSlot;
  57. var separator = (_getPropsSlot = getPropsSlot(slots, props, 'separator')) !== null && _getPropsSlot !== void 0 ? _getPropsSlot : '/';
  58. var children = getPropsSlot(slots, props);
  59. var cls = attrs.class,
  60. style = attrs.style,
  61. restAttrs = _objectWithoutProperties(attrs, _excluded);
  62. var link;
  63. if (props.href !== undefined) {
  64. link = _createVNode("a", _objectSpread({
  65. "class": "".concat(prefixCls.value, "-link"),
  66. "onClick": props.onClick
  67. }, restAttrs), [children]);
  68. } else {
  69. link = _createVNode("span", _objectSpread({
  70. "class": "".concat(prefixCls.value, "-link"),
  71. "onClick": props.onClick
  72. }, restAttrs), [children]);
  73. }
  74. // wrap to dropDown
  75. link = renderBreadcrumbNode(link, prefixCls.value);
  76. if (children) {
  77. return _createVNode("span", {
  78. "class": cls,
  79. "style": style
  80. }, [link, separator && _createVNode("span", {
  81. "class": "".concat(prefixCls.value, "-separator")
  82. }, [separator])]);
  83. }
  84. return null;
  85. };
  86. }
  87. });