-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Adding support for multiple occurrences 2. Adding support for multiple highlights 3. Adding support for case-sensitive mode 4. Adding support for regexp
Showing
31 changed files
with
971 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type TuiArrayOrValue<T> = T | readonly T[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type {TuiArrayOrValue} from '@taiga-ui/cdk/types'; | ||
|
||
export function tuiToArray<T>(value: TuiArrayOrValue<T>): readonly T[] { | ||
return value instanceof Array ? value : [value]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
projects/demo/src/modules/directives/highlight/examples/1/index.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
projects/demo/src/modules/directives/highlight/examples/2/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<tui-input | ||
tuiTextfieldIconLeft="tuiIconSearchLarge" | ||
[(ngModel)]="search" | ||
> | ||
Search | ||
</tui-input> | ||
<table | ||
tuiHighlightMultiOccurrences | ||
class="tui-space_top-4" | ||
[tuiHighlight]="search" | ||
> | ||
<thead> | ||
<tr> | ||
<th>Member</th> | ||
<th>Nickname</th> | ||
<th>Fate</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let row of rows"> | ||
<td *ngFor="let cell of row"> | ||
{{ cell }} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> |
20 changes: 20 additions & 0 deletions
20
projects/demo/src/modules/directives/highlight/examples/2/index.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
:host { | ||
display: block; | ||
--tui-highlight-background: var(--tui-primary); | ||
--tui-highlight-radius: 5px; | ||
--tui-highlight-color: var(--tui-base-01); | ||
} | ||
|
||
table { | ||
width: 100%; | ||
border-spacing: 0; | ||
} | ||
|
||
th, | ||
td { | ||
text-align: left; | ||
border: 1px solid var(--tui-base-03); | ||
height: 3.375rem; | ||
padding: 0 1rem; | ||
vertical-align: middle; | ||
} |
34 changes: 34 additions & 0 deletions
34
projects/demo/src/modules/directives/highlight/examples/2/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {NgForOf} from '@angular/common'; | ||
import {Component} from '@angular/core'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiTextfieldControllerModule} from '@taiga-ui/core'; | ||
import {TuiHighlightDirective} from '@taiga-ui/kit'; | ||
import {TuiInputModule} from '@taiga-ui/legacy'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [ | ||
TuiInputModule, | ||
TuiTextfieldControllerModule, | ||
FormsModule, | ||
NgForOf, | ||
TuiHighlightDirective, | ||
], | ||
templateUrl: './index.html', | ||
styleUrls: ['./index.less'], | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export default class ExampleComponent { | ||
protected search = ''; | ||
|
||
protected readonly rows = [ | ||
['King Arthur', '-', 'Arrested'], | ||
['Sir Bedevere', 'The Wise', 'Arrested'], | ||
['Sir Lancelot', 'The Brave', 'Arrested'], | ||
['Sir Galahad', 'The Chaste', 'Killed'], | ||
['Sir Robin', 'The Not-Quite-So-Brave-As-Sir-Lancelot', 'Killed'], | ||
]; | ||
} |
20 changes: 20 additions & 0 deletions
20
projects/demo/src/modules/directives/highlight/examples/3/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<table | ||
tuiHighlightMultiOccurrences | ||
class="tui-space_top-4" | ||
[tuiHighlight]="regexp" | ||
> | ||
<thead> | ||
<tr> | ||
<th>Member</th> | ||
<th>Nickname</th> | ||
<th>Fate</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let row of rows"> | ||
<td *ngFor="let cell of row"> | ||
{{ cell }} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> |
20 changes: 20 additions & 0 deletions
20
projects/demo/src/modules/directives/highlight/examples/3/index.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
:host { | ||
display: block; | ||
--tui-highlight-background: var(--tui-primary); | ||
--tui-highlight-radius: 5px; | ||
--tui-highlight-color: var(--tui-base-01); | ||
} | ||
|
||
table { | ||
width: 100%; | ||
border-spacing: 0; | ||
} | ||
|
||
th, | ||
td { | ||
text-align: left; | ||
border: 1px solid var(--tui-base-03); | ||
height: 3.375rem; | ||
padding: 0 1rem; | ||
vertical-align: middle; | ||
} |
25 changes: 25 additions & 0 deletions
25
projects/demo/src/modules/directives/highlight/examples/3/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {NgForOf} from '@angular/common'; | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiHighlightDirective} from '@taiga-ui/kit'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [NgForOf, TuiHighlightDirective], | ||
templateUrl: './index.html', | ||
styleUrls: ['./index.less'], | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export default class ExampleComponent { | ||
protected readonly rows = [ | ||
['King Arthur', '-', 'Arrested'], | ||
['Sir Bedevere', 'The Wise', 'Arrested'], | ||
['Sir Lancelot', 'The Brave', 'Arrested'], | ||
['Sir Galahad', 'The Chaste', 'Killed'], | ||
['Sir Robin', 'The Not-Quite-So-Brave-As-Sir-Lancelot', 'Killed'], | ||
]; | ||
|
||
protected readonly regexp = [/S[a-z]+/g, /A[a-z]+/g]; | ||
} |
20 changes: 20 additions & 0 deletions
20
projects/demo/src/modules/directives/highlight/examples/4/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<table | ||
tuiHighlightMultiOccurrences | ||
class="tui-space_top-4" | ||
[tuiHighlight]="search | tuiToRegexp" | ||
> | ||
<thead> | ||
<tr> | ||
<th>Member</th> | ||
<th>Nickname</th> | ||
<th>Fate</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let row of rows"> | ||
<td *ngFor="let cell of row"> | ||
{{ cell }} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> |
20 changes: 20 additions & 0 deletions
20
projects/demo/src/modules/directives/highlight/examples/4/index.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
:host { | ||
display: block; | ||
--tui-highlight-background: var(--tui-primary); | ||
--tui-highlight-radius: 5px; | ||
--tui-highlight-color: var(--tui-base-01); | ||
} | ||
|
||
table { | ||
width: 100%; | ||
border-spacing: 0; | ||
} | ||
|
||
th, | ||
td { | ||
text-align: left; | ||
border: 1px solid var(--tui-base-03); | ||
height: 3.375rem; | ||
padding: 0 1rem; | ||
vertical-align: middle; | ||
} |
26 changes: 26 additions & 0 deletions
26
projects/demo/src/modules/directives/highlight/examples/4/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {NgForOf} from '@angular/common'; | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiHighlightDirective, TuiToRegexpPipe} from '@taiga-ui/kit'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [NgForOf, TuiHighlightDirective, TuiToRegexpPipe], | ||
templateUrl: './index.html', | ||
styleUrls: ['./index.less'], | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export default class ExampleComponent { | ||
protected readonly rows = [ | ||
['King Arthur', '-', 'Arrested'], | ||
['Sir Bedevere', 'The Wise', 'Arrested'], | ||
['Sir Lancelot', 'The Brave', 'Arrested'], | ||
['Sir Galahad', 'The Chaste', 'Killed'], | ||
['Sir Robin', 'The Not-Quite-So-Brave-As-Sir-Lancelot', 'Killed'], | ||
]; | ||
|
||
/* cspell:disable-next-line */ | ||
protected readonly search = ['Sir', 'Arrested', 'killed']; | ||
} |
2 changes: 1 addition & 1 deletion
2
projects/demo/src/modules/directives/highlight/examples/import/template.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
```html | ||
<div | ||
class="block" | ||
[tuiHighlight]="query" | ||
[tuiHighlightColor]="'#228B22'" | ||
> | ||
... | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface TuiHighlightOccurrence { | ||
index: number; | ||
length: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'mark[tuiHighlightMark]', | ||
template: '', | ||
styleUrls: ['./highlight.style.less'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TuiHighlightComponent {} |
Oops, something went wrong.