@nextcloud/vue
Version:
Nextcloud vue components
27 lines (26 loc) • 3.32 kB
JavaScript
import "../assets/index47.css";
import { n as f } from "../chunks/_plugin-vue2_normalizer-5b4c43a4.mjs";
const y = { name: "NcButton", props: { alignment: { type: String, default: "center", validator: (t) => ["start", "start-reverse", "center", "center-reverse", "end", "end-reverse"].includes(t) }, disabled: { type: Boolean, default: !1 }, type: { type: String, validator(t) {
return ["primary", "secondary", "tertiary", "tertiary-no-background", "tertiary-on-primary", "error", "warning", "success"].indexOf(t) !== -1;
}, default: "secondary" }, nativeType: { type: String, validator(t) {
return ["submit", "reset", "button"].indexOf(t) !== -1;
}, default: "button" }, wide: { type: Boolean, default: !1 }, ariaLabel: { type: String, default: null }, href: { type: String, default: null }, download: { type: String, default: null }, to: { type: [String, Object], default: null }, exact: { type: Boolean, default: !1 }, ariaHidden: { type: Boolean, default: null }, pressed: { type: Boolean, default: null } }, emits: ["update:pressed", "click"], computed: { realType() {
return this.pressed ? "primary" : this.pressed === !1 && this.type === "primary" ? "secondary" : this.type;
}, flexAlignment() {
return this.alignment.split("-")[0];
}, isReverseAligned() {
return this.alignment.includes("-");
} }, render(t) {
var l, o, i, u, d;
const e = (u = (i = (o = (l = this.$slots.default) == null ? void 0 : l[0]) == null ? void 0 : o.text) == null ? void 0 : i.trim) == null ? void 0 : u.call(i), n = !!e, s = (d = this.$slots) == null ? void 0 : d.icon;
!e && !this.ariaLabel && console.warn("You need to fill either the text or the ariaLabel props in the button component.", { text: e, ariaLabel: this.ariaLabel }, this);
const a = ({ navigate: r, isActive: p, isExactActive: c } = {}) => t(this.to || !this.href ? "button" : "a", { class: ["button-vue", { "button-vue--icon-only": s && !n, "button-vue--text-only": n && !s, "button-vue--icon-and-text": s && n, [`button-vue--vue-${this.realType}`]: this.realType, "button-vue--wide": this.wide, [`button-vue--${this.flexAlignment}`]: this.flexAlignment !== "center", "button-vue--reverse": this.isReverseAligned, active: p, "router-link-exact-active": c }], attrs: { "aria-label": this.ariaLabel, "aria-pressed": this.pressed, disabled: this.disabled, type: this.href ? null : this.nativeType, role: this.href ? "button" : null, href: !this.to && this.href ? this.href : null, target: !this.to && this.href ? "_self" : null, rel: !this.to && this.href ? "nofollow noreferrer noopener" : null, download: !this.to && this.href && this.download ? this.download : null, ...this.$attrs }, on: { ...this.$listeners, click: (h) => {
typeof this.pressed == "boolean" && this.$emit("update:pressed", !this.pressed), this.$emit("click", h), r == null || r(h);
} } }, [t("span", { class: "button-vue__wrapper" }, [s ? t("span", { class: "button-vue__icon", attrs: { "aria-hidden": this.ariaHidden } }, [this.$slots.icon]) : null, n ? t("span", { class: "button-vue__text" }, [e]) : null])]);
return this.to ? t("router-link", { props: { custom: !0, to: this.to, exact: this.exact }, scopedSlots: { default: a } }) : a();
} }, b = null, v = null;
var m = f(y, b, v, !1, null, "bb88e612", null, null);
const w = m.exports;
export {
w as default
};