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
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
import { fromAction } from 'svelte/attachments';
|
|
7
7
|
import {
|
|
8
8
|
swipeActions as swipeGesture,
|
|
9
|
-
|
|
9
|
+
edgeMostAction,
|
|
10
|
+
type SwipeEdge,
|
|
11
|
+
type SwipeEdgeActions
|
|
10
12
|
} from '../../actions/swipeActions';
|
|
11
13
|
|
|
12
14
|
interface Props {
|
|
@@ -18,10 +20,25 @@
|
|
|
18
20
|
interactive?: boolean;
|
|
19
21
|
href?: string;
|
|
20
22
|
onclick?: () => void;
|
|
21
|
-
/** Actions revealed by swiping. Mirrors SwiftUI's
|
|
23
|
+
/** Actions revealed by swiping right in LTR. Mirrors SwiftUI's `.swipeActions(edge: .leading)`. */
|
|
24
|
+
leadingSwipeActions?: Snippet;
|
|
25
|
+
/** Actions revealed by swiping left in LTR. Mirrors SwiftUI's `.swipeActions(edge: .trailing)`. */
|
|
26
|
+
trailingSwipeActions?: Snippet;
|
|
27
|
+
/** Whether a full swipe from the leading edge triggers its edge-most action. Defaults to true, as in SwiftUI. */
|
|
28
|
+
leadingAllowsFullSwipe?: boolean;
|
|
29
|
+
/** Whether a full swipe from the trailing edge triggers its edge-most action. Defaults to true, as in SwiftUI. */
|
|
30
|
+
trailingAllowsFullSwipe?: boolean;
|
|
31
|
+
/** Runs on a full leading swipe in place of clicking the edge-most leading action. Return `true` to keep the row swiped away instead of springing back. */
|
|
32
|
+
onLeadingFullSwipe?: () => boolean | void;
|
|
33
|
+
/** Runs on a full trailing swipe in place of clicking the edge-most trailing action. Return `true` to keep the row swiped away instead of springing back. */
|
|
34
|
+
onTrailingFullSwipe?: () => boolean | void;
|
|
35
|
+
/** Deprecated: use `leadingSwipeActions` or `trailingSwipeActions`. Actions on the `swipeEdge` edge. */
|
|
22
36
|
swipeActions?: Snippet;
|
|
37
|
+
/** Deprecated: the edge `swipeActions` belongs to. */
|
|
23
38
|
swipeEdge?: SwipeEdge;
|
|
39
|
+
/** Deprecated: full swipe for `swipeActions`. Off by default. */
|
|
24
40
|
allowsFullSwipe?: boolean;
|
|
41
|
+
/** Deprecated: runs on a full swipe of `swipeActions`. */
|
|
25
42
|
onFullSwipe?: () => void;
|
|
26
43
|
class?: string;
|
|
27
44
|
}
|
|
@@ -35,6 +52,12 @@
|
|
|
35
52
|
interactive = false,
|
|
36
53
|
href,
|
|
37
54
|
onclick,
|
|
55
|
+
leadingSwipeActions,
|
|
56
|
+
trailingSwipeActions,
|
|
57
|
+
leadingAllowsFullSwipe = true,
|
|
58
|
+
trailingAllowsFullSwipe = true,
|
|
59
|
+
onLeadingFullSwipe,
|
|
60
|
+
onTrailingFullSwipe,
|
|
38
61
|
swipeActions,
|
|
39
62
|
swipeEdge = 'trailing',
|
|
40
63
|
allowsFullSwipe = false,
|
|
@@ -44,8 +67,42 @@
|
|
|
44
67
|
|
|
45
68
|
const isInteractive = $derived(interactive || !!href || !!onclick);
|
|
46
69
|
|
|
47
|
-
|
|
70
|
+
// The deprecated single edge snippet fills its edge when the edge's own
|
|
71
|
+
// snippet is not given.
|
|
72
|
+
const legacyEdge = $derived(swipeEdge === 'leading' ? 'leading' : 'trailing');
|
|
73
|
+
const usesLegacy = (edge: SwipeEdge) =>
|
|
74
|
+
!!swipeActions && legacyEdge === edge && !(edge === 'leading' ? leadingSwipeActions : trailingSwipeActions);
|
|
75
|
+
const leadingSnippet = $derived(leadingSwipeActions ?? (usesLegacy('leading') ? swipeActions : undefined));
|
|
76
|
+
const trailingSnippet = $derived(trailingSwipeActions ?? (usesLegacy('trailing') ? swipeActions : undefined));
|
|
77
|
+
const hasSwipe = $derived(!!leadingSnippet || !!trailingSnippet);
|
|
78
|
+
|
|
79
|
+
let leadingStrip = $state<HTMLElement | null>(null);
|
|
80
|
+
let trailingStrip = $state<HTMLElement | null>(null);
|
|
48
81
|
let swipeRowElement = $state<HTMLElement | null>(null);
|
|
82
|
+
|
|
83
|
+
function edgeOptions(edge: SwipeEdge): SwipeEdgeActions | undefined {
|
|
84
|
+
const snippet = edge === 'leading' ? leadingSnippet : trailingSnippet;
|
|
85
|
+
if (!snippet) return undefined;
|
|
86
|
+
const actionsElement = edge === 'leading' ? leadingStrip : trailingStrip;
|
|
87
|
+
if (usesLegacy(edge)) {
|
|
88
|
+
// The deprecated full swipe leaves the row swiped away, as it always has.
|
|
89
|
+
return {
|
|
90
|
+
actionsElement,
|
|
91
|
+
allowsFullSwipe,
|
|
92
|
+
onFullSwipe: () => {
|
|
93
|
+
onFullSwipe?.();
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const callback = edge === 'leading' ? onLeadingFullSwipe : onTrailingFullSwipe;
|
|
99
|
+
return {
|
|
100
|
+
actionsElement,
|
|
101
|
+
allowsFullSwipe: edge === 'leading' ? leadingAllowsFullSwipe : trailingAllowsFullSwipe,
|
|
102
|
+
// As in SwiftUI, a full swipe runs the edge-most action.
|
|
103
|
+
onFullSwipe: callback ?? (() => edgeMostAction(actionsElement, edge)?.click())
|
|
104
|
+
};
|
|
105
|
+
}
|
|
49
106
|
</script>
|
|
50
107
|
|
|
51
108
|
{#snippet rowInner()}
|
|
@@ -106,29 +163,31 @@
|
|
|
106
163
|
{/if}
|
|
107
164
|
{/snippet}
|
|
108
165
|
|
|
109
|
-
{#if
|
|
166
|
+
{#if hasSwipe}
|
|
110
167
|
<div class="swipe-row" bind:this={swipeRowElement}>
|
|
111
|
-
<!--
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
</div>
|
|
168
|
+
<!-- The strips sit around the row in reading order, leading actions
|
|
169
|
+
first, so the keyboard and screen readers reach them with no swipe.
|
|
170
|
+
Focus inside a strip opens it. -->
|
|
171
|
+
{#if leadingSnippet}
|
|
172
|
+
<div class="swipe-actions" data-swipe-edge="leading" bind:this={leadingStrip}>
|
|
173
|
+
{@render leadingSnippet()}
|
|
174
|
+
</div>
|
|
175
|
+
{/if}
|
|
120
176
|
<div
|
|
121
177
|
class="swipe-content"
|
|
122
178
|
{@attach fromAction(swipeGesture, () => ({
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
stateElement: swipeRowElement
|
|
126
|
-
allowsFullSwipe,
|
|
127
|
-
onFullSwipe
|
|
179
|
+
leading: edgeOptions('leading'),
|
|
180
|
+
trailing: edgeOptions('trailing'),
|
|
181
|
+
stateElement: swipeRowElement
|
|
128
182
|
}))}
|
|
129
183
|
>
|
|
130
184
|
{@render row()}
|
|
131
185
|
</div>
|
|
186
|
+
{#if trailingSnippet}
|
|
187
|
+
<div class="swipe-actions" data-swipe-edge="trailing" bind:this={trailingStrip}>
|
|
188
|
+
{@render trailingSnippet()}
|
|
189
|
+
</div>
|
|
190
|
+
{/if}
|
|
132
191
|
</div>
|
|
133
192
|
{:else}
|
|
134
193
|
{@render row()}
|
|
@@ -136,6 +195,10 @@
|
|
|
136
195
|
|
|
137
196
|
<style>
|
|
138
197
|
.list-row {
|
|
198
|
+
/* iOS separator and cell highlight colours. Text on both holds 4.5:1. */
|
|
199
|
+
--_separator: var(--glass-list-separator, rgba(84, 84, 88, 0.65));
|
|
200
|
+
--_highlight: var(--glass-list-row-highlight, #3a3a3c);
|
|
201
|
+
--_secondary: #aeaeb2;
|
|
139
202
|
display: block;
|
|
140
203
|
width: 100%;
|
|
141
204
|
padding: 0;
|
|
@@ -143,9 +206,26 @@
|
|
|
143
206
|
border: none;
|
|
144
207
|
text-decoration: none;
|
|
145
208
|
color: inherit;
|
|
146
|
-
text-align:
|
|
209
|
+
text-align: start;
|
|
147
210
|
font-family: inherit;
|
|
148
211
|
cursor: default;
|
|
212
|
+
/* Clips the separator, which runs on past the trailing accessory. */
|
|
213
|
+
overflow: hidden;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
:global(:where(:root[data-theme='light'])) .list-row {
|
|
217
|
+
--_separator: var(--glass-list-separator, rgba(60, 60, 67, 0.29));
|
|
218
|
+
--_highlight: var(--glass-list-row-highlight, #d1d1d6);
|
|
219
|
+
--_secondary: #545458;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
@media (prefers-contrast: more) {
|
|
223
|
+
.list-row {
|
|
224
|
+
--_separator: var(--glass-list-separator, #8e8e93);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
:global(:where([data-contrast='more'])) .list-row {
|
|
228
|
+
--_separator: var(--glass-list-separator, #8e8e93);
|
|
149
229
|
}
|
|
150
230
|
|
|
151
231
|
.list-row.interactive {
|
|
@@ -169,23 +249,25 @@
|
|
|
169
249
|
background: var(--glass-hover-subtle);
|
|
170
250
|
}
|
|
171
251
|
|
|
252
|
+
/* The iOS cell highlight while the row is held. */
|
|
172
253
|
.list-row.interactive:active {
|
|
173
|
-
background: var(--
|
|
254
|
+
background: var(--_highlight);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@media (forced-colors: active) {
|
|
258
|
+
.list-row {
|
|
259
|
+
--_separator: CanvasText;
|
|
260
|
+
}
|
|
174
261
|
}
|
|
175
262
|
|
|
176
263
|
/* Scoped under .list-row so it outranks HStack's own padding reset
|
|
177
|
-
(.hstack.svelte-x) instead of depending on stylesheet order.
|
|
264
|
+
(.hstack.svelte-x) instead of depending on stylesheet order. 6px above
|
|
265
|
+
and below makes a 44pt row of one line and a 52pt row with a subtitle. */
|
|
178
266
|
.list-row :global(.row-content) {
|
|
179
|
-
padding:
|
|
267
|
+
padding: 6px 16px;
|
|
180
268
|
min-height: 44px;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
.list-row.has-divider {
|
|
184
|
-
border-bottom: 1px solid var(--glass-divider);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.list-row:last-child {
|
|
188
|
-
border-bottom: none;
|
|
269
|
+
/* The 44pt includes the padding. */
|
|
270
|
+
box-sizing: border-box;
|
|
189
271
|
}
|
|
190
272
|
|
|
191
273
|
.row-leading {
|
|
@@ -199,15 +281,41 @@
|
|
|
199
281
|
min-width: 0;
|
|
200
282
|
}
|
|
201
283
|
|
|
284
|
+
/* The text column fills the row's height, so its bottom edge is the row's
|
|
285
|
+
(less the padding) and the separator can start where the text starts. */
|
|
286
|
+
.list-row :global(.row-main) {
|
|
287
|
+
position: relative;
|
|
288
|
+
align-self: stretch;
|
|
289
|
+
justify-content: center;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.list-row.has-divider :global(.row-main)::after {
|
|
293
|
+
content: '';
|
|
294
|
+
position: absolute;
|
|
295
|
+
inset-inline-start: 0;
|
|
296
|
+
inset-inline-end: -100vw;
|
|
297
|
+
bottom: -6px;
|
|
298
|
+
border-bottom: 0.5px solid var(--_separator);
|
|
299
|
+
pointer-events: none;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/* The last row of a list has no separator under it. A swipeable row is the
|
|
303
|
+
only child of its own wrapper, so its wrapper is the one to ask. */
|
|
304
|
+
.list-row:last-child:not(.swipe-content > .list-row) :global(.row-main)::after,
|
|
305
|
+
.swipe-row:last-child .list-row :global(.row-main)::after {
|
|
306
|
+
content: none;
|
|
307
|
+
}
|
|
308
|
+
|
|
202
309
|
.row-title {
|
|
203
|
-
font-size:
|
|
204
|
-
|
|
310
|
+
font-size: 17px;
|
|
311
|
+
line-height: 22px;
|
|
312
|
+
color: var(--color-text, var(--glass-text-color-default));
|
|
205
313
|
}
|
|
206
314
|
|
|
207
315
|
.row-subtitle {
|
|
208
|
-
font-size:
|
|
209
|
-
|
|
210
|
-
|
|
316
|
+
font-size: 13px;
|
|
317
|
+
line-height: 18px;
|
|
318
|
+
color: var(--color-text-secondary, var(--_secondary));
|
|
211
319
|
}
|
|
212
320
|
|
|
213
321
|
.row-trailing {
|
|
@@ -216,35 +324,82 @@
|
|
|
216
324
|
color: var(--color-text-tertiary);
|
|
217
325
|
}
|
|
218
326
|
|
|
219
|
-
/* Swipe actions. The action writes --swipe-x,
|
|
220
|
-
|
|
327
|
+
/* Swipe actions. The action writes --swipe-x, the revealed distance of
|
|
328
|
+
each edge (--swipe-reveal-leading and --swipe-reveal-trailing) and
|
|
329
|
+
data-swipe-state onto .swipe-row, so the content and the strips read the
|
|
221
330
|
same numbers and cannot drift apart. */
|
|
222
331
|
.swipe-row {
|
|
223
332
|
position: relative;
|
|
224
333
|
overflow: hidden;
|
|
225
334
|
}
|
|
226
335
|
|
|
336
|
+
/* iOS 26 draws each action as its own capsule, inset from the row with a
|
|
337
|
+
gap between them, rather than a full height block flush with the edge. */
|
|
227
338
|
.swipe-actions {
|
|
228
339
|
position: absolute;
|
|
229
340
|
top: 0;
|
|
230
341
|
bottom: 0;
|
|
231
342
|
display: flex;
|
|
232
343
|
align-items: stretch;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
344
|
+
gap: 8px;
|
|
345
|
+
padding: 6px 8px;
|
|
346
|
+
box-sizing: border-box;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/* Natural width, or the revealed distance when the row is dragged further:
|
|
350
|
+
the strip always reaches the content's edge. Only the distance the row has
|
|
351
|
+
uncovered shows, so a strip never shows through the row at rest. Leading
|
|
352
|
+
sits on the left in LTR and on the right in RTL. */
|
|
353
|
+
.swipe-actions[data-swipe-edge='leading'] {
|
|
354
|
+
inset-inline-start: 0;
|
|
355
|
+
min-width: var(--swipe-reveal-leading, 0px);
|
|
356
|
+
clip-path: inset(0 calc(100% - var(--swipe-reveal-leading, 0px)) 0 0);
|
|
236
357
|
}
|
|
237
358
|
|
|
238
359
|
.swipe-actions[data-swipe-edge='trailing'] {
|
|
239
|
-
|
|
360
|
+
inset-inline-end: 0;
|
|
361
|
+
min-width: var(--swipe-reveal-trailing, 0px);
|
|
362
|
+
clip-path: inset(0 0 0 calc(100% - var(--swipe-reveal-trailing, 0px)));
|
|
240
363
|
}
|
|
241
364
|
|
|
242
|
-
|
|
243
|
-
|
|
365
|
+
/* Keyed on the direction the gesture read, which follows CSS direction as
|
|
366
|
+
well as dir, so the clips and the gesture always agree. */
|
|
367
|
+
.swipe-row:global([data-swipe-direction='rtl']) .swipe-actions[data-swipe-edge='leading'] {
|
|
368
|
+
clip-path: inset(0 0 0 calc(100% - var(--swipe-reveal-leading, 0px)));
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.swipe-row:global([data-swipe-direction='rtl']) .swipe-actions[data-swipe-edge='trailing'] {
|
|
372
|
+
clip-path: inset(0 calc(100% - var(--swipe-reveal-trailing, 0px)) 0 0);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/* Every action is a capsule. :where() has zero specificity, so a caller's
|
|
376
|
+
own colours and shapes still win. */
|
|
377
|
+
:where(.swipe-actions > :global(*)) {
|
|
378
|
+
display: inline-flex;
|
|
379
|
+
align-items: center;
|
|
380
|
+
justify-content: center;
|
|
381
|
+
gap: 4px;
|
|
382
|
+
min-width: 52px;
|
|
383
|
+
padding: 0 16px;
|
|
384
|
+
box-sizing: border-box;
|
|
385
|
+
border: 0;
|
|
386
|
+
border-radius: var(--glass-radius-full);
|
|
387
|
+
/* systemGray, deep enough for a white label at 4.5:1. */
|
|
388
|
+
background: #636366;
|
|
389
|
+
color: #ffffff;
|
|
390
|
+
font: 600 15px/20px var(--font-system, system-ui);
|
|
391
|
+
cursor: pointer;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/* The capsule fill is dropped when colours are forced, so outline it. */
|
|
395
|
+
@media (forced-colors: active) {
|
|
396
|
+
:where(.swipe-actions > :global(*)) {
|
|
397
|
+
border: 1px solid ButtonText;
|
|
398
|
+
}
|
|
244
399
|
}
|
|
245
400
|
|
|
246
|
-
/* The edge-most action absorbs the extra width and keeps its label centred
|
|
247
|
-
|
|
401
|
+
/* The edge-most action absorbs the extra width and keeps its label centred,
|
|
402
|
+
so on a full swipe its capsule stretches across the row. */
|
|
248
403
|
:where(.swipe-actions[data-swipe-edge='trailing'] > :global(:last-child)),
|
|
249
404
|
:where(.swipe-actions[data-swipe-edge='leading'] > :global(:first-child)) {
|
|
250
405
|
flex: 1 0 auto;
|
|
@@ -254,11 +409,16 @@
|
|
|
254
409
|
text-align: center;
|
|
255
410
|
}
|
|
256
411
|
|
|
412
|
+
/* Inside a List card the row takes the card's colour, which a page's own
|
|
413
|
+
--color-bg must not cover. Elsewhere it takes the page's. */
|
|
257
414
|
.swipe-content {
|
|
258
415
|
position: relative;
|
|
259
|
-
background: var(--color-bg, transparent);
|
|
416
|
+
background: var(--_row-bg, var(--color-bg, transparent));
|
|
260
417
|
transform: translateX(var(--swipe-x, 0));
|
|
261
418
|
touch-action: pan-y;
|
|
419
|
+
/* A mouse drag slides the row, so it must not select the row's text. */
|
|
420
|
+
-webkit-user-select: none;
|
|
421
|
+
user-select: none;
|
|
262
422
|
}
|
|
263
423
|
|
|
264
424
|
/* Settled positions animate in step: the content slides and the strip
|
|
@@ -270,6 +430,7 @@
|
|
|
270
430
|
.swipe-row:global([data-swipe-state]):not(:global([data-swipe-dragging])) .swipe-actions {
|
|
271
431
|
transition:
|
|
272
432
|
transform var(--transition-fast),
|
|
273
|
-
min-width var(--transition-fast)
|
|
433
|
+
min-width var(--transition-fast),
|
|
434
|
+
clip-path var(--transition-fast);
|
|
274
435
|
}
|
|
275
436
|
</style>
|
|
@@ -9,10 +9,25 @@ interface Props {
|
|
|
9
9
|
interactive?: boolean;
|
|
10
10
|
href?: string;
|
|
11
11
|
onclick?: () => void;
|
|
12
|
-
/** Actions revealed by swiping. Mirrors SwiftUI's
|
|
12
|
+
/** Actions revealed by swiping right in LTR. Mirrors SwiftUI's `.swipeActions(edge: .leading)`. */
|
|
13
|
+
leadingSwipeActions?: Snippet;
|
|
14
|
+
/** Actions revealed by swiping left in LTR. Mirrors SwiftUI's `.swipeActions(edge: .trailing)`. */
|
|
15
|
+
trailingSwipeActions?: Snippet;
|
|
16
|
+
/** Whether a full swipe from the leading edge triggers its edge-most action. Defaults to true, as in SwiftUI. */
|
|
17
|
+
leadingAllowsFullSwipe?: boolean;
|
|
18
|
+
/** Whether a full swipe from the trailing edge triggers its edge-most action. Defaults to true, as in SwiftUI. */
|
|
19
|
+
trailingAllowsFullSwipe?: boolean;
|
|
20
|
+
/** Runs on a full leading swipe in place of clicking the edge-most leading action. Return `true` to keep the row swiped away instead of springing back. */
|
|
21
|
+
onLeadingFullSwipe?: () => boolean | void;
|
|
22
|
+
/** Runs on a full trailing swipe in place of clicking the edge-most trailing action. Return `true` to keep the row swiped away instead of springing back. */
|
|
23
|
+
onTrailingFullSwipe?: () => boolean | void;
|
|
24
|
+
/** Deprecated: use `leadingSwipeActions` or `trailingSwipeActions`. Actions on the `swipeEdge` edge. */
|
|
13
25
|
swipeActions?: Snippet;
|
|
26
|
+
/** Deprecated: the edge `swipeActions` belongs to. */
|
|
14
27
|
swipeEdge?: SwipeEdge;
|
|
28
|
+
/** Deprecated: full swipe for `swipeActions`. Off by default. */
|
|
15
29
|
allowsFullSwipe?: boolean;
|
|
30
|
+
/** Deprecated: runs on a full swipe of `swipeActions`. */
|
|
16
31
|
onFullSwipe?: () => void;
|
|
17
32
|
class?: string;
|
|
18
33
|
}
|
|
@@ -2,15 +2,34 @@
|
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import { tick } from 'svelte';
|
|
4
4
|
import { fitFocusRing } from '../../actions/focusRingFit';
|
|
5
|
+
import {
|
|
6
|
+
MENU_ITEM_SELECTOR,
|
|
7
|
+
activationCloses,
|
|
8
|
+
menuItemState,
|
|
9
|
+
menuKeyTarget
|
|
10
|
+
} from '../../actions/menuLogic';
|
|
11
|
+
import { playGrow } from '../../actions/anchorPlacement';
|
|
12
|
+
import { prefersReducedMotion } from '../../actions/reducedMotion';
|
|
5
13
|
|
|
6
14
|
interface Props {
|
|
7
15
|
label: Snippet;
|
|
8
16
|
children: Snippet;
|
|
9
17
|
align?: 'start' | 'end';
|
|
18
|
+
/**
|
|
19
|
+
* Grows the panel out of the trigger, as menus do on iOS 26, instead of
|
|
20
|
+
* the default scale and fade. Under reduced motion it only fades.
|
|
21
|
+
*/
|
|
22
|
+
morph?: boolean;
|
|
10
23
|
class?: string;
|
|
11
24
|
}
|
|
12
25
|
|
|
13
|
-
let {
|
|
26
|
+
let {
|
|
27
|
+
label,
|
|
28
|
+
children,
|
|
29
|
+
align = 'start',
|
|
30
|
+
morph = false,
|
|
31
|
+
class: className = ''
|
|
32
|
+
}: Props = $props();
|
|
14
33
|
|
|
15
34
|
const panelId = $props.id();
|
|
16
35
|
|
|
@@ -18,14 +37,23 @@
|
|
|
18
37
|
let triggerEl = $state<HTMLButtonElement>();
|
|
19
38
|
let panelEl = $state<HTMLDivElement>();
|
|
20
39
|
|
|
21
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The items of the menu that holds `from`: the panel itself, or an open
|
|
42
|
+
* submenu. Items of a nested submenu belong to it, not to this list.
|
|
43
|
+
*/
|
|
44
|
+
function menuItems(from: Element | null = null): HTMLElement[] {
|
|
22
45
|
if (!panelEl) return [];
|
|
23
|
-
|
|
46
|
+
const owner = from?.closest('[role="menu"]') ?? panelEl;
|
|
47
|
+
const menu = panelEl.contains(owner) ? owner : panelEl;
|
|
48
|
+
return Array.from(menu.querySelectorAll<HTMLElement>(MENU_ITEM_SELECTOR)).filter(
|
|
49
|
+
(item) => item.parentElement?.closest('[role="menu"]') === menu
|
|
50
|
+
);
|
|
24
51
|
}
|
|
25
52
|
|
|
26
53
|
async function openMenu() {
|
|
27
54
|
open = true;
|
|
28
55
|
await tick();
|
|
56
|
+
if (morph && panelEl && triggerEl) playGrow(panelEl, triggerEl, prefersReducedMotion());
|
|
29
57
|
menuItems()[0]?.focus();
|
|
30
58
|
}
|
|
31
59
|
|
|
@@ -40,31 +68,23 @@
|
|
|
40
68
|
}
|
|
41
69
|
|
|
42
70
|
function handlePanelKeydown(e: KeyboardEvent) {
|
|
43
|
-
|
|
44
|
-
if (items.length === 0) return;
|
|
45
|
-
const current = items.indexOf(document.activeElement as HTMLElement);
|
|
46
|
-
|
|
71
|
+
if (e.defaultPrevented) return;
|
|
47
72
|
if (e.key === 'Escape') {
|
|
48
73
|
e.preventDefault();
|
|
49
74
|
closeMenu(true);
|
|
50
|
-
|
|
51
|
-
e.preventDefault();
|
|
52
|
-
items[(current + 1) % items.length]?.focus();
|
|
53
|
-
} else if (e.key === 'ArrowUp') {
|
|
54
|
-
e.preventDefault();
|
|
55
|
-
items[(current - 1 + items.length) % items.length]?.focus();
|
|
56
|
-
} else if (e.key === 'Home') {
|
|
57
|
-
e.preventDefault();
|
|
58
|
-
items[0]?.focus();
|
|
59
|
-
} else if (e.key === 'End') {
|
|
60
|
-
e.preventDefault();
|
|
61
|
-
items[items.length - 1]?.focus();
|
|
75
|
+
return;
|
|
62
76
|
}
|
|
77
|
+
const active = document.activeElement;
|
|
78
|
+
const items = menuItems(active);
|
|
79
|
+
const next = menuKeyTarget(e.key, items.indexOf(active as HTMLElement), items.length);
|
|
80
|
+
if (next === null) return;
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
items[next]?.focus();
|
|
63
83
|
}
|
|
64
84
|
|
|
65
85
|
function handlePanelClick(e: MouseEvent) {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
86
|
+
const item = (e.target as HTMLElement).closest(MENU_ITEM_SELECTOR);
|
|
87
|
+
if (item && activationCloses(menuItemState(item))) {
|
|
68
88
|
closeMenu();
|
|
69
89
|
}
|
|
70
90
|
}
|
|
@@ -101,6 +121,7 @@
|
|
|
101
121
|
tabindex="-1"
|
|
102
122
|
class="glass-menu-panel"
|
|
103
123
|
class:align-end={align === 'end'}
|
|
124
|
+
class:morph
|
|
104
125
|
onkeydown={handlePanelKeydown}
|
|
105
126
|
onclick={handlePanelClick}
|
|
106
127
|
>
|
|
@@ -153,14 +174,17 @@
|
|
|
153
174
|
position: absolute;
|
|
154
175
|
top: calc(100% + 8px);
|
|
155
176
|
left: 0;
|
|
156
|
-
|
|
157
|
-
|
|
177
|
+
box-sizing: border-box;
|
|
178
|
+
/* iOS 26 menus are wider and rounder, and their rows sit 8px in from the
|
|
179
|
+
edge, so a row's rounding is concentric with the panel's. */
|
|
180
|
+
min-width: 250px;
|
|
181
|
+
padding: 8px;
|
|
158
182
|
overflow: hidden;
|
|
159
183
|
background: var(--glass-sheet-bg);
|
|
160
184
|
backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
|
|
161
185
|
-webkit-backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
|
|
162
186
|
border: var(--glass-border-width) solid var(--glass-border);
|
|
163
|
-
border-radius: var(--glass-radius-
|
|
187
|
+
border-radius: var(--glass-radius-xl);
|
|
164
188
|
box-shadow:
|
|
165
189
|
0 12px 40px -8px var(--glass-shadow),
|
|
166
190
|
0 4px 12px -2px var(--glass-shadow);
|
|
@@ -175,9 +199,9 @@
|
|
|
175
199
|
transform-origin: top right;
|
|
176
200
|
}
|
|
177
201
|
|
|
178
|
-
/*
|
|
179
|
-
.glass-menu-panel
|
|
180
|
-
|
|
202
|
+
/* The grow from the trigger runs in script, so the keyframes stand down. */
|
|
203
|
+
.glass-menu-panel.morph {
|
|
204
|
+
animation: none;
|
|
181
205
|
}
|
|
182
206
|
|
|
183
207
|
@keyframes glass-menu-pop {
|
|
@@ -3,6 +3,11 @@ interface Props {
|
|
|
3
3
|
label: Snippet;
|
|
4
4
|
children: Snippet;
|
|
5
5
|
align?: 'start' | 'end';
|
|
6
|
+
/**
|
|
7
|
+
* Grows the panel out of the trigger, as menus do on iOS 26, instead of
|
|
8
|
+
* the default scale and fade. Under reduced motion it only fades.
|
|
9
|
+
*/
|
|
10
|
+
morph?: boolean;
|
|
6
11
|
class?: string;
|
|
7
12
|
}
|
|
8
13
|
declare const Menu: import("svelte").Component<Props, {}, string>;
|