-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(addon-doc):
API
add new component (#9015)
Co-authored-by: taiga-family-bot <[email protected]>
- Loading branch information
1 parent
66f40a6
commit a87b608
Showing
22 changed files
with
549 additions
and
10 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,59 @@ | ||
import {NgForOf, NgIf, NgSwitch, NgSwitchCase} from '@angular/common'; | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
EventEmitter, | ||
Input, | ||
Output, | ||
} from '@angular/core'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {TuiIcon} from '@taiga-ui/core/components/icon'; | ||
import {TuiTextfield} from '@taiga-ui/core/components/textfield'; | ||
import {TuiDataListWrapper} from '@taiga-ui/kit/components/data-list-wrapper'; | ||
import {TuiSwitch} from '@taiga-ui/kit/components/switch'; | ||
import {TuiChevron} from '@taiga-ui/kit/directives/chevron'; | ||
import {TuiInputNumberModule} from '@taiga-ui/legacy/components/input-number'; | ||
import {TuiTextfieldControllerModule} from '@taiga-ui/legacy/directives/textfield-controller'; | ||
|
||
import {TuiInspectPipe} from '../documentation/pipes/inspect.pipe'; | ||
import {TuiDocTypeReferencePipe} from '../documentation/pipes/type-reference.pipe'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'tr[tuiDocAPIItem]', | ||
imports: [ | ||
FormsModule, | ||
NgForOf, | ||
NgIf, | ||
NgSwitch, | ||
NgSwitchCase, | ||
TuiChevron, | ||
TuiDataListWrapper, | ||
TuiDocTypeReferencePipe, | ||
TuiIcon, | ||
TuiInputNumberModule, | ||
TuiInspectPipe, | ||
TuiSwitch, | ||
TuiTextfield, | ||
TuiTextfieldControllerModule, | ||
], | ||
templateUrl: './api-item.template.html', | ||
styleUrls: ['./api-item.style.less'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TuiDocAPIItem<T> { | ||
@Input() | ||
public name = ''; | ||
|
||
@Input() | ||
public type = ''; | ||
|
||
@Input() | ||
public value?: T; | ||
|
||
@Input() | ||
public items: readonly T[] = []; | ||
|
||
@Output() | ||
public readonly valueChange = new EventEmitter<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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
@import '@taiga-ui/core/styles/taiga-ui-local'; | ||
|
||
:host { | ||
box-shadow: inset 0 -1px var(--tui-border-normal); | ||
} | ||
|
||
.t-td { | ||
padding: 1.5rem 2rem 1.5rem 0; | ||
vertical-align: top; | ||
|
||
&:last-child { | ||
padding-inline-end: 0; | ||
text-align: end; | ||
} | ||
} | ||
|
||
.t-name { | ||
display: flex !important; | ||
min-block-size: 1.5rem; | ||
inline-size: fit-content; | ||
margin: 0 0 0.5rem !important; | ||
-webkit-text-fill-color: var(--tui-background-accent-2-pressed); | ||
|
||
&_input { | ||
-webkit-text-fill-color: var(--tui-text-negative); | ||
} | ||
|
||
&_banana { | ||
-webkit-text-fill-color: var(--tui-text-action); | ||
} | ||
|
||
&_output { | ||
-webkit-text-fill-color: var(--tui-status-info); | ||
} | ||
} | ||
|
||
.t-type { | ||
flex-wrap: wrap; | ||
align-items: center; | ||
justify-content: flex-start; | ||
min-block-size: 1.5rem; | ||
margin: 0 !important; | ||
} | ||
|
||
.t-reference { | ||
display: inline-flex; | ||
color: var(--tui-text-action); | ||
text-decoration: none; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 3px; | ||
} | ||
|
||
.t-input { | ||
min-inline-size: 10rem; | ||
margin-block-start: -0.625rem; | ||
} | ||
|
||
@media @tui-mobile { | ||
:host { | ||
gap: 1rem; | ||
padding: 1rem 0; | ||
} | ||
|
||
.t-td { | ||
padding: 0; | ||
|
||
&:last-child { | ||
text-align: start; | ||
} | ||
} | ||
|
||
.t-input { | ||
margin: 0; | ||
} | ||
} |
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,97 @@ | ||
<td class="t-td"> | ||
<code | ||
class="t-name" | ||
[class.t-name_banana]="name.startsWith('[(')" | ||
[class.t-name_input]="name.startsWith('[')" | ||
[class.t-name_output]="name.startsWith('(')" | ||
> | ||
{{ name }} | ||
</code> | ||
<ng-content /> | ||
</td> | ||
<td class="t-td"> | ||
<code class="t-type"> | ||
<ng-container *ngFor="let item of type | tuiDocTypeReference; let last = last"> | ||
<a | ||
*ngIf="item.reference; else default" | ||
target="_blank" | ||
class="t-reference" | ||
[attr.href]="item.reference" | ||
> | ||
{{ item.type }} | ||
<tui-icon | ||
icon="@tui.external-link" | ||
[style.font-size.rem]="1" | ||
/> | ||
</a> | ||
<ng-template #default> | ||
{{ item.type }} | ||
</ng-template> | ||
<span *ngIf="!last"> | </span> | ||
</ng-container> | ||
</code> | ||
</td> | ||
<td class="t-td"> | ||
<tui-textfield | ||
*ngIf="items.length; else noItems" | ||
tuiChevron | ||
tuiTextfieldSize="m" | ||
class="t-input" | ||
[content]="content" | ||
[tuiTextfieldCleaner]="type.includes('null')" | ||
> | ||
<select | ||
placeholder="null" | ||
tuiTextfield | ||
[ngModel]="value ?? null" | ||
(ngModelChange)="valueChange.emit($event)" | ||
></select> | ||
<tui-data-list-wrapper | ||
*tuiTextfieldDropdown | ||
[itemContent]="content" | ||
[items]="items" | ||
/> | ||
</tui-textfield> | ||
<ng-template | ||
#content | ||
let-data | ||
> | ||
<code [style.margin]="0">{{ data | tuiInspectAny }}</code> | ||
</ng-template> | ||
<ng-template #noItems> | ||
<ng-container [ngSwitch]="type"> | ||
<input | ||
*ngSwitchCase="'boolean'" | ||
tuiSwitch | ||
type="checkbox" | ||
[id]="name" | ||
[ngModel]="value" | ||
(ngModelChange)="valueChange.emit($event)" | ||
/> | ||
|
||
<tui-textfield | ||
*ngSwitchCase="'string'" | ||
tuiTextfieldSize="m" | ||
class="t-input" | ||
> | ||
<input | ||
tuiTextfield | ||
[id]="name" | ||
[ngModel]="value || ''" | ||
(ngModelChange)="valueChange.emit($event)" | ||
/> | ||
</tui-textfield> | ||
|
||
<tui-input-number | ||
*ngSwitchCase="'number'" | ||
tuiTextfieldSize="m" | ||
class="t-input" | ||
[nativeId]="name" | ||
[ngModel]="value" | ||
[step]="1" | ||
[tuiTextfieldLabelOutside]="true" | ||
(ngModelChange)="valueChange.emit($event || 0)" | ||
/> | ||
</ng-container> | ||
</ng-template> | ||
</td> |
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,19 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
inject, | ||
ViewEncapsulation, | ||
} from '@angular/core'; | ||
import {TUI_DOC_DOCUMENTATION_TEXTS} from '@taiga-ui/addon-doc/tokens'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'table[tuiDocAPI]', | ||
templateUrl: './api.template.html', | ||
styleUrls: ['./api.style.less'], | ||
encapsulation: ViewEncapsulation.None, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TuiDocAPI { | ||
protected readonly texts = inject(TUI_DOC_DOCUMENTATION_TEXTS); | ||
} |
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,38 @@ | ||
@import '@taiga-ui/core/styles/taiga-ui-local'; | ||
|
||
[tuiDocAPI] { | ||
inline-size: 100%; | ||
|
||
tbody [tuiTitle] { | ||
align-items: flex-start; | ||
color: var(--tui-text-secondary); | ||
padding: 1rem; | ||
box-shadow: 0 1px var(--tui-border-normal); | ||
background: var(--tui-background-base-alt); | ||
} | ||
|
||
th { | ||
padding: 0.5rem 0; | ||
color: var(--tui-text-secondary); | ||
font-weight: normal; | ||
text-align: start; | ||
box-shadow: inset 0 -1px var(--tui-border-normal); | ||
|
||
&:last-child { | ||
text-align: end; | ||
} | ||
} | ||
} | ||
|
||
@media @tui-mobile { | ||
[tuiDocAPI], | ||
[tuiDocAPI] tbody, | ||
[tuiDocAPI] tr { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
th { | ||
display: none; | ||
} | ||
} | ||
} |
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,8 @@ | ||
<thead> | ||
<tr> | ||
<th>{{ texts[2] }}</th> | ||
<th>{{ texts[1] }}</th> | ||
<th>{{ texts[3] }}</th> | ||
</tr> | ||
</thead> | ||
<ng-content /> |
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
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
Oops, something went wrong.