@easyv/react-components 0.3.13 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@
6
6
  * pures - 多纯色集合
7
7
  */
8
8
  export declare type ColorType = 'pure' | 'linear' | 'pures' | 'range';
9
- interface StopItem {
9
+ export interface StopItem {
10
10
  /**
11
11
  * 偏移量
12
12
  * 0 - 100
@@ -58,4 +58,3 @@ export interface Color {
58
58
  hsv: HSV;
59
59
  alpha: number;
60
60
  }
61
- export {};
@@ -1,19 +1,13 @@
1
- import { ColorValueMap } from './interface';
2
- export declare function toHex(x: any): string;
1
+ import { ColorValueMap, StopItem } from './interface';
2
+ export declare function toHex(x: number | string): string;
3
3
  export declare function resolveColor(colorParam: string): {
4
- r?: undefined;
5
- g?: undefined;
6
- b?: undefined;
7
- a?: undefined;
8
- hex?: undefined;
9
- } | {
10
- r: any;
11
- g: any;
12
- b: any;
13
- a: any;
4
+ r: number;
5
+ g: number;
6
+ b: number;
7
+ a: number;
14
8
  hex: string;
15
9
  };
16
- export declare function transformColor(color: any, a: any): string | undefined;
10
+ export declare function transformColor(color: string, a: number): string;
17
11
  export declare function getBackgroundAccordingColor(color: any, fixedAngle?: number): {
18
12
  backgroundImage: string;
19
13
  background?: undefined;
@@ -21,7 +15,7 @@ export declare function getBackgroundAccordingColor(color: any, fixedAngle?: num
21
15
  background: any;
22
16
  backgroundImage?: undefined;
23
17
  } | undefined;
24
- export declare function getMiddleColor(colors: any, offset: any): any;
18
+ export declare function getMiddleColor(colors: StopItem[], offset: number): any;
25
19
  export declare function getHexValue(hex: string): string;
26
20
  export declare function getLinearGradientStyle(color: ColorValueMap['linear']): {
27
21
  backgroundImage: string;
@@ -1,42 +1,51 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
2
  import tinycolor from 'tinycolor2';
3
3
  export function toHex(x) {
4
- return ('0' + parseInt(x).toString(16)).slice(-2);
4
+ return ('0' + parseInt(x + '').toString(16)).slice(-2);
5
5
  }
6
6
  export function resolveColor(colorParam) {
7
7
  if (!colorParam || typeof colorParam !== 'string') {
8
- return {};
8
+ return {
9
+ r: 255,
10
+ g: 255,
11
+ b: 255,
12
+ a: 1,
13
+ hex: '#ffffff'
14
+ };
9
15
  }
10
16
 
11
17
  // 转为小写并去除空格
12
- var color = colorParam.toLowerCase().replace(/\s+/g, '');
13
- var hexReg = /^#([0-9|a-f]{3}|[0-9|a-f]{6})$/;
14
- var rgbReg = /^(rgb\(\d+,\d+,\d+\)|rgba\(\d+,\d+,\d+,(\d+)?(\.)?(\d+)?\))$/;
15
- // const rgbReg1 = /^(rgb\(\d+,\d+,\d+\)|rgba\((\d+)?(\.)?(\d+)?,(\d+)?(\.)?(\d+)?,(\d+)?(\.)?(\d+)?,(\d+)?(\.)?(\d+)?\))$/;
18
+ // const color = colorParam.toLowerCase().replace(/\s+/g, '');
19
+ // const hexReg = /^#([0-9|a-f]{3}|[0-9|a-f]{6})$/;
20
+ // const rgbReg = /^(rgb\(\d+,\d+,\d+\)|rgba\(\d+,\d+,\d+,(\d+)?(\.)?(\d+)?\))$/;
16
21
 
17
- var r, g, b, a;
18
- if (hexReg.test(color)) {
19
- if (color.length === 4) {
20
- r = parseInt(color.slice(1, 2) + color.slice(1, 2), 16);
21
- g = parseInt(color.slice(2, 3) + color.slice(2, 3), 16);
22
- b = parseInt(color.slice(3, 4) + color.slice(3, 4), 16);
23
- } else {
24
- r = parseInt(color.slice(1, 3), 16);
25
- g = parseInt(color.slice(3, 5), 16);
26
- b = parseInt(color.slice(5, 7), 16);
27
- }
28
- a = 1;
29
- } else if (rgbReg.test(color)) {
30
- var colors = color.replace(/rgba|rgb|\(|\)/g, '').split(',');
31
- r = Number(colors[0]);
32
- g = Number(colors[1]);
33
- b = Number(colors[2]);
34
- a = colors.length === 4 ? Number(colors[3]) : 1;
35
- } else {
36
- return {};
37
- }
22
+ // let r, g, b, a;
23
+ // if (hexReg.test(color)) {
24
+ // if (color.length === 4) {
25
+ // r = parseInt(color.slice(1, 2) + color.slice(1, 2), 16);
26
+ // g = parseInt(color.slice(2, 3) + color.slice(2, 3), 16);
27
+ // b = parseInt(color.slice(3, 4) + color.slice(3, 4), 16);
28
+ // } else {
29
+ // r = parseInt(color.slice(1, 3), 16);
30
+ // g = parseInt(color.slice(3, 5), 16);
31
+ // b = parseInt(color.slice(5, 7), 16);
32
+ // }
33
+ // a = 1;
34
+ // } else if (rgbReg.test(color)) {
35
+ // let colors = color.replace(/rgba|rgb|\(|\)/g, '').split(',');
36
+ // r = Number(colors[0]);
37
+ // g = Number(colors[1]);
38
+ // b = Number(colors[2]);
39
+ // a = colors.length === 4 ? Number(colors[3]) : 1;
40
+ // } else {
41
+ // return {};
42
+ // }
38
43
 
39
- // return { r: Math.floor(r), g: Math.floor(g), b: Math.floor(b), a, hex: `#${toHex(r)}${toHex(g)}${toHex(b)}` };
44
+ var _tinycolor$toRgb = tinycolor(colorParam).toRgb(),
45
+ r = _tinycolor$toRgb.r,
46
+ g = _tinycolor$toRgb.g,
47
+ b = _tinycolor$toRgb.b,
48
+ a = _tinycolor$toRgb.a;
40
49
  return {
41
50
  r: r,
42
51
  g: g,
@@ -179,9 +188,6 @@ export function getMiddleColor(colors, offset) {
179
188
  if (!rightColor) {
180
189
  return leftColor.color;
181
190
  }
182
-
183
- // console.log(leftColor, rightColor, leftColors, rightColors, '计算color');
184
-
185
191
  var _resolveColor6 = resolveColor(leftColor.color),
186
192
  leftR = _resolveColor6.r,
187
193
  leftG = _resolveColor6.g,
@@ -192,9 +198,6 @@ export function getMiddleColor(colors, offset) {
192
198
  rightG = _resolveColor7.g,
193
199
  rightB = _resolveColor7.b,
194
200
  rightA = _resolveColor7.a;
195
-
196
- // console.log(resolveColor(leftColor.color), resolveColor(rightColor.color), '计算color');
197
-
198
201
  var newR = Math.round((rightR - leftR) / (rightColor.offset - leftColor.offset) * (offset - leftColor.offset) + leftR);
199
202
  var newG = Math.round((rightG - leftG) / (rightColor.offset - leftColor.offset) * (offset - leftColor.offset) + leftG);
200
203
  var newB = Math.round((rightB - leftB) / (rightColor.offset - leftColor.offset) * (offset - leftColor.offset) + leftB);
@@ -0,0 +1,20 @@
1
+ import type { InputProps } from '@arco-design/web-react';
2
+ import type { InputSearchProps, RefInputType, RefTextAreaType, TextAreaProps } from '@arco-design/web-react/es/Input';
3
+ interface BaseInputProps {
4
+ /** 显示边框 */
5
+ bordered?: boolean;
6
+ /** 是否失去焦点时,触发 onChange 事件 */
7
+ changeOnBlur?: boolean;
8
+ }
9
+ interface XInputProps extends InputProps, BaseInputProps {
10
+ /** 是否允许文本为空 */
11
+ enableEmpty?: boolean;
12
+ /** 是否聚焦后自动选中输入框的文本 */
13
+ autoSelect?: boolean;
14
+ onChange?: (value: string, e: any) => void;
15
+ }
16
+ interface XInputSearchProps extends InputSearchProps, BaseInputProps {
17
+ }
18
+ interface XTextAreaProps extends TextAreaProps, BaseInputProps {
19
+ }
20
+ export type { XInputProps as InputProps, XInputSearchProps as InputSearchProps, RefInputType, RefTextAreaType, XTextAreaProps as TextAreaProps, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/react-components",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "description": "a react component library base on arco design",
5
5
  "license": "MIT",
6
6
  "sideEffects": [