goodteditor-ui 1.0.9 → 1.0.12
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.
- package/.eslintrc.js +7 -7
- package/.idea/codeStyles/Project.xml +51 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/goodt-ui.iml +12 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.prettierrc +14 -14
- package/README.md +35 -35
- package/babel.config.js +5 -5
- package/index.js +51 -47
- package/jsconfig.json +13 -13
- package/package.json +57 -57
- package/src/App.vue +36 -36
- package/src/components/ui/Avatar.md +68 -0
- package/src/components/ui/Avatar.vue +177 -0
- package/src/components/ui/Badge.md +20 -20
- package/src/components/ui/Badge.vue +75 -75
- package/src/components/ui/Collapse.md +90 -90
- package/src/components/ui/Collapse.vue +86 -86
- package/src/components/ui/ColorPicker/Alpha.vue +114 -114
- package/src/components/ui/ColorPicker/Colors.vue +117 -117
- package/src/components/ui/ColorPicker/Hue.vue +113 -113
- package/src/components/ui/ColorPicker/Preview.vue +55 -55
- package/src/components/ui/ColorPicker/Saturation.vue +123 -123
- package/src/components/ui/ColorPicker/mixin.js +105 -105
- package/src/components/ui/ColorPicker.md +17 -17
- package/src/components/ui/ColorPicker.vue +314 -314
- package/src/components/ui/Datalist.md +41 -41
- package/src/components/ui/Datalist.vue +157 -157
- package/src/components/ui/DatePicker.md +168 -168
- package/src/components/ui/DatePicker.vue +527 -527
- package/src/components/ui/FileSelector.md +105 -105
- package/src/components/ui/FileSelector.vue +82 -82
- package/src/components/ui/Grid.md +130 -130
- package/src/components/ui/Grid.vue +92 -92
- package/src/components/ui/Image.md +59 -59
- package/src/components/ui/Image.vue +57 -57
- package/src/components/ui/InputAutocomplete.md +115 -115
- package/src/components/ui/InputAutocomplete.vue +341 -341
- package/src/components/ui/InputColorPicker.md +51 -51
- package/src/components/ui/InputColorPicker.vue +151 -151
- package/src/components/ui/InputDatePicker.md +121 -121
- package/src/components/ui/InputDatePicker.vue +310 -310
- package/src/components/ui/InputTags.md +51 -51
- package/src/components/ui/InputTags.vue +184 -184
- package/src/components/ui/InputTimePicker.md +25 -25
- package/src/components/ui/InputTimePicker.vue +253 -253
- package/src/components/ui/InputUnits.md +20 -20
- package/src/components/ui/InputUnits.vue +257 -257
- package/src/components/ui/Lazy.md +37 -37
- package/src/components/ui/Lazy.vue +92 -92
- package/src/components/ui/Pagination.md +74 -74
- package/src/components/ui/Pagination.vue +138 -138
- package/src/components/ui/Paginator.md +34 -34
- package/src/components/ui/Paginator.vue +83 -83
- package/src/components/ui/Popover.md +34 -34
- package/src/components/ui/Popover.vue +209 -209
- package/src/components/ui/Popup.md +59 -59
- package/src/components/ui/Popup.vue +150 -150
- package/src/components/ui/ResponsiveContainer.md +58 -0
- package/src/components/ui/ResponsiveContainer.vue +99 -0
- package/src/components/ui/Select.md +187 -187
- package/src/components/ui/Select.vue +420 -420
- package/src/components/ui/TimePicker.md +50 -50
- package/src/components/ui/TimePicker.vue +252 -252
- package/src/components/ui/Tooltip.md +52 -52
- package/src/components/ui/Tooltip.vue +113 -113
- package/src/components/ui/utils/FormComponent.js +107 -107
- package/src/components/ui/utils/Helpers.js +61 -61
- package/src/components/ui/utils/WithPopover.js +81 -81
- package/src/main.js +8 -8
- package/styleguide.config.js +37 -37
- package/vue.config.js +8 -8
- package/dist/js.png +0 -0
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
methods: {
|
|
3
|
-
setColorValue(color) {
|
|
4
|
-
let rgba = { r: 0, g: 0, b: 0, a: 1 };
|
|
5
|
-
if (/#/.test(color)) {
|
|
6
|
-
rgba = this.hex2rgb(color);
|
|
7
|
-
} else if (/rgb/.test(color)) {
|
|
8
|
-
rgba = this.rgb2rgba(color);
|
|
9
|
-
} else if (typeof color === 'string') {
|
|
10
|
-
rgba = this.rgb2rgba(`rgba(${color})`);
|
|
11
|
-
} else if (Object.prototype.toString.call(color) === '[object Object]') {
|
|
12
|
-
rgba = color;
|
|
13
|
-
}
|
|
14
|
-
let fix = c => (c < 0 ? 0 : c > 255 ? 255 : c);
|
|
15
|
-
['r', 'g', 'b'].forEach(c => (rgba[c] = fix(rgba[c])));
|
|
16
|
-
const { r, g, b, a } = rgba;
|
|
17
|
-
const { h, s, v } = this.rgb2hsv(rgba);
|
|
18
|
-
return {
|
|
19
|
-
r,
|
|
20
|
-
g,
|
|
21
|
-
b,
|
|
22
|
-
a: a === undefined ? 1 : a,
|
|
23
|
-
h,
|
|
24
|
-
s,
|
|
25
|
-
v,
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
createAlphaSquare(size) {
|
|
29
|
-
const canvas = document.createElement('canvas');
|
|
30
|
-
const ctx = canvas.getContext('2d');
|
|
31
|
-
const doubleSize = size * 2;
|
|
32
|
-
canvas.width = doubleSize;
|
|
33
|
-
canvas.height = doubleSize;
|
|
34
|
-
|
|
35
|
-
ctx.fillStyle = '#ffffff';
|
|
36
|
-
ctx.fillRect(0, 0, doubleSize, doubleSize);
|
|
37
|
-
ctx.fillStyle = '#ccd5db';
|
|
38
|
-
ctx.fillRect(0, 0, size, size);
|
|
39
|
-
ctx.fillRect(size, size, size, size);
|
|
40
|
-
|
|
41
|
-
return canvas;
|
|
42
|
-
},
|
|
43
|
-
createLinearGradient(direction, ctx, width, height, color1, color2) {
|
|
44
|
-
const isL = direction === 'l';
|
|
45
|
-
const gradient = ctx.createLinearGradient(0, 0, isL ? width : 0, isL ? 0 : height);
|
|
46
|
-
gradient.addColorStop(0.01, color1);
|
|
47
|
-
gradient.addColorStop(0.99, color2);
|
|
48
|
-
ctx.fillStyle = gradient;
|
|
49
|
-
ctx.fillRect(0, 0, width, height);
|
|
50
|
-
},
|
|
51
|
-
rgb2hex({ r, g, b }, toUpper) {
|
|
52
|
-
const change = val => ('0' + Number(val).toString(16)).slice(-2);
|
|
53
|
-
const color = `#${change(r)}${change(g)}${change(b)}`;
|
|
54
|
-
return toUpper ? color.toUpperCase() : color;
|
|
55
|
-
},
|
|
56
|
-
hex2rgb(hex) {
|
|
57
|
-
hex = hex.slice(1);
|
|
58
|
-
const change = val => parseInt(val, 16) || 0;
|
|
59
|
-
return {
|
|
60
|
-
r: change(hex.slice(0, 2)),
|
|
61
|
-
g: change(hex.slice(2, 4)),
|
|
62
|
-
b: change(hex.slice(4, 6)),
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
rgb2rgba(rgba) {
|
|
66
|
-
if (typeof rgba === 'string') {
|
|
67
|
-
rgba = (/rgba?\((.*?)\)/.exec(rgba) || ['', '0,0,0,1'])[1].split(',');
|
|
68
|
-
return {
|
|
69
|
-
r: Number(rgba[0]) || 0,
|
|
70
|
-
g: Number(rgba[1]) || 0,
|
|
71
|
-
b: Number(rgba[2]) || 0,
|
|
72
|
-
a: Number(rgba[3] ? rgba[3] : 1),
|
|
73
|
-
};
|
|
74
|
-
} else {
|
|
75
|
-
return rgba;
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
rgb2hsv({ r, g, b }) {
|
|
79
|
-
r = r / 255;
|
|
80
|
-
g = g / 255;
|
|
81
|
-
b = b / 255;
|
|
82
|
-
const max = Math.max(r, g, b);
|
|
83
|
-
const min = Math.min(r, g, b);
|
|
84
|
-
const delta = max - min;
|
|
85
|
-
let h = 0;
|
|
86
|
-
if (max === min) {
|
|
87
|
-
h = 0;
|
|
88
|
-
} else if (max === r) {
|
|
89
|
-
if (g >= b) {
|
|
90
|
-
h = (60 * (g - b)) / delta;
|
|
91
|
-
} else {
|
|
92
|
-
h = (60 * (g - b)) / delta + 360;
|
|
93
|
-
}
|
|
94
|
-
} else if (max === g) {
|
|
95
|
-
h = (60 * (b - r)) / delta + 120;
|
|
96
|
-
} else if (max === b) {
|
|
97
|
-
h = (60 * (r - g)) / delta + 240;
|
|
98
|
-
}
|
|
99
|
-
h = Math.floor(h);
|
|
100
|
-
let s = parseFloat((max === 0 ? 0 : 1 - min / max).toFixed(2));
|
|
101
|
-
let v = parseFloat(max.toFixed(2));
|
|
102
|
-
return { h, s, v };
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
};
|
|
1
|
+
export default {
|
|
2
|
+
methods: {
|
|
3
|
+
setColorValue(color) {
|
|
4
|
+
let rgba = { r: 0, g: 0, b: 0, a: 1 };
|
|
5
|
+
if (/#/.test(color)) {
|
|
6
|
+
rgba = this.hex2rgb(color);
|
|
7
|
+
} else if (/rgb/.test(color)) {
|
|
8
|
+
rgba = this.rgb2rgba(color);
|
|
9
|
+
} else if (typeof color === 'string') {
|
|
10
|
+
rgba = this.rgb2rgba(`rgba(${color})`);
|
|
11
|
+
} else if (Object.prototype.toString.call(color) === '[object Object]') {
|
|
12
|
+
rgba = color;
|
|
13
|
+
}
|
|
14
|
+
let fix = c => (c < 0 ? 0 : c > 255 ? 255 : c);
|
|
15
|
+
['r', 'g', 'b'].forEach(c => (rgba[c] = fix(rgba[c])));
|
|
16
|
+
const { r, g, b, a } = rgba;
|
|
17
|
+
const { h, s, v } = this.rgb2hsv(rgba);
|
|
18
|
+
return {
|
|
19
|
+
r,
|
|
20
|
+
g,
|
|
21
|
+
b,
|
|
22
|
+
a: a === undefined ? 1 : a,
|
|
23
|
+
h,
|
|
24
|
+
s,
|
|
25
|
+
v,
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
createAlphaSquare(size) {
|
|
29
|
+
const canvas = document.createElement('canvas');
|
|
30
|
+
const ctx = canvas.getContext('2d');
|
|
31
|
+
const doubleSize = size * 2;
|
|
32
|
+
canvas.width = doubleSize;
|
|
33
|
+
canvas.height = doubleSize;
|
|
34
|
+
|
|
35
|
+
ctx.fillStyle = '#ffffff';
|
|
36
|
+
ctx.fillRect(0, 0, doubleSize, doubleSize);
|
|
37
|
+
ctx.fillStyle = '#ccd5db';
|
|
38
|
+
ctx.fillRect(0, 0, size, size);
|
|
39
|
+
ctx.fillRect(size, size, size, size);
|
|
40
|
+
|
|
41
|
+
return canvas;
|
|
42
|
+
},
|
|
43
|
+
createLinearGradient(direction, ctx, width, height, color1, color2) {
|
|
44
|
+
const isL = direction === 'l';
|
|
45
|
+
const gradient = ctx.createLinearGradient(0, 0, isL ? width : 0, isL ? 0 : height);
|
|
46
|
+
gradient.addColorStop(0.01, color1);
|
|
47
|
+
gradient.addColorStop(0.99, color2);
|
|
48
|
+
ctx.fillStyle = gradient;
|
|
49
|
+
ctx.fillRect(0, 0, width, height);
|
|
50
|
+
},
|
|
51
|
+
rgb2hex({ r, g, b }, toUpper) {
|
|
52
|
+
const change = val => ('0' + Number(val).toString(16)).slice(-2);
|
|
53
|
+
const color = `#${change(r)}${change(g)}${change(b)}`;
|
|
54
|
+
return toUpper ? color.toUpperCase() : color;
|
|
55
|
+
},
|
|
56
|
+
hex2rgb(hex) {
|
|
57
|
+
hex = hex.slice(1);
|
|
58
|
+
const change = val => parseInt(val, 16) || 0;
|
|
59
|
+
return {
|
|
60
|
+
r: change(hex.slice(0, 2)),
|
|
61
|
+
g: change(hex.slice(2, 4)),
|
|
62
|
+
b: change(hex.slice(4, 6)),
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
rgb2rgba(rgba) {
|
|
66
|
+
if (typeof rgba === 'string') {
|
|
67
|
+
rgba = (/rgba?\((.*?)\)/.exec(rgba) || ['', '0,0,0,1'])[1].split(',');
|
|
68
|
+
return {
|
|
69
|
+
r: Number(rgba[0]) || 0,
|
|
70
|
+
g: Number(rgba[1]) || 0,
|
|
71
|
+
b: Number(rgba[2]) || 0,
|
|
72
|
+
a: Number(rgba[3] ? rgba[3] : 1),
|
|
73
|
+
};
|
|
74
|
+
} else {
|
|
75
|
+
return rgba;
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
rgb2hsv({ r, g, b }) {
|
|
79
|
+
r = r / 255;
|
|
80
|
+
g = g / 255;
|
|
81
|
+
b = b / 255;
|
|
82
|
+
const max = Math.max(r, g, b);
|
|
83
|
+
const min = Math.min(r, g, b);
|
|
84
|
+
const delta = max - min;
|
|
85
|
+
let h = 0;
|
|
86
|
+
if (max === min) {
|
|
87
|
+
h = 0;
|
|
88
|
+
} else if (max === r) {
|
|
89
|
+
if (g >= b) {
|
|
90
|
+
h = (60 * (g - b)) / delta;
|
|
91
|
+
} else {
|
|
92
|
+
h = (60 * (g - b)) / delta + 360;
|
|
93
|
+
}
|
|
94
|
+
} else if (max === g) {
|
|
95
|
+
h = (60 * (b - r)) / delta + 120;
|
|
96
|
+
} else if (max === b) {
|
|
97
|
+
h = (60 * (r - g)) / delta + 240;
|
|
98
|
+
}
|
|
99
|
+
h = Math.floor(h);
|
|
100
|
+
let s = parseFloat((max === 0 ? 0 : 1 - min / max).toFixed(2));
|
|
101
|
+
let v = parseFloat(max.toFixed(2));
|
|
102
|
+
return { h, s, v };
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
```vue
|
|
2
|
-
<template>
|
|
3
|
-
<div class="pad-l5">
|
|
4
|
-
<p>model: {{ model }}</p>
|
|
5
|
-
<color-picker v-model="model"></color-picker>
|
|
6
|
-
</div>
|
|
7
|
-
</template>
|
|
8
|
-
<script>
|
|
9
|
-
export default {
|
|
10
|
-
data() {
|
|
11
|
-
return {
|
|
12
|
-
model: '#ff00ff',
|
|
13
|
-
};
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
</script>
|
|
17
|
-
```
|
|
1
|
+
```vue
|
|
2
|
+
<template>
|
|
3
|
+
<div class="pad-l5">
|
|
4
|
+
<p>model: {{ model }}</p>
|
|
5
|
+
<color-picker v-model="model"></color-picker>
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
<script>
|
|
9
|
+
export default {
|
|
10
|
+
data() {
|
|
11
|
+
return {
|
|
12
|
+
model: '#ff00ff',
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
</script>
|
|
17
|
+
```
|