@glass-sdk/liquid-glass 0.0.1 → 0.0.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.
Files changed (109) hide show
  1. package/README.md +133 -494
  2. package/dist/core/concentric.js +86 -0
  3. package/dist/core/materials.js +41 -0
  4. package/dist/core/morph-path.js +206 -0
  5. package/dist/core/optics.js +7 -0
  6. package/dist/core/progressive.js +35 -0
  7. package/dist/{concentric-COCiG9DQ.js → core/shape.js} +1 -85
  8. package/dist/core/spring.js +78 -0
  9. package/dist/core/union.js +117 -0
  10. package/dist/core.js +6 -9
  11. package/dist/dom/compose-layers.js +54 -0
  12. package/dist/dom/compound-field.js +23 -0
  13. package/dist/dom/control-motion.js +101 -0
  14. package/dist/dom/engine.js +7 -0
  15. package/dist/dom/exit-handoff.js +14 -0
  16. package/dist/dom/filter-bounds.js +87 -0
  17. package/dist/dom/filter-budget.js +45 -0
  18. package/dist/dom/filter-groups.js +38 -0
  19. package/dist/dom/filter-paint-root.js +41 -0
  20. package/dist/dom/filter-patch.js +129 -0
  21. package/dist/dom/filter-reach.js +36 -0
  22. package/dist/dom/filter-stages.js +7 -0
  23. package/dist/dom/fixed-shape.js +20 -0
  24. package/dist/dom/foreground.js +36 -0
  25. package/dist/dom/interaction.js +129 -0
  26. package/dist/dom/lens-layers.js +163 -0
  27. package/dist/dom/map-blend.js +8 -0
  28. package/dist/dom/map-encoder.js +47 -0
  29. package/dist/dom/map-encoder.worker.js +16 -0
  30. package/dist/dom/map-encoding.js +17 -0
  31. package/dist/dom/map-image.js +34 -0
  32. package/dist/dom/map-store.js +189 -0
  33. package/dist/dom/maps.js +131 -0
  34. package/dist/dom/material-graph.js +52 -0
  35. package/dist/dom/morph.js +296 -0
  36. package/dist/dom/page-zoom.js +46 -0
  37. package/dist/dom/png.js +105 -0
  38. package/dist/dom/progressive.js +299 -0
  39. package/dist/dom/renderer.js +6 -0
  40. package/dist/dom/sampling-bounds.js +22 -0
  41. package/dist/dom/selection.js +106 -0
  42. package/dist/dom/shape-layout.js +199 -0
  43. package/dist/dom/shared-backdrop.js +41 -0
  44. package/dist/dom/ticker.js +103 -0
  45. package/dist/dom/warm.js +108 -0
  46. package/dist/dom.js +694 -2
  47. package/dist/gpu/geometry.js +9 -0
  48. package/dist/gpu/maps.js +8 -0
  49. package/dist/gpu/planes.js +4 -0
  50. package/dist/gpu.js +213 -2
  51. package/dist/index.js +10 -932
  52. package/dist/react/button.js +23 -0
  53. package/dist/react/control-thumb.js +50 -0
  54. package/dist/react/menu.js +159 -0
  55. package/dist/react/merged-ref.js +18 -0
  56. package/dist/react/progressive.js +73 -0
  57. package/dist/react/scene.js +122 -0
  58. package/dist/react/shape.js +93 -0
  59. package/dist/react/surface.js +69 -0
  60. package/dist/react/tabs.js +94 -0
  61. package/dist/react/toolbar.js +145 -0
  62. package/dist/react/value-control-motion.js +9 -0
  63. package/dist/react/value-controls.js +176 -0
  64. package/dist/styles.css +19 -0
  65. package/dist/types/core/optics.d.ts +0 -1
  66. package/dist/types/core/spring.d.ts +1 -1
  67. package/dist/types/dom/compose-layers.d.ts +15 -0
  68. package/dist/types/dom/compound-field.d.ts +35 -0
  69. package/dist/types/dom/engine.d.ts +9 -0
  70. package/dist/types/dom/exit-handoff.d.ts +7 -0
  71. package/dist/types/dom/filter-bounds.d.ts +1 -1
  72. package/dist/types/dom/filter-budget.d.ts +20 -0
  73. package/dist/types/dom/filter-groups.d.ts +25 -0
  74. package/dist/types/dom/filter-paint-root.d.ts +9 -0
  75. package/dist/types/dom/filter-patch.d.ts +3 -8
  76. package/dist/types/dom/filter-reach.d.ts +23 -0
  77. package/dist/types/dom/filter-stages.d.ts +5 -0
  78. package/dist/types/dom/index.d.ts +3 -0
  79. package/dist/types/dom/lens-layers.d.ts +68 -0
  80. package/dist/types/dom/map-blend.d.ts +22 -0
  81. package/dist/types/dom/map-encoding.d.ts +1 -1
  82. package/dist/types/dom/map-image.d.ts +5 -2
  83. package/dist/types/dom/maps.d.ts +5 -5
  84. package/dist/types/dom/material-graph.d.ts +22 -0
  85. package/dist/types/dom/morph.d.ts +8 -0
  86. package/dist/types/dom/page-zoom.d.ts +18 -0
  87. package/dist/types/dom/png.d.ts +2 -0
  88. package/dist/types/dom/progressive.d.ts +29 -1
  89. package/dist/types/dom/renderer.d.ts +4 -0
  90. package/dist/types/dom/sampling-bounds.d.ts +10 -0
  91. package/dist/types/dom/shared-backdrop.d.ts +19 -0
  92. package/dist/types/dom/warm.d.ts +4 -1
  93. package/dist/types/gpu/geometry.d.ts +17 -0
  94. package/dist/types/gpu/index.d.ts +4 -16
  95. package/dist/types/gpu/planes.d.ts +2 -0
  96. package/dist/types/react/button.d.ts +11 -0
  97. package/dist/types/react/index.d.ts +14 -149
  98. package/dist/types/react/menu.d.ts +29 -0
  99. package/dist/types/react/progressive.d.ts +15 -0
  100. package/dist/types/react/scene.d.ts +35 -0
  101. package/dist/types/react/surface.d.ts +35 -0
  102. package/dist/types/react/tabs.d.ts +29 -0
  103. package/dist/types/react/toolbar.d.ts +21 -0
  104. package/package.json +1 -1
  105. package/dist/dom-CKc8vDTR.js +0 -2532
  106. package/dist/gpu-Co5Y89mh.js +0 -244
  107. package/dist/map-encoder.worker-DO1drw0Y.js +0 -16
  108. package/dist/materials-DVPgteZ9.js +0 -234
  109. package/dist/types/dom/progressive-maps.d.ts +0 -6
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { GlassSurface as e } from "./surface.js";
3
+ import { jsx as t } from "react/jsx-runtime";
4
+ import { Button as n } from "@base-ui/react/button";
5
+ //#region src/react/button.tsx
6
+ function r({ material: r, appearance: i, radius: a = "capsule", refraction: o, tint: s, interactive: c = !0, motion: l, size: u = "default", className: d = "", style: f, children: p, ...m }) {
7
+ return /* @__PURE__ */ t(e, {
8
+ material: r,
9
+ appearance: i,
10
+ radius: u.startsWith("icon") ? "circle" : a,
11
+ refraction: o,
12
+ tint: s,
13
+ interactive: c,
14
+ motion: l,
15
+ className: `lg-button ${d}`,
16
+ style: f,
17
+ "data-size": u,
18
+ render: /* @__PURE__ */ t(n, { ...m }),
19
+ children: p
20
+ });
21
+ }
22
+ //#endregion
23
+ export { r as GlassButton };
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { GlassShape as e } from "./shape.js";
3
+ import { attachNativeControlMotion as t } from "../dom/control-motion.js";
4
+ import { useGlassMotion as n } from "./scene.js";
5
+ import { GlassSurface as r } from "./surface.js";
6
+ import { useCallback as i, useEffect as a, useState as o } from "react";
7
+ import { useRender as s } from "@base-ui/react/use-render";
8
+ import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
9
+ //#region src/react/control-thumb.tsx
10
+ function d(e) {
11
+ let [t, n] = o(e);
12
+ return a(() => {
13
+ let t = setTimeout(() => n(e), e ? 0 : 320);
14
+ return () => clearTimeout(t);
15
+ }, [e]), e ? "pressed" : t ? "settling" : "idle";
16
+ }
17
+ function f({ pressed: a, options: o, tag: f = "div", ref: p, children: m, motion: h, interactive: g = !0, ..._ }) {
18
+ let v = d(a), y = h === "none" ? a ? "pressed" : "idle" : v, b = n(h), x = i((e) => {
19
+ if (e) return t(e, b, g);
20
+ }, [b, g]);
21
+ return s({
22
+ defaultTagName: f,
23
+ ref: [x, p ?? null],
24
+ props: {
25
+ ..._,
26
+ className: `lg-control-thumb ${_.className ?? ""}`,
27
+ "data-press-phase": y,
28
+ children: /* @__PURE__ */ u(c, { children: [
29
+ m,
30
+ y !== "idle" && /* @__PURE__ */ l(r, {
31
+ ...o,
32
+ material: o.material ?? "clear",
33
+ refraction: o.refraction ?? (_.className?.includes("lg-switch-thumb") ? 7.75 : 5),
34
+ radius: o.radius ?? "capsule",
35
+ render: /* @__PURE__ */ l("span", {}),
36
+ className: "lg-control-lens",
37
+ "aria-hidden": "true"
38
+ }),
39
+ /* @__PURE__ */ l(e, {
40
+ radius: o.radius ?? "capsule",
41
+ render: /* @__PURE__ */ l("span", {}),
42
+ className: "lg-control-face",
43
+ "aria-hidden": "true"
44
+ })
45
+ ] })
46
+ }
47
+ });
48
+ }
49
+ //#endregion
50
+ export { f as ControlThumb };
@@ -0,0 +1,159 @@
1
+ "use client";
2
+ import { GlassShape as e } from "./shape.js";
3
+ import { prepareSubmenuHandoff as t } from "../dom/morph.js";
4
+ import { useScene as n } from "./scene.js";
5
+ import { GlassSurface as r } from "./surface.js";
6
+ import { useMergedRef as i } from "./merged-ref.js";
7
+ import { Fragment as a, createContext as o, useCallback as s, useContext as c, useEffect as l, useRef as u, useState as d } from "react";
8
+ import { useRender as f } from "@base-ui/react/use-render";
9
+ import { jsx as p } from "react/jsx-runtime";
10
+ import { Menu as m } from "@base-ui/react/menu";
11
+ //#region src/react/menu.tsx
12
+ var h = o(null);
13
+ function g(e) {
14
+ let [t] = d(() => ({
15
+ triggers: /* @__PURE__ */ new Map(),
16
+ stable: e
17
+ }));
18
+ return t;
19
+ }
20
+ function _(e) {
21
+ let t = c(h), [n] = d(() => e);
22
+ return s((e) => {
23
+ if (e && t) return t.triggers.set(e, n(e)), () => {
24
+ t.triggers.delete(e);
25
+ };
26
+ }, [t, n]);
27
+ }
28
+ function v(e) {
29
+ let t = g(!0);
30
+ return /* @__PURE__ */ p(h.Provider, {
31
+ value: t,
32
+ children: /* @__PURE__ */ p(m.Root, { ...e })
33
+ });
34
+ }
35
+ function y({ ref: e, ...t }) {
36
+ let n = _((e) => e.parentElement), r = f({
37
+ render: /* @__PURE__ */ p(m.Trigger, { ...t }),
38
+ ref: [n, e ?? null]
39
+ });
40
+ return /* @__PURE__ */ p("span", {
41
+ className: "lg-menu-anchor",
42
+ children: r
43
+ });
44
+ }
45
+ function b(e) {
46
+ let t = g(!1);
47
+ return /* @__PURE__ */ p(h.Provider, {
48
+ value: t,
49
+ children: /* @__PURE__ */ p(m.SubmenuRoot, { ...e })
50
+ });
51
+ }
52
+ function x({ ref: n, delay: r = 40, onPointerEnter: a, onPointerLeave: o, onFocus: s, onBlur: c, ...d }) {
53
+ let f = _(() => null), h = u(void 0), g = (e) => {
54
+ h.current?.(), h.current = t(e);
55
+ }, v = () => {
56
+ h.current?.(), h.current = void 0;
57
+ };
58
+ return l(() => v, []), /* @__PURE__ */ p(e, {
59
+ ref: i(f, n),
60
+ concentric: { contentPadding: 8 },
61
+ render: /* @__PURE__ */ p(m.SubmenuTrigger, {
62
+ delay: r,
63
+ ...d,
64
+ onPointerEnter: (e) => {
65
+ a?.(e), !e.defaultPrevented && !d.disabled && g(e.currentTarget);
66
+ },
67
+ onPointerLeave: (e) => {
68
+ o?.(e), v();
69
+ },
70
+ onFocus: (e) => {
71
+ s?.(e), !e.defaultPrevented && !d.disabled && g(e.currentTarget);
72
+ },
73
+ onBlur: (e) => {
74
+ c?.(e), v();
75
+ }
76
+ })
77
+ });
78
+ }
79
+ var S = m.Group;
80
+ function C(t) {
81
+ return /* @__PURE__ */ p(e, {
82
+ concentric: { contentPadding: 8 },
83
+ render: /* @__PURE__ */ p(m.GroupLabel, { ...t })
84
+ });
85
+ }
86
+ var w = m.Separator;
87
+ function T(t) {
88
+ return /* @__PURE__ */ p(e, {
89
+ concentric: { contentPadding: 8 },
90
+ render: /* @__PURE__ */ p(m.CheckboxItem, { ...t })
91
+ });
92
+ }
93
+ var E = m.RadioGroup;
94
+ function D(t) {
95
+ return /* @__PURE__ */ p(e, {
96
+ concentric: { contentPadding: 8 },
97
+ render: /* @__PURE__ */ p(m.RadioItem, { ...t })
98
+ });
99
+ }
100
+ function O({ children: e, className: t = "", style: i, material: o = "regular", appearance: s, radius: l = 28, refraction: u, tint: d, interactive: f, motion: g, morph: _, neck: v, side: y, align: b, sideOffset: x, alignOffset: S, collisionAvoidance: C, positionerProps: w, portalProps: T, ...E }) {
101
+ let { root: D } = n(), O = c(h), k = () => {
102
+ let e = [...O?.triggers.keys() ?? []];
103
+ return e.find((e) => e.hasAttribute("data-popup-open")) ?? e[0] ?? null;
104
+ }, A = () => {
105
+ let e = k();
106
+ return e ? O?.triggers.get(e) ?? null : null;
107
+ }, j = O?.stable ? O : null;
108
+ return /* @__PURE__ */ p(m.Portal, {
109
+ ...T,
110
+ container: D,
111
+ style: {
112
+ display: "contents",
113
+ ...T?.style
114
+ },
115
+ children: /* @__PURE__ */ p(m.Positioner, {
116
+ className: "lg-menu-positioner",
117
+ ...w,
118
+ anchor: w?.anchor ?? (j ? A : void 0),
119
+ side: y ?? w?.side,
120
+ align: b ?? w?.align ?? "end",
121
+ sideOffset: x ?? w?.sideOffset ?? 8,
122
+ alignOffset: S ?? w?.alignOffset,
123
+ collisionAvoidance: C ?? w?.collisionAvoidance,
124
+ children: /* @__PURE__ */ p(r, {
125
+ material: o,
126
+ appearance: s,
127
+ radius: l,
128
+ refraction: u,
129
+ tint: d,
130
+ interactive: f,
131
+ motion: g,
132
+ morphFrom: k,
133
+ morph: _,
134
+ neck: v,
135
+ style: i,
136
+ className: `lg-menu ${t}`,
137
+ render: /* @__PURE__ */ p(m.Popup, { ...E }),
138
+ children: /* @__PURE__ */ p(a, { children: e })
139
+ })
140
+ })
141
+ });
142
+ }
143
+ function k(t) {
144
+ return /* @__PURE__ */ p(e, {
145
+ concentric: { contentPadding: 8 },
146
+ render: /* @__PURE__ */ p(m.Item, { ...t })
147
+ });
148
+ }
149
+ function A(e) {
150
+ return /* @__PURE__ */ p(O, {
151
+ neck: 0,
152
+ ...e,
153
+ "data-glass-submenu": "",
154
+ side: e.side ?? e.positionerProps?.side ?? "inline-end",
155
+ align: e.align ?? e.positionerProps?.align ?? "start"
156
+ });
157
+ }
158
+ //#endregion
159
+ export { v as GlassMenu, T as GlassMenuCheckboxItem, O as GlassMenuContent, S as GlassMenuGroup, C as GlassMenuGroupLabel, k as GlassMenuItem, E as GlassMenuRadioGroup, D as GlassMenuRadioItem, w as GlassMenuSeparator, b as GlassMenuSubmenu, A as GlassMenuSubmenuContent, x as GlassMenuSubmenuTrigger, y as GlassMenuTrigger };
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { useCallback as e } from "react";
3
+ //#region src/react/merged-ref.ts
4
+ function t(e, t) {
5
+ if (typeof e == "function") return e(t);
6
+ e && (e.current = t);
7
+ }
8
+ function n(n, r) {
9
+ return e((e) => {
10
+ let i = [t(n, e), t(r, e)];
11
+ return () => [n, r].forEach((e, n) => {
12
+ let r = i[n];
13
+ typeof r == "function" ? r() : t(e, null);
14
+ });
15
+ }, [n, r]);
16
+ }
17
+ //#endregion
18
+ export { n as useMergedRef };
@@ -0,0 +1,73 @@
1
+ "use client";
2
+ import { validateProgressive as e } from "../core/progressive.js";
3
+ import { useScene as t } from "./scene.js";
4
+ import { useCallback as n, useLayoutEffect as r } from "react";
5
+ import { useRender as i } from "@base-ui/react/use-render";
6
+ //#region src/react/progressive.tsx
7
+ function a({ edge: r = "bottom", size: a = 80, blur: o = 20, refraction: s = 0, disabled: c = !1, className: l = "", style: u, ref: d, ...f }) {
8
+ let { controller: p } = t();
9
+ e({
10
+ edge: r,
11
+ size: a,
12
+ blur: o,
13
+ refraction: s
14
+ });
15
+ let m = n((e) => {
16
+ if (e) return p.addProgressiveBlur(e, {
17
+ edge: r,
18
+ size: a,
19
+ blur: o,
20
+ refraction: s,
21
+ disabled: c
22
+ });
23
+ }, [
24
+ p,
25
+ r,
26
+ a,
27
+ o,
28
+ s,
29
+ c
30
+ ]);
31
+ return i({
32
+ ref: [m, d ?? null],
33
+ props: {
34
+ ...f,
35
+ "aria-hidden": !0,
36
+ "data-edge": r,
37
+ className: `lg-progressive-blur ${l}`,
38
+ style: {
39
+ "--lg-blur-size": `${a}px`,
40
+ ...u,
41
+ pointerEvents: "none"
42
+ }
43
+ }
44
+ });
45
+ }
46
+ var o = ["top", "bottom"];
47
+ function s({ target: n, edges: i = o, size: a = 80, blur: s = 20, refraction: c = 0, disabled: l = !1 }) {
48
+ let { controller: u } = t();
49
+ e({
50
+ size: a,
51
+ blur: s,
52
+ refraction: c
53
+ }), i.forEach((t) => e({ edge: t }));
54
+ let d = [...new Set(i)].join(",");
55
+ return r(() => u.addScrollEdges({
56
+ target: () => n.current,
57
+ edges: d ? d.split(",") : [],
58
+ size: a,
59
+ blur: s,
60
+ refraction: c,
61
+ disabled: l
62
+ }), [
63
+ u,
64
+ n,
65
+ d,
66
+ a,
67
+ s,
68
+ c,
69
+ l
70
+ ]), null;
71
+ }
72
+ //#endregion
73
+ export { a as GlassProgressiveBlur, s as GlassScrollEdges };
@@ -0,0 +1,122 @@
1
+ "use client";
2
+ import { webkit as e } from "../dom/engine.js";
3
+ import { createGlassScene as t } from "../dom.js";
4
+ import { createContext as n, useCallback as r, useContext as i, useLayoutEffect as a, useRef as o, useState as s, useSyncExternalStore as c } from "react";
5
+ import { useRender as l } from "@base-ui/react/use-render";
6
+ import { jsx as u } from "react/jsx-runtime";
7
+ //#region src/react/scene.tsx
8
+ var d = {
9
+ setContent() {},
10
+ addForeground() {
11
+ return () => {};
12
+ },
13
+ addAnimator() {
14
+ return () => {};
15
+ },
16
+ addProgressiveBlur() {
17
+ return () => {};
18
+ },
19
+ addScrollEdges() {
20
+ return () => {};
21
+ },
22
+ addSurface() {
23
+ return () => {};
24
+ },
25
+ dispose() {}
26
+ }, f = n(null);
27
+ function p(e) {
28
+ let t = i(f);
29
+ return e ?? t?.motion ?? "full";
30
+ }
31
+ function m() {
32
+ let e = i(f);
33
+ if (!e) throw Error("Glass components must be inside <GlassScene>.");
34
+ return e;
35
+ }
36
+ function h() {
37
+ let { controller: e } = m();
38
+ return r((t) => {
39
+ if (t) return e.addForeground(t);
40
+ }, [e]);
41
+ }
42
+ function g({ render: e, ref: t, ...n }) {
43
+ let r = h();
44
+ return l({
45
+ render: e,
46
+ ref: [r, t ?? null],
47
+ props: n
48
+ });
49
+ }
50
+ function _({ children: e, className: n = "", onDiagnostic: i, maxSurfaces: c = 16, ref: p, material: m = "clear", appearance: h = "light", motion: g = "full", ..._ }) {
51
+ let v = Math.max(1, Math.min(64, Math.floor(c)));
52
+ if (!Number.isFinite(v)) throw RangeError("maxSurfaces must be finite.");
53
+ let [y, b] = s({
54
+ controller: d,
55
+ root: null,
56
+ maxSurfaces: v,
57
+ material: m,
58
+ appearance: h,
59
+ motion: g
60
+ }), x = o(i);
61
+ a(() => {
62
+ x.current = i;
63
+ }, [i]);
64
+ let S = r((e) => {
65
+ if (!e) return;
66
+ let n = t(e, {
67
+ maxSurfaces: v,
68
+ onDiagnostic: (e) => x.current?.(e)
69
+ });
70
+ return b((t) => ({
71
+ ...t,
72
+ controller: n,
73
+ root: e,
74
+ maxSurfaces: v
75
+ })), () => n.dispose();
76
+ }, [v]);
77
+ return l({
78
+ ref: [S, p ?? null],
79
+ props: {
80
+ ..._,
81
+ className: `lg-scene ${n}`,
82
+ children: /* @__PURE__ */ u(f.Provider, {
83
+ value: {
84
+ ...y,
85
+ material: m,
86
+ appearance: h,
87
+ motion: g
88
+ },
89
+ children: e
90
+ })
91
+ }
92
+ });
93
+ }
94
+ var v = () => () => {}, y = () => e, b = () => !1;
95
+ function x({ layout: e = "overlay", className: t = "", ref: n, ...i }) {
96
+ let { controller: a } = m(), o = c(v, y, b) && e === "scroll", s = r((e) => (a.setContent(e), () => {
97
+ a.setContent(null);
98
+ }), [a]), d = l({
99
+ ref: [s, n ?? null],
100
+ props: {
101
+ ...i,
102
+ "data-layout": e,
103
+ className: `lg-content ${t}`
104
+ }
105
+ });
106
+ return d = /* @__PURE__ */ u("div", {
107
+ "data-glass-blur-host": "",
108
+ "data-layout": e,
109
+ children: d
110
+ }), o && (d = /* @__PURE__ */ u("svg", {
111
+ className: "lg-scroll-paint-root",
112
+ width: "100%",
113
+ height: "100%",
114
+ children: /* @__PURE__ */ u("foreignObject", {
115
+ width: "100%",
116
+ height: "100%",
117
+ children: d
118
+ })
119
+ })), d;
120
+ }
121
+ //#endregion
122
+ export { x as GlassContent, g as GlassForeground, _ as GlassScene, h as useGlassForeground, p as useGlassMotion, m as useScene };
@@ -0,0 +1,93 @@
1
+ "use client";
2
+ import { observeFixedShape as e } from "../dom/fixed-shape.js";
3
+ import { observeConcentricShape as t, observeCornerPlacement as n, shapeContainerAttributes as r } from "../dom/shape-layout.js";
4
+ import { useLayoutEffect as i, useRef as a } from "react";
5
+ import { useRender as o } from "@base-ui/react/use-render";
6
+ import { jsx as s } from "react/jsx-runtime";
7
+ //#region src/react/shape.tsx
8
+ function c({ concentric: e, container: t, ...n }) {
9
+ return e ? /* @__PURE__ */ s(u, {
10
+ ...n,
11
+ concentric: e,
12
+ container: t
13
+ }) : /* @__PURE__ */ s(l, { ...n });
14
+ }
15
+ function l({ radius: t = 8, render: n, ref: s, style: c, ...l }) {
16
+ let u = a(null);
17
+ return i(() => {
18
+ if (u.current) return e(u.current, t);
19
+ }, [t]), o({
20
+ render: n,
21
+ ref: [u, s ?? null],
22
+ props: {
23
+ ...l,
24
+ ...r(t),
25
+ "data-lg-shape": "",
26
+ style: {
27
+ ...c,
28
+ borderRadius: 0
29
+ }
30
+ }
31
+ });
32
+ }
33
+ function u({ radius: e, concentric: n, container: s, render: c, ref: l, style: u, ...d }) {
34
+ let f = a(null), p = typeof n == "object" ? n : {}, m = JSON.stringify({
35
+ ...p,
36
+ radius: e ?? p.radius ?? 8
37
+ });
38
+ return i(() => {
39
+ if (f.current) return t(f.current, JSON.parse(m), s ? () => s.current : void 0);
40
+ }, [m, s]), o({
41
+ render: c,
42
+ ref: [f, l ?? null],
43
+ props: {
44
+ ...d,
45
+ ...r(e ?? p.radius ?? 8),
46
+ "data-lg-shape": "",
47
+ "data-lg-concentric": "",
48
+ style: {
49
+ ...u,
50
+ borderRadius: 0
51
+ }
52
+ }
53
+ });
54
+ }
55
+ function d({ radius: e = 8, render: t, ref: n, ...i }) {
56
+ return o({
57
+ render: t,
58
+ ref: n ?? null,
59
+ props: {
60
+ ...i,
61
+ ...r(e)
62
+ }
63
+ });
64
+ }
65
+ function f({ enabled: e = !0, corner: t = "top-right", gap: r = 8, radius: s = "circle", container: c, render: l, ref: u, style: d, ...f }) {
66
+ let p = a(null);
67
+ return i(() => {
68
+ if (p.current && e) return n(p.current, {
69
+ corner: t,
70
+ gap: r,
71
+ radius: s
72
+ }, c ? () => c.current : void 0);
73
+ }, [
74
+ t,
75
+ r,
76
+ s,
77
+ c,
78
+ e
79
+ ]), o({
80
+ render: l,
81
+ ref: [p, u ?? null],
82
+ props: {
83
+ ...f,
84
+ "data-lg-corner": t,
85
+ style: {
86
+ position: "absolute",
87
+ ...d
88
+ }
89
+ }
90
+ });
91
+ }
92
+ //#endregion
93
+ export { f as GlassCorner, c as GlassShape, d as GlassShapeContainer };
@@ -0,0 +1,69 @@
1
+ "use client";
2
+ import { shapeContainerAttributes as e } from "../dom/shape-layout.js";
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;
13
+ });
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
31
+ }), [
32
+ s,
33
+ c,
34
+ l,
35
+ O,
36
+ k,
37
+ d,
38
+ f,
39
+ p,
40
+ v,
41
+ y,
42
+ h,
43
+ g,
44
+ _,
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],
56
+ 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 }
65
+ }
66
+ });
67
+ }
68
+ //#endregion
69
+ export { s as GlassSurface };
@@ -0,0 +1,94 @@
1
+ "use client";
2
+ import { GlassShape as e } from "./shape.js";
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
18
+ };
19
+ return /* @__PURE__ */ u(h.Provider, {
20
+ value: v,
21
+ children: /* @__PURE__ */ u(a, {
22
+ material: v.material,
23
+ appearance: v.appearance,
24
+ radius: n,
25
+ 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, {
33
+ activateOnFocus: !0,
34
+ ...g
35
+ }),
36
+ children: m
37
+ })
38
+ });
39
+ }
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
+ });
55
+ }
56
+ function v({ children: t, className: n, ...r }) {
57
+ return /* @__PURE__ */ u(e, {
58
+ radius: "capsule",
59
+ concentric: !0,
60
+ render: /* @__PURE__ */ u(f.Tab, {
61
+ ...r,
62
+ className: (e) => `lg-tab ${typeof n == "function" ? n(e) : n ?? ""}`
63
+ }),
64
+ children: /* @__PURE__ */ u("span", {
65
+ className: "lg-tab-label",
66
+ children: t
67
+ })
68
+ });
69
+ }
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,
73
+ defaultValue: t ?? e.find((e) => !e.disabled)?.value,
74
+ className: `lg-tabs ${f}`,
75
+ children: /* @__PURE__ */ d(g, {
76
+ material: n,
77
+ appearance: r,
78
+ radius: i,
79
+ refraction: a,
80
+ 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, {
86
+ value: e.value,
87
+ disabled: e.disabled,
88
+ children: e.label
89
+ }, e.value))]
90
+ })
91
+ });
92
+ }
93
+ //#endregion
94
+ export { y as GlassTabs, m as GlassTabsContent, _ as GlassTabsIndicator, g as GlassTabsList, p as GlassTabsRoot, v as GlassTabsTrigger };