@glass-sdk/liquid-glass 0.0.2 → 0.0.3-beta.1

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.
Files changed (146) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/README.md +66 -149
  3. package/dist/core/concentric.js +20 -3
  4. package/dist/core/corner-options.js +12 -0
  5. package/dist/core/corner-path.js +118 -0
  6. package/dist/core/materials.js +264 -32
  7. package/dist/core/optics.js +1 -2
  8. package/dist/core/progressive.js +1 -2
  9. package/dist/core/shape.js +18 -28
  10. package/dist/core/spring.js +5 -10
  11. package/dist/core.js +5 -6
  12. package/dist/dom/backdrop-glass.js +46 -0
  13. package/dist/dom/compose-layers.js +42 -31
  14. package/dist/dom/composited.js +136 -0
  15. package/dist/dom/control-motion.js +58 -47
  16. package/dist/dom/engine.js +1 -2
  17. package/dist/dom/escaped-layers.js +179 -0
  18. package/dist/dom/filter-bounds.js +42 -13
  19. package/dist/dom/filter-budget.js +1 -2
  20. package/dist/dom/filter-chain.js +40 -0
  21. package/dist/dom/filter-groups.js +33 -14
  22. package/dist/dom/filter-paint-root.js +8 -6
  23. package/dist/dom/filter-patch.js +94 -55
  24. package/dist/dom/filter-reach.js +32 -19
  25. package/dist/dom/filter-stages.js +1 -2
  26. package/dist/dom/fixed-shape.js +23 -16
  27. package/dist/dom/foreground.js +16 -17
  28. package/dist/dom/interaction.js +65 -92
  29. package/dist/dom/layout-rect.js +42 -0
  30. package/dist/dom/layout-size.js +28 -0
  31. package/dist/dom/lens-layers.js +250 -136
  32. package/dist/dom/map-encoder.js +16 -13
  33. package/dist/dom/map-encoder.worker.js +2 -3
  34. package/dist/dom/map-encoding.js +49 -12
  35. package/dist/dom/map-image.js +29 -7
  36. package/dist/dom/map-store.js +1 -2
  37. package/dist/dom/maps.js +133 -83
  38. package/dist/dom/material-graph.js +108 -29
  39. package/dist/dom/media-mirror.js +244 -0
  40. package/dist/dom/page-zoom.js +19 -18
  41. package/dist/dom/png.js +1 -2
  42. package/dist/dom/progressive.js +152 -147
  43. package/dist/dom/renderer.js +1 -2
  44. package/dist/dom/sampling-bounds.js +1 -2
  45. package/dist/dom/selection.js +133 -79
  46. package/dist/dom/shape-attributes.js +9 -0
  47. package/dist/dom/shape-effects.js +14 -0
  48. package/dist/dom/shape-geometry.js +3 -0
  49. package/dist/dom/shape-layout.js +115 -116
  50. package/dist/dom/shared-backdrop.js +33 -25
  51. package/dist/dom/specular.js +116 -0
  52. package/dist/dom/ticker.js +28 -19
  53. package/dist/dom/tint-color.js +24 -0
  54. package/dist/dom/warm.js +63 -59
  55. package/dist/dom.js +591 -505
  56. package/dist/gpu/geometry.js +2 -3
  57. package/dist/gpu/maps.js +1109 -7
  58. package/dist/gpu/planes.js +2 -3
  59. package/dist/gpu.js +66 -64
  60. package/dist/index.js +12 -10
  61. package/dist/react/button.js +12 -11
  62. package/dist/react/color-picker.js +199 -0
  63. package/dist/react/control-thumb.js +4 -5
  64. package/dist/react/menu.js +82 -111
  65. package/dist/react/merged-ref.js +1 -2
  66. package/dist/react/progressive.js +1 -2
  67. package/dist/react/scene.js +71 -55
  68. package/dist/react/shape.js +67 -47
  69. package/dist/react/slider.js +81 -0
  70. package/dist/react/surface.js +90 -56
  71. package/dist/react/switch.js +101 -0
  72. package/dist/react/tabs.js +85 -63
  73. package/dist/react/toolbar.js +38 -123
  74. package/dist/react/value-control-motion.js +1 -2
  75. package/dist/styles.css +517 -111
  76. package/dist/types/core/concentric.d.ts +8 -0
  77. package/dist/types/core/corner-options.d.ts +4 -0
  78. package/dist/types/core/corner-path.d.ts +8 -0
  79. package/dist/types/core/index.d.ts +3 -5
  80. package/dist/types/core/materials.d.ts +100 -28
  81. package/dist/types/core/shape.d.ts +4 -6
  82. package/dist/types/core/spring.d.ts +8 -12
  83. package/dist/types/dom/backdrop-glass.d.ts +38 -0
  84. package/dist/types/dom/compose-layers.d.ts +4 -0
  85. package/dist/types/dom/composited.d.ts +61 -0
  86. package/dist/types/dom/escaped-layers.d.ts +32 -0
  87. package/dist/types/dom/filter-bounds.d.ts +4 -0
  88. package/dist/types/dom/filter-chain.d.ts +6 -0
  89. package/dist/types/dom/filter-groups.d.ts +1 -1
  90. package/dist/types/dom/filter-paint-root.d.ts +3 -0
  91. package/dist/types/dom/filter-patch.d.ts +5 -0
  92. package/dist/types/dom/filter-reach.d.ts +9 -9
  93. package/dist/types/dom/foreground.d.ts +2 -1
  94. package/dist/types/dom/index.d.ts +8 -19
  95. package/dist/types/dom/interaction.d.ts +8 -8
  96. package/dist/types/dom/layout-rect.d.ts +17 -0
  97. package/dist/types/dom/layout-size.d.ts +11 -0
  98. package/dist/types/dom/lens-layers.d.ts +18 -10
  99. package/dist/types/dom/map-encoder.d.ts +5 -2
  100. package/dist/types/dom/map-encoding.d.ts +12 -3
  101. package/dist/types/dom/map-image.d.ts +7 -1
  102. package/dist/types/dom/maps.d.ts +25 -7
  103. package/dist/types/dom/material-graph.d.ts +73 -10
  104. package/dist/types/dom/media-mirror.d.ts +49 -0
  105. package/dist/types/dom/progressive.d.ts +2 -5
  106. package/dist/types/dom/sampling-bounds.d.ts +1 -3
  107. package/dist/types/dom/selection.d.ts +29 -4
  108. package/dist/types/dom/shape-attributes.d.ts +6 -0
  109. package/dist/types/dom/shape-effects.d.ts +10 -0
  110. package/dist/types/dom/shape-geometry.d.ts +6 -0
  111. package/dist/types/dom/shape-layout.d.ts +2 -4
  112. package/dist/types/dom/shared-backdrop.d.ts +7 -3
  113. package/dist/types/dom/specular.d.ts +50 -0
  114. package/dist/types/dom/ticker.d.ts +4 -1
  115. package/dist/types/dom/tint-color.d.ts +11 -0
  116. package/dist/types/dom/warm.d.ts +8 -2
  117. package/dist/types/gpu/geometry.d.ts +2 -0
  118. package/dist/types/gpu/planes.d.ts +3 -2
  119. package/dist/types/index.d.ts +1 -1
  120. package/dist/types/react/button.d.ts +1 -1
  121. package/dist/types/react/color-picker.d.ts +26 -0
  122. package/dist/types/react/index.d.ts +14 -10
  123. package/dist/types/react/menu.d.ts +4 -5
  124. package/dist/types/react/progressive.d.ts +1 -1
  125. package/dist/types/react/scene.d.ts +4 -2
  126. package/dist/types/react/shape.d.ts +11 -1
  127. package/dist/types/react/slider.d.ts +14 -0
  128. package/dist/types/react/surface.d.ts +11 -22
  129. package/dist/types/react/switch.d.ts +9 -0
  130. package/dist/types/react/tabs.d.ts +3 -3
  131. package/dist/types/react/toolbar.d.ts +1 -1
  132. package/package.json +46 -40
  133. package/dist/core/morph-path.js +0 -206
  134. package/dist/core/union.js +0 -117
  135. package/dist/dom/compound-field.js +0 -23
  136. package/dist/dom/exit-handoff.js +0 -14
  137. package/dist/dom/map-blend.js +0 -8
  138. package/dist/dom/morph.js +0 -296
  139. package/dist/react/value-controls.js +0 -176
  140. package/dist/types/core/morph-path.d.ts +0 -110
  141. package/dist/types/core/union.d.ts +0 -20
  142. package/dist/types/dom/compound-field.d.ts +0 -35
  143. package/dist/types/dom/exit-handoff.d.ts +0 -7
  144. package/dist/types/dom/map-blend.d.ts +0 -22
  145. package/dist/types/dom/morph.d.ts +0 -78
  146. package/dist/types/react/value-controls.d.ts +0 -20
@@ -0,0 +1,81 @@
1
+ "use client";
2
+ import { useGlassForeground as e } from "./scene.js";
3
+ import { useMergedRef as t } from "./merged-ref.js";
4
+ import { GlassShape as n } from "./shape.js";
5
+ import { ControlThumb as r } from "./control-thumb.js";
6
+ import { useEffect as i, useState as a } from "react";
7
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
+ import { Slider as c } from "@base-ui/react/slider";
9
+ // src/react/slider.tsx
10
+ function l({ material: l, appearance: u, tint: d, refraction: f, specular: p, radius: m = "capsule", motion: h, interactive: g = !0, className: _ = "", style: v, ticks: y = !1, min: b = 0, max: x = 100, step: S = .1, thumbProps: C, "aria-label": w, "aria-labelledby": T, ...E }) {
11
+ if (!Number.isFinite(b) || !Number.isFinite(x) || x <= b || !Number.isFinite(x - b) || !Number.isFinite(S) || S <= 0) throw RangeError("GlassSlider requires finite min < max and a positive finite step.");
12
+ let D = (x - b) / S;
13
+ if (y && (D < 1 || D > 100 || Math.abs(D - Math.round(D)) > 1e-7)) throw RangeError("Ticked sliders require 1–100 evenly divided intervals.");
14
+ let O = e(), k = t(E.ref, O), { className: A = "", ...j } = C ?? {}, [M, N] = a(!1);
15
+ return i(() => {
16
+ if (!M) return;
17
+ let e = () => N(!1);
18
+ return window.addEventListener("pointerup", e), window.addEventListener("pointercancel", e), window.addEventListener("blur", e), () => {
19
+ window.removeEventListener("pointerup", e), window.removeEventListener("pointercancel", e), window.removeEventListener("blur", e);
20
+ };
21
+ }, [M]), /* @__PURE__ */ o(c.Root, {
22
+ defaultValue: b,
23
+ ...E,
24
+ ref: k,
25
+ min: b,
26
+ max: x,
27
+ step: S,
28
+ className: `lg-slider ${_}`,
29
+ style: {
30
+ ...d === void 0 ? {} : { "--lg-accent": d },
31
+ ...v
32
+ },
33
+ "data-ticks": y ? "" : void 0,
34
+ children: /* @__PURE__ */ s(c.Control, {
35
+ className: "lg-slider-control",
36
+ onPointerDownCapture: (e) => {
37
+ !e.defaultPrevented && !E.disabled && e.button === 0 && N(!0);
38
+ },
39
+ onPointerUp: () => N(!1),
40
+ onPointerCancel: () => N(!1),
41
+ onLostPointerCapture: () => N(!1),
42
+ children: [
43
+ /* @__PURE__ */ o(n, {
44
+ radius: "capsule",
45
+ render: /* @__PURE__ */ o(c.Track, {}),
46
+ className: "lg-slider-track",
47
+ children: /* @__PURE__ */ o(n, {
48
+ radius: "capsule",
49
+ render: /* @__PURE__ */ o(c.Indicator, {}),
50
+ className: "lg-slider-fill"
51
+ })
52
+ }),
53
+ y && /* @__PURE__ */ o("div", {
54
+ className: "lg-slider-ticks",
55
+ "aria-hidden": "true",
56
+ children: Array.from({ length: Math.round(D) + 1 }, (e, t) => /* @__PURE__ */ o("span", {}, t))
57
+ }),
58
+ /* @__PURE__ */ o(c.Thumb, {
59
+ "aria-label": w,
60
+ "aria-labelledby": T,
61
+ ...j,
62
+ render: (e, t) => /* @__PURE__ */ o(r, {
63
+ ...e,
64
+ motion: h,
65
+ interactive: g,
66
+ pressed: M || t.dragging,
67
+ options: {
68
+ material: l,
69
+ appearance: u,
70
+ radius: m,
71
+ refraction: f,
72
+ specular: p
73
+ },
74
+ className: `lg-slider-thumb ${typeof A == "function" ? A(t) : A}`
75
+ })
76
+ })
77
+ ]
78
+ })
79
+ });
80
+ }
81
+ export { l as GlassSlider };
@@ -1,69 +1,103 @@
1
1
  "use client";
2
- import { shapeContainerAttributes as e } from "../dom/shape-layout.js";
2
+ import { shapeContainerAttributes as e } from "../dom/shape-attributes.js";
3
3
  import { useScene as t } from "./scene.js";
4
- import { useCallback as n, useLayoutEffect as r, useMemo as i, useRef as a } from "react";
5
- import { useRender as o } from "@base-ui/react/use-render";
6
- //#region src/react/surface.tsx
7
- function s({ material: s, appearance: c, radius: l, concentric: u, refraction: d, tint: f, interactive: p = !1, morphFrom: m, morph: h, neck: g, morphEnter: _, fluid: v = !1, motion: y, render: b, ref: x, children: S, className: C = "", style: w, ...T }) {
8
- let E = t(), { controller: D } = E;
9
- s ??= E.material, c ??= E.appearance, y ??= E.motion;
10
- let O = !!u, k = typeof u == "object" ? u.inset : void 0, A = a(m);
11
- r(() => {
12
- A.current = m;
4
+ import { useCallback as n, useLayoutEffect as r, useMemo as i, useRef as a, useState as o } from "react";
5
+ import { useRender as s } from "@base-ui/react/use-render";
6
+ import { jsx as c } from "react/jsx-runtime";
7
+ // src/react/surface.tsx
8
+ function l(e) {
9
+ return /* @__PURE__ */ c(f, { ...e });
10
+ }
11
+ function u(e, t) {
12
+ let n, r = 0, i = e.ownerDocument.defaultView ?? window, a = new MutationObserver(() => {
13
+ if (n || !e.hasAttribute("data-ending-style")) return;
14
+ n = e.animate([{ opacity: 1 }, { opacity: 1 }], { duration: 400 });
15
+ let a = 0, o = () => {
16
+ a = (t ?? e.ownerDocument).querySelector("[data-glass-pending]") ? 0 : a + 1, a >= 2 ? n?.finish() : r = i.requestAnimationFrame(o);
17
+ };
18
+ r = i.requestAnimationFrame(o);
13
19
  });
14
- let j = !!m, M = i(() => ({
15
- material: s,
16
- appearance: c,
17
- radius: l,
18
- concentric: O ? { inset: k } : void 0,
19
- refraction: d,
20
- tint: f,
21
- interactive: p,
22
- fluid: v,
23
- motion: y,
24
- morph: h,
25
- neck: g,
26
- morphEnter: _,
27
- morphFrom: j ? () => {
28
- let e = A.current;
29
- return typeof e == "function" ? e() : e?.current;
30
- } : void 0
20
+ return a.observe(e, {
21
+ attributes: !0,
22
+ attributeFilter: ["data-ending-style"]
23
+ }), () => {
24
+ a.disconnect(), i.cancelAnimationFrame(r);
25
+ };
26
+ }
27
+ function d(e) {
28
+ return /* @__PURE__ */ c(f, {
29
+ ...e,
30
+ popup: !0
31
+ });
32
+ }
33
+ function f({ material: c, appearance: l, radius: d, concentric: f, refraction: p, tint: m, specular: h, frost: g, floating: _, aberration: v, interactive: y = !1, motion: b, popup: x = !1, render: S, ref: C, children: w, className: T = "", style: E, ...D }) {
34
+ let O = t(), { controller: k } = O;
35
+ c ??= O.material, l ??= O.appearance, b ??= O.motion, h ??= O.specular, g ??= O.frost, _ ??= x;
36
+ let A = !!f, j = typeof f == "object" ? f.inset : void 0, M = {
37
+ material: c,
38
+ appearance: l,
39
+ refraction: p,
40
+ tint: m,
41
+ frost: g,
42
+ floating: _,
43
+ aberration: v
44
+ }, N = a(M);
45
+ N.current = M;
46
+ let P = i(() => ({
47
+ radius: d,
48
+ concentric: A ? { inset: j } : void 0,
49
+ specular: h,
50
+ interactive: y,
51
+ motion: b,
52
+ popup: x
31
53
  }), [
32
- s,
54
+ d,
55
+ A,
56
+ j,
57
+ h,
58
+ y,
59
+ b,
60
+ x
61
+ ]), [F, I] = o(null), L = n((e) => {
62
+ if (!e) return;
63
+ let t = k.addSurface(e, {
64
+ ...P,
65
+ ...N.current
66
+ }), n = x ? u(e, O.root) : void 0;
67
+ return I(e), () => {
68
+ n?.(), t(), I(null);
69
+ };
70
+ }, [
71
+ k,
72
+ P,
73
+ x,
74
+ O.root
75
+ ]);
76
+ return r(() => {
77
+ F && k.updateSurface(F, M);
78
+ }, [
79
+ k,
80
+ F,
33
81
  c,
34
82
  l,
35
- O,
36
- k,
37
- d,
38
- f,
39
83
  p,
40
- v,
41
- y,
42
- h,
84
+ m,
43
85
  g,
44
86
  _,
45
- j
46
- ]), N = n((e) => {
47
- if (!e) return;
48
- let t = D.addSurface(e, M);
49
- return () => {
50
- t();
51
- };
52
- }, [D, M]);
53
- return o({
54
- render: b,
55
- ref: [N, x ?? null],
87
+ v
88
+ ]), s({
89
+ render: S,
90
+ ref: [L, C ?? null],
56
91
  props: {
57
- ...T,
58
- ...e(l ?? 8),
59
- "data-glass-material": s,
60
- "data-glass-appearance": c,
61
- "data-glass-interactive": p ? "" : void 0,
62
- className: `lg-surface ${C}`,
63
- style: { ...w },
64
- ...S === void 0 ? {} : { children: S }
92
+ ...D,
93
+ ...e(d ?? 8),
94
+ "data-glass-material": c,
95
+ "data-glass-appearance": l,
96
+ "data-glass-interactive": y ? "" : void 0,
97
+ className: `lg-surface ${T}`,
98
+ style: { ...E },
99
+ ...w === void 0 ? {} : { children: w }
65
100
  }
66
101
  });
67
102
  }
68
- //#endregion
69
- export { s as GlassSurface };
103
+ export { d as GlassPopupSurface, l as GlassSurface };
@@ -0,0 +1,101 @@
1
+ "use client";
2
+ import { useGlassForeground as e } from "./scene.js";
3
+ import { useMergedRef as t } from "./merged-ref.js";
4
+ import { GlassShape as n } from "./shape.js";
5
+ import { switchDragState as r } from "./value-control-motion.js";
6
+ import { ControlThumb as i } from "./control-thumb.js";
7
+ import { useRef as a, useState as o } from "react";
8
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
9
+ import { Switch as l } from "@base-ui/react/switch";
10
+ // src/react/switch.tsx
11
+ function u({ material: u, appearance: d, tint: f, refraction: p, specular: m, radius: h = "capsule", motion: g, interactive: _ = !0, className: v = "", style: y, ...b }) {
12
+ let x = e(), S = t(b.ref, x), [C, w] = o(!1), [T, E] = o(null), D = a(null), O = a(!1), k = b.readOnly || b.disabled;
13
+ return /* @__PURE__ */ c(l.Root, {
14
+ ...b,
15
+ ref: S,
16
+ nativeButton: !1,
17
+ className: `lg-switch ${v}`,
18
+ style: {
19
+ ...f === void 0 ? {} : { "--lg-accent": f },
20
+ ...y
21
+ },
22
+ render: (e, t) => /* @__PURE__ */ s("span", {
23
+ ...e,
24
+ role: "switch",
25
+ "aria-checked": t.checked,
26
+ tabIndex: e.tabIndex ?? 0,
27
+ style: {
28
+ ...e.style,
29
+ "--lg-switch-position": T ?? +!!t.checked
30
+ },
31
+ "data-presentation-checked": T === null ? void 0 : T === 1 ? "true" : "false",
32
+ onPointerDown: (n) => {
33
+ if (e.onPointerDown?.(n), n.defaultPrevented || k || n.button !== 0) return;
34
+ O.current = !1;
35
+ let r = getComputedStyle(n.currentTarget).direction === "rtl", i = +!!t.checked, a = n.currentTarget.getBoundingClientRect(), o = n.clientX >= a.left + a.width / 2 !== r;
36
+ D.current = {
37
+ id: n.pointerId,
38
+ x: n.clientX,
39
+ start: i,
40
+ current: i,
41
+ left: a.left,
42
+ width: a.width,
43
+ rtl: r,
44
+ oppositeHalf: o !== t.checked,
45
+ moved: !1
46
+ }, n.currentTarget.setPointerCapture(n.pointerId), E(i), w(!0);
47
+ },
48
+ onPointerMove: (t) => {
49
+ e.onPointerMove?.(t);
50
+ let n = D.current;
51
+ if (!n || n.id !== t.pointerId || t.defaultPrevented) return;
52
+ let i = t.clientX - n.x;
53
+ n.moved ||= Math.abs(i) > 3, n.current = Number(r(n, t.clientX)), n.moved && E(n.current);
54
+ },
55
+ onPointerUp: (n) => {
56
+ e.onPointerUp?.(n);
57
+ let r = D.current;
58
+ r && r.id === n.pointerId && (D.current = null, n.currentTarget.hasPointerCapture(n.pointerId) && n.currentTarget.releasePointerCapture(n.pointerId), r.moved && (!n.defaultPrevented && r.current >= .5 !== t.checked && n.currentTarget.click(), O.current = !0), E(null), w(!1));
59
+ },
60
+ onPointerCancel: (t) => {
61
+ e.onPointerCancel?.(t), D.current = null, O.current = !0, E(null), w(!1);
62
+ },
63
+ onLostPointerCapture: (t) => {
64
+ e.onLostPointerCapture?.(t), D.current && (D.current = null, O.current = !0, E(null), w(!1));
65
+ },
66
+ onClickCapture: (t) => {
67
+ O.current ? (O.current = !1, t.preventDefault(), t.stopPropagation()) : e.onClickCapture?.(t);
68
+ },
69
+ onKeyDown: (t) => {
70
+ e.onKeyDown?.(t), O.current = !1, t.defaultPrevented || k || t.key !== " " && t.key !== "Enter" || w(!0);
71
+ },
72
+ onKeyUp: (t) => {
73
+ e.onKeyUp?.(t), w(!1);
74
+ },
75
+ onBlur: (t) => {
76
+ e.onBlur?.(t), w(!1);
77
+ }
78
+ }),
79
+ children: [/* @__PURE__ */ s(n, {
80
+ radius: "capsule",
81
+ render: /* @__PURE__ */ s("span", {}),
82
+ className: "lg-switch-track",
83
+ "aria-hidden": "true"
84
+ }), /* @__PURE__ */ s(l.Thumb, { render: (e) => /* @__PURE__ */ s(i, {
85
+ ...e,
86
+ tag: "span",
87
+ pressed: C,
88
+ motion: g,
89
+ interactive: _,
90
+ options: {
91
+ material: u,
92
+ appearance: d,
93
+ radius: h,
94
+ refraction: p,
95
+ specular: m
96
+ },
97
+ className: "lg-switch-thumb"
98
+ }) })]
99
+ });
100
+ }
101
+ export { u as GlassSwitch };
@@ -1,88 +1,111 @@
1
1
  "use client";
2
- import { GlassShape as e } from "./shape.js";
2
+ import { attachSelectionLens as e } from "../dom/selection.js";
3
3
  import { resolveMotion as t } from "../dom/interaction.js";
4
- import { attachSelectionLens as n } from "../dom/selection.js";
5
- import { useGlassMotion as r, useScene as i } from "./scene.js";
6
- import { GlassSurface as a } from "./surface.js";
7
- import { useMergedRef as o } from "./merged-ref.js";
8
- import { createContext as s, useCallback as c, useContext as l } from "react";
9
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
10
- import { Tabs as f } from "@base-ui/react/tabs";
11
- //#region src/react/tabs.tsx
12
- var p = f.Root, m = f.Panel, h = s({});
13
- function g({ material: e, appearance: t, radius: n = "capsule", refraction: r, tint: o, interactive: s = !0, motion: c, size: l = "default", className: d = "", style: p, children: m, ...g }) {
14
- let _ = i(), v = {
15
- material: e ?? _.material,
16
- appearance: t ?? _.appearance,
17
- motion: c
4
+ import { useMergedRef as n } from "./merged-ref.js";
5
+ import { GlassShape as r } from "./shape.js";
6
+ import { useGlassMotion as i, useScene as a } from "./scene.js";
7
+ import { GlassSurface as o } from "./surface.js";
8
+ import { createContext as s, useCallback as c, useContext as l, useState as u } from "react";
9
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
10
+ import { createPortal as m } from "react-dom";
11
+ import { Tabs as h } from "@base-ui/react/tabs";
12
+ // src/react/tabs.tsx
13
+ var g = h.Root, _ = h.Panel, v = s({});
14
+ function y({ material: e, appearance: t, radius: n = "capsule", refraction: r, tint: i, specular: s, frost: c, interactive: l = !1, motion: u, size: d = "default", className: p = "", style: m, children: g, ..._ }) {
15
+ let y = a(), b = {
16
+ material: e ?? y.material,
17
+ appearance: t ?? y.appearance,
18
+ motion: u
18
19
  };
19
- return /* @__PURE__ */ u(h.Provider, {
20
- value: v,
21
- children: /* @__PURE__ */ u(a, {
22
- material: v.material,
23
- appearance: v.appearance,
20
+ return /* @__PURE__ */ f(v.Provider, {
21
+ value: b,
22
+ children: /* @__PURE__ */ f(o, {
23
+ material: b.material,
24
+ appearance: b.appearance,
24
25
  radius: n,
25
26
  refraction: r,
26
- tint: o,
27
- interactive: s,
28
- motion: c,
29
- style: p,
30
- className: `lg-tabs-list ${d}`,
31
- "data-size": l,
32
- render: /* @__PURE__ */ u(f.List, {
27
+ tint: i,
28
+ specular: s,
29
+ frost: c,
30
+ interactive: l,
31
+ motion: u,
32
+ style: m,
33
+ className: `lg-tabs-list ${p}`,
34
+ "data-size": d,
35
+ render: /* @__PURE__ */ f(h.List, {
33
36
  activateOnFocus: !0,
34
- ...g
37
+ ..._
35
38
  }),
36
- children: m
39
+ children: g
37
40
  })
38
41
  });
39
42
  }
40
- function _({ material: e = "clear", appearance: s, radius: d = "capsule", refraction: p, tint: m, motion: g, className: _ = "", style: v, ref: y, ...b }) {
41
- let x = l(h), { controller: S } = i(), C = r(g ?? x.motion), w = c((e) => {
42
- if (e) return S.addAnimator(n(e, () => t(C)));
43
- }, [S, C]);
44
- return /* @__PURE__ */ u(a, {
45
- material: e,
46
- appearance: s ?? x.appearance,
47
- radius: d,
48
- refraction: p,
49
- tint: m,
50
- style: v,
51
- ref: o(w, y),
52
- className: `lg-tab-indicator ${_}`,
53
- render: /* @__PURE__ */ u(f.Indicator, { ...b })
54
- });
43
+ function b({ material: r = "regular", appearance: s, radius: g = "capsule", refraction: _, tint: y, specular: b, frost: x, motion: S, className: C = "", style: w, ref: T, ...E }) {
44
+ let D = l(v), { controller: O, root: k } = a(), A = i(S ?? D.motion), [j, M] = u(null), [N, P] = u(!1), F = c((n) => {
45
+ if (!n) return;
46
+ let r = e(n, () => t(A), P);
47
+ M(r);
48
+ let i = O.addAnimator(r);
49
+ return () => {
50
+ i(), M(null);
51
+ };
52
+ }, [O, A]), I = c((e) => (j?.setLens(e, k), () => j?.setLens(null, null)), [j, k]), L = s ?? D.appearance;
53
+ return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(o, {
54
+ material: r,
55
+ appearance: L,
56
+ radius: g,
57
+ refraction: _,
58
+ tint: y,
59
+ specular: b,
60
+ frost: x,
61
+ style: w,
62
+ ref: n(F, T),
63
+ className: `lg-tab-indicator ${C}`,
64
+ render: /* @__PURE__ */ f(h.Indicator, { ...E })
65
+ }), k && j && N ? m(/* @__PURE__ */ f(o, {
66
+ material: "lens",
67
+ refraction: 6,
68
+ aberration: !0,
69
+ appearance: L,
70
+ radius: g,
71
+ ref: I,
72
+ className: "lg-tab-lens",
73
+ "aria-hidden": "true",
74
+ render: /* @__PURE__ */ f("span", {})
75
+ }), k) : null] });
55
76
  }
56
- function v({ children: t, className: n, ...r }) {
57
- return /* @__PURE__ */ u(e, {
77
+ function x({ children: e, className: t, ...n }) {
78
+ return /* @__PURE__ */ f(r, {
58
79
  radius: "capsule",
59
80
  concentric: !0,
60
- render: /* @__PURE__ */ u(f.Tab, {
61
- ...r,
62
- className: (e) => `lg-tab ${typeof n == "function" ? n(e) : n ?? ""}`
81
+ render: /* @__PURE__ */ f(h.Tab, {
82
+ ...n,
83
+ className: (e) => `lg-tab ${typeof t == "function" ? t(e) : t ?? ""}`
63
84
  }),
64
- children: /* @__PURE__ */ u("span", {
85
+ children: /* @__PURE__ */ f("span", {
65
86
  className: "lg-tab-label",
66
- children: t
87
+ children: e
67
88
  })
68
89
  });
69
90
  }
70
- function y({ items: e, defaultValue: t, material: n, appearance: r, radius: i, refraction: a, tint: o, interactive: s, motion: c, size: l, className: f = "", "aria-label": m = "Sections", ...h }) {
71
- return /* @__PURE__ */ u(p, {
72
- ...h,
91
+ function S({ items: e, defaultValue: t, material: n, appearance: r, radius: i, refraction: a, tint: o, specular: s, frost: c, interactive: l, motion: u, size: d, className: m = "", "aria-label": h = "Sections", ..._ }) {
92
+ return /* @__PURE__ */ f(g, {
93
+ ..._,
73
94
  defaultValue: t ?? e.find((e) => !e.disabled)?.value,
74
- className: `lg-tabs ${f}`,
75
- children: /* @__PURE__ */ d(g, {
95
+ className: `lg-tabs ${m}`,
96
+ children: /* @__PURE__ */ p(y, {
76
97
  material: n,
77
98
  appearance: r,
78
99
  radius: i,
79
100
  refraction: a,
80
101
  tint: o,
81
- interactive: s,
82
- motion: c,
83
- size: l,
84
- "aria-label": m,
85
- children: [/* @__PURE__ */ u(_, { tint: o }), e.map((e) => /* @__PURE__ */ u(v, {
102
+ specular: s,
103
+ frost: c,
104
+ interactive: l,
105
+ motion: u,
106
+ size: d,
107
+ "aria-label": h,
108
+ children: [/* @__PURE__ */ f(b, { tint: o }), e.map((e) => /* @__PURE__ */ f(x, {
86
109
  value: e.value,
87
110
  disabled: e.disabled,
88
111
  children: e.label
@@ -90,5 +113,4 @@ function y({ items: e, defaultValue: t, material: n, appearance: r, radius: i, r
90
113
  })
91
114
  });
92
115
  }
93
- //#endregion
94
- export { y as GlassTabs, m as GlassTabsContent, _ as GlassTabsIndicator, g as GlassTabsList, p as GlassTabsRoot, v as GlassTabsTrigger };
116
+ export { S as GlassTabs, _ as GlassTabsContent, b as GlassTabsIndicator, y as GlassTabsList, g as GlassTabsRoot, x as GlassTabsTrigger };