import { IfIncludesParam, IsHashPath, ParamString, ResolveSlash } from '../../types/StringTypes'; import { GetValueFromBeforePath, GetValueFromTransform, IsAllOptional, IsOptional, MakeObjectOptional, MakeUndefinedOptional, MergeObj, MergeParamsAndCreate, PickValue } from '../../types/types'; import { ParamPath, ParamsConfig } from '../Param'; import { SearchParamsPathType, SearchParamsType } from '../SearchParam'; /** * @important This config is not used in children paths */ type PathConfig = { /** * Makes so path works in all routes */ fitInAllRoutes?: boolean; /** * Turns path into a hash path */ hash?: boolean; }; export type AddConfigParamsIntoRoutes>, Params extends Record, ParamsResult extends Record> = { [K in keyof Routes]: Path, IsHashPath> extends true ? PickValue : MergeObj>, IsHashPath> extends true ? PickValue : MergeObj>>, PickValue, PickValue, PickValue, PickValue>; }; export type InjectParamsIntoPathType>, Params extends Record, ParamsResult extends Record> = { [K in keyof Routes]: PathType> extends true ? '' : BaseKey, PickValue]>, IsHashPath> extends true ? PickValue : MergeObj>, IsHashPath> extends true ? PickValue : MergeObj>, PickValue, PickValue>; }; export type PathType, ParamsResult extends Record, SearchParams extends SearchParamsType | undefined, Routes extends Record>, All = IfIncludesParam> = (All extends false ? ({ /** * Method to obtain the true path. * Calling it with `params` will replace the params with the params value on the path. */ get: (params?: SearchParamsPathType) => Key; }) : { /** * Method to obtain the true path. * Calling it with `params` will replace the params with the params value on the path. */ get: IsAllOptional extends true ? (params?: Params & SearchParamsPathType) => Key : (params: Params & SearchParamsPathType) => Key; /** * Hook to receive the params related to the route. * Here all the transform method will transform the params to the desired params. */ useParams: () => ParamsResult; }) & InjectParamsIntoPathType & (IsOptional extends true ? {} : { searchParams: string[]; useSearchParams: () => SearchParams; }) & { /** * Generated string from chain functions. Includes path with `params`. */ path: Key; }; /** * Creates a new path * @param path {string} - path base/start */ export declare function path> = Record>, Params extends Record = Record, ParamsResult extends Record = Record, SearchParams extends SearchParamsType = SearchParamsType>(): Path; export declare function path> = Record>, Params extends Record = Record, ParamsResult extends Record = Record, SearchParams extends SearchParamsType = SearchParamsType, Key extends string = string>(path: Key): Path; export declare function path> = Record>, Params extends Record = Record, ParamsResult extends Record = Record, SearchParams extends SearchParamsType = SearchParamsType, Key extends string = string>(path: Key, config: PathConfig & { hash: true; }): Path, Params, ParamsResult, SearchParams>; export declare function path> = Record>, Params extends Record = Record, ParamsResult extends Record = Record, SearchParams extends SearchParamsType = SearchParamsType, Key extends string = string>(path: Key, config: PathConfig): Path; export declare class Path>, Key extends string, Params extends Record = Record, ParamsResult extends Record = Record, SearchParams extends SearchParamsType = SearchParamsType> { protected _key: Key; protected _params: Params; protected _paramsResult: ParamsResult; protected _routes: Routes; protected _searchParams: SearchParams; protected config: PathConfig; protected paths: Array | string>; protected searchParamsList: string[]; private _includeCurrentURL?; constructor(path?: string, config?: PathConfig); /** * Add's new value to the path. (Add's the value into the path in the calling other). * @param path {string} - new path part */ addPath(path?: string): Path; /** * Makes method `get` to return the current path as hash. * @param currentURL {boolean | ((currentHash: URL) => string | undefined)} @default true */ currentURL(currentURL?: ((currentHash: URL) => string | undefined) | boolean): Path; /** * Add's param to the path. (Add's the param into the path in the calling other). * @param value {string} - param name */ param(value: K): Path]>, MergeParamsAndCreate, MergeParamsAndCreate, SearchParams>; /** * Add's param to the path. (Add's the param into the path in the calling other). * @param value {string} - param name */ param(value: K): Path]>, MergeParamsAndCreate, MergeParamsAndCreate, SearchParams>; /** * Add's param to the path. (Add's the param into the path in the calling other). * @param value {string} - param name */ param = ParamsConfig>(value: ParamPath): Path]>, MergeParamsAndCreate>, MergeParamsAndCreate> ? Config['optional'] : false, GetValueFromTransform>, SearchParams>; /** * Add's param to the path. (Add's the param into the path in the calling other). * @param value {string} - param name * @param config {ParamsConfig} - param configuration. */ param = ParamsConfig>(value: K, config: Config): Path]>, MergeParamsAndCreate>, MergeParamsAndCreate> ? Config['optional'] : false, GetValueFromTransform>, SearchParams>; /** * Children path's of current path. * * @param routes {Record>} - object containing the current path children path's */ routes>>(routes: S): Path; /** * Add's param to the path. (Add's the param into the path in the calling other). * @param value {string} - param name * @param config {ParamsConfig} - param configuration. */ searchParams(searchParams: SP): Path>>; protected clone(): Path; protected createPath(previousPaths?: Array | string>): any; private extractSearchParams; } export {};