From 5c11a426ddb2b4a15405b879a3dcc44a875e6435 Mon Sep 17 00:00:00 2001 From: ParsaArvanehPA Date: Thu, 1 Feb 2024 22:52:18 +0330 Subject: [PATCH 1/6] fix(module:tabs): wrong cursor --- components/tabs/style/patch.less | 1 + 1 file changed, 1 insertion(+) diff --git a/components/tabs/style/patch.less b/components/tabs/style/patch.less index 4b2cdd47488..a3e00fdba0f 100644 --- a/components/tabs/style/patch.less +++ b/components/tabs/style/patch.less @@ -7,6 +7,7 @@ .ant-tabs-tab-btn { border: none; background-color: unset; + cursor: pointer; } .ant-tabs-tab a[nz-tab-link] { From 5a031368c77a64167745d09e7b7199d4a305b7c4 Mon Sep 17 00:00:00 2001 From: Parsa Arvaneh Date: Sat, 2 Mar 2024 01:28:21 +0330 Subject: [PATCH 2/6] feat(module:typography): more edit triggers --- components/typography/demo/interactive.ts | 16 ++++++ components/typography/demo/module | 3 +- components/typography/text-edit.component.ts | 28 ++++++---- components/typography/typography.component.ts | 12 ++++- components/typography/typography.spec.ts | 54 +++++++++++++++++++ 5 files changed, 99 insertions(+), 14 deletions(-) diff --git a/components/typography/demo/interactive.ts b/components/typography/demo/interactive.ts index 993e7e85982..d962a677b5b 100644 --- a/components/typography/demo/interactive.ts +++ b/components/typography/demo/interactive.ts @@ -1,5 +1,7 @@ import { Component } from '@angular/core'; +import { NzEditTriggerState } from 'ng-zorro-antd/typography/text-edit.component'; + @Component({ selector: 'nz-demo-typography-interactive', template: ` @@ -13,6 +15,17 @@ import { Component } from '@angular/core'; >

+
+

+ Trigger edit with: + + + + + +

+

+

Replace copy text.

- + + + `, changeDetection: ChangeDetectionStrategy.OnPush, @@ -68,6 +73,7 @@ export class NzTextEditComponent implements OnInit { @Input() text?: string; @Input() icon: NzTSType = 'edit'; + @Input() nzTriggerType: NzEditTriggerState = 'icon'; @Input() tooltip?: null | NzTSType; @Output() readonly startEditing = new EventEmitter(); @Output() readonly endEditing = new EventEmitter(true); diff --git a/components/typography/typography.component.ts b/components/typography/typography.component.ts index aa33cb4b325..9d8ee853f85 100644 --- a/components/typography/typography.component.ts +++ b/components/typography/typography.component.ts @@ -39,7 +39,7 @@ import { InputBoolean, InputNumber, isStyleSupport, measure } from 'ng-zorro-ant import { NzI18nService, NzTextI18nInterface } from 'ng-zorro-antd/i18n'; import { NzTextCopyComponent } from './text-copy.component'; -import { NzTextEditComponent } from './text-edit.component'; +import { NzEditTriggerState, NzTextEditComponent } from './text-edit.component'; const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'typography'; const EXPAND_ELEMENT_CLASSNAME = 'ant-typography-expand'; @@ -56,7 +56,7 @@ const EXPAND_ELEMENT_CLASSNAME = 'ant-typography-expand'; template: ` - {{ content }} + {{ content }} @@ -146,6 +147,7 @@ export class NzTypographyComponent implements OnInit, AfterViewInit, OnDestroy, @Input() nzType: 'secondary' | 'warning' | 'danger' | 'success' | undefined; @Input() nzCopyText: string | undefined; @Input() nzSuffix: string | undefined; + @Input() nzTriggerType: NzEditTriggerState = 'icon'; @Output() readonly nzContentChange = new EventEmitter(); @Output() readonly nzCopy = new EventEmitter(); @Output() readonly nzExpandChange = new EventEmitter(); @@ -212,6 +214,12 @@ export class NzTypographyComponent implements OnInit, AfterViewInit, OnDestroy, this.editing = true; } + onTextClickEdit(): void { + if (this.nzEditable && (this.nzTriggerType === 'text' || this.nzTriggerType === 'both')) { + this.textEditRef?.onClick(); + } + } + onEndEditing(text: string): void { this.editing = false; this.nzContentChange.emit(text); diff --git a/components/typography/typography.spec.ts b/components/typography/typography.spec.ts index 9cf4204df73..7cab6f08503 100644 --- a/components/typography/typography.spec.ts +++ b/components/typography/typography.spec.ts @@ -18,6 +18,7 @@ import { NzSafeAny } from 'ng-zorro-antd/core/types'; import { NzIconTestModule } from 'ng-zorro-antd/icon/testing'; import { NzTextEditComponent } from '.'; +import { NzEditTriggerState } from './text-edit.component'; import { NzTypographyComponent } from './typography.component'; import { NzTypographyModule } from './typography.module'; @@ -543,6 +544,57 @@ describe('change detection behavior', () => { done(); }); }); + + it('should have default edit trigger option', () => { + expect(fixture.componentInstance.nzTrigger).toEqual('icon'); + }); + + it('should have edit button in "both" and "icon" trigger state', () => { + fixture.componentInstance.nzTrigger = 'both'; + fixture.detectChanges(); + let editButton = componentElement.querySelector('.ant-typography-edit'); + expect(editButton).not.toBeNull(); + + fixture.componentInstance.nzTrigger = 'icon'; + fixture.detectChanges(); + editButton = componentElement.querySelector('.ant-typography-edit'); + expect(editButton).not.toBeNull(); + + fixture.componentInstance.nzTrigger = 'text'; + fixture.detectChanges(); + editButton = componentElement.querySelector('.ant-typography-edit'); + expect(editButton).toBeNull(); + }); + + it('in "both" trigger state, should start editing when text is clicked', () => { + fixture.componentInstance.nzTrigger = 'both'; + fixture.detectChanges(); + let text = componentElement.querySelector('span'); + text!.click(); + fixture.detectChanges(); + let editingTextArea = componentElement.querySelector('textarea'); + expect(editingTextArea).not.toBeNull(); + }); + + it('in "text" trigger state, should start editing when text is clicked', () => { + fixture.componentInstance.nzTrigger = 'text'; + fixture.detectChanges(); + let text = componentElement.querySelector('span'); + text!.click(); + fixture.detectChanges(); + let editingTextArea = componentElement.querySelector('textarea'); + expect(editingTextArea).not.toBeNull(); + }); + + it('in "icon" trigger state, should not start editing when text is clicked', () => { + fixture.componentInstance.nzTrigger = 'icon'; + fixture.detectChanges(); + let text = componentElement.querySelector('span'); + text!.click(); + fixture.detectChanges(); + let editingTextArea = componentElement.querySelector('textarea'); + expect(editingTextArea).toBeNull(); + }); }); @Component({ @@ -600,6 +652,7 @@ export class NzTestTypographyCopyComponent { nzEditable [nzEditIcon]="icon" [nzEditTooltip]="tooltip" + [nzTriggerType]="nzTrigger" (nzContentChange)="onChange($event)" [nzContent]="str" >

@@ -610,6 +663,7 @@ export class NzTestTypographyEditComponent { str = 'This is an editable text.'; icon = 'edit'; tooltip?: string | null; + nzTrigger: NzEditTriggerState = 'icon'; onChange = (text: string): void => { this.str = text; From a10a874e5fbf1eb23cc1eecc7bf782304e24a274 Mon Sep 17 00:00:00 2001 From: Parsa Arvaneh Date: Sat, 2 Mar 2024 01:36:37 +0330 Subject: [PATCH 3/6] feat(module:typography): more edit triggers --- components/typography/doc/index.en-US.md | 1 + components/typography/doc/index.zh-CN.md | 39 ++++++++++++------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/components/typography/doc/index.en-US.md b/components/typography/doc/index.en-US.md index 6c6a04ac090..0906c853b8a 100644 --- a/components/typography/doc/index.en-US.md +++ b/components/typography/doc/index.en-US.md @@ -26,6 +26,7 @@ import { NzTypographyModule } from 'ng-zorro-antd/typography'; | `[nzContent]` | Component content | `string` | - | | | `[nzCopyable]` | Can copy, require use `[nzContent]` | `boolean` | `false` | | | `[nzEditable]` | Editable, require use `[nzContent]` | `boolean` | `false` | | +| `[nzTriggerType]` | Edit mode trigger, require use `[nzContent]` | `icon \| text \| both` | `icon` | | | `[nzCopyIcons]` | Custom copy icons | `[string \| TemplateRef, string \| TemplateRef]` | `['copy', 'check']` | ✅ | | `[nzCopyTooltips]` | Custom tooltips text, hide when it is `null` | `null \| [string \| TemplateRef, string \| TemplateRef]` | - | ✅ | | `[nzEditIcon]` | Custom edit icon | `string \| TemplateRef` | `'edit'` | ✅ | diff --git a/components/typography/doc/index.zh-CN.md b/components/typography/doc/index.zh-CN.md index a5f2755004a..8b4a9690358 100644 --- a/components/typography/doc/index.zh-CN.md +++ b/components/typography/doc/index.zh-CN.md @@ -22,22 +22,23 @@ import { NzTypographyModule } from 'ng-zorro-antd/typography'; ### [nz-typography]:standalone -| 参数 | 说明 | 类型 | 默认值 | 全局配置 | -| ------------------- | --------------------------------------------------- | -------------------------------------------------------------------- | ------------------- | -------- | -| `[nzContent]` | 组件内容 | `string` | - | -| `[nzCopyable]` | 是否可拷贝,需要配合 `[nzContent]` 使用 | `boolean` | `false` | -| `[nzEditable]` | 是否可编辑,需要配合 `[nzContent]` 使用 | `boolean` | `false` | -| `[nzCopyIcons]` | 自定义拷贝图标 | `[string \| TemplateRef, string \| TemplateRef]` | `['copy', 'check']` | ✅ | -| `[nzCopyTooltips]` | 自定义提示文案,为 `null` 时隐藏文案 | `null \| [string \| TemplateRef, string \| TemplateRef]` | - | ✅ | -| `[nzEditIcon]` | 自定义编辑图标 | `string \| TemplateRef` | `'edit'` | ✅ | -| `[nzEditTooltip]` | 自定义提示文案,为 `null` 时隐藏文案 | `null \| string \| TemplateRef` | - | ✅ | -| `[nzEllipsis]` | 自动溢出省略,动态内容时需要配合 `[nzContent]` 使用 | `boolean` | `false` | -| `[nzExpandable]` | 自动溢出省略时是否可展开 | `boolean` | `false` | | -| `[nzSuffix]` | 自动溢出省略时的文本后缀 | `string` | - | | -| `[nzCopyText]` | 自定义被拷贝的文本 | `string` | - | | -| `[nzDisabled]` | 禁用文本 | `boolean` | `false` | | -| `[nzEllipsisRows]` | 自动溢出省略时省略行数 | `number` | `1` | ✅ | -| `[nzType]` | 文本类型 | `'secondary' \| 'warning' \| 'danger' \| 'success'` | - | | -| `(nzContentChange)` | 当用户提交编辑内容时触发 | `EventEmitter` | - | | -| `(nzExpandChange)` | 展开省略文本时触发 | `EventEmitter` | - | | -| `(nzOnEllipsis)` | 当省略状态变化时触发 | `EventEmitter` | - | | +| 参数 | 说明 | 类型 | 默认值 | 全局配置 | +| ------------------- | --------------------------------------------------- | -------------------------------------------------------------------- | -------- | -------- | +| `[nzContent]` | 组件内容 | `string` | - | | +| `[nzCopyable]` | 是否可拷贝,需要配合 `[nzContent]` 使用 | `boolean` | `false` | | +| `[nzEditable]` | 是否可编辑,需要配合 `[nzContent]` 使用 | `boolean` | `false` | | +| `[nzEditable]` | 是否可编辑,需要配合 `[nzContent]` 使用 | `boolean` | `false` | | +| `[nzTriggerType]` | 编辑模式触发器类型, 需要配合 `[nzContent]` 使用 | `icon \| text \| both` | `icon` | | +| `[nzCopyTooltips]` | 自定义提示文案,为 `null` 时隐藏文案 | `null \| [string \| TemplateRef, string \| TemplateRef]` | - | ✅ | +| `[nzEditIcon]` | 自定义编辑图标 | `string \| TemplateRef` | `'edit'` | ✅ | +| `[nzEditTooltip]` | 自定义提示文案,为 `null` 时隐藏文案 | `null \| string \| TemplateRef` | - | ✅ | +| `[nzEllipsis]` | 自动溢出省略,动态内容时需要配合 `[nzContent]` 使用 | `boolean` | `false` | | +| `[nzExpandable]` | 自动溢出省略时是否可展开 | `boolean` | `false` | | +| `[nzSuffix]` | 自动溢出省略时的文本后缀 | `string` | - | | +| `[nzCopyText]` | 自定义被拷贝的文本 | `string` | - | | +| `[nzDisabled]` | 禁用文本 | `boolean` | `false` | | +| `[nzEllipsisRows]` | 自动溢出省略时省略行数 | `number` | `1` | ✅ | +| `[nzType]` | 文本类型 | `'secondary' \| 'warning' \| 'danger' \| 'success'` | - | | +| `(nzContentChange)` | 当用户提交编辑内容时触发 | `EventEmitter` | - | | +| `(nzExpandChange)` | 展开省略文本时触发 | `EventEmitter` | - | | +| `(nzOnEllipsis)` | 当省略状态变化时触发 | `EventEmitter` | - | | From d426202b8b69f2cc6aff00adfa73c155a8fa7a76 Mon Sep 17 00:00:00 2001 From: Parsa Arvaneh Date: Sun, 14 Jul 2024 17:34:37 +0330 Subject: [PATCH 4/6] feat(module:typography): more edit triggers --- components/typography/typography.component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/typography/typography.component.ts b/components/typography/typography.component.ts index 9d8ee853f85..658d62870a7 100644 --- a/components/typography/typography.component.ts +++ b/components/typography/typography.component.ts @@ -56,7 +56,11 @@ const EXPAND_ELEMENT_CLASSNAME = 'ant-typography-expand'; template: ` - {{ content }} + @if (nzEllipsis) { + {{ content }} + } @else { + {{ content }} + } Date: Wed, 17 Jul 2024 11:36:03 +0330 Subject: [PATCH 5/6] feat(module:typography): more edit triggers --- components/typography/demo/interactive.ts | 12 ++++--- components/typography/text-edit.component.ts | 34 ++++++++++--------- components/typography/typography.component.ts | 4 +-- components/typography/typography.spec.ts | 16 ++++----- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/components/typography/demo/interactive.ts b/components/typography/demo/interactive.ts index d962a677b5b..7dd09b55a7c 100644 --- a/components/typography/demo/interactive.ts +++ b/components/typography/demo/interactive.ts @@ -1,7 +1,5 @@ import { Component } from '@angular/core'; -import { NzEditTriggerState } from 'ng-zorro-antd/typography/text-edit.component'; - @Component({ selector: 'nz-demo-typography-interactive', template: ` @@ -24,7 +22,12 @@ import { NzEditTriggerState } from 'ng-zorro-antd/typography/text-edit.component

-

+

Replace copy text.

; @Component({ selector: 'nz-text-edit', @@ -45,19 +45,21 @@ export type NzEditTriggerState = (typeof nzEditTriggerStates)[number]; - - - + @if (nzTriggerType.includes('icon')) { + + + + } `, changeDetection: ChangeDetectionStrategy.OnPush, @@ -73,7 +75,7 @@ export class NzTextEditComponent implements OnInit { @Input() text?: string; @Input() icon: NzTSType = 'edit'; - @Input() nzTriggerType: NzEditTriggerState = 'icon'; + @Input() nzTriggerType: NzEditTriggerState = ['icon']; @Input() tooltip?: null | NzTSType; @Output() readonly startEditing = new EventEmitter(); @Output() readonly endEditing = new EventEmitter(true); diff --git a/components/typography/typography.component.ts b/components/typography/typography.component.ts index 658d62870a7..911ed2857ea 100644 --- a/components/typography/typography.component.ts +++ b/components/typography/typography.component.ts @@ -151,7 +151,7 @@ export class NzTypographyComponent implements OnInit, AfterViewInit, OnDestroy, @Input() nzType: 'secondary' | 'warning' | 'danger' | 'success' | undefined; @Input() nzCopyText: string | undefined; @Input() nzSuffix: string | undefined; - @Input() nzTriggerType: NzEditTriggerState = 'icon'; + @Input() nzTriggerType: NzEditTriggerState = ['icon']; @Output() readonly nzContentChange = new EventEmitter(); @Output() readonly nzCopy = new EventEmitter(); @Output() readonly nzExpandChange = new EventEmitter(); @@ -219,7 +219,7 @@ export class NzTypographyComponent implements OnInit, AfterViewInit, OnDestroy, } onTextClickEdit(): void { - if (this.nzEditable && (this.nzTriggerType === 'text' || this.nzTriggerType === 'both')) { + if (this.nzEditable && this.nzTriggerType.includes('text')) { this.textEditRef?.onClick(); } } diff --git a/components/typography/typography.spec.ts b/components/typography/typography.spec.ts index 7cab6f08503..f518a084988 100644 --- a/components/typography/typography.spec.ts +++ b/components/typography/typography.spec.ts @@ -546,28 +546,28 @@ describe('change detection behavior', () => { }); it('should have default edit trigger option', () => { - expect(fixture.componentInstance.nzTrigger).toEqual('icon'); + expect(fixture.componentInstance.nzTrigger).toEqual(['icon']); }); it('should have edit button in "both" and "icon" trigger state', () => { - fixture.componentInstance.nzTrigger = 'both'; + fixture.componentInstance.nzTrigger = ['text', 'icon']; fixture.detectChanges(); let editButton = componentElement.querySelector('.ant-typography-edit'); expect(editButton).not.toBeNull(); - fixture.componentInstance.nzTrigger = 'icon'; + fixture.componentInstance.nzTrigger = ['icon']; fixture.detectChanges(); editButton = componentElement.querySelector('.ant-typography-edit'); expect(editButton).not.toBeNull(); - fixture.componentInstance.nzTrigger = 'text'; + fixture.componentInstance.nzTrigger = ['text']; fixture.detectChanges(); editButton = componentElement.querySelector('.ant-typography-edit'); expect(editButton).toBeNull(); }); it('in "both" trigger state, should start editing when text is clicked', () => { - fixture.componentInstance.nzTrigger = 'both'; + fixture.componentInstance.nzTrigger = ['text', 'icon']; fixture.detectChanges(); let text = componentElement.querySelector('span'); text!.click(); @@ -577,7 +577,7 @@ describe('change detection behavior', () => { }); it('in "text" trigger state, should start editing when text is clicked', () => { - fixture.componentInstance.nzTrigger = 'text'; + fixture.componentInstance.nzTrigger = ['text']; fixture.detectChanges(); let text = componentElement.querySelector('span'); text!.click(); @@ -587,7 +587,7 @@ describe('change detection behavior', () => { }); it('in "icon" trigger state, should not start editing when text is clicked', () => { - fixture.componentInstance.nzTrigger = 'icon'; + fixture.componentInstance.nzTrigger = ['icon']; fixture.detectChanges(); let text = componentElement.querySelector('span'); text!.click(); @@ -663,7 +663,7 @@ export class NzTestTypographyEditComponent { str = 'This is an editable text.'; icon = 'edit'; tooltip?: string | null; - nzTrigger: NzEditTriggerState = 'icon'; + nzTrigger: NzEditTriggerState = ['icon']; onChange = (text: string): void => { this.str = text; From 7f4b0e6a088e1bbe2596f0f529d9aa9ce29cad0c Mon Sep 17 00:00:00 2001 From: Parsa Arvaneh Date: Wed, 17 Jul 2024 11:56:53 +0330 Subject: [PATCH 6/6] feat(module:typography): more edit triggers