@mizuui/liquid-glass-vue 0.1.0 → 0.1.2

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.
@@ -0,0 +1,279 @@
1
+ import { ref as E, onMounted as R, watch as _, onBeforeUnmount as F, createBlock as H, openBlock as I, resolveDynamicComponent as P, withCtx as z, renderSlot as O } from "vue";
2
+ const y = (e, r, t) => e < r ? r : e > t ? t : e;
3
+ function T(e, r, t, s, a) {
4
+ const p = Math.abs(e) - (t - a), n = Math.abs(r) - (s - a), l = Math.max(p, 0), c = Math.max(n, 0), i = Math.hypot(l, c), u = Math.min(Math.max(p, n), 0) + i - a, o = e < 0 ? -1 : 1, d = r < 0 ? -1 : 1;
5
+ let h, g;
6
+ return i > 0 ? (h = o * l / i, g = d * c / i) : p > n ? (h = o, g = 0) : (h = 0, g = d), { distance: u, nx: h, ny: g };
7
+ }
8
+ function j({
9
+ width: e,
10
+ height: r,
11
+ radius: t = 24,
12
+ depth: s = 8,
13
+ falloff: a = 2,
14
+ resolution: p = 512
15
+ }) {
16
+ const n = Math.min(1, p / Math.max(e, r, 1)), l = Math.max(1, Math.round(e * n)), c = Math.max(1, Math.round(r * n)), i = document.createElement("canvas");
17
+ i.width = l, i.height = c;
18
+ const u = i.getContext("2d"), o = u.createImageData(l, c), d = o.data, h = l / 2, g = c / 2, N = y(t * n, 0, Math.min(h, g)), B = y(s * n, 0.5, Math.min(h, g)), A = Math.max(0.1, a);
19
+ for (let x = 0; x < c; x++)
20
+ for (let v = 0; v < l; v++) {
21
+ const $ = v + 0.5 - h, q = x + 0.5 - g, { distance: C, nx: G, ny: L } = T($, q, h, g, N);
22
+ let S = 0;
23
+ if (C < 0) {
24
+ const D = -C;
25
+ S = Math.pow(1 - y(D / B, 0, 1), A);
26
+ }
27
+ const k = (x * l + v) * 4;
28
+ d[k] = y(Math.round(128 + G * S * 127), 0, 255), d[k + 1] = y(Math.round(128 + L * S * 127), 0, 255), d[k + 2] = 128, d[k + 3] = 255;
29
+ }
30
+ return u.putImageData(o, 0, 0), { href: i.toDataURL(), width: l, height: c };
31
+ }
32
+ const w = "http://www.w3.org/2000/svg", U = "http://www.w3.org/1999/xlink";
33
+ let b = null;
34
+ function W() {
35
+ return b && b.isConnected || (b = document.createElementNS(w, "svg"), b.setAttribute("aria-hidden", "true"), b.setAttribute("focusable", "false"), b.dataset.liquidGlass = "filters", b.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none;", document.body.appendChild(b)), b;
36
+ }
37
+ function m(e, r) {
38
+ const t = document.createElementNS(w, e);
39
+ for (const s in r) t.setAttribute(s, r[s]);
40
+ return t;
41
+ }
42
+ function K(e, r) {
43
+ return `${{
44
+ r: "1 0 0 0 0 0 0 0 0 0 0 0 0 0 0",
45
+ g: "0 0 0 0 0 0 1 0 0 0 0 0 0 0 0",
46
+ b: "0 0 0 0 0 0 0 0 0 0 0 0 1 0 0"
47
+ }[e]} 0 0 0 ${r ? 1 : 0} 0`;
48
+ }
49
+ function V(e) {
50
+ const r = m("filter", {
51
+ id: e,
52
+ "color-interpolation-filters": "sRGB",
53
+ x: "0",
54
+ y: "0",
55
+ width: "100%",
56
+ height: "100%"
57
+ });
58
+ return W().appendChild(r), {
59
+ url: `url(#${e})`,
60
+ update({ map: t, scale: s, aberration: a, blur: p }) {
61
+ r.replaceChildren();
62
+ const n = m("feImage", {
63
+ result: "map",
64
+ preserveAspectRatio: "none",
65
+ x: "0",
66
+ y: "0",
67
+ width: String(t.displayWidth),
68
+ height: String(t.displayHeight)
69
+ });
70
+ n.setAttribute("href", t.href), n.setAttributeNS(U, "xlink:href", t.href), r.appendChild(n);
71
+ const l = (i, u) => m("feDisplacementMap", {
72
+ in: "SourceGraphic",
73
+ in2: "map",
74
+ scale: String(i),
75
+ xChannelSelector: "R",
76
+ yChannelSelector: "G",
77
+ result: u
78
+ });
79
+ let c = "refracted";
80
+ a > 0 ? ([
81
+ ["r", s + a],
82
+ ["g", s],
83
+ ["b", s - a]
84
+ ].forEach(([u, o], d) => {
85
+ r.appendChild(l(o, `pass-${u}`)), r.appendChild(
86
+ m("feColorMatrix", {
87
+ in: `pass-${u}`,
88
+ type: "matrix",
89
+ values: K(u, d === 0),
90
+ result: `channel-${u}`
91
+ })
92
+ );
93
+ }), r.appendChild(
94
+ m("feComposite", {
95
+ in: "channel-r",
96
+ in2: "channel-g",
97
+ operator: "arithmetic",
98
+ k2: "1",
99
+ k3: "1",
100
+ result: "rg"
101
+ })
102
+ ), r.appendChild(
103
+ m("feComposite", {
104
+ in: "rg",
105
+ in2: "channel-b",
106
+ operator: "arithmetic",
107
+ k2: "1",
108
+ k3: "1",
109
+ result: "refracted"
110
+ })
111
+ )) : r.appendChild(l(s, "refracted")), p > 0 && (r.appendChild(
112
+ m("feGaussianBlur", { in: c, stdDeviation: String(p), result: "blurred" })
113
+ ), c = "blurred");
114
+ },
115
+ destroy() {
116
+ r.remove();
117
+ }
118
+ };
119
+ }
120
+ const M = "mizuui-liquid-glass-core-styles", X = `
121
+ .liquid-glass {
122
+ position: relative;
123
+ isolation: isolate;
124
+ border-radius: var(--lg-radius, 24px);
125
+ -webkit-backdrop-filter: var(--lg-backdrop, none);
126
+ backdrop-filter: var(--lg-backdrop, none);
127
+ transform: translateZ(0);
128
+ }
129
+
130
+ .liquid-glass::after {
131
+ content: '';
132
+ position: absolute;
133
+ inset: 0;
134
+ z-index: 1;
135
+ border-radius: inherit;
136
+ pointer-events: none;
137
+ box-shadow:
138
+ inset 2px 2px 1px -2px rgba(255, 255, 255, calc(0.9 * var(--lg-specular, 1))),
139
+ inset -1.5px -1.5px 1px -1.5px rgba(255, 255, 255, calc(0.6 * var(--lg-specular, 1))),
140
+ inset 0 0 6px 1px rgba(255, 255, 255, calc(0.25 * var(--lg-specular, 1)));
141
+ }
142
+ `;
143
+ function Y() {
144
+ if (typeof document > "u" || document.getElementById(M)) return;
145
+ const e = document.createElement("style");
146
+ e.id = M, e.textContent = X, document.head.appendChild(e);
147
+ }
148
+ const f = {
149
+ /** Corner radius in px. Keep in sync with any border-radius you set yourself. */
150
+ radius: 30,
151
+ /** Thickness of the refracting bevel in px. */
152
+ depth: 35,
153
+ /** Maximum backdrop displacement in px. This is the strength of the lensing. */
154
+ strength: 120,
155
+ /** Falloff curve of the bevel. Higher = the bend is pushed closer to the edge. */
156
+ falloff: 2,
157
+ /** Per-channel offset in px. Gives the prism fringe real glass has. */
158
+ chromaticAberration: 0,
159
+ /** Backdrop blur in px. Leave at 0 — blur is frosted glass, not liquid glass. */
160
+ blur: 15,
161
+ /** Backdrop saturation multiplier. */
162
+ saturation: 3,
163
+ /** Backdrop brightness multiplier. */
164
+ brightness: 1.04,
165
+ /** Specular rim intensity, 0 disables it. */
166
+ specular: 1,
167
+ /** Max pixel size of the generated displacement map. */
168
+ resolution: 512,
169
+ /** Blur used when the browser cannot run SVG filters in a backdrop-filter. */
170
+ fallbackBlur: 8
171
+ };
172
+ let Z = 0;
173
+ function J() {
174
+ return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("backdrop-filter", "url(#x)") && !/\bGecko\/\b/.test(navigator.userAgent ?? "");
175
+ }
176
+ function Q(e, r = {}) {
177
+ Y();
178
+ let t = { ...f, ...r }, s = !1, a = 0;
179
+ const n = J() ? V(`liquid-glass-${++Z}`) : null;
180
+ e.classList.add("liquid-glass");
181
+ function l() {
182
+ const o = [];
183
+ t.brightness !== 1 && o.push(`brightness(${t.brightness})`), t.saturation !== 1 && o.push(`saturate(${t.saturation})`), n ? (t.blur > 0 && o.push(`blur(${t.blur}px)`), o.push(n.url)) : t.fallbackBlur > 0 && o.push(`blur(${t.fallbackBlur}px)`), e.style.setProperty("--lg-backdrop", o.join(" ") || "none"), e.style.setProperty("--lg-radius", `${t.radius}px`), e.style.setProperty("--lg-specular", String(t.specular));
184
+ }
185
+ function c() {
186
+ if (a = 0, s || !n) return;
187
+ const { width: o, height: d } = e.getBoundingClientRect();
188
+ if (o < 1 || d < 1) return;
189
+ const h = j({
190
+ width: o,
191
+ height: d,
192
+ radius: t.radius,
193
+ depth: t.depth,
194
+ falloff: t.falloff,
195
+ resolution: t.resolution
196
+ });
197
+ n.update({
198
+ map: { ...h, displayWidth: o, displayHeight: d },
199
+ scale: t.strength,
200
+ aberration: t.chromaticAberration,
201
+ blur: 0
202
+ });
203
+ }
204
+ function i() {
205
+ s || a || (a = requestAnimationFrame(c));
206
+ }
207
+ const u = typeof ResizeObserver < "u" ? new ResizeObserver(i) : null;
208
+ return u?.observe(e), l(), i(), {
209
+ get options() {
210
+ return { ...t };
211
+ },
212
+ update(o = {}) {
213
+ t = { ...t, ...o }, l(), i();
214
+ },
215
+ refresh: i,
216
+ destroy() {
217
+ s || (s = !0, a && cancelAnimationFrame(a), u?.disconnect(), n?.destroy(), e.classList.remove("liquid-glass"), e.style.removeProperty("--lg-backdrop"), e.style.removeProperty("--lg-radius"), e.style.removeProperty("--lg-specular"));
218
+ }
219
+ };
220
+ }
221
+ const tt = {
222
+ __name: "LiquidGlass",
223
+ props: {
224
+ /** Element or component to render as the glass surface. */
225
+ as: { type: [String, Object], default: "div" },
226
+ radius: { type: Number, default: f.radius },
227
+ depth: { type: Number, default: f.depth },
228
+ strength: { type: Number, default: f.strength },
229
+ falloff: { type: Number, default: f.falloff },
230
+ chromaticAberration: { type: Number, default: f.chromaticAberration },
231
+ blur: { type: Number, default: f.blur },
232
+ saturation: { type: Number, default: f.saturation },
233
+ brightness: { type: Number, default: f.brightness },
234
+ specular: { type: Number, default: f.specular },
235
+ resolution: { type: Number, default: f.resolution },
236
+ fallbackBlur: { type: Number, default: f.fallbackBlur }
237
+ },
238
+ setup(e, { expose: r }) {
239
+ const t = e, s = E(null);
240
+ let a = null;
241
+ const p = () => ({
242
+ radius: t.radius,
243
+ depth: t.depth,
244
+ strength: t.strength,
245
+ falloff: t.falloff,
246
+ chromaticAberration: t.chromaticAberration,
247
+ blur: t.blur,
248
+ saturation: t.saturation,
249
+ brightness: t.brightness,
250
+ specular: t.specular,
251
+ resolution: t.resolution,
252
+ fallbackBlur: t.fallbackBlur
253
+ });
254
+ return R(() => {
255
+ const n = s.value instanceof HTMLElement ? s.value : s.value?.$el;
256
+ n instanceof HTMLElement && (a = Q(n, p()));
257
+ }), _(p, (n) => a?.update(n)), F(() => {
258
+ a?.destroy(), a = null;
259
+ }), r({
260
+ refresh: () => a?.refresh()
261
+ }), (n, l) => (I(), H(P(e.as), {
262
+ ref_key: "root",
263
+ ref: s
264
+ }, {
265
+ default: z(() => [
266
+ O(n.$slots, "default")
267
+ ]),
268
+ _: 3
269
+ }, 512));
270
+ }
271
+ }, rt = {
272
+ install(e, r = {}) {
273
+ e.component(r.name ?? "LiquidGlass", tt);
274
+ }
275
+ };
276
+ export {
277
+ tt as LiquidGlass,
278
+ rt as default
279
+ };
@@ -0,0 +1,23 @@
1
+ (function(y,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],c):(y=typeof globalThis<"u"?globalThis:y||self,c(y.LiquidGlassVue={},y.Vue))})(this,function(y,c){"use strict";const S=(t,r,e)=>t<r?r:t>e?e:t;function A(t,r,e,s,a){const h=Math.abs(t)-(e-a),n=Math.abs(r)-(s-a),l=Math.max(h,0),d=Math.max(n,0),o=Math.hypot(l,d),u=Math.min(Math.max(h,n),0)+o-a,i=t<0?-1:1,p=r<0?-1:1;let b,m;return o>0?(b=i*l/o,m=p*d/o):h>n?(b=i,m=0):(b=0,m=p),{distance:u,nx:b,ny:m}}function $({width:t,height:r,radius:e=24,depth:s=8,falloff:a=2,resolution:h=512}){const n=Math.min(1,h/Math.max(t,r,1)),l=Math.max(1,Math.round(t*n)),d=Math.max(1,Math.round(r*n)),o=document.createElement("canvas");o.width=l,o.height=d;const u=o.getContext("2d"),i=u.createImageData(l,d),p=i.data,b=l/2,m=d/2,I=S(e*n,0,Math.min(b,m)),j=S(s*n,.5,Math.min(b,m)),O=Math.max(.1,a);for(let k=0;k<d;k++)for(let M=0;M<l;M++){const z=M+.5-b,U=k+.5-m,{distance:B,nx:V,ny:W}=A(z,U,b,m,I);let C=0;if(B<0){const K=-B;C=Math.pow(1-S(K/j,0,1),O)}const v=(k*l+M)*4;p[v]=S(Math.round(128+V*C*127),0,255),p[v+1]=S(Math.round(128+W*C*127),0,255),p[v+2]=128,p[v+3]=255}return u.putImageData(i,0,0),{href:o.toDataURL(),width:l,height:d}}const w="http://www.w3.org/2000/svg",G="http://www.w3.org/1999/xlink";let g=null;function L(){return g&&g.isConnected||(g=document.createElementNS(w,"svg"),g.setAttribute("aria-hidden","true"),g.setAttribute("focusable","false"),g.dataset.liquidGlass="filters",g.style.cssText="position:absolute;width:0;height:0;overflow:hidden;pointer-events:none;",document.body.appendChild(g)),g}function x(t,r){const e=document.createElementNS(w,t);for(const s in r)e.setAttribute(s,r[s]);return e}function _(t,r){return`${{r:"1 0 0 0 0 0 0 0 0 0 0 0 0 0 0",g:"0 0 0 0 0 0 1 0 0 0 0 0 0 0 0",b:"0 0 0 0 0 0 0 0 0 0 0 0 1 0 0"}[t]} 0 0 0 ${r?1:0} 0`}function D(t){const r=x("filter",{id:t,"color-interpolation-filters":"sRGB",x:"0",y:"0",width:"100%",height:"100%"});return L().appendChild(r),{url:`url(#${t})`,update({map:e,scale:s,aberration:a,blur:h}){r.replaceChildren();const n=x("feImage",{result:"map",preserveAspectRatio:"none",x:"0",y:"0",width:String(e.displayWidth),height:String(e.displayHeight)});n.setAttribute("href",e.href),n.setAttributeNS(G,"xlink:href",e.href),r.appendChild(n);const l=(o,u)=>x("feDisplacementMap",{in:"SourceGraphic",in2:"map",scale:String(o),xChannelSelector:"R",yChannelSelector:"G",result:u});let d="refracted";a>0?([["r",s+a],["g",s],["b",s-a]].forEach(([u,i],p)=>{r.appendChild(l(i,`pass-${u}`)),r.appendChild(x("feColorMatrix",{in:`pass-${u}`,type:"matrix",values:_(u,p===0),result:`channel-${u}`}))}),r.appendChild(x("feComposite",{in:"channel-r",in2:"channel-g",operator:"arithmetic",k2:"1",k3:"1",result:"rg"})),r.appendChild(x("feComposite",{in:"rg",in2:"channel-b",operator:"arithmetic",k2:"1",k3:"1",result:"refracted"}))):r.appendChild(l(s,"refracted")),h>0&&(r.appendChild(x("feGaussianBlur",{in:d,stdDeviation:String(h),result:"blurred"})),d="blurred")},destroy(){r.remove()}}}const N="mizuui-liquid-glass-core-styles",E=`
2
+ .liquid-glass {
3
+ position: relative;
4
+ isolation: isolate;
5
+ border-radius: var(--lg-radius, 24px);
6
+ -webkit-backdrop-filter: var(--lg-backdrop, none);
7
+ backdrop-filter: var(--lg-backdrop, none);
8
+ transform: translateZ(0);
9
+ }
10
+
11
+ .liquid-glass::after {
12
+ content: '';
13
+ position: absolute;
14
+ inset: 0;
15
+ z-index: 1;
16
+ border-radius: inherit;
17
+ pointer-events: none;
18
+ box-shadow:
19
+ inset 2px 2px 1px -2px rgba(255, 255, 255, calc(0.9 * var(--lg-specular, 1))),
20
+ inset -1.5px -1.5px 1px -1.5px rgba(255, 255, 255, calc(0.6 * var(--lg-specular, 1))),
21
+ inset 0 0 6px 1px rgba(255, 255, 255, calc(0.25 * var(--lg-specular, 1)));
22
+ }
23
+ `;function R(){if(typeof document>"u"||document.getElementById(N))return;const t=document.createElement("style");t.id=N,t.textContent=E,document.head.appendChild(t)}const f={radius:30,depth:35,strength:120,falloff:2,chromaticAberration:0,blur:15,saturation:3,brightness:1.04,specular:1,resolution:512,fallbackBlur:8};let F=0;function H(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("backdrop-filter","url(#x)")&&!/\bGecko\/\b/.test(navigator.userAgent??"")}function P(t,r={}){R();let e={...f,...r},s=!1,a=0;const n=H()?D(`liquid-glass-${++F}`):null;t.classList.add("liquid-glass");function l(){const i=[];e.brightness!==1&&i.push(`brightness(${e.brightness})`),e.saturation!==1&&i.push(`saturate(${e.saturation})`),n?(e.blur>0&&i.push(`blur(${e.blur}px)`),i.push(n.url)):e.fallbackBlur>0&&i.push(`blur(${e.fallbackBlur}px)`),t.style.setProperty("--lg-backdrop",i.join(" ")||"none"),t.style.setProperty("--lg-radius",`${e.radius}px`),t.style.setProperty("--lg-specular",String(e.specular))}function d(){if(a=0,s||!n)return;const{width:i,height:p}=t.getBoundingClientRect();if(i<1||p<1)return;const b=$({width:i,height:p,radius:e.radius,depth:e.depth,falloff:e.falloff,resolution:e.resolution});n.update({map:{...b,displayWidth:i,displayHeight:p},scale:e.strength,aberration:e.chromaticAberration,blur:0})}function o(){s||a||(a=requestAnimationFrame(d))}const u=typeof ResizeObserver<"u"?new ResizeObserver(o):null;return u?.observe(t),l(),o(),{get options(){return{...e}},update(i={}){e={...e,...i},l(),o()},refresh:o,destroy(){s||(s=!0,a&&cancelAnimationFrame(a),u?.disconnect(),n?.destroy(),t.classList.remove("liquid-glass"),t.style.removeProperty("--lg-backdrop"),t.style.removeProperty("--lg-radius"),t.style.removeProperty("--lg-specular"))}}}const q={__name:"LiquidGlass",props:{as:{type:[String,Object],default:"div"},radius:{type:Number,default:f.radius},depth:{type:Number,default:f.depth},strength:{type:Number,default:f.strength},falloff:{type:Number,default:f.falloff},chromaticAberration:{type:Number,default:f.chromaticAberration},blur:{type:Number,default:f.blur},saturation:{type:Number,default:f.saturation},brightness:{type:Number,default:f.brightness},specular:{type:Number,default:f.specular},resolution:{type:Number,default:f.resolution},fallbackBlur:{type:Number,default:f.fallbackBlur}},setup(t,{expose:r}){const e=t,s=c.ref(null);let a=null;const h=()=>({radius:e.radius,depth:e.depth,strength:e.strength,falloff:e.falloff,chromaticAberration:e.chromaticAberration,blur:e.blur,saturation:e.saturation,brightness:e.brightness,specular:e.specular,resolution:e.resolution,fallbackBlur:e.fallbackBlur});return c.onMounted(()=>{const n=s.value instanceof HTMLElement?s.value:s.value?.$el;n instanceof HTMLElement&&(a=P(n,h()))}),c.watch(h,n=>a?.update(n)),c.onBeforeUnmount(()=>{a?.destroy(),a=null}),r({refresh:()=>a?.refresh()}),(n,l)=>(c.openBlock(),c.createBlock(c.resolveDynamicComponent(t.as),{ref_key:"root",ref:s},{default:c.withCtx(()=>[c.renderSlot(n.$slots,"default")]),_:3},512))}},T={install(t,r={}){t.component(r.name??"LiquidGlass",q)}};y.LiquidGlass=q,y.default=T,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { DefineComponent, Plugin } from 'vue'
2
- import type { LiquidGlassOptions } from 'mizuui-liquid-glass-core'
2
+ import type { LiquidGlassOptions } from '@mizuui/liquid-glass-core'
3
3
 
4
4
  export interface LiquidGlassProps extends LiquidGlassOptions {
5
5
  as?: string | object
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@mizuui/liquid-glass-vue",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A <LiquidGlass> component for Vue 3. Anything inside the tag sits on real refracting glass.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "main": "./lib/mizuui-liquid-glass-vue.umd.js",
8
- "module": "./lib/mizuui-liquid-glass-vue.es.js",
7
+ "main": "./dist/mizuui-liquid-glass-vue.umd.js",
8
+ "module": "./dist/mizuui-liquid-glass-vue.es.js",
9
9
  "types": "./index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
12
  "types": "./index.d.ts",
13
- "import": "./lib/mizuui-liquid-glass-vue.es.js",
14
- "require": "./lib/mizuui-liquid-glass-vue.umd.js"
13
+ "import": "./dist/mizuui-liquid-glass-vue.es.js",
14
+ "require": "./dist/mizuui-liquid-glass-vue.umd.js"
15
15
  }
16
16
  },
17
17
  "files": [
18
- "lib",
18
+ "dist",
19
19
  "index.d.ts",
20
20
  "README.md"
21
21
  ],
@@ -23,7 +23,7 @@
23
23
  "build": "vite build"
24
24
  },
25
25
  "dependencies": {
26
- "@mizuui/liquid-glass-core": "0.1.0"
26
+ "@mizuui/liquid-glass-core": "^0.1.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "vue": "^3.4.0"
@@ -1,61 +0,0 @@
1
- import { ref as n, onMounted as i, watch as f, onBeforeUnmount as c, createBlock as d, openBlock as p, resolveDynamicComponent as m, withCtx as b, renderSlot as h } from "vue";
2
- import { defaultOptions as t, createLiquidGlass as y } from "mizuui-liquid-glass-core";
3
- const N = {
4
- __name: "LiquidGlass",
5
- props: {
6
- /** Element or component to render as the glass surface. */
7
- as: { type: [String, Object], default: "div" },
8
- radius: { type: Number, default: t.radius },
9
- depth: { type: Number, default: t.depth },
10
- strength: { type: Number, default: t.strength },
11
- falloff: { type: Number, default: t.falloff },
12
- chromaticAberration: { type: Number, default: t.chromaticAberration },
13
- blur: { type: Number, default: t.blur },
14
- saturation: { type: Number, default: t.saturation },
15
- brightness: { type: Number, default: t.brightness },
16
- specular: { type: Number, default: t.specular },
17
- resolution: { type: Number, default: t.resolution },
18
- fallbackBlur: { type: Number, default: t.fallbackBlur }
19
- },
20
- setup(l, { expose: s }) {
21
- const e = l, u = n(null);
22
- let a = null;
23
- const o = () => ({
24
- radius: e.radius,
25
- depth: e.depth,
26
- strength: e.strength,
27
- falloff: e.falloff,
28
- chromaticAberration: e.chromaticAberration,
29
- blur: e.blur,
30
- saturation: e.saturation,
31
- brightness: e.brightness,
32
- specular: e.specular,
33
- resolution: e.resolution,
34
- fallbackBlur: e.fallbackBlur
35
- });
36
- return i(() => {
37
- const r = u.value instanceof HTMLElement ? u.value : u.value?.$el;
38
- r instanceof HTMLElement && (a = y(r, o()));
39
- }), f(o, (r) => a?.update(r)), c(() => {
40
- a?.destroy(), a = null;
41
- }), s({
42
- refresh: () => a?.refresh()
43
- }), (r, g) => (p(), d(m(l.as), {
44
- ref_key: "root",
45
- ref: u
46
- }, {
47
- default: b(() => [
48
- h(r.$slots, "default")
49
- ]),
50
- _: 3
51
- }, 512));
52
- }
53
- }, L = {
54
- install(l, s = {}) {
55
- l.component(s.name ?? "LiquidGlass", N);
56
- }
57
- };
58
- export {
59
- N as LiquidGlass,
60
- L as default
61
- };
@@ -1 +0,0 @@
1
- (function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("mizuui-liquid-glass-core")):typeof define=="function"&&define.amd?define(["exports","vue","mizuui-liquid-glass-core"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u.LiquidGlassVue={},u.Vue,u.LiquidGlassCore))})(this,function(u,e,t){"use strict";const f={__name:"LiquidGlass",props:{as:{type:[String,Object],default:"div"},radius:{type:Number,default:t.defaultOptions.radius},depth:{type:Number,default:t.defaultOptions.depth},strength:{type:Number,default:t.defaultOptions.strength},falloff:{type:Number,default:t.defaultOptions.falloff},chromaticAberration:{type:Number,default:t.defaultOptions.chromaticAberration},blur:{type:Number,default:t.defaultOptions.blur},saturation:{type:Number,default:t.defaultOptions.saturation},brightness:{type:Number,default:t.defaultOptions.brightness},specular:{type:Number,default:t.defaultOptions.specular},resolution:{type:Number,default:t.defaultOptions.resolution},fallbackBlur:{type:Number,default:t.defaultOptions.fallbackBlur}},setup(l,{expose:s}){const n=l,o=e.ref(null);let r=null;const i=()=>({radius:n.radius,depth:n.depth,strength:n.strength,falloff:n.falloff,chromaticAberration:n.chromaticAberration,blur:n.blur,saturation:n.saturation,brightness:n.brightness,specular:n.specular,resolution:n.resolution,fallbackBlur:n.fallbackBlur});return e.onMounted(()=>{const a=o.value instanceof HTMLElement?o.value:o.value?.$el;a instanceof HTMLElement&&(r=t.createLiquidGlass(a,i()))}),e.watch(i,a=>r?.update(a)),e.onBeforeUnmount(()=>{r?.destroy(),r=null}),s({refresh:()=>r?.refresh()}),(a,p)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.as),{ref_key:"root",ref:o},{default:e.withCtx(()=>[e.renderSlot(a.$slots,"default")]),_:3},512))}},d={install(l,s={}){l.component(s.name??"LiquidGlass",f)}};u.LiquidGlass=f,u.default=d,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});