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