goodteditor-ui 1.0.12 → 1.0.13

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.
Files changed (75) hide show
  1. package/.eslintrc.js +7 -7
  2. package/.prettierrc +14 -14
  3. package/README.md +35 -35
  4. package/babel.config.js +5 -5
  5. package/dist/js.png +0 -0
  6. package/index.js +51 -51
  7. package/jsconfig.json +13 -13
  8. package/package.json +57 -57
  9. package/src/App.vue +36 -36
  10. package/src/components/ui/Avatar.md +68 -68
  11. package/src/components/ui/Avatar.vue +177 -177
  12. package/src/components/ui/Badge.md +20 -20
  13. package/src/components/ui/Badge.vue +75 -75
  14. package/src/components/ui/Collapse.md +90 -90
  15. package/src/components/ui/Collapse.vue +86 -86
  16. package/src/components/ui/ColorPicker/Alpha.vue +114 -114
  17. package/src/components/ui/ColorPicker/Colors.vue +117 -117
  18. package/src/components/ui/ColorPicker/Hue.vue +113 -113
  19. package/src/components/ui/ColorPicker/Preview.vue +55 -55
  20. package/src/components/ui/ColorPicker/Saturation.vue +123 -123
  21. package/src/components/ui/ColorPicker/mixin.js +105 -105
  22. package/src/components/ui/ColorPicker.md +17 -17
  23. package/src/components/ui/ColorPicker.vue +314 -314
  24. package/src/components/ui/Datalist.md +41 -41
  25. package/src/components/ui/Datalist.vue +157 -157
  26. package/src/components/ui/DatePicker.md +168 -168
  27. package/src/components/ui/DatePicker.vue +527 -527
  28. package/src/components/ui/FileSelector.md +105 -105
  29. package/src/components/ui/FileSelector.vue +82 -82
  30. package/src/components/ui/Grid.md +130 -130
  31. package/src/components/ui/Grid.vue +92 -92
  32. package/src/components/ui/Image.md +59 -59
  33. package/src/components/ui/Image.vue +57 -57
  34. package/src/components/ui/InputAutocomplete.md +115 -115
  35. package/src/components/ui/InputAutocomplete.vue +341 -341
  36. package/src/components/ui/InputColorPicker.md +51 -51
  37. package/src/components/ui/InputColorPicker.vue +151 -151
  38. package/src/components/ui/InputDatePicker.md +121 -121
  39. package/src/components/ui/InputDatePicker.vue +310 -310
  40. package/src/components/ui/InputTags.md +51 -51
  41. package/src/components/ui/InputTags.vue +184 -184
  42. package/src/components/ui/InputTimePicker.md +25 -25
  43. package/src/components/ui/InputTimePicker.vue +253 -253
  44. package/src/components/ui/InputUnits.md +20 -20
  45. package/src/components/ui/InputUnits.vue +257 -257
  46. package/src/components/ui/Lazy.md +37 -37
  47. package/src/components/ui/Lazy.vue +92 -92
  48. package/src/components/ui/Pagination.md +74 -74
  49. package/src/components/ui/Pagination.vue +138 -138
  50. package/src/components/ui/Paginator.md +34 -34
  51. package/src/components/ui/Paginator.vue +83 -83
  52. package/src/components/ui/Popover.md +34 -34
  53. package/src/components/ui/Popover.vue +258 -209
  54. package/src/components/ui/Popup.md +59 -59
  55. package/src/components/ui/Popup.vue +150 -150
  56. package/src/components/ui/ResponsiveContainer.md +58 -58
  57. package/src/components/ui/ResponsiveContainer.vue +99 -99
  58. package/src/components/ui/Select.md +187 -187
  59. package/src/components/ui/Select.vue +420 -420
  60. package/src/components/ui/TimePicker.md +50 -50
  61. package/src/components/ui/TimePicker.vue +252 -252
  62. package/src/components/ui/Tooltip.md +114 -52
  63. package/src/components/ui/Tooltip.vue +113 -113
  64. package/src/components/ui/utils/FormComponent.js +107 -107
  65. package/src/components/ui/utils/Helpers.js +84 -61
  66. package/src/components/ui/utils/WithPopover.js +99 -81
  67. package/src/main.js +8 -8
  68. package/styleguide.config.js +37 -37
  69. package/vue.config.js +8 -8
  70. package/.idea/codeStyles/Project.xml +0 -51
  71. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  72. package/.idea/goodt-ui.iml +0 -12
  73. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  74. package/.idea/modules.xml +0 -8
  75. package/.idea/vcs.xml +0 -6
@@ -1,123 +1,123 @@
1
- <template>
2
- <div class="ui-color-picker-saturation" @mousedown.prevent.stop="selectSaturation">
3
- <canvas ref="canvasSaturation" />
4
- <div class="slide" :style="slideSaturationStyle" />
5
- </div>
6
- </template>
7
- <style lang="less" scoped>
8
- .ui-color-picker-saturation {
9
- position: relative;
10
- cursor: pointer;
11
- .slide {
12
- position: absolute;
13
- left: 100px;
14
- top: 0;
15
- width: 10px;
16
- height: 10px;
17
- border-radius: 50%;
18
- border: 1px solid #fff;
19
- box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.3);
20
- pointer-events: none;
21
- }
22
- }
23
- </style>
24
- <script>
25
- import mixin from './mixin';
26
- export default {
27
- mixins: [mixin],
28
- props: {
29
- color: {
30
- type: String,
31
- default: '#000000',
32
- },
33
- hsv: {
34
- type: Object,
35
- default: null,
36
- },
37
- size: {
38
- type: Number,
39
- default: 150,
40
- },
41
- },
42
- data() {
43
- return {
44
- slideSaturationStyle: {},
45
- };
46
- },
47
- created() {
48
- this._color = { r: 0, g: 0, b: 0 };
49
- },
50
- mounted() {
51
- this.renderColor();
52
- this.renderSlide();
53
- },
54
- methods: {
55
- renderColor() {
56
- const canvas = this.$refs.canvasSaturation;
57
- const size = this.size;
58
- const ctx = canvas.getContext('2d');
59
- canvas.width = size;
60
- canvas.height = size;
61
-
62
- ctx.fillStyle = this.color;
63
- ctx.fillRect(0, 0, size, size);
64
-
65
- this.createLinearGradient('l', ctx, size, size, '#FFFFFF', 'rgba(255,255,255,0)');
66
- this.createLinearGradient('p', ctx, size, size, 'rgba(0,0,0,0)', '#000000');
67
- },
68
- renderSlide() {
69
- this.slideSaturationStyle = {
70
- left: this.hsv.s * this.size - 5 + 'px',
71
- top: (1 - this.hsv.v) * this.size - 5 + 'px',
72
- };
73
- },
74
- selectSaturation(e) {
75
- const { top: saturationTop, left: saturationLeft } = this.$el.getBoundingClientRect();
76
- const ctx = e.target.getContext('2d');
77
-
78
- const mousemove = e => {
79
- let x = e.clientX - saturationLeft;
80
- let y = e.clientY - saturationTop;
81
-
82
- if (x < 0) {
83
- x = 0;
84
- }
85
- if (y < 0) {
86
- y = 0;
87
- }
88
- if (x > this.size) {
89
- x = this.size;
90
- }
91
- if (y > this.size) {
92
- y = this.size;
93
- }
94
-
95
- this.slideSaturationStyle = {
96
- left: x - 5 + 'px',
97
- top: y - 5 + 'px',
98
- };
99
- const imgData = ctx.getImageData(
100
- Math.min(x, this.size - 1),
101
- Math.min(y, this.size - 1),
102
- 1,
103
- 1
104
- );
105
- const [r, g, b] = imgData.data;
106
- this._color = { r, g, b };
107
- this.$emit('changeSaturation', this._color);
108
- };
109
-
110
- mousemove(e);
111
-
112
- const mouseup = () => {
113
- document.removeEventListener('mousemove', mousemove);
114
- document.removeEventListener('mouseup', mouseup);
115
- this.$emit('selectSaturation', this._color);
116
- };
117
-
118
- document.addEventListener('mousemove', mousemove);
119
- document.addEventListener('mouseup', mouseup);
120
- },
121
- },
122
- };
123
- </script>
1
+ <template>
2
+ <div class="ui-color-picker-saturation" @mousedown.prevent.stop="selectSaturation">
3
+ <canvas ref="canvasSaturation" />
4
+ <div class="slide" :style="slideSaturationStyle" />
5
+ </div>
6
+ </template>
7
+ <style lang="less" scoped>
8
+ .ui-color-picker-saturation {
9
+ position: relative;
10
+ cursor: pointer;
11
+ .slide {
12
+ position: absolute;
13
+ left: 100px;
14
+ top: 0;
15
+ width: 10px;
16
+ height: 10px;
17
+ border-radius: 50%;
18
+ border: 1px solid #fff;
19
+ box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.3);
20
+ pointer-events: none;
21
+ }
22
+ }
23
+ </style>
24
+ <script>
25
+ import mixin from './mixin';
26
+ export default {
27
+ mixins: [mixin],
28
+ props: {
29
+ color: {
30
+ type: String,
31
+ default: '#000000',
32
+ },
33
+ hsv: {
34
+ type: Object,
35
+ default: null,
36
+ },
37
+ size: {
38
+ type: Number,
39
+ default: 150,
40
+ },
41
+ },
42
+ data() {
43
+ return {
44
+ slideSaturationStyle: {},
45
+ };
46
+ },
47
+ created() {
48
+ this._color = { r: 0, g: 0, b: 0 };
49
+ },
50
+ mounted() {
51
+ this.renderColor();
52
+ this.renderSlide();
53
+ },
54
+ methods: {
55
+ renderColor() {
56
+ const canvas = this.$refs.canvasSaturation;
57
+ const size = this.size;
58
+ const ctx = canvas.getContext('2d');
59
+ canvas.width = size;
60
+ canvas.height = size;
61
+
62
+ ctx.fillStyle = this.color;
63
+ ctx.fillRect(0, 0, size, size);
64
+
65
+ this.createLinearGradient('l', ctx, size, size, '#FFFFFF', 'rgba(255,255,255,0)');
66
+ this.createLinearGradient('p', ctx, size, size, 'rgba(0,0,0,0)', '#000000');
67
+ },
68
+ renderSlide() {
69
+ this.slideSaturationStyle = {
70
+ left: this.hsv.s * this.size - 5 + 'px',
71
+ top: (1 - this.hsv.v) * this.size - 5 + 'px',
72
+ };
73
+ },
74
+ selectSaturation(e) {
75
+ const { top: saturationTop, left: saturationLeft } = this.$el.getBoundingClientRect();
76
+ const ctx = e.target.getContext('2d');
77
+
78
+ const mousemove = e => {
79
+ let x = e.clientX - saturationLeft;
80
+ let y = e.clientY - saturationTop;
81
+
82
+ if (x < 0) {
83
+ x = 0;
84
+ }
85
+ if (y < 0) {
86
+ y = 0;
87
+ }
88
+ if (x > this.size) {
89
+ x = this.size;
90
+ }
91
+ if (y > this.size) {
92
+ y = this.size;
93
+ }
94
+
95
+ this.slideSaturationStyle = {
96
+ left: x - 5 + 'px',
97
+ top: y - 5 + 'px',
98
+ };
99
+ const imgData = ctx.getImageData(
100
+ Math.min(x, this.size - 1),
101
+ Math.min(y, this.size - 1),
102
+ 1,
103
+ 1
104
+ );
105
+ const [r, g, b] = imgData.data;
106
+ this._color = { r, g, b };
107
+ this.$emit('changeSaturation', this._color);
108
+ };
109
+
110
+ mousemove(e);
111
+
112
+ const mouseup = () => {
113
+ document.removeEventListener('mousemove', mousemove);
114
+ document.removeEventListener('mouseup', mouseup);
115
+ this.$emit('selectSaturation', this._color);
116
+ };
117
+
118
+ document.addEventListener('mousemove', mousemove);
119
+ document.addEventListener('mouseup', mouseup);
120
+ },
121
+ },
122
+ };
123
+ </script>
@@ -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
+ ```