open-pioneer / trails-openlayers-base-packages

Common OpenLayers packages for the Open Pioneer Trails client framework.
Apache License 2.0
8 stars 6 forks source link

[Search] Make CustomComponents more adjustable #360

Open artmarks opened 3 weeks ago

artmarks commented 3 weeks ago

Issue description

We need a specific info message if there is no result found in the search. The message should have a certain format and coloring.

Discussion

To realize this we could create a new optional prop customComponents that looks like this:

export interface CustomComponents {
    Menu?: ComponentType<MenuProps<SearchOption, false, SearchGroupOption>> | undefined,
    Input?: ComponentType<InputProps<SearchOption, false, SearchGroupOption>> | undefined,
    SingleValue?: ComponentType<SingleValueProps<SearchOption, false, SearchGroupOption>> | undefined,
    Option?: ComponentType<OptionProps<SearchOption, false, SearchGroupOption>> | undefined,
    NoOptionsMessage?: ComponentType<NoticeProps<SearchOption, false, SearchGroupOption>> | undefined,
    LoadingMessage?: ComponentType<NoticeProps<SearchOption, false, SearchGroupOption>> | undefined,
    ValueContainer?: ComponentType<ValueContainerProps<SearchOption, false, SearchGroupOption>> | undefined,
    IndicatorsContainer?: ComponentType<IndicatorsContainerProps<SearchOption, false, SearchGroupOption>> | undefined,
    ClearIndicator?: ComponentType<ClearIndicatorProps<SearchOption, false, SearchGroupOption>> | undefined
}

and exchange thoose given components with the defaults ones in useCustomComponents.

We would also be open to other suggestions to our issue :)

Validations

mbeckem commented 5 days ago

I wouldn't go as far as exposing all possible options that react-select gives us. I'd like to preserve the option to switch to another component in the future. Exposing an API that is very close to react-select's functionality would make that very hard. The following features may be a good compromise for the time being (with PRs being highly welcome):

I think other 'overrides' are a bit out of scope at the moment and would need a good justification before thinking about implementing them.