@gallerist/renderer-dom 0.0.0-stage → 0.3.1
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/LICENSE +21 -0
- package/README.md +34 -2
- package/dist/index.cjs +1965 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +252 -0
- package/dist/index.d.ts +252 -0
- package/dist/index.js +1949 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -3
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { MediaAdapter, OverlaySpec, Group, ViewerApi, ViewerOptions, Collection } from '@gallerist/core';
|
|
2
|
+
export { KeyReconcile, reconcileKeys, windowIndices } from '@gallerist/core/internal';
|
|
3
|
+
|
|
4
|
+
declare function imageAdapter(): MediaAdapter;
|
|
5
|
+
|
|
6
|
+
/** Visual skin. `gallery` ships in gallerist.css; `console` and `editorial` need their stylesheet
|
|
7
|
+
* (console.css, editorial.css) loaded after it. */
|
|
8
|
+
type Skin = 'gallery' | 'console' | 'editorial' | (string & {});
|
|
9
|
+
/** Accents are named per skin. Gallery: periwinkle (default), mint, amber, vermilion. Console:
|
|
10
|
+
* amber (default), cyan, vermilion. Editorial: vermilion (default), cobalt. A name the skin
|
|
11
|
+
* doesn't know falls back to its default. */
|
|
12
|
+
type Accent = 'periwinkle' | 'mint' | 'amber' | 'cyan' | 'vermilion' | 'cobalt' | (string & {});
|
|
13
|
+
/** `auto` follows the system's `prefers-color-scheme`. Unset, each skin uses its own default:
|
|
14
|
+
* Gallery and Console dark, Editorial the light wall. */
|
|
15
|
+
type ColorScheme = 'dark' | 'light' | 'auto';
|
|
16
|
+
interface Appearance {
|
|
17
|
+
skin?: Skin;
|
|
18
|
+
accent?: Accent;
|
|
19
|
+
scheme?: ColorScheme;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Write an appearance onto a viewer root (`data-gallerist-skin|accent|scheme`). Only the options
|
|
23
|
+
* present in `appearance` change, so `applyAppearance(root, { accent: 'cyan' })` keeps the skin and
|
|
24
|
+
* scheme; an option present but `undefined` goes back to its default (`gallery`, the skin's own
|
|
25
|
+
* scheme and accent).
|
|
26
|
+
*/
|
|
27
|
+
declare function applyAppearance(root: HTMLElement, appearance: Appearance): void;
|
|
28
|
+
|
|
29
|
+
type PresetName = 'filmstrip' | 'immersive' | 'reviewer' | 'contact' | 'editorial' | 'tour';
|
|
30
|
+
type ResolvedPreset = {
|
|
31
|
+
/** data-* attributes the renderer sets on the root (drives the theme). */
|
|
32
|
+
readonly rootAttrs: Readonly<Record<string, string>>;
|
|
33
|
+
/** default arrow placement (overridable by an explicit mount option). */
|
|
34
|
+
readonly arrows: ArrowLayout;
|
|
35
|
+
/** default chrome auto-hide-on-idle (overridable). */
|
|
36
|
+
readonly autoHide: boolean;
|
|
37
|
+
/** default thumbnail rail placement (overridable). */
|
|
38
|
+
readonly rail: RailPlacement;
|
|
39
|
+
/** thumbnails() defaults: the plugin applies them to the options it wasn't given. */
|
|
40
|
+
readonly thumbnails: Readonly<{
|
|
41
|
+
itemAxis: 'vertical' | 'horizontal';
|
|
42
|
+
groupDisplay?: 'stacked' | 'flat' | 'index';
|
|
43
|
+
timeline?: boolean;
|
|
44
|
+
numberItems?: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
/** turn on the zoom navigator by default (overridable). */
|
|
47
|
+
readonly navigator?: boolean;
|
|
48
|
+
/** frame the media (overridable). */
|
|
49
|
+
readonly frame?: boolean;
|
|
50
|
+
/** default item indicator (overridable). */
|
|
51
|
+
readonly itemIndicator?: ItemIndicator;
|
|
52
|
+
/** which arrow keys and on-screen arrows move between groups, if not the rail's own (overridable). */
|
|
53
|
+
readonly groupAxis?: GroupAxis;
|
|
54
|
+
/** name the group arrows after the group they go to (overridable). */
|
|
55
|
+
readonly arrowLabels?: boolean;
|
|
56
|
+
};
|
|
57
|
+
/** Resolve a preset name to its layout config; unknown names warn (dev) and fall back to `filmstrip`. */
|
|
58
|
+
declare function resolvePreset(name: string): ResolvedPreset;
|
|
59
|
+
|
|
60
|
+
interface Strings {
|
|
61
|
+
/** accessible name of the overlay dialog (the `label` mount option still wins) */
|
|
62
|
+
dialog: string;
|
|
63
|
+
/** role description announced for an inline viewer */
|
|
64
|
+
carousel: string;
|
|
65
|
+
close: string;
|
|
66
|
+
previous: string;
|
|
67
|
+
next: string;
|
|
68
|
+
previousItem: string;
|
|
69
|
+
nextItem: string;
|
|
70
|
+
/** name of a labelled group arrow (`arrowLabels`), given the group it goes to */
|
|
71
|
+
previousTo: (name: string) => string;
|
|
72
|
+
nextTo: (name: string) => string;
|
|
73
|
+
resetZoom: string;
|
|
74
|
+
showThumbnails: string;
|
|
75
|
+
hideThumbnails: string;
|
|
76
|
+
/** name of a caption renderer's band while it scrolls (it then takes focus, to scroll by keyboard) */
|
|
77
|
+
caption: string;
|
|
78
|
+
/** label of an item pill in the position indicator */
|
|
79
|
+
item: (n: number) => string;
|
|
80
|
+
/** announced on group navigation, e.g. "Group 2 of 12" */
|
|
81
|
+
groupOf: (n: number, total: number) => string;
|
|
82
|
+
/** announced on item navigation (and for every item in linear mode), e.g. "Item 3 of 5" */
|
|
83
|
+
itemOf: (n: number, total: number) => string;
|
|
84
|
+
}
|
|
85
|
+
declare const DEFAULT_STRINGS: Strings;
|
|
86
|
+
|
|
87
|
+
type ItemIndicator = 'pills' | 'dots' | 'counter' | 'placard';
|
|
88
|
+
interface MountOptions {
|
|
89
|
+
/** null/undefined → overlay (portal to body); element → inline. */
|
|
90
|
+
container?: HTMLElement | null;
|
|
91
|
+
controls?: boolean;
|
|
92
|
+
adapters?: MediaAdapter[];
|
|
93
|
+
preload?: {
|
|
94
|
+
ahead: number;
|
|
95
|
+
behind: number;
|
|
96
|
+
};
|
|
97
|
+
/** global overlays applied to every slide (spec §8.1, §9). */
|
|
98
|
+
overlays?: OverlaySpec[];
|
|
99
|
+
/**
|
|
100
|
+
* Placement of the within-group ↑/↓ arrows, surfaced as `data-gallerist-arrows` for the theme
|
|
101
|
+
* (UX-D). `pill-right` (default): ←/→ on the side edges, ↑/↓ as a stacked pill at right-center.
|
|
102
|
+
* `corner-br`: ↑/↓ paired bottom-right. `dpad`: all four clustered as a d-pad. `split`: legacy
|
|
103
|
+
* ↑/↓ top/bottom-center. `docked` (the `reviewer` preset): nothing over the media — the group
|
|
104
|
+
* arrows sit in gutters beside the stage, and the item navigator (↑ · `n / N` · ↓) docks as a
|
|
105
|
+
* header on the aside item column when it shows, else at the end of the caption row.
|
|
106
|
+
*/
|
|
107
|
+
arrows?: ArrowLayout;
|
|
108
|
+
/**
|
|
109
|
+
* Auto-hide the chrome after a period of inactivity (UX-C), flagged as `data-gallerist-idle` for
|
|
110
|
+
* the theme. Default true; inert under prefers-reduced-motion. The thumbnail rail collapses
|
|
111
|
+
* separately (the `t` key / toggle button / fullscreen), tracked as `data-gallerist-rail`.
|
|
112
|
+
*/
|
|
113
|
+
autoHide?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Named layout preset (UX-E) — sets `data-gallerist-preset` and supplies defaults for `arrows` and
|
|
116
|
+
* `autoHide` (both still overridable by explicit options above). Plugin regions get the preset
|
|
117
|
+
* too: thumbnails() takes `resolvePreset(name).thumbnails` for the options it wasn't given.
|
|
118
|
+
*/
|
|
119
|
+
preset?: PresetName;
|
|
120
|
+
/**
|
|
121
|
+
* Thumbnail rail placement (UX-E), surfaced as `data-gallerist-rail-pos`. `bottom` (default) keeps
|
|
122
|
+
* the rail horizontal (group axis = ←/→); `left` / `right` run it vertically and remap the
|
|
123
|
+
* keys/arrows (group axis = ↑/↓, items = ←/→ — touch swipes stay conventional); `hidden` starts
|
|
124
|
+
* collapsed (reveal with the toggle / `t` / hover). Overridable; presets supply a default.
|
|
125
|
+
*/
|
|
126
|
+
rail?: RailPlacement;
|
|
127
|
+
/**
|
|
128
|
+
* Linear traversal: ←/→ walk the flattened item sequence across groups (1a, 1b, 2a, 2b, 2c, 3a…),
|
|
129
|
+
* ↑/↓ retire, the counter shows `item N / total`, and the within-group pills hide — surfaced as
|
|
130
|
+
* `data-gallerist-linear`. Unset, it follows the rail: on while the `thumbnails` region holds an
|
|
131
|
+
* element marked `data-gallerist-linear` (a flat rail, `thumbnails({ groupDisplay: 'flat' })`,
|
|
132
|
+
* marks its region so), off otherwise, and it changes when the plugins do. `true` or `false`
|
|
133
|
+
* fixes it.
|
|
134
|
+
*/
|
|
135
|
+
linear?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Whether navigation wraps at the ends (mirror of the core `loop` option). Only consulted for
|
|
138
|
+
* `linear` traversal, to wrap the flattened sequence at the global first/last item. Default false.
|
|
139
|
+
*/
|
|
140
|
+
loop?: boolean;
|
|
141
|
+
/** UI text overrides (button labels, announcements) for translation; merged over English. */
|
|
142
|
+
strings?: Partial<Strings>;
|
|
143
|
+
/**
|
|
144
|
+
* How the position within a multi-item group is shown, surfaced as the indicator's `data-mode`.
|
|
145
|
+
* `pills` (default): numbered pills up to 8 items, then `n / N`. `dots`: plain dots with the
|
|
146
|
+
* `n / N` count, up to 12 items, then the count alone. `counter`: always `n / N`. `placard`: the
|
|
147
|
+
* whole item navigator (↑ · ticks · `n / N` · ↓) moves into the caption, which becomes a label
|
|
148
|
+
* beside the work in the `editorial` preset. On a touch screen the theme shows the count only
|
|
149
|
+
* (swipes navigate).
|
|
150
|
+
*/
|
|
151
|
+
itemIndicator?: ItemIndicator;
|
|
152
|
+
/**
|
|
153
|
+
* Visual skin (`data-gallerist-skin`, default `gallery`). Other skins need their stylesheet loaded
|
|
154
|
+
* after gallerist.css, e.g. `@gallerist/theme-default/console.css` for `console`.
|
|
155
|
+
*/
|
|
156
|
+
skin?: Skin;
|
|
157
|
+
/** The skin's accent by name (`data-gallerist-accent`); unset uses the skin's default. */
|
|
158
|
+
accent?: Accent;
|
|
159
|
+
/** `dark`, `light`, or `auto` to follow the system (`data-gallerist-scheme`); unset, the skin's
|
|
160
|
+
* own default (Gallery and Console dark, Editorial light). */
|
|
161
|
+
scheme?: ColorScheme;
|
|
162
|
+
/**
|
|
163
|
+
* Zoom navigator: while zoomed in, a minimap of the image in the stage's bottom corner with a box
|
|
164
|
+
* for the visible part; click or drag it to move around. Default off (the `reviewer` preset turns
|
|
165
|
+
* it on). Part of the built-in controls, so `controls: false` has none.
|
|
166
|
+
*/
|
|
167
|
+
navigator?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Framed media: the image hangs inside the stage with room around it (the skin's
|
|
170
|
+
* `--gallerist-frame-inset`), and the media element is sized to the image itself so a skin can
|
|
171
|
+
* give it a mat and a shadow. Zoom bounds, overlays and pins follow the framed box. Default off
|
|
172
|
+
* (the `editorial` preset turns it on).
|
|
173
|
+
*/
|
|
174
|
+
frame?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Which arrow keys and on-screen arrows move between groups. Default: follows the rail (`horizontal`
|
|
177
|
+
* with a bottom rail, `vertical` with a side rail). The `tour` preset keeps `horizontal` beside a
|
|
178
|
+
* side rail, so ←/→ moves between sections while ↑/↓ moves within one.
|
|
179
|
+
*/
|
|
180
|
+
groupAxis?: GroupAxis;
|
|
181
|
+
/**
|
|
182
|
+
* Name the group arrows after the group they go to: `true` uses `group.caption`, a function returns
|
|
183
|
+
* the label. Needs horizontal group arrows in the `pill-right` layout; otherwise ignored. The name
|
|
184
|
+
* also goes into the arrow's accessible name (`strings.previousTo` / `nextTo`).
|
|
185
|
+
*/
|
|
186
|
+
arrowLabels?: boolean | ((group: Group, index: number) => string | undefined);
|
|
187
|
+
/** Accessible name for the overlay dialog (default 'Media viewer'); sets aria-label. */
|
|
188
|
+
label?: string;
|
|
189
|
+
/** Element (or getter) to return focus to when the overlay closes. Falls back to whatever
|
|
190
|
+
* had focus when it opened — useful when the trigger lives in a tree that may have unmounted. */
|
|
191
|
+
returnFocus?: HTMLElement | (() => HTMLElement | null);
|
|
192
|
+
}
|
|
193
|
+
type ArrowLayout = 'pill-right' | 'corner-br' | 'dpad' | 'split' | 'docked';
|
|
194
|
+
type RailPlacement = 'bottom' | 'hidden' | 'left' | 'right';
|
|
195
|
+
type GroupAxis = 'horizontal' | 'vertical';
|
|
196
|
+
interface RendererHandle {
|
|
197
|
+
root: HTMLElement;
|
|
198
|
+
destroy(): void;
|
|
199
|
+
}
|
|
200
|
+
declare function mount(viewer: ViewerApi, opts?: MountOptions): RendererHandle;
|
|
201
|
+
|
|
202
|
+
type PerGallery<T> = T | ((gallery: string) => T);
|
|
203
|
+
interface BindOptions {
|
|
204
|
+
/** which elements are links (default `[data-gallerist]`). */
|
|
205
|
+
selector?: string;
|
|
206
|
+
/** where to look for them (default `document`). */
|
|
207
|
+
root?: Document | HTMLElement;
|
|
208
|
+
/**
|
|
209
|
+
* `createViewer` options besides the collection (`plugins`, `loop`…), or a function returning a set
|
|
210
|
+
* per gallery. With several galleries use the function for `pins()`, which holds its state on the
|
|
211
|
+
* plugin and so can't be shared between viewers.
|
|
212
|
+
*/
|
|
213
|
+
viewer?: PerGallery<Omit<ViewerOptions, 'collection' | 'groups' | 'items'>>;
|
|
214
|
+
/** `mount` options (`preset`, `skin`…), or one set per gallery. */
|
|
215
|
+
mount?: PerGallery<MountOptions>;
|
|
216
|
+
}
|
|
217
|
+
interface BindHandle {
|
|
218
|
+
/** open a gallery from code, at its first item or the one given. */
|
|
219
|
+
open(gallery?: string, at?: {
|
|
220
|
+
g?: number;
|
|
221
|
+
i?: number;
|
|
222
|
+
}): void;
|
|
223
|
+
/** the gallery's viewer, once it has been opened. */
|
|
224
|
+
viewer(gallery?: string): ViewerApi | undefined;
|
|
225
|
+
/** stop listening and destroy every viewer. */
|
|
226
|
+
destroy(): void;
|
|
227
|
+
}
|
|
228
|
+
interface LinkCollection {
|
|
229
|
+
collection: Collection;
|
|
230
|
+
/** where each link landed */
|
|
231
|
+
positions: Map<Element, {
|
|
232
|
+
g: number;
|
|
233
|
+
i: number;
|
|
234
|
+
}>;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Build a collection from link elements. A link with `data-gallerist-group` joins the group of that
|
|
238
|
+
* id, in first-seen order (named by `-group-caption`, with `-group-subtitle` in its meta); any other
|
|
239
|
+
* link is a group of its own. Elements with neither a `data-gallerist-src` nor an `href` are skipped.
|
|
240
|
+
*/
|
|
241
|
+
declare function collectionFromLinks(links: Iterable<Element>, idPrefix?: string): LinkCollection;
|
|
242
|
+
/**
|
|
243
|
+
* Open a viewer from `data-gallerist` links. Each distinct attribute value is its own gallery. A plain
|
|
244
|
+
* click opens the viewer at that link; a modified click (new tab, download) stays the browser's.
|
|
245
|
+
*/
|
|
246
|
+
declare function bind(opts?: BindOptions): BindHandle;
|
|
247
|
+
|
|
248
|
+
/** Package version, injected from package.json at build (tsup `define`). Guarded with `typeof` so
|
|
249
|
+
* importing the source without the define (e2e / example fixtures) yields a dev marker, not a crash. */
|
|
250
|
+
declare const VERSION: string;
|
|
251
|
+
|
|
252
|
+
export { type Accent, type Appearance, type ArrowLayout, type BindHandle, type BindOptions, type ColorScheme, DEFAULT_STRINGS, type GroupAxis, type ItemIndicator, type MountOptions, type PresetName, type RailPlacement, type RendererHandle, type ResolvedPreset, type Skin, type Strings, VERSION, applyAppearance, bind, collectionFromLinks, imageAdapter, mount, resolvePreset };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { MediaAdapter, OverlaySpec, Group, ViewerApi, ViewerOptions, Collection } from '@gallerist/core';
|
|
2
|
+
export { KeyReconcile, reconcileKeys, windowIndices } from '@gallerist/core/internal';
|
|
3
|
+
|
|
4
|
+
declare function imageAdapter(): MediaAdapter;
|
|
5
|
+
|
|
6
|
+
/** Visual skin. `gallery` ships in gallerist.css; `console` and `editorial` need their stylesheet
|
|
7
|
+
* (console.css, editorial.css) loaded after it. */
|
|
8
|
+
type Skin = 'gallery' | 'console' | 'editorial' | (string & {});
|
|
9
|
+
/** Accents are named per skin. Gallery: periwinkle (default), mint, amber, vermilion. Console:
|
|
10
|
+
* amber (default), cyan, vermilion. Editorial: vermilion (default), cobalt. A name the skin
|
|
11
|
+
* doesn't know falls back to its default. */
|
|
12
|
+
type Accent = 'periwinkle' | 'mint' | 'amber' | 'cyan' | 'vermilion' | 'cobalt' | (string & {});
|
|
13
|
+
/** `auto` follows the system's `prefers-color-scheme`. Unset, each skin uses its own default:
|
|
14
|
+
* Gallery and Console dark, Editorial the light wall. */
|
|
15
|
+
type ColorScheme = 'dark' | 'light' | 'auto';
|
|
16
|
+
interface Appearance {
|
|
17
|
+
skin?: Skin;
|
|
18
|
+
accent?: Accent;
|
|
19
|
+
scheme?: ColorScheme;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Write an appearance onto a viewer root (`data-gallerist-skin|accent|scheme`). Only the options
|
|
23
|
+
* present in `appearance` change, so `applyAppearance(root, { accent: 'cyan' })` keeps the skin and
|
|
24
|
+
* scheme; an option present but `undefined` goes back to its default (`gallery`, the skin's own
|
|
25
|
+
* scheme and accent).
|
|
26
|
+
*/
|
|
27
|
+
declare function applyAppearance(root: HTMLElement, appearance: Appearance): void;
|
|
28
|
+
|
|
29
|
+
type PresetName = 'filmstrip' | 'immersive' | 'reviewer' | 'contact' | 'editorial' | 'tour';
|
|
30
|
+
type ResolvedPreset = {
|
|
31
|
+
/** data-* attributes the renderer sets on the root (drives the theme). */
|
|
32
|
+
readonly rootAttrs: Readonly<Record<string, string>>;
|
|
33
|
+
/** default arrow placement (overridable by an explicit mount option). */
|
|
34
|
+
readonly arrows: ArrowLayout;
|
|
35
|
+
/** default chrome auto-hide-on-idle (overridable). */
|
|
36
|
+
readonly autoHide: boolean;
|
|
37
|
+
/** default thumbnail rail placement (overridable). */
|
|
38
|
+
readonly rail: RailPlacement;
|
|
39
|
+
/** thumbnails() defaults: the plugin applies them to the options it wasn't given. */
|
|
40
|
+
readonly thumbnails: Readonly<{
|
|
41
|
+
itemAxis: 'vertical' | 'horizontal';
|
|
42
|
+
groupDisplay?: 'stacked' | 'flat' | 'index';
|
|
43
|
+
timeline?: boolean;
|
|
44
|
+
numberItems?: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
/** turn on the zoom navigator by default (overridable). */
|
|
47
|
+
readonly navigator?: boolean;
|
|
48
|
+
/** frame the media (overridable). */
|
|
49
|
+
readonly frame?: boolean;
|
|
50
|
+
/** default item indicator (overridable). */
|
|
51
|
+
readonly itemIndicator?: ItemIndicator;
|
|
52
|
+
/** which arrow keys and on-screen arrows move between groups, if not the rail's own (overridable). */
|
|
53
|
+
readonly groupAxis?: GroupAxis;
|
|
54
|
+
/** name the group arrows after the group they go to (overridable). */
|
|
55
|
+
readonly arrowLabels?: boolean;
|
|
56
|
+
};
|
|
57
|
+
/** Resolve a preset name to its layout config; unknown names warn (dev) and fall back to `filmstrip`. */
|
|
58
|
+
declare function resolvePreset(name: string): ResolvedPreset;
|
|
59
|
+
|
|
60
|
+
interface Strings {
|
|
61
|
+
/** accessible name of the overlay dialog (the `label` mount option still wins) */
|
|
62
|
+
dialog: string;
|
|
63
|
+
/** role description announced for an inline viewer */
|
|
64
|
+
carousel: string;
|
|
65
|
+
close: string;
|
|
66
|
+
previous: string;
|
|
67
|
+
next: string;
|
|
68
|
+
previousItem: string;
|
|
69
|
+
nextItem: string;
|
|
70
|
+
/** name of a labelled group arrow (`arrowLabels`), given the group it goes to */
|
|
71
|
+
previousTo: (name: string) => string;
|
|
72
|
+
nextTo: (name: string) => string;
|
|
73
|
+
resetZoom: string;
|
|
74
|
+
showThumbnails: string;
|
|
75
|
+
hideThumbnails: string;
|
|
76
|
+
/** name of a caption renderer's band while it scrolls (it then takes focus, to scroll by keyboard) */
|
|
77
|
+
caption: string;
|
|
78
|
+
/** label of an item pill in the position indicator */
|
|
79
|
+
item: (n: number) => string;
|
|
80
|
+
/** announced on group navigation, e.g. "Group 2 of 12" */
|
|
81
|
+
groupOf: (n: number, total: number) => string;
|
|
82
|
+
/** announced on item navigation (and for every item in linear mode), e.g. "Item 3 of 5" */
|
|
83
|
+
itemOf: (n: number, total: number) => string;
|
|
84
|
+
}
|
|
85
|
+
declare const DEFAULT_STRINGS: Strings;
|
|
86
|
+
|
|
87
|
+
type ItemIndicator = 'pills' | 'dots' | 'counter' | 'placard';
|
|
88
|
+
interface MountOptions {
|
|
89
|
+
/** null/undefined → overlay (portal to body); element → inline. */
|
|
90
|
+
container?: HTMLElement | null;
|
|
91
|
+
controls?: boolean;
|
|
92
|
+
adapters?: MediaAdapter[];
|
|
93
|
+
preload?: {
|
|
94
|
+
ahead: number;
|
|
95
|
+
behind: number;
|
|
96
|
+
};
|
|
97
|
+
/** global overlays applied to every slide (spec §8.1, §9). */
|
|
98
|
+
overlays?: OverlaySpec[];
|
|
99
|
+
/**
|
|
100
|
+
* Placement of the within-group ↑/↓ arrows, surfaced as `data-gallerist-arrows` for the theme
|
|
101
|
+
* (UX-D). `pill-right` (default): ←/→ on the side edges, ↑/↓ as a stacked pill at right-center.
|
|
102
|
+
* `corner-br`: ↑/↓ paired bottom-right. `dpad`: all four clustered as a d-pad. `split`: legacy
|
|
103
|
+
* ↑/↓ top/bottom-center. `docked` (the `reviewer` preset): nothing over the media — the group
|
|
104
|
+
* arrows sit in gutters beside the stage, and the item navigator (↑ · `n / N` · ↓) docks as a
|
|
105
|
+
* header on the aside item column when it shows, else at the end of the caption row.
|
|
106
|
+
*/
|
|
107
|
+
arrows?: ArrowLayout;
|
|
108
|
+
/**
|
|
109
|
+
* Auto-hide the chrome after a period of inactivity (UX-C), flagged as `data-gallerist-idle` for
|
|
110
|
+
* the theme. Default true; inert under prefers-reduced-motion. The thumbnail rail collapses
|
|
111
|
+
* separately (the `t` key / toggle button / fullscreen), tracked as `data-gallerist-rail`.
|
|
112
|
+
*/
|
|
113
|
+
autoHide?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Named layout preset (UX-E) — sets `data-gallerist-preset` and supplies defaults for `arrows` and
|
|
116
|
+
* `autoHide` (both still overridable by explicit options above). Plugin regions get the preset
|
|
117
|
+
* too: thumbnails() takes `resolvePreset(name).thumbnails` for the options it wasn't given.
|
|
118
|
+
*/
|
|
119
|
+
preset?: PresetName;
|
|
120
|
+
/**
|
|
121
|
+
* Thumbnail rail placement (UX-E), surfaced as `data-gallerist-rail-pos`. `bottom` (default) keeps
|
|
122
|
+
* the rail horizontal (group axis = ←/→); `left` / `right` run it vertically and remap the
|
|
123
|
+
* keys/arrows (group axis = ↑/↓, items = ←/→ — touch swipes stay conventional); `hidden` starts
|
|
124
|
+
* collapsed (reveal with the toggle / `t` / hover). Overridable; presets supply a default.
|
|
125
|
+
*/
|
|
126
|
+
rail?: RailPlacement;
|
|
127
|
+
/**
|
|
128
|
+
* Linear traversal: ←/→ walk the flattened item sequence across groups (1a, 1b, 2a, 2b, 2c, 3a…),
|
|
129
|
+
* ↑/↓ retire, the counter shows `item N / total`, and the within-group pills hide — surfaced as
|
|
130
|
+
* `data-gallerist-linear`. Unset, it follows the rail: on while the `thumbnails` region holds an
|
|
131
|
+
* element marked `data-gallerist-linear` (a flat rail, `thumbnails({ groupDisplay: 'flat' })`,
|
|
132
|
+
* marks its region so), off otherwise, and it changes when the plugins do. `true` or `false`
|
|
133
|
+
* fixes it.
|
|
134
|
+
*/
|
|
135
|
+
linear?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Whether navigation wraps at the ends (mirror of the core `loop` option). Only consulted for
|
|
138
|
+
* `linear` traversal, to wrap the flattened sequence at the global first/last item. Default false.
|
|
139
|
+
*/
|
|
140
|
+
loop?: boolean;
|
|
141
|
+
/** UI text overrides (button labels, announcements) for translation; merged over English. */
|
|
142
|
+
strings?: Partial<Strings>;
|
|
143
|
+
/**
|
|
144
|
+
* How the position within a multi-item group is shown, surfaced as the indicator's `data-mode`.
|
|
145
|
+
* `pills` (default): numbered pills up to 8 items, then `n / N`. `dots`: plain dots with the
|
|
146
|
+
* `n / N` count, up to 12 items, then the count alone. `counter`: always `n / N`. `placard`: the
|
|
147
|
+
* whole item navigator (↑ · ticks · `n / N` · ↓) moves into the caption, which becomes a label
|
|
148
|
+
* beside the work in the `editorial` preset. On a touch screen the theme shows the count only
|
|
149
|
+
* (swipes navigate).
|
|
150
|
+
*/
|
|
151
|
+
itemIndicator?: ItemIndicator;
|
|
152
|
+
/**
|
|
153
|
+
* Visual skin (`data-gallerist-skin`, default `gallery`). Other skins need their stylesheet loaded
|
|
154
|
+
* after gallerist.css, e.g. `@gallerist/theme-default/console.css` for `console`.
|
|
155
|
+
*/
|
|
156
|
+
skin?: Skin;
|
|
157
|
+
/** The skin's accent by name (`data-gallerist-accent`); unset uses the skin's default. */
|
|
158
|
+
accent?: Accent;
|
|
159
|
+
/** `dark`, `light`, or `auto` to follow the system (`data-gallerist-scheme`); unset, the skin's
|
|
160
|
+
* own default (Gallery and Console dark, Editorial light). */
|
|
161
|
+
scheme?: ColorScheme;
|
|
162
|
+
/**
|
|
163
|
+
* Zoom navigator: while zoomed in, a minimap of the image in the stage's bottom corner with a box
|
|
164
|
+
* for the visible part; click or drag it to move around. Default off (the `reviewer` preset turns
|
|
165
|
+
* it on). Part of the built-in controls, so `controls: false` has none.
|
|
166
|
+
*/
|
|
167
|
+
navigator?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Framed media: the image hangs inside the stage with room around it (the skin's
|
|
170
|
+
* `--gallerist-frame-inset`), and the media element is sized to the image itself so a skin can
|
|
171
|
+
* give it a mat and a shadow. Zoom bounds, overlays and pins follow the framed box. Default off
|
|
172
|
+
* (the `editorial` preset turns it on).
|
|
173
|
+
*/
|
|
174
|
+
frame?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Which arrow keys and on-screen arrows move between groups. Default: follows the rail (`horizontal`
|
|
177
|
+
* with a bottom rail, `vertical` with a side rail). The `tour` preset keeps `horizontal` beside a
|
|
178
|
+
* side rail, so ←/→ moves between sections while ↑/↓ moves within one.
|
|
179
|
+
*/
|
|
180
|
+
groupAxis?: GroupAxis;
|
|
181
|
+
/**
|
|
182
|
+
* Name the group arrows after the group they go to: `true` uses `group.caption`, a function returns
|
|
183
|
+
* the label. Needs horizontal group arrows in the `pill-right` layout; otherwise ignored. The name
|
|
184
|
+
* also goes into the arrow's accessible name (`strings.previousTo` / `nextTo`).
|
|
185
|
+
*/
|
|
186
|
+
arrowLabels?: boolean | ((group: Group, index: number) => string | undefined);
|
|
187
|
+
/** Accessible name for the overlay dialog (default 'Media viewer'); sets aria-label. */
|
|
188
|
+
label?: string;
|
|
189
|
+
/** Element (or getter) to return focus to when the overlay closes. Falls back to whatever
|
|
190
|
+
* had focus when it opened — useful when the trigger lives in a tree that may have unmounted. */
|
|
191
|
+
returnFocus?: HTMLElement | (() => HTMLElement | null);
|
|
192
|
+
}
|
|
193
|
+
type ArrowLayout = 'pill-right' | 'corner-br' | 'dpad' | 'split' | 'docked';
|
|
194
|
+
type RailPlacement = 'bottom' | 'hidden' | 'left' | 'right';
|
|
195
|
+
type GroupAxis = 'horizontal' | 'vertical';
|
|
196
|
+
interface RendererHandle {
|
|
197
|
+
root: HTMLElement;
|
|
198
|
+
destroy(): void;
|
|
199
|
+
}
|
|
200
|
+
declare function mount(viewer: ViewerApi, opts?: MountOptions): RendererHandle;
|
|
201
|
+
|
|
202
|
+
type PerGallery<T> = T | ((gallery: string) => T);
|
|
203
|
+
interface BindOptions {
|
|
204
|
+
/** which elements are links (default `[data-gallerist]`). */
|
|
205
|
+
selector?: string;
|
|
206
|
+
/** where to look for them (default `document`). */
|
|
207
|
+
root?: Document | HTMLElement;
|
|
208
|
+
/**
|
|
209
|
+
* `createViewer` options besides the collection (`plugins`, `loop`…), or a function returning a set
|
|
210
|
+
* per gallery. With several galleries use the function for `pins()`, which holds its state on the
|
|
211
|
+
* plugin and so can't be shared between viewers.
|
|
212
|
+
*/
|
|
213
|
+
viewer?: PerGallery<Omit<ViewerOptions, 'collection' | 'groups' | 'items'>>;
|
|
214
|
+
/** `mount` options (`preset`, `skin`…), or one set per gallery. */
|
|
215
|
+
mount?: PerGallery<MountOptions>;
|
|
216
|
+
}
|
|
217
|
+
interface BindHandle {
|
|
218
|
+
/** open a gallery from code, at its first item or the one given. */
|
|
219
|
+
open(gallery?: string, at?: {
|
|
220
|
+
g?: number;
|
|
221
|
+
i?: number;
|
|
222
|
+
}): void;
|
|
223
|
+
/** the gallery's viewer, once it has been opened. */
|
|
224
|
+
viewer(gallery?: string): ViewerApi | undefined;
|
|
225
|
+
/** stop listening and destroy every viewer. */
|
|
226
|
+
destroy(): void;
|
|
227
|
+
}
|
|
228
|
+
interface LinkCollection {
|
|
229
|
+
collection: Collection;
|
|
230
|
+
/** where each link landed */
|
|
231
|
+
positions: Map<Element, {
|
|
232
|
+
g: number;
|
|
233
|
+
i: number;
|
|
234
|
+
}>;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Build a collection from link elements. A link with `data-gallerist-group` joins the group of that
|
|
238
|
+
* id, in first-seen order (named by `-group-caption`, with `-group-subtitle` in its meta); any other
|
|
239
|
+
* link is a group of its own. Elements with neither a `data-gallerist-src` nor an `href` are skipped.
|
|
240
|
+
*/
|
|
241
|
+
declare function collectionFromLinks(links: Iterable<Element>, idPrefix?: string): LinkCollection;
|
|
242
|
+
/**
|
|
243
|
+
* Open a viewer from `data-gallerist` links. Each distinct attribute value is its own gallery. A plain
|
|
244
|
+
* click opens the viewer at that link; a modified click (new tab, download) stays the browser's.
|
|
245
|
+
*/
|
|
246
|
+
declare function bind(opts?: BindOptions): BindHandle;
|
|
247
|
+
|
|
248
|
+
/** Package version, injected from package.json at build (tsup `define`). Guarded with `typeof` so
|
|
249
|
+
* importing the source without the define (e2e / example fixtures) yields a dev marker, not a crash. */
|
|
250
|
+
declare const VERSION: string;
|
|
251
|
+
|
|
252
|
+
export { type Accent, type Appearance, type ArrowLayout, type BindHandle, type BindOptions, type ColorScheme, DEFAULT_STRINGS, type GroupAxis, type ItemIndicator, type MountOptions, type PresetName, type RailPlacement, type RendererHandle, type ResolvedPreset, type Skin, type Strings, VERSION, applyAppearance, bind, collectionFromLinks, imageAdapter, mount, resolvePreset };
|