Skip to content

Commit 9db42c8

Browse files
committed
Remove private modules of eui and the custom color swatches
1 parent 28f63fc commit 9db42c8

File tree

2 files changed

+10
-69
lines changed

2 files changed

+10
-69
lines changed

src/plugins/vis_type_timeseries/public/application/components/color_picker.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@
2121
// The color picker is not yet accessible.
2222

2323
import React, { useState } from 'react';
24-
import { EuiIconTip, EuiColorPicker, EuiColorPickerSwatch } from '@elastic/eui';
25-
// @ts-ignore
26-
import { useColorPickerState, EuiColorPickerOutput } from '@elastic/eui/lib/services';
24+
import {
25+
EuiIconTip,
26+
EuiColorPicker,
27+
EuiColorPickerProps,
28+
EuiColorPickerSwatch,
29+
} from '@elastic/eui';
2730
import { i18n } from '@kbn/i18n';
28-
import { COLOR_SWATCHES } from './custom_color_swatches';
2931

3032
const COMMAS_NUMS_ONLY_RE = /[^0-9,]/g;
3133

@@ -42,12 +44,10 @@ export interface ColorPickerProps {
4244

4345
export function ColorPicker({ name, value, disableTrash = false, onChange }: ColorPickerProps) {
4446
const initialColorValue = value ? value.replace(COMMAS_NUMS_ONLY_RE, '') : '';
45-
const [color, setColor] = useColorPickerState(initialColorValue);
46-
const [selectedColor, setSelectedColor] = useState(color);
47+
const [color, setColor] = useState(initialColorValue);
4748

48-
const handleColorChange = (text: string, { rgba, hex, isValid }: EuiColorPickerOutput) => {
49-
setColor(text, { hex, isValid });
50-
setSelectedColor(hex);
49+
const handleColorChange: EuiColorPickerProps['onChange'] = (text: string, { rgba, hex }) => {
50+
setColor(text);
5151
const part: ColorProps = {};
5252
part[name] = hex ? `rgba(${rgba.join(',')})` : '';
5353
onChange(part);
@@ -57,7 +57,6 @@ export function ColorPicker({ name, value, disableTrash = false, onChange }: Col
5757
const part: ColorProps = {};
5858
part[name] = null;
5959
onChange(part);
60-
setSelectedColor('');
6160
};
6261

6362
const label = value
@@ -76,8 +75,7 @@ export function ColorPicker({ name, value, disableTrash = false, onChange }: Col
7675
color={color}
7776
secondaryInputDisplay="top"
7877
showAlpha
79-
swatches={COLOR_SWATCHES}
80-
button={<EuiColorPickerSwatch color={selectedColor} aria-label={label} />}
78+
button={<EuiColorPickerSwatch color={color} aria-label={label} />}
8179
/>
8280
{!disableTrash && (
8381
<div className="tvbColorPicker__clear" onClick={handleClear}>

src/plugins/vis_type_timeseries/public/application/components/custom_color_swatches.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)