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

190 lines (181 loc) 7.02 kB
import ChevronRight from '@primeicons/vue/chevron-right'; import BaseComponent from '@primevue/core/basecomponent'; import BreadcrumbStyle from 'primevue/breadcrumb/style'; import { isString } from '@primeuix/utils/object'; import { mergeProps, toRaw, openBlock, createElementBlock, createBlock, resolveDynamicComponent, normalizeClass, createCommentVNode, toDisplayString, resolveComponent, createElementVNode, Fragment, renderList, renderSlot, createVNode } from 'vue'; var script$2 = { name: 'BaseBreadcrumb', "extends": BaseComponent, props: { model: { type: Array, "default": null }, home: { type: null, "default": null } }, style: BreadcrumbStyle, provide: function provide() { return { $pcBreadcrumb: this, $parentInstance: this }; } }; var script$1 = { name: 'BreadcrumbItem', hostName: 'Breadcrumb', "extends": BaseComponent, props: { item: null, templates: null, index: null }, methods: { onClick: function onClick(event) { if (this.item.command) { this.item.command({ originalEvent: event, item: this.item }); } }, visible: function visible() { return typeof this.item.visible === 'function' ? this.item.visible() : this.item.visible !== false; }, disabled: function disabled() { return typeof this.item.disabled === 'function' ? this.item.disabled() : this.item.disabled; }, label: function label() { return typeof this.item.label === 'function' ? this.item.label() : this.item.label; }, isCurrentUrl: function isCurrentUrl() { var _this$item = this.item, to = _this$item.to, url = _this$item.url; var lastPath = typeof window !== 'undefined' ? window.location.pathname : ''; return to === lastPath || url === lastPath ? 'page' : undefined; }, resolveIcon: function resolveIcon(icon) { return isString(icon) ? icon : toRaw(icon); }, isComponentIcon: function isComponentIcon(icon) { return !!icon && !isString(icon); } }, computed: { ptmOptions: function ptmOptions() { return { context: { item: this.item, index: this.index } }; }, getMenuItemProps: function getMenuItemProps() { var _this = this; return { action: mergeProps({ "class": this.cx('itemLink'), 'aria-current': this.isCurrentUrl(), onClick: function onClick($event) { return _this.onClick($event); } }, this.ptm('itemLink', this.ptmOptions)), icon: mergeProps({ "class": [this.cx('itemIcon'), isString(this.item.icon) ? this.item.icon : undefined] }, this.ptm('itemIcon', this.ptmOptions)), label: mergeProps({ "class": this.cx('itemLabel') }, this.ptm('itemLabel', this.ptmOptions)) }; } } }; var _hoisted_1 = ["href", "target", "aria-current"]; function render$1(_ctx, _cache, $props, $setup, $data, $options) { return $options.visible() ? (openBlock(), createElementBlock("li", mergeProps({ key: 0, "class": [_ctx.cx('item'), $props.item["class"]] }, _ctx.ptm('item', $options.ptmOptions)), [!$props.templates.item ? (openBlock(), createElementBlock("a", mergeProps({ key: 0, href: $props.item.url || '#', "class": _ctx.cx('itemLink'), target: $props.item.target, "aria-current": $options.isCurrentUrl(), onClick: _cache[0] || (_cache[0] = function () { return $options.onClick && $options.onClick.apply($options, arguments); }) }, _ctx.ptm('itemLink', $options.ptmOptions)), [$props.templates && $props.templates.itemicon ? (openBlock(), createBlock(resolveDynamicComponent($props.templates.itemicon), { key: 0, item: $props.item, "class": normalizeClass(_ctx.cx('itemIcon', $options.ptmOptions)) }, null, 8, ["item", "class"])) : $options.isComponentIcon($props.item.icon) ? (openBlock(), createBlock(resolveDynamicComponent($options.resolveIcon($props.item.icon)), mergeProps({ key: 1, "class": _ctx.cx('itemIcon') }, _ctx.ptm('itemIcon', $options.ptmOptions)), null, 16, ["class"])) : $props.item.icon ? (openBlock(), createElementBlock("span", mergeProps({ key: 2, "class": [_ctx.cx('itemIcon'), $props.item.icon] }, _ctx.ptm('itemIcon', $options.ptmOptions)), null, 16)) : createCommentVNode("", true), $props.item.label ? (openBlock(), createElementBlock("span", mergeProps({ key: 3, "class": _ctx.cx('itemLabel') }, _ctx.ptm('itemLabel', $options.ptmOptions)), toDisplayString($options.label()), 17)) : createCommentVNode("", true)], 16, _hoisted_1)) : (openBlock(), createBlock(resolveDynamicComponent($props.templates.item), { key: 1, item: $props.item, label: $options.label(), icon: $props.item.icon ? $options.resolveIcon($props.item.icon) : undefined, props: $options.getMenuItemProps }, null, 8, ["item", "label", "icon", "props"]))], 16)) : createCommentVNode("", true); } script$1.render = render$1; var script = { name: 'Breadcrumb', "extends": script$2, inheritAttrs: false, components: { BreadcrumbItem: script$1, ChevronRight: ChevronRight } }; function render(_ctx, _cache, $props, $setup, $data, $options) { var _component_BreadcrumbItem = resolveComponent("BreadcrumbItem"); var _component_ChevronRight = resolveComponent("ChevronRight"); return openBlock(), createElementBlock("nav", mergeProps({ "class": _ctx.cx('root') }, _ctx.ptmi('root')), [createElementVNode("ol", mergeProps({ "class": _ctx.cx('list') }, _ctx.ptm('list')), [_ctx.home ? (openBlock(), createBlock(_component_BreadcrumbItem, mergeProps({ key: 0, item: _ctx.home, "class": _ctx.cx('homeItem'), templates: _ctx.$slots, pt: _ctx.pt, unstyled: _ctx.unstyled }, _ctx.ptm('homeItem')), null, 16, ["item", "class", "templates", "pt", "unstyled"])) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.model, function (item, i) { return openBlock(), createElementBlock(Fragment, { key: item.label + '_' + i }, [_ctx.home || i !== 0 ? (openBlock(), createElementBlock("li", mergeProps({ key: 0, "class": _ctx.cx('separator') }, { ref_for: true }, _ctx.ptm('separator')), [renderSlot(_ctx.$slots, "separator", {}, function () { return [createVNode(_component_ChevronRight, mergeProps({ "aria-hidden": "true", "class": _ctx.cx('separatorIcon') }, { ref_for: true }, _ctx.ptm('separatorIcon')), null, 16, ["class"])]; })], 16)) : createCommentVNode("", true), createVNode(_component_BreadcrumbItem, { item: item, index: i, templates: _ctx.$slots, pt: _ctx.pt, unstyled: _ctx.unstyled }, null, 8, ["item", "index", "templates", "pt", "unstyled"])], 64); }), 128))], 16)], 16); } script.render = render; export { script as default };