renusify 2.5.2 → 3.0.1

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 (212) hide show
  1. package/components/app/index.vue +74 -22
  2. package/components/app/toast/index.vue +76 -71
  3. package/components/app/toast/toast.vue +62 -44
  4. package/components/avatar/index.vue +207 -84
  5. package/components/button/buttonConfirm.vue +53 -26
  6. package/components/button/buttonGroup.js +0 -2
  7. package/components/button/buttonGroup.vue +310 -62
  8. package/components/button/index.vue +584 -100
  9. package/components/calendar/index.js +0 -2
  10. package/components/calendar/index.vue +326 -262
  11. package/components/calendar/month.vue +64 -55
  12. package/components/calendar/year.vue +30 -25
  13. package/components/card/index.vue +139 -59
  14. package/components/codeEditor/highlightCss.vue +38 -39
  15. package/components/codeEditor/highlightHtml.vue +64 -64
  16. package/components/codeEditor/highlightJs.vue +37 -38
  17. package/components/codeEditor/index.vue +129 -79
  18. package/components/codeEditor/run.vue +225 -39
  19. package/components/codeEditor/useCodeFormatter.js +150 -0
  20. package/components/confirm/index.vue +139 -80
  21. package/components/container/col.vue +5 -4
  22. package/components/container/divider.vue +28 -19
  23. package/components/container/index.vue +34 -15
  24. package/components/container/row.vue +26 -9
  25. package/components/container/spacer.vue +2 -4
  26. package/components/container/style.scss +3 -0
  27. package/components/content/index.vue +49 -32
  28. package/components/cropper/index.vue +401 -244
  29. package/components/float/index.vue +542 -415
  30. package/components/form/addressInput/index.vue +184 -109
  31. package/components/form/camInput/index.vue +370 -244
  32. package/components/form/checkInput/index.vue +138 -71
  33. package/components/form/checkboxInput/index.vue +93 -49
  34. package/components/form/colorInput/Alpha.vue +81 -83
  35. package/components/form/colorInput/Hue.vue +91 -68
  36. package/components/form/colorInput/Preview.vue +43 -47
  37. package/components/form/colorInput/Saturation.vue +101 -86
  38. package/components/form/colorInput/index.vue +71 -39
  39. package/components/form/colorInput/picker.vue +111 -106
  40. package/components/form/colorInput/useColor.js +153 -0
  41. package/components/form/dateInput/index.vue +691 -356
  42. package/components/form/dateInput/month.vue +63 -54
  43. package/components/form/dateInput/year.vue +35 -25
  44. package/components/form/fileInput/index.js +0 -1
  45. package/components/form/fileInput/index.vue +263 -106
  46. package/components/form/fileInput/single.vue +332 -168
  47. package/components/form/groupInput/index.vue +199 -101
  48. package/components/form/index.vue +189 -83
  49. package/components/form/input/index.vue +416 -377
  50. package/components/form/jsonInput/JsonView.vue +54 -56
  51. package/components/form/jsonInput/index.vue +247 -165
  52. package/components/form/maskInput/index.vue +252 -132
  53. package/components/form/numberInput/index.js +0 -1
  54. package/components/form/numberInput/index.vue +226 -117
  55. package/components/form/passwordInput/index.js +2 -1
  56. package/components/form/passwordInput/index.vue +269 -102
  57. package/components/form/radioInput/index.vue +143 -72
  58. package/components/form/rangeInput/index.vue +280 -167
  59. package/components/form/ratingInput/index.vue +57 -57
  60. package/components/form/selectInput/index.js +1 -3
  61. package/components/form/selectInput/index.vue +584 -296
  62. package/components/form/switchInput/index.vue +73 -59
  63. package/components/form/telInput/index.js +0 -1
  64. package/components/form/telInput/index.vue +238 -135
  65. package/components/form/textArea/index.vue +72 -35
  66. package/components/form/textEditor/index.vue +739 -0
  67. package/components/form/{text-editor → textEditor}/style.scss +8 -16
  68. package/components/form/textInput/index.vue +54 -32
  69. package/components/form/timeInput/index.vue +82 -55
  70. package/components/form/timeInput/range.vue +115 -94
  71. package/components/form/timeInput/timepicker.vue +382 -449
  72. package/components/form/uniqueInput/index.vue +105 -48
  73. package/components/form/unitInput/index.vue +139 -84
  74. package/components/formCreator/index.js +0 -1
  75. package/components/formCreator/index.vue +314 -148
  76. package/components/highlight/index.vue +41 -25
  77. package/components/highlight/style.scss +2 -2
  78. package/components/highlight/{mixin.js → useHighlight.js} +181 -160
  79. package/components/icon/index.vue +79 -33
  80. package/components/img/index.vue +250 -147
  81. package/components/img/preview.vue +180 -198
  82. package/components/img/svgImg.vue +42 -39
  83. package/components/index.js +5 -20
  84. package/components/infinite/index.js +3 -3
  85. package/components/infinite/index.vue +290 -66
  86. package/components/map/index.vue +428 -261
  87. package/components/map/route.vue +794 -487
  88. package/components/map/select.vue +118 -58
  89. package/components/menu/index.vue +206 -94
  90. package/components/meta/meta.js +26 -3
  91. package/components/modal/index.vue +382 -156
  92. package/components/notify/index.vue +204 -86
  93. package/components/notify/notification.vue +38 -55
  94. package/components/progress/circle.vue +189 -70
  95. package/components/progress/line.vue +266 -46
  96. package/components/searchBox/index.js +1 -3
  97. package/components/searchBox/index.vue +194 -101
  98. package/components/skeleton/index.vue +45 -20
  99. package/components/slider/index.vue +319 -156
  100. package/components/swiper/index.vue +237 -108
  101. package/components/table/crud/footer.vue +77 -53
  102. package/components/table/crud/header.vue +71 -72
  103. package/components/table/crud/index.vue +629 -399
  104. package/components/table/index.vue +721 -278
  105. package/components/timeAgo/index.vue +145 -96
  106. package/components/tour/index.vue +338 -235
  107. package/components/tree/index.vue +235 -89
  108. package/components/tree/tree-element.vue +106 -106
  109. package/directive/animate/index.js +77 -0
  110. package/directive/clickOutSide/index.js +98 -0
  111. package/directive/drag/index.js +153 -0
  112. package/directive/index.js +11 -13
  113. package/directive/intersect/index.js +263 -0
  114. package/directive/mask/index.js +67 -0
  115. package/directive/parallax/index.js +78 -0
  116. package/directive/ripple/index.js +14 -0
  117. package/directive/scroll/index.js +272 -24
  118. package/directive/sortable/index.js +274 -0
  119. package/directive/title/index.js +75 -0
  120. package/directive/touch/index.js +268 -0
  121. package/index.js +11 -19
  122. package/package.json +5 -2
  123. package/plugins/validation/Validate.js +88 -79
  124. package/scripts/generate-docs.mjs +226 -0
  125. package/scripts/menu.mjs +240 -0
  126. package/scripts/parser.mjs +1086 -0
  127. package/style/_index.scss +7 -0
  128. package/style/app.scss +13 -65
  129. package/style/colors.scss +5 -22
  130. package/style/functions/index.scss +8 -0
  131. package/style/mixins/index.scss +17 -5
  132. package/style/variables/base.scss +155 -178
  133. package/style/variables/color.scss +0 -12
  134. package/style/variables/utilities.scss +0 -180
  135. package/tools/helper.js +0 -8
  136. package/tools/icons.js +7 -2
  137. package/tools/root.js +71 -0
  138. package/components/app/style.scss +0 -41
  139. package/components/app/toast/style.scss +0 -20
  140. package/components/avatar/style.scss +0 -32
  141. package/components/bar/bottomNav.js +0 -1
  142. package/components/bar/bottomNav.vue +0 -28
  143. package/components/bar/bottomNavigationCircle.js +0 -2
  144. package/components/bar/bottomNavigationCircle.vue +0 -99
  145. package/components/bar/scss/bottomNav.scss +0 -67
  146. package/components/bar/scss/toolbar.scss +0 -174
  147. package/components/bar/toolbar/index.js +0 -8
  148. package/components/bar/toolbar/index.vue +0 -35
  149. package/components/bar/toolbar/laptop.vue +0 -33
  150. package/components/bar/toolbar/menuChilds.vue +0 -41
  151. package/components/bar/toolbar/menuLaptop.vue +0 -41
  152. package/components/bar/toolbar/menuMob.vue +0 -39
  153. package/components/bar/toolbar/mixin.js +0 -43
  154. package/components/bar/toolbar/mobile.vue +0 -34
  155. package/components/breadcrumb/bredcrumbItem.vue +0 -39
  156. package/components/breadcrumb/index.js +0 -3
  157. package/components/breadcrumb/index.vue +0 -71
  158. package/components/breadcrumb/style.scss +0 -51
  159. package/components/button/style.scss +0 -411
  160. package/components/card/style.scss +0 -86
  161. package/components/chart/chart.js +0 -1
  162. package/components/chart/chart.vue +0 -69
  163. package/components/chart/worldMap.js +0 -2
  164. package/components/chart/worldMap.vue +0 -1112
  165. package/components/chat/MessageList.vue +0 -163
  166. package/components/chat/chatInput.vue +0 -150
  167. package/components/chat/chatMsg.vue +0 -276
  168. package/components/chat/index.js +0 -11
  169. package/components/chat/index.vue +0 -113
  170. package/components/chip/index.js +0 -3
  171. package/components/chip/index.vue +0 -77
  172. package/components/chip/style.scss +0 -199
  173. package/components/codeEditor/mixin.js +0 -145
  174. package/components/countdown/index.js +0 -1
  175. package/components/countdown/index.vue +0 -105
  176. package/components/form/colorInput/mixin.js +0 -132
  177. package/components/form/fileInput/file.js +0 -148
  178. package/components/form/telInput/assets/flags.png +0 -0
  179. package/components/form/telInput/assets/flags@2x.png +0 -0
  180. package/components/form/text-editor/index.vue +0 -705
  181. package/components/icon/style.scss +0 -17
  182. package/components/infinite/div.js +0 -6
  183. package/components/infinite/div.vue +0 -193
  184. package/components/infinite/page.js +0 -3
  185. package/components/infinite/page.vue +0 -105
  186. package/components/list/index.js +0 -3
  187. package/components/list/index.vue +0 -122
  188. package/components/list/style.scss +0 -66
  189. package/components/message/index.js +0 -4
  190. package/components/message/index.vue +0 -40
  191. package/components/modal/style.scss +0 -146
  192. package/components/nestable/NestableItem.vue +0 -307
  193. package/components/nestable/editable.js +0 -44
  194. package/components/nestable/index.js +0 -1
  195. package/components/nestable/index.vue +0 -226
  196. package/components/nestable/methods.js +0 -416
  197. package/components/progress/style.scss +0 -229
  198. package/components/table/style.scss +0 -338
  199. package/components/tabs/index.js +0 -3
  200. package/components/tabs/index.vue +0 -151
  201. package/components/timeline/index.js +0 -6
  202. package/components/timeline/index.vue +0 -76
  203. package/directive/resize/index.js +0 -30
  204. package/directive/skeleton/index.js +0 -27
  205. package/directive/skeleton/style.scss +0 -37
  206. package/plugins/request/Request.js +0 -68
  207. package/style/animation.scss +0 -94
  208. package/style/style.scss +0 -8
  209. package/tools/rootable.js +0 -75
  210. /package/components/form/{text-editor → textEditor}/index.js +0 -0
  211. /package/components/form/{text-editor → textEditor}/preview.js +0 -0
  212. /package/components/form/{text-editor → textEditor}/preview.vue +0 -0
@@ -1,85 +1,108 @@
1
1
  <template>
2
2
  <div class="hue ms-1">
3
- <canvas ref="canvas" :width="width" :height="height" v-touch="{'end':move,
4
- 'move':move}"/>
5
- <div :style="style" class="slide"/>
3
+ <canvas
4
+ ref="canvasRef"
5
+ v-touch="{'end': handleMove, 'move': handleMove}"
6
+ :height="height"
7
+ :width="width"
8
+ />
9
+ <div :style="slideStyle" class="slide"/>
6
10
  </div>
7
11
  </template>
8
12
 
9
- <script >
10
-
11
- export default
12
- {
13
- props: {
14
- hsv: {
15
- type: Object,
16
- default: null,
17
- },
18
- width: {
19
- type: Number,
20
- default: 15,
21
- },
22
- height: {
23
- type: Number,
24
- default: 152,
25
- },
26
- },
27
- emits: ['selectHue'],
28
- data() {
29
- return {
30
- style: {},
31
- ctx: null
32
- }
13
+ <script setup>
14
+ import {ref, watch, onMounted, computed} from 'vue'
15
+
16
+ const props = defineProps({
17
+ hsv: {
18
+ type: Object,
19
+ default: () => ({h: 0}),
33
20
  },
34
- mounted() {
35
- this.ctx = this.$refs.canvas.getContext('2d', {willReadFrequently: true})
36
- this.renderColor()
37
- this.renderSlide()
21
+ width: {
22
+ type: Number,
23
+ default: 15,
38
24
  },
39
- methods: {
40
- renderColor() {
41
- const g = this.ctx.createLinearGradient(0, 0, 0, this.height)
42
- g.addColorStop(0, '#FF0000') // red
43
- g.addColorStop(0.17 * 1, '#FF00FF') // purple
44
- g.addColorStop(0.17 * 2, '#0000FF') // blue
45
- g.addColorStop(0.17 * 3, '#00FFFF') // green
46
- g.addColorStop(0.17 * 4, '#00FF00') // green
47
- g.addColorStop(0.17 * 5, '#FFFF00') // yellow
48
- g.addColorStop(1, '#FF0000') // red
49
- this.ctx.fillStyle = g
50
- this.ctx.fillRect(0, 0, this.width, this.height)
51
- },
52
- renderSlide() {
53
- this.style = {
54
- top: (1 - this.hsv.h / 360) * this.height + 'px',
55
- }
56
- },
57
- move(e) {
58
- let y = e.current.y
59
-
60
- if (y < 0) {
61
- y = 0
62
- }
63
- if (y > this.height) {
64
- y = this.height
65
- }
66
-
67
- this.style = {
68
- top: y - 2 + 'px',
69
- }
70
-
71
- const imgData = this.ctx.getImageData(0, Math.min(y, this.height - 1), 1, 1)
72
- const [r, g, b] = imgData.data
73
- this.$emit('selectHue', {r, g, b})
74
- }
25
+ height: {
26
+ type: Number,
27
+ default: 152,
75
28
  },
29
+ })
30
+
31
+ const emit = defineEmits(['selectHue'])
32
+
33
+ const canvasRef = ref(null)
34
+ const ctx = ref(null)
35
+ const slideTop = ref('0px')
36
+
37
+ const slideStyle = computed(() => ({
38
+ top: slideTop.value,
39
+ }))
40
+
41
+ watch(() => props.hsv?.h, () => {
42
+ renderSlide()
43
+ }, {immediate: true})
44
+
45
+
46
+ onMounted(() => {
47
+ if (canvasRef.value) {
48
+ ctx.value = canvasRef.value.getContext('2d', {willReadFrequently: true})
49
+ renderColor()
50
+ renderSlide()
51
+ }
52
+ })
53
+
54
+ function renderColor() {
55
+ if (!ctx.value) return
56
+
57
+ const gradient = ctx.value.createLinearGradient(0, 0, 0, props.height)
58
+ gradient.addColorStop(0, '#FF0000') // red
59
+ gradient.addColorStop(0.17 * 1, '#FF00FF') // purple
60
+ gradient.addColorStop(0.17 * 2, '#0000FF') // blue
61
+ gradient.addColorStop(0.17 * 3, '#00FFFF') // cyan
62
+ gradient.addColorStop(0.17 * 4, '#00FF00') // green
63
+ gradient.addColorStop(0.17 * 5, '#FFFF00') // yellow
64
+ gradient.addColorStop(1, '#FF0000') // red
65
+
66
+ ctx.value.fillStyle = gradient
67
+ ctx.value.fillRect(0, 0, props.width, props.height)
76
68
  }
69
+
70
+ function renderSlide() {
71
+ if (!props.hsv) return
72
+
73
+ const hue = props.hsv.h || 0
74
+ const topPosition = (1 - hue / 360) * props.height
75
+ slideTop.value = `${topPosition}px`
76
+ }
77
+
78
+ function handleMove(e) {
79
+ let y = e.current.y
80
+
81
+ if (y < 0) y = 0
82
+ if (y > props.height) y = props.height
83
+
84
+ slideTop.value = `${y - 2}px`
85
+
86
+ if (!ctx.value) return
87
+
88
+ const pixelY = Math.min(y, props.height - 1)
89
+ const imgData = ctx.value.getImageData(0, pixelY, 1, 1)
90
+ const [r, g, b] = imgData.data
91
+
92
+ emit('selectHue', {r, g, b})
93
+ }
94
+
95
+ defineExpose({
96
+ renderColor,
97
+ renderSlide
98
+ })
77
99
  </script>
78
100
 
79
101
  <style lang="scss">
80
102
  .hue {
81
103
  position: relative;
82
104
  cursor: pointer;
105
+
83
106
  .slide {
84
107
  position: absolute;
85
108
  left: 0;
@@ -91,4 +114,4 @@ export default
91
114
  pointer-events: none;
92
115
  }
93
116
  }
94
- </style>
117
+ </style>
@@ -1,53 +1,49 @@
1
1
  <template>
2
- <canvas ref="canvas" :width="width" :height="height"/>
2
+ <canvas ref="canvasRef" :height="height" :width="width"/>
3
3
  </template>
4
- <script>
5
- import {color} from "./mixin.js";
6
-
7
- export default {
8
- props: {
9
- color: {
10
- type: String,
11
- default: '#000000',
12
- },
13
- width: {
14
- type: Number,
15
- default: 100,
16
- },
17
- height: {
18
- type: Number,
19
- default: 30,
20
- },
21
- },
22
- mixins: [color],
23
- data() {
24
- return {
25
- alphaSize: 7,
26
- ctx: null
27
- }
28
- },
29
- watch: {
30
- color() {
31
- this.renderColor()
32
- },
4
+
5
+ <script setup>
6
+ import {ref, watch, onMounted} from 'vue'
7
+ import {useColor} from './useColor.js'
8
+
9
+ const props = defineProps({
10
+ color: {
11
+ type: String,
12
+ default: '#000000',
33
13
  },
34
- mounted() {
35
- this.ctx = this.$refs.canvas.getContext('2d', {willReadFrequently: true})
36
- this.renderColor()
14
+ width: {
15
+ type: Number,
16
+ default: 100,
37
17
  },
38
- methods: {
39
- renderColor() {
40
- if (!this.ctx) {
41
- return
42
- }
43
- const canvasSquare = this.createAlphaSquare(this.alphaSize)
44
-
45
- this.ctx.fillStyle = this.ctx.createPattern(canvasSquare, 'repeat')
46
- this.ctx.fillRect(0, 0, this.width, this.height)
47
-
48
- this.ctx.fillStyle = this.color
49
- this.ctx.fillRect(0, 0, this.width, this.height)
50
- },
18
+ height: {
19
+ type: Number,
20
+ default: 30,
51
21
  },
22
+ })
23
+
24
+ const {createAlphaSquare} = useColor()
25
+
26
+ const canvasRef = ref(null)
27
+ const ctx = ref(null)
28
+ const alphaSize = ref(7)
29
+
30
+ watch(() => props.color, renderColor)
31
+
32
+ onMounted(() => {
33
+ if (canvasRef.value) {
34
+ ctx.value = canvasRef.value.getContext('2d', {willReadFrequently: true})
35
+ renderColor()
36
+ }
37
+ })
38
+
39
+ function renderColor() {
40
+ if (!ctx.value) return
41
+
42
+ const canvasSquare = createAlphaSquare(alphaSize.value)
43
+ ctx.value.fillStyle = ctx.value.createPattern(canvasSquare, 'repeat')
44
+ ctx.value.fillRect(0, 0, props.width, props.height)
45
+
46
+ ctx.value.fillStyle = props.color
47
+ ctx.value.fillRect(0, 0, props.width, props.height)
52
48
  }
53
- </script>
49
+ </script>
@@ -1,98 +1,113 @@
1
1
  <template>
2
2
  <div class="saturation">
3
- <canvas ref="canvas" :width="size" :height="size" v-touch="{'end':move,
4
- 'move':move}"/>
3
+ <canvas
4
+ ref="canvasRef"
5
+ v-touch="{'end': handleMove, 'move': handleMove}"
6
+ :height="size"
7
+ :width="size"
8
+ />
5
9
  <div :style="style" class="slide"/>
6
10
  </div>
7
11
  </template>
8
12
 
9
- <script>
10
- import {color} from "./mixin.js";
11
-
12
- export default {
13
- props: {
14
- color: {
15
- type: String,
16
- default: '#000000',
17
- },
18
- hsv: {
19
- type: Object,
20
- default: null,
21
- },
22
- size: {
23
- type: Number,
24
- default: 152,
25
- },
26
- },
27
- mixins: [color],
28
- emits: ['selectSaturation'],
29
- data() {
30
- return {
31
- style: {},
32
- ctx: null
33
- }
13
+
14
+ <script setup>
15
+ import {ref, onMounted} from 'vue'
16
+ import {useColor} from './useColor.js'
17
+
18
+ const props = defineProps({
19
+ color: {
20
+ type: String,
21
+ default: '#000000',
34
22
  },
35
- mounted() {
36
- this.ctx = this.$refs.canvas.getContext('2d', {willReadFrequently: true})
37
- this.renderColor()
38
- this.renderSlide()
23
+ hsv: {
24
+ type: Object,
25
+ default: null,
39
26
  },
40
- methods: {
41
- renderColor() {
42
- const size = this.size
43
-
44
- this.ctx.fillStyle = this.color
45
- this.ctx.fillRect(0, 0, size, size)
46
-
47
- this.createLinearGradient(
48
- 'l',
49
- this.ctx,
50
- size,
51
- size,
52
- '#FFFFFF',
53
- 'rgba(255,255,255,0)'
54
- )
55
- this.createLinearGradient('p', this.ctx, size, size, 'rgba(0,0,0,0)', '#000000')
56
- },
57
- renderSlide() {
58
- this.style = {
59
- left: this.hsv.s * this.size - 5 + 'px',
60
- top: (1 - this.hsv.v) * this.size - 5 + 'px',
61
- }
62
- },
63
- move(e) {
64
- let x = e.current.x
65
- let y = e.current.y
66
-
67
- if (x < 0) {
68
- x = 0
69
- }
70
- if (y < 0) {
71
- y = 0
72
- }
73
- if (x > this.size) {
74
- x = this.size
75
- }
76
- if (y > this.size) {
77
- y = this.size
78
- }
79
-
80
- this.style = {
81
- left: x - 5 + 'px',
82
- top: y - 5 + 'px',
83
- }
84
-
85
- const imgData = this.ctx.getImageData(
86
- Math.min(x, this.size - 1),
87
- Math.min(y, this.size - 1),
88
- 1,
89
- 1
90
- )
91
- const [r, g, b] = imgData.data
92
- this.$emit('selectSaturation', {r, g, b})
93
- }
27
+ size: {
28
+ type: Number,
29
+ default: 152,
94
30
  },
31
+ })
32
+
33
+ const emit = defineEmits(['selectSaturation'])
34
+
35
+ const {createLinearGradient} = useColor()
36
+
37
+ const canvasRef = ref(null)
38
+ const ctx = ref(null)
39
+ const style = ref({})
40
+
41
+
42
+ onMounted(() => {
43
+ if (canvasRef.value) {
44
+ ctx.value = canvasRef.value.getContext('2d', {willReadFrequently: true})
45
+ renderColor()
46
+ renderSlide()
47
+ }
48
+ })
49
+
50
+ function renderColor() {
51
+ const size = props.size
52
+
53
+ ctx.value.fillStyle = props.color
54
+ ctx.value.fillRect(0, 0, size, size)
55
+
56
+ createLinearGradient(
57
+ 'l',
58
+ ctx.value,
59
+ size,
60
+ size,
61
+ '#FFFFFF',
62
+ 'rgba(255,255,255,0)'
63
+ )
64
+ createLinearGradient('p', ctx.value, size, size, 'rgba(0,0,0,0)', '#000000')
95
65
  }
66
+
67
+
68
+ function renderSlide() {
69
+ style.value = {
70
+ left: props.hsv.s * props.size - 5 + 'px',
71
+ top: (1 - props.hsv.v) * props.size - 5 + 'px',
72
+ }
73
+ }
74
+
75
+ function handleMove(e) {
76
+ let x = e.current.x
77
+ let y = e.current.y
78
+
79
+ if (x < 0) {
80
+ x = 0
81
+ }
82
+ if (y < 0) {
83
+ y = 0
84
+ }
85
+ if (x > props.size) {
86
+ x = props.size
87
+ }
88
+ if (y > props.size) {
89
+ y = props.size
90
+ }
91
+
92
+ style.value = {
93
+ left: x - 5 + 'px',
94
+ top: y - 5 + 'px',
95
+ }
96
+
97
+ const imgData = ctx.value.getImageData(
98
+ Math.min(x, props.size - 1),
99
+ Math.min(y, props.size - 1),
100
+ 1,
101
+ 1
102
+ )
103
+ const [r, g, b] = imgData.data
104
+ emit('selectSaturation', {r, g, b})
105
+ }
106
+
107
+ defineExpose({
108
+ renderColor,
109
+ renderSlide
110
+ })
96
111
  </script>
97
112
 
98
113
  <style lang="scss">
@@ -112,4 +127,4 @@ export default {
112
127
  pointer-events: none;
113
128
  }
114
129
  }
115
- </style>
130
+ </style>
@@ -1,9 +1,10 @@
1
1
  <template>
2
- <r-input class="mt-5" :model-value="modelValue" hide labelControlClass="label-active"
2
+ <r-input :model-value="modelValue"
3
+ @click.prevent="open=true"
3
4
  :class="`${$r.prefix}color-picker`">
4
- <div :style="{'background-color':modelValue||'#ffffff'}" class="shower" @click.prevent="open=true"></div>
5
+ <div :style="{'background-color':modelValue}" class="shower"></div>
5
6
  <r-modal v-model="open" class="color-picker-modal" maxWidth="260px" no-close-btn>
6
- <picker :color="modelValue" @changeColor="emit"></picker>
7
+ <picker :color="modelValue" @changeColor="emitColor"></picker>
7
8
  <div class="d-flex h-space-between">
8
9
  <r-btn class="color-success flex-grow-1 me-1" outlined @click.prevent="close()">
9
10
  <r-icon v-html="$r.icons.check" exact></r-icon>
@@ -15,52 +16,83 @@
15
16
  </r-modal>
16
17
  </r-input>
17
18
  </template>
18
- <script>
19
- import {defineAsyncComponent} from 'vue'
19
+ <script setup>
20
+ import {ref} from 'vue'
21
+ import Picker from "./picker.vue";
20
22
 
21
- export default {
22
- name: 'r-color-picker',
23
- components: {Picker:defineAsyncComponent(()=>import('./picker.vue'))},
24
- props: {
25
- modelValue: String,
26
- format: {type: String, default: 'rgba'}
27
- },
28
- emits: ['update:modelValue', 'close'],
29
- data() {
30
- return {
31
- open: false
32
- }
33
- },
34
- methods: {
35
- clear() {
36
- this.open = false
37
- this.$emit('update:modelValue', null)
38
- this.$emit('close', true)
39
- },
40
- close() {
41
- this.open = false
42
- this.$emit('close', true)
43
- },
44
- emit(e) {
45
- let r = e.hex
46
- if (this.format === 'rgba') {
47
- r = e.rgba
48
- }
49
- this.$emit('update:modelValue', r)
50
- }
23
+ const props = defineProps({
24
+ /**
25
+ * The model value for the color picker (v-model)
26
+ * @type {String}
27
+ */
28
+ modelValue: String,
29
+
30
+ /**
31
+ * Color format to output
32
+ * @type {String}
33
+ * @default 'rgba'
34
+ * @values rgba, hex
35
+ */
36
+ format: {
37
+ type: String,
38
+ default: 'rgba'
51
39
  }
40
+ })
41
+
42
+ const emit = defineEmits([
43
+ /**
44
+ * Emitted when the color value changes
45
+ * @param {String} color - The new color value
46
+ */
47
+ 'update:modelValue',
48
+
49
+ /**
50
+ * Emitted when the color picker is closed
51
+ * @param {Boolean} true - Indicates the picker is closed
52
+ */
53
+ 'close'
54
+ ])
52
55
 
56
+ const open = ref(false)
57
+
58
+ /**
59
+ * Clears the selected color and closes the picker
60
+ */
61
+ function clear() {
62
+ open.value = false
63
+ emit('update:modelValue', null)
64
+ emit('close', true)
65
+ }
66
+
67
+ /**
68
+ * Closes the color picker
69
+ */
70
+ function close() {
71
+ open.value = false
72
+ emit('close', true)
73
+ }
74
+
75
+ /**
76
+ * Emits the selected color in the specified format
77
+ * @param {Object} e - Color picker event object
78
+ * @param {String} e.hex - Hex color value
79
+ * @param {String} e.rgba - RGBA color value
80
+ */
81
+ function emitColor(e) {
82
+ let result = e.hex
83
+ if (props.format === 'rgba') {
84
+ result = e.rgba
85
+ }
86
+ emit('update:modelValue', result)
53
87
  }
54
88
  </script>
55
89
  <style lang="scss">
56
- @use "../../../style/variables/base";
90
+ @use "../../../style" as *;
57
91
 
58
- .#{base.$prefix}color-picker {
92
+ .#{$prefix}color-picker {
59
93
  .shower {
60
94
  width: 100%;
61
95
  height: 30px;
62
- cursor: pointer;
63
- border: 1px solid black;
64
96
  }
65
97
 
66
98
  .color-picker-modal {