UNPKG

primevue

Version:

PrimeVue is a premium UI library for Vue featuring a rich set of 90+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBlock, wh

116 lines (110 loc) 3 kB
import { isRTL } from '@primeuix/utils/dom'; import BaseComponent from '@primevue/core/basecomponent'; import TabsStyle from 'primevue/tabs/style'; import { openBlock, createElementBlock, mergeProps, renderSlot } from 'vue'; var script$1 = { name: 'BaseTabs', "extends": BaseComponent, props: { value: { type: [String, Number], "default": undefined }, lazy: { type: Boolean, "default": false }, showNavigators: { type: Boolean, "default": true }, tabindex: { type: Number, "default": 0 }, selectOnFocus: { type: Boolean, "default": false }, /** * @deprecated since v5.0. */ scrollable: { type: Boolean, "default": false }, scrollStrategy: { type: [String, Function], "default": 'nearest' } }, style: TabsStyle, provide: function provide() { return { $pcTabs: this, $parentInstance: this }; } }; var script = { name: 'Tabs', "extends": script$1, inheritAttrs: false, emits: ['update:value'], data: function data() { return { d_value: this.value }; }, watch: { value: function value(newValue) { this.d_value = newValue; } }, methods: { updateValue: function updateValue(newValue) { if (this.d_value !== newValue) { this.d_value = newValue; this.$emit('update:value', newValue); } }, scrollToActiveTab: function scrollToActiveTab(content, tab) { if (!content || !tab || this.scrollStrategy === false) return; if (typeof this.scrollStrategy === 'function') { this.scrollStrategy(content, tab); return; } var contentWidth = content.clientWidth; var currentScrollLeft = Math.abs(content.scrollLeft); var tabLeft = tab.offsetLeft; var tabWidth = tab.offsetWidth; var tabRight = tabLeft + tabWidth; var targetScrollLeft; if (this.scrollStrategy === 'center') { targetScrollLeft = tabLeft - (contentWidth - tabWidth) / 2; } else { var padding = contentWidth * 0.1; if (tabLeft < currentScrollLeft + padding) { targetScrollLeft = tabLeft - padding; } else if (tabRight > currentScrollLeft + contentWidth - padding) { targetScrollLeft = tabRight - contentWidth + padding; } else { return; } } var maxScrollLeft = content.scrollWidth - contentWidth; var clampedScrollLeft = Math.max(0, Math.min(targetScrollLeft, maxScrollLeft)); content.scrollTo({ left: isRTL(content) ? -clampedScrollLeft : clampedScrollLeft, behavior: 'smooth' }); } } }; function render(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("div", mergeProps({ "class": _ctx.cx('root') }, _ctx.ptmi('root')), [renderSlot(_ctx.$slots, "default")], 16); } script.render = render; export { script as default };