@tempots/ui
Version:
Provides a higher level of renderables to help fast development with Tempo.
52 lines (51 loc) • 1.62 kB
TypeScript
import { Prop } from '@tempots/dom';
/**
* Represents the data for a location.
*
* @public
*/
export type LocationData = {
/**
* The pathname of the location.
*/
readonly pathname: string;
/**
* The search parameters of the location.
*/
readonly search: Record<string, string>;
/**
* The hash of the location.
*/
readonly hash?: string;
};
/**
* Compares two location objects and returns true if they are equal, false otherwise.
* @param a - The first location object to compare.
* @param b - The second location object to compare.
* @returns True if the location objects are equal, false otherwise.
* @public
*/
export declare const areLocationsEqual: (a: LocationData, b: LocationData) => boolean;
/**
* Converts a URL string into a LocationData object.
* @param url - The URL string to convert.
* @returns The LocationData object representing the URL.
* @public
*/
export declare const locationFromURL: (url: string, baseUrl?: string) => LocationData;
/**
* Sets the location from the given URL and updates the specified property.
* @param prop - The property to update with the new location.
* @param url - The URL from which to extract the location.
* @returns The updated property.
* @public
*/
export declare const setLocationFromUrl: (prop: Prop<LocationData>, url: string) => Prop<LocationData>;
/**
* Returns the full URL based on the provided location data.
*
* @param location - The location data object.
* @returns The full URL string.
* @public
*/
export declare const urlFromLocation: (location: LocationData) => string;