@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.
- package/README.md +133 -494
- package/dist/core/concentric.js +86 -0
- package/dist/core/materials.js +41 -0
- package/dist/core/morph-path.js +206 -0
- package/dist/core/optics.js +7 -0
- package/dist/core/progressive.js +35 -0
- package/dist/{concentric-COCiG9DQ.js → core/shape.js} +1 -85
- package/dist/core/spring.js +78 -0
- package/dist/core/union.js +117 -0
- package/dist/core.js +6 -9
- package/dist/dom/compose-layers.js +54 -0
- package/dist/dom/compound-field.js +23 -0
- package/dist/dom/control-motion.js +101 -0
- package/dist/dom/engine.js +7 -0
- package/dist/dom/exit-handoff.js +14 -0
- package/dist/dom/filter-bounds.js +87 -0
- package/dist/dom/filter-budget.js +45 -0
- package/dist/dom/filter-groups.js +38 -0
- package/dist/dom/filter-paint-root.js +41 -0
- package/dist/dom/filter-patch.js +129 -0
- package/dist/dom/filter-reach.js +36 -0
- package/dist/dom/filter-stages.js +7 -0
- package/dist/dom/fixed-shape.js +20 -0
- package/dist/dom/foreground.js +36 -0
- package/dist/dom/interaction.js +129 -0
- package/dist/dom/lens-layers.js +163 -0
- package/dist/dom/map-blend.js +8 -0
- package/dist/dom/map-encoder.js +47 -0
- package/dist/dom/map-encoder.worker.js +16 -0
- package/dist/dom/map-encoding.js +17 -0
- package/dist/dom/map-image.js +34 -0
- package/dist/dom/map-store.js +189 -0
- package/dist/dom/maps.js +131 -0
- package/dist/dom/material-graph.js +52 -0
- package/dist/dom/morph.js +296 -0
- package/dist/dom/page-zoom.js +46 -0
- package/dist/dom/png.js +105 -0
- package/dist/dom/progressive.js +299 -0
- package/dist/dom/renderer.js +6 -0
- package/dist/dom/sampling-bounds.js +22 -0
- package/dist/dom/selection.js +106 -0
- package/dist/dom/shape-layout.js +199 -0
- package/dist/dom/shared-backdrop.js +41 -0
- package/dist/dom/ticker.js +103 -0
- package/dist/dom/warm.js +108 -0
- package/dist/dom.js +694 -2
- package/dist/gpu/geometry.js +9 -0
- package/dist/gpu/maps.js +8 -0
- package/dist/gpu/planes.js +4 -0
- package/dist/gpu.js +213 -2
- package/dist/index.js +10 -932
- package/dist/react/button.js +23 -0
- package/dist/react/control-thumb.js +50 -0
- package/dist/react/menu.js +159 -0
- package/dist/react/merged-ref.js +18 -0
- package/dist/react/progressive.js +73 -0
- package/dist/react/scene.js +122 -0
- package/dist/react/shape.js +93 -0
- package/dist/react/surface.js +69 -0
- package/dist/react/tabs.js +94 -0
- package/dist/react/toolbar.js +145 -0
- package/dist/react/value-control-motion.js +9 -0
- package/dist/react/value-controls.js +176 -0
- package/dist/styles.css +19 -0
- package/dist/types/core/optics.d.ts +0 -1
- package/dist/types/core/spring.d.ts +1 -1
- package/dist/types/dom/compose-layers.d.ts +15 -0
- package/dist/types/dom/compound-field.d.ts +35 -0
- package/dist/types/dom/engine.d.ts +9 -0
- package/dist/types/dom/exit-handoff.d.ts +7 -0
- package/dist/types/dom/filter-bounds.d.ts +1 -1
- package/dist/types/dom/filter-budget.d.ts +20 -0
- package/dist/types/dom/filter-groups.d.ts +25 -0
- package/dist/types/dom/filter-paint-root.d.ts +9 -0
- package/dist/types/dom/filter-patch.d.ts +3 -8
- package/dist/types/dom/filter-reach.d.ts +23 -0
- package/dist/types/dom/filter-stages.d.ts +5 -0
- package/dist/types/dom/index.d.ts +3 -0
- package/dist/types/dom/lens-layers.d.ts +68 -0
- package/dist/types/dom/map-blend.d.ts +22 -0
- package/dist/types/dom/map-encoding.d.ts +1 -1
- package/dist/types/dom/map-image.d.ts +5 -2
- package/dist/types/dom/maps.d.ts +5 -5
- package/dist/types/dom/material-graph.d.ts +22 -0
- package/dist/types/dom/morph.d.ts +8 -0
- package/dist/types/dom/page-zoom.d.ts +18 -0
- package/dist/types/dom/png.d.ts +2 -0
- package/dist/types/dom/progressive.d.ts +29 -1
- package/dist/types/dom/renderer.d.ts +4 -0
- package/dist/types/dom/sampling-bounds.d.ts +10 -0
- package/dist/types/dom/shared-backdrop.d.ts +19 -0
- package/dist/types/dom/warm.d.ts +4 -1
- package/dist/types/gpu/geometry.d.ts +17 -0
- package/dist/types/gpu/index.d.ts +4 -16
- package/dist/types/gpu/planes.d.ts +2 -0
- package/dist/types/react/button.d.ts +11 -0
- package/dist/types/react/index.d.ts +14 -149
- package/dist/types/react/menu.d.ts +29 -0
- package/dist/types/react/progressive.d.ts +15 -0
- package/dist/types/react/scene.d.ts +35 -0
- package/dist/types/react/surface.d.ts +35 -0
- package/dist/types/react/tabs.d.ts +29 -0
- package/dist/types/react/toolbar.d.ts +21 -0
- package/package.json +1 -1
- package/dist/dom-CKc8vDTR.js +0 -2532
- package/dist/gpu-Co5Y89mh.js +0 -244
- package/dist/map-encoder.worker-DO1drw0Y.js +0 -16
- package/dist/materials-DVPgteZ9.js +0 -234
- package/dist/types/dom/progressive-maps.d.ts +0 -6
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { gecko as e, webkit as t } from "./engine.js";
|
|
2
|
+
import { filterBudgetFactor as n, filterGraphOutsets as r, outsetBudget as i } from "./filter-budget.js";
|
|
3
|
+
import { pngDataUrlSync as a } from "./png.js";
|
|
4
|
+
import { filterPixelRatio as o, pageZoom as s, untiledOutsets as c } from "./page-zoom.js";
|
|
5
|
+
import { patchFilters as l } from "./filter-patch.js";
|
|
6
|
+
import { physicalEdge as u, scrollEdgeStrength as d, validateProgressive as f } from "../core/progressive.js";
|
|
7
|
+
import { padRepaintReach as p, repaintReach as m } from "./filter-reach.js";
|
|
8
|
+
import { filterPrimitiveCount as h } from "./filter-stages.js";
|
|
9
|
+
import { acquireFilterPaintRoot as g } from "./filter-paint-root.js";
|
|
10
|
+
//#region src/dom/progressive.ts
|
|
11
|
+
var _ = t ? "webkit" : e ? "gecko" : "chromium", v = 0, y = "http://www.w3.org/2000/svg", b = 6, x = (e) => e * e * (3 - 2 * e), S = (e) => .5 - Math.sin(Math.asin(1 - 2 * Math.max(0, Math.min(1, e))) / 3), C = (e, t) => Math.max(0, 1 - Math.abs(b * x(Math.max(0, Math.min(1, t))) - e)), w = Array.from({ length: 7 }, (e, t) => [S((t - 1) / b), S((t + 1) / b)]), T = (e) => {
|
|
12
|
+
let t = e / b;
|
|
13
|
+
return 3.92 * t * (1 - t);
|
|
14
|
+
};
|
|
15
|
+
function E(e) {
|
|
16
|
+
let t = 1 / (1 + .3275911 * Math.abs(e) / Math.SQRT2), n = 1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - .284496736) * t + .254829592) * t * Math.exp(-e * e / 2);
|
|
17
|
+
return e < 0 ? (1 - n) / 2 : (1 + n) / 2;
|
|
18
|
+
}
|
|
19
|
+
function D(e) {
|
|
20
|
+
let t = -8, n = 8;
|
|
21
|
+
for (let r = 0; r < 48; r++) {
|
|
22
|
+
let r = (t + n) / 2;
|
|
23
|
+
E(r) < e ? t = r : n = r;
|
|
24
|
+
}
|
|
25
|
+
return (t + n) / 2;
|
|
26
|
+
}
|
|
27
|
+
var O = Array.from({ length: 7 }, (e, t) => Array.from({ length: 65 }, (e, n) => {
|
|
28
|
+
let r = n / 64, i = r <= 0 ? 0 : r >= 1 ? 1 : .5 + D(r) / 6;
|
|
29
|
+
return Number(C(t, i).toFixed(4));
|
|
30
|
+
}).join(" ")), k = 64, A = /* @__PURE__ */ new Map();
|
|
31
|
+
function j(e) {
|
|
32
|
+
let t = A.get(e);
|
|
33
|
+
if (t) return t;
|
|
34
|
+
let [, n, r] = e.split(":"), i = Number(r), [o, s] = w[i], c = n === "top" || n === "bottom", l = n === "top" || n === "left", u = /* @__PURE__ */ new Uint8Array(256);
|
|
35
|
+
for (let e = 0; e < k; e++) {
|
|
36
|
+
let t = (e + .5) / k, n = l ? s - t * (s - o) : o + t * (s - o);
|
|
37
|
+
u.set([
|
|
38
|
+
255,
|
|
39
|
+
255,
|
|
40
|
+
255,
|
|
41
|
+
Math.round(255 * C(i, n))
|
|
42
|
+
], e * 4);
|
|
43
|
+
}
|
|
44
|
+
let d = a(c ? 1 : k, c ? k : 1, u);
|
|
45
|
+
return A.set(e, d), d;
|
|
46
|
+
}
|
|
47
|
+
var M = (e) => {
|
|
48
|
+
let t = Math.floor(e.x), n = Math.floor(e.y);
|
|
49
|
+
return {
|
|
50
|
+
x: t,
|
|
51
|
+
y: n,
|
|
52
|
+
width: Math.ceil(e.x + e.width) - t,
|
|
53
|
+
height: Math.ceil(e.y + e.height) - n
|
|
54
|
+
};
|
|
55
|
+
}, N = (e) => `x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}"`, P = (e, t) => ({
|
|
56
|
+
x: e.x - t,
|
|
57
|
+
y: e.y - t,
|
|
58
|
+
width: e.width + 2 * t,
|
|
59
|
+
height: e.height + 2 * t
|
|
60
|
+
});
|
|
61
|
+
function F(e, t, n) {
|
|
62
|
+
switch (e.edge) {
|
|
63
|
+
case "bottom": return M({
|
|
64
|
+
x: e.x,
|
|
65
|
+
y: e.y + t * e.height,
|
|
66
|
+
width: e.width,
|
|
67
|
+
height: (n - t) * e.height
|
|
68
|
+
});
|
|
69
|
+
case "top": return M({
|
|
70
|
+
x: e.x,
|
|
71
|
+
y: e.y + (1 - n) * e.height,
|
|
72
|
+
width: e.width,
|
|
73
|
+
height: (n - t) * e.height
|
|
74
|
+
});
|
|
75
|
+
case "right": return M({
|
|
76
|
+
x: e.x + t * e.width,
|
|
77
|
+
y: e.y,
|
|
78
|
+
width: (n - t) * e.width,
|
|
79
|
+
height: e.height
|
|
80
|
+
});
|
|
81
|
+
case "left": return M({
|
|
82
|
+
x: e.x + (1 - n) * e.width,
|
|
83
|
+
y: e.y,
|
|
84
|
+
width: (n - t) * e.width,
|
|
85
|
+
height: e.height
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
var I = (e, t) => e.x < t.x + t.width && t.x < e.x + e.width && e.y < t.y + t.height && t.y < e.y + e.height;
|
|
90
|
+
function L(e, t, n, r, i) {
|
|
91
|
+
let a = [], o = e.edge === "top" || e.edge === "bottom", s = e.edge === "bottom" || e.edge === "right" ? -1 : 1, c = o ? e.height : e.width;
|
|
92
|
+
if (!r) {
|
|
93
|
+
let n = c / 6;
|
|
94
|
+
a.push(`<feFlood flood-color="#fff" ${N(F(e, .5, 1.5))} result="${t}step"/>`, `<feGaussianBlur in="${t}step" stdDeviation="${o ? `0 ${n}` : `${n} 0`}" ${N(M(e))} result="${t}ramp"/>`);
|
|
95
|
+
}
|
|
96
|
+
let l = [], u = [];
|
|
97
|
+
for (let c = 0; c <= b; c++) {
|
|
98
|
+
let d = F(e, w[c][0], w[c][1]), f = ` ${N(c === 0 && i ? i : d)}`, p = e.blur * (c / b) ** 2, m = n, h = e.refraction * T(c);
|
|
99
|
+
if (h > .01) {
|
|
100
|
+
let e = (h * s).toFixed(3);
|
|
101
|
+
a.push(`<feOffset in="${n}" dx="${o ? 0 : e}" dy="${o ? e : 0}" ${N(P(d, Math.ceil(3 * p) + 1))} result="${t}shift${c}"/>`), m = `${t}shift${c}`;
|
|
102
|
+
}
|
|
103
|
+
c && (a.push(`<feGaussianBlur in="${m}" stdDeviation="${p}" ${N(d)} result="${t}blur${c}"/>`), m = `${t}blur${c}`), a.push(r ? `<feImage data-map="pg:${e.edge}:${c}" preserveAspectRatio="none" ${N(d)} result="${t}weight${c}"/>` : `<feComponentTransfer in="${t}ramp"${f} result="${t}weight${c}"><feFuncA type="table" tableValues="${O[c]}"/></feComponentTransfer>`), a.push(`<feComposite in="${m}" in2="${t}weight${c}" operator="in"${f} result="${t}part${c}"/>`), (c % 2 ? u : l).push(`${t}part${c}`);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
markup: a,
|
|
107
|
+
even: l,
|
|
108
|
+
odd: u
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function R(e, t, n, r, i = _) {
|
|
112
|
+
let a = Math.max(256, ...t.map((e) => Math.ceil((e.edge === "top" || e.edge === "bottom" ? e.height : e.width) / 2 + 3 * e.blur + e.refraction + 8))), o = {
|
|
113
|
+
x: -a,
|
|
114
|
+
y: -a,
|
|
115
|
+
width: n + 2 * a,
|
|
116
|
+
height: r + 2 * a
|
|
117
|
+
}, s = [], c = (e, t, n) => `<feMerge result="${t}"${n ? ` ${N(n)}` : ""}>${e.map((e) => `<feMergeNode in="${e}"/>`).join("")}</feMerge>`, l = (e, t, n, r) => i === "gecko" ? `<feComposite in="${e}" in2="${t}" operator="arithmetic" k2="1" k3="1"${r ? ` ${N(r)}` : ""} result="${n}"/>` : `<feComposite in="${e}" in2="${t}" operator="lighter"${r ? ` ${N(r)}` : ""} result="${n}"/>`;
|
|
118
|
+
if (i === "gecko") {
|
|
119
|
+
let e = "SourceGraphic";
|
|
120
|
+
t.forEach((t, n) => {
|
|
121
|
+
let r = `e${n}`, { markup: i, even: a, odd: u } = L(t, r, e, !1, o);
|
|
122
|
+
s.push(...i, c(a, `${r}even`, o), c(u, `${r}odd`, M(t)), l(`${r}even`, `${r}odd`, `${r}result`, o)), e = `${r}result`;
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
let e = t.every((e, n) => t.every((t, r) => n === r || !I(M(e), M(t)))) ? [t] : t.map((e) => [e]), n = "SourceGraphic";
|
|
126
|
+
e.forEach((e, r) => {
|
|
127
|
+
let a = [], o = [];
|
|
128
|
+
e.forEach((e) => {
|
|
129
|
+
let r = `e${t.indexOf(e)}`, { markup: u, even: d, odd: f } = L(e, r, n, i === "webkit");
|
|
130
|
+
s.push(...u, `<feFlood flood-color="#fff" ${N(M(e))} result="${r}area"/>`, c(d, `${r}even`, M(e)), c(f, `${r}odd`, M(e)), l(`${r}even`, `${r}odd`, `${r}result`, M(e))), a.push(`${r}result`), o.push(`${r}area`);
|
|
131
|
+
});
|
|
132
|
+
let u = `g${r}`;
|
|
133
|
+
o.length > 1 && s.push(c(o, `${u}areas`)), s.push(`<feComposite in="${n}" in2="${o.length > 1 ? `${u}areas` : o[0]}" operator="out" result="${u}outside"/>`, c([`${u}outside`, ...a], `${u}result`)), n = `${u}result`;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return `<filter id="${e}" x="${-a / n}" y="${-a / r}" width="${1 + 2 * a / n}" height="${1 + 2 * a / r}" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" color-interpolation-filters="sRGB">${s.join("")}</filter>`;
|
|
137
|
+
}
|
|
138
|
+
function z(a, _, b = !1) {
|
|
139
|
+
let x = document.createElementNS(y, "svg");
|
|
140
|
+
x.setAttribute("aria-hidden", "true"), x.setAttribute("width", "0"), x.setAttribute("height", "0"), x.style.cssText = "position:absolute;pointer-events:none;overflow:hidden";
|
|
141
|
+
let S = document.createElementNS(y, "defs");
|
|
142
|
+
x.append(S), a.ownerDocument.body.append(x);
|
|
143
|
+
let C = `lg-progressive-${++v}`, w = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Set(), E = 0, D = 1, O = !1, k = "", A = 0, M = /* @__PURE__ */ new Map();
|
|
144
|
+
function N(e, t) {
|
|
145
|
+
e.style.filter === t.applied && (e.style.filter = t.original), t.layer.dispose(), t.releasePaint?.(), M.delete(e);
|
|
146
|
+
}
|
|
147
|
+
function P(e) {
|
|
148
|
+
let n = /* @__PURE__ */ new Map();
|
|
149
|
+
for (let t of T) {
|
|
150
|
+
let r = typeof t.target == "function" ? t.target() : t.target;
|
|
151
|
+
if (r === e) continue;
|
|
152
|
+
let i = r;
|
|
153
|
+
if (!i) continue;
|
|
154
|
+
let a = n.get(i) ?? [];
|
|
155
|
+
a.push(t), n.set(i, a);
|
|
156
|
+
}
|
|
157
|
+
for (let [e, t] of M) n.has(e) || N(e, t);
|
|
158
|
+
let r = 0;
|
|
159
|
+
for (let [e, i] of n) {
|
|
160
|
+
let n = M.get(e);
|
|
161
|
+
n || (n = {
|
|
162
|
+
layer: z(a, _, !0),
|
|
163
|
+
options: [],
|
|
164
|
+
remove: [],
|
|
165
|
+
original: e.style.filter,
|
|
166
|
+
releasePaint: t ? g(e) : void 0,
|
|
167
|
+
applied: e.style.filter
|
|
168
|
+
}, M.set(e, n)), (i.length !== n.options.length || i.some((e, t) => e !== n.options[t])) && (n.remove.forEach((e) => e()), n.remove = i.map((e) => n.layer.addScroll(e)), n.options = i);
|
|
169
|
+
let o = n.layer.update(e), s = [n.original, o].filter(Boolean).join(" ");
|
|
170
|
+
e.style.filter !== s && (e.style.filter = s), n.applied = s, r += n.layer.count();
|
|
171
|
+
}
|
|
172
|
+
return r;
|
|
173
|
+
}
|
|
174
|
+
let F = matchMedia("(prefers-reduced-transparency: reduce)"), I = matchMedia("(forced-colors: active)"), L = "", B = "", V = 0, H = [], U, W = 0, G = (e) => {
|
|
175
|
+
a.dataset.glassBlurEdges !== e && (a.dataset.glassBlurEdges = e);
|
|
176
|
+
};
|
|
177
|
+
function K() {
|
|
178
|
+
H = [], L && l(S, [], j), L = "", B = "", V = 0, U = void 0, W = 0, b || G("0");
|
|
179
|
+
}
|
|
180
|
+
let q = () => w.size + [...T].reduce((e, t) => e + new Set(t.edges ?? ["top", "bottom"]).size, 0);
|
|
181
|
+
function J(e) {
|
|
182
|
+
if (f(e.options), q() >= 64) throw RangeError("A GlassScene supports at most 64 progressive blur regions.");
|
|
183
|
+
return w.add(e), () => {
|
|
184
|
+
w.delete(e);
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
add(e, t = {}) {
|
|
189
|
+
return J({
|
|
190
|
+
element: e,
|
|
191
|
+
options: t
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
addScroll(e) {
|
|
195
|
+
let t = [...new Set(e.edges ?? ["top", "bottom"])];
|
|
196
|
+
if (f(e), t.forEach((e) => f({ edge: e })), q() + t.length > 64) throw RangeError("A GlassScene supports at most 64 progressive blur regions.");
|
|
197
|
+
if (!b) return T.add(e), () => {
|
|
198
|
+
T.delete(e);
|
|
199
|
+
};
|
|
200
|
+
let n = t.map((t) => J({
|
|
201
|
+
options: {
|
|
202
|
+
...e,
|
|
203
|
+
edge: t
|
|
204
|
+
},
|
|
205
|
+
target: e.target
|
|
206
|
+
}));
|
|
207
|
+
return () => n.forEach((e) => e());
|
|
208
|
+
},
|
|
209
|
+
count() {
|
|
210
|
+
return V;
|
|
211
|
+
},
|
|
212
|
+
regions() {
|
|
213
|
+
return H;
|
|
214
|
+
},
|
|
215
|
+
operations() {
|
|
216
|
+
return W;
|
|
217
|
+
},
|
|
218
|
+
outsets() {
|
|
219
|
+
return E;
|
|
220
|
+
},
|
|
221
|
+
scrollsContent() {
|
|
222
|
+
return O;
|
|
223
|
+
},
|
|
224
|
+
error() {
|
|
225
|
+
return U ?? [...M.values()].map((e) => e.layer.error()).find(Boolean);
|
|
226
|
+
},
|
|
227
|
+
update(f) {
|
|
228
|
+
E = 0;
|
|
229
|
+
let g = b ? 0 : P(f);
|
|
230
|
+
b || G(String(g));
|
|
231
|
+
let _ = [...T].filter((e) => (typeof e.target == "function" ? e.target() : e.target) === f).flatMap((e) => [...new Set(e.edges ?? ["top", "bottom"])].map((t) => ({
|
|
232
|
+
options: {
|
|
233
|
+
...e,
|
|
234
|
+
edge: t
|
|
235
|
+
},
|
|
236
|
+
target: e.target
|
|
237
|
+
})));
|
|
238
|
+
O = _.length > 0;
|
|
239
|
+
let v = [...w, ..._];
|
|
240
|
+
if (!f || F.matches || I.matches || !v.length) return (L || B) && K(), b || G(String(g)), "";
|
|
241
|
+
let y = f.getBoundingClientRect(), x = f.offsetWidth, M = f.offsetHeight;
|
|
242
|
+
if (!x || !M || !y.width || !y.height) return K(), "";
|
|
243
|
+
let N = x / y.width, z = M / y.height, q = [];
|
|
244
|
+
for (let { element: e, options: t, target: n } of v) {
|
|
245
|
+
if (t.disabled || !(t.size ?? 80) || !(t.blur ?? 20) && !(t.refraction ?? 0)) continue;
|
|
246
|
+
let r = typeof n == "function" ? n() : n;
|
|
247
|
+
if (n && !r) continue;
|
|
248
|
+
let i = getComputedStyle(r ?? a).direction === "rtl", o = u(t.edge ?? "bottom", i), s = o === "top" || o === "bottom", c = e?.getBoundingClientRect(), l = 1;
|
|
249
|
+
if (r) {
|
|
250
|
+
let e = r.clientWidth, n = r.clientHeight, a = r.getBoundingClientRect(), u = a.width / (r.offsetWidth || 1), f = a.height / (r.offsetHeight || 1), p = a.left + r.clientLeft * u, m = a.top + r.clientTop * f, h = Math.min(t.size ?? 80, (s ? n : e) / 2);
|
|
251
|
+
l = d(o, r.scrollLeft, r.scrollTop, Math.max(0, r.scrollWidth - e), Math.max(0, r.scrollHeight - n), i, h), c = new DOMRect(o === "right" ? p + (e - h) * u : p, o === "bottom" ? m + (n - h) * f : m, (s ? e : h) * u, (s ? h : n) * f);
|
|
252
|
+
}
|
|
253
|
+
if (!c || !l || c.bottom < 0 || c.top > innerHeight || c.right < 0 || c.left > innerWidth) continue;
|
|
254
|
+
let f = s ? Math.max(c.left, y.left) : c.left, p = s ? c.top : Math.max(c.top, y.top), m = s ? Math.min(c.right, y.right) : c.right, h = s ? c.bottom : Math.min(c.bottom, y.bottom);
|
|
255
|
+
m <= f || h <= p || c.bottom <= y.top || c.top >= y.bottom || c.right <= y.left || c.left >= y.right || q.push({
|
|
256
|
+
edge: o,
|
|
257
|
+
x: (f - y.left) * N,
|
|
258
|
+
y: (p - y.top) * z,
|
|
259
|
+
width: (m - f) * N,
|
|
260
|
+
height: (h - p) * z,
|
|
261
|
+
blur: (t.blur ?? 20) * l,
|
|
262
|
+
refraction: (t.refraction ?? 0) * l
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
if (H = q, !q.length) return (L || B) && K(), b || G(String(g)), "";
|
|
266
|
+
let J = o();
|
|
267
|
+
if (t) {
|
|
268
|
+
let e = JSON.stringify([
|
|
269
|
+
x,
|
|
270
|
+
M,
|
|
271
|
+
...q.map((e) => [
|
|
272
|
+
e.edge,
|
|
273
|
+
e.width,
|
|
274
|
+
e.height,
|
|
275
|
+
e.blur,
|
|
276
|
+
e.refraction
|
|
277
|
+
])
|
|
278
|
+
]);
|
|
279
|
+
e !== k && (k = e, A = r(R(C, q, x, M)));
|
|
280
|
+
let t = A * J, i = n(x * J, M * J, t);
|
|
281
|
+
if (E = t * i / J, i < 1) for (let e of q) e.blur *= i, e.refraction *= i;
|
|
282
|
+
}
|
|
283
|
+
let Y = R(C, q, x, M);
|
|
284
|
+
if (t) {
|
|
285
|
+
let e = E > c(x, M) / 2, t = Math.min((e ? 2 : 1) * m(Y, x, M), i(x * J, M * J) / J / 2, e ? Infinity : c(x, M, .85) / 2);
|
|
286
|
+
t > E && (Y = p(Y, Math.floor(t), x, M, e), E = Math.floor(t));
|
|
287
|
+
}
|
|
288
|
+
let X = s();
|
|
289
|
+
return (Y !== L || X !== D) && (L = Y, D = X, V = q.length, W = e ? h(Y) : 0, U = W > 64 ? /* @__PURE__ */ RangeError(`Progressive blur requires ${W} filter operations; this browser supports 64 per element.`) : void 0, B = `url("#${l(S, [Y], j)(C)}")`), b || G(String(g + q.length)), B;
|
|
290
|
+
},
|
|
291
|
+
dispose() {
|
|
292
|
+
w.clear(), T.clear();
|
|
293
|
+
for (let [e, t] of M) N(e, t);
|
|
294
|
+
x.remove(), b || delete a.dataset.glassBlurEdges;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
//#endregion
|
|
299
|
+
export { z as createProgressiveLayer, j as maskUrl, R as progressiveGraph, O as rampTables };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/dom/sampling-bounds.ts
|
|
2
|
+
function e(e, t, n = !1) {
|
|
3
|
+
let r = Math.abs(t), i = (e) => !n || t < 0 ? r + 3 : Math.min(r, Math.max(0, r - e / 2) + r / 255) + 3, a = i(e.width), o = i(e.height);
|
|
4
|
+
return {
|
|
5
|
+
x: e.x - a,
|
|
6
|
+
y: e.y - o,
|
|
7
|
+
width: e.width + 2 * a,
|
|
8
|
+
height: e.height + 2 * o
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function t(e) {
|
|
12
|
+
if (!e.length) throw RangeError("At least one sampling box is required.");
|
|
13
|
+
let t = Math.min(...e.map((e) => e.x)), n = Math.min(...e.map((e) => e.y));
|
|
14
|
+
return {
|
|
15
|
+
x: t,
|
|
16
|
+
y: n,
|
|
17
|
+
width: Math.max(...e.map((e) => e.x + e.width)) - t,
|
|
18
|
+
height: Math.max(...e.map((e) => e.y + e.height)) - n
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { e as refractionSamplingBounds, t as unionSamplingBounds };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Spring as e, springs as t } from "../core/spring.js";
|
|
2
|
+
//#region src/dom/selection.ts
|
|
3
|
+
var n = (e) => !e.matches(":disabled, [data-disabled], [aria-disabled='true']");
|
|
4
|
+
function r(r, i) {
|
|
5
|
+
let a = r.parentElement;
|
|
6
|
+
if (!a) return {
|
|
7
|
+
frame() {},
|
|
8
|
+
dispose() {}
|
|
9
|
+
};
|
|
10
|
+
let o = r.ownerDocument.defaultView, s = {
|
|
11
|
+
left: r.style.left,
|
|
12
|
+
top: r.style.top,
|
|
13
|
+
width: r.style.width,
|
|
14
|
+
height: r.style.height,
|
|
15
|
+
scale: r.style.scale
|
|
16
|
+
}, c = new e(0, t.layout), l = new e(0, t.layout), u = new e(0, t.layout), d = new e(0, t.layout), f = !1, p = 0, m = !1, h = !1, g = null, _ = () => a.getAttribute("aria-orientation") === "vertical" || a.dataset.orientation === "vertical", v = () => [...a.querySelectorAll("[role=\"tab\"]")].filter((e) => e.parentElement === a || e.closest("[role=\"tablist\"]") === a), y = (e) => _() ? {
|
|
17
|
+
pos: e.offsetTop,
|
|
18
|
+
cross: e.offsetLeft,
|
|
19
|
+
length: e.offsetHeight,
|
|
20
|
+
thickness: e.offsetWidth
|
|
21
|
+
} : {
|
|
22
|
+
pos: e.offsetLeft,
|
|
23
|
+
cross: e.offsetTop,
|
|
24
|
+
length: e.offsetWidth,
|
|
25
|
+
thickness: e.offsetHeight
|
|
26
|
+
}, b = (e) => _() ? e.clientY : e.clientX, x = (e) => {
|
|
27
|
+
let t = a.getBoundingClientRect();
|
|
28
|
+
return _() ? (e - t.top) * a.offsetHeight / (t.height || 1) : (e - t.left) * a.offsetWidth / (t.width || 1);
|
|
29
|
+
}, S = (e) => v().filter(n).map((t) => ({
|
|
30
|
+
tab: t,
|
|
31
|
+
distance: Math.abs(y(t).pos + y(t).length / 2 - e)
|
|
32
|
+
})).sort((e, t) => e.distance - t.distance)[0]?.tab;
|
|
33
|
+
function C(e) {
|
|
34
|
+
if (e.button !== 0 || i() === "none") return;
|
|
35
|
+
let t = e.target?.closest("[role=\"tab\"]");
|
|
36
|
+
if (!t || !a.contains(t) || !n(t)) return;
|
|
37
|
+
let r = x(b(e)), s = t.getAttribute("aria-selected") === "true";
|
|
38
|
+
g = {
|
|
39
|
+
id: e.pointerId,
|
|
40
|
+
start: b(e),
|
|
41
|
+
client: b(e),
|
|
42
|
+
grab: s ? r - (c.value + u.value / 2) : 0
|
|
43
|
+
}, m = !1, o.addEventListener("pointermove", w), o.addEventListener("pointerup", E), o.addEventListener("pointercancel", D);
|
|
44
|
+
}
|
|
45
|
+
function w(e) {
|
|
46
|
+
g && e.pointerId === g.id && (g.client = b(e), m ||= Math.abs(g.client - g.start) > 4);
|
|
47
|
+
}
|
|
48
|
+
function T() {
|
|
49
|
+
g = null, o.removeEventListener("pointermove", w), o.removeEventListener("pointerup", E), o.removeEventListener("pointercancel", D);
|
|
50
|
+
}
|
|
51
|
+
function E(e) {
|
|
52
|
+
if (!g || e.pointerId !== g.id) return;
|
|
53
|
+
let t = S(c.value + u.value / 2);
|
|
54
|
+
T(), m && t && (h = !0, setTimeout(() => {
|
|
55
|
+
h = !1;
|
|
56
|
+
}, 0), t.getAttribute("aria-selected") !== "true" && t.click());
|
|
57
|
+
}
|
|
58
|
+
function D(e) {
|
|
59
|
+
g && e.pointerId === g.id && T();
|
|
60
|
+
}
|
|
61
|
+
function O(e) {
|
|
62
|
+
h && e.isTrusted && (h = !1, e.preventDefault(), e.stopPropagation());
|
|
63
|
+
}
|
|
64
|
+
return a.addEventListener("pointerdown", C), a.addEventListener("click", O, !0), {
|
|
65
|
+
frame(e) {
|
|
66
|
+
let n = p ? Math.min((e - p) / 1e3, 1 / 20) : 1 / 60;
|
|
67
|
+
p = e;
|
|
68
|
+
let a = i(), o = v().find((e) => e.getAttribute("aria-selected") === "true");
|
|
69
|
+
if (!o) return !1;
|
|
70
|
+
let h = y(o);
|
|
71
|
+
if (!f || a !== "full") c.jump(h.pos), l.jump(h.cross), u.jump(h.length), d.jump(h.thickness), f = h.length > 0;
|
|
72
|
+
else if (g && m && a === "full") {
|
|
73
|
+
let e = v().map(y), n = Math.min(...e.map((e) => e.pos)), r = Math.max(...e.map((e) => e.pos + e.length)), i = S(x(g.client) - g.grab), a = i ? y(i).length : h.length, o = Math.max(n + a / 2, Math.min(r - a / 2, x(g.client) - g.grab));
|
|
74
|
+
c.configure(t.track).target = o - a / 2, u.configure(t.track).target = a, l.target = h.cross, d.target = h.thickness;
|
|
75
|
+
} else {
|
|
76
|
+
for (let e of [
|
|
77
|
+
c,
|
|
78
|
+
l,
|
|
79
|
+
u,
|
|
80
|
+
d
|
|
81
|
+
]) e.configure(t.layout);
|
|
82
|
+
c.target = h.pos, l.target = h.cross, u.target = h.length, d.target = h.thickness;
|
|
83
|
+
}
|
|
84
|
+
for (let e of [
|
|
85
|
+
c,
|
|
86
|
+
l,
|
|
87
|
+
u,
|
|
88
|
+
d
|
|
89
|
+
]) e.step(n);
|
|
90
|
+
let b = Math.min(.2, Math.abs(c.velocity) * 35e-5) * (g ? 1 : .6), C = 1 + b, w = 1 / Math.sqrt(1 + b), T = _();
|
|
91
|
+
r.style.left = `${(T ? l.value : c.value).toFixed(3)}px`, r.style.top = `${(T ? c.value : l.value).toFixed(3)}px`, r.style.width = `${(T ? d.value : u.value).toFixed(3)}px`, r.style.height = `${(T ? u.value : d.value).toFixed(3)}px`;
|
|
92
|
+
let E = T ? `${w.toFixed(4)} ${C.toFixed(4)}` : `${C.toFixed(4)} ${w.toFixed(4)}`;
|
|
93
|
+
return r.style.scale = Math.abs(C - 1) + Math.abs(w - 1) > 1e-4 ? E : s.scale, g ? r.dataset.glassLifted = "" : delete r.dataset.glassLifted, !f || !!g || [
|
|
94
|
+
c,
|
|
95
|
+
l,
|
|
96
|
+
u,
|
|
97
|
+
d
|
|
98
|
+
].some((e) => !e.settled);
|
|
99
|
+
},
|
|
100
|
+
dispose() {
|
|
101
|
+
T(), a.removeEventListener("pointerdown", C), a.removeEventListener("click", O, !0), Object.assign(r.style, s), delete r.dataset.glassLifted;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { r as attachSelectionLens };
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { cornerOptions as e } from "../core/shape.js";
|
|
2
|
+
import { concentricOutline as t, contentInsets as n, cornerPlacement as r, insetShape as i, polygonClip as a } from "../core/concentric.js";
|
|
3
|
+
import { createTicker as o } from "./ticker.js";
|
|
4
|
+
import { getLayoutSize as s } from "@lisse/core";
|
|
5
|
+
//#region src/dom/shape-layout.ts
|
|
6
|
+
var c = /* @__PURE__ */ new Set(), l, u = /* @__PURE__ */ new Map();
|
|
7
|
+
function d() {
|
|
8
|
+
u = /* @__PURE__ */ new Map();
|
|
9
|
+
let e = [], t = !1;
|
|
10
|
+
for (let n of c) try {
|
|
11
|
+
let r = n();
|
|
12
|
+
r?.changed && (t = !0), e.push(r?.write);
|
|
13
|
+
} catch (e) {
|
|
14
|
+
c.delete(n), queueMicrotask(() => {
|
|
15
|
+
throw e;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
active: t,
|
|
20
|
+
write: () => {
|
|
21
|
+
for (let t of e) t?.();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function f(e, ...t) {
|
|
26
|
+
c.add(e), l ??= o(d, { root: document });
|
|
27
|
+
for (let e of t) l.observe(e);
|
|
28
|
+
return l.wake(), () => {
|
|
29
|
+
c.delete(e);
|
|
30
|
+
for (let e of t) l?.unobserve(e);
|
|
31
|
+
c.size || (l?.dispose(), l = void 0);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function p(e) {
|
|
35
|
+
e && l?.observe(e), l?.wake();
|
|
36
|
+
}
|
|
37
|
+
function m(t) {
|
|
38
|
+
return e(t), {
|
|
39
|
+
"data-lg-container": "",
|
|
40
|
+
"data-lg-container-radius": String(t)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function h(e, t) {
|
|
44
|
+
let n = m(t), r = Object.keys(n).map((t) => [t, e.getAttribute(t)]);
|
|
45
|
+
for (let [t, r] of Object.entries(n)) e.getAttribute(t) !== r && e.setAttribute(t, r);
|
|
46
|
+
let i = !1;
|
|
47
|
+
return () => {
|
|
48
|
+
if (!i) {
|
|
49
|
+
i = !0;
|
|
50
|
+
for (let [t, n] of r) n === null ? e.removeAttribute(t) : e.setAttribute(t, n);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var g = /* @__PURE__ */ new WeakMap();
|
|
55
|
+
function _(e, t) {
|
|
56
|
+
t ? g.set(e, t) : g.delete(e);
|
|
57
|
+
}
|
|
58
|
+
function v(e) {
|
|
59
|
+
let t = e.getAttribute("data-lg-container-radius");
|
|
60
|
+
if (t === null) throw Error("Declare the container with GlassShapeContainer, GlassShape, GlassSurface, or registerShapeContainer.");
|
|
61
|
+
let { width: n, height: r } = s(e);
|
|
62
|
+
return {
|
|
63
|
+
width: n,
|
|
64
|
+
height: r,
|
|
65
|
+
radius: t === "circle" || t === "capsule" ? t : Number(t),
|
|
66
|
+
outline: g.get(e)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function y(e, t) {
|
|
70
|
+
if (t) return t();
|
|
71
|
+
let n = e.parentElement?.closest("[data-lg-container]");
|
|
72
|
+
if (!n && e.isConnected) throw Error("Container-relative geometry requires a declared shape container.");
|
|
73
|
+
return n ?? null;
|
|
74
|
+
}
|
|
75
|
+
function b(e, r = {}, o) {
|
|
76
|
+
if (r.contentPadding !== void 0 && (!Number.isFinite(r.contentPadding) || r.contentPadding < 0)) throw RangeError("Content padding must be finite and nonnegative.");
|
|
77
|
+
let c = h(e, r.radius ?? 8), l = {
|
|
78
|
+
clipPath: e.style.clipPath,
|
|
79
|
+
paddingLeft: e.style.paddingLeft,
|
|
80
|
+
paddingRight: e.style.paddingRight
|
|
81
|
+
}, d = "", m = "", g = [], b = "", x = "", S, C = [], w, T = f(() => {
|
|
82
|
+
let c = y(e, o);
|
|
83
|
+
if (!c || !e.isConnected) return;
|
|
84
|
+
c !== w && (w = c, p(c));
|
|
85
|
+
let l = v(c), f = s(e), h = c.getBoundingClientRect(), T = e.getBoundingClientRect();
|
|
86
|
+
if (!l.width || !l.height || !f.width || !f.height || !h.width || !h.height) return;
|
|
87
|
+
let E = (T.left - h.left) * l.width / h.width, D = (T.top - h.top) * l.height / h.height, O = JSON.stringify([
|
|
88
|
+
l,
|
|
89
|
+
f.width,
|
|
90
|
+
f.height,
|
|
91
|
+
E,
|
|
92
|
+
D,
|
|
93
|
+
r
|
|
94
|
+
]), k = d !== O;
|
|
95
|
+
if (k) {
|
|
96
|
+
d = O;
|
|
97
|
+
let o = r.inset ?? Math.max(0, Math.min(E, D, l.width - E - f.width, l.height - D - f.height)), s = JSON.stringify([l, o]);
|
|
98
|
+
s !== m && (g = i(l, o), m = s);
|
|
99
|
+
let c = t(g, {
|
|
100
|
+
x: E,
|
|
101
|
+
y: D,
|
|
102
|
+
width: f.width,
|
|
103
|
+
height: f.height
|
|
104
|
+
}, r.radius ?? 8);
|
|
105
|
+
b = a(c), C = c;
|
|
106
|
+
let u = Math.min(f.height, Math.max(16, parseFloat(getComputedStyle(e).lineHeight) || 20));
|
|
107
|
+
S = r.contentPadding === void 0 ? void 0 : n(c, f.width, f.height, u);
|
|
108
|
+
}
|
|
109
|
+
if (S) {
|
|
110
|
+
let e = u.get(c) ?? {
|
|
111
|
+
left: 0,
|
|
112
|
+
right: 0
|
|
113
|
+
};
|
|
114
|
+
e.left = Math.max(e.left, S.left), e.right = Math.max(e.right, S.right), u.set(c, e);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
changed: k,
|
|
118
|
+
write: () => {
|
|
119
|
+
if (_(e, C), x !== b && (e.style.clipPath = b, x = b), S) {
|
|
120
|
+
let t = u.get(c), n = `${t.left + r.contentPadding}px`, i = `${t.right + r.contentPadding}px`;
|
|
121
|
+
e.style.paddingLeft !== n && (e.style.paddingLeft = n), e.style.paddingRight !== i && (e.style.paddingRight = i);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}, e);
|
|
126
|
+
return () => {
|
|
127
|
+
T(), c(), _(e), Object.assign(e.style, l);
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function x(e, t = {}, n) {
|
|
131
|
+
let i = {
|
|
132
|
+
left: e.style.left,
|
|
133
|
+
top: e.style.top,
|
|
134
|
+
right: e.style.right,
|
|
135
|
+
bottom: e.style.bottom
|
|
136
|
+
}, a = "", o = "", c = 0, l, u = f(() => {
|
|
137
|
+
let i = y(e, n);
|
|
138
|
+
if (!i || !e.isConnected) return;
|
|
139
|
+
i !== l && (l = i, p(i));
|
|
140
|
+
let u = v(i), d = s(e), f = i.getBoundingClientRect();
|
|
141
|
+
if (!u.width || !u.height || !d.width || !d.height || !f.width || !f.height) return;
|
|
142
|
+
let m = getComputedStyle(e).position === "fixed" ? null : e.offsetParent, h = m?.getBoundingClientRect(), g = JSON.stringify([
|
|
143
|
+
u,
|
|
144
|
+
d.width,
|
|
145
|
+
d.height,
|
|
146
|
+
f.x,
|
|
147
|
+
f.y,
|
|
148
|
+
f.width,
|
|
149
|
+
f.height,
|
|
150
|
+
h?.x,
|
|
151
|
+
h?.y,
|
|
152
|
+
m?.scrollLeft,
|
|
153
|
+
m?.scrollTop,
|
|
154
|
+
t
|
|
155
|
+
]);
|
|
156
|
+
if (g === a) return { changed: !1 };
|
|
157
|
+
a = g;
|
|
158
|
+
let _ = JSON.stringify([
|
|
159
|
+
u,
|
|
160
|
+
d.width,
|
|
161
|
+
d.height,
|
|
162
|
+
t
|
|
163
|
+
]);
|
|
164
|
+
_ !== o && (c = r(u, d.width, d.height, t.gap ?? 8, t.radius ?? "circle"), o = _);
|
|
165
|
+
let b = c, x = t.corner ?? "top-right", S = x.endsWith("right") ? u.width - b - d.width : b, C = x.startsWith("bottom") ? u.height - b - d.height : b, w = f.width / u.width, T = f.height / u.height, E = m && h ? h.width / m.offsetWidth : 1, D = m && h ? h.height / m.offsetHeight : 1, O = (f.left + S * w - (h?.left ?? 0)) / E + (m?.scrollLeft ?? 0) - (m?.clientLeft ?? 0), k = (f.top + C * T - (h?.top ?? 0)) / D + (m?.scrollTop ?? 0) - (m?.clientTop ?? 0);
|
|
166
|
+
return {
|
|
167
|
+
changed: !0,
|
|
168
|
+
write: () => {
|
|
169
|
+
e.style.left = `${O}px`, e.style.top = `${k}px`, e.style.right = "auto", e.style.bottom = "auto";
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}, e);
|
|
173
|
+
return () => {
|
|
174
|
+
u(), Object.assign(e.style, i);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function S(e, n, r) {
|
|
178
|
+
let a = "", o = [];
|
|
179
|
+
return () => {
|
|
180
|
+
let c = y(e);
|
|
181
|
+
if (!c) return;
|
|
182
|
+
let l = v(c), u = s(e), d = c.getBoundingClientRect(), f = e.getBoundingClientRect();
|
|
183
|
+
if (!l.width || !l.height || !d.width || !d.height || !u.width || !u.height) return;
|
|
184
|
+
let p = {
|
|
185
|
+
x: (f.left - d.left) * l.width / d.width,
|
|
186
|
+
y: (f.top - d.top) * l.height / d.height,
|
|
187
|
+
width: u.width,
|
|
188
|
+
height: u.height
|
|
189
|
+
}, m = JSON.stringify([
|
|
190
|
+
l,
|
|
191
|
+
p,
|
|
192
|
+
n,
|
|
193
|
+
r
|
|
194
|
+
]), h = n ?? Math.max(0, Math.min(p.x, p.y, l.width - p.x - p.width, l.height - p.y - p.height));
|
|
195
|
+
return m !== a && (o = t(i(l, h), p, r), a = m), o;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
export { S as createConcentricResolver, b as observeConcentricShape, x as observeCornerPlacement, h as registerShapeContainer, _ as setResolvedShape, m as shapeContainerAttributes, p as wakeShapeLayout };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { materials as e } from "../core/materials.js";
|
|
2
|
+
import { unionSamplingBounds as t } from "./sampling-bounds.js";
|
|
3
|
+
//#region src/dom/shared-backdrop.ts
|
|
4
|
+
function n(n, r) {
|
|
5
|
+
let i = /* @__PURE__ */ new Map();
|
|
6
|
+
for (let e of n) {
|
|
7
|
+
if (e.options.material !== "regular" || e.inputs.length) continue;
|
|
8
|
+
let t = e.options.appearance ?? "light", n = i.get(t) ?? [];
|
|
9
|
+
n.push(e), i.set(t, n);
|
|
10
|
+
}
|
|
11
|
+
let a = /* @__PURE__ */ new Map(), o = (e) => `x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}"`;
|
|
12
|
+
for (let [n, s] of i) {
|
|
13
|
+
let i = e.regular[n], c = e.regular.blur * r, l = i.fillSigma * r, u = Math.ceil(3 * c) + 2, d = Math.ceil(3 * l) + 2, f = (e, t) => ({
|
|
14
|
+
x: e.x - t,
|
|
15
|
+
y: e.y - t,
|
|
16
|
+
width: e.width + 2 * t,
|
|
17
|
+
height: e.height + 2 * t
|
|
18
|
+
}), p = (e) => e.width * e.height, m = (e) => 3 * p(f(e, u)) + 3 * p(f(e, d)) + 2 * p(e), h = [];
|
|
19
|
+
for (let e of s) {
|
|
20
|
+
let n = -1, r = 0, i = e.bounds;
|
|
21
|
+
for (let [a, o] of h.entries()) {
|
|
22
|
+
let s = t([o.bounds, e.bounds]), c = m(o.bounds) + m(e.bounds) - m(s);
|
|
23
|
+
c > r && (n = a, r = c, i = s);
|
|
24
|
+
}
|
|
25
|
+
n < 0 ? h.push({
|
|
26
|
+
members: [e],
|
|
27
|
+
bounds: e.bounds
|
|
28
|
+
}) : (h[n].members.push(e), h[n].bounds = i);
|
|
29
|
+
}
|
|
30
|
+
for (let { members: e, bounds: t } of h) {
|
|
31
|
+
let r = o(f(t, u)), s = o(f(t, d)), p = o(t), m = e.length === 1 ? e[0].id : `shared${n === "dark" ? "Dark" : "Light"}-${e.map((e) => e.id).sort().join("-")}`, h = {
|
|
32
|
+
result: `${m}mix`,
|
|
33
|
+
markup: `<feGaussianBlur in="SourceGraphic" stdDeviation="${c}" result="${m}frost" ${r}/><feGaussianBlur in="SourceGraphic" stdDeviation="${l}" result="${m}fill" ${s}/><feBlend in="${m}frost" in2="${m}fill" mode="${n === "dark" ? "darken" : "lighten"}" result="${m}blend" ${p}/><feComposite in="${m}blend" in2="${m}frost" operator="arithmetic" k2="${i.fillOpacity}" k3="${1 - i.fillOpacity}" k4="0" result="${m}mix" ${p}/>`
|
|
34
|
+
};
|
|
35
|
+
for (let t of e) a.set(t.key, h);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return a;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { n as sharedBackdropMaterials };
|