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
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte action: flips a glass surface's text between dark and light to suit
|
|
3
|
+
* what is behind it, as iOS 26 Liquid Glass does. Glass wires it in, so every
|
|
4
|
+
* glass surface has it.
|
|
5
|
+
*
|
|
6
|
+
* The surface gets `data-glass-tone="light"` over a light backdrop and
|
|
7
|
+
* `data-glass-tone="dark"` over a dark one. glasslikeui.css turns that into
|
|
8
|
+
* `--glass-fg`, `--glass-fg-secondary` and `--glass-fg-accent`, which component
|
|
9
|
+
* text reads with the theme colour as the fallback.
|
|
10
|
+
* `data-glass-tone-secondary` holds how dim secondary text may go, and
|
|
11
|
+
* `data-glass-tone-accent` how much accent colour accent text may keep, and
|
|
12
|
+
* still hold 4.5:1.
|
|
13
|
+
*
|
|
14
|
+
* A page cannot read the pixels behind an element, so the backdrop is
|
|
15
|
+
* estimated: a few points on the surface are hit tested with
|
|
16
|
+
* `elementsFromPoint`, open shadow roots included, and the background colours
|
|
17
|
+
* below the surface are painted together, with the surface's own fill on top.
|
|
18
|
+
* A linear gradient is read at the point. Images, video, canvas and inline SVG
|
|
19
|
+
* are not read. An author marks them, or a section holding them, with
|
|
20
|
+
* `data-glass-backdrop="light|dark"`. A point with an unmarked one is skipped,
|
|
21
|
+
* and a surface with no readable point keeps the theme colours. Elements with
|
|
22
|
+
* `pointer-events: none` are invisible to hit testing, so an overlay like that
|
|
23
|
+
* needs the hint on the surface's own section.
|
|
24
|
+
*
|
|
25
|
+
* Floating surfaces (fixed or sticky, or inside a fixed or sticky element) are
|
|
26
|
+
* checked again on scroll, at most once per animation frame, and every
|
|
27
|
+
* 500ms while on screen, for backdrops that change by themselves. Every surface
|
|
28
|
+
* is checked on resize, on its own resize, on a theme or preference change,
|
|
29
|
+
* when a transition or animation ends, on history navigation, and when
|
|
30
|
+
* `refreshAdaptiveTone()` is called. Only surfaces on screen do work.
|
|
31
|
+
*
|
|
32
|
+
* A page turns the automatic tone off for everything inside an element with
|
|
33
|
+
* `data-glass-adaptive="off"`, such as `<html>`. Forced colours turn it off too.
|
|
34
|
+
*/
|
|
35
|
+
import { type GlassTone } from './glassToneLogic';
|
|
36
|
+
export type { GlassTone } from './glassToneLogic';
|
|
37
|
+
export interface AdaptiveToneOptions {
|
|
38
|
+
/** `auto` follows the backdrop. `light` and `dark` force a tone. `theme` turns it off. */
|
|
39
|
+
tone?: GlassTone;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Checks every glass surface's tone again on the next frame. Call it after
|
|
43
|
+
* changing what is behind glass with nothing scrolling, such as swapping a
|
|
44
|
+
* route's content at the top of the page.
|
|
45
|
+
*/
|
|
46
|
+
export declare function refreshAdaptiveTone(): void;
|
|
47
|
+
export declare function adaptiveTone(node: HTMLElement, options?: AdaptiveToneOptions): {
|
|
48
|
+
update(next?: AdaptiveToneOptions): void;
|
|
49
|
+
destroy(): void;
|
|
50
|
+
};
|
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Svelte action: flips a glass surface's text between dark and light to suit
|
|
23
|
+
* what is behind it, as iOS 26 Liquid Glass does. Glass wires it in, so every
|
|
24
|
+
* glass surface has it.
|
|
25
|
+
*
|
|
26
|
+
* The surface gets `data-glass-tone="light"` over a light backdrop and
|
|
27
|
+
* `data-glass-tone="dark"` over a dark one. glasslikeui.css turns that into
|
|
28
|
+
* `--glass-fg`, `--glass-fg-secondary` and `--glass-fg-accent`, which component
|
|
29
|
+
* text reads with the theme colour as the fallback.
|
|
30
|
+
* `data-glass-tone-secondary` holds how dim secondary text may go, and
|
|
31
|
+
* `data-glass-tone-accent` how much accent colour accent text may keep, and
|
|
32
|
+
* still hold 4.5:1.
|
|
33
|
+
*
|
|
34
|
+
* A page cannot read the pixels behind an element, so the backdrop is
|
|
35
|
+
* estimated: a few points on the surface are hit tested with
|
|
36
|
+
* `elementsFromPoint`, open shadow roots included, and the background colours
|
|
37
|
+
* below the surface are painted together, with the surface's own fill on top.
|
|
38
|
+
* A linear gradient is read at the point. Images, video, canvas and inline SVG
|
|
39
|
+
* are not read. An author marks them, or a section holding them, with
|
|
40
|
+
* `data-glass-backdrop="light|dark"`. A point with an unmarked one is skipped,
|
|
41
|
+
* and a surface with no readable point keeps the theme colours. Elements with
|
|
42
|
+
* `pointer-events: none` are invisible to hit testing, so an overlay like that
|
|
43
|
+
* needs the hint on the surface's own section.
|
|
44
|
+
*
|
|
45
|
+
* Floating surfaces (fixed or sticky, or inside a fixed or sticky element) are
|
|
46
|
+
* checked again on scroll, at most once per animation frame, and every
|
|
47
|
+
* 500ms while on screen, for backdrops that change by themselves. Every surface
|
|
48
|
+
* is checked on resize, on its own resize, on a theme or preference change,
|
|
49
|
+
* when a transition or animation ends, on history navigation, and when
|
|
50
|
+
* `refreshAdaptiveTone()` is called. Only surfaces on screen do work.
|
|
51
|
+
*
|
|
52
|
+
* A page turns the automatic tone off for everything inside an element with
|
|
53
|
+
* `data-glass-adaptive="off"`, such as `<html>`. Forced colours turn it off too.
|
|
54
|
+
*/
|
|
55
|
+
import { chooseTone, accentStep, backdropCandidates, flattenFill, gradientColours, linearGradientAt, paintOver, parseCssColor, parseLinearGradient, readBackdropHint, readSaturation, resolveGlassTone, saturate, samplePoints, secondaryStep } from './glassToneLogic';
|
|
56
|
+
var TONE_ATTRIBUTE = 'data-glass-tone';
|
|
57
|
+
var SECONDARY_ATTRIBUTE = 'data-glass-tone-secondary';
|
|
58
|
+
var ACCENT_ATTRIBUTE = 'data-glass-tone-accent';
|
|
59
|
+
/** Set a frame after the first tone, so the text fades on later flips only. */
|
|
60
|
+
var READY_ATTRIBUTE = 'data-glass-tone-ready';
|
|
61
|
+
/** Elements whose pixels adaptiveTone does not read. */
|
|
62
|
+
var MEDIA_TAGS = new Set(['IMG', 'VIDEO', 'CANVAS', 'IFRAME', 'PICTURE', 'OBJECT', 'EMBED']);
|
|
63
|
+
/** The canvas colours browsers paint where the page paints nothing. */
|
|
64
|
+
var CANVAS_LIGHT = [255, 255, 255];
|
|
65
|
+
var CANVAS_DARK = [18, 18, 18];
|
|
66
|
+
/** Settles a theme change whose fills cross-fade, after the longest transition. */
|
|
67
|
+
var SETTLE_DELAY = 400;
|
|
68
|
+
/** How often a floating surface on screen is checked with nothing moving. */
|
|
69
|
+
var POLL_INTERVAL = 500;
|
|
70
|
+
/** Root attributes a theme or preference switch writes. */
|
|
71
|
+
var ROOT_ATTRIBUTES = ['data-theme', 'class', 'style', 'data-reduced-transparency', 'data-contrast', 'data-glass-adaptive'];
|
|
72
|
+
var MEDIA_QUERIES = [
|
|
73
|
+
'(prefers-color-scheme: dark)',
|
|
74
|
+
'(prefers-reduced-transparency: reduce)',
|
|
75
|
+
'(prefers-contrast: more)',
|
|
76
|
+
'(forced-colors: active)'
|
|
77
|
+
];
|
|
78
|
+
/** Document events after which what is behind a surface may have changed. */
|
|
79
|
+
var CHANGE_EVENTS = ['transitionend', 'animationend', 'animationiteration'];
|
|
80
|
+
var entries = new Map();
|
|
81
|
+
var dirty = new Set();
|
|
82
|
+
var frame = 0;
|
|
83
|
+
var settle;
|
|
84
|
+
var poll;
|
|
85
|
+
var intersection;
|
|
86
|
+
var resize;
|
|
87
|
+
/** Undoes what start() set up. */
|
|
88
|
+
var teardown = [];
|
|
89
|
+
function schedule(node) {
|
|
90
|
+
dirty.add(node);
|
|
91
|
+
if (frame === 0)
|
|
92
|
+
frame = requestAnimationFrame(flush);
|
|
93
|
+
}
|
|
94
|
+
function scheduleAll() {
|
|
95
|
+
for (var _i = 0, _a = entries.keys(); _i < _a.length; _i++) {
|
|
96
|
+
var node = _a[_i];
|
|
97
|
+
schedule(node);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* On scroll: floating surfaces, which the page moves under; surfaces that came
|
|
102
|
+
* on screen before any sample point did; and, for a scroll inside an element,
|
|
103
|
+
* every surface outside it, which may float over it.
|
|
104
|
+
*/
|
|
105
|
+
function onScroll(event) {
|
|
106
|
+
var scroller = event.target instanceof Element ? event.target : null;
|
|
107
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
108
|
+
var _a = entries_1[_i], node = _a[0], entry = _a[1];
|
|
109
|
+
if (entry.floating || (entry.visible && entry.pending) || (scroller && !scroller.contains(node)))
|
|
110
|
+
schedule(node);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Checks every glass surface's tone again on the next frame. Call it after
|
|
115
|
+
* changing what is behind glass with nothing scrolling, such as swapping a
|
|
116
|
+
* route's content at the top of the page.
|
|
117
|
+
*/
|
|
118
|
+
export function refreshAdaptiveTone() {
|
|
119
|
+
scheduleAll();
|
|
120
|
+
}
|
|
121
|
+
function onThemeChange() {
|
|
122
|
+
scheduleAll();
|
|
123
|
+
clearTimeout(settle);
|
|
124
|
+
settle = setTimeout(scheduleAll, SETTLE_DELAY);
|
|
125
|
+
}
|
|
126
|
+
/** A transition or animation ended: re-check, unless it was on glass itself. */
|
|
127
|
+
function onChangeEvent(event) {
|
|
128
|
+
var target = event.target;
|
|
129
|
+
for (var _i = 0, _a = entries.keys(); _i < _a.length; _i++) {
|
|
130
|
+
var node = _a[_i];
|
|
131
|
+
if (node.contains(target))
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
scheduleAll();
|
|
135
|
+
}
|
|
136
|
+
function flush() {
|
|
137
|
+
frame = 0;
|
|
138
|
+
var batch = __spreadArray([], dirty, true);
|
|
139
|
+
dirty.clear();
|
|
140
|
+
// Every read first, then every write, so the writes force no layout between reads.
|
|
141
|
+
var decisions = [];
|
|
142
|
+
for (var _i = 0, batch_1 = batch; _i < batch_1.length; _i++) {
|
|
143
|
+
var node = batch_1[_i];
|
|
144
|
+
var entry = entries.get(node);
|
|
145
|
+
// Off screen: skipped, and measured again when the observer brings it back.
|
|
146
|
+
if (!entry.visible)
|
|
147
|
+
continue;
|
|
148
|
+
var decision = measure(node, entry);
|
|
149
|
+
if (decision)
|
|
150
|
+
decisions.push([node, entry, decision]);
|
|
151
|
+
}
|
|
152
|
+
styleCache.clear();
|
|
153
|
+
for (var _a = 0, decisions_1 = decisions; _a < decisions_1.length; _a++) {
|
|
154
|
+
var _b = decisions_1[_a], node = _b[0], entry = _b[1], decision = _b[2];
|
|
155
|
+
commit(node, entry, decision);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function prefers(query) {
|
|
159
|
+
return typeof matchMedia === 'function' && matchMedia(query).matches;
|
|
160
|
+
}
|
|
161
|
+
function canvasColour() {
|
|
162
|
+
var scheme = getComputedStyle(document.documentElement).colorScheme;
|
|
163
|
+
var dark = /\bdark\b/.test(scheme);
|
|
164
|
+
var light = /\blight\b/.test(scheme);
|
|
165
|
+
return dark && (!light || prefers('(prefers-color-scheme: dark)')) ? CANVAS_DARK : CANVAS_LIGHT;
|
|
166
|
+
}
|
|
167
|
+
var colourCache = new Map();
|
|
168
|
+
var painter;
|
|
169
|
+
/**
|
|
170
|
+
* Reads any CSS colour. The sRGB forms are parsed. Others, such as oklch(),
|
|
171
|
+
* are painted on a 1x1 canvas and read back, once each.
|
|
172
|
+
*/
|
|
173
|
+
function readColour(value) {
|
|
174
|
+
var parsed = parseCssColor(value);
|
|
175
|
+
if (parsed)
|
|
176
|
+
return parsed;
|
|
177
|
+
var cached = colourCache.get(value);
|
|
178
|
+
if (cached !== undefined)
|
|
179
|
+
return cached;
|
|
180
|
+
if (painter === undefined) {
|
|
181
|
+
painter = document.createElement('canvas').getContext('2d', { willReadFrequently: true });
|
|
182
|
+
}
|
|
183
|
+
var colour = null;
|
|
184
|
+
if (painter) {
|
|
185
|
+
// A value the canvas cannot read leaves fillStyle as it was, so it
|
|
186
|
+
// reads back as each of two different colours set before it.
|
|
187
|
+
painter.fillStyle = '#000000';
|
|
188
|
+
painter.fillStyle = value;
|
|
189
|
+
var first = painter.fillStyle;
|
|
190
|
+
painter.fillStyle = '#ffffff';
|
|
191
|
+
painter.fillStyle = value;
|
|
192
|
+
if (painter.fillStyle === first) {
|
|
193
|
+
painter.clearRect(0, 0, 1, 1);
|
|
194
|
+
painter.fillRect(0, 0, 1, 1);
|
|
195
|
+
var _a = painter.getImageData(0, 0, 1, 1).data, r = _a[0], g = _a[1], b = _a[2], a = _a[3];
|
|
196
|
+
colour = { rgb: [r, g, b], alpha: a / 255 };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
colourCache.set(value, colour);
|
|
200
|
+
return colour;
|
|
201
|
+
}
|
|
202
|
+
/** Styles read this frame, so an element under several points is read once. */
|
|
203
|
+
var styleCache = new Map();
|
|
204
|
+
var faded = function (colour, opacity) { return ({ rgb: colour.rgb, alpha: colour.alpha * opacity }); };
|
|
205
|
+
function hintAbove(element) {
|
|
206
|
+
var _a, _b;
|
|
207
|
+
return readBackdropHint((_b = (_a = element.closest('[data-glass-backdrop]')) === null || _a === void 0 ? void 0 : _a.getAttribute('data-glass-backdrop')) !== null && _b !== void 0 ? _b : null);
|
|
208
|
+
}
|
|
209
|
+
function readStyle(element) {
|
|
210
|
+
var own = readBackdropHint(element.getAttribute('data-glass-backdrop'));
|
|
211
|
+
if (own)
|
|
212
|
+
return { layers: [own] };
|
|
213
|
+
if (MEDIA_TAGS.has(element.tagName) || element instanceof SVGElement)
|
|
214
|
+
return { layers: [hintAbove(element)] };
|
|
215
|
+
var style = getComputedStyle(element);
|
|
216
|
+
var parsed = Number.parseFloat(style.opacity);
|
|
217
|
+
var opacity = Number.isFinite(parsed) ? parsed : 1;
|
|
218
|
+
var colour = readColour(style.backgroundColor);
|
|
219
|
+
var gradient = parseLinearGradient(style.backgroundImage, readColour);
|
|
220
|
+
if (gradient)
|
|
221
|
+
return { gradient: gradient, colour: colour, opacity: opacity, box: element.getBoundingClientRect() };
|
|
222
|
+
var stops = gradientColours(style.backgroundImage, readColour);
|
|
223
|
+
if (stops === null)
|
|
224
|
+
return { layers: [hintAbove(element)] };
|
|
225
|
+
// A custom element with no open shadow root and nothing painted of its own
|
|
226
|
+
// may paint in a closed root, which cannot be read: unknown unless hinted.
|
|
227
|
+
if (element.tagName.includes('-') && !element.shadowRoot && stops.length === 0 && !(colour === null || colour === void 0 ? void 0 : colour.alpha)) {
|
|
228
|
+
return { layers: [hintAbove(element)] };
|
|
229
|
+
}
|
|
230
|
+
var layers = stops.length > 0 ? [stops.map(function (s) { return faded(s, opacity); })] : [];
|
|
231
|
+
layers.push(colour && [faded(colour, opacity)]);
|
|
232
|
+
return { layers: layers };
|
|
233
|
+
}
|
|
234
|
+
function styleOf(element) {
|
|
235
|
+
var style = styleCache.get(element);
|
|
236
|
+
if (!style) {
|
|
237
|
+
style = readStyle(element);
|
|
238
|
+
styleCache.set(element, style);
|
|
239
|
+
}
|
|
240
|
+
return style;
|
|
241
|
+
}
|
|
242
|
+
/** The layers one element paints behind a glass surface at a point, front first. */
|
|
243
|
+
function layersAt(element, x, y) {
|
|
244
|
+
var style = styleOf(element);
|
|
245
|
+
if ('layers' in style)
|
|
246
|
+
return style.layers;
|
|
247
|
+
var at = linearGradientAt(style.gradient, style.box, x, y);
|
|
248
|
+
return [[faded(at, style.opacity)], style.colour && [faded(style.colour, style.opacity)]];
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The surface's own fill (its background, then its ::before and ::after), and
|
|
252
|
+
* the saturation its backdrop-filter gives the fill and the page under it.
|
|
253
|
+
*/
|
|
254
|
+
function surfaceOf(node) {
|
|
255
|
+
var layers = [];
|
|
256
|
+
var saturation = 1;
|
|
257
|
+
for (var _i = 0, _a = [null, '::before', '::after']; _i < _a.length; _i++) {
|
|
258
|
+
var pseudo = _a[_i];
|
|
259
|
+
var style = getComputedStyle(node, pseudo);
|
|
260
|
+
var colour = readColour(style.backgroundColor);
|
|
261
|
+
if (colour)
|
|
262
|
+
layers.push(colour);
|
|
263
|
+
saturation *= readSaturation(style.backdropFilter || style.getPropertyValue('-webkit-backdrop-filter'));
|
|
264
|
+
}
|
|
265
|
+
return { fill: flattenFill(layers), saturation: saturation };
|
|
266
|
+
}
|
|
267
|
+
/** Whether nothing under this layer can show through it. */
|
|
268
|
+
function covers(layer) {
|
|
269
|
+
return !Array.isArray(layer) || layer.every(function (colour) { return colour.alpha >= 1; });
|
|
270
|
+
}
|
|
271
|
+
/** The elements at a point, front first, with open shadow roots opened up. */
|
|
272
|
+
function stackAt(x, y) {
|
|
273
|
+
var stack = [];
|
|
274
|
+
for (var _i = 0, _a = document.elementsFromPoint(x, y); _i < _a.length; _i++) {
|
|
275
|
+
var element = _a[_i];
|
|
276
|
+
var root = element.shadowRoot;
|
|
277
|
+
if (root) {
|
|
278
|
+
for (var _b = 0, _c = root.elementsFromPoint(x, y); _b < _c.length; _b++) {
|
|
279
|
+
var inner = _c[_b];
|
|
280
|
+
if (root.contains(inner))
|
|
281
|
+
stack.push(inner);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
stack.push(element);
|
|
285
|
+
}
|
|
286
|
+
return stack;
|
|
287
|
+
}
|
|
288
|
+
/** The opaque colours that may sit behind the surface at one point, or null. */
|
|
289
|
+
function backdropAt(node, x, y, canvas) {
|
|
290
|
+
var stack = stackAt(x, y);
|
|
291
|
+
// The surface, its content and anything in front of it are not behind it.
|
|
292
|
+
var start = 0;
|
|
293
|
+
stack.forEach(function (element, index) {
|
|
294
|
+
if (node.contains(element))
|
|
295
|
+
start = index + 1;
|
|
296
|
+
});
|
|
297
|
+
var layers = [];
|
|
298
|
+
for (var _i = 0, _a = stack.slice(start); _i < _a.length; _i++) {
|
|
299
|
+
var element = _a[_i];
|
|
300
|
+
var own = layersAt(element, x, y);
|
|
301
|
+
layers.push.apply(layers, own);
|
|
302
|
+
// Nothing further down shows through, so stop reading styles.
|
|
303
|
+
if (own.some(covers))
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
return backdropCandidates(layers, canvas);
|
|
307
|
+
}
|
|
308
|
+
/** A colour custom property set on the surface, if it reads as a colour. */
|
|
309
|
+
function tokenColour(node, name) {
|
|
310
|
+
return readColour(getComputedStyle(node).getPropertyValue(name));
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The surfaces accent text may sit on: the glass, and the glass under a
|
|
314
|
+
* selection fill (--glass-active-bg), as the selected tab sits on.
|
|
315
|
+
*/
|
|
316
|
+
function accentSurfaces(node, surfaces) {
|
|
317
|
+
var selection = tokenColour(node, '--glass-active-bg');
|
|
318
|
+
if (!selection)
|
|
319
|
+
return __spreadArray([], surfaces, true);
|
|
320
|
+
return __spreadArray(__spreadArray([], surfaces, true), surfaces.map(function (surface) { return paintOver(selection, surface); }), true);
|
|
321
|
+
}
|
|
322
|
+
/** Works out one surface's tone without writing anything. Null keeps what it has. */
|
|
323
|
+
function measure(node, entry) {
|
|
324
|
+
var _a;
|
|
325
|
+
if (!node.isConnected)
|
|
326
|
+
return null;
|
|
327
|
+
if (prefers('(forced-colors: active)') || node.closest('[data-glass-adaptive="off"]')) {
|
|
328
|
+
return { tone: null, secondary: null, accent: null };
|
|
329
|
+
}
|
|
330
|
+
var box = node.getBoundingClientRect();
|
|
331
|
+
var points = samplePoints(box, window.innerWidth, window.innerHeight);
|
|
332
|
+
// Off screen or not laid out: keep what it has until it can be measured.
|
|
333
|
+
entry.pending = points.length === 0;
|
|
334
|
+
if (entry.pending)
|
|
335
|
+
return null;
|
|
336
|
+
var _b = surfaceOf(node), fill = _b.fill, saturation = _b.saturation;
|
|
337
|
+
var canvas = canvasColour();
|
|
338
|
+
// An engine that paints backdrop-filter saturates the fill and the page
|
|
339
|
+
// under it together. One that does not shows the page with the fill over it.
|
|
340
|
+
var filtered = paintsBackdropFilter();
|
|
341
|
+
var surfaces = [];
|
|
342
|
+
for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
|
|
343
|
+
var _c = points_1[_i], x = _c[0], y = _c[1];
|
|
344
|
+
for (var _d = 0, _e = (_a = backdropAt(node, x, y, canvas)) !== null && _a !== void 0 ? _a : []; _d < _e.length; _d++) {
|
|
345
|
+
var colour = _e[_d];
|
|
346
|
+
var painted = paintOver(fill, colour);
|
|
347
|
+
surfaces.push(filtered ? saturate(painted, saturation) : painted);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
var tone = chooseTone(surfaces, entry.tone);
|
|
351
|
+
if (tone === null)
|
|
352
|
+
return { tone: null, secondary: null, accent: null };
|
|
353
|
+
var accent = tokenColour(node, '--color-accent');
|
|
354
|
+
return {
|
|
355
|
+
tone: tone,
|
|
356
|
+
secondary: secondaryStep(tone, surfaces),
|
|
357
|
+
accent: accent && accent.alpha >= 1 ? accentStep(tone, accent.rgb, accentSurfaces(node, surfaces)) : null
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
function setAttribute(node, name, value) {
|
|
361
|
+
if (value === null)
|
|
362
|
+
node.removeAttribute(name);
|
|
363
|
+
else if (node.getAttribute(name) !== value)
|
|
364
|
+
node.setAttribute(name, value);
|
|
365
|
+
}
|
|
366
|
+
function write(node, decision) {
|
|
367
|
+
setAttribute(node, TONE_ATTRIBUTE, decision.tone);
|
|
368
|
+
setAttribute(node, SECONDARY_ATTRIBUTE, decision.secondary === null ? null : String(decision.secondary));
|
|
369
|
+
setAttribute(node, ACCENT_ATTRIBUTE, decision.accent === null ? null : String(decision.accent));
|
|
370
|
+
}
|
|
371
|
+
function commit(node, entry, decision) {
|
|
372
|
+
entry.tone = decision.tone;
|
|
373
|
+
write(node, decision);
|
|
374
|
+
}
|
|
375
|
+
/** Whether the surface moves against the page as it scrolls. */
|
|
376
|
+
function isFloating(node) {
|
|
377
|
+
for (var el = node; el; el = el.parentElement) {
|
|
378
|
+
var position = getComputedStyle(el).position;
|
|
379
|
+
if (position === 'fixed' || position === 'sticky')
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
function listen(target, type, handler, options) {
|
|
385
|
+
target.addEventListener(type, handler, options);
|
|
386
|
+
teardown.push(function () { return target.removeEventListener(type, handler, options); });
|
|
387
|
+
}
|
|
388
|
+
function onPoll() {
|
|
389
|
+
for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
|
|
390
|
+
var _a = entries_2[_i], node = _a[0], entry = _a[1];
|
|
391
|
+
if (entry.floating && entry.visible)
|
|
392
|
+
schedule(node);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/** Runs the 500ms check only while a floating surface is on screen and the page is shown. */
|
|
396
|
+
function updatePoll() {
|
|
397
|
+
var needed = false;
|
|
398
|
+
if (document.visibilityState !== 'hidden') {
|
|
399
|
+
for (var _i = 0, _a = entries.values(); _i < _a.length; _i++) {
|
|
400
|
+
var entry = _a[_i];
|
|
401
|
+
if (entry.floating && entry.visible)
|
|
402
|
+
needed = true;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (needed && poll === undefined)
|
|
406
|
+
poll = setInterval(onPoll, POLL_INTERVAL);
|
|
407
|
+
if (!needed && poll !== undefined) {
|
|
408
|
+
clearInterval(poll);
|
|
409
|
+
poll = undefined;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function start() {
|
|
413
|
+
if (typeof IntersectionObserver === 'function') {
|
|
414
|
+
var observer_1 = new IntersectionObserver(function (records) {
|
|
415
|
+
for (var _i = 0, records_1 = records; _i < records_1.length; _i++) {
|
|
416
|
+
var record = records_1[_i];
|
|
417
|
+
var entry = entries.get(record.target);
|
|
418
|
+
if (!entry)
|
|
419
|
+
continue;
|
|
420
|
+
entry.visible = record.isIntersecting;
|
|
421
|
+
schedule(record.target);
|
|
422
|
+
}
|
|
423
|
+
updatePoll();
|
|
424
|
+
}, { threshold: [0, 0.25, 0.5, 0.75, 1] });
|
|
425
|
+
intersection = observer_1;
|
|
426
|
+
teardown.push(function () { return observer_1.disconnect(); });
|
|
427
|
+
}
|
|
428
|
+
if (typeof ResizeObserver === 'function') {
|
|
429
|
+
var observer_2 = new ResizeObserver(function (records) {
|
|
430
|
+
for (var _i = 0, records_2 = records; _i < records_2.length; _i++) {
|
|
431
|
+
var record = records_2[_i];
|
|
432
|
+
var node = record.target;
|
|
433
|
+
var entry = entries.get(node);
|
|
434
|
+
if (!entry)
|
|
435
|
+
continue;
|
|
436
|
+
entry.floating = isFloating(node);
|
|
437
|
+
schedule(node);
|
|
438
|
+
}
|
|
439
|
+
updatePoll();
|
|
440
|
+
});
|
|
441
|
+
resize = observer_2;
|
|
442
|
+
teardown.push(function () { return observer_2.disconnect(); });
|
|
443
|
+
}
|
|
444
|
+
if (typeof MutationObserver === 'function') {
|
|
445
|
+
var observer_3 = new MutationObserver(onThemeChange);
|
|
446
|
+
for (var _i = 0, _a = [document.documentElement, document.body]; _i < _a.length; _i++) {
|
|
447
|
+
var root = _a[_i];
|
|
448
|
+
if (root)
|
|
449
|
+
observer_3.observe(root, { attributes: true, attributeFilter: ROOT_ATTRIBUTES });
|
|
450
|
+
}
|
|
451
|
+
teardown.push(function () { return observer_3.disconnect(); });
|
|
452
|
+
}
|
|
453
|
+
if (typeof matchMedia === 'function') {
|
|
454
|
+
for (var _b = 0, MEDIA_QUERIES_1 = MEDIA_QUERIES; _b < MEDIA_QUERIES_1.length; _b++) {
|
|
455
|
+
var query = MEDIA_QUERIES_1[_b];
|
|
456
|
+
listen(matchMedia(query), 'change', onThemeChange);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
// Capture, so a scroll in any scroller reaches it. Passive: it never blocks.
|
|
460
|
+
listen(window, 'scroll', onScroll, { capture: true, passive: true });
|
|
461
|
+
listen(window, 'resize', scheduleAll, { passive: true });
|
|
462
|
+
listen(window, 'popstate', scheduleAll);
|
|
463
|
+
listen(window, 'hashchange', scheduleAll);
|
|
464
|
+
for (var _c = 0, CHANGE_EVENTS_1 = CHANGE_EVENTS; _c < CHANGE_EVENTS_1.length; _c++) {
|
|
465
|
+
var type = CHANGE_EVENTS_1[_c];
|
|
466
|
+
listen(document, type, onChangeEvent, { capture: true, passive: true });
|
|
467
|
+
}
|
|
468
|
+
listen(document, 'visibilitychange', updatePoll);
|
|
469
|
+
}
|
|
470
|
+
function stop() {
|
|
471
|
+
for (var _i = 0, teardown_1 = teardown; _i < teardown_1.length; _i++) {
|
|
472
|
+
var undo = teardown_1[_i];
|
|
473
|
+
undo();
|
|
474
|
+
}
|
|
475
|
+
teardown = [];
|
|
476
|
+
intersection = resize = undefined;
|
|
477
|
+
cancelAnimationFrame(frame);
|
|
478
|
+
frame = 0;
|
|
479
|
+
clearTimeout(settle);
|
|
480
|
+
clearInterval(poll);
|
|
481
|
+
poll = undefined;
|
|
482
|
+
}
|
|
483
|
+
function watch(node) {
|
|
484
|
+
if (entries.has(node))
|
|
485
|
+
return;
|
|
486
|
+
if (entries.size === 0)
|
|
487
|
+
start();
|
|
488
|
+
// Visible until the observer says otherwise, so the first frame measures it.
|
|
489
|
+
var entry = { visible: true, tone: null, floating: isFloating(node), pending: false };
|
|
490
|
+
entries.set(node, entry);
|
|
491
|
+
intersection === null || intersection === void 0 ? void 0 : intersection.observe(node);
|
|
492
|
+
resize === null || resize === void 0 ? void 0 : resize.observe(node);
|
|
493
|
+
// Measured now, before the first paint, so the text does not start in the
|
|
494
|
+
// theme colour and then flip. The fade waits a frame, so this does not fade.
|
|
495
|
+
var decision = measure(node, entry);
|
|
496
|
+
styleCache.clear();
|
|
497
|
+
if (decision)
|
|
498
|
+
commit(node, entry, decision);
|
|
499
|
+
updatePoll();
|
|
500
|
+
}
|
|
501
|
+
function unwatch(node) {
|
|
502
|
+
entries.delete(node);
|
|
503
|
+
dirty.delete(node);
|
|
504
|
+
intersection === null || intersection === void 0 ? void 0 : intersection.unobserve(node);
|
|
505
|
+
resize === null || resize === void 0 ? void 0 : resize.unobserve(node);
|
|
506
|
+
if (entries.size === 0)
|
|
507
|
+
stop();
|
|
508
|
+
else
|
|
509
|
+
updatePoll();
|
|
510
|
+
}
|
|
511
|
+
/** Whether this engine paints `backdrop-filter`, so the glass saturation shows. */
|
|
512
|
+
function paintsBackdropFilter() {
|
|
513
|
+
if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function')
|
|
514
|
+
return false;
|
|
515
|
+
return CSS.supports('backdrop-filter', 'saturate(2)') || CSS.supports('-webkit-backdrop-filter', 'saturate(2)');
|
|
516
|
+
}
|
|
517
|
+
function supported() {
|
|
518
|
+
return typeof document.elementsFromPoint === 'function' && typeof requestAnimationFrame === 'function';
|
|
519
|
+
}
|
|
520
|
+
var NONE = { tone: null, secondary: null, accent: null };
|
|
521
|
+
function apply(node, tone) {
|
|
522
|
+
if (tone === 'auto' && supported()) {
|
|
523
|
+
watch(node);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
unwatch(node);
|
|
527
|
+
write(node, __assign(__assign({}, NONE), { tone: tone === 'light' || tone === 'dark' ? tone : null }));
|
|
528
|
+
}
|
|
529
|
+
export function adaptiveTone(node, options) {
|
|
530
|
+
if (options === void 0) { options = {}; }
|
|
531
|
+
var tone = resolveGlassTone(options.tone);
|
|
532
|
+
var alive = true;
|
|
533
|
+
apply(node, tone);
|
|
534
|
+
// Whatever the tone, transitions on the surface wait for the frame after the
|
|
535
|
+
// first one, so the text does not fade from the theme colour into it.
|
|
536
|
+
var ready = function () {
|
|
537
|
+
if (alive)
|
|
538
|
+
node.setAttribute(READY_ATTRIBUTE, '');
|
|
539
|
+
};
|
|
540
|
+
if (typeof requestAnimationFrame === 'function')
|
|
541
|
+
requestAnimationFrame(ready);
|
|
542
|
+
else
|
|
543
|
+
ready();
|
|
544
|
+
return {
|
|
545
|
+
update: function (next) {
|
|
546
|
+
if (next === void 0) { next = {}; }
|
|
547
|
+
var resolved = resolveGlassTone(next.tone);
|
|
548
|
+
if (resolved === tone)
|
|
549
|
+
return;
|
|
550
|
+
tone = resolved;
|
|
551
|
+
apply(node, tone);
|
|
552
|
+
// The framework may drop a ready mark it wrote for a forced tone.
|
|
553
|
+
if (typeof requestAnimationFrame === 'function')
|
|
554
|
+
requestAnimationFrame(ready);
|
|
555
|
+
else
|
|
556
|
+
ready();
|
|
557
|
+
// A forced tone was in the markup, which the framework may clear after
|
|
558
|
+
// this runs, so check again on the next frame.
|
|
559
|
+
if (entries.has(node))
|
|
560
|
+
schedule(node);
|
|
561
|
+
},
|
|
562
|
+
destroy: function () {
|
|
563
|
+
alive = false;
|
|
564
|
+
unwatch(node);
|
|
565
|
+
write(node, NONE);
|
|
566
|
+
node.removeAttribute(READY_ATTRIBUTE);
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The decisions Alert and ActionSheet make about their buttons, as plain
|
|
3
|
+
* functions so mutation testing reaches them (Stryker cannot instrument .svelte
|
|
4
|
+
* files). They follow iOS 26 alerts and confirmation dialogs and the WAI-ARIA
|
|
5
|
+
* alertdialog pattern. Internal.
|
|
6
|
+
*/
|
|
7
|
+
import type { AlertAction } from '../constants/alertAction';
|
|
8
|
+
/** A label longer than this does not fit beside another, so the buttons stack. */
|
|
9
|
+
export declare const LONG_ACTION_LABEL = 14;
|
|
10
|
+
/** How an alert lays out its buttons: in a row, or stacked. */
|
|
11
|
+
export type AlertAxis = 'horizontal' | 'vertical';
|
|
12
|
+
/** The axis of an alert's buttons and the order to draw them in, as indexes into the actions. */
|
|
13
|
+
export interface AlertLayout {
|
|
14
|
+
axis: AlertAxis;
|
|
15
|
+
order: number[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Lays out an alert's buttons as iOS 26 does. One or two short buttons sit in
|
|
19
|
+
* a row with the cancel button leading. Three or more, or a label too long to
|
|
20
|
+
* share the row, stack, with the cancel button last.
|
|
21
|
+
*/
|
|
22
|
+
export declare function alertLayout(actions: readonly AlertAction[]): AlertLayout;
|
|
23
|
+
/**
|
|
24
|
+
* The action Escape runs, or null. It is the cancel action. A one button alert
|
|
25
|
+
* with no cancel, such as an OK alert, runs that button, since it only
|
|
26
|
+
* acknowledges. Otherwise Escape does nothing: the choice has to be made. A
|
|
27
|
+
* disabled action never runs.
|
|
28
|
+
*/
|
|
29
|
+
export declare function escapeActionIndex(actions: readonly AlertAction[]): number | null;
|
|
30
|
+
/**
|
|
31
|
+
* The action that takes focus when the dialog opens, or null to focus the
|
|
32
|
+
* dialog itself. The WAI-ARIA alertdialog pattern asks for the least
|
|
33
|
+
* destructive choice: the cancel action, else the first that is not
|
|
34
|
+
* destructive, else the first that is enabled. With `cancelHidden` (an
|
|
35
|
+
* anchored action sheet, whose Cancel is kept for assistive technology but
|
|
36
|
+
* not drawn) the choice is the first visible action that is not destructive.
|
|
37
|
+
* When there is none (the usual "Delete Photo, Cancel" sheet) the answer is
|
|
38
|
+
* null, so the dialog itself takes focus: one Return never runs a destructive
|
|
39
|
+
* action, the sheet opens looking as iOS draws it, and Tab still reaches the
|
|
40
|
+
* hidden Cancel, which shows itself on focus.
|
|
41
|
+
*/
|
|
42
|
+
export declare function initialFocusIndex(actions: readonly AlertAction[], cancelHidden?: boolean): number | null;
|
|
43
|
+
/** The action Return runs from the alert's text field: the first enabled preferred one, or null. */
|
|
44
|
+
export declare function submitActionIndex(actions: readonly AlertAction[]): number | null;
|
|
45
|
+
/** The buttons of an action sheet: the main group in order, and the cancel action apart. */
|
|
46
|
+
export interface ActionSheetGroups {
|
|
47
|
+
main: number[];
|
|
48
|
+
cancel: number | null;
|
|
49
|
+
}
|
|
50
|
+
/** Splits an action sheet's actions into the main group and the cancel action, drawn apart on iOS. */
|
|
51
|
+
export declare function actionSheetGroups(actions: readonly AlertAction[]): ActionSheetGroups;
|
|
52
|
+
/**
|
|
53
|
+
* What is wrong with a list of actions, as messages for a console warning. An
|
|
54
|
+
* empty list is fine for an Alert, which falls back to an OK button.
|
|
55
|
+
*/
|
|
56
|
+
export declare function alertActionProblems(actions: readonly AlertAction[]): string[];
|
|
57
|
+
/** Writes each problem with the actions to the console, once per call, naming the component. */
|
|
58
|
+
export declare function warnAlertActions(component: string, actions: readonly AlertAction[]): void;
|
|
59
|
+
/** The button an Alert shows when it is given no actions, as SwiftUI's alert does. */
|
|
60
|
+
export declare const DEFAULT_ALERT_ACTIONS: readonly AlertAction[];
|
|
61
|
+
/**
|
|
62
|
+
* What Escape or a tap outside does to an action sheet. With a cancel action
|
|
63
|
+
* it runs that action, or nothing while it is disabled. With none the sheet
|
|
64
|
+
* just closes ('close'): unlike an alert, an action sheet can always be put
|
|
65
|
+
* away without choosing.
|
|
66
|
+
*/
|
|
67
|
+
export declare function actionSheetDismissal(actions: readonly AlertAction[]): number | 'close' | null;
|