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

88 lines (82 loc) 2.73 kB
import { mergeProps, openBlock, createBlock, resolveDynamicComponent, withCtx, renderSlot, normalizeClass } from 'vue'; import BaseComponent from '@primevue/core/basecomponent'; import CompareItemStyle from 'primevue/compareitem/style'; var script$1 = { name: 'BaseCompareItem', "extends": BaseComponent, props: { position: { type: String, "default": 'before' }, as: { type: [String, Object], "default": 'DIV' }, asChild: { type: Boolean, "default": false } }, style: CompareItemStyle, provide: function provide() { return { $pcCompareItem: this, $parentInstance: this }; } }; var script = { name: 'CompareItem', "extends": script$1, inheritAttrs: false, inject: ['$pcCompare'], methods: { getItemStyle: function getItemStyle() { var compare = this.$pcCompare; var percent = compare.getValuePercent(compare.d_value); var positionValue = compare.isHorizontal ? percent : 100 - percent; return { position: 'absolute', inset: 0, clipPath: compare.isHorizontal ? this.position === 'before' ? "inset(0 ".concat(Math.max(0, 100 - positionValue), "% 0 0)") : "inset(0 0 0 ".concat(Math.max(0, positionValue), "%)") : this.position === 'before' ? "inset(0 0 ".concat(Math.max(0, 100 - positionValue), "% 0)") : "inset(".concat(Math.max(0, positionValue), "% 0 0 0)") }; } }, computed: { attrs: function attrs() { var _this$$pcCompare; return mergeProps(this.a11yAttrs, (_this$$pcCompare = this.$pcCompare) === null || _this$$pcCompare === void 0 ? void 0 : _this$$pcCompare.ptm('item'), this.ptmi('root')); }, a11yAttrs: function a11yAttrs() { var compare = this.$pcCompare; if (!compare) return {}; return { style: this.getItemStyle(), 'data-pc-section': 'root', 'data-position': this.position, 'data-orientation': compare.orientation, 'data-disabled': compare.disabled ? '' : undefined, 'data-invalid': compare.invalid ? '' : undefined, 'data-dragging': compare.isDragging ? '' : undefined }; } } }; function render(_ctx, _cache, $props, $setup, $data, $options) { return !_ctx.asChild ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.as), mergeProps({ key: 0, "class": _ctx.cx('root') }, $options.attrs), { "default": withCtx(function () { return [renderSlot(_ctx.$slots, "default")]; }), _: 3 }, 16, ["class"])) : renderSlot(_ctx.$slots, "default", { key: 1, "class": normalizeClass(_ctx.cx('root')), a11yAttrs: $options.a11yAttrs }); } script.render = render; export { script as default };