Skip to content

Commit

Permalink
Merge branch 'master' into feature/select
Browse files Browse the repository at this point in the history
  • Loading branch information
Tibing committed Sep 11, 2018
2 parents 3f72cd4 + 29e4fef commit 3fd8649
Show file tree
Hide file tree
Showing 66 changed files with 2,874 additions and 55 deletions.
2 changes: 1 addition & 1 deletion docs/articles/install-into-existing.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Same way you can enable Auth Module (more details under [Auth Module Concepts &
## Install Styles
Now, let's import Nebular styles
Include Bootstrap and default Nebular theme CSS files into your `.angular-cli.json` file:
Include Bootstrap and default Nebular theme CSS files into your `angular.json` file (or `.angular-cli.json` for Angular < 6.0):
```scss
"styles": [
Expand Down
File renamed without changes
33 changes: 33 additions & 0 deletions docs/assets/images/components/toastr.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions docs/structure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,26 @@ export const structure = [
'NbContextMenuDirective',
],
},
{
type: 'tabs',
name: 'Dialog',
icon: 'dialog.svg',
source: [
'NbDialogService',
'NbDialogRef',
'NbDialogConfig',
],
},
{
type: 'tabs',
name: 'Toastr',
icon: 'toastr.svg',
source: [
'NbToastrService',
'NbToastComponent',
'NbToastrConfig',
],
},
{
type: 'tabs',
name: 'Select',
Expand Down
8 changes: 4 additions & 4 deletions e2e/popover.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,28 @@ describe('nb-popover', () => {
element(placementRight).click();
const container = element(popover);
expect(container.isPresent()).toBeTruthy();
expect(container.getAttribute('class')).toEqual('right');
expect(container.getAttribute('class')).toEqual('nb-overlay-right');
});

it('render container in the bottom', () => {
element(placementBottom).click();
const container = element(popover);
expect(container.isPresent()).toBeTruthy();
expect(container.getAttribute('class')).toEqual('bottom');
expect(container.getAttribute('class')).toEqual('nb-overlay-bottom');
});

it('render container in the top', () => {
element(placementTop).click();
const container = element(popover);
expect(container.isPresent()).toBeTruthy();
expect(container.getAttribute('class')).toEqual('top');
expect(container.getAttribute('class')).toEqual('nb-overlay-top');
});

it('render container in the left', () => {
element(placementLeft).click();
const container = element(popover);
expect(container.isPresent()).toBeTruthy();
expect(container.getAttribute('class')).toEqual('left');
expect(container.getAttribute('class')).toEqual('nb-overlay-left');
});

it('open popover by host click', () => {
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions scripts/gulp/tasks/bundle/rollup-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ const ROLLUP_GLOBALS = {
'@angular/common/testing': 'ng.common.testing',
'@angular/common/http/testing': 'ng.common.http.testing',
'@angular/cdk/overlay': 'ng.cdk.overlay',
'@angular/cdk/portal': 'ng.cdk.overlay',
'@angular/cdk/platform': 'ng.cdk.overlay',
'@angular/cdk/platform': 'ng.cdk.platform',
'@angular/cdk/portal': 'ng.cdk.portal',
'@angular/cdk/a11y': 'ng.cdk.a11y',


// RxJS dependencies
Expand Down
12 changes: 12 additions & 0 deletions src/framework/theme/components/cdk/a11y/a11y.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';

import { NbFocusTrapFactoryService } from './focus-trap';


@NgModule({
providers: [
NbFocusTrapFactoryService,
],
})
export class NbA11yModule {
}
49 changes: 49 additions & 0 deletions src/framework/theme/components/cdk/a11y/focus-trap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Inject, Injectable, NgZone } from '@angular/core';
import { FocusTrap, FocusTrapFactory, InteractivityChecker } from '@angular/cdk/a11y';

import { NB_DOCUMENT } from '../../../theme.options';


/**
* Overrides angular cdk focus trap to keep restore functionality inside trap.
* */
export class NbFocusTrap extends FocusTrap {
protected previouslyFocusedElement: HTMLElement;

constructor(
protected element: HTMLElement,
protected checker: InteractivityChecker,
protected ngZone: NgZone,
protected document: Document,
deferAnchors) {
super(element, checker, ngZone, document, deferAnchors);
this.savePreviouslyFocusedElement();
}

restoreFocus() {
this.previouslyFocusedElement.focus();
this.destroy();
}

blurPreviouslyFocusedElement() {
this.previouslyFocusedElement.blur();
}

protected savePreviouslyFocusedElement() {
this.previouslyFocusedElement = this.document.activeElement as HTMLElement;
}
}

@Injectable()
export class NbFocusTrapFactoryService extends FocusTrapFactory {
constructor(
protected checker: InteractivityChecker,
protected ngZone: NgZone,
@Inject(NB_DOCUMENT) private document) {
super(checker, ngZone, document);
}

create(element: HTMLElement, deferCaptureElements?: boolean): NbFocusTrap {
return new NbFocusTrap(element, this.checker, this.ngZone, this.document, deferCaptureElements);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ import { NbViewportRulerAdapter } from './viewport-ruler-adapter';
{ provide: ScrollDispatcher, useClass: NbScrollDispatcherAdapter },
],
})
export class NbAdapterModule {
export class NbCdkAdapterModule {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { NbLayoutScrollService } from '../../../services/scroll.service';

@Injectable()
export class NbScrollDispatcherAdapter extends ScrollDispatcher {
constructor(_ngZone: NgZone, _platform: NbPlatform, protected scrollService: NbLayoutScrollService) {
super(_ngZone, _platform);
constructor(ngZone: NgZone, platform: NbPlatform, protected scrollService: NbLayoutScrollService) {
super(ngZone, platform);
}

scrolled(auditTimeInMs?: number): Observable<CdkScrollable | void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ import { NbLayoutScrollService, NbScrollPosition } from '../../../services/scrol

@Injectable()
export class NbViewportRulerAdapter extends ViewportRuler {
constructor(_platform: NbPlatform, ngZone: NgZone,
constructor(platform: NbPlatform, ngZone: NgZone,
protected ruler: NbLayoutRulerService,
protected scroll: NbLayoutScrollService) {
super(_platform, ngZone);
super(platform, ngZone);
}

getViewportSize(): Readonly<{ width: number; height: number; }> {
let res;
/*
* getDimensions call is really synchronous operation.
* And we have to conform with the interface of the original service.
* */
this.ruler.getDimensions()
.pipe(map(dimensions => ({ width: dimensions.clientWidth, height: dimensions.clientHeight })))
.subscribe(rect => res = rect);
Expand All @@ -25,6 +29,10 @@ export class NbViewportRulerAdapter extends ViewportRuler {

getViewportScrollPosition(): { left: number; top: number } {
let res;
/*
* getPosition call is really synchronous operation.
* And we have to conform with the interface of the original service.
* */
this.scroll.getPosition()
.pipe(map((position: NbScrollPosition) => ({ top: position.y, left: position.x })))
.subscribe(position => res = position);
Expand Down
6 changes: 5 additions & 1 deletion src/framework/theme/components/cdk/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
export * from './overlay/mapping';
export * from './overlay';
export * from './a11y/a11y.module';
export * from './a11y/focus-trap';
export * from './adapter/overlay-container-adapter';
export * from './adapter/scroll-dispatcher-adapter';
export * from './adapter/viewport-ruler-adapter';
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@import '~@angular/cdk/overlay-prebuilt.css';

@mixin nb-overlay-theme {
.overlay-backdrop {
background: rgba(0, 0, 0, 0.288);
background: nb-theme(overlay-backdrop-bg);
}
}
1 change: 1 addition & 0 deletions src/framework/theme/components/cdk/overlay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './overlay-position';
export * from './overlay-container';
export * from './overlay-trigger';
export * from './mapping';
export * from './position-helper';
33 changes: 26 additions & 7 deletions src/framework/theme/components/cdk/overlay/mapping.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import { Directive, Injectable, NgModule, TemplateRef, ViewContainerRef } from '@angular/core';
import { CdkPortal, ComponentPortal, Portal, PortalModule, TemplatePortal } from '@angular/cdk/portal';
import {
CdkPortal,
CdkPortalOutlet,
ComponentPortal,
Portal,
PortalInjector,
PortalModule,
TemplatePortal,
} from '@angular/cdk/portal';
import {
ComponentType,
ConnectedOverlayPositionChange,
ConnectedPosition,
ConnectionPositionPair,
FlexibleConnectedPositionStrategy,
GlobalPositionStrategy,
Overlay,
OverlayConfig,
OverlayContainer,
OverlayModule,
OverlayPositionBuilder,
OverlayRef,
PositionStrategy, ScrollStrategy,
PositionStrategy,
ScrollStrategy,
ScrollStrategyOptions,
} from '@angular/cdk/overlay';
import { Platform } from '@angular/cdk/platform';

Expand All @@ -21,8 +31,12 @@ import { Platform } from '@angular/cdk/platform';
export class NbPortalDirective extends CdkPortal {
}

@Directive({ selector: '[nbPortalOutlet]' })
export class NbPortalOutletDirective extends CdkPortalOutlet {
}

@Injectable()
export class NbOverlayService extends Overlay {
export class NbOverlay extends Overlay {
}

@Injectable()
Expand All @@ -48,20 +62,24 @@ export class NbOverlayContainer extends OverlayContainer {
export class NbFlexibleConnectedPositionStrategy extends FlexibleConnectedPositionStrategy {
}

export class NbPortalInjector extends PortalInjector {
}

export type NbPortal<T = any> = Portal<T>;
export type NbOverlayRef = OverlayRef;
export type NbComponentType<T = any> = ComponentType<T>;
export type NbGlobalPositionStrategy = GlobalPositionStrategy;
export type NbPositionStrategy = PositionStrategy;
export type NbConnectedPosition = ConnectedPosition;
export type NbConnectedOverlayPositionChange = ConnectedOverlayPositionChange;
export type NbConnectionPositionPair = ConnectionPositionPair;
export type NbOverlayConfig = OverlayConfig;
export type NbScrollStrategyOptions = ScrollStrategyOptions;
export type NbScrollStrategy = ScrollStrategy;

const CDK_MODULES = [OverlayModule, PortalModule];

const CDK_PROVIDERS = [
NbOverlayService,
NbOverlay,
NbPlatform,
NbOverlayPositionBuilder,
];
Expand All @@ -75,8 +93,9 @@ const CDK_PROVIDERS = [
exports: [
...CDK_MODULES,
NbPortalDirective,
NbPortalOutletDirective,
],
declarations: [NbPortalDirective],
declarations: [NbPortalDirective, NbPortalOutletDirective],
providers: [...CDK_PROVIDERS],
})
export class NbCdkMappingModule {
Expand Down
10 changes: 5 additions & 5 deletions src/framework/theme/components/cdk/overlay/overlay-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ import { NbPosition } from './overlay-position';
export abstract class NbPositionedContainer {
@Input() position: NbPosition;

@HostBinding('class.top')
@HostBinding('class.nb-overlay-top')
get top(): boolean {
return this.position === NbPosition.TOP
}

@HostBinding('class.right')
@HostBinding('class.nb-overlay-right')
get right(): boolean {
return this.position === NbPosition.RIGHT
}

@HostBinding('class.bottom')
@HostBinding('class.nb-overlay-bottom')
get bottom(): boolean {
return this.position === NbPosition.BOTTOM
}

@HostBinding('class.left')
@HostBinding('class.nb-overlay-left')
get left(): boolean {
return this.position === NbPosition.LEFT
}
Expand Down Expand Up @@ -54,7 +54,7 @@ export class NbOverlayContainerComponent {
if (this.isComponent) {
Object.assign(el._componentRef.instance, this.context);
/**
* Change detection have to performed here, because another way applied context
* Change detection has to be performed here, because another way applied context
* will be rendered on the next change detection loop and
* we'll have incorrect positioning. Because rendered component may change its size
* based on the context.
Expand Down
Loading

0 comments on commit 3fd8649

Please sign in to comment.