Skip to content

Commit

Permalink
refactor: provide services where actually needed
Browse files Browse the repository at this point in the history
  • Loading branch information
spike-rabbit committed Nov 15, 2024
1 parent 4746a5e commit fb09808
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { DataTableBodyComponent } from './body/body.component';
import { DataTableHeaderComponent } from './header/header.component';
import { ScrollbarHelper } from '../services/scrollbar-helper.service';
import { ColumnChangesService } from '../services/column-changes.service';
import { DimensionsHelper } from '../services/dimensions-helper.service';
import { throttleable } from '../utils/throttle';
import { adjustColumnWidths, forceFillColumnWidths } from '../utils/math';
import { sortGroupedRows, sortRows } from '../utils/sort';
Expand Down Expand Up @@ -84,7 +83,8 @@ import { ProgressBarComponent } from './body/progress-bar.component';
{
provide: DatatableComponentToken,
useExisting: DatatableComponent
}
},
ColumnChangesService
],
standalone: true,
imports: [
Expand All @@ -100,7 +100,6 @@ export class DatatableComponent<TRow = any>
implements OnInit, DoCheck, AfterViewInit, AfterContentInit, OnDestroy
{
private scrollbarHelper = inject(ScrollbarHelper);
private dimensionsHelper = inject(DimensionsHelper);
private cd = inject(ChangeDetectorRef);
private columnChangesService = inject(ColumnChangesService);
private configuration = inject<INgxDatatableConfig>('configuration' as any, { optional: true });
Expand Down Expand Up @@ -961,7 +960,7 @@ export class DatatableComponent<TRow = any>
*
*/
recalculateDims(): void {
const dims = this.dimensionsHelper.getDimensions(this.element);
const dims = this.element.getBoundingClientRect();
this._innerWidth = Math.floor(dims.width);

if (this.scrollbarV) {
Expand Down
4 changes: 0 additions & 4 deletions projects/ngx-datatable/src/lib/ngx-datatable.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { ModuleWithProviders, NgModule } from '@angular/core';
import { ScrollbarHelper } from './services/scrollbar-helper.service';
import { DimensionsHelper } from './services/dimensions-helper.service';
import { ColumnChangesService } from './services/column-changes.service';
import { DataTableFooterTemplateDirective } from './components/footer/footer-template.directive';
import { DatatableComponent } from './components/datatable.component';
import { DataTableColumnDirective } from './components/columns/column.directive';
Expand Down Expand Up @@ -40,7 +37,6 @@ import {
DatatableRowDefComponent,
DatatableRowDefDirective
],
providers: [ScrollbarHelper, DimensionsHelper, ColumnChangesService],
exports: [
DatatableComponent,
DatatableRowDetailDirective,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DOCUMENT } from '@angular/common';
* Gets the width of the scrollbar. Nesc for windows
* http://stackoverflow.com/a/13382873/888165
*/
@Injectable()
@Injectable({ providedIn: 'root' })
export class ScrollbarHelper {
private document = inject(DOCUMENT);

Expand Down
1 change: 0 additions & 1 deletion projects/ngx-datatable/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export * from './lib/directives/disable-row.directive';

// services
export * from './lib/services/scrollbar-helper.service';
export * from './lib/services/dimensions-helper.service';
export * from './lib/services/column-changes.service';

// types
Expand Down

0 comments on commit fb09808

Please sign in to comment.