@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.
- package/CHANGELOG.md +124 -0
- package/README.md +66 -149
- package/dist/core/concentric.js +20 -3
- package/dist/core/corner-options.js +12 -0
- package/dist/core/corner-path.js +118 -0
- package/dist/core/materials.js +264 -32
- package/dist/core/optics.js +1 -2
- package/dist/core/progressive.js +1 -2
- package/dist/core/shape.js +18 -28
- package/dist/core/spring.js +5 -10
- package/dist/core.js +5 -6
- package/dist/dom/backdrop-glass.js +46 -0
- package/dist/dom/compose-layers.js +42 -31
- package/dist/dom/composited.js +136 -0
- package/dist/dom/control-motion.js +58 -47
- package/dist/dom/engine.js +1 -2
- package/dist/dom/escaped-layers.js +179 -0
- package/dist/dom/filter-bounds.js +42 -13
- package/dist/dom/filter-budget.js +1 -2
- package/dist/dom/filter-chain.js +40 -0
- package/dist/dom/filter-groups.js +33 -14
- package/dist/dom/filter-paint-root.js +8 -6
- package/dist/dom/filter-patch.js +94 -55
- package/dist/dom/filter-reach.js +32 -19
- package/dist/dom/filter-stages.js +1 -2
- package/dist/dom/fixed-shape.js +23 -16
- package/dist/dom/foreground.js +16 -17
- package/dist/dom/interaction.js +65 -92
- package/dist/dom/layout-rect.js +42 -0
- package/dist/dom/layout-size.js +28 -0
- package/dist/dom/lens-layers.js +250 -136
- package/dist/dom/map-encoder.js +16 -13
- package/dist/dom/map-encoder.worker.js +2 -3
- package/dist/dom/map-encoding.js +49 -12
- package/dist/dom/map-image.js +29 -7
- package/dist/dom/map-store.js +1 -2
- package/dist/dom/maps.js +133 -83
- package/dist/dom/material-graph.js +108 -29
- package/dist/dom/media-mirror.js +244 -0
- package/dist/dom/page-zoom.js +19 -18
- package/dist/dom/png.js +1 -2
- package/dist/dom/progressive.js +152 -147
- package/dist/dom/renderer.js +1 -2
- package/dist/dom/sampling-bounds.js +1 -2
- package/dist/dom/selection.js +133 -79
- package/dist/dom/shape-attributes.js +9 -0
- package/dist/dom/shape-effects.js +14 -0
- package/dist/dom/shape-geometry.js +3 -0
- package/dist/dom/shape-layout.js +115 -116
- package/dist/dom/shared-backdrop.js +33 -25
- package/dist/dom/specular.js +116 -0
- package/dist/dom/ticker.js +28 -19
- package/dist/dom/tint-color.js +24 -0
- package/dist/dom/warm.js +63 -59
- package/dist/dom.js +591 -505
- package/dist/gpu/geometry.js +2 -3
- package/dist/gpu/maps.js +1109 -7
- package/dist/gpu/planes.js +2 -3
- package/dist/gpu.js +66 -64
- package/dist/index.js +12 -10
- package/dist/react/button.js +12 -11
- package/dist/react/color-picker.js +199 -0
- package/dist/react/control-thumb.js +4 -5
- package/dist/react/menu.js +82 -111
- package/dist/react/merged-ref.js +1 -2
- package/dist/react/progressive.js +1 -2
- package/dist/react/scene.js +71 -55
- package/dist/react/shape.js +67 -47
- package/dist/react/slider.js +81 -0
- package/dist/react/surface.js +90 -56
- package/dist/react/switch.js +101 -0
- package/dist/react/tabs.js +85 -63
- package/dist/react/toolbar.js +38 -123
- package/dist/react/value-control-motion.js +1 -2
- package/dist/styles.css +517 -111
- package/dist/types/core/concentric.d.ts +8 -0
- package/dist/types/core/corner-options.d.ts +4 -0
- package/dist/types/core/corner-path.d.ts +8 -0
- package/dist/types/core/index.d.ts +3 -5
- package/dist/types/core/materials.d.ts +100 -28
- package/dist/types/core/shape.d.ts +4 -6
- package/dist/types/core/spring.d.ts +8 -12
- package/dist/types/dom/backdrop-glass.d.ts +38 -0
- package/dist/types/dom/compose-layers.d.ts +4 -0
- package/dist/types/dom/composited.d.ts +61 -0
- package/dist/types/dom/escaped-layers.d.ts +32 -0
- package/dist/types/dom/filter-bounds.d.ts +4 -0
- package/dist/types/dom/filter-chain.d.ts +6 -0
- package/dist/types/dom/filter-groups.d.ts +1 -1
- package/dist/types/dom/filter-paint-root.d.ts +3 -0
- package/dist/types/dom/filter-patch.d.ts +5 -0
- package/dist/types/dom/filter-reach.d.ts +9 -9
- package/dist/types/dom/foreground.d.ts +2 -1
- package/dist/types/dom/index.d.ts +8 -19
- package/dist/types/dom/interaction.d.ts +8 -8
- package/dist/types/dom/layout-rect.d.ts +17 -0
- package/dist/types/dom/layout-size.d.ts +11 -0
- package/dist/types/dom/lens-layers.d.ts +18 -10
- package/dist/types/dom/map-encoder.d.ts +5 -2
- package/dist/types/dom/map-encoding.d.ts +12 -3
- package/dist/types/dom/map-image.d.ts +7 -1
- package/dist/types/dom/maps.d.ts +25 -7
- package/dist/types/dom/material-graph.d.ts +73 -10
- package/dist/types/dom/media-mirror.d.ts +49 -0
- package/dist/types/dom/progressive.d.ts +2 -5
- package/dist/types/dom/sampling-bounds.d.ts +1 -3
- package/dist/types/dom/selection.d.ts +29 -4
- package/dist/types/dom/shape-attributes.d.ts +6 -0
- package/dist/types/dom/shape-effects.d.ts +10 -0
- package/dist/types/dom/shape-geometry.d.ts +6 -0
- package/dist/types/dom/shape-layout.d.ts +2 -4
- package/dist/types/dom/shared-backdrop.d.ts +7 -3
- package/dist/types/dom/specular.d.ts +50 -0
- package/dist/types/dom/ticker.d.ts +4 -1
- package/dist/types/dom/tint-color.d.ts +11 -0
- package/dist/types/dom/warm.d.ts +8 -2
- package/dist/types/gpu/geometry.d.ts +2 -0
- package/dist/types/gpu/planes.d.ts +3 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/react/button.d.ts +1 -1
- package/dist/types/react/color-picker.d.ts +26 -0
- package/dist/types/react/index.d.ts +14 -10
- package/dist/types/react/menu.d.ts +4 -5
- package/dist/types/react/progressive.d.ts +1 -1
- package/dist/types/react/scene.d.ts +4 -2
- package/dist/types/react/shape.d.ts +11 -1
- package/dist/types/react/slider.d.ts +14 -0
- package/dist/types/react/surface.d.ts +11 -22
- package/dist/types/react/switch.d.ts +9 -0
- package/dist/types/react/tabs.d.ts +3 -3
- package/dist/types/react/toolbar.d.ts +1 -1
- package/package.json +46 -40
- package/dist/core/morph-path.js +0 -206
- package/dist/core/union.js +0 -117
- package/dist/dom/compound-field.js +0 -23
- package/dist/dom/exit-handoff.js +0 -14
- package/dist/dom/map-blend.js +0 -8
- package/dist/dom/morph.js +0 -296
- package/dist/react/value-controls.js +0 -176
- package/dist/types/core/morph-path.d.ts +0 -110
- package/dist/types/core/union.d.ts +0 -20
- package/dist/types/dom/compound-field.d.ts +0 -35
- package/dist/types/dom/exit-handoff.d.ts +0 -7
- package/dist/types/dom/map-blend.d.ts +0 -22
- package/dist/types/dom/morph.d.ts +0 -78
- package/dist/types/react/value-controls.d.ts +0 -20
package/dist/gpu/planes.js
CHANGED
package/dist/gpu.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import i from "./
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { outlineSegments as e } from "./core/concentric.js";
|
|
2
|
+
import { shapeSegments as t } from "./core/shape.js";
|
|
3
|
+
import n from "./gpu/maps.js";
|
|
4
|
+
import { mapPlanes as r } from "./gpu/planes.js";
|
|
5
|
+
import { refractionFor as i } from "./core/materials.js";
|
|
6
|
+
import { mapScale as a } from "./gpu/geometry.js";
|
|
7
|
+
import { effect as o, frame as s, init as c, target as l } from "vgpu";
|
|
8
|
+
// src/gpu/index.ts
|
|
9
|
+
var u = 32, d = 4096;
|
|
10
|
+
function f(n) {
|
|
10
11
|
if (![
|
|
11
12
|
n.width,
|
|
12
13
|
n.height,
|
|
13
14
|
n.dpr ?? 1
|
|
14
15
|
].every(Number.isFinite) || n.width <= 0 || n.height <= 0) throw RangeError("Glass geometry must have positive, finite dimensions.");
|
|
15
|
-
let
|
|
16
|
-
if (
|
|
17
|
-
let { segments: s } = n.outline ?
|
|
16
|
+
let r = a(n), i = Math.ceil((n.width + 4) * r), o = Math.ceil((n.height + 4) * r);
|
|
17
|
+
if (i > 4096 || o * 3 > 8192) throw RangeError("Glass map exceeds the 4096 × 4096 pixel surface limit.");
|
|
18
|
+
let { segments: s } = n.outline ? e(n.outline) : t(n.width, n.height, n.radius);
|
|
18
19
|
return {
|
|
19
20
|
geometry: n,
|
|
20
|
-
columns:
|
|
21
|
+
columns: i,
|
|
21
22
|
rows: o,
|
|
22
|
-
dpr:
|
|
23
|
+
dpr: r,
|
|
23
24
|
segments: s
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
|
-
var
|
|
27
|
+
var p = class {
|
|
27
28
|
gpu;
|
|
28
29
|
shader;
|
|
29
30
|
ready;
|
|
@@ -43,9 +44,10 @@ var f = class {
|
|
|
43
44
|
symmetric: 1,
|
|
44
45
|
start: 0,
|
|
45
46
|
count: 0,
|
|
46
|
-
|
|
47
|
+
rim: 0,
|
|
48
|
+
height: 20
|
|
47
49
|
};
|
|
48
|
-
this.shader =
|
|
50
|
+
this.shader = o(e, n, {
|
|
49
51
|
label: "liquid-glass/material-field",
|
|
50
52
|
set: {
|
|
51
53
|
batch: {
|
|
@@ -55,9 +57,9 @@ var f = class {
|
|
|
55
57
|
0,
|
|
56
58
|
0
|
|
57
59
|
],
|
|
58
|
-
shapes: Array.from({ length:
|
|
60
|
+
shapes: Array.from({ length: u }, () => t)
|
|
59
61
|
},
|
|
60
|
-
outline: { segments: Array.from({ length:
|
|
62
|
+
outline: { segments: Array.from({ length: d }, () => [
|
|
61
63
|
0,
|
|
62
64
|
0,
|
|
63
65
|
0,
|
|
@@ -76,7 +78,7 @@ var f = class {
|
|
|
76
78
|
return new Promise((n, r) => {
|
|
77
79
|
let i;
|
|
78
80
|
try {
|
|
79
|
-
i =
|
|
81
|
+
i = f(e);
|
|
80
82
|
} catch (e) {
|
|
81
83
|
r(e);
|
|
82
84
|
return;
|
|
@@ -95,8 +97,8 @@ var f = class {
|
|
|
95
97
|
this.queue = [];
|
|
96
98
|
let t = [], n = 0, r = 0, i = [];
|
|
97
99
|
for (let a of e) {
|
|
98
|
-
let e = a.rows *
|
|
99
|
-
t.length && (t.length ===
|
|
100
|
+
let e = a.rows * 3 + a.rows * 3 % 2;
|
|
101
|
+
t.length && (t.length === u || n + a.segments.length > d || r + e > 8192) && (i.push(t), t = [], n = 0, r = 0), t.push(a), n += a.segments.length, r += e;
|
|
100
102
|
}
|
|
101
103
|
t.length && i.push(t);
|
|
102
104
|
for (let e of i) this.draw(e);
|
|
@@ -104,7 +106,7 @@ var f = class {
|
|
|
104
106
|
slot(e) {
|
|
105
107
|
let t = this.slots.find((e) => !e.busy);
|
|
106
108
|
return t ? (t.busy = !0, (t.target.size[0] !== e[0] || t.target.size[1] !== e[1]) && t.target.resize(e), t) : (t = {
|
|
107
|
-
target:
|
|
109
|
+
target: l(this.gpu, {
|
|
108
110
|
size: e,
|
|
109
111
|
label: "liquid-glass/maps"
|
|
110
112
|
}),
|
|
@@ -114,11 +116,11 @@ var f = class {
|
|
|
114
116
|
async draw(e) {
|
|
115
117
|
try {
|
|
116
118
|
await this.ready;
|
|
117
|
-
let t = Math.max(...e.map((e) => e.columns)), n = [], r = 0,
|
|
119
|
+
let t = Math.max(...e.map((e) => e.columns)), n = [], r = 0, a = [], o = e.map((e) => {
|
|
118
120
|
n.push(r);
|
|
119
|
-
let t =
|
|
120
|
-
|
|
121
|
-
let
|
|
121
|
+
let t = a.length;
|
|
122
|
+
a.push(...e.segments);
|
|
123
|
+
let o = {
|
|
122
124
|
size: [e.geometry.width, e.geometry.height],
|
|
123
125
|
row: r,
|
|
124
126
|
rows: e.rows,
|
|
@@ -128,21 +130,22 @@ var f = class {
|
|
|
128
130
|
symmetric: +!e.geometry.outline,
|
|
129
131
|
start: t,
|
|
130
132
|
count: e.segments.length,
|
|
131
|
-
|
|
133
|
+
rim: e.geometry.material === void 0 || e.geometry.material === "regular" ? 0 : e.geometry.material === "lens" ? 2 : 1,
|
|
134
|
+
height: i(e.geometry.material ?? "regular", Math.min(e.geometry.width, e.geometry.height)).height
|
|
132
135
|
};
|
|
133
|
-
return r += e.rows *
|
|
134
|
-
}),
|
|
135
|
-
for (;
|
|
136
|
-
...
|
|
137
|
-
row:
|
|
136
|
+
return r += e.rows * 3 + e.rows * 3 % 2, o;
|
|
137
|
+
}), c = r;
|
|
138
|
+
for (; o.length < u;) o.push({
|
|
139
|
+
...o[0],
|
|
140
|
+
row: c + 2
|
|
138
141
|
});
|
|
139
|
-
for (;
|
|
142
|
+
for (; a.length < d;) a.push([
|
|
140
143
|
0,
|
|
141
144
|
0,
|
|
142
145
|
0,
|
|
143
146
|
0
|
|
144
147
|
]);
|
|
145
|
-
let
|
|
148
|
+
let l = this.slot([t, c]);
|
|
146
149
|
try {
|
|
147
150
|
this.shader.set({
|
|
148
151
|
batch: {
|
|
@@ -152,11 +155,11 @@ var f = class {
|
|
|
152
155
|
0,
|
|
153
156
|
0
|
|
154
157
|
],
|
|
155
|
-
shapes:
|
|
158
|
+
shapes: o
|
|
156
159
|
},
|
|
157
|
-
outline: { segments:
|
|
158
|
-
}),
|
|
159
|
-
target:
|
|
160
|
+
outline: { segments: a }
|
|
161
|
+
}), s(this.gpu, (e) => e.pass({
|
|
162
|
+
target: l.target,
|
|
160
163
|
clear: [
|
|
161
164
|
0,
|
|
162
165
|
0,
|
|
@@ -164,25 +167,25 @@ var f = class {
|
|
|
164
167
|
0
|
|
165
168
|
]
|
|
166
169
|
}, this.shader));
|
|
167
|
-
let r = await
|
|
170
|
+
let r = await l.target.color.read({
|
|
168
171
|
mipLevel: 0,
|
|
169
172
|
region: "all"
|
|
170
|
-
}),
|
|
171
|
-
e.forEach((e,
|
|
172
|
-
let
|
|
173
|
-
for (let
|
|
174
|
-
let
|
|
175
|
-
|
|
173
|
+
}), i = performance.now();
|
|
174
|
+
e.forEach((e, a) => {
|
|
175
|
+
let o = e.rows * 3, s = new Uint8Array(e.columns * o * 4);
|
|
176
|
+
for (let i = 0; i < o; i++) {
|
|
177
|
+
let o = (n[a] + i) * t * 4;
|
|
178
|
+
s.set(r.subarray(o, o + e.columns * 4), i * e.columns * 4);
|
|
176
179
|
}
|
|
177
180
|
e.resolve({
|
|
178
181
|
width: e.columns,
|
|
179
182
|
height: e.rows,
|
|
180
|
-
pixels:
|
|
181
|
-
duration:
|
|
183
|
+
pixels: s,
|
|
184
|
+
duration: i - e.started
|
|
182
185
|
});
|
|
183
186
|
});
|
|
184
187
|
} finally {
|
|
185
|
-
|
|
188
|
+
l.busy = !1;
|
|
186
189
|
}
|
|
187
190
|
} catch (t) {
|
|
188
191
|
for (let n of e) n.reject(t instanceof Error ? t : Error(String(t)));
|
|
@@ -191,23 +194,22 @@ var f = class {
|
|
|
191
194
|
dispose() {
|
|
192
195
|
this.gpu.dispose();
|
|
193
196
|
}
|
|
194
|
-
},
|
|
195
|
-
function
|
|
196
|
-
if (
|
|
197
|
-
let e =
|
|
198
|
-
let n = new
|
|
199
|
-
return t.
|
|
200
|
-
|
|
197
|
+
}, m;
|
|
198
|
+
function h() {
|
|
199
|
+
if (m) return m;
|
|
200
|
+
let e = c().then((t) => {
|
|
201
|
+
let n = new p(t);
|
|
202
|
+
return t.lost.then(() => {
|
|
203
|
+
m === e && (m = void 0), n.dispose();
|
|
201
204
|
}), n;
|
|
202
205
|
}).catch((t) => {
|
|
203
|
-
throw
|
|
206
|
+
throw m === e && (m = void 0), t;
|
|
204
207
|
});
|
|
205
|
-
return
|
|
208
|
+
return m = e, e;
|
|
206
209
|
}
|
|
207
|
-
async function
|
|
208
|
-
let e =
|
|
209
|
-
|
|
210
|
+
async function g() {
|
|
211
|
+
let e = m;
|
|
212
|
+
m = void 0, e && (await e).dispose();
|
|
210
213
|
}
|
|
211
|
-
var
|
|
212
|
-
|
|
213
|
-
export { f as MaterialRenderer, h as disposeMaterialRenderer, m as getMaterialRenderer, n as mapPlanes, r as mapScale, g as materialShader };
|
|
214
|
+
var _ = n;
|
|
215
|
+
export { p as MaterialRenderer, g as disposeMaterialRenderer, h as getMaterialRenderer, r as mapPlanes, a as mapScale, _ as materialShader };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { GlassCorner as e,
|
|
3
|
-
import { GlassContent as
|
|
4
|
-
import { GlassSurface as
|
|
5
|
-
import { GlassButton as
|
|
6
|
-
import { GlassToolbar as
|
|
7
|
-
import { GlassTabs as
|
|
8
|
-
import { GlassMenu as
|
|
9
|
-
import { GlassProgressiveBlur as
|
|
10
|
-
import { GlassSlider as
|
|
11
|
-
|
|
2
|
+
import { GlassCorner as e, GlassRow as t, GlassShape as n, GlassShapeContainer as r } from "./react/shape.js";
|
|
3
|
+
import { GlassContent as i, GlassForeground as a, GlassScene as o, useGlassForeground as s, useGlassMotion as c } from "./react/scene.js";
|
|
4
|
+
import { GlassPopupSurface as l, GlassSurface as u } from "./react/surface.js";
|
|
5
|
+
import { GlassButton as d } from "./react/button.js";
|
|
6
|
+
import { GlassToolbar as f, GlassToolbarButton as p, GlassToolbarGroup as m, GlassToolbarLink as h, GlassToolbarSpacer as g } from "./react/toolbar.js";
|
|
7
|
+
import { GlassTabs as _, GlassTabsContent as v, GlassTabsIndicator as y, GlassTabsList as b, GlassTabsRoot as x, GlassTabsTrigger as S } from "./react/tabs.js";
|
|
8
|
+
import { GlassMenu as C, GlassMenuCheckboxItem as w, GlassMenuContent as T, GlassMenuGroup as E, GlassMenuGroupLabel as D, GlassMenuItem as O, GlassMenuRadioGroup as k, GlassMenuRadioItem as A, GlassMenuSeparator as j, GlassMenuSubmenu as M, GlassMenuSubmenuContent as N, GlassMenuSubmenuTrigger as P, GlassMenuTrigger as F } from "./react/menu.js";
|
|
9
|
+
import { GlassProgressiveBlur as I, GlassScrollEdges as L } from "./react/progressive.js";
|
|
10
|
+
import { GlassSlider as R } from "./react/slider.js";
|
|
11
|
+
import { GlassSwitch as z } from "./react/switch.js";
|
|
12
|
+
import { GlassColorPicker as B } from "./react/color-picker.js";
|
|
13
|
+
export { d as GlassButton, B as GlassColorPicker, i as GlassContent, e as GlassCorner, a as GlassForeground, C as GlassMenu, w as GlassMenuCheckboxItem, T as GlassMenuContent, E as GlassMenuGroup, D as GlassMenuGroupLabel, O as GlassMenuItem, k as GlassMenuRadioGroup, A as GlassMenuRadioItem, j as GlassMenuSeparator, M as GlassMenuSubmenu, N as GlassMenuSubmenuContent, P as GlassMenuSubmenuTrigger, F as GlassMenuTrigger, l as GlassPopupSurface, I as GlassProgressiveBlur, t as GlassRow, o as GlassScene, L as GlassScrollEdges, n as GlassShape, r as GlassShapeContainer, R as GlassSlider, u as GlassSurface, z as GlassSwitch, _ as GlassTabs, v as GlassTabsContent, y as GlassTabsIndicator, b as GlassTabsList, x as GlassTabsRoot, S as GlassTabsTrigger, f as GlassToolbar, p as GlassToolbarButton, m as GlassToolbarGroup, h as GlassToolbarLink, g as GlassToolbarSpacer, s as useGlassForeground, c as useGlassMotion };
|
package/dist/react/button.js
CHANGED
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
import { GlassSurface as e } from "./surface.js";
|
|
3
3
|
import { jsx as t } from "react/jsx-runtime";
|
|
4
4
|
import { Button as n } from "@base-ui/react/button";
|
|
5
|
-
|
|
6
|
-
function r({ material: r, appearance: i, radius: a = "capsule", refraction: o, tint: s,
|
|
5
|
+
// src/react/button.tsx
|
|
6
|
+
function r({ material: r, appearance: i, radius: a = "capsule", refraction: o, tint: s, specular: c, frost: l, interactive: u = !0, motion: d, size: f = "default", className: p = "", style: m, children: h, ...g }) {
|
|
7
7
|
return /* @__PURE__ */ t(e, {
|
|
8
8
|
material: r,
|
|
9
9
|
appearance: i,
|
|
10
|
-
radius:
|
|
10
|
+
radius: f.startsWith("icon") ? "circle" : a,
|
|
11
11
|
refraction: o,
|
|
12
12
|
tint: s,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
specular: c,
|
|
14
|
+
frost: l,
|
|
15
|
+
interactive: u,
|
|
16
|
+
motion: d,
|
|
17
|
+
className: `lg-button ${p}`,
|
|
18
|
+
style: m,
|
|
19
|
+
"data-size": f,
|
|
20
|
+
render: /* @__PURE__ */ t(n, { ...g }),
|
|
21
|
+
children: h
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
|
-
//#endregion
|
|
23
24
|
export { r as GlassButton };
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { GlassContent as e, GlassScene as t } from "./scene.js";
|
|
3
|
+
import { GlassSurface as n } from "./surface.js";
|
|
4
|
+
import { useEffect as r, useRef as i, useState as a } from "react";
|
|
5
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
6
|
+
// src/react/color-picker.tsx
|
|
7
|
+
var c = (e) => e * e * (3 - 2 * e), l = (e) => .5 - Math.sin(Math.asin(1 - 2 * e) / 3);
|
|
8
|
+
function u(e, t, n) {
|
|
9
|
+
let r = (r) => {
|
|
10
|
+
let i = (r + e / 60) % 6;
|
|
11
|
+
return n - n * t * c(Math.max(0, Math.min(i, 4 - i, 1)));
|
|
12
|
+
};
|
|
13
|
+
return [
|
|
14
|
+
r(5),
|
|
15
|
+
r(3),
|
|
16
|
+
r(1)
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
var d = /^#?([\da-f]{6})$/i;
|
|
20
|
+
function f(e) {
|
|
21
|
+
let t = d.exec(e);
|
|
22
|
+
if (!t) return;
|
|
23
|
+
let n = parseInt(t[1], 16), r = (n >> 16 & 255) / 255, i = (n >> 8 & 255) / 255, a = (n & 255) / 255, o = Math.max(r, i, a), s = o - Math.min(r, i, a), c = 0;
|
|
24
|
+
s && (c = o === r ? ((i - a) / s + 6) % 6 : o === i ? (a - r) / s + 2 : (r - i) / s + 4);
|
|
25
|
+
let u = Math.floor(c);
|
|
26
|
+
return {
|
|
27
|
+
h: (u + l(c - u)) * 60,
|
|
28
|
+
s: o ? s / o : 0,
|
|
29
|
+
v: o
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function p({ h: e, s: t, v: n }) {
|
|
33
|
+
return `#${u(e, t, n).map((e) => Math.round(e * 255).toString(16).padStart(2, "0")).join("")}`;
|
|
34
|
+
}
|
|
35
|
+
var m = (e) => (e % 360 + 360) % 360, h = (e) => Math.max(0, Math.min(1, e)), g = /* @__PURE__ */ new Map();
|
|
36
|
+
function _(e, t) {
|
|
37
|
+
let n = Math.round(e * t), r = String(n), i = g.get(r);
|
|
38
|
+
return i || (i = new Promise((e, t) => {
|
|
39
|
+
let r = document.createElement("canvas");
|
|
40
|
+
r.width = r.height = n;
|
|
41
|
+
let i = r.getContext("2d");
|
|
42
|
+
if (!i) return t(/* @__PURE__ */ Error("Canvas 2D is unavailable."));
|
|
43
|
+
let a = i.createImageData(n, n), o = n / 2, s = 1, c = () => (s = s * 16807 % 2147483647, s / 2147483647 - .5);
|
|
44
|
+
for (let e = 0; e < n; e++) for (let t = 0; t < n; t++) {
|
|
45
|
+
let r = t + .5 - o, i = e + .5 - o, s = Math.hypot(r, i), l = h(o - s + .5);
|
|
46
|
+
if (!l) continue;
|
|
47
|
+
let [d, f, p] = u(m(Math.atan2(i, r) * 180 / Math.PI), Math.min(1, s / o), 1), g = (e * n + t) * 4;
|
|
48
|
+
a.data[g] = d * 255 + c(), a.data[g + 1] = f * 255 + c(), a.data[g + 2] = p * 255 + c(), a.data[g + 3] = l * 255;
|
|
49
|
+
}
|
|
50
|
+
i.putImageData(a, 0, 0), r.toBlob((n) => n ? e(URL.createObjectURL(n)) : t(/* @__PURE__ */ Error("Wheel encoding failed.")));
|
|
51
|
+
}), i.catch(() => g.delete(r)), g.set(r, i), i);
|
|
52
|
+
}
|
|
53
|
+
function v({ value: c, defaultValue: l = "#007aff", onValueChange: u, onValueCommitted: g, size: v = 240, name: y, disabled: b = !1, appearance: x, refraction: S = 16, specular: C = !0, motion: w, "aria-label": T = "Color", className: E = "", style: D }) {
|
|
54
|
+
if (c !== void 0 && !d.test(c)) throw RangeError("GlassColorPicker value must be a six-digit hex color.");
|
|
55
|
+
if (!(v > 0) || !Number.isFinite(v)) throw RangeError("GlassColorPicker size must be positive and finite.");
|
|
56
|
+
let [O, k] = a(() => f(c ?? l) ?? {
|
|
57
|
+
h: 211,
|
|
58
|
+
s: 1,
|
|
59
|
+
v: 1
|
|
60
|
+
}), A = p(O), [j, M] = a(c);
|
|
61
|
+
if (c !== j && (M(c), c !== void 0 && `#${d.exec(c)[1].toLowerCase()}` !== A)) {
|
|
62
|
+
let e = f(c);
|
|
63
|
+
k({
|
|
64
|
+
h: e.s && e.v ? e.h : O.h,
|
|
65
|
+
s: e.v ? e.s : O.s,
|
|
66
|
+
v: e.v
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
let [N, P] = a(!1), [F, I] = a(), L = i(null), R = i(O);
|
|
70
|
+
R.current = O, r(() => {
|
|
71
|
+
let e = !0;
|
|
72
|
+
return _(v, Math.min(2, Math.max(1, window.devicePixelRatio || 1))).then((t) => e && I(t), () => void 0), () => {
|
|
73
|
+
e = !1;
|
|
74
|
+
};
|
|
75
|
+
}, [v]);
|
|
76
|
+
let z = (e) => {
|
|
77
|
+
let t = p(R.current);
|
|
78
|
+
R.current = e, k(e);
|
|
79
|
+
let n = p(e);
|
|
80
|
+
n !== t && u?.(n);
|
|
81
|
+
}, B = () => g?.(p(R.current)), V = (e) => {
|
|
82
|
+
let t = L.current.getBoundingClientRect(), n = e.clientX - (t.left + t.width / 2), r = e.clientY - (t.top + t.height / 2);
|
|
83
|
+
z({
|
|
84
|
+
h: m(Math.atan2(r, n) * 180 / Math.PI),
|
|
85
|
+
s: h(Math.hypot(n, r) / (t.width / 2)),
|
|
86
|
+
v: 1
|
|
87
|
+
});
|
|
88
|
+
}, H = (e) => {
|
|
89
|
+
N && N !== "key" && (e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), P(!1), B());
|
|
90
|
+
}, U = (e) => {
|
|
91
|
+
let t = e.shiftKey ? 10 : 1, { h: n, s: r } = R.current, i = e.key === "ArrowRight" ? {
|
|
92
|
+
h: m(n + t),
|
|
93
|
+
s: r,
|
|
94
|
+
v: 1
|
|
95
|
+
} : e.key === "ArrowLeft" ? {
|
|
96
|
+
h: m(n - t),
|
|
97
|
+
s: r,
|
|
98
|
+
v: 1
|
|
99
|
+
} : e.key === "ArrowUp" ? {
|
|
100
|
+
h: n,
|
|
101
|
+
s: h(r + t / 100),
|
|
102
|
+
v: 1
|
|
103
|
+
} : e.key === "ArrowDown" ? {
|
|
104
|
+
h: n,
|
|
105
|
+
s: h(r - t / 100),
|
|
106
|
+
v: 1
|
|
107
|
+
} : void 0;
|
|
108
|
+
i && (e.preventDefault(), N || P("key"), z(i));
|
|
109
|
+
}, W = O.h * Math.PI / 180, G = {
|
|
110
|
+
left: `${50 + Math.cos(W) * O.s * 50}%`,
|
|
111
|
+
top: `${50 + Math.sin(W) * O.s * 50}%`
|
|
112
|
+
}, K = {
|
|
113
|
+
"data-open": N ? "" : void 0,
|
|
114
|
+
"data-touch": N === "touch" ? "" : void 0
|
|
115
|
+
};
|
|
116
|
+
return /* @__PURE__ */ s(t, {
|
|
117
|
+
material: "lens",
|
|
118
|
+
appearance: x,
|
|
119
|
+
motion: w,
|
|
120
|
+
maxSurfaces: 2,
|
|
121
|
+
className: `lg-color-picker ${E}`,
|
|
122
|
+
"data-disabled": b ? "" : void 0,
|
|
123
|
+
style: {
|
|
124
|
+
"--lg-color-wheel-size": `${v}px`,
|
|
125
|
+
"--lg-color": A,
|
|
126
|
+
...D
|
|
127
|
+
},
|
|
128
|
+
children: [
|
|
129
|
+
/* @__PURE__ */ o(e, {
|
|
130
|
+
className: "lg-color-picker-canvas",
|
|
131
|
+
"aria-hidden": "true",
|
|
132
|
+
children: /* @__PURE__ */ o("div", {
|
|
133
|
+
className: "lg-color-wheel-colors",
|
|
134
|
+
style: F ? { backgroundImage: `url("${F}")` } : void 0
|
|
135
|
+
})
|
|
136
|
+
}),
|
|
137
|
+
/* @__PURE__ */ s("div", {
|
|
138
|
+
ref: L,
|
|
139
|
+
className: "lg-color-wheel",
|
|
140
|
+
role: "slider",
|
|
141
|
+
tabIndex: b ? -1 : 0,
|
|
142
|
+
"aria-label": T,
|
|
143
|
+
"aria-roledescription": "color wheel",
|
|
144
|
+
"aria-valuemin": 0,
|
|
145
|
+
"aria-valuemax": 360,
|
|
146
|
+
"aria-valuenow": Math.round(O.h),
|
|
147
|
+
"aria-valuetext": `${A}, hue ${Math.round(O.h)} degrees, saturation ${Math.round(O.s * 100)} percent`,
|
|
148
|
+
"aria-disabled": b || void 0,
|
|
149
|
+
onPointerDown: (e) => {
|
|
150
|
+
b || e.button !== 0 || (e.preventDefault(), e.currentTarget.focus({ preventScroll: !0 }), e.currentTarget.setPointerCapture(e.pointerId), P(e.pointerType === "touch" ? "touch" : "pointer"), V(e));
|
|
151
|
+
},
|
|
152
|
+
onPointerMove: (e) => {
|
|
153
|
+
N && N !== "key" && V(e);
|
|
154
|
+
},
|
|
155
|
+
onPointerUp: H,
|
|
156
|
+
onPointerCancel: H,
|
|
157
|
+
onLostPointerCapture: H,
|
|
158
|
+
onKeyDown: b ? void 0 : U,
|
|
159
|
+
onKeyUp: () => {
|
|
160
|
+
N === "key" && (P(!1), B());
|
|
161
|
+
},
|
|
162
|
+
onBlur: () => {
|
|
163
|
+
N === "key" && P(!1);
|
|
164
|
+
},
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ o("span", {
|
|
167
|
+
className: "lg-color-lens-shadow",
|
|
168
|
+
style: G,
|
|
169
|
+
...K,
|
|
170
|
+
"aria-hidden": "true"
|
|
171
|
+
}),
|
|
172
|
+
/* @__PURE__ */ o(n, {
|
|
173
|
+
radius: "circle",
|
|
174
|
+
refraction: S,
|
|
175
|
+
specular: C,
|
|
176
|
+
className: "lg-color-lens",
|
|
177
|
+
style: G,
|
|
178
|
+
...K,
|
|
179
|
+
"aria-hidden": "true",
|
|
180
|
+
children: /* @__PURE__ */ o("span", { className: "lg-color-lens-point" })
|
|
181
|
+
}),
|
|
182
|
+
/* @__PURE__ */ o("span", {
|
|
183
|
+
className: "lg-color-knob",
|
|
184
|
+
style: G,
|
|
185
|
+
...K,
|
|
186
|
+
"aria-hidden": "true"
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
}),
|
|
190
|
+
y && /* @__PURE__ */ o("input", {
|
|
191
|
+
type: "hidden",
|
|
192
|
+
name: y,
|
|
193
|
+
value: A,
|
|
194
|
+
disabled: b
|
|
195
|
+
})
|
|
196
|
+
]
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
export { v as GlassColorPicker };
|
|
@@ -6,11 +6,11 @@ import { GlassSurface as r } from "./surface.js";
|
|
|
6
6
|
import { useCallback as i, useEffect as a, useState as o } from "react";
|
|
7
7
|
import { useRender as s } from "@base-ui/react/use-render";
|
|
8
8
|
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
9
|
-
|
|
9
|
+
// src/react/control-thumb.tsx
|
|
10
10
|
function d(e) {
|
|
11
11
|
let [t, n] = o(e);
|
|
12
12
|
return a(() => {
|
|
13
|
-
let t = setTimeout(() => n(e), e ? 0 :
|
|
13
|
+
let t = setTimeout(() => n(e), e ? 0 : 240);
|
|
14
14
|
return () => clearTimeout(t);
|
|
15
15
|
}, [e]), e ? "pressed" : t ? "settling" : "idle";
|
|
16
16
|
}
|
|
@@ -29,8 +29,8 @@ function f({ pressed: a, options: o, tag: f = "div", ref: p, children: m, motion
|
|
|
29
29
|
m,
|
|
30
30
|
y !== "idle" && /* @__PURE__ */ l(r, {
|
|
31
31
|
...o,
|
|
32
|
-
material: o.material ?? "
|
|
33
|
-
|
|
32
|
+
material: o.material ?? "lens",
|
|
33
|
+
aberration: !0,
|
|
34
34
|
radius: o.radius ?? "capsule",
|
|
35
35
|
render: /* @__PURE__ */ l("span", {}),
|
|
36
36
|
className: "lg-control-lens",
|
|
@@ -46,5 +46,4 @@ function f({ pressed: a, options: o, tag: f = "div", ref: p, children: m, motion
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
//#endregion
|
|
50
49
|
export { f as ControlThumb };
|