renusify 2.5.1 → 3.0.0
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/components/app/index.vue +74 -22
- package/components/app/toast/index.vue +76 -71
- package/components/app/toast/toast.vue +62 -44
- package/components/avatar/index.vue +208 -84
- package/components/button/buttonConfirm.vue +53 -26
- package/components/button/buttonGroup.js +0 -2
- package/components/button/buttonGroup.vue +310 -62
- package/components/button/index.vue +584 -100
- package/components/calendar/index.js +0 -2
- package/components/calendar/index.vue +326 -262
- package/components/calendar/month.vue +64 -55
- package/components/calendar/year.vue +30 -25
- package/components/card/index.vue +139 -59
- package/components/codeEditor/highlightCss.vue +38 -39
- package/components/codeEditor/highlightHtml.vue +64 -64
- package/components/codeEditor/highlightJs.vue +37 -38
- package/components/codeEditor/index.vue +129 -79
- package/components/codeEditor/run.vue +225 -39
- package/components/codeEditor/useCodeFormatter.js +150 -0
- package/components/confirm/index.vue +140 -81
- package/components/container/col.vue +5 -4
- package/components/container/divider.vue +28 -19
- package/components/container/index.vue +34 -15
- package/components/container/row.vue +26 -9
- package/components/container/spacer.vue +2 -4
- package/components/container/style.scss +3 -0
- package/components/content/index.vue +49 -32
- package/components/cropper/index.vue +401 -244
- package/components/float/index.vue +542 -415
- package/components/form/addressInput/index.vue +184 -109
- package/components/form/camInput/index.vue +370 -244
- package/components/form/checkInput/index.vue +138 -71
- package/components/form/checkboxInput/index.vue +87 -47
- package/components/form/colorInput/Alpha.vue +81 -83
- package/components/form/colorInput/Hue.vue +91 -68
- package/components/form/colorInput/Preview.vue +43 -47
- package/components/form/colorInput/Saturation.vue +101 -86
- package/components/form/colorInput/index.vue +72 -40
- package/components/form/colorInput/picker.vue +111 -106
- package/components/form/colorInput/useColor.js +153 -0
- package/components/form/dateInput/index.vue +691 -356
- package/components/form/dateInput/month.vue +63 -54
- package/components/form/dateInput/year.vue +35 -25
- package/components/form/fileInput/index.js +0 -1
- package/components/form/fileInput/index.vue +263 -106
- package/components/form/fileInput/single.vue +323 -164
- package/components/form/groupInput/index.vue +199 -101
- package/components/form/index.vue +189 -83
- package/components/form/input/index.vue +416 -377
- package/components/form/jsonInput/JsonView.vue +54 -56
- package/components/form/jsonInput/index.vue +247 -165
- package/components/form/maskInput/index.vue +252 -132
- package/components/form/numberInput/index.js +0 -1
- package/components/form/numberInput/index.vue +226 -117
- package/components/form/passwordInput/index.js +2 -1
- package/components/form/passwordInput/index.vue +269 -102
- package/components/form/radioInput/index.vue +143 -72
- package/components/form/rangeInput/index.vue +280 -167
- package/components/form/ratingInput/index.vue +57 -57
- package/components/form/selectInput/index.js +1 -3
- package/components/form/selectInput/index.vue +584 -296
- package/components/form/switchInput/index.vue +73 -59
- package/components/form/telInput/index.js +0 -1
- package/components/form/telInput/index.vue +238 -135
- package/components/form/textArea/index.vue +72 -35
- package/components/form/textEditor/index.vue +739 -0
- package/components/form/{text-editor → textEditor}/style.scss +8 -16
- package/components/form/textInput/index.vue +54 -32
- package/components/form/timeInput/index.vue +83 -56
- package/components/form/timeInput/range.vue +116 -95
- package/components/form/timeInput/timepicker.vue +382 -449
- package/components/form/uniqueInput/index.vue +105 -48
- package/components/form/unitInput/index.vue +139 -84
- package/components/formCreator/index.js +0 -1
- package/components/formCreator/index.vue +314 -148
- package/components/highlight/index.vue +41 -25
- package/components/highlight/style.scss +2 -2
- package/components/highlight/{mixin.js → useHighlight.js} +181 -160
- package/components/icon/index.vue +79 -33
- package/components/img/index.vue +249 -147
- package/components/img/preview.vue +180 -198
- package/components/img/svgImg.vue +42 -39
- package/components/index.js +5 -20
- package/components/infinite/index.js +1 -2
- package/components/infinite/index.vue +248 -66
- package/components/map/index.vue +428 -261
- package/components/map/route.vue +794 -487
- package/components/map/select.vue +118 -58
- package/components/menu/index.vue +201 -91
- package/components/meta/meta.js +26 -3
- package/components/modal/index.vue +383 -158
- package/components/notify/index.vue +204 -86
- package/components/notify/notification.vue +38 -55
- package/components/progress/circle.vue +189 -70
- package/components/progress/line.vue +266 -46
- package/components/searchBox/index.js +1 -3
- package/components/searchBox/index.vue +194 -101
- package/components/skeleton/index.vue +45 -20
- package/components/slider/index.vue +318 -156
- package/components/swiper/index.vue +254 -106
- package/components/table/crud/footer.vue +77 -53
- package/components/table/crud/header.vue +71 -72
- package/components/table/crud/index.vue +631 -401
- package/components/table/index.vue +721 -278
- package/components/timeAgo/index.vue +145 -96
- package/components/tour/index.vue +338 -235
- package/components/tree/index.vue +235 -89
- package/components/tree/tree-element.vue +107 -106
- package/directive/animate/index.js +77 -0
- package/directive/clickOutSide/index.js +98 -0
- package/directive/drag/index.js +153 -0
- package/directive/index.js +11 -13
- package/directive/intersect/index.js +263 -0
- package/directive/mask/index.js +67 -0
- package/directive/parallax/index.js +78 -0
- package/directive/ripple/index.js +14 -0
- package/directive/scroll/index.js +244 -0
- package/directive/sortable/index.js +274 -0
- package/directive/title/index.js +75 -0
- package/directive/touch/index.js +268 -0
- package/index.js +10 -8
- package/package.json +5 -2
- package/plugins/validation/Validate.js +88 -79
- package/scripts/generate-docs.mjs +226 -0
- package/scripts/menu.mjs +240 -0
- package/scripts/parser.mjs +1086 -0
- package/style/_index.scss +7 -0
- package/style/app.scss +13 -65
- package/style/colors.scss +5 -22
- package/style/functions/index.scss +8 -0
- package/style/mixins/index.scss +17 -5
- package/style/variables/base.scss +154 -175
- package/style/variables/color.scss +0 -12
- package/style/variables/utilities.scss +0 -180
- package/tools/helper.js +0 -8
- package/tools/icons.js +6 -1
- package/tools/root.js +71 -0
- package/components/app/style.scss +0 -41
- package/components/app/toast/style.scss +0 -20
- package/components/avatar/style.scss +0 -32
- package/components/bar/bottomNav.js +0 -1
- package/components/bar/bottomNav.vue +0 -28
- package/components/bar/bottomNavigationCircle.js +0 -2
- package/components/bar/bottomNavigationCircle.vue +0 -99
- package/components/bar/scss/bottomNav.scss +0 -67
- package/components/bar/scss/toolbar.scss +0 -174
- package/components/bar/toolbar/index.js +0 -8
- package/components/bar/toolbar/index.vue +0 -35
- package/components/bar/toolbar/laptop.vue +0 -33
- package/components/bar/toolbar/menuChilds.vue +0 -41
- package/components/bar/toolbar/menuLaptop.vue +0 -41
- package/components/bar/toolbar/menuMob.vue +0 -39
- package/components/bar/toolbar/mixin.js +0 -43
- package/components/bar/toolbar/mobile.vue +0 -34
- package/components/breadcrumb/bredcrumbItem.vue +0 -39
- package/components/breadcrumb/index.js +0 -3
- package/components/breadcrumb/index.vue +0 -71
- package/components/breadcrumb/style.scss +0 -51
- package/components/button/style.scss +0 -411
- package/components/card/style.scss +0 -86
- package/components/chart/chart.js +0 -1
- package/components/chart/chart.vue +0 -69
- package/components/chart/worldMap.js +0 -2
- package/components/chart/worldMap.vue +0 -1112
- package/components/chat/MessageList.vue +0 -163
- package/components/chat/chatInput.vue +0 -150
- package/components/chat/chatMsg.vue +0 -276
- package/components/chat/index.js +0 -11
- package/components/chat/index.vue +0 -113
- package/components/chip/index.js +0 -3
- package/components/chip/index.vue +0 -77
- package/components/chip/style.scss +0 -199
- package/components/codeEditor/mixin.js +0 -145
- package/components/countdown/index.js +0 -1
- package/components/countdown/index.vue +0 -105
- package/components/form/colorInput/mixin.js +0 -132
- package/components/form/fileInput/file.js +0 -148
- package/components/form/telInput/assets/flags.png +0 -0
- package/components/form/telInput/assets/flags@2x.png +0 -0
- package/components/form/text-editor/index.vue +0 -710
- package/components/icon/style.scss +0 -17
- package/components/infinite/div.js +0 -6
- package/components/infinite/div.vue +0 -193
- package/components/infinite/page.js +0 -3
- package/components/infinite/page.vue +0 -105
- package/components/list/index.js +0 -3
- package/components/list/index.vue +0 -122
- package/components/list/style.scss +0 -66
- package/components/message/index.js +0 -4
- package/components/message/index.vue +0 -40
- package/components/modal/style.scss +0 -146
- package/components/nestable/NestableItem.vue +0 -307
- package/components/nestable/editable.js +0 -44
- package/components/nestable/index.js +0 -1
- package/components/nestable/index.vue +0 -226
- package/components/nestable/methods.js +0 -416
- package/components/progress/style.scss +0 -229
- package/components/table/style.scss +0 -338
- package/components/tabs/index.js +0 -3
- package/components/tabs/index.vue +0 -151
- package/components/timeline/index.js +0 -6
- package/components/timeline/index.vue +0 -76
- package/directive/resize/index.js +0 -30
- package/directive/skeleton/index.js +0 -27
- package/directive/skeleton/style.scss +0 -37
- package/plugins/request/Request.js +0 -68
- package/style/animation.scss +0 -94
- package/style/style.scss +0 -8
- package/tools/rootable.js +0 -75
- /package/components/form/{text-editor → textEditor}/index.js +0 -0
- /package/components/form/{text-editor → textEditor}/preview.js +0 -0
- /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
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.renderSlide()
|
|
21
|
+
width: {
|
|
22
|
+
type: Number,
|
|
23
|
+
default: 15,
|
|
38
24
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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="
|
|
2
|
+
<canvas ref="canvasRef" :height="height" :width="width"/>
|
|
3
3
|
</template>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
14
|
+
width: {
|
|
15
|
+
type: Number,
|
|
16
|
+
default: 100,
|
|
37
17
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
4
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.renderSlide()
|
|
23
|
+
hsv: {
|
|
24
|
+
type: Object,
|
|
25
|
+
default: null,
|
|
39
26
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
2
|
+
<r-input :model-value="modelValue"
|
|
3
|
+
@click.prevent="open=true"
|
|
3
4
|
:class="`${$r.prefix}color-picker`">
|
|
4
|
-
<div :style="{'background-color':modelValue
|
|
5
|
-
<r-modal v-model="open"
|
|
6
|
-
<picker :color="modelValue" @changeColor="
|
|
5
|
+
<div :style="{'background-color':modelValue}" class="shower"></div>
|
|
6
|
+
<r-modal v-model="open" class="color-picker-modal" maxWidth="260px" no-close-btn>
|
|
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 {
|
|
19
|
+
<script setup>
|
|
20
|
+
import {ref} from 'vue'
|
|
21
|
+
import Picker from "./picker.vue";
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
90
|
+
@use "../../../style" as *;
|
|
57
91
|
|
|
58
|
-
.#{
|
|
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 {
|