diff --git a/packages/abc/let/demo/async.md b/packages/abc/let/demo/async.md deleted file mode 100644 index 32dbe51d8..000000000 --- a/packages/abc/let/demo/async.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -title: - zh-CN: 异步 - en-US: async -order: 2 ---- - -## zh-CN - -一次订阅多次使用。 - -## en-US - -One subscription and multiple use. - -```ts -import { Platform } from '@angular/cdk/platform'; -import { AsyncPipe } from '@angular/common'; -import { ChangeDetectionStrategy, Component } from '@angular/core'; -import { interval, startWith } from 'rxjs'; - -import { LetDirective } from '@delon/abc/let'; -import type { NzSafeAny } from 'ng-zorro-antd/core/types'; - -@Component({ - selector: 'app-demo', - template: ` - @if (timer$ !== null) { - -

Timer value: {{ time }}

-

Timer value: {{ time }}

-

Timer value: {{ time }}

-
- } - `, - changeDetection: ChangeDetectionStrategy.OnPush, - standalone: true, - imports: [LetDirective, AsyncPipe] -}) -export class DemoComponent { - timer$: NzSafeAny | null = null; - - constructor(platform: Platform) { - if (!platform.isBrowser) return; - - this.timer$ = interval(1000).pipe(startWith(0)); - } -} -``` diff --git a/packages/abc/let/demo/simple.md b/packages/abc/let/demo/simple.md deleted file mode 100644 index 026e8ca3e..000000000 --- a/packages/abc/let/demo/simple.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: - zh-CN: 基础样例 - en-US: Basic Usage -order: 1 ---- - -## zh-CN - -最简单的用法。 - -## en-US - -Simplest of usage. - -```ts -import { ChangeDetectionStrategy, Component } from '@angular/core'; - -import { LetDirective } from '@delon/abc/let'; -import { NzButtonModule } from 'ng-zorro-antd/button'; - -@Component({ - selector: 'app-demo', - template: ` -

v1 (use *let directive) called count: {{ v1Count }}; v2 called count: {{ v2Count }};

-
-

{{ v }}

-

{{ v }}

-
-

{{ value2 }}

-

{{ value2 }}

- - `, - changeDetection: ChangeDetectionStrategy.OnPush, - standalone: true, - imports: [LetDirective, NzButtonModule] -}) -export class DemoComponent { - v1Count = 0; - v2Count = 0; - v1 = 'v1'; - v2 = 'v2'; - - get value1(): string { - ++this.v1Count; - return this.v1; - } - - get value2(): string { - ++this.v2Count; - return this.v2; - } - - update(): void { - this.v1 = `v1-${Math.random()}`; - this.v2 = `v2-${Math.random()}`; - } -} -``` diff --git a/packages/abc/let/index.en-US.md b/packages/abc/let/index.en-US.md deleted file mode 100644 index 57c3b42b4..000000000 --- a/packages/abc/let/index.en-US.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -type: Basic -order: 1 -title: let -subtitle: Let -cols: 1 -module: import { LetModule } from '@delon/abc/let'; -deprecated: 19.0.0 ---- - -# Will be removed in v19, Please use `@let` instead. - -Allows to reuse computed value in several places in template to avoid recalculations of getters or many `async` pipes. - -```html -
-

{{ v }}

-
-
-

{{ time }}

-
-``` - -## API - -### [let]:standalone - -| Property | Description | Type | Default | Global Config | -|----------|-------------|------|---------|---------------| -| `[let]` | Expression | `T` | - | - | diff --git a/packages/abc/let/index.ts b/packages/abc/let/index.ts deleted file mode 100644 index 44e69d0d1..000000000 --- a/packages/abc/let/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './let.directive'; -export * from './let.module'; diff --git a/packages/abc/let/index.zh-CN.md b/packages/abc/let/index.zh-CN.md deleted file mode 100644 index e8be7def7..000000000 --- a/packages/abc/let/index.zh-CN.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -type: Basic -order: 1 -title: let -subtitle: 定义 -cols: 1 -module: import { LetModule } from '@delon/abc/let'; -deprecated: 19.0.0 ---- - -# Will be removed in v19, Please use `@let` instead. - -允许在模板内复用计算值(包含异步),避免重复重新计算。 - -```html -
-

{{ v }}

-
-
-

{{ time }}

-
-``` - -## API - -### [let]:standalone - -| 参数 | 说明 | 类型 | 默认值 | 全局配置 | -|----|----|----|-----|------| -| `[let]` | 表达式 | `T` | - | - | diff --git a/packages/abc/let/let.directive.ts b/packages/abc/let/let.directive.ts deleted file mode 100644 index 54f7337a0..000000000 --- a/packages/abc/let/let.directive.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Directive, Inject, Input, TemplateRef, ViewContainerRef } from '@angular/core'; - -import type { NzSafeAny } from 'ng-zorro-antd/core/types'; - -export class LetContext { - constructor(private readonly dir: LetDirective) {} - - get $implicit(): T { - return this.dir.let; - } - - get let(): T { - return this.dir.let; - } -} - -/** - * @deprecated Will be removed in v19, Please use `@let` instead. - */ -@Directive({ selector: '[let]', standalone: true }) -export class LetDirective { - @Input({ required: true }) let!: T; - - constructor(@Inject(ViewContainerRef) vc: ViewContainerRef, @Inject(TemplateRef) ref: TemplateRef>) { - vc.createEmbeddedView(ref, new LetContext(this)); - } - - static ngTemplateContextGuard(_dir: LetDirective, _ctx: NzSafeAny): _ctx is LetDirective { - return true; - } -} diff --git a/packages/abc/let/let.module.ts b/packages/abc/let/let.module.ts deleted file mode 100644 index 8c841b19d..000000000 --- a/packages/abc/let/let.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; - -import { LetDirective } from './let.directive'; - -const DIRECTIVES = [LetDirective]; - -/** - * @deprecated Will be removed in v19, Please use `@let` instead. - */ -@NgModule({ - imports: DIRECTIVES, - exports: DIRECTIVES -}) -export class LetModule {} diff --git a/packages/abc/let/let.spec.ts b/packages/abc/let/let.spec.ts deleted file mode 100644 index 23edf99b3..000000000 --- a/packages/abc/let/let.spec.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Component, DebugElement } from '@angular/core'; -import { ComponentFixture } from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; - -import { createTestContext } from '@delon/testing'; - -import { LetDirective } from './let.directive'; - -describe('abc: let', () => { - let fixture: ComponentFixture; - let dl: DebugElement; - - beforeEach(() => { - ({ fixture, dl } = createTestContext(TestComponent)); - fixture.detectChanges(); - }); - - function getValue(): string { - return (dl.query(By.css('.value')).nativeElement as HTMLElement).textContent!.trim(); - } - - it('should be working', () => { - expect(getValue()).toContain(`aaa`); - }); -}); - -@Component({ - template: `
{{ value }}{{ value }}{{ value }}
`, - imports: [LetDirective] -}) -class TestComponent { - counter = 0; - - get getter(): string { - this.counter++; - - return 'a'; - } -} diff --git a/packages/abc/let/ng-package.json b/packages/abc/let/ng-package.json deleted file mode 100644 index 9c677523c..000000000 --- a/packages/abc/let/ng-package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "lib": { - "flatModuleFile": "let", - "entryFile": "index.ts" - } -} diff --git a/scripts/site/route-paths.txt b/scripts/site/route-paths.txt index cefb45317..78246ee2b 100644 --- a/scripts/site/route-paths.txt +++ b/scripts/site/route-paths.txt @@ -101,8 +101,6 @@ /components/highlight/zh /components/hotkey/en /components/hotkey/zh -/components/let/en -/components/let/zh /components/loading/en /components/loading/zh /components/lodop/en @@ -344,4 +342,4 @@ /util/pipes-format/en /util/pipes-format/zh /util/token/en -/util/token/zh \ No newline at end of file +/util/token/zh