Skip to content

Commit 213b3e2

Browse files
committed
feat: add Type declarations
1 parent bf5948f commit 213b3e2

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"repository": "https://github.com/ckpack/vue-color",
66
"sideEffects": false,
77
"type": "module",
8+
"types": "./types.d.ts",
89
"main": "dist/index.js",
910
"module": "libs/index.js",
1011
"unpkg": "dist/index.min.js",

types.d.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
declare module '@ckpack/vue-color' {
2+
import type { DefineComponent } from 'vue';
3+
import type { ColorInput, HSV, HSL, RGBA } from '@ctrl/tinycolor';
4+
5+
interface Payload {
6+
a: number
7+
hex: string
8+
hex8: string
9+
hsl: HSL
10+
hsv: HSV
11+
oldHue: number
12+
rgba: RGBA
13+
source: 'rgba' | 'hsl' | 'hex' | 'hsv' | 'hsva'
14+
}
15+
16+
interface Props {
17+
modelValue?: ColorInput
18+
'onUpdate:modelValue'?: (data: Payload) => void
19+
}
20+
21+
interface Context {
22+
colorChange: Function;
23+
isValidHex: Function
24+
simpleCheckForValidColor: Function
25+
paletteUpperCase: Function
26+
isTransparent: Function
27+
}
28+
29+
const Chrome: DefineComponent<Props & {
30+
disableAlpha?: boolean
31+
disableFields?: boolean
32+
}, Context>;
33+
34+
const Compact: DefineComponent<Props & {
35+
palette?: ColorInput[]
36+
}, Context>;
37+
38+
const Grayscale: DefineComponent<Props & {
39+
palette?: ColorInput[]
40+
}, Context>;
41+
42+
const Material: DefineComponent<Props & {
43+
value?: 'horizontal' | 'vertical'
44+
}, Context>;
45+
46+
const Photoshop: DefineComponent<Props & {
47+
head?: string
48+
disableFields?: boolean
49+
hasResetButton?: boolean
50+
acceptLabel?: string
51+
cancelLabel?: string
52+
resetLabel?: string
53+
newLabel?: string
54+
currentLabel?: string
55+
}, Context>;
56+
57+
const Sketch: DefineComponent<Props & {
58+
presetColors?: ColorInput[]
59+
disableAlpha?: boolean
60+
disableFields?: boolean
61+
}, Context>;
62+
63+
const Slider: DefineComponent<Props & {
64+
swatches?: string[] | { s: number, l: number }[]
65+
}, Context>;
66+
67+
const Swatches: DefineComponent<Props & {
68+
palette?: ColorInput[]
69+
}, Context>;
70+
71+
const Twitter: DefineComponent<Props & {
72+
width?: string | number
73+
defaultColors?: ColorInput[]
74+
triangle?: 'hide' | 'top-left' | 'top-right'
75+
}, Context>;
76+
}

0 commit comments

Comments
 (0)