@nutui/taro-biz 0.0.1-alpha.7 → 0.0.1-alpha.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.
@@ -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-34Y0-ZOh.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-34Y0-ZOh.js");exports.default=e.JDMaterialView;exports.getCornerRadius=e.getCornerRadius;exports.getFrostedPreset=e.getFrostedPreset;exports.getPreset=e.getPreset;
@@ -0,0 +1 @@
1
+ "use strict";const R=require("react/jsx-runtime"),y=require("react"),P=require("classnames"),u=require("@tarojs/taro"),M=require("@tarojs/components"),j=require("@jdtaro/ui"),x=require("./typings-DP_XKs5o.js"),w=26;function q(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 N(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 p="255, 255, 255",C="31, 34, 38";function F(t,r){switch(t){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(${C}, 0.9)`:`rgba(${p}, 0.9)`};case"promotion-fair":return{blurRadius:40,tintColor:`rgba(${p}, 0.85)`};case"promotion-deep":return{blurRadius:40,tintColor:`rgba(${p}, 0.2)`};case"immersive":return{blurRadius:40,tintColor:`rgba(${C}, 0.4)`};case"bottom-bar":return{blurRadius:50,tintColor:r?`rgba(${C}, 0.8)`:`rgba(${p}, 0.8)`};default:return{blurRadius:40}}}function V(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 $={...x.ComponentDefaults};function B(){return["harmony","harmonyhybrid","jdharmony"].includes(u.getEnv().toLowerCase())}function _(){var t;try{const r=u.getSystemInfoSync(),e=String((r==null?void 0:r.platform)||"").toLowerCase(),s=String((r==null?void 0:r.system)||""),a=e==="ios",b=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:b,dark:m}}catch{return{isIOS:!1,iosMajor:0,dark:!1}}}function E(){try{const t=u.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:b,children:m,rest:g}=t,i=r?V(r,e):void 0,o={};i?(o.blurScale=i.blurScale,o.borderRadius=i.borderRadius,o.colorMode=i.colorMode):o.colorMode=e?"dark":"light";const c=s??(i==null?void 0:i.overlayColor);return c&&(o.overlayColor=c),R.jsx(M.View,{className:a,style:b,...o,...g,children:m})}function J(t){const{scene:r,dark:e,targetId:s,overlayColor:a,cls:b,style:m,children:g,rest:i}=t,o=r?F(r,e):void 0,c={...m};o&&o.blurRadius>0&&(c.backdropFilter=`blur(${o.blurRadius}px)`);const v=a??(o==null?void 0:o.tintColor),d={};return s&&(d.targetId=s),r&&(d.scene=r),v&&(d.overlayColor=v),R.jsx(M.View,{className:b,style:c,...d,...i,children:g})}const k=t=>{const{className:r,style:e,children:s,scene:a,targetId:b,liquidGlass:m,frostedGlass:g,gradientBlur:i,overlayColor:o,...c}={...$,...t},d=P("nut-jdmaterialview",r),{isIOS:I,iosMajor:G}=y.useMemo(()=>_(),[]),[f,L]=y.useState(()=>E()),S=y.useCallback(n=>{const h=typeof n=="string"?n:String((n==null?void 0:n.theme)||"");L(h.toLowerCase()==="dark")},[]);y.useEffect(()=>{var n;try{(n=u.onThemeChange)==null||n.call(u,S)}catch{}return()=>{var h;try{(h=u.offThemeChange)==null||h.call(u,S)}catch{}}},[S]);const l=y.useMemo(()=>a?q(a,f,G):void 0,[a,f,G]),O=m??(l==null?void 0:l.liquidGlass),A=g??(l==null?void 0:l.frostedGlass),D=i??(l==null?void 0:l.gradientBlur);if(I){const n={...l==null?void 0:l.fallbackStyle,...e};return R.jsx(j.JDIOSMaterialView,{className:d,style:n,liquidGlass:O,frostedGlass:A,gradientBlur:D,...c,children:s})}return B()?H({scene:a,dark:f,overlayColor:o,cls:d,style:e,children:s,rest:c}):J({scene:a,dark:f,targetId:b,overlayColor:o,cls:d,style:e,children:s,rest:c})};k.displayName="NutJDMaterialView";exports.JDMaterialView=k;exports.getCornerRadius=N;exports.getFrostedPreset=F;exports.getPreset=q;
@@ -1,4 +1,4 @@
1
- import { J as e } from "../jdmaterialview.taro-Ch_ytSl9.mjs";
1
+ import { J as e } from "../jdmaterialview.taro-DHsrFcZg.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-DHsrFcZg.mjs";
2
+ import { g as s, a as o, b as g } from "../jdmaterialview.taro-DHsrFcZg.mjs";
3
3
  export {
4
4
  r as default,
5
5
  s as getCornerRadius,
@@ -0,0 +1,243 @@
1
+ import { jsx as C } from "react/jsx-runtime";
2
+ import { useMemo as w, useState as D, useCallback as N, useEffect as P } from "react";
3
+ import $ from "classnames";
4
+ import h, { getEnv as B } from "@tarojs/taro";
5
+ import { View as F } from "@tarojs/components";
6
+ import { JDIOSMaterialView as T } from "@jdtaro/ui";
7
+ import { C as j } from "./typings-CdeuPEKG.mjs";
8
+ const k = 26;
9
+ function x(t, r, e) {
10
+ const a = e >= k;
11
+ switch (t) {
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 or(t, r) {
65
+ const e = r >= k;
66
+ switch (t) {
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", S = "31, 34, 38";
82
+ function V(t, r) {
83
+ switch (t) {
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(${S}, 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(${S}, 0.4)` };
102
+ case "bottom-bar":
103
+ return {
104
+ blurRadius: 50,
105
+ tintColor: r ? `rgba(${S}, 0.8)` : `rgba(${y}, 0.8)`
106
+ };
107
+ default:
108
+ return { blurRadius: 40 };
109
+ }
110
+ }
111
+ function _(t, r) {
112
+ const e = r ? "dark" : "light";
113
+ switch (t) {
114
+ case "top-solid":
115
+ return {
116
+ blurScale: 1,
117
+ borderRadius: 8,
118
+ colorMode: e,
119
+ overlayColor: r ? "#2A2F36" : "#FFFFFF"
120
+ };
121
+ case "top-plain":
122
+ return { blurScale: 0, borderRadius: 8, colorMode: e };
123
+ case "top-bar":
124
+ return { blurScale: 0.9, borderRadius: 0, colorMode: e };
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: e };
133
+ default:
134
+ return { blurScale: 0, borderRadius: 0, colorMode: e };
135
+ }
136
+ }
137
+ const E = {
138
+ ...j
139
+ };
140
+ function H() {
141
+ return ["harmony", "harmonyhybrid", "jdharmony"].includes(
142
+ B().toLowerCase()
143
+ );
144
+ }
145
+ function J() {
146
+ var t;
147
+ try {
148
+ const r = h.getSystemInfoSync(), e = String((r == null ? void 0 : r.platform) || "").toLowerCase(), a = String((r == null ? void 0 : r.system) || ""), s = e === "ios", d = s ? parseInt(((t = a.match(/\d+/)) == null ? void 0 : t[0]) || "0", 10) : 0, m = String((r == null ? void 0 : r.theme) || "").toLowerCase() === "dark";
149
+ return { isIOS: s, iosMajor: d, dark: m };
150
+ } catch {
151
+ return { isIOS: !1, iosMajor: 0, dark: !1 };
152
+ }
153
+ }
154
+ function Y() {
155
+ try {
156
+ const t = h.getSystemInfoSync();
157
+ return String((t == null ? void 0 : t.theme) || "").toLowerCase() === "dark";
158
+ } catch {
159
+ return !1;
160
+ }
161
+ }
162
+ function K(t) {
163
+ const { scene: r, dark: e, overlayColor: a, cls: s, style: d, children: m, rest: b } = t, i = r ? _(r, e) : void 0, o = {};
164
+ i ? (o.blurScale = i.blurScale, o.borderRadius = i.borderRadius, o.colorMode = i.colorMode) : o.colorMode = e ? "dark" : "light";
165
+ const c = a ?? (i == null ? void 0 : i.overlayColor);
166
+ return c && (o.overlayColor = c), /* @__PURE__ */ C(F, { className: s, style: d, ...o, ...b, children: m });
167
+ }
168
+ function Q(t) {
169
+ const { scene: r, dark: e, targetId: a, overlayColor: s, cls: d, style: m, children: b, rest: i } = t, o = r ? V(r, e) : void 0, c = { ...m };
170
+ o && o.blurRadius > 0 && (c.backdropFilter = `blur(${o.blurRadius}px)`);
171
+ const p = s ?? (o == null ? void 0 : o.tintColor), u = {};
172
+ return a && (u.targetId = a), r && (u.scene = r), p && (u.overlayColor = p), /* @__PURE__ */ C(F, { className: d, style: c, ...u, ...i, children: b });
173
+ }
174
+ const U = (t) => {
175
+ const {
176
+ className: r,
177
+ style: e,
178
+ children: a,
179
+ scene: s,
180
+ targetId: d,
181
+ liquidGlass: m,
182
+ frostedGlass: b,
183
+ gradientBlur: i,
184
+ overlayColor: o,
185
+ ...c
186
+ } = { ...E, ...t }, u = $("nut-jdmaterialview", r), { isIOS: I, iosMajor: R } = w(() => J(), []), [f, q] = D(() => Y()), v = N(
187
+ (n) => {
188
+ const g = typeof n == "string" ? n : String((n == null ? void 0 : n.theme) || "");
189
+ q(g.toLowerCase() === "dark");
190
+ },
191
+ []
192
+ );
193
+ P(() => {
194
+ var n, g;
195
+ try {
196
+ (g = (n = h).onThemeChange) == null || g.call(n, v);
197
+ } catch {
198
+ }
199
+ return () => {
200
+ var G, M;
201
+ try {
202
+ (M = (G = h).offThemeChange) == null || M.call(G, v);
203
+ } catch {
204
+ }
205
+ };
206
+ }, [v]);
207
+ const l = w(
208
+ () => s ? x(s, f, R) : void 0,
209
+ [s, f, R]
210
+ ), L = m ?? (l == null ? void 0 : l.liquidGlass), O = b ?? (l == null ? void 0 : l.frostedGlass), A = i ?? (l == null ? void 0 : l.gradientBlur);
211
+ if (I) {
212
+ const n = { ...l == null ? void 0 : l.fallbackStyle, ...e };
213
+ return /* @__PURE__ */ C(
214
+ T,
215
+ {
216
+ className: u,
217
+ style: n,
218
+ liquidGlass: L,
219
+ frostedGlass: O,
220
+ gradientBlur: A,
221
+ ...c,
222
+ children: a
223
+ }
224
+ );
225
+ }
226
+ return H() ? K({ scene: s, dark: f, overlayColor: o, cls: u, style: e, children: a, rest: c }) : Q({
227
+ scene: s,
228
+ dark: f,
229
+ targetId: d,
230
+ overlayColor: o,
231
+ cls: u,
232
+ style: e,
233
+ children: a,
234
+ rest: c
235
+ });
236
+ };
237
+ U.displayName = "NutJDMaterialView";
238
+ export {
239
+ U as J,
240
+ V as a,
241
+ x as b,
242
+ or as g
243
+ };
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.8",
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
- };