Add string_contains operator
Summary: Doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU/edit#heading=h.pg8svtdjlx7 Reviewed By: lblasa Differential Revision: D49226934 fbshipit-source-id: 12d43334e87b0fb502173143d5a19a48cd2fc9ee
This commit is contained in:
committed by
Facebook GitHub Bot
parent
589937bc8f
commit
ceac388eed
@@ -11,16 +11,27 @@ import {OperatorConfig} from '../PowerSearch';
|
||||
|
||||
export type PowerSearchOperatorProcessor = (
|
||||
powerSearchOperatorConfig: OperatorConfig,
|
||||
searchValue: any,
|
||||
value: any,
|
||||
) => boolean;
|
||||
|
||||
export type PowerSearchOperatorProcessorConfig = {
|
||||
[key: string]: PowerSearchOperatorProcessor;
|
||||
};
|
||||
|
||||
export const dataTablePowerSearchOperators = {} satisfies {
|
||||
export const dataTablePowerSearchOperators = {
|
||||
string_contains: () => ({
|
||||
label: 'contains',
|
||||
key: 'string_contains',
|
||||
valueType: 'STRING',
|
||||
}),
|
||||
} satisfies {
|
||||
[key: string]: (...args: any[]) => OperatorConfig;
|
||||
};
|
||||
|
||||
export const dataTablePowerSearchOperatorProcessorConfig =
|
||||
{} satisfies PowerSearchOperatorProcessorConfig;
|
||||
export type PowerSearchOperatorProcessorConfig = {
|
||||
[K in keyof typeof dataTablePowerSearchOperators]: PowerSearchOperatorProcessor;
|
||||
};
|
||||
|
||||
export const dataTablePowerSearchOperatorProcessorConfig = {
|
||||
string_contains: (operator, searchValue, value) =>
|
||||
(value as string)
|
||||
.toLowerCase()
|
||||
.includes((searchValue as string).toLowerCase()),
|
||||
} satisfies PowerSearchOperatorProcessorConfig;
|
||||
|
||||
Reference in New Issue
Block a user