UNPKG

@seplan/diti-ds

Version:

Reusable UI component library developed by DITI (Technology and Innovation Directorate of SEPLAN PI) based on Mantine and Tailwind CSS

79 lines (57 loc) 2.46 kB
import { ClassValue } from 'clsx'; import { OptionsFilter } from '@mantine/core'; declare interface ApiError { message: string; body?: unknown; getErrorMessage(): string; } export declare function buildDjangoErrorMessage(error: DjangoError): string; /** * Legacy alias for formatDjangoErrors * @deprecated Use formatDjangoErrors or getDjangoErrorMessage instead */ export declare const buildErrorMessage: typeof formatDjangoErrors; /** * Build parameters with automatic event scoping * Handles the common pattern of adding evento_id when not null or 'global' */ export declare function buildEventScopedParams({ evento_id, ...params }: ParamsRecord & { evento_id: string | null; }): URLSearchParams; export declare function calculateExpiryTime(expiresIn: number, buffer?: number): number; export declare function cn(...inputs: ClassValue[]): string; export declare const CPF: { format: typeof formatCPF; isValid: typeof isValidCPF; }; export declare type DjangoError = string[] | string | (Record<string, string | string[]> & {}); /** * Função de filtro para o componente Select do Mantine que ignora acentos. * * @example * <Select * searchable * data={options} * filter={filterOptions} * /> */ export declare const filterOptions: OptionsFilter; export declare function formatCPF(cpf: string): string; export declare function formatCurrency(value: number | string): string; export declare function formatDate(date: Date | string, locale?: string, options?: Intl.DateTimeFormatOptions): string; export declare function formatDateTime(date: Date | string, locale?: string): string; /** * Formats Django validation errors into user-friendly messages * Legacy function - prefer getDjangoErrorMessage for new code */ export declare function formatDjangoErrors(errors: DjangoError): string; export declare function getDjangoErrorMessage(error: ApiError): string; export declare function isDjangoValidationError(error: unknown): error is DjangoError; export declare function isValidCPF(cpf: string): boolean; /** * Normalizes text for search by removing accents and converting to lowercase */ export declare function normalizeForSearch(str: string): string; declare type ParamsRecord = Record<string, string | number | boolean | null | undefined>; export declare function removeAccents(str: string): string; export { }