mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
refactor: refactor color picker circluar dependency (#42843)
* refactor: fix color-picker circluar dependency * fix: fix import path
This commit is contained in:
parent
f066df8dc7
commit
e3110e5458
@ -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<
|
||||
|
@ -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;
|
||||
|
@ -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) : '');
|
||||
|
Loading…
Reference in New Issue
Block a user