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.
Files changed (128) hide show
  1. package/README.md +892 -24
  2. package/dist/actions/adaptiveTone.d.ts +50 -0
  3. package/dist/actions/adaptiveTone.js +569 -0
  4. package/dist/actions/alertLogic.d.ts +67 -0
  5. package/dist/actions/alertLogic.js +123 -0
  6. package/dist/actions/anchorPlacement.d.ts +92 -0
  7. package/dist/actions/anchorPlacement.js +137 -0
  8. package/dist/actions/dragSnap.d.ts +1 -1
  9. package/dist/actions/dragSnapMath.d.ts +70 -0
  10. package/dist/actions/dragSnapMath.js +115 -0
  11. package/dist/actions/glassToneLogic.d.ts +182 -0
  12. package/dist/actions/glassToneLogic.js +513 -0
  13. package/dist/actions/heightTransition.d.ts +32 -0
  14. package/dist/actions/heightTransition.js +64 -0
  15. package/dist/actions/index.d.ts +1 -0
  16. package/dist/actions/index.js +1 -0
  17. package/dist/actions/inertSiblings.js +20 -4
  18. package/dist/actions/menuLogic.d.ts +40 -0
  19. package/dist/actions/menuLogic.js +68 -0
  20. package/dist/actions/modalDialog.d.ts +19 -0
  21. package/dist/actions/modalDialog.js +48 -0
  22. package/dist/actions/popoverLogic.d.ts +25 -0
  23. package/dist/actions/popoverLogic.js +48 -0
  24. package/dist/actions/rovingIndex.d.ts +30 -0
  25. package/dist/actions/rovingIndex.js +49 -0
  26. package/dist/actions/scrollRunTracker.d.ts +36 -0
  27. package/dist/actions/scrollRunTracker.js +77 -0
  28. package/dist/actions/scrollUnder.d.ts +21 -0
  29. package/dist/actions/scrollUnder.js +29 -0
  30. package/dist/actions/segmentedLogic.d.ts +38 -0
  31. package/dist/actions/segmentedLogic.js +59 -0
  32. package/dist/actions/sheetLogic.d.ts +43 -0
  33. package/dist/actions/sheetLogic.js +71 -0
  34. package/dist/actions/sliderLogic.d.ts +29 -0
  35. package/dist/actions/sliderLogic.js +53 -0
  36. package/dist/actions/swipeActions.d.ts +46 -2
  37. package/dist/actions/swipeActions.js +267 -46
  38. package/dist/actions/tabBarMinimize.d.ts +31 -0
  39. package/dist/actions/tabBarMinimize.js +38 -0
  40. package/dist/actions/tabViewLogic.d.ts +47 -0
  41. package/dist/actions/tabViewLogic.js +71 -0
  42. package/dist/actions/toggleKnobLogic.d.ts +57 -0
  43. package/dist/actions/toggleKnobLogic.js +66 -0
  44. package/dist/actions/toolbarFocus.d.ts +44 -0
  45. package/dist/actions/toolbarFocus.js +228 -0
  46. package/dist/actions/topLayer.d.ts +12 -0
  47. package/dist/actions/topLayer.js +18 -0
  48. package/dist/components/dialog/ActionSheet.svelte +457 -0
  49. package/dist/components/dialog/ActionSheet.svelte.d.ts +25 -0
  50. package/dist/components/dialog/Alert.svelte +337 -0
  51. package/dist/components/dialog/Alert.svelte.d.ts +28 -0
  52. package/dist/components/dialog/index.d.ts +6 -0
  53. package/dist/components/dialog/index.js +6 -0
  54. package/dist/components/glass/Glass.svelte +49 -17
  55. package/dist/components/glass/Glass.svelte.d.ts +8 -0
  56. package/dist/components/glass/GlassSection.svelte +9 -1
  57. package/dist/components/glass/LensFilters.svelte +4 -2
  58. package/dist/components/glass/Popover.svelte +379 -0
  59. package/dist/components/glass/Popover.svelte.d.ts +30 -0
  60. package/dist/components/glass/Sheet.svelte +470 -103
  61. package/dist/components/glass/Sheet.svelte.d.ts +55 -7
  62. package/dist/components/glass/index.d.ts +3 -0
  63. package/dist/components/glass/index.js +1 -0
  64. package/dist/components/index.d.ts +2 -0
  65. package/dist/components/index.js +4 -0
  66. package/dist/components/interactive/Badge.svelte +97 -6
  67. package/dist/components/interactive/Badge.svelte.d.ts +13 -2
  68. package/dist/components/interactive/Button.svelte +162 -20
  69. package/dist/components/interactive/Button.svelte.d.ts +14 -1
  70. package/dist/components/interactive/IconButton.svelte +214 -4
  71. package/dist/components/interactive/IconButton.svelte.d.ts +2 -1
  72. package/dist/components/interactive/ProgressView.svelte +306 -0
  73. package/dist/components/interactive/ProgressView.svelte.d.ts +25 -0
  74. package/dist/components/interactive/Segment.d.ts +14 -0
  75. package/dist/components/interactive/Segment.js +1 -0
  76. package/dist/components/interactive/SegmentedControl.svelte +399 -0
  77. package/dist/components/interactive/SegmentedControl.svelte.d.ts +17 -0
  78. package/dist/components/interactive/Slider.svelte +299 -0
  79. package/dist/components/interactive/Slider.svelte.d.ts +23 -0
  80. package/dist/components/interactive/TabView.svelte +573 -41
  81. package/dist/components/interactive/TabView.svelte.d.ts +25 -0
  82. package/dist/components/interactive/Toggle.svelte +287 -16
  83. package/dist/components/interactive/Toggle.svelte.d.ts +12 -0
  84. package/dist/components/interactive/index.d.ts +4 -0
  85. package/dist/components/interactive/index.js +3 -0
  86. package/dist/components/list/List.svelte +41 -17
  87. package/dist/components/list/List.svelte.d.ts +1 -0
  88. package/dist/components/list/ListRow.svelte +208 -47
  89. package/dist/components/list/ListRow.svelte.d.ts +16 -1
  90. package/dist/components/menu/Menu.svelte +51 -27
  91. package/dist/components/menu/Menu.svelte.d.ts +5 -0
  92. package/dist/components/menu/MenuItem.svelte +82 -25
  93. package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
  94. package/dist/components/menu/MenuSection.svelte +95 -0
  95. package/dist/components/menu/MenuSection.svelte.d.ts +18 -0
  96. package/dist/components/menu/MenuSubmenu.svelte +196 -0
  97. package/dist/components/menu/MenuSubmenu.svelte.d.ts +11 -0
  98. package/dist/components/menu/index.d.ts +4 -1
  99. package/dist/components/menu/index.js +3 -1
  100. package/dist/components/navigation/NavigationBar.svelte +97 -15
  101. package/dist/components/navigation/NavigationBar.svelte.d.ts +6 -0
  102. package/dist/components/toolbar/Toolbar.svelte +43 -0
  103. package/dist/components/toolbar/Toolbar.svelte.d.ts +13 -0
  104. package/dist/components/toolbar/ToolbarItemGroup.svelte +45 -0
  105. package/dist/components/toolbar/ToolbarItemGroup.svelte.d.ts +14 -0
  106. package/dist/components/toolbar/ToolbarSpacer.svelte +36 -0
  107. package/dist/components/toolbar/ToolbarSpacer.svelte.d.ts +12 -0
  108. package/dist/components/toolbar/index.d.ts +7 -0
  109. package/dist/components/toolbar/index.js +7 -0
  110. package/dist/components/typography/Text.svelte +9 -1
  111. package/dist/constants/alertAction.d.ts +19 -0
  112. package/dist/constants/alertAction.js +1 -0
  113. package/dist/constants/badge.d.ts +32 -0
  114. package/dist/constants/badge.js +47 -0
  115. package/dist/constants/buttons.d.ts +45 -0
  116. package/dist/constants/buttons.js +52 -0
  117. package/dist/constants/colors.d.ts +9 -4
  118. package/dist/constants/colors.js +9 -4
  119. package/dist/constants/index.d.ts +3 -0
  120. package/dist/constants/index.js +3 -0
  121. package/dist/constants/progress.d.ts +56 -0
  122. package/dist/constants/progress.js +75 -0
  123. package/dist/constants/variants.d.ts +6 -2
  124. package/dist/constants/variants.js +2 -2
  125. package/dist/styles/glasslikeui.css +135 -1
  126. package/dist/styles/lens.css +21 -19
  127. package/dist/styles/squircle.css +17 -7
  128. package/package.json +1 -1
@@ -1,10 +1,12 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
3
  import { fitFocusRing } from '../../actions/focusRingFit';
4
+ import { glassButtonVars } from '../../constants/variants';
4
5
 
5
6
  interface Props {
6
7
  children: Snippet;
7
- variant?: 'plain' | 'filled';
8
+ /** `glass` and `glassProminent` are the iOS 26 toolbar glass buttons. */
9
+ variant?: 'plain' | 'filled' | 'glass' | 'glassProminent';
8
10
  size?: 'sm' | 'md' | 'lg';
9
11
  label?: string | undefined;
10
12
  onclick?: ((e: MouseEvent) => void) | undefined;
@@ -25,6 +27,14 @@
25
27
  class: className = ''
26
28
  }: Props = $props();
27
29
 
30
+ // null for plain and filled, so they emit no backdrop layer.
31
+ const glass = $derived(glassButtonVars(variant));
32
+ const glassStyle = $derived(
33
+ glass
34
+ ? `; --btn-glass-blur: ${glass.blur}px; --btn-glass-saturation: ${glass.saturation}; --btn-glass-opacity: ${glass.opacity};`
35
+ : ''
36
+ );
37
+
28
38
  const sizeMap = {
29
39
  sm: 32,
30
40
  md: 40,
@@ -39,8 +49,10 @@
39
49
  {onclick}
40
50
  {disabled}
41
51
  {type}
52
+ class:is-glass={!!glass}
53
+ class:is-tinted={glass?.tinted}
42
54
  {@attach fitFocusRing}
43
- style="--btn-size: {sizeMap[size]}px"
55
+ style="--btn-size: {sizeMap[size]}px{glassStyle}"
44
56
  >
45
57
  {@render children()}
46
58
  </button>
@@ -57,11 +69,13 @@
57
69
  cursor: pointer;
58
70
  transition: all var(--transition-fast);
59
71
  background: transparent;
60
- color: var(--color-text-secondary);
72
+ /* The adaptive tone of the glass it sits on (see adaptiveTone), or the
73
+ theme colour. */
74
+ color: var(--glass-fg-secondary, var(--color-text-secondary));
61
75
  }
62
76
 
63
77
  .icon-button:hover {
64
- color: var(--color-text);
78
+ color: var(--glass-fg, var(--color-text));
65
79
  }
66
80
 
67
81
  /* Shared focus ring. :where keeps it at zero specificity, so a page's own
@@ -105,4 +119,200 @@
105
119
  .icon-button.variant-filled:hover {
106
120
  background: var(--color-accent-hover);
107
121
  }
122
+ /* Glass variants, the iOS 26 toolbar glass buttons. The same layers and
123
+ fills as the glass Button, so the two cannot drift apart (a test compares
124
+ them). */
125
+ .icon-button.is-glass {
126
+ position: relative;
127
+ transition: all var(--transition-fast), scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
128
+ background: transparent;
129
+ /* The theme's text colour when the page sets no --color-text, rather than
130
+ whatever the page inherits, which may be dark on the dark glass. */
131
+ color: var(--glass-fg, var(--color-text, var(--glass-text-color-default, #f5f5f7)));
132
+ isolation: isolate;
133
+ }
134
+
135
+ /* A page can restyle the fill with --glass-button-fill, and its hover and
136
+ pressed fills with --glass-button-fill-hover and -active. Unset, those two
137
+ follow --glass-button-fill if that is set. Reduced transparency reads none
138
+ of them. */
139
+
140
+ /* Both layers sit at negative z-index inside the isolated button: behind the
141
+ label, which is unpositioned and would otherwise be painted over. */
142
+ .icon-button.is-glass::before {
143
+ content: '';
144
+ position: absolute;
145
+ inset: 0;
146
+ z-index: -1;
147
+ border-radius: inherit;
148
+ /* Smoked glass: whatever is behind, even white, the fill stays dark enough
149
+ for a light label at 4.5:1. A white fill cannot over a bright backdrop. */
150
+ background: var(--glass-button-fill, rgba(62, 62, 64, 0.75));
151
+ backdrop-filter: blur(var(--btn-glass-blur)) saturate(var(--btn-glass-saturation));
152
+ -webkit-backdrop-filter: blur(var(--btn-glass-blur)) saturate(var(--btn-glass-saturation));
153
+ pointer-events: none;
154
+ }
155
+
156
+ .icon-button.is-glass::after {
157
+ content: '';
158
+ position: absolute;
159
+ inset: 0;
160
+ z-index: -1;
161
+ border-radius: inherit;
162
+ pointer-events: none;
163
+ border: var(--glass-border-width) solid var(--glass-border);
164
+ box-shadow: inset 0 1px 0 0 var(--glass-highlight);
165
+ }
166
+
167
+ .icon-button.is-glass > :global(*) {
168
+ position: relative;
169
+ z-index: 2;
170
+ }
171
+
172
+ /* Deepens on hover and press: brightening would cost the label its contrast. */
173
+ .icon-button.is-glass:hover::before {
174
+ background: var(--glass-button-fill-hover, var(--glass-button-fill, rgba(50, 50, 52, 0.75)));
175
+ }
176
+
177
+ .icon-button.is-glass:active::before {
178
+ background: var(--glass-button-fill-active, var(--glass-button-fill, rgba(38, 38, 40, 0.75)));
179
+ }
180
+
181
+ /* Pressed, glass grows a little and settles back with a small overshoot, as
182
+ iOS 26 glass scales and bounces (WWDC25 323). Not under reduced motion. */
183
+ .icon-button.is-glass:active {
184
+ scale: 1.04;
185
+ }
186
+
187
+ @media (prefers-reduced-motion: reduce) {
188
+ .icon-button.is-glass:active {
189
+ scale: none;
190
+ }
191
+ }
192
+ :global(:where([data-reduced-motion='true'])) .icon-button.is-glass:active {
193
+ scale: none;
194
+ }
195
+
196
+ /* The light theme has a dark label, so its white fill is opaque enough to hold
197
+ it at 4.5:1 even over black, and brightens on hover and press. :where adds
198
+ no specificity, so the prominent and reduced transparency rules below still
199
+ win. */
200
+ :global(:where(:root[data-theme='light'])) .icon-button.is-glass::before {
201
+ background: var(--glass-button-fill, rgba(255, 255, 255, 0.55));
202
+ }
203
+
204
+ :global(:where(:root[data-theme='light'])) .icon-button.is-glass:hover::before {
205
+ background: var(--glass-button-fill-hover, var(--glass-button-fill, rgba(255, 255, 255, 0.65)));
206
+ }
207
+
208
+ :global(:where(:root[data-theme='light'])) .icon-button.is-glass:active::before {
209
+ background: var(--glass-button-fill-active, var(--glass-button-fill, rgba(255, 255, 255, 0.75)));
210
+ }
211
+
212
+ /* Prominent glass: a see-through accent fill, shaded so the label holds 4.5:1
213
+ whatever is behind it. An accent label on an accent wash could not. */
214
+ .icon-button.is-glass.is-tinted {
215
+ color: var(--color-on-accent, white);
216
+ }
217
+
218
+ .icon-button.is-glass.is-tinted::before {
219
+ background: color-mix(
220
+ in srgb,
221
+ color-mix(in srgb, var(--color-accent) 80%, black) 84%,
222
+ transparent
223
+ );
224
+ }
225
+
226
+ .icon-button.is-glass.is-tinted:hover::before {
227
+ background: color-mix(
228
+ in srgb,
229
+ color-mix(in srgb, var(--color-accent) 76%, black) 84%,
230
+ transparent
231
+ );
232
+ }
233
+
234
+ .icon-button.is-glass.is-tinted:active::before {
235
+ background: color-mix(
236
+ in srgb,
237
+ color-mix(in srgb, var(--color-accent) 72%, black) 84%,
238
+ transparent
239
+ );
240
+ }
241
+
242
+ /* Reduced transparency: no see-through layer, and a solid fill on the button
243
+ itself, where contrast checkers can read it and no fill or rule given to
244
+ ::before can cover it. Plain glass mixes its white fill into the surface
245
+ colour. Prominent glass becomes solid accent, shaded on hover and press from
246
+ the accent where the button is, so a wrapper's own accent carries through.
247
+ The attribute works on the root or on any ancestor. */
248
+ @media (prefers-reduced-transparency: reduce) {
249
+ .icon-button.is-glass::before {
250
+ content: none;
251
+ }
252
+ .icon-button.is-glass {
253
+ background: color-mix(
254
+ in srgb,
255
+ white calc(var(--btn-glass-opacity) * 93%),
256
+ rgb(var(--glass-surface-color, 28, 28, 30))
257
+ );
258
+ }
259
+ .icon-button.is-glass:hover {
260
+ background: color-mix(
261
+ in srgb,
262
+ white calc(var(--btn-glass-opacity) * 76%),
263
+ rgb(var(--glass-surface-color, 28, 28, 30))
264
+ );
265
+ }
266
+ .icon-button.is-glass:active {
267
+ background: color-mix(
268
+ in srgb,
269
+ white calc(var(--btn-glass-opacity) * 60%),
270
+ rgb(var(--glass-surface-color, 28, 28, 30))
271
+ );
272
+ }
273
+ .icon-button.is-glass.is-tinted {
274
+ color: var(--color-on-accent, white);
275
+ background: var(--color-accent);
276
+ }
277
+ .icon-button.is-glass.is-tinted:hover {
278
+ background: color-mix(in srgb, var(--color-accent) 85%, black);
279
+ }
280
+ .icon-button.is-glass.is-tinted:active {
281
+ background: color-mix(in srgb, var(--color-accent) 85%, black);
282
+ }
283
+ }
284
+ :global(:where([data-reduced-transparency='true'])) .icon-button.is-glass::before {
285
+ content: none;
286
+ }
287
+ :global(:where([data-reduced-transparency='true'])) .icon-button.is-glass {
288
+ background: color-mix(
289
+ in srgb,
290
+ white calc(var(--btn-glass-opacity) * 93%),
291
+ rgb(var(--glass-surface-color, 28, 28, 30))
292
+ );
293
+ }
294
+ :global(:where([data-reduced-transparency='true'])) .icon-button.is-glass:hover {
295
+ background: color-mix(
296
+ in srgb,
297
+ white calc(var(--btn-glass-opacity) * 76%),
298
+ rgb(var(--glass-surface-color, 28, 28, 30))
299
+ );
300
+ }
301
+ :global(:where([data-reduced-transparency='true'])) .icon-button.is-glass:active {
302
+ background: color-mix(
303
+ in srgb,
304
+ white calc(var(--btn-glass-opacity) * 60%),
305
+ rgb(var(--glass-surface-color, 28, 28, 30))
306
+ );
307
+ }
308
+ :global(:where([data-reduced-transparency='true'])) .icon-button.is-glass.is-tinted {
309
+ color: var(--color-on-accent, white);
310
+ background: var(--color-accent);
311
+ }
312
+ :global(:where([data-reduced-transparency='true'])) .icon-button.is-glass.is-tinted:hover {
313
+ background: color-mix(in srgb, var(--color-accent) 85%, black);
314
+ }
315
+ :global(:where([data-reduced-transparency='true'])) .icon-button.is-glass.is-tinted:active {
316
+ background: color-mix(in srgb, var(--color-accent) 85%, black);
317
+ }
108
318
  </style>
@@ -1,7 +1,8 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  interface Props {
3
3
  children: Snippet;
4
- variant?: 'plain' | 'filled';
4
+ /** `glass` and `glassProminent` are the iOS 26 toolbar glass buttons. */
5
+ variant?: 'plain' | 'filled' | 'glass' | 'glassProminent';
5
6
  size?: 'sm' | 'md' | 'lg';
6
7
  label?: string | undefined;
7
8
  onclick?: ((e: MouseEvent) => void) | undefined;
@@ -0,0 +1,306 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import {
4
+ DEFAULT_PROGRESS_LABEL,
5
+ DEFAULT_PROGRESS_VIEW_STYLE,
6
+ PROGRESS_SIZE_PX,
7
+ isDeterminate,
8
+ progressAria,
9
+ progressFraction,
10
+ resolveProgressStyle,
11
+ ringDash,
12
+ spinnerSpokeOpacities,
13
+ type ProgressSize,
14
+ type ProgressViewStyle
15
+ } from '../../constants/progress';
16
+
17
+ interface Props {
18
+ /** Completed amount. Leave unset (or null) for an indeterminate view. */
19
+ value?: number | null | undefined;
20
+ /** The value that means complete. Defaults to 1, as in SwiftUI. */
21
+ total?: number;
22
+ /** `automatic` draws a bar when determinate and a spinner when not. */
23
+ progressViewStyle?: ProgressViewStyle;
24
+ size?: ProgressSize;
25
+ /** Visible label, which also names the progressbar. */
26
+ label?: string | undefined;
27
+ /** A custom label, in place of `label`. */
28
+ children?: Snippet | undefined;
29
+ /** Visible text for the current value, such as "40%". Also read as aria-valuetext. */
30
+ currentValueLabel?: string | undefined;
31
+ /** Accessible name when there is no visible label. Defaults to "Loading", so the progressbar is never nameless. */
32
+ accessibilityLabel?: string | undefined;
33
+ /** Sets the view on a glass platter. */
34
+ glass?: boolean;
35
+ class?: string;
36
+ }
37
+
38
+ let {
39
+ value,
40
+ total = 1,
41
+ progressViewStyle = DEFAULT_PROGRESS_VIEW_STYLE,
42
+ size = 'md',
43
+ label,
44
+ children,
45
+ currentValueLabel,
46
+ accessibilityLabel,
47
+ glass = false,
48
+ class: className = ''
49
+ }: Props = $props();
50
+
51
+ const uid = $props.id();
52
+ const labelId = `${uid}-label`;
53
+
54
+ const determinate = $derived(isDeterminate(value));
55
+ const fraction = $derived(progressFraction(value, total));
56
+ const shape = $derived(resolveProgressStyle(progressViewStyle, determinate));
57
+ const aria = $derived(progressAria(value, total, currentValueLabel));
58
+ const px = $derived(PROGRESS_SIZE_PX[size] ?? PROGRESS_SIZE_PX.md);
59
+ const hasLabel = $derived(!!children || !!label);
60
+ const valueLabelId = `${uid}-value`;
61
+ // A progressbar needs a name (axe aria-progressbar-name).
62
+ const fallbackName = $derived(accessibilityLabel || DEFAULT_PROGRESS_LABEL);
63
+ const spokes = spinnerSpokeOpacities();
64
+ // A 20 unit view box, scaled to the size; the ring's stroke sits inside it.
65
+ const RING_RADIUS = 8.5;
66
+ const dash = $derived(ringDash(fraction ?? 0, RING_RADIUS));
67
+ </script>
68
+
69
+ <div
70
+ class="progress-view style-{shape} size-{size} {className}"
71
+ class:determinate
72
+ class:indeterminate={!determinate}
73
+ class:is-glass={glass}
74
+ data-progress-style={shape}
75
+ role="progressbar"
76
+ aria-labelledby={hasLabel ? labelId : undefined}
77
+ aria-label={hasLabel ? undefined : fallbackName}
78
+ aria-describedby={!determinate && currentValueLabel ? valueLabelId : undefined}
79
+ {...aria}
80
+ style="--progress-fraction: {fraction ?? 0}; --progress-diameter: {px.diameter}px; --progress-track: {px.track}px;"
81
+ >
82
+ <!-- As on iOS: the label sits above a bar and below a spinner or ring, with
83
+ the value label last either way. DOM order, so reading order matches. -->
84
+ {#if shape === 'linear'}
85
+ {@render labelText()}
86
+ {/if}
87
+
88
+ {#if shape === 'linear'}
89
+ <span class="progress-track" aria-hidden="true">
90
+ <span class="progress-fill"></span>
91
+ </span>
92
+ {:else if determinate}
93
+ <svg class="progress-ring" viewBox="0 0 20 20" aria-hidden="true" focusable="false">
94
+ <circle class="ring-track" cx="10" cy="10" r={RING_RADIUS} />
95
+ <circle
96
+ class="ring-fill"
97
+ cx="10"
98
+ cy="10"
99
+ r={RING_RADIUS}
100
+ stroke-dasharray={dash.length}
101
+ stroke-dashoffset={dash.offset}
102
+ />
103
+ </svg>
104
+ {:else}
105
+ <svg class="progress-spinner" viewBox="0 0 20 20" aria-hidden="true" focusable="false">
106
+ {#each spokes as opacity, i (i)}
107
+ <line
108
+ x1="10"
109
+ y1="2"
110
+ x2="10"
111
+ y2="5.5"
112
+ opacity={opacity}
113
+ transform="rotate({-i * (360 / spokes.length)} 10 10)"
114
+ />
115
+ {/each}
116
+ </svg>
117
+ {/if}
118
+
119
+ {#if shape !== 'linear'}
120
+ {@render labelText()}
121
+ {/if}
122
+
123
+ {#if currentValueLabel}
124
+ <!-- A progressbar's children are presentational, so the text reaches assistive
125
+ tech as aria-valuetext (determinate) or aria-describedby (indeterminate). -->
126
+ <span class="progress-value-label" id={valueLabelId} aria-hidden={determinate ? 'true' : undefined}>{currentValueLabel}</span>
127
+ {/if}
128
+ </div>
129
+
130
+ {#snippet labelText()}
131
+ {#if hasLabel}
132
+ <span class="progress-label" id={labelId}>
133
+ {#if children}{@render children()}{:else}{label}{/if}
134
+ </span>
135
+ {/if}
136
+ {/snippet}
137
+
138
+ <style>
139
+ .progress-view {
140
+ display: inline-flex;
141
+ flex-direction: column;
142
+ align-items: center;
143
+ gap: 6px;
144
+ color: var(--color-text, var(--glass-text-color-default, #f5f5f7));
145
+ font-size: 0.9375rem;
146
+ box-sizing: border-box;
147
+ position: relative;
148
+ }
149
+
150
+ /* A bar fills the width it is given, label above and value below. */
151
+ .progress-view.style-linear {
152
+ display: flex;
153
+ align-items: stretch;
154
+ width: 100%;
155
+ }
156
+
157
+ .progress-label {
158
+ color: var(--color-text, var(--glass-text-color-default, #f5f5f7));
159
+ }
160
+
161
+ .progress-value-label {
162
+ color: var(--color-text-secondary, var(--glass-text-color-default, #f5f5f7));
163
+ font-size: 0.8125rem;
164
+ font-variant-numeric: tabular-nums;
165
+ }
166
+
167
+ /* Linear: a translucent track, as iOS's system fill, with an accent bar. */
168
+ .progress-track {
169
+ position: relative;
170
+ display: block;
171
+ height: var(--progress-track);
172
+ border-radius: var(--glass-radius-full, 9999px);
173
+ background: var(--glass-progress-track, rgba(120, 120, 128, 0.36));
174
+ overflow: hidden;
175
+ }
176
+
177
+ .progress-fill {
178
+ position: absolute;
179
+ inset-block: 0;
180
+ inset-inline-start: 0;
181
+ border-radius: inherit;
182
+ background: var(--color-accent);
183
+ }
184
+
185
+ /* Logical size, so the bar grows from the right under dir="rtl". */
186
+ .determinate .progress-fill {
187
+ inline-size: calc(var(--progress-fraction) * 100%);
188
+ transition: inline-size var(--transition-fast, 150ms ease);
189
+ }
190
+
191
+ .indeterminate .progress-fill {
192
+ inline-size: 30%;
193
+ animation: progress-slide 1.4s ease-in-out infinite;
194
+ }
195
+
196
+ .progress-ring,
197
+ .progress-spinner {
198
+ display: block;
199
+ width: var(--progress-diameter);
200
+ height: var(--progress-diameter);
201
+ }
202
+
203
+ .ring-track,
204
+ .ring-fill {
205
+ fill: none;
206
+ stroke-width: 3;
207
+ }
208
+
209
+ .ring-track {
210
+ stroke: var(--glass-progress-track, rgba(120, 120, 128, 0.36));
211
+ }
212
+
213
+ /* Starts at twelve o'clock and runs clockwise. */
214
+ .ring-fill {
215
+ stroke: var(--color-accent);
216
+ stroke-linecap: round;
217
+ transform: rotate(-90deg);
218
+ transform-origin: 50% 50%;
219
+ transition: stroke-dashoffset var(--transition-fast, 150ms ease);
220
+ }
221
+
222
+ /* The iOS activity indicator: grey spokes, stepping round once a second. */
223
+ .progress-spinner {
224
+ color: var(--progress-spinner-color, var(--color-text-secondary, var(--glass-text-color-default, #f5f5f7)));
225
+ animation: progress-spin 1s steps(8, end) infinite;
226
+ }
227
+
228
+ .progress-spinner line {
229
+ stroke: currentColor;
230
+ stroke-width: 2;
231
+ stroke-linecap: round;
232
+ }
233
+
234
+ /* Glass platter: a blurred capsule behind the whole view. */
235
+ .progress-view.is-glass {
236
+ padding: 10px 14px;
237
+ border-radius: var(--glass-radius-lg, 16px);
238
+ background: var(--glass-surface-bg, rgba(28, 28, 30, 0.3));
239
+ backdrop-filter: blur(20px) saturate(1.8);
240
+ -webkit-backdrop-filter: blur(20px) saturate(1.8);
241
+ border: var(--glass-border-width, 0.5px) solid var(--glass-border, rgba(255, 255, 255, 0.12));
242
+ box-shadow: inset 0 1px 0 0 var(--glass-highlight, rgba(255, 255, 255, 0.08));
243
+ }
244
+
245
+ @keyframes progress-spin {
246
+ to {
247
+ transform: rotate(360deg);
248
+ }
249
+ }
250
+
251
+ @keyframes progress-slide {
252
+ from {
253
+ inset-inline-start: -30%;
254
+ }
255
+ to {
256
+ inset-inline-start: 100%;
257
+ }
258
+ }
259
+
260
+ @keyframes progress-pulse {
261
+ 50% {
262
+ opacity: 0.45;
263
+ }
264
+ }
265
+
266
+ /* Reduced motion: nothing spins or slides. A slow fade still says busy;
267
+ a determinate bar jumps to its value. */
268
+ @media (prefers-reduced-motion: reduce) {
269
+ .progress-spinner {
270
+ animation: progress-pulse 2s ease-in-out infinite;
271
+ }
272
+ .indeterminate .progress-fill {
273
+ inline-size: 100%;
274
+ animation: progress-pulse 2s ease-in-out infinite;
275
+ }
276
+ .determinate .progress-fill,
277
+ .ring-fill {
278
+ transition: none;
279
+ }
280
+ }
281
+ :global([data-reduced-motion='true']) .progress-spinner {
282
+ animation: progress-pulse 2s ease-in-out infinite;
283
+ }
284
+ :global([data-reduced-motion='true']) .indeterminate .progress-fill {
285
+ inline-size: 100%;
286
+ animation: progress-pulse 2s ease-in-out infinite;
287
+ }
288
+ :global([data-reduced-motion='true']) .determinate .progress-fill,
289
+ :global([data-reduced-motion='true']) .ring-fill {
290
+ transition: none;
291
+ }
292
+
293
+ /* Reduced transparency: a solid platter. */
294
+ @media (prefers-reduced-transparency: reduce) {
295
+ .progress-view.is-glass {
296
+ backdrop-filter: none;
297
+ -webkit-backdrop-filter: none;
298
+ background: rgb(var(--glass-surface-color, 28, 28, 30));
299
+ }
300
+ }
301
+ :global(:where([data-reduced-transparency='true'])) .progress-view.is-glass {
302
+ backdrop-filter: none;
303
+ -webkit-backdrop-filter: none;
304
+ background: rgb(var(--glass-surface-color, 28, 28, 30));
305
+ }
306
+ </style>
@@ -0,0 +1,25 @@
1
+ import type { Snippet } from 'svelte';
2
+ import { type ProgressSize, type ProgressViewStyle } from '../../constants/progress';
3
+ interface Props {
4
+ /** Completed amount. Leave unset (or null) for an indeterminate view. */
5
+ value?: number | null | undefined;
6
+ /** The value that means complete. Defaults to 1, as in SwiftUI. */
7
+ total?: number;
8
+ /** `automatic` draws a bar when determinate and a spinner when not. */
9
+ progressViewStyle?: ProgressViewStyle;
10
+ size?: ProgressSize;
11
+ /** Visible label, which also names the progressbar. */
12
+ label?: string | undefined;
13
+ /** A custom label, in place of `label`. */
14
+ children?: Snippet | undefined;
15
+ /** Visible text for the current value, such as "40%". Also read as aria-valuetext. */
16
+ currentValueLabel?: string | undefined;
17
+ /** Accessible name when there is no visible label. Defaults to "Loading", so the progressbar is never nameless. */
18
+ accessibilityLabel?: string | undefined;
19
+ /** Sets the view on a glass platter. */
20
+ glass?: boolean;
21
+ class?: string;
22
+ }
23
+ declare const ProgressView: import("svelte").Component<Props, {}, string>;
24
+ type ProgressView = ReturnType<typeof ProgressView>;
25
+ export default ProgressView;
@@ -0,0 +1,14 @@
1
+ import type { Snippet } from 'svelte';
2
+ /** One choice in a SegmentedControl. */
3
+ export interface Segment {
4
+ /** The value the control takes when this segment is chosen. Unique within the control. */
5
+ value: string;
6
+ /** The segment's text, and its accessible name. */
7
+ label: string;
8
+ /** An icon drawn before the label. */
9
+ icon?: Snippet;
10
+ /** Whether the label is read by assistive technology only, for an icon-only segment. */
11
+ hidesLabel?: boolean;
12
+ /** Whether this segment cannot be chosen. */
13
+ disabled?: boolean;
14
+ }
@@ -0,0 +1 @@
1
+ export {};