'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var index$1 = require('../vc-resize-observer/index.js');
var classNames = require('../_util/classNames.js');
var index = require('../_util/vue-types/index.js');

function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
}
const UNDEFINED = void 0;
var Item = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "Item",
  props: {
    prefixCls: String,
    item: index.default.any,
    renderItem: Function,
    responsive: Boolean,
    itemKey: {
      type: [String, Number]
    },
    registerSize: Function,
    display: Boolean,
    order: Number,
    component: index.default.any,
    invalidate: Boolean
  },
  setup(props, {
    slots,
    expose
  }) {
    const mergedHidden = vue.computed(() => props.responsive && !props.display);
    const itemNodeRef = vue.ref();
    expose({
      itemNodeRef
    });
    function internalRegisterSize(width) {
      props.registerSize(props.itemKey, width);
    }
    vue.onUnmounted(() => {
      internalRegisterSize(null);
    });
    return () => {
      var _a;
      const {
        prefixCls,
        invalidate,
        item,
        renderItem,
        responsive,
        registerSize,
        itemKey,
        display,
        order,
        component: Component = "div",
        ...restProps
      } = props;
      const children = (_a = slots.default) == null ? void 0 : _a.call(slots);
      const childNode = renderItem && item !== UNDEFINED ? renderItem(item) : children;
      let overflowStyle;
      if (!invalidate) {
        overflowStyle = {
          opacity: mergedHidden.value ? 0 : 1,
          height: mergedHidden.value ? 0 : UNDEFINED,
          overflowY: mergedHidden.value ? "hidden" : UNDEFINED,
          order: responsive ? order : UNDEFINED,
          pointerEvents: mergedHidden.value ? "none" : UNDEFINED,
          position: mergedHidden.value ? "absolute" : UNDEFINED
        };
      }
      const overflowProps = {};
      if (mergedHidden.value)
        overflowProps["aria-hidden"] = true;
      return vue.createVNode(index$1.default, {
        "disabled": !responsive,
        "onResize": ({
          offsetWidth
        }) => {
          internalRegisterSize(offsetWidth);
        }
      }, {
        default: () => vue.createVNode(Component, vue.mergeProps({
          "class": classNames.default(!invalidate && prefixCls),
          "style": overflowStyle
        }, overflowProps, restProps, {
          "ref": itemNodeRef
        }), _isSlot(childNode) ? childNode : {
          default: () => [childNode]
        })
      });
    };
  }
});

exports.default = Item;
//# sourceMappingURL=Item.js.map
