Extract PowerSearchStringTerm
Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48601912 fbshipit-source-id: 90f67f1ea19ef6ae8b5d92f26894af2ab20fa821
This commit is contained in:
committed by
Facebook GitHub Bot
parent
380e99400f
commit
a9fb5d9863
@@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {Input} from 'antd';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
type PowerSearchStringTermProps = {
|
||||||
|
onCancel: () => void;
|
||||||
|
onChange: (value: string) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const PowerSearchStringTerm: React.FC<PowerSearchStringTermProps> = ({
|
||||||
|
onCancel,
|
||||||
|
onChange,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<Input
|
||||||
|
autoFocus
|
||||||
|
style={{width: 100}}
|
||||||
|
placeholder="..."
|
||||||
|
onBlur={(event) => {
|
||||||
|
const newValue = event.target.value;
|
||||||
|
|
||||||
|
if (!newValue) {
|
||||||
|
onCancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
onChange(newValue);
|
||||||
|
}}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (event.key === 'Enter' || event.key === 'Escape') {
|
||||||
|
event.currentTarget.blur();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -8,9 +8,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {CloseOutlined} from '@ant-design/icons';
|
import {CloseOutlined} from '@ant-design/icons';
|
||||||
import {Button, Input, Space} from 'antd';
|
import {Button, Space} from 'antd';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {FieldConfig, OperatorConfig} from './PowerSearchConfig';
|
import {FieldConfig, OperatorConfig} from './PowerSearchConfig';
|
||||||
|
import {PowerSearchStringTerm} from './PowerSearchStringTerm';
|
||||||
|
|
||||||
export type IncompleteSearchExpressionTerm = {
|
export type IncompleteSearchExpressionTerm = {
|
||||||
field: FieldConfig;
|
field: FieldConfig;
|
||||||
@@ -39,29 +40,14 @@ export const PowerSearchTerm: React.FC<PowerSearchTermProps> = ({
|
|||||||
{searchValueRenderer === 'button' ? (
|
{searchValueRenderer === 'button' ? (
|
||||||
<Button>{searchTerm.searchValue ?? '...'}</Button>
|
<Button>{searchTerm.searchValue ?? '...'}</Button>
|
||||||
) : (
|
) : (
|
||||||
// TODO: Fix width
|
<PowerSearchStringTerm
|
||||||
<Input
|
onCancel={onCancel}
|
||||||
autoFocus
|
onChange={(newValue) => {
|
||||||
style={{width: 100}}
|
|
||||||
placeholder="..."
|
|
||||||
onBlur={(event) => {
|
|
||||||
const newValue = event.target.value;
|
|
||||||
|
|
||||||
if (!newValue) {
|
|
||||||
onCancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
onFinalize({
|
onFinalize({
|
||||||
...searchTerm,
|
...searchTerm,
|
||||||
searchValue: newValue,
|
searchValue: newValue,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event) => {
|
|
||||||
if (event.key === 'Enter' || event.key === 'Escape') {
|
|
||||||
event.currentTarget.blur();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user