geostyler
Version:
Framework for styling geodata
57 lines (56 loc) • 2.65 kB
TypeScript
import { default as React } from 'react';
import { Data as GeoStylerData } from 'geostyler-data';
import { ComparisonFilter as GsComparisonFilter, PropertyType } from 'geostyler-style';
type ValidationResult = {
isValid: boolean;
errorMsg: string;
};
interface Validators {
attribute: (attrName: string) => boolean;
operator: (operator: string) => boolean;
value: (value: PropertyType, data?: GeoStylerData, selectedAttribute?: string) => ValidationResult;
}
export interface ComparisonFilterComposableProps {
/**
* A custom filter function which is passed each attribute.
* Should return true to accept each attribute or false to reject it.
*/
attributeNameFilter?: (attributeName: string) => boolean;
/** Mapping function for attribute names of underlying AttributeCombo */
attributeNameMappingFunction?: (originalAttributeName: string) => string;
/** Set true to hide the attribute's type in the AttributeCombo select options */
hideAttributeType?: boolean;
/** Show title of selected item in underlying OperatorCombo */
showOperatorTitles?: boolean;
/** Mapping function for operator names of underlying OperatorCombo */
operatorNameMappingFunction?: (originalOperatorName: string) => string;
/** Mapping function for operator title in underlying OperatorCombo */
operatorTitleMappingFunction?: (originalOperatorName: string) => string;
/** Object aggregating validation functions for attribute, operator and value */
validators?: Validators;
/** Show ui in micro mode. Which disables labels etc. */
microUI?: boolean;
}
export interface ComparisonFilterInternalProps {
/** Initial comparison filter object */
filter?: GsComparisonFilter;
/** Label for the underlying OperatorCombo */
operatorLabel?: string;
/** Placeholder for the underlying OperatorCombo */
operatorPlaceholderString?: string;
/** Validation help text for the underlying OperatorCombo */
operatorValidationHelpString?: string;
/** Callback function for onFilterChange */
onFilterChange?: ((compFilter: GsComparisonFilter) => void);
}
export declare const ComparisonFilterDefaultValidator: (newValue: PropertyType, data: GeoStylerData, selectedAttribute: string) => ValidationResult;
export type ComparisonFilterProps = ComparisonFilterInternalProps & ComparisonFilterComposableProps;
/**
* UI for a ComparisonFilter consisting of
*
* - A combo to select the attribute
* - A combo to select the operator
* - An input field for the value
*/
export declare const ComparisonFilter: React.FC<ComparisonFilterProps>;
export {};