Skip to content
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
66 changes: 33 additions & 33 deletions packages/bits/demo/src/components/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
// © 2022 SolarWinds Worldwide, LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// © 2022 SolarWinds Worldwide, LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import { Component, ViewEncapsulation, inject } from "@angular/core";

import { ThemeSwitchService } from "@nova-ui/bits";

@Component({
selector: "nui-app",
templateUrl: "app.component.html",
styleUrls: ["app.component.less"],
encapsulation: ViewEncapsulation.None,
standalone: false,
})
export class AppComponent { themeSwitcherService = inject(ThemeSwitchService);

import { Component, ViewEncapsulation } from "@angular/core";

import { ThemeSwitchService } from "@nova-ui/bits";

@Component({
selector: "nui-app",
templateUrl: "app.component.html",
styleUrls: ["app.component.less"],
encapsulation: ViewEncapsulation.None,
standalone: false,
})
export class AppComponent {
constructor(public themeSwitcherService: ThemeSwitchService) {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import { Component, OnDestroy, OnInit } from "@angular/core";
import { Component, OnDestroy, OnInit, inject } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { Subscription } from "rxjs";

Expand All @@ -30,15 +30,13 @@ import { BreadcrumbItem, BreadcrumbStateService } from "@nova-ui/bits";
standalone: false,
})
export class BreadcrumbBasicExampleComponent implements OnInit, OnDestroy {
private router = inject(Router);
private routerState = inject(ActivatedRoute);
private breadcrumbStateService = inject(BreadcrumbStateService);

public breadcrumbSource: Array<BreadcrumbItem>;
private routerSubscription: Subscription;

constructor(
private router: Router,
private routerState: ActivatedRoute,
private breadcrumbStateService: BreadcrumbStateService
) {}

public ngOnInit(): void {
this.breadcrumbSource = this.breadcrumbStateService.getBreadcrumbState(
this.routerState,
Expand Down Expand Up @@ -109,7 +107,9 @@ export class BreadcrumbBasicExampleComponent implements OnInit, OnDestroy {
standalone: false,
})
export class BreadcrumbCountriesSubviewComponent {
constructor(private router: Router, private routerState: ActivatedRoute) {}
private router = inject(Router);
private routerState = inject(ActivatedRoute);


public relativeNavigation(routerState: string): void {
this.router.navigate([routerState], { relativeTo: this.routerState });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import { Component, OnDestroy, OnInit } from "@angular/core";
import { Component, OnDestroy, OnInit, inject } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { Subscription } from "rxjs";

Expand All @@ -30,15 +30,13 @@ import { BreadcrumbItem, BreadcrumbStateService } from "@nova-ui/bits";
standalone: false,
})
export class BreadcrumbVisualTestComponent implements OnInit, OnDestroy {
private router = inject(Router);
private routerState = inject(ActivatedRoute);
private breadcrumbStateService = inject(BreadcrumbStateService);

public breadcrumbSource: Array<BreadcrumbItem>;
private routerSubscription: Subscription;

constructor(
private router: Router,
private routerState: ActivatedRoute,
private breadcrumbStateService: BreadcrumbStateService
) {}

public ngOnInit(): void {
this.breadcrumbSource = this.breadcrumbStateService.getBreadcrumbState(
this.routerState
Expand Down Expand Up @@ -89,7 +87,9 @@ export class BreadcrumbVisualTestComponent implements OnInit, OnDestroy {
standalone: false,
})
export class BreadcrumbFirstSubviewLevelComponent {
constructor(private router: Router, private routerState: ActivatedRoute) {}
private router = inject(Router);
private routerState = inject(ActivatedRoute);


goNext(): void {
this.router.navigate(["second-subroute"], {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import { Component, Inject } from "@angular/core";
import { Component, inject } from "@angular/core";

import { ToastService } from "@nova-ui/bits";

Expand All @@ -28,7 +28,8 @@ import { ToastService } from "@nova-ui/bits";
standalone: false,
})
export class ButtonBasicExampleComponent {
constructor(@Inject(ToastService) private toastService: ToastService) {}
private toastService = inject<ToastService>(ToastService);


onClick(): void {
this.toastService.info({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import { Component } from "@angular/core";
import { Component, inject } from "@angular/core";

import { ToastService } from "@nova-ui/bits";

Expand All @@ -28,15 +28,15 @@ import { ToastService } from "@nova-ui/bits";
standalone: false,
})
export class CheckboxGroupBasicExampleComponent {
private toastService = inject(ToastService);

public cabbage = $localize`Cabbage`;
public potato = $localize`Potato`;
public tomato = $localize`Tomato`;
public carrot = $localize`Carrot`;
public vegetables = [this.cabbage, this.potato, this.tomato, this.carrot];
public selectedVegetables = [this.potato, this.tomato];

constructor(private toastService: ToastService) {}

public isChecked(vegetable: string): boolean {
return this.selectedVegetables.indexOf(vegetable) > -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import { Component } from "@angular/core";
import { Component, inject } from "@angular/core";
import { FormBuilder, Validators } from "@angular/forms";

import { ToastService } from "@nova-ui/bits";
Expand All @@ -29,6 +29,9 @@ import { ToastService } from "@nova-ui/bits";
standalone: false,
})
export class CheckboxGroupInFormExampleComponent {
private formBuilder = inject(FormBuilder);
private toastService = inject(ToastService);

public cabbage = $localize`Cabbage`;
public potato = $localize`Potato`;
public tomato = $localize`Tomato`;
Expand All @@ -37,10 +40,7 @@ export class CheckboxGroupInFormExampleComponent {
public selectedVegetables = [this.cabbage];
public myForm;

constructor(
private formBuilder: FormBuilder,
private toastService: ToastService
) {
constructor() {
this.myForm = this.formBuilder.group({
checkboxGroup: this.formBuilder.control(
[this.cabbage, this.potato],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import { Component } from "@angular/core";
import { Component, inject } from "@angular/core";
import { FormBuilder } from "@angular/forms";

@Component({
Expand All @@ -27,6 +27,8 @@ import { FormBuilder } from "@angular/forms";
standalone: false,
})
export class CheckboxGroupTestComponent {
private formBuilder = inject(FormBuilder);

public cabbage = "Cabbage";
public potato = "Potato";
public tomato = "Tomato";
Expand All @@ -37,7 +39,7 @@ export class CheckboxGroupTestComponent {
public selectedVegetables = [this.potato, this.tomato, this.disabledOne];
public testForm;

constructor(private formBuilder: FormBuilder) {
constructor() {
this.testForm = this.formBuilder.group({
checkboxGroup: this.formBuilder.control({
value: this.selectedVegetables,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import { Component } from "@angular/core";
import { Component, inject } from "@angular/core";
import { FormBuilder } from "@angular/forms";

@Component({
Expand All @@ -27,6 +27,8 @@ import { FormBuilder } from "@angular/forms";
standalone: false,
})
export class CheckboxGroupVisualTestComponent {
private formBuilder = inject(FormBuilder);

public cabbage = "Cabbage";
public potato = "Potato";
public tomato = "Tomato";
Expand All @@ -36,7 +38,7 @@ export class CheckboxGroupVisualTestComponent {
public selectedVegetables = [this.potato, this.tomato, this.disabledOne];
public testForm;

constructor(private formBuilder: FormBuilder) {
constructor() {
this.testForm = this.formBuilder.group({
checkboxGroup: this.formBuilder.control({
value: this.selectedVegetables,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import { Component, OnInit } from "@angular/core";
import { Component, OnInit, inject } from "@angular/core";
import {
FormBuilder,
FormControl,
Expand All @@ -33,12 +33,10 @@ import { ToastService } from "@nova-ui/bits";
standalone: false,
})
export class CheckboxInFormExampleComponent implements OnInit {
public myForm: FormGroup<{ checkbox: FormControl<boolean | null> }>;
private formBuilder = inject(FormBuilder);
private toastService = inject(ToastService);

constructor(
private formBuilder: FormBuilder,
private toastService: ToastService
) {}
public myForm: FormGroup<{ checkbox: FormControl<boolean | null> }>;

public ngOnInit(): void {
this.myForm = this.formBuilder.group({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import { Component } from "@angular/core";
import { Component, inject } from "@angular/core";

import { ToastService } from "@nova-ui/bits";

Expand All @@ -28,9 +28,10 @@ import { ToastService } from "@nova-ui/bits";
standalone: false,
})
export class CheckboxLinkExampleComponent {
private toastService = inject(ToastService);

public action(): boolean {
this.toastService.warning({ message: $localize`Link clicked!` });
return false;
}
constructor(private toastService: ToastService) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import { Component } from "@angular/core";
import { Component, inject } from "@angular/core";

import { CheckboxChangeEvent, ToastService } from "@nova-ui/bits";

Expand All @@ -28,7 +28,8 @@ import { CheckboxChangeEvent, ToastService } from "@nova-ui/bits";
standalone: false,
})
export class CheckboxOutputExampleComponent {
constructor(private toastService: ToastService) {}
private toastService = inject(ToastService);


public onValueChanged($event: CheckboxChangeEvent): void {
this.toastService.success({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import {
ChangeDetectionStrategy,
Component,
SecurityContext,
} from "@angular/core";
import { ChangeDetectionStrategy, Component, SecurityContext, inject } from "@angular/core";
import { FormControl } from "@angular/forms";
import { DomSanitizer } from "@angular/platform-browser";

Expand All @@ -34,14 +30,14 @@ import { DomSanitizer } from "@angular/platform-browser";
standalone: false,
})
export class ComboboxV2CreateOptionMultiselectExampleComponent {
private domSanitizer = inject(DomSanitizer);

public options = Array.from({ length: 3 }).map(
(_, i) => $localize`Item ${i}`
);

public comboboxControl = new FormControl<string[] | null>(null);

constructor(private domSanitizer: DomSanitizer) {}

public createOption(optionName: string): void {
const sanitizedOption = this.domSanitizer
.sanitize(SecurityContext.HTML, optionName)
Expand Down
Loading
Loading