@sofyan/glass 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -3
- package/dist/dark.css +97 -0
- package/dist/glass.css +28 -24
- package/dist/react/index.d.ts +10 -2
- package/dist/react/index.js +45 -14
- package/dist/react/index.js.map +1 -1
- package/dist/tailwind.css +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -33,6 +33,12 @@ Without Tailwind:
|
|
|
33
33
|
@import '@sofyan/glass/glass.css';
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
Optional dark theme, after either of the above (see [Dark mode](#dark-mode)):
|
|
37
|
+
|
|
38
|
+
```css
|
|
39
|
+
@import '@sofyan/glass/dark.css';
|
|
40
|
+
```
|
|
41
|
+
|
|
36
42
|
### Classes
|
|
37
43
|
|
|
38
44
|
| Class | What |
|
|
@@ -59,8 +65,34 @@ Every value is a custom property. Override any of them on `:root` (or on an elem
|
|
|
59
65
|
--lg-blur: 20px;
|
|
60
66
|
--lg-radius-sheet: 24px;
|
|
61
67
|
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The accent colours (`--lg-accent`, `--lg-accent-strong`, `--lg-accent-2`,
|
|
71
|
+
`--lg-accent-2-strong`) and the sheet fill (`--lg-sheet-fill`) are resolved where they are
|
|
72
|
+
used, so they follow `--color-primary`, `--color-secondary` and the `--lg-c-*` neutrals
|
|
73
|
+
wherever those are set, not only on `:root`.
|
|
74
|
+
|
|
75
|
+
See the top of [`src/glass.css`](src/glass.css) for the full list.
|
|
76
|
+
|
|
77
|
+
#### Dark mode
|
|
62
78
|
|
|
63
|
-
|
|
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.
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<html class="dark">
|
|
88
|
+
…
|
|
89
|
+
</html>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
To build your own dark theme instead, redefine the tokens under your selector. The
|
|
93
|
+
neutrals are RGB triplets:
|
|
94
|
+
|
|
95
|
+
```css
|
|
64
96
|
.dark {
|
|
65
97
|
--lg-c-canvas: 11 11 12;
|
|
66
98
|
--lg-c-paper: 28 28 30;
|
|
@@ -69,8 +101,6 @@ Every value is a custom property. Override any of them on `:root` (or on an elem
|
|
|
69
101
|
}
|
|
70
102
|
```
|
|
71
103
|
|
|
72
|
-
See the top of [`src/glass.css`](src/glass.css) for the full list.
|
|
73
|
-
|
|
74
104
|
## React
|
|
75
105
|
|
|
76
106
|
```tsx
|
|
@@ -99,6 +129,8 @@ focus returns to the opener. A tap outside closes it too.
|
|
|
99
129
|
- **Phones (< 640px):** a bottom sheet with a grabber. Pull it down to close: past a quarter
|
|
100
130
|
of its height, or with a quick flick. Otherwise it settles back. The header always drags;
|
|
101
131
|
the body drags only when scrolled to the top, so scrolling the text never closes it.
|
|
132
|
+
- After a swipe, `onClose` runs once the sheet has slid away. If `open` is still true a
|
|
133
|
+
moment later (say you ask "discard changes?" first), the sheet slides back.
|
|
102
134
|
- **640px and up:** a centred card. No swipe.
|
|
103
135
|
- Opening focuses the dialog itself, so a screen reader starts at the title and no focus
|
|
104
136
|
ring shows on the close button.
|
|
@@ -111,6 +143,10 @@ To add the gesture to your own sheet, use the hook:
|
|
|
111
143
|
useSwipeToClose(sheetRef, { enabled: open, scrollRef: bodyRef, onClose });
|
|
112
144
|
```
|
|
113
145
|
|
|
146
|
+
Pass `enabled: false` once the sheet is closed. After `onClose` the hook keeps the sheet
|
|
147
|
+
off-screen and clears its inline styles when `enabled` turns false; if that has not
|
|
148
|
+
happened a moment later, it slides the sheet back.
|
|
149
|
+
|
|
114
150
|
### Refraction (Chromium only)
|
|
115
151
|
|
|
116
152
|
Mount `<GlassFilter />` once near the root, then add `refract` (or `glass-refract`). Safari
|
package/dist/dark.css
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @sofyan/glass: opt-in dark theme
|
|
3
|
+
* ---------------------------------------------------------------------------
|
|
4
|
+
* Import it after glass.css (or tailwind.css):
|
|
5
|
+
*
|
|
6
|
+
* @import '@sofyan/glass/tailwind.css';
|
|
7
|
+
* @import '@sofyan/glass/dark.css';
|
|
8
|
+
*
|
|
9
|
+
* Then add class="dark" or data-theme="dark" to any element: <html> for the whole page,
|
|
10
|
+
* or a wrapper for one part of it. Everything inside follows.
|
|
11
|
+
*
|
|
12
|
+
* It only retunes tokens (neutrals, the light glass, shadows) and the denser fills of
|
|
13
|
+
* menus and sheets. Tones you set yourself (glass-dark, glass-clear, glass-tinted, ...)
|
|
14
|
+
* stay as they are.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
@layer theme, base, components, utilities;
|
|
18
|
+
|
|
19
|
+
/* ── Tokens ───────────────────────────────────────────────────────────── */
|
|
20
|
+
/* :is(), not :where(): glass.css sets these tokens on :root, and on <html class="dark">
|
|
21
|
+
a zero-specificity rule would lose to it. :is() ties with :root, so the later rule
|
|
22
|
+
(this file) wins. */
|
|
23
|
+
@layer base {
|
|
24
|
+
:is(.dark, [data-theme='dark']) {
|
|
25
|
+
color-scheme: dark;
|
|
26
|
+
|
|
27
|
+
--lg-c-canvas: 11 11 12;
|
|
28
|
+
--lg-c-paper: 28 28 30;
|
|
29
|
+
--lg-c-raised: 44 44 46;
|
|
30
|
+
--lg-c-ink: 245 245 247;
|
|
31
|
+
--lg-c-ink-2: 152 152 157;
|
|
32
|
+
--lg-c-ink-3: 142 142 147;
|
|
33
|
+
--lg-c-line: 255 255 255;
|
|
34
|
+
|
|
35
|
+
--lg-light-fill: rgba(30, 30, 32, 0.66);
|
|
36
|
+
--lg-light-fill-hover: rgba(44, 44, 46, 0.76);
|
|
37
|
+
--lg-light-text: #f5f5f7;
|
|
38
|
+
--lg-light-rim: rgba(255, 255, 255, 0.14);
|
|
39
|
+
--lg-light-edge: rgba(255, 255, 255, 0.08);
|
|
40
|
+
|
|
41
|
+
--lg-sheen: none;
|
|
42
|
+
|
|
43
|
+
--lg-shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.3);
|
|
44
|
+
--lg-shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
|
|
45
|
+
--lg-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* The same fallbacks as glass.css, for the dark fills. They come after the rule above so
|
|
49
|
+
they win over it. */
|
|
50
|
+
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
|
51
|
+
:is(.dark, [data-theme='dark']) {
|
|
52
|
+
--lg-light-fill: rgba(30, 30, 32, 0.92);
|
|
53
|
+
--lg-light-fill-hover: rgba(44, 44, 46, 0.96);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
58
|
+
:is(.dark, [data-theme='dark']) {
|
|
59
|
+
--lg-light-fill: rgba(30, 30, 32, 0.97);
|
|
60
|
+
--lg-light-fill-hover: #2c2c2e;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@media (prefers-contrast: more) {
|
|
65
|
+
:is(.dark, [data-theme='dark']) {
|
|
66
|
+
--lg-light-edge: rgba(255, 255, 255, 0.45);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* ── Composites ───────────────────────────────────────────────────────── */
|
|
72
|
+
@layer components {
|
|
73
|
+
/* Denser fills for floating overlays. The :not() skips surfaces with a tone of their own,
|
|
74
|
+
which glass.css lets win by source order; :where() keeps it out of the specificity. */
|
|
75
|
+
:where(.dark, [data-theme='dark'])
|
|
76
|
+
.glass-menu:where(
|
|
77
|
+
:not(.glass-dark, .glass-clear, .glass-tinted, .glass-tinted-secondary, .glass-danger)
|
|
78
|
+
) {
|
|
79
|
+
--lg-fill: rgba(36, 36, 40, 0.88);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
:where(.dark, [data-theme='dark'])
|
|
83
|
+
.glass-sheet:where(
|
|
84
|
+
:not(.glass-dark, .glass-clear, .glass-tinted, .glass-tinted-secondary, .glass-danger)
|
|
85
|
+
) {
|
|
86
|
+
--lg-fill: rgba(30, 30, 34, 0.92);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
:where(.dark, [data-theme='dark']) .glass-menu-item:hover,
|
|
90
|
+
:where(.dark, [data-theme='dark']) .glass-menu-item:focus-visible {
|
|
91
|
+
background-color: rgba(255, 255, 255, 0.1);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
:where(.dark, [data-theme='dark']) .glass-menu-separator {
|
|
95
|
+
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent);
|
|
96
|
+
}
|
|
97
|
+
}
|
package/dist/glass.css
CHANGED
|
@@ -27,12 +27,15 @@
|
|
|
27
27
|
/* ── Tokens ───────────────────────────────────────────────────────────── */
|
|
28
28
|
@layer base {
|
|
29
29
|
:root {
|
|
30
|
-
/*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
/* Derived tokens. Not declared here: a var() in a :root value is resolved at :root, so
|
|
31
|
+
it would ignore --color-* or --lg-c-* overrides set lower down (e.g. on a `.dark`
|
|
32
|
+
wrapper). Each use site falls back to the default below instead. Set any of them,
|
|
33
|
+
on :root or on an element, to override it.
|
|
34
|
+
--lg-accent default var(--color-primary, #0a84ff)
|
|
35
|
+
--lg-accent-strong default var(--color-primary-dark, #0060df)
|
|
36
|
+
--lg-accent-2 default var(--color-secondary, #5e5ce6)
|
|
37
|
+
--lg-accent-2-strong default var(--color-secondary-dark, #4b49c9)
|
|
38
|
+
--lg-sheet-fill default rgb(var(--lg-c-paper)), the <dialog> sheet's fill */
|
|
36
39
|
--lg-danger: #ff3b30; /* iOS system red */
|
|
37
40
|
--lg-danger-strong: #e5352b;
|
|
38
41
|
|
|
@@ -98,7 +101,6 @@
|
|
|
98
101
|
|
|
99
102
|
/* Overlays */
|
|
100
103
|
--lg-scrim: rgba(0, 0, 0, 0.4);
|
|
101
|
-
--lg-sheet-fill: rgb(var(--lg-c-paper));
|
|
102
104
|
--lg-sheet-max-height: 85dvh;
|
|
103
105
|
--lg-sheet-max-width: 640px;
|
|
104
106
|
}
|
|
@@ -212,7 +214,8 @@
|
|
|
212
214
|
}
|
|
213
215
|
|
|
214
216
|
:is(.glass-interactive, .glass-btn):focus-visible {
|
|
215
|
-
outline: 2px solid
|
|
217
|
+
outline: 2px solid
|
|
218
|
+
color-mix(in srgb, var(--lg-accent, var(--color-primary, #0a84ff)) 70%, white);
|
|
216
219
|
outline-offset: 2px;
|
|
217
220
|
}
|
|
218
221
|
|
|
@@ -336,11 +339,11 @@
|
|
|
336
339
|
border-radius: 0.75rem;
|
|
337
340
|
font-size: 0.875rem;
|
|
338
341
|
line-height: 1.25rem;
|
|
339
|
-
color:
|
|
340
|
-
background-color:
|
|
342
|
+
color: rgb(var(--lg-c-ink));
|
|
343
|
+
background-color: rgb(var(--lg-c-paper) / 0.55);
|
|
341
344
|
box-shadow:
|
|
342
|
-
inset 0 1px 2px
|
|
343
|
-
inset 0 0 0 1px
|
|
345
|
+
inset 0 1px 2px rgb(var(--lg-c-line) / 0.08),
|
|
346
|
+
inset 0 0 0 1px rgb(var(--lg-c-line) / 0.08);
|
|
344
347
|
-webkit-backdrop-filter: blur(var(--lg-blur-thin));
|
|
345
348
|
backdrop-filter: blur(var(--lg-blur-thin));
|
|
346
349
|
transition:
|
|
@@ -349,15 +352,16 @@
|
|
|
349
352
|
}
|
|
350
353
|
|
|
351
354
|
.glass-input::placeholder {
|
|
352
|
-
color:
|
|
355
|
+
color: rgb(var(--lg-c-ink-2));
|
|
353
356
|
}
|
|
354
357
|
|
|
355
358
|
.glass-input:focus {
|
|
356
359
|
outline: none;
|
|
357
|
-
background-color:
|
|
360
|
+
background-color: rgb(var(--lg-c-paper) / 0.85);
|
|
358
361
|
box-shadow:
|
|
359
|
-
inset 0 0 0 1.5px
|
|
360
|
-
|
|
362
|
+
inset 0 0 0 1.5px
|
|
363
|
+
color-mix(in srgb, var(--lg-accent, var(--color-primary, #0a84ff)) 70%, transparent),
|
|
364
|
+
0 0 0 4px color-mix(in srgb, var(--lg-accent, var(--color-primary, #0a84ff)) 16%, transparent);
|
|
361
365
|
}
|
|
362
366
|
|
|
363
367
|
/* Small chip / badge: thin, pill. */
|
|
@@ -418,13 +422,13 @@
|
|
|
418
422
|
}
|
|
419
423
|
|
|
420
424
|
.glass-tinted {
|
|
421
|
-
--lg-fill: var(--lg-accent);
|
|
422
|
-
--lg-fill-hover: var(--lg-accent-strong);
|
|
425
|
+
--lg-fill: var(--lg-accent, var(--color-primary, #0a84ff));
|
|
426
|
+
--lg-fill-hover: var(--lg-accent-strong, var(--color-primary-dark, #0060df));
|
|
423
427
|
}
|
|
424
428
|
|
|
425
429
|
.glass-tinted-secondary {
|
|
426
|
-
--lg-fill: var(--lg-accent-2);
|
|
427
|
-
--lg-fill-hover: var(--lg-accent-2-strong);
|
|
430
|
+
--lg-fill: var(--lg-accent-2, var(--color-secondary, #5e5ce6));
|
|
431
|
+
--lg-fill-hover: var(--lg-accent-2-strong, var(--color-secondary-dark, #4b49c9));
|
|
428
432
|
}
|
|
429
433
|
|
|
430
434
|
.glass-danger {
|
|
@@ -500,7 +504,7 @@
|
|
|
500
504
|
overflow: hidden;
|
|
501
505
|
border-radius: var(--lg-radius-xl);
|
|
502
506
|
color: rgb(var(--lg-c-ink));
|
|
503
|
-
background-color: var(--lg-sheet-fill);
|
|
507
|
+
background-color: var(--lg-sheet-fill, rgb(var(--lg-c-paper)));
|
|
504
508
|
box-shadow:
|
|
505
509
|
inset 0 0 0 1px rgb(var(--lg-c-line) / 0.1),
|
|
506
510
|
var(--lg-shadow-lg);
|
|
@@ -576,7 +580,7 @@
|
|
|
576
580
|
}
|
|
577
581
|
|
|
578
582
|
.glass-dialog-close:focus-visible {
|
|
579
|
-
outline: 2px solid var(--lg-accent);
|
|
583
|
+
outline: 2px solid var(--lg-accent, var(--color-primary, #0a84ff));
|
|
580
584
|
outline-offset: 2px;
|
|
581
585
|
}
|
|
582
586
|
|
|
@@ -636,9 +640,9 @@
|
|
|
636
640
|
}
|
|
637
641
|
}
|
|
638
642
|
|
|
639
|
-
/* While a finger drags the sheet, it follows exactly (no easing).
|
|
643
|
+
/* While a finger drags the sheet, it follows exactly (no easing). The hook switches the
|
|
644
|
+
open animation off inline, and keeps it off until the sheet closes. */
|
|
640
645
|
dialog.glass-dialog[data-dragging] {
|
|
641
|
-
animation: none;
|
|
642
646
|
transition: none;
|
|
643
647
|
user-select: none;
|
|
644
648
|
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -94,7 +94,10 @@ interface SwipeToCloseOptions {
|
|
|
94
94
|
enabled: boolean;
|
|
95
95
|
/** The scrolling part of the sheet. A press there drags only while it is scrolled to the top. */
|
|
96
96
|
scrollRef?: RefObject<HTMLElement | null>;
|
|
97
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Called once the sheet has slid away. The sheet stays off-screen until `enabled` turns
|
|
99
|
+
* false; if that has not happened `REOPEN_AFTER_MS` later, it slides back.
|
|
100
|
+
*/
|
|
98
101
|
onClose: () => void;
|
|
99
102
|
/** Media query for when the gesture applies. Default: the phone bottom-sheet layout. */
|
|
100
103
|
media?: string;
|
|
@@ -105,7 +108,12 @@ interface SwipeToCloseOptions {
|
|
|
105
108
|
* a non-passive touchmove we can stop that pan once the drag is ours. Mouse and pen use
|
|
106
109
|
* pointer events. The sheet follows the finger via an inline transform and either slides
|
|
107
110
|
* away (then `onClose`) or settles back.
|
|
111
|
+
*
|
|
112
|
+
* After a slide-away the inline transform is kept until the effect is torn down (the owner
|
|
113
|
+
* closed the sheet and `enabled` turned false). Clearing it earlier would show the sheet at
|
|
114
|
+
* rest for a frame before the close is committed.
|
|
108
115
|
*/
|
|
109
116
|
declare function useSwipeToClose(sheetRef: RefObject<HTMLElement | null>, { enabled, scrollRef, onClose, media }: SwipeToCloseOptions): void;
|
|
110
117
|
|
|
111
|
-
export { Glass, GlassButton,
|
|
118
|
+
export { Glass, GlassButton, GlassFilter, GlassSheet, glassClasses, shouldClose, supportsBackdropRefraction, useSwipeToClose };
|
|
119
|
+
export type { GlassButtonProps, GlassButtonSize, GlassButtonVariant, GlassOptions, GlassProps, GlassShape, GlassSheetProps, GlassThickness, GlassTone, ReleaseState, SwipeToCloseOptions };
|
package/dist/react/index.js
CHANGED
|
@@ -188,6 +188,8 @@ var CLOSE_DISTANCE_RATIO = 0.25;
|
|
|
188
188
|
var CLOSE_VELOCITY = 0.5;
|
|
189
189
|
var MIN_FLICK_PX = 24;
|
|
190
190
|
var SETTLE_MS = 220;
|
|
191
|
+
var REOPEN_AFTER_MS = 250;
|
|
192
|
+
var SETTLE_EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
|
|
191
193
|
function shouldClose({ offset, height, velocity }) {
|
|
192
194
|
if (offset <= 0) return false;
|
|
193
195
|
if (height > 0 && offset >= height * CLOSE_DISTANCE_RATIO) return true;
|
|
@@ -203,21 +205,44 @@ function useSwipeToClose(sheetRef, { enabled, scrollRef, onClose, media = "(max-
|
|
|
203
205
|
if (!enabled || !sheet) return;
|
|
204
206
|
let drag = null;
|
|
205
207
|
let suppressClick = false;
|
|
206
|
-
let
|
|
208
|
+
let alive = true;
|
|
209
|
+
let closing = false;
|
|
210
|
+
let timer;
|
|
211
|
+
const clearTimer = () => {
|
|
212
|
+
clearTimeout(timer);
|
|
213
|
+
timer = void 0;
|
|
214
|
+
};
|
|
207
215
|
const applies = () => typeof window.matchMedia !== "function" || window.matchMedia(media).matches;
|
|
208
216
|
const resetStyles = () => {
|
|
209
217
|
sheet.style.transform = "";
|
|
210
218
|
sheet.style.transition = "";
|
|
211
219
|
sheet.removeAttribute("data-dragging");
|
|
212
220
|
};
|
|
221
|
+
const settleBack = () => {
|
|
222
|
+
sheet.style.transition = `transform ${SETTLE_MS}ms ${SETTLE_EASE}`;
|
|
223
|
+
sheet.style.transform = "";
|
|
224
|
+
timer = setTimeout(resetStyles, SETTLE_MS);
|
|
225
|
+
};
|
|
226
|
+
const requestClose = (comeBack) => {
|
|
227
|
+
try {
|
|
228
|
+
onCloseRef.current();
|
|
229
|
+
} finally {
|
|
230
|
+
if (alive) {
|
|
231
|
+
timer = setTimeout(() => {
|
|
232
|
+
closing = false;
|
|
233
|
+
comeBack();
|
|
234
|
+
}, REOPEN_AFTER_MS);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
213
238
|
const begin = (id, x, y, target) => {
|
|
214
|
-
if (drag || !applies()) return;
|
|
239
|
+
if (drag || closing || !applies()) return;
|
|
215
240
|
const el = target instanceof Element ? target : null;
|
|
216
241
|
if (!el || !sheet.contains(el) || el.closest(INTERACTIVE)) return;
|
|
217
242
|
const scroller = scrollRef?.current;
|
|
218
243
|
if (scroller && scroller.contains(el) && scroller.scrollTop > 0) return;
|
|
219
|
-
if (scroller?.contains(el) &&
|
|
220
|
-
|
|
244
|
+
if (scroller?.contains(el) && window.getSelection()?.isCollapsed === false) return;
|
|
245
|
+
clearTimer();
|
|
221
246
|
drag = {
|
|
222
247
|
pointerId: id,
|
|
223
248
|
startX: x,
|
|
@@ -241,6 +266,7 @@ function useSwipeToClose(sheetRef, { enabled, scrollRef, onClose, media = "(max-
|
|
|
241
266
|
drag.active = true;
|
|
242
267
|
sheet.setAttribute("data-dragging", "");
|
|
243
268
|
sheet.style.transition = "none";
|
|
269
|
+
sheet.style.animation = "none";
|
|
244
270
|
}
|
|
245
271
|
const now = performance.now();
|
|
246
272
|
const dt = now - drag.lastT;
|
|
@@ -260,17 +286,20 @@ function useSwipeToClose(sheetRef, { enabled, scrollRef, onClose, media = "(max-
|
|
|
260
286
|
suppressClick = true;
|
|
261
287
|
sheet.removeAttribute("data-dragging");
|
|
262
288
|
const close = shouldClose({ offset, height: sheet.getBoundingClientRect().height, velocity });
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if (
|
|
289
|
+
const reduceMotion = prefersReducedMotion();
|
|
290
|
+
if (!close) {
|
|
291
|
+
if (reduceMotion) resetStyles();
|
|
292
|
+
else settleBack();
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
closing = true;
|
|
296
|
+
if (reduceMotion) {
|
|
297
|
+
requestClose(resetStyles);
|
|
266
298
|
return;
|
|
267
299
|
}
|
|
268
|
-
sheet.style.transition = `transform ${SETTLE_MS}ms
|
|
269
|
-
sheet.style.transform =
|
|
270
|
-
|
|
271
|
-
if (close) onCloseRef.current();
|
|
272
|
-
resetStyles();
|
|
273
|
-
}, SETTLE_MS);
|
|
300
|
+
sheet.style.transition = `transform ${SETTLE_MS}ms ${SETTLE_EASE}`;
|
|
301
|
+
sheet.style.transform = "translate3d(0, 100%, 0)";
|
|
302
|
+
timer = setTimeout(() => requestClose(settleBack), SETTLE_MS);
|
|
274
303
|
};
|
|
275
304
|
const cancel = () => {
|
|
276
305
|
const wasActive = drag?.active === true;
|
|
@@ -324,7 +353,9 @@ function useSwipeToClose(sheetRef, { enabled, scrollRef, onClose, media = "(max-
|
|
|
324
353
|
window.addEventListener("pointercancel", onPointerCancel);
|
|
325
354
|
window.addEventListener("pointerdown", clearSuppress, true);
|
|
326
355
|
return () => {
|
|
327
|
-
|
|
356
|
+
alive = false;
|
|
357
|
+
sheet.style.animation = "";
|
|
358
|
+
clearTimer();
|
|
328
359
|
resetStyles();
|
|
329
360
|
sheet.removeEventListener("touchstart", onTouchStart);
|
|
330
361
|
sheet.removeEventListener("touchmove", onTouchMove);
|
package/dist/react/index.js.map
CHANGED
|
@@ -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. The close button stays, as the\n * single-tap alternative to the swipe (WCAG 2.5.1 and 2.5.7).\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\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\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 /** Called once the sheet has slid away. */\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 once the drag is ours. Mouse and pen use\n * pointer events. The sheet follows the finger via an inline transform and either slides\n * away (then `onClose`) or settles back.\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 let suppressClick = false;\n let settleTimer: ReturnType<typeof setTimeout> | undefined;\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 };\n\n const begin = (id: Drag['pointerId'], x: number, y: number, target: EventTarget | null) => {\n if (drag || !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) return;\n clearTimeout(settleTimer);\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 }\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 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 suppressClick = true;\n sheet.removeAttribute('data-dragging');\n\n const close = shouldClose({ offset, height: sheet.getBoundingClientRect().height, velocity });\n if (prefersReducedMotion()) {\n resetStyles();\n if (close) onCloseRef.current();\n return;\n }\n sheet.style.transition = `transform ${SETTLE_MS}ms cubic-bezier(0.22, 1, 0.36, 1)`;\n sheet.style.transform = close ? 'translate3d(0, 100%, 0)' : '';\n // A timer, not transitionend: that event never fires if nothing moved or the tab hid.\n settleTimer = setTimeout(() => {\n if (close) onCloseRef.current();\n resetStyles();\n }, SETTLE_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 const t = e.touches[0];\n if (e.touches.length !== 1 || !t) return cancel();\n begin('touch', t.clientX, t.clientY, e.target);\n };\n const onTouchMove = (e: TouchEvent) => {\n const t = e.touches[0];\n if (!t || drag?.pointerId !== 'touch') return;\n if (move(t.clientX, t.clientY) && e.cancelable) e.preventDefault();\n };\n const onTouchEnd = () => {\n if (drag?.pointerId === 'touch') end();\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', cancel);\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 clearTimeout(settleTimer);\n resetStyles();\n sheet.removeEventListener('touchstart', onTouchStart);\n sheet.removeEventListener('touchmove', onTouchMove);\n sheet.removeEventListener('touchend', onTouchEnd);\n sheet.removeEventListener('touchcancel', cancel);\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;A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S;AAAA,cACT,cAAY;AAAA,cACZ,WAAU;AAAA,cAEV,0BAAAA,KAAC,aAAU;AAAA;AAAA,UACb;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"]}
|
|
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. The close button stays, as the\n * single-tap alternative to the swipe (WCAG 2.5.1 and 2.5.7).\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 * 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\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 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 once the drag is ours. Mouse and pen use\n * pointer events. The sheet follows the finger via an inline transform and either slides\n * away (then `onClose`) or settles back.\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 */\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 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 };\n\n /** Animate back to rest, then drop the inline styles. */\n const settleBack = () => {\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 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 suppressClick = true;\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 if (reduceMotion) {\n // No slide: close from where the finger let go, and snap back if it stays open.\n requestClose(resetStyles);\n return;\n }\n sheet.style.transition = `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 timer = setTimeout(() => requestClose(settleBack), SETTLE_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 const t = e.touches[0];\n if (e.touches.length !== 1 || !t) return cancel();\n begin('touch', t.clientX, t.clientY, e.target);\n };\n const onTouchMove = (e: TouchEvent) => {\n const t = e.touches[0];\n if (!t || drag?.pointerId !== 'touch') return;\n if (move(t.clientX, t.clientY) && e.cancelable) e.preventDefault();\n };\n const onTouchEnd = () => {\n if (drag?.pointerId === 'touch') end();\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', cancel);\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 sheet.style.animation = '';\n clearTimer();\n resetStyles();\n sheet.removeEventListener('touchstart', onTouchStart);\n sheet.removeEventListener('touchmove', onTouchMove);\n sheet.removeEventListener('touchend', onTouchEnd);\n sheet.removeEventListener('touchcancel', cancel);\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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BAAAF;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MAEJ,GAAG,EAAE,UAAU,MAAM;AAAA,MACtB,UAAU;AAAA,MACV,mBAAiB;AAAA,MAEjB,SAAS,MAAM;AACb,YAAI,KAAM,SAAQ;AAAA,MACpB;AAAA,MAGA,eAAe,CAAC,MAAM;AACpB,uBAAe,UAAU,0BAA0B,KAAK,UAAU,CAAC;AAAA,MACrE;AAAA,MACA,aAAa,CAAC,MAAM;AAClB,YAAI,eAAe,WAAW,UAAU,CAAC,EAAG,SAAQ;AACpD,uBAAe,UAAU;AAAA,MAC3B;AAAA,MACA,WAAW,GAAG,gBAAgB,SAAS;AAAA,MAEtC;AAAA,wBAAgB,gBAAAD,KAAC,SAAI,WAAU,wBAAuB,eAAY,QAAO;AAAA,QAC1E,gBAAAC,MAAC,YAAO,WAAU,uBAChB;AAAA,0BAAAA,MAAC,SAAI,WAAU,wBACZ;AAAA,uBAAW,gBAAAD,KAAC,OAAE,WAAU,wBAAwB,mBAAQ;AAAA,YACzD,gBAAAA,KAAC,QAAG,IAAI,SAAS,WAAU,sBACxB,iBACH;AAAA,aACF;AAAA,UACA,gBAAAA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS;AAAA,cACT,cAAY;AAAA,cACZ,WAAU;AAAA,cAEV,0BAAAA,KAAC,aAAU;AAAA;AAAA,UACb;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/dist/tailwind.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sofyan/glass",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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,
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"./glass.css": "./dist/glass.css",
|
|
29
29
|
"./tailwind.css": "./dist/tailwind.css",
|
|
30
|
+
"./dark.css": "./dist/dark.css",
|
|
30
31
|
"./react": {
|
|
31
32
|
"types": "./dist/react/index.d.ts",
|
|
32
33
|
"import": "./dist/react/index.js"
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
"prettier": "^3.6.0",
|
|
64
65
|
"react": "^19.2.0",
|
|
65
66
|
"react-dom": "^19.2.0",
|
|
66
|
-
"tsup": "^
|
|
67
|
+
"tsup": "^9.0.0",
|
|
67
68
|
"typescript": "^5.9.3",
|
|
68
69
|
"vitest": "^4.1.12"
|
|
69
70
|
},
|