Skip to content

Commit

Permalink
Merge branch 'main' into landing
Browse files Browse the repository at this point in the history
  • Loading branch information
VidhiRambhia authored Dec 3, 2023
2 parents 424e980 + 1d9b0b1 commit f8c0119
Show file tree
Hide file tree
Showing 218 changed files with 1,100 additions and 1,087 deletions.
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/master/cspell.schema.json",
"import": ["node_modules/@taiga-ui/cspell-config/cspell.config.js"],
"import": ["@taiga-ui/cspell-config/cspell.config.js"],
"files": ["*/*.*"],
"ignorePaths": [
".git",
Expand Down
820 changes: 321 additions & 499 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,22 @@
"@playwright/test": "1.40.1",
"@taiga-ui/browserslist-config": "0.4.0",
"@taiga-ui/commitlint-config": "0.4.2",
"@taiga-ui/cspell-config": "0.23.0",
"@taiga-ui/eslint-plugin-experience": "0.38.1",
"@taiga-ui/cspell-config": "0.24.0",
"@taiga-ui/eslint-plugin-experience": "0.39.3",
"@taiga-ui/prettier-config": "0.6.0",
"@taiga-ui/stylelint-config": "0.10.0",
"@taiga-ui/tsconfig": "0.6.0",
"@testing-library/cypress": "10.0.1",
"@tinkoff/ng-event-plugins": "3.1.0",
"@tinkoff/tui-editor": "1.8.4",
"@types/glob": "8.1.0",
"@types/node": "20.10.0",
"@types/node": "20.10.1",
"@types/parse5": "6.0.3",
"@types/webpack-env": "1.18.4",
"angular-http-server": "1.12.0",
"babel-loader": "9.1.3",
"cpy-cli": "5.0.0",
"cspell": "8.0.0",
"cspell": "8.1.0",
"cypress": "13.6.0",
"cypress-real-events": "1.11.0",
"eslint": "8.54.0",
Expand All @@ -153,7 +153,7 @@
"ng-packagr": "12.2.7",
"nx": "17.1.3",
"prettier": "3.1.0",
"rollup": "4.6.0",
"rollup": "4.6.1",
"standard-version": "9.5.0",
"stylelint": "15.11.0",
"ts-loader": "9.5.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class TuiBarChartComponent {
private getMax(values: ReadonlyArray<readonly number[]>, collapsed: boolean): number {
return collapsed
? Math.max(
// eslint-disable-next-line no-restricted-syntax
...values.reduce((result, next) =>
result.map((value, index) => value + next[index]),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
TuiNotificationModule,
TuiPrimitiveTextfieldModule,
TuiTextfieldControllerModule,
TuiTooltipModule,
} from '@taiga-ui/core';
import {
TuiBadgeModule,
Expand All @@ -27,12 +26,12 @@ import {TuiDocDocumentationComponent} from './documentation.component';
import {TuiDocDocumentationPropertyConnectorDirective} from './documentation-property-connector.directive';
import {TuiShowCleanerPipe} from './pipes/cleaner.pipe';
import {TuiGetColorPipe} from './pipes/color.pipe';
import {TuiShowContentTooltip} from './pipes/content-tooltip.pipe';
import {TuiInspectPipe} from './pipes/inspect.pipe';
import {TuiGetOpacityPipe} from './pipes/opacity.pipe';
import {TuiIsOptionalPipe} from './pipes/optional.pipe';
import {TuiIsPrimitivePolymorpheusContentPipe} from './pipes/primitive-polymorpheus-content.pipe';
import {TuiStripOptionalPipe} from './pipes/strip-optional.pipe';
import {TuiDocTypeReferencePipe} from './pipes/type-reference.pipe';

@NgModule({
imports: [
Expand All @@ -42,7 +41,6 @@ import {TuiStripOptionalPipe} from './pipes/strip-optional.pipe';
TuiBadgeModule,
TuiSelectModule,
TuiToggleModule,
TuiTooltipModule,
TuiLinkModule,
TuiInputNumberModule,
TuiModeModule,
Expand All @@ -63,7 +61,7 @@ import {TuiStripOptionalPipe} from './pipes/strip-optional.pipe';
TuiIsOptionalPipe,
TuiShowCleanerPipe,
TuiStripOptionalPipe,
TuiShowContentTooltip,
TuiDocTypeReferencePipe,
TuiDocDocumentationComponent,
TuiIsPrimitivePolymorpheusContentPipe,
TuiDocDocumentationPropertyConnectorDirective,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,30 @@
.t-heading {
font: var(--tui-font-heading-4);
}

.t-code-type {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: start;
}

.t-code-reference {
display: inline-flex;
color: var(--tui-link);
text-decoration: none;
align-items: center;
justify-content: center;
gap: 3px;

&:after {
content: '';
font-size: 1rem;
width: 1rem;
height: 1rem;
background: currentColor;
// TODO: migrate to <tui-icon /> in v4.0
mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="1rem" height="1rem" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>')
center/100%;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,27 @@
</td>
<td class="t-cell">
<span class="type">
<code>{{ propertyConnector.documentationPropertyType }}</code>
<tui-tooltip
*ngIf="propertyConnector.documentationPropertyType | tuiShowContentTooltip"
[content]="content"
[describeId]="propertyConnector.attrName"
>
<ng-template #content>
{{ texts[4] }}
<code class="t-code-type">
<ng-container
*ngFor="
let item of propertyConnector.documentationPropertyType | tuiDocTypeReference;
let last = last
"
>
<a
href="https://github.com/taiga-family/ng-polymorpheus"
rel="noreferrer"
*ngIf="item.reference; else default"
target="_blank"
tuiLink
tuiMode="onDark"
class="t-code-reference"
[attr.href]="item.reference"
>
<code>ng-polymorpheus</code>
{{ item.type }}
</a>
</ng-template>
</tui-tooltip>
<ng-template #default>
{{ item.type }}
</ng-template>
<span *ngIf="!last">&nbsp;|&nbsp;</span>
</ng-container>
</code>
</span>
</td>
<td
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {Inject, Pipe, PipeTransform} from '@angular/core';
import {
TUI_DOC_TYPE_REFERENCE_HANDLER,
TUI_DOC_TYPE_REFERENCE_PARSER,
} from '@taiga-ui/addon-doc/tokens';
import type {TuiDocTypeReferenceParsed} from '@taiga-ui/addon-doc/utils';
import {TuiHandler, TuiStringHandler} from '@taiga-ui/cdk';

@Pipe({name: `tuiDocTypeReference`})
export class TuiDocTypeReferencePipe implements PipeTransform {
constructor(
@Inject(TUI_DOC_TYPE_REFERENCE_PARSER)
private readonly parser: TuiHandler<string, TuiDocTypeReferenceParsed>,
@Inject(TUI_DOC_TYPE_REFERENCE_HANDLER)
private readonly linkHandler?: TuiStringHandler<string | null> | null,
) {}

transform(original: string): ReadonlyArray<{
type: string;
extracted: string;
reference: string | null;
}> {
return this.parser(original)
.map(({type, extracted}) => ({
type,
extracted,
reference: this.linkHandler?.(extracted) ?? null,
}))
.sort((a, b) => b.reference?.localeCompare(a.reference ?? ``) ?? -1);
}
}
2 changes: 1 addition & 1 deletion projects/addon-doc/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export * from './documentation/documentation.module';
export * from './documentation/documentation-property-connector.directive';
export * from './documentation/pipes/cleaner.pipe';
export * from './documentation/pipes/color.pipe';
export * from './documentation/pipes/content-tooltip.pipe';
export * from './documentation/pipes/inspect.pipe';
export * from './documentation/pipes/opacity.pipe';
export * from './documentation/pipes/optional.pipe';
export * from './documentation/pipes/primitive-polymorpheus-content.pipe';
export * from './documentation/pipes/strip-optional.pipe';
export * from './documentation/pipes/type-reference.pipe';
export * from './example/example.component';
export * from './example/example.module';
export * from './example/example.options';
Expand Down
5 changes: 3 additions & 2 deletions projects/addon-doc/components/main/main.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ code:not(pre code) {
align-items: center;
border-radius: 0.25rem;
font-weight: 500;
border: 1px solid var(--tui-base-04);
outline: 1px solid var(--tui-base-04);
font-size: 0.75rem;
padding: 0 0.125rem;
padding: 0 0.3125rem;
margin: 0.125rem 0;
//noinspection CssInvalidPropertyValue
text-wrap: wrap;

Expand Down
1 change: 1 addition & 0 deletions projects/addon-doc/tokens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export * from './scroll-behavior';
export * from './see-also';
export * from './source-code';
export * from './title';
export * from './type-reference-handler';
export * from './url-state-handler';
1 change: 1 addition & 0 deletions projects/addon-doc/tokens/scroll-behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {TUI_REDUCED_MOTION} from '@taiga-ui/core';

/**
* Defines the transition animation for scroll
* @deprecated will be remove in v4.0
*/
export const TUI_DOC_SCROLL_BEHAVIOR = tuiCreateTokenFromFactory<ScrollBehavior>(() =>
inject(TUI_REDUCED_MOTION) ? `auto` : `smooth`,
Expand Down
12 changes: 12 additions & 0 deletions projects/addon-doc/tokens/type-reference-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {
TuiDocTypeReferenceParsed,
tuiTypeReferenceParser,
} from '@taiga-ui/addon-doc/utils';
import {tuiCreateToken, TuiHandler, TuiStringHandler} from '@taiga-ui/cdk';

export const TUI_DOC_TYPE_REFERENCE_HANDLER = tuiCreateToken<TuiStringHandler<
string | null
> | null>(null);

export const TUI_DOC_TYPE_REFERENCE_PARSER =
tuiCreateToken<TuiHandler<string, TuiDocTypeReferenceParsed>>(tuiTypeReferenceParser);
1 change: 1 addition & 0 deletions projects/addon-doc/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export * from './raw-load-record';
export * from './sort-pages';
export * from './to-flat-map-pages';
export * from './transliterate-keyboard-layout';
export * from './type-reference-parser';
58 changes: 58 additions & 0 deletions projects/addon-doc/utils/test/type-reference-parser.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {tuiTypeReferenceParser} from '@taiga-ui/addon-doc';

describe(`tuiTypeReferenceParser`, () => {
it(`parse`, () => {
expect(
tuiTypeReferenceParser(`
PolymorpheusContent<TuiValueContentContext<T | G, K | V>>
| Map<T, boolean>
| ReadonlyArray<string | null>
| readonly string[]
| T
| ReadonlyArray<readonly number[]>
| [TuiDay, number][]
| TuiStringHandler<number>
| null
| readonly [number, number]
| 'positive'
| 'negative'
| -1
| 2
| 0
| void
| CustomEvent<TuiIconError>
| TuiComparator<T>
| readonly T[]
| TuiDay
| [TuiTime, TuiTime]
| T[][]
`),
).toEqual([
{
type: `PolymorpheusContent<TuiValueContentContext<T | G, K | V>>`,
extracted: `PolymorpheusContent`,
},
{type: `Map<T, boolean>`, extracted: `Map`},
{type: `ReadonlyArray<string | null>`, extracted: `string`},
{type: `readonly string[]`, extracted: `string`},
{type: `T`, extracted: `unknown`},
{type: `ReadonlyArray<readonly number[]>`, extracted: `number`},
{type: `[TuiDay, number][]`, extracted: `TuiDay`},
{type: `TuiStringHandler<number>`, extracted: `TuiStringHandler`},
{type: `null`, extracted: `null`},
{type: `readonly [number, number]`, extracted: `number`},
{type: `'positive'`, extracted: `string`},
{type: `'negative'`, extracted: `string`},
{type: `-1`, extracted: `number`},
{type: `2`, extracted: `number`},
{type: `0`, extracted: `number`},
{type: `void`, extracted: `void`},
{type: `CustomEvent<TuiIconError>`, extracted: `CustomEvent`},
{type: `TuiComparator<T>`, extracted: `TuiComparator`},
{type: `readonly T[]`, extracted: `unknown`},
{type: `TuiDay`, extracted: `TuiDay`},
{type: `[TuiTime, TuiTime]`, extracted: `TuiTime`},
{type: `T[][]`, extracted: `unknown`},
]);
});
});
30 changes: 30 additions & 0 deletions projects/addon-doc/utils/type-reference-parser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export type TuiDocTypeReferenceParsed = ReadonlyArray<{type: string; extracted: string}>;

export function tuiTypeReferenceParser(types: string): TuiDocTypeReferenceParsed {
const generics = types.match(/<([^>]+)>/g) ?? [];

const escaped = generics
.reduce(
(result, current) => result.replace(current, current.replace(/\|/g, `&`)),
types,
)
.split(`|`)
.map(item => item.trim());

return escaped.reduce<TuiDocTypeReferenceParsed>((result, type) => {
let extracted = type
.trim()
.replace(/readonly /g, ``)
.replace(/\[\]/g, ``);

extracted =
extracted.match(/ReadonlyArray<([^>]+)>/)?.[1]?.split(`&`)?.[0] ?? extracted;
extracted = extracted.match(/\[([^\]]+)\]/)?.[1]?.split(`,`)?.[0] ?? extracted;
extracted = (extracted.split(`<`)?.[0] ?? extracted)?.trim() ?? ``;
extracted = Number.isNaN(parseFloat(extracted)) ? extracted : `number`;
extracted = /^'(.+)'$|^"(.+)"$|^`(.+)`$/.test(extracted) ? `string` : extracted;
extracted = extracted.length === 1 ? `unknown` : extracted;

return result.concat({type: type.replace(/&/g, `|`), extracted});
}, []);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@angular/core';
import {TuiComparator} from '@taiga-ui/addon-table/types';
import {EMPTY_QUERY} from '@taiga-ui/cdk';
import {filter, map} from 'rxjs/operators';
import {delay, filter, map} from 'rxjs/operators';

import {TuiSortableDirective} from './sortable.directive';
import {TuiTableDirective} from './table.directive';
Expand All @@ -20,19 +20,30 @@ export class TuiSortByDirective<T extends Partial<Record<keyof T, any>>> {
@ContentChildren(TuiSortableDirective, {descendants: true})
private readonly sortables: QueryList<TuiSortableDirective<T>> = EMPTY_QUERY;

@Input()
tuiSortBy: string | keyof T | null = null;
@Input('tuiSortBy')
set sortBy(sortBy: string | keyof T | null) {
this.tuiSortBy = sortBy;
this.checkSortables();
}

@Output()
readonly tuiSortByChange = this.table.sorterChange.pipe(
// delay is for getting actual ContentChildren (sortables) https://github.com/angular/angular/issues/38976
delay(0),
filter(() => !!this.sortables.length),
map(sorter => this.getKey(sorter)),
);

tuiSortBy: string | keyof T | null = null;

constructor(
@Inject(TuiTableDirective) private readonly table: TuiTableDirective<T>,
) {}

checkSortables(): void {
this.sortables.forEach(s => s.check());
}

private getKey(sorter: TuiComparator<T> | null): keyof T | null {
return this.sortables.find(s => s.sorter === sorter)?.key || null;
}
Expand Down
Loading

0 comments on commit f8c0119

Please sign in to comment.