Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65faa63059 |
44
dist/remote/TabSelector.js
vendored
44
dist/remote/TabSelector.js
vendored
@ -2,12 +2,12 @@ const _ = "uikit-tab-selector", U = "__UIKIT_REACT_REMOTE_DEPS__", W = `:host {
|
||||
.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; min-height: 46px; width: max-content; padding: 4px 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 { 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: 44px; padding-inline: 8px; }
|
||||
.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; }
|
||||
@ -30,7 +30,7 @@ const _ = "uikit-tab-selector", U = "__UIKIT_REACT_REMOTE_DEPS__", W = `:host {
|
||||
.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 { height: auto; padding-block: 4px; }
|
||||
.desktopWithSubtitle { padding-block: 2px; }
|
||||
.desktopBox { flex-shrink: 1; }
|
||||
.desktopIcon { flex-shrink: 0; width: 16px; height: 16px; }
|
||||
.desktopCompact .desktopIcon, .desktopBox .desktopIcon { width: 14px; height: 14px; }
|
||||
@ -55,17 +55,17 @@ function P() {
|
||||
return window[U] || {};
|
||||
}
|
||||
function V(n) {
|
||||
const { useEffect: a, useRef: b } = 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: "" } : {
|
||||
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 ?? ""), m = t.mobileTitle == null ? i : g(t.mobileTitle, i.title);
|
||||
return { desktop: i, mobile: m };
|
||||
}, u = (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;
|
||||
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: m,
|
||||
onChange: u,
|
||||
counts: N,
|
||||
formatCount: T = I,
|
||||
ariaLabel: y = "تبها",
|
||||
@ -79,7 +79,7 @@ function V(n) {
|
||||
desktopGap: B,
|
||||
desktopWidth: K = "full"
|
||||
}) {
|
||||
const S = b(null), k = b(null), p = z === "compact", v = t.find((e) => e.id === i && !e.disabled)?.id ?? t.find((e) => !e.disabled)?.id;
|
||||
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",
|
||||
@ -104,7 +104,7 @@ function V(n) {
|
||||
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?.(), m?.(r.id);
|
||||
e.currentTarget.parentElement?.children?.[h]?.focus?.(), u?.(r.id);
|
||||
};
|
||||
return /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
|
||||
"div",
|
||||
@ -123,7 +123,7 @@ function V(n) {
|
||||
{
|
||||
key: e.id,
|
||||
ref: l ? k : void 0,
|
||||
className: `${o.mobileTab} ${p ? o.mobileCompact : ""} ${l ? o.mobileActive : ""}`,
|
||||
className: `${o.mobileTab} ${m ? o.mobileCompact : ""} ${l ? o.mobileActive : ""}`,
|
||||
type: "button",
|
||||
role: "tab",
|
||||
"aria-selected": l,
|
||||
@ -132,7 +132,7 @@ function V(n) {
|
||||
disabled: e.disabled,
|
||||
tabIndex: e.id === v ? 0 : -1,
|
||||
onClick: () => {
|
||||
e.disabled || m?.(e.id);
|
||||
e.disabled || u?.(e.id);
|
||||
},
|
||||
onKeyDown: (h) => C(h, e)
|
||||
},
|
||||
@ -145,17 +145,17 @@ function V(n) {
|
||||
), /* @__PURE__ */ n.createElement(
|
||||
"div",
|
||||
{
|
||||
className: `${o.desktopList} ${p ? o.desktopCompact : ""}`,
|
||||
className: `${o.desktopList} ${m ? o.desktopCompact : ""}`,
|
||||
role: "tablist",
|
||||
"aria-label": y,
|
||||
"aria-orientation": "horizontal",
|
||||
dir: f,
|
||||
style: {
|
||||
width: u(K, "100%"),
|
||||
gap: u(B, p ? "2px" : "4px"),
|
||||
"--tab-height": u($, p ? "30px" : "32px"),
|
||||
"--tab-px": u(D, p ? "4px" : "10px"),
|
||||
"--tab-font-size": u(M, p ? "12px" : "13px")
|
||||
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) => {
|
||||
@ -172,7 +172,7 @@ function V(n) {
|
||||
tabIndex: e.id === v ? 0 : -1,
|
||||
className: `${o.desktopTab} ${l ? o.desktopActive : ""} ${c.subtitle ? o.desktopWithSubtitle : ""} ${h ? o.desktopBox : ""}`,
|
||||
onClick: () => {
|
||||
e.disabled || m?.(e.id);
|
||||
e.disabled || u?.(e.id);
|
||||
},
|
||||
onKeyDown: (d) => C(d, e)
|
||||
},
|
||||
@ -205,12 +205,12 @@ class F extends HTMLElement {
|
||||
return this._props;
|
||||
}
|
||||
_render() {
|
||||
const { React: a, createRoot: b } = P();
|
||||
if (!a || !b) {
|
||||
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 = b(this._mount), this._view = V(a)), this._root.render(a.createElement(this._view, this._props));
|
||||
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);
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
dist/remote/index.html
vendored
2
dist/remote/index.html
vendored
@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="color-scheme" content="light" />
|
||||
<title>UI Kit Remote Demo</title>
|
||||
<script type="module" crossorigin src="./demo-assets/index-BN5FDFRa.js"></script>
|
||||
<script type="module" crossorigin src="./demo-assets/index-C0gx3Eus.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "uikit",
|
||||
"version": "1.9.0",
|
||||
"version": "1.9.1",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user