refactor: refactor color picker circluar dependency (#42843)

* refactor: fix color-picker circluar dependency

* fix: fix import path
This commit is contained in:
muxin 2023-06-12 10:11:17 +08:00 committed by GitHub
parent f066df8dc7
commit e3110e5458
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,11 @@
/* eslint-disable class-methods-use-this */
import type { ColorGenInput } from '@rc-component/color-picker';
import { Color as RcColor } from '@rc-component/color-picker';
import { getHex } from './util';
export const toHexFormat = (value?: string, alpha?: boolean) =>
value?.replace(/[^\w/]/gi, '').slice(0, alpha ? 8 : 6) || '';
export const getHex = (value?: string, alpha?: boolean) => (value ? toHexFormat(value, alpha) : '');
export interface Color
extends Pick<

View File

@ -2,8 +2,9 @@ import type { FC } from 'react';
import React, { useEffect, useState } from 'react';
import Input from '../../input';
import type { Color } from '../color';
import { toHexFormat } from '../color';
import type { ColorPickerBaseProps } from '../interface';
import { generateColor, toHexFormat } from '../util';
import { generateColor } from '../util';
interface ColorHexInputProps extends Pick<ColorPickerBaseProps, 'prefixCls'> {
value?: Color;

View File

@ -13,8 +13,3 @@ export const generateColor = (color: ColorGenInput<Color>): Color => {
};
export const getAlphaColor = (color: Color) => getRoundNumber(color.toHsb().a * 100);
export const toHexFormat = (value?: string, alpha?: boolean) =>
value?.replace(/[^\w/]/gi, '').slice(0, alpha ? 8 : 6) || '';
export const getHex = (value?: string, alpha?: boolean) => (value ? toHexFormat(value, alpha) : '');