'use strict';

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

var vue = require('vue');
require('../../../utils/index.cjs');
var index = require('../../vc-resize-observer/src/index.cjs');
var vueTypes = require('../../../utils/vue/vueTypes.cjs');
var _class = require('../../../utils/dom/class.cjs');

const UNDEFINED = void 0;
var Item = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "Item",
  props: {
    prefixCls: String,
    item: vueTypes.default.any,
    renderItem: Function,
    responsive: Boolean,
    itemKey: {
      type: [String, Number]
    },
    registerSize: Function,
    display: Boolean,
    order: Number,
    component: vueTypes.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.default, {
        "disabled": !responsive,
        "onResize": ({
          offsetWidth
        }) => {
          internalRegisterSize(offsetWidth);
        }
      }, {
        default: () => vue.createVNode(Component, {
          "class": _class.classNames(!invalidate && prefixCls),
          "style": overflowStyle,
          ...overflowProps,
          ...restProps,
          "ref": itemNodeRef
        }, {
          default: () => [childNode]
        })
      });
    };
  }
});

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