@uvalib/web-components 1.4.0 → 1.6.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.
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Versions of an image compared over the photo: Switch, Reveal (a wipe) and Fade. Loaded by
3
+ * `<uvalib-lightbox>` the first time an open image has versions, so pages without them never
4
+ * load it.
5
+ */
6
+ import { nothing } from 'lit';
7
+ export type CompareMode = 'switch' | 'wipe' | 'fade';
8
+ /** How long (ms) after the last slider or drag change it counts as settled. Tests shorten it. */
9
+ export declare const compareTiming: {
10
+ settle: number;
11
+ };
12
+ /** What the lightbox lends the comparison. */
13
+ export interface CompareHost {
14
+ el: HTMLElement;
15
+ light: boolean;
16
+ root: Node;
17
+ noStyle: boolean;
18
+ /** The `compare` attribute: the first mode. */
19
+ mode(): string;
20
+ /** The URL the viewer would load for `href` ('' when it may not be shown). */
21
+ size(href: string): string;
22
+ /** Write the comparison to `version-param` (replaceState). */
23
+ write(value: string | null): void;
24
+ update(): void;
25
+ }
26
+ /** The parts of a lightbox slide the comparison reads. */
27
+ export interface CompareSlide {
28
+ id: string;
29
+ href: string;
30
+ versions: string | unknown[] | null;
31
+ }
32
+ /**
33
+ * The comparison for one lightbox. State: the mode, the version shown (Switch) or compared
34
+ * with the original (Reveal, Fade), and the percentage of it shown. Another version's image
35
+ * is requested the first time it is needed, and drawn (and announced) once it has loaded.
36
+ */
37
+ export declare class Compare {
38
+ private readonly host;
39
+ private list;
40
+ private slideKey;
41
+ private id;
42
+ private warned;
43
+ /** The mode the visitor (or the address) chose; else the lightbox's `compare`. */
44
+ private chosen;
45
+ mode: CompareMode;
46
+ /** The version compared with the original (Reveal, Fade), from 1. */
47
+ private other;
48
+ /** The percentage of `other` shown (Reveal, Fade). */
49
+ private value;
50
+ /** The version shown (Switch), from 0. */
51
+ private shown;
52
+ private holding;
53
+ private requested;
54
+ private ready;
55
+ private failed;
56
+ private message;
57
+ private flip;
58
+ private pendingAnnounce;
59
+ private announceNext;
60
+ private settleTimer;
61
+ private settled;
62
+ private dragging;
63
+ private dragEnd;
64
+ private readonly uid;
65
+ constructor(host: CompareHost);
66
+ /** At least two usable versions. */
67
+ get active(): boolean;
68
+ /** Follow the open image: a new one starts again (in the current mode); `restore` is the address's value. */
69
+ sync(slide: CompareSlide, index: number, restore: string | null): void;
70
+ /** Forget the open image (the viewer closed): report a change still settling first. */
71
+ reset(): void;
72
+ private parse;
73
+ /** `2`, `switch:2`, `wipe:40`, `fade:60`, `wipe:40:2` (the version compared, from 1). */
74
+ private restore;
75
+ private encode;
76
+ /** The version over the original: shown (Switch) or compared (Reveal, Fade). */
77
+ private get top();
78
+ /** The percentage of the top version asked for. */
79
+ private get amount();
80
+ /** The percentage of it on screen: none until its image has loaded. */
81
+ private get seen();
82
+ private label;
83
+ /** Request the top version's image the first time it is needed. */
84
+ private need;
85
+ private set;
86
+ private change;
87
+ /** A visitor's change has settled: the event, analytics, the address and the announcement. */
88
+ private settle;
89
+ private say;
90
+ private stateText;
91
+ private setMode;
92
+ private hold;
93
+ private loaded;
94
+ private errored;
95
+ /** The `o` key held anywhere in the dialog shows the original. True when handled. */
96
+ key(e: KeyboardEvent): boolean;
97
+ /** A press on the photo in Reveal moves the divider there; a drag keeps moving it. */
98
+ pointer(e: PointerEvent): void;
99
+ /** A drag that ended outside the photo must not count as a click on the backdrop. */
100
+ dragged(): boolean;
101
+ private readonly onInput;
102
+ /** Shift with an arrow, and Page Up / Page Down, move 10%. */
103
+ private readonly onSliderKey;
104
+ private readonly onHold;
105
+ /** The image's accessible name ends with what is on screen. */
106
+ alt(base: string): string;
107
+ get stackClass(): string;
108
+ get stackStyle(): string;
109
+ /** The other versions' images (each requested on first use), the divider and the side labels. */
110
+ layers(): import("lit").TemplateResult<1> | (typeof nothing | import("lit").TemplateResult<1>)[];
111
+ /** Notes of the versions on screen, then the controls. `slot` puts them under regions' image. */
112
+ controls(slot: string): import("lit").TemplateResult<1>;
113
+ /**
114
+ * Full size, in every mode: the original and the version shown (Switch) or compared (Reveal,
115
+ * Fade), each named. The same two links in every mode keep the toolbar's height, so changing
116
+ * mode never moves the photo; and a visitor can always open the original at full size.
117
+ */
118
+ full(): {
119
+ href: string;
120
+ label: string;
121
+ }[];
122
+ }