@redot-src/glare 1.2.1 → 1.4.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/dist/icons.d.ts CHANGED
@@ -5,11 +5,18 @@ export declare const icons: {
5
5
  readonly zoomIn: string;
6
6
  readonly zoomOut: string;
7
7
  readonly download: string;
8
- readonly share: string;
9
8
  readonly thumbs: string;
10
9
  readonly play: string;
11
10
  readonly pause: string;
12
11
  readonly fullscreen: string;
13
12
  readonly fullscreenExit: string;
14
13
  readonly more: string;
14
+ readonly thumbImage: string;
15
+ readonly thumbVideo: string;
16
+ readonly thumbEmbed: string;
17
+ readonly thumbIframe: string;
18
+ readonly thumbInline: string;
19
+ readonly thumbAjax: string;
20
+ readonly thumbHtml: string;
21
+ readonly thumbSlide: string;
15
22
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Glare } from './core/glare';
2
- export type { AjaxOptions, AnimationEffect, BoundGroup, ClickAction, ClickActionName, ContentType, EventHandler, EventName, FullscreenOptions, GlareInstance, GlareOptions, GlareRefs, I18nDict, IframeOptions, ImageOptions, LifecycleEvent, LifecycleHandler, MediaProvider, ResolvedOptions, ShareOptions, SlideEvent, SlideItem, SlideSource, SlideshowOptions, ThumbsOptions, ToolbarButton, TouchOptions, TransitionEffect, VideoOptions, } from './types';
2
+ export type { AjaxOptions, Anchor, AnchorPosition, AnimationEffect, BoundGroup, ClickAction, ClickActionName, ContentType, CustomButton, EventHandler, EventName, FullscreenOptions, GlareInstance, GlareOptions, GlareRefs, I18nDict, IframeOptions, ImageOptions, LifecycleEvent, LifecycleHandler, MediaProvider, ResolvedOptions, SlideEvent, SlideItem, SlideSource, SlideshowOptions, ThumbsFit, ThumbsOptions, ToolbarButton, TouchOptions, TransitionEffect, VideoOptions, } from './types';
3
3
  export type { Point, Zoom, ZoomState } from './core/zoom';
4
4
  export { Glare };
5
5
  export declare const autoBind: typeof Glare.autoBind;
@@ -4,4 +4,3 @@ export declare const spinnerTemplate = "<div class=\"glare-spinner\" role=\"stat
4
4
  export declare const errorTemplate = "<div class=\"glare-error\"><p>{{ERROR}}</p></div>";
5
5
  export declare const videoTemplate: string;
6
6
  export declare const iframeTemplate = "<iframe class=\"glare-iframe\"></iframe>";
7
- export declare const shareTemplate: string;
package/dist/types.d.ts CHANGED
@@ -1,16 +1,29 @@
1
1
  import type { Point, Zoom } from './core/zoom';
2
2
  import type { Fullscreen } from './modules/fullscreen';
3
- import type { Share } from './modules/share';
4
3
  import type { Slideshow } from './modules/slideshow';
5
4
  import type { Thumbs } from './modules/thumbs';
6
5
  export type ContentType = 'image' | 'video' | 'embed' | 'iframe' | 'inline' | 'ajax' | 'html';
7
- /** Effect played when the lightbox opens. */
8
- export type AnimationEffect = false | 'fade' | 'zoom';
9
- /** Effect played when moving between slides. */
10
- export type TransitionEffect = false | 'fade' | 'slide' | 'circular' | 'tube' | 'zoom-in-out' | 'rotate';
6
+ /** Effect played when the lightbox opens and closes. Any other name is a custom effect, written in CSS. */
7
+ export type AnimationEffect = false | 'fade' | 'zoom' | (string & {});
8
+ /** A spot in the lightbox the opening image can grow from, as `<vertical>-<horizontal>`. */
9
+ export type AnchorPosition = `${'top' | 'center' | 'bottom'}-${'left' | 'center' | 'right'}`;
10
+ /** Where the `'zoom'` effect starts: the slide's trigger, a position, an element, or a selector. */
11
+ export type Anchor = 'trigger' | AnchorPosition | HTMLElement | (string & {});
12
+ /** Effect played when moving between slides. Any other name is a custom effect, written in CSS. */
13
+ export type TransitionEffect = false | 'fade' | 'slide' | 'circular' | 'tube' | 'zoom-in-out' | 'rotate' | (string & {});
11
14
  export type ClickActionName = 'close' | 'next' | 'nextOrClose' | 'toggleControls' | 'zoom';
12
15
  export type ClickAction = false | ClickActionName | ((current: SlideItem, event: Event) => ClickActionName | false | void);
13
- export type ToolbarButton = 'zoom' | 'slideshow' | 'thumbs' | 'share' | 'download' | 'fullscreen' | 'more' | 'close' | (string & {});
16
+ /** A toolbar button defined inline: rendered like the built-in ones and wired to `click`. */
17
+ export interface CustomButton {
18
+ /** Identifies the button; also its `glare-button--{name}` class. */
19
+ name: string;
20
+ /** Tooltip and accessible name. */
21
+ label: string;
22
+ /** The button's content as HTML, usually an inline `<svg>`. */
23
+ icon: string;
24
+ click: (instance: GlareInstance, current: SlideItem, event: MouseEvent) => void;
25
+ }
26
+ export type ToolbarButton = 'zoom' | 'slideshow' | 'thumbs' | 'download' | 'fullscreen' | 'more' | 'close' | (string & {}) | CustomButton;
14
27
  export interface MediaProvider {
15
28
  matcher: RegExp;
16
29
  type?: ContentType;
@@ -77,10 +90,13 @@ export interface VideoOptions {
77
90
  format?: string;
78
91
  autoStart?: boolean;
79
92
  }
93
+ /** How a thumbnail image fills its square, as CSS `object-fit`. */
94
+ export type ThumbsFit = 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
80
95
  export interface ThumbsOptions {
81
96
  autoStart?: boolean;
82
97
  parentEl?: string | HTMLElement;
83
98
  axis?: 'x' | 'y';
99
+ fit?: ThumbsFit;
84
100
  }
85
101
  export interface SlideshowOptions {
86
102
  autoStart?: boolean;
@@ -89,10 +105,6 @@ export interface SlideshowOptions {
89
105
  export interface FullscreenOptions {
90
106
  autoStart?: boolean;
91
107
  }
92
- export interface ShareOptions {
93
- url?: string | ((item: SlideItem) => string);
94
- tpl?: string;
95
- }
96
108
  export type I18nDict = {
97
109
  CLOSE: string;
98
110
  NEXT: string;
@@ -108,9 +120,7 @@ export type I18nDict = {
108
120
  FULL_SCREEN_EXIT: string;
109
121
  THUMBS: string;
110
122
  DOWNLOAD: string;
111
- SHARE: string;
112
123
  MORE: string;
113
- COPY: string;
114
124
  ZOOM: string;
115
125
  ZOOM_OUT: string;
116
126
  };
@@ -135,6 +145,8 @@ export interface GlareOptions extends EventHandlers {
135
145
  trapFocus?: boolean;
136
146
  defaultType?: ContentType;
137
147
  parentEl?: string | HTMLElement;
148
+ /** Same-origin window (e.g. `window.parent`) whose own `window.Glare` opens the lightbox instead. */
149
+ delegate?: Window;
138
150
  baseClass?: string;
139
151
  slideClass?: string;
140
152
  arrows?: boolean;
@@ -145,6 +157,7 @@ export interface GlareOptions extends EventHandlers {
145
157
  caption?: string | ((instance: GlareInstance, current: SlideItem) => string);
146
158
  animationEffect?: AnimationEffect;
147
159
  animationDuration?: number;
160
+ anchor?: Anchor;
148
161
  zoomOpacity?: boolean;
149
162
  transitionEffect?: TransitionEffect;
150
163
  transitionDuration?: number;
@@ -165,7 +178,6 @@ export interface GlareOptions extends EventHandlers {
165
178
  slideshow?: SlideshowOptions | boolean;
166
179
  thumbs?: ThumbsOptions | boolean;
167
180
  fullscreen?: FullscreenOptions | boolean;
168
- share?: ShareOptions | boolean;
169
181
  lang?: string;
170
182
  i18n?: Record<string, Partial<I18nDict>>;
171
183
  baseTpl?: string;
@@ -173,7 +185,7 @@ export interface GlareOptions extends EventHandlers {
173
185
  spinnerTpl?: string;
174
186
  errorTpl?: string;
175
187
  }
176
- type DefaultedKey = Exclude<keyof GlareOptions, keyof EventHandlers | 'caption'>;
188
+ type DefaultedKey = Exclude<keyof GlareOptions, keyof EventHandlers | 'caption' | 'delegate'>;
177
189
  /** Options after the defaults have been merged in: everything but callbacks is present. */
178
190
  export type ResolvedOptions = GlareOptions & Required<Pick<GlareOptions, DefaultedKey>> & {
179
191
  image: Required<ImageOptions>;
@@ -208,7 +220,6 @@ export interface GlareInstance {
208
220
  slideshow?: Slideshow;
209
221
  thumbs?: Thumbs;
210
222
  fullscreen?: Fullscreen;
211
- share?: Share;
212
223
  open(index?: number): void;
213
224
  close(): void;
214
225
  next(): void;
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@redot-src/glare",
3
- "version": "1.2.1",
3
+ "version": "1.4.0",
4
4
  "description": "Modern, touch-enabled, fully customizable lightbox for the web — zero dependencies.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "author": "Glare Contributors",
8
- "homepage": "https://redot-src.github.io/glare/",
7
+ "author": {
8
+ "name": "Redot",
9
+ "url": "https://redot.dev"
10
+ },
11
+ "homepage": "https://glare.redot.dev/",
9
12
  "repository": {
10
13
  "type": "git",
11
14
  "url": "git+https://github.com/redot-src/glare.git"
@@ -50,14 +53,11 @@
50
53
  "./dist/*": "./dist/*"
51
54
  },
52
55
  "scripts": {
53
- "dev": "vite --mode demo",
56
+ "dev": "vitepress dev docs",
54
57
  "build": "npm run typecheck && vite build && vite build --mode umd && tsc -p tsconfig.build.json",
55
58
  "typecheck": "tsc --noEmit",
56
- "demo:build": "vite build --mode demo",
57
- "docs:dev": "vitepress dev docs",
58
59
  "docs:build": "vitepress build docs",
59
60
  "docs:preview": "vitepress preview docs",
60
- "pages:build": "npm run docs:build && npm run demo:build",
61
61
  "prepublishOnly": "npm run build"
62
62
  },
63
63
  "devDependencies": {
@@ -65,5 +65,9 @@
65
65
  "typescript": "^5.9.2",
66
66
  "vite": "^7.1.5",
67
67
  "vitepress": "^1.6.4"
68
+ },
69
+ "allowScripts": {
70
+ "esbuild@0.28.2": true,
71
+ "esbuild@0.21.5": true
68
72
  }
69
73
  }
@@ -1,17 +0,0 @@
1
- import type { ShareOptions } from '../types';
2
- import type { Glare } from '../core/glare';
3
- /** Overlay with social share links and a copyable URL. */
4
- export declare class Share {
5
- private readonly glare;
6
- private readonly container;
7
- private readonly opts;
8
- private overlay;
9
- private off;
10
- constructor(glare: Glare, container: HTMLElement, opts: ShareOptions);
11
- get isOpen(): boolean;
12
- open(): void;
13
- close(): void;
14
- destroy(): void;
15
- private copy;
16
- private resolveUrl;
17
- }