@sofyan/glass 0.1.6 → 0.2.0

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 CHANGED
@@ -4,7 +4,8 @@ Liquid Glass for the web: a translucent material (CSS), React components, and a
4
4
  `<dialog>` sheet that closes with a swipe down on phones.
5
5
 
6
6
  - **CSS first.** Plain CSS in cascade layers. Works with Tailwind v4 (its utilities always
7
- win) and without Tailwind.
7
+ win) and without Tailwind. An unlayered build is there too, for apps whose own CSS is
8
+ unlayered or that support browsers without cascade layers.
8
9
  - **Accessible.** Fallbacks for no `backdrop-filter`, reduced transparency, more contrast
9
10
  and reduced motion. A tap outside the sheet is the single-tap alternative to the swipe
10
11
  (WCAG 2.5.1, 2.5.7); the close button stays for screen readers and keyboards.
@@ -39,6 +40,21 @@ Optional dark theme, after either of the above (see [Dark mode](#dark-mode)):
39
40
  @import '@sofyan/glass/dark.css';
40
41
  ```
41
42
 
43
+ Unlayered, when your app's own CSS is unlayered, or when it must support browsers without
44
+ cascade layers (before Safari 15.4, Chrome 99, Firefox 97), which drop layered CSS
45
+ entirely. The dark theme is optional here too:
46
+
47
+ ```css
48
+ @import '@sofyan/glass/glass.unlayered.css';
49
+ @import '@sofyan/glass/dark.unlayered.css';
50
+ ```
51
+
52
+ They hold the same rules in the same order, without the layers, so normal specificity and
53
+ source order decide: Tailwind utilities no longer win automatically. Load them before your
54
+ own CSS. There is no unlayered `tailwind.css`, since it only makes sense with layered
55
+ Tailwind; see [Using it in each kind of app](#using-it-in-each-kind-of-app) for the `lg-*`
56
+ colours.
57
+
42
58
  ### Classes
43
59
 
44
60
  | Class | What |
@@ -76,12 +92,13 @@ See the top of [`src/glass.css`](src/glass.css) for the full list.
76
92
 
77
93
  #### Dark mode
78
94
 
79
- Import `dark.css` after `glass.css` or `tailwind.css`, then add `class="dark"` or
80
- `data-theme="dark"` to any element: `<html>` for the whole page, or a wrapper for one part
81
- of it. It sets `color-scheme: dark`, retunes the neutrals, the light glass and the shadows,
82
- and gives menus and sheets denser dark fills. Surfaces with a tone of their own
83
- (`glass-dark`, `glass-clear`, `glass-tinted`, ...) keep it. The reduced transparency, more
84
- contrast and no `backdrop-filter` fallbacks still apply.
95
+ Import `dark.css` after `glass.css` or `tailwind.css` (or `dark.unlayered.css` after
96
+ `glass.unlayered.css`), then add `class="dark"` or `data-theme="dark"` to any element:
97
+ `<html>` for the whole page, or a wrapper for one part of it. It sets `color-scheme: dark`,
98
+ retunes the neutrals, the light glass and the shadows, and gives menus and sheets denser
99
+ dark fills. Surfaces with a tone of their own (`glass-dark`, `glass-clear`, `glass-tinted`,
100
+ ...) keep it. The reduced transparency, more contrast and no `backdrop-filter` fallbacks
101
+ still apply.
85
102
 
86
103
  ```html
87
104
  <html class="dark">
@@ -128,7 +145,8 @@ focus returns to the opener. A tap outside closes it too.
128
145
 
129
146
  - **Phones (< 640px):** a bottom sheet with a grabber. Pull it down to close: past a quarter
130
147
  of its height, or with a quick flick. Otherwise it settles back. The header always drags;
131
- the body drags only when scrolled to the top, so scrolling the text never closes it.
148
+ the body, and any scrolling list inside it, drags only when scrolled to the top, so
149
+ scrolling never closes it. The scrolling areas under the finger are found by themselves.
132
150
  - After a swipe, `onClose` runs once the sheet has slid away. If `open` is still true a
133
151
  moment later (say you ask "discard changes?" first), the sheet slides back.
134
152
  - On phones there is no visible ✕, like a native sheet: the grabber, a pull down or a tap
@@ -136,19 +154,47 @@ focus returns to the opener. A tap outside closes it too.
136
154
  keyboard focuses it.
137
155
  - While a finger is on the sheet, the page behind stays still: the hook cancels the touch
138
156
  moves that have nothing to scroll (iOS Safari would pan the page otherwise). Mark a
139
- sideways scroller in the header or footer with `data-glass-no-drag`.
157
+ sideways scroller outside a scrolling area (in the header or footer, say) with
158
+ `data-glass-no-drag`.
140
159
  - **640px and up:** a centred card. No swipe.
141
160
  - Opening focuses the dialog itself, so a screen reader starts at the title and no focus
142
161
  ring shows on the close button.
143
162
  - `swipeToClose={false}` turns the gesture off. Add `data-glass-no-drag` to an element to
144
163
  stop a drag starting on it (e.g. a horizontal carousel).
145
164
 
146
- To add the gesture to your own sheet, use the hook:
165
+ ### Use it on your own sheet
166
+
167
+ `useSwipeToClose` gives any sheet the same gesture. All it needs is a ref on the panel
168
+ that moves:
147
169
 
148
170
  ```tsx
149
- useSwipeToClose(sheetRef, { enabled: open, scrollRef: bodyRef, onClose });
171
+ import { useRef, type ReactNode } from 'react';
172
+ import { useSwipeToClose } from '@sofyan/glass/react';
173
+
174
+ type SheetProps = { open: boolean; onClose: () => void; children: ReactNode };
175
+
176
+ function Sheet({ open, onClose, children }: SheetProps) {
177
+ const panelRef = useRef<HTMLDivElement>(null);
178
+ useSwipeToClose(panelRef, { enabled: open, onClose });
179
+
180
+ if (!open) return null;
181
+ return (
182
+ <div className="my-backdrop">
183
+ <div ref={panelRef} className="my-panel">
184
+ {children}
185
+ </div>
186
+ </div>
187
+ );
188
+ }
150
189
  ```
151
190
 
191
+ There is no need to say which part scrolls, however deep it sits. At each press the hook
192
+ looks at the elements from the finger up to the panel (the panel too): one with
193
+ `overflow-y` auto or scroll and more content than fits is a scrolling area, and while any
194
+ of them is scrolled down, a pull scrolls it instead of moving the sheet. `scrollRef` is
195
+ optional, for a scroller it cannot see that way (say, `overflow-y: hidden` scrolled by a
196
+ script). The gesture applies below 640px; pass `media` to change that.
197
+
152
198
  Pass `enabled: false` once the sheet is closed. After `onClose` the hook keeps the sheet
153
199
  off-screen and clears its inline styles when `enabled` turns false; if that has not
154
200
  happened a moment later, it slides the sheet back.
@@ -166,11 +212,50 @@ dialog.my-sheet[data-closing]::backdrop {
166
212
  }
167
213
  ```
168
214
 
215
+ When the backdrop is a parent element instead, select it with `:has()`:
216
+ `.my-backdrop:has(> [data-closing]) { background-color: transparent; }`.
217
+
169
218
  ### Refraction (Chromium only)
170
219
 
171
220
  Mount `<GlassFilter />` once near the root, then add `refract` (or `glass-refract`). Safari
172
221
  and Firefox keep the plain blur.
173
222
 
223
+ ## Using it in each kind of app
224
+
225
+ Pick one stylesheet, then the markup that fits your framework:
226
+
227
+ | App | Use |
228
+ | ------------------------------------------------------------ | --------------------------------------------------------- |
229
+ | Tailwind v4 (layered, as `@import 'tailwindcss'` loads it) | `tailwind.css` (+ `dark.css`) |
230
+ | No Tailwind | `glass.css` (+ `dark.css`) |
231
+ | Own CSS unlayered, or must support browsers without `@layer` | `glass.unlayered.css` (+ `dark.unlayered.css`) |
232
+ | React 18 or 19 | `@sofyan/glass/react` components, on top of that CSS file |
233
+ | Vue, Blade/Livewire or plain HTML | The classes directly, on top of that CSS file |
234
+
235
+ With the unlayered build, the `lg-*` Tailwind colours (`bg-lg-paper`, ...) come from
236
+ `tailwind.css`, which you don't import. Copy its block into your own `@theme`:
237
+
238
+ ```css
239
+ @theme inline {
240
+ --color-lg-canvas: rgb(var(--lg-c-canvas));
241
+ --color-lg-paper: rgb(var(--lg-c-paper));
242
+ --color-lg-raised: rgb(var(--lg-c-raised));
243
+ --color-lg-ink: rgb(var(--lg-c-ink));
244
+ --color-lg-ink-2: rgb(var(--lg-c-ink-2));
245
+ --color-lg-ink-3: rgb(var(--lg-c-ink-3));
246
+ --color-lg-line: rgb(var(--lg-c-line));
247
+ --color-lg-accent: var(--lg-accent, var(--color-primary, #0a84ff));
248
+ }
249
+ ```
250
+
251
+ Without React, use the [classes](#classes) in your templates:
252
+
253
+ ```html
254
+ <button type="button" class="glass-btn">Share</button>
255
+ <button type="button" class="glass-btn glass-tinted glass-btn-lg">Buy tickets</button>
256
+ <nav class="glass glass-dark glass-pill">…</nav>
257
+ ```
258
+
174
259
  ## Develop
175
260
 
176
261
  ```sh
@@ -0,0 +1,99 @@
1
+ /*
2
+ * @sofyan/glass: opt-in dark theme, unlayered build
3
+ * ---------------------------------------------------------------------------
4
+ * Generated from src/dark.css by the build: the same rules in the same order, with the
5
+ * cascade layers taken out. Edit the source, not this file.
6
+ *
7
+ * The dark theme for glass.unlayered.css. Import it after that file:
8
+ *
9
+ * @import '@sofyan/glass/glass.unlayered.css';
10
+ * @import '@sofyan/glass/dark.unlayered.css';
11
+ *
12
+ * Then add class="dark" or data-theme="dark" to any element: <html> for the whole page,
13
+ * or a wrapper for one part of it. Everything inside follows.
14
+ *
15
+ * It only retunes tokens (neutrals, the light glass, shadows) and the denser fills of
16
+ * menus and sheets. Tones you set yourself (glass-dark, glass-clear, glass-tinted, ...)
17
+ * stay as they are.
18
+ *
19
+ * Cascade: no cascade layers here, so normal specificity and source order decide.
20
+ * Tailwind utilities no longer win automatically: an unlayered utility overrides a glass
21
+ * rule only when it is more specific, or as specific and loaded later, and a layered one
22
+ * never does. So load the glass files before your own CSS.
23
+ */
24
+
25
+ /* ── Tokens ───────────────────────────────────────────────────────────── */
26
+ /* :is(), not :where(): glass.css sets these tokens on :root, and on <html class="dark">
27
+ a zero-specificity rule would lose to it. :is() ties with :root, so the later rule
28
+ (this file) wins. */
29
+ :is(.dark, [data-theme='dark']) {
30
+ color-scheme: dark;
31
+
32
+ --lg-c-canvas: 11 11 12;
33
+ --lg-c-paper: 28 28 30;
34
+ --lg-c-raised: 44 44 46;
35
+ --lg-c-ink: 245 245 247;
36
+ --lg-c-ink-2: 152 152 157;
37
+ --lg-c-ink-3: 142 142 147;
38
+ --lg-c-line: 255 255 255;
39
+
40
+ --lg-light-fill: rgba(30, 30, 32, 0.66);
41
+ --lg-light-fill-hover: rgba(44, 44, 46, 0.76);
42
+ --lg-light-text: #f5f5f7;
43
+ --lg-light-rim: rgba(255, 255, 255, 0.14);
44
+ --lg-light-edge: rgba(255, 255, 255, 0.08);
45
+
46
+ --lg-sheen: none;
47
+
48
+ --lg-shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.3);
49
+ --lg-shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
50
+ --lg-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
51
+ }
52
+
53
+ /* The same fallbacks as glass.css, for the dark fills. They come after the rule above so
54
+ they win over it. */
55
+ @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
56
+ :is(.dark, [data-theme='dark']) {
57
+ --lg-light-fill: rgba(30, 30, 32, 0.92);
58
+ --lg-light-fill-hover: rgba(44, 44, 46, 0.96);
59
+ }
60
+ }
61
+
62
+ @media (prefers-reduced-transparency: reduce) {
63
+ :is(.dark, [data-theme='dark']) {
64
+ --lg-light-fill: rgba(30, 30, 32, 0.97);
65
+ --lg-light-fill-hover: #2c2c2e;
66
+ }
67
+ }
68
+
69
+ @media (prefers-contrast: more) {
70
+ :is(.dark, [data-theme='dark']) {
71
+ --lg-light-edge: rgba(255, 255, 255, 0.45);
72
+ }
73
+ }
74
+
75
+ /* ── Composites ───────────────────────────────────────────────────────── */
76
+ /* Denser fills for floating overlays. The :not() skips surfaces with a tone of their own,
77
+ which glass.css lets win by source order; :where() keeps it out of the specificity. */
78
+ :where(.dark, [data-theme='dark'])
79
+ .glass-menu:where(
80
+ :not(.glass-dark, .glass-clear, .glass-tinted, .glass-tinted-secondary, .glass-danger)
81
+ ) {
82
+ --lg-fill: rgba(36, 36, 40, 0.88);
83
+ }
84
+
85
+ :where(.dark, [data-theme='dark'])
86
+ .glass-sheet:where(
87
+ :not(.glass-dark, .glass-clear, .glass-tinted, .glass-tinted-secondary, .glass-danger)
88
+ ) {
89
+ --lg-fill: rgba(30, 30, 34, 0.92);
90
+ }
91
+
92
+ :where(.dark, [data-theme='dark']) .glass-menu-item:hover,
93
+ :where(.dark, [data-theme='dark']) .glass-menu-item:focus-visible {
94
+ background-color: rgba(255, 255, 255, 0.1);
95
+ }
96
+
97
+ :where(.dark, [data-theme='dark']) .glass-menu-separator {
98
+ background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent);
99
+ }
@@ -0,0 +1,727 @@
1
+ /*
2
+ * @sofyan/glass: Liquid Glass material, unlayered build
3
+ * ---------------------------------------------------------------------------
4
+ * Generated from src/glass.css by the build: the same rules in the same order, with the
5
+ * cascade layers taken out. Edit the source, not this file.
6
+ *
7
+ * Use it instead of glass.css when your app's own CSS is unlayered, or when it must
8
+ * support browsers without cascade layers (before Safari 15.4, Chrome 99, Firefox 97),
9
+ * which drop layered CSS entirely.
10
+ *
11
+ * A translucent, light-bending material inspired by Apple's Liquid Glass:
12
+ * - backdrop blur + saturation boost so content behind the layer glows through
13
+ * - a specular rim (bright top edge that fades) drawn as a masked gradient ring,
14
+ * so it follows any border-radius
15
+ * - a near-invisible sheen, soft depth shadows and a gentle spring on press
16
+ *
17
+ * Every visual decision is a CSS custom property (--lg-*). Override any of them on
18
+ * :root (or on an element) to retune the material without touching components.
19
+ *
20
+ * Cascade: no cascade layers here, so normal specificity and source order decide.
21
+ * Tailwind utilities no longer win automatically: an unlayered utility overrides a glass
22
+ * rule only when it is more specific, or as specific and loaded later, and a layered one
23
+ * never does. So load the glass files before your own CSS.
24
+ *
25
+ * Accessibility (bottom of file):
26
+ * - no backdrop-filter support → denser fill
27
+ * - prefers-reduced-transparency → near-opaque fill, no blur
28
+ * - prefers-contrast: more → solid edges, no sheen
29
+ * - prefers-reduced-motion → no lift, press or slide animations
30
+ */
31
+
32
+ /* ── Tokens ───────────────────────────────────────────────────────────── */
33
+ :root {
34
+ /* Derived tokens. Not declared here: a var() in a :root value is resolved at :root, so
35
+ it would ignore --color-* or --lg-c-* overrides set lower down (e.g. on a `.dark`
36
+ wrapper). Each use site falls back to the default below instead. Set any of them,
37
+ on :root or on an element, to override it.
38
+ --lg-accent default var(--color-primary, #0a84ff)
39
+ --lg-accent-strong default var(--color-primary-dark, #0060df)
40
+ --lg-accent-2 default var(--color-secondary, #5e5ce6)
41
+ --lg-accent-2-strong default var(--color-secondary-dark, #4b49c9)
42
+ --lg-sheet-fill default rgb(var(--lg-c-paper)), the <dialog> sheet's fill */
43
+ --lg-danger: #ff3b30; /* iOS system red */
44
+ --lg-danger-strong: #e5352b;
45
+
46
+ /* Theme-aware neutrals as RGB triplets, so `rgb(var(--lg-c-ink) / 0.5)` works.
47
+ tailwind.css maps them to `lg-*` colours. Redefine them for dark mode. */
48
+ --lg-c-canvas: 245 245 247;
49
+ --lg-c-paper: 255 255 255;
50
+ --lg-c-raised: 255 255 255;
51
+ --lg-c-ink: 29 29 31;
52
+ --lg-c-ink-2: 110 110 115;
53
+ --lg-c-ink-3: 160 160 166;
54
+ --lg-c-line: 0 0 0;
55
+
56
+ /* Material */
57
+ --lg-blur: 24px;
58
+ --lg-blur-thin: 12px;
59
+ --lg-blur-thick: 40px;
60
+ --lg-saturate: 180%;
61
+
62
+ /* Light glass (over light or colourful content) */
63
+ --lg-light-fill: rgba(255, 255, 255, 0.66);
64
+ --lg-light-fill-hover: rgba(255, 255, 255, 0.8);
65
+ --lg-light-text: #0b1220;
66
+ --lg-light-rim: rgba(255, 255, 255, 0.8);
67
+ --lg-light-rim-low: rgba(255, 255, 255, 0);
68
+ --lg-light-edge: rgba(15, 23, 42, 0.06);
69
+
70
+ /* Dark glass (over dark or photographic content) */
71
+ --lg-dark-fill: rgba(30, 30, 34, 0.5);
72
+ --lg-dark-fill-hover: rgba(44, 44, 50, 0.58);
73
+ --lg-dark-text: #ffffff;
74
+ --lg-dark-rim: rgba(255, 255, 255, 0.16);
75
+ --lg-dark-rim-low: rgba(255, 255, 255, 0);
76
+ --lg-dark-edge: rgba(255, 255, 255, 0.08);
77
+
78
+ /* Clear glass (minimal tint, floating over media) */
79
+ --lg-clear-fill: rgba(255, 255, 255, 0.1);
80
+ --lg-clear-fill-hover: rgba(255, 255, 255, 0.18);
81
+
82
+ /* Sheen: deliberately near-invisible. A visible gloss band reads as 2009-era Aero;
83
+ modern glass is flat and lit only at the edge. */
84
+ --lg-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 30%);
85
+ --lg-sheen-dark: none;
86
+
87
+ /* Depth: one large, faint, diffuse shadow, no hard contact shadows. */
88
+ --lg-shadow-sm: 0 2px 12px rgba(15, 23, 42, 0.05);
89
+ --lg-shadow-md: 0 8px 32px rgba(15, 23, 42, 0.08);
90
+ --lg-shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.12);
91
+ --lg-shadow-dark: 0 12px 40px rgba(0, 0, 0, 0.35);
92
+
93
+ /* Shape: soft, not bubbly. */
94
+ --lg-radius-sm: 10px;
95
+ --lg-radius-md: 14px;
96
+ --lg-radius-lg: 16px;
97
+ --lg-radius-xl: 20px;
98
+ --lg-radius-sheet: 20px;
99
+
100
+ /* Motion: a gentle settle, not a bouncy overshoot. */
101
+ --lg-ease-spring: cubic-bezier(0.32, 1.2, 0.5, 1);
102
+ --lg-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
103
+ --lg-duration: 380ms;
104
+ --lg-duration-fast: 180ms;
105
+
106
+ /* Overlays */
107
+ --lg-scrim: rgba(0, 0, 0, 0.4);
108
+ --lg-sheet-max-height: 85dvh;
109
+ --lg-sheet-max-width: 640px;
110
+ }
111
+
112
+ /* Fallbacks that change tokens. */
113
+ @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
114
+ :root {
115
+ --lg-light-fill: rgba(255, 255, 255, 0.92);
116
+ --lg-light-fill-hover: rgba(255, 255, 255, 0.98);
117
+ --lg-dark-fill: rgba(16, 16, 20, 0.9);
118
+ --lg-dark-fill-hover: rgba(28, 28, 34, 0.94);
119
+ --lg-clear-fill: rgba(16, 16, 20, 0.6);
120
+ --lg-clear-fill-hover: rgba(16, 16, 20, 0.7);
121
+ }
122
+ }
123
+
124
+ @media (prefers-reduced-transparency: reduce) {
125
+ :root {
126
+ --lg-light-fill: rgba(255, 255, 255, 0.97);
127
+ --lg-light-fill-hover: #ffffff;
128
+ --lg-dark-fill: rgba(18, 18, 22, 0.97);
129
+ --lg-dark-fill-hover: #1c1c22;
130
+ --lg-clear-fill: rgba(18, 18, 22, 0.85);
131
+ --lg-clear-fill-hover: rgba(18, 18, 22, 0.92);
132
+ --lg-blur: 0px;
133
+ --lg-blur-thin: 0px;
134
+ --lg-blur-thick: 0px;
135
+ --lg-saturate: 100%;
136
+ }
137
+ }
138
+
139
+ @media (prefers-contrast: more) {
140
+ :root {
141
+ --lg-light-edge: rgba(15, 23, 42, 0.45);
142
+ --lg-dark-edge: rgba(255, 255, 255, 0.55);
143
+ --lg-sheen: none;
144
+ --lg-sheen-dark: none;
145
+ }
146
+ }
147
+
148
+ /* ── Base material ──────────────────────────────────────────────────── */
149
+ /* Every class in this list is a glass surface; the composites below add to it. */
150
+ :where(.glass, .glass-btn, .glass-menu, .glass-sheet, .glass-chip) {
151
+ --lg-fill: var(--lg-light-fill);
152
+ --lg-fill-hover: var(--lg-light-fill-hover);
153
+ --lg-rim: var(--lg-light-rim);
154
+ --lg-rim-low: var(--lg-light-rim-low);
155
+ --lg-edge: var(--lg-light-edge);
156
+ --lg-shadow: var(--lg-shadow-md);
157
+ --lg-surface-sheen: var(--lg-sheen);
158
+ --lg-surface-blur: var(--lg-blur);
159
+ }
160
+
161
+ .glass,
162
+ .glass-btn,
163
+ .glass-menu,
164
+ .glass-sheet,
165
+ .glass-chip {
166
+ position: relative;
167
+ isolation: isolate;
168
+ color: var(--lg-light-text);
169
+ background-color: var(--lg-fill);
170
+ background-image: var(--lg-surface-sheen);
171
+ border-radius: var(--lg-radius-md);
172
+ box-shadow:
173
+ inset 0 0 0 1px var(--lg-edge),
174
+ var(--lg-shadow);
175
+ -webkit-backdrop-filter: blur(var(--lg-surface-blur)) saturate(var(--lg-saturate));
176
+ backdrop-filter: blur(var(--lg-surface-blur)) saturate(var(--lg-saturate));
177
+ }
178
+
179
+ /* Specular rim: a 1px gradient ring that follows the border radius. Light catches the
180
+ top edge only, then fades. */
181
+ :is(.glass, .glass-btn, .glass-menu, .glass-sheet, .glass-chip)::before {
182
+ content: '';
183
+ position: absolute;
184
+ inset: 0;
185
+ z-index: 1;
186
+ border-radius: inherit;
187
+ padding: 1px;
188
+ pointer-events: none;
189
+ background: linear-gradient(180deg, var(--lg-rim) 0%, var(--lg-rim-low) 40%);
190
+ -webkit-mask:
191
+ linear-gradient(#000 0 0) content-box,
192
+ linear-gradient(#000 0 0);
193
+ -webkit-mask-composite: xor;
194
+ mask:
195
+ linear-gradient(#000 0 0) content-box exclude,
196
+ linear-gradient(#000 0 0);
197
+ }
198
+
199
+ /* ── Interaction ────────────────────────────────────────────────────── */
200
+ .glass-interactive,
201
+ .glass-btn {
202
+ cursor: pointer;
203
+ transition:
204
+ transform var(--lg-duration) var(--lg-ease-spring),
205
+ background-color var(--lg-duration-fast) ease,
206
+ box-shadow var(--lg-duration) var(--lg-ease-out);
207
+ }
208
+
209
+ :is(.glass-interactive, .glass-btn):hover {
210
+ background-color: var(--lg-fill-hover);
211
+ }
212
+
213
+ :is(.glass-interactive, .glass-btn):active {
214
+ transform: scale(0.97);
215
+ transition-duration: var(--lg-duration-fast);
216
+ }
217
+
218
+ :is(.glass-interactive, .glass-btn):focus-visible {
219
+ outline: 2px solid
220
+ color-mix(in srgb, var(--lg-accent, var(--color-primary, #0a84ff)) 70%, white);
221
+ outline-offset: 2px;
222
+ }
223
+
224
+ /* Cards that float up on hover. */
225
+ .glass-lift {
226
+ transition:
227
+ transform var(--lg-duration) var(--lg-ease-spring),
228
+ box-shadow var(--lg-duration) var(--lg-ease-out),
229
+ background-color var(--lg-duration-fast) ease;
230
+ }
231
+
232
+ .glass-lift:hover {
233
+ --lg-shadow: var(--lg-shadow-lg);
234
+ transform: translateY(-4px);
235
+ }
236
+
237
+ /* ── Composite components ───────────────────────────────────────────── */
238
+
239
+ /* Buttons: small radius, interactive, 44px touch target. */
240
+ .glass-btn {
241
+ display: inline-flex;
242
+ align-items: center;
243
+ justify-content: center;
244
+ gap: 0.5rem;
245
+ min-height: 44px;
246
+ padding: 0.625rem 1.25rem;
247
+ border-radius: var(--lg-radius-sm);
248
+ font-size: 0.875rem;
249
+ line-height: 1.25rem;
250
+ font-weight: 600;
251
+ }
252
+
253
+ .glass-btn-sm {
254
+ padding: 0.375rem 0.875rem;
255
+ font-size: 0.75rem;
256
+ line-height: 1rem;
257
+ }
258
+
259
+ .glass-btn-lg {
260
+ padding: 0.875rem 1.75rem;
261
+ font-size: 1rem;
262
+ line-height: 1.5rem;
263
+ }
264
+
265
+ .glass-block {
266
+ width: 100%;
267
+ }
268
+
269
+ .glass-btn:disabled,
270
+ .glass-btn[aria-disabled='true'] {
271
+ cursor: not-allowed;
272
+ opacity: 0.5;
273
+ transform: none;
274
+ }
275
+
276
+ /* Popover / dropdown menus: thick, large radius, dense enough that saturated content
277
+ (badges, red buttons) doesn't read through. */
278
+ .glass-menu {
279
+ --lg-surface-blur: var(--lg-blur-thick);
280
+ --lg-shadow: var(--lg-shadow-lg);
281
+ --lg-fill: rgba(250, 250, 252, 0.86);
282
+ padding: 0.375rem;
283
+ border-radius: var(--lg-radius-lg);
284
+ animation: lg-pop var(--lg-duration) var(--lg-ease-spring) both;
285
+ transform-origin: top right;
286
+ }
287
+
288
+ .glass-menu-item {
289
+ display: flex;
290
+ width: 100%;
291
+ align-items: center;
292
+ gap: 0.75rem;
293
+ padding: 0.625rem 0.875rem;
294
+ border-radius: 0.75rem;
295
+ text-align: left;
296
+ font-size: 0.875rem;
297
+ line-height: 1.25rem;
298
+ font-weight: 500;
299
+ transition:
300
+ background-color var(--lg-duration-fast) ease,
301
+ transform var(--lg-duration-fast) ease;
302
+ }
303
+
304
+ .glass-menu-item:hover,
305
+ .glass-menu-item:focus-visible {
306
+ background-color: rgba(15, 23, 42, 0.06);
307
+ outline: none;
308
+ }
309
+
310
+ .glass-menu-item:active {
311
+ transform: scale(0.985);
312
+ }
313
+
314
+ .glass-menu-separator {
315
+ height: 1px;
316
+ margin: 0.25rem 0.5rem;
317
+ background: linear-gradient(90deg, transparent, rgba(15, 23, 42, 0.1), transparent);
318
+ }
319
+
320
+ /* Modal surface + scrim (for overlays you position yourself; see .glass-dialog for the
321
+ native <dialog> sheet). */
322
+ .glass-scrim {
323
+ background-color: var(--lg-scrim);
324
+ /* Fade the colour, not opacity: an opacity animation would make the scrim a backdrop
325
+ root and stop the sheet inside it from blurring the page. */
326
+ animation: lg-scrim-in var(--lg-duration-fast) ease;
327
+ }
328
+
329
+ .glass-sheet {
330
+ --lg-surface-blur: var(--lg-blur-thick);
331
+ --lg-shadow: var(--lg-shadow-lg);
332
+ --lg-fill: rgba(255, 255, 255, 0.9);
333
+ border-radius: var(--lg-radius-xl);
334
+ animation: lg-sheet-in var(--lg-duration) var(--lg-ease-spring) both;
335
+ }
336
+
337
+ /* Inputs */
338
+ .glass-input {
339
+ width: 100%;
340
+ padding: 0.625rem 1rem;
341
+ border-radius: 0.75rem;
342
+ font-size: 0.875rem;
343
+ line-height: 1.25rem;
344
+ color: rgb(var(--lg-c-ink));
345
+ background-color: rgb(var(--lg-c-paper) / 0.55);
346
+ box-shadow:
347
+ inset 0 1px 2px rgb(var(--lg-c-line) / 0.08),
348
+ inset 0 0 0 1px rgb(var(--lg-c-line) / 0.08);
349
+ -webkit-backdrop-filter: blur(var(--lg-blur-thin));
350
+ backdrop-filter: blur(var(--lg-blur-thin));
351
+ transition:
352
+ background-color var(--lg-duration-fast) ease,
353
+ box-shadow var(--lg-duration-fast) ease;
354
+ }
355
+
356
+ .glass-input::placeholder {
357
+ color: rgb(var(--lg-c-ink-2));
358
+ }
359
+
360
+ .glass-input:focus {
361
+ outline: none;
362
+ background-color: rgb(var(--lg-c-paper) / 0.85);
363
+ box-shadow:
364
+ inset 0 0 0 1.5px
365
+ color-mix(in srgb, var(--lg-accent, var(--color-primary, #0a84ff)) 70%, transparent),
366
+ 0 0 0 4px color-mix(in srgb, var(--lg-accent, var(--color-primary, #0a84ff)) 16%, transparent);
367
+ }
368
+
369
+ /* Small chip / badge: thin, pill. */
370
+ .glass-chip {
371
+ --lg-surface-blur: var(--lg-blur-thin);
372
+ --lg-shadow: var(--lg-shadow-sm);
373
+ display: inline-flex;
374
+ align-items: center;
375
+ gap: 0.375rem;
376
+ padding: 0.25rem 0.75rem;
377
+ border-radius: 9999px;
378
+ font-size: 0.75rem;
379
+ line-height: 1rem;
380
+ font-weight: 600;
381
+ }
382
+
383
+ /* ── Tones ──────────────────────────────────────────────────────────── */
384
+ .glass-dark {
385
+ --lg-fill: var(--lg-dark-fill);
386
+ --lg-fill-hover: var(--lg-dark-fill-hover);
387
+ --lg-rim: var(--lg-dark-rim);
388
+ --lg-rim-low: var(--lg-dark-rim-low);
389
+ --lg-edge: var(--lg-dark-edge);
390
+ --lg-shadow: var(--lg-shadow-dark);
391
+ --lg-surface-sheen: var(--lg-sheen-dark);
392
+ color: var(--lg-dark-text);
393
+ }
394
+
395
+ .glass-dark .glass-menu-item:hover,
396
+ .glass-dark .glass-menu-item:focus-visible {
397
+ background-color: rgba(255, 255, 255, 0.1);
398
+ }
399
+
400
+ .glass-dark .glass-menu-separator {
401
+ background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent);
402
+ }
403
+
404
+ .glass-clear {
405
+ --lg-fill: var(--lg-clear-fill);
406
+ --lg-fill-hover: var(--lg-clear-fill-hover);
407
+ --lg-rim: rgba(255, 255, 255, 0.6);
408
+ --lg-rim-low: rgba(255, 255, 255, 0.12);
409
+ --lg-edge: rgba(255, 255, 255, 0.08);
410
+ --lg-shadow: var(--lg-shadow-sm);
411
+ color: #fff;
412
+ }
413
+
414
+ /* Solid tones for primary actions. */
415
+ .glass-tinted,
416
+ .glass-tinted-secondary,
417
+ .glass-danger {
418
+ --lg-rim: rgba(255, 255, 255, 0.28);
419
+ --lg-rim-low: rgba(255, 255, 255, 0);
420
+ --lg-edge: transparent;
421
+ --lg-shadow: 0 0 #0000;
422
+ --lg-surface-sheen: none;
423
+ color: #fff;
424
+ }
425
+
426
+ .glass-tinted {
427
+ --lg-fill: var(--lg-accent, var(--color-primary, #0a84ff));
428
+ --lg-fill-hover: var(--lg-accent-strong, var(--color-primary-dark, #0060df));
429
+ }
430
+
431
+ .glass-tinted-secondary {
432
+ --lg-fill: var(--lg-accent-2, var(--color-secondary, #5e5ce6));
433
+ --lg-fill-hover: var(--lg-accent-2-strong, var(--color-secondary-dark, #4b49c9));
434
+ }
435
+
436
+ .glass-danger {
437
+ --lg-fill: var(--lg-danger);
438
+ --lg-fill-hover: var(--lg-danger-strong);
439
+ }
440
+
441
+ /* ── Thickness ──────────────────────────────────────────────────────── */
442
+ .glass-thin {
443
+ --lg-surface-blur: var(--lg-blur-thin);
444
+ --lg-shadow: var(--lg-shadow-sm);
445
+ }
446
+
447
+ .glass-thick {
448
+ --lg-surface-blur: var(--lg-blur-thick);
449
+ --lg-shadow: var(--lg-shadow-lg);
450
+ }
451
+
452
+ .glass-flat {
453
+ --lg-shadow: 0 0 #0000;
454
+ }
455
+
456
+ /* ── Shape ──────────────────────────────────────────────────────────── */
457
+ .glass-sm {
458
+ border-radius: var(--lg-radius-sm);
459
+ }
460
+
461
+ .glass-lg {
462
+ border-radius: var(--lg-radius-lg);
463
+ }
464
+
465
+ .glass-xl {
466
+ border-radius: var(--lg-radius-xl);
467
+ }
468
+
469
+ .glass-pill {
470
+ border-radius: 9999px;
471
+ }
472
+
473
+ /* Denser fills for floating overlays in dark mode. */
474
+ .glass-menu.glass-dark {
475
+ --lg-fill: rgba(20, 20, 24, 0.9);
476
+ }
477
+
478
+ .glass-sheet.glass-dark {
479
+ --lg-fill: rgba(20, 20, 24, 0.8);
480
+ }
481
+
482
+ /* ── Backgrounds ────────────────────────────────────────────────────── */
483
+ /* Page backgrounds behind glass: flat and neutral. */
484
+ .glass-canvas {
485
+ background-color: rgb(var(--lg-c-canvas));
486
+ }
487
+
488
+ /* Chromium-only refraction: <GlassFilter /> sets data-lg-refract on <html> when the
489
+ browser supports SVG filters inside backdrop-filter. Elsewhere this is a no-op. */
490
+ [data-lg-refract] .glass-refract {
491
+ -webkit-backdrop-filter: url(#lg-refract) blur(var(--lg-surface-blur))
492
+ saturate(var(--lg-saturate));
493
+ backdrop-filter: url(#lg-refract) blur(var(--lg-surface-blur)) saturate(var(--lg-saturate));
494
+ }
495
+
496
+ /* ── Dialog sheet (<GlassSheet />, or a <dialog class="glass-dialog">) ──── */
497
+ /* Centred card from 640px up; a bottom sheet on phones. The header and grabber drag the
498
+ sheet; the body scrolls. */
499
+ dialog.glass-dialog {
500
+ width: 100%;
501
+ max-width: var(--lg-sheet-max-width);
502
+ max-height: 80dvh;
503
+ margin: auto;
504
+ padding: 0;
505
+ border: 0;
506
+ overflow: hidden;
507
+ border-radius: var(--lg-radius-xl);
508
+ color: rgb(var(--lg-c-ink));
509
+ background-color: var(--lg-sheet-fill, rgb(var(--lg-c-paper)));
510
+ box-shadow:
511
+ inset 0 0 0 1px rgb(var(--lg-c-line) / 0.1),
512
+ var(--lg-shadow-lg);
513
+ overscroll-behavior: contain;
514
+ }
515
+
516
+ dialog.glass-dialog[open] {
517
+ display: flex;
518
+ flex-direction: column;
519
+ }
520
+
521
+ dialog.glass-dialog:focus {
522
+ outline: none;
523
+ }
524
+
525
+ dialog.glass-dialog::backdrop {
526
+ background-color: var(--lg-scrim);
527
+ overflow: hidden;
528
+ overscroll-behavior: contain;
529
+ /* Both ways: out on a swipe-close, back in if the sheet comes back. No effect on open,
530
+ where the backdrop is new and has nothing to transition from. */
531
+ transition: background-color var(--lg-duration-fast) var(--lg-ease-out);
532
+ }
533
+
534
+ /* Set by the swipe hook from release until the sheet has closed. iOS Safari can leave a
535
+ closed dialog's backdrop painted, so it must already be clear when the close happens. */
536
+ dialog.glass-dialog[data-closing]::backdrop {
537
+ background-color: transparent;
538
+ }
539
+
540
+ .glass-dialog-grabber {
541
+ display: none;
542
+ }
543
+
544
+ .glass-dialog-header {
545
+ display: flex;
546
+ flex-shrink: 0;
547
+ align-items: flex-start;
548
+ gap: 0.75rem;
549
+ padding: 1rem 1.5rem;
550
+ border-bottom: 1px solid rgb(var(--lg-c-line) / 0.08);
551
+ }
552
+
553
+ .glass-dialog-heading {
554
+ min-width: 0;
555
+ flex: 1 1 auto;
556
+ }
557
+
558
+ .glass-dialog-eyebrow {
559
+ margin: 0;
560
+ font-size: 13px;
561
+ line-height: 1rem;
562
+ color: rgb(var(--lg-c-ink-2));
563
+ }
564
+
565
+ .glass-dialog-title {
566
+ margin: 0.25rem 0 0;
567
+ font-size: 1.25rem;
568
+ line-height: 1.75rem;
569
+ font-weight: 600;
570
+ color: rgb(var(--lg-c-ink));
571
+ }
572
+
573
+ .glass-dialog-close {
574
+ display: flex;
575
+ flex-shrink: 0;
576
+ align-items: center;
577
+ justify-content: center;
578
+ width: 44px;
579
+ height: 44px;
580
+ padding: 0;
581
+ border: 0;
582
+ border-radius: 9999px;
583
+ color: rgb(var(--lg-c-ink-2));
584
+ background-color: rgb(var(--lg-c-line) / 0.05);
585
+ cursor: pointer;
586
+ transition: background-color var(--lg-duration-fast) ease;
587
+ }
588
+
589
+ .glass-dialog-close:hover {
590
+ background-color: rgb(var(--lg-c-line) / 0.1);
591
+ }
592
+
593
+ .glass-dialog-close:focus-visible {
594
+ outline: 2px solid var(--lg-accent, var(--color-primary, #0a84ff));
595
+ outline-offset: 2px;
596
+ }
597
+
598
+ /* flex-auto, not flex-1: Safari resolves a 0% basis to zero in this auto-height column
599
+ dialog and collapses the body (WebKit bug 281973). */
600
+ .glass-dialog-body {
601
+ min-height: 0;
602
+ flex: 1 1 auto;
603
+ overflow-y: auto;
604
+ overscroll-behavior: contain;
605
+ padding: 1.25rem 1.5rem;
606
+ }
607
+
608
+ .glass-dialog-footer {
609
+ flex-shrink: 0;
610
+ padding: 1rem 1.5rem;
611
+ border-top: 1px solid rgb(var(--lg-c-line) / 0.08);
612
+ }
613
+
614
+ @media (max-width: 639.98px) {
615
+ dialog.glass-dialog[open] {
616
+ max-width: none;
617
+ max-height: var(--lg-sheet-max-height);
618
+ margin: auto 0 0;
619
+ border-radius: var(--lg-radius-sheet) var(--lg-radius-sheet) 0 0;
620
+ /* Slides up on open. A keyframe animation, not a transition from @starting-style:
621
+ iOS Safari could leave that transition stuck part way. */
622
+ animation: lg-dialog-up 0.28s var(--lg-ease-out);
623
+ }
624
+
625
+ /* The grabber: a visible hint that the sheet can be pulled down. */
626
+ .glass-dialog-grabber {
627
+ display: block;
628
+ flex-shrink: 0;
629
+ padding: 6px 0 0;
630
+ touch-action: none;
631
+ }
632
+
633
+ .glass-dialog-grabber::after {
634
+ content: '';
635
+ display: block;
636
+ width: 36px;
637
+ height: 5px;
638
+ margin: 0 auto;
639
+ border-radius: 9999px;
640
+ background-color: rgb(var(--lg-c-line) / 0.2);
641
+ }
642
+
643
+ .glass-dialog-header {
644
+ padding-top: 0.5rem;
645
+ }
646
+
647
+ /* Like a native sheet: no ✕ on phones. A pull down or a tap outside closes it. The
648
+ button stays for screen readers, and shows when the keyboard focuses it. */
649
+ .glass-dialog-close:not(:focus-visible) {
650
+ position: absolute;
651
+ width: 1px;
652
+ height: 1px;
653
+ margin: -1px;
654
+ padding: 0;
655
+ overflow: hidden;
656
+ clip-path: inset(50%);
657
+ white-space: nowrap;
658
+ }
659
+
660
+ /* Clear the home indicator under the last line. */
661
+ .glass-dialog-body:last-child,
662
+ .glass-dialog-footer {
663
+ padding-bottom: max(env(safe-area-inset-bottom), 20px);
664
+ }
665
+ }
666
+
667
+ /* While a finger drags the sheet, it follows exactly (no easing). The hook switches the
668
+ open animation off inline, and keeps it off until the sheet closes. */
669
+ dialog.glass-dialog[data-dragging] {
670
+ transition: none;
671
+ user-select: none;
672
+ }
673
+
674
+ /* ── Keyframes ──────────────────────────────────────────────────────── */
675
+ /* Pop-ins animate transform only: an element with opacity < 1 can't sample its
676
+ backdrop in Chromium, so fading would show unblurred content until it settles. */
677
+ @keyframes lg-pop {
678
+ from {
679
+ transform: scale(0.92) translateY(-6px);
680
+ }
681
+ to {
682
+ transform: scale(1) translateY(0);
683
+ }
684
+ }
685
+
686
+ @keyframes lg-sheet-in {
687
+ from {
688
+ transform: scale(0.94) translateY(12px);
689
+ }
690
+ to {
691
+ transform: scale(1) translateY(0);
692
+ }
693
+ }
694
+
695
+ @keyframes lg-dialog-up {
696
+ from {
697
+ transform: translateY(100%);
698
+ }
699
+ }
700
+
701
+ @keyframes lg-scrim-in {
702
+ from {
703
+ background-color: transparent;
704
+ }
705
+ }
706
+
707
+ /* ── Reduced motion (last, so it wins over everything above) ────────── */
708
+ @media (prefers-reduced-motion: reduce) {
709
+ .glass-btn,
710
+ .glass-interactive,
711
+ .glass-lift,
712
+ .glass-menu,
713
+ .glass-menu-item,
714
+ .glass-sheet,
715
+ .glass-scrim,
716
+ dialog.glass-dialog[open],
717
+ dialog.glass-dialog::backdrop {
718
+ animation: none;
719
+ transition: none;
720
+ }
721
+
722
+ :is(.glass-interactive, .glass-btn):active,
723
+ .glass-menu-item:active,
724
+ .glass-lift:hover {
725
+ transform: none;
726
+ }
727
+ }
@@ -93,7 +93,13 @@ declare function shouldClose({ offset, height, velocity }: ReleaseState): boolea
93
93
  interface SwipeToCloseOptions {
94
94
  /** Turn the gesture on or off (e.g. only while open, only in the bottom-sheet layout). */
95
95
  enabled: boolean;
96
- /** The scrolling part of the sheet. A press there drags only while it is scrolled to the top. */
96
+ /**
97
+ * Optional. The scrolling areas under the finger are found by themselves: every element
98
+ * from the press up to the sheet (itself included) with `overflow-y` auto, scroll or
99
+ * overlay and more content than fits. A press inside one drags only while all of them are
100
+ * scrolled to the top. Pass a scroller here only when that test misses it, e.g. one with
101
+ * `overflow-y: hidden` that a script scrolls; it then counts whenever it holds the press.
102
+ */
97
103
  scrollRef?: RefObject<HTMLElement | null>;
98
104
  /**
99
105
  * Called once the sheet has slid away. The sheet stays off-screen until `enabled` turns
@@ -113,10 +119,18 @@ interface SwipeToCloseOptions {
113
119
  * follows the finger via an inline transform and either slides away (then `onClose`) or
114
120
  * settles back.
115
121
  *
122
+ * The scrolling areas need no wiring: at each press the hook walks from the element under
123
+ * the finger up to the sheet and takes every element a person can scroll vertically. If any
124
+ * of them is scrolled down, the gesture is theirs (a pull down scrolls back up) and no drag
125
+ * starts. A sideways scroller does not block a drag (only vertical scrolling counts), and a
126
+ * sideways move lets go of one. Outside every vertical scroller the page is held (below),
127
+ * which stops a sideways scroller there too: mark it `data-glass-no-drag`.
128
+ *
116
129
  * iOS Safari decides at the first touchmove of a gesture whether the page pans, and later
117
130
  * moves can no longer stop it. So wherever nothing in the sheet would scroll for that touch
118
- * (the header, grabber and backdrop, a downward pull at the top of the body, a body with
119
- * nothing to scroll), touchmoves are cancelled from the first one; taps still click.
131
+ * (outside every scroller, such as the header, grabber and backdrop; a downward pull at the
132
+ * top of a scroller; a scroller with nothing to scroll), touchmoves are cancelled from the
133
+ * first one; taps still click.
120
134
  *
121
135
  * After a slide-away the inline transform is kept until the effect is torn down (the owner
122
136
  * closed the sheet and `enabled` turned false). Clearing it earlier would show the sheet at
@@ -197,6 +197,9 @@ function shouldClose({ offset, height, velocity }) {
197
197
  return velocity >= CLOSE_VELOCITY && offset >= MIN_FLICK_PX;
198
198
  }
199
199
  var INTERACTIVE = 'button, a[href], input, select, textarea, label, summary, [contenteditable=""], [contenteditable="true"], [role="button"], [role="slider"], [data-glass-no-drag]';
200
+ var SCROLLING_OVERFLOW = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
201
+ var scrollsVertically = (el) => el.scrollHeight > el.clientHeight && SCROLLING_OVERFLOW.has(getComputedStyle(el).overflowY);
202
+ var anyCanScroll = (scrollers) => scrollers.some((el) => el.scrollHeight > el.clientHeight);
200
203
  var runs = /* @__PURE__ */ new WeakMap();
201
204
  var prefersReducedMotion = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
202
205
  function useSwipeToClose(sheetRef, { enabled, scrollRef, onClose, media = "(max-width: 639.98px)" }) {
@@ -243,13 +246,23 @@ function useSwipeToClose(sheetRef, { enabled, scrollRef, onClose, media = "(max-
243
246
  }
244
247
  }
245
248
  };
249
+ const scrollersUnder = (target) => {
250
+ const found = [];
251
+ for (let el = target; el; el = el.parentElement) {
252
+ if (scrollsVertically(el)) found.push(el);
253
+ if (el === sheet) break;
254
+ }
255
+ const given = scrollRef?.current;
256
+ if (given?.contains(target) && !found.includes(given)) found.push(given);
257
+ return found;
258
+ };
246
259
  const begin = (id, x, y, target) => {
247
260
  if (drag || closing || !applies()) return;
248
261
  const el = target instanceof Element ? target : null;
249
262
  if (!el || !sheet.contains(el) || el.closest(INTERACTIVE)) return;
250
- const scroller = scrollRef?.current;
251
- if (scroller && scroller.contains(el) && scroller.scrollTop > 0) return;
252
- if (scroller?.contains(el) && window.getSelection()?.isCollapsed === false) return;
263
+ const scrollers = scrollersUnder(el);
264
+ if (scrollers.some((s) => s.scrollTop > 0)) return;
265
+ if (scrollers.length > 0 && window.getSelection()?.isCollapsed === false) return;
253
266
  clearTimer();
254
267
  drag = {
255
268
  pointerId: id,
@@ -258,7 +271,8 @@ function useSwipeToClose(sheetRef, { enabled, scrollRef, onClose, media = "(max-
258
271
  lastY: y,
259
272
  lastT: performance.now(),
260
273
  velocity: 0,
261
- active: null
274
+ active: null,
275
+ scrollers
262
276
  };
263
277
  };
264
278
  const move = (x, y) => {
@@ -313,29 +327,24 @@ function useSwipeToClose(sheetRef, { enabled, scrollRef, onClose, media = "(max-
313
327
  drag = null;
314
328
  if (wasActive) resetStyles();
315
329
  };
316
- const bodyCannotScroll = () => {
317
- const scroller = scrollRef?.current;
318
- return !scroller || scroller.scrollHeight <= scroller.clientHeight;
319
- };
320
330
  const onTouchStart = (e) => {
321
331
  holdPage = false;
322
332
  const t = e.touches[0];
323
333
  if (e.touches.length !== 1 || !t) return cancel();
324
334
  begin("touch", t.clientX, t.clientY, e.target);
325
- const scroller = scrollRef?.current;
326
- const inBody = !!scroller && e.target instanceof Node && scroller.contains(e.target);
327
- holdPage = drag?.pointerId === "touch" && (!inBody || bodyCannotScroll());
335
+ holdPage = drag?.pointerId === "touch" && !anyCanScroll(drag.scrollers);
328
336
  };
329
337
  const onTouchMove = (e) => {
330
338
  const t = e.touches[0];
331
339
  let stopPan = holdPage;
332
340
  if (t && drag?.pointerId === "touch") {
333
- const pulledDown = t.clientY > drag.startY;
341
+ const { startY, scrollers } = drag;
342
+ const pulledDown = t.clientY > startY;
334
343
  if (move(t.clientX, t.clientY)) {
335
344
  stopPan = true;
336
345
  } else if (drag) {
337
346
  stopPan ||= pulledDown;
338
- } else if (bodyCannotScroll()) {
347
+ } else if (!anyCanScroll(scrollers)) {
339
348
  holdPage = true;
340
349
  stopPan = true;
341
350
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/Glass.tsx","../../src/react/cx.ts","../../src/react/GlassButton.tsx","../../src/react/GlassFilter.tsx","../../src/react/GlassSheet.tsx","../../src/react/swipe.ts"],"sourcesContent":["import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementType,\n type ForwardedRef,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react';\nimport { cx } from './cx';\n\nexport type GlassTone = 'light' | 'dark' | 'clear' | 'tinted' | 'tinted-secondary' | 'danger';\nexport type GlassThickness = 'thin' | 'regular' | 'thick';\nexport type GlassShape = 'sm' | 'md' | 'lg' | 'xl' | 'pill';\n\nconst TONE_CLASS: Record<GlassTone, string | undefined> = {\n light: undefined,\n dark: 'glass-dark',\n clear: 'glass-clear',\n tinted: 'glass-tinted',\n 'tinted-secondary': 'glass-tinted-secondary',\n danger: 'glass-danger',\n};\n\nconst THICKNESS_CLASS: Record<GlassThickness, string | undefined> = {\n thin: 'glass-thin',\n regular: undefined,\n thick: 'glass-thick',\n};\n\nconst SHAPE_CLASS: Record<GlassShape, string | undefined> = {\n sm: 'glass-sm',\n md: undefined,\n lg: 'glass-lg',\n xl: 'glass-xl',\n pill: 'glass-pill',\n};\n\nexport interface GlassOptions {\n tone?: GlassTone;\n thickness?: GlassThickness;\n shape?: GlassShape;\n /** Hover fill, press-scale and focus ring. Use for clickable surfaces. */\n interactive?: boolean;\n /** Float upward on hover. Use for cards. */\n lift?: boolean;\n /** Chromium-only SVG refraction (no-op elsewhere). Needs <GlassFilter /> mounted once. */\n refract?: boolean;\n}\n\n/** The class list for a glass surface, for elements you can't swap for <Glass>. */\nexport function glassClasses({\n tone = 'light',\n thickness = 'regular',\n shape = 'md',\n interactive = false,\n lift = false,\n refract = false,\n}: GlassOptions = {}): string {\n return cx(\n 'glass',\n TONE_CLASS[tone],\n THICKNESS_CLASS[thickness],\n SHAPE_CLASS[shape],\n interactive && 'glass-interactive',\n lift && 'glass-lift',\n refract && 'glass-refract',\n );\n}\n\nexport type GlassProps<T extends ElementType = 'div'> = GlassOptions & {\n as?: T;\n className?: string;\n children?: ReactNode;\n} & Omit<ComponentPropsWithoutRef<T>, keyof GlassOptions | 'as' | 'className' | 'children'>;\n\nfunction GlassInner<T extends ElementType = 'div'>(\n {\n as,\n tone,\n thickness,\n shape,\n interactive,\n lift,\n refract,\n className,\n children,\n ...rest\n }: GlassProps<T>,\n ref: ForwardedRef<Element>,\n) {\n const Component: ElementType = as ?? 'div';\n return (\n <Component\n ref={ref}\n className={cx(\n glassClasses({ tone, thickness, shape, interactive, lift, refract }),\n className,\n )}\n {...rest}\n >\n {children}\n </Component>\n );\n}\n\n/** A Liquid Glass surface. Polymorphic: `<Glass as=\"nav\" tone=\"dark\" shape=\"pill\">`. */\nexport const Glass = forwardRef(GlassInner) as <T extends ElementType = 'div'>(\n props: GlassProps<T> & { ref?: Ref<Element> },\n) => ReactElement | null;\n","/** Join class names, skipping falsy values. */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(' ');\n}\n","import { forwardRef, type ButtonHTMLAttributes } from 'react';\nimport { cx } from './cx';\n\nexport type GlassButtonVariant = 'glass' | 'dark' | 'clear' | 'primary' | 'secondary' | 'danger';\nexport type GlassButtonSize = 'sm' | 'md' | 'lg';\n\nconst VARIANT_CLASS: Record<GlassButtonVariant, string | undefined> = {\n glass: undefined,\n dark: 'glass-dark',\n clear: 'glass-clear',\n primary: 'glass-tinted',\n secondary: 'glass-tinted-secondary',\n danger: 'glass-danger',\n};\n\nconst SIZE_CLASS: Record<GlassButtonSize, string | undefined> = {\n sm: 'glass-btn-sm',\n md: undefined,\n lg: 'glass-btn-lg',\n};\n\nexport interface GlassButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: GlassButtonVariant;\n size?: GlassButtonSize;\n /** Stretch to the container width. */\n block?: boolean;\n}\n\n/** A glass button with a 44px touch target. Defaults to `type=\"button\"`. */\nexport const GlassButton = forwardRef<HTMLButtonElement, GlassButtonProps>(function GlassButton(\n { variant = 'glass', size = 'md', block = false, className, type = 'button', ...rest },\n ref,\n) {\n return (\n <button\n ref={ref}\n type={type}\n className={cx(\n 'glass-btn',\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n block && 'glass-block',\n className,\n )}\n {...rest}\n />\n );\n});\n","import { useEffect } from 'react';\n\n/**\n * True when the browser renders SVG filters inside `backdrop-filter`\n * (currently Chromium only). Safari and Firefox accept the syntax but either\n * ignore it or drop the whole backdrop, so we gate on the engine instead.\n */\nexport function supportsBackdropRefraction(): boolean {\n if (typeof navigator === 'undefined' || typeof CSS === 'undefined') return false;\n const uaData = (navigator as Navigator & { userAgentData?: { brands?: { brand: string }[] } })\n .userAgentData;\n const isChromium = !!uaData?.brands?.some((b) => b.brand === 'Chromium');\n return isChromium && CSS.supports('backdrop-filter', 'url(#lg-refract)');\n}\n\n/**\n * Mount once near the app root. Provides the `#lg-refract` displacement filter\n * used by `.glass-refract` and flags support on <html data-lg-refract>.\n */\nexport function GlassFilter() {\n useEffect(() => {\n if (!supportsBackdropRefraction()) return;\n const root = document.documentElement;\n root.setAttribute('data-lg-refract', '');\n return () => {\n root.removeAttribute('data-lg-refract');\n };\n }, []);\n\n return (\n <svg\n aria-hidden=\"true\"\n focusable=\"false\"\n width=\"0\"\n height=\"0\"\n style={{ position: 'absolute', width: 0, height: 0, overflow: 'hidden' }}\n >\n <filter\n id=\"lg-refract\"\n x=\"0\"\n y=\"0\"\n width=\"100%\"\n height=\"100%\"\n colorInterpolationFilters=\"sRGB\"\n >\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.008 0.012\"\n numOctaves=\"2\"\n seed=\"7\"\n result=\"noise\"\n />\n <feGaussianBlur in=\"noise\" stdDeviation=\"2\" result=\"softNoise\" />\n <feDisplacementMap\n in=\"SourceGraphic\"\n in2=\"softNoise\"\n scale=\"18\"\n xChannelSelector=\"R\"\n yChannelSelector=\"G\"\n />\n </filter>\n </svg>\n );\n}\n","import {\n useEffect,\n useId,\n useRef,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n} from 'react';\nimport { cx } from './cx';\nimport { useSwipeToClose } from './swipe';\n\nexport interface GlassSheetProps {\n open: boolean;\n /** Called when the person closes it: the close button, a swipe down, Esc or a tap outside. */\n onClose: () => void;\n /** Names the dialog (aria-labelledby). */\n title: ReactNode;\n /** Small line above the title, e.g. \"About event\". */\n eyebrow?: ReactNode;\n /** Accessible name of the close button. Translate it. */\n closeLabel?: string;\n /** Pull down to close in the phone (bottom sheet) layout. Default true. */\n swipeToClose?: boolean;\n /** Content pinned under the scrolling body, e.g. actions. */\n footer?: ReactNode;\n children?: ReactNode;\n className?: string;\n bodyClassName?: string;\n}\n\n/** Light dismiss is native where `closedby` is supported; elsewhere it is done below. */\nconst needsLightDismissFallback = () =>\n typeof HTMLDialogElement !== 'undefined' && !('closedBy' in HTMLDialogElement.prototype);\n\nconst isOutside = (e: ReactMouseEvent<HTMLDialogElement>) => {\n const r = e.currentTarget.getBoundingClientRect();\n return e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom;\n};\n\nfunction CloseIcon() {\n return (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M6 18 18 6M6 6l12 12\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\n/**\n * A modal sheet on a native <dialog>: the browser makes the page inert, keeps focus inside,\n * closes on Esc and returns focus to the opener. Centred from 640px up; on phones a bottom\n * sheet with a grabber that can be pulled down to close. On phones the ✕ is hidden, like a\n * native sheet: a tap outside is the single-tap alternative to the swipe (WCAG 2.5.1 and\n * 2.5.7), and the button stays for screen readers and keyboards.\n *\n * Opening focuses the dialog itself rather than the close button, so screen readers start\n * at the title and no focus ring flashes on the ✕ for touch users.\n */\nexport function GlassSheet({\n open,\n onClose,\n title,\n eyebrow,\n closeLabel = 'Close',\n swipeToClose = true,\n footer,\n children,\n className,\n bodyClassName,\n}: GlassSheetProps) {\n const dialogRef = useRef<HTMLDialogElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\n const titleId = useId();\n const pressedOutside = useRef(false);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog || open === dialog.hasAttribute('open')) return;\n // Feature-checked: older engines and jsdom lack showModal/close.\n if (open) {\n if (typeof dialog.showModal === 'function') dialog.showModal();\n else dialog.setAttribute('open', '');\n dialog.focus({ preventScroll: true });\n if (bodyRef.current) bodyRef.current.scrollTop = 0;\n } else if (typeof dialog.close === 'function') {\n dialog.close();\n } else {\n dialog.removeAttribute('open');\n }\n }, [open]);\n\n useSwipeToClose(dialogRef, { enabled: open && swipeToClose, scrollRef: bodyRef, onClose });\n\n return (\n <dialog\n ref={dialogRef}\n // Not yet in React's types; React passes it through as an attribute.\n {...{ closedby: 'any' }}\n tabIndex={-1}\n aria-labelledby={titleId}\n // Esc or light dismiss closed it; when `open` is already false the page closed it.\n onClose={() => {\n if (open) onClose();\n }}\n // Without `closedby`: close only when both the press and the release are outside the\n // box, so a text selection dragged onto the backdrop does not dismiss.\n onPointerDown={(e) => {\n pressedOutside.current = needsLightDismissFallback() && isOutside(e);\n }}\n onPointerUp={(e) => {\n if (pressedOutside.current && isOutside(e)) onClose();\n pressedOutside.current = false;\n }}\n className={cx('glass-dialog', className)}\n >\n {swipeToClose && <div className=\"glass-dialog-grabber\" aria-hidden=\"true\" />}\n <header className=\"glass-dialog-header\">\n <div className=\"glass-dialog-heading\">\n {eyebrow && <p className=\"glass-dialog-eyebrow\">{eyebrow}</p>}\n <h2 id={titleId} className=\"glass-dialog-title\">\n {title}\n </h2>\n </div>\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={closeLabel}\n className=\"glass-dialog-close\"\n >\n <CloseIcon />\n </button>\n </header>\n <div ref={bodyRef} className={cx('glass-dialog-body', bodyClassName)}>\n {children}\n </div>\n {footer && <div className=\"glass-dialog-footer\">{footer}</div>}\n </dialog>\n );\n}\n","import { useEffect, useRef, type RefObject } from 'react';\n\n/** Movement (px) before a press counts as a drag, so taps and small jitters stay taps. */\nexport const DRAG_SLOP_PX = 8;\n/** Pull further than this share of the sheet's height and it closes on release. */\nexport const CLOSE_DISTANCE_RATIO = 0.25;\n/** Or flick downward at least this fast (px per ms), however short the pull. */\nexport const CLOSE_VELOCITY = 0.5;\n/** A flick only counts once the sheet has moved this far, so a twitch doesn't close it. */\nexport const MIN_FLICK_PX = 24;\n/** How long the sheet takes to slide away or settle back (ms). */\nexport const SETTLE_MS = 220;\n/**\n * How long after release the owner is asked to close (ms): the slide-away plus a margin, so\n * the transition has really finished. Closing a dialog while its transform is still moving\n * is one more thing iOS Safari may get wrong.\n */\nexport const SLIDE_AWAY_MS = SETTLE_MS + 60;\n/**\n * After `onClose`, how long the sheet waits off-screen for its owner to close it (ms). If it\n * is still open by then (the owner kept it, e.g. to ask \"discard changes?\"), it comes back.\n */\nexport const REOPEN_AFTER_MS = 250;\n\nconst SETTLE_EASE = 'cubic-bezier(0.22, 1, 0.36, 1)';\n\nexport interface ReleaseState {\n /** How far the sheet is pulled down (px). */\n offset: number;\n /** The sheet's height (px). */\n height: number;\n /** Downward speed at release (px per ms; negative means moving up). */\n velocity: number;\n}\n\n/** Whether a released drag should close the sheet or let it settle back. */\nexport function shouldClose({ offset, height, velocity }: ReleaseState): boolean {\n if (offset <= 0) return false;\n if (height > 0 && offset >= height * CLOSE_DISTANCE_RATIO) return true;\n return velocity >= CLOSE_VELOCITY && offset >= MIN_FLICK_PX;\n}\n\n/** Controls a press should leave alone: a drag starting on one would steal its tap. */\nconst INTERACTIVE =\n 'button, a[href], input, select, textarea, label, summary, [contenteditable=\"\"], [contenteditable=\"true\"], [role=\"button\"], [role=\"slider\"], [data-glass-no-drag]';\n\n/** Counts the hook runs per sheet, so a late tidy-up never touches a sheet that is in use again. */\nconst runs = new WeakMap<HTMLElement, number>();\n\nconst prefersReducedMotion = () =>\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n\nexport interface SwipeToCloseOptions {\n /** Turn the gesture on or off (e.g. only while open, only in the bottom-sheet layout). */\n enabled: boolean;\n /** The scrolling part of the sheet. A press there drags only while it is scrolled to the top. */\n scrollRef?: RefObject<HTMLElement | null>;\n /**\n * Called once the sheet has slid away. The sheet stays off-screen until `enabled` turns\n * false; if that has not happened `REOPEN_AFTER_MS` later, it slides back.\n *\n * From release until the sheet is closed and tidied up (or comes back) it carries\n * `data-closing`. Style the backdrop with it, so the dim is gone before the close.\n */\n onClose: () => void;\n /** Media query for when the gesture applies. Default: the phone bottom-sheet layout. */\n media?: string;\n}\n\ninterface Drag {\n pointerId: number | 'touch';\n startX: number;\n startY: number;\n lastY: number;\n lastT: number;\n velocity: number;\n /** Null until the press has moved past the slop and we know whether it is our drag. */\n active: boolean | null;\n}\n\n/**\n * Pull-down-to-close for a sheet. Touch uses touch events, because a pointer-events drag\n * over scrollable content is cancelled by the browser as soon as it starts to pan; with\n * a non-passive touchmove we can stop that pan. Mouse and pen use pointer events. The sheet\n * follows the finger via an inline transform and either slides away (then `onClose`) or\n * settles back.\n *\n * iOS Safari decides at the first touchmove of a gesture whether the page pans, and later\n * moves can no longer stop it. So wherever nothing in the sheet would scroll for that touch\n * (the header, grabber and backdrop, a downward pull at the top of the body, a body with\n * nothing to scroll), touchmoves are cancelled from the first one; taps still click.\n *\n * After a slide-away the inline transform is kept until the effect is torn down (the owner\n * closed the sheet and `enabled` turned false). Clearing it earlier would show the sheet at\n * rest for a frame before the close is committed.\n *\n * From release until the sheet is closed and tidied up, or comes back, the sheet has the\n * attribute `data-closing`. Fade the backdrop out with it (`[data-closing]::backdrop`): iOS\n * Safari can leave a dialog's backdrop painted after it closes, so it must be clear by then.\n */\nexport function useSwipeToClose(\n sheetRef: RefObject<HTMLElement | null>,\n { enabled, scrollRef, onClose, media = '(max-width: 639.98px)' }: SwipeToCloseOptions,\n): void {\n const onCloseRef = useRef(onClose);\n onCloseRef.current = onClose;\n\n useEffect(() => {\n const sheet = sheetRef.current;\n if (!enabled || !sheet) return;\n\n let drag: Drag | null = null;\n // Cancel every touchmove until this touch ends: nothing under it scrolls, so a pan would\n // move the page behind the dialog. Cleared on touchstart, touchend and touchcancel.\n let holdPage = false;\n let suppressClick = false;\n // False once the effect is torn down, so nothing is scheduled on a sheet we let go of.\n let alive = true;\n // True from release until the owner closes the sheet or it comes back.\n let closing = false;\n // The release phases (slide away, wait for the owner, settle back) run one after\n // another, so a single timer handle covers them.\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const clearTimer = () => {\n clearTimeout(timer);\n timer = undefined;\n };\n\n const applies = () =>\n typeof window.matchMedia !== 'function' || window.matchMedia(media).matches;\n\n const resetStyles = () => {\n sheet.style.transform = '';\n sheet.style.transition = '';\n sheet.removeAttribute('data-dragging');\n sheet.removeAttribute('data-closing');\n };\n\n // Start clean: an earlier run may have left its inline styles (see the cleanup).\n runs.set(sheet, (runs.get(sheet) ?? 0) + 1);\n resetStyles();\n sheet.style.animation = '';\n\n /** Animate back to rest, then drop the inline styles. */\n const settleBack = () => {\n // Now, not once it has settled: the backdrop fades back in while the sheet slides up.\n sheet.removeAttribute('data-closing');\n sheet.style.transition = `transform ${SETTLE_MS}ms ${SETTLE_EASE}`;\n sheet.style.transform = '';\n // A timer, not transitionend: that event never fires if nothing moved or the tab hid.\n timer = setTimeout(resetStyles, SETTLE_MS);\n };\n\n /**\n * Ask the owner to close, leaving the sheet where it is. The effect cleanup clears the\n * styles once the sheet really closes; if it is still open after REOPEN_AFTER_MS,\n * `comeBack` runs.\n */\n const requestClose = (comeBack: () => void) => {\n try {\n onCloseRef.current();\n } finally {\n // The owner may have closed the sheet synchronously, tearing this effect down.\n if (alive) {\n timer = setTimeout(() => {\n closing = false;\n comeBack();\n }, REOPEN_AFTER_MS);\n }\n }\n };\n\n const begin = (id: Drag['pointerId'], x: number, y: number, target: EventTarget | null) => {\n // While closing, the sheet is sliding away or waiting for its owner: leave it be.\n if (drag || closing || !applies()) return;\n const el = target instanceof Element ? target : null;\n if (!el || !sheet.contains(el) || el.closest(INTERACTIVE)) return;\n const scroller = scrollRef?.current;\n if (scroller && scroller.contains(el) && scroller.scrollTop > 0) return;\n // Text selected inside the body: the press is probably adjusting it.\n if (scroller?.contains(el) && window.getSelection()?.isCollapsed === false) return;\n clearTimer();\n drag = {\n pointerId: id,\n startX: x,\n startY: y,\n lastY: y,\n lastT: performance.now(),\n velocity: 0,\n active: null,\n };\n };\n\n /** Returns true while the move belongs to the drag (so the caller can stop scrolling). */\n const move = (x: number, y: number): boolean => {\n if (!drag) return false;\n const dy = y - drag.startY;\n const dx = x - drag.startX;\n if (drag.active === null) {\n if (Math.abs(dy) < DRAG_SLOP_PX && Math.abs(dx) < DRAG_SLOP_PX) return false;\n // Upward or sideways: a scroll or a swipe for something else. Let it go.\n if (dy <= 0 || Math.abs(dx) > Math.abs(dy)) {\n drag = null;\n return false;\n }\n drag.active = true;\n sheet.setAttribute('data-dragging', '');\n sheet.style.transition = 'none';\n // Off until the sheet closes (see cleanup). An open animation with a fill mode would\n // override the inline transform, and switching it off only for the drag would replay\n // it on release.\n sheet.style.animation = 'none';\n }\n const now = performance.now();\n const dt = now - drag.lastT;\n if (dt > 0) drag.velocity = (y - drag.lastY) / dt;\n drag.lastY = y;\n drag.lastT = now;\n sheet.style.transform = `translate3d(0, ${Math.max(0, dy - DRAG_SLOP_PX)}px, 0)`;\n return true;\n };\n\n const end = () => {\n if (!drag) return;\n const wasActive = drag.active === true;\n const wasTouch = drag.pointerId === 'touch';\n const offset = Math.max(0, drag.lastY - drag.startY - DRAG_SLOP_PX);\n // A long pause before letting go means the flick is over.\n const velocity = performance.now() - drag.lastT > 100 ? 0 : drag.velocity;\n drag = null;\n if (!wasActive) return;\n // Only a mouse or pen drag ends in a click to swallow. A touch drag does not, and the\n // flag would then eat the next real activation (e.g. from a screen reader).\n suppressClick = !wasTouch;\n sheet.removeAttribute('data-dragging');\n\n const close = shouldClose({ offset, height: sheet.getBoundingClientRect().height, velocity });\n const reduceMotion = prefersReducedMotion();\n if (!close) {\n if (reduceMotion) resetStyles();\n else settleBack();\n return;\n }\n closing = true;\n // The backdrop fades out from now, so nothing dark is left to repaint at the close.\n sheet.setAttribute('data-closing', '');\n // Reduced motion: no slide, the sheet goes at once. The close still waits, so it never\n // lands in the frame the backdrop changes.\n sheet.style.transition = reduceMotion ? 'none' : `transform ${SETTLE_MS}ms ${SETTLE_EASE}`;\n sheet.style.transform = 'translate3d(0, 100%, 0)';\n // A timer, not transitionend: that event never fires if nothing moved or the tab hid.\n const comeBack = reduceMotion ? resetStyles : settleBack;\n timer = setTimeout(() => requestClose(comeBack), SLIDE_AWAY_MS);\n };\n\n const cancel = () => {\n const wasActive = drag?.active === true;\n drag = null;\n if (wasActive) resetStyles();\n };\n\n /** Whether the body has nothing to scroll, so a pan in it would chain to the page. */\n const bodyCannotScroll = () => {\n const scroller = scrollRef?.current;\n return !scroller || scroller.scrollHeight <= scroller.clientHeight;\n };\n\n // Touch\n const onTouchStart = (e: TouchEvent) => {\n holdPage = false;\n const t = e.touches[0];\n if (e.touches.length !== 1 || !t) return cancel();\n begin('touch', t.clientX, t.clientY, e.target);\n // Outside the body (header, grabber, footer, the backdrop) nothing scrolls natively;\n // nor does a body whose content fits. Hold from the start: the first move decides.\n const scroller = scrollRef?.current;\n const inBody = !!scroller && e.target instanceof Node && scroller.contains(e.target);\n holdPage = drag?.pointerId === 'touch' && (!inBody || bodyCannotScroll());\n };\n const onTouchMove = (e: TouchEvent) => {\n const t = e.touches[0];\n let stopPan = holdPage;\n if (t && drag?.pointerId === 'touch') {\n const pulledDown = t.clientY > drag.startY;\n if (move(t.clientX, t.clientY)) {\n stopPan = true; // our drag\n } else if (drag) {\n // Within the slop. At the top of the body a pull down has nothing to scroll.\n stopPan ||= pulledDown;\n } else if (bodyCannotScroll()) {\n // Dropped as not ours, and the body has nothing to scroll: keep the page still.\n holdPage = true;\n stopPan = true;\n }\n }\n if (stopPan && e.cancelable) e.preventDefault();\n };\n const onTouchEnd = () => {\n holdPage = false;\n if (drag?.pointerId === 'touch') end();\n };\n const onTouchCancel = () => {\n holdPage = false;\n cancel();\n };\n\n // Mouse and pen (touch is handled above)\n const onPointerDown = (e: PointerEvent) => {\n if (e.pointerType === 'touch' || e.button !== 0) return;\n begin(e.pointerId, e.clientX, e.clientY, e.target);\n };\n const onPointerMove = (e: PointerEvent) => {\n if (drag?.pointerId !== e.pointerId) return;\n if (move(e.clientX, e.clientY)) e.preventDefault();\n };\n const onPointerUp = (e: PointerEvent) => {\n if (drag?.pointerId === e.pointerId) end();\n };\n const onPointerCancel = (e: PointerEvent) => {\n if (drag?.pointerId === e.pointerId) cancel();\n };\n\n // A mouse drag ends with a click on whatever is under it; that click must not count.\n const onClickCapture = (e: MouseEvent) => {\n if (!suppressClick) return;\n suppressClick = false;\n e.preventDefault();\n e.stopPropagation();\n };\n const clearSuppress = () => {\n suppressClick = false;\n };\n\n sheet.addEventListener('touchstart', onTouchStart, { passive: true });\n sheet.addEventListener('touchmove', onTouchMove, { passive: false });\n sheet.addEventListener('touchend', onTouchEnd);\n sheet.addEventListener('touchcancel', onTouchCancel);\n sheet.addEventListener('pointerdown', onPointerDown);\n sheet.addEventListener('click', onClickCapture, true);\n window.addEventListener('pointermove', onPointerMove);\n window.addEventListener('pointerup', onPointerUp);\n window.addEventListener('pointercancel', onPointerCancel);\n window.addEventListener('pointerdown', clearSuppress, true);\n\n return () => {\n alive = false;\n clearTimer();\n // Never change the sheet in the frame it closes: moving it or restarting its open\n // animation together with dialog.close() is the suspected cause of the backdrop staying\n // painted on iOS Safari. Tidy up a moment later (styles and `data-closing`), unless the\n // sheet is in use again.\n const mine = runs.get(sheet);\n setTimeout(() => {\n if (runs.get(sheet) !== mine) return;\n resetStyles();\n sheet.style.animation = '';\n }, SLIDE_AWAY_MS);\n sheet.removeEventListener('touchstart', onTouchStart);\n sheet.removeEventListener('touchmove', onTouchMove);\n sheet.removeEventListener('touchend', onTouchEnd);\n sheet.removeEventListener('touchcancel', onTouchCancel);\n sheet.removeEventListener('pointerdown', onPointerDown);\n sheet.removeEventListener('click', onClickCapture, true);\n window.removeEventListener('pointermove', onPointerMove);\n window.removeEventListener('pointerup', onPointerUp);\n window.removeEventListener('pointercancel', onPointerCancel);\n window.removeEventListener('pointerdown', clearSuppress, true);\n };\n }, [enabled, media, scrollRef, sheetRef]);\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAOK;;;ACPA,SAAS,MAAM,OAAyD;AAC7E,SAAO,MAAM,OAAO,OAAO,EAAE,KAAK,GAAG;AACvC;;;AD0FI;AA9EJ,IAAM,aAAoD;AAAA,EACxD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,oBAAoB;AAAA,EACpB,QAAQ;AACV;AAEA,IAAM,kBAA8D;AAAA,EAClE,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AACT;AAEA,IAAM,cAAsD;AAAA,EAC1D,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AACR;AAeO,SAAS,aAAa;AAAA,EAC3B,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,OAAO;AAAA,EACP,UAAU;AACZ,IAAkB,CAAC,GAAW;AAC5B,SAAO;AAAA,IACL;AAAA,IACA,WAAW,IAAI;AAAA,IACf,gBAAgB,SAAS;AAAA,IACzB,YAA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AAU,uBAAuB,kBAAO;AAAA;AAAA;AAAA,EAC1D;AAEJ;","names":["forwardRef","jsx","forwardRef","GlassButton","jsx","useEffect","useRef","useEffect","jsx","jsxs","useRef","useEffect"]}
1
+ {"version":3,"sources":["../../src/react/Glass.tsx","../../src/react/cx.ts","../../src/react/GlassButton.tsx","../../src/react/GlassFilter.tsx","../../src/react/GlassSheet.tsx","../../src/react/swipe.ts"],"sourcesContent":["import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementType,\n type ForwardedRef,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react';\nimport { cx } from './cx';\n\nexport type GlassTone = 'light' | 'dark' | 'clear' | 'tinted' | 'tinted-secondary' | 'danger';\nexport type GlassThickness = 'thin' | 'regular' | 'thick';\nexport type GlassShape = 'sm' | 'md' | 'lg' | 'xl' | 'pill';\n\nconst TONE_CLASS: Record<GlassTone, string | undefined> = {\n light: undefined,\n dark: 'glass-dark',\n clear: 'glass-clear',\n tinted: 'glass-tinted',\n 'tinted-secondary': 'glass-tinted-secondary',\n danger: 'glass-danger',\n};\n\nconst THICKNESS_CLASS: Record<GlassThickness, string | undefined> = {\n thin: 'glass-thin',\n regular: undefined,\n thick: 'glass-thick',\n};\n\nconst SHAPE_CLASS: Record<GlassShape, string | undefined> = {\n sm: 'glass-sm',\n md: undefined,\n lg: 'glass-lg',\n xl: 'glass-xl',\n pill: 'glass-pill',\n};\n\nexport interface GlassOptions {\n tone?: GlassTone;\n thickness?: GlassThickness;\n shape?: GlassShape;\n /** Hover fill, press-scale and focus ring. Use for clickable surfaces. */\n interactive?: boolean;\n /** Float upward on hover. Use for cards. */\n lift?: boolean;\n /** Chromium-only SVG refraction (no-op elsewhere). Needs <GlassFilter /> mounted once. */\n refract?: boolean;\n}\n\n/** The class list for a glass surface, for elements you can't swap for <Glass>. */\nexport function glassClasses({\n tone = 'light',\n thickness = 'regular',\n shape = 'md',\n interactive = false,\n lift = false,\n refract = false,\n}: GlassOptions = {}): string {\n return cx(\n 'glass',\n TONE_CLASS[tone],\n THICKNESS_CLASS[thickness],\n SHAPE_CLASS[shape],\n interactive && 'glass-interactive',\n lift && 'glass-lift',\n refract && 'glass-refract',\n );\n}\n\nexport type GlassProps<T extends ElementType = 'div'> = GlassOptions & {\n as?: T;\n className?: string;\n children?: ReactNode;\n} & Omit<ComponentPropsWithoutRef<T>, keyof GlassOptions | 'as' | 'className' | 'children'>;\n\nfunction GlassInner<T extends ElementType = 'div'>(\n {\n as,\n tone,\n thickness,\n shape,\n interactive,\n lift,\n refract,\n className,\n children,\n ...rest\n }: GlassProps<T>,\n ref: ForwardedRef<Element>,\n) {\n const Component: ElementType = as ?? 'div';\n return (\n <Component\n ref={ref}\n className={cx(\n glassClasses({ tone, thickness, shape, interactive, lift, refract }),\n className,\n )}\n {...rest}\n >\n {children}\n </Component>\n );\n}\n\n/** A Liquid Glass surface. Polymorphic: `<Glass as=\"nav\" tone=\"dark\" shape=\"pill\">`. */\nexport const Glass = forwardRef(GlassInner) as <T extends ElementType = 'div'>(\n props: GlassProps<T> & { ref?: Ref<Element> },\n) => ReactElement | null;\n","/** Join class names, skipping falsy values. */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(' ');\n}\n","import { forwardRef, type ButtonHTMLAttributes } from 'react';\nimport { cx } from './cx';\n\nexport type GlassButtonVariant = 'glass' | 'dark' | 'clear' | 'primary' | 'secondary' | 'danger';\nexport type GlassButtonSize = 'sm' | 'md' | 'lg';\n\nconst VARIANT_CLASS: Record<GlassButtonVariant, string | undefined> = {\n glass: undefined,\n dark: 'glass-dark',\n clear: 'glass-clear',\n primary: 'glass-tinted',\n secondary: 'glass-tinted-secondary',\n danger: 'glass-danger',\n};\n\nconst SIZE_CLASS: Record<GlassButtonSize, string | undefined> = {\n sm: 'glass-btn-sm',\n md: undefined,\n lg: 'glass-btn-lg',\n};\n\nexport interface GlassButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: GlassButtonVariant;\n size?: GlassButtonSize;\n /** Stretch to the container width. */\n block?: boolean;\n}\n\n/** A glass button with a 44px touch target. Defaults to `type=\"button\"`. */\nexport const GlassButton = forwardRef<HTMLButtonElement, GlassButtonProps>(function GlassButton(\n { variant = 'glass', size = 'md', block = false, className, type = 'button', ...rest },\n ref,\n) {\n return (\n <button\n ref={ref}\n type={type}\n className={cx(\n 'glass-btn',\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n block && 'glass-block',\n className,\n )}\n {...rest}\n />\n );\n});\n","import { useEffect } from 'react';\n\n/**\n * True when the browser renders SVG filters inside `backdrop-filter`\n * (currently Chromium only). Safari and Firefox accept the syntax but either\n * ignore it or drop the whole backdrop, so we gate on the engine instead.\n */\nexport function supportsBackdropRefraction(): boolean {\n if (typeof navigator === 'undefined' || typeof CSS === 'undefined') return false;\n const uaData = (navigator as Navigator & { userAgentData?: { brands?: { brand: string }[] } })\n .userAgentData;\n const isChromium = !!uaData?.brands?.some((b) => b.brand === 'Chromium');\n return isChromium && CSS.supports('backdrop-filter', 'url(#lg-refract)');\n}\n\n/**\n * Mount once near the app root. Provides the `#lg-refract` displacement filter\n * used by `.glass-refract` and flags support on <html data-lg-refract>.\n */\nexport function GlassFilter() {\n useEffect(() => {\n if (!supportsBackdropRefraction()) return;\n const root = document.documentElement;\n root.setAttribute('data-lg-refract', '');\n return () => {\n root.removeAttribute('data-lg-refract');\n };\n }, []);\n\n return (\n <svg\n aria-hidden=\"true\"\n focusable=\"false\"\n width=\"0\"\n height=\"0\"\n style={{ position: 'absolute', width: 0, height: 0, overflow: 'hidden' }}\n >\n <filter\n id=\"lg-refract\"\n x=\"0\"\n y=\"0\"\n width=\"100%\"\n height=\"100%\"\n colorInterpolationFilters=\"sRGB\"\n >\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.008 0.012\"\n numOctaves=\"2\"\n seed=\"7\"\n result=\"noise\"\n />\n <feGaussianBlur in=\"noise\" stdDeviation=\"2\" result=\"softNoise\" />\n <feDisplacementMap\n in=\"SourceGraphic\"\n in2=\"softNoise\"\n scale=\"18\"\n xChannelSelector=\"R\"\n yChannelSelector=\"G\"\n />\n </filter>\n </svg>\n );\n}\n","import {\n useEffect,\n useId,\n useRef,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n} from 'react';\nimport { cx } from './cx';\nimport { useSwipeToClose } from './swipe';\n\nexport interface GlassSheetProps {\n open: boolean;\n /** Called when the person closes it: the close button, a swipe down, Esc or a tap outside. */\n onClose: () => void;\n /** Names the dialog (aria-labelledby). */\n title: ReactNode;\n /** Small line above the title, e.g. \"About event\". */\n eyebrow?: ReactNode;\n /** Accessible name of the close button. Translate it. */\n closeLabel?: string;\n /** Pull down to close in the phone (bottom sheet) layout. Default true. */\n swipeToClose?: boolean;\n /** Content pinned under the scrolling body, e.g. actions. */\n footer?: ReactNode;\n children?: ReactNode;\n className?: string;\n bodyClassName?: string;\n}\n\n/** Light dismiss is native where `closedby` is supported; elsewhere it is done below. */\nconst needsLightDismissFallback = () =>\n typeof HTMLDialogElement !== 'undefined' && !('closedBy' in HTMLDialogElement.prototype);\n\nconst isOutside = (e: ReactMouseEvent<HTMLDialogElement>) => {\n const r = e.currentTarget.getBoundingClientRect();\n return e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom;\n};\n\nfunction CloseIcon() {\n return (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M6 18 18 6M6 6l12 12\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\n/**\n * A modal sheet on a native <dialog>: the browser makes the page inert, keeps focus inside,\n * closes on Esc and returns focus to the opener. Centred from 640px up; on phones a bottom\n * sheet with a grabber that can be pulled down to close. On phones the ✕ is hidden, like a\n * native sheet: a tap outside is the single-tap alternative to the swipe (WCAG 2.5.1 and\n * 2.5.7), and the button stays for screen readers and keyboards.\n *\n * Opening focuses the dialog itself rather than the close button, so screen readers start\n * at the title and no focus ring flashes on the ✕ for touch users.\n */\nexport function GlassSheet({\n open,\n onClose,\n title,\n eyebrow,\n closeLabel = 'Close',\n swipeToClose = true,\n footer,\n children,\n className,\n bodyClassName,\n}: GlassSheetProps) {\n const dialogRef = useRef<HTMLDialogElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\n const titleId = useId();\n const pressedOutside = useRef(false);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog || open === dialog.hasAttribute('open')) return;\n // Feature-checked: older engines and jsdom lack showModal/close.\n if (open) {\n if (typeof dialog.showModal === 'function') dialog.showModal();\n else dialog.setAttribute('open', '');\n dialog.focus({ preventScroll: true });\n if (bodyRef.current) bodyRef.current.scrollTop = 0;\n } else if (typeof dialog.close === 'function') {\n dialog.close();\n } else {\n dialog.removeAttribute('open');\n }\n }, [open]);\n\n useSwipeToClose(dialogRef, { enabled: open && swipeToClose, scrollRef: bodyRef, onClose });\n\n return (\n <dialog\n ref={dialogRef}\n // Not yet in React's types; React passes it through as an attribute.\n {...{ closedby: 'any' }}\n tabIndex={-1}\n aria-labelledby={titleId}\n // Esc or light dismiss closed it; when `open` is already false the page closed it.\n onClose={() => {\n if (open) onClose();\n }}\n // Without `closedby`: close only when both the press and the release are outside the\n // box, so a text selection dragged onto the backdrop does not dismiss.\n onPointerDown={(e) => {\n pressedOutside.current = needsLightDismissFallback() && isOutside(e);\n }}\n onPointerUp={(e) => {\n if (pressedOutside.current && isOutside(e)) onClose();\n pressedOutside.current = false;\n }}\n className={cx('glass-dialog', className)}\n >\n {swipeToClose && <div className=\"glass-dialog-grabber\" aria-hidden=\"true\" />}\n <header className=\"glass-dialog-header\">\n <div className=\"glass-dialog-heading\">\n {eyebrow && <p className=\"glass-dialog-eyebrow\">{eyebrow}</p>}\n <h2 id={titleId} className=\"glass-dialog-title\">\n {title}\n </h2>\n </div>\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={closeLabel}\n className=\"glass-dialog-close\"\n >\n <CloseIcon />\n </button>\n </header>\n <div ref={bodyRef} className={cx('glass-dialog-body', bodyClassName)}>\n {children}\n </div>\n {footer && <div className=\"glass-dialog-footer\">{footer}</div>}\n </dialog>\n );\n}\n","import { useEffect, useRef, type RefObject } from 'react';\n\n/** Movement (px) before a press counts as a drag, so taps and small jitters stay taps. */\nexport const DRAG_SLOP_PX = 8;\n/** Pull further than this share of the sheet's height and it closes on release. */\nexport const CLOSE_DISTANCE_RATIO = 0.25;\n/** Or flick downward at least this fast (px per ms), however short the pull. */\nexport const CLOSE_VELOCITY = 0.5;\n/** A flick only counts once the sheet has moved this far, so a twitch doesn't close it. */\nexport const MIN_FLICK_PX = 24;\n/** How long the sheet takes to slide away or settle back (ms). */\nexport const SETTLE_MS = 220;\n/**\n * How long after release the owner is asked to close (ms): the slide-away plus a margin, so\n * the transition has really finished. Closing a dialog while its transform is still moving\n * is one more thing iOS Safari may get wrong.\n */\nexport const SLIDE_AWAY_MS = SETTLE_MS + 60;\n/**\n * After `onClose`, how long the sheet waits off-screen for its owner to close it (ms). If it\n * is still open by then (the owner kept it, e.g. to ask \"discard changes?\"), it comes back.\n */\nexport const REOPEN_AFTER_MS = 250;\n\nconst SETTLE_EASE = 'cubic-bezier(0.22, 1, 0.36, 1)';\n\nexport interface ReleaseState {\n /** How far the sheet is pulled down (px). */\n offset: number;\n /** The sheet's height (px). */\n height: number;\n /** Downward speed at release (px per ms; negative means moving up). */\n velocity: number;\n}\n\n/** Whether a released drag should close the sheet or let it settle back. */\nexport function shouldClose({ offset, height, velocity }: ReleaseState): boolean {\n if (offset <= 0) return false;\n if (height > 0 && offset >= height * CLOSE_DISTANCE_RATIO) return true;\n return velocity >= CLOSE_VELOCITY && offset >= MIN_FLICK_PX;\n}\n\n/** Controls a press should leave alone: a drag starting on one would steal its tap. */\nconst INTERACTIVE =\n 'button, a[href], input, select, textarea, label, summary, [contenteditable=\"\"], [contenteditable=\"true\"], [role=\"button\"], [role=\"slider\"], [data-glass-no-drag]';\n\n/** Computed `overflow-y` values a person can scroll (`overlay` is a legacy alias of `auto`). */\nconst SCROLLING_OVERFLOW = new Set(['auto', 'scroll', 'overlay']);\n\n/**\n * Whether a person can scroll `el` vertically: it has more content than fits and its\n * `overflow-y` lets them. `hidden` does not count: only a script can scroll that.\n */\nconst scrollsVertically = (el: Element) =>\n el.scrollHeight > el.clientHeight && SCROLLING_OVERFLOW.has(getComputedStyle(el).overflowY);\n\n/** Whether a pan in any of `scrollers` has something to scroll, rather than chaining on. */\nconst anyCanScroll = (scrollers: readonly Element[]) =>\n scrollers.some((el) => el.scrollHeight > el.clientHeight);\n\n/** Counts the hook runs per sheet, so a late tidy-up never touches a sheet that is in use again. */\nconst runs = new WeakMap<HTMLElement, number>();\n\nconst prefersReducedMotion = () =>\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n\nexport interface SwipeToCloseOptions {\n /** Turn the gesture on or off (e.g. only while open, only in the bottom-sheet layout). */\n enabled: boolean;\n /**\n * Optional. The scrolling areas under the finger are found by themselves: every element\n * from the press up to the sheet (itself included) with `overflow-y` auto, scroll or\n * overlay and more content than fits. A press inside one drags only while all of them are\n * scrolled to the top. Pass a scroller here only when that test misses it, e.g. one with\n * `overflow-y: hidden` that a script scrolls; it then counts whenever it holds the press.\n */\n scrollRef?: RefObject<HTMLElement | null>;\n /**\n * Called once the sheet has slid away. The sheet stays off-screen until `enabled` turns\n * false; if that has not happened `REOPEN_AFTER_MS` later, it slides back.\n *\n * From release until the sheet is closed and tidied up (or comes back) it carries\n * `data-closing`. Style the backdrop with it, so the dim is gone before the close.\n */\n onClose: () => void;\n /** Media query for when the gesture applies. Default: the phone bottom-sheet layout. */\n media?: string;\n}\n\ninterface Drag {\n pointerId: number | 'touch';\n startX: number;\n startY: number;\n lastY: number;\n lastT: number;\n velocity: number;\n /** Null until the press has moved past the slop and we know whether it is our drag. */\n active: boolean | null;\n /** The scrollers under the press (see `scrollersUnder`), all at the top when it began. */\n scrollers: Element[];\n}\n\n/**\n * Pull-down-to-close for a sheet. Touch uses touch events, because a pointer-events drag\n * over scrollable content is cancelled by the browser as soon as it starts to pan; with\n * a non-passive touchmove we can stop that pan. Mouse and pen use pointer events. The sheet\n * follows the finger via an inline transform and either slides away (then `onClose`) or\n * settles back.\n *\n * The scrolling areas need no wiring: at each press the hook walks from the element under\n * the finger up to the sheet and takes every element a person can scroll vertically. If any\n * of them is scrolled down, the gesture is theirs (a pull down scrolls back up) and no drag\n * starts. A sideways scroller does not block a drag (only vertical scrolling counts), and a\n * sideways move lets go of one. Outside every vertical scroller the page is held (below),\n * which stops a sideways scroller there too: mark it `data-glass-no-drag`.\n *\n * iOS Safari decides at the first touchmove of a gesture whether the page pans, and later\n * moves can no longer stop it. So wherever nothing in the sheet would scroll for that touch\n * (outside every scroller, such as the header, grabber and backdrop; a downward pull at the\n * top of a scroller; a scroller with nothing to scroll), touchmoves are cancelled from the\n * first one; taps still click.\n *\n * After a slide-away the inline transform is kept until the effect is torn down (the owner\n * closed the sheet and `enabled` turned false). Clearing it earlier would show the sheet at\n * rest for a frame before the close is committed.\n *\n * From release until the sheet is closed and tidied up, or comes back, the sheet has the\n * attribute `data-closing`. Fade the backdrop out with it (`[data-closing]::backdrop`): iOS\n * Safari can leave a dialog's backdrop painted after it closes, so it must be clear by then.\n */\nexport function useSwipeToClose(\n sheetRef: RefObject<HTMLElement | null>,\n { enabled, scrollRef, onClose, media = '(max-width: 639.98px)' }: SwipeToCloseOptions,\n): void {\n const onCloseRef = useRef(onClose);\n onCloseRef.current = onClose;\n\n useEffect(() => {\n const sheet = sheetRef.current;\n if (!enabled || !sheet) return;\n\n let drag: Drag | null = null;\n // Cancel every touchmove until this touch ends: nothing under it scrolls, so a pan would\n // move the page behind the dialog. Cleared on touchstart, touchend and touchcancel.\n let holdPage = false;\n let suppressClick = false;\n // False once the effect is torn down, so nothing is scheduled on a sheet we let go of.\n let alive = true;\n // True from release until the owner closes the sheet or it comes back.\n let closing = false;\n // The release phases (slide away, wait for the owner, settle back) run one after\n // another, so a single timer handle covers them.\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const clearTimer = () => {\n clearTimeout(timer);\n timer = undefined;\n };\n\n const applies = () =>\n typeof window.matchMedia !== 'function' || window.matchMedia(media).matches;\n\n const resetStyles = () => {\n sheet.style.transform = '';\n sheet.style.transition = '';\n sheet.removeAttribute('data-dragging');\n sheet.removeAttribute('data-closing');\n };\n\n // Start clean: an earlier run may have left its inline styles (see the cleanup).\n runs.set(sheet, (runs.get(sheet) ?? 0) + 1);\n resetStyles();\n sheet.style.animation = '';\n\n /** Animate back to rest, then drop the inline styles. */\n const settleBack = () => {\n // Now, not once it has settled: the backdrop fades back in while the sheet slides up.\n sheet.removeAttribute('data-closing');\n sheet.style.transition = `transform ${SETTLE_MS}ms ${SETTLE_EASE}`;\n sheet.style.transform = '';\n // A timer, not transitionend: that event never fires if nothing moved or the tab hid.\n timer = setTimeout(resetStyles, SETTLE_MS);\n };\n\n /**\n * Ask the owner to close, leaving the sheet where it is. The effect cleanup clears the\n * styles once the sheet really closes; if it is still open after REOPEN_AFTER_MS,\n * `comeBack` runs.\n */\n const requestClose = (comeBack: () => void) => {\n try {\n onCloseRef.current();\n } finally {\n // The owner may have closed the sheet synchronously, tearing this effect down.\n if (alive) {\n timer = setTimeout(() => {\n closing = false;\n comeBack();\n }, REOPEN_AFTER_MS);\n }\n }\n };\n\n /**\n * The scrollers under a press: every element from `target` up to the sheet (itself\n * included) that a person can scroll vertically, plus `scrollRef` when it holds `target`.\n * Once per press, a handful of elements: read on the spot, nothing cached or observed.\n */\n const scrollersUnder = (target: Element): Element[] => {\n const found: Element[] = [];\n for (let el: Element | null = target; el; el = el.parentElement) {\n if (scrollsVertically(el)) found.push(el);\n if (el === sheet) break;\n }\n const given = scrollRef?.current;\n if (given?.contains(target) && !found.includes(given)) found.push(given);\n return found;\n };\n\n const begin = (id: Drag['pointerId'], x: number, y: number, target: EventTarget | null) => {\n // While closing, the sheet is sliding away or waiting for its owner: leave it be.\n if (drag || closing || !applies()) return;\n const el = target instanceof Element ? target : null;\n if (!el || !sheet.contains(el) || el.closest(INTERACTIVE)) return;\n const scrollers = scrollersUnder(el);\n // A scroller under the finger is scrolled down: the gesture scrolls it, not the sheet.\n if (scrollers.some((s) => s.scrollTop > 0)) return;\n // Text selected inside a scroller: the press is probably adjusting it.\n if (scrollers.length > 0 && window.getSelection()?.isCollapsed === false) return;\n clearTimer();\n drag = {\n pointerId: id,\n startX: x,\n startY: y,\n lastY: y,\n lastT: performance.now(),\n velocity: 0,\n active: null,\n scrollers,\n };\n };\n\n /** Returns true while the move belongs to the drag (so the caller can stop scrolling). */\n const move = (x: number, y: number): boolean => {\n if (!drag) return false;\n const dy = y - drag.startY;\n const dx = x - drag.startX;\n if (drag.active === null) {\n if (Math.abs(dy) < DRAG_SLOP_PX && Math.abs(dx) < DRAG_SLOP_PX) return false;\n // Upward or sideways: a scroll or a swipe for something else. Let it go.\n if (dy <= 0 || Math.abs(dx) > Math.abs(dy)) {\n drag = null;\n return false;\n }\n drag.active = true;\n sheet.setAttribute('data-dragging', '');\n sheet.style.transition = 'none';\n // Off until the sheet closes (see cleanup). An open animation with a fill mode would\n // override the inline transform, and switching it off only for the drag would replay\n // it on release.\n sheet.style.animation = 'none';\n }\n const now = performance.now();\n const dt = now - drag.lastT;\n if (dt > 0) drag.velocity = (y - drag.lastY) / dt;\n drag.lastY = y;\n drag.lastT = now;\n sheet.style.transform = `translate3d(0, ${Math.max(0, dy - DRAG_SLOP_PX)}px, 0)`;\n return true;\n };\n\n const end = () => {\n if (!drag) return;\n const wasActive = drag.active === true;\n const wasTouch = drag.pointerId === 'touch';\n const offset = Math.max(0, drag.lastY - drag.startY - DRAG_SLOP_PX);\n // A long pause before letting go means the flick is over.\n const velocity = performance.now() - drag.lastT > 100 ? 0 : drag.velocity;\n drag = null;\n if (!wasActive) return;\n // Only a mouse or pen drag ends in a click to swallow. A touch drag does not, and the\n // flag would then eat the next real activation (e.g. from a screen reader).\n suppressClick = !wasTouch;\n sheet.removeAttribute('data-dragging');\n\n const close = shouldClose({ offset, height: sheet.getBoundingClientRect().height, velocity });\n const reduceMotion = prefersReducedMotion();\n if (!close) {\n if (reduceMotion) resetStyles();\n else settleBack();\n return;\n }\n closing = true;\n // The backdrop fades out from now, so nothing dark is left to repaint at the close.\n sheet.setAttribute('data-closing', '');\n // Reduced motion: no slide, the sheet goes at once. The close still waits, so it never\n // lands in the frame the backdrop changes.\n sheet.style.transition = reduceMotion ? 'none' : `transform ${SETTLE_MS}ms ${SETTLE_EASE}`;\n sheet.style.transform = 'translate3d(0, 100%, 0)';\n // A timer, not transitionend: that event never fires if nothing moved or the tab hid.\n const comeBack = reduceMotion ? resetStyles : settleBack;\n timer = setTimeout(() => requestClose(comeBack), SLIDE_AWAY_MS);\n };\n\n const cancel = () => {\n const wasActive = drag?.active === true;\n drag = null;\n if (wasActive) resetStyles();\n };\n\n // Touch\n const onTouchStart = (e: TouchEvent) => {\n holdPage = false;\n const t = e.touches[0];\n if (e.touches.length !== 1 || !t) return cancel();\n begin('touch', t.clientX, t.clientY, e.target);\n // Outside every scroller (header, grabber, footer, the backdrop) nothing scrolls\n // natively; nor in scrollers whose content fits. Hold from the start: the first move\n // decides.\n holdPage = drag?.pointerId === 'touch' && !anyCanScroll(drag.scrollers);\n };\n const onTouchMove = (e: TouchEvent) => {\n const t = e.touches[0];\n let stopPan = holdPage;\n if (t && drag?.pointerId === 'touch') {\n const { startY, scrollers } = drag;\n const pulledDown = t.clientY > startY;\n if (move(t.clientX, t.clientY)) {\n stopPan = true; // our drag\n } else if (drag) {\n // Within the slop. At the top of a scroller a pull down has nothing to scroll.\n stopPan ||= pulledDown;\n } else if (!anyCanScroll(scrollers)) {\n // Dropped as not ours, and nothing under it can scroll: keep the page still.\n holdPage = true;\n stopPan = true;\n }\n }\n if (stopPan && e.cancelable) e.preventDefault();\n };\n const onTouchEnd = () => {\n holdPage = false;\n if (drag?.pointerId === 'touch') end();\n };\n const onTouchCancel = () => {\n holdPage = false;\n cancel();\n };\n\n // Mouse and pen (touch is handled above)\n const onPointerDown = (e: PointerEvent) => {\n if (e.pointerType === 'touch' || e.button !== 0) return;\n begin(e.pointerId, e.clientX, e.clientY, e.target);\n };\n const onPointerMove = (e: PointerEvent) => {\n if (drag?.pointerId !== e.pointerId) return;\n if (move(e.clientX, e.clientY)) e.preventDefault();\n };\n const onPointerUp = (e: PointerEvent) => {\n if (drag?.pointerId === e.pointerId) end();\n };\n const onPointerCancel = (e: PointerEvent) => {\n if (drag?.pointerId === e.pointerId) cancel();\n };\n\n // A mouse drag ends with a click on whatever is under it; that click must not count.\n const onClickCapture = (e: MouseEvent) => {\n if (!suppressClick) return;\n suppressClick = false;\n e.preventDefault();\n e.stopPropagation();\n };\n const clearSuppress = () => {\n suppressClick = false;\n };\n\n sheet.addEventListener('touchstart', onTouchStart, { passive: true });\n sheet.addEventListener('touchmove', onTouchMove, { passive: false });\n sheet.addEventListener('touchend', onTouchEnd);\n sheet.addEventListener('touchcancel', onTouchCancel);\n sheet.addEventListener('pointerdown', onPointerDown);\n sheet.addEventListener('click', onClickCapture, true);\n window.addEventListener('pointermove', onPointerMove);\n window.addEventListener('pointerup', onPointerUp);\n window.addEventListener('pointercancel', onPointerCancel);\n window.addEventListener('pointerdown', clearSuppress, true);\n\n return () => {\n alive = false;\n clearTimer();\n // Never change the sheet in the frame it closes: moving it or restarting its open\n // animation together with dialog.close() is the suspected cause of the backdrop staying\n // painted on iOS Safari. Tidy up a moment later (styles and `data-closing`), unless the\n // sheet is in use again.\n const mine = runs.get(sheet);\n setTimeout(() => {\n if (runs.get(sheet) !== mine) return;\n resetStyles();\n sheet.style.animation = '';\n }, SLIDE_AWAY_MS);\n sheet.removeEventListener('touchstart', onTouchStart);\n sheet.removeEventListener('touchmove', onTouchMove);\n sheet.removeEventListener('touchend', onTouchEnd);\n sheet.removeEventListener('touchcancel', onTouchCancel);\n sheet.removeEventListener('pointerdown', onPointerDown);\n sheet.removeEventListener('click', onClickCapture, true);\n window.removeEventListener('pointermove', onPointerMove);\n window.removeEventListener('pointerup', onPointerUp);\n window.removeEventListener('pointercancel', onPointerCancel);\n window.removeEventListener('pointerdown', clearSuppress, true);\n };\n }, [enabled, media, scrollRef, sheetRef]);\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAOK;;;ACPA,SAAS,MAAM,OAAyD;AAC7E,SAAO,MAAM,OAAO,OAAO,EAAE,KAAK,GAAG;AACvC;;;AD0FI;AA9EJ,IAAM,aAAoD;AAAA,EACxD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,oBAAoB;AAAA,EACpB,QAAQ;AACV;AAEA,IAAM,kBAA8D;AAAA,EAClE,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AACT;AAEA,IAAM,cAAsD;AAAA,EAC1D,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AACR;AAeO,SAAS,aAAa;AAAA,EAC3B,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,OAAO;AAAA,EACP,UAAU;AACZ,IAAkB,CAAC,GAAW;AAC5B,SAAO;AAAA,IACL;AAAA,IACA,WAAW,IAAI;AAAA,IACf,gBAAgB,SAAS;AAAA,IACzB,YAAY,KAAK;AAAA,IACjB,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AACF;AAQA,SAAS,WACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,YAAyB,MAAM;AACrC,SACE;AAAA,IAAC;AAAA;AAAA,MAC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ACb;AAAA,WACF;AAAA,QACA,gBAAAA,KAAC,SAAI,KAAK,SAAS,WAAW,GAAG,qBAAqB,aAAa,GAChE,UACH;AAAA,QACC,UAAU,gBAAAA,KAAC,SAAI,WAAU,uBAAuB,kBAAO;AAAA;AAAA;AAAA,EAC1D;AAEJ;","names":["forwardRef","jsx","forwardRef","GlassButton","jsx","useEffect","useRef","useEffect","jsx","jsxs","useRef","useEffect"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sofyan/glass",
3
- "version": "0.1.6",
3
+ "version": "0.2.0",
4
4
  "description": "Liquid Glass material for the web: CSS (Tailwind v4 friendly) and React components, including a swipe-to-close sheet.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -28,6 +28,8 @@
28
28
  "./glass.css": "./dist/glass.css",
29
29
  "./tailwind.css": "./dist/tailwind.css",
30
30
  "./dark.css": "./dist/dark.css",
31
+ "./glass.unlayered.css": "./dist/glass.unlayered.css",
32
+ "./dark.unlayered.css": "./dist/dark.unlayered.css",
31
33
  "./react": {
32
34
  "types": "./dist/react/index.d.ts",
33
35
  "import": "./dist/react/index.js"
@@ -35,7 +37,7 @@
35
37
  "./package.json": "./package.json"
36
38
  },
37
39
  "scripts": {
38
- "build": "tsup && node scripts/copy-css.mjs",
40
+ "build": "tsup && node scripts/build-css.mjs",
39
41
  "typecheck": "tsc --noEmit",
40
42
  "test": "vitest run",
41
43
  "format": "prettier -w .",
@@ -61,6 +63,7 @@
61
63
  "@types/react": "^19.2.0",
62
64
  "@types/react-dom": "^19.2.0",
63
65
  "jsdom": "^25.0.1",
66
+ "postcss": "^8.5.34",
64
67
  "prettier": "^3.6.0",
65
68
  "react": "^19.2.0",
66
69
  "react-dom": "^19.2.0",