UNPKG

xdesign-vue-next

Version:

XDesign Component for vue-next

91 lines (87 loc) 3.2 kB
/** * xdesign v1.0.6 * (c) 2023 xdesign * @license MIT */ import _defineProperty from '@babel/runtime/helpers/defineProperty'; import _slicedToArray from '@babel/runtime/helpers/slicedToArray'; import { defineComponent, computed, ref, onMounted, nextTick, watch, createVNode } from 'vue'; import { firstUpperCase } from '../utils/helper.js'; import props from './props.js'; import { usePrefixClass } from '../hooks/useConfig.js'; import '@babel/runtime/helpers/objectWithoutProperties'; import 'lodash/camelCase'; import 'lodash/isUndefined'; import 'lodash/isNull'; import 'lodash/isArray'; import 'lodash/isNumber'; import 'lodash/isString'; import '../config-provider/useConfig.js'; import 'lodash/isFunction'; import 'lodash/cloneDeep'; import '../config-provider/context.js'; import 'lodash/mergeWith'; import 'lodash/merge'; import '../_common/js/global-config/default-config.js'; import '../_common/js/global-config/locale/en_US.js'; import '../_chunks/dep-3a1cce9f.js'; var TTabNavBar = defineComponent({ props: { navs: { type: Array }, placement: props.placement, value: props.value }, setup: function setup(props) { var COMPONENT_NAME = usePrefixClass("tabs"); var classPrefix = usePrefixClass(); var navBarClass = computed(function () { return ["".concat(COMPONENT_NAME.value, "__bar"), "".concat(classPrefix.value, "-is-").concat(props.placement)]; }); var navBarStyle = ref(null); var getStyle = function getStyle() { var _props$navs$i$el, _ref3; var isVertical = ["left", "right"].includes(props.placement.toLowerCase()); var _ref = isVertical ? ["height", "top"] : ["width", "left"], _ref2 = _slicedToArray(_ref, 2), sizePropName = _ref2[0], offsetPropName = _ref2[1]; var offset = 0; var i = 0; for (; i < props.navs.length; i++) { var _props$navs$i; if (props.navs[i].props.value === props.value) { break; } offset += ((_props$navs$i = props.navs[i]) === null || _props$navs$i === void 0 || (_props$navs$i = _props$navs$i.el) === null || _props$navs$i === void 0 ? void 0 : _props$navs$i["client".concat(firstUpperCase(sizePropName))]) || 0; } if (!props.navs[i]) return {}; return _ref3 = {}, _defineProperty(_ref3, offsetPropName, "".concat(offset, "px")), _defineProperty(_ref3, sizePropName, "".concat(((_props$navs$i$el = props.navs[i].el) === null || _props$navs$i$el === void 0 ? void 0 : _props$navs$i$el["client".concat(firstUpperCase(sizePropName))]) || 0, "px")), _ref3; }; onMounted(function () { nextTick(function () { navBarStyle.value = getStyle(); }); }); watch([function () { return props.navs; }, function () { return props.value; }, function () { return props.placement; }], function () { nextTick(function () { navBarStyle.value = getStyle(); }); }); return function () { return createVNode("div", { "class": navBarClass.value, "style": navBarStyle.value }, null); }; } }); export { TTabNavBar as default }; //# sourceMappingURL=tab-nav-bar.js.map