@randevcx/ranui
Version:
UI Component library based on `Web Component`
208 lines (207 loc) • 5.97 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);
return value;
};
import { H as HTMLElementSSR, c as createCustomError } from "./index-CSnBqUsQ.js";
class Loading extends HTMLElementSSR() {
constructor() {
super();
__publicField(this, "contain");
__publicField(this, "rotateLoading", () => {
const loading = document.createElement("div");
loading.setAttribute(
"class",
"rotate"
/* ROTATE */
);
this.contain.appendChild(loading);
});
__publicField(this, "stretchLoading", () => {
const loading = document.createElement("div");
loading.setAttribute(
"class",
"stretch"
/* STRETCH */
);
const arr = [1, 2, 3, 4, 5];
arr.forEach((i) => {
const rect = document.createElement("div");
rect.setAttribute("class", `rect${i}`);
loading.appendChild(rect);
});
this.contain.appendChild(loading);
});
__publicField(this, "doubleBounceLoading", () => {
const loading = document.createElement("div");
loading.setAttribute(
"class",
"double-bounce"
/* DOUBLE_BOUNCE */
);
const arr = [1, 2];
arr.forEach((i) => {
const rect = document.createElement("div");
rect.setAttribute("class", `double-bounce${i}`);
loading.appendChild(rect);
});
this.contain.appendChild(loading);
});
__publicField(this, "cubeLoading", () => {
const loading = document.createElement("div");
loading.setAttribute(
"class",
"cube"
/* CUBE */
);
const arr = [1, 2];
arr.forEach((i) => {
const rect = document.createElement("div");
rect.setAttribute("class", `cube${i}`);
loading.appendChild(rect);
});
this.contain.appendChild(loading);
});
__publicField(this, "dotLoading", () => {
const loading = document.createElement("div");
loading.setAttribute(
"class",
"dot"
/* DOT */
);
const arr = [1, 2];
arr.forEach((i) => {
const rect = document.createElement("div");
rect.setAttribute("class", `dot${i}`);
loading.appendChild(rect);
});
this.contain.appendChild(loading);
});
__publicField(this, "tripleBounceLoading", () => {
const loading = document.createElement("div");
loading.setAttribute(
"class",
"triple-bounce"
/* TRIPLE_BOUNCE */
);
const arr = [1, 2, 3];
arr.forEach((i) => {
const rect = document.createElement("div");
rect.setAttribute("class", `triple-bounce${i}`);
loading.appendChild(rect);
});
this.contain.appendChild(loading);
});
__publicField(this, "scaleOutLoading", () => {
const loading = document.createElement("div");
loading.setAttribute("class", "scale-out");
this.contain.appendChild(loading);
});
__publicField(this, "circleLoading", () => {
const loading = document.createElement("div");
loading.setAttribute("class", "circle");
[
[1, 2, 3, 4],
[1, 2, 3, 4],
[1, 2, 3, 4]
].forEach((i, index2) => {
const container = document.createElement("div");
container.setAttribute("class", `circle-container container${index2 + 1}`);
i.forEach((j) => {
const rect = document.createElement("div");
rect.setAttribute("class", `circle${j}`);
container.appendChild(rect);
});
loading.appendChild(container);
});
this.contain.appendChild(loading);
});
__publicField(this, "createLoading", () => {
this.contain.innerHTML = "";
const NAME_MAP = {
[
"stretch"
/* STRETCH */
]: this.stretchLoading,
[
"rotate"
/* ROTATE */
]: this.rotateLoading,
[
"double-bounce"
/* DOUBLE_BOUNCE */
]: this.doubleBounceLoading,
[
"cube"
/* CUBE */
]: this.cubeLoading,
[
"dot"
/* DOT */
]: this.dotLoading,
[
"triple-bounce"
/* TRIPLE_BOUNCE */
]: this.tripleBounceLoading,
[
"scale-out"
/* SCALE_OUT */
]: this.scaleOutLoading,
[
"circle"
/* CIRCLE */
]: this.circleLoading
};
const handler = NAME_MAP[this.name];
handler && handler();
if (this.contains(this.contain))
return;
this.appendChild(this.contain);
});
this.contain = document.createElement("div");
this.contain.setAttribute("class", "ran-loading");
}
static get observedAttributes() {
return ["name"];
}
get name() {
const name = this.getAttribute("name") || "";
if (!name)
return "circle";
return name;
}
set name(value) {
this.setAttribute("name", value || "");
}
connectedCallback() {
}
disconnectCallback() {
}
attributeChangedCallback(k, o, n) {
if (o !== n) {
if (k === "name") {
this.createLoading();
}
}
}
}
function Custom() {
if (typeof document !== "undefined" && !customElements.get("r-loading")) {
customElements.define("r-loading", Loading);
return Loading;
} else {
return createCustomError("document is undefined or r-loading is exist");
}
}
const index = Custom();
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
Loading,
default: index
}, Symbol.toStringTag, { value: "Module" }));
export {
Loading as L,
index as a,
index$1 as i
};