@nutui/taro-biz 0.0.1-alpha.7 → 0.0.1-alpha.9

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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../jdmaterialview.taro-0ZhXkmW9.js"),r=require("../jdmaterialsblurtarget.taro-BbcxTuKJ.js");exports.JDMaterialView=e.JDMaterialView;exports.JDMaterialsBlurTarget=r.JDMaterialsBlurTarget;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../jdmaterialview.taro-BocjWSVM.js"),r=require("../jdmaterialsblurtarget.taro-BbcxTuKJ.js");exports.JDMaterialView=e.JDMaterialView;exports.JDMaterialsBlurTarget=r.JDMaterialsBlurTarget;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jdmaterialview.taro-0ZhXkmW9.js");exports.default=e.JDMaterialView;exports.getCornerRadius=e.getCornerRadius;exports.getFrostedPreset=e.getFrostedPreset;exports.getPreset=e.getPreset;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jdmaterialview.taro-BocjWSVM.js");exports.default=e.JDMaterialView;exports.getCornerRadius=e.getCornerRadius;exports.getFrostedPreset=e.getFrostedPreset;exports.getPreset=e.getPreset;
@@ -0,0 +1 @@
1
+ "use strict";const C=require("react/jsx-runtime"),f=require("react"),P=require("classnames"),d=require("@tarojs/taro"),M=require("@tarojs/components"),j=require("@jdtaro/ui"),x=require("./typings-DP_XKs5o.js"),w=26;function F(t,r,e){const s=e>=w;switch(t){case"top-solid":return s?{liquidGlass:{style:"regular",interactive:!0,tintColor:r?"rgba(0, 0, 0, 0.75)":"rgba(255, 255, 255, 0.45)",showTintOverlay:r}}:{fallbackStyle:{backgroundColor:r?"#2A2F36":"#FFFFFF"}};case"top-plain":return s?{liquidGlass:{style:"regular",interactive:!0,tintColor:r?"rgba(0, 0, 0, 0.75)":"rgba(255, 255, 255, 0.45)",showTintOverlay:r}}:{};case"top-bar":return{frostedGlass:{style:r?"thick-dark":"thick-light"}};case"promotion-fair":return{liquidGlass:{style:"clear",interactive:!1},frostedGlass:{style:"thick-light",alpha:.85}};case"promotion-deep":return{liquidGlass:{style:"clear",interactive:!1},frostedGlass:{style:"thick-light",alpha:.35}};case"immersive":return s?{liquidGlass:{style:"regular",forceDark:!0,interactive:!0,tintColor:"rgba(0, 0, 0, 0.75)"}}:{frostedGlass:{style:"regular-dark",alpha:.4}};case"bottom-bar":return{gradientBlur:{minBlur:.5,maxBlur:.8,overlayAlpha:.9,overlayColor:r?"rgba(0, 0, 0, 1)":"rgba(255, 255, 255, 1)"}};default:return{}}}function $(t,r){const e=r>=w;switch(t){case"top-bar":case"bottom-bar":return 0;case"top-plain":return e?12:0;case"top-solid":case"promotion-fair":case"promotion-deep":case"immersive":return e?12:8;default:return 0}}const R="255, 255, 255",S="31, 34, 38";function q(t,r){switch(t){case"top-solid":return{blurRadius:40,borderRadius:12,tintColor:r?"rgba(42, 47, 54, 1)":"rgba(255, 255, 255, 1)"};case"top-plain":return{blurRadius:40,borderRadius:12};case"top-bar":return{blurRadius:40,borderRadius:12,tintColor:r?`rgba(${S}, 0.9)`:`rgba(${R}, 0.9)`};case"promotion-fair":return{blurRadius:40,borderRadius:12,tintColor:`rgba(${R}, 0.85)`};case"promotion-deep":return{blurRadius:40,borderRadius:12,tintColor:`rgba(${R}, 0.2)`};case"immersive":return{blurRadius:40,borderRadius:12,tintColor:`rgba(${S}, 0.4)`};case"bottom-bar":return{blurRadius:50,borderRadius:0,tintColor:r?`rgba(${S}, 0.8)`:`rgba(${R}, 0.8)`};default:return{blurRadius:40,borderRadius:12}}}function N(t,r){const e=r?"dark":"light";switch(t){case"top-solid":return{blurScale:1,borderRadius:8,colorMode:e,overlayColor:r?"#2A2F36":"#FFFFFF"};case"top-plain":return{blurScale:0,borderRadius:8,colorMode:e};case"top-bar":return{blurScale:.9,borderRadius:0,colorMode:e};case"promotion-fair":return{blurScale:.85,borderRadius:8,colorMode:"light"};case"promotion-deep":return{blurScale:.2,borderRadius:8,colorMode:"light"};case"immersive":return{blurScale:.4,borderRadius:8,colorMode:"dark"};case"bottom-bar":return{blurScale:.2,borderRadius:0,colorMode:e};default:return{blurScale:0,borderRadius:0,colorMode:e}}}const V={...x.ComponentDefaults};function B(){return["harmony","harmonyhybrid","jdharmony"].includes(d.getEnv().toLowerCase())}function _(){var t;try{const r=d.getSystemInfoSync(),e=String((r==null?void 0:r.platform)||"").toLowerCase(),s=String((r==null?void 0:r.system)||""),a=e==="ios",i=a?parseInt(((t=s.match(/\d+/))==null?void 0:t[0])||"0",10):0,m=String((r==null?void 0:r.theme)||"").toLowerCase()==="dark";return{isIOS:a,iosMajor:i,dark:m}}catch{return{isIOS:!1,iosMajor:0,dark:!1}}}function E(){try{const t=d.getSystemInfoSync();return String((t==null?void 0:t.theme)||"").toLowerCase()==="dark"}catch{return!1}}function H(t){const{scene:r,dark:e,overlayColor:s,cls:a,style:i,children:m,rest:g}=t,n=r?N(r,e):void 0,o={};n?(o.blurScale=n.blurScale,o.borderRadius=n.borderRadius,o.colorMode=n.colorMode):o.colorMode=e?"dark":"light",(i==null?void 0:i.borderRadius)!==void 0&&(o.borderRadius=parseFloat(String(i.borderRadius)));const u=s??(n==null?void 0:n.overlayColor);return u&&(o.overlayColor=u),C.jsx(M.View,{className:a,style:i,...o,...g,children:m})}function J(t){const{scene:r,dark:e,targetId:s,overlayColor:a,cls:i,style:m,children:g,rest:n}=t,o=r?q(r,e):void 0,u={...m};o&&o.blurRadius>0&&(u.backdropFilter=`blur(${o.blurRadius}px)`),o&&u.borderRadius===void 0&&(u.borderRadius=`${o.borderRadius}px`);const p=a??(o==null?void 0:o.tintColor),b={};return s&&(b.targetId=s),r&&(b.scene=r),p&&(b.overlayColor=p),C.jsx(M.View,{className:i,style:u,...b,...n,children:g})}const k=t=>{const{className:r,style:e,children:s,scene:a,targetId:i,liquidGlass:m,frostedGlass:g,gradientBlur:n,overlayColor:o,...u}={...V,...t},b=P("nut-jdmaterialview",r),{isIOS:I,iosMajor:G}=f.useMemo(()=>_(),[]),[y,L]=f.useState(()=>E()),v=f.useCallback(c=>{const h=typeof c=="string"?c:String((c==null?void 0:c.theme)||"");L(h.toLowerCase()==="dark")},[]);f.useEffect(()=>{var c;try{(c=d.onThemeChange)==null||c.call(d,v)}catch{}return()=>{var h;try{(h=d.offThemeChange)==null||h.call(d,v)}catch{}}},[v]);const l=f.useMemo(()=>a?F(a,y,G):void 0,[a,y,G]),O=m??(l==null?void 0:l.liquidGlass),A=g??(l==null?void 0:l.frostedGlass),D=n??(l==null?void 0:l.gradientBlur);if(I){const c={...l==null?void 0:l.fallbackStyle,...e};return C.jsx(j.JDIOSMaterialView,{className:b,style:c,liquidGlass:O,frostedGlass:A,gradientBlur:D,...u,children:s})}return B()?H({scene:a,dark:y,overlayColor:o,cls:b,style:e,children:s,rest:u}):J({scene:a,dark:y,targetId:i,overlayColor:o,cls:b,style:e,children:s,rest:u})};k.displayName="NutJDMaterialView";exports.JDMaterialView=k;exports.getCornerRadius=$;exports.getFrostedPreset=q;exports.getPreset=F;
@@ -1,4 +1,4 @@
1
- import { J as e } from "../jdmaterialview.taro-Ch_ytSl9.mjs";
1
+ import { J as e } from "../jdmaterialview.taro-B3s_ZzgX.mjs";
2
2
  import { J as o } from "../jdmaterialsblurtarget.taro-DCTEjmIC.mjs";
3
3
  export {
4
4
  e as JDMaterialView,
@@ -1,5 +1,5 @@
1
- import { J as r } from "../jdmaterialview.taro-Ch_ytSl9.mjs";
2
- import { g as s, a as o, b as g } from "../jdmaterialview.taro-Ch_ytSl9.mjs";
1
+ import { J as r } from "../jdmaterialview.taro-B3s_ZzgX.mjs";
2
+ import { g as s, a as o, b as g } from "../jdmaterialview.taro-B3s_ZzgX.mjs";
3
3
  export {
4
4
  r as default,
5
5
  s as getCornerRadius,
@@ -0,0 +1,246 @@
1
+ import { jsx as S } from "react/jsx-runtime";
2
+ import { useMemo as F, useState as D, useCallback as $, useEffect as N } from "react";
3
+ import P from "classnames";
4
+ import h, { getEnv as x } from "@tarojs/taro";
5
+ import { View as w } from "@tarojs/components";
6
+ import { JDIOSMaterialView as B } from "@jdtaro/ui";
7
+ import { C as T } from "./typings-CdeuPEKG.mjs";
8
+ const k = 26;
9
+ function j(o, r, e) {
10
+ const a = e >= k;
11
+ switch (o) {
12
+ case "top-solid":
13
+ return a ? {
14
+ liquidGlass: {
15
+ style: "regular",
16
+ interactive: !0,
17
+ tintColor: r ? "rgba(0, 0, 0, 0.75)" : "rgba(255, 255, 255, 0.45)",
18
+ showTintOverlay: r
19
+ }
20
+ } : { fallbackStyle: { backgroundColor: r ? "#2A2F36" : "#FFFFFF" } };
21
+ case "top-plain":
22
+ return a ? {
23
+ liquidGlass: {
24
+ style: "regular",
25
+ interactive: !0,
26
+ tintColor: r ? "rgba(0, 0, 0, 0.75)" : "rgba(255, 255, 255, 0.45)",
27
+ showTintOverlay: r
28
+ }
29
+ } : {};
30
+ case "top-bar":
31
+ return { frostedGlass: { style: r ? "thick-dark" : "thick-light" } };
32
+ case "promotion-fair":
33
+ return {
34
+ liquidGlass: { style: "clear", interactive: !1 },
35
+ frostedGlass: { style: "thick-light", alpha: 0.85 }
36
+ };
37
+ case "promotion-deep":
38
+ return {
39
+ liquidGlass: { style: "clear", interactive: !1 },
40
+ frostedGlass: { style: "thick-light", alpha: 0.35 }
41
+ };
42
+ case "immersive":
43
+ return a ? {
44
+ liquidGlass: {
45
+ style: "regular",
46
+ forceDark: !0,
47
+ interactive: !0,
48
+ tintColor: "rgba(0, 0, 0, 0.75)"
49
+ }
50
+ } : { frostedGlass: { style: "regular-dark", alpha: 0.4 } };
51
+ case "bottom-bar":
52
+ return {
53
+ gradientBlur: {
54
+ minBlur: 0.5,
55
+ maxBlur: 0.8,
56
+ overlayAlpha: 0.9,
57
+ overlayColor: r ? "rgba(0, 0, 0, 1)" : "rgba(255, 255, 255, 1)"
58
+ }
59
+ };
60
+ default:
61
+ return {};
62
+ }
63
+ }
64
+ function tr(o, r) {
65
+ const e = r >= k;
66
+ switch (o) {
67
+ case "top-bar":
68
+ case "bottom-bar":
69
+ return 0;
70
+ case "top-plain":
71
+ return e ? 12 : 0;
72
+ case "top-solid":
73
+ case "promotion-fair":
74
+ case "promotion-deep":
75
+ case "immersive":
76
+ return e ? 12 : 8;
77
+ default:
78
+ return 0;
79
+ }
80
+ }
81
+ const y = "255, 255, 255", v = "31, 34, 38";
82
+ function V(o, r) {
83
+ switch (o) {
84
+ case "top-solid":
85
+ return {
86
+ blurRadius: 40,
87
+ borderRadius: 12,
88
+ tintColor: r ? "rgba(42, 47, 54, 1)" : "rgba(255, 255, 255, 1)"
89
+ };
90
+ case "top-plain":
91
+ return { blurRadius: 40, borderRadius: 12 };
92
+ case "top-bar":
93
+ return {
94
+ blurRadius: 40,
95
+ borderRadius: 12,
96
+ tintColor: r ? `rgba(${v}, 0.9)` : `rgba(${y}, 0.9)`
97
+ };
98
+ case "promotion-fair":
99
+ return { blurRadius: 40, borderRadius: 12, tintColor: `rgba(${y}, 0.85)` };
100
+ case "promotion-deep":
101
+ return { blurRadius: 40, borderRadius: 12, tintColor: `rgba(${y}, 0.2)` };
102
+ case "immersive":
103
+ return { blurRadius: 40, borderRadius: 12, tintColor: `rgba(${v}, 0.4)` };
104
+ case "bottom-bar":
105
+ return {
106
+ blurRadius: 50,
107
+ borderRadius: 0,
108
+ tintColor: r ? `rgba(${v}, 0.8)` : `rgba(${y}, 0.8)`
109
+ };
110
+ default:
111
+ return { blurRadius: 40, borderRadius: 12 };
112
+ }
113
+ }
114
+ function _(o, r) {
115
+ const e = r ? "dark" : "light";
116
+ switch (o) {
117
+ case "top-solid":
118
+ return {
119
+ blurScale: 1,
120
+ borderRadius: 8,
121
+ colorMode: e,
122
+ overlayColor: r ? "#2A2F36" : "#FFFFFF"
123
+ };
124
+ case "top-plain":
125
+ return { blurScale: 0, borderRadius: 8, colorMode: e };
126
+ case "top-bar":
127
+ return { blurScale: 0.9, borderRadius: 0, colorMode: e };
128
+ case "promotion-fair":
129
+ return { blurScale: 0.85, borderRadius: 8, colorMode: "light" };
130
+ case "promotion-deep":
131
+ return { blurScale: 0.2, borderRadius: 8, colorMode: "light" };
132
+ case "immersive":
133
+ return { blurScale: 0.4, borderRadius: 8, colorMode: "dark" };
134
+ case "bottom-bar":
135
+ return { blurScale: 0.2, borderRadius: 0, colorMode: e };
136
+ default:
137
+ return { blurScale: 0, borderRadius: 0, colorMode: e };
138
+ }
139
+ }
140
+ const E = {
141
+ ...T
142
+ };
143
+ function H() {
144
+ return ["harmony", "harmonyhybrid", "jdharmony"].includes(
145
+ x().toLowerCase()
146
+ );
147
+ }
148
+ function J() {
149
+ var o;
150
+ try {
151
+ const r = h.getSystemInfoSync(), e = String((r == null ? void 0 : r.platform) || "").toLowerCase(), a = String((r == null ? void 0 : r.system) || ""), s = e === "ios", i = s ? parseInt(((o = a.match(/\d+/)) == null ? void 0 : o[0]) || "0", 10) : 0, b = String((r == null ? void 0 : r.theme) || "").toLowerCase() === "dark";
152
+ return { isIOS: s, iosMajor: i, dark: b };
153
+ } catch {
154
+ return { isIOS: !1, iosMajor: 0, dark: !1 };
155
+ }
156
+ }
157
+ function Y() {
158
+ try {
159
+ const o = h.getSystemInfoSync();
160
+ return String((o == null ? void 0 : o.theme) || "").toLowerCase() === "dark";
161
+ } catch {
162
+ return !1;
163
+ }
164
+ }
165
+ function K(o) {
166
+ const { scene: r, dark: e, overlayColor: a, cls: s, style: i, children: b, rest: m } = o, n = r ? _(r, e) : void 0, t = {};
167
+ n ? (t.blurScale = n.blurScale, t.borderRadius = n.borderRadius, t.colorMode = n.colorMode) : t.colorMode = e ? "dark" : "light", (i == null ? void 0 : i.borderRadius) !== void 0 && (t.borderRadius = parseFloat(String(i.borderRadius)));
168
+ const u = a ?? (n == null ? void 0 : n.overlayColor);
169
+ return u && (t.overlayColor = u), /* @__PURE__ */ S(w, { className: s, style: i, ...t, ...m, children: b });
170
+ }
171
+ function Q(o) {
172
+ const { scene: r, dark: e, targetId: a, overlayColor: s, cls: i, style: b, children: m, rest: n } = o, t = r ? V(r, e) : void 0, u = { ...b };
173
+ t && t.blurRadius > 0 && (u.backdropFilter = `blur(${t.blurRadius}px)`), t && u.borderRadius === void 0 && (u.borderRadius = `${t.borderRadius}px`);
174
+ const p = s ?? (t == null ? void 0 : t.tintColor), d = {};
175
+ return a && (d.targetId = a), r && (d.scene = r), p && (d.overlayColor = p), /* @__PURE__ */ S(w, { className: i, style: u, ...d, ...n, children: m });
176
+ }
177
+ const U = (o) => {
178
+ const {
179
+ className: r,
180
+ style: e,
181
+ children: a,
182
+ scene: s,
183
+ targetId: i,
184
+ liquidGlass: b,
185
+ frostedGlass: m,
186
+ gradientBlur: n,
187
+ overlayColor: t,
188
+ ...u
189
+ } = { ...E, ...o }, d = P("nut-jdmaterialview", r), { isIOS: I, iosMajor: C } = F(() => J(), []), [f, q] = D(() => Y()), R = $(
190
+ (c) => {
191
+ const g = typeof c == "string" ? c : String((c == null ? void 0 : c.theme) || "");
192
+ q(g.toLowerCase() === "dark");
193
+ },
194
+ []
195
+ );
196
+ N(() => {
197
+ var c, g;
198
+ try {
199
+ (g = (c = h).onThemeChange) == null || g.call(c, R);
200
+ } catch {
201
+ }
202
+ return () => {
203
+ var G, M;
204
+ try {
205
+ (M = (G = h).offThemeChange) == null || M.call(G, R);
206
+ } catch {
207
+ }
208
+ };
209
+ }, [R]);
210
+ const l = F(
211
+ () => s ? j(s, f, C) : void 0,
212
+ [s, f, C]
213
+ ), L = b ?? (l == null ? void 0 : l.liquidGlass), O = m ?? (l == null ? void 0 : l.frostedGlass), A = n ?? (l == null ? void 0 : l.gradientBlur);
214
+ if (I) {
215
+ const c = { ...l == null ? void 0 : l.fallbackStyle, ...e };
216
+ return /* @__PURE__ */ S(
217
+ B,
218
+ {
219
+ className: d,
220
+ style: c,
221
+ liquidGlass: L,
222
+ frostedGlass: O,
223
+ gradientBlur: A,
224
+ ...u,
225
+ children: a
226
+ }
227
+ );
228
+ }
229
+ return H() ? K({ scene: s, dark: f, overlayColor: t, cls: d, style: e, children: a, rest: u }) : Q({
230
+ scene: s,
231
+ dark: f,
232
+ targetId: i,
233
+ overlayColor: t,
234
+ cls: d,
235
+ style: e,
236
+ children: a,
237
+ rest: u
238
+ });
239
+ };
240
+ U.displayName = "NutJDMaterialView";
241
+ export {
242
+ U as J,
243
+ V as a,
244
+ j as b,
245
+ tr as g
246
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nutui/taro-biz",
3
- "version": "0.0.1-alpha.7",
3
+ "version": "0.0.1-alpha.9",
4
4
  "main": "dist/cjs/index/index.js",
5
5
  "module": "dist/es/index/index.js",
6
6
  "sideEffects": [
@@ -1 +0,0 @@
1
- "use strict";const R=require("react/jsx-runtime"),m=require("react"),B=require("classnames"),u=require("@tarojs/taro"),F=require("@tarojs/components"),L=require("@jdtaro/ui"),j=require("./typings-DP_XKs5o.js"),q=26;function I(e,r,t){const a=t>=q;switch(e){case"top-solid":return a?{liquidGlass:{style:"regular",interactive:!0,tintColor:r?"rgba(0, 0, 0, 0.75)":"rgba(255, 255, 255, 0.45)",showTintOverlay:r}}:{fallbackStyle:{backgroundColor:r?"#2A2F36":"#FFFFFF"}};case"top-plain":return a?{liquidGlass:{style:"regular",interactive:!0,tintColor:r?"rgba(0, 0, 0, 0.75)":"rgba(255, 255, 255, 0.45)",showTintOverlay:r}}:{};case"top-bar":return{frostedGlass:{style:r?"thick-dark":"thick-light"}};case"promotion-fair":return{liquidGlass:{style:"clear",interactive:!1},frostedGlass:{style:"thick-light",alpha:.85}};case"promotion-deep":return{liquidGlass:{style:"clear",interactive:!1},frostedGlass:{style:"thick-light",alpha:.35}};case"immersive":return a?{liquidGlass:{style:"regular",forceDark:!0,interactive:!0,tintColor:"rgba(0, 0, 0, 0.75)"}}:{frostedGlass:{style:"regular-dark",alpha:.4}};case"bottom-bar":return{gradientBlur:{minBlur:.5,maxBlur:.8,overlayAlpha:.9,overlayColor:r?"rgba(0, 0, 0, 1)":"rgba(255, 255, 255, 1)"}};default:return{}}}function D(e,r){const t=r>=q;switch(e){case"top-bar":case"bottom-bar":return 0;case"top-plain":return t?12:0;case"top-solid":case"promotion-fair":case"promotion-deep":case"immersive":return t?12:8;default:return 0}}const h="255, 255, 255",G="31, 34, 38";function P(e,r){switch(e){case"top-solid":return{blurRadius:40,tintColor:r?"rgba(42, 47, 54, 1)":"rgba(255, 255, 255, 1)"};case"top-plain":return{blurRadius:40};case"top-bar":return{blurRadius:40,tintColor:r?`rgba(${G}, 0.9)`:`rgba(${h}, 0.9)`};case"promotion-fair":return{blurRadius:40,tintColor:`rgba(${h}, 0.85)`};case"promotion-deep":return{blurRadius:40,tintColor:`rgba(${h}, 0.2)`};case"immersive":return{blurRadius:40,tintColor:`rgba(${G}, 0.4)`};case"bottom-bar":return{blurRadius:50,tintColor:r?`rgba(${G}, 0.8)`:`rgba(${h}, 0.8)`};default:return{blurRadius:40}}}function $(e,r){const t=r?"dark":"light";switch(e){case"top-solid":return{blurScale:1,borderRadius:8,colorMode:t,overlayColor:r?"#2A2F36":"#FFFFFF"};case"top-plain":return{blurScale:0,borderRadius:8,colorMode:t};case"top-bar":return{blurScale:.9,borderRadius:0,colorMode:t};case"promotion-fair":return{blurScale:.85,borderRadius:8,colorMode:"light"};case"promotion-deep":return{blurScale:.2,borderRadius:8,colorMode:"light"};case"immersive":return{blurScale:.4,borderRadius:8,colorMode:"dark"};case"bottom-bar":return{blurScale:.2,borderRadius:0,colorMode:t};default:return{blurScale:0,borderRadius:0,colorMode:t}}}const N={...j.ComponentDefaults};function V(){return["harmony","harmonyhybrid","jdharmony"].includes(u.getEnv().toLowerCase())}function _(e){return e.style.startsWith("thin")?10:e.style.startsWith("thick")?40:20}function E(e){const r={},t=e.maxBlur??0;return t>0&&(r.backdropFilter=`blur(${t*50}px)`),e.overlayAlpha&&e.overlayAlpha>0&&(r.backgroundColor=e.overlayColor||"rgba(255,255,255,1)",r.opacity=e.overlayAlpha),r}function H(){var e;try{const r=u.getSystemInfoSync(),t=String((r==null?void 0:r.platform)||"").toLowerCase(),a=String((r==null?void 0:r.system)||""),o=t==="ios",d=o?parseInt(((e=a.match(/\d+/))==null?void 0:e[0])||"0",10):0,y=String((r==null?void 0:r.theme)||"").toLowerCase()==="dark";return{isIOS:o,iosMajor:d,dark:y}}catch{return{isIOS:!1,iosMajor:0,dark:!1}}}function J(){try{const e=u.getSystemInfoSync();return String((e==null?void 0:e.theme)||"").toLowerCase()==="dark"}catch{return!1}}function T(e){const{scene:r,dark:t,overlayColor:a,cls:o,style:d,children:y,rest:g}=e,l=r?$(r,t):void 0,i={};l?(i.blurScale=l.blurScale,i.borderRadius=l.borderRadius,i.colorMode=l.colorMode):i.colorMode=t?"dark":"light";const n=a??(l==null?void 0:l.overlayColor);return n&&(i.overlayColor=n),R.jsx(F.View,{className:o,style:d,...i,...g,children:y})}function W(e){const{scene:r,targetId:t,overlayColor:a,frostedGlass:o,gradientBlur:d,cls:y,style:g,children:l,rest:i}=e,n={...g};if(o){const v=_(o);n.backdropFilter=`blur(${v}px)`,o.alpha!==void 0&&(n.opacity=o.alpha)}else d&&Object.assign(n,E(d));const p=a??(o?o.style.endsWith("-dark")?"rgba(0, 0, 0, 0.3)":"rgba(255, 255, 255, 0.3)":void 0),b={};return t&&(b.targetId=t),r&&(b.scene=r),p&&(b.overlayColor=p),R.jsx(F.View,{className:y,style:n,...b,...i,children:l})}const A=e=>{const{className:r,style:t,children:a,scene:o,targetId:d,liquidGlass:y,frostedGlass:g,gradientBlur:l,overlayColor:i,...n}={...N,...e},b=B("nut-jdmaterialview",r),{isIOS:v,iosMajor:M}=m.useMemo(()=>H(),[]),[S,O]=m.useState(()=>J()),C=m.useCallback(c=>{const f=typeof c=="string"?c:String((c==null?void 0:c.theme)||"");O(f.toLowerCase()==="dark")},[]);m.useEffect(()=>{var c;try{(c=u.onThemeChange)==null||c.call(u,C)}catch{}return()=>{var f;try{(f=u.offThemeChange)==null||f.call(u,C)}catch{}}},[C]);const s=m.useMemo(()=>o?I(o,S,M):void 0,[o,S,M]),x=y??(s==null?void 0:s.liquidGlass),k=g??(s==null?void 0:s.frostedGlass),w=l??(s==null?void 0:s.gradientBlur);if(v){const c={...s==null?void 0:s.fallbackStyle,...t};return R.jsx(L.JDIOSMaterialView,{className:b,style:c,liquidGlass:x,frostedGlass:k,gradientBlur:w,...n,children:a})}return V()?T({scene:o,dark:S,overlayColor:i,cls:b,style:t,children:a,rest:n}):W({scene:o,targetId:d,overlayColor:i,frostedGlass:k,gradientBlur:w,cls:b,style:t,children:a,rest:n})};A.displayName="NutJDMaterialView";exports.JDMaterialView=A;exports.getCornerRadius=D;exports.getFrostedPreset=P;exports.getPreset=I;
@@ -1,254 +0,0 @@
1
- import { jsx as G } from "react/jsx-runtime";
2
- import { useMemo as I, useState as L, useCallback as x, useEffect as D } from "react";
3
- import $ from "classnames";
4
- import g, { getEnv as N } from "@tarojs/taro";
5
- import { View as A } from "@tarojs/components";
6
- import { JDIOSMaterialView as P } from "@jdtaro/ui";
7
- import { C as j } from "./typings-CdeuPEKG.mjs";
8
- const O = 26;
9
- function T(e, r, t) {
10
- const a = t >= O;
11
- switch (e) {
12
- case "top-solid":
13
- return a ? {
14
- liquidGlass: {
15
- style: "regular",
16
- interactive: !0,
17
- tintColor: r ? "rgba(0, 0, 0, 0.75)" : "rgba(255, 255, 255, 0.45)",
18
- showTintOverlay: r
19
- }
20
- } : { fallbackStyle: { backgroundColor: r ? "#2A2F36" : "#FFFFFF" } };
21
- case "top-plain":
22
- return a ? {
23
- liquidGlass: {
24
- style: "regular",
25
- interactive: !0,
26
- tintColor: r ? "rgba(0, 0, 0, 0.75)" : "rgba(255, 255, 255, 0.45)",
27
- showTintOverlay: r
28
- }
29
- } : {};
30
- case "top-bar":
31
- return { frostedGlass: { style: r ? "thick-dark" : "thick-light" } };
32
- case "promotion-fair":
33
- return {
34
- liquidGlass: { style: "clear", interactive: !1 },
35
- frostedGlass: { style: "thick-light", alpha: 0.85 }
36
- };
37
- case "promotion-deep":
38
- return {
39
- liquidGlass: { style: "clear", interactive: !1 },
40
- frostedGlass: { style: "thick-light", alpha: 0.35 }
41
- };
42
- case "immersive":
43
- return a ? {
44
- liquidGlass: {
45
- style: "regular",
46
- forceDark: !0,
47
- interactive: !0,
48
- tintColor: "rgba(0, 0, 0, 0.75)"
49
- }
50
- } : { frostedGlass: { style: "regular-dark", alpha: 0.4 } };
51
- case "bottom-bar":
52
- return {
53
- gradientBlur: {
54
- minBlur: 0.5,
55
- maxBlur: 0.8,
56
- overlayAlpha: 0.9,
57
- overlayColor: r ? "rgba(0, 0, 0, 1)" : "rgba(255, 255, 255, 1)"
58
- }
59
- };
60
- default:
61
- return {};
62
- }
63
- }
64
- function ar(e, r) {
65
- const t = r >= O;
66
- switch (e) {
67
- case "top-bar":
68
- case "bottom-bar":
69
- return 0;
70
- case "top-plain":
71
- return t ? 12 : 0;
72
- case "top-solid":
73
- case "promotion-fair":
74
- case "promotion-deep":
75
- case "immersive":
76
- return t ? 12 : 8;
77
- default:
78
- return 0;
79
- }
80
- }
81
- const y = "255, 255, 255", C = "31, 34, 38";
82
- function sr(e, r) {
83
- switch (e) {
84
- case "top-solid":
85
- return {
86
- blurRadius: 40,
87
- tintColor: r ? "rgba(42, 47, 54, 1)" : "rgba(255, 255, 255, 1)"
88
- };
89
- case "top-plain":
90
- return { blurRadius: 40 };
91
- case "top-bar":
92
- return {
93
- blurRadius: 40,
94
- tintColor: r ? `rgba(${C}, 0.9)` : `rgba(${y}, 0.9)`
95
- };
96
- case "promotion-fair":
97
- return { blurRadius: 40, tintColor: `rgba(${y}, 0.85)` };
98
- case "promotion-deep":
99
- return { blurRadius: 40, tintColor: `rgba(${y}, 0.2)` };
100
- case "immersive":
101
- return { blurRadius: 40, tintColor: `rgba(${C}, 0.4)` };
102
- case "bottom-bar":
103
- return {
104
- blurRadius: 50,
105
- tintColor: r ? `rgba(${C}, 0.8)` : `rgba(${y}, 0.8)`
106
- };
107
- default:
108
- return { blurRadius: 40 };
109
- }
110
- }
111
- function V(e, r) {
112
- const t = r ? "dark" : "light";
113
- switch (e) {
114
- case "top-solid":
115
- return {
116
- blurScale: 1,
117
- borderRadius: 8,
118
- colorMode: t,
119
- overlayColor: r ? "#2A2F36" : "#FFFFFF"
120
- };
121
- case "top-plain":
122
- return { blurScale: 0, borderRadius: 8, colorMode: t };
123
- case "top-bar":
124
- return { blurScale: 0.9, borderRadius: 0, colorMode: t };
125
- case "promotion-fair":
126
- return { blurScale: 0.85, borderRadius: 8, colorMode: "light" };
127
- case "promotion-deep":
128
- return { blurScale: 0.2, borderRadius: 8, colorMode: "light" };
129
- case "immersive":
130
- return { blurScale: 0.4, borderRadius: 8, colorMode: "dark" };
131
- case "bottom-bar":
132
- return { blurScale: 0.2, borderRadius: 0, colorMode: t };
133
- default:
134
- return { blurScale: 0, borderRadius: 0, colorMode: t };
135
- }
136
- }
137
- const _ = {
138
- ...j
139
- };
140
- function E() {
141
- return ["harmony", "harmonyhybrid", "jdharmony"].includes(
142
- N().toLowerCase()
143
- );
144
- }
145
- function H(e) {
146
- return e.style.startsWith("thin") ? 10 : e.style.startsWith("thick") ? 40 : 20;
147
- }
148
- function J(e) {
149
- const r = {}, t = e.maxBlur ?? 0;
150
- return t > 0 && (r.backdropFilter = `blur(${t * 50}px)`), e.overlayAlpha && e.overlayAlpha > 0 && (r.backgroundColor = e.overlayColor || "rgba(255,255,255,1)", r.opacity = e.overlayAlpha), r;
151
- }
152
- function W() {
153
- var e;
154
- try {
155
- const r = g.getSystemInfoSync(), t = String((r == null ? void 0 : r.platform) || "").toLowerCase(), a = String((r == null ? void 0 : r.system) || ""), o = t === "ios", u = o ? parseInt(((e = a.match(/\d+/)) == null ? void 0 : e[0]) || "0", 10) : 0, b = String((r == null ? void 0 : r.theme) || "").toLowerCase() === "dark";
156
- return { isIOS: o, iosMajor: u, dark: b };
157
- } catch {
158
- return { isIOS: !1, iosMajor: 0, dark: !1 };
159
- }
160
- }
161
- function Y() {
162
- try {
163
- const e = g.getSystemInfoSync();
164
- return String((e == null ? void 0 : e.theme) || "").toLowerCase() === "dark";
165
- } catch {
166
- return !1;
167
- }
168
- }
169
- function K(e) {
170
- const { scene: r, dark: t, overlayColor: a, cls: o, style: u, children: b, rest: m } = e, l = r ? V(r, t) : void 0, i = {};
171
- l ? (i.blurScale = l.blurScale, i.borderRadius = l.borderRadius, i.colorMode = l.colorMode) : i.colorMode = t ? "dark" : "light";
172
- const n = a ?? (l == null ? void 0 : l.overlayColor);
173
- return n && (i.overlayColor = n), /* @__PURE__ */ G(A, { className: o, style: u, ...i, ...m, children: b });
174
- }
175
- function Q(e) {
176
- const { scene: r, targetId: t, overlayColor: a, frostedGlass: o, gradientBlur: u, cls: b, style: m, children: l, rest: i } = e, n = { ...m };
177
- if (o) {
178
- const p = H(o);
179
- n.backdropFilter = `blur(${p}px)`, o.alpha !== void 0 && (n.opacity = o.alpha);
180
- } else u && Object.assign(n, J(u));
181
- const h = a ?? (o ? o.style.endsWith("-dark") ? "rgba(0, 0, 0, 0.3)" : "rgba(255, 255, 255, 0.3)" : void 0), d = {};
182
- return t && (d.targetId = t), r && (d.scene = r), h && (d.overlayColor = h), /* @__PURE__ */ G(A, { className: b, style: n, ...d, ...i, children: l });
183
- }
184
- const U = (e) => {
185
- const {
186
- className: r,
187
- style: t,
188
- children: a,
189
- scene: o,
190
- targetId: u,
191
- liquidGlass: b,
192
- frostedGlass: m,
193
- gradientBlur: l,
194
- overlayColor: i,
195
- ...n
196
- } = { ..._, ...e }, d = $("nut-jdmaterialview", r), { isIOS: p, iosMajor: R } = I(() => W(), []), [v, q] = L(() => Y()), S = x(
197
- (c) => {
198
- const f = typeof c == "string" ? c : String((c == null ? void 0 : c.theme) || "");
199
- q(f.toLowerCase() === "dark");
200
- },
201
- []
202
- );
203
- D(() => {
204
- var c, f;
205
- try {
206
- (f = (c = g).onThemeChange) == null || f.call(c, S);
207
- } catch {
208
- }
209
- return () => {
210
- var F, w;
211
- try {
212
- (w = (F = g).offThemeChange) == null || w.call(F, S);
213
- } catch {
214
- }
215
- };
216
- }, [S]);
217
- const s = I(
218
- () => o ? T(o, v, R) : void 0,
219
- [o, v, R]
220
- ), B = b ?? (s == null ? void 0 : s.liquidGlass), k = m ?? (s == null ? void 0 : s.frostedGlass), M = l ?? (s == null ? void 0 : s.gradientBlur);
221
- if (p) {
222
- const c = { ...s == null ? void 0 : s.fallbackStyle, ...t };
223
- return /* @__PURE__ */ G(
224
- P,
225
- {
226
- className: d,
227
- style: c,
228
- liquidGlass: B,
229
- frostedGlass: k,
230
- gradientBlur: M,
231
- ...n,
232
- children: a
233
- }
234
- );
235
- }
236
- return E() ? K({ scene: o, dark: v, overlayColor: i, cls: d, style: t, children: a, rest: n }) : Q({
237
- scene: o,
238
- targetId: u,
239
- overlayColor: i,
240
- frostedGlass: k,
241
- gradientBlur: M,
242
- cls: d,
243
- style: t,
244
- children: a,
245
- rest: n
246
- });
247
- };
248
- U.displayName = "NutJDMaterialView";
249
- export {
250
- U as J,
251
- sr as a,
252
- T as b,
253
- ar as g
254
- };