ranui
Version:
UI Component library based on `Web Component`
120 lines (119 loc) • 4.71 kB
JavaScript
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
const f7170ee498e0dd32cbdcb63fba8f75cc = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}";
function CustomElement() {
if (typeof window !== "undefined" && !customElements.get("r-tab")) {
class TabPane extends HTMLElement {
constructor() {
super();
__publicField(this, "_div");
__publicField(this, "parent");
/**
* @description: 在页面元素都加载完毕后,设置 tab 上的图标
*/
__publicField(this, "initAttribute", () => {
var _a, _b, _c;
this.parent = this.parentNode;
this.key && ((_a = this.parent) == null ? void 0 : _a.updateAttribute(this.key, "icon", this.icon));
this.key && ((_b = this.parent) == null ? void 0 : _b.updateAttribute(this.key, "iconSize", this.iconSize));
this.key && ((_c = this.parent) == null ? void 0 : _c.updateAttribute(this.key, "effect", this.effect));
});
this._div = document.createElement("slot");
const shadowRoot = this.attachShadow({ mode: "closed" });
const F7170EE498E0DD32CBDCB63FBA8F75CC = document.createElement("style");
F7170EE498E0DD32CBDCB63FBA8F75CC.textContent = f7170ee498e0dd32cbdcb63fba8f75cc;
shadowRoot.appendChild(F7170EE498E0DD32CBDCB63FBA8F75CC);
shadowRoot.appendChild(this._div);
}
static get observedAttributes() {
return ["label", "key", "disabled", "icon", "effect", "iconSize"];
}
get label() {
return this.getAttribute("label") || "";
}
set label(value) {
this.setAttribute("label", value);
}
get icon() {
return this.getAttribute("icon");
}
set icon(value) {
if (!value || value === "false") {
this.removeAttribute("icon");
} else {
this.setAttribute("icon", value);
}
}
get iconSize() {
return this.getAttribute("iconSize");
}
set iconSize(value) {
if (!value || value === "false") {
this.removeAttribute("iconSize");
} else {
this.setAttribute("iconSize", value);
}
}
get key() {
return this.getAttribute("r-key");
}
set key(value) {
if (value) {
this.setAttribute("r-key", value);
} else {
this.removeAttribute("r-key");
}
}
get disabled() {
return this.getAttribute("disabled");
}
set disabled(value) {
if (!value || value === "false") {
this.removeAttribute("disabled");
} else {
this.setAttribute("disabled", value);
}
}
get effect() {
return this.getAttribute("effect");
}
set effect(value) {
if (!value || value === "false") {
this.removeAttribute("effect");
} else {
this.setAttribute("effect", value);
}
}
onClick(e) {
}
connectedCallback() {
this._div.addEventListener("click", this.onClick);
document.addEventListener("DOMContentLoaded", this.initAttribute);
}
disconnectCallback() {
document.removeEventListener("DOMContentLoaded", this.initAttribute);
}
attributeChangedCallback(name, oldValue, newValue) {
var _a, _b, _c, _d, _e;
if (oldValue !== newValue && this.key && ((_a = this.parent) == null ? void 0 : _a.updateAttribute)) {
if (name === "icon") (_b = this.parent) == null ? void 0 : _b.updateAttribute(this.key, "icon", newValue);
if (name === "iconSize") (_c = this.parent) == null ? void 0 : _c.updateAttribute(this.key, "iconSize", newValue);
if (name === "effect") (_d = this.parent) == null ? void 0 : _d.updateAttribute(this.key, "effect", newValue);
if (name === "disabled") (_e = this.parent) == null ? void 0 : _e.updateAttribute(this.key, "disabled", newValue);
}
}
}
customElements.define("r-tab", TabPane);
return TabPane;
}
}
const index = CustomElement();
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: index
}, Symbol.toStringTag, { value: "Module" }));
export {
index as a,
index$1 as i
};