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

105 lines (99 loc) 4.73 kB
import { mergeProps, openBlock, createBlock, resolveDynamicComponent, withCtx, renderSlot, normalizeClass } from 'vue'; import BaseComponent from '@primevue/core/basecomponent'; import Button from 'primevue/button'; import SidebarTriggerStyle from 'primevue/sidebartrigger/style'; var script$1 = { name: 'BaseSidebarTrigger', "extends": BaseComponent, props: { target: { type: String, "default": undefined }, as: { type: [String, Object, Function], "default": function _default() { return Button; } }, asChild: { type: Boolean, "default": false } }, style: SidebarTriggerStyle, provide: function provide() { return { $pcSidebarTrigger: this, $parentInstance: this }; } }; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } var script = { name: 'SidebarTrigger', "extends": script$1, inheritAttrs: false, inject: { $pcSidebar: { "default": null }, $pcSidebarLayout: { "default": null } }, methods: { onClick: function onClick(event) { var _this$$pcSidebarLayou, _this$$pcSidebarLayou2; // Let the layout know this click came from a trigger so its SidebarMain outside-click // handler does not immediately undo the toggle when the same event bubbles up. (_this$$pcSidebarLayou = this.$pcSidebarLayout) === null || _this$$pcSidebarLayou === void 0 || (_this$$pcSidebarLayou2 = _this$$pcSidebarLayou.notifyTriggerClick) === null || _this$$pcSidebarLayou2 === void 0 || _this$$pcSidebarLayou2.call(_this$$pcSidebarLayou, event); if (this.$pcSidebar) { this.$pcSidebar.toggle(event); return; } if (this.$pcSidebarLayout) { this.$pcSidebarLayout.toggleSidebar(this.target, event); } } }, computed: { a11yAttrs: function a11yAttrs() { var _this$$pcSidebar$getS, _this$$pcSidebar; var sidebarPart = (_this$$pcSidebar$getS = (_this$$pcSidebar = this.$pcSidebar) === null || _this$$pcSidebar === void 0 ? void 0 : _this$$pcSidebar.getSectionAttrs('trigger')) !== null && _this$$pcSidebar$getS !== void 0 ? _this$$pcSidebar$getS : {}; return _objectSpread(_objectSpread({}, sidebarPart), {}, { 'data-pc-name': 'sidebartrigger', 'data-pc-section': 'root' }); }, attrs: function attrs() { return mergeProps(this.$attrs, this.a11yAttrs, this.ptmi('root')); } } }; function render(_ctx, _cache, $props, $setup, $data, $options) { return !_ctx.asChild ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.as), mergeProps({ key: 0, "class": _ctx.cx('root'), type: _ctx.as === 'BUTTON' || _ctx.as === 'button' ? 'button' : undefined }, $options.attrs, { onClick: $options.onClick }), { "default": withCtx(function () { return [renderSlot(_ctx.$slots, "default")]; }), _: 3 }, 16, ["class", "type", "onClick"])) : renderSlot(_ctx.$slots, "default", { key: 1, a11yAttrs: $options.a11yAttrs, "class": normalizeClass(_ctx.cx('root')), onClick: $options.onClick }); } script.render = render; export { script as default };