@zakisheriff/liquid-glass 0.1.0

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.
package/dist/index.js ADDED
@@ -0,0 +1,932 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ GlassButton: () => GlassButton,
34
+ GlassCard: () => GlassCard,
35
+ GlassInput: () => GlassInput,
36
+ GlassNav: () => GlassNav,
37
+ GlassSheet: () => GlassSheet,
38
+ GlassSlider: () => GlassSlider,
39
+ LiquidGlassFilter: () => LiquidGlassFilter,
40
+ useGlassAnimation: () => useGlassAnimation,
41
+ useGlassEffect: () => useGlassEffect
42
+ });
43
+ module.exports = __toCommonJS(index_exports);
44
+
45
+ // src/components/GlassButton/GlassButton.tsx
46
+ var import_react2 = __toESM(require("react"));
47
+
48
+ // src/filters/LiquidGlassFilter.tsx
49
+ var import_react = require("react");
50
+ var import_jsx_runtime = require("react/jsx-runtime");
51
+ var GlassFilterContext = (0, import_react.createContext)(false);
52
+ function useGlassFilterMounted() {
53
+ return (0, import_react.useContext)(GlassFilterContext);
54
+ }
55
+ function LiquidGlassFilter({ children }) {
56
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(GlassFilterContext.Provider, { value: true, children: [
57
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GlassFilterSVG, {}),
58
+ children
59
+ ] });
60
+ }
61
+ function GlassFilterSVG() {
62
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
+ "svg",
64
+ {
65
+ width: "0",
66
+ height: "0",
67
+ style: { position: "absolute", pointerEvents: "none" },
68
+ "aria-hidden": "true",
69
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("defs", { children: Array.from({ length: 10 }, (_, i) => {
70
+ const level = i + 1;
71
+ const scale = level * 2;
72
+ const freq1 = 0.012 + level * 1e-3;
73
+ const freq2 = 0.01 + level * 8e-4;
74
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
75
+ "filter",
76
+ {
77
+ id: `liquid-glass-refract-${level}`,
78
+ x: "-10%",
79
+ y: "-10%",
80
+ width: "120%",
81
+ height: "120%",
82
+ colorInterpolationFilters: "sRGB",
83
+ children: [
84
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
85
+ "feTurbulence",
86
+ {
87
+ type: "fractalNoise",
88
+ baseFrequency: `${freq1} ${freq2}`,
89
+ numOctaves: 3,
90
+ seed: 42,
91
+ result: "noise"
92
+ }
93
+ ),
94
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
95
+ "feDisplacementMap",
96
+ {
97
+ in: "SourceGraphic",
98
+ in2: "noise",
99
+ scale,
100
+ xChannelSelector: "R",
101
+ yChannelSelector: "G"
102
+ }
103
+ )
104
+ ]
105
+ },
106
+ level
107
+ );
108
+ }) })
109
+ }
110
+ );
111
+ }
112
+
113
+ // src/components/GlassButton/GlassButton.tsx
114
+ var import_jsx_runtime2 = require("react/jsx-runtime");
115
+ var GlassButton = import_react2.default.forwardRef(
116
+ ({
117
+ intensity = 5,
118
+ tint,
119
+ shimmer = true,
120
+ thickness = 1,
121
+ size = "md",
122
+ variant = "default",
123
+ className,
124
+ style,
125
+ children,
126
+ ...rest
127
+ }, ref) => {
128
+ const isFilterMounted = useGlassFilterMounted();
129
+ const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
130
+ const glassStyle = (0, import_react2.useMemo)(() => {
131
+ const filterId = `liquid-glass-refract-${clampedIntensity}`;
132
+ const vars = {
133
+ "--glass-blur": `${clampedIntensity * 2.4}px`,
134
+ "--glass-border-width": `${thickness}px`,
135
+ "--glass-refraction-filter": `url(#${filterId})`
136
+ };
137
+ if (tint) {
138
+ vars["--glass-tint"] = tint;
139
+ }
140
+ return vars;
141
+ }, [clampedIntensity, tint, thickness]);
142
+ const rootClasses = [
143
+ "lg-root",
144
+ "lg-button",
145
+ `lg-button--${size}`,
146
+ `lg-button--${variant}`,
147
+ shimmer ? "lg-button--shimmer" : "",
148
+ className ?? ""
149
+ ].filter(Boolean).join(" ");
150
+ const freq1 = 0.012 + clampedIntensity * 1e-3;
151
+ const freq2 = 0.01 + clampedIntensity * 8e-4;
152
+ const scale = clampedIntensity * 2;
153
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: rootClasses, "data-liquid-glass": true, style: { ...glassStyle, ...style }, children: [
154
+ !isFilterMounted && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
155
+ "svg",
156
+ {
157
+ width: "0",
158
+ height: "0",
159
+ style: { position: "absolute", pointerEvents: "none" },
160
+ "aria-hidden": "true",
161
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
162
+ "filter",
163
+ {
164
+ id: `liquid-glass-refract-${clampedIntensity}`,
165
+ x: "-10%",
166
+ y: "-10%",
167
+ width: "120%",
168
+ height: "120%",
169
+ colorInterpolationFilters: "sRGB",
170
+ children: [
171
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
172
+ "feTurbulence",
173
+ {
174
+ type: "fractalNoise",
175
+ baseFrequency: `${freq1} ${freq2}`,
176
+ numOctaves: 3,
177
+ seed: 42,
178
+ result: "noise"
179
+ }
180
+ ),
181
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
182
+ "feDisplacementMap",
183
+ {
184
+ in: "SourceGraphic",
185
+ in2: "noise",
186
+ scale,
187
+ xChannelSelector: "R",
188
+ yChannelSelector: "G"
189
+ }
190
+ )
191
+ ]
192
+ }
193
+ ) })
194
+ }
195
+ ),
196
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
197
+ "button",
198
+ {
199
+ ref,
200
+ className: "lg-surface",
201
+ ...rest,
202
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "lg-content", children })
203
+ }
204
+ ),
205
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "lg-backdrop-surface", "aria-hidden": "true" }),
206
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "lg-shadow", "aria-hidden": "true" })
207
+ ] });
208
+ }
209
+ );
210
+ GlassButton.displayName = "GlassButton";
211
+
212
+ // src/components/GlassCard/GlassCard.tsx
213
+ var import_react3 = __toESM(require("react"));
214
+ var import_jsx_runtime3 = require("react/jsx-runtime");
215
+ var GlassCard = import_react3.default.forwardRef(
216
+ ({
217
+ intensity = 5,
218
+ tint,
219
+ shimmer = true,
220
+ thickness = 1,
221
+ padding = "24px",
222
+ radius = "20px",
223
+ className,
224
+ style,
225
+ children,
226
+ ...rest
227
+ }, ref) => {
228
+ const isFilterMounted = useGlassFilterMounted();
229
+ const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
230
+ const glassStyle = (0, import_react3.useMemo)(() => {
231
+ const filterId = `liquid-glass-refract-${clampedIntensity}`;
232
+ const vars = {
233
+ "--glass-blur": `${clampedIntensity * 2.4}px`,
234
+ "--glass-border-width": `${thickness}px`,
235
+ "--glass-radius": radius,
236
+ "--glass-padding": padding,
237
+ "--glass-refraction-filter": `url(#${filterId})`
238
+ };
239
+ if (tint) {
240
+ vars["--glass-tint"] = tint;
241
+ }
242
+ return vars;
243
+ }, [clampedIntensity, tint, thickness, radius, padding]);
244
+ const rootClasses = [
245
+ "lg-root",
246
+ "lg-card",
247
+ shimmer ? "lg-card--shimmer" : "",
248
+ className ?? ""
249
+ ].filter(Boolean).join(" ");
250
+ const freq1 = 0.012 + clampedIntensity * 1e-3;
251
+ const freq2 = 0.01 + clampedIntensity * 8e-4;
252
+ const scale = clampedIntensity * 2;
253
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
254
+ "div",
255
+ {
256
+ ref,
257
+ className: rootClasses,
258
+ "data-liquid-glass": true,
259
+ style: { ...glassStyle, ...style },
260
+ ...rest,
261
+ children: [
262
+ !isFilterMounted && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
263
+ "svg",
264
+ {
265
+ width: "0",
266
+ height: "0",
267
+ style: { position: "absolute", pointerEvents: "none" },
268
+ "aria-hidden": "true",
269
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
270
+ "filter",
271
+ {
272
+ id: `liquid-glass-refract-${clampedIntensity}`,
273
+ x: "-10%",
274
+ y: "-10%",
275
+ width: "120%",
276
+ height: "120%",
277
+ colorInterpolationFilters: "sRGB",
278
+ children: [
279
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
280
+ "feTurbulence",
281
+ {
282
+ type: "fractalNoise",
283
+ baseFrequency: `${freq1} ${freq2}`,
284
+ numOctaves: 3,
285
+ seed: 42,
286
+ result: "noise"
287
+ }
288
+ ),
289
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
290
+ "feDisplacementMap",
291
+ {
292
+ in: "SourceGraphic",
293
+ in2: "noise",
294
+ scale,
295
+ xChannelSelector: "R",
296
+ yChannelSelector: "G"
297
+ }
298
+ )
299
+ ]
300
+ }
301
+ ) })
302
+ }
303
+ ),
304
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "lg-surface lg-card__surface", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "lg-content lg-card__content", children }) }),
305
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "lg-backdrop-surface lg-card__backdrop-surface", "aria-hidden": "true" }),
306
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "lg-shadow", "aria-hidden": "true" })
307
+ ]
308
+ }
309
+ );
310
+ }
311
+ );
312
+ GlassCard.displayName = "GlassCard";
313
+
314
+ // src/components/GlassInput/GlassInput.tsx
315
+ var import_react4 = __toESM(require("react"));
316
+ var import_jsx_runtime4 = require("react/jsx-runtime");
317
+ var GlassInput = import_react4.default.forwardRef(
318
+ ({
319
+ intensity = 5,
320
+ tint,
321
+ placeholder,
322
+ value,
323
+ onChange,
324
+ label,
325
+ className,
326
+ style,
327
+ id: externalId,
328
+ ...rest
329
+ }, ref) => {
330
+ const autoId = (0, import_react4.useId)();
331
+ const inputId = externalId ?? autoId;
332
+ const [focused, setFocused] = (0, import_react4.useState)(false);
333
+ const [hasValue, setHasValue] = (0, import_react4.useState)(() => Boolean(value));
334
+ const isFilterMounted = useGlassFilterMounted();
335
+ const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
336
+ const handleFocus = (0, import_react4.useCallback)(
337
+ (e) => {
338
+ setFocused(true);
339
+ rest.onFocus?.(e);
340
+ },
341
+ [rest.onFocus]
342
+ );
343
+ const handleBlur = (0, import_react4.useCallback)(
344
+ (e) => {
345
+ setFocused(false);
346
+ rest.onBlur?.(e);
347
+ },
348
+ [rest.onBlur]
349
+ );
350
+ const handleChange = (0, import_react4.useCallback)(
351
+ (e) => {
352
+ setHasValue(e.target.value.length > 0);
353
+ onChange?.(e);
354
+ },
355
+ [onChange]
356
+ );
357
+ const glassStyle = (0, import_react4.useMemo)(() => {
358
+ const filterId = `liquid-glass-refract-${clampedIntensity}`;
359
+ const vars = {
360
+ "--glass-blur": `${clampedIntensity * 2.4}px`,
361
+ "--glass-border-width": "1px",
362
+ "--glass-refraction-filter": `url(#${filterId})`
363
+ };
364
+ if (tint) {
365
+ vars["--glass-tint"] = tint;
366
+ }
367
+ return vars;
368
+ }, [clampedIntensity, tint]);
369
+ const rootClasses = [
370
+ "lg-root",
371
+ "lg-input",
372
+ focused ? "lg-input--focused" : "",
373
+ hasValue || value ? "lg-input--has-value" : "",
374
+ className ?? ""
375
+ ].filter(Boolean).join(" ");
376
+ const freq1 = 0.012 + clampedIntensity * 1e-3;
377
+ const freq2 = 0.01 + clampedIntensity * 8e-4;
378
+ const scale = clampedIntensity * 2;
379
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: rootClasses, "data-liquid-glass": true, style: { ...glassStyle, ...style }, children: [
380
+ !isFilterMounted && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
381
+ "svg",
382
+ {
383
+ width: "0",
384
+ height: "0",
385
+ style: { position: "absolute", pointerEvents: "none" },
386
+ "aria-hidden": "true",
387
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
388
+ "filter",
389
+ {
390
+ id: `liquid-glass-refract-${clampedIntensity}`,
391
+ x: "-10%",
392
+ y: "-10%",
393
+ width: "120%",
394
+ height: "120%",
395
+ colorInterpolationFilters: "sRGB",
396
+ children: [
397
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
398
+ "feTurbulence",
399
+ {
400
+ type: "fractalNoise",
401
+ baseFrequency: `${freq1} ${freq2}`,
402
+ numOctaves: 3,
403
+ seed: 42,
404
+ result: "noise"
405
+ }
406
+ ),
407
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
408
+ "feDisplacementMap",
409
+ {
410
+ in: "SourceGraphic",
411
+ in2: "noise",
412
+ scale,
413
+ xChannelSelector: "R",
414
+ yChannelSelector: "G"
415
+ }
416
+ )
417
+ ]
418
+ }
419
+ ) })
420
+ }
421
+ ),
422
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "lg-surface lg-input__surface", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "lg-content lg-input__content", children: [
423
+ label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { className: "lg-input__label", htmlFor: inputId, children: label }),
424
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
425
+ "input",
426
+ {
427
+ ref,
428
+ id: inputId,
429
+ className: "lg-input__field",
430
+ type: "text",
431
+ placeholder,
432
+ value,
433
+ onChange: handleChange,
434
+ onFocus: handleFocus,
435
+ onBlur: handleBlur,
436
+ ...rest
437
+ }
438
+ )
439
+ ] }) }),
440
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "lg-backdrop-surface lg-input__backdrop-surface", "aria-hidden": "true" }),
441
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "lg-shadow", "aria-hidden": "true" })
442
+ ] });
443
+ }
444
+ );
445
+ GlassInput.displayName = "GlassInput";
446
+
447
+ // src/components/GlassSheet/GlassSheet.tsx
448
+ var import_react5 = require("react");
449
+ var import_jsx_runtime5 = require("react/jsx-runtime");
450
+ var GlassSheet = ({
451
+ open,
452
+ onClose,
453
+ intensity = 5,
454
+ tint,
455
+ children
456
+ }) => {
457
+ const [mounted, setMounted] = (0, import_react5.useState)(open);
458
+ const [visible, setVisible] = (0, import_react5.useState)(false);
459
+ const sheetRef = (0, import_react5.useRef)(null);
460
+ const isFilterMounted = useGlassFilterMounted();
461
+ const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
462
+ (0, import_react5.useEffect)(() => {
463
+ if (open) {
464
+ setMounted(true);
465
+ requestAnimationFrame(() => {
466
+ requestAnimationFrame(() => setVisible(true));
467
+ });
468
+ } else {
469
+ setVisible(false);
470
+ }
471
+ }, [open]);
472
+ const handleTransitionEnd = (0, import_react5.useCallback)(() => {
473
+ if (!open) setMounted(false);
474
+ }, [open]);
475
+ (0, import_react5.useEffect)(() => {
476
+ if (!open) return;
477
+ const onKeyDown = (e) => {
478
+ if (e.key === "Escape") onClose?.();
479
+ };
480
+ window.addEventListener("keydown", onKeyDown);
481
+ return () => window.removeEventListener("keydown", onKeyDown);
482
+ }, [open, onClose]);
483
+ (0, import_react5.useEffect)(() => {
484
+ if (mounted) {
485
+ const prev = document.body.style.overflow;
486
+ document.body.style.overflow = "hidden";
487
+ return () => {
488
+ document.body.style.overflow = prev;
489
+ };
490
+ }
491
+ }, [mounted]);
492
+ const glassStyle = (0, import_react5.useMemo)(() => {
493
+ const filterId = `liquid-glass-refract-${clampedIntensity}`;
494
+ const vars = {
495
+ "--glass-blur": `${clampedIntensity * 2.4}px`,
496
+ "--glass-border-width": "1px",
497
+ "--glass-refraction-filter": `url(#${filterId})`
498
+ };
499
+ if (tint) {
500
+ vars["--glass-tint"] = tint;
501
+ }
502
+ return vars;
503
+ }, [clampedIntensity, tint]);
504
+ const freq1 = 0.012 + clampedIntensity * 1e-3;
505
+ const freq2 = 0.01 + clampedIntensity * 8e-4;
506
+ const scale = clampedIntensity * 2;
507
+ if (!mounted) return null;
508
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
509
+ "div",
510
+ {
511
+ className: `lg-sheet-overlay${visible ? " lg-sheet-overlay--visible" : ""}`,
512
+ onTransitionEnd: handleTransitionEnd,
513
+ role: "dialog",
514
+ "aria-modal": "true",
515
+ children: [
516
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg-sheet-backdrop", onClick: onClose, "aria-hidden": "true" }),
517
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
518
+ "div",
519
+ {
520
+ ref: sheetRef,
521
+ className: `lg-root lg-sheet${visible ? " lg-sheet--visible" : ""}`,
522
+ "data-liquid-glass": true,
523
+ style: glassStyle,
524
+ children: [
525
+ !isFilterMounted && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
526
+ "svg",
527
+ {
528
+ width: "0",
529
+ height: "0",
530
+ style: { position: "absolute", pointerEvents: "none" },
531
+ "aria-hidden": "true",
532
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
533
+ "filter",
534
+ {
535
+ id: `liquid-glass-refract-${clampedIntensity}`,
536
+ x: "-10%",
537
+ y: "-10%",
538
+ width: "120%",
539
+ height: "120%",
540
+ colorInterpolationFilters: "sRGB",
541
+ children: [
542
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
543
+ "feTurbulence",
544
+ {
545
+ type: "fractalNoise",
546
+ baseFrequency: `${freq1} ${freq2}`,
547
+ numOctaves: 3,
548
+ seed: 42,
549
+ result: "noise"
550
+ }
551
+ ),
552
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
553
+ "feDisplacementMap",
554
+ {
555
+ in: "SourceGraphic",
556
+ in2: "noise",
557
+ scale,
558
+ xChannelSelector: "R",
559
+ yChannelSelector: "G"
560
+ }
561
+ )
562
+ ]
563
+ }
564
+ ) })
565
+ }
566
+ ),
567
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "lg-surface lg-sheet__surface", children: [
568
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg-sheet__handle", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "lg-sheet__handle-bar" }) }),
569
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg-content lg-sheet__content", children })
570
+ ] }),
571
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg-backdrop-surface lg-sheet__backdrop-surface", "aria-hidden": "true" }),
572
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg-shadow lg-sheet__shadow", "aria-hidden": "true" })
573
+ ]
574
+ }
575
+ )
576
+ ]
577
+ }
578
+ );
579
+ };
580
+ GlassSheet.displayName = "GlassSheet";
581
+
582
+ // src/components/GlassNav/GlassNav.tsx
583
+ var import_react6 = require("react");
584
+ var import_jsx_runtime6 = require("react/jsx-runtime");
585
+ var GlassNav = ({
586
+ items,
587
+ activeIndex = 0,
588
+ onChange,
589
+ intensity = 5
590
+ }) => {
591
+ const navRef = (0, import_react6.useRef)(null);
592
+ const itemRefs = (0, import_react6.useRef)([]);
593
+ const isFilterMounted = useGlassFilterMounted();
594
+ const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
595
+ const [indicatorStyle, setIndicatorStyle] = (0, import_react6.useState)({});
596
+ const updateIndicator = (0, import_react6.useCallback)(() => {
597
+ const el = itemRefs.current[activeIndex];
598
+ const parent = navRef.current;
599
+ if (!el || !parent) return;
600
+ const parentRect = parent.getBoundingClientRect();
601
+ const rect = el.getBoundingClientRect();
602
+ setIndicatorStyle({
603
+ width: `${rect.width}px`,
604
+ height: `${rect.height}px`,
605
+ transform: `translateX(${rect.left - parentRect.left}px)`
606
+ });
607
+ }, [activeIndex]);
608
+ (0, import_react6.useEffect)(() => {
609
+ updateIndicator();
610
+ window.addEventListener("resize", updateIndicator);
611
+ return () => window.removeEventListener("resize", updateIndicator);
612
+ }, [updateIndicator, items.length]);
613
+ const glassStyle = (0, import_react6.useMemo)(() => {
614
+ const filterId = `liquid-glass-refract-${clampedIntensity}`;
615
+ return {
616
+ "--glass-blur": `${clampedIntensity * 2.4}px`,
617
+ "--glass-border-width": "1px",
618
+ "--glass-refraction-filter": `url(#${filterId})`
619
+ };
620
+ }, [clampedIntensity]);
621
+ const freq1 = 0.012 + clampedIntensity * 1e-3;
622
+ const freq2 = 0.01 + clampedIntensity * 8e-4;
623
+ const scale = clampedIntensity * 2;
624
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "lg-root lg-nav", "data-liquid-glass": true, style: glassStyle, children: [
625
+ !isFilterMounted && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
626
+ "svg",
627
+ {
628
+ width: "0",
629
+ height: "0",
630
+ style: { position: "absolute", pointerEvents: "none" },
631
+ "aria-hidden": "true",
632
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
633
+ "filter",
634
+ {
635
+ id: `liquid-glass-refract-${clampedIntensity}`,
636
+ x: "-10%",
637
+ y: "-10%",
638
+ width: "120%",
639
+ height: "120%",
640
+ colorInterpolationFilters: "sRGB",
641
+ children: [
642
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
643
+ "feTurbulence",
644
+ {
645
+ type: "fractalNoise",
646
+ baseFrequency: `${freq1} ${freq2}`,
647
+ numOctaves: 3,
648
+ seed: 42,
649
+ result: "noise"
650
+ }
651
+ ),
652
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
653
+ "feDisplacementMap",
654
+ {
655
+ in: "SourceGraphic",
656
+ in2: "noise",
657
+ scale,
658
+ xChannelSelector: "R",
659
+ yChannelSelector: "G"
660
+ }
661
+ )
662
+ ]
663
+ }
664
+ ) })
665
+ }
666
+ ),
667
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "lg-surface lg-nav__surface", children: [
668
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "lg-nav__indicator", style: indicatorStyle, "aria-hidden": "true" }),
669
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("nav", { ref: navRef, className: "lg-content lg-nav__content", role: "tablist", children: items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
670
+ "button",
671
+ {
672
+ ref: (el) => {
673
+ itemRefs.current[i] = el;
674
+ },
675
+ role: "tab",
676
+ "aria-selected": i === activeIndex,
677
+ className: `lg-nav__item${i === activeIndex ? " lg-nav__item--active" : ""}`,
678
+ onClick: () => onChange?.(i),
679
+ type: "button",
680
+ children: [
681
+ item.icon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-nav__icon", children: item.icon }),
682
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-nav__label", children: item.label })
683
+ ]
684
+ },
685
+ i
686
+ )) })
687
+ ] }),
688
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "lg-backdrop-surface lg-nav__backdrop-surface", "aria-hidden": "true" }),
689
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "lg-shadow", "aria-hidden": "true" })
690
+ ] });
691
+ };
692
+ GlassNav.displayName = "GlassNav";
693
+
694
+ // src/components/GlassSlider/GlassSlider.tsx
695
+ var import_react7 = __toESM(require("react"));
696
+ var import_jsx_runtime7 = require("react/jsx-runtime");
697
+ var GlassSlider = import_react7.default.forwardRef(
698
+ ({
699
+ intensity = 5,
700
+ tint,
701
+ shimmer = true,
702
+ thickness = 1,
703
+ showThumb = true,
704
+ icon,
705
+ label,
706
+ value = 0,
707
+ min = 0,
708
+ max = 100,
709
+ onChange,
710
+ className,
711
+ style,
712
+ ...rest
713
+ }, ref) => {
714
+ const isFilterMounted = useGlassFilterMounted();
715
+ const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
716
+ const numValue = Number(value);
717
+ const numMin = Number(min);
718
+ const numMax = Number(max);
719
+ const percentage = numMax > numMin ? (numValue - numMin) / (numMax - numMin) * 100 : 0;
720
+ const ratio = numMax > numMin ? (numValue - numMin) / (numMax - numMin) : 0;
721
+ const glassStyle = (0, import_react7.useMemo)(() => {
722
+ const filterId = `liquid-glass-refract-${clampedIntensity}`;
723
+ const vars = {
724
+ "--glass-blur": `${clampedIntensity * 2.4}px`,
725
+ "--glass-border-width": `${thickness}px`,
726
+ "--glass-refraction-filter": `url(#${filterId})`,
727
+ "--slider-percentage": `${percentage}%`,
728
+ "--slider-ratio": ratio
729
+ };
730
+ if (tint) {
731
+ vars["--glass-tint"] = tint;
732
+ }
733
+ return vars;
734
+ }, [clampedIntensity, tint, thickness, percentage, ratio]);
735
+ const rootClasses = [
736
+ "lg-root",
737
+ "lg-slider",
738
+ shimmer ? "lg-slider--shimmer" : "",
739
+ showThumb ? "lg-slider--with-thumb" : "lg-slider--no-thumb",
740
+ className ?? ""
741
+ ].filter(Boolean).join(" ");
742
+ const handleChange = (e) => {
743
+ if (onChange) {
744
+ onChange(Number(e.target.value));
745
+ }
746
+ };
747
+ const freq1 = 0.012 + clampedIntensity * 1e-3;
748
+ const freq2 = 0.01 + clampedIntensity * 8e-4;
749
+ const scale = clampedIntensity * 2;
750
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: rootClasses, "data-liquid-glass": true, style: { ...glassStyle, ...style }, children: [
751
+ !isFilterMounted && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
752
+ "svg",
753
+ {
754
+ width: "0",
755
+ height: "0",
756
+ style: { position: "absolute", pointerEvents: "none" },
757
+ "aria-hidden": "true",
758
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
759
+ "filter",
760
+ {
761
+ id: `liquid-glass-refract-${clampedIntensity}`,
762
+ x: "-10%",
763
+ y: "-10%",
764
+ width: "120%",
765
+ height: "120%",
766
+ colorInterpolationFilters: "sRGB",
767
+ children: [
768
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
769
+ "feTurbulence",
770
+ {
771
+ type: "fractalNoise",
772
+ baseFrequency: `${freq1} ${freq2}`,
773
+ numOctaves: 3,
774
+ seed: 42,
775
+ result: "noise"
776
+ }
777
+ ),
778
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
779
+ "feDisplacementMap",
780
+ {
781
+ in: "SourceGraphic",
782
+ in2: "noise",
783
+ scale,
784
+ xChannelSelector: "R",
785
+ yChannelSelector: "G"
786
+ }
787
+ )
788
+ ]
789
+ }
790
+ ) })
791
+ }
792
+ ),
793
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "lg-slider-track", children: [
794
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "lg-backdrop-surface", "aria-hidden": "true" }),
795
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { position: "absolute", inset: 0, overflow: "hidden", borderRadius: "inherit", zIndex: 2, pointerEvents: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "lg-slider-fill", "aria-hidden": "true" }) }),
796
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "lg-shadow", "aria-hidden": "true" }),
797
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "lg-slider-content", children: [
798
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
799
+ icon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "lg-slider-icon", children: icon }),
800
+ label && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "lg-slider-label", children: label })
801
+ ] }),
802
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "lg-slider-value-text", children: numValue })
803
+ ] }),
804
+ showThumb && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "lg-slider-thumb", "aria-hidden": "true" }),
805
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
806
+ "input",
807
+ {
808
+ type: "range",
809
+ ref,
810
+ min,
811
+ max,
812
+ value,
813
+ onChange: handleChange,
814
+ className: "lg-slider-input",
815
+ ...rest
816
+ }
817
+ )
818
+ ] })
819
+ ] });
820
+ }
821
+ );
822
+ GlassSlider.displayName = "GlassSlider";
823
+
824
+ // src/hooks/useGlassEffect.ts
825
+ var import_react8 = require("react");
826
+ function parseTintColor(tint) {
827
+ const defaults = { h: 0, s: 0, l: 100, a: 0.1 };
828
+ if (!tint) return defaults;
829
+ const rgbaMatch = tint.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/);
830
+ if (rgbaMatch) {
831
+ const r = parseInt(rgbaMatch[1]) / 255;
832
+ const g = parseInt(rgbaMatch[2]) / 255;
833
+ const b = parseInt(rgbaMatch[3]) / 255;
834
+ const a = rgbaMatch[4] ? parseFloat(rgbaMatch[4]) : 1;
835
+ const max = Math.max(r, g, b);
836
+ const min = Math.min(r, g, b);
837
+ const l = (max + min) / 2;
838
+ if (max === min) return { h: 0, s: 0, l: l * 100, a };
839
+ const d = max - min;
840
+ const s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
841
+ let h = 0;
842
+ if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
843
+ else if (max === g) h = ((b - r) / d + 2) / 6;
844
+ else h = ((r - g) / d + 4) / 6;
845
+ return { h: h * 360, s: s * 100, l: l * 100, a };
846
+ }
847
+ const hexMatch = tint.match(/^#([\da-f]{3,8})$/i);
848
+ if (hexMatch) {
849
+ let hex = hexMatch[1];
850
+ if (hex.length === 3) hex = hex.split("").map((c) => c + c).join("");
851
+ const r = parseInt(hex.slice(0, 2), 16) / 255;
852
+ const g = parseInt(hex.slice(2, 4), 16) / 255;
853
+ const b = parseInt(hex.slice(4, 6), 16) / 255;
854
+ const a = hex.length === 8 ? parseInt(hex.slice(6, 8), 16) / 255 : 1;
855
+ const max = Math.max(r, g, b);
856
+ const min = Math.min(r, g, b);
857
+ const l = (max + min) / 2;
858
+ if (max === min) return { h: 0, s: 0, l: l * 100, a };
859
+ const d = max - min;
860
+ const s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
861
+ let h = 0;
862
+ if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
863
+ else if (max === g) h = ((b - r) / d + 2) / 6;
864
+ else h = ((r - g) / d + 4) / 6;
865
+ return { h: h * 360, s: s * 100, l: l * 100, a };
866
+ }
867
+ return defaults;
868
+ }
869
+ function useGlassEffect(options = {}) {
870
+ const {
871
+ intensity = 5,
872
+ tint,
873
+ shimmer = true,
874
+ thickness,
875
+ blur
876
+ } = options;
877
+ return (0, import_react8.useMemo)(() => {
878
+ const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
879
+ const filterId = `liquid-glass-refract-${clampedIntensity}`;
880
+ const style = {
881
+ "--glass-intensity": clampedIntensity,
882
+ "--glass-shimmer": shimmer ? 1 : 0
883
+ };
884
+ if (tint) {
885
+ const parsed = parseTintColor(tint);
886
+ style["--glass-tint-h"] = parsed.h;
887
+ style["--glass-tint-s"] = `${parsed.s}%`;
888
+ style["--glass-tint-l"] = `${parsed.l}%`;
889
+ style["--glass-tint-a"] = parsed.a;
890
+ }
891
+ if (thickness !== void 0) {
892
+ style["--glass-border-width"] = `${thickness}px`;
893
+ }
894
+ if (blur !== void 0) {
895
+ style["--glass-blur"] = `${blur}px`;
896
+ }
897
+ return { style, filterId };
898
+ }, [intensity, tint, shimmer, thickness, blur]);
899
+ }
900
+
901
+ // src/hooks/useGlassAnimation.ts
902
+ var import_react9 = require("react");
903
+ function useGlassAnimation() {
904
+ const [isHovered, setIsHovered] = (0, import_react9.useState)(false);
905
+ const [isPressed, setIsPressed] = (0, import_react9.useState)(false);
906
+ const [isFocused, setIsFocused] = (0, import_react9.useState)(false);
907
+ const handlers = {
908
+ onPointerEnter: (0, import_react9.useCallback)(() => setIsHovered(true), []),
909
+ onPointerLeave: (0, import_react9.useCallback)(() => {
910
+ setIsHovered(false);
911
+ setIsPressed(false);
912
+ }, []),
913
+ onPointerDown: (0, import_react9.useCallback)(() => setIsPressed(true), []),
914
+ onPointerUp: (0, import_react9.useCallback)(() => setIsPressed(false), []),
915
+ onFocus: (0, import_react9.useCallback)(() => setIsFocused(true), []),
916
+ onBlur: (0, import_react9.useCallback)(() => setIsFocused(false), [])
917
+ };
918
+ return { isHovered, isPressed, isFocused, handlers };
919
+ }
920
+ // Annotate the CommonJS export names for ESM import in node:
921
+ 0 && (module.exports = {
922
+ GlassButton,
923
+ GlassCard,
924
+ GlassInput,
925
+ GlassNav,
926
+ GlassSheet,
927
+ GlassSlider,
928
+ LiquidGlassFilter,
929
+ useGlassAnimation,
930
+ useGlassEffect
931
+ });
932
+ //# sourceMappingURL=index.js.map