@ks89/angular-modal-gallery
Version:
Image gallery for Angular
1,251 lines (1,194 loc) • 391 kB
JavaScript
import * as i0 from '@angular/core';
import { Component, ChangeDetectionStrategy, Injectable, EventEmitter, Directive, Input, Output, HostListener, HostBinding, PLATFORM_ID, Inject, InjectionToken, SecurityContext, ViewChild, Injector, APP_INITIALIZER, NgModule } from '@angular/core';
import * as i2$1 from '@angular/common';
import { isPlatformBrowser, CommonModule } from '@angular/common';
import * as i1 from '@angular/cdk/overlay';
import { OverlayConfig, OverlayModule } from '@angular/cdk/overlay';
import { Subject, timer } from 'rxjs';
import { map, filter, switchMap, takeUntil } from 'rxjs/operators';
import * as i1$1 from '@angular/cdk/layout';
import { Breakpoints } from '@angular/cdk/layout';
import * as i2 from '@angular/platform-browser';
import { ComponentPortal } from '@angular/cdk/portal';
/*
The MIT License (MIT)
Copyright (c) 2017-2024 Stefano Cappa (Ks89)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Key of the keyboard's key `enter`
*/
const ENTER_KEY = 'Enter';
/**
* Code of the keyboard's key `enter`
*/
const ENTER_CODE = 'Enter';
/**
* Key of the keyboard's key `esc`
*/
const ESC_KEY = 'Escape';
/**
* Code of the keyboard's key `esc`
*/
const ESC_CODE = 'Escape';
/**
* Key of the keyboard's key 'right arrow'
*/
const RIGHT_ARROW_KEY = 'ArrowRight';
/**
* Code of the keyboard's key 'right arrow'
*/
const RIGHT_ARROW_CODE = 'ArrowRight';
/**
* Key of the keyboard's key 'left arrow'
*/
const LEFT_ARROW_KEY = 'ArrowLeft';
/**
* Code of the keyboard's key 'left arrow'
*/
const LEFT_ARROW_CODE = 'ArrowLeft';
/**
* Key of the keyboard's key 'left arrow'
*/
const UP_ARROW_KEY = 'ArrowUp';
/**
* Code of the keyboard's key 'left arrow'
*/
const UP_ARROW_CODE = 'ArrowUp';
/**
* Key of the keyboard's key 'left arrow'
*/
const DOWN_ARROW_KEY = 'ArrowDown';
/**
* Code of the keyboard's key 'left arrow'
*/
const DOWN_ARROW_CODE = 'ArrowDown';
/**
* Key of the keyboard's key `space`
*/
const SPACE_KEY = '';
/**
* Code of the keyboard's key `space`
*/
const SPACE_CODE = 'Space';
/**
* Const to represent the right direction
*/
const DIRECTION_RIGHT = 'right';
/**
* Const to represent the left direction
*/
const DIRECTION_LEFT = 'left';
/**
* Keycode of the main mouse button
*/
const MOUSE_MAIN_BUTTON_CLICK = 0;
/**
* Const NEXT
*/
const NEXT = 1;
/**
* Const PREV
*/
const PREV = -1;
/**
* Const NOTHING to represents a situation when it isn't both NEXT and PREV
*/
const NOTHING = 0;
/*
The MIT License (MIT)
Copyright (c) 2017-2024 Stefano Cappa (Ks89)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Provides some useful methods to add accessibility features to subclasses.
* In particular, it exposes a method to handle navigation event with both Keyboard and Mouse
* and another with also the direction (right or left).
*/
class AccessibleComponent {
constructor() { }
/**
* Method to handle navigation events with both Keyboard and Mouse.
* @param string direction of the navigation that can be either 'next' or 'prev'
* @param KeyboardEvent | MouseEvent event payload
* @returns number -1 for PREV, 1 for NEXT and 0 for NOTHING
*/
handleNavigationEvent(direction, event) {
if (!event) {
return NOTHING;
}
if (event instanceof KeyboardEvent) {
return this.handleKeyboardNavigationEvent(direction, event);
}
else if (event instanceof MouseEvent) {
return this.handleMouseNavigationEvent(direction, event);
}
return NOTHING;
}
/**
* Method to handle events over an image, for instance a keypress with the Keyboard or a Mouse click.
* @param event KeyboardEvent | MouseEvent payload
* @returns number 1 for NEXT and 0 for NOTHING
*/
handleImageEvent(event) {
if (!event) {
return NOTHING;
}
if (event instanceof KeyboardEvent) {
return this.handleImageKeyboardEvent(event);
}
else if (event instanceof MouseEvent) {
return this.handleImageMouseEvent(event);
}
return NOTHING;
}
/**
* Private method to handle keyboard events over an image.
* @param event KeyboardEvent payload
* @returns number 1 for NEXT and 0 for NOTHING
*/
handleImageKeyboardEvent(event) {
const key = event.code;
if (key === SPACE_CODE || key === ENTER_CODE) {
return NEXT;
}
return NOTHING;
}
/**
* Private method to handle mouse events over an image.
* @param MouseEvent event payload
* @returns number 1 for NEXT and 0 for NOTHING
*/
handleImageMouseEvent(event) {
const mouseBtn = event.button;
if (mouseBtn === MOUSE_MAIN_BUTTON_CLICK) {
return NEXT;
}
return NOTHING;
}
/**
* Method to handle events over an image, for instance a keypress with the Keyboard or a Mouse click.
* @param string direction of the navigation that can be either 'next' or 'prev'
* @param KeyboardEvent event payload
* @returns number -1 for PREV, 1 for NEXT and 0 for NOTHING
*/
handleKeyboardNavigationEvent(direction, event) {
const key = event.code;
if (key === SPACE_CODE || key === ENTER_CODE) {
return direction === DIRECTION_RIGHT ? NEXT : PREV;
}
return NOTHING;
}
/**
* Method to handle events over an image, for instance a keypress with the Keyboard or a Mouse click.
* @param string direction of the navigation that can be either 'next' or 'prev'
* @param MouseEvent event payload
* @returns number -1 for PREV, 1 for NEXT and 0 for NOTHING
*/
handleMouseNavigationEvent(direction, event) {
const mouseBtn = event.button;
if (mouseBtn === MOUSE_MAIN_BUTTON_CLICK) {
return direction === DIRECTION_RIGHT ? NEXT : PREV;
}
return NOTHING;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: AccessibleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.5", type: AccessibleComponent, isStandalone: false, selector: "ks-accessible", ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: AccessibleComponent, decorators: [{
type: Component,
args: [{
selector: 'ks-accessible',
template: ``,
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false
}]
}], ctorParameters: () => [] });
/*
The MIT License (MIT)
Copyright (c) 2017-2024 Stefano Cappa (Ks89)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Class `Image` that represents an image with both `modal` and `plain` configurations.
* Both image `id` and `modal` are mandatory, instead `plain` is optional.
*/
class Image {
constructor(id, modal, plain, loading = 'lazy', fetchpriority = 'auto') {
this.id = id;
this.modal = modal;
this.plain = plain;
this.loading = loading;
this.fetchpriority = fetchpriority;
}
}
/**
* Class `ImageEvent` that represents the event payload with the result and the triggered action.
* It also contains the source id of the gallery that emitted this event
*/
class ImageEvent {
constructor(galleryId, action, result) {
this.galleryId = galleryId;
this.action = action;
this.result = result;
}
}
/**
* Class `ImageModalEvent` that represents the event payload with galleryId, result and the triggered action.
*/
class ImageModalEvent extends ImageEvent {
constructor(galleryId, action, result) {
super(galleryId, action, result);
}
}
/*
The MIT License (MIT)
Copyright (c) 2017-2024 Stefano Cappa (Ks89)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Enum `Action` with a list of possible actions, based on the source of the action.
*/
var Action;
(function (Action) {
Action[Action["NORMAL"] = 0] = "NORMAL";
Action[Action["CLICK"] = 1] = "CLICK";
Action[Action["KEYBOARD"] = 2] = "KEYBOARD";
Action[Action["SWIPE"] = 3] = "SWIPE";
Action[Action["LOAD"] = 4] = "LOAD";
Action[Action["AUTOPLAY"] = 5] = "AUTOPLAY";
})(Action || (Action = {}));
/*
The MIT License (MIT)
Copyright (c) 2017-2024 Stefano Cappa (Ks89)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Utility function to get the index of the input `image` from `arrayOfImages`
* @param image Image to get the index. The image 'id' must be a number >= 0
* @param arrayOfImages Image[] to search the image within it
* @returns number the index of the image. -1 if not found.
* @throws an Error if either image or arrayOfImages are not valid,
* or if the input image doesn't contain an 'id', or the 'id' is < 0
*/
function getIndex(image, arrayOfImages) {
if (!image) {
throw new Error('image must be a valid Image object');
}
if (!arrayOfImages) {
throw new Error('arrayOfImages must be a valid Image[]');
}
if (!image.id && image.id !== 0) {
// id = 0 is admitted
throw new Error(`A numeric Image 'id' is mandatory`);
}
if (image.id < 0) {
throw new Error(`Image 'id' must be >= 0`);
}
return arrayOfImages.findIndex((val) => val.id === image.id);
}
/*
The MIT License (MIT)
Copyright (c) 2017-2024 Stefano Cappa (Ks89)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Enum `DescriptionStrategy` with keys and their relative key codes.
*/
var DescriptionStrategy;
(function (DescriptionStrategy) {
DescriptionStrategy[DescriptionStrategy["ALWAYS_HIDDEN"] = 1] = "ALWAYS_HIDDEN";
DescriptionStrategy[DescriptionStrategy["ALWAYS_VISIBLE"] = 2] = "ALWAYS_VISIBLE";
DescriptionStrategy[DescriptionStrategy["HIDE_IF_EMPTY"] = 3] = "HIDE_IF_EMPTY";
})(DescriptionStrategy || (DescriptionStrategy = {}));
/**
* Default accessibility configuration.
*/
const KS_DEFAULT_ACCESSIBILITY_CONFIG = {
backgroundAriaLabel: 'Modal gallery full screen background',
backgroundTitle: '',
plainGalleryContentAriaLabel: 'Plain gallery content',
plainGalleryContentTitle: '',
modalGalleryContentAriaLabel: 'Modal gallery content',
modalGalleryContentTitle: '',
loadingSpinnerAriaLabel: 'The current image is loading. Please be patient.',
loadingSpinnerTitle: 'The current image is loading. Please be patient.',
mainContainerAriaLabel: 'Current image and navigation',
mainContainerTitle: '',
mainPrevImageAriaLabel: 'Previous image',
mainPrevImageTitle: 'Previous image',
mainNextImageAriaLabel: 'Next image',
mainNextImageTitle: 'Next image',
dotsContainerAriaLabel: 'Image navigation dots',
dotsContainerTitle: '',
dotAriaLabel: 'Navigate to image number',
previewsContainerAriaLabel: 'Image previews',
previewsContainerTitle: '',
previewScrollPrevAriaLabel: 'Scroll previous previews',
previewScrollPrevTitle: 'Scroll previous previews',
previewScrollNextAriaLabel: 'Scroll next previews',
previewScrollNextTitle: 'Scroll next previews',
carouselContainerAriaLabel: 'Current image and navigation',
carouselContainerTitle: '',
carouselPrevImageAriaLabel: 'Previous image',
carouselPrevImageTitle: 'Previous image',
carouselNextImageAriaLabel: 'Next image',
carouselNextImageTitle: 'Next image',
carouselPreviewsContainerAriaLabel: 'Image previews',
carouselPreviewsContainerTitle: '',
carouselPreviewScrollPrevAriaLabel: 'Scroll previous previews',
carouselPreviewScrollPrevTitle: 'Scroll previous previews',
carouselPreviewScrollNextAriaLabel: 'Scroll next previews',
carouselPreviewScrollNextTitle: 'Scroll next previews'
};
/*
The MIT License (MIT)
Copyright (c) 2017-2024 Stefano Cappa (Ks89)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Enum `ButtonsStrategy` to configure the logic of a button.
*/
var ButtonsStrategy;
(function (ButtonsStrategy) {
// don't use 0 here
// the first index is 1 and all of the following members are auto-incremented from that point on
ButtonsStrategy[ButtonsStrategy["DEFAULT"] = 1] = "DEFAULT";
ButtonsStrategy[ButtonsStrategy["SIMPLE"] = 2] = "SIMPLE";
ButtonsStrategy[ButtonsStrategy["ADVANCED"] = 3] = "ADVANCED";
ButtonsStrategy[ButtonsStrategy["FULL"] = 4] = "FULL";
ButtonsStrategy[ButtonsStrategy["CUSTOM"] = 5] = "CUSTOM";
})(ButtonsStrategy || (ButtonsStrategy = {}));
/**
* Enum `ButtonType` is the type of a button.
*/
var ButtonType;
(function (ButtonType) {
// don't use 0 here
// the first index is 1 and all of the following members are auto-incremented from that point on
ButtonType[ButtonType["DELETE"] = 1] = "DELETE";
ButtonType[ButtonType["EXTURL"] = 2] = "EXTURL";
ButtonType[ButtonType["DOWNLOAD"] = 3] = "DOWNLOAD";
ButtonType[ButtonType["CLOSE"] = 4] = "CLOSE";
ButtonType[ButtonType["CUSTOM"] = 5] = "CUSTOM";
ButtonType[ButtonType["FULLSCREEN"] = 6] = "FULLSCREEN";
})(ButtonType || (ButtonType = {}));
/**
* Array of admitted types of buttons.
*/
const WHITELIST_BUTTON_TYPES = [
ButtonType.FULLSCREEN,
ButtonType.DELETE,
ButtonType.EXTURL,
ButtonType.DOWNLOAD,
ButtonType.CLOSE,
ButtonType.CUSTOM
];
/*
The MIT License (MIT)
Copyright (c) 2017-2024 Stefano Cappa (Ks89)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Class `LineLayout` to configure a linear plain gallery.
*/
class LineLayout {
constructor(size, breakConfig, justify) {
this.size = size;
this.breakConfig = breakConfig;
this.justify = justify;
}
}
/**
* Class `GridLayout` to configure a grid plain gallery.
*/
class GridLayout {
constructor(size, breakConfig) {
this.size = size;
this.breakConfig = breakConfig;
}
}
/**
* Enum `PlainGalleryStrategy` to choose the behaviour of the plain gallery.
*/
var PlainGalleryStrategy;
(function (PlainGalleryStrategy) {
// don't use 0 here
// the first index is 1 and all of the following members are auto-incremented from that point on
PlainGalleryStrategy[PlainGalleryStrategy["ROW"] = 1] = "ROW";
PlainGalleryStrategy[PlainGalleryStrategy["COLUMN"] = 2] = "COLUMN";
PlainGalleryStrategy[PlainGalleryStrategy["GRID"] = 3] = "GRID";
PlainGalleryStrategy[PlainGalleryStrategy["CUSTOM"] = 4] = "CUSTOM"; // full custom strategy
})(PlainGalleryStrategy || (PlainGalleryStrategy = {}));
/*
The MIT License (MIT)
Copyright (c) 2017-2024 Stefano Cappa (Ks89)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Enum `LoadingType` with a list of possible types.
*/
var LoadingType;
(function (LoadingType) {
LoadingType[LoadingType["STANDARD"] = 1] = "STANDARD";
LoadingType[LoadingType["CIRCULAR"] = 2] = "CIRCULAR";
LoadingType[LoadingType["BARS"] = 3] = "BARS";
LoadingType[LoadingType["DOTS"] = 4] = "DOTS";
LoadingType[LoadingType["CUBE_FLIPPING"] = 5] = "CUBE_FLIPPING";
LoadingType[LoadingType["CIRCLES"] = 6] = "CIRCLES";
LoadingType[LoadingType["EXPLOSING_SQUARES"] = 7] = "EXPLOSING_SQUARES";
})(LoadingType || (LoadingType = {}));
/*
The MIT License (MIT)
Copyright (c) 2017-2024 Stefano Cappa (Ks89)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
const DEFAULT_PREVIEW_SIZE = { height: '50px', width: 'auto' };
const DEFAULT_LAYOUT = new LineLayout(DEFAULT_PREVIEW_SIZE, { length: -1, wrap: false }, 'flex-start');
const DEFAULT_PLAIN_CONFIG = {
strategy: PlainGalleryStrategy.ROW,
layout: DEFAULT_LAYOUT,
advanced: { aTags: false, additionalBackground: '50% 50%/cover' }
};
const DEFAULT_LOADING = { enable: true, type: LoadingType.STANDARD };
const DEFAULT_DESCRIPTION_STYLE = {
bgColor: 'rgba(0, 0, 0, .5)',
textColor: 'white',
marginTop: '0px',
marginBottom: '0px',
marginLeft: '0px',
marginRight: '0px'
};
const DEFAULT_DESCRIPTION = {
strategy: DescriptionStrategy.ALWAYS_VISIBLE,
imageText: 'Image ',
numberSeparator: '/',
beforeTextDescription: ' - ',
style: DEFAULT_DESCRIPTION_STYLE
};
const DEFAULT_CAROUSEL_DESCRIPTION = {
strategy: DescriptionStrategy.ALWAYS_HIDDEN,
imageText: 'Image ',
numberSeparator: '/',
beforeTextDescription: ' - ',
style: DEFAULT_DESCRIPTION_STYLE
};
const DEFAULT_CURRENT_IMAGE_CONFIG = {
navigateOnClick: true,
loadingConfig: DEFAULT_LOADING,
description: DEFAULT_DESCRIPTION,
downloadable: false,
invertSwipe: false
};
const DEFAULT_CAROUSEL_IMAGE_CONFIG = {
description: DEFAULT_CAROUSEL_DESCRIPTION,
invertSwipe: false
};
const DEFAULT_CURRENT_CAROUSEL_CONFIG = {
maxWidth: '100%',
maxHeight: '400px',
showArrows: true,
objectFit: 'cover',
keyboardEnable: true,
modalGalleryEnable: false
};
const DEFAULT_CURRENT_CAROUSEL_PLAY = {
autoPlay: true,
interval: 5000,
pauseOnHover: true
};
const DEFAULT_CAROUSEL_BREAKPOINTS = { xSmall: 100, small: 100, medium: 150, large: 200, xLarge: 200 };
const DEFAULT_CAROUSEL_PREVIEWS_CONFIG = {
visible: true,
number: 4,
arrows: true,
clickable: true,
width: 100 / 4 + '%',
maxHeight: '200px',
breakpoints: DEFAULT_CAROUSEL_BREAKPOINTS
};
const DEFAULT_SLIDE_CONFIG = {
infinite: false,
playConfig: { autoPlay: false, interval: 5000, pauseOnHover: true },
sidePreviews: { show: true, size: { width: '100px', height: 'auto' } }
};
const DEFAULT_PREVIEW_CONFIG = {
visible: true,
number: 3,
arrows: true,
clickable: true,
size: DEFAULT_PREVIEW_SIZE
};
const DEFAULT_CONFIG = Object.freeze({
slideConfig: DEFAULT_SLIDE_CONFIG,
accessibilityConfig: KS_DEFAULT_ACCESSIBILITY_CONFIG,
previewConfig: DEFAULT_PREVIEW_CONFIG,
buttonsConfig: { visible: true, strategy: ButtonsStrategy.DEFAULT },
dotsConfig: { visible: true },
plainGalleryConfig: DEFAULT_PLAIN_CONFIG,
currentImageConfig: DEFAULT_CURRENT_IMAGE_CONFIG,
keyboardConfig: undefined, // by default nothing, because the library uses default buttons automatically
carouselConfig: DEFAULT_CURRENT_CAROUSEL_CONFIG,
carouselImageConfig: DEFAULT_CAROUSEL_IMAGE_CONFIG,
carouselPreviewsConfig: DEFAULT_CAROUSEL_PREVIEWS_CONFIG,
carouselPlayConfig: DEFAULT_CURRENT_CAROUSEL_PLAY,
carouselDotsConfig: { visible: true },
carouselSlideInfinite: true,
enableCloseOutside: true
});
/**
* Service to handle library configuration in a unique place
*/
class ConfigService {
constructor() {
this.configMap = new Map();
}
getConfig(id) {
this.initIfNotExists(id);
return this.configMap.get(id);
}
setConfig(id, obj) {
this.initIfNotExists(id);
if (!obj) {
return;
}
if (!DEFAULT_CONFIG ||
!DEFAULT_CONFIG.slideConfig ||
!DEFAULT_CONFIG.slideConfig.sidePreviews ||
!DEFAULT_CONFIG.previewConfig ||
!DEFAULT_CONFIG.previewConfig.size ||
!DEFAULT_CONFIG.previewConfig.number ||
!DEFAULT_CONFIG.plainGalleryConfig ||
!DEFAULT_CONFIG.currentImageConfig ||
!DEFAULT_CONFIG.currentImageConfig ||
!DEFAULT_CONFIG.currentImageConfig.description ||
!DEFAULT_CONFIG.carouselImageConfig ||
!DEFAULT_CONFIG.carouselImageConfig.description ||
!DEFAULT_CONFIG.carouselPreviewsConfig ||
!DEFAULT_CONFIG.carouselPreviewsConfig.breakpoints ||
!DEFAULT_CAROUSEL_PREVIEWS_CONFIG.number) {
throw new Error('Internal library error - DEFAULT_CONFIG must be fully initialized!!!');
}
const newConfig = Object.assign({}, this.configMap.get(id));
if (obj.slideConfig) {
let playConfig;
let sidePreviews;
let size;
if (obj.slideConfig.playConfig) {
playConfig = Object.assign({}, DEFAULT_CONFIG.slideConfig.playConfig, obj.slideConfig.playConfig);
}
else {
playConfig = DEFAULT_CONFIG.slideConfig.playConfig;
}
if (obj.slideConfig.sidePreviews) {
if (obj.slideConfig.sidePreviews.size) {
size = Object.assign({}, DEFAULT_CONFIG.slideConfig.sidePreviews.size, obj.slideConfig.sidePreviews.size);
}
else {
size = DEFAULT_CONFIG.slideConfig.sidePreviews.size;
}
sidePreviews = Object.assign({}, DEFAULT_CONFIG.slideConfig.sidePreviews, obj.slideConfig.sidePreviews);
}
else {
sidePreviews = DEFAULT_CONFIG.slideConfig.sidePreviews;
size = DEFAULT_CONFIG.slideConfig.sidePreviews.size;
}
const newSlideConfig = Object.assign({}, DEFAULT_CONFIG.slideConfig, obj.slideConfig);
newSlideConfig.playConfig = playConfig;
newSlideConfig.sidePreviews = sidePreviews;
newSlideConfig.sidePreviews.size = size;
newConfig.slideConfig = newSlideConfig;
}
if (obj.accessibilityConfig) {
newConfig.accessibilityConfig = Object.assign({}, DEFAULT_CONFIG.accessibilityConfig, obj.accessibilityConfig);
}
if (obj.previewConfig) {
let size;
let num;
if (obj.previewConfig.size) {
size = Object.assign({}, DEFAULT_CONFIG.previewConfig.size, obj.previewConfig.size);
}
else {
size = DEFAULT_CONFIG.previewConfig.size;
}
if (obj.previewConfig.number) {
if (obj.previewConfig.number <= 0) {
// if number is <= 0 reset to default
num = DEFAULT_CONFIG.previewConfig.number;
}
else {
num = obj.previewConfig.number;
}
}
else {
num = DEFAULT_CONFIG.previewConfig.number;
}
const newPreviewConfig = Object.assign({}, DEFAULT_CONFIG.previewConfig, obj.previewConfig);
newPreviewConfig.size = size;
newPreviewConfig.number = num;
newConfig.previewConfig = newPreviewConfig;
}
if (obj.buttonsConfig) {
newConfig.buttonsConfig = Object.assign({}, DEFAULT_CONFIG.buttonsConfig, obj.buttonsConfig);
}
if (obj.dotsConfig) {
newConfig.dotsConfig = Object.assign({}, DEFAULT_CONFIG.dotsConfig, obj.dotsConfig);
}
if (obj.plainGalleryConfig) {
let advanced;
let layout;
if (obj.plainGalleryConfig.advanced) {
advanced = Object.assign({}, DEFAULT_CONFIG.plainGalleryConfig.advanced, obj.plainGalleryConfig.advanced);
}
else {
advanced = DEFAULT_CONFIG.plainGalleryConfig.advanced;
}
if (obj.plainGalleryConfig.layout) {
// it isn't mandatory to use assign, because obj.plainGalleryConfig.layout is an instance of class (LineaLayout, GridLayout)
layout = obj.plainGalleryConfig.layout;
}
else {
layout = DEFAULT_CONFIG.plainGalleryConfig.layout;
}
const newPlainGalleryConfig = Object.assign({}, DEFAULT_CONFIG.plainGalleryConfig, obj.plainGalleryConfig);
newPlainGalleryConfig.layout = layout;
newPlainGalleryConfig.advanced = advanced;
newConfig.plainGalleryConfig = initPlainGalleryConfig(newPlainGalleryConfig);
}
if (obj.currentImageConfig) {
let loading;
let description;
let descriptionStyle;
if (obj.currentImageConfig.loadingConfig) {
loading = Object.assign({}, DEFAULT_CONFIG.currentImageConfig.loadingConfig, obj.currentImageConfig.loadingConfig);
}
else {
loading = DEFAULT_CONFIG.currentImageConfig.loadingConfig;
}
if (obj.currentImageConfig.description) {
description = Object.assign({}, DEFAULT_CONFIG.currentImageConfig.description, obj.currentImageConfig.description);
if (obj.currentImageConfig.description.style) {
descriptionStyle = Object.assign({}, DEFAULT_CONFIG.currentImageConfig.description.style, obj.currentImageConfig.description.style);
}
else {
descriptionStyle = DEFAULT_CONFIG.currentImageConfig.description.style;
}
}
else {
description = DEFAULT_CONFIG.currentImageConfig.description;
descriptionStyle = DEFAULT_CONFIG.currentImageConfig.description.style;
}
const newCurrentImageConfig = Object.assign({}, DEFAULT_CONFIG.currentImageConfig, obj.currentImageConfig);
newCurrentImageConfig.loadingConfig = loading;
newCurrentImageConfig.description = description;
newCurrentImageConfig.description.style = descriptionStyle;
newConfig.currentImageConfig = newCurrentImageConfig;
}
if (obj.keyboardConfig) {
newConfig.keyboardConfig = Object.assign({}, DEFAULT_CONFIG.keyboardConfig, obj.keyboardConfig);
}
// carousel
if (obj.carouselConfig) {
newConfig.carouselConfig = Object.assign({}, DEFAULT_CONFIG.carouselConfig, obj.carouselConfig);
}
if (obj.carouselImageConfig) {
let description;
let descriptionStyle;
if (obj.carouselImageConfig.description) {
description = Object.assign({}, DEFAULT_CONFIG.carouselImageConfig.description, obj.carouselImageConfig.description);
if (obj.carouselImageConfig.description.style) {
descriptionStyle = Object.assign({}, DEFAULT_CONFIG.carouselImageConfig.description.style, obj.carouselImageConfig.description.style);
}
else {
descriptionStyle = DEFAULT_CONFIG.carouselImageConfig.description.style;
}
}
else {
description = DEFAULT_CONFIG.carouselImageConfig.description;
descriptionStyle = DEFAULT_CONFIG.carouselImageConfig.description.style;
}
const newCarouselImageConfig = Object.assign({}, DEFAULT_CONFIG.carouselImageConfig, obj.carouselImageConfig);
newCarouselImageConfig.description = description;
newCarouselImageConfig.description.style = descriptionStyle;
newConfig.carouselImageConfig = newCarouselImageConfig;
}
if (obj.carouselPlayConfig) {
// check values
if (obj.carouselPlayConfig.interval <= 0) {
throw new Error(`Carousel's interval must be a number >= 0`);
}
newConfig.carouselPlayConfig = Object.assign({}, DEFAULT_CONFIG.carouselPlayConfig, obj.carouselPlayConfig);
}
if (obj.carouselPreviewsConfig) {
// check values
let num;
let breakpoints;
if (!obj.carouselPreviewsConfig.number || obj.carouselPreviewsConfig.number <= 0) {
num = DEFAULT_CAROUSEL_PREVIEWS_CONFIG.number;
}
else {
num = obj.carouselPreviewsConfig.number;
}
if (obj.carouselPreviewsConfig.breakpoints) {
breakpoints = Object.assign({}, DEFAULT_CONFIG.carouselPreviewsConfig.breakpoints, obj.carouselPreviewsConfig.breakpoints);
}
else {
breakpoints = DEFAULT_CONFIG.carouselPreviewsConfig.breakpoints;
}
newConfig.carouselPreviewsConfig = Object.assign({}, DEFAULT_CONFIG.carouselPreviewsConfig, obj.carouselPreviewsConfig);
newConfig.carouselPreviewsConfig.number = num;
newConfig.carouselPreviewsConfig.breakpoints = breakpoints;
// Init preview image width based on the number of previews in PreviewConfig
// Don't move this line above, because I need to be sure that both configPreview.number
// and configPreview.size are initialized
newConfig.carouselPreviewsConfig.width = 100 / newConfig.carouselPreviewsConfig.number + '%';
}
if (obj.carouselDotsConfig) {
newConfig.carouselDotsConfig = Object.assign({}, DEFAULT_CONFIG.carouselDotsConfig, obj.carouselDotsConfig);
}
if (obj.carouselSlideInfinite === undefined) {
newConfig.carouselSlideInfinite = DEFAULT_CONFIG.carouselSlideInfinite;
}
else {
newConfig.carouselSlideInfinite = obj.carouselSlideInfinite;
}
if (obj.enableCloseOutside === undefined) {
newConfig.enableCloseOutside = DEFAULT_CONFIG.enableCloseOutside;
}
else {
newConfig.enableCloseOutside = obj.enableCloseOutside;
}
this.configMap.set(id, newConfig);
}
initIfNotExists(id) {
if (!this.configMap.has(id)) {
this.configMap.set(id, DEFAULT_CONFIG);
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ConfigService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ConfigService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ConfigService, decorators: [{
type: Injectable,
args: [{ providedIn: 'root' }]
}] });
/**
* Function to build and return a `PlainGalleryConfig` object, proving also default values and validating the input object.
* @param plainGalleryConfig object with the config requested by user
* @returns PlainGalleryConfig the plain gallery configuration
* @throws an Error if layout and strategy aren't compatible
*/
function initPlainGalleryConfig(plainGalleryConfig) {
const newPlayGalleryConfig = Object.assign({}, DEFAULT_CONFIG.plainGalleryConfig, plainGalleryConfig);
if (newPlayGalleryConfig.layout instanceof LineLayout) {
if (newPlayGalleryConfig.strategy !== PlainGalleryStrategy.ROW && newPlayGalleryConfig.strategy !== PlainGalleryStrategy.COLUMN) {
throw new Error('LineLayout requires either ROW or COLUMN strategy');
}
if (!newPlayGalleryConfig.layout || !newPlayGalleryConfig.layout.breakConfig) {
throw new Error('Both layout and breakConfig must be valid');
}
}
if (newPlayGalleryConfig.layout instanceof GridLayout) {
if (newPlayGalleryConfig.strategy !== PlainGalleryStrategy.GRID) {
throw new Error('GridLayout requires GRID strategy');
}
if (!newPlayGalleryConfig.layout || !newPlayGalleryConfig.layout.breakConfig) {
throw new Error('Both layout and breakConfig must be valid');
}
// force wrap for grid layout
newPlayGalleryConfig.layout.breakConfig.wrap = true;
}
return newPlayGalleryConfig;
}
/*
The MIT License (MIT)
Copyright (c) 2017-2024 Stefano Cappa (Ks89)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Class that represents the modal dialog instance.
* It is returned by the open method.
*/
class ModalGalleryRef {
constructor(overlayRef) {
this.overlayRef = overlayRef;
this.close = new Subject();
this.close$ = this.close.asObservable();
this.show = new Subject();
this.show$ = this.show.asObservable();
this.firstImage = new Subject();
this.firstImage$ = this.firstImage.asObservable();
this.lastImage = new Subject();
this.lastImage$ = this.lastImage.asObservable();
this.hasData = new Subject();
this.hasData$ = this.hasData.asObservable();
this.buttonBeforeHook = new Subject();
this.buttonBeforeHook$ = this.buttonBeforeHook.asObservable();
this.buttonAfterHook = new Subject();
this.buttonAfterHook$ = this.buttonAfterHook.asObservable();
}
/**
* Close modal dialog, disposing the Overlay.
*/
closeModal() {
this.overlayRef.dispose();
}
/**
* Method to emit close event.
* @param event ImageModalEvent event payload
*/
emitClose(event) {
this.close.next(event);
}
/**
* Method to emit show event.
* @param event ImageModalEvent event payload
*/
emitShow(event) {
this.show.next(event);
}
/**
* Method to emit firstImage event.
* @param event ImageModalEvent event payload
*/
emitFirstImage(event) {
this.firstImage.next(event);
}
/**
* Method to emit lastImage event.
* @param event ImageModalEvent event payload
*/
emitLastImage(event) {
this.lastImage.next(event);
}
/**
* Method to emit hasData event.
* @param event ImageModalEvent event payload
*/
emitHasData(event) {
this.hasData.next(event);
}
/**
* Method to emit buttonBeforeHook event.
* @param event ImageModalEvent event payload
*/
emitButtonBeforeHook(event) {
this.buttonBeforeHook.next(event);
}
/**
* Method to emit buttonAfterHook event.
* @param event ImageModalEvent event payload
*/
emitButtonAfterHook(event) {
this.buttonAfterHook.next(event);
}
}
const DEFAULT_DIALOG_CONFIG = {
hasBackdrop: true,
backdropClass: 'ks-modal-gallery-backdrop',
panelClass: 'ks-modal-gallery-panel'
};
class ModalGalleryService {
constructor(overlay, configService) {
this.overlay = overlay;
this.configService = configService;
this.updateImages = new Subject();
this.updateImages$ = this.updateImages.asObservable();
this.triggerAttachToOverlay = new EventEmitter();
}
/**
* Method to open modal gallery passing the configuration
* @param config ModalGalleryConfig that contains: id, array of images, current image and optionally the configuration object
* @return ModalGalleryRef | undefined is the object used to listen for events.
*/
open(config) {
// Returns an OverlayRef which is a PortalHost
const overlayRef = this.createOverlay();
// Instantiate a reference to the dialog
this.dialogRef = new ModalGalleryRef(overlayRef);
// Attach dialog container
this.triggerAttachToOverlay.emit({
overlayRef,
config,
dialogRef: this.dialogRef
});
overlayRef.backdropClick().subscribe(() => {
if (this.dialogRef) {
this.dialogRef.closeModal();
}
});
return this.dialogRef;
}
/**
* Method to close a modal gallery previously opened.
* @param id Unique identifier of the modal gallery
* @param clickOutside boolean is true if closed clicking on the modal backdrop, false otherwise.
*/
close(id, clickOutside) {
const libConfig = this.configService.getConfig(id);
if (clickOutside) {
if (this.dialogRef && libConfig && libConfig.enableCloseOutside) {
this.dialogRef.closeModal();
}
}
else {
if (this.dialogRef) {
this.dialogRef.closeModal();
}
}
}
/**
* Method to update images array.
* @param images Image[] updated array of images
*/
updateModalImages(images) {
this.updateImages.next(images);
}
/**
* Method to emit close event.
* @param event ImageModalEvent is the event payload
*/
emitClose(event) {
if (!this.dialogRef) {
return;
}
this.dialogRef.emitClose(event);
}
/**
* Method to emit show event.
* @param event ImageModalEvent is the event payload
*/
emitShow(event) {
if (!this.dialogRef) {
return;
}
this.dialogRef.emitShow(event);
}
/**
* Method to emit firstImage event.
* @param event ImageModalEvent is the event payload
*/
emitFirstImage(event) {
if (!this.dialogRef) {
return;
}
this.dialogRef.emitFirstImage(event);
}
/**
* Method to emit lastImage event.
* @param event ImageModalEvent is the event payload
*/
emitLastImage(event) {
if (!this.dialogRef) {
return;
}
this.dialogRef.emitLastImage(event);
}
/**
* Method to emit hasData event.
* @param event ImageModalEvent is the event payload
*/
emitHasData(event) {
if (!this.dialogRef) {
return;
}
this.dialogRef.emitHasData(event);
}
/**
* Method to emit buttonBeforeHook event.
* @param event ButtonEvent is the event payload
*/
emitButtonBeforeHook(event) {
if (!this.dialogRef) {
return;
}
this.dialogRef.emitButtonBeforeHook(event);
}
/**
* Method to emit buttonAfterHook event.
* @param event ButtonEvent is the event payload
*/
emitButtonAfterHook(event) {
if (!this.dialogRef) {
return;
}
this.dialogRef.emitButtonAfterHook(event);
}
/**
* Private method to create an Overlay using Angular CDK APIs
* @private
*/
createOverlay() {
const overlayConfig = this.getOverlayConfig();
return this.overlay.create(overlayConfig);
}
/**
* Private method to create an OverlayConfig instance
* @private
*/
getOverlayConfig() {
const positionStrategy = this.overlay.position().global().centerHorizontally().centerVertically();
return new OverlayConfig({
hasBackdrop: DEFAULT_DIALOG_CONFIG.hasBackdrop,
backdropClass: DEFAULT_DIALOG_CONFIG.backdropClass,
panelClass: DEFAULT_DIALOG_CONFIG.panelClass,
scrollStrategy: this.overlay.scrollStrategies.block(),
positionStrategy
});
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ModalGalleryService, deps: [{ token: i1.Overlay }, { token: ConfigService }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ModalGalleryService, providedIn: '