aot-ui 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2081,95 +2081,95 @@ function xt(e, t) {
2081
2081
  return Number.isFinite(r) ? r : t;
2082
2082
  }
2083
2083
  function St({ items: e, index: t, defaultIndex: n = 0, onChange: r, className: i = "", "aria-label": a = "底部导航", barOnly: o = !1 }) {
2084
- let c = t !== void 0, [u, d] = h(n), f = c ? t : u, p = m(null), g = m([]), [y, b] = h(0), [x, S] = h({
2084
+ let c = Array.isArray(e) ? e : [], u = t !== void 0, [d, f] = h(n), p = u ? t : d, g = m(null), y = m([]), [b, x] = h(0), [S, C] = h({
2085
2085
  idle: "#9ca3af",
2086
2086
  active: bt("--aot-config-primary", "#2563eb")
2087
- }), [C, w] = h(40), [T, E] = h(14), D = !o && e.some((e) => e.content != null), O = s((e) => {
2088
- c || d(e), r?.(e);
2089
- }, [c, r]), k = s(() => {
2090
- let t = p.current;
2091
- if (!t) return [];
2092
- let n = t.getBoundingClientRect(), r = C, i = (n.height - r) / 2;
2093
- return g.current.slice(0, e.length).map((e) => {
2087
+ }), [w, T] = h(40), [E, D] = h(14), O = !o && c.some((e) => e.content != null), k = s((e) => {
2088
+ u || f(e), r?.(e);
2089
+ }, [u, r]), A = s(() => {
2090
+ let e = g.current;
2091
+ if (!e) return [];
2092
+ let t = e.getBoundingClientRect(), n = w, r = (t.height - n) / 2;
2093
+ return y.current.slice(0, c.length).map((e) => {
2094
2094
  if (!e) return {
2095
2095
  left: 0,
2096
2096
  width: 0,
2097
- height: r,
2098
- top: i
2097
+ height: n,
2098
+ top: r
2099
2099
  };
2100
- let t = e.getBoundingClientRect(), a = Math.min(10, t.width * .12);
2100
+ let i = e.getBoundingClientRect(), a = Math.min(10, i.width * .12);
2101
2101
  return {
2102
- left: t.left - n.left + a,
2103
- width: Math.max(t.width - a * 2, 28),
2104
- height: r,
2105
- top: i
2102
+ left: i.left - t.left + a,
2103
+ width: Math.max(i.width - a * 2, 28),
2104
+ height: n,
2105
+ top: r
2106
2106
  };
2107
2107
  });
2108
2108
  }, [
2109
- e.length,
2110
- C,
2111
- y
2112
- ]), { frame: A, select: j } = yt({
2113
- count: e.length,
2114
- index: f,
2115
- measure: k,
2116
- onIndexChange: O
2109
+ c.length,
2110
+ w,
2111
+ b
2112
+ ]), { frame: j, select: M } = yt({
2113
+ count: c.length,
2114
+ index: p,
2115
+ measure: A,
2116
+ onIndexChange: k
2117
2117
  });
2118
2118
  l(() => {
2119
- S({
2119
+ C({
2120
2120
  idle: bt("--color-bnav-idle", "#9ca3af"),
2121
2121
  active: bt("--color-bnav-active", bt("--aot-config-primary", "#2563eb"))
2122
- }), w(xt("--bnav-capsule-h", 40)), E(xt("--bnav-push", 14));
2122
+ }), T(xt("--bnav-capsule-h", 40)), D(xt("--bnav-push", 14));
2123
2123
  }, []), l(() => {
2124
- let e = p.current;
2125
- if (e) return it(e, () => b((e) => e + 1));
2124
+ let e = g.current;
2125
+ if (e) return it(e, () => x((e) => e + 1));
2126
2126
  }, []);
2127
- let M = e[A.pageIndex], N = { "--bnav-page-push": `${A.pageDir === 0 ? 0 : A.pageDir * T}px` }, P = A.capsule;
2127
+ let N = c[j.pageIndex], P = { "--bnav-page-push": `${j.pageDir === 0 ? 0 : j.pageDir * E}px` }, F = j.capsule;
2128
2128
  return /* @__PURE__ */ v("div", {
2129
2129
  className: [
2130
2130
  "bottom-nav",
2131
2131
  o ? "bottom-nav--bar-only" : "",
2132
2132
  i
2133
2133
  ].filter(Boolean).join(" "),
2134
- children: [D ? /* @__PURE__ */ _("div", {
2134
+ children: [O ? /* @__PURE__ */ _("div", {
2135
2135
  className: "bottom-nav__stage",
2136
- children: M ? /* @__PURE__ */ _("div", {
2137
- className: `bottom-nav__page${A.pageKey > 0 ? " is-enter" : ""}`,
2138
- style: N,
2136
+ children: N ? /* @__PURE__ */ _("div", {
2137
+ className: `bottom-nav__page${j.pageKey > 0 ? " is-enter" : ""}`,
2138
+ style: P,
2139
2139
  role: "tabpanel",
2140
- id: `bnav-panel-${M.key}`,
2141
- "aria-labelledby": `bnav-tab-${M.key}`,
2142
- children: M.content
2143
- }, `${M.key}-${A.pageKey}`) : null
2140
+ id: `bnav-panel-${N.key}`,
2141
+ "aria-labelledby": `bnav-tab-${N.key}`,
2142
+ children: N.content
2143
+ }, `${N.key}-${j.pageKey}`) : null
2144
2144
  }) : null, /* @__PURE__ */ v("div", {
2145
- ref: p,
2145
+ ref: g,
2146
2146
  className: "bottom-nav__bar",
2147
2147
  role: "tablist",
2148
2148
  "aria-label": a,
2149
- children: [P && P.width > 0 ? /* @__PURE__ */ _("span", {
2149
+ children: [F && F.width > 0 ? /* @__PURE__ */ _("span", {
2150
2150
  className: "bottom-nav__capsule",
2151
2151
  "aria-hidden": !0,
2152
2152
  style: {
2153
- transform: `translate3d(${P.left}px, ${P.top}px, 0)`,
2154
- width: P.width,
2155
- height: P.height
2153
+ transform: `translate3d(${F.left}px, ${F.top}px, 0)`,
2154
+ width: F.width,
2155
+ height: F.height
2156
2156
  }
2157
- }) : null, e.map((e, t) => {
2158
- let n = A.blends[t] ?? 0, r = mt(x.idle, x.active, n), i = t === A.pageIndex, a = i ? A.iconScale : 1, o = Math.max(0, Math.floor(e.badge || 0));
2157
+ }) : null, c.map((e, t) => {
2158
+ let n = j.blends[t] ?? 0, r = mt(S.idle, S.active, n), i = t === j.pageIndex, a = i ? j.iconScale : 1, o = Math.max(0, Math.floor(e.badge || 0));
2159
2159
  return /* @__PURE__ */ v("button", {
2160
2160
  ref: (e) => {
2161
- g.current[t] = e;
2161
+ y.current[t] = e;
2162
2162
  },
2163
2163
  type: "button",
2164
2164
  role: "tab",
2165
2165
  id: `bnav-tab-${e.key}`,
2166
2166
  className: ["bottom-nav__tab", e.disabled ? "is-disabled" : ""].filter(Boolean).join(" "),
2167
2167
  "aria-selected": i,
2168
- "aria-controls": D ? `bnav-panel-${e.key}` : void 0,
2168
+ "aria-controls": O ? `bnav-panel-${e.key}` : void 0,
2169
2169
  tabIndex: i ? 0 : -1,
2170
- disabled: A.animating || e.disabled,
2170
+ disabled: j.animating || e.disabled,
2171
2171
  style: { color: r },
2172
- onClick: () => j(t),
2172
+ onClick: () => M(t),
2173
2173
  children: [/* @__PURE__ */ v("span", {
2174
2174
  className: "bottom-nav__icon",
2175
2175
  style: { transform: `scale(${a})` },
@@ -13652,11 +13652,11 @@ function _c({ title: e, description: t = "暂无数据", image: n, showImage: r
13652
13652
  className: "aot-empty__image",
13653
13653
  children: o
13654
13654
  }),
13655
- e ? /* @__PURE__ */ _("h3", {
13655
+ e != null && e !== !1 ? /* @__PURE__ */ _("h3", {
13656
13656
  className: "aot-empty__title",
13657
13657
  children: e
13658
13658
  }) : null,
13659
- t ? /* @__PURE__ */ _("p", {
13659
+ t != null && t !== !1 ? /* @__PURE__ */ _("p", {
13660
13660
  className: "aot-empty__desc",
13661
13661
  children: t
13662
13662
  }) : null,
@@ -14598,8 +14598,8 @@ function Zc({ index: e }) {
14598
14598
  ]
14599
14599
  });
14600
14600
  }
14601
- function Qc({ items: e = [], loaded: t = !1, className: n = "", children: r, layout: i = "feed", count: a = 6 }) {
14602
- let o = i === "grid";
14601
+ function Qc({ items: e, loaded: t = !1, className: n = "", children: r, layout: i = "feed", count: a = 6 }) {
14602
+ let o = i === "grid", s = Array.isArray(e) ? e : [], c = Math.max(1, Number(a) || 6);
14603
14603
  return /* @__PURE__ */ v("div", {
14604
14604
  className: [
14605
14605
  "feed-skeleton",
@@ -14614,7 +14614,7 @@ function Qc({ items: e = [], loaded: t = !1, className: n = "", children: r, lay
14614
14614
  className: "feed-skeleton__shimmer",
14615
14615
  "aria-hidden": !0
14616
14616
  }),
14617
- o ? Array.from({ length: Math.max(1, a) }, (e, t) => /* @__PURE__ */ _(Zc, { index: t }, `tile-${t}`)) : e.map((e, n) => /* @__PURE__ */ _(Xc, {
14617
+ o ? Array.from({ length: c }, (e, t) => /* @__PURE__ */ _(Zc, { index: t }, `tile-${t}`)) : s.map((e, n) => /* @__PURE__ */ _(Xc, {
14618
14618
  item: e,
14619
14619
  loaded: !!t,
14620
14620
  index: n
@@ -18985,7 +18985,7 @@ function af({ count: e }) {
18985
18985
  }, `sk-${t}`)) });
18986
18986
  }
18987
18987
  function of({ className: e = "", items: t, retryMs: n = $d, onRetry: r, onLoaded: i, status: a, title: o, description: s, retryText: c = "点我重试", skeletonCount: u = rf, children: d }) {
18988
- let f = a !== void 0, g = p(() => t?.length ? t : tf.map((e) => ({ ...e })), [t]), [y, b] = h(0), [x, S] = h("error"), C = f ? a : x, [w, T] = h(!1), [E, D] = h(!1), [O, k] = h(!0), [A, j] = h(!1), [M, N] = h(!1), P = m(null);
18988
+ let f = a !== void 0, g = p(() => Array.isArray(t) && t.length ? t : tf.map((e) => ({ ...e })), [t]), [y, b] = h(0), [x, S] = h("error"), C = f ? a : x, [w, T] = h(!1), [E, D] = h(!1), [O, k] = h(!0), [A, j] = h(!1), [M, N] = h(!1), P = m(null);
18989
18989
  l(() => () => {
18990
18990
  P.current != null && window.clearTimeout(P.current);
18991
18991
  }, []), l(() => {
@@ -21848,44 +21848,44 @@ function Hp() {
21848
21848
  })
21849
21849
  });
21850
21850
  }
21851
- function Up({ className: e = "", variant: t = "demo", offline: n, onOfflineChange: r, offlineText: i = "网络已断开,正在重连··", restoredText: a = "已恢复连接" }) {
21852
- let o = n !== void 0, [s, c] = h(!1), u = o ? !!n : s, [d, f] = h("hidden"), [p, g] = h(0), [y, b] = h(!1), x = m(null), S = m(!1), C = () => {
21853
- x.current != null && (window.clearTimeout(x.current), x.current = null);
21851
+ function Up({ className: e = "", variant: t, offline: n, onOfflineChange: r, offlineText: i = "网络已断开,正在重连··", restoredText: a = "已恢复连接" }) {
21852
+ let o = n !== void 0, s = t ?? (o ? "strip" : "demo"), [c, u] = h(!1), d = o ? !!n : c, [f, p] = h("hidden"), [g, y] = h(0), [b, x] = h(!1), S = m(null), C = m(!1), w = () => {
21853
+ S.current != null && (window.clearTimeout(S.current), S.current = null);
21854
21854
  };
21855
- l(() => () => C(), []), l(() => {
21856
- C(), u ? (S.current = !0, b(!0), f("offline")) : S.current ? (S.current = !1, g((e) => e + 1), f("restored"), b(!0), x.current = window.setTimeout(() => {
21857
- f("leaving"), x.current = window.setTimeout(() => {
21858
- f("hidden"), b(!1), x.current = null;
21855
+ l(() => () => w(), []), l(() => {
21856
+ w(), d ? (C.current = !0, x(!0), p("offline")) : C.current ? (C.current = !1, y((e) => e + 1), p("restored"), x(!0), S.current = window.setTimeout(() => {
21857
+ p("leaving"), S.current = window.setTimeout(() => {
21858
+ p("hidden"), x(!1), S.current = null;
21859
21859
  }, 300);
21860
- }, zp)) : (f("hidden"), b(!1));
21861
- }, [u]);
21862
- let w = (e) => {
21863
- o || c(e), r?.(e);
21864
- }, T = d === "offline" || d === "restored", E = d === "leaving", D = d === "restored" || d === "leaving", O = d !== "hidden", k = /* @__PURE__ */ v("div", {
21860
+ }, zp)) : (p("hidden"), x(!1));
21861
+ }, [d]);
21862
+ let T = (e) => {
21863
+ o || u(e), r?.(e);
21864
+ }, E = f === "offline" || f === "restored", D = f === "leaving", O = f === "restored" || f === "leaving", k = f !== "hidden", A = /* @__PURE__ */ v("div", {
21865
21865
  className: [
21866
21866
  "aot-ob__banner",
21867
- T ? "is-in" : "",
21868
- E ? "is-out is-in" : "",
21869
- D ? "is-ok" : ""
21867
+ E ? "is-in" : "",
21868
+ D ? "is-out is-in" : "",
21869
+ O ? "is-ok" : ""
21870
21870
  ].filter(Boolean).join(" "),
21871
21871
  role: "status",
21872
21872
  "aria-live": "polite",
21873
- "aria-hidden": !O,
21874
- children: [D ? /* @__PURE__ */ _("span", {
21873
+ "aria-hidden": !k,
21874
+ children: [O ? /* @__PURE__ */ _("span", {
21875
21875
  className: "aot-ob__check",
21876
21876
  children: /* @__PURE__ */ _(Hp, {})
21877
- }) : null, /* @__PURE__ */ _("span", { children: D ? a : i })]
21877
+ }) : null, /* @__PURE__ */ _("span", { children: O ? a : i })]
21878
21878
  });
21879
- return t === "strip" ? /* @__PURE__ */ _("div", {
21879
+ return s === "strip" ? /* @__PURE__ */ _("div", {
21880
21880
  className: [
21881
21881
  "aot-ob",
21882
21882
  "aot-ob--strip",
21883
- O ? "is-visible" : "is-hidden",
21883
+ k ? "is-visible" : "is-hidden",
21884
21884
  e
21885
21885
  ].filter(Boolean).join(" "),
21886
21886
  style: { "--ob-slide-ms": "300ms" },
21887
- "data-phase": d,
21888
- children: k
21887
+ "data-phase": f,
21888
+ children: A
21889
21889
  }) : /* @__PURE__ */ v("div", {
21890
21890
  className: `aot-ob${e ? ` ${e}` : ""}`,
21891
21891
  style: { "--ob-slide-ms": "300ms" },
@@ -21897,18 +21897,18 @@ function Up({ className: e = "", variant: t = "demo", offline: n, onOfflineChang
21897
21897
  children: "动态"
21898
21898
  }), /* @__PURE__ */ v("div", {
21899
21899
  className: "aot-ob__switch",
21900
- children: [/* @__PURE__ */ _("span", { children: u ? "已断网" : "网络正常" }), /* @__PURE__ */ _("button", {
21900
+ children: [/* @__PURE__ */ _("span", { children: d ? "已断网" : "网络正常" }), /* @__PURE__ */ _("button", {
21901
21901
  type: "button",
21902
- className: `aot-ob__toggle${u ? " is-on" : ""}`,
21903
- "aria-pressed": u,
21904
- "aria-label": u ? "模拟恢复网络" : "模拟断网",
21905
- onClick: () => w(!u)
21902
+ className: `aot-ob__toggle${d ? " is-on" : ""}`,
21903
+ "aria-pressed": d,
21904
+ "aria-label": d ? "模拟恢复网络" : "模拟断网",
21905
+ onClick: () => T(!d)
21906
21906
  })]
21907
21907
  })]
21908
21908
  }),
21909
- k,
21909
+ A,
21910
21910
  /* @__PURE__ */ v("div", {
21911
- className: `aot-ob__feed${y ? " has-banner" : ""}`,
21911
+ className: `aot-ob__feed${b ? " has-banner" : ""}`,
21912
21912
  children: [/* @__PURE__ */ _("p", {
21913
21913
  className: "aot-ob__hint",
21914
21914
  children: "断网时已加载内容可继续滑动;未加载图片保持灰位。打开开关模拟断网,再关掉模拟恢复。"
@@ -21925,8 +21925,8 @@ function Up({ className: e = "", variant: t = "demo", offline: n, onOfflineChang
21925
21925
  })
21926
21926
  }) : /* @__PURE__ */ _(Vp, {
21927
21927
  src: e.src,
21928
- online: !u,
21929
- loadKey: p,
21928
+ online: !d,
21929
+ loadKey: g,
21930
21930
  alt: ""
21931
21931
  }), /* @__PURE__ */ v("div", {
21932
21932
  className: "aot-ob__copy",
@@ -1,2 +1,2 @@
1
1
  import { BottomNavProps } from '../types';
2
- export declare function BottomNav({ items, index: indexProp, defaultIndex, onChange, className, "aria-label": ariaLabel, barOnly, }: BottomNavProps): import('react').JSX.Element;
2
+ export declare function BottomNav({ items: itemsProp, index: indexProp, defaultIndex, onChange, className, "aria-label": ariaLabel, barOnly, }: BottomNavProps): import('react').JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { OfflineBannerProps } from '../types';
2
- export declare function OfflineBanner({ className, variant, offline: offlineProp, onOfflineChange, offlineText, restoredText, }: OfflineBannerProps): import('react').JSX.Element;
2
+ export declare function OfflineBanner({ className, variant: variantProp, offline: offlineProp, onOfflineChange, offlineText, restoredText, }: OfflineBannerProps): import('react').JSX.Element;
@@ -5,7 +5,7 @@ export type OfflineBannerProps = {
5
5
  /**
6
6
  * `demo`:画廊完整演示(模拟开关 + 动态列表)。
7
7
  * `strip`:仅状态条,供业务壳使用。
8
- * @default "demo"
8
+ * 省略时:传了受控 `offline` → `strip`,否则 → `demo`。
9
9
  */
10
10
  variant?: OfflineBannerVariant;
11
11
  /** Controlled offline switch; omit for internal toggle (demo). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aot-ui",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "AOT React UI component kit",
5
5
  "type": "module",
6
6
  "main": "./dist-lib/aot-ui.js",