diff --git a/src/plugins/vis_type_timeseries/public/application/components/color_picker.tsx b/src/plugins/vis_type_timeseries/public/application/components/color_picker.tsx index 8ca9e1a2c5dcb6c..9ca33e3e4295339 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/color_picker.tsx +++ b/src/plugins/vis_type_timeseries/public/application/components/color_picker.tsx @@ -21,11 +21,13 @@ // The color picker is not yet accessible. import React, { useState } from 'react'; -import { EuiIconTip, EuiColorPicker, EuiColorPickerSwatch } from '@elastic/eui'; -// @ts-ignore -import { useColorPickerState, EuiColorPickerOutput } from '@elastic/eui/lib/services'; +import { + EuiIconTip, + EuiColorPicker, + EuiColorPickerProps, + EuiColorPickerSwatch, +} from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { COLOR_SWATCHES } from './custom_color_swatches'; const COMMAS_NUMS_ONLY_RE = /[^0-9,]/g; @@ -42,12 +44,13 @@ export interface ColorPickerProps { export function ColorPicker({ name, value, disableTrash = false, onChange }: ColorPickerProps) { const initialColorValue = value ? value.replace(COMMAS_NUMS_ONLY_RE, '') : ''; - const [color, setColor] = useColorPickerState(initialColorValue); - const [selectedColor, setSelectedColor] = useState(color); + const [color, setColor] = useState(initialColorValue); - const handleColorChange = (text: string, { rgba, hex, isValid }: EuiColorPickerOutput) => { - setColor(text, { hex, isValid }); - setSelectedColor(hex); + const handleColorChange: EuiColorPickerProps['onChange'] = ( + text: string, + { rgba, hex, isValid } + ) => { + setColor(text); const part: ColorProps = {}; part[name] = hex ? `rgba(${rgba.join(',')})` : ''; onChange(part); @@ -57,7 +60,6 @@ export function ColorPicker({ name, value, disableTrash = false, onChange }: Col const part: ColorProps = {}; part[name] = null; onChange(part); - setSelectedColor(''); }; const label = value @@ -76,8 +78,7 @@ export function ColorPicker({ name, value, disableTrash = false, onChange }: Col color={color} secondaryInputDisplay="top" showAlpha - swatches={COLOR_SWATCHES} - button={} + button={} /> {!disableTrash && (
diff --git a/src/plugins/vis_type_timeseries/public/application/components/custom_color_swatches.ts b/src/plugins/vis_type_timeseries/public/application/components/custom_color_swatches.ts deleted file mode 100644 index 42dee8654ca1765..000000000000000 --- a/src/plugins/vis_type_timeseries/public/application/components/custom_color_swatches.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export const COLOR_SWATCHES = [ - '#0F1419', - '#333333', - '#4D4D4D', - '#666666', - '#808080', - '#999999', - '#B3B3B3', - '#CCCCCC', - '#FFFFFF', - '#9F0500', - '#D33115', - '#F44E3B', - '#C45100', - '#E27300', - '#FE9200', - '#FB9E00', - '#FCC400', - '#FCDC00', - '#808900', - '#B0BC00', - '#DBDF00', - '#194D33', - '#68BC00', - '#A4DD00', - '#0C797D', - '#16A5A5', - '#68CCCA', - '#0062B1', - '#009CE0', - '#73D8FF', - '#653294', - '#7B64FF', - '#AEA1FF', - '#AB149E', - '#FA28FF', - '#FDA1FF', -];