Skip to content

Commit 82b8538

Browse files
authored
Merge pull request #32 from wu-component/feature/ui-component-marvin
feat:add colorpicker component
2 parents e94f997 + 9abd86e commit 82b8538

File tree

18 files changed

+4434
-3
lines changed

18 files changed

+4434
-3
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { resolve } from "path";
2+
import { nodeResolve } from "@rollup/plugin-node-resolve";
3+
import commonjs from "@rollup/plugin-commonjs";
4+
import postcss from "rollup-plugin-postcss";
5+
import typescript from "rollup-plugin-typescript2";
6+
import json from "@rollup/plugin-json";
7+
import replace from "@rollup/plugin-replace";
8+
import scss from 'rollup-plugin-scss'
9+
import autoprefixer from 'autoprefixer'
10+
import url from '@rollup/plugin-url';
11+
12+
const input = resolve(__dirname, "../src/packages");
13+
const output = resolve(__dirname, "../dist-lib");
14+
const getPath = _path => resolve(__dirname, _path)
15+
const extensions = [
16+
'.js',
17+
'.ts',
18+
'.tsx'
19+
]
20+
let defaults = { compilerOptions: { declaration: true } };
21+
const config = []
22+
// 整合打;包
23+
config.push({
24+
input: resolve(__dirname, "../src/packages/wu-color-picker/index.tsx"),
25+
plugins: [
26+
url({
27+
include: ['**/*.woff', '**/*.woff2', '**/*.ttf'],
28+
// setting infinite limit will ensure that the files
29+
// are always bundled with the code, not copied to /dist
30+
limit: Infinity,
31+
}),
32+
nodeResolve(),
33+
commonjs(),
34+
postcss({
35+
extensions: [ '.css', 'scss' ],
36+
name: 'index',
37+
to: `${output}/index.css`,
38+
plugins: [
39+
autoprefixer()
40+
],
41+
extract: false
42+
}),
43+
typescript({
44+
tsconfig: getPath('../tsconfig.json'), // 导入本地ts配置
45+
tsconfigDefaults: defaults,
46+
tsconfigOverride: {
47+
compilerOptions: {
48+
declaration: true
49+
}
50+
},
51+
extensions
52+
}),
53+
json(),
54+
replace({
55+
preventAssignment: true
56+
})
57+
],
58+
output: [
59+
{
60+
name: 'webUIPlusColorPicker',
61+
file: `${output}/web-plus-color-picker.umd.js`,
62+
format: 'umd',
63+
globals: {
64+
'@canyuegongzi/web-core-plus': 'webCorePlus'
65+
}
66+
},
67+
// { file: `${output}/web-plus.cjs.js`, format: 'cjs' },
68+
// { file: `${output}/web-plus.esm.js`, format: 'es' }
69+
70+
],
71+
external: [/web-core-plus$/],
72+
})
73+
export default config;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { OnConnected, WuComponent, OnDisConnected } from '@canyuegongzi/web-core-plus';
2+
export declare class WuColorPane extends WuComponent implements OnConnected, OnDisConnected {
3+
private type;
4+
private typeindex;
5+
private palette;
6+
private colors;
7+
private pane;
8+
private rangeHue;
9+
private rangeOpacity;
10+
private copyBtn;
11+
private copyinfo;
12+
private switch;
13+
private colorHexa;
14+
private colorRgba;
15+
private colorHlsa;
16+
private $value;
17+
private nativeclick;
18+
private start;
19+
val: any;
20+
private timeout;
21+
constructor();
22+
defaultvalue: string;
23+
choose(ev: any): void;
24+
connected(shadowRoot: ShadowRoot): void;
25+
mousemove: (ev: any) => void;
26+
mouseup: () => any;
27+
disConnected(): void;
28+
get value(): any;
29+
get color(): {
30+
h: number;
31+
s: number;
32+
v: number;
33+
a: number;
34+
toHSVA(): number[];
35+
toHSLA(): any[];
36+
toRGBA(): number[];
37+
toCMYK(): number[];
38+
toHEXA(): string[];
39+
clone: () => any;
40+
};
41+
valueChange(val: string, old?: string): void;
42+
valueChangeEvent(): {
43+
value: any;
44+
color: {
45+
h: number;
46+
s: number;
47+
v: number;
48+
a: number;
49+
toHSVA(): number[];
50+
toHSLA(): any[];
51+
toRGBA(): number[];
52+
toCMYK(): number[];
53+
toHEXA(): string[];
54+
clone: () => any;
55+
};
56+
};
57+
init(color: string): void;
58+
/**
59+
* 更新
60+
*/
61+
updatePicker(): void;
62+
render(_renderProps?: {}, _store?: {}): any;
63+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { UISize } from "@/interface";
2+
import { OnConnected, WuComponent } from '@canyuegongzi/web-core-plus';
3+
import '../wu-popover';
4+
import '../wu-button';
5+
import { WuColorPane } from "./color-pane";
6+
import './color-pane';
7+
export declare class WuColorPicker extends WuComponent implements OnConnected {
8+
popover: any;
9+
popoverRef: any;
10+
popcon: any;
11+
colorPane: WuColorPane;
12+
nativeclick: boolean;
13+
constructor();
14+
size: UISize;
15+
defaultvalue: string;
16+
disabled: boolean;
17+
val: string;
18+
$value: any;
19+
connected(shadowRoot: ShadowRoot): void;
20+
/**
21+
* 确认颜色
22+
*/
23+
okCallback(): void;
24+
/**
25+
* 确认颜色
26+
*/
27+
cancleCallback(): void;
28+
/**
29+
* 打开选择器
30+
*/
31+
openPicker(): void;
32+
valueChange(value: string, old: string): void;
33+
changeEvent(): {
34+
value: any;
35+
color: {
36+
h: number;
37+
s: number;
38+
v: number;
39+
a: number;
40+
toHSVA(): number[];
41+
toHSLA(): any[];
42+
toRGBA(): number[];
43+
toCMYK(): number[];
44+
toHEXA(): string[];
45+
clone: () => any;
46+
};
47+
};
48+
get color(): {
49+
h: number;
50+
s: number;
51+
v: number;
52+
a: number;
53+
toHSVA(): number[];
54+
toHSLA(): any[];
55+
toRGBA(): number[];
56+
toCMYK(): number[];
57+
toHEXA(): string[];
58+
clone: () => any;
59+
};
60+
get value(): any;
61+
render(_renderProps?: {}, _store?: {}): any;
62+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/**
2+
* Convert HSV spectrum to RGB.
3+
* @param h Hue
4+
* @param s Saturation
5+
* @param v Value
6+
* @returns {number[]} Array with rgb values.
7+
*/
8+
export declare function hsvToRgb(h: any, s: any, v: any): number[];
9+
/**
10+
* Convert HSV spectrum to Hex.
11+
* @param h Hue
12+
* @param s Saturation
13+
* @param v Value
14+
* @returns {string[]} Hex values
15+
*/
16+
export declare function hsvToHex(h: any, s: any, v: any): string[];
17+
/**
18+
* Convert HSV spectrum to CMYK.
19+
* @param h Hue
20+
* @param s Saturation
21+
* @param v Value
22+
* @returns {number[]} CMYK values
23+
*/
24+
export declare function hsvToCmyk(h: any, s: any, v: any): number[];
25+
/**
26+
* Convert HSV spectrum to HSL.
27+
* @param h Hue
28+
* @param s Saturation
29+
* @param v Value
30+
* @returns {number[]} HSL values
31+
*/
32+
export declare function hsvToHsl(h: any, s: any, v: any): any[];
33+
/**
34+
* Convert RGB to HSV.
35+
* @param r Red
36+
* @param g Green
37+
* @param b Blue
38+
* @return {number[]} HSV values.
39+
*/
40+
export declare function rgbToHsv(r: any, g: any, b: any): number[];
41+
/**
42+
* Convert CMYK to HSV.
43+
* @param c Cyan
44+
* @param m Magenta
45+
* @param y Yellow
46+
* @param k Key (Black)
47+
* @return {number[]} HSV values.
48+
*/
49+
export declare function cmykToHsv(c: any, m: any, y: any, k: any): number[];
50+
/**
51+
* Convert HSL to HSV.
52+
* @param h Hue
53+
* @param s Saturation
54+
* @param l Lightness
55+
* @return {number[]} HSV values.
56+
*/
57+
export declare function hslToHsv(h: any, s: any, l: any): any[];
58+
/**
59+
* Convert HEX to HSV.
60+
* @param hex Hexadecimal string of rgb colors, can have length 3 or 6.
61+
* @return {number[]} HSV values.
62+
*/
63+
export declare function hexToHsv(hex: any): number[];
64+
/**
65+
* Try's to parse a string which represents a color to a HSV array.
66+
* Current supported types are cmyk, rgba, hsla and hexadecimal.
67+
* @param str
68+
* @return {*}
69+
*/
70+
export declare function parseToHSVA(str: any): {
71+
values: number[];
72+
type: "cmyk";
73+
a?: undefined;
74+
} | {
75+
values: any[];
76+
a: any;
77+
type: "rgba";
78+
} | {
79+
values: any[];
80+
a: any;
81+
type: "hexa";
82+
} | {
83+
values: any[];
84+
a: any;
85+
type: "hsla";
86+
} | {
87+
values: any[];
88+
a: any;
89+
type: "hsva";
90+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Simple class which holds the properties
3+
* of the color represention model hsla (hue saturation lightness alpha)
4+
*/
5+
export declare function HSVaColor(h?: number, s?: number, v?: number, a?: number): {
6+
h: number;
7+
s: number;
8+
v: number;
9+
a: number;
10+
toHSVA(): number[];
11+
toHSLA(): any[];
12+
toRGBA(): number[];
13+
toCMYK(): number[];
14+
toHEXA(): string[];
15+
clone: () => any;
16+
};

packages/web-plus-ui/dist-lib/packages/wu-popover/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export declare class WuPopover extends WuComponent implements OnConnected {
1515
disappear: boolean;
1616
disabled: boolean;
1717
private popper;
18+
closeEmit(): {
19+
value: boolean;
20+
};
1821
onEnter: (evt: any) => void;
1922
onEnterPopover: (evt: any) => void;
2023
updatePosition(): void;

0 commit comments

Comments
 (0)