UNPKG

tdesign-vue

Version:
157 lines (153 loc) 6.11 kB
/** * tdesign v1.14.1 * (c) 2025 tdesign * @license MIT */ import { h as helper } from '../_chunks/dep-6a4dc7bb.js'; import _defineProperty from '@babel/runtime/helpers/defineProperty'; import props from './props.js'; import _StickyItem from './sticky-item.js'; import mixins from '../utils/mixins.js'; import getConfigReceiverMixins from '../config-provider/config-receiver.js'; import { emitEvent } from '../utils/event.js'; import './sticky-item-props.js'; import '../popup/index.js'; import '../popup/popup.js'; import '@babel/runtime/helpers/typeof'; import '@popperjs/core'; import 'lodash-es'; import '../utils/dom.js'; import 'vue'; import 'raf'; import '../utils/easing.js'; import '../utils/render-tnode.js'; import '@babel/runtime/helpers/readOnlyError'; import '@vue/composition-api'; 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 '../popup/utils.js'; import '../utils/map-props.js'; import '../utils/withInstall.js'; import '../popup/plugin.js'; import '../_common/js/log/log.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'; 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 _StickyTool = mixins(getConfigReceiverMixins("sticky-tool")).extend({ name: "TStickyTool", components: { TStickyItem: _StickyItem }, props: _objectSpread({}, props), computed: { classes: function classes() { return [this.componentName, "".concat(this.componentName, "--").concat(this.shape)]; }, styles: function styles() { var styles = this.getOffset(); if (this.width) styles.width = typeof this.width === "number" ? "".concat(this.width, "px") : this.width; return styles; } }, render: function render() { var _this$$scopedSlots, _this = this; var h = arguments[0]; var nodes = ((_this$$scopedSlots = this.$scopedSlots) === null || _this$$scopedSlots === void 0 ? void 0 : _this$$scopedSlots["default"]) && this.$scopedSlots["default"](null); var list = this.getList(); var content = list.map(function (item, index) { var type = _this.type, shape = _this.shape, placement = _this.placement, popupProps = _this.popupProps, handleClick = _this.handleClick, handleHover = _this.handleHover; var itemProps = _objectSpread(_objectSpread({}, item), {}, { type: type, shape: shape, placement: placement, basePopupProps: popupProps, baseWidth: _this.styles.width, onClick: handleClick, onHover: handleHover, fatherCompName: _this.componentName }); var stickyItem = h("t-sticky-item", helper([{}, { "props": itemProps }, { "key": index }])); if (nodes && nodes[index]) { var vnode = nodes[index]; if (vnode.componentOptions) { vnode.componentOptions.propsData = itemProps; return vnode; } return stickyItem; } return stickyItem; }); return h("div", { "class": this.classes, "style": this.styles }, [content]); }, methods: { getList: function getList() { var _this$$scopedSlots2, _this$list; var nodes = ((_this$$scopedSlots2 = this.$scopedSlots) === null || _this$$scopedSlots2 === void 0 ? void 0 : _this$$scopedSlots2["default"]) && this.$scopedSlots["default"](null); var list; if ((_this$list = this.list) !== null && _this$list !== void 0 && _this$list.length) { list = this.list; } else { list = this.getListBySlots(nodes); } return list; }, getListBySlots: function getListBySlots(nodes) { var arr = []; nodes === null || nodes === void 0 || nodes.forEach(function (node) { var _node$componentOption; var option = node === null || node === void 0 || (_node$componentOption = node.componentOptions) === null || _node$componentOption === void 0 ? void 0 : _node$componentOption.propsData; if (!option) return; arr.push(option); }); return arr; }, getOffset: function getOffset() { var _this$offset; var position = this.offset ? [80, 24] : ["80px", "24px"]; (_this$offset = this.offset) === null || _this$offset === void 0 || _this$offset.forEach(function (item, index) { position[index] = isNaN(Number(item)) ? "calc( ".concat(position[index], "px + ").concat(item, ")") : "".concat(position[index] + item, "px"); }); var offsetStyle = {}; this.placement.split("-").forEach(function (item, index) { if (item !== "center") { offsetStyle[item] = position[index]; } else { offsetStyle.top = "50%"; offsetStyle.transform = "translate(0, -50%)"; } }); return offsetStyle; }, handleClick: function handleClick(context) { emitEvent(this, "click", context); }, handleHover: function handleHover(context) { emitEvent(this, "hover", context); } } }); export { _StickyTool as default }; //# sourceMappingURL=sticky-tool.js.map