RawItem.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
  3. var _excluded = ["component"],
  4. _excluded2 = ["className"],
  5. _excluded3 = ["class"];
  6. import { resolveDirective as _resolveDirective, createVNode as _createVNode } from "vue";
  7. import { defineComponent } from 'vue';
  8. import classNames from '../_util/classNames';
  9. import PropTypes from '../_util/vue-types';
  10. import { OverflowContextProvider, useInjectOverflowContext } from './context';
  11. import Item from './Item';
  12. export default defineComponent({
  13. compatConfig: {
  14. MODE: 3
  15. },
  16. name: 'RawItem',
  17. inheritAttrs: false,
  18. props: {
  19. component: PropTypes.any,
  20. title: PropTypes.any,
  21. id: String,
  22. onMouseenter: {
  23. type: Function
  24. },
  25. onMouseleave: {
  26. type: Function
  27. },
  28. onClick: {
  29. type: Function
  30. },
  31. onKeydown: {
  32. type: Function
  33. },
  34. onFocus: {
  35. type: Function
  36. }
  37. },
  38. setup: function setup(props, _ref) {
  39. var slots = _ref.slots,
  40. attrs = _ref.attrs;
  41. var context = useInjectOverflowContext();
  42. return function () {
  43. // Render directly when context not provided
  44. if (!context.value) {
  45. var _slots$default;
  46. var _props$component = props.component,
  47. Component = _props$component === void 0 ? 'div' : _props$component,
  48. _restProps = _objectWithoutProperties(props, _excluded);
  49. return _createVNode(Component, _objectSpread(_objectSpread({}, _restProps), attrs), {
  50. default: function _default() {
  51. return [(_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
  52. }
  53. });
  54. }
  55. var _context$value = context.value,
  56. contextClassName = _context$value.className,
  57. restContext = _objectWithoutProperties(_context$value, _excluded2);
  58. var className = attrs.class,
  59. restProps = _objectWithoutProperties(attrs, _excluded3);
  60. // Do not pass context to sub item to avoid multiple measure
  61. return _createVNode(OverflowContextProvider, {
  62. "value": null
  63. }, {
  64. default: function _default() {
  65. return [_createVNode(Item, _objectSpread(_objectSpread(_objectSpread({
  66. "class": classNames(contextClassName, className)
  67. }, restContext), restProps), props), slots)];
  68. }
  69. });
  70. };
  71. }
  72. });