Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@
prizmInputSelectOption
>
<ng-container *ngIf="!parent.isNullish(item); else nullContentTemplate">
@if (parent.selectTranslation$ | async; as dictionary) {
<span
class="text"
#elem
*prizmLet="
item | prizmCallFunc : parent.stringify : $any(parent.nullContent) | prizmToObservable | async as text
item
| prizmCallFunc
: parent.stringify
: $any(
parent.nullContent === parent.nullContentTextKey
? dictionary[parent.nullContentTextKey]
: parent.nullContent
)
| prizmToObservable
| async as text
"
[prizmHint]="text"
[prizmHintHost]="hostHint"
Expand All @@ -36,12 +46,18 @@
{{ text }}
</ng-container>
</span>
}
</ng-container>

<ng-template #nullContentTemplate>
<ng-container *ngIf="parent.nullContent">
<ng-container *polymorphOutlet="parent.nullContent as content">
{{ content }}
@if (parent.selectTranslation$ | async; as dictionary) {
{{
content === parent.nullContentTextKey ? dictionary[parent.nullContentTextKey] : parent.nullContent
}}

}
</ng-container>
</ng-container>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@
(isOpenChange)="opened$$.next($event)"
>
<ng-container>
@if (selectTranslation$ | async; as dictionary) {
<ng-container
*polymorphOutlet="
valueTemplate && editableTemplate as content;
context: {
$implicit: $any(val),
value: val | prizmCallFunc : transformer,
stringify: $any(val | prizmCallFunc : stringify : $any(nullContent) | prizmToObservable | async)
stringify: $any(
val
| prizmCallFunc
: stringify
: $any(nullContent === nullContentTextKey ? dictionary[nullContentTextKey] : nullContent)
| prizmToObservable
| async
)
}
"
>
Expand Down Expand Up @@ -54,8 +62,8 @@
/>
</ng-container>
</ng-container>
}
</ng-container>

<ng-template #editableTemplate>
<div
#focusableElementRef
Expand All @@ -70,26 +78,40 @@
prizmInput
>
<ng-container *ngIf="isNotNullish(val); else placeholderTemplate">
@if (selectTranslation$ | async; as dictionary) {
<ng-container
*polymorphOutlet="
valueTemplate as content;
context: {
$implicit: $any(val),
value: val | prizmCallFunc : transformer,
stringify: $any(
val | prizmCallFunc : stringify : $any(nullContent) | prizmToObservable | async
val
| prizmCallFunc
: stringify
: $any(
nullContent === nullContentTextKey ? dictionary[nullContentTextKey] : nullContent
)
| prizmToObservable
| async
)
}
"
>
<ng-container
*prizmLet="
val | prizmCallFunc : stringify : $any(nullContent) | prizmToObservable | async as text
val
| prizmCallFunc
: stringify
: $any(nullContent === nullContentTextKey ? dictionary[nullContentTextKey] : nullContent)
| prizmToObservable
| async as text
"
>
{{ text }}
</ng-container>
</ng-container>
}
</ng-container>
<ng-template #placeholderTemplate>
<div class="placeholder">{{ placeholder }}</div>
Expand Down Expand Up @@ -124,11 +146,13 @@
</ng-container>
</ng-container>
<ng-template #emptyTemplate>
@if (selectTranslation$ | async; as dictionary) {
<div class="empty-template">
<ng-container *polymorphOutlet="emptyContent as content">
{{ content }}
{{ content || dictionary[emptyContentTextKey] }}
</ng-container>
</div>
}
</ng-template>
</prizm-data-list>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
PolymorphOutletDirective,
} from '../../../directives/polymorph';
import {
EMPTY_CONTENT_TEXT_KEY,
NULL_CONTENT_TEXT_KEY,
PRIZM_SELECT_OPTIONS,
PrizmSelectOptions,
PrizmSelectStringify,
Expand All @@ -42,6 +44,7 @@ import {
shareReplay,
startWith,
switchMap,
take,
takeUntil,
tap,
} from 'rxjs/operators';
Expand Down Expand Up @@ -89,11 +92,12 @@ import { PrizmInputSelectDataListDirective } from './input-select-data-list.dire
import { BooleanInput } from '@angular/cdk/coercion';
import { PrizmScrollbarDirective } from '../../scrollbar/scrollbar.directive';
import { PrizmOverlayComponent } from '../../../modules/overlay/overlay.component';
import { PRIZM_SEARCH_TEXT } from '../../../tokens';
import { PRIZM_SEARCH_TEXT, PRIZM_SELECT } from '../../../tokens';
import { prizmI18nInitWithKey } from '../../../services';
import { PrizmIconsFullComponent } from '@prizm-ui/icons';
import { PrizmIconsFullRegistry } from '@prizm-ui/icons/core';
import { prizmIconsMagnifyingGlass, prizmIconsTriangleDown } from '@prizm-ui/icons/full/source';
import { PrizmLanguageSelect } from '@prizm-ui/i18n';

@Component({
selector: 'prizm-input-select',
Expand Down Expand Up @@ -121,7 +125,6 @@ import { prizmIconsMagnifyingGlass, prizmIconsTriangleDown } from '@prizm-ui/ico
PrizmSelectInputItemComponent,
PrizmDropdownHostComponent,
PrizmToObservablePipe,
PrizmInputSelectOptionDirective,
PrizmIconsFullComponent,
PrizmFocusableDirective,
],
Expand All @@ -135,6 +138,7 @@ import { prizmIconsMagnifyingGlass, prizmIconsTriangleDown } from '@prizm-ui/ico
PrizmInputSelectOptionService,
{ provide: PrizmInputControl, useExisting: PrizmSelectInputComponent },
...prizmI18nInitWithKey(PRIZM_SEARCH_TEXT, 'search'),
...prizmI18nInitWithKey(PRIZM_SELECT, 'select'),
],
exportAs: 'prizmSelectInput',
})
Expand Down Expand Up @@ -212,9 +216,12 @@ export class PrizmSelectInputComponent<T>
@prizmDefaultProp()
emptyContent: PolymorphContent = this.options.emptyContent;

readonly nullContentTextKey = NULL_CONTENT_TEXT_KEY;
readonly emptyContentTextKey = EMPTY_CONTENT_TEXT_KEY;

@Input()
@prizmDefaultProp()
nullContent: PolymorphContent = this.options.nullContent;
nullContent: PolymorphContent = this.options.nullContent ?? this.nullContentTextKey;

override readonly clickable = true;
readonly isPolymorphPrimitive = isPolymorphPrimitive;
Expand Down Expand Up @@ -272,7 +279,8 @@ export class PrizmSelectInputComponent<T>
constructor(
@Inject(PRIZM_SELECT_OPTIONS) private readonly options: PrizmSelectOptions<T>,
@Inject(Injector) injector: Injector,
@Inject(PRIZM_SEARCH_TEXT) readonly searchLabelTranslation$: Observable<string>
@Inject(PRIZM_SEARCH_TEXT) readonly searchLabelTranslation$: Observable<string>,
@Inject(PRIZM_SELECT) readonly selectTranslation$: Observable<PrizmLanguageSelect['select']>
) {
super(injector);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export const PRIZM_SELECT_DEFAULT_OPTIONS: PrizmSelectOptions<unknown> = {
dropdownWidth: '100%',
minDropdownHeight: 0,
maxDropdownHeight: 342,
emptyContent: 'Ничего не найдено',
nullContent: 'Не выбрано',
emptyContent: null,
nullContent: null,
transformer: item => item,
searchMatcher: (searchValue: string, item: unknown): boolean => {
return !!item?.toString()?.toLowerCase().includes(searchValue?.toLowerCase());
Expand Down Expand Up @@ -100,3 +100,6 @@ export const prizmSelectOptionsProvider: (options: Partial<PrizmSelectOptions<un
provide: PRIZM_SELECT_OPTIONS,
useValue: { ...PRIZM_SELECT_DEFAULT_OPTIONS, ...options },
});

export const NULL_CONTENT_TEXT_KEY = 'nullContentText';
export const EMPTY_CONTENT_TEXT_KEY = 'emptyContentText';
3 changes: 3 additions & 0 deletions libs/components/src/lib/tokens/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
PrizmLanguageInputLayoutDateTimeRange,
PrizmLanguageKit,
PrizmLanguagePaginator,
PrizmLanguageSelect,
PrizmLanguageTimePagination,
PrizmLanguageTimePicker,
} from '@prizm-ui/i18n';
Expand Down Expand Up @@ -88,3 +89,5 @@ export const PRIZM_TIME_PAGINATION = new InjectionToken<
export const PRIZM_TIME_PICKER = new InjectionToken<Observable<PrizmLanguageTimePicker['timePicker']>>(
`time picker i18n text`
);

export const PRIZM_SELECT = new InjectionToken<Observable<PrizmLanguageSelect['select']>>(`select i18n text`);
10 changes: 9 additions & 1 deletion libs/i18n/src/lib/interfaces/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export interface PrizmLanguageInputLayout {
};
}

export interface PrizmLanguageSelect {
select: {
nullContentText: string;
emptyContentText: string;
};
}

export interface PrizmLanguageInputLayoutDateTime {
inputLayoutDateTime: {
wrongFormat: string;
Expand Down Expand Up @@ -337,6 +344,7 @@ export interface PrizmLanguage
PrizmLanguageColumnSettings,
PrizmLanguagePaginator,
PrizmLanguageTimePagination,
PrizmLanguageTimePicker {}
PrizmLanguageTimePicker,
PrizmLanguageSelect {}

export type PrizmI18nFn<K> = (lan: PrizmLanguageName) => K | Observable<K>;
2 changes: 2 additions & 0 deletions libs/i18n/src/lib/languages/english/english.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { PRIZM_ENGLISH_TIME_PAGINATION } from './time-pagination';
import { PRIZM_ENGLISH_TIME_PICKER } from './time-picker';
import { PRIZM_ENGLISH_LANGUAGE_KIT } from './kit';
import { PRIZM_ENGLISH_PAGINATOR } from './paginator';
import { PRIZM_ENGLISH_SELECT } from './select';

export const PRIZM_ENGLISH_LANGUAGE = {
name: `english`,
Expand All @@ -27,4 +28,5 @@ export const PRIZM_ENGLISH_LANGUAGE = {
...PRIZM_ENGLISH_PAGINATOR,
...PRIZM_ENGLISH_TIME_PAGINATION,
...PRIZM_ENGLISH_TIME_PICKER,
...PRIZM_ENGLISH_SELECT,
} as PrizmLanguage;
1 change: 1 addition & 0 deletions libs/i18n/src/lib/languages/english/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './column-settings';
export * from './paginator';
export * from './input-layout-date-time';
export * from './input';
export * from './select';
8 changes: 8 additions & 0 deletions libs/i18n/src/lib/languages/english/select.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { PrizmLanguageSelect } from '../../interfaces';

export const PRIZM_ENGLISH_SELECT: PrizmLanguageSelect = {
select: {
nullContentText: 'Is not chosen',
emptyContentText: 'Nothing found',
},
};
1 change: 1 addition & 0 deletions libs/i18n/src/lib/languages/russian/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './column-settings';
export * from './paginator';
export * from './input';
export * from './input-layout-date-time';
export * from './select';
2 changes: 2 additions & 0 deletions libs/i18n/src/lib/languages/russian/russian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { PRIZM_RUSSIAN_TIME_PAGINATION } from './time-pagination';
import { PRIZM_RUSSIAN_TIME_PICKER } from './time-picker';
import { PRIZM_RUSSIAN_LANGUAGE_KIT } from './kit';
import { PRIZM_RUSSIAN_PAGINATOR } from './paginator';
import { PRIZM_RUSSIAN_SELECT } from './select';

export const PRIZM_RUSSIAN_LANGUAGE = {
name: `russian`,
Expand All @@ -27,4 +28,5 @@ export const PRIZM_RUSSIAN_LANGUAGE = {
...PRIZM_RUSSIAN_PAGINATOR,
...PRIZM_RUSSIAN_TIME_PAGINATION,
...PRIZM_RUSSIAN_TIME_PICKER,
...PRIZM_RUSSIAN_SELECT,
} as PrizmLanguage;
8 changes: 8 additions & 0 deletions libs/i18n/src/lib/languages/russian/select.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { PrizmLanguageSelect } from '../../interfaces';

export const PRIZM_RUSSIAN_SELECT: PrizmLanguageSelect = {
select: {
nullContentText: 'Не выбрано',
emptyContentText: 'Ничего не найдено',
},
};