diff --git a/src-docs/src/views/expression/expression.js b/src-docs/src/views/expression/expression.js index 894e23856a7..8dff4a6f37f 100644 --- a/src-docs/src/views/expression/expression.js +++ b/src-docs/src/views/expression/expression.js @@ -5,24 +5,39 @@ import { EuiFlexItem, EuiFlexGroup, EuiPopover, - EuiSelect, EuiFieldNumber, EuiExpression, + EuiSelectable, } from '../../../../src/components'; import { useGeneratedHtmlId } from '../../../../src/services'; -// Rise the popovers above GuidePageSideNav -const POPOVER_STYLE = { zIndex: '200' }; - export default () => { const [example1, setExample1] = useState({ isOpen: false, + options: [ + { label: 'count()', checked: 'on' }, + { label: 'average()' }, + { label: 'sum()' }, + { label: 'median()' }, + { label: 'min()' }, + { label: 'max()' }, + ], value: 'count()', }); const [example2, setExample2] = useState({ + isOpen: false, + options: [ + { label: 'Is above', checked: 'on' }, + { label: 'Is below' }, + { label: 'Is exactly' }, + ], + value: 'Is above', + }); + + const [example3, setExample3] = useState({ + isOpen: false, value: 100, - description: 'Is above', }); const expressionPopoverId__1 = useGeneratedHtmlId({ @@ -34,6 +49,11 @@ export default () => { suffix: 'second', }); + const expressionPopoverId__3 = useGeneratedHtmlId({ + prefix: 'expressionPopover', + suffix: 'third', + }); + const openExample1 = () => { setExample1({ ...example1, @@ -43,26 +63,49 @@ export default () => { ...example2, isOpen: false, }); + setExample3({ + ...example3, + isOpen: false, + }); }; - const closeExample1 = () => { + const openExample2 = () => { setExample1({ ...example1, isOpen: false, }); + setExample2({ + ...example2, + isOpen: true, + }); + setExample3({ + ...example3, + isOpen: false, + }); }; - const openExample2 = () => { + const openExample3 = () => { setExample1({ ...example1, isOpen: false, }); setExample2({ ...example2, + isOpen: false, + }); + setExample3({ + ...example3, isOpen: true, }); }; + const closeExample1 = () => { + setExample1({ + ...example1, + isOpen: false, + }); + }; + const closeExample2 = () => { setExample2({ ...example2, @@ -70,72 +113,64 @@ export default () => { }); }; - const changeExample1 = (event) => { + const closeExample3 = () => { + setExample3({ + ...example3, + isOpen: false, + }); + }; + + const changeExample1 = (options) => { setExample1({ - ...example1, - value: event.target.value, + options: options, + isOpen: false, + value: options.filter((option) => option.checked === 'on')[0]?.label, }); }; - const changeExample2Value = (e) => { - const sanitizedValue = parseInt(e.target.value, 10); + const changeExample2 = (options) => { setExample2({ - ...example2, - value: isNaN(sanitizedValue) ? '' : sanitizedValue, + options: options, + isOpen: false, + value: options.filter((option) => option.checked === 'on')[0]?.label, }); }; - const changeExample2Description = (event) => { - setExample2({ - ...example2, - description: event.target.value, + const changeExample3 = (e) => { + setExample3({ + ...example3, + value: e.target.value, }); }; const renderPopover1 = () => ( -