UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

86 lines (85 loc) 3.97 kB
import BaseLayer from '../../models/layers/baselayer.js'; import Feature from 'ol/Feature.js'; import { Geometry } from 'ol/geom.js'; import State from '../state/state.js'; import IGirafeContext from '../context/icontext.js'; /** * Checks if the system prefers dark mode. * Falls back safely if matchMedia is not supported. * @returns True if system is in dark mode. */ export declare const systemIsInDarkMode: () => boolean; /** * Checks if on Safari. * @returns True if on Safari. */ export declare const isSafari: () => boolean; /** * Checks if on Firefox. * @returns True if on Firefox. */ export declare const isFirefox: () => boolean; /** * Returns a valid index within the given maximum index. * Out of bound index loops back to the first valid index. * @param index - The index to validate. * @param maxIndex - The maximum index. If not provided or 0, returns 0. * @returns The valid index. */ export declare const getValidIndex: (index: number, maxIndex?: number) => number; /** * Returns a value bounded between a minimum and maximum limit. * @returns The bounded value. */ export declare const minMax: (value: number, minLimit: number, maxLimit: number) => number; /** * Transforms a hex string into rgba values. * @param hex - A hex color, starting with '#' and including 3 (=shorthand), 6 (=default) or 8 (=including alpha) values. * @returns an array of rgba values: R, G, B [0-255], alpha [0-1]. Or null if the hex color is invalid. */ export declare const hexToRgbaArray: (hex: string) => [number, number, number, number] | null; /** * Transforms a rgb string into rgba values. * @param rgbaStr - A rgb or rgba color, starting with 'rgb' and including 3 or 4 (=including alpha) values. * @returns an array of rgba values: R, G, B [0-255] and alpha [0-1]. Or null if the rgb string is invalid. */ export declare const rgbStrToRgbaArray: (rgbaStr: string) => [number, number, number, number] | null; /** * Transform a color string to an array of rgba values. * @param color A string representing a color. Can be of type hex ('#0033ff') or rgb(a) ('rgba(255, 23, 15, 0.5)'). * @returns an array of rgba values: R, G, B [0-255] and alpha [0-1]. Or null if the color isn't in a valid format. */ export declare const colorToRgbaArray: (color: string) => [number, number, number, number] | null; /** * Check whether the provided text is a matching the correct email form */ export declare const isValidEmail: (email: string) => boolean; /** * Applies the given Opacity to the given Layers (if they have such a Property). * @param opacity Value of Opacity * @param layers Layers to apply it * @param callback Optional Callback after Opacity has been applied */ export declare const applyOpacityToLayers: (opacity: number, layers: BaseLayer[], callback?: (layer: BaseLayer) => void) => void; /** * Applies the given Array of Features to the Selection (<code>state.selection.selectedFeatures</code>) depending on the * given SelectionMode (via <code>state.selection.selectionMode</code>). * @param features Array of Features to add/replace/remove to/from existing selected Features * @param state The State to apply the given Features */ export declare const applyFeaturesToSelection: (features: Feature<Geometry>[], state: State) => void; export declare const linkify: (str: string) => string; /** * Apply default prefix to a relative URL * Is usefull on the demo website for metadata or some images urls * @param context * @param metadataUrl * @returns */ export declare function applyDefaultPrefixToUrl(context: IGirafeContext, metadataUrl?: string): string | undefined; /** * Splits a String containing Numbers into an Array of Numbers. The Separator is a comma. Or returns * <code>undefined</code> if the input is <code>undefined</code> * @param numbersAsString The String containing Numbers. */ export declare const splitTrimAndConvertToNumber: (numbersAsString: string | undefined) => number[] | undefined;