@koalarx/ui
Version:
Koala UI is a modern and accessible component library designed to speed up interface development in Angular projects. With simple integration and clear documentation, you can easily build robust and visually appealing applications.
74 lines (69 loc) • 4.77 kB
TypeScript
import * as _angular_core from '@angular/core';
import { Injector, Signal, Type } from '@angular/core';
import * as _angular_common_http from '@angular/common/http';
import { HttpClient, HttpResourceRef } from '@angular/common/http';
import * as rxjs from 'rxjs';
import { GetManyResult, QueryPagination, SortFilterType } from '@koalarx/ui/core/models';
import { AutocompleteOption } from '@koalarx/ui/shared/components/input-field/autocomplete';
import { SelectOption } from '@koalarx/ui/shared/components/input-field/select';
import { DatatableConfig } from '@koalarx/ui/shared/components/datatable';
interface HttpResourceRequestOptions<EntityType> {
debounceTime?: number;
endpoint?: string;
mapOption?: (item: any) => Omit<AutocompleteOption<EntityType> | SelectOption<EntityType> | GetManyResult<EntityType>, 'data'>;
}
declare abstract class HttpBase<EntityType = any, PayloadType = any, QueryType = any> {
protected readonly resource: string;
private readonly appConfig;
protected readonly injector: Injector;
protected readonly http: HttpClient;
protected readonly url: string;
protected readonly hostApi: string;
constructor(resource: string, hostApi?: string);
post<T>(data: PayloadType, endpoint?: string): rxjs.Observable<T>;
put<T>(id: string, data: PayloadType): rxjs.Observable<T>;
patch<T>(id: string, data: any): rxjs.Observable<T>;
delete<T>(id: string): rxjs.Observable<T>;
getMany<TResponse = EntityType>(query: QueryType, endpoint?: string): rxjs.Observable<GetManyResult<TResponse>>;
getById<TResponse = EntityType>(id: string | null): rxjs.Observable<TResponse>;
getManyWithResource<TResponse = EntityType>(query: Signal<QueryType>, { endpoint, mapOption, }?: Omit<HttpResourceRequestOptions<TResponse>, 'debounceTime'>): _angular_common_http.HttpResourceRef<GetManyResult<TResponse> | undefined>;
getByIdWithResource<TResponse = EntityType>(id: Signal<string | null>, endpoint?: string, mapResponse?: (response: TResponse) => TResponse): _angular_common_http.HttpResourceRef<TResponse | undefined>;
getByOneWithResource<TResponse = EntityType>(endpoint: Signal<string | null>, params?: Signal<any>, mapResponse?: (response: TResponse) => TResponse): _angular_common_http.HttpResourceRef<TResponse | undefined>;
getManyForSelector<TResponse = EntityType>(query: QueryType | Signal<QueryType>, mapOption: (item: TResponse) => Omit<AutocompleteOption<TResponse> | SelectOption<TResponse>, 'data'>): _angular_core.ResourceRef<{
data: TResponse;
label: string;
value: string | number | boolean | null;
}[]>;
}
type PaginationType = 'paginator' | 'loadMore';
declare abstract class ListBase<QueryType extends QueryPagination, TEntity = any> {
protected readonly componentFilter?: Type<any> | undefined;
private reloading;
private currentPaginationType;
protected readonly resourceRef: HttpResourceRef<GetManyResult<TEntity> | undefined>;
protected readonly limitPage: _angular_core.WritableSignal<number>;
protected readonly page: _angular_core.WritableSignal<number>;
protected readonly filter: _angular_core.WritableSignal<QueryType>;
protected readonly resource: HttpBase<TEntity, any, QueryType>;
protected readonly totalItemsOnPage: _angular_core.WritableSignal<number>;
protected readonly totalItems: _angular_core.WritableSignal<number>;
protected readonly list: _angular_core.WritableSignal<TEntity[]>;
protected readonly sortFilter: _angular_core.WritableSignal<SortFilterType | null>;
protected readonly paginationType: _angular_core.ModelSignal<PaginationType>;
protected readonly withPagination: _angular_core.Signal<boolean>;
protected readonly datatableConfig: _angular_core.WritableSignal<DatatableConfig>;
queryParams: _angular_core.Signal<QueryType>;
reload: _angular_core.InputSignal<boolean>;
constructor(resource: Type<HttpBase<TEntity, any, QueryType>>, componentFilter?: Type<any> | undefined);
protected sort(sortFilter: SortFilterType): void;
protected reloadList(): void;
protected loadMore(): void;
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ListBase<any, any>, never>;
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<ListBase<any, any>, never, never, { "paginationType": { "alias": "paginationType"; "required": false; "isSignal": true; }; "reload": { "alias": "reload"; "required": false; "isSignal": true; }; }, { "paginationType": "paginationTypeChange"; }, never, never, true, never>;
}
declare abstract class PageBase {
protected reload: _angular_core.WritableSignal<boolean>;
protected reloadList(): void;
}
export { HttpBase, ListBase, PageBase };
export type { HttpResourceRequestOptions };