@studiohyperdrive/ngx-cookies
Version:
An integrated Angular approach to the vanilla cookieconsent library.
119 lines (118 loc) • 4.09 kB
TypeScript
import { NgxWindowService } from '@studiohyperdrive/ngx-core';
import { Observable } from 'rxjs';
import { NgxCookieCategories, NgxCookieChangedEvent, NgxCookieConfiguration, NgxCookieEvent, NgxCookieLanguageConfiguration, NgxCookieValue } from '../../types';
import * as i0 from "@angular/core";
/**
* A service that implements the CookieConsent from https://cookieconsent.orestbida.com and provides the necessary Observables to handle this setup.
*/
export declare class NgxCookieService {
private readonly windowsService;
/**
* Subject to hold the onFirstConsent event
*/
private readonly firstCookiesConsentedSubject;
/**
* Subject to hold the onConsent event
*/
private readonly cookiesConsentedSubject;
/**
* Subject to hold the consentChanged event
*/
private readonly cookiesConsentChangedSubject;
/**
* Subject to hold the modalVisible event
*/
private readonly modalVisibleSubject;
/**
* Subject to hold the cookiesChanged event
*/
private readonly cookiesChangedSubject;
/**
* An event triggered only the very first time that the user expresses their choice of consent
*/
readonly firstCookiesConsented$: Observable<NgxCookieEvent>;
/**
* An event triggering the choice of consent on every page load.
*/
readonly cookiesConsented$: Observable<NgxCookieEvent>;
/**
* An event triggered when the user modifies their preferences and only if consent has already been provided.
*/
readonly cookiesConsentChanged$: Observable<NgxCookieChangedEvent>;
/**
* Whether the cookies modal is currently visible
*/
readonly modalVisible$: Observable<boolean>;
/**
* Emits every time the set cookies have been changed
*/
readonly cookiesChanged$: Observable<Record<string, any>>;
constructor(windowsService: NgxWindowService);
/**
* Sets up the CookieConsent.
*
* For more information of on this configuration, check the documentation
* https://cookieconsent.orestbida.com/essential/getting-started.html
*
* @param categories - The categories of cookies
* @param language - The language settings of the cookies
* @param configuration - An optional set configuration settings
*/
setupCookiesHandler(categories: NgxCookieCategories, language: NgxCookieLanguageConfiguration, configuration?: NgxCookieConfiguration): void;
/**
* Whether a certain category of cookies was accepted
*
* @param name - The name of the category
*/
hasAcceptedCategory(name: string): Observable<boolean>;
/**
* Accept a category of cookies
*
* @param name - The name of the categories
*/
acceptCategory(name: string): void;
/**
* Whether a certain service within a category was accepted
*
* @param category - The name of the category
* @param name - The name of the service
*/
hasAcceptedService(category: string, name: string): Observable<boolean>;
/**
* Accept a category of cookies
*
* @param category - The name of the category
* @param name - The name of the service
*/
acceptService(category: string, name: string): void;
/**
* Show the cookie modal
*/
showModal(): void;
/**
* Get a cookie
*
* @param cookie - Name of the cookie
*/
getCookie<DataType = any>(cookie: string): DataType | undefined;
/**
* Get a cookie as an observable
*
* @param cookie - Name of the cookie
*/
getCookieObservable<DataType = any>(cookie: string): Observable<DataType | undefined>;
/**
* Set a cookie
*
* @param cookie - The cookie we wish to set
*/
setCookie(cookie: NgxCookieValue): void;
/**
* Remove a cookie
*
* @param cookie - The cookie we wish to remove
*/
removeCookie(cookie: string): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxCookieService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<NgxCookieService>;
}