Skip to content

refactor: remove explicit public access modifiers #354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions projects/angular-split/src/lib/component/split.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,15 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
private startPoint: IPoint | null = null
private endPoint: IPoint | null = null

public readonly displayedAreas: Array<IArea> = []
readonly displayedAreas: Array<IArea> = []
private readonly hiddenAreas: Array<IArea> = []

@ViewChildren('gutterEls') private gutterEls: QueryList<ElementRef>

_clickTimeout: number | null = null
draggedGutterNum: number = undefined

public ngAfterViewInit() {
ngAfterViewInit() {
this.ngZone.runOutsideAngular(() => {
// To avoid transition at first rendering
setTimeout(() => this.renderer.addClass(this.elRef.nativeElement, 'as-init'))
Expand All @@ -332,7 +332,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
return this.displayedAreas.length === 0 ? 0 : this.displayedAreas.length - 1
}

public addArea(component: SplitAreaDirective): void {
addArea(component: SplitAreaDirective): void {
const newArea: IArea = {
component,
order: 0,
Expand All @@ -352,7 +352,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
}
}

public removeArea(component: SplitAreaDirective): void {
removeArea(component: SplitAreaDirective): void {
if (this.displayedAreas.some((a) => a.component === component)) {
const area = this.displayedAreas.find((a) => a.component === component)
this.displayedAreas.splice(this.displayedAreas.indexOf(area), 1)
Expand All @@ -364,13 +364,13 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
}
}

public updateArea(component: SplitAreaDirective, resetOrders: boolean, resetSizes: boolean): void {
updateArea(component: SplitAreaDirective, resetOrders: boolean, resetSizes: boolean): void {
if (component.visible === true) {
this.build(resetOrders, resetSizes)
}
}

public showArea(component: SplitAreaDirective): void {
showArea(component: SplitAreaDirective): void {
const area = this.hiddenAreas.find((a) => a.component === component)
if (area === undefined) {
return
Expand All @@ -382,7 +382,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
this.build(true, true)
}

public hideArea(comp: SplitAreaDirective): void {
hideArea(comp: SplitAreaDirective): void {
const area = this.displayedAreas.find((a) => a.component === comp)
if (area === undefined) {
return
Expand All @@ -398,11 +398,11 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
this.build(true, true)
}

public getVisibleAreaSizes(): IOutputAreaSizes {
getVisibleAreaSizes(): IOutputAreaSizes {
return this.displayedAreas.map((a) => a.size)
}

public setVisibleAreaSizes(sizes: IOutputAreaSizes): boolean {
setVisibleAreaSizes(sizes: IOutputAreaSizes): boolean {
if (sizes.length !== this.displayedAreas.length) {
return false
}
Expand Down Expand Up @@ -568,7 +568,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
}
}

public clickGutter(event: MouseEvent | TouchEvent, gutterNum: number): void {
clickGutter(event: MouseEvent | TouchEvent, gutterNum: number): void {
const tempPoint = getPointFromEvent(event)

// Be sure mouseup/touchend happened if touch/cursor is not moved.
Expand All @@ -594,7 +594,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
}
}

public startKeyboardDrag(event: KeyboardEvent, gutterOrder: number, gutterNum: number) {
startKeyboardDrag(event: KeyboardEvent, gutterOrder: number, gutterNum: number) {
if (this.disabled === true || this.isWaitingClear === true) {
return
}
Expand All @@ -615,7 +615,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
this.stopDragging()
}

public startMouseDrag(event: MouseEvent | TouchEvent, gutterOrder: number, gutterNum: number): void {
startMouseDrag(event: MouseEvent | TouchEvent, gutterOrder: number, gutterNum: number): void {
if (this.customGutter && !this.customGutter.canStartDragging(event.target as HTMLElement, gutterNum)) {
return
}
Expand Down Expand Up @@ -829,7 +829,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
// Hack because of browser messing up with sizes using calc(X% - Ypx) -> el.getBoundingClientRect()
// If not there, playing with gutters makes total going down to 99.99875% then 99.99286%, 99.98986%,..
const all = [...areasBefore.list, ...areasAfter.list]
const wildcardArea = all.find((a) => a.percentAfterAbsorption == '*')
const wildcardArea = all.find((a) => a.percentAfterAbsorption === '*')
// In case we have a wildcard area - always align the percents on the wildcard area.
const areaToReset =
wildcardArea ??
Expand Down Expand Up @@ -901,7 +901,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
})
}

public notify(type: 'start' | 'progress' | 'end' | 'click' | 'dblclick' | 'transitionEnd', gutterNum: number): void {
notify(type: 'start' | 'progress' | 'end' | 'click' | 'dblclick' | 'transitionEnd', gutterNum: number): void {
const sizes = this.getVisibleAreaSizes()

if (type === 'start') {
Expand All @@ -922,11 +922,11 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
}
}

public ngOnDestroy(): void {
ngOnDestroy(): void {
this.stopDragging()
}

public collapseArea(comp: SplitAreaDirective, newSize: number, gutter: 'left' | 'right'): void {
collapseArea(comp: SplitAreaDirective, newSize: number, gutter: 'left' | 'right'): void {
const area = this.displayedAreas.find((a) => a.component === comp)
if (area === undefined) {
return
Expand All @@ -944,7 +944,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
this.updateArea(comp, false, false)
}

public expandArea(comp: SplitAreaDirective): void {
expandArea(comp: SplitAreaDirective): void {
const area = this.displayedAreas.find((a) => a.component === comp)
if (area === undefined) {
return
Expand All @@ -961,7 +961,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
this.updateArea(comp, false, false)
}

public getAriaAreaSizeText(size: IAreaSize): string {
getAriaAreaSizeText(size: IAreaSize): string {
if (size === '*') {
return null
}
Expand Down
18 changes: 9 additions & 9 deletions projects/angular-split/src/lib/directive/split-area.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ export class SplitAreaDirective implements OnInit, OnDestroy {

constructor(
private ngZone: NgZone,
public elRef: ElementRef,
private renderer: Renderer2,
private split: SplitComponent,
readonly elRef: ElementRef,
) {
this.renderer.addClass(this.elRef.nativeElement, 'as-split-area')
}

public ngOnInit(): void {
ngOnInit(): void {
this.split.addArea(this)

this.ngZone.runOutsideAngular(() => {
Expand Down Expand Up @@ -131,11 +131,11 @@ export class SplitAreaDirective implements OnInit, OnDestroy {
})
}

public setStyleOrder(value: number): void {
setStyleOrder(value: number): void {
this.renderer.setStyle(this.elRef.nativeElement, 'order', value)
}

public setStyleFlex(grow: number, shrink: number, basis: string, isMin: boolean, isMax: boolean): void {
setStyleFlex(grow: number, shrink: number, basis: string, isMin: boolean, isMax: boolean): void {
// Need 3 separated properties to work on IE11 (https://github.com/angular/flex-layout/issues/323)
this.renderer.setStyle(this.elRef.nativeElement, 'flex-grow', grow)
this.renderer.setStyle(this.elRef.nativeElement, 'flex-shrink', shrink)
Expand All @@ -154,14 +154,14 @@ export class SplitAreaDirective implements OnInit, OnDestroy {
}
}

public lockEvents(): void {
lockEvents(): void {
this.ngZone.runOutsideAngular(() => {
this.lockListeners.push(this.renderer.listen(this.elRef.nativeElement, 'selectstart', () => false))
this.lockListeners.push(this.renderer.listen(this.elRef.nativeElement, 'dragstart', () => false))
})
}

public unlockEvents(): void {
unlockEvents(): void {
while (this.lockListeners.length > 0) {
const fct = this.lockListeners.pop()
if (fct) {
Expand All @@ -170,7 +170,7 @@ export class SplitAreaDirective implements OnInit, OnDestroy {
}
}

public ngOnDestroy(): void {
ngOnDestroy(): void {
this.unlockEvents()

if (this.transitionListener) {
Expand All @@ -183,11 +183,11 @@ export class SplitAreaDirective implements OnInit, OnDestroy {
this.split.removeArea(this)
}

public collapse(newSize = 0, gutter: 'left' | 'right' = 'right'): void {
collapse(newSize = 0, gutter: 'left' | 'right' = 'right'): void {
this.split.collapseArea(this, newSize, gutter)
}

public expand(): void {
expand(): void {
this.split.expandArea(this)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface SplitGutterDynamicInjectorTemplateContext {
})
export class SplitGutterDynamicInjectorDirective {
@Input('asSplitGutterDynamicInjector')
public set gutterNum(value: number) {
set gutterNum(value: number) {
this.vcr.clear()

const injector = Injector.create({
Expand Down
10 changes: 5 additions & 5 deletions projects/angular-split/src/lib/gutter/split-gutter.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ export class SplitGutterDirective {
* The map holds reference to the drag handle elements inside instances
* of the provided template.
*/
public gutterToHandleElementMap = new Map<number, ElementRef<HTMLElement>[]>()
gutterToHandleElementMap = new Map<number, ElementRef<HTMLElement>[]>()
/**
* The map holds reference to the excluded drag elements inside instances
* of the provided template.
*/
public gutterToExcludeDragElementMap = new Map<number, ElementRef<HTMLElement>[]>()
gutterToExcludeDragElementMap = new Map<number, ElementRef<HTMLElement>[]>()

constructor(public template: TemplateRef<SplitGutterTemplateContext>) {}

public canStartDragging(originElement: HTMLElement, gutterNum: number) {
canStartDragging(originElement: HTMLElement, gutterNum: number) {
if (this.gutterToExcludeDragElementMap.has(gutterNum)) {
const isInsideExclude = this.gutterToExcludeDragElementMap
.get(gutterNum)
Expand All @@ -70,15 +70,15 @@ export class SplitGutterDirective {
return true
}

public addToMap(map: Map<number, ElementRef<HTMLElement>[]>, gutterNum: number, elementRef: ElementRef<HTMLElement>) {
addToMap(map: Map<number, ElementRef<HTMLElement>[]>, gutterNum: number, elementRef: ElementRef<HTMLElement>) {
if (map.has(gutterNum)) {
map.get(gutterNum).push(elementRef)
} else {
map.set(gutterNum, [elementRef])
}
}

public removedFromMap(
removedFromMap(
map: Map<number, ElementRef<HTMLElement>[]>,
gutterNum: number,
elementRef: ElementRef<HTMLElement>,
Expand Down