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,13 +1,20 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import { HStack } from '../layout';
|
|
4
|
+
import { watchScrollUnder } from '../../actions/scrollUnder';
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
7
|
title?: string;
|
|
7
8
|
leading?: Snippet;
|
|
8
9
|
trailing?: Snippet;
|
|
9
10
|
largeTitle?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Kept for compatibility. The bar is now transparent at rest by default
|
|
13
|
+
* and shows the scroll edge effect once content scrolls under it, so
|
|
14
|
+
* this changes nothing but the `transparent` class.
|
|
15
|
+
*/
|
|
10
16
|
transparent?: boolean;
|
|
17
|
+
/** Shows the scroll edge effect even at the top, for content that scrolls in its own container. */
|
|
11
18
|
scrolled?: boolean;
|
|
12
19
|
class?: string;
|
|
13
20
|
}
|
|
@@ -24,6 +31,18 @@
|
|
|
24
31
|
|
|
25
32
|
let sentinelEl = $state<HTMLElement | undefined>();
|
|
26
33
|
let collapsed = $state(false);
|
|
34
|
+
let scrolledUnder = $state(false);
|
|
35
|
+
const showsEdge = $derived(scrolled || scrolledUnder || collapsed);
|
|
36
|
+
|
|
37
|
+
// The bar is fixed to the viewport, so content is under it whenever the
|
|
38
|
+
// window has scrolled. A page that scrolls an inner container passes
|
|
39
|
+
// `scrolled` instead.
|
|
40
|
+
$effect(() => {
|
|
41
|
+
if (typeof window === 'undefined') return;
|
|
42
|
+
return watchScrollUnder(window, (under) => {
|
|
43
|
+
scrolledUnder = under;
|
|
44
|
+
});
|
|
45
|
+
});
|
|
27
46
|
|
|
28
47
|
$effect(() => {
|
|
29
48
|
if (!largeTitle || !sentinelEl || typeof IntersectionObserver === 'undefined') return;
|
|
@@ -43,7 +62,7 @@
|
|
|
43
62
|
|
|
44
63
|
{#if largeTitle}
|
|
45
64
|
<div class="nav-large {className}" class:is-collapsed={collapsed}>
|
|
46
|
-
<header class="navigation-bar large" class:transparent class:scrolled={
|
|
65
|
+
<header class="navigation-bar large" class:transparent class:scrolled={showsEdge}>
|
|
47
66
|
<nav class="nav-content">
|
|
48
67
|
<HStack spacing="sm" alignment="center" justify="between">
|
|
49
68
|
<div class="nav-leading">
|
|
@@ -71,7 +90,7 @@
|
|
|
71
90
|
</div>
|
|
72
91
|
</div>
|
|
73
92
|
{:else}
|
|
74
|
-
<header class="navigation-bar {className}" class:transparent class:scrolled>
|
|
93
|
+
<header class="navigation-bar {className}" class:transparent class:scrolled={showsEdge}>
|
|
75
94
|
<nav class="nav-content">
|
|
76
95
|
<HStack spacing="sm" alignment="center" justify="between">
|
|
77
96
|
<div class="nav-leading">
|
|
@@ -95,7 +114,11 @@
|
|
|
95
114
|
{/if}
|
|
96
115
|
|
|
97
116
|
<style>
|
|
117
|
+
/* iOS 26 draws no bar background and no divider. The bar floats over the
|
|
118
|
+
content, and only the glass buttons in it have a surface. */
|
|
98
119
|
.navigation-bar {
|
|
120
|
+
/* The solid bar more contrast asks for. */
|
|
121
|
+
--_nav-solid: rgba(0, 0, 0, 0.98);
|
|
99
122
|
position: fixed;
|
|
100
123
|
top: 0;
|
|
101
124
|
left: 0;
|
|
@@ -104,26 +127,85 @@
|
|
|
104
127
|
height: 56px;
|
|
105
128
|
display: flex;
|
|
106
129
|
align-items: center;
|
|
130
|
+
font-family: var(--font-system);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* The scroll edge effect: a blur and a tint behind the bar that fade out
|
|
134
|
+
below it, shown only while content scrolls under the bar, so the title
|
|
135
|
+
stays readable over busy content without a hard edge. The header is a
|
|
136
|
+
stacking context (fixed, with a z-index), so -1 keeps the layer above the
|
|
137
|
+
page and below the bar's own content. */
|
|
138
|
+
.navigation-bar::before {
|
|
139
|
+
content: '';
|
|
140
|
+
position: absolute;
|
|
141
|
+
inset: 0 0 calc(-1 * var(--glass-nav-edge-fade, 24px)) 0;
|
|
142
|
+
z-index: -1;
|
|
143
|
+
pointer-events: none;
|
|
107
144
|
background: var(--glass-nav-bg);
|
|
108
145
|
backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
|
|
109
146
|
-webkit-backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
147
|
+
mask-image: linear-gradient(to bottom, #000 calc(100% - var(--glass-nav-edge-fade, 24px)), transparent);
|
|
148
|
+
-webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - var(--glass-nav-edge-fade, 24px)), transparent);
|
|
149
|
+
opacity: 0;
|
|
150
|
+
transition: opacity var(--transition);
|
|
113
151
|
}
|
|
114
152
|
|
|
115
|
-
.navigation-bar.
|
|
116
|
-
|
|
153
|
+
.navigation-bar.scrolled::before {
|
|
154
|
+
opacity: 1;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
:global(:where(:root[data-theme='light'])) .navigation-bar {
|
|
158
|
+
--_nav-solid: rgba(255, 255, 255, 0.98);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/* Reduced transparency: a solid bar, cut off at its edge. --glass-nav-bg is
|
|
162
|
+
near opaque then. */
|
|
163
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
164
|
+
.navigation-bar::before {
|
|
165
|
+
inset: 0;
|
|
166
|
+
mask-image: none;
|
|
167
|
+
-webkit-mask-image: none;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
:global(:where([data-reduced-transparency='true'])) .navigation-bar::before {
|
|
171
|
+
inset: 0;
|
|
172
|
+
mask-image: none;
|
|
173
|
+
-webkit-mask-image: none;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* More contrast: a near opaque bar with no blur and a strong divider, so
|
|
177
|
+
its edge is plain to see. */
|
|
178
|
+
@media (prefers-contrast: more) {
|
|
179
|
+
.navigation-bar::before {
|
|
180
|
+
inset: 0;
|
|
181
|
+
background: var(--_nav-solid);
|
|
182
|
+
backdrop-filter: none;
|
|
183
|
+
-webkit-backdrop-filter: none;
|
|
184
|
+
mask-image: none;
|
|
185
|
+
-webkit-mask-image: none;
|
|
186
|
+
border-bottom: 1px solid #8e8e93;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
:global(:where([data-contrast='more'])) .navigation-bar::before {
|
|
190
|
+
inset: 0;
|
|
191
|
+
background: var(--_nav-solid);
|
|
117
192
|
backdrop-filter: none;
|
|
118
193
|
-webkit-backdrop-filter: none;
|
|
119
|
-
|
|
194
|
+
mask-image: none;
|
|
195
|
+
-webkit-mask-image: none;
|
|
196
|
+
border-bottom: 1px solid #8e8e93;
|
|
120
197
|
}
|
|
121
198
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
199
|
+
@media (forced-colors: active) {
|
|
200
|
+
.navigation-bar::before {
|
|
201
|
+
inset: 0;
|
|
202
|
+
background: Canvas;
|
|
203
|
+
backdrop-filter: none;
|
|
204
|
+
-webkit-backdrop-filter: none;
|
|
205
|
+
mask-image: none;
|
|
206
|
+
-webkit-mask-image: none;
|
|
207
|
+
border-bottom: 1px solid CanvasText;
|
|
208
|
+
}
|
|
127
209
|
}
|
|
128
210
|
|
|
129
211
|
.nav-content {
|
|
@@ -148,7 +230,7 @@
|
|
|
148
230
|
.nav-title-compact {
|
|
149
231
|
font-size: 17px;
|
|
150
232
|
font-weight: 600;
|
|
151
|
-
color: var(--color-text);
|
|
233
|
+
color: var(--glass-fg, var(--color-text, var(--glass-text-color-default)));
|
|
152
234
|
text-align: center;
|
|
153
235
|
flex: 1;
|
|
154
236
|
white-space: nowrap;
|
|
@@ -177,7 +259,7 @@
|
|
|
177
259
|
.nav-large-title {
|
|
178
260
|
font-size: clamp(1.75rem, 5vw, 2.25rem);
|
|
179
261
|
font-weight: 700;
|
|
180
|
-
color: var(--color-text);
|
|
262
|
+
color: var(--glass-fg, var(--color-text, var(--glass-text-color-default)));
|
|
181
263
|
letter-spacing: -0.02em;
|
|
182
264
|
margin: 0;
|
|
183
265
|
font-family: var(--font-system);
|
|
@@ -4,7 +4,13 @@ interface Props {
|
|
|
4
4
|
leading?: Snippet;
|
|
5
5
|
trailing?: Snippet;
|
|
6
6
|
largeTitle?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Kept for compatibility. The bar is now transparent at rest by default
|
|
9
|
+
* and shows the scroll edge effect once content scrolls under it, so
|
|
10
|
+
* this changes nothing but the `transparent` class.
|
|
11
|
+
*/
|
|
7
12
|
transparent?: boolean;
|
|
13
|
+
/** Shows the scroll edge effect even at the top, for content that scrolls in its own container. */
|
|
8
14
|
scrolled?: boolean;
|
|
9
15
|
class?: string;
|
|
10
16
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { toolbarFocus } from '../../actions/toolbarFocus';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
/** The accessible name of the toolbar. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** The direction the items run in, and the arrow keys that move between them. */
|
|
9
|
+
orientation?: 'horizontal' | 'vertical';
|
|
10
|
+
/** The items: ToolbarItemGroup, ToolbarSpacer and single controls. */
|
|
11
|
+
children: Snippet;
|
|
12
|
+
class?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let { label, orientation = 'horizontal', children, class: className = '' }: Props = $props();
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div
|
|
19
|
+
class="toolbar {className}"
|
|
20
|
+
class:is-vertical={orientation === 'vertical'}
|
|
21
|
+
role="toolbar"
|
|
22
|
+
aria-label={label}
|
|
23
|
+
aria-orientation={orientation}
|
|
24
|
+
{@attach (node: HTMLDivElement) => toolbarFocus(node, orientation)}
|
|
25
|
+
>
|
|
26
|
+
{@render children()}
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
/* The toolbar itself has no fill. As on iOS 26, its items float on their
|
|
31
|
+
own glass: each ToolbarItemGroup is one capsule, and spacers split them. */
|
|
32
|
+
.toolbar {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: row;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: var(--toolbar-gap, var(--spacing-xs));
|
|
37
|
+
min-width: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.toolbar.is-vertical {
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** The accessible name of the toolbar. */
|
|
4
|
+
label: string;
|
|
5
|
+
/** The direction the items run in, and the arrow keys that move between them. */
|
|
6
|
+
orientation?: 'horizontal' | 'vertical';
|
|
7
|
+
/** The items: ToolbarItemGroup, ToolbarSpacer and single controls. */
|
|
8
|
+
children: Snippet;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const Toolbar: import("svelte").Component<Props, {}, string>;
|
|
12
|
+
type Toolbar = ReturnType<typeof Toolbar>;
|
|
13
|
+
export default Toolbar;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { Glass } from '../glass';
|
|
4
|
+
import type { GlassVariant } from '../../constants/variants';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
/** The accessible name of the group. With one, the group is announced as a group. */
|
|
8
|
+
label?: string | undefined;
|
|
9
|
+
/** The glass the capsule is made of. */
|
|
10
|
+
variant?: GlassVariant;
|
|
11
|
+
/** The controls that share the capsule. */
|
|
12
|
+
children: Snippet;
|
|
13
|
+
class?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let { label, variant = 'regular', children, class: className = '' }: Props = $props();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class="toolbar-group {className}" role={label ? 'group' : undefined} aria-label={label || undefined}>
|
|
20
|
+
<Glass {variant} shape="capsule" padding="none" class="toolbar-group-glass">
|
|
21
|
+
<div class="toolbar-group-items">
|
|
22
|
+
{@render children()}
|
|
23
|
+
</div>
|
|
24
|
+
</Glass>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<style>
|
|
28
|
+
.toolbar-group {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
flex: 0 0 auto;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.toolbar-group-items {
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: row;
|
|
36
|
+
align-items: center;
|
|
37
|
+
gap: var(--toolbar-group-gap, 2px);
|
|
38
|
+
padding: var(--toolbar-group-padding, 4px);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* A vertical toolbar stacks the controls in each capsule too. */
|
|
42
|
+
:global(.toolbar.is-vertical) .toolbar-group-items {
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { GlassVariant } from '../../constants/variants';
|
|
3
|
+
interface Props {
|
|
4
|
+
/** The accessible name of the group. With one, the group is announced as a group. */
|
|
5
|
+
label?: string | undefined;
|
|
6
|
+
/** The glass the capsule is made of. */
|
|
7
|
+
variant?: GlassVariant;
|
|
8
|
+
/** The controls that share the capsule. */
|
|
9
|
+
children: Snippet;
|
|
10
|
+
class?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const ToolbarItemGroup: import("svelte").Component<Props, {}, string>;
|
|
13
|
+
type ToolbarItemGroup = ReturnType<typeof ToolbarItemGroup>;
|
|
14
|
+
export default ToolbarItemGroup;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
/**
|
|
4
|
+
* `flexible` takes all the free room, pushing the items after it to the far
|
|
5
|
+
* end. `fixed` is a set gap between two glass groups. Mirrors SwiftUI's
|
|
6
|
+
* ToolbarSpacer, which is flexible by default.
|
|
7
|
+
*/
|
|
8
|
+
sizing?: 'fixed' | 'flexible';
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { sizing = 'flexible', class: className = '' }: Props = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div
|
|
16
|
+
class="toolbar-spacer {className}"
|
|
17
|
+
class:is-fixed={sizing === 'fixed'}
|
|
18
|
+
class:is-flexible={sizing !== 'fixed'}
|
|
19
|
+
aria-hidden="true"
|
|
20
|
+
></div>
|
|
21
|
+
|
|
22
|
+
<style>
|
|
23
|
+
.toolbar-spacer {
|
|
24
|
+
flex: 0 0 auto;
|
|
25
|
+
align-self: stretch;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.toolbar-spacer.is-flexible {
|
|
29
|
+
flex: 1 1 auto;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* The basis runs along the toolbar, so the same rule serves a vertical one. */
|
|
33
|
+
.toolbar-spacer.is-fixed {
|
|
34
|
+
flex: 0 0 var(--toolbar-spacer-fixed, var(--spacing-xs));
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/**
|
|
3
|
+
* `flexible` takes all the free room, pushing the items after it to the far
|
|
4
|
+
* end. `fixed` is a set gap between two glass groups. Mirrors SwiftUI's
|
|
5
|
+
* ToolbarSpacer, which is flexible by default.
|
|
6
|
+
*/
|
|
7
|
+
sizing?: 'fixed' | 'flexible';
|
|
8
|
+
class?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const ToolbarSpacer: import("svelte").Component<Props, {}, string>;
|
|
11
|
+
type ToolbarSpacer = ReturnType<typeof ToolbarSpacer>;
|
|
12
|
+
export default ToolbarSpacer;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolbar Components
|
|
3
|
+
* A glass toolbar, its grouped capsules and its spacers
|
|
4
|
+
*/
|
|
5
|
+
export { default as Toolbar } from './Toolbar.svelte';
|
|
6
|
+
export { default as ToolbarItemGroup } from './ToolbarItemGroup.svelte';
|
|
7
|
+
export { default as ToolbarSpacer } from './ToolbarSpacer.svelte';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolbar Components
|
|
3
|
+
* A glass toolbar, its grouped capsules and its spacers
|
|
4
|
+
*/
|
|
5
|
+
export { default as Toolbar } from './Toolbar.svelte';
|
|
6
|
+
export { default as ToolbarItemGroup } from './ToolbarItemGroup.svelte';
|
|
7
|
+
export { default as ToolbarSpacer } from './ToolbarSpacer.svelte';
|
|
@@ -90,9 +90,17 @@
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
.text.gradient {
|
|
93
|
-
background: var(--glass-text-gradient);
|
|
93
|
+
background: var(--glass-text-gradient, linear-gradient(currentColor, currentColor));
|
|
94
94
|
-webkit-background-clip: text;
|
|
95
95
|
-webkit-text-fill-color: transparent;
|
|
96
96
|
background-clip: text;
|
|
97
97
|
}
|
|
98
|
+
|
|
99
|
+
/* Forced colours drop the background image, so paint the text plainly. */
|
|
100
|
+
@media (forced-colors: active) {
|
|
101
|
+
.text.gradient {
|
|
102
|
+
background: none;
|
|
103
|
+
-webkit-text-fill-color: currentColor;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
98
106
|
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One button of an Alert or an ActionSheet, mirroring a SwiftUI Button with a
|
|
3
|
+
* ButtonRole inside `.alert` or `.confirmationDialog`.
|
|
4
|
+
*/
|
|
5
|
+
export interface AlertAction {
|
|
6
|
+
/** The button's text, which is also its accessible name. */
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* `cancel` dismisses without acting: Escape runs it, and it sits apart from
|
|
10
|
+
* the other buttons. `destructive` draws the label in the danger colour.
|
|
11
|
+
*/
|
|
12
|
+
role?: 'cancel' | 'destructive' | undefined;
|
|
13
|
+
/** The default action: drawn filled, and run by Return in the alert's text field. */
|
|
14
|
+
preferred?: boolean | undefined;
|
|
15
|
+
/** Shows the button but stops it from being chosen. */
|
|
16
|
+
disabled?: boolean | undefined;
|
|
17
|
+
/** Runs when the button is chosen, before the dialog closes. */
|
|
18
|
+
onclick?: (() => void) | undefined;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a badge shows, worked out from the value a caller gives it, as plain
|
|
3
|
+
* functions so mutation testing reaches them (Stryker cannot instrument .svelte
|
|
4
|
+
* files). Shared by Badge and the per-tab badge of TabView. Internal.
|
|
5
|
+
*/
|
|
6
|
+
/** A badge value: a count, a short text, `true` for a dot, or nothing. */
|
|
7
|
+
export type BadgeValue = number | string | boolean | null | undefined;
|
|
8
|
+
/** What a badge draws: nothing, a dot, or a short text such as a count. */
|
|
9
|
+
export type BadgeDisplay = {
|
|
10
|
+
kind: 'hidden';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'dot';
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'text';
|
|
15
|
+
text: string;
|
|
16
|
+
};
|
|
17
|
+
/** The largest count a badge shows before it reads as the maximum and a plus, as on iOS. */
|
|
18
|
+
export declare const DEFAULT_BADGE_MAX = 99;
|
|
19
|
+
/** The words read for a dot badge when the caller gives none. */
|
|
20
|
+
export declare const DEFAULT_DOT_BADGE_LABEL = "New";
|
|
21
|
+
/**
|
|
22
|
+
* What a badge shows for a value. A count below 1 (or not a number) hides the
|
|
23
|
+
* badge, as a zero badge does on iOS, and a count over `max` reads "99+". A
|
|
24
|
+
* text shows trimmed, and an empty one hides. `true` is a dot and `false` hides.
|
|
25
|
+
*/
|
|
26
|
+
export declare function badgeDisplay(value: BadgeValue, max?: number): BadgeDisplay;
|
|
27
|
+
/**
|
|
28
|
+
* The words assistive technology reads for a badge: the caller's `label` when
|
|
29
|
+
* there is one, else the text the badge shows, or the default dot words for a
|
|
30
|
+
* dot. Empty when the badge is hidden.
|
|
31
|
+
*/
|
|
32
|
+
export declare function badgeSpokenText(display: BadgeDisplay, label?: string): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a badge shows, worked out from the value a caller gives it, as plain
|
|
3
|
+
* functions so mutation testing reaches them (Stryker cannot instrument .svelte
|
|
4
|
+
* files). Shared by Badge and the per-tab badge of TabView. Internal.
|
|
5
|
+
*/
|
|
6
|
+
/** The largest count a badge shows before it reads as the maximum and a plus, as on iOS. */
|
|
7
|
+
export var DEFAULT_BADGE_MAX = 99;
|
|
8
|
+
/** The words read for a dot badge when the caller gives none. */
|
|
9
|
+
export var DEFAULT_DOT_BADGE_LABEL = 'New';
|
|
10
|
+
var HIDDEN = { kind: 'hidden' };
|
|
11
|
+
/** The cap in use: a whole number of at least 1, else the default. */
|
|
12
|
+
function badgeCap(max) {
|
|
13
|
+
return Number.isFinite(max) && max >= 1 ? Math.floor(max) : DEFAULT_BADGE_MAX;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* What a badge shows for a value. A count below 1 (or not a number) hides the
|
|
17
|
+
* badge, as a zero badge does on iOS, and a count over `max` reads "99+". A
|
|
18
|
+
* text shows trimmed, and an empty one hides. `true` is a dot and `false` hides.
|
|
19
|
+
*/
|
|
20
|
+
export function badgeDisplay(value, max) {
|
|
21
|
+
if (max === void 0) { max = DEFAULT_BADGE_MAX; }
|
|
22
|
+
if (typeof value === 'number') {
|
|
23
|
+
if (!Number.isFinite(value) || value < 1)
|
|
24
|
+
return HIDDEN;
|
|
25
|
+
var count = Math.floor(value);
|
|
26
|
+
var cap = badgeCap(max);
|
|
27
|
+
return { kind: 'text', text: count > cap ? "".concat(cap, "+") : String(count) };
|
|
28
|
+
}
|
|
29
|
+
if (typeof value === 'string') {
|
|
30
|
+
var text = value.trim();
|
|
31
|
+
return text ? { kind: 'text', text: text } : HIDDEN;
|
|
32
|
+
}
|
|
33
|
+
return value === true ? { kind: 'dot' } : HIDDEN;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The words assistive technology reads for a badge: the caller's `label` when
|
|
37
|
+
* there is one, else the text the badge shows, or the default dot words for a
|
|
38
|
+
* dot. Empty when the badge is hidden.
|
|
39
|
+
*/
|
|
40
|
+
export function badgeSpokenText(display, label) {
|
|
41
|
+
if (display.kind === 'hidden')
|
|
42
|
+
return '';
|
|
43
|
+
var own = label === null || label === void 0 ? void 0 : label.trim();
|
|
44
|
+
if (own)
|
|
45
|
+
return own;
|
|
46
|
+
return display.kind === 'dot' ? DEFAULT_DOT_BADGE_LABEL : display.text;
|
|
47
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button sizes, shapes and roles, mirroring SwiftUI's `controlSize`,
|
|
3
|
+
* `buttonBorderShape` and `ButtonRole`.
|
|
4
|
+
*/
|
|
5
|
+
/** Control sizes. `xl` is iOS 26's extra large control size. */
|
|
6
|
+
export declare const BUTTON_SIZES: readonly ["sm", "md", "lg", "xl"];
|
|
7
|
+
export type ButtonSize = (typeof BUTTON_SIZES)[number];
|
|
8
|
+
export declare const DEFAULT_BUTTON_SIZE: ButtonSize;
|
|
9
|
+
export interface ButtonSizeStyle {
|
|
10
|
+
/** Block (vertical) padding. */
|
|
11
|
+
paddingBlock: string;
|
|
12
|
+
/** Inline (horizontal) padding. */
|
|
13
|
+
paddingInline: string;
|
|
14
|
+
fontSize: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const BUTTON_SIZE_STYLES: Record<ButtonSize, ButtonSizeStyle>;
|
|
17
|
+
/** Border shapes, as SwiftUI's `buttonBorderShape`. */
|
|
18
|
+
export declare const BUTTON_SHAPES: readonly ["capsule", "circle", "roundedRect"];
|
|
19
|
+
export type ButtonShape = (typeof BUTTON_SHAPES)[number];
|
|
20
|
+
export declare const DEFAULT_BUTTON_SHAPE: ButtonShape;
|
|
21
|
+
/** Roles, as SwiftUI's `ButtonRole` (`.cancel`, `.destructive`, `.confirm`). */
|
|
22
|
+
export declare const BUTTON_ROLES: readonly ["cancel", "destructive", "confirm"];
|
|
23
|
+
export type ButtonRole = (typeof BUTTON_ROLES)[number];
|
|
24
|
+
/** Accepted aliases, resolved to a role. `primary` is the audit's name for `confirm`. */
|
|
25
|
+
export declare const BUTTON_ROLE_ALIASES: Record<string, any>;
|
|
26
|
+
/** What the `buttonRole` prop takes: a role or an alias. */
|
|
27
|
+
export type ButtonRoleInput = ButtonRole | keyof typeof BUTTON_ROLE_ALIASES;
|
|
28
|
+
export interface ButtonBoxStyle {
|
|
29
|
+
/** CSS padding shorthand. */
|
|
30
|
+
padding: string;
|
|
31
|
+
fontSize: string;
|
|
32
|
+
/** CSS border-radius value. */
|
|
33
|
+
radius: string;
|
|
34
|
+
/** CSS aspect-ratio, or null to leave the box unconstrained. */
|
|
35
|
+
aspectRatio: string | null;
|
|
36
|
+
}
|
|
37
|
+
/** The box a size and shape give a Button. Unknown values fall back to md and capsule. */
|
|
38
|
+
export declare function buttonBoxStyle(size: ButtonSize, shape: ButtonShape): ButtonBoxStyle;
|
|
39
|
+
/** The role a `buttonRole` value means, with aliases resolved; anything else is no role. */
|
|
40
|
+
export declare function resolveButtonRole(role: unknown): ButtonRole | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Whether activation is blocked. A loading button stays focusable (so focus is
|
|
43
|
+
* not lost mid-action) but does nothing, as a disabled one does.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buttonBlocked(disabled: boolean, loading: boolean): boolean;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button sizes, shapes and roles, mirroring SwiftUI's `controlSize`,
|
|
3
|
+
* `buttonBorderShape` and `ButtonRole`.
|
|
4
|
+
*/
|
|
5
|
+
import { CORNER_RADIUS } from './sizes';
|
|
6
|
+
/** Control sizes. `xl` is iOS 26's extra large control size. */
|
|
7
|
+
export var BUTTON_SIZES = ['sm', 'md', 'lg', 'xl'];
|
|
8
|
+
export var DEFAULT_BUTTON_SIZE = 'md';
|
|
9
|
+
export var BUTTON_SIZE_STYLES = {
|
|
10
|
+
sm: { paddingBlock: '8px', paddingInline: '16px', fontSize: '0.875rem' },
|
|
11
|
+
md: { paddingBlock: '12px', paddingInline: '24px', fontSize: '1rem' },
|
|
12
|
+
lg: { paddingBlock: '16px', paddingInline: '32px', fontSize: '1.0625rem' },
|
|
13
|
+
xl: { paddingBlock: '20px', paddingInline: '40px', fontSize: '1.1875rem' }
|
|
14
|
+
};
|
|
15
|
+
/** Border shapes, as SwiftUI's `buttonBorderShape`. */
|
|
16
|
+
export var BUTTON_SHAPES = ['capsule', 'circle', 'roundedRect'];
|
|
17
|
+
export var DEFAULT_BUTTON_SHAPE = 'capsule';
|
|
18
|
+
/** Roles, as SwiftUI's `ButtonRole` (`.cancel`, `.destructive`, `.confirm`). */
|
|
19
|
+
export var BUTTON_ROLES = ['cancel', 'destructive', 'confirm'];
|
|
20
|
+
/** Accepted aliases, resolved to a role. `primary` is the audit's name for `confirm`. */
|
|
21
|
+
export var BUTTON_ROLE_ALIASES = { primary: 'confirm' };
|
|
22
|
+
function own(table, key) {
|
|
23
|
+
// hasOwnProperty, not `in`: 'toString' would otherwise pass.
|
|
24
|
+
return Object.prototype.hasOwnProperty.call(table, key);
|
|
25
|
+
}
|
|
26
|
+
/** The box a size and shape give a Button. Unknown values fall back to md and capsule. */
|
|
27
|
+
export function buttonBoxStyle(size, shape) {
|
|
28
|
+
var s = BUTTON_SIZE_STYLES[own(BUTTON_SIZE_STYLES, size) ? size : DEFAULT_BUTTON_SIZE];
|
|
29
|
+
// A circle is as wide as it is tall, so it takes the block padding all round.
|
|
30
|
+
if (shape === 'circle') {
|
|
31
|
+
return { padding: s.paddingBlock, fontSize: s.fontSize, radius: '50%', aspectRatio: '1 / 1' };
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
padding: "".concat(s.paddingBlock, " ").concat(s.paddingInline),
|
|
35
|
+
fontSize: s.fontSize,
|
|
36
|
+
radius: shape === 'roundedRect' ? CORNER_RADIUS.sm : CORNER_RADIUS.full,
|
|
37
|
+
aspectRatio: null
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** The role a `buttonRole` value means, with aliases resolved; anything else is no role. */
|
|
41
|
+
export function resolveButtonRole(role) {
|
|
42
|
+
if (BUTTON_ROLES.includes(role))
|
|
43
|
+
return role;
|
|
44
|
+
return own(BUTTON_ROLE_ALIASES, role) ? BUTTON_ROLE_ALIASES[role] : undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Whether activation is blocked. A loading button stays focusable (so focus is
|
|
48
|
+
* not lost mid-action) but does nothing, as a disabled one does.
|
|
49
|
+
*/
|
|
50
|
+
export function buttonBlocked(disabled, loading) {
|
|
51
|
+
return disabled || loading;
|
|
52
|
+
}
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
* Color design tokens
|
|
3
3
|
* Centralized color constants for consistent theming
|
|
4
4
|
*/
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Text color CSS values. On a toned glass surface (see adaptiveTone) the
|
|
7
|
+
* neutral ones follow the backdrop through --glass-fg and --glass-fg-secondary.
|
|
8
|
+
* Elsewhere those are unset and the theme colour is used. Tertiary maps to the
|
|
9
|
+
* secondary tone, the dimmest colour that holds 4.5:1 there.
|
|
10
|
+
*/
|
|
6
11
|
export declare const TEXT_COLORS: {
|
|
7
|
-
readonly primary: "var(--color-text)";
|
|
8
|
-
readonly secondary: "var(--color-text-secondary)";
|
|
9
|
-
readonly tertiary: "var(--color-text-tertiary)";
|
|
12
|
+
readonly primary: "var(--glass-fg, var(--color-text))";
|
|
13
|
+
readonly secondary: "var(--glass-fg-secondary, var(--color-text-secondary))";
|
|
14
|
+
readonly tertiary: "var(--glass-fg-secondary, var(--color-text-tertiary))";
|
|
10
15
|
readonly accent: "var(--color-accent)";
|
|
11
16
|
readonly white: "#ffffff";
|
|
12
17
|
};
|
package/dist/constants/colors.js
CHANGED
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
* Color design tokens
|
|
3
3
|
* Centralized color constants for consistent theming
|
|
4
4
|
*/
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Text color CSS values. On a toned glass surface (see adaptiveTone) the
|
|
7
|
+
* neutral ones follow the backdrop through --glass-fg and --glass-fg-secondary.
|
|
8
|
+
* Elsewhere those are unset and the theme colour is used. Tertiary maps to the
|
|
9
|
+
* secondary tone, the dimmest colour that holds 4.5:1 there.
|
|
10
|
+
*/
|
|
6
11
|
export var TEXT_COLORS = {
|
|
7
|
-
primary: 'var(--color-text)',
|
|
8
|
-
secondary: 'var(--color-text-secondary)',
|
|
9
|
-
tertiary: 'var(--color-text-tertiary)',
|
|
12
|
+
primary: 'var(--glass-fg, var(--color-text))',
|
|
13
|
+
secondary: 'var(--glass-fg-secondary, var(--color-text-secondary))',
|
|
14
|
+
tertiary: 'var(--glass-fg-secondary, var(--color-text-tertiary))',
|
|
10
15
|
accent: 'var(--color-accent)',
|
|
11
16
|
white: '#ffffff'
|
|
12
17
|
};
|