UNPKG

tdesign-vue

Version:
137 lines (133 loc) 6.82 kB
/** * tdesign v1.14.1 * (c) 2025 tdesign * @license MIT */ import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { defineComponent, ref, computed } from '@vue/composition-api'; import { omit } from 'lodash-es'; import { Popup } from '../popup/index.js'; import { defaultVisibleDelay } from '../popup/utils.js'; import _DropdownMenu from './dropdown-menu.js'; import props from './props.js'; import { usePrefixClass } from '../hooks/useConfig.js'; import { useTNodeJSX } from '../hooks/tnode.js'; import useDropdownOptions from './hooks/useDropdownOptions.js'; import '../popup/popup.js'; import '@babel/runtime/helpers/typeof'; import '@popperjs/core'; import '../utils/dom.js'; import 'vue'; import 'raf'; import '../utils/easing.js'; import '../utils/render-tnode.js'; import '@babel/runtime/helpers/readOnlyError'; import '../utils/helper.js'; import '@babel/runtime/helpers/objectWithoutProperties'; import '@babel/runtime/helpers/slicedToArray'; import '../_common/js/utils/setStyle.js'; import '../popup/props.js'; import '../popup/container.js'; import '../config-provider/config-receiver.js'; import '../config-provider/context.js'; import '../_common/js/global-config/default-config.js'; import '../_common/js/global-config/locale/zh_CN.js'; import '../_chunks/dep-ba613a02.js'; import '../_chunks/dep-fdb1b253.js'; import 'dayjs'; import '../_common/js/global-config/t.js'; import '../utils/mixins.js'; import '../utils/event.js'; import '../utils/map-props.js'; import '../utils/withInstall.js'; import '../popup/plugin.js'; import '../_common/js/log/log.js'; import 'tdesign-icons-vue'; import './dropdown-item.js'; import './dropdown-item-props.js'; import '../utils/ripple.js'; import '../config.js'; import '../hooks/render-tnode.js'; import '../config-provider/useConfig.js'; import '../divider/index.js'; import '../divider/divider.js'; import '../divider/props.js'; import '../hooks/useGlobalIcon.js'; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var _Dropdown = defineComponent({ name: "TDropdown", props: _objectSpread({}, props), setup: function setup(props2, _ref) { var emit = _ref.emit; var dropdownClass = usePrefixClass("dropdown"); var isPopupVisible = ref(false); var invisibleDelay = computed(function () { var _props2$popupProps; var popupInvisibleDelay = (_props2$popupProps = props2.popupProps) === null || _props2$popupProps === void 0 ? void 0 : _props2$popupProps.delay; if (!popupInvisibleDelay) return defaultVisibleDelay[1] + 10; return popupInvisibleDelay[1] ? popupInvisibleDelay[1] + 10 : popupInvisibleDelay[0] + 10; }); var handleMenuClick = function handleMenuClick(data, context) { var _props2$onClick; if (props2.hideAfterItemClick) { setTimeout(function () { var _props2$popupProps2, _props2$popupProps2$o, _props2$popupProps3, _props2$popupProps3$o; isPopupVisible.value = false; (_props2$popupProps2 = props2.popupProps) === null || _props2$popupProps2 === void 0 || (_props2$popupProps2$o = _props2$popupProps2.onVisibleChange) === null || _props2$popupProps2$o === void 0 || _props2$popupProps2$o.call(_props2$popupProps2, false, context); (_props2$popupProps3 = props2.popupProps) === null || _props2$popupProps3 === void 0 || (_props2$popupProps3$o = _props2$popupProps3["on-visible-change"]) === null || _props2$popupProps3$o === void 0 || _props2$popupProps3$o.call(_props2$popupProps3, false, context); }, invisibleDelay.value); } props2 === null || props2 === void 0 || (_props2$onClick = props2.onClick) === null || _props2$onClick === void 0 || _props2$onClick.call(props2, data, context); emit("click", data, context); }; var handleVisibleChange = function handleVisibleChange(visible, context) { var _props2$popupProps4, _props2$popupProps4$o, _props2$popupProps5, _props2$popupProps5$o; if (!visible) { setTimeout(function () { isPopupVisible.value = visible; }, invisibleDelay.value); } else { isPopupVisible.value = visible; } (_props2$popupProps4 = props2.popupProps) === null || _props2$popupProps4 === void 0 || (_props2$popupProps4$o = _props2$popupProps4.onVisibleChange) === null || _props2$popupProps4$o === void 0 || _props2$popupProps4$o.call(_props2$popupProps4, visible, context); (_props2$popupProps5 = props2.popupProps) === null || _props2$popupProps5 === void 0 || (_props2$popupProps5$o = _props2$popupProps5["on-visible-change"]) === null || _props2$popupProps5$o === void 0 || _props2$popupProps5$o.call(_props2$popupProps5, visible, context); }; return { dropdownClass: dropdownClass, handleMenuClick: handleMenuClick, isPopupVisible: isPopupVisible, handleVisibleChange: handleVisibleChange }; }, render: function render() { var _this$popupProps, _renderTNodeJSX; var h = arguments[0]; var popupParams = _objectSpread(_objectSpread({ disabled: this.disabled, placement: this.placement, trigger: this.trigger }, omit(this.popupProps, ["onVisibleChange", "on-visible-change"])), {}, { overlayInnerClassName: [this.dropdownClass, (_this$popupProps = this.popupProps) === null || _this$popupProps === void 0 ? void 0 : _this$popupProps.overlayInnerClassName] }); var renderTNodeJSX = useTNodeJSX(); var options = useDropdownOptions(this.$props, this.$slots); var trigger = (_renderTNodeJSX = renderTNodeJSX("default")) === null || _renderTNodeJSX === void 0 ? void 0 : _renderTNodeJSX[0]; return h(Popup, { "props": _objectSpread({}, _objectSpread({ destroyOnClose: true, visible: this.isPopupVisible, onVisibleChange: this.handleVisibleChange, expandAnimation: true }, popupParams)) }, [h(_DropdownMenu, { "slot": "content", "props": _objectSpread({}, _objectSpread(_objectSpread({}, this.$props), {}, { options: options.value, onClick: this.handleMenuClick })) }), trigger]); } }); export { _Dropdown as default }; //# sourceMappingURL=dropdown.js.map