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.
- 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 +207 -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 +139 -80
- 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 +93 -49
- 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 +71 -39
- 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 +332 -168
- 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 +82 -55
- package/components/form/timeInput/range.vue +115 -94
- 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 +250 -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 +3 -3
- package/components/infinite/index.vue +290 -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 +206 -94
- package/components/meta/meta.js +26 -3
- package/components/modal/index.vue +382 -156
- 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 +319 -156
- package/components/swiper/index.vue +237 -108
- package/components/table/crud/footer.vue +77 -53
- package/components/table/crud/header.vue +71 -72
- package/components/table/crud/index.vue +629 -399
- 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 +106 -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 +272 -24
- package/directive/sortable/index.js +274 -0
- package/directive/title/index.js +75 -0
- package/directive/touch/index.js +268 -0
- package/index.js +11 -19
- 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 +155 -178
- package/style/variables/color.scss +0 -12
- package/style/variables/utilities.scss +0 -180
- package/tools/helper.js +0 -8
- package/tools/icons.js +7 -2
- 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 -705
- 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
|
@@ -4,21 +4,21 @@
|
|
|
4
4
|
>
|
|
5
5
|
<div class="color-set">
|
|
6
6
|
<Saturation
|
|
7
|
-
ref="
|
|
7
|
+
ref="saturationRef"
|
|
8
8
|
:hsv="{h:h,s:s,v:v}"
|
|
9
9
|
:color="rgbaString"
|
|
10
10
|
:size="200"
|
|
11
11
|
@selectSaturation="selectSaturation"
|
|
12
12
|
/>
|
|
13
13
|
<Hue
|
|
14
|
-
ref="
|
|
14
|
+
ref="hueRef"
|
|
15
15
|
:hsv="{h:h,s:s,v:v}"
|
|
16
16
|
:width="15"
|
|
17
17
|
:height="200"
|
|
18
18
|
@selectHue="selectHue"
|
|
19
19
|
/>
|
|
20
20
|
<Alpha
|
|
21
|
-
ref="
|
|
21
|
+
ref="alphaRef"
|
|
22
22
|
:color="rgbaString"
|
|
23
23
|
:rgba="rgba"
|
|
24
24
|
:width="15"
|
|
@@ -49,119 +49,124 @@
|
|
|
49
49
|
<slot></slot>
|
|
50
50
|
</div>
|
|
51
51
|
</template>
|
|
52
|
+
<script setup>
|
|
53
|
+
import {nextTick, ref, computed, watch} from 'vue'
|
|
54
|
+
import {rgb2hex, setColorValue} from './useColor.js'
|
|
55
|
+
import Saturation from "./Saturation.vue";
|
|
56
|
+
import Hue from "./Hue.vue";
|
|
57
|
+
import Alpha from "./Alpha.vue";
|
|
58
|
+
import Preview from "./Preview.vue";
|
|
59
|
+
|
|
60
|
+
const props = defineProps({
|
|
61
|
+
color: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: '#2F1DCC',
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
const emit = defineEmits(['changeColor'])
|
|
67
|
+
const r = ref(0)
|
|
68
|
+
const g = ref(0)
|
|
69
|
+
const b = ref(0)
|
|
70
|
+
const a = ref(1)
|
|
71
|
+
const h = ref(0)
|
|
72
|
+
const s = ref(0)
|
|
73
|
+
const v = ref(0)
|
|
74
|
+
|
|
75
|
+
const saturationRef = ref(null)
|
|
76
|
+
const hueRef = ref(null)
|
|
77
|
+
const alphaRef = ref(null)
|
|
78
|
+
|
|
79
|
+
const rgba = computed(() => ({
|
|
80
|
+
r: r.value,
|
|
81
|
+
g: g.value,
|
|
82
|
+
b: b.value,
|
|
83
|
+
a: a.value
|
|
84
|
+
}))
|
|
85
|
+
const rgbaString = computed(() =>
|
|
86
|
+
`rgba(${r.value}, ${g.value}, ${b.value}, ${a.value})`
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
const hexString = computed(() =>
|
|
90
|
+
rgb2hex(rgba.value, true)
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
watch(() => props.color, (newColor) => {
|
|
94
|
+
setColorValue(newColor, {
|
|
95
|
+
r, g, b, a, h, s, v
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
watch(rgba, () => {
|
|
100
|
+
emit('changeColor', {
|
|
101
|
+
rgba: rgbaString.value,
|
|
102
|
+
hex: hexString.value,
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
function selectSaturation(color) {
|
|
107
|
+
setColorValue(color, {
|
|
108
|
+
r, g, b, a, h, s, v
|
|
109
|
+
})
|
|
110
|
+
}
|
|
52
111
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
type: String,
|
|
68
|
-
default: '#2F1DCC',
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
emits: ['changeColor'],
|
|
72
|
-
data() {
|
|
73
|
-
return {
|
|
74
|
-
r: 0,
|
|
75
|
-
g: 0,
|
|
76
|
-
b: 0,
|
|
77
|
-
a: 1,
|
|
78
|
-
h: 0,
|
|
79
|
-
s: 0,
|
|
80
|
-
v: 0
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
computed: {
|
|
84
|
-
rgba() {
|
|
85
|
-
return {
|
|
86
|
-
r: this.r,
|
|
87
|
-
g: this.g,
|
|
88
|
-
b: this.b,
|
|
89
|
-
a: this.a
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
rgbaString() {
|
|
94
|
-
return `rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})`
|
|
95
|
-
},
|
|
96
|
-
hexString() {
|
|
97
|
-
return this.rgb2hex(this.rgba, true)
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
created() {
|
|
101
|
-
this.setColorValue(this.color)
|
|
102
|
-
},
|
|
103
|
-
watch: {
|
|
104
|
-
color: function () {
|
|
105
|
-
this.setColorValue(this.color)
|
|
106
|
-
},
|
|
107
|
-
rgba: function () {
|
|
108
|
-
this.$emit('changeColor', {
|
|
109
|
-
rgba: this.rgbaString,
|
|
110
|
-
hex: this.hexString,
|
|
111
|
-
})
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
methods: {
|
|
115
|
-
selectSaturation(color) {
|
|
116
|
-
this.setColorValue(color)
|
|
117
|
-
},
|
|
118
|
-
selectHue(color) {
|
|
119
|
-
this.setColorValue(color)
|
|
120
|
-
this.$nextTick(() => {
|
|
121
|
-
|
|
122
|
-
this.$refs.saturation.renderColor()
|
|
123
|
-
|
|
124
|
-
this.$refs.saturation.renderSlide()
|
|
125
|
-
})
|
|
126
|
-
},
|
|
127
|
-
selectAlpha(a) {
|
|
128
|
-
this.a = a
|
|
129
|
-
},
|
|
130
|
-
inputHex(color) {
|
|
131
|
-
const value = color.target.value
|
|
132
|
-
this.setColorValue(value)
|
|
133
|
-
this.$nextTick(() => {
|
|
134
|
-
|
|
135
|
-
this.$refs.saturation.renderColor()
|
|
136
|
-
|
|
137
|
-
this.$refs.saturation.renderSlide()
|
|
138
|
-
|
|
139
|
-
this.$refs.hue.renderSlide()
|
|
140
|
-
})
|
|
141
|
-
},
|
|
142
|
-
inputRgba(color) {
|
|
143
|
-
const value = color.target.value
|
|
144
|
-
this.setColorValue(value)
|
|
145
|
-
this.$nextTick(() => {
|
|
146
|
-
this.$refs.saturation.renderColor()
|
|
147
|
-
|
|
148
|
-
this.$refs.saturation.renderSlide()
|
|
149
|
-
|
|
150
|
-
this.$refs.hue.renderSlide()
|
|
151
|
-
})
|
|
152
|
-
}
|
|
153
|
-
},
|
|
112
|
+
function selectHue(color) {
|
|
113
|
+
setColorValue(color, {
|
|
114
|
+
r, g, b, a, h, s, v
|
|
115
|
+
})
|
|
116
|
+
nextTick(() => {
|
|
117
|
+
|
|
118
|
+
saturationRef.value.renderColor()
|
|
119
|
+
|
|
120
|
+
saturationRef.value.renderSlide()
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function selectAlpha(e) {
|
|
125
|
+
a.value = e
|
|
154
126
|
}
|
|
127
|
+
|
|
128
|
+
function inputHex(color) {
|
|
129
|
+
const value = color.target.value
|
|
130
|
+
setColorValue(value, {
|
|
131
|
+
r, g, b, a, h, s, v
|
|
132
|
+
})
|
|
133
|
+
nextTick(() => {
|
|
134
|
+
|
|
135
|
+
saturationRef.value.renderColor()
|
|
136
|
+
|
|
137
|
+
saturationRef.value.renderSlide()
|
|
138
|
+
|
|
139
|
+
hueRef.value.renderSlide()
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function inputRgba(color) {
|
|
144
|
+
const value = color.target.value
|
|
145
|
+
setColorValue(value, {
|
|
146
|
+
r, g, b, a, h, s, v
|
|
147
|
+
})
|
|
148
|
+
nextTick(() => {
|
|
149
|
+
saturationRef.value.renderColor()
|
|
150
|
+
|
|
151
|
+
saturationRef.value.renderSlide()
|
|
152
|
+
|
|
153
|
+
hueRef.value.renderSlide()
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
setColorValue(props.color, {
|
|
158
|
+
r, g, b, a, h, s, v
|
|
159
|
+
})
|
|
155
160
|
</script>
|
|
156
161
|
|
|
157
162
|
<style lang="scss">
|
|
158
163
|
@use "sass:map";
|
|
159
|
-
@use "../../../style
|
|
164
|
+
@use "../../../style" as *;
|
|
160
165
|
|
|
161
166
|
|
|
162
167
|
.color-box {
|
|
163
168
|
padding: 10px;
|
|
164
|
-
border-radius: map.get(
|
|
169
|
+
border-radius: map.get($borders, 'sm');
|
|
165
170
|
box-shadow: 0 0 16px 0 rgba(0, 0, 0, 0.16);
|
|
166
171
|
z-index: 1;
|
|
167
172
|
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
export const useColor = () => {
|
|
2
|
+
const setColorValue = (color, component) => {
|
|
3
|
+
let rgba = {r: 0, g: 0, b: 0, a: 1}
|
|
4
|
+
const rgbRegex = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*((?:\d*\.)?\d+(?:%?))\s*)?\)$/i;
|
|
5
|
+
const hexRegex = /^#([a-f0-9]{6}|[a-f0-9]{8})$/i
|
|
6
|
+
|
|
7
|
+
if (hexRegex.test(color)) {
|
|
8
|
+
rgba = hex2rgba(color)
|
|
9
|
+
} else if (rgbRegex.test(color)) {
|
|
10
|
+
rgba = rgb2rgba(color)
|
|
11
|
+
} else if (Object.prototype.toString.call(color) === '[object Object]') {
|
|
12
|
+
rgba = color
|
|
13
|
+
} else {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
component.r.value = rgba.r
|
|
18
|
+
component.g.value = rgba.g
|
|
19
|
+
component.b.value = rgba.b
|
|
20
|
+
|
|
21
|
+
if (rgba.a >= 0 && rgba.a <= 1) {
|
|
22
|
+
component.a.value = rgba.a
|
|
23
|
+
} else {
|
|
24
|
+
component.a.value = 1
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setHSV(rgba, component)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const createAlphaSquare = (size) => {
|
|
31
|
+
const canvas = document.createElement('canvas')
|
|
32
|
+
const ctx = canvas.getContext('2d')
|
|
33
|
+
const doubleSize = size * 2
|
|
34
|
+
canvas.width = doubleSize
|
|
35
|
+
canvas.height = doubleSize
|
|
36
|
+
|
|
37
|
+
ctx.fillStyle = '#ffffff'
|
|
38
|
+
ctx.fillRect(0, 0, doubleSize, doubleSize)
|
|
39
|
+
ctx.fillStyle = '#ccd5db'
|
|
40
|
+
ctx.fillRect(0, 0, size, size)
|
|
41
|
+
ctx.fillRect(size, size, size, size)
|
|
42
|
+
|
|
43
|
+
return canvas
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const createLinearGradient = (direction, ctx, width, height, color1, color2) => {
|
|
47
|
+
const isL = direction === 'l'
|
|
48
|
+
const gradient = ctx.createLinearGradient(
|
|
49
|
+
0,
|
|
50
|
+
0,
|
|
51
|
+
isL ? width : 0,
|
|
52
|
+
isL ? 0 : height
|
|
53
|
+
)
|
|
54
|
+
gradient.addColorStop(0.01, color1)
|
|
55
|
+
gradient.addColorStop(0.99, color2)
|
|
56
|
+
ctx.fillStyle = gradient
|
|
57
|
+
ctx.fillRect(0, 0, width, height)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const rgb2hex = ({r, g, b, a}, toUpper = false) => {
|
|
61
|
+
const change = (val) => {
|
|
62
|
+
const hex = Math.round(val).toString(16)
|
|
63
|
+
return hex.length === 1 ? '0' + hex : hex
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let color = `#${change(r)}${change(g)}${change(b)}`
|
|
67
|
+
|
|
68
|
+
if (a !== undefined && a !== 1) {
|
|
69
|
+
const alpha = Math.round(a * 255)
|
|
70
|
+
color += change(alpha)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return toUpper ? color.toUpperCase() : color
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const hex2rgba = (hex) => {
|
|
77
|
+
hex = hex.slice(1)
|
|
78
|
+
const change = (val) => parseInt(val, 16) || 0
|
|
79
|
+
const r = change(hex.slice(0, 2))
|
|
80
|
+
const g = change(hex.slice(2, 4))
|
|
81
|
+
const b = change(hex.slice(4, 6))
|
|
82
|
+
|
|
83
|
+
let a = 1
|
|
84
|
+
if (hex.length === 8) {
|
|
85
|
+
const alphaHex = hex.slice(6, 8)
|
|
86
|
+
a = parseFloat((parseInt(alphaHex, 16) / 255).toFixed(2))
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {r, g, b, a}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const rgb2rgba = (rgba) => {
|
|
93
|
+
rgba = (/rgba?\((.*?)\)/.exec(rgba) || ['', '0,0,0,1'])[1].split(',')
|
|
94
|
+
return {
|
|
95
|
+
r: Number(rgba[0]) || 0,
|
|
96
|
+
g: Number(rgba[1]) || 0,
|
|
97
|
+
b: Number(rgba[2]) || 0,
|
|
98
|
+
a: Number(rgba[3] ? rgba[3] : 1),
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const setHSV = ({r, g, b}, component) => {
|
|
103
|
+
r = r / 255
|
|
104
|
+
g = g / 255
|
|
105
|
+
b = b / 255
|
|
106
|
+
const max = Math.max(r, g, b)
|
|
107
|
+
const min = Math.min(r, g, b)
|
|
108
|
+
const delta = max - min
|
|
109
|
+
let h = 0
|
|
110
|
+
|
|
111
|
+
if (max === min) {
|
|
112
|
+
h = 0
|
|
113
|
+
} else if (max === r) {
|
|
114
|
+
if (g >= b) {
|
|
115
|
+
h = (60 * (g - b)) / delta
|
|
116
|
+
} else {
|
|
117
|
+
h = (60 * (g - b)) / delta + 360
|
|
118
|
+
}
|
|
119
|
+
} else if (max === g) {
|
|
120
|
+
h = (60 * (b - r)) / delta + 120
|
|
121
|
+
} else if (max === b) {
|
|
122
|
+
h = (60 * (r - g)) / delta + 240
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
h = Math.floor(h)
|
|
126
|
+
let s = parseFloat((max === 0 ? 0 : 1 - min / max).toFixed(2))
|
|
127
|
+
let v = parseFloat(max.toFixed(2))
|
|
128
|
+
|
|
129
|
+
component.h.value = h
|
|
130
|
+
component.s.value = s
|
|
131
|
+
component.v.value = v
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
setColorValue,
|
|
136
|
+
createAlphaSquare,
|
|
137
|
+
createLinearGradient,
|
|
138
|
+
rgb2hex,
|
|
139
|
+
hex2rgba,
|
|
140
|
+
rgb2rgba,
|
|
141
|
+
setHSV
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const {
|
|
146
|
+
setColorValue,
|
|
147
|
+
createAlphaSquare,
|
|
148
|
+
createLinearGradient,
|
|
149
|
+
rgb2hex,
|
|
150
|
+
hex2rgba,
|
|
151
|
+
rgb2rgba,
|
|
152
|
+
setHSV
|
|
153
|
+
} = useColor()
|