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
91 lines (85 loc) • 3.7 kB
JavaScript
import { isElement } from '@primeuix/utils/dom';
import { mergeProps, openBlock, createBlock, resolveDynamicComponent, withCtx, renderSlot, normalizeClass } from 'vue';
import BaseComponent from '@primevue/core/basecomponent';
import ScrollAreaViewportStyle from 'primevue/scrollareaviewport/style';
var script$1 = {
name: 'BaseScrollAreaViewport',
"extends": BaseComponent,
props: {
as: {
type: [String, Object],
"default": 'DIV'
},
asChild: {
type: Boolean,
"default": false
}
},
style: ScrollAreaViewportStyle,
provide: function provide() {
return {
$pcScrollAreaViewport: this,
$parentInstance: this
};
}
};
var script = {
name: 'ScrollAreaViewport',
"extends": script$1,
inheritAttrs: false,
inject: ['$pcScrollArea'],
beforeUnmount: function beforeUnmount() {
var _this$$pcScrollArea;
(_this$$pcScrollArea = this.$pcScrollArea) === null || _this$$pcScrollArea === void 0 || _this$$pcScrollArea.setViewportEl(null);
},
methods: {
setRef: function setRef(el) {
var _el$$el, _this$$pcScrollArea2;
var dom = isElement(el) ? el : (_el$$el = el === null || el === void 0 ? void 0 : el.$el) !== null && _el$$el !== void 0 ? _el$$el : null;
(_this$$pcScrollArea2 = this.$pcScrollArea) === null || _this$$pcScrollArea2 === void 0 || _this$$pcScrollArea2.setViewportEl(dom);
},
onScroll: function onScroll(event) {
var _this$$pcScrollArea3;
(_this$$pcScrollArea3 = this.$pcScrollArea) === null || _this$$pcScrollArea3 === void 0 || _this$$pcScrollArea3.onScroll(event);
}
},
computed: {
scrollMeta: function scrollMeta() {
var _this$$pcScrollArea$s, _this$$pcScrollArea4;
return (_this$$pcScrollArea$s = (_this$$pcScrollArea4 = this.$pcScrollArea) === null || _this$$pcScrollArea4 === void 0 ? void 0 : _this$$pcScrollArea4.scrollMeta) !== null && _this$$pcScrollArea$s !== void 0 ? _this$$pcScrollArea$s : {};
},
attrs: function attrs() {
return mergeProps(this.a11yAttrs, this.ptmi('root'));
},
a11yAttrs: function a11yAttrs() {
var _this$$pcScrollArea5, _this$$pcScrollArea6, _this$$pcScrollArea$t, _this$$pcScrollArea7;
return {
ref: this.setRef,
tabindex: (_this$$pcScrollArea5 = this.$pcScrollArea) !== null && _this$$pcScrollArea5 !== void 0 && _this$$pcScrollArea5.hasOverflowX || (_this$$pcScrollArea6 = this.$pcScrollArea) !== null && _this$$pcScrollArea6 !== void 0 && _this$$pcScrollArea6.hasOverflowY ? (_this$$pcScrollArea$t = (_this$$pcScrollArea7 = this.$pcScrollArea) === null || _this$$pcScrollArea7 === void 0 ? void 0 : _this$$pcScrollArea7.tabIndex) !== null && _this$$pcScrollArea$t !== void 0 ? _this$$pcScrollArea$t : 0 : undefined,
'data-scroll-x-before': this.scrollMeta.xBefore ? '' : undefined,
'data-scroll-x-after': this.scrollMeta.xAfter ? '' : undefined,
'data-scroll-y-before': this.scrollMeta.yBefore ? '' : undefined,
'data-scroll-y-after': this.scrollMeta.yAfter ? '' : undefined,
onScroll: this.onScroll
};
}
}
};
function render(_ctx, _cache, $props, $setup, $data, $options) {
return !_ctx.asChild ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.as), mergeProps({
key: 0,
"class": _ctx.cx('root'),
style: _ctx.sx('root')
}, $options.attrs), {
"default": withCtx(function () {
return [renderSlot(_ctx.$slots, "default")];
}),
_: 3
}, 16, ["class", "style"])) : renderSlot(_ctx.$slots, "default", {
key: 1,
"class": normalizeClass(_ctx.cx('root')),
a11yAttrs: $options.a11yAttrs
});
}
script.render = render;
export { script as default };