buefy 0.9.13 → 0.9.17
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/CHANGELOG.md +1706 -1639
- package/README.md +1 -1
- package/dist/buefy.css +313 -1
- package/dist/buefy.esm.js +4431 -2331
- package/dist/buefy.esm.min.js +2 -2
- package/dist/buefy.js +4467 -2364
- package/dist/buefy.min.css +1 -1
- package/dist/buefy.min.js +2 -2
- package/dist/cjs/autocomplete.js +5 -5
- package/dist/cjs/button.js +3 -3
- package/dist/cjs/carousel.js +4 -4
- package/dist/cjs/{chunk-34949503.js → chunk-0d6f213f.js} +2 -2
- package/dist/cjs/{chunk-2c7de785.js → chunk-0e3108f5.js} +2 -2
- package/dist/cjs/{chunk-2911aa4b.js → chunk-1438658c.js} +14 -11
- package/dist/cjs/{chunk-114191ae.js → chunk-1f7e4ed3.js} +3 -3
- package/dist/cjs/{chunk-a11294f9.js → chunk-334bc809.js} +1 -1
- package/dist/cjs/chunk-45739695.js +332 -0
- package/dist/cjs/{chunk-c7b2aa4b.js → chunk-4bcfaf1c.js} +0 -0
- package/dist/cjs/{chunk-f5106717.js → chunk-5058e659.js} +3 -3
- package/dist/cjs/{chunk-61023b09.js → chunk-545e1c7f.js} +102 -16
- package/dist/cjs/{chunk-30670fac.js → chunk-54b0042d.js} +19 -3
- package/dist/cjs/{chunk-fe2f57ee.js → chunk-5ed8a75a.js} +2 -2
- package/dist/cjs/{chunk-d120e215.js → chunk-73f8eef8.js} +8 -2
- package/dist/cjs/{chunk-2062216d.js → chunk-7c11fdde.js} +5 -4
- package/dist/cjs/{chunk-3cc5d9a6.js → chunk-841c0e0f.js} +1 -1
- package/dist/cjs/{chunk-9e4cf4c5.js → chunk-87a116d9.js} +0 -0
- package/dist/cjs/{chunk-fefd7b77.js → chunk-a53b7aff.js} +0 -0
- package/dist/cjs/{chunk-d0f8ea39.js → chunk-c0a093d7.js} +7 -7
- package/dist/cjs/{chunk-7da0c017.js → chunk-c8abb3ed.js} +21 -21
- package/dist/cjs/{chunk-c6fbc7b4.js → chunk-d0df905a.js} +15 -2
- package/dist/cjs/{chunk-d54e40f6.js → chunk-e86d3eeb.js} +1 -8
- package/dist/cjs/{chunk-6cb902f8.js → chunk-e872f5e2.js} +1 -1
- package/dist/cjs/{chunk-2ae50815.js → chunk-f5285f14.js} +4 -4
- package/dist/cjs/clockpicker.js +8 -8
- package/dist/cjs/colorpicker.js +1752 -0
- package/dist/cjs/config.js +1 -1
- package/dist/cjs/datepicker.js +11 -11
- package/dist/cjs/datetimepicker.js +30 -14
- package/dist/cjs/dialog.js +5 -5
- package/dist/cjs/dropdown.js +3 -3
- package/dist/cjs/field.js +2 -2
- package/dist/cjs/helpers.js +21 -1
- package/dist/cjs/icon.js +2 -2
- package/dist/cjs/image.js +2 -2
- package/dist/cjs/index.js +27 -22
- package/dist/cjs/input.js +4 -4
- package/dist/cjs/loading.js +5 -5
- package/dist/cjs/menu.js +2 -2
- package/dist/cjs/message.js +4 -9
- package/dist/cjs/modal.js +5 -5
- package/dist/cjs/navbar.js +4 -1
- package/dist/cjs/notification.js +7 -7
- package/dist/cjs/numberinput.js +30 -21
- package/dist/cjs/pagination.js +7 -7
- package/dist/cjs/progress.js +3 -3
- package/dist/cjs/rate.js +2 -2
- package/dist/cjs/select.js +4 -4
- package/dist/cjs/sidebar.js +1 -1
- package/dist/cjs/slider.js +3 -3
- package/dist/cjs/snackbar.js +5 -4
- package/dist/cjs/steps.js +5 -5
- package/dist/cjs/table.js +157 -146
- package/dist/cjs/tabs.js +7 -7
- package/dist/cjs/taginput.js +5 -5
- package/dist/cjs/timepicker.js +12 -12
- package/dist/cjs/toast.js +3 -3
- package/dist/cjs/tooltip.js +4 -4
- package/dist/cjs/upload.js +23 -9
- package/dist/components/autocomplete/index.js +24 -2
- package/dist/components/autocomplete/index.min.js +2 -2
- package/dist/components/breadcrumb/index.js +1 -1
- package/dist/components/breadcrumb/index.min.js +1 -1
- package/dist/components/button/index.js +8 -2
- package/dist/components/button/index.min.js +2 -2
- package/dist/components/carousel/index.js +8 -2
- package/dist/components/carousel/index.min.js +2 -2
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/checkbox/index.min.js +1 -1
- package/dist/components/clockpicker/index.js +41 -22
- package/dist/components/clockpicker/index.min.js +2 -2
- package/dist/components/collapse/index.js +1 -1
- package/dist/components/collapse/index.min.js +1 -1
- package/dist/components/colorpicker/index.js +4318 -0
- package/dist/components/colorpicker/index.min.js +2 -0
- package/dist/components/datepicker/index.js +48 -26
- package/dist/components/datepicker/index.min.js +2 -2
- package/dist/components/datetimepicker/index.js +66 -28
- package/dist/components/datetimepicker/index.min.js +2 -2
- package/dist/components/dialog/index.js +8 -2
- package/dist/components/dialog/index.min.js +2 -2
- package/dist/components/dropdown/index.js +14 -1
- package/dist/components/dropdown/index.min.js +2 -2
- package/dist/components/field/index.js +21 -21
- package/dist/components/field/index.min.js +1 -1
- package/dist/components/icon/index.js +8 -2
- package/dist/components/icon/index.min.js +2 -2
- package/dist/components/image/index.js +1 -1
- package/dist/components/image/index.min.js +1 -1
- package/dist/components/input/index.js +8 -2
- package/dist/components/input/index.min.js +2 -2
- package/dist/components/loading/index.js +1 -1
- package/dist/components/loading/index.min.js +1 -1
- package/dist/components/menu/index.js +8 -2
- package/dist/components/menu/index.min.js +2 -2
- package/dist/components/message/index.js +11 -9
- package/dist/components/message/index.min.js +2 -2
- package/dist/components/modal/index.js +1 -1
- package/dist/components/modal/index.min.js +1 -1
- package/dist/components/navbar/index.js +4 -1
- package/dist/components/navbar/index.min.js +2 -2
- package/dist/components/notification/index.js +13 -13
- package/dist/components/notification/index.min.js +2 -2
- package/dist/components/numberinput/index.js +34 -19
- package/dist/components/numberinput/index.min.js +2 -2
- package/dist/components/pagination/index.js +107 -16
- package/dist/components/pagination/index.min.js +2 -2
- package/dist/components/progress/index.js +2 -2
- package/dist/components/progress/index.min.js +2 -2
- package/dist/components/radio/index.js +1 -1
- package/dist/components/radio/index.min.js +1 -1
- package/dist/components/rate/index.js +8 -2
- package/dist/components/rate/index.min.js +2 -2
- package/dist/components/select/index.js +8 -2
- package/dist/components/select/index.min.js +2 -2
- package/dist/components/sidebar/index.js +1 -1
- package/dist/components/sidebar/index.min.js +1 -1
- package/dist/components/skeleton/index.js +1 -1
- package/dist/components/skeleton/index.min.js +1 -1
- package/dist/components/slider/index.js +2 -2
- package/dist/components/slider/index.min.js +2 -2
- package/dist/components/snackbar/index.js +4 -10
- package/dist/components/snackbar/index.min.js +2 -2
- package/dist/components/steps/index.js +8 -2
- package/dist/components/steps/index.min.js +2 -2
- package/dist/components/switch/index.js +1 -1
- package/dist/components/switch/index.min.js +1 -1
- package/dist/components/table/index.js +253 -133
- package/dist/components/table/index.min.js +2 -2
- package/dist/components/tabs/index.js +10 -4
- package/dist/components/tabs/index.min.js +2 -2
- package/dist/components/tag/index.js +1 -1
- package/dist/components/tag/index.min.js +1 -1
- package/dist/components/taginput/index.js +24 -2
- package/dist/components/taginput/index.min.js +2 -2
- package/dist/components/timepicker/index.js +41 -22
- package/dist/components/timepicker/index.min.js +2 -2
- package/dist/components/toast/index.js +2 -9
- package/dist/components/toast/index.min.js +2 -2
- package/dist/components/tooltip/index.js +2 -2
- package/dist/components/tooltip/index.min.js +2 -2
- package/dist/components/upload/index.js +20 -6
- package/dist/components/upload/index.min.js +2 -2
- package/dist/esm/autocomplete.js +6 -6
- package/dist/esm/button.js +4 -4
- package/dist/esm/carousel.js +4 -4
- package/dist/esm/{chunk-18e8b067.js → chunk-1a4fde6d.js} +102 -17
- package/dist/esm/{chunk-3773c62d.js → chunk-22cf6667.js} +2 -2
- package/dist/esm/{chunk-ece062a7.js → chunk-262b3f82.js} +1 -1
- package/dist/esm/chunk-455cdeae.js +317 -0
- package/dist/esm/{chunk-d7f92d97.js → chunk-5435bd9a.js} +5 -4
- package/dist/esm/{chunk-e7c9b2cb.js → chunk-58cdbf2b.js} +2 -2
- package/dist/esm/{chunk-29ca0df8.js → chunk-60a03517.js} +1 -1
- package/dist/esm/{chunk-21fc0948.js → chunk-66cef090.js} +7 -7
- package/dist/esm/{chunk-71a547bc.js → chunk-690d5be4.js} +1 -1
- package/dist/esm/{chunk-83eb0d37.js → chunk-6adc5c5d.js} +3 -3
- package/dist/esm/{chunk-c9c58d0c.js → chunk-6d0f2352.js} +0 -0
- package/dist/esm/{chunk-8d0f95b8.js → chunk-6d96579e.js} +4 -4
- package/dist/esm/{chunk-22e9f916.js → chunk-6fb4a069.js} +14 -11
- package/dist/esm/{chunk-75a5af93.js → chunk-84c6dfd6.js} +0 -0
- package/dist/esm/{chunk-ae8ab23a.js → chunk-a628d44d.js} +3 -3
- package/dist/esm/{chunk-b0c0c6b0.js → chunk-c9c18b2f.js} +0 -0
- package/dist/esm/{chunk-9f7f7441.js → chunk-d35985c7.js} +0 -0
- package/dist/esm/{chunk-799e084d.js → chunk-d9232770.js} +1 -8
- package/dist/esm/{chunk-4b67a181.js → chunk-dbd43ef1.js} +15 -2
- package/dist/esm/{chunk-d92f0cd9.js → chunk-e044aa02.js} +8 -2
- package/dist/esm/{chunk-b07e3182.js → chunk-effa4d25.js} +21 -21
- package/dist/esm/{chunk-6019fd7a.js → chunk-f9eaeac4.js} +19 -3
- package/dist/esm/clockpicker.js +8 -8
- package/dist/esm/colorpicker.js +1748 -0
- package/dist/esm/config.js +1 -1
- package/dist/esm/datepicker.js +10 -10
- package/dist/esm/datetimepicker.js +29 -13
- package/dist/esm/dialog.js +4 -4
- package/dist/esm/dropdown.js +4 -4
- package/dist/esm/field.js +3 -3
- package/dist/esm/helpers.js +20 -2
- package/dist/esm/icon.js +3 -3
- package/dist/esm/image.js +3 -3
- package/dist/esm/index.js +94 -91
- package/dist/esm/input.js +5 -5
- package/dist/esm/loading.js +3 -3
- package/dist/esm/menu.js +2 -2
- package/dist/esm/message.js +3 -8
- package/dist/esm/modal.js +3 -3
- package/dist/esm/navbar.js +4 -1
- package/dist/esm/notification.js +5 -5
- package/dist/esm/numberinput.js +30 -21
- package/dist/esm/pagination.js +4 -4
- package/dist/esm/progress.js +3 -3
- package/dist/esm/rate.js +2 -2
- package/dist/esm/select.js +5 -5
- package/dist/esm/sidebar.js +1 -1
- package/dist/esm/slider.js +2 -2
- package/dist/esm/snackbar.js +4 -3
- package/dist/esm/steps.js +5 -5
- package/dist/esm/table.js +155 -144
- package/dist/esm/tabs.js +7 -7
- package/dist/esm/taginput.js +5 -5
- package/dist/esm/timepicker.js +11 -11
- package/dist/esm/toast.js +2 -2
- package/dist/esm/tooltip.js +3 -3
- package/dist/esm/upload.js +21 -7
- package/dist/vetur/attributes.json +96 -0
- package/dist/vetur/tags.json +30 -1
- package/package.json +1 -1
- package/src/components/autocomplete/Autocomplete.vue +10 -0
- package/src/components/breadcrumb/__snapshots__/BreadcrumbItem.spec.js.snap +1 -5
- package/src/components/carousel/__snapshots__/CarouselList.spec.js.snap +48 -48
- package/src/components/colorpicker/Colorpicker.spec.js +10 -0
- package/src/components/colorpicker/Colorpicker.vue +354 -0
- package/src/components/colorpicker/ColorpickerAlphaSlider.spec.js +14 -0
- package/src/components/colorpicker/ColorpickerAlphaSlider.vue +194 -0
- package/src/components/colorpicker/ColorpickerHSLRepresentationSquare.spec.js +22 -0
- package/src/components/colorpicker/ColorpickerHSLRepresentationSquare.vue +366 -0
- package/src/components/colorpicker/ColorpickerHSLRepresentationTriangle.spec.js +22 -0
- package/src/components/colorpicker/ColorpickerHSLRepresentationTriangle.vue +442 -0
- package/src/components/colorpicker/__snapshots__/ColorPickerHSLRepresentationSquare.spec.js.snap +12 -0
- package/src/components/colorpicker/__snapshots__/Colorpicker.spec.js.snap +32 -0
- package/src/components/colorpicker/__snapshots__/ColorpickerAlphaSlider.spec.js.snap +11 -0
- package/src/components/colorpicker/__snapshots__/ColorpickerHSLRepresentationTriangle.spec.js.snap +36 -0
- package/src/components/colorpicker/index.js +17 -0
- package/src/components/datepicker/DatepickerTableRow.spec.js +26 -0
- package/src/components/datepicker/DatepickerTableRow.vue +4 -5
- package/src/components/datetimepicker/Datetimepicker.vue +17 -1
- package/src/components/dropdown/Dropdown.vue +13 -0
- package/src/components/field/Field.vue +271 -271
- package/src/components/index.js +2 -0
- package/src/components/message/Message.vue +0 -5
- package/src/components/navbar/NavbarDropdown.vue +4 -0
- package/src/components/notification/Notification.vue +1 -1
- package/src/components/numberinput/Numberinput.spec.js +62 -0
- package/src/components/numberinput/Numberinput.vue +22 -15
- package/src/components/pagination/Pagination.vue +141 -51
- package/src/components/progress/Progress.vue +1 -1
- package/src/components/snackbar/index.js +2 -1
- package/src/components/table/Table.spec.js +17 -3
- package/src/components/table/Table.vue +1436 -1409
- package/src/components/table/TablePagination.vue +10 -2
- package/src/components/tabs/Tabs.vue +2 -0
- package/src/components/timepicker/__snapshots__/Timepicker.spec.js.snap +18 -47
- package/src/components/tooltip/Tooltip.vue +2 -2
- package/src/components/upload/Upload.vue +19 -7
- package/src/scss/buefy.scss +1 -0
- package/src/scss/components/_colorpicker.scss +283 -0
- package/src/scss/components/_pagination.scss +38 -0
- package/src/utils/MessageMixin.js +2 -1
- package/src/utils/NoticeMixin.js +1 -5
- package/src/utils/color.js +441 -0
- package/src/utils/color.spec.js +52 -0
- package/src/utils/helpers.js +16 -0
- package/src/utils/icons.js +7 -1
- package/types/components.d.ts +7 -2
- package/types/helpers.d.ts +2 -1
- package/dist/cjs/chunk-92621ff7.js +0 -141
- package/dist/esm/chunk-2452e3d3.js +0 -134
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="colorpicker control"
|
|
4
|
+
:class="[size, {'is-expanded': expanded}]"
|
|
5
|
+
>
|
|
6
|
+
<b-dropdown
|
|
7
|
+
v-if="!isMobile || inline"
|
|
8
|
+
ref="dropdown"
|
|
9
|
+
:position="position"
|
|
10
|
+
:expanded="expanded"
|
|
11
|
+
:disabled="disabled"
|
|
12
|
+
:inline="inline"
|
|
13
|
+
:mobile-modal="mobileModal"
|
|
14
|
+
:trap-focus="trapFocus"
|
|
15
|
+
:aria-role="ariaRole"
|
|
16
|
+
:aria-modal="!inline"
|
|
17
|
+
:append-to-body="appendToBody"
|
|
18
|
+
append-to-body-copy-parent
|
|
19
|
+
@active-change="onActiveChange"
|
|
20
|
+
>
|
|
21
|
+
<template #trigger v-if="!inline">
|
|
22
|
+
<slot name="trigger">
|
|
23
|
+
<b-button
|
|
24
|
+
:style="triggerStyle"
|
|
25
|
+
:expanded="expanded"
|
|
26
|
+
:disabled="disabled"
|
|
27
|
+
>
|
|
28
|
+
<span class="color-name">{{ colorFormatter(colorSelected) }}</span>
|
|
29
|
+
</b-button>
|
|
30
|
+
</slot>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<b-dropdown-item
|
|
34
|
+
:disabled="disabled"
|
|
35
|
+
:focusable="focusable"
|
|
36
|
+
custom
|
|
37
|
+
:class="{'dropdown-horizonal-colorpicker': horizontalColorPicker}"
|
|
38
|
+
>
|
|
39
|
+
<div>
|
|
40
|
+
<header class="colorpicker-header">
|
|
41
|
+
<template v-if="$slots.header !== undefined && $slots.header.length">
|
|
42
|
+
<slot name="header" />
|
|
43
|
+
</template>
|
|
44
|
+
</header>
|
|
45
|
+
<div class="colorpicker-content">
|
|
46
|
+
<b-colorpicker-h-s-l-representation-square
|
|
47
|
+
v-if="representation === 'square'"
|
|
48
|
+
:value="colorSelected"
|
|
49
|
+
@input="updateColor"
|
|
50
|
+
/>
|
|
51
|
+
<b-colorpicker-h-s-l-representation-triangle
|
|
52
|
+
v-else
|
|
53
|
+
:value="colorSelected"
|
|
54
|
+
@input="updateColor"
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
<footer class="colorpicker-footer">
|
|
59
|
+
<b-colorpicker-alpha-slider
|
|
60
|
+
v-if="alpha"
|
|
61
|
+
v-model="colorSelected.alpha"
|
|
62
|
+
:color="colorSelected"
|
|
63
|
+
/>
|
|
64
|
+
<slot name="footer" :color="colorSelected">
|
|
65
|
+
<b-field class="colorpicker-fields" grouped>
|
|
66
|
+
<b-field horizontal label="R">
|
|
67
|
+
<b-input
|
|
68
|
+
type="number"
|
|
69
|
+
v-model.number="colorSelected.red"
|
|
70
|
+
size="is-small"
|
|
71
|
+
aria-label="Red"
|
|
72
|
+
/>
|
|
73
|
+
</b-field>
|
|
74
|
+
<b-field horizontal label="G">
|
|
75
|
+
<b-input
|
|
76
|
+
type="number"
|
|
77
|
+
v-model.number="colorSelected.green"
|
|
78
|
+
size="is-small"
|
|
79
|
+
aria-label="Green"
|
|
80
|
+
/>
|
|
81
|
+
</b-field>
|
|
82
|
+
<b-field horizontal label="B">
|
|
83
|
+
<b-input
|
|
84
|
+
type="number"
|
|
85
|
+
v-model.number="colorSelected.blue"
|
|
86
|
+
size="is-small"
|
|
87
|
+
aria-label="Blue"
|
|
88
|
+
/>
|
|
89
|
+
</b-field>
|
|
90
|
+
</b-field>
|
|
91
|
+
</slot>
|
|
92
|
+
</footer>
|
|
93
|
+
</b-dropdown-item>
|
|
94
|
+
</b-dropdown>
|
|
95
|
+
</div>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<script>
|
|
99
|
+
import FormElementMixin from '../../utils/FormElementMixin'
|
|
100
|
+
import { isMobile } from '../../utils/helpers'
|
|
101
|
+
import config from '../../utils/config'
|
|
102
|
+
import Color from '../../utils/color'
|
|
103
|
+
|
|
104
|
+
import Dropdown from '../dropdown/Dropdown'
|
|
105
|
+
import DropdownItem from '../dropdown/DropdownItem'
|
|
106
|
+
import Input from '../input/Input'
|
|
107
|
+
import Field from '../field/Field'
|
|
108
|
+
import Select from '../select/Select'
|
|
109
|
+
import Icon from '../icon/Icon'
|
|
110
|
+
|
|
111
|
+
import ColorpickerHSLRepresentationTriangle from './ColorpickerHSLRepresentationTriangle'
|
|
112
|
+
import ColorpickerHSLRepresentationSquare from './ColorpickerHSLRepresentationSquare'
|
|
113
|
+
import ColorpickerAlphaSlider from './ColorpickerAlphaSlider'
|
|
114
|
+
|
|
115
|
+
const defaultColorFormatter = (color, vm) => {
|
|
116
|
+
if (color.alpha < 1) {
|
|
117
|
+
return color.toString('hexa')
|
|
118
|
+
} else {
|
|
119
|
+
return color.toString('hex')
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const defaultColorParser = (color, vm) => {
|
|
124
|
+
return Color.parse(color)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export default {
|
|
128
|
+
name: 'BColorpicker',
|
|
129
|
+
components: {
|
|
130
|
+
[ColorpickerHSLRepresentationTriangle.name]: ColorpickerHSLRepresentationTriangle,
|
|
131
|
+
[ColorpickerHSLRepresentationSquare.name]: ColorpickerHSLRepresentationSquare,
|
|
132
|
+
[ColorpickerAlphaSlider.name]: ColorpickerAlphaSlider,
|
|
133
|
+
[Input.name]: Input,
|
|
134
|
+
[Field.name]: Field,
|
|
135
|
+
[Select.name]: Select,
|
|
136
|
+
[Icon.name]: Icon,
|
|
137
|
+
[Dropdown.name]: Dropdown,
|
|
138
|
+
[DropdownItem.name]: DropdownItem
|
|
139
|
+
},
|
|
140
|
+
mixins: [FormElementMixin],
|
|
141
|
+
inheritAttrs: false,
|
|
142
|
+
provide() {
|
|
143
|
+
return {
|
|
144
|
+
$colorpicker: this
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
props: {
|
|
148
|
+
value: {
|
|
149
|
+
type: [String, Object],
|
|
150
|
+
validator(value) {
|
|
151
|
+
return typeof value === 'string' ||
|
|
152
|
+
(
|
|
153
|
+
typeof value === 'object' &&
|
|
154
|
+
typeof value.red === 'number' &&
|
|
155
|
+
typeof value.green === 'number' &&
|
|
156
|
+
typeof value.blue === 'number'
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
representation: {
|
|
161
|
+
type: String,
|
|
162
|
+
default: 'triangle',
|
|
163
|
+
value(value) {
|
|
164
|
+
return ['triangle', 'square'].some((r) => r === value)
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
inline: Boolean,
|
|
168
|
+
disabled: Boolean,
|
|
169
|
+
horizontalColorPicker: {
|
|
170
|
+
type: Boolean,
|
|
171
|
+
default: false
|
|
172
|
+
},
|
|
173
|
+
colorFormatter: {
|
|
174
|
+
type: Function,
|
|
175
|
+
default: (color, vm) => {
|
|
176
|
+
if (typeof config.defaultColorFormatter === 'function') {
|
|
177
|
+
return config.defaultColorFormatter(color)
|
|
178
|
+
} else {
|
|
179
|
+
return defaultColorFormatter(color, vm)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
colorParser: {
|
|
184
|
+
type: Function,
|
|
185
|
+
default: (color, vm) => {
|
|
186
|
+
if (typeof config.defaultColorParser === 'function') {
|
|
187
|
+
return config.defaultColorParser(color)
|
|
188
|
+
} else {
|
|
189
|
+
return defaultColorParser(color, vm)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
alpha: {
|
|
194
|
+
type: Boolean,
|
|
195
|
+
default: false
|
|
196
|
+
},
|
|
197
|
+
expanded: Boolean,
|
|
198
|
+
position: String,
|
|
199
|
+
mobileModal: {
|
|
200
|
+
type: Boolean,
|
|
201
|
+
default: () => config.defaultDatepickerMobileModal
|
|
202
|
+
},
|
|
203
|
+
focusable: {
|
|
204
|
+
type: Boolean,
|
|
205
|
+
default: true
|
|
206
|
+
},
|
|
207
|
+
trapFocus: {
|
|
208
|
+
type: Boolean,
|
|
209
|
+
default: () => config.defaultTrapFocus
|
|
210
|
+
},
|
|
211
|
+
appendToBody: Boolean
|
|
212
|
+
},
|
|
213
|
+
data() {
|
|
214
|
+
const color = this.colorParser(this.value)
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
colorSelected: color
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
computed: {
|
|
221
|
+
background() {
|
|
222
|
+
if (this.alpha) {
|
|
223
|
+
return `linear-gradient(
|
|
224
|
+
45deg,
|
|
225
|
+
${this.colorSelected.toString('hex')} 50%,
|
|
226
|
+
${this.colorSelected.toString('hexa')} 50%
|
|
227
|
+
)`
|
|
228
|
+
} else {
|
|
229
|
+
const hex = this.colorSelected.toString('hex')
|
|
230
|
+
return `linear-gradient(
|
|
231
|
+
45deg,
|
|
232
|
+
${hex} 50%,
|
|
233
|
+
${hex} 50%
|
|
234
|
+
)`
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
triggerStyle() {
|
|
238
|
+
const { red, green, blue } = this.colorSelected
|
|
239
|
+
const light = (red * 0.299 + green * 0.587 + blue * 0.114) > 186
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
backgroundColor: '#ffffff',
|
|
243
|
+
backgroundImage: `
|
|
244
|
+
${this.background},
|
|
245
|
+
linear-gradient(45deg, #c7c7c7 25%, transparent 25%, transparent 75%, #c7c7c7 75%, #c7c7c7),
|
|
246
|
+
linear-gradient(45deg, #c7c7c7 25%, transparent 25%, transparent 75%, #c7c7c7 75%, #c7c7c7)
|
|
247
|
+
`,
|
|
248
|
+
backgroundSize: '100% 100%, 16px 16px, 16px 16px',
|
|
249
|
+
backgroundPosition: '0 0, 8px 8px, 0 0',
|
|
250
|
+
color: light ? '#000000' : '#FFFFFF',
|
|
251
|
+
textShadow: `0 0 2px ${light ? '#FFFFFFAA' : '#000000AA'}`
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
isMobile() {
|
|
256
|
+
return this.mobileNative && isMobile.any()
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
ariaRole() {
|
|
260
|
+
if (!this.inline) {
|
|
261
|
+
return 'dialog'
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
watch: {
|
|
266
|
+
value(value) {
|
|
267
|
+
this.colorSelected = new Color(value)
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
methods: {
|
|
271
|
+
updateColor(value) {
|
|
272
|
+
value.alpha = this.colorSelected.alpha
|
|
273
|
+
this.colorSelected = value
|
|
274
|
+
this.$emit('change', value)
|
|
275
|
+
},
|
|
276
|
+
/*
|
|
277
|
+
* Format color into string
|
|
278
|
+
*/
|
|
279
|
+
formatValue(value) {
|
|
280
|
+
return value ? this.colorFormatter(value, this) : null
|
|
281
|
+
},
|
|
282
|
+
|
|
283
|
+
/*
|
|
284
|
+
* Toggle datepicker
|
|
285
|
+
*/
|
|
286
|
+
togglePicker(active) {
|
|
287
|
+
if (this.$refs.dropdown) {
|
|
288
|
+
const isActive = typeof active === 'boolean'
|
|
289
|
+
? active
|
|
290
|
+
: !this.$refs.dropdown.isActive
|
|
291
|
+
if (isActive) {
|
|
292
|
+
this.$refs.dropdown.isActive = isActive
|
|
293
|
+
} else if (this.closeOnClick) {
|
|
294
|
+
this.$refs.dropdown.isActive = isActive
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
/*
|
|
300
|
+
* Call default onFocus method and show datepicker
|
|
301
|
+
*/
|
|
302
|
+
handleOnFocus(event) {
|
|
303
|
+
this.onFocus(event)
|
|
304
|
+
if (this.openOnFocus) {
|
|
305
|
+
this.togglePicker(true)
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
|
|
309
|
+
/*
|
|
310
|
+
* Toggle dropdown
|
|
311
|
+
*/
|
|
312
|
+
toggle() {
|
|
313
|
+
if (this.mobileNative && this.isMobile) {
|
|
314
|
+
const input = this.$refs.input.$refs.input
|
|
315
|
+
input.focus()
|
|
316
|
+
input.click()
|
|
317
|
+
return
|
|
318
|
+
}
|
|
319
|
+
this.$refs.dropdown.toggle()
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
/*
|
|
323
|
+
* Avoid dropdown toggle when is already visible
|
|
324
|
+
*/
|
|
325
|
+
onInputClick(event) {
|
|
326
|
+
if (this.$refs.dropdown.isActive) {
|
|
327
|
+
event.stopPropagation()
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Keypress event that is bound to the document.
|
|
333
|
+
*/
|
|
334
|
+
keyPress({ key }) {
|
|
335
|
+
if (this.$refs.dropdown && this.$refs.dropdown.isActive && (key === 'Escape' || key === 'Esc')) {
|
|
336
|
+
this.togglePicker(false)
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Emit 'blur' event on dropdown is not active (closed)
|
|
342
|
+
*/
|
|
343
|
+
onActiveChange(value) {
|
|
344
|
+
if (!value) {
|
|
345
|
+
this.onBlur()
|
|
346
|
+
}
|
|
347
|
+
/*
|
|
348
|
+
* Emit 'active-change' when on dropdown active state change
|
|
349
|
+
*/
|
|
350
|
+
this.$emit('active-change', value)
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils'
|
|
2
|
+
import BColorpickerAlphaSlider from '@components/colorpicker/ColorpickerAlphaSlider'
|
|
3
|
+
|
|
4
|
+
describe('BColorpickerAlphaSlider', () => {
|
|
5
|
+
it('render correctly', () => {
|
|
6
|
+
const wrapper = shallowMount(BColorpickerAlphaSlider, {
|
|
7
|
+
propsData: {
|
|
8
|
+
value: 100
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
expect(wrapper.html()).toMatchSnapshot()
|
|
13
|
+
})
|
|
14
|
+
})
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="b-colorpicker-alpha-slider"
|
|
4
|
+
:style="style"
|
|
5
|
+
@click="clickAlpha"
|
|
6
|
+
@keydown="alphaKeyPress"
|
|
7
|
+
@mousedown="startMouseCapture"
|
|
8
|
+
@touchstart.prevent="startMouseCapture"
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
ref="alphaCursor"
|
|
12
|
+
role="slider"
|
|
13
|
+
class="alpha-range-thumb"
|
|
14
|
+
tabindex="0"
|
|
15
|
+
aria-label="Tranparency"
|
|
16
|
+
aria-valuemin="0"
|
|
17
|
+
:aria-valuenow="percent"
|
|
18
|
+
aria-valuemax="100"
|
|
19
|
+
:style="{ left: `${percent}%` }"
|
|
20
|
+
>
|
|
21
|
+
<b-tooltip :label="`${percent}%`" :always="captureMouse">
|
|
22
|
+
|
|
23
|
+
</b-tooltip>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
import Color from '../../utils/color'
|
|
30
|
+
import Tooltip from '../tooltip/Tooltip'
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
name: 'BColorpickerAlphaSlider',
|
|
34
|
+
components: {
|
|
35
|
+
[Tooltip.name]: Tooltip
|
|
36
|
+
},
|
|
37
|
+
props: {
|
|
38
|
+
value: {
|
|
39
|
+
type: Number,
|
|
40
|
+
validator: (value) => value >= 0 && value < 256
|
|
41
|
+
},
|
|
42
|
+
color: [String, Object]
|
|
43
|
+
},
|
|
44
|
+
data() {
|
|
45
|
+
const color = Color.parse(this.color)
|
|
46
|
+
|
|
47
|
+
color.alpha = 0
|
|
48
|
+
return {
|
|
49
|
+
startColor: color.toString('hex'),
|
|
50
|
+
endColor: color.toString('hexa'),
|
|
51
|
+
percent: Math.round((1 - this.value / 255) * 100),
|
|
52
|
+
captureMouse: false,
|
|
53
|
+
clientOffset: {
|
|
54
|
+
cx: -1,
|
|
55
|
+
cy: -1,
|
|
56
|
+
width: 0,
|
|
57
|
+
height: 0
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
computed: {
|
|
62
|
+
style() {
|
|
63
|
+
return {
|
|
64
|
+
backgroundImage:
|
|
65
|
+
`linear-gradient(90deg, ${this.startColor} 0%, ${this.endColor} 100%),
|
|
66
|
+
linear-gradient(45deg, #c7c7c7 25%, transparent 25%, transparent 75%, #c7c7c7 75%, #c7c7c7),
|
|
67
|
+
linear-gradient(45deg, #c7c7c7 25%, transparent 25%, transparent 75%, #c7c7c7 75%, #c7c7c7)`,
|
|
68
|
+
backgroundSize: '100% 100%, 1em 1em, 1em 1em',
|
|
69
|
+
backgroundPosition: '0 0, .5em .5em, 0 0'
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
watch: {
|
|
74
|
+
value(newValue, oldValue) {
|
|
75
|
+
if (newValue !== oldValue) {
|
|
76
|
+
this.percent = Math.round((1 - newValue / 255) * 100)
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
color(newColor) {
|
|
80
|
+
const color = Color.parse(newColor)
|
|
81
|
+
|
|
82
|
+
color.alpha = 0
|
|
83
|
+
this.startColor = color.toString('hex')
|
|
84
|
+
this.endColor = color.toString('hexa')
|
|
85
|
+
},
|
|
86
|
+
captureMouse(newValue, oldValue) {
|
|
87
|
+
if (oldValue === false && newValue !== false) {
|
|
88
|
+
const rect = this.$el.getBoundingClientRect()
|
|
89
|
+
// Caching offset
|
|
90
|
+
this.clientOffset.cx = rect.x + rect.width / 2
|
|
91
|
+
this.clientOffset.cy = rect.y + rect.height / 2
|
|
92
|
+
this.clientOffset.width = rect.width
|
|
93
|
+
this.clientOffset.height = rect.height
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
methods: {
|
|
98
|
+
increaseAlpha(value = 1) {
|
|
99
|
+
this.percent = Math.max(0, Math.min(100, this.percent + value))
|
|
100
|
+
},
|
|
101
|
+
decreaseAlpha(value = 0.01) {
|
|
102
|
+
this.increaseAlpha(-value)
|
|
103
|
+
},
|
|
104
|
+
alphaKeyPress(event) {
|
|
105
|
+
let handled = false
|
|
106
|
+
switch (event.key) {
|
|
107
|
+
case 'ArrowRight':
|
|
108
|
+
case 'ArrowUp':
|
|
109
|
+
this.increaseAlpha()
|
|
110
|
+
handled = true
|
|
111
|
+
break
|
|
112
|
+
case 'ArrowLeft':
|
|
113
|
+
case 'ArrowDown':
|
|
114
|
+
this.decreaseAlpha()
|
|
115
|
+
handled = true
|
|
116
|
+
break
|
|
117
|
+
case 'Home':
|
|
118
|
+
this.decreaseAlpha(this.percent)
|
|
119
|
+
handled = true
|
|
120
|
+
break
|
|
121
|
+
case 'End':
|
|
122
|
+
this.increaseAlpha(100 - this.percent)
|
|
123
|
+
handled = true
|
|
124
|
+
break
|
|
125
|
+
case 'PageUp':
|
|
126
|
+
this.increaseAlpha(10 - (this.percent % 10))
|
|
127
|
+
handled = true
|
|
128
|
+
break
|
|
129
|
+
case 'PageDown':
|
|
130
|
+
this.decreaseAlpha(this.percent % 10)
|
|
131
|
+
handled = true
|
|
132
|
+
break
|
|
133
|
+
}
|
|
134
|
+
if (handled) {
|
|
135
|
+
event.preventDefault()
|
|
136
|
+
event.stopPropagation()
|
|
137
|
+
this.emitAlpha()
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
clickAlpha(event) {
|
|
141
|
+
this.startMouseCapture(event)
|
|
142
|
+
this.trackMouse(event)
|
|
143
|
+
this.stopMouseCapture(event)
|
|
144
|
+
this.$refs.alphaCursor.focus()
|
|
145
|
+
},
|
|
146
|
+
startMouseCapture(event) {
|
|
147
|
+
event.stopPropagation()
|
|
148
|
+
|
|
149
|
+
this.captureMouse = true
|
|
150
|
+
},
|
|
151
|
+
trackMouse(event) {
|
|
152
|
+
if (this.captureMouse === false) {
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
event.preventDefault()
|
|
156
|
+
event.stopPropagation()
|
|
157
|
+
|
|
158
|
+
let [mouseX] = [0, 0]
|
|
159
|
+
if (typeof event.touches !== 'undefined' && event.touches.length) {
|
|
160
|
+
[mouseX] = [event.touches[0].clientX]
|
|
161
|
+
} else {
|
|
162
|
+
[mouseX] = [event.clientX]
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const ratio = 0.5 + (this.clientOffset.cx - mouseX) / this.clientOffset.width
|
|
166
|
+
this.percent = Math.round(100 - Math.max(0, Math.min(1, ratio)) * 100)
|
|
167
|
+
this.emitAlpha()
|
|
168
|
+
},
|
|
169
|
+
stopMouseCapture(event) {
|
|
170
|
+
if (this.captureMouse !== false) {
|
|
171
|
+
event.preventDefault()
|
|
172
|
+
event.stopPropagation()
|
|
173
|
+
this.$refs.alphaCursor.focus()
|
|
174
|
+
}
|
|
175
|
+
this.captureMouse = false
|
|
176
|
+
},
|
|
177
|
+
emitAlpha() {
|
|
178
|
+
this.$emit('input', (1 - this.percent / 100) * 255)
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
mounted() {
|
|
182
|
+
window.addEventListener('mousemove', this.trackMouse)
|
|
183
|
+
window.addEventListener('touchmove', this.trackMouse, { passive: false })
|
|
184
|
+
window.addEventListener('mouseup', this.stopMouseCapture)
|
|
185
|
+
window.addEventListener('touchend', this.stopMouseCapture)
|
|
186
|
+
},
|
|
187
|
+
beforeDestroy() {
|
|
188
|
+
window.removeEventListener('mousemove', this.trackMouse)
|
|
189
|
+
window.removeEventListener('touchmove', this.trackMouse)
|
|
190
|
+
window.removeEventListener('mouseup', this.stopMouseCapture)
|
|
191
|
+
window.removeEventListener('touchend', this.stopMouseCapture)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils'
|
|
2
|
+
import Color from '@utils/color'
|
|
3
|
+
import BColorpickerHSLRepresentationSquare from '@components/colorpicker/ColorpickerHSLRepresentationSquare'
|
|
4
|
+
|
|
5
|
+
let defaultProps
|
|
6
|
+
|
|
7
|
+
describe('BColorpickerHSLRepresentationSquare', () => {
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
defaultProps = () => ({
|
|
10
|
+
value: Color.parse('#123456')
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
it('render correctly', () => {
|
|
14
|
+
const wrapper = shallowMount(BColorpickerHSLRepresentationSquare, {
|
|
15
|
+
propsData: {
|
|
16
|
+
...defaultProps()
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
expect(wrapper.html()).toMatchSnapshot()
|
|
21
|
+
})
|
|
22
|
+
})
|