UNPKG

@nebular/theme

Version:
1,222 lines (1,199 loc) 1.02 MB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('rxjs'), require('rxjs/operators'), 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/scrolling'), require('@angular/platform-browser'), require('@angular/animations'), require('intersection-observer'), require('@angular/cdk/bidi'), require('@angular/cdk/table'), require('@angular/cdk/keycodes')) : typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/common', 'rxjs', 'rxjs/operators', '@angular/forms', '@angular/router', '@angular/cdk/a11y', '@angular/cdk/portal', '@angular/cdk/overlay', '@angular/cdk/platform', '@angular/cdk/scrolling', '@angular/platform-browser', '@angular/animations', 'intersection-observer', '@angular/cdk/bidi', '@angular/cdk/table', '@angular/cdk/keycodes'], factory) : (factory((global.nb = global.nb || {}, global.nb.theme = global.nb.theme || {}),global.ng.core,global.ng.common,global.Rx,global.Rx.operators,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.scrolling,global.ng.platformBrowser,global.ng.animations,global['intersection-observer'],global.ng.cdk.bidi,global.ng.cdk.table,global.ng.cdk.keycodes)); }(this, (function (exports,i0,i1,rxjs,rxjs_operators,_angular_forms,_angular_router,_angular_cdk_a11y,_angular_cdk_portal,_angular_cdk_overlay,_angular_cdk_platform,i2,_angular_platformBrowser,_angular_animations,intersectionObserver,_angular_cdk_bidi,_angular_cdk_table,_angular_cdk_keycodes) { 'use strict'; /** * @license * Copyright Akveo. All Rights Reserved. * Licensed under the MIT License. See License.txt in the project root for license information. */ var NB_THEME_OPTIONS = new i0.InjectionToken('Nebular Theme Options'); var NB_MEDIA_BREAKPOINTS = new i0.InjectionToken('Nebular Media Breakpoints'); var NB_BUILT_IN_JS_THEMES = new i0.InjectionToken('Nebular Built-in JS Themes'); var NB_JS_THEMES = new i0.InjectionToken('Nebular JS Themes'); /** * We're providing browser apis with tokens to improve testing capabilities. * */ var NB_WINDOW = new i0.InjectionToken('Window'); var NB_DOCUMENT = new i0.InjectionToken('Document'); var palette = { primary: '#3366ff', success: '#00d68f', info: '#0095ff', warning: '#ffaa00', danger: '#ff3d71', }; var DEFAULT_THEME = { name: 'default', variables: { fontMain: 'Open Sans, sans-serif', fontSecondary: 'Raleway, sans-serif', bg: '#ffffff', bg2: '#f7f9fc', bg3: '#edf1f7', bg4: '#e4e9f2', border: '#ffffff', border2: '#f7f9fc', border3: '#edf1f7', border4: '#e4e9f2', border5: '#c5cee0', fg: '#8f9bb3', fgHeading: '#1a2138', fgText: '#1a2138', fgHighlight: palette.primary, layoutBg: '#f7f9fc', separator: '#edf1f7', primary: palette.primary, success: palette.success, info: palette.info, warning: palette.warning, danger: palette.danger, primaryLight: '#598bff', successLight: '#2ce69b', infoLight: '#42aaff', warningLight: '#ffc94d', dangerLight: '#ff708d', }, }; var palette$1 = { primary: '#a16eff', success: '#00d68f', info: '#0095ff', warning: '#ffaa00', danger: '#ff3d71', }; var COSMIC_THEME = { name: 'cosmic', variables: { fontMain: 'Open Sans, sans-serif', fontSecondary: 'Raleway, sans-serif', bg: '#323259', bg2: '#252547', bg3: '#1b1b38', bg4: '#13132b', border: '#323259', border2: '#252547', border3: '#1b1b38', border4: '#13132b', border5: '#13132b', fg: '#b4b4db', fgHeading: '#ffffff', fgText: '#ffffff', fgHighlight: palette$1.primary, layoutBg: '#151a30', separator: '#151a30', primary: palette$1.primary, success: palette$1.success, info: palette$1.info, warning: palette$1.warning, danger: palette$1.danger, primaryLight: '#b18aff', successLight: '#2ce69b', infoLight: '#42aaff', warningLight: '#ffc94d', dangerLight: '#ff708d', }, }; var palette$2 = { primary: '#73a1ff', success: '#5dcfe3', info: '#ba7fec', warning: '#ffa36b', danger: '#ff6b83', }; var CORPORATE_THEME = { name: 'corporate', base: 'default', variables: { fontMain: 'Open Sans, sans-serif', fontSecondary: 'Raleway, sans-serif', bg: '#ffffff', bg2: '#f7f9fc', bg3: '#edf1f7', bg4: '#e4e9f2', border: '#ffffff', border2: '#f7f9fc', border3: '#edf1f7', border4: '#e4e9f2', border5: '#c5cee0', fg: '#8f9bb3', fgHeading: '#1a2138', fgText: '#1a2138', fgHighlight: palette$2.primary, layoutBg: '#f7f9fc', separator: '#edf1f7', primary: palette$2.primary, success: palette$2.success, info: palette$2.info, warning: palette$2.warning, danger: palette$2.danger, primaryLight: '#598bff', successLight: '#2ce69b', infoLight: '#42aaff', warningLight: '#ffc94d', dangerLight: '#ff708d', }, }; var palette$3 = { primary: '#3366ff', success: '#00d68f', info: '#0095ff', warning: '#ffaa00', danger: '#ff3d71', }; var DARK_THEME = { name: 'dark', variables: { fontMain: 'Open Sans, sans-serif', fontSecondary: 'Raleway, sans-serif', bg: '#222b45', bg2: '#1a2138', bg3: '#151a30', bg4: '#101426', border: '#222b45', border2: '#1a2138', border3: '#151a30', border4: '#101426', border5: '#101426', fg: '#8f9bb3', fgHeading: '#ffffff', fgText: '#ffffff', fgHighlight: palette$3.primary, layoutBg: '#1b1b38', separator: '#1b1b38', primary: palette$3.primary, success: palette$3.success, info: palette$3.info, warning: palette$3.warning, danger: palette$3.danger, primaryLight: '#598bff', successLight: '#2ce69b', infoLight: '#42aaff', warningLight: '#ffc94d', dangerLight: '#ff708d', }, }; /** * @license * Copyright Akveo. All Rights Reserved. * Licensed under the MIT License. See License.txt in the project root for license information. */ var __decorate$2 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata$1 = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param$1 = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var BUILT_IN_THEMES = [ DEFAULT_THEME, COSMIC_THEME, CORPORATE_THEME, DARK_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) { var _this = this; if (newThemes === void 0) { newThemes = []; } this.themes = {}; 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 */ NbJSThemesRegistry.prototype.register = function (config, themeName, baseTheme) { 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 */ NbJSThemesRegistry.prototype.has = function (themeName) { return !!this.themes[themeName]; }; /** * Return a theme * @param themeName * @returns NbJSThemeOptions */ NbJSThemesRegistry.prototype.get = function (themeName) { if (!this.themes[themeName]) { throw Error("NbThemeConfig: no theme '" + themeName + "' found registered."); } return JSON.parse(JSON.stringify(this.themes[themeName])); }; NbJSThemesRegistry.prototype.combineByNames = function (newThemes, oldThemes) { var _this = this; if (newThemes) { var mergedThemes_1 = []; newThemes.forEach(function (theme) { var sameOld = oldThemes.find(function (tm) { return tm.name === theme.name; }) || {}; 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; }; NbJSThemesRegistry.prototype.isObject = function (item) { return item && typeof item === 'object' && !Array.isArray(item); }; // TODO: move to helpers NbJSThemesRegistry.prototype.mergeDeep = function (target) { var _a, _b; var sources = []; for (var _i = 1; _i < arguments.length; _i++) { sources[_i - 1] = arguments[_i]; } if (!sources.length) { return target; } 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, [target].concat(sources)); }; NbJSThemesRegistry = __decorate$2([ i0.Injectable(), __param$1(0, i0.Inject(NB_BUILT_IN_JS_THEMES)), __param$1(1, i0.Inject(NB_JS_THEMES)), __metadata$1("design:paramtypes", [Array, Array]) ], NbJSThemesRegistry); return NbJSThemesRegistry; }()); /** * @license * Copyright Akveo. All Rights Reserved. * Licensed under the MIT License. See License.txt in the project root for license information. */ var __decorate$3 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata$2 = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param$2 = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; 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}} */ NbMediaBreakpointsService.prototype.getByWidth = function (width) { var unknown = { name: 'unknown', width: width }; var breakpoints = this.getBreakpoints(); return breakpoints .find(function (point, index) { 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 */ NbMediaBreakpointsService.prototype.getByName = function (name) { var unknown = { name: 'unknown', width: NaN }; 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[] */ NbMediaBreakpointsService.prototype.getBreakpoints = function () { return this.breakpoints; }; /** * Returns a map of configured breakpoints for the theme * @returns {[p: string]: number} */ NbMediaBreakpointsService.prototype.getBreakpointsMap = function () { return this.breakpointsMap; }; NbMediaBreakpointsService = __decorate$3([ i0.Injectable(), __param$2(0, i0.Inject(NB_MEDIA_BREAKPOINTS)), __metadata$2("design:paramtypes", [Object]) ], NbMediaBreakpointsService); return NbMediaBreakpointsService; }()); /** * @license * Copyright Akveo. All Rights Reserved. * Licensed under the MIT License. See License.txt in the project root for license information. */ var __decorate$1 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; /** * 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 */ NbThemeService.prototype.changeTheme = function (name) { this.themeChanges$.next({ name: name, previous: this.currentTheme }); this.currentTheme = name; }; NbThemeService.prototype.changeWindowWidth = 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>} */ NbThemeService.prototype.getJsTheme = function () { var _this = this; return this.onThemeChange().pipe(rxjs_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]>} */ NbThemeService.prototype.onMediaQueryChange = function () { var _this = this; return this.changeWindowWidth$ .pipe(rxjs_operators.startWith(undefined), rxjs_operators.pairwise(), rxjs_operators.map(function (_a) { var prevWidth = _a[0], width = _a[1]; return [ _this.breakpointService.getByWidth(prevWidth), _this.breakpointService.getByWidth(width), ]; }), rxjs_operators.filter(function (_a) { var prevPoint = _a[0], point = _a[1]; return prevPoint.name !== point.name; }), rxjs_operators.distinctUntilChanged(null, function (params) { return params[0].name + params[1].name; }), rxjs_operators.share()); }; /** * Triggered when current theme is changed * @returns {Observable<any>} */ NbThemeService.prototype.onThemeChange = function () { return this.themeChanges$.pipe(rxjs_operators.share()); }; /** * Append a class to nb-layout * @param {string} className */ NbThemeService.prototype.appendLayoutClass = function (className) { this.appendLayoutClass$.next(className); }; /** * Triggered when a new class is added to nb-layout through `appendLayoutClass` method * @returns {Observable<any>} */ NbThemeService.prototype.onAppendLayoutClass = function () { return this.appendLayoutClass$.pipe(rxjs_operators.share()); }; /** * Removes a class from nb-layout * @param {string} className */ NbThemeService.prototype.removeLayoutClass = function (className) { this.removeLayoutClass$.next(className); }; /** * Triggered when a class is removed from nb-layout through `removeLayoutClass` method * @returns {Observable<any>} */ NbThemeService.prototype.onRemoveLayoutClass = function () { return this.removeLayoutClass$.pipe(rxjs_operators.share()); }; NbThemeService = __decorate$1([ i0.Injectable(), __param(0, i0.Inject(NB_THEME_OPTIONS)), __metadata("design:paramtypes", [Object, NbMediaBreakpointsService, NbJSThemesRegistry]) ], NbThemeService); return NbThemeService; }()); var __decorate$4 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata$3 = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param$3 = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; /** * @license * Copyright Akveo. All Rights Reserved. * Licensed under the MIT License. See License.txt in the project root for license information. */ /** * 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> */ NbSpinnerService.prototype.registerLoader = function (method) { this.loaders.push(method); }; /** * Clears the list of loader */ NbSpinnerService.prototype.clear = function () { this.loaders = []; }; /** * Start the loader process, show spinnder and execute loaders */ NbSpinnerService.prototype.load = function () { this.showSpinner(); this.executeAll(); }; NbSpinnerService.prototype.executeAll = 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? NbSpinnerService.prototype.showSpinner = function () { var el = this.getSpinnerElement(); if (el) { el.style['display'] = 'block'; } }; NbSpinnerService.prototype.hideSpinner = function () { var el = this.getSpinnerElement(); if (el) { el.style['display'] = 'none'; } }; NbSpinnerService.prototype.getSpinnerElement = function () { return this.document.getElementById(this.selector); }; NbSpinnerService = __decorate$4([ i0.Injectable(), __param$3(0, i0.Inject(NB_DOCUMENT)), __metadata$3("design:paramtypes", [Object]) ], NbSpinnerService); return NbSpinnerService; }()); var __decorate$5 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata$4 = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param$4 = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; /** * Layout direction. * */ (function (NbLayoutDirection) { NbLayoutDirection["LTR"] = "ltr"; NbLayoutDirection["RTL"] = "rtl"; })(exports.NbLayoutDirection || (exports.NbLayoutDirection = {})); /** * Layout direction setting injection token. * */ 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 = exports.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. * */ NbLayoutDirectionService.prototype.isLtr = function () { return this.direction === exports.NbLayoutDirection.LTR; }; /** * Returns true if layout direction set to right to left. * @returns boolean. * */ NbLayoutDirectionService.prototype.isRtl = function () { return this.direction === exports.NbLayoutDirection.RTL; }; /** * Returns current layout direction. * @returns NbLayoutDirection. * */ NbLayoutDirectionService.prototype.getDirection = function () { return this.direction; }; /** * Sets layout direction * @param {NbLayoutDirection} direction */ NbLayoutDirectionService.prototype.setDirection = function (direction) { this.direction = direction; this.$directionChange.next(direction); }; /** * Triggered when direction was changed. * @returns Observable<NbLayoutDirection>. */ NbLayoutDirectionService.prototype.onDirectionChange = function () { return this.$directionChange.pipe(rxjs_operators.share()); }; NbLayoutDirectionService = __decorate$5([ i0.Injectable(), __param$4(0, i0.Optional()), __param$4(0, i0.Inject(NB_LAYOUT_DIRECTION)), __metadata$4("design:paramtypes", [Object]) ], NbLayoutDirectionService); return NbLayoutDirectionService; }()); var __decorate$6 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; /** * 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(); this.scrollable$ = new rxjs.Subject(); } /** * Returns scroll position * * @returns {Observable<NbScrollPosition>} */ NbLayoutScrollService.prototype.getPosition = function () { var _this = this; return rxjs.Observable.create(function (observer) { 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 */ NbLayoutScrollService.prototype.scrollTo = 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>} */ NbLayoutScrollService.prototype.onScroll = function () { return this.scroll$.pipe(rxjs_operators.share()); }; /** * @private * @returns Observable<NbScrollPosition>. */ NbLayoutScrollService.prototype.onManualScroll = function () { return this.manualScroll$.pipe(rxjs_operators.share()); }; /** * @private * @returns {Subject<any>} */ NbLayoutScrollService.prototype.onGetPosition = function () { return this.scrollPositionReq$; }; NbLayoutScrollService.prototype.onScrollableChange = function () { return this.scrollable$.pipe(rxjs_operators.share()); }; /** * @private * @param {any} event */ NbLayoutScrollService.prototype.fireScrollChange = function (event) { this.scroll$.next(event); }; NbLayoutScrollService.prototype.scrollable = function (scrollable) { this.scrollable$.next(scrollable); }; NbLayoutScrollService = __decorate$6([ i0.Injectable() ], NbLayoutScrollService); return NbLayoutScrollService; }()); var __decorate$7 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; /** * 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>} */ NbLayoutRulerService.prototype.getDimensions = function () { var _this = this; return rxjs.Observable.create(function (observer) { var listener = new rxjs.Subject(); listener.subscribe(observer); _this.contentDimensionsReq$.next({ listener: listener }); return function () { return listener.complete(); }; }); }; /** * @private * @returns {Subject<any>} */ NbLayoutRulerService.prototype.onGetDimensions = function () { return this.contentDimensionsReq$; }; NbLayoutRulerService = __decorate$7([ i0.Injectable() ], NbLayoutRulerService); return NbLayoutRulerService; }()); /** * @license * Copyright Akveo. All Rights Reserved. * Licensed under the MIT License. See License.txt in the project root for license information. */ var __decorate$9 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var NbSharedModule = /** @class */ (function () { function NbSharedModule() { } NbSharedModule = __decorate$9([ i0.NgModule({ exports: [ i1.CommonModule, // TODO: probably we don't need FormsModule in SharedModule _angular_forms.FormsModule, _angular_router.RouterModule, ], }) ], NbSharedModule); return NbSharedModule; }()); var __extends = (this && this.__extends) || (function () { 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); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate$11 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata$5 = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param$5 = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; /** * Overrides angular cdk focus trap to keep restore functionality inside trap. * */ var NbFocusTrap = /** @class */ (function (_super) { __extends(NbFocusTrap, _super); function NbFocusTrap(element, checker, ngZone, document, deferAnchors) { var _this = _super.call(this, element, checker, ngZone, document, deferAnchors) || this; _this.element = element; _this.checker = checker; _this.ngZone = ngZone; _this.document = document; _this.savePreviouslyFocusedElement(); return _this; } NbFocusTrap.prototype.restoreFocus = function () { this.previouslyFocusedElement.focus(); this.destroy(); }; NbFocusTrap.prototype.blurPreviouslyFocusedElement = function () { this.previouslyFocusedElement.blur(); }; NbFocusTrap.prototype.savePreviouslyFocusedElement = function () { this.previouslyFocusedElement = this.document.activeElement; }; return NbFocusTrap; }(_angular_cdk_a11y.FocusTrap)); var NbFocusTrapFactoryService = /** @class */ (function (_super) { __extends(NbFocusTrapFactoryService, _super); function NbFocusTrapFactoryService(checker, ngZone, document) { var _this = _super.call(this, checker, ngZone, document) || this; _this.checker = checker; _this.ngZone = ngZone; _this.document = document; return _this; } NbFocusTrapFactoryService.prototype.create = function (element, deferCaptureElements) { return new NbFocusTrap(element, this.checker, this.ngZone, this.document, deferCaptureElements); }; NbFocusTrapFactoryService = __decorate$11([ i0.Injectable(), __param$5(2, i0.Inject(NB_DOCUMENT)), __metadata$5("design:paramtypes", [_angular_cdk_a11y.InteractivityChecker, i0.NgZone, Object]) ], NbFocusTrapFactoryService); return NbFocusTrapFactoryService; }(_angular_cdk_a11y.FocusTrapFactory)); var __decorate$10 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var NbA11yModule = /** @class */ (function () { function NbA11yModule() { } NbA11yModule_1 = NbA11yModule; NbA11yModule.forRoot = function () { return { ngModule: NbA11yModule_1, providers: [NbFocusTrapFactoryService], }; }; var NbA11yModule_1; NbA11yModule = NbA11yModule_1 = __decorate$10([ i0.NgModule({}) ], NbA11yModule); return NbA11yModule; }()); var __extends$1 = (this && this.__extends) || (function () { 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); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate$12 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var NbPortalDirective = /** @class */ (function (_super) { __extends$1(NbPortalDirective, _super); function NbPortalDirective() { return _super !== null && _super.apply(this, arguments) || this; } NbPortalDirective = __decorate$12([ i0.Directive({ selector: '[nbPortal]' }) ], NbPortalDirective); return NbPortalDirective; }(_angular_cdk_portal.CdkPortal)); var NbPortalOutletDirective = /** @class */ (function (_super) { __extends$1(NbPortalOutletDirective, _super); function NbPortalOutletDirective() { return _super !== null && _super.apply(this, arguments) || this; } NbPortalOutletDirective = __decorate$12([ i0.Directive({ selector: '[nbPortalOutlet]' }) ], NbPortalOutletDirective); return NbPortalOutletDirective; }(_angular_cdk_portal.CdkPortalOutlet)); var NbComponentPortal = /** @class */ (function (_super) { __extends$1(NbComponentPortal, _super); function NbComponentPortal() { return _super !== null && _super.apply(this, arguments) || this; } return NbComponentPortal; }(_angular_cdk_portal.ComponentPortal)); var NbOverlay = /** @class */ (function (_super) { __extends$1(NbOverlay, _super); function NbOverlay() { return _super !== null && _super.apply(this, arguments) || this; } NbOverlay = __decorate$12([ i0.Injectable() ], NbOverlay); return NbOverlay; }(_angular_cdk_overlay.Overlay)); var NbPlatform = /** @class */ (function (_super) { __extends$1(NbPlatform, _super); function NbPlatform() { return _super !== null && _super.apply(this, arguments) || this; } NbPlatform = __decorate$12([ i0.Injectable() ], NbPlatform); return NbPlatform; }(_angular_cdk_platform.Platform)); var NbOverlayPositionBuilder = /** @class */ (function (_super) { __extends$1(NbOverlayPositionBuilder, _super); function NbOverlayPositionBuilder() { return _super !== null && _super.apply(this, arguments) || this; } NbOverlayPositionBuilder = __decorate$12([ i0.Injectable() ], NbOverlayPositionBuilder); return NbOverlayPositionBuilder; }(_angular_cdk_overlay.OverlayPositionBuilder)); var NbTemplatePortal = /** @class */ (function (_super) { __extends$1(NbTemplatePortal, _super); function NbTemplatePortal(template, viewContainerRef, context) { return _super.call(this, template, viewContainerRef, context) || this; } return NbTemplatePortal; }(_angular_cdk_portal.TemplatePortal)); var NbOverlayContainer = /** @class */ (function (_super) { __extends$1(NbOverlayContainer, _super); function NbOverlayContainer() { return _super !== null && _super.apply(this, arguments) || this; } NbOverlayContainer.ngInjectableDef = i0.ɵɵdefineInjectable({ factory: function NbOverlayContainer_Factory() { return new NbOverlayContainer(i0.ɵɵinject(i1.DOCUMENT)); }, token: NbOverlayContainer, providedIn: "root" }); return NbOverlayContainer; }(_angular_cdk_overlay.OverlayContainer)); var NbFlexibleConnectedPositionStrategy = /** @class */ (function (_super) { __extends$1(NbFlexibleConnectedPositionStrategy, _super); function NbFlexibleConnectedPositionStrategy() { return _super !== null && _super.apply(this, arguments) || this; } return NbFlexibleConnectedPositionStrategy; }(_angular_cdk_overlay.FlexibleConnectedPositionStrategy)); var NbPortalInjector = /** @class */ (function (_super) { __extends$1(NbPortalInjector, _super); function NbPortalInjector() { return _super !== null && _super.apply(this, arguments) || this; } return NbPortalInjector; }(_angular_cdk_portal.PortalInjector)); var CDK_MODULES = [_angular_cdk_overlay.OverlayModule, _angular_cdk_portal.PortalModule]; /** * This module helps us to keep all angular/cdk deps inside our cdk module via providing aliases. * Approach will help us move cdk in separate npm package and refactor nebular/theme code. * */ var NbCdkMappingModule = /** @class */ (function () { function NbCdkMappingModule() { } NbCdkMappingModule_1 = NbCdkMappingModule; NbCdkMappingModule.forRoot = function () { return { ngModule: NbCdkMappingModule_1, providers: [ NbOverlay, NbPlatform, NbOverlayPositionBuilder, ], }; }; var NbCdkMappingModule_1; NbCdkMappingModule = NbCdkMappingModule_1 = __decorate$12([ i0.NgModule({ imports: CDK_MODULES.slice(), exports: CDK_MODULES.concat([ NbPortalDirective, NbPortalOutletDirective, ]), declarations: [NbPortalDirective, NbPortalOutletDirective], }) ], NbCdkMappingModule); return NbCdkMappingModule; }()); var __extends$3 = (this && this.__extends) || (function () { 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); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate$14 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; /** * Provides nb-layout as overlay container. * Container has to be cleared when layout destroys. * Another way previous version of the container will be used * but it isn't inserted in DOM and exists in memory only. * This case important only if you switch between multiple layouts. * */ var NbOverlayContainerAdapter = /** @class */ (function (_super) { __extends$3(NbOverlayContainerAdapter, _super); function NbOverlayContainerAdapter() { return _super !== null && _super.apply(this, arguments) || this; } NbOverlayContainerAdapter.prototype.setContainer = function (container) { this.container = container; }; NbOverlayContainerAdapter.prototype.clearContainer = function () { this.container = null; this._containerElement = null; }; NbOverlayContainerAdapter.prototype._createContainer = function () { var container = this._document.createElement('div'); container.classList.add('cdk-overlay-container'); this.container.appendChild(container); this._containerElement = container; }; NbOverlayContainerAdapter = __decorate$14([ i0.Injectable() ], NbOverlayContainerAdapter); return NbOverlayContainerAdapter; }(NbOverlayContainer)); var __extends$4 = (this && this.__extends) || (function () { 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); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate$15 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata$7 = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var NbViewportRulerAdapter = /** @class */ (function (_super) { __extends$4(NbViewportRulerAdapter, _super); function NbViewportRulerAdapter(platform, ngZone, ruler, scroll) { var _this = _super.call(this, platform, ngZone) || this; _this.ruler = ruler; _this.scroll = scroll; return _this; } NbViewportRulerAdapter.prototype.getViewportSize = function () { var res; /* * getDimensions call is really synchronous operation. * And we have to conform with the interface of the original service. * */ this.ruler.getDimensions() .pipe(rxjs_operators.map(function (dimensions) { return ({ width: dimensions.clientWidth, height: dimensions.clientHeight }); })) .subscribe(function (rect) { return res = rect; }); return res; }; NbViewportRulerAdapter.prototype.getViewportScrollPosition = function () { var res; /* * getPosition call is really synchronous operation. * And we have to conform with the interface of the original service. * */ this.scroll.getPosition() .pipe(rxjs_operators.map(function (position) { return ({ top: position.y, left: position.x }); })) .subscribe(function (position) { return res = position; }); return res; }; NbViewportRulerAdapter = __decorate$15([ i0.Injectable(), __metadata$7("design:paramtypes", [NbPlatform, i0.NgZone, NbLayoutRulerService, NbLayoutScrollService]) ], NbViewportRulerAdapter); return NbViewportRulerAdapter; }(_angular_cdk_overlay.ViewportRuler)); var __decorate$16 = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata$8 = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; (function (NbGlobalLogicalPosition) { NbGlobalLogicalPosition["TOP_START"] = "top-start"; NbGlobalLogicalPosition["TOP_END"] = "top-end"; NbGlobalLogicalPosition["BOTTOM_START"] = "bottom-start"; NbGlobalLogicalPosition["BOTTOM_END"] = "bottom-end"; })(exports.NbGlobalLogicalPosition || (exports.NbGlobalLogicalPosition = {})); (function (NbGlobalPhysicalPosition) { NbGlobalPhysicalPosition["TOP_RIGHT"] = "top-right"; NbGlobalPhysicalPosition["TOP_LEFT"] = "top-le