Skip to content

Commit

Permalink
refactor(ngrid): move registry to core package
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Since the registry and it's type mapping symbols are for intenral or plugin use they are now part of the core pacakge. Currently the single/multi directives are still in the main package but they might also be moved in a later phase
  • Loading branch information
shlomiassaf committed Dec 21, 2020
1 parent 2990511 commit 55e8f31
Show file tree
Hide file tree
Showing 38 changed files with 69 additions and 69 deletions.
6 changes: 2 additions & 4 deletions apps/libs/docs-app-lib/lib/pbl-docs-app-shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { MatSidenavModule } from '@angular/material/sidenav';
import { FlexModule } from '@angular/flex-layout/flex';
import { ExtendedModule } from '@angular/flex-layout/extended';

import { PblNgridModule, PblNgridRegistryService } from '@pebula/ngrid';
import { PblNgridModule } from '@pebula/ngrid';
import { PblTocModule } from '@pebula/apps/docs-app-lib/toc.module';

import {
Expand Down Expand Up @@ -94,9 +94,7 @@ const MATERIAL_IMPORTS = [

PblNgridModule
],
providers: [
PblNgridRegistryService,
],
providers: [ ],
})
export class PblDocsAppSharedModule {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatRadioModule } from '@angular/material/radio';

import { PblNgridModule, PblNgridRegistryService } from '@pebula/ngrid';
import { PblNgridRegistryService } from '@pebula/ngrid/core';
import { PblNgridModule } from '@pebula/ngrid';
import { PblNgridDragModule } from '@pebula/ngrid/drag';
import { PblNgridTargetEventsModule } from '@pebula/ngrid/target-events';
import { PblNgridBlockUiModule } from '@pebula/ngrid/block-ui';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { MatRadioModule } from '@angular/material/radio';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';

import { PblNgridModule, PblNgridRegistryService } from '@pebula/ngrid';
import { PblNgridRegistryService } from '@pebula/ngrid/core';
import { PblNgridModule } from '@pebula/ngrid';
import { PblNgridDragModule } from '@pebula/ngrid/drag';
import { PblNgridTargetEventsModule } from '@pebula/ngrid/target-events';
import { PblNgridBlockUiModule } from '@pebula/ngrid/block-ui';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { CommonModule } from '@angular/common';
import { MatIconModule } from '@angular/material/icon';
import { MatChipsModule } from '@angular/material/chips';

import { PblNgridModule, PblNgridRegistryService } from '@pebula/ngrid';
import { PblNgridRegistryService } from '@pebula/ngrid/core';
import { PblNgridModule } from '@pebula/ngrid';
import { PblNgridDragModule } from '@pebula/ngrid/drag';
import { PblNgridTargetEventsModule } from '@pebula/ngrid/target-events';
import { PblNgridBlockUiModule } from '@pebula/ngrid/block-ui';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { MatSliderModule } from '@angular/material/slider';
import { MatRadioModule } from '@angular/material/radio';
import { MatCheckboxModule } from '@angular/material/checkbox';

import { PblNgridModule, PblNgridRegistryService } from '@pebula/ngrid';
import { PblNgridRegistryService } from '@pebula/ngrid/core';
import { PblNgridModule } from '@pebula/ngrid';
import { PblNgridDragModule } from '@pebula/ngrid/drag';
import { PblNgridTargetEventsModule } from '@pebula/ngrid/target-events';
import { PblNgridBlockUiModule } from '@pebula/ngrid/block-ui';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { MatMenuModule } from '@angular/material/menu';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';

import { PblNgridModule, PblNgridConfigService, PblNgridRegistryService, ngridPlugin } from '@pebula/ngrid';
import { PblNgridRegistryService } from '@pebula/ngrid/core';
import { PblNgridModule, PblNgridConfigService, ngridPlugin } from '@pebula/ngrid';
import { PblNgridOverlayPanelModule, PblNgridOverlayPanelComponentExtension } from '@pebula/ngrid/overlay-panel';

import { MatHeaderContextMenuTrigger } from './header-context/header-context-menu-trigger';
Expand Down
3 changes: 2 additions & 1 deletion libs/ngrid-material/sort/src/lib/mat-sort.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { CommonModule } from '@angular/common';
import { MatSortModule, MatSortHeader } from '@angular/material/sort';
import { MatButtonModule } from '@angular/material/button';

import { PblNgridModule, PblNgridRegistryService, ngridPlugin } from '@pebula/ngrid';
import { PblNgridRegistryService } from '@pebula/ngrid/core';
import { PblNgridModule, ngridPlugin } from '@pebula/ngrid';
import { PblNgridMatSortDirective, PLUGIN_KEY } from './mat-sort.directive';
import { MatSortExtension } from './mat-sort-component-extension';

Expand Down
5 changes: 3 additions & 2 deletions libs/ngrid/block-ui/src/lib/block-ui/directives.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// tslint:disable:use-host-property-decorator
import { Directive, TemplateRef } from '@angular/core';
import { PblNgridComponent, PblNgridRegistryService, PblNgridSingleTemplateRegistry } from '@pebula/ngrid';
import { PblNgridRegistryService } from '@pebula/ngrid/core';
import { PblNgridComponent, PblNgridSingleTemplateRegistry } from '@pebula/ngrid';

declare module '@pebula/ngrid/lib/grid/registry/types' {
declare module '@pebula/ngrid/core/lib/registry/types' {
interface PblNgridSingleRegistryMap {
blocker?: PblNgridBlockUiDefDirective;
}
Expand Down
1 change: 1 addition & 0 deletions libs/ngrid/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './lib/events/index';
export * from './lib/paginator/index';
export * from './lib/registry/index';
export * from './lib/utils/index';
2 changes: 2 additions & 0 deletions libs/ngrid/core/src/lib/registry/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './types';
export * from './registry.service';
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { Subject, Observable } from 'rxjs';
import {
Injectable,
Optional,
SkipSelf,
OnDestroy,
} from '@angular/core';
import { unrx } from '@pebula/ngrid/core';
import { Injectable, Optional, SkipSelf, OnDestroy } from '@angular/core';

import { unrx } from '../utils/unrx';
import {
PblNgridMultiRegistryMap,
PblNgridSingleRegistryMap,
Expand Down Expand Up @@ -45,9 +40,9 @@ export class PblNgridRegistryService implements OnDestroy {

protected root: PblNgridRegistryService & { bufferedData?: RegistryChangedEvent[] };

protected _multi: { [K in keyof PblNgridMultiRegistryMap]: Array<PblNgridMultiRegistryMap[K]> } = {};
protected _multiDefaults: PblNgridMultiRegistryMap = {};
protected _singles: PblNgridSingleRegistryMap = {};
protected _multi: { [K in keyof PblNgridMultiRegistryMap]: Array<PblNgridMultiRegistryMap[K]> } = { } as any;
protected _multiDefaults: PblNgridMultiRegistryMap = {} as any;
protected _singles: PblNgridSingleRegistryMap = {} as any;

protected readonly changes$: Subject<RegistryChangedEvent[]>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ export interface RegistryChangedEvent {
/**
* A map of valid single-item value that can be registered, and their type.
*/
export interface PblNgridSingleRegistryMap { } // tslint:disable-line: no-empty-interface
export interface PblNgridSingleRegistryMap {
'*': any;
}

/**
* A map of valid multi-item value that can be registered, and their type (the single type, i.e. T in Array<T>)
*/
export interface PblNgridMultiRegistryMap { } // tslint:disable-line: no-empty-interface

export interface PblNgridMultiRegistryMap {
'*': any;
}
6 changes: 3 additions & 3 deletions libs/ngrid/detail-row/src/lib/detail-row/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
TemplateRef,
Input,
} from '@angular/core';
import { BooleanInput } from '@angular/cdk/coercion';

import { PblNgridRegistryService, PblNgridSingleTemplateRegistry, PblNgridRowContext, PblNgridRowDef } from '@pebula/ngrid';
import { PblNgridRegistryService } from '@pebula/ngrid/core';
import { PblNgridSingleTemplateRegistry, PblNgridRowContext, PblNgridRowDef } from '@pebula/ngrid';

declare module '@pebula/ngrid/lib/grid/registry/types' {
declare module '@pebula/ngrid/core/lib/registry/types' {
interface PblNgridSingleRegistryMap {
detailRowParent?: PblNgridDetailRowParentRefDirective<any>;
detailRow?: PblNgridDetailRowDefDirective;
Expand Down
3 changes: 2 additions & 1 deletion libs/ngrid/drag/src/lib/column-resize/cell-resizer-ref.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Directive, TemplateRef } from '@angular/core';
import { PblNgridRegistryService, PblNgridMultiTemplateRegistry, PblNgridDataHeaderExtensionRef, PblNgridDataHeaderExtensionContext } from '@pebula/ngrid';
import { PblNgridRegistryService } from '@pebula/ngrid/core';
import { PblNgridMultiTemplateRegistry, PblNgridDataHeaderExtensionRef, PblNgridDataHeaderExtensionContext } from '@pebula/ngrid';

/**
* Marks the element as the resizer template for cells.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Directive, TemplateRef } from '@angular/core';
import { PblNgridRegistryService } from '@pebula/ngrid/core';
import {
PblNgridRegistryService,
PblNgridMultiTemplateRegistry,
PblNgridDataHeaderExtensionRef,
PblNgridDataHeaderExtensionContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {

import { PblNgridRowDef } from '@pebula/ngrid';

declare module '@pebula/ngrid/lib/grid/registry/types' {
declare module '@pebula/ngrid/core/lib/registry/types' {
interface PblNgridSingleRegistryMap {
infiniteVirtualRow?: PblNgridInfiniteVirtualRowRefDirective;
}
Expand Down
3 changes: 2 additions & 1 deletion libs/ngrid/overlay-panel/src/lib/overlay-panel-def.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Directive, TemplateRef, Input } from '@angular/core';
import { PblNgridComponent, PblNgridMultiTemplateRegistry, PblNgridRegistryService } from '@pebula/ngrid';
import { PblNgridRegistryService } from '@pebula/ngrid/core';
import { PblNgridComponent, PblNgridMultiTemplateRegistry } from '@pebula/ngrid';
import { PblNgridOverlayPanelRef } from './overlay-panel-ref';

export interface PblNgridOverlayPanelContext<T = any> {
Expand Down
2 changes: 1 addition & 1 deletion libs/ngrid/overlay-panel/src/lib/overlay-panel.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { PblNgridOverlayPanelComponentExtension } from './component-registry-ext
import { PblNgridOverlayPanelRef } from './overlay-panel-ref';
import { PblNgridOverlayPanelContext } from './overlay-panel-def';

declare module '@pebula/ngrid/lib/grid/registry/types' {
declare module '@pebula/ngrid/core/lib/registry/types' {
interface PblNgridMultiRegistryMap {
overlayPanels?:
| PblNgridMultiTemplateRegistry<any, 'overlayPanels'>
Expand Down
1 change: 0 additions & 1 deletion libs/ngrid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export {
PblNgridRowDef, PblNgridRowOverride, PblNgridRowComponent, PblNgridColumnRowComponent, PblNgridMetaRowComponent,

PblNgridComponent,
PblNgridRegistryService,
AutoSizeToFitOptions, ColumnApi,

PblNgridSingleTemplateRegistry, PblNgridMultiTemplateRegistry, PblNgridMultiComponentRegistry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
OnInit,
OnDestroy,
} from '@angular/core';
import { PblNgridRegistryService } from '@pebula/ngrid/core';

import { PblColumnTypeDefinitionDataMap } from '../../column/model';
import { PblNgridRegistryService } from '../../registry';
import { PblNgridCellDefDirectiveBase } from './types';

@Directive()
Expand Down
4 changes: 2 additions & 2 deletions libs/ngrid/src/lib/grid/cell/cell-def/cell-def.directive.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// tslint:disable:use-input-property-decorator
import { Directive, TemplateRef } from '@angular/core';
import { PblNgridRegistryService } from '@pebula/ngrid/core';

import { PblColumnTypeDefinitionDataMap } from '../../column/model';
import { PblNgridCellContext } from '../../context/index';
import { PblNgridRegistryService } from '../../registry/registry.service';
import { PblNgridBaseCellDef } from './base-cell-def.directive';

/**
Expand Down Expand Up @@ -41,7 +41,7 @@ export class PblNgridCellDefDirective<T, P extends keyof PblColumnTypeDefinition
}
}

declare module '../../registry/types' {
declare module '@pebula/ngrid/core/lib/registry/types' {
interface PblNgridMultiRegistryMap {
tableCell?: PblNgridCellDefDirective<any>;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Directive, TemplateRef } from '@angular/core';
import { PblNgridRegistryService } from '@pebula/ngrid/core';

import { PblColumnTypeDefinitionDataMap } from '../../column/model';
import { PblNgridCellContext } from '../../context/index';
import { PblNgridRegistryService } from '../../registry/registry.service';
import { PblNgridBaseCellDef } from './base-cell-def.directive';

@Directive({
Expand All @@ -26,7 +26,7 @@ export class PblNgridEditorCellDefDirective<T, P extends keyof PblColumnTypeDefi
}
}

declare module '../../registry/types' {
declare module '@pebula/ngrid/core/lib/registry/types' {
interface PblNgridMultiRegistryMap {
editorCell?: PblNgridEditorCellDefDirective<any>;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Directive, TemplateRef } from '@angular/core';
import { PblNgridRegistryService } from '@pebula/ngrid/core';

import { PblNgridMetaCellContext } from '../../context/index';
import { PblNgridRegistryService } from '../../registry/registry.service';
import { PblNgridBaseCellDef } from './base-cell-def.directive';

@Directive({
Expand All @@ -24,7 +24,7 @@ export class PblNgridFooterCellDefDirective<T> extends PblNgridBaseCellDef<PblNg
}
}

declare module '../../registry/types' {
declare module '@pebula/ngrid/core/lib/registry/types' {
interface PblNgridMultiRegistryMap {
footerCell?: PblNgridFooterCellDefDirective<any>;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// tslint:disable:use-input-property-decorator
import { Directive, TemplateRef } from '@angular/core';
import { PblNgridRegistryService } from '@pebula/ngrid/core';

import { PblNgridMetaCellContext } from '../../context/index';
import { PblNgridRegistryService } from '../../registry/registry.service';
import { PblNgridBaseCellDef } from './base-cell-def.directive';

/**
Expand Down Expand Up @@ -40,7 +40,7 @@ export class PblNgridHeaderCellDefDirective<T> extends PblNgridBaseCellDef<PblNg
}
}

declare module '../../registry/types' {
declare module '@pebula/ngrid/core/lib/registry/types' {
interface PblNgridMultiRegistryMap {
headerCell?: PblNgridHeaderCellDefDirective<any>;
}
Expand Down
3 changes: 2 additions & 1 deletion libs/ngrid/src/lib/grid/cell/cell-def/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PblNgridRegistryService } from '@pebula/ngrid/core';

import { PblColumn, PblMetaColumn, COLUMN, isPblColumn } from '../../column/model';
import { PblNgridRegistryService } from '../../registry';
import { PblNgridHeaderCellDefDirective } from './header-cell-def.directive';
import { PblNgridCellDefDirective } from './cell-def.directive';
import { PblNgridFooterCellDefDirective } from './footer-cell-def.directive';
Expand Down
6 changes: 3 additions & 3 deletions libs/ngrid/src/lib/grid/cell/header-cell.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import {
EmbeddedViewRef,
Inject,
} from '@angular/core';
import { unrx } from '@pebula/ngrid/core';
import { unrx, PblNgridMultiRegistryMap } from '@pebula/ngrid/core';

import { EXT_API_TOKEN, PblNgridInternalExtensionApi } from '../../ext/grid-ext-api';
import { PblNgridComponent } from '../ngrid.component';
import { COLUMN, PblMetaColumn, PblColumn, PblColumnGroup, isPblColumn, isPblColumnGroup } from '../column/model';
import { COLUMN, PblMetaColumn, PblColumn } from '../column/model';
import { MetaCellContext, PblNgridMetaCellContext } from '../context/index';
import { PblNgridMultiRegistryMap, PblNgridDataHeaderExtensionContext, PblNgridMultiComponentRegistry, PblNgridMultiTemplateRegistry } from '../registry';
import { PblNgridDataHeaderExtensionContext, PblNgridMultiComponentRegistry, PblNgridMultiTemplateRegistry } from '../registry';
import { PblNgridColumnDef, WidthChangeEvent } from '../column/directives/column-def';
import { applySourceWidth, applyWidth, initCellElement } from './utils';
import { PblNgridBaseCell } from './base-cell';
Expand Down
2 changes: 1 addition & 1 deletion libs/ngrid/src/lib/grid/column/management/column-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '../model';
import { StaticColumnWidthLogic } from '../width-logic/static-column-width';
import { resetColumnWidths } from '../../utils/width';
import { PblColumnStoreMetaRow, PblMetaColumnStore, PblRowColumnsChangeEvent, PblRowTypeToColumnTypeMap } from './types';
import { PblMetaColumnStore, PblRowColumnsChangeEvent, PblRowTypeToColumnTypeMap } from './types';
import { HiddenColumns } from './hidden-columns';
import { GridRowType } from '../../row/types';
import { PblNgridBaseRowComponent } from '../../row/base-row.component';
Expand Down
1 change: 0 additions & 1 deletion libs/ngrid/src/lib/grid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export {
} from './row';

export {
PblNgridRegistryService,
PblNgridHeaderExtensionRefDirective,
PblNgridNoDataRefDirective,
PblNgridPaginatorRefDirective,
Expand Down
3 changes: 1 addition & 2 deletions libs/ngrid/src/lib/grid/ngrid.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Direction, Directionality } from '@angular/cdk/bidi';
import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
import { CdkHeaderRowDef, CdkFooterRowDef, CdkRowDef } from '@angular/cdk/table';

import { PblNgridPaginatorKind, unrx } from '@pebula/ngrid/core';
import { PblNgridRegistryService, PblNgridPaginatorKind, unrx } from '@pebula/ngrid/core';

import { EXT_API_TOKEN, PblNgridExtensionApi, PblNgridInternalExtensionApi } from '../ext/grid-ext-api';
import { PblNgridPluginController, PblNgridPluginContext } from '../ext/plugin-control';
Expand All @@ -37,7 +37,6 @@ import { PblCdkTableComponent } from './pbl-cdk-table/pbl-cdk-table.component';
import { PblColumn, PblNgridColumnSet, PblNgridColumnDefinitionSet } from './column/model';
import { PblColumnStore, ColumnApi, AutoSizeToFitOptions } from './column/management';
import { PblNgridCellContext, PblNgridMetaCellContext, PblNgridContextApi, PblNgridRowContext } from './context/index';
import { PblNgridRegistryService } from './registry/registry.service';
import { PblNgridConfigService } from './services/config';
import { DynamicColumnWidthLogic } from './column/width-logic/dynamic-column-width';
import { PblCdkVirtualScrollViewportComponent } from './features/virtual-scroll/virtual-scroll-viewport.component';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Directive, TemplateRef, Injector, Input } from '@angular/core';
import { PblNgridRegistryService } from '@pebula/ngrid/core';

import { PblColumn } from '../../column/model';
import { MetaCellContext } from '../../context/index';
import { PblNgridHeaderCellComponent } from '../../cell/header-cell.component'
import { PblNgridRegistryService } from '../registry.service';
import { PblNgridMultiTemplateRegistry } from './multi-template.directives';
import { PblNgridMultiComponentRegistry } from './multi-component';

Expand Down Expand Up @@ -80,7 +80,7 @@ export class PblNgridHeaderExtensionRefDirective extends PblNgridMultiTemplateRe
constructor(tRef: TemplateRef<PblNgridDataHeaderExtensionContext>, registry: PblNgridRegistryService) { super(tRef, registry); }
}

declare module '../types' {
declare module '@pebula/ngrid/core/lib/registry/types' {
interface PblNgridMultiRegistryMap {
dataHeaderExtensions?: (PblNgridMultiTemplateRegistry<PblNgridDataHeaderExtensionContext, 'dataHeaderExtensions'> & PblNgridDataHeaderExtensionRef)
| (PblNgridMultiComponentRegistry<any, 'dataHeaderExtensions'> & PblNgridDataHeaderExtensionRef);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ComponentFactory, ComponentRef } from '@angular/core';
import { PblNgridMultiRegistryMap } from '@pebula/ngrid/core';

import { PblColumn } from '../../column/model';
import { PblNgridMetaCellContext } from '../../context/index';
import { PblNgridMultiRegistryMap } from '../types';

export abstract class PblNgridMultiComponentRegistry<T, TKind extends keyof PblNgridMultiRegistryMap> {
abstract readonly name: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Directive, TemplateRef, OnInit, OnDestroy } from '@angular/core';

import { PblNgridMultiRegistryMap } from '../types';
import { PblNgridRegistryService } from '../registry.service';
import { PblNgridRegistryService, PblNgridMultiRegistryMap } from '@pebula/ngrid/core';

@Directive()
export abstract class PblNgridMultiTemplateRegistry<T, TKind extends keyof PblNgridMultiRegistryMap> implements OnInit, OnDestroy {
Expand Down
Loading

0 comments on commit 55e8f31

Please sign in to comment.