Skip to content

Commit

Permalink
refactor(ngrid): move configuration symbols to core package
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
To reduce clutter in the main packge the configuration symbols moved to `@pebula/ngrid/core`.
At this point all symbols were re-exported from the main module so this no effect there. However, if you've extended on of the symbols using augmentation you will need to update the augmentation module path.
  • Loading branch information
shlomiassaf committed Dec 21, 2020
1 parent 33d2bca commit fc259ba
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 48 deletions.
4 changes: 2 additions & 2 deletions apps/ngrid-docs-app/content/extending-ngrid/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ The answer is using the grid created event, which fires every time a new grid in
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ON_INIT } from '@pebula/ngrid/core';
import { PblNgridModule, PblNgridConfigService, PblNgridPluginController } from '@pebula/ngrid';
import { ON_INIT, PblNgridConfigService } from '@pebula/ngrid/core';
import { PblNgridModule, PblNgridPluginController } from '@pebula/ngrid';
import { PblNgridTargetEventsModule } from '@pebula/ngrid/target-events';

import { PLUGIN_KEY, PblNgridClipboardPlugin } from './clipboard.plugin';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import { ScrollDispatcher } from '@angular/cdk/scrolling';
import { Platform} from '@angular/cdk/platform';
import { TooltipPosition, MatTooltipDefaultOptions, MatTooltip, MAT_TOOLTIP_SCROLL_STRATEGY, MAT_TOOLTIP_DEFAULT_OPTIONS } from '@angular/material/tooltip';

import { unrx } from '@pebula/ngrid/core';
import { PblNgridComponent, PblNgridPluginController, PblNgridConfigService } from '@pebula/ngrid';
import { unrx, PblNgridConfigService } from '@pebula/ngrid/core';
import { PblNgridComponent, PblNgridPluginController } from '@pebula/ngrid';
import { PblNgridCellEvent } from '@pebula/ngrid/target-events';

declare module '@pebula/ngrid/lib/grid/services/config' {
declare module '@pebula/ngrid/core/lib/configuration/type' {
interface PblNgridConfig {
cellTooltip?: CellTooltipOptions & {
/** When set to true will apply the default cell tooltip to ALL tables */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { CommonModule } from '@angular/common';
import { OverlayModule } from '@angular/cdk/overlay';
import { MatTooltipModule } from '@angular/material/tooltip';

import { PblNgridModule, PblNgridPluginController, PblNgridConfigService, ngridPlugin } from '@pebula/ngrid';
import { PblNgridConfigService } from '@pebula/ngrid/core';
import { PblNgridModule, PblNgridPluginController, ngridPlugin } from '@pebula/ngrid';
import { PblNgridTargetEventsModule } from '@pebula/ngrid/target-events';

import { PblNgridCellTooltipDirective, PLUGIN_KEY } from './cell-tooltip.directive';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { MatMenuModule } from '@angular/material/menu';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';

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

import { MatHeaderContextMenuTrigger } from './header-context/header-context-menu-trigger';
Expand Down
2 changes: 1 addition & 1 deletion libs/ngrid/clipboard/src/lib/clipboard.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ declare module '@pebula/ngrid/lib/ext/types' {
}
}

declare module '@pebula/ngrid/lib/grid/services/config' {
declare module '@pebula/ngrid/core/lib/configuration/type' {
interface PblNgridConfig {
clipboard?: {
/** When set to true will enable the clipboard plugin on all grid instances by default. */
Expand Down
1 change: 1 addition & 0 deletions libs/ngrid/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './lib/registry/index';
export * from './lib/utils/index';
export * from './lib/models/column';
export * from './lib/data-source/index';
export * from './lib/configuration/index';
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import { Observable, ReplaySubject } from 'rxjs';

import { Inject, Injectable, InjectionToken, Optional } from '@angular/core';

export interface PblNgridConfig {
table?: {
showHeader?: boolean;
showFooter?: boolean;
noFiller?: boolean;
clearContextOnSourceChanging?: boolean;
}
}
import { PblNgridConfig } from './type';

const DEFAULT_TABLE_CONFIG: PblNgridConfig['table'] = {
showHeader: true,
Expand All @@ -20,9 +11,7 @@ const DEFAULT_TABLE_CONFIG: PblNgridConfig['table'] = {

export const PEB_NGRID_CONFIG = new InjectionToken<PblNgridConfig>('PEB_NGRID_CONFIG');

@Injectable({
providedIn: 'root',
})
@Injectable({ providedIn: 'root' })
export class PblNgridConfigService {

private config = new Map<keyof PblNgridConfig, any>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './type';
export * from './config';
8 changes: 8 additions & 0 deletions libs/ngrid/core/src/lib/configuration/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface PblNgridConfig {
table?: {
showHeader?: boolean;
showFooter?: boolean;
noFiller?: boolean;
clearContextOnSourceChanging?: boolean;
}
}
5 changes: 3 additions & 2 deletions libs/ngrid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { isPblColumn, isPblMetaColumn, isPblColumnGroup } from './lib/grid/index
/* Some symbols in `@pebula/ngrid/core` are also used by "regular" users of ngrid (as opposed to internal/plugin use) so we need to re-export them
from the main package so "regular" user will not have to specifically address `@pebula/ngrid/core` */
export {
// Configuration
PEB_NGRID_CONFIG, PblNgridConfig, PblNgridConfigService,

// Pagination
PblNgridPaginatorKind, PblPaginator, PblPaginatorChangeEvent,

Expand Down Expand Up @@ -32,8 +35,6 @@ export {
} from '@pebula/ngrid/core';

export {
PEB_NGRID_CONFIG, PblNgridConfig, PblNgridConfigService,

PblColumn, PblMetaColumn, PblColumnGroup, PblColumnFactory, COLUMN, columnFactory,
isPblMetaColumn, isPblColumnGroup, isPblColumn,

Expand Down
3 changes: 1 addition & 2 deletions libs/ngrid/src/lib/ext/grid-ext-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Observable } from 'rxjs';
import { InjectionToken } from '@angular/core';
import { Direction } from '@angular/cdk/bidi';

import { PblNgridEvents } from '@pebula/ngrid/core';
import { PblNgridConfigService, PblNgridEvents } from '@pebula/ngrid/core';
import { PblCdkTableComponent } from '../grid/pbl-cdk-table/pbl-cdk-table.component';
import { ContextApi } from '../grid/context/api';
import { PblNgridComponent } from '../grid/ngrid.component';
Expand All @@ -12,7 +12,6 @@ import { PblCdkVirtualScrollViewportComponent } from '../grid/features/virtual-s
import { NotifyPropChangeMethod, OnPropChangedEvent } from './types';
import { PblNgridMetaRowService } from '../grid/meta-rows/meta-row.service';
import { RowsApi, PblRowsApi } from '../grid/row';
import { PblNgridConfigService } from '../grid/services/config';
import { PblNgridPluginContext, PblNgridPluginController } from './plugin-control';

export const EXT_API_TOKEN = new InjectionToken('PBL_NGRID_EXTERNAL_API');
Expand Down
3 changes: 1 addition & 2 deletions libs/ngrid/src/lib/grid/api-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Observable, of, Subject, EMPTY } from 'rxjs';
import { ChangeDetectorRef, ElementRef, Injector, IterableDiffers, NgZone, ViewContainerRef } from '@angular/core';
import { Direction, Directionality } from '@angular/cdk/bidi';

import { PblNgridEvents, ON_DESTROY, ON_CONSTRUCTED } from '@pebula/ngrid/core';
import { PblNgridConfigService, PblNgridEvents, ON_DESTROY, ON_CONSTRUCTED } from '@pebula/ngrid/core';
import { PblNgridInternalExtensionApi } from '../ext/grid-ext-api';
import { ColumnApi, PblColumnStore } from './column/management';
import { PblNgridComponent } from './ngrid.component';
Expand All @@ -15,7 +15,6 @@ import { PblNgridMetaRowService } from './meta-rows/meta-row.service';
import { PblNgridPluginContext } from '../ext/plugin-control';
import { OnPropChangedEvent } from '../ext/types';
import { PblCdkVirtualScrollViewportComponent } from './features/virtual-scroll/virtual-scroll-viewport.component';
import { PblNgridConfigService } from './services/config';
import { bindGridToDataSource } from './bind-grid-to-datasource';

export interface RequiredAngularTokens {
Expand Down
3 changes: 1 addition & 2 deletions libs/ngrid/src/lib/grid/features/virtual-scroll/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { EmbeddedViewRef, ViewContainerRef } from '@angular/core';
import { ListRange } from '@angular/cdk/collections';

import { PblNgridConfigService } from '../../services/config';
import { PblNgridConfigService } from '@pebula/ngrid/core';
import { PblNgridVirtualScrollStrategy } from './strategies/types';

export type StickyDirectionVt = 'top' | 'bottom';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ import {
CdkVirtualForOf,
ViewportRuler,
} from '@angular/cdk/scrolling';
import { unrx } from '@pebula/ngrid/core';
import { PblNgridConfigService, unrx } from '@pebula/ngrid/core';

import { PblNgridConfigService } from '../../services/config';
import { PblNgridComponent } from '../../ngrid.component';
import { PblNgridBaseVirtualScrollDirective } from './strategies/base-v-scroll.directive'
import { PblNgridVirtualScrollStrategy } from './strategies/types';
Expand All @@ -42,7 +41,7 @@ import { RowIntersectionTracker } from './row-intersection';
import { resolveScrollStrategy } from './utils';
import { VirtualScrollHightPaging } from './virtual-scroll-height-paging';

declare module '../../services/config' {
declare module '@pebula/ngrid/core/lib/configuration/type' {
interface PblNgridConfig {
virtualScroll?: {
wheelMode?: PblNgridBaseVirtualScrollDirective['wheelMode'];
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
@@ -1,4 +1,3 @@
export * from './services/index';
export * from './meta-rows/index';

export {
Expand Down
3 changes: 2 additions & 1 deletion libs/ngrid/src/lib/grid/ngrid.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coerci
import { CdkHeaderRowDef, CdkFooterRowDef, CdkRowDef } from '@angular/cdk/table';

import {
PblNgridConfigService,

PblNgridRegistryService,
PblNgridPaginatorKind,

Expand All @@ -45,7 +47,6 @@ import { PblCdkTableComponent } from './pbl-cdk-table/pbl-cdk-table.component';
import { PblColumn, PblNgridColumnSet, } from './column/model';
import { PblColumnStore, ColumnApi, AutoSizeToFitOptions } from './column/management';
import { PblNgridCellContext, PblNgridMetaCellContext, PblNgridContextApi, PblNgridRowContext } from './context/index';
import { PblNgridConfigService } from './services/config';
import { DynamicColumnWidthLogic } from './column/width-logic/dynamic-column-width';
import { PblCdkVirtualScrollViewportComponent } from './features/virtual-scroll/virtual-scroll-viewport.component';
import { PblNgridMetaRowService } from './meta-rows/meta-row.service';
Expand Down
6 changes: 4 additions & 2 deletions libs/ngrid/src/lib/ngrid.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import { CommonModule } from '@angular/common';
import { ScrollingModule as ScrollingModuleExp } from '@angular/cdk-experimental/scrolling';
import { ScrollingModule } from '@angular/cdk/scrolling';
import { CdkTableModule } from '@angular/cdk/table';
import { PblNgridRegistryService } from '@pebula/ngrid/core';
import {
PEB_NGRID_CONFIG, PblNgridConfig, PblNgridConfigService,
PblNgridRegistryService,
} from '@pebula/ngrid/core';

/**
* NOTE ABOUT IMPORTS
Expand Down Expand Up @@ -55,7 +58,6 @@ import { PblCdkAutoSizeVirtualScrollDirective } from './grid/features/virtual-s
import { PblCdkFixedSizedVirtualScrollDirective } from './grid/features/virtual-scroll/strategies/cdk-wrappers/v-scroll-fixed.directive';
import { PblNgridScrolling } from './grid/features/virtual-scroll/scrolling-plugin.directive';
import { PblNgridComponent } from './grid/ngrid.component';
import { PEB_NGRID_CONFIG, PblNgridConfig, PblNgridConfigService } from './grid/services/config';
import { PROVIDERS } from './di-factories';

export const COMMON_TABLE_TEMPLATE_INIT = new InjectionToken('COMMON TABLE TEMPLATE INIT');
Expand Down
3 changes: 2 additions & 1 deletion libs/ngrid/state/src/lib/ngrid-state.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { PblNgridPluginController, PblNgridModule, PblNgridConfigService, ngridPlugin } from '@pebula/ngrid';
import { PblNgridConfigService } from '@pebula/ngrid/core';
import { PblNgridPluginController, PblNgridModule, ngridPlugin } from '@pebula/ngrid';

import { registerBuiltInHandlers } from './core/built-in-handlers/_register';
import { PblNgridStatePlugin, PblNgridStatePluginDirective, PLUGIN_KEY } from './state-plugin';
Expand Down
2 changes: 1 addition & 1 deletion libs/ngrid/state/src/lib/state-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { hasState, saveState, loadState, PblNgridStateLoadOptions, PblNgridState

import { userSessionPref } from './presets';

declare module '@pebula/ngrid/lib/grid/services/config' {
declare module '@pebula/ngrid/core/lib/configuration/type' {
interface PblNgridConfig {
state?: {
/** When set to true will enable the state plugin on all table instances by default. */
Expand Down
7 changes: 4 additions & 3 deletions libs/ngrid/sticky/src/lib/sticky.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { CdkTableModule } from '@angular/cdk/table';
import { PblNgridModule, PblNgridPluginController, PblNgridConfigService, ngridPlugin } from '@pebula/ngrid';
import { PblNgridConfigService } from '@pebula/ngrid/core';

import { PblNgridModule, PblNgridPluginController, ngridPlugin } from '@pebula/ngrid';
import { PblNgridStickyPluginDirective, setStickyRow, setStickyColumns, PLUGIN_KEY } from './sticky/sticky-plugin';

declare module '@pebula/ngrid/lib/grid/services/config' {
declare module '@pebula/ngrid/core/lib/configuration/type' {
interface PblNgridConfig {
stickyPlugin?: {
headers?: Array<'table' | number>;
Expand Down
4 changes: 2 additions & 2 deletions libs/ngrid/target-events/src/lib/target-events.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { CdkTableModule } from '@angular/cdk/table';
import { PblNgridModule, PblNgridPluginController, PblNgridConfigService, ngridPlugin } from '@pebula/ngrid';
import { PblNgridConfigService } from '@pebula/ngrid/core';
import { PblNgridModule, PblNgridPluginController, ngridPlugin } from '@pebula/ngrid';
import { PblNgridTargetEventsPlugin, PblNgridTargetEventsPluginDirective, PLUGIN_KEY, runOnce } from './target-events/target-events-plugin';
import { PblNgridCellEditDirective } from './target-events/cell-edit.directive';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as Events from './events';
import { matrixRowFromRow, isRowContainer, findCellRenderIndex, findParentCell } from './utils';
import { handleFocusAndSelection } from './focus-and-selection';

declare module '@pebula/ngrid/lib/grid/services/config' {
declare module '@pebula/ngrid/core/lib/configuration/type' {
interface PblNgridConfig {
targetEvents?: {
/** When set to true will enable the target events plugin on all table instances by default. */
Expand Down
5 changes: 2 additions & 3 deletions libs/ngrid/transpose/src/lib/transpose-plugin.directive.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Directive, Input, OnDestroy } from '@angular/core';
import { coerceBooleanProperty } from '@angular/cdk/coercion';

import { PblColumnDefinition, PblNgridColumnDefinitionSet, unrx } from '@pebula/ngrid/core';
import { PblNgridConfigService, PblColumnDefinition, PblNgridColumnDefinitionSet, unrx } from '@pebula/ngrid/core';
import {
columnFactory,
PblNgridConfigService,
PblNgridComponent,
PblNgridPluginController,
PblColumn,
Expand All @@ -15,7 +14,7 @@ import { getCellValueTransformed, createTransformedColumn } from './utils';

const DEFAULT_HEADER_COLUMN = { prop: '__transpose__', css: 'pbl-ngrid-header-cell pbl-ngrid-transposed-header-cell' };

declare module '@pebula/ngrid/lib/grid/services/config' {
declare module '@pebula/ngrid/core/lib/configuration/type' {
interface PblNgridConfig {
transposePlugin?: {
header?: Partial<PblColumnDefinition>;
Expand Down

0 comments on commit fc259ba

Please sign in to comment.