uikit/dist/remote/AppSidebar.js
Mohamadzadeh 46e32ff4db
All checks were successful
Build and Deploy Next.js + Nginx Docker Image / build-and-deploy (push) Successful in 49s
Build and Deploy Next.js + Nginx Docker Image / deploy (push) Successful in 9s
uikit-v1.3.3-remote-persistence-complete
2026-10-31 11:17:20 +03:30

702 lines
21 KiB
JavaScript

const g = "__UIKIT_REACT_REMOTE_DEPS__", m = "uikit-app-sidebar", b = `
<svg fill="currentColor" width="16" height="16" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
<title>ionicons-v5-i</title>
<path d="M336,376V272H191a16,16,0,0,1,0-32H336V136a56.06,56.06,0,0,0-56-56H88a56.06,56.06,0,0,0-56,56V376a56.06,56.06,0,0,0,56,56H280A56.06,56.06,0,0,0,336,376Z"/>
<path d="M425.37,272l-52.68,52.69a16,16,0,0,0,22.62,22.62l80-80a16,16,0,0,0,0-22.62l-80-80a16,16,0,0,0-22.62,22.62L425.37,240H336v32Z"/>
</svg>`, v = `
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
<circle cx="5" cy="12" r="2"/>
<circle cx="12" cy="12" r="2"/>
<circle cx="19" cy="12" r="2"/>
</svg>`, y = `
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" focusable="false">
<path d="M18 6 6 18"/>
<path d="m6 6 12 12"/>
</svg>`, _ = `
:host {
box-sizing: border-box;
display: block;
width: 72px;
min-width: 72px;
max-width: 72px;
height: calc(100dvh - 110px);
min-height: calc(100dvh - 110px);
max-height: calc(100dvh - 110px);
flex: 0 0 72px;
font-family: inherit;
color: #1a202c;
direction: rtl;
}
*, *::before, *::after { box-sizing: border-box; }
.desktop-nav {
width: 100%;
height: 100%;
min-height: 0;
padding: 16px 0;
overflow-y: auto;
overflow-x: hidden;
overscroll-behavior: contain;
background: #fff;
border-left: 1px solid #e2e8f0;
scrollbar-width: thin;
scrollbar-color: #cbd5e0 transparent;
}
.desktop-nav::-webkit-scrollbar { width: 4px; }
.desktop-nav::-webkit-scrollbar-track { background: transparent; }
.desktop-nav::-webkit-scrollbar-thumb {
border-radius: 999px;
background: #cbd5e0;
}
.items {
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
width: 100%;
}
.item-wrap {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 56px;
height: 42px;
flex: 0 0 42px;
}
.item {
appearance: none;
-webkit-appearance: none;
display: inline-flex;
align-items: center;
justify-content: center;
width: 56px;
height: 42px;
min-width: 56px;
min-height: 42px;
margin: 0;
padding: 0;
border: 0;
border-radius: 6px;
outline: 0;
background: transparent;
color: #718096;
text-decoration: none;
font: inherit;
line-height: 1;
cursor: pointer;
transition: background-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}
.item:hover:not([aria-disabled="true"]) { background: #edf2f7; }
.item[data-active="true"] { background: #e2e8f0; }
.item[data-active="true"]:hover { background: #e2e8f0; }
.item:focus-visible { box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.45); }
.item[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; }
.icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
font-size: 16px;
color: #314E89 !important;
pointer-events: none;
}
.icon > *,
.icon svg {
display: block;
width: 16px;
height: 16px;
max-width: 16px;
max-height: 16px;
color: #314E89 !important;
}
.exit-icon svg {
width: 16px;
height: 16px;
fill: currentColor;
stroke: none;
}
.floating-tooltip {
position: fixed;
z-index: 2147483000;
display: none;
min-width: max-content;
max-width: 280px;
padding: 8px 12px;
border-radius: 6px;
background: #2d3748;
color: #fff;
font-family: inherit;
font-size: 12px;
font-weight: 700;
line-height: 1.2;
white-space: nowrap;
pointer-events: none;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.14);
}
.floating-tooltip[data-open="true"] { display: block; }
.floating-tooltip::after {
content: "";
position: absolute;
top: 16px;
left: 100%;
width: 0;
height: 0;
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-left: 6px solid #2d3748;
}
.mobile-nav,
.drawer-layer {
display: none;
}
@media (max-width: 61.999em) {
:host {
display: block;
width: 0;
min-width: 0;
max-width: none;
height: 0;
min-height: 0;
flex: 0 0 0;
}
.desktop-nav,
.floating-tooltip {
display: none !important;
}
.mobile-nav {
position: fixed;
inset-inline: 0;
bottom: 0;
z-index: 1200;
display: block;
background: #fff;
border-top: 1px solid #e2e8f0;
box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.08);
padding-bottom: env(safe-area-inset-bottom);
}
.mobile-bar {
display: flex;
align-items: stretch;
width: 100%;
height: 56px;
padding-inline: 6px;
gap: 4px;
}
.mobile-slot {
display: flex;
flex: 1 1 0;
min-width: 0;
align-items: center;
}
.mobile-control {
appearance: none;
-webkit-appearance: none;
display: flex;
width: 100%;
min-width: 0;
height: 100%;
margin: 0;
padding: 0;
align-items: center;
justify-content: center;
border: 0;
outline: 0;
background: transparent;
color: #718096;
text-decoration: none;
font: inherit;
cursor: pointer;
}
.mobile-control[aria-disabled="true"] {
cursor: not-allowed;
}
.mobile-content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
min-width: 0;
gap: 2px;
padding: 4px;
border-radius: 12px;
color: #718096;
background: transparent;
opacity: 1;
transition: background-color 150ms ease, color 150ms ease;
}
.mobile-control[data-active="true"] .mobile-content {
color: #2b6cb0;
background: #ebf8ff;
}
.mobile-control[aria-disabled="true"] .mobile-content {
opacity: 0.4;
}
.mobile-control.mobile-exit .mobile-content {
color: #c53030;
}
.mobile-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
flex: 0 0 16px;
color: #314E89 !important;
pointer-events: none;
}
.mobile-icon > *,
.mobile-icon svg {
display: block;
width: 16px;
height: 16px;
max-width: 16px;
max-height: 16px;
color: #314E89 !important;
}
.mobile-control.mobile-exit .mobile-icon,
.mobile-control.mobile-exit .mobile-icon > *,
.mobile-control.mobile-exit .mobile-icon svg,
.drawer-exit .mobile-icon,
.drawer-exit .mobile-icon > *,
.drawer-exit .mobile-icon svg {
color: #c53030 !important;
}
.mobile-label {
display: block;
width: 100%;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: currentColor;
font-size: 10px;
font-weight: 500;
line-height: 1.375;
text-align: center;
}
.mobile-control[data-active="true"] .mobile-label {
font-weight: 700;
}
.drawer-layer {
position: fixed;
inset: 0;
z-index: 1300;
display: none;
align-items: flex-end;
justify-content: stretch;
}
.drawer-layer[data-open="true"] {
display: flex;
}
.drawer-overlay {
position: absolute;
inset: 0;
background: rgba(0, 0, 0, 0.48);
}
.drawer-panel {
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
width: 100%;
max-height: min(78dvh, 620px);
padding-bottom: env(safe-area-inset-bottom);
overflow: hidden;
border-radius: 16px 16px 0 0;
background: #fff;
box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.16);
}
.drawer-header {
position: relative;
display: flex;
min-height: 52px;
padding: 14px 48px 14px 16px;
align-items: center;
border-bottom: 1px solid #e2e8f0;
color: #1a202c;
font-size: 16px;
font-weight: 700;
line-height: 1.3;
}
.drawer-close {
appearance: none;
-webkit-appearance: none;
position: absolute;
top: 10px;
inset-inline-end: 10px;
display: inline-flex;
width: 32px;
height: 32px;
padding: 0;
align-items: center;
justify-content: center;
border: 0;
border-radius: 8px;
background: transparent;
color: #4a5568;
cursor: pointer;
}
.drawer-body {
padding: 16px;
overflow-y: auto;
overscroll-behavior: contain;
}
.drawer-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px;
}
.drawer-item-wrap {
min-width: 0;
}
.drawer-item {
appearance: none;
-webkit-appearance: none;
display: flex;
width: 100%;
height: 70px;
min-width: 0;
padding: 4px;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 4px;
border: 1px solid #e2e8f0;
border-radius: 8px;
background: #fff;
color: #4a5568;
text-decoration: none;
font: inherit;
cursor: pointer;
}
.drawer-item[data-active="true"] {
border-color: #63b3ed;
background: #ebf8ff;
color: #2c5282;
}
.drawer-item[aria-disabled="true"] {
opacity: 0.4;
cursor: not-allowed;
}
.drawer-item .mobile-label {
display: -webkit-box;
overflow: hidden;
white-space: normal;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-size: 10px;
line-height: 1.25;
}
.drawer-item[data-active="true"] .mobile-label {
font-weight: 700;
}
.drawer-exit-section {
margin-top: 16px;
padding-top: 16px;
border-top: 1px solid #e2e8f0;
}
.drawer-exit {
appearance: none;
-webkit-appearance: none;
display: flex;
width: 100%;
min-height: 44px;
padding: 12px;
align-items: center;
justify-content: center;
gap: 8px;
border: 0;
border-radius: 12px;
background: #fff5f5;
color: #c53030;
font: inherit;
font-weight: 700;
cursor: pointer;
}
.drawer-exit[aria-disabled="true"] {
opacity: 0.4;
cursor: not-allowed;
}
}
@media (min-width: 62em) {
.mobile-nav,
.drawer-layer {
display: none !important;
}
}
@media (prefers-reduced-motion: reduce) {
.item,
.mobile-content { transition: none; }
}
`;
function x() {
return typeof window > "u" ? {} : window[g] || {};
}
function a(h, e) {
const t = document.createElement(h);
return e && (t.className = e), t;
}
function w(h, e) {
h.innerHTML = e || "";
}
class k extends HTMLElement {
constructor() {
super(), this._props = {}, this._iconRoots = [], this._shadow = this.attachShadow({ mode: "open" }), this._drawerOpen = !1, this._moreButton = null, this._shadow.addEventListener("keydown", (e) => {
e.key === "Escape" && this._drawerOpen && this.setDrawerOpen(!1);
});
}
connectedCallback() {
this.render();
}
disconnectedCallback() {
this.cleanupIconRoots();
}
set componentProps(e) {
const t = this._props;
this._props = e || {}, this.isConnected && (this.canPatchActiveOnly(t, this._props) ? this.patchActiveItems() : this.render());
}
sameIcon(e, t) {
if (e === t) return !0;
const { React: i } = x();
if (!i?.isValidElement?.(e) || !i.isValidElement(t) || e.type !== t.type || e.key !== t.key) return !1;
const o = e.props || {}, n = t.props || {}, r = Object.keys(o);
return r.length === Object.keys(n).length && r.every((s) => Object.is(o[s], n[s]));
}
canPatchActiveOnly(e, t) {
if (!e || !t) return !1;
for (const r of ["ariaLabel", "dir", "showExit", "exitDisabled"])
if (e[r] !== t[r]) return !1;
const i = Array.isArray(e.items) ? e.items.filter((r) => r && !r.hidden) : [], o = Array.isArray(t.items) ? t.items.filter((r) => r && !r.hidden) : [];
if (i.length !== o.length) return !1;
const n = ["id", "title", "mobileTitle", "disabled", "href", "target", "rel", "iconSvg"];
return i.every((r, s) => {
const d = o[s];
return n.every((l) => r[l] === d[l]) && this.sameIcon(r.icon, d.icon);
});
}
patchActiveItems() {
const e = Array.isArray(this._props.items) ? this._props.items.filter((t) => t && !t.hidden) : [];
for (const t of this._shadow.querySelectorAll("[data-item-index]")) {
const o = !!e[Number(t.dataset.itemIndex)]?.active;
t.dataset.active = o ? "true" : "false", o ? t.setAttribute("aria-current", "page") : t.removeAttribute("aria-current");
}
this._moreButton && (this._moreButton.dataset.active = e.slice(4).some((t) => !!t?.active) ? "true" : "false");
}
get componentProps() {
return this._props;
}
cleanupIconRoots() {
for (const e of this._iconRoots)
try {
e.unmount();
} catch {
}
this._iconRoots = [];
}
mountReactIcon(e, t) {
const { React: i, createRoot: o } = x();
if (!i || !o || !i.isValidElement?.(t)) return !1;
const n = o(e);
return n.render(t), this._iconRoots.push(n), !0;
}
renderIcon(e, t) {
const i = t?.icon;
if (!this.mountReactIcon(e, i)) {
if (typeof t?.iconSvg == "string") {
w(e, t.iconSvg);
return;
}
typeof i == "string" && i.trim().startsWith("<svg") && w(e, i);
}
}
getItemLabel(e) {
return String(e?.mobileTitle || e?.title || "");
}
hideTooltip() {
this._tooltip && (this._tooltip.dataset.open = "false");
}
showTooltip(e, t) {
if (!this._tooltip || !e || !t) return;
this._tooltip.textContent = t, this._tooltip.dataset.open = "true", this._tooltip.style.left = "0px", this._tooltip.style.top = "0px";
const i = e.getBoundingClientRect(), o = this._tooltip.getBoundingClientRect(), n = Math.max(8, i.left - o.width - 10), r = Math.max(8, Math.min(i.top, window.innerHeight - o.height - 8));
this._tooltip.style.left = `${n}px`, this._tooltip.style.top = `${r}px`;
}
bindTooltip(e, t, i) {
const o = () => this.showTooltip(t, i), n = () => this.hideTooltip();
e.addEventListener("mouseenter", o), e.addEventListener("mouseleave", n), t.addEventListener("focus", o), t.addEventListener("blur", n);
}
createItemControl(e, t, i, o) {
const n = !!e?.disabled, r = !!e?.active, s = typeof e?.onClick == "function", d = typeof e?.href == "string" && e.href.length > 0, l = a(d && !s ? "a" : "button", i);
return l.tagName === "BUTTON" ? l.type = "button" : (l.href = e.href, e.target && (l.target = e.target), e.rel && (l.rel = e.rel)), l.setAttribute("aria-label", String(e?.title || `آیتم ${t + 1}`)), l.setAttribute("aria-disabled", n ? "true" : "false"), l.dataset.active = r ? "true" : "false", l.dataset.itemIndex = String(t), r && l.setAttribute("aria-current", "page"), n && (l.tabIndex = -1), l.addEventListener("click", (p) => {
const c = (Array.isArray(this._props.items) ? this._props.items.filter((u) => u && !u.hidden) : [])[t] || e;
if (c.disabled) {
p.preventDefault(), p.stopPropagation();
return;
}
typeof c.onClick == "function" && c.onClick(c, p), typeof o == "function" && o(c, p);
}), l;
}
createNavItem(e, t) {
const i = a("div", "item-wrap"), n = !!e?.disabled ? "عدم دسترسی" : String(e?.title || ""), r = this.createItemControl(e, t, "item"), s = a("span", "icon");
return r.appendChild(s), this.renderIcon(s, e), i.appendChild(r), this.bindTooltip(i, r, n), i;
}
createExitItem() {
const { onExit: e, exitDisabled: t = !1 } = this._props, i = "خروج", o = a("div", "item-wrap"), n = a("button", "item");
n.type = "button", n.setAttribute("aria-label", i), n.setAttribute("aria-disabled", t ? "true" : "false"), t && (n.tabIndex = -1), n.addEventListener("click", (s) => {
this._props.exitDisabled || typeof this._props.onExit == "function" && this._props.onExit(s);
});
const r = a("span", "icon exit-icon");
return r.innerHTML = b, n.appendChild(r), o.appendChild(n), this.bindTooltip(
o,
n,
t ? "عدم دسترسی" : i
), o;
}
createMobileContent(e, t = !1) {
const i = a("span", "mobile-content"), o = a("span", `mobile-icon${t ? " exit-icon" : ""}`);
t ? o.innerHTML = b : this.renderIcon(o, e);
const n = a("span", "mobile-label");
return n.textContent = t ? "خروج" : this.getItemLabel(e), i.appendChild(o), i.appendChild(n), i;
}
createMobileItem(e, t, { drawer: i = !1 } = {}) {
const o = a("div", i ? "drawer-item-wrap" : "mobile-slot"), n = this.createItemControl(
e,
t,
i ? "drawer-item" : "mobile-control",
i ? () => this.setDrawerOpen(!1) : void 0
);
return n.appendChild(this.createMobileContent(e)), o.appendChild(n), o;
}
createMobileExit({ drawer: e = !1 } = {}) {
const { onExit: t, exitDisabled: i = !1 } = this._props, o = "خروج";
if (e) {
const s = a("div", "drawer-exit-section"), d = a("button", "drawer-exit");
d.type = "button", d.setAttribute("aria-label", o), d.setAttribute("aria-disabled", i ? "true" : "false"), i && (d.tabIndex = -1);
const l = a("span", "mobile-icon exit-icon");
l.innerHTML = b;
const p = a("span");
return p.textContent = "خروج", d.appendChild(l), d.appendChild(p), d.addEventListener("click", (f) => {
this._props.exitDisabled || (this.setDrawerOpen(!1), typeof this._props.onExit == "function" && this._props.onExit(f));
}), s.appendChild(d), s;
}
const n = a("div", "mobile-slot"), r = a("button", "mobile-control mobile-exit");
return r.type = "button", r.setAttribute("aria-label", o), r.setAttribute("aria-disabled", i ? "true" : "false"), r.dataset.active = "false", i && (r.tabIndex = -1), r.appendChild(this.createMobileContent(null, !0)), r.addEventListener("click", (s) => {
this._props.exitDisabled || typeof this._props.onExit == "function" && this._props.onExit(s);
}), n.appendChild(r), n;
}
createMoreButton(e) {
const t = a("div", "mobile-slot"), i = a("button", "mobile-control");
i.type = "button", i.setAttribute("aria-label", "نمایش سایر بخش‌ها"), i.setAttribute("aria-haspopup", "dialog"), i.setAttribute("aria-expanded", this._drawerOpen ? "true" : "false"), i.dataset.active = e ? "true" : "false";
const o = a("span", "mobile-content"), n = a("span", "mobile-icon");
n.innerHTML = v;
const r = a("span", "mobile-label");
return r.textContent = "بیشتر", o.appendChild(n), o.appendChild(r), i.appendChild(o), i.addEventListener("click", () => this.setDrawerOpen(!0)), t.appendChild(i), this._moreButton = i, t;
}
createDrawer(e) {
const t = a("div", "drawer-layer");
t.dataset.open = this._drawerOpen ? "true" : "false";
const i = a("div", "drawer-overlay");
i.addEventListener("click", () => this.setDrawerOpen(!1));
const o = a("section", "drawer-panel");
o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "true"), o.setAttribute("aria-label", "سایر بخش‌های سامانه");
const n = a("div", "drawer-header");
n.textContent = "سایر بخش‌های سامانه";
const r = a("button", "drawer-close");
r.type = "button", r.setAttribute("aria-label", "بستن"), r.innerHTML = y, r.addEventListener("click", () => this.setDrawerOpen(!1)), n.appendChild(r);
const s = a("div", "drawer-body"), d = a("div", "drawer-grid");
return e.forEach((l, p) => {
d.appendChild(this.createMobileItem(l, p + 4, { drawer: !0 }));
}), s.appendChild(d), this._props.showExit && s.appendChild(this.createMobileExit({ drawer: !0 })), o.appendChild(n), o.appendChild(s), t.appendChild(i), t.appendChild(o), this._drawerLayer = t, t;
}
setDrawerOpen(e) {
this._drawerOpen = !!e, this._drawerLayer && (this._drawerLayer.dataset.open = this._drawerOpen ? "true" : "false"), this._moreButton && this._moreButton.setAttribute("aria-expanded", this._drawerOpen ? "true" : "false"), !this._drawerOpen && this._moreButton && this._moreButton.focus({ preventScroll: !0 });
}
renderDesktop(e) {
const t = a("nav", "desktop-nav");
t.setAttribute("aria-label", this._props.ariaLabel || "ناوبری اصلی"), t.dir = this._props.dir === "ltr" ? "ltr" : "rtl";
const i = a("div", "items");
return e.forEach((o, n) => {
i.appendChild(this.createNavItem(o, n));
}), this._props.showExit && i.appendChild(this.createExitItem()), t.appendChild(i), t;
}
renderMobile(e) {
const t = a("nav", "mobile-nav");
t.setAttribute("aria-label", `${this._props.ariaLabel || "ناوبری اصلی"} موبایل`), t.dir = this._props.dir === "ltr" ? "ltr" : "rtl";
const i = a("div", "mobile-bar"), o = e.length > 4, n = o ? e.slice(0, 4) : e, r = o ? e.slice(4) : [];
if (n.forEach((s, d) => {
i.appendChild(this.createMobileItem(s, d));
}), o) {
const s = r.some((d) => !!d?.active);
i.appendChild(this.createMoreButton(s));
} else this._props.showExit && i.appendChild(this.createMobileExit());
return t.appendChild(i), {
mobileNav: t,
drawer: o ? this.createDrawer(r) : null
};
}
render() {
this.cleanupIconRoots(), this._shadow.replaceChildren(), this._drawerOpen = !1, this._drawerLayer = null, this._moreButton = null;
const e = document.createElement("style");
e.textContent = _, this._shadow.appendChild(e);
const t = Array.isArray(this._props.items) ? this._props.items.filter((n) => n && !n.hidden) : [];
this._shadow.appendChild(this.renderDesktop(t));
const { mobileNav: i, drawer: o } = this.renderMobile(t);
this._shadow.appendChild(i), o && this._shadow.appendChild(o), this._tooltip = a("span", "floating-tooltip"), this._tooltip.setAttribute("role", "tooltip"), this._tooltip.dataset.open = "false", this._shadow.appendChild(this._tooltip);
}
}
customElements.get(m) || customElements.define(m, k);
export {
k as AppSidebarElement
};