/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, computed, createVNode, mergeProps } from 'vue';
import { usePrefixClass } from '../hooks/useConfig.js';
import { Popup } from '../popup/index.js';
import PopupProps from '../popup/props.js';
import '../hooks/index.js';
import TdStickyToolProps from './props.js';
import baseProps from './sticky-item-props.js';
import { useTNodeJSX } from '../hooks/tnode.js';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import 'lodash/isFunction';
import 'lodash/isString';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import 'lodash/isArray';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-2e5d8948.js';
import 'dayjs';
import '../_chunks/dep-4580aabe.js';
import '../config-provider/type.js';
import '../utils/withInstall.js';
import '../popup/popup.js';
import '@babel/runtime/helpers/slicedToArray';
import '@popperjs/core';
import 'lodash/isObject';
import '../hooks/useVModel.js';
import 'lodash/kebabCase';
import '../utils/dom.js';
import '../utils/easing.js';
import '../_common/js/utils/set-style.js';
import '../popup/container.js';
import '@babel/runtime/helpers/toConsumableArray';
import '../hooks/useResizeObserver.js';
import '../popup/style';
import '../popup/type.js';
import '../hooks/icon.js';
import '../hooks/slot.js';
import 'lodash/camelCase';
import '../utils/render-tnode.js';
import 'lodash/isEmpty';
import '../hooks/useCommonClassName.js';
import '../hooks/useDefaultValue.js';
import '../hooks/useDestroyOnClose.js';
import '../hooks/useKeepAnimation.js';
import '../hooks/useRipple.js';
import '../utils/set-style.js';
import '../hooks/useVirtualScroll.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _StickyItem = defineComponent({
  name: "TStickyItem",
  props: _objectSpread(_objectSpread({}, baseProps), {}, {
    type: TdStickyToolProps.type,
    shape: TdStickyToolProps.shape,
    placement: TdStickyToolProps.placement,
    basePopupProps: PopupProps,
    baseWidth: TdStickyToolProps.width,
    onClick: TdStickyToolProps.onClick,
    onHover: TdStickyToolProps.onHover
  }),
  setup: function setup(props) {
    var COMPONENT_NAME = usePrefixClass("sticky-item");
    var baseClass = computed(function () {
      return ["".concat(COMPONENT_NAME.value), "".concat(COMPONENT_NAME.value, "--").concat(props.type), "".concat(COMPONENT_NAME.value, "--").concat(props.shape)];
    });
    var labelClass = computed(function () {
      return ["".concat(COMPONENT_NAME.value, "__label")];
    });
    var popupPlacement = computed(function () {
      return props.placement.includes("right") ? "left" : "right";
    });
    var styles = computed(function () {
      var styles2 = {};
      if (props.baseWidth) {
        var selfWidth = props.type === "normal" ? "56px" : "40px";
        styles2.margin = "calc((".concat(props.baseWidth, " - ").concat(selfWidth, ")/2)");
      }
      return styles2;
    });
    var handleClickItem = function handleClickItem(e) {
      var item = {};
      Object.keys(baseProps).forEach(function (i) {
        return item[i] = props[i];
      });
      props.onClick({
        e: e,
        item: item
      });
    };
    var handleHoverItem = function handleHoverItem(e) {
      var item = {};
      Object.keys(baseProps).forEach(function (i) {
        return item[i] = props[i];
      });
      props.onHover({
        e: e,
        item: item
      });
    };
    var renderTNodeJSX = useTNodeJSX();
    var icon = renderTNodeJSX("icon");
    var label = renderTNodeJSX("label");
    var popup = renderTNodeJSX("popup");
    var popupProps = Object.assign({
      hideEmptyPopup: true
    }, props.basePopupProps, props.popupProps);
    return function () {
      return createVNode(Popup, mergeProps({
        "overlayInnerClassName": "".concat(usePrefixClass("sticky-tool").value, "-popup-content"),
        "trigger": props.trigger,
        "placement": popupPlacement.value,
        "content": function content() {
          return popup;
        }
      }, popupProps), {
        "default": function _default() {
          return [createVNode("div", {
            "class": baseClass.value,
            "style": styles.value,
            "onClick": handleClickItem,
            "onMouseenter": handleHoverItem
          }, [icon, props.type === "normal" ? createVNode("div", {
            "class": labelClass.value
          }, [label]) : null])];
        }
      });
    };
  }
});

export { _StickyItem as default };
//# sourceMappingURL=sticky-item.js.map
