const _ = "uikit-tab-selector", U = "__UIKIT_REACT_REMOTE_DEPS__", W = `:host { display:block; min-width:0; max-width:100%; font-family:inherit; } *, *::before, *::after { box-sizing:border-box; } .mobileScroll { display: block; width: 100%; min-width: 0; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scrollbar-width: none; } .mobileScroll::-webkit-scrollbar { display: none; } .mobileList { display: flex; width: max-content; min-width: 100%; align-items: stretch; gap: 4px; } .mobileTab { display: inline-flex; flex-direction: row; position: relative; align-items: center; justify-content: center; flex-shrink: 0; gap: 6px; height: 36px; min-height: 36px; width: max-content; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #4a5568; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background-color 150ms ease, border-color 150ms ease; touch-action: pan-x; } .mobileTab:hover { background: #f7fafc; } .mobileTab:active { background: #ebf8ff; } .mobileTab:disabled { opacity: .4; cursor: not-allowed; } .mobileTab:focus-visible { outline: 2px solid #63b3ed; outline-offset: -2px; } .mobileCompact { gap: 5px; min-height: 36px; padding-inline: 8px; } .mobileActive, .mobileActive:hover { background: #bee3f8; border-color: #bee3f8; color: #2c5282; font-weight: 800; } .mobileIcon { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; width: 27px; height: 27px; border-radius: 8px; background: #edf2f7; color: #718096; } .mobileActive .mobileIcon { background: #90cdf4; color: #2c5282; } .mobileIconSvg { width: 17px; height: 17px; flex-shrink: 0; } .mobileCompact .mobileIcon { width: 25px; height: 25px; } .mobileCompact .mobileIconSvg { width: 15px; height: 15px; } .mobileText { display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; gap: 1px; text-align: center; } .mobileTitle { display: block; font-size: 12.5px; font-weight: 700; line-height: 1.45; white-space: nowrap; } .mobileActive .mobileTitle { font-weight: 800; } .mobileCompact .mobileTitle { font-size: 12px; } .mobileSubtitle { display: block; font-size: 10.5px; font-weight: 500; line-height: 1.35; color: #718096; white-space: nowrap; } .mobileCompact .mobileSubtitle { font-size: 10px; } .mobileActive .mobileSubtitle { color: #3182ce; } .mobileCount { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; min-width: 18px; height: 19px; padding-inline: 5px; border-radius: 999px; background: #edf2f7; color: #718096; font-size: 10px; font-weight: 800; line-height: 1; } .mobileActive .mobileCount { background: #90cdf4; color: #2c5282; } .mobileUnderline { position: absolute; bottom: 0; left: 8px; right: 8px; height: 3px; background: #3182ce; border-radius: 2px 2px 0 0; pointer-events: none; } .desktopList { display: none; min-width: 0; flex-wrap: wrap; align-items: center; overflow-x: hidden; } .desktopTab { position: relative; display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; min-width: 0; min-height: var(--tab-height); height: var(--tab-height); padding: 0 var(--tab-px); gap: 4px; border-radius: 6px; font: inherit; font-size: var(--tab-font-size); font-weight: 600; line-height: 1; color: #718096; background: transparent; border: 1px solid transparent; cursor: pointer; transition: background-color 150ms ease, border-color 150ms ease; } .desktopTab:hover { background: #ebf8ff; color: #3182ce; border-color: #bee3f8; } .desktopTab:focus-visible { outline: 2px solid #63b3ed; outline-offset: -2px; } .desktopTab:disabled { opacity: .4; cursor: not-allowed; } .desktopActive, .desktopActive:hover { background: #bee3f8; color: #2b6cb0; border-color: #90cdf4; font-weight: 800; } .desktopWithSubtitle { padding-block: 2px; } .desktopBox { flex-shrink: 1; } .desktopIcon { flex-shrink: 0; width: 16px; height: 16px; } .desktopCompact .desktopIcon, .desktopBox .desktopIcon { width: 14px; height: 14px; } .desktopIconInline { flex-shrink: 0; width: 14px; height: 14px; } .desktopContent { display: inline-flex; align-items: center; min-width: 0; gap: 5px; } .desktopCompact .desktopContent { gap: 4px; } .desktopTitleStack { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2px; min-width: 0; } .desktopTitle { white-space: nowrap; } .desktopWithSubtitle .desktopTitle { line-height: 1.1; } .desktopSubtitle { font-size: .78em; line-height: 1.1; font-weight: 500; color: #a0aec0; white-space: nowrap; } .desktopActive .desktopSubtitle { color: #3182ce; } .desktopCount { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 16px; padding-inline: 4px; border-radius: 999px; background: #edf2f7; color: #718096; font-size: 10px; font-weight: 800; line-height: 1; } .desktopCompact .desktopCount { min-width: 17px; height: 15px; font-size: 9px; } .desktopActive .desktopCount { background: #90cdf4; color: #2c5282; } @media (min-width: 62em) { .mobileScroll { display: none; } .desktopList { display: flex; } } /* The active underline is shared by mobile and desktop tabs. */ .desktopActive::after { content: ""; position: absolute; bottom: 0; left: 8px; right: 8px; height: 3px; background: #3182ce; border-radius: 2px 2px 0 0; pointer-events: none; } @media (prefers-reduced-motion: reduce) { button { transition:none !important; } }`; function P() { return window[U] || {}; } function V(n) { const { useEffect: a, useRef: p } = n, o = { mobileScroll: "mobileScroll", mobileList: "mobileList", mobileTab: "mobileTab", mobileCompact: "mobileCompact", mobileActive: "mobileActive", mobileIcon: "mobileIcon", mobileIconSvg: "mobileIconSvg", mobileText: "mobileText", mobileTitle: "mobileTitle", mobileSubtitle: "mobileSubtitle", mobileCount: "mobileCount", mobileUnderline: "mobileUnderline", desktopList: "desktopList", desktopTab: "desktopTab", desktopActive: "desktopActive", desktopWithSubtitle: "desktopWithSubtitle", desktopBox: "desktopBox", desktopIcon: "desktopIcon", desktopCompact: "desktopCompact", desktopIconInline: "desktopIconInline", desktopContent: "desktopContent", desktopTitleStack: "desktopTitleStack", desktopTitle: "desktopTitle", desktopSubtitle: "desktopSubtitle", desktopCount: "desktopCount" }, I = (t) => String(t).replace(/[0-9]/g, (i) => "۰۱۲۳۴۵۶۷۸۹"[Number(i)]), g = (t, i = "") => t == null ? { title: String(i), subtitle: "" } : typeof t != "object" ? { title: String(t), subtitle: "" } : { title: String(t.title ?? i), subtitle: String(t.subtitle ?? "") }, w = (t) => { const i = g(t.desktopTitle ?? t.label, t.label ?? ""), u = t.mobileTitle == null ? i : g(t.mobileTitle, i.title); return { desktop: i, mobile: u }; }, b = (t, i) => t == null ? i : typeof t == "number" ? `${t * 4}px` : t === "full" ? "100%" : String(t), x = (t, i) => t ? n.isValidElement(t) ? n.cloneElement(t, { className: [t.props.className, i].filter(Boolean).join(" ") }) : n.createElement(t, { className: i, "aria-hidden": !0 }) : null; function A({ items: t = [], value: i, onChange: u, counts: N, formatCount: T = I, ariaLabel: y = "تب‌ها", direction: f = "rtl", density: z = "regular", desktopElement: L = "button", desktopIconLayout: j = "leading", desktopHeight: $, desktopPaddingX: D, desktopFontSize: M, desktopGap: B, desktopWidth: K = "full" }) { const S = p(null), k = p(null), m = z === "compact", v = t.find((e) => e.id === i && !e.disabled)?.id ?? t.find((e) => !e.disabled)?.id; a(() => { !k.current || !S.current || k.current.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" }); }, [i]); const E = (e) => { const l = N?.[e.id] ?? e.count; return l != null && l !== "" && Number.isFinite(Number(l)) && Number(l) >= 0 ? Number(l) : null; }, C = (e, l) => { if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(e.key)) return; const s = t.filter((d) => !d.disabled); if (s.length === 0) return; e.preventDefault(); const c = s.findIndex((d) => d.id === l.id); let r; if (e.key === "Home") r = s[0]; else if (e.key === "End") r = s[s.length - 1]; else { const d = e.key === "ArrowLeft" ? f === "rtl" ? 1 : -1 : f === "rtl" ? -1 : 1; r = s[(Math.max(0, c) + d + s.length) % s.length]; } const h = t.findIndex((d) => d.id === r.id); e.currentTarget.parentElement?.children?.[h]?.focus?.(), u?.(r.id); }; return /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement( "div", { ref: S, className: o.mobileScroll, role: "tablist", "aria-label": y, "aria-orientation": "horizontal", dir: f }, /* @__PURE__ */ n.createElement("div", { className: o.mobileList }, t.map((e) => { const l = i === e.id, s = E(e), { desktop: c, mobile: r } = w(e); return /* @__PURE__ */ n.createElement( "button", { key: e.id, ref: l ? k : void 0, className: `${o.mobileTab} ${m ? o.mobileCompact : ""} ${l ? o.mobileActive : ""}`, type: "button", role: "tab", "aria-selected": l, "aria-label": [c.title, c.subtitle].filter(Boolean).join(" — "), "aria-controls": e.controls, disabled: e.disabled, tabIndex: e.id === v ? 0 : -1, onClick: () => { e.disabled || u?.(e.id); }, onKeyDown: (h) => C(h, e) }, e.icon ? /* @__PURE__ */ n.createElement("span", { className: o.mobileIcon }, x(e.icon, o.mobileIconSvg)) : null, /* @__PURE__ */ n.createElement("span", { className: o.mobileText }, /* @__PURE__ */ n.createElement("span", { className: o.mobileTitle }, r.title), r.subtitle ? /* @__PURE__ */ n.createElement("span", { className: o.mobileSubtitle }, r.subtitle) : null), s !== null ? /* @__PURE__ */ n.createElement("span", { className: o.mobileCount }, T(s)) : null, l ? /* @__PURE__ */ n.createElement("span", { className: o.mobileUnderline, "aria-hidden": "true" }) : null ); })) ), /* @__PURE__ */ n.createElement( "div", { className: `${o.desktopList} ${m ? o.desktopCompact : ""}`, role: "tablist", "aria-label": y, "aria-orientation": "horizontal", dir: f, style: { width: b(K, "100%"), gap: b(B, m ? "2px" : "4px"), "--tab-height": b($, "36px"), "--tab-px": b(D, m ? "4px" : "10px"), "--tab-font-size": b(M, m ? "12px" : "13px") } }, t.map((e) => { const l = i === e.id, s = E(e), { desktop: c } = w(e), r = j === "inline", h = L === "box"; return /* @__PURE__ */ n.createElement( "button", { key: e.id, type: "button", role: "tab", "aria-selected": l, "aria-controls": e.controls, disabled: e.disabled, tabIndex: e.id === v ? 0 : -1, className: `${o.desktopTab} ${l ? o.desktopActive : ""} ${c.subtitle ? o.desktopWithSubtitle : ""} ${h ? o.desktopBox : ""}`, onClick: () => { e.disabled || u?.(e.id); }, onKeyDown: (d) => C(d, e) }, !r && e.icon ? x(e.icon, o.desktopIcon) : null, /* @__PURE__ */ n.createElement("span", { className: o.desktopContent }, r && e.icon ? x(e.icon, o.desktopIconInline) : null, /* @__PURE__ */ n.createElement("span", { className: o.desktopTitleStack }, /* @__PURE__ */ n.createElement("span", { className: o.desktopTitle }, c.title), c.subtitle ? /* @__PURE__ */ n.createElement("span", { className: o.desktopSubtitle }, c.subtitle) : null), s !== null ? /* @__PURE__ */ n.createElement("span", { className: o.desktopCount }, T(s)) : null) ); }) )); } return A; } class F extends HTMLElement { constructor() { super(), this._props = {}, this._shadow = this.attachShadow({ mode: "open" }); const a = document.createElement("style"); a.textContent = W, this._shadow.append(a), this._mount = document.createElement("div"), this._mount.style.display = "contents", this._shadow.append(this._mount), this._root = null, this._view = null; } connectedCallback() { this._render(); } disconnectedCallback() { queueMicrotask(() => { this.isConnected || !this._root || (this._root.unmount(), this._root = null, this._view = null); }); } set componentProps(a) { this._props = a || {}, this.isConnected && this._render(); } get componentProps() { return this._props; } _render() { const { React: a, createRoot: p } = P(); if (!a || !p) { console.error("[uikit/remote/ui] TabSelector requires host React and ReactDOM.createRoot."); return; } this._root || (this._root = p(this._mount), this._view = V(a)), this._root.render(a.createElement(this._view, this._props)); } } customElements.get(_) || customElements.define(_, F);