glasslikeui 1.9.0 → 1.10.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 +892 -24
- package/dist/actions/adaptiveTone.d.ts +50 -0
- package/dist/actions/adaptiveTone.js +569 -0
- package/dist/actions/alertLogic.d.ts +67 -0
- package/dist/actions/alertLogic.js +123 -0
- package/dist/actions/anchorPlacement.d.ts +92 -0
- package/dist/actions/anchorPlacement.js +137 -0
- package/dist/actions/dragSnap.d.ts +1 -1
- package/dist/actions/dragSnapMath.d.ts +70 -0
- package/dist/actions/dragSnapMath.js +115 -0
- package/dist/actions/glassToneLogic.d.ts +182 -0
- package/dist/actions/glassToneLogic.js +513 -0
- package/dist/actions/heightTransition.d.ts +32 -0
- package/dist/actions/heightTransition.js +64 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +1 -0
- package/dist/actions/inertSiblings.js +20 -4
- package/dist/actions/menuLogic.d.ts +40 -0
- package/dist/actions/menuLogic.js +68 -0
- package/dist/actions/modalDialog.d.ts +19 -0
- package/dist/actions/modalDialog.js +48 -0
- package/dist/actions/popoverLogic.d.ts +25 -0
- package/dist/actions/popoverLogic.js +48 -0
- package/dist/actions/rovingIndex.d.ts +30 -0
- package/dist/actions/rovingIndex.js +49 -0
- package/dist/actions/scrollRunTracker.d.ts +36 -0
- package/dist/actions/scrollRunTracker.js +77 -0
- package/dist/actions/scrollUnder.d.ts +21 -0
- package/dist/actions/scrollUnder.js +29 -0
- package/dist/actions/segmentedLogic.d.ts +38 -0
- package/dist/actions/segmentedLogic.js +59 -0
- package/dist/actions/sheetLogic.d.ts +43 -0
- package/dist/actions/sheetLogic.js +71 -0
- package/dist/actions/sliderLogic.d.ts +29 -0
- package/dist/actions/sliderLogic.js +53 -0
- package/dist/actions/swipeActions.d.ts +46 -2
- package/dist/actions/swipeActions.js +267 -46
- package/dist/actions/tabBarMinimize.d.ts +31 -0
- package/dist/actions/tabBarMinimize.js +38 -0
- package/dist/actions/tabViewLogic.d.ts +47 -0
- package/dist/actions/tabViewLogic.js +71 -0
- package/dist/actions/toggleKnobLogic.d.ts +57 -0
- package/dist/actions/toggleKnobLogic.js +66 -0
- package/dist/actions/toolbarFocus.d.ts +44 -0
- package/dist/actions/toolbarFocus.js +228 -0
- package/dist/actions/topLayer.d.ts +12 -0
- package/dist/actions/topLayer.js +18 -0
- package/dist/components/dialog/ActionSheet.svelte +457 -0
- package/dist/components/dialog/ActionSheet.svelte.d.ts +25 -0
- package/dist/components/dialog/Alert.svelte +337 -0
- package/dist/components/dialog/Alert.svelte.d.ts +28 -0
- package/dist/components/dialog/index.d.ts +6 -0
- package/dist/components/dialog/index.js +6 -0
- package/dist/components/glass/Glass.svelte +49 -17
- package/dist/components/glass/Glass.svelte.d.ts +8 -0
- package/dist/components/glass/GlassSection.svelte +9 -1
- package/dist/components/glass/LensFilters.svelte +4 -2
- package/dist/components/glass/Popover.svelte +379 -0
- package/dist/components/glass/Popover.svelte.d.ts +30 -0
- package/dist/components/glass/Sheet.svelte +470 -103
- package/dist/components/glass/Sheet.svelte.d.ts +55 -7
- package/dist/components/glass/index.d.ts +3 -0
- package/dist/components/glass/index.js +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +4 -0
- package/dist/components/interactive/Badge.svelte +97 -6
- package/dist/components/interactive/Badge.svelte.d.ts +13 -2
- package/dist/components/interactive/Button.svelte +162 -20
- package/dist/components/interactive/Button.svelte.d.ts +14 -1
- package/dist/components/interactive/IconButton.svelte +214 -4
- package/dist/components/interactive/IconButton.svelte.d.ts +2 -1
- package/dist/components/interactive/ProgressView.svelte +306 -0
- package/dist/components/interactive/ProgressView.svelte.d.ts +25 -0
- package/dist/components/interactive/Segment.d.ts +14 -0
- package/dist/components/interactive/Segment.js +1 -0
- package/dist/components/interactive/SegmentedControl.svelte +399 -0
- package/dist/components/interactive/SegmentedControl.svelte.d.ts +17 -0
- package/dist/components/interactive/Slider.svelte +299 -0
- package/dist/components/interactive/Slider.svelte.d.ts +23 -0
- package/dist/components/interactive/TabView.svelte +573 -41
- package/dist/components/interactive/TabView.svelte.d.ts +25 -0
- package/dist/components/interactive/Toggle.svelte +287 -16
- package/dist/components/interactive/Toggle.svelte.d.ts +12 -0
- package/dist/components/interactive/index.d.ts +4 -0
- package/dist/components/interactive/index.js +3 -0
- package/dist/components/list/List.svelte +41 -17
- package/dist/components/list/List.svelte.d.ts +1 -0
- package/dist/components/list/ListRow.svelte +208 -47
- package/dist/components/list/ListRow.svelte.d.ts +16 -1
- package/dist/components/menu/Menu.svelte +51 -27
- package/dist/components/menu/Menu.svelte.d.ts +5 -0
- package/dist/components/menu/MenuItem.svelte +82 -25
- package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
- package/dist/components/menu/MenuSection.svelte +95 -0
- package/dist/components/menu/MenuSection.svelte.d.ts +18 -0
- package/dist/components/menu/MenuSubmenu.svelte +196 -0
- package/dist/components/menu/MenuSubmenu.svelte.d.ts +11 -0
- package/dist/components/menu/index.d.ts +4 -1
- package/dist/components/menu/index.js +3 -1
- package/dist/components/navigation/NavigationBar.svelte +97 -15
- package/dist/components/navigation/NavigationBar.svelte.d.ts +6 -0
- package/dist/components/toolbar/Toolbar.svelte +43 -0
- package/dist/components/toolbar/Toolbar.svelte.d.ts +13 -0
- package/dist/components/toolbar/ToolbarItemGroup.svelte +45 -0
- package/dist/components/toolbar/ToolbarItemGroup.svelte.d.ts +14 -0
- package/dist/components/toolbar/ToolbarSpacer.svelte +36 -0
- package/dist/components/toolbar/ToolbarSpacer.svelte.d.ts +12 -0
- package/dist/components/toolbar/index.d.ts +7 -0
- package/dist/components/toolbar/index.js +7 -0
- package/dist/components/typography/Text.svelte +9 -1
- package/dist/constants/alertAction.d.ts +19 -0
- package/dist/constants/alertAction.js +1 -0
- package/dist/constants/badge.d.ts +32 -0
- package/dist/constants/badge.js +47 -0
- package/dist/constants/buttons.d.ts +45 -0
- package/dist/constants/buttons.js +52 -0
- package/dist/constants/colors.d.ts +9 -4
- package/dist/constants/colors.js +9 -4
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.js +3 -0
- package/dist/constants/progress.d.ts +56 -0
- package/dist/constants/progress.js +75 -0
- package/dist/constants/variants.d.ts +6 -2
- package/dist/constants/variants.js +2 -2
- package/dist/styles/glasslikeui.css +135 -1
- package/dist/styles/lens.css +21 -19
- package/dist/styles/squircle.css +17 -7
- package/package.json +1 -1
|
@@ -1,36 +1,23 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts" module>
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import {
|
|
4
|
-
import { getIconPath } from '../../icons';
|
|
5
|
-
import { dragSurface } from '../../actions/dragSurface';
|
|
6
|
-
import {
|
|
7
|
-
detentFractions,
|
|
8
|
-
isDragStartAllowed,
|
|
9
|
-
sheetYForFraction,
|
|
10
|
-
detentAt,
|
|
11
|
-
type SheetDetentName
|
|
12
|
-
} from '../../actions/dragSnapMath';
|
|
13
|
-
import { startSheetExit, type SheetExit } from '../../actions/sheetExit';
|
|
14
|
-
import { inertSiblings } from '../../actions/inertSiblings';
|
|
15
|
-
import { trapTab } from '../../actions/focusTrap';
|
|
3
|
+
import type { SheetDetent, SheetDetentName, SheetLabels } from '../../actions/dragSnapMath';
|
|
16
4
|
|
|
17
|
-
|
|
18
|
-
const DRAG_REGIONS = '.sheet-handle-container, .sheet-header';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The body, where a press only arms a drag that starts once it pulls down
|
|
22
|
-
* with the content at the top, so taps and scrolling there keep working.
|
|
23
|
-
*/
|
|
24
|
-
const BODY_DRAG_REGION = '.sheet-content';
|
|
25
|
-
|
|
26
|
-
interface Props {
|
|
5
|
+
export interface SheetProps<D extends SheetDetent = SheetDetentName> {
|
|
27
6
|
isOpen?: boolean;
|
|
28
7
|
title?: string;
|
|
29
8
|
children: Snippet;
|
|
30
9
|
onClose?: () => void;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
10
|
+
/** Called with the detent the sheet settles on after a drag or a key press. */
|
|
11
|
+
onDetentChange?: (detent: D) => void;
|
|
12
|
+
/**
|
|
13
|
+
* The sizes the sheet snaps to: the named sizes, or custom ones as
|
|
14
|
+
* `{ fraction }` (a share of the viewport height, like SwiftUI's
|
|
15
|
+
* `.fraction`) or `{ height }` (CSS pixels, like `.height`). Mix freely in
|
|
16
|
+
* any order: the sheet sorts them, and counts sizes that match once.
|
|
17
|
+
*/
|
|
18
|
+
detents?: readonly D[];
|
|
19
|
+
/** The detent the sheet opens at. A custom one matches by value. */
|
|
20
|
+
initialDetent?: D;
|
|
34
21
|
showHandle?: boolean;
|
|
35
22
|
draggable?: boolean;
|
|
36
23
|
/**
|
|
@@ -47,8 +34,68 @@
|
|
|
47
34
|
* leads.
|
|
48
35
|
*/
|
|
49
36
|
closePlacement?: 'leading' | 'trailing';
|
|
37
|
+
/**
|
|
38
|
+
* `false` shows a non-modal sheet, like a SwiftUI sheet with background
|
|
39
|
+
* interaction enabled: no dimmed backdrop, and the page behind stays
|
|
40
|
+
* usable. Focus is not trapped and the page is not made inert. Escape
|
|
41
|
+
* closes it only while focus is inside it. Default `true`.
|
|
42
|
+
*/
|
|
43
|
+
modal?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Floats the sheet in from the screen edges with rounded bottom corners, as
|
|
46
|
+
* iOS 26 shows sheets below full height. At a full height detent (`large`
|
|
47
|
+
* or taller) it meets the edges and turns more opaque. Default `true`.
|
|
48
|
+
*/
|
|
49
|
+
inset?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The grabber's spoken words, to translate them: its name (`size`), the
|
|
52
|
+
* named detents and `pixels(n)` for a height detent. Any left out stay
|
|
53
|
+
* in English.
|
|
54
|
+
*/
|
|
55
|
+
labels?: Partial<SheetLabels>;
|
|
50
56
|
class?: string;
|
|
51
57
|
}
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<script lang="ts" generics="D extends SheetDetent = SheetDetentName">
|
|
61
|
+
import { untrack } from 'svelte';
|
|
62
|
+
import { fromAction } from 'svelte/attachments';
|
|
63
|
+
import { getIconPath } from '../../icons';
|
|
64
|
+
import { dragSurface } from '../../actions/dragSurface';
|
|
65
|
+
import {
|
|
66
|
+
detentLabel,
|
|
67
|
+
sheetLabels,
|
|
68
|
+
isDragStartAllowed,
|
|
69
|
+
isFullHeightFraction,
|
|
70
|
+
clampIndex,
|
|
71
|
+
detentKey,
|
|
72
|
+
isDetentOffered,
|
|
73
|
+
levelIndexOf,
|
|
74
|
+
openingDetent,
|
|
75
|
+
normalizeDetents,
|
|
76
|
+
sheetYForFraction,
|
|
77
|
+
detentAt
|
|
78
|
+
} from '../../actions/dragSnapMath';
|
|
79
|
+
import { startSheetExit, type SheetExit } from '../../actions/sheetExit';
|
|
80
|
+
import { inertSiblings } from '../../actions/inertSiblings';
|
|
81
|
+
import { trapTab } from '../../actions/focusTrap';
|
|
82
|
+
import {
|
|
83
|
+
canCloseSheet,
|
|
84
|
+
closeButtonLeads,
|
|
85
|
+
grabberKeyTarget,
|
|
86
|
+
isAtScrollTop,
|
|
87
|
+
sheetKeyAction,
|
|
88
|
+
shouldReturnFocus
|
|
89
|
+
} from '../../actions/sheetLogic';
|
|
90
|
+
|
|
91
|
+
/** The parts of the sheet a drag starts from on the press: the handle and the header. */
|
|
92
|
+
const DRAG_REGIONS = '.sheet-handle-container, .sheet-header';
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The body, where a press only arms a drag that starts once it pulls down
|
|
96
|
+
* with the content at the top, so taps and scrolling there keep working.
|
|
97
|
+
*/
|
|
98
|
+
const BODY_DRAG_REGION = '.sheet-content';
|
|
52
99
|
|
|
53
100
|
let {
|
|
54
101
|
isOpen = $bindable(false),
|
|
@@ -56,25 +103,66 @@
|
|
|
56
103
|
children,
|
|
57
104
|
onClose,
|
|
58
105
|
onDetentChange,
|
|
59
|
-
detents = ['medium', 'large'],
|
|
60
|
-
initialDetent = 'medium',
|
|
106
|
+
detents = ['medium', 'large'] as readonly SheetDetent[] as readonly D[],
|
|
107
|
+
initialDetent = 'medium' as D,
|
|
61
108
|
showHandle = true,
|
|
62
109
|
draggable = true,
|
|
63
110
|
interactiveDismissDisabled = false,
|
|
64
111
|
closePlacement = 'leading',
|
|
112
|
+
modal = true,
|
|
113
|
+
inset = true,
|
|
114
|
+
labels,
|
|
65
115
|
class: className = ''
|
|
66
|
-
}:
|
|
116
|
+
}: SheetProps<D> = $props();
|
|
67
117
|
|
|
68
118
|
const uid = $props.id();
|
|
69
119
|
const titleId = `${uid}-title`;
|
|
70
120
|
|
|
71
|
-
const closeLeads = $derived(closePlacement
|
|
121
|
+
const closeLeads = $derived(closeButtonLeads(closePlacement));
|
|
122
|
+
|
|
123
|
+
// Height detents are a share of the viewport, so they follow its height.
|
|
124
|
+
let viewportHeight = $state(typeof window === 'undefined' ? 0 : window.innerHeight);
|
|
125
|
+
// Sorted smallest first and deduplicated, so the grabber, the slider value
|
|
126
|
+
// and the drag all walk the sizes in order. Each level keeps the detent the
|
|
127
|
+
// consumer passed, which is what onDetentChange reports.
|
|
128
|
+
const levels = $derived(normalizeDetents(detents, viewportHeight));
|
|
129
|
+
const fractions = $derived(levels.map((level) => level.fraction));
|
|
130
|
+
// The selection is the detent itself, not its place in the list: a resize
|
|
131
|
+
// can reorder height detents against fraction ones, and the sheet must stay
|
|
132
|
+
// on the size the user picked. It starts at initialDetent (the smallest when
|
|
133
|
+
// that is not offered), and starts over only when initialDetent's value
|
|
134
|
+
// changes. The key is a string, so a new object with the same value, as an
|
|
135
|
+
// inline or spread literal makes on every update, changes nothing.
|
|
136
|
+
const initialKey = $derived(detentKey(initialDetent));
|
|
137
|
+
let selectedDetent = $derived.by<SheetDetent>(() => {
|
|
138
|
+
void initialKey;
|
|
139
|
+
return untrack(() => openingDetent(levels, initialDetent, viewportHeight));
|
|
140
|
+
});
|
|
141
|
+
// The level with the selected detent's size, or the nearest when that size
|
|
142
|
+
// is no longer offered. Clamped, so an empty list never yields an index past it.
|
|
143
|
+
const currentIndex = $derived(
|
|
144
|
+
clampIndex(levelIndexOf(levels, selectedDetent, viewportHeight), levels.length)
|
|
145
|
+
);
|
|
146
|
+
let sheetEl = $state<HTMLElement | undefined>();
|
|
72
147
|
|
|
73
|
-
|
|
74
|
-
|
|
148
|
+
// The grabber is a vertical slider over the detents when there is more than
|
|
149
|
+
// one to move between.
|
|
150
|
+
// A detents list that no longer offers the selected size moves the sheet to
|
|
151
|
+
// the nearest one. Adopt it as the selection and report it, so the
|
|
152
|
+
// consumer's state follows what is on screen.
|
|
153
|
+
$effect(() => {
|
|
154
|
+
const shown = levels[currentIndex]?.detent;
|
|
155
|
+
if (shown === undefined || isDetentOffered(levels, selectedDetent, viewportHeight)) return;
|
|
156
|
+
untrack(() => {
|
|
157
|
+
selectedDetent = shown;
|
|
158
|
+
onDetentChange?.(shown);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
75
161
|
|
|
76
|
-
|
|
77
|
-
|
|
162
|
+
const words = $derived(sheetLabels(labels));
|
|
163
|
+
const grabberActive = $derived(showHandle && draggable && levels.length > 1);
|
|
164
|
+
const currentDetent = $derived(levels[currentIndex]?.detent);
|
|
165
|
+
const fullHeight = $derived(isFullHeightFraction(detentAt(fractions, currentIndex)));
|
|
78
166
|
|
|
79
167
|
// The sheet stays in the DOM after isOpen turns false, for as long as its exit
|
|
80
168
|
// animation runs. `mounted` is set once it has been shown and cleared when the
|
|
@@ -108,19 +196,26 @@
|
|
|
108
196
|
}
|
|
109
197
|
|
|
110
198
|
function finishExit() {
|
|
199
|
+
const active = document.activeElement;
|
|
200
|
+
const giveBack = shouldReturnFocus(
|
|
201
|
+
modal,
|
|
202
|
+
!active || active === document.body || (sheetEl?.contains(active) ?? false)
|
|
203
|
+
);
|
|
111
204
|
exit = null;
|
|
112
205
|
mounted = false;
|
|
113
206
|
// The opener sits behind the sheet, so it cannot take focus until the page
|
|
114
207
|
// is no longer inert.
|
|
115
208
|
releaseInert?.();
|
|
116
|
-
if (opener instanceof HTMLElement && opener.isConnected)
|
|
209
|
+
if (giveBack && opener instanceof HTMLElement && opener.isConnected) {
|
|
210
|
+
opener.focus({ preventScroll: true });
|
|
211
|
+
}
|
|
117
212
|
opener = null;
|
|
118
213
|
}
|
|
119
214
|
|
|
120
215
|
function close() {
|
|
121
216
|
// A closed or already closing sheet ignores repeat requests, so onClose
|
|
122
217
|
// fires exactly once per close.
|
|
123
|
-
if (!isOpen
|
|
218
|
+
if (!canCloseSheet(isOpen, exit !== null)) return;
|
|
124
219
|
beginExit();
|
|
125
220
|
isOpen = false;
|
|
126
221
|
onClose?.();
|
|
@@ -128,11 +223,18 @@
|
|
|
128
223
|
|
|
129
224
|
function handleKeydown(e: KeyboardEvent) {
|
|
130
225
|
// The window listener is always attached, so a closed sheet would
|
|
131
|
-
// otherwise fire onClose on every Escape.
|
|
132
|
-
|
|
133
|
-
|
|
226
|
+
// otherwise fire onClose on every Escape: sheetKeyAction ignores keys then.
|
|
227
|
+
// A key something inside already handled, such as Escape closing a menu
|
|
228
|
+
// or a popover in the sheet, is not the sheet's.
|
|
229
|
+
if (e.defaultPrevented) return;
|
|
230
|
+
const action = sheetKeyAction(e.key, isOpen, {
|
|
231
|
+
modal,
|
|
232
|
+
focusInside: sheetEl?.contains(document.activeElement) ?? false
|
|
233
|
+
});
|
|
234
|
+
if (action === 'close') {
|
|
235
|
+
e.preventDefault();
|
|
134
236
|
close();
|
|
135
|
-
} else if (
|
|
237
|
+
} else if (action === 'trap' && sheetEl) {
|
|
136
238
|
trapTab(e, sheetEl);
|
|
137
239
|
}
|
|
138
240
|
}
|
|
@@ -144,9 +246,18 @@
|
|
|
144
246
|
}
|
|
145
247
|
|
|
146
248
|
function handleSnap(index: number) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
249
|
+
const detent = levels[index]?.detent;
|
|
250
|
+
if (detent === undefined) return;
|
|
251
|
+
selectedDetent = detent;
|
|
252
|
+
onDetentChange?.(detent);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Arrow keys, Page Up and Down, Home and End on the grabber change the detent. */
|
|
256
|
+
function handleGrabberKey(e: KeyboardEvent) {
|
|
257
|
+
const next = grabberKeyTarget(e.key, currentIndex, levels.length);
|
|
258
|
+
if (next === null) return;
|
|
259
|
+
e.preventDefault();
|
|
260
|
+
if (next !== currentIndex) handleSnap(next);
|
|
150
261
|
}
|
|
151
262
|
|
|
152
263
|
function canStartDrag(event: PointerEvent): boolean {
|
|
@@ -168,7 +279,7 @@
|
|
|
168
279
|
|
|
169
280
|
function trackScrollTop(node: HTMLElement) {
|
|
170
281
|
// Content is mounted afresh on every open, so start from its real offset.
|
|
171
|
-
const sync = () => (contentAtTop = node.scrollTop
|
|
282
|
+
const sync = () => (contentAtTop = isAtScrollTop(node.scrollTop));
|
|
172
283
|
sync();
|
|
173
284
|
node.addEventListener('scroll', sync, { passive: true });
|
|
174
285
|
return () => node.removeEventListener('scroll', sync);
|
|
@@ -199,7 +310,7 @@
|
|
|
199
310
|
// The page behind a modal dialog is inert for as long as the sheet is on screen.
|
|
200
311
|
// Declared after the focus effect so the opener is recorded before it goes inert.
|
|
201
312
|
$effect(() => {
|
|
202
|
-
if (!sheetEl) return;
|
|
313
|
+
if (!sheetEl || !modal) return;
|
|
203
314
|
const release = inertSiblings(sheetEl);
|
|
204
315
|
releaseInert = release;
|
|
205
316
|
return () => {
|
|
@@ -208,8 +319,9 @@
|
|
|
208
319
|
};
|
|
209
320
|
});
|
|
210
321
|
|
|
322
|
+
// Only a modal sheet locks the page's scroll: a non-modal one leaves it usable.
|
|
211
323
|
$effect(() => {
|
|
212
|
-
if (present) {
|
|
324
|
+
if (present && modal) {
|
|
213
325
|
document.body.style.overflow = 'hidden';
|
|
214
326
|
}
|
|
215
327
|
return () => {
|
|
@@ -220,7 +332,7 @@
|
|
|
220
332
|
$effect(() => () => exit?.cancel());
|
|
221
333
|
</script>
|
|
222
334
|
|
|
223
|
-
<svelte:window onkeydown={handleKeydown} />
|
|
335
|
+
<svelte:window onkeydown={handleKeydown} bind:innerHeight={viewportHeight} />
|
|
224
336
|
|
|
225
337
|
{#snippet closeButton()}
|
|
226
338
|
<button type="button" class="sheet-close-btn" onclick={close} aria-label="Close">
|
|
@@ -242,62 +354,93 @@
|
|
|
242
354
|
</button>
|
|
243
355
|
{/snippet}
|
|
244
356
|
|
|
245
|
-
{#
|
|
357
|
+
{#snippet panel()}
|
|
246
358
|
<div
|
|
247
|
-
|
|
359
|
+
bind:this={sheetEl}
|
|
360
|
+
class="sheet-container {className}"
|
|
361
|
+
style:--sheet-hidden-height={sheetYForFraction(detentAt(fractions, currentIndex))}
|
|
248
362
|
class:open={isOpen}
|
|
249
363
|
data-sheet-state={sheetState}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
364
|
+
role="dialog"
|
|
365
|
+
aria-modal={modal ? 'true' : undefined}
|
|
366
|
+
aria-labelledby={title ? titleId : undefined}
|
|
367
|
+
aria-label={title ? undefined : 'Sheet'}
|
|
368
|
+
tabindex="-1"
|
|
369
|
+
{@attach fromAction(dragSurface, () => ({
|
|
370
|
+
detents: fractions,
|
|
371
|
+
initial: currentIndex,
|
|
372
|
+
disabled: !draggable || (fractions.length < 2 && interactiveDismissDisabled),
|
|
373
|
+
canStart: canStartDrag,
|
|
374
|
+
canStartAfterSlop: canStartBodyDrag,
|
|
375
|
+
onSnap: handleSnap,
|
|
376
|
+
...(interactiveDismissDisabled ? {} : { onDismiss: close })
|
|
377
|
+
}))}
|
|
253
378
|
>
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
onSnap: handleSnap,
|
|
272
|
-
...(interactiveDismissDisabled ? {} : { onDismiss: close })
|
|
273
|
-
}))}
|
|
274
|
-
>
|
|
275
|
-
{#if showHandle}
|
|
379
|
+
{#if showHandle}
|
|
380
|
+
{#if grabberActive}
|
|
381
|
+
<div
|
|
382
|
+
class="sheet-handle-container"
|
|
383
|
+
role="slider"
|
|
384
|
+
tabindex="0"
|
|
385
|
+
aria-label={words.size}
|
|
386
|
+
aria-orientation="vertical"
|
|
387
|
+
aria-valuemin={1}
|
|
388
|
+
aria-valuemax={levels.length}
|
|
389
|
+
aria-valuenow={currentIndex + 1}
|
|
390
|
+
aria-valuetext={currentDetent === undefined ? undefined : detentLabel(currentDetent, words)}
|
|
391
|
+
onkeydown={handleGrabberKey}
|
|
392
|
+
>
|
|
393
|
+
<div class="sheet-handle"></div>
|
|
394
|
+
</div>
|
|
395
|
+
{:else}
|
|
276
396
|
<div class="sheet-handle-container">
|
|
277
397
|
<div class="sheet-handle"></div>
|
|
278
398
|
</div>
|
|
279
399
|
{/if}
|
|
400
|
+
{/if}
|
|
401
|
+
|
|
402
|
+
{#if title}
|
|
403
|
+
<header class="sheet-header" data-close-placement={closeLeads ? 'leading' : 'trailing'}>
|
|
404
|
+
{#if closeLeads}
|
|
405
|
+
{@render closeButton()}
|
|
406
|
+
{:else}
|
|
407
|
+
<div class="sheet-spacer"></div>
|
|
408
|
+
{/if}
|
|
409
|
+
<h2 class="sheet-title" id={titleId}>{title}</h2>
|
|
410
|
+
{#if closeLeads}
|
|
411
|
+
<div class="sheet-spacer"></div>
|
|
412
|
+
{:else}
|
|
413
|
+
{@render closeButton()}
|
|
414
|
+
{/if}
|
|
415
|
+
</header>
|
|
416
|
+
{/if}
|
|
417
|
+
|
|
418
|
+
<div class="sheet-content" data-scroll-at-top={contentAtTop} {@attach trackScrollTop}>
|
|
419
|
+
{@render children()}
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
{/snippet}
|
|
280
423
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
{
|
|
296
|
-
|
|
297
|
-
<div class="sheet-content" data-scroll-at-top={contentAtTop} {@attach trackScrollTop}>
|
|
298
|
-
{@render children()}
|
|
424
|
+
{#if present}
|
|
425
|
+
<div
|
|
426
|
+
class="sheet-backdrop"
|
|
427
|
+
class:open={isOpen}
|
|
428
|
+
data-sheet-state={sheetState}
|
|
429
|
+
data-modal={modal ? 'true' : 'false'}
|
|
430
|
+
onclick={handleBackdropClick}
|
|
431
|
+
onkeydown={(e) => e.key === 'Escape' && !e.defaultPrevented && close()}
|
|
432
|
+
role="presentation"
|
|
433
|
+
>
|
|
434
|
+
{#if inset}
|
|
435
|
+
<!-- Clips the sheet above the bottom edge and rounds its lower corners.
|
|
436
|
+
It ignores the pointer, so a press above the sheet still reaches the
|
|
437
|
+
backdrop. -->
|
|
438
|
+
<div class="sheet-inset-frame" data-full-height={fullHeight ? 'true' : 'false'}>
|
|
439
|
+
{@render panel()}
|
|
299
440
|
</div>
|
|
300
|
-
|
|
441
|
+
{:else}
|
|
442
|
+
{@render panel()}
|
|
443
|
+
{/if}
|
|
301
444
|
</div>
|
|
302
445
|
{/if}
|
|
303
446
|
|
|
@@ -373,17 +516,33 @@
|
|
|
373
516
|
border-radius: 3px;
|
|
374
517
|
}
|
|
375
518
|
|
|
519
|
+
/* The grabber's keyboard focus ring goes on the pill: the sheet clips its
|
|
520
|
+
own edges, so a ring around the full width row would be cut off. :where
|
|
521
|
+
keeps it at zero specificity, so a page's own focus rules win. */
|
|
522
|
+
.sheet-handle-container:focus-visible {
|
|
523
|
+
outline: none;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
:where(.sheet-handle-container:focus-visible .sheet-handle) {
|
|
527
|
+
outline: var(--glass-focus-ring-width, 2px) solid var(--glass-focus-ring-color, var(--glass-focus-ring-color-default, #9ecbff));
|
|
528
|
+
outline-offset: var(--glass-focus-ring-offset, 2px);
|
|
529
|
+
box-shadow: 0 0 0 var(--glass-focus-ring-offset, 2px) var(--glass-focus-ring-halo-color, var(--glass-focus-ring-halo-color-default, #000000));
|
|
530
|
+
}
|
|
531
|
+
|
|
376
532
|
/* Title centred between the close button and an empty cell of the same
|
|
377
533
|
width, so the title stays centred whatever its length. The header is also a
|
|
378
534
|
drag region. */
|
|
379
535
|
.sheet-header {
|
|
380
536
|
padding: 0 var(--spacing-md);
|
|
381
537
|
height: 56px;
|
|
382
|
-
border-bottom: 1px solid var(--glass-divider);
|
|
383
538
|
display: grid;
|
|
384
539
|
grid-template-columns: 36px minmax(0, 1fr) 36px;
|
|
385
540
|
align-items: center;
|
|
386
541
|
gap: var(--spacing-sm);
|
|
542
|
+
/* The library does not set --color-text, so fall back to the theme's own
|
|
543
|
+
text colour: unset, the header took the page's, black by default, onto
|
|
544
|
+
a dark sheet. The close button glyph uses the same colour. */
|
|
545
|
+
color: var(--glass-fg, var(--color-text, var(--glass-text-color-default, #f5f5f7)));
|
|
387
546
|
}
|
|
388
547
|
|
|
389
548
|
/* Grid lines are logical: column 1 is the inline start, so a leading close
|
|
@@ -403,7 +562,25 @@
|
|
|
403
562
|
grid-column: 3;
|
|
404
563
|
}
|
|
405
564
|
|
|
565
|
+
/* The button is narrower than its column. Each placement pushes it to the
|
|
566
|
+
column's side nearest the title, so the two sit the same distance in from
|
|
567
|
+
the header's padding and are exact mirrors. */
|
|
568
|
+
.sheet-header[data-close-placement='leading'] .sheet-close-btn {
|
|
569
|
+
justify-self: end;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
.sheet-header[data-close-placement='trailing'] .sheet-close-btn {
|
|
573
|
+
justify-self: start;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/* The close button is the iOS 26 glass button, as on a toolbar. Sheet is a
|
|
577
|
+
primitive and cannot import IconButton, so these rules repeat the plain
|
|
578
|
+
glass IconButton's, with its glass variant values set here rather than
|
|
579
|
+
inline. A test keeps the two the same. */
|
|
406
580
|
.sheet-close-btn {
|
|
581
|
+
--btn-glass-blur: 10px;
|
|
582
|
+
--btn-glass-saturation: 1.4;
|
|
583
|
+
--btn-glass-opacity: 0.3;
|
|
407
584
|
display: inline-flex;
|
|
408
585
|
align-items: center;
|
|
409
586
|
justify-content: center;
|
|
@@ -412,16 +589,131 @@
|
|
|
412
589
|
padding: 0;
|
|
413
590
|
border: none;
|
|
414
591
|
border-radius: 50%;
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
color: var(--color-text-
|
|
592
|
+
position: relative;
|
|
593
|
+
background: transparent;
|
|
594
|
+
/* The theme's text colour when the page sets no --color-text. */
|
|
595
|
+
color: var(--glass-fg, var(--color-text, var(--glass-text-color-default, #f5f5f7)));
|
|
596
|
+
isolation: isolate;
|
|
419
597
|
cursor: pointer;
|
|
420
|
-
|
|
598
|
+
/* Named properties rather than all, which the sheet never animates. */
|
|
599
|
+
transition:
|
|
600
|
+
background var(--transition-fast),
|
|
601
|
+
opacity var(--transition-fast),
|
|
602
|
+
scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.sheet-close-btn::before {
|
|
606
|
+
content: '';
|
|
607
|
+
position: absolute;
|
|
608
|
+
inset: 0;
|
|
609
|
+
z-index: -1;
|
|
610
|
+
border-radius: inherit;
|
|
611
|
+
background: var(--glass-button-fill, rgba(62, 62, 64, 0.75));
|
|
612
|
+
backdrop-filter: blur(var(--btn-glass-blur)) saturate(var(--btn-glass-saturation));
|
|
613
|
+
-webkit-backdrop-filter: blur(var(--btn-glass-blur)) saturate(var(--btn-glass-saturation));
|
|
614
|
+
pointer-events: none;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
.sheet-close-btn::after {
|
|
618
|
+
content: '';
|
|
619
|
+
position: absolute;
|
|
620
|
+
inset: 0;
|
|
621
|
+
z-index: -1;
|
|
622
|
+
border-radius: inherit;
|
|
623
|
+
pointer-events: none;
|
|
624
|
+
border: var(--glass-border-width) solid var(--glass-border);
|
|
625
|
+
box-shadow: inset 0 1px 0 0 var(--glass-highlight);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
.sheet-close-btn > :global(*) {
|
|
629
|
+
position: relative;
|
|
630
|
+
z-index: 2;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.sheet-close-btn:hover::before {
|
|
634
|
+
background: var(--glass-button-fill-hover, var(--glass-button-fill, rgba(50, 50, 52, 0.75)));
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
.sheet-close-btn:active::before {
|
|
638
|
+
background: var(--glass-button-fill-active, var(--glass-button-fill, rgba(38, 38, 40, 0.75)));
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/* Pressed, glass grows a little and settles back with a small overshoot, as
|
|
642
|
+
iOS 26 glass scales and bounces (WWDC25 323). Not under reduced motion. */
|
|
643
|
+
.sheet-close-btn:active {
|
|
644
|
+
scale: 1.04;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
@media (prefers-reduced-motion: reduce) {
|
|
648
|
+
.sheet-close-btn:active {
|
|
649
|
+
scale: none;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
:global(:where([data-reduced-motion='true'])) .sheet-close-btn:active {
|
|
653
|
+
scale: none;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
:global(:where(:root[data-theme='light'])) .sheet-close-btn::before {
|
|
657
|
+
background: var(--glass-button-fill, rgba(255, 255, 255, 0.55));
|
|
421
658
|
}
|
|
422
659
|
|
|
423
|
-
.sheet-close-btn:hover {
|
|
424
|
-
background:
|
|
660
|
+
:global(:where(:root[data-theme='light'])) .sheet-close-btn:hover::before {
|
|
661
|
+
background: var(--glass-button-fill-hover, var(--glass-button-fill, rgba(255, 255, 255, 0.65)));
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
:global(:where(:root[data-theme='light'])) .sheet-close-btn:active::before {
|
|
665
|
+
background: var(--glass-button-fill-active, var(--glass-button-fill, rgba(255, 255, 255, 0.75)));
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
669
|
+
.sheet-close-btn::before {
|
|
670
|
+
content: none;
|
|
671
|
+
}
|
|
672
|
+
.sheet-close-btn {
|
|
673
|
+
background: color-mix(
|
|
674
|
+
in srgb,
|
|
675
|
+
white calc(var(--btn-glass-opacity) * 93%),
|
|
676
|
+
rgb(var(--glass-surface-color, 28, 28, 30))
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
.sheet-close-btn:hover {
|
|
680
|
+
background: color-mix(
|
|
681
|
+
in srgb,
|
|
682
|
+
white calc(var(--btn-glass-opacity) * 76%),
|
|
683
|
+
rgb(var(--glass-surface-color, 28, 28, 30))
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
.sheet-close-btn:active {
|
|
687
|
+
background: color-mix(
|
|
688
|
+
in srgb,
|
|
689
|
+
white calc(var(--btn-glass-opacity) * 60%),
|
|
690
|
+
rgb(var(--glass-surface-color, 28, 28, 30))
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
:global(:where([data-reduced-transparency='true'])) .sheet-close-btn::before {
|
|
695
|
+
content: none;
|
|
696
|
+
}
|
|
697
|
+
:global(:where([data-reduced-transparency='true'])) .sheet-close-btn {
|
|
698
|
+
background: color-mix(
|
|
699
|
+
in srgb,
|
|
700
|
+
white calc(var(--btn-glass-opacity) * 93%),
|
|
701
|
+
rgb(var(--glass-surface-color, 28, 28, 30))
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
:global(:where([data-reduced-transparency='true'])) .sheet-close-btn:hover {
|
|
705
|
+
background: color-mix(
|
|
706
|
+
in srgb,
|
|
707
|
+
white calc(var(--btn-glass-opacity) * 76%),
|
|
708
|
+
rgb(var(--glass-surface-color, 28, 28, 30))
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
:global(:where([data-reduced-transparency='true'])) .sheet-close-btn:active {
|
|
712
|
+
background: color-mix(
|
|
713
|
+
in srgb,
|
|
714
|
+
white calc(var(--btn-glass-opacity) * 60%),
|
|
715
|
+
rgb(var(--glass-surface-color, 28, 28, 30))
|
|
716
|
+
);
|
|
425
717
|
}
|
|
426
718
|
|
|
427
719
|
.sheet-close-btn:focus-visible {
|
|
@@ -435,7 +727,7 @@
|
|
|
435
727
|
.sheet-title {
|
|
436
728
|
font-size: 17px;
|
|
437
729
|
font-weight: 600;
|
|
438
|
-
color: var(--color-text);
|
|
730
|
+
color: var(--glass-fg, var(--color-text, var(--glass-text-color-default, #f5f5f7)));
|
|
439
731
|
text-align: center;
|
|
440
732
|
font-family: var(--font-system);
|
|
441
733
|
margin: 0;
|
|
@@ -484,4 +776,79 @@
|
|
|
484
776
|
max-width: var(--glass-sheet-max-width, 900px);
|
|
485
777
|
}
|
|
486
778
|
}
|
|
779
|
+
|
|
780
|
+
/* Non-modal: no dimming or blur, and presses beside the sheet reach the page.
|
|
781
|
+
The sheet itself still takes the pointer, except while it slides out. */
|
|
782
|
+
.sheet-backdrop[data-modal='false'] {
|
|
783
|
+
background: transparent;
|
|
784
|
+
backdrop-filter: none;
|
|
785
|
+
-webkit-backdrop-filter: none;
|
|
786
|
+
pointer-events: none;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
.sheet-backdrop[data-modal='false'] > .sheet-container:not([data-sheet-state='closing']),
|
|
790
|
+
.sheet-inset-frame > .sheet-container:not([data-sheet-state='closing']) {
|
|
791
|
+
pointer-events: auto;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/* Inset: a frame fixed to the viewport, its sides and bottom pulled in by
|
|
795
|
+
--glass-sheet-inset, clips the sheet and rounds its lower corners. The
|
|
796
|
+
sheet slides inside it exactly as it does on its own. At a full height
|
|
797
|
+
detent the frame grows to the screen edges, in step with the slide. */
|
|
798
|
+
.sheet-inset-frame {
|
|
799
|
+
--_sheet-lift: var(--glass-sheet-inset, 8px);
|
|
800
|
+
position: fixed;
|
|
801
|
+
top: 0;
|
|
802
|
+
bottom: var(--_sheet-lift);
|
|
803
|
+
left: var(--_sheet-lift);
|
|
804
|
+
right: var(--_sheet-lift);
|
|
805
|
+
margin: 0 auto;
|
|
806
|
+
overflow: hidden;
|
|
807
|
+
border-radius: 0 0 var(--glass-sheet-inset-radius, var(--glass-radius-xl))
|
|
808
|
+
var(--glass-sheet-inset-radius, var(--glass-radius-xl));
|
|
809
|
+
pointer-events: none;
|
|
810
|
+
z-index: 1001;
|
|
811
|
+
transition:
|
|
812
|
+
left var(--transition-spring, 0.4s cubic-bezier(0.32, 0.72, 0, 1)),
|
|
813
|
+
right var(--transition-spring, 0.4s cubic-bezier(0.32, 0.72, 0, 1)),
|
|
814
|
+
bottom var(--transition-spring, 0.4s cubic-bezier(0.32, 0.72, 0, 1)),
|
|
815
|
+
border-radius var(--transition-spring, 0.4s cubic-bezier(0.32, 0.72, 0, 1));
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
.sheet-inset-frame[data-full-height='true'] {
|
|
819
|
+
--_sheet-lift: 0px;
|
|
820
|
+
border-radius: 0;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
.sheet-inset-frame > .sheet-container {
|
|
824
|
+
position: absolute;
|
|
825
|
+
max-width: none;
|
|
826
|
+
margin: 0;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/* Full height is more opaque, as on iOS 26: the sheet's own colour with its
|
|
830
|
+
alpha raised to --glass-sheet-full-height-alpha. Engines without relative
|
|
831
|
+
colours keep --glass-sheet-bg. */
|
|
832
|
+
.sheet-inset-frame[data-full-height='true'] > .sheet-container {
|
|
833
|
+
background: var(--glass-sheet-bg);
|
|
834
|
+
background: rgb(from var(--glass-sheet-bg) r g b / max(alpha, var(--glass-sheet-full-height-alpha, 0.94)));
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/* The frame ends --_sheet-lift above the screen's bottom, so the content
|
|
838
|
+
gives up that much more to keep its end reachable. */
|
|
839
|
+
.sheet-inset-frame .sheet-content {
|
|
840
|
+
margin-bottom: calc(var(--sheet-hidden-height, 0px) + var(--_sheet-lift));
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
@supports (height: 100dvh) {
|
|
844
|
+
.sheet-inset-frame .sheet-content {
|
|
845
|
+
margin-bottom: calc(var(--sheet-hidden-height, 0px) + var(--_sheet-lift) + 100vh - 100dvh);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
@media (min-width: 769px) {
|
|
850
|
+
.sheet-inset-frame {
|
|
851
|
+
max-width: var(--glass-sheet-max-width, 900px);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
487
854
|
</style>
|