theme-lib
Version:
This is a simple example Angular Library published to npm.
1,463 lines (1,447 loc) • 1.87 MB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/common'), require('@angular/forms'), require('@angular/router'), require('@angular/cdk/a11y'), require('@angular/cdk/portal'), require('@angular/cdk/overlay'), require('@angular/cdk/platform'), require('@angular/cdk/bidi'), require('@angular/animations'), require('@angular/platform-browser'), require('intersection-observer')) :
typeof define === 'function' && define.amd ? define('theme-lib', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/common', '@angular/forms', '@angular/router', '@angular/cdk/a11y', '@angular/cdk/portal', '@angular/cdk/overlay', '@angular/cdk/platform', '@angular/cdk/bidi', '@angular/animations', '@angular/platform-browser', 'intersection-observer'], factory) :
(factory((global['theme-lib'] = {}),global.ng.core,global.rxjs,global.rxjs.operators,global.ng.common,global.ng.forms,global.ng.router,global.ng.cdk.a11y,global.ng.cdk.portal,global.ng.cdk.overlay,global.ng.cdk.platform,global.ng.cdk.bidi,global.ng.animations,global.ng.platformBrowser));
}(this, (function (exports,i0,rxjs,operators,i1,forms,router,a11y,portal,overlay,platform,bidi,animations,platformBrowser) { 'use strict';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var NB_THEME_OPTIONS = new i0.InjectionToken('Nebular Theme Options');
/** @type {?} */
var NB_MEDIA_BREAKPOINTS = new i0.InjectionToken('Nebular Media Breakpoints');
/** @type {?} */
var NB_BUILT_IN_JS_THEMES = new i0.InjectionToken('Nebular Built-in JS Themes');
/** @type {?} */
var NB_JS_THEMES = new i0.InjectionToken('Nebular JS Themes');
/*
* We're providing browser apis with tokens to improve testing capabilities.
* */
/** @type {?} */
var NB_WINDOW = new i0.InjectionToken('Window');
/** @type {?} */
var NB_DOCUMENT = new i0.InjectionToken('Document');
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function () {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m)
return m.call(o);
return {
next: function () {
if (o && i >= o.length)
o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m)
return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
ar.push(r.value);
}
catch (error) {
e = { error: error };
}
finally {
try {
if (r && !r.done && (m = i["return"]))
m.call(i);
}
finally {
if (e)
throw e.error;
}
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NbColorHelper = /** @class */ (function () {
function NbColorHelper() {
}
/**
* @param {?} color
* @param {?} weight
* @return {?}
*/
NbColorHelper.shade = /**
* @param {?} color
* @param {?} weight
* @return {?}
*/
function (color, weight) {
return NbColorHelper.mix('#000000', color, weight);
};
/**
* @param {?} color
* @param {?} weight
* @return {?}
*/
NbColorHelper.tint = /**
* @param {?} color
* @param {?} weight
* @return {?}
*/
function (color, weight) {
return NbColorHelper.mix('#ffffff', color, weight);
};
/**
* @param {?} color1
* @param {?} color2
* @param {?} weight
* @return {?}
*/
NbColorHelper.mix = /**
* @param {?} color1
* @param {?} color2
* @param {?} weight
* @return {?}
*/
function (color1, color2, weight) {
/** @type {?} */
var d2h = function (d) { return d.toString(16); };
/** @type {?} */
var h2d = function (h) { return parseInt(h, 16); };
/** @type {?} */
var result = '#';
for (var i = 1; i < 7; i += 2) {
/** @type {?} */
var firstPart = h2d(color1.substr(i, 2));
/** @type {?} */
var secondPart = h2d(color2.substr(i, 2));
/** @type {?} */
var resultPart = d2h(Math.floor(secondPart + (firstPart - secondPart) * (weight / 100.0)));
result += ('0' + resultPart).slice(-2);
}
return result;
};
/**
* @param {?} hex
* @param {?} alpha
* @return {?}
*/
NbColorHelper.hexToRgbA = /**
* @param {?} hex
* @param {?} alpha
* @return {?}
*/
function (hex, alpha) {
/** @type {?} */
var c;
if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)) {
c = hex.substring(1).split('');
if (c.length === 3) {
c = [c[0], c[0], c[1], c[1], c[2], c[2]];
}
c = '0x' + c.join('');
return 'rgba(' + [(c >> 16) & 255, (c >> 8) & 255, c & 255].join(',') + ',' + alpha + ')';
}
throw new Error('Bad Hex');
};
return NbColorHelper;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var palette = {
primary: '#8a7fff',
success: '#40dc7e',
info: '#4ca6ff',
warning: '#ffa100',
danger: '#ff4c6a',
};
/** @type {?} */
var DEFAULT_THEME = {
name: 'default',
variables: {
fontMain: '"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
fontSecondary: '"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
bg: '#ffffff',
fg: '#a4abb3',
fgHeading: '#2a2a2a',
fgText: '#3b3b3b',
fgHighlight: '#41d974',
layoutBg: '#ebeff5',
separator: '#ebeef2',
primary: palette.primary,
success: palette.success,
info: palette.info,
warning: palette.warning,
danger: palette.danger,
primaryLight: NbColorHelper.tint(palette.primary, 15),
successLight: NbColorHelper.tint(palette.success, 15),
infoLight: NbColorHelper.tint(palette.info, 15),
warningLight: NbColorHelper.tint(palette.warning, 15),
dangerLight: NbColorHelper.tint(palette.danger, 15),
},
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var palette$1 = {
primary: '#7659ff',
success: '#00d977',
info: '#0088ff',
warning: '#ffa100',
danger: '#ff386a',
};
/** @type {?} */
var COSMIC_THEME = {
name: 'cosmic',
base: 'default',
variables: {
bg: '#3d3780',
fg: '#a1a1e5',
fgHeading: '#ffffff',
fgText: '#d1d1ff',
fgHighlight: '#00f9a6',
layoutBg: '#2f296b',
separator: '#342e73',
primary: palette$1.primary,
success: palette$1.success,
info: palette$1.info,
warning: palette$1.warning,
danger: palette$1.danger,
primaryLight: NbColorHelper.tint(palette$1.primary, 20),
successLight: NbColorHelper.tint(palette$1.success, 20),
infoLight: NbColorHelper.tint(palette$1.info, 20),
warningLight: NbColorHelper.tint(palette$1.warning, 20),
dangerLight: NbColorHelper.tint(palette$1.danger, 20),
},
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var palette$2 = {
primary: '#73a1ff',
success: '#5dcfe3',
info: '#ba7fec',
warning: '#ffa36b',
danger: '#ff6b83',
};
/** @type {?} */
var CORPORATE_THEME = {
name: 'corporate',
base: 'default',
variables: {
fg: '#f1f5f8',
bg: '#ffffff',
fgHeading: '#181818',
fgText: '#4b4b4b',
fgHighlight: '#a4abb3',
layoutBg: '#f1f5f8',
separator: '#cdd5dc',
primary: palette$2.primary,
success: palette$2.success,
info: palette$2.info,
warning: palette$2.warning,
danger: palette$2.danger,
primaryLight: NbColorHelper.tint(palette$2.primary, 15),
successLight: NbColorHelper.tint(palette$2.success, 15),
infoLight: NbColorHelper.tint(palette$2.info, 15),
warningLight: NbColorHelper.tint(palette$2.warning, 15),
dangerLight: NbColorHelper.tint(palette$2.danger, 15),
},
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var BUILT_IN_THEMES = [
DEFAULT_THEME,
COSMIC_THEME,
CORPORATE_THEME,
];
/*
* Js Themes registry - provides access to the JS themes' variables.
* Usually shouldn't be used directly, but through the NbThemeService class methods (getJsTheme).
*/
var NbJSThemesRegistry = /** @class */ (function () {
function NbJSThemesRegistry(builtInThemes, newThemes) {
if (newThemes === void 0) {
newThemes = [];
}
var _this = this;
this.themes = {};
/** @type {?} */
var themes = this.combineByNames(newThemes, builtInThemes);
themes.forEach(function (theme) {
_this.register(theme, theme.name, theme.base);
});
}
/*
* Registers a new JS theme
* @param config any
* @param themeName string
* @param baseTheme string
*/
/*
* Registers a new JS theme
* @param config any
* @param themeName string
* @param baseTheme string
*/
/**
* @param {?} config
* @param {?} themeName
* @param {?} baseTheme
* @return {?}
*/
NbJSThemesRegistry.prototype.register = /*
* Registers a new JS theme
* @param config any
* @param themeName string
* @param baseTheme string
*/
/**
* @param {?} config
* @param {?} themeName
* @param {?} baseTheme
* @return {?}
*/
function (config, themeName, baseTheme) {
/** @type {?} */
var base = this.has(baseTheme) ? this.get(baseTheme) : {};
this.themes[themeName] = this.mergeDeep({}, base, config);
};
/*
* Checks whether the theme is registered
* @param themeName
* @returns boolean
*/
/*
* Checks whether the theme is registered
* @param themeName
* @returns boolean
*/
/**
* @param {?} themeName
* @return {?}
*/
NbJSThemesRegistry.prototype.has = /*
* Checks whether the theme is registered
* @param themeName
* @returns boolean
*/
/**
* @param {?} themeName
* @return {?}
*/
function (themeName) {
return !!this.themes[themeName];
};
/*
* Return a theme
* @param themeName
* @returns NbJSThemeOptions
*/
/*
* Return a theme
* @param themeName
* @returns NbJSThemeOptions
*/
/**
* @param {?} themeName
* @return {?}
*/
NbJSThemesRegistry.prototype.get = /*
* Return a theme
* @param themeName
* @returns NbJSThemeOptions
*/
/**
* @param {?} themeName
* @return {?}
*/
function (themeName) {
if (!this.themes[themeName]) {
throw Error("NbThemeConfig: no theme '" + themeName + "' found registered.");
}
return JSON.parse(JSON.stringify(this.themes[themeName]));
};
/**
* @private
* @param {?} newThemes
* @param {?} oldThemes
* @return {?}
*/
NbJSThemesRegistry.prototype.combineByNames = /**
* @private
* @param {?} newThemes
* @param {?} oldThemes
* @return {?}
*/
function (newThemes, oldThemes) {
var _this = this;
if (newThemes) {
/** @type {?} */
var mergedThemes_1 = [];
newThemes.forEach(function (theme) {
/** @type {?} */
var sameOld = oldThemes.find(function (tm) { return tm.name === theme.name; })
|| ( /** @type {?} */({}));
/** @type {?} */
var mergedTheme = _this.mergeDeep({}, sameOld, theme);
mergedThemes_1.push(mergedTheme);
});
oldThemes.forEach(function (theme) {
if (!mergedThemes_1.find(function (tm) { return tm.name === theme.name; })) {
mergedThemes_1.push(theme);
}
});
return mergedThemes_1;
}
return oldThemes;
};
/**
* @private
* @param {?} item
* @return {?}
*/
NbJSThemesRegistry.prototype.isObject = /**
* @private
* @param {?} item
* @return {?}
*/
function (item) {
return item && typeof item === 'object' && !Array.isArray(item);
};
// TODO: move to helpers
// TODO: move to helpers
/**
* @private
* @param {?} target
* @param {...?} sources
* @return {?}
*/
NbJSThemesRegistry.prototype.mergeDeep =
// TODO: move to helpers
/**
* @private
* @param {?} target
* @param {...?} sources
* @return {?}
*/
function (target) {
var sources = [];
for (var _i = 1; _i < arguments.length; _i++) {
sources[_i - 1] = arguments[_i];
}
var _a, _b;
if (!sources.length) {
return target;
}
/** @type {?} */
var source = sources.shift();
if (this.isObject(target) && this.isObject(source)) {
for (var key in source) {
if (this.isObject(source[key])) {
if (!target[key]) {
Object.assign(target, (_a = {}, _a[key] = {}, _a));
}
this.mergeDeep(target[key], source[key]);
}
else {
Object.assign(target, (_b = {}, _b[key] = source[key], _b));
}
}
}
return this.mergeDeep.apply(this, __spread([target], sources));
};
NbJSThemesRegistry.decorators = [
{ type: i0.Injectable }
];
/** @nocollapse */
NbJSThemesRegistry.ctorParameters = function () {
return [
{ type: Array, decorators: [{ type: i0.Inject, args: [NB_BUILT_IN_JS_THEMES,] }] },
{ type: Array, decorators: [{ type: i0.Inject, args: [NB_JS_THEMES,] }] }
];
};
return NbJSThemesRegistry;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var DEFAULT_MEDIA_BREAKPOINTS = [
{
name: 'xs',
width: 0,
},
{
name: 'is',
width: 400,
},
{
name: 'sm',
width: 576,
},
{
name: 'md',
width: 768,
},
{
name: 'lg',
width: 992,
},
{
name: 'xl',
width: 1200,
},
{
name: 'xxl',
width: 1400,
},
{
name: 'xxxl',
width: 1600,
},
];
/*
* Manages media breakpoints
*
* Provides access to available media breakpoints to convert window width to a configured breakpoint,
* e.g. 200px - *xs* breakpoint
*/
var NbMediaBreakpointsService = /** @class */ (function () {
function NbMediaBreakpointsService(breakpoints) {
this.breakpoints = breakpoints;
this.breakpointsMap = this.breakpoints.reduce(function (res, b) {
res[b.name] = b.width;
return res;
}, {});
}
/*
* Returns a configured breakpoint by width
* @param width number
* @returns {Z|{name: string, width: number}}
*/
/*
* Returns a configured breakpoint by width
* @param width number
* @returns {Z|{name: string, width: number}}
*/
/**
* @param {?} width
* @return {?}
*/
NbMediaBreakpointsService.prototype.getByWidth = /*
* Returns a configured breakpoint by width
* @param width number
* @returns {Z|{name: string, width: number}}
*/
/**
* @param {?} width
* @return {?}
*/
function (width) {
/** @type {?} */
var unknown = { name: 'unknown', width: width };
/** @type {?} */
var breakpoints = this.getBreakpoints();
return breakpoints
.find(function (point, index) {
/** @type {?} */
var next = breakpoints[index + 1];
return width >= point.width && (!next || width < next.width);
}) || unknown;
};
/*
* Returns a configured breakpoint by name
* @param name string
* @returns NbMediaBreakpoint
*/
/*
* Returns a configured breakpoint by name
* @param name string
* @returns NbMediaBreakpoint
*/
/**
* @param {?} name
* @return {?}
*/
NbMediaBreakpointsService.prototype.getByName = /*
* Returns a configured breakpoint by name
* @param name string
* @returns NbMediaBreakpoint
*/
/**
* @param {?} name
* @return {?}
*/
function (name) {
/** @type {?} */
var unknown = { name: 'unknown', width: NaN };
/** @type {?} */
var breakpoints = this.getBreakpoints();
return breakpoints.find(function (point) { return name === point.name; }) || unknown;
};
/*
* Returns a list of configured breakpoints for the theme
* @returns NbMediaBreakpoint[]
*/
/*
* Returns a list of configured breakpoints for the theme
* @returns NbMediaBreakpoint[]
*/
/**
* @return {?}
*/
NbMediaBreakpointsService.prototype.getBreakpoints = /*
* Returns a list of configured breakpoints for the theme
* @returns NbMediaBreakpoint[]
*/
/**
* @return {?}
*/
function () {
return this.breakpoints;
};
/*
* Returns a map of configured breakpoints for the theme
* @returns {[p: string]: number}
*/
/*
* Returns a map of configured breakpoints for the theme
* @returns {[p: string]: number}
*/
/**
* @return {?}
*/
NbMediaBreakpointsService.prototype.getBreakpointsMap = /*
* Returns a map of configured breakpoints for the theme
* @returns {[p: string]: number}
*/
/**
* @return {?}
*/
function () {
return this.breakpointsMap;
};
NbMediaBreakpointsService.decorators = [
{ type: i0.Injectable }
];
/** @nocollapse */
NbMediaBreakpointsService.ctorParameters = function () {
return [
{ type: undefined, decorators: [{ type: i0.Inject, args: [NB_MEDIA_BREAKPOINTS,] }] }
];
};
return NbMediaBreakpointsService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/*
* Main Nebular service. Includes various helper methods.
*/
var NbThemeService = /** @class */ (function () {
function NbThemeService(options, breakpointService, jsThemesRegistry) {
this.options = options;
this.breakpointService = breakpointService;
this.jsThemesRegistry = jsThemesRegistry;
this.themeChanges$ = new rxjs.ReplaySubject(1);
this.appendLayoutClass$ = new rxjs.Subject();
this.removeLayoutClass$ = new rxjs.Subject();
this.changeWindowWidth$ = new rxjs.ReplaySubject(2);
if (options && options.name) {
this.changeTheme(options.name);
}
}
/*
* Change current application theme
* @param {string} name
*/
/*
* Change current application theme
* @param {string} name
*/
/**
* @param {?} name
* @return {?}
*/
NbThemeService.prototype.changeTheme = /*
* Change current application theme
* @param {string} name
*/
/**
* @param {?} name
* @return {?}
*/
function (name) {
this.themeChanges$.next({ name: name, previous: this.currentTheme });
this.currentTheme = name;
};
/**
* @param {?} width
* @return {?}
*/
NbThemeService.prototype.changeWindowWidth = /**
* @param {?} width
* @return {?}
*/
function (width) {
this.changeWindowWidth$.next(width);
};
/*
* Returns a theme object with variables (color/paddings/etc) on a theme change.
* Once subscribed - returns current theme.
*
* @returns {Observable<NbJSThemeOptions>}
*/
/*
* Returns a theme object with variables (color/paddings/etc) on a theme change.
* Once subscribed - returns current theme.
*
* @returns {Observable<NbJSThemeOptions>}
*/
/**
* @return {?}
*/
NbThemeService.prototype.getJsTheme = /*
* Returns a theme object with variables (color/paddings/etc) on a theme change.
* Once subscribed - returns current theme.
*
* @returns {Observable<NbJSThemeOptions>}
*/
/**
* @return {?}
*/
function () {
var _this = this;
return this.onThemeChange().pipe(operators.map(function (theme) {
return _this.jsThemesRegistry.get(theme.name);
}));
};
/*
* Triggers media query breakpoint change
* Returns a pair where the first item is previous media breakpoint and the second item is current breakpoit.
* ```ts
* [{ name: 'xs', width: 0 }, { name: 'md', width: 768 }] // change from `xs` to `md`
* ```
* @returns {Observable<[NbMediaBreakpoint, NbMediaBreakpoint]>}
*/
/*
* Triggers media query breakpoint change
* Returns a pair where the first item is previous media breakpoint and the second item is current breakpoit.
* ```ts
* [{ name: 'xs', width: 0 }, { name: 'md', width: 768 }] // change from `xs` to `md`
* ```
* @returns {Observable<[NbMediaBreakpoint, NbMediaBreakpoint]>}
*/
/**
* @return {?}
*/
NbThemeService.prototype.onMediaQueryChange = /*
* Triggers media query breakpoint change
* Returns a pair where the first item is previous media breakpoint and the second item is current breakpoit.
* ```ts
* [{ name: 'xs', width: 0 }, { name: 'md', width: 768 }] // change from `xs` to `md`
* ```
* @returns {Observable<[NbMediaBreakpoint, NbMediaBreakpoint]>}
*/
/**
* @return {?}
*/
function () {
var _this = this;
return this.changeWindowWidth$
.pipe(operators.startWith(undefined), operators.pairwise(), operators.map(function (_a) {
var _b = __read(_a, 2), prevWidth = _b[0], width = _b[1];
return [
_this.breakpointService.getByWidth(prevWidth),
_this.breakpointService.getByWidth(width),
];
}), operators.filter(function (_a) {
var _b = __read(_a, 2), prevPoint = _b[0], point = _b[1];
return prevPoint.name !== point.name;
}), operators.distinctUntilChanged(null, function (params) { return params[0].name + params[1].name; }), operators.share());
};
/*
* Triggered when current theme is changed
* @returns {Observable<any>}
*/
/*
* Triggered when current theme is changed
* @returns {Observable<any>}
*/
/**
* @return {?}
*/
NbThemeService.prototype.onThemeChange = /*
* Triggered when current theme is changed
* @returns {Observable<any>}
*/
/**
* @return {?}
*/
function () {
return this.themeChanges$.pipe(operators.share());
};
/*
* Append a class to nb-layout
* @param {string} className
*/
/*
* Append a class to nb-layout
* @param {string} className
*/
/**
* @param {?} className
* @return {?}
*/
NbThemeService.prototype.appendLayoutClass = /*
* Append a class to nb-layout
* @param {string} className
*/
/**
* @param {?} className
* @return {?}
*/
function (className) {
this.appendLayoutClass$.next(className);
};
/*
* Triggered when a new class is added to nb-layout through `appendLayoutClass` method
* @returns {Observable<any>}
*/
/*
* Triggered when a new class is added to nb-layout through `appendLayoutClass` method
* @returns {Observable<any>}
*/
/**
* @return {?}
*/
NbThemeService.prototype.onAppendLayoutClass = /*
* Triggered when a new class is added to nb-layout through `appendLayoutClass` method
* @returns {Observable<any>}
*/
/**
* @return {?}
*/
function () {
return this.appendLayoutClass$.pipe(operators.share());
};
/*
* Removes a class from nb-layout
* @param {string} className
*/
/*
* Removes a class from nb-layout
* @param {string} className
*/
/**
* @param {?} className
* @return {?}
*/
NbThemeService.prototype.removeLayoutClass = /*
* Removes a class from nb-layout
* @param {string} className
*/
/**
* @param {?} className
* @return {?}
*/
function (className) {
this.removeLayoutClass$.next(className);
};
/*
* Triggered when a class is removed from nb-layout through `removeLayoutClass` method
* @returns {Observable<any>}
*/
/*
* Triggered when a class is removed from nb-layout through `removeLayoutClass` method
* @returns {Observable<any>}
*/
/**
* @return {?}
*/
NbThemeService.prototype.onRemoveLayoutClass = /*
* Triggered when a class is removed from nb-layout through `removeLayoutClass` method
* @returns {Observable<any>}
*/
/**
* @return {?}
*/
function () {
return this.removeLayoutClass$.pipe(operators.share());
};
NbThemeService.decorators = [
{ type: i0.Injectable }
];
/** @nocollapse */
NbThemeService.ctorParameters = function () {
return [
{ type: undefined, decorators: [{ type: i0.Inject, args: [NB_THEME_OPTIONS,] }] },
{ type: NbMediaBreakpointsService },
{ type: NbJSThemesRegistry }
];
};
return NbThemeService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/*
* Service to control the global page spinner.
*/
var NbSpinnerService = /** @class */ (function () {
function NbSpinnerService(document) {
this.document = document;
this.loaders = [];
this.selector = 'nb-global-spinner';
}
/*
* Appends new loader to the list of loader to be completed before
* spinner will be hidden
* @param method Promise<any>
*/
/*
* Appends new loader to the list of loader to be completed before
* spinner will be hidden
* @param method Promise<any>
*/
/**
* @param {?} method
* @return {?}
*/
NbSpinnerService.prototype.registerLoader = /*
* Appends new loader to the list of loader to be completed before
* spinner will be hidden
* @param method Promise<any>
*/
/**
* @param {?} method
* @return {?}
*/
function (method) {
this.loaders.push(method);
};
/*
* Clears the list of loader
*/
/*
* Clears the list of loader
*/
/**
* @return {?}
*/
NbSpinnerService.prototype.clear = /*
* Clears the list of loader
*/
/**
* @return {?}
*/
function () {
this.loaders = [];
};
/*
* Start the loader process, show spinnder and execute loaders
*/
/*
* Start the loader process, show spinnder and execute loaders
*/
/**
* @return {?}
*/
NbSpinnerService.prototype.load = /*
* Start the loader process, show spinnder and execute loaders
*/
/**
* @return {?}
*/
function () {
this.showSpinner();
this.executeAll();
};
/**
* @private
* @param {?=} done
* @return {?}
*/
NbSpinnerService.prototype.executeAll = /**
* @private
* @param {?=} done
* @return {?}
*/
function (done) {
var _this = this;
if (done === void 0) {
done = function () { };
}
Promise.all(this.loaders).then(function (values) {
_this.hideSpinner();
done.call(null, values);
})
.catch(function (error) {
// TODO: Promise.reject
console.error(error);
});
};
// TODO is there any better way of doing this?
// TODO is there any better way of doing this?
/**
* @private
* @return {?}
*/
NbSpinnerService.prototype.showSpinner =
// TODO is there any better way of doing this?
/**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var el = this.getSpinnerElement();
if (el) {
el.style['display'] = 'block';
}
};
/**
* @private
* @return {?}
*/
NbSpinnerService.prototype.hideSpinner = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var el = this.getSpinnerElement();
if (el) {
el.style['display'] = 'none';
}
};
/**
* @private
* @return {?}
*/
NbSpinnerService.prototype.getSpinnerElement = /**
* @private
* @return {?}
*/
function () {
return this.document.getElementById(this.selector);
};
NbSpinnerService.decorators = [
{ type: i0.Injectable }
];
/** @nocollapse */
NbSpinnerService.ctorParameters = function () {
return [
{ type: undefined, decorators: [{ type: i0.Inject, args: [NB_DOCUMENT,] }] }
];
};
return NbSpinnerService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @enum {string} */
var NbLayoutDirection = {
LTR: 'ltr',
RTL: 'rtl',
};
/*
* Layout direction setting injection token.
* */
/** @type {?} */
var NB_LAYOUT_DIRECTION = new i0.InjectionToken('Layout direction');
/*
* Layout Direction Service.
* Allows to set or get layout direction and listen to its changes
*/
var NbLayoutDirectionService = /** @class */ (function () {
function NbLayoutDirectionService(direction) {
if (direction === void 0) {
direction = NbLayoutDirection.LTR;
}
this.direction = direction;
this.$directionChange = new rxjs.ReplaySubject(1);
this.setDirection(direction);
}
/*
* Returns true if layout direction set to left to right.
* @returns boolean.
* */
/*
* Returns true if layout direction set to left to right.
* @returns boolean.
* */
/**
* @return {?}
*/
NbLayoutDirectionService.prototype.isLtr = /*
* Returns true if layout direction set to left to right.
* @returns boolean.
* */
/**
* @return {?}
*/
function () {
return this.direction === NbLayoutDirection.LTR;
};
/*
* Returns true if layout direction set to right to left.
* @returns boolean.
* */
/*
* Returns true if layout direction set to right to left.
* @returns boolean.
* */
/**
* @return {?}
*/
NbLayoutDirectionService.prototype.isRtl = /*
* Returns true if layout direction set to right to left.
* @returns boolean.
* */
/**
* @return {?}
*/
function () {
return this.direction === NbLayoutDirection.RTL;
};
/*
* Returns current layout direction.
* @returns NbLayoutDirection.
* */
/*
* Returns current layout direction.
* @returns NbLayoutDirection.
* */
/**
* @return {?}
*/
NbLayoutDirectionService.prototype.getDirection = /*
* Returns current layout direction.
* @returns NbLayoutDirection.
* */
/**
* @return {?}
*/
function () {
return this.direction;
};
/*
* Sets layout direction
* @param {NbLayoutDirection} direction
*/
/*
* Sets layout direction
* @param {NbLayoutDirection} direction
*/
/**
* @param {?} direction
* @return {?}
*/
NbLayoutDirectionService.prototype.setDirection = /*
* Sets layout direction
* @param {NbLayoutDirection} direction
*/
/**
* @param {?} direction
* @return {?}
*/
function (direction) {
this.direction = direction;
this.$directionChange.next(direction);
};
/*
* Triggered when direction was changed.
* @returns Observable<NbLayoutDirection>.
*/
/*
* Triggered when direction was changed.
* @returns Observable<NbLayoutDirection>.
*/
/**
* @return {?}
*/
NbLayoutDirectionService.prototype.onDirectionChange = /*
* Triggered when direction was changed.
* @returns Observable<NbLayoutDirection>.
*/
/**
* @return {?}
*/
function () {
return this.$directionChange.pipe(operators.share());
};
NbLayoutDirectionService.decorators = [
{ type: i0.Injectable }
];
/** @nocollapse */
NbLayoutDirectionService.ctorParameters = function () {
return [
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [NB_LAYOUT_DIRECTION,] }] }
];
};
return NbLayoutDirectionService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/*
* Layout scroll service. Provides information about current scroll position,
* as well as methods to update position of the scroll.
*
* The reason we added this service is that in Nebular there are two scroll modes:
* - the default mode when scroll is on body
* - and the `withScroll` mode, when scroll is removed from the body and moved to an element inside of the
* `nb-layout` component
*/
var NbLayoutScrollService = /** @class */ (function () {
function NbLayoutScrollService() {
this.scrollPositionReq$ = new rxjs.Subject();
this.manualScroll$ = new rxjs.Subject();
this.scroll$ = new rxjs.Subject();
}
/*
* Returns scroll position
*
* @returns {Observable<NbScrollPosition>}
*/
/*
* Returns scroll position
*
* @returns {Observable<NbScrollPosition>}
*/
/**
* @return {?}
*/
NbLayoutScrollService.prototype.getPosition = /*
* Returns scroll position
*
* @returns {Observable<NbScrollPosition>}
*/
/**
* @return {?}
*/
function () {
var _this = this;
return rxjs.Observable.create(function (observer) {
/** @type {?} */
var listener = new rxjs.Subject();
listener.subscribe(observer);
_this.scrollPositionReq$.next({ listener: listener });
return function () { return listener.complete(); };
});
};
/*
* Sets scroll position
*
* @param {number} x
* @param {number} y
*/
/*
* Sets scroll position
*
* @param {number} x
* @param {number} y
*/
/**
* @param {?=} x
* @param {?=} y
* @return {?}
*/
NbLayoutScrollService.prototype.scrollTo = /*
* Sets scroll position
*
* @param {number} x
* @param {number} y
*/
/**
* @param {?=} x
* @param {?=} y
* @return {?}
*/
function (x, y) {
if (x === void 0) {
x = null;
}
if (y === void 0) {
y = null;
}
this.manualScroll$.next({ x: x, y: y });
};
/*
* Returns a stream of scroll events
*
* @returns {Observable<any>}
*/
/*
* Returns a stream of scroll events
*
* @returns {Observable<any>}
*/
/**
* @return {?}
*/
NbLayoutScrollService.prototype.onScroll = /*
* Returns a stream of scroll events
*
* @returns {Observable<any>}
*/
/**
* @return {?}
*/
function () {
return this.scroll$.pipe(operators.share());
};
/*
* @private
* @returns Observable<NbScrollPosition>.
*/
/*
* @private
* @returns Observable<NbScrollPosition>.
*/
/**
* @return {?}
*/
NbLayoutScrollService.prototype.onManualScroll = /*
* @private
* @returns Observable<NbScrollPosition>.
*/
/**
* @return {?}
*/
function () {
return this.manualScroll$.pipe(operators.share());
};
/*
* @private
* @returns {Subject<any>}
*/
/*
* @private
* @returns {Subject<any>}
*/
/**
* @return {?}
*/
NbLayoutScrollService.prototype.onGetPosition = /*
* @private
* @returns {Subject<any>}
*/
/**
* @return {?}
*/
function () {
return this.scrollPositionReq$;
};
/*
* @private
* @param {any} event
*/
/*
* @private
* @param {any} event
*/
/**
* @param {?} event
* @return {?}
*/
NbLayoutScrollService.prototype.fireScrollChange = /*
* @private
* @param {any} event
*/
/**
* @param {?} event
* @return {?}
*/
function (event) {
this.scroll$.next(event);
};
NbLayoutScrollService.decorators = [
{ type: i0.Injectable }
];
return NbLayoutScrollService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/*
* Simple helper service to return Layout dimensions
* Depending of current Layout scroll mode (default or `withScroll` when scroll is moved to an element
* inside of the layout) corresponding dimensions will be returns - of `documentElement` in first case and
* `.scrollable-container` in the second.
*/
var NbLayoutRulerService = /** @class */ (function () {
function NbLayoutRulerService() {
this.contentDimensionsReq$ = new rxjs.Subject();
}
/*
* Content dimensions
* @returns {Observable<NbLayoutDimensions>}
*/
/*
* Content dimensions
* @returns {Observable<NbLayoutDimensions>}
*/
/**
* @return {?}