Skip to content

Commit 6795846

Browse files
committed
chore: merge main
2 parents 951754b + 063d7ba commit 6795846

36 files changed

Lines changed: 6707 additions & 6433 deletions

.github/workflows/build.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ env:
66

77
on:
88
push:
9-
branches: [ "main" ]
9+
branches: ["main"]
1010
pull_request:
11-
branches: [ "main" ]
11+
branches: ["main"]
1212

1313
jobs:
1414
build:
@@ -17,14 +17,15 @@ jobs:
1717

1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v6
2121
with:
2222
fetch-depth: 0
23-
- uses: actions/setup-node@v3
23+
- uses: actions/setup-node@v6
2424
with:
2525
node-version: lts/*
26-
- uses: nrwl/nx-set-shas@v3
26+
cache: npm
27+
- uses: nrwl/nx-set-shas@v5
2728
- name: npm install
28-
run: npm install --legacy-peer-deps
29+
run: npm install --force
2930
- name: Build.all affected
30-
run: npx nx affected --target=build --exclude nativescript-demo-ng
31+
run: npx nx affected --target=build,test --exclude nativescript-demo-ng

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@ Thumbs.db
5151
.nx/workspace-data
5252
.cursor/rules/nx-rules.mdc
5353
.github/instructions/nx.instructions.md
54+
55+
.claude/worktrees
56+
.nx/polygraph
57+
.nx/self-healing

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ packages/angular/dist
2020
**/xplat/nativescript/scss/fonticons/*.css
2121
**/xplat/nativescript*/plugins/**/*
2222
/.nx/cache
23-
/.nx/workspace-data
23+
/.nx/workspace-data
24+
.nx/self-healing

apps/nativescript-demo-ng/.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
},
1111
"rules": {
1212
"@angular-eslint/directive-selector": [
13-
"error",
13+
"warn",
1414
{
1515
"type": "attribute",
1616
"prefix": "",
1717
"style": "camelCase"
1818
}
1919
],
2020
"@angular-eslint/component-selector": [
21-
"error",
21+
"warn",
2222
{
2323
"type": "element",
2424
"prefix": "",

apps/nativescript-demo-ng/src/app/app.routes.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Routes } from '@angular/router';
22
import { ItemDetailComponent } from './item/item-detail.component';
33
import { ItemsComponent } from './item/items.component';
4+
import { InputBindingDemoComponent } from './input-binding-demo/input-binding-demo.component';
45
import { ListViewStickyComponent } from './list-view-sticky/list-view-sticky.component';
56
import { SPLIT_VIEW_ROUTES } from './split-view-demo/split-view.routes';
67
// import { HomeComponent } from './home/home.component';
@@ -10,6 +11,14 @@ export const routes: Routes = [
1011
{ path: '', redirectTo: '/rootlazy', pathMatch: 'full' },
1112
{ path: 'items', component: ItemsComponent },
1213
{ path: 'item/:id', component: ItemDetailComponent },
14+
{
15+
path: 'input-binding-demo/:name',
16+
component: InputBindingDemoComponent,
17+
data: { title: 'Demo Page' },
18+
resolve: {
19+
timestamp: () => new Date().toISOString(),
20+
},
21+
},
1322
{ path: 'item2', loadChildren: () => import('./item2/item2.routes').then((m) => m.ITEM2_ROUTES) },
1423
{ path: 'rootlazy', loadChildren: () => import('./item3/item3.module').then((m) => m.Item3Module) },
1524
{
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Component, input, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { NativeScriptCommonModule } from '@nativescript/angular';
3+
4+
@Component({
5+
selector: 'ns-input-binding-demo',
6+
template: `
7+
<ActionBar title="Input Binding Demo" class="action-bar"></ActionBar>
8+
<StackLayout class="p-4">
9+
<Label text="Route Input Binding Demo" class="text-2xl font-bold text-center"></Label>
10+
11+
<Label class="mt-4 text-lg font-bold" text="Route Param:"></Label>
12+
<Label class="text-base" [text]="'name = ' + name()"></Label>
13+
14+
<Label class="mt-4 text-lg font-bold" text="Query Param:"></Label>
15+
<Label class="text-base" [text]="'language = ' + language()"></Label>
16+
17+
<Label class="mt-4 text-lg font-bold" text="Resolver Data:"></Label>
18+
<Label class="text-base" [text]="'timestamp = ' + timestamp()"></Label>
19+
20+
<Label class="mt-4 text-lg font-bold" text="Static Route Data:"></Label>
21+
<Label class="text-base" [text]="'title = ' + title()"></Label>
22+
</StackLayout>
23+
`,
24+
imports: [NativeScriptCommonModule],
25+
schemas: [NO_ERRORS_SCHEMA],
26+
})
27+
export class InputBindingDemoComponent {
28+
name = input<string>();
29+
language = input<string>();
30+
timestamp = input<string>();
31+
title = input<string>();
32+
}

apps/nativescript-demo-ng/src/app/item3/items.component.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@
4444
backgroundColor="#00d2ff"
4545
class="text-white mt-2 w-full font-bold h-[50]"
4646
></Button>
47+
<Button
48+
[nsRouterLink]="['/input-binding-demo', 'Angular']"
49+
[queryParams]="{ language: 'en' }"
50+
text="Input Binding Demo"
51+
[borderRadius]="borderRadius"
52+
[fontSize]="fontSize"
53+
padding="0"
54+
backgroundColor="#4CAF50"
55+
class="text-white mt-2 w-full font-bold h-[50]"
56+
></Button>
4757
</StackLayout>
4858
<ListView row="1" [items]="items" backgroundColor="#efefef">
4959
<ng-template let-item="item">

apps/nativescript-demo-ng/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
provideNativeScriptNgZone,
55
provideNativeScriptRouter,
66
runNativeScriptAngularApp,
7+
provideComponentInputBinding,
78
} from '@nativescript/angular';
89
import { Trace, Utils, SplitView } from '@nativescript/core';
910

@@ -38,6 +39,7 @@ runNativeScriptAngularApp({
3839
providers: [
3940
provideNativeScriptHttpClient(withInterceptorsFromDi()),
4041
provideNativeScriptRouter(routes),
42+
provideComponentInputBinding(),
4143
// provideNativeScriptRouter(SPLIT_VIEW_ROUTES),
4244
ZONELESS ? provideZonelessChangeDetection() : provideNativeScriptNgZone(),
4345
],
Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,61 @@
1-
import { NSRouterLink } from '@nativescript/angular';
2-
import { ActivatedRoute, Router } from '@angular/router';
1+
import { NSRouterLink, NativeScriptRouterModule } from '@nativescript/angular';
32
import { RouterExtensions } from '@nativescript/angular';
4-
import { fake, spy, stub } from './test-config.spec';
5-
import { SinonStub } from 'sinon';
6-
import { Label } from '@nativescript/core';
3+
import { fake } from './test-config.spec';
4+
import { Component, ViewChild } from '@angular/core';
5+
import { TestBed, ComponentFixture } from '@angular/core/testing';
6+
import { NativeScriptModule } from '@nativescript/angular';
77

8-
describe('NSRouterLink', () => {
9-
const mockRouter = {} as Router;
10-
const mockRouterExtensions = {
11-
navigateByUrl: fake(),
12-
navigate: fake(),
13-
};
14-
const mockActivatedRoute = {} as ActivatedRoute;
15-
let nsRouterLink: NSRouterLink;
16-
let urlTreeStub: SinonStub;
8+
@Component({
9+
imports: [NativeScriptRouterModule, NSRouterLink],
10+
template: `<Label nsRouterLink="/test" text="Test"></Label>`,
11+
})
12+
class RouterLinkTestComponent {
13+
@ViewChild(NSRouterLink, { static: false }) nsRouterLink: NSRouterLink;
14+
}
1715

18-
beforeEach(() => {
19-
const el = {
20-
nativeElement: new Label(),
21-
};
22-
nsRouterLink = new NSRouterLink(null, mockRouter, mockRouterExtensions as unknown as RouterExtensions, mockActivatedRoute, el);
23-
urlTreeStub = stub(nsRouterLink, 'urlTree').get(() => null);
24-
});
16+
describe('NSRouterLink', () => {
17+
let mockNavigate: ReturnType<typeof fake>;
18+
let fixture: ComponentFixture<RouterLinkTestComponent>;
2519

26-
afterEach(() => {
27-
urlTreeStub.restore();
20+
beforeEach(async () => {
21+
mockNavigate = fake();
22+
TestBed.configureTestingModule({
23+
imports: [
24+
NativeScriptModule,
25+
NativeScriptRouterModule.forRoot([{ path: 'test', component: RouterLinkTestComponent }]),
26+
RouterLinkTestComponent,
27+
],
28+
providers: [
29+
{
30+
provide: RouterExtensions,
31+
useValue: {
32+
navigateByUrl: fake(),
33+
navigate: mockNavigate,
34+
},
35+
},
36+
],
37+
});
38+
await TestBed.compileComponents();
39+
fixture = TestBed.createComponent(RouterLinkTestComponent);
40+
fixture.detectChanges();
41+
await fixture.whenStable();
2842
});
2943

3044
it('#tap should call navigate with undefined transition in extras when boolean is given for pageTransition input', () => {
31-
nsRouterLink.pageTransition = false;
32-
nsRouterLink.onTap();
33-
expect(mockRouterExtensions.navigate.lastCall.args[1].transition).toBeUndefined();
34-
// assert.isUndefined(mockRouterExtensions.navigateByUrl.lastCall.args[1].transition);
45+
const directive = fixture.componentInstance.nsRouterLink;
46+
directive.pageTransition = false;
47+
directive['onTap']();
48+
expect(mockNavigate.lastCall.args[1].transition).toBeUndefined();
3549
});
3650

3751
it('#tap should call navigate with correct transition in extras when NavigationTransition object is given for pageTransition input', () => {
3852
const pageTransition = {
3953
name: 'slide',
4054
duration: 500,
4155
};
42-
nsRouterLink.pageTransition = pageTransition;
43-
stub(nsRouterLink, 'urlTree').get(() => null);
44-
nsRouterLink.onTap();
45-
expect(mockRouterExtensions.navigate.lastCall.args[1].transition).toBe(pageTransition);
56+
const directive = fixture.componentInstance.nsRouterLink;
57+
directive.pageTransition = pageTransition;
58+
directive['onTap']();
59+
expect(mockNavigate.lastCall.args[1].transition).toBe(pageTransition);
4660
});
4761
});

0 commit comments

Comments
 (0)