RawItem.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import { resolveDirective as _resolveDirective, createVNode as _createVNode } from "vue";
  3. var __rest = this && this.__rest || function (s, e) {
  4. var t = {};
  5. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  6. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  7. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  8. }
  9. return t;
  10. };
  11. import { defineComponent } from 'vue';
  12. import classNames from '../_util/classNames';
  13. import PropTypes from '../_util/vue-types';
  14. import { OverflowContextProvider, useInjectOverflowContext } from './context';
  15. import Item from './Item';
  16. export default defineComponent({
  17. compatConfig: {
  18. MODE: 3
  19. },
  20. name: 'RawItem',
  21. inheritAttrs: false,
  22. props: {
  23. component: PropTypes.any,
  24. title: PropTypes.any,
  25. id: String,
  26. onMouseenter: {
  27. type: Function
  28. },
  29. onMouseleave: {
  30. type: Function
  31. },
  32. onClick: {
  33. type: Function
  34. },
  35. onKeydown: {
  36. type: Function
  37. },
  38. onFocus: {
  39. type: Function
  40. },
  41. role: String,
  42. tabindex: Number
  43. },
  44. setup(props, _ref) {
  45. let {
  46. slots,
  47. attrs
  48. } = _ref;
  49. const context = useInjectOverflowContext();
  50. return () => {
  51. var _a;
  52. // Render directly when context not provided
  53. if (!context.value) {
  54. const {
  55. component: Component = 'div'
  56. } = props,
  57. restProps = __rest(props, ["component"]);
  58. return _createVNode(Component, _objectSpread(_objectSpread({}, restProps), attrs), {
  59. default: () => [(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)]
  60. });
  61. }
  62. const _b = context.value,
  63. {
  64. className: contextClassName
  65. } = _b,
  66. restContext = __rest(_b, ["className"]);
  67. const {
  68. class: className
  69. } = attrs,
  70. restProps = __rest(attrs, ["class"]);
  71. // Do not pass context to sub item to avoid multiple measure
  72. return _createVNode(OverflowContextProvider, {
  73. "value": null
  74. }, {
  75. default: () => [_createVNode(Item, _objectSpread(_objectSpread(_objectSpread({
  76. "class": classNames(contextClassName, className)
  77. }, restContext), restProps), props), slots)]
  78. });
  79. };
  80. }
  81. });