@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
@@ -1,19 +1,40 @@
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() {}
1
+ import { Spring as e } from "../core/spring.js";
2
+ // src/dom/selection.ts
3
+ var t = (e) => !e.matches(":disabled, [data-disabled], [aria-disabled='true']"), n = {
4
+ lift: {
5
+ duration: .25,
6
+ bounce: 0
7
+ },
8
+ settle: {
9
+ duration: .4,
10
+ bounce: 0
11
+ },
12
+ end: {
13
+ duration: .3,
14
+ bounce: .1
15
+ },
16
+ squash: {
17
+ duration: .38,
18
+ bounce: .45
19
+ }
20
+ }, r = {
21
+ along: 1 / 3,
22
+ across: .29
23
+ };
24
+ function i(i, a, o) {
25
+ let s = i.parentElement;
26
+ if (!s) return {
27
+ frame: () => !1,
28
+ dispose() {},
29
+ setLens() {}
9
30
  };
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) => _() ? {
31
+ let c = i.ownerDocument.defaultView, l = {
32
+ left: i.style.left,
33
+ top: i.style.top,
34
+ width: i.style.width,
35
+ height: i.style.height,
36
+ opacity: i.style.opacity
37
+ }, u = new e(0, n.settle), d = new e(0, n.settle), f = new e(0, n.settle), p = new e(0, n.settle), m = new e(0, n.lift), h = new e(0, n.squash), g = 0, _ = null, v = null, y = null, b = !1, x = 0, S = !1, C = !1, w = !1, T = null, E = null, D = () => s.getAttribute("aria-orientation") === "vertical" || s.dataset.orientation === "vertical", O = () => [...s.querySelectorAll("[role=\"tab\"]")].filter((e) => e.closest("[role=\"tablist\"]") === s), k = (e) => D() ? {
17
38
  pos: e.offsetTop,
18
39
  cross: e.offsetLeft,
19
40
  length: e.offsetHeight,
@@ -23,84 +44,117 @@ function r(r, i) {
23
44
  cross: e.offsetTop,
24
45
  length: e.offsetWidth,
25
46
  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 = {
47
+ }, A = (e) => D() ? e.clientY : e.clientX, j = (e) => {
48
+ let t = s.getBoundingClientRect();
49
+ return D() ? (e - t.top) * s.offsetHeight / (t.height || 1) : (e - t.left) * s.offsetWidth / (t.width || 1);
50
+ }, M = (e) => {
51
+ let n = O().filter(t);
52
+ return n.find((t) => {
53
+ let n = k(t);
54
+ return e >= n.pos && e < n.pos + n.length;
55
+ }) ?? n.map((t) => ({
56
+ tab: t,
57
+ distance: Math.abs(k(t).pos + k(t).length / 2 - e)
58
+ })).sort((e, t) => e.distance - t.distance)[0]?.tab;
59
+ }, N = () => O().find((e) => e.getAttribute("aria-selected") === "true");
60
+ function P(e) {
61
+ if (e.button !== 0 || a() !== "full") return;
62
+ let r = e.target?.closest("[role=\"tab\"]");
63
+ if (!r || !s.contains(r) || !t(r)) return;
64
+ let i = j(A(e)), l = r === N() ? i - (u.value + d.value / 2) : 0;
65
+ T = {
39
66
  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);
67
+ start: A(e),
68
+ client: A(e),
69
+ grab: l,
70
+ moved: !1,
71
+ held: r
72
+ }, E = null, m.configure(n.lift).target = 1, C || (C = !0, o?.(!0)), c.addEventListener("pointermove", F), c.addEventListener("pointerup", L), c.addEventListener("pointercancel", R);
73
+ }
74
+ function F(e) {
75
+ T && e.pointerId === T.id && (T.client = A(e), T.moved ||= Math.abs(T.client - T.start) > 3);
76
+ }
77
+ function I() {
78
+ T = null, m.configure(n.settle).target = 0, c.removeEventListener("pointermove", F), c.removeEventListener("pointerup", L), c.removeEventListener("pointercancel", R);
44
79
  }
45
- function w(e) {
46
- g && e.pointerId === g.id && (g.client = b(e), m ||= Math.abs(g.client - g.start) > 4);
80
+ function L(e) {
81
+ if (!T || e.pointerId !== T.id) return;
82
+ let t = T.moved, n = t ? M(u.target + d.target / 2) : T.held;
83
+ I(), n && (E = {
84
+ tab: n,
85
+ at: performance.now()
86
+ }, t && (S = !0, setTimeout(() => {
87
+ S = !1;
88
+ }, 0), n.getAttribute("aria-selected") !== "true" && n.click()));
47
89
  }
48
- function T() {
49
- g = null, o.removeEventListener("pointermove", w), o.removeEventListener("pointerup", E), o.removeEventListener("pointercancel", D);
90
+ function R(e) {
91
+ T && e.pointerId === T.id && (I(), E = null);
50
92
  }
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());
93
+ function z(e) {
94
+ S && e.isTrusted && (S = !1, e.preventDefault(), e.stopPropagation());
57
95
  }
58
- function D(e) {
59
- g && e.pointerId === g.id && T();
96
+ function B() {
97
+ a() === "full" && (w = !0, C || (C = !0, o?.(!0)));
60
98
  }
61
- function O(e) {
62
- h && e.isTrusted && (h = !1, e.preventDefault(), e.stopPropagation());
99
+ function V() {
100
+ w = !1;
63
101
  }
64
- return a.addEventListener("pointerdown", C), a.addEventListener("click", O, !0), {
102
+ s.addEventListener("pointerenter", B), s.addEventListener("pointerleave", V), s.addEventListener("pointerdown", P), s.addEventListener("click", z, !0);
103
+ let H = () => {
104
+ v && !v.hidden && (v.hidden = !0);
105
+ };
106
+ return {
107
+ setLens(e, t) {
108
+ v && v !== e && (v.hidden = !0), v = e, y = t, v && (v.hidden = !0);
109
+ },
65
110
  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
- }
111
+ let t = x ? Math.min((e - x) / 1e3, 1 / 20) : 1 / 60;
112
+ x = e;
113
+ let c = a() === "full";
114
+ E && (N() === E.tab || e - E.at > 600) && (E = null);
115
+ let S = N();
116
+ if (!S) return !1;
117
+ let A = O(), M = !!T?.moved && c, P = k(E?.tab ?? T?.held ?? S), F = !1;
118
+ if (T && M) {
119
+ let e = k(A[0]), t = k(A.at(-1)), r = k(T.held), i = j(T.client) - T.grab - r.length / 2;
120
+ u.configure(n.end), d.configure(n.end), i <= e.pos ? (T.held = A[0], P = e) : i + r.length >= t.pos + t.length ? (T.held = A.at(-1), P = t) : (P = {
121
+ ...r,
122
+ pos: i
123
+ }, F = b);
124
+ } else u.configure(n.settle), d.configure(n.settle);
125
+ !b || !c ? (u.jump(P.pos), d.jump(P.length), f.jump(P.cross), p.jump(P.thickness), m.jump(0), h.jump(0), b = P.length > 0) : (u.target = P.pos, d.target = P.length, f.target = P.cross, p.target = P.thickness), _ = F ? (_ ?? u.value - P.pos) * Math.exp(-50 * t) : null, g = _ === null ? u.velocity : g + ((P.pos + _ - u.value) / (t || 1) - g) * t * 20, h.target = M && v?.style.backdropFilter ? Math.min(.045, Math.abs(g) * 85e-6) : 0;
84
126
  for (let e of [
85
- c,
86
- l,
87
127
  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,
128
+ d,
129
+ f,
130
+ p,
131
+ m,
132
+ h
133
+ ]) e.step(t);
134
+ _ !== null && (u.jump(P.pos + _).velocity = g);
135
+ let I = D(), L = (e, t, n, r, i) => {
136
+ e.style.left = `${(I ? n : t).toFixed(3)}px`, e.style.top = `${(I ? t : n).toFixed(3)}px`, e.style.width = `${(I ? i : r).toFixed(3)}px`, e.style.height = `${(I ? r : i).toFixed(3)}px`;
137
+ };
138
+ L(i, u.value, f.value, d.value, p.value);
139
+ let R = Math.max(0, Math.min(1, m.value));
140
+ if (i.style.opacity = R > .001 ? (1 - R).toFixed(3) : l.opacity, v && y && (R > .001 || w)) {
141
+ let e = R > .001 ? R : 1, t = p.value, n = t * (1 + 2 * r.across), i = d.value + 2 * t * r.along * e, a = t * (1 + 2 * r.across * e) / n, o = i / a, c = s.getBoundingClientRect(), l = y.getBoundingClientRect(), m = c.left - l.left + y.scrollLeft - y.clientLeft, g = c.top - l.top + y.scrollTop - y.clientTop, _ = u.value + d.value / 2, b = f.value + t / 2, x = 1 + h.value, S = 1 - 2.4 * h.value;
142
+ v.hidden && (v.hidden = !1);
143
+ let C = R > .001 ? "" : "hidden";
144
+ v.style.visibility !== C && (v.style.visibility = C), L(v, _ - o / 2 + (I ? g : m), b - n / 2 + (I ? m : g), o, n), v.style.scale = I ? `${(a * S).toFixed(4)} ${(a * x).toFixed(4)}` : `${(a * x).toFixed(4)} ${(a * S).toFixed(4)}`;
145
+ } else H();
146
+ return T ? i.dataset.glassLifted = "" : delete i.dataset.glassLifted, C && !T && !w && m.settled && m.value === 0 && (C = !1, o?.(!1)), !b || !!T || !!E || [
96
147
  u,
97
- d
148
+ d,
149
+ f,
150
+ p,
151
+ m,
152
+ h
98
153
  ].some((e) => !e.settled);
99
154
  },
100
155
  dispose() {
101
- T(), a.removeEventListener("pointerdown", C), a.removeEventListener("click", O, !0), Object.assign(r.style, s), delete r.dataset.glassLifted;
156
+ T && I(), s.removeEventListener("pointerenter", B), s.removeEventListener("pointerleave", V), s.removeEventListener("pointerdown", P), s.removeEventListener("click", z, !0), Object.assign(i.style, l), delete i.dataset.glassLifted, H();
102
157
  }
103
158
  };
104
159
  }
105
- //#endregion
106
- export { r as attachSelectionLens };
160
+ export { i as attachSelectionLens };
@@ -0,0 +1,9 @@
1
+ import { cornerOptions as e } from "../core/corner-options.js";
2
+ // src/dom/shape-attributes.ts
3
+ function t(t) {
4
+ return e(t), {
5
+ "data-lg-container": "",
6
+ "data-lg-container-radius": String(t)
7
+ };
8
+ }
9
+ export { t as shapeContainerAttributes };
@@ -0,0 +1,14 @@
1
+ import { acquirePosition as e, createDropShadow as t, createSvgEffects as n, extractAndStripEffects as r, hasEffects as i, observeAnchor as a, releasePosition as o, restoreStyles as s } from "@lisse/core";
2
+ // src/dom/shape-effects.ts
3
+ function c(c) {
4
+ let l = r(c), u = i(l.effects) ? c.parentElement : null, d = u ? e(u) : !1, f = u ? n(u, c) : null, p = u && l.effects.shadow ? t(u, c) : null, m = u ? a(u, c) : null;
5
+ return {
6
+ update(e, t, n, r) {
7
+ f?.update(e, l.effects, t, n, r), p && l.effects.shadow && p.update(e, l.effects.shadow, t, n, r);
8
+ },
9
+ dispose() {
10
+ m?.(), f?.destroy(), p?.destroy(), d && u && o(u), s(c, l.savedStyles);
11
+ }
12
+ };
13
+ }
14
+ export { c as createShapeEffects };
@@ -0,0 +1,3 @@
1
+ import { observeFixedShape as e } from "./fixed-shape.js";
2
+ import { observeConcentricShape as t, observeCornerPlacement as n } from "./shape-layout.js";
3
+ export { t as observeConcentricShape, n as observeCornerPlacement, e as observeFixedShape };
@@ -1,17 +1,17 @@
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();
1
+ import { getLayoutSize as e } from "./layout-size.js";
2
+ import { shapeContainerAttributes as t } from "./shape-attributes.js";
3
+ import { concentricOutline as n, contentInsets as r, cornerPlacement as i, insetShape as a, polygonClip as o, scrolledShape as s } from "../core/concentric.js";
4
+ import { createTicker as c } from "./ticker.js";
5
+ // src/dom/shape-layout.ts
6
+ var l = /* @__PURE__ */ new Set(), u, d = /* @__PURE__ */ new Map();
7
+ function f() {
8
+ d = /* @__PURE__ */ new Map();
9
9
  let e = [], t = !1;
10
- for (let n of c) try {
10
+ for (let n of l) try {
11
11
  let r = n();
12
12
  r?.changed && (t = !0), e.push(r?.write);
13
13
  } catch (e) {
14
- c.delete(n), queueMicrotask(() => {
14
+ l.delete(n), queueMicrotask(() => {
15
15
  throw e;
16
16
  });
17
17
  }
@@ -22,32 +22,26 @@ function d() {
22
22
  }
23
23
  };
24
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);
25
+ function p(e, ...t) {
26
+ l.add(e), u ??= c(f, { root: document });
27
+ for (let e of t) u.observe(e);
28
+ return u.wake(), () => {
29
+ l.delete(e);
30
+ for (let e of t) u?.unobserve(e);
31
+ l.size || (u?.dispose(), u = void 0);
32
32
  };
33
33
  }
34
- function p(e) {
35
- e && l?.observe(e), l?.wake();
34
+ function m(e) {
35
+ e && u?.observe(e), u?.wake();
36
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;
37
+ function h(e, n) {
38
+ let r = t(n), i = Object.keys(r).map((t) => [t, e.getAttribute(t)]);
39
+ for (let [t, n] of Object.entries(r)) e.getAttribute(t) !== n && e.setAttribute(t, n);
40
+ let a = !1;
47
41
  return () => {
48
- if (!i) {
49
- i = !0;
50
- for (let [t, n] of r) n === null ? e.removeAttribute(t) : e.setAttribute(t, n);
42
+ if (!a) {
43
+ a = !0;
44
+ for (let [t, n] of i) n === null ? e.removeAttribute(t) : e.setAttribute(t, n);
51
45
  }
52
46
  };
53
47
  }
@@ -55,91 +49,97 @@ var g = /* @__PURE__ */ new WeakMap();
55
49
  function _(e, t) {
56
50
  t ? g.set(e, t) : g.delete(e);
57
51
  }
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);
52
+ function v(e, t) {
53
+ for (let n = e.parentElement; n && n !== t; n = n.parentElement) {
54
+ let e = getComputedStyle(n);
55
+ if (/(auto|scroll)/.test(e.overflowY + e.overflowX)) return n;
56
+ }
57
+ }
58
+ function y(t) {
59
+ let n = t.getAttribute("data-lg-container-radius");
60
+ if (n === null) throw Error("Declare the container with GlassShapeContainer, GlassShape, GlassSurface, or registerShapeContainer.");
61
+ let { width: r, height: i } = e(t);
62
62
  return {
63
- width: n,
64
- height: r,
65
- radius: t === "circle" || t === "capsule" ? t : Number(t),
66
- outline: g.get(e)
63
+ width: r,
64
+ height: i,
65
+ radius: n === "circle" || n === "capsule" ? n : Number(n),
66
+ outline: g.get(t)
67
67
  };
68
68
  }
69
- function y(e, t) {
69
+ function b(e, t) {
70
70
  if (t) return t();
71
71
  let n = e.parentElement?.closest("[data-lg-container]");
72
72
  if (!n && e.isConnected) throw Error("Container-relative geometry requires a declared shape container.");
73
73
  return n ?? null;
74
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);
75
+ function x(t, i = {}, c) {
76
+ if (i.contentPadding !== void 0 && (!Number.isFinite(i.contentPadding) || i.contentPadding < 0)) throw RangeError("Content padding must be finite and nonnegative.");
77
+ let l = h(t, i.radius ?? 8), u = {
78
+ clipPath: t.style.clipPath,
79
+ paddingLeft: t.style.paddingLeft,
80
+ paddingRight: t.style.paddingRight
81
+ }, f = "", g = "", x = [], S = "", C = "", w, T = [], E, D, O = p(() => {
82
+ let l = b(t, c);
83
+ if (!l || !t.isConnected) return;
84
+ l !== E && (E = l, D = v(t, l), m(l));
85
+ let u = y(l), p = e(t), h = l.getBoundingClientRect(), O = t.getBoundingClientRect();
86
+ if (!u.width || !u.height || !p.width || !p.height || !h.width || !h.height) return;
87
+ let k = u.width / h.width, A = u.height / h.height, j = D ? s(u, (D.scrollWidth - D.clientWidth) * k, (D.scrollHeight - D.clientHeight) * A) : u, M = (O.left - h.left + (D?.scrollLeft ?? 0)) * k, N = (O.top - h.top + (D?.scrollTop ?? 0)) * A, P = JSON.stringify([
88
+ j,
89
+ p.width,
90
+ p.height,
91
+ M,
92
+ N,
93
+ i
94
+ ]), F = f !== P;
95
+ if (F) {
96
+ f = P;
97
+ let e = i.inset ?? Math.max(0, Math.min(M, N, j.width - M - p.width, j.height - N - p.height)), s = JSON.stringify([j, e]);
98
+ s !== g && (x = a(j, e), g = s);
99
+ let c = n(x, {
100
+ x: M,
101
+ y: N,
102
+ width: p.width,
103
+ height: p.height
104
+ }, i.radius ?? 8);
105
+ S = o(c), T = c;
106
+ let l = Math.min(p.height, Math.max(16, parseFloat(getComputedStyle(t).lineHeight) || 20));
107
+ w = i.contentPadding === void 0 ? void 0 : r(c, p.width, p.height, l);
108
108
  }
109
- if (S) {
110
- let e = u.get(c) ?? {
109
+ if (w) {
110
+ let e = d.get(l) ?? {
111
111
  left: 0,
112
112
  right: 0
113
113
  };
114
- e.left = Math.max(e.left, S.left), e.right = Math.max(e.right, S.right), u.set(c, e);
114
+ e.left = Math.max(e.left, w.left), e.right = Math.max(e.right, w.right), d.set(l, e);
115
115
  }
116
116
  return {
117
- changed: k,
117
+ changed: F,
118
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);
119
+ if (_(t, T), C !== S && (t.style.clipPath = S, C = S), w) {
120
+ let e = d.get(l), n = `${e.left + i.contentPadding}px`, r = `${e.right + i.contentPadding}px`;
121
+ t.style.paddingLeft !== n && (t.style.paddingLeft = n), t.style.paddingRight !== r && (t.style.paddingRight = r);
122
122
  }
123
123
  }
124
124
  };
125
- }, e);
125
+ }, t);
126
126
  return () => {
127
- T(), c(), _(e), Object.assign(e.style, l);
127
+ O(), l(), _(t), Object.assign(t.style, u);
128
128
  };
129
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();
130
+ function S(t, n = {}, r) {
131
+ let a = {
132
+ left: t.style.left,
133
+ top: t.style.top,
134
+ right: t.style.right,
135
+ bottom: t.style.bottom
136
+ }, o = "", s = "", c = 0, l, u = p(() => {
137
+ let a = b(t, r);
138
+ if (!a || !t.isConnected) return;
139
+ a !== l && (l = a, m(a));
140
+ let u = y(a), d = e(t), f = a.getBoundingClientRect();
141
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([
142
+ let p = getComputedStyle(t).position === "fixed" ? null : t.offsetParent, h = p?.getBoundingClientRect(), g = JSON.stringify([
143
143
  u,
144
144
  d.width,
145
145
  d.height,
@@ -149,37 +149,37 @@ function x(e, t = {}, n) {
149
149
  f.height,
150
150
  h?.x,
151
151
  h?.y,
152
- m?.scrollLeft,
153
- m?.scrollTop,
154
- t
152
+ p?.scrollLeft,
153
+ p?.scrollTop,
154
+ n
155
155
  ]);
156
- if (g === a) return { changed: !1 };
157
- a = g;
156
+ if (g === o) return { changed: !1 };
157
+ o = g;
158
158
  let _ = JSON.stringify([
159
159
  u,
160
160
  d.width,
161
161
  d.height,
162
- t
162
+ n
163
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);
164
+ _ !== s && (c = i(u, d.width, d.height, n.gap ?? 8, n.radius ?? "circle"), s = _);
165
+ let v = c, x = n.corner ?? "top-right", S = x.endsWith("right") ? u.width - v - d.width : v, C = x.startsWith("bottom") ? u.height - v - d.height : v, w = f.width / u.width, T = f.height / u.height, E = p && h ? h.width / p.offsetWidth : 1, D = p && h ? h.height / p.offsetHeight : 1, O = (f.left + S * w - (h?.left ?? 0)) / E + (p?.scrollLeft ?? 0) - (p?.clientLeft ?? 0), k = (f.top + C * T - (h?.top ?? 0)) / D + (p?.scrollTop ?? 0) - (p?.clientTop ?? 0);
166
166
  return {
167
167
  changed: !0,
168
168
  write: () => {
169
- e.style.left = `${O}px`, e.style.top = `${k}px`, e.style.right = "auto", e.style.bottom = "auto";
169
+ t.style.left = `${O}px`, t.style.top = `${k}px`, t.style.right = "auto", t.style.bottom = "auto";
170
170
  }
171
171
  };
172
- }, e);
172
+ }, t);
173
173
  return () => {
174
- u(), Object.assign(e.style, i);
174
+ u(), Object.assign(t.style, a);
175
175
  };
176
176
  }
177
- function S(e, n, r) {
178
- let a = "", o = [];
177
+ function C(t, r, i) {
178
+ let o = "", s = [];
179
179
  return () => {
180
- let c = y(e);
180
+ let c = b(t);
181
181
  if (!c) return;
182
- let l = v(c), u = s(e), d = c.getBoundingClientRect(), f = e.getBoundingClientRect();
182
+ let l = y(c), u = e(t), d = c.getBoundingClientRect(), f = t.getBoundingClientRect();
183
183
  if (!l.width || !l.height || !d.width || !d.height || !u.width || !u.height) return;
184
184
  let p = {
185
185
  x: (f.left - d.left) * l.width / d.width,
@@ -189,11 +189,10 @@ function S(e, n, r) {
189
189
  }, m = JSON.stringify([
190
190
  l,
191
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;
192
+ r,
193
+ i
194
+ ]), h = r ?? Math.max(0, Math.min(p.x, p.y, l.width - p.x - p.width, l.height - p.y - p.height));
195
+ return m !== o && (s = n(a(l, h), p, i), o = m), s;
196
196
  };
197
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 };
198
+ export { C as createConcentricResolver, x as observeConcentricShape, S as observeCornerPlacement, h as registerShapeContainer, _ as setResolvedShape, t as shapeContainerAttributes, m as wakeShapeLayout };