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

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var hooks_useConfig = require('../hooks/useConfig.js');
var popup_index = require('../popup/index.js');
var popup_props = require('../popup/props.js');
var stickyTool_props = require('./props.js');
var stickyTool_stickyItemProps = require('./sticky-item-props.js');
var hooks_tnode = require('../hooks/tnode.js');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('lodash/isFunction');
require('lodash/isString');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('lodash/isArray');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-7f0559c3.js');
require('dayjs');
require('../utils/withInstall.js');
require('../popup/popup.js');
require('@babel/runtime/helpers/slicedToArray');
require('@popperjs/core');
require('lodash/isObject');
require('../hooks/useVModel.js');
require('lodash/kebabCase');
require('../utils/dom.js');
require('../utils/easing.js');
require('../_common/js/utils/set-style.js');
require('../popup/container.js');
require('@babel/runtime/helpers/toConsumableArray');
require('../hooks/useResizeObserver.js');
require('lodash/camelCase');
require('../utils/render-tnode.js');
require('lodash/isEmpty');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

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__default["default"](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 = vue.defineComponent({
  name: "TStickyItem",
  props: _objectSpread(_objectSpread({}, stickyTool_stickyItemProps["default"]), {}, {
    type: stickyTool_props["default"].type,
    shape: stickyTool_props["default"].shape,
    placement: stickyTool_props["default"].placement,
    basePopupProps: popup_props["default"],
    baseWidth: stickyTool_props["default"].width,
    onClick: stickyTool_props["default"].onClick,
    onHover: stickyTool_props["default"].onHover
  }),
  setup: function setup(props) {
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("sticky-item");
    var baseClass = vue.computed(function () {
      return ["".concat(COMPONENT_NAME.value), "".concat(COMPONENT_NAME.value, "--").concat(props.type), "".concat(COMPONENT_NAME.value, "--").concat(props.shape)];
    });
    var labelClass = vue.computed(function () {
      return ["".concat(COMPONENT_NAME.value, "__label")];
    });
    var popupPlacement = vue.computed(function () {
      return props.placement.includes("right") ? "left" : "right";
    });
    var styles = vue.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(stickyTool_stickyItemProps["default"]).forEach(function (i) {
        return item[i] = props[i];
      });
      props.onClick({
        e: e,
        item: item
      });
    };
    var handleHoverItem = function handleHoverItem(e) {
      var item = {};
      Object.keys(stickyTool_stickyItemProps["default"]).forEach(function (i) {
        return item[i] = props[i];
      });
      props.onHover({
        e: e,
        item: item
      });
    };
    var renderTNodeJSX = hooks_tnode.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 vue.createVNode(popup_index.Popup, vue.mergeProps({
        "overlayInnerClassName": "".concat(hooks_useConfig.usePrefixClass("sticky-tool").value, "-popup-content"),
        "trigger": props.trigger,
        "placement": popupPlacement.value,
        "content": function content() {
          return popup;
        }
      }, popupProps), {
        "default": function _default() {
          return [vue.createVNode("div", {
            "class": baseClass.value,
            "style": styles.value,
            "onClick": handleClickItem,
            "onMouseenter": handleHoverItem
          }, [icon, props.type === "normal" ? vue.createVNode("div", {
            "class": labelClass.value
          }, [label]) : null])];
        }
      });
    };
  }
});

exports["default"] = _StickyItem;
//# sourceMappingURL=sticky-item.js.map
