@nutui/taro-biz 0.0.1-alpha.18 → 0.0.1-alpha.19

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.
@@ -1,4 +1,4 @@
1
- import { J as e } from "../jdmaterialview.taro-C86oW55a.mjs";
1
+ import { J as e } from "../jdmaterialview.taro-BOujNGjv.mjs";
2
2
  import { J as o } from "../jdmaterialsblurtarget.taro-DCTEjmIC.mjs";
3
3
  export {
4
4
  e as JDMaterialView,
@@ -1,4 +1,8 @@
1
- import { J as e } from "../jdmaterialview.taro-C86oW55a.mjs";
1
+ import { J as r } from "../jdmaterialview.taro-BOujNGjv.mjs";
2
+ import { g as s, a as o, b as g } from "../jdmaterialview.taro-BOujNGjv.mjs";
2
3
  export {
3
- e as default
4
+ r as default,
5
+ s as getCornerRadius,
6
+ o as getFrostedPreset,
7
+ g as getPreset
4
8
  };
@@ -1,13 +1,13 @@
1
- import { jsx as R } from "react/jsx-runtime";
2
- import { useMemo as M, useState as O, useCallback as B, useEffect as N } from "react";
3
- import D from "classnames";
4
- import h, { getEnv as P } from "@tarojs/taro";
5
- import { View as w } from "@tarojs/components";
6
- import { JDIOSMaterialView as j } from "@jdtaro/ui";
7
- import { C as V } from "./typings-CdeuPEKG.mjs";
8
- const F = 26;
9
- function T(e, r, o) {
10
- const t = o >= F;
1
+ import { jsx as k } from "react/jsx-runtime";
2
+ import { useMemo as F, useState as N, useCallback as P, useEffect as j } from "react";
3
+ import V from "classnames";
4
+ import h, { getEnv as T } from "@tarojs/taro";
5
+ import { View as I } from "@tarojs/components";
6
+ import { JDIOSMaterialView as _ } from "@jdtaro/ui";
7
+ import { C as E } from "./typings-CdeuPEKG.mjs";
8
+ const $ = 26;
9
+ function H(e, r, o) {
10
+ const t = o >= $;
11
11
  switch (e) {
12
12
  case "top-solid":
13
13
  return t ? {
@@ -61,8 +61,8 @@ function T(e, r, o) {
61
61
  return {};
62
62
  }
63
63
  }
64
- function _(e, r) {
65
- const o = r >= F;
64
+ function J(e, r) {
65
+ const o = r >= $;
66
66
  switch (e) {
67
67
  case "top-bar":
68
68
  case "bottom-bar":
@@ -78,7 +78,7 @@ function _(e, r) {
78
78
  return 0;
79
79
  }
80
80
  }
81
- function I(e) {
81
+ function x(e) {
82
82
  switch (e) {
83
83
  case "top-bar":
84
84
  case "bottom-bar":
@@ -93,9 +93,9 @@ function I(e) {
93
93
  return 0;
94
94
  }
95
95
  }
96
- const y = "255, 255, 255", C = "31, 34, 38";
97
- function E(e, r) {
98
- const o = I(e);
96
+ const p = "255, 255, 255", G = "31, 34, 38";
97
+ function Y(e, r) {
98
+ const o = x(e);
99
99
  switch (e) {
100
100
  case "top-solid":
101
101
  return {
@@ -109,30 +109,30 @@ function E(e, r) {
109
109
  return {
110
110
  blurRadius: 40,
111
111
  borderRadius: o,
112
- tintColor: r ? `rgba(${C}, 0.9)` : `rgba(${y}, 0.9)`
112
+ tintColor: r ? `rgba(${G}, 0.9)` : `rgba(${p}, 0.9)`
113
113
  };
114
114
  case "promotion-fair":
115
- return { blurRadius: 40, borderRadius: o, tintColor: `rgba(${y}, 0.85)` };
115
+ return { blurRadius: 40, borderRadius: o, tintColor: `rgba(${p}, 0.85)` };
116
116
  case "promotion-deep":
117
- return { blurRadius: 40, borderRadius: o, tintColor: `rgba(${y}, 0.2)` };
117
+ return { blurRadius: 40, borderRadius: o, tintColor: `rgba(${p}, 0.2)` };
118
118
  case "immersive":
119
- return { blurRadius: 40, borderRadius: o, tintColor: `rgba(${C}, 0.4)` };
119
+ return { blurRadius: 40, borderRadius: o, tintColor: `rgba(${G}, 0.4)` };
120
120
  case "bottom-bar":
121
121
  return {
122
122
  blurRadius: 50,
123
123
  borderRadius: o,
124
- tintColor: r ? `rgba(${C}, 0.8)` : `rgba(${y}, 0.8)`
124
+ tintColor: r ? `rgba(${G}, 0.8)` : `rgba(${p}, 0.8)`
125
125
  };
126
126
  default:
127
127
  return { blurRadius: 40, borderRadius: o };
128
128
  }
129
129
  }
130
- function H(e) {
130
+ function K(e) {
131
131
  const r = e ? "0, 0, 0" : "255, 255, 255";
132
132
  return `linear-gradient(to bottom, rgba(${r}, 0.8) 0%, rgba(${r}, 0.8) 56%, rgba(${r}, 0.78) 66%, rgba(${r}, 0.72) 76%, rgba(${r}, 0.62) 86%, rgba(${r}, 0.49) 94%, rgba(${r}, 0.3) 100%)`;
133
133
  }
134
- function J(e, r) {
135
- const o = r ? "dark" : "light", t = I(e);
134
+ function Q(e, r) {
135
+ const o = r ? "dark" : "light", t = x(e);
136
136
  switch (e) {
137
137
  case "top-solid":
138
138
  return {
@@ -161,22 +161,22 @@ function J(e, r) {
161
161
  blurScale: 0.2,
162
162
  borderRadius: t,
163
163
  colorMode: o,
164
- backgroundGradient: H(r),
164
+ backgroundGradient: K(r),
165
165
  boxShadow: "0 8px 40px rgba(0, 0, 0, 0.12)"
166
166
  };
167
167
  default:
168
168
  return { blurScale: 0, borderRadius: t, colorMode: o };
169
169
  }
170
170
  }
171
- const Y = {
172
- ...V
171
+ const U = {
172
+ ...E
173
173
  };
174
- function K() {
174
+ function z() {
175
175
  return ["harmony", "harmonyhybrid", "jdharmony"].includes(
176
- P().toLowerCase()
176
+ T().toLowerCase()
177
177
  );
178
178
  }
179
- function Q() {
179
+ function W() {
180
180
  var e;
181
181
  try {
182
182
  const r = h.getSystemInfoSync(), o = String((r == null ? void 0 : r.platform) || "").toLowerCase(), t = String((r == null ? void 0 : r.system) || ""), i = o === "ios", u = i ? parseInt(((e = t.match(/\d+/)) == null ? void 0 : e[0]) || "0", 10) : 0, b = String((r == null ? void 0 : r.theme) || "").toLowerCase() === "dark";
@@ -185,7 +185,7 @@ function Q() {
185
185
  return { isIOS: !1, iosMajor: 0, dark: !1 };
186
186
  }
187
187
  }
188
- function U() {
188
+ function X() {
189
189
  try {
190
190
  const e = h.getSystemInfoSync();
191
191
  return String((e == null ? void 0 : e.theme) || "").toLowerCase() === "dark";
@@ -193,82 +193,88 @@ function U() {
193
193
  return !1;
194
194
  }
195
195
  }
196
- function z(e) {
197
- const { scene: r, dark: o, overlayColor: t, cls: i, style: u, children: b, rest: g } = e, a = r ? J(r, o) : void 0, s = {};
196
+ function Z(e) {
197
+ const { scene: r, dark: o, overlayColor: t, cls: i, style: u, children: b, rest: m } = e, a = r ? Q(r, o) : void 0, s = {};
198
198
  a ? (s.blurScale = a.blurScale, s.borderRadius = a.borderRadius, s.colorMode = a.colorMode) : s.colorMode = o ? "dark" : "light", (u == null ? void 0 : u.borderRadius) !== void 0 && (s.borderRadius = parseFloat(String(u.borderRadius)));
199
- const l = { ...u }, m = t ?? (a == null ? void 0 : a.overlayColor);
200
- return m && l.backgroundColor === void 0 && (l.backgroundColor = m), a != null && a.backgroundGradient && l.background === void 0 && (l.background = a.backgroundGradient), a != null && a.boxShadow && l.boxShadow === void 0 && (l.boxShadow = a.boxShadow), /* @__PURE__ */ R(w, { className: i, style: l, ...s, ...g, children: b });
199
+ const l = { ...u }, d = t ?? (a == null ? void 0 : a.overlayColor);
200
+ return d && l.backgroundColor === void 0 && (l.backgroundColor = d), a != null && a.backgroundGradient && l.background === void 0 && (l.background = a.backgroundGradient), a != null && a.boxShadow && l.boxShadow === void 0 && (l.boxShadow = a.boxShadow), /* @__PURE__ */ k(I, { className: i, style: l, ...s, ...m, children: b });
201
201
  }
202
- function W(e) {
203
- const { scene: r, dark: o, targetId: t, overlayColor: i, cls: u, style: b, children: g, rest: a } = e, s = r ? E(r, o) : void 0, l = { ...b };
202
+ function rr(e) {
203
+ const { scene: r, dark: o, targetId: t, overlayColor: i, cls: u, style: b, children: m, rest: a } = e, s = r ? Y(r, o) : void 0, l = { ...b };
204
204
  s && s.blurRadius > 0 && (l.backdropFilter = `blur(${s.blurRadius}px)`), s && l.borderRadius === void 0 && (l.borderRadius = `${s.borderRadius}px`);
205
- const m = i ?? (s == null ? void 0 : s.tintColor), d = {};
206
- return t && (d.targetId = t), r && (d.scene = r), m && (d.overlayColor = m), /* @__PURE__ */ R(w, { className: u, style: l, ...d, ...a, children: g });
205
+ const d = i ?? (s == null ? void 0 : s.tintColor), g = {};
206
+ return t && (g.targetId = t), r && (g.scene = r), d && (g.overlayColor = d), /* @__PURE__ */ k(I, { className: u, style: l, ...g, ...a, children: m });
207
207
  }
208
- const X = (e) => {
208
+ const or = (e) => {
209
209
  const {
210
210
  className: r,
211
211
  style: o,
212
212
  children: t,
213
213
  scene: i,
214
214
  targetId: u,
215
- liquidGlass: b,
216
- frostedGlass: g,
217
- gradientBlur: a,
218
- overlayColor: s,
219
- ...l
220
- } = { ...Y, ...e }, d = D("nut-jdmaterialview", r), { isIOS: $, iosMajor: S } = M(() => Q(), []), [f, x] = O(() => U()), v = B(
215
+ theme: b = "auto",
216
+ liquidGlass: m,
217
+ frostedGlass: a,
218
+ gradientBlur: s,
219
+ overlayColor: l,
220
+ ...d
221
+ } = { ...U, ...e }, S = V("nut-jdmaterialview", r), { isIOS: q, iosMajor: v } = F(() => W(), []), C = b === "auto", [L, A] = N(() => X()), R = P(
221
222
  (c) => {
222
- const p = typeof c == "string" ? c : String((c == null ? void 0 : c.theme) || "");
223
- x(p.toLowerCase() === "dark");
223
+ const y = typeof c == "string" ? c : String((c == null ? void 0 : c.theme) || "");
224
+ A(y.toLowerCase() === "dark");
224
225
  },
225
226
  []
226
227
  );
227
- N(() => {
228
- var c, p;
229
- try {
230
- (p = (c = h).onThemeChange) == null || p.call(c, v);
231
- } catch {
232
- }
233
- return () => {
234
- var G, k;
228
+ j(() => {
229
+ var c, y;
230
+ if (C) {
235
231
  try {
236
- (k = (G = h).offThemeChange) == null || k.call(G, v);
232
+ (y = (c = h).onThemeChange) == null || y.call(c, R);
237
233
  } catch {
238
234
  }
239
- };
240
- }, [v]);
241
- const n = M(
242
- () => i ? T(i, f, S) : void 0,
243
- [i, f, S]
244
- ), q = b ?? (n == null ? void 0 : n.liquidGlass), L = g ?? (n == null ? void 0 : n.frostedGlass), A = a ?? (n == null ? void 0 : n.gradientBlur);
245
- if ($) {
235
+ return () => {
236
+ var w, M;
237
+ try {
238
+ (M = (w = h).offThemeChange) == null || M.call(w, R);
239
+ } catch {
240
+ }
241
+ };
242
+ }
243
+ }, [C, R]);
244
+ const f = C ? L : b === "dark", n = F(
245
+ () => i ? H(i, f, v) : void 0,
246
+ [i, f, v]
247
+ ), O = m ?? (n == null ? void 0 : n.liquidGlass), B = a ?? (n == null ? void 0 : n.frostedGlass), D = s ?? (n == null ? void 0 : n.gradientBlur);
248
+ if (q) {
246
249
  const c = { ...n == null ? void 0 : n.fallbackStyle, ...o };
247
- return i && c.borderRadius === void 0 && (c.borderRadius = `${_(i, S)}px`), /* @__PURE__ */ R(
248
- j,
250
+ return i && c.borderRadius === void 0 && (c.borderRadius = `${J(i, v)}px`), /* @__PURE__ */ k(
251
+ _,
249
252
  {
250
- className: d,
253
+ className: S,
251
254
  style: c,
252
- liquidGlass: q,
253
- frostedGlass: L,
254
- gradientBlur: A,
255
- ...l,
255
+ liquidGlass: O,
256
+ frostedGlass: B,
257
+ gradientBlur: D,
258
+ ...d,
256
259
  children: t
257
260
  }
258
261
  );
259
262
  }
260
- return K() ? z({ scene: i, dark: f, overlayColor: s, cls: d, style: o, children: t, rest: l }) : W({
263
+ return z() ? Z({ scene: i, dark: f, overlayColor: l, cls: S, style: o, children: t, rest: d }) : rr({
261
264
  scene: i,
262
265
  dark: f,
263
266
  targetId: u,
264
- overlayColor: s,
265
- cls: d,
267
+ overlayColor: l,
268
+ cls: S,
266
269
  style: o,
267
270
  children: t,
268
- rest: l
271
+ rest: d
269
272
  });
270
273
  };
271
- X.displayName = "NutJDMaterialView";
274
+ or.displayName = "NutJDMaterialView";
272
275
  export {
273
- X as J
276
+ or as J,
277
+ Y as a,
278
+ H as b,
279
+ J as g
274
280
  };
@@ -1,3 +1,4 @@
1
1
  import { JDMaterialView } from './jdmaterialview.taro';
2
2
  export type { JDMaterialViewProps, MaterialScene } from './types';
3
+ export { getPreset, getCornerRadius, getFrostedPreset } from './scene-presets.taro';
3
4
  export default JDMaterialView;
@@ -0,0 +1,46 @@
1
+ import type { MaterialScene } from './types';
2
+ /**
3
+ * 解析场景材质预设。
4
+ * @param scene 材质场景
5
+ * @param dark 是否暗色(已由 theme 解析)
6
+ * @param iosMajor iOS 主版本号(非 iOS 或解析失败传 0;用于液态玻璃场景的 <26 回退)
7
+ */
8
+ export declare function getPreset(scene: MaterialScene, dark: boolean, iosMajor: number): MaterialPreset;
9
+ /**
10
+ * 解析场景默认圆角(业务未传 borderRadius 时使用)。
11
+ * 对齐 ObjC JDGlassContainerView 的 effectiveCornerRadius:
12
+ * - 背板(top-bar / bottom-bar)恒 0;
13
+ * - top 容器 iOS≥26 用玻璃时 12,<26 回退 8;
14
+ * - top-plain 透明回退时 <26 归 0(透明无背景,圆角无意义)。
15
+ * @param scene 材质场景
16
+ * @param iosMajor iOS 主版本号(<26 走回退圆角)
17
+ */
18
+ export declare function getCornerRadius(scene: MaterialScene, iosMajor: number): number;
19
+ /**
20
+ * 非 iOS(安卓 / 鸿蒙)场景圆角。安卓与鸿蒙圆角完全一致,共用此函数(设计已对齐):
21
+ * - 悬浮容器(top-solid / top-plain / promotion-fair / promotion-deep / immersive):8
22
+ * - 背板(top-bar / bottom-bar):0
23
+ * 日夜一致、与平台/版本无关。iOS 圆角另走 getCornerRadius(按版本回退,规则不同)。
24
+ * @param scene 材质场景
25
+ */
26
+ export declare function getNonIOSCornerRadius(scene: MaterialScene): number;
27
+ /**
28
+ * 解析非 iOS 场景毛玻璃预设。
29
+ * 对齐安卓 GlassStyle:blurRadius + borderRadius + 叠加色(tintColor = rgba(overlayRGB, alpha%))。
30
+ * 圆角为安卓专用:每场景定值、日夜一致、与 iOS 版本无关(bottom-bar 为 0,其余 12),
31
+ * 不复用 iOS 的 getCornerRadius(后者按版本回退且 top-bar 恒 0,规则不同)。
32
+ * @param scene 材质场景
33
+ * @param dark 是否暗色(已由 theme 解析)
34
+ */
35
+ export declare function getFrostedPreset(scene: MaterialScene, dark: boolean): FrostedPreset;
36
+ /**
37
+ * 解析鸿蒙场景预设。blurScale / borderRadius / colorMode 透传鸿蒙原生 prop;
38
+ * overlayColor 落 CSS style.backgroundColor(非原生属性)。
39
+ * colorMode 由「场景」决定,而非简单跟随系统:
40
+ * - promotion-fair / promotion-deep 恒 light;immersive 恒 dark;
41
+ * - 其余场景(top-solid / top-plain / top-bar / bottom-bar)跟随系统明暗。
42
+ * overlayColor 仅 top-solid 有(随明暗),其余场景颜色靠 colorMode 控制。
43
+ * @param scene 材质场景
44
+ * @param dark 是否暗色(已由 theme 解析,用于跟随系统的场景)
45
+ */
46
+ export declare function getHarmonyPreset(scene: MaterialScene, dark: boolean): HarmonyPreset;
@@ -17,4 +17,9 @@ export interface JDMaterialViewProps extends BasicComponent {
17
17
  scene: MaterialScene;
18
18
  /** 模糊源 targetId,与 JDMaterialsBlurTarget 的 blurId 对应 */
19
19
  targetId: string;
20
+ /**
21
+ * 明暗主题。默认 auto 跟随系统主题;传 light / dark 则固定为对应明暗、
22
+ * 不再随系统主题变化。(immersive、promotion-* 等场景明暗由场景语义固定,不受影响)
23
+ */
24
+ theme?: 'auto' | 'light' | 'dark';
20
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nutui/taro-biz",
3
- "version": "0.0.1-alpha.18",
3
+ "version": "0.0.1-alpha.19",
4
4
  "main": "dist/es/index/index.js",
5
5
  "module": "dist/es/index/index.js",
6
6
  "types": "dist/es/index/index.d.ts",