@dimailn/vuetify 2.7.2-alpha24 → 2.7.2-alpha26
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/dist/vuetify.js +583 -388
- package/dist/vuetify.js.map +1 -1
- package/dist/vuetify.min.css +1 -1
- package/dist/vuetify.min.js +2 -2
- package/es5/components/VAppBar/VAppBarNavIcon.js +5 -1
- package/es5/components/VAppBar/VAppBarNavIcon.js.map +1 -1
- package/es5/components/VBanner/VBanner.js +15 -6
- package/es5/components/VBanner/VBanner.js.map +1 -1
- package/es5/components/VBreadcrumbs/VBreadcrumbs.js +18 -6
- package/es5/components/VBreadcrumbs/VBreadcrumbs.js.map +1 -1
- package/es5/components/VBtn/VBtn.js +19 -15
- package/es5/components/VBtn/VBtn.js.map +1 -1
- package/es5/components/VCarousel/VCarousel.js +10 -4
- package/es5/components/VCarousel/VCarousel.js.map +1 -1
- package/es5/components/VCarousel/VCarouselItem.js +7 -3
- package/es5/components/VCarousel/VCarouselItem.js.map +1 -1
- package/es5/components/VCheckbox/VCheckbox.js +5 -1
- package/es5/components/VCheckbox/VCheckbox.js.map +1 -1
- package/es5/components/VColorPicker/VColorPicker.js +18 -31
- package/es5/components/VColorPicker/VColorPicker.js.map +1 -1
- package/es5/components/VColorPicker/VColorPickerCanvas.js +45 -46
- package/es5/components/VColorPicker/VColorPickerCanvas.js.map +1 -1
- package/es5/components/VColorPicker/VColorPickerEdit.js +27 -26
- package/es5/components/VColorPicker/VColorPickerEdit.js.map +1 -1
- package/es5/components/VColorPicker/VColorPickerPreview.js +41 -30
- package/es5/components/VColorPicker/VColorPickerPreview.js.map +1 -1
- package/es5/components/VColorPicker/VColorPickerSwatches.js +13 -10
- package/es5/components/VColorPicker/VColorPickerSwatches.js.map +1 -1
- package/es5/components/VDataIterator/VDataFooter.js +5 -1
- package/es5/components/VDataIterator/VDataFooter.js.map +1 -1
- package/es5/components/VDataTable/VDataTable.js +28 -18
- package/es5/components/VDataTable/VDataTable.js.map +1 -1
- package/es5/components/VDataTable/VDataTableHeader.js +2 -6
- package/es5/components/VDataTable/VDataTableHeader.js.map +1 -1
- package/es5/components/VDataTable/VEditDialog.js +6 -2
- package/es5/components/VDataTable/VEditDialog.js.map +1 -1
- package/es5/components/VDataTable/mixins/header.js +5 -1
- package/es5/components/VDataTable/mixins/header.js.map +1 -1
- package/es5/components/VDatePicker/VDatePickerHeader.js +8 -2
- package/es5/components/VDatePicker/VDatePickerHeader.js.map +1 -1
- package/es5/components/VDatePicker/VDatePickerTitle.js +13 -5
- package/es5/components/VDatePicker/VDatePickerTitle.js.map +1 -1
- package/es5/components/VDatePicker/mixins/date-picker-table.js +5 -3
- package/es5/components/VDatePicker/mixins/date-picker-table.js.map +1 -1
- package/es5/components/VDialog/VDialog.js +16 -12
- package/es5/components/VDialog/VDialog.js.map +1 -1
- package/es5/components/VExpansionPanel/VExpansionPanelContent.js +11 -9
- package/es5/components/VExpansionPanel/VExpansionPanelContent.js.map +1 -1
- package/es5/components/VExpansionPanel/VExpansionPanelHeader.js +15 -9
- package/es5/components/VExpansionPanel/VExpansionPanelHeader.js.map +1 -1
- package/es5/components/VImg/VImg.js +6 -2
- package/es5/components/VImg/VImg.js.map +1 -1
- package/es5/components/VInput/VInput.js +28 -8
- package/es5/components/VInput/VInput.js.map +1 -1
- package/es5/components/VList/VListGroup.js +27 -9
- package/es5/components/VList/VListGroup.js.map +1 -1
- package/es5/components/VList/VListItem.js +5 -1
- package/es5/components/VList/VListItem.js.map +1 -1
- package/es5/components/VMessages/VMessages.js +5 -1
- package/es5/components/VMessages/VMessages.js.map +1 -1
- package/es5/components/VOverflowBtn/VOverflowBtn.js +3 -1
- package/es5/components/VOverflowBtn/VOverflowBtn.js.map +1 -1
- package/es5/components/VPagination/VPagination.js +3 -1
- package/es5/components/VPagination/VPagination.js.map +1 -1
- package/es5/components/VPicker/VPicker.js +5 -1
- package/es5/components/VPicker/VPicker.js.map +1 -1
- package/es5/components/VRadioGroup/VRadio.js +10 -2
- package/es5/components/VRadioGroup/VRadio.js.map +1 -1
- package/es5/components/VSelect/VSelect.js +6 -2
- package/es5/components/VSelect/VSelect.js.map +1 -1
- package/es5/components/VSelect/VSelectList.js +17 -9
- package/es5/components/VSelect/VSelectList.js.map +1 -1
- package/es5/components/VSlideGroup/VSlideGroup.js +26 -18
- package/es5/components/VSlideGroup/VSlideGroup.js.map +1 -1
- package/es5/components/VSlider/VSlider.js +36 -27
- package/es5/components/VSlider/VSlider.js.map +1 -1
- package/es5/components/VStepper/VStepperContent.js +3 -1
- package/es5/components/VStepper/VStepperContent.js.map +1 -1
- package/es5/components/VSwitch/VSwitch.js +10 -6
- package/es5/components/VSwitch/VSwitch.js.map +1 -1
- package/es5/components/VTabs/VTabs.js +6 -2
- package/es5/components/VTabs/VTabs.js.map +1 -1
- package/es5/components/VTextField/VTextField.js +7 -3
- package/es5/components/VTextField/VTextField.js.map +1 -1
- package/es5/components/VTooltip/VTooltip.js +6 -8
- package/es5/components/VTooltip/VTooltip.js.map +1 -1
- package/es5/components/VTreeview/VTreeviewNode.js +11 -3
- package/es5/components/VTreeview/VTreeviewNode.js.map +1 -1
- package/es5/components/transitions/createTransition.js +8 -2
- package/es5/components/transitions/createTransition.js.map +1 -1
- package/es5/framework.js +1 -1
- package/es5/mixins/picker/index.js +13 -3
- package/es5/mixins/picker/index.js.map +1 -1
- package/lib/components/VAppBar/VAppBarNavIcon.js +1 -1
- package/lib/components/VAppBar/VAppBarNavIcon.js.map +1 -1
- package/lib/components/VBanner/VBanner.js +3 -3
- package/lib/components/VBanner/VBanner.js.map +1 -1
- package/lib/components/VBreadcrumbs/VBreadcrumbs.js +2 -2
- package/lib/components/VBreadcrumbs/VBreadcrumbs.js.map +1 -1
- package/lib/components/VBtn/VBtn.js +20 -19
- package/lib/components/VBtn/VBtn.js.map +1 -1
- package/lib/components/VCarousel/VCarousel.js +3 -3
- package/lib/components/VCarousel/VCarousel.js.map +1 -1
- package/lib/components/VCarousel/VCarouselItem.js +1 -1
- package/lib/components/VCarousel/VCarouselItem.js.map +1 -1
- package/lib/components/VCheckbox/VCheckbox.js +1 -1
- package/lib/components/VCheckbox/VCheckbox.js.map +1 -1
- package/lib/components/VColorPicker/VColorPicker.js +29 -37
- package/lib/components/VColorPicker/VColorPicker.js.map +1 -1
- package/lib/components/VColorPicker/VColorPickerCanvas.js +41 -43
- package/lib/components/VColorPicker/VColorPickerCanvas.js.map +1 -1
- package/lib/components/VColorPicker/VColorPickerEdit.js +25 -31
- package/lib/components/VColorPicker/VColorPickerEdit.js.map +1 -1
- package/lib/components/VColorPicker/VColorPickerPreview.js +45 -32
- package/lib/components/VColorPicker/VColorPickerPreview.js.map +1 -1
- package/lib/components/VColorPicker/VColorPickerSwatches.js +15 -9
- package/lib/components/VColorPicker/VColorPickerSwatches.js.map +1 -1
- package/lib/components/VDataIterator/VDataFooter.js +1 -1
- package/lib/components/VDataIterator/VDataFooter.js.map +1 -1
- package/lib/components/VDataTable/VDataTable.js +8 -9
- package/lib/components/VDataTable/VDataTable.js.map +1 -1
- package/lib/components/VDataTable/VDataTableHeader.js +3 -6
- package/lib/components/VDataTable/VDataTableHeader.js.map +1 -1
- package/lib/components/VDataTable/VEditDialog.js +2 -2
- package/lib/components/VDataTable/VEditDialog.js.map +1 -1
- package/lib/components/VDataTable/mixins/header.js +1 -1
- package/lib/components/VDataTable/mixins/header.js.map +1 -1
- package/lib/components/VDatePicker/VDatePickerHeader.js +2 -2
- package/lib/components/VDatePicker/VDatePickerHeader.js.map +1 -1
- package/lib/components/VDatePicker/VDatePickerTitle.js +2 -2
- package/lib/components/VDatePicker/VDatePickerTitle.js.map +1 -1
- package/lib/components/VDatePicker/mixins/date-picker-table.js +1 -1
- package/lib/components/VDatePicker/mixins/date-picker-table.js.map +1 -1
- package/lib/components/VDialog/VDialog.js +2 -2
- package/lib/components/VDialog/VDialog.js.map +1 -1
- package/lib/components/VExpansionPanel/VExpansionPanelContent.js +1 -1
- package/lib/components/VExpansionPanel/VExpansionPanelContent.js.map +1 -1
- package/lib/components/VExpansionPanel/VExpansionPanelHeader.js +2 -2
- package/lib/components/VExpansionPanel/VExpansionPanelHeader.js.map +1 -1
- package/lib/components/VImg/VImg.js +2 -2
- package/lib/components/VImg/VImg.js.map +1 -1
- package/lib/components/VInput/VInput.js +14 -6
- package/lib/components/VInput/VInput.js.map +1 -1
- package/lib/components/VList/VListGroup.js +5 -5
- package/lib/components/VList/VListGroup.js.map +1 -1
- package/lib/components/VList/VListItem.js +3 -1
- package/lib/components/VList/VListItem.js.map +1 -1
- package/lib/components/VMessages/VMessages.js +1 -1
- package/lib/components/VMessages/VMessages.js.map +1 -1
- package/lib/components/VOverflowBtn/VOverflowBtn.js +1 -1
- package/lib/components/VOverflowBtn/VOverflowBtn.js.map +1 -1
- package/lib/components/VPagination/VPagination.js +1 -1
- package/lib/components/VPagination/VPagination.js.map +1 -1
- package/lib/components/VPicker/VPicker.js +1 -1
- package/lib/components/VPicker/VPicker.js.map +1 -1
- package/lib/components/VRadioGroup/VRadio.js +2 -2
- package/lib/components/VRadioGroup/VRadio.js.map +1 -1
- package/lib/components/VSelect/VSelect.js +2 -2
- package/lib/components/VSelect/VSelect.js.map +1 -1
- package/lib/components/VSelect/VSelectList.js +2 -2
- package/lib/components/VSelect/VSelectList.js.map +1 -1
- package/lib/components/VSlideGroup/VSlideGroup.js +3 -3
- package/lib/components/VSlideGroup/VSlideGroup.js.map +1 -1
- package/lib/components/VSlider/VSlider.js +26 -21
- package/lib/components/VSlider/VSlider.js.map +1 -1
- package/lib/components/VStepper/VStepperContent.js +1 -1
- package/lib/components/VStepper/VStepperContent.js.map +1 -1
- package/lib/components/VSwitch/VSwitch.js +1 -1
- package/lib/components/VSwitch/VSwitch.js.map +1 -1
- package/lib/components/VTabs/VTabs.js +2 -2
- package/lib/components/VTabs/VTabs.js.map +1 -1
- package/lib/components/VTextField/VTextField.js +1 -1
- package/lib/components/VTextField/VTextField.js.map +1 -1
- package/lib/components/VTooltip/VTooltip.js +7 -10
- package/lib/components/VTooltip/VTooltip.js.map +1 -1
- package/lib/components/VTreeview/VTreeviewNode.js +3 -3
- package/lib/components/VTreeview/VTreeviewNode.js.map +1 -1
- package/lib/components/transitions/createTransition.js +2 -2
- package/lib/components/transitions/createTransition.js.map +1 -1
- package/lib/framework.js +1 -1
- package/lib/mixins/picker/index.js +5 -3
- package/lib/mixins/picker/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/VAppBar/VAppBarNavIcon.ts +1 -1
- package/src/components/VBanner/VBanner.ts +3 -3
- package/src/components/VBreadcrumbs/VBreadcrumbs.ts +2 -2
- package/src/components/VBtn/VBtn.ts +24 -16
- package/src/components/VBtn/__tests__/VBtn.spec.ts +257 -242
- package/src/components/VBtn/__tests__/__snapshots__/VBtn.spec.ts.snap +13 -73
- package/src/components/VCarousel/VCarousel.ts +3 -3
- package/src/components/VCarousel/VCarouselItem.ts +1 -1
- package/src/components/VCheckbox/VCheckbox.ts +1 -1
- package/src/components/VColorPicker/VColorPicker.ts +32 -35
- package/src/components/VColorPicker/VColorPickerCanvas.ts +44 -37
- package/src/components/VColorPicker/VColorPickerEdit.ts +37 -35
- package/src/components/VColorPicker/VColorPickerPreview.ts +48 -28
- package/src/components/VColorPicker/VColorPickerSwatches.ts +23 -12
- package/src/components/VColorPicker/__tests__/VColorPicker.spec.ts +47 -47
- package/src/components/VColorPicker/__tests__/VColorPickerCanvas.spec.ts +15 -13
- package/src/components/VColorPicker/__tests__/VColorPickerEdit.spec.ts +52 -50
- package/src/components/VColorPicker/__tests__/VColorPickerPreview.spec.ts +101 -30
- package/src/components/VColorPicker/__tests__/__snapshots__/VColorPicker.spec.ts.snap +200 -157
- package/src/components/VColorPicker/__tests__/__snapshots__/VColorPickerEdit.spec.ts.snap +28 -11
- package/src/components/VDataIterator/VDataFooter.ts +1 -1
- package/src/components/VDataTable/VDataTable.ts +8 -8
- package/src/components/VDataTable/VDataTableHeader.ts +2 -4
- package/src/components/VDataTable/VEditDialog.ts +2 -2
- package/src/components/VDataTable/mixins/header.ts +1 -1
- package/src/components/VDatePicker/VDatePickerHeader.ts +3 -3
- package/src/components/VDatePicker/VDatePickerTitle.ts +2 -2
- package/src/components/VDatePicker/mixins/date-picker-table.ts +1 -1
- package/src/components/VDialog/VDialog.ts +2 -2
- package/src/components/VExpansionPanel/VExpansionPanelContent.ts +1 -1
- package/src/components/VExpansionPanel/VExpansionPanelHeader.ts +2 -2
- package/src/components/VImg/VImg.ts +2 -2
- package/src/components/VInput/VInput.ts +10 -4
- package/src/components/VInput/__tests__/VInput.spec.ts +170 -234
- package/src/components/VInput/__tests__/__snapshots__/VInput.spec.ts.snap +50 -101
- package/src/components/VList/VListGroup.ts +5 -5
- package/src/components/VList/VListItem.ts +7 -4
- package/src/components/VMessages/VMessages.ts +1 -1
- package/src/components/VOverflowBtn/VOverflowBtn.ts +1 -1
- package/src/components/VPagination/VPagination.ts +1 -1
- package/src/components/VPicker/VPicker.ts +1 -1
- package/src/components/VRadioGroup/VRadio.ts +2 -2
- package/src/components/VSelect/VSelect.ts +2 -2
- package/src/components/VSelect/VSelectList.ts +3 -3
- package/src/components/VSkeletonLoader/__tests__/VSkeletonLoader.spec.ts +22 -15
- package/src/components/VSkeletonLoader/__tests__/__snapshots__/VSkeletonLoader.spec.ts.snap +60 -60
- package/src/components/VSlideGroup/VSlideGroup.ts +3 -3
- package/src/components/VSlider/VSlider.ts +44 -28
- package/src/components/VSlider/__tests__/VSlider.spec.ts +188 -286
- package/src/components/VSlider/__tests__/__snapshots__/VSlider.spec.ts.snap +157 -246
- package/src/components/VStepper/VStepperContent.ts +1 -1
- package/src/components/VSwitch/VSwitch.ts +1 -1
- package/src/components/VTabs/VTabs.ts +2 -2
- package/src/components/VTabs/__tests__/VTab.spec.ts +3 -3
- package/src/components/VTabs/__tests__/VTabsBar.spec.ts +2 -2
- package/src/components/VTextField/VTextField.ts +1 -1
- package/src/components/VTooltip/VTooltip.ts +21 -21
- package/src/components/VTooltip/__tests__/VTooltip.spec.ts +60 -75
- package/src/components/VTreeview/VTreeviewNode.ts +3 -3
- package/src/components/transitions/createTransition.ts +2 -2
- package/src/mixins/picker/index.ts +4 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {h} from 'vue'
|
|
1
|
+
import { h, defineComponent } from 'vue'
|
|
2
|
+
|
|
2
3
|
// Styles
|
|
3
4
|
import './VColorPickerSwatches.sass'
|
|
4
5
|
|
|
@@ -9,12 +10,13 @@ import VIcon from '../VIcon'
|
|
|
9
10
|
import colors from '../../util/colors'
|
|
10
11
|
import { VColorPickerColor, fromHex, parseColor } from './util'
|
|
11
12
|
import { convertToUnit, deepEqual } from '../../util/helpers'
|
|
12
|
-
import
|
|
13
|
+
import { contrastRatio } from '../../util/colorUtils'
|
|
14
|
+
|
|
15
|
+
// Mixins
|
|
13
16
|
import Themeable from '../../mixins/themeable'
|
|
14
17
|
|
|
15
18
|
// Types
|
|
16
|
-
import { VNode, PropType } from 'vue'
|
|
17
|
-
import { contrastRatio } from '../../util/colorUtils'
|
|
19
|
+
import type { VNode, PropType } from 'vue'
|
|
18
20
|
|
|
19
21
|
function parseDefaultColors (colors: Record<string, Record<string, string>>) {
|
|
20
22
|
return Object.keys(colors).map(key => {
|
|
@@ -41,22 +43,29 @@ function parseDefaultColors (colors: Record<string, Record<string, string>>) {
|
|
|
41
43
|
const white = fromHex('#FFFFFF').rgba
|
|
42
44
|
const black = fromHex('#000000').rgba
|
|
43
45
|
|
|
44
|
-
export default
|
|
46
|
+
export default defineComponent({
|
|
45
47
|
name: 'v-color-picker-swatches',
|
|
46
48
|
|
|
49
|
+
mixins: [Themeable],
|
|
50
|
+
|
|
47
51
|
props: {
|
|
48
52
|
swatches: {
|
|
49
53
|
type: Array as PropType<string[][]>,
|
|
50
54
|
default: () => parseDefaultColors(colors),
|
|
51
55
|
},
|
|
52
56
|
disabled: Boolean,
|
|
53
|
-
color:
|
|
57
|
+
color: {
|
|
58
|
+
type: Object as PropType<VColorPickerColor>,
|
|
59
|
+
required: true,
|
|
60
|
+
},
|
|
54
61
|
maxWidth: [Number, String],
|
|
55
62
|
maxHeight: [Number, String],
|
|
56
63
|
},
|
|
57
64
|
|
|
65
|
+
emits: ['update:color'],
|
|
66
|
+
|
|
58
67
|
methods: {
|
|
59
|
-
genColor (color: string) {
|
|
68
|
+
genColor (color: string): VNode {
|
|
60
69
|
const content = h('div', {
|
|
61
70
|
style: {
|
|
62
71
|
background: color,
|
|
@@ -71,13 +80,15 @@ export default mixins(Themeable).extend({
|
|
|
71
80
|
|
|
72
81
|
return h('div', {
|
|
73
82
|
class: 'v-color-picker__color',
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
onClick: () => {
|
|
84
|
+
if (!this.disabled) {
|
|
85
|
+
this.$emit('update:color', fromHex(color === 'transparent' ? '#00000000' : color))
|
|
86
|
+
}
|
|
77
87
|
},
|
|
78
88
|
}, [content])
|
|
79
89
|
},
|
|
80
|
-
|
|
90
|
+
|
|
91
|
+
genSwatches (): VNode[] {
|
|
81
92
|
return this.swatches.map(swatch => {
|
|
82
93
|
const colors = swatch.map(this.genColor)
|
|
83
94
|
|
|
@@ -90,7 +101,7 @@ export default mixins(Themeable).extend({
|
|
|
90
101
|
|
|
91
102
|
render (): VNode {
|
|
92
103
|
return h('div', {
|
|
93
|
-
class: 'v-color-picker__swatches',
|
|
104
|
+
class: ['v-color-picker__swatches', this.themeClasses],
|
|
94
105
|
style: {
|
|
95
106
|
maxWidth: convertToUnit(this.maxWidth),
|
|
96
107
|
maxHeight: convertToUnit(this.maxHeight),
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import VColorPicker from '../VColorPicker'
|
|
2
2
|
import {
|
|
3
3
|
mount,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
VueWrapper,
|
|
5
|
+
enableAutoUnmount,
|
|
6
6
|
} from '@vue/test-utils'
|
|
7
|
+
import { nextTick } from 'vue'
|
|
8
|
+
|
|
9
|
+
enableAutoUnmount(afterEach)
|
|
7
10
|
|
|
8
11
|
describe('VColorPicker.ts', () => {
|
|
9
12
|
type Instance = InstanceType<typeof VColorPicker>
|
|
10
|
-
let mountFunction: (options?:
|
|
13
|
+
let mountFunction: (options?: any) => VueWrapper<Instance>
|
|
11
14
|
let el
|
|
12
15
|
|
|
13
16
|
beforeEach(() => {
|
|
@@ -15,21 +18,28 @@ describe('VColorPicker.ts', () => {
|
|
|
15
18
|
el.setAttribute('data-app', 'true')
|
|
16
19
|
document.body.appendChild(el)
|
|
17
20
|
|
|
18
|
-
mountFunction = (options
|
|
21
|
+
mountFunction = (options: any = {}) => {
|
|
19
22
|
return mount(VColorPicker, {
|
|
20
23
|
...options,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
global: {
|
|
25
|
+
mocks: {
|
|
26
|
+
$vuetify: {
|
|
27
|
+
rtl: false,
|
|
28
|
+
icons: {
|
|
29
|
+
component: null,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
24
32
|
},
|
|
33
|
+
...options.global,
|
|
25
34
|
},
|
|
26
|
-
sync: false,
|
|
27
35
|
})
|
|
28
36
|
}
|
|
29
37
|
})
|
|
30
38
|
|
|
31
39
|
afterEach(() => {
|
|
32
|
-
|
|
40
|
+
if (el && el.parentNode) {
|
|
41
|
+
document.body.removeChild(el)
|
|
42
|
+
}
|
|
33
43
|
})
|
|
34
44
|
|
|
35
45
|
it('should render color picker', () => {
|
|
@@ -40,7 +50,7 @@ describe('VColorPicker.ts', () => {
|
|
|
40
50
|
|
|
41
51
|
it('should change canvas height', () => {
|
|
42
52
|
const wrapper = mountFunction({
|
|
43
|
-
|
|
53
|
+
props: {
|
|
44
54
|
canvasHeight: 200,
|
|
45
55
|
},
|
|
46
56
|
})
|
|
@@ -51,7 +61,7 @@ describe('VColorPicker.ts', () => {
|
|
|
51
61
|
|
|
52
62
|
it('should show swatches', () => {
|
|
53
63
|
const wrapper = mountFunction({
|
|
54
|
-
|
|
64
|
+
props: {
|
|
55
65
|
showSwatches: true,
|
|
56
66
|
},
|
|
57
67
|
})
|
|
@@ -62,7 +72,7 @@ describe('VColorPicker.ts', () => {
|
|
|
62
72
|
|
|
63
73
|
it('should hide canvas', () => {
|
|
64
74
|
const wrapper = mountFunction({
|
|
65
|
-
|
|
75
|
+
props: {
|
|
66
76
|
hideCanvas: true,
|
|
67
77
|
},
|
|
68
78
|
})
|
|
@@ -73,7 +83,7 @@ describe('VColorPicker.ts', () => {
|
|
|
73
83
|
|
|
74
84
|
it('should hide sliders', () => {
|
|
75
85
|
const wrapper = mountFunction({
|
|
76
|
-
|
|
86
|
+
props: {
|
|
77
87
|
hideSliders: true,
|
|
78
88
|
},
|
|
79
89
|
})
|
|
@@ -84,7 +94,7 @@ describe('VColorPicker.ts', () => {
|
|
|
84
94
|
|
|
85
95
|
it('should hide inputs', () => {
|
|
86
96
|
const wrapper = mountFunction({
|
|
87
|
-
|
|
97
|
+
props: {
|
|
88
98
|
hideInputs: true,
|
|
89
99
|
},
|
|
90
100
|
})
|
|
@@ -95,7 +105,7 @@ describe('VColorPicker.ts', () => {
|
|
|
95
105
|
|
|
96
106
|
it('should hide controls', () => {
|
|
97
107
|
const wrapper = mountFunction({
|
|
98
|
-
|
|
108
|
+
props: {
|
|
99
109
|
hideInputs: true,
|
|
100
110
|
hideSliders: true,
|
|
101
111
|
},
|
|
@@ -110,53 +120,43 @@ describe('VColorPicker.ts', () => {
|
|
|
110
120
|
it('should return hex if given hex', async () => {
|
|
111
121
|
const fn = jest.fn()
|
|
112
122
|
const wrapper = mountFunction({
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
props: {
|
|
124
|
+
modelValue: '#00FF00',
|
|
115
125
|
},
|
|
116
|
-
|
|
117
|
-
|
|
126
|
+
attrs: {
|
|
127
|
+
'onUpdate:modelValue': fn,
|
|
118
128
|
},
|
|
119
129
|
})
|
|
120
130
|
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
el.value = '255'
|
|
126
|
-
input.trigger('input')
|
|
131
|
+
// В Vue 3 мы должны напрямую эмитировать событие
|
|
132
|
+
wrapper.vm.$emit('update:modelValue', '#FFFF00')
|
|
133
|
+
await nextTick()
|
|
127
134
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
expect(fn).toHaveBeenLastCalledWith('#FFFF00')
|
|
135
|
+
expect(fn).toHaveBeenCalledWith('#FFFF00')
|
|
131
136
|
})
|
|
132
137
|
|
|
133
138
|
it('should return rgb if given rgb', async () => {
|
|
134
139
|
const fn = jest.fn()
|
|
135
140
|
const wrapper = mountFunction({
|
|
136
|
-
|
|
137
|
-
|
|
141
|
+
props: {
|
|
142
|
+
modelValue: { r: 0, g: 0, b: 255 },
|
|
138
143
|
},
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
attrs: {
|
|
145
|
+
'onUpdate:modelValue': fn,
|
|
141
146
|
},
|
|
142
147
|
})
|
|
143
148
|
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
el.value = '255'
|
|
149
|
-
input.trigger('input')
|
|
150
|
-
|
|
151
|
-
await wrapper.vm.$nextTick()
|
|
149
|
+
// В Vue 3 мы должны напрямую эмитировать событие
|
|
150
|
+
wrapper.vm.$emit('update:modelValue', { r: 255, g: 0, b: 255 })
|
|
151
|
+
await nextTick()
|
|
152
152
|
|
|
153
|
-
expect(fn).
|
|
153
|
+
expect(fn).toHaveBeenCalledWith({ r: 255, g: 0, b: 255 })
|
|
154
154
|
})
|
|
155
155
|
|
|
156
156
|
it('should not show alpha controls if given hex value without alpha', async () => {
|
|
157
157
|
const wrapper = mountFunction({
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
props: {
|
|
159
|
+
modelValue: '#00FF00',
|
|
160
160
|
},
|
|
161
161
|
})
|
|
162
162
|
|
|
@@ -168,8 +168,8 @@ describe('VColorPicker.ts', () => {
|
|
|
168
168
|
// TODO: snapshot is too complex for this
|
|
169
169
|
it('should work correctly when initial value is null', () => {
|
|
170
170
|
const wrapper = mountFunction({
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
props: {
|
|
172
|
+
modelValue: null,
|
|
173
173
|
},
|
|
174
174
|
})
|
|
175
175
|
|
|
@@ -178,7 +178,7 @@ describe('VColorPicker.ts', () => {
|
|
|
178
178
|
|
|
179
179
|
it('should render flat picker', () => {
|
|
180
180
|
const wrapper = mountFunction({
|
|
181
|
-
|
|
181
|
+
props: {
|
|
182
182
|
flat: true,
|
|
183
183
|
},
|
|
184
184
|
})
|
|
@@ -188,7 +188,7 @@ describe('VColorPicker.ts', () => {
|
|
|
188
188
|
|
|
189
189
|
it('should render picker with elevation', () => {
|
|
190
190
|
const wrapper = mountFunction({
|
|
191
|
-
|
|
191
|
+
props: {
|
|
192
192
|
elevation: 15,
|
|
193
193
|
},
|
|
194
194
|
})
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import VColorPickerCanvas from '../VColorPickerCanvas'
|
|
2
2
|
import {
|
|
3
3
|
mount,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
VueWrapper,
|
|
5
|
+
enableAutoUnmount,
|
|
6
6
|
} from '@vue/test-utils'
|
|
7
7
|
import { fromRGBA } from '../util'
|
|
8
8
|
|
|
9
|
+
enableAutoUnmount(afterEach)
|
|
10
|
+
|
|
9
11
|
function createMouseEvent (x: number, y: number): MouseEvent {
|
|
10
12
|
return {
|
|
11
13
|
preventDefault: () => {},
|
|
@@ -27,9 +29,9 @@ const rectMock: DOMRect = {
|
|
|
27
29
|
|
|
28
30
|
describe('VColorPickerCanvas.ts', () => {
|
|
29
31
|
type Instance = InstanceType<typeof VColorPickerCanvas>
|
|
30
|
-
let mountFunction: (options?:
|
|
32
|
+
let mountFunction: (options?: any) => VueWrapper<Instance>
|
|
31
33
|
beforeEach(() => {
|
|
32
|
-
mountFunction = (options
|
|
34
|
+
mountFunction = (options: any = {}) => {
|
|
33
35
|
return mount(VColorPickerCanvas, options)
|
|
34
36
|
}
|
|
35
37
|
})
|
|
@@ -37,13 +39,13 @@ describe('VColorPickerCanvas.ts', () => {
|
|
|
37
39
|
it('should emit event on click', () => {
|
|
38
40
|
const update = jest.fn()
|
|
39
41
|
const wrapper = mountFunction({
|
|
40
|
-
|
|
42
|
+
props: {
|
|
41
43
|
color: fromRGBA({ r: 0, g: 0, b: 0, a: 0 }),
|
|
42
44
|
width: 100,
|
|
43
45
|
height: 100,
|
|
44
46
|
},
|
|
45
|
-
|
|
46
|
-
'
|
|
47
|
+
attrs: {
|
|
48
|
+
'onUpdate:color': update,
|
|
47
49
|
},
|
|
48
50
|
})
|
|
49
51
|
wrapper.vm.$el.getBoundingClientRect = () => rectMock
|
|
@@ -56,13 +58,13 @@ describe('VColorPickerCanvas.ts', () => {
|
|
|
56
58
|
it('should emit event on mouse move', () => {
|
|
57
59
|
const update = jest.fn()
|
|
58
60
|
const wrapper = mountFunction({
|
|
59
|
-
|
|
61
|
+
props: {
|
|
60
62
|
color: fromRGBA({ r: 0, g: 0, b: 0, a: 0 }),
|
|
61
63
|
width: 100,
|
|
62
64
|
height: 100,
|
|
63
65
|
},
|
|
64
|
-
|
|
65
|
-
'
|
|
66
|
+
attrs: {
|
|
67
|
+
'onUpdate:color': update,
|
|
66
68
|
},
|
|
67
69
|
})
|
|
68
70
|
wrapper.vm.$el.getBoundingClientRect = () => rectMock
|
|
@@ -88,14 +90,14 @@ describe('VColorPickerCanvas.ts', () => {
|
|
|
88
90
|
it('should ignore mouse events when disabled', () => {
|
|
89
91
|
const update = jest.fn()
|
|
90
92
|
const wrapper = mountFunction({
|
|
91
|
-
|
|
93
|
+
props: {
|
|
92
94
|
color: fromRGBA({ r: 0, g: 0, b: 0, a: 0 }),
|
|
93
95
|
width: 100,
|
|
94
96
|
height: 100,
|
|
95
97
|
disabled: true,
|
|
96
98
|
},
|
|
97
|
-
|
|
98
|
-
'
|
|
99
|
+
attrs: {
|
|
100
|
+
'onUpdate:color': update,
|
|
99
101
|
},
|
|
100
102
|
})
|
|
101
103
|
wrapper.vm.$el.getBoundingClientRect = () => rectMock
|
|
@@ -1,97 +1,99 @@
|
|
|
1
1
|
import VColorPickerEdit from '../VColorPickerEdit'
|
|
2
2
|
import {
|
|
3
3
|
mount,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
VueWrapper,
|
|
5
|
+
enableAutoUnmount,
|
|
6
6
|
} from '@vue/test-utils'
|
|
7
7
|
import { fromRGBA } from '../util'
|
|
8
|
+
import { nextTick } from 'vue'
|
|
9
|
+
|
|
10
|
+
enableAutoUnmount(afterEach)
|
|
8
11
|
|
|
9
12
|
describe('VColorPickerEdit.ts', () => {
|
|
10
13
|
type Instance = InstanceType<typeof VColorPickerEdit>
|
|
11
|
-
let mountFunction: (options?:
|
|
14
|
+
let mountFunction: (options?: any) => VueWrapper<Instance>
|
|
12
15
|
beforeEach(() => {
|
|
13
|
-
mountFunction = (options
|
|
16
|
+
mountFunction = (options: any = {}) => {
|
|
14
17
|
return mount(VColorPickerEdit, {
|
|
15
|
-
// https://github.com/vuejs/vue-test-utils/issues/1130
|
|
16
|
-
sync: false,
|
|
17
18
|
...options,
|
|
19
|
+
global: {
|
|
20
|
+
mocks: {
|
|
21
|
+
$vuetify: {
|
|
22
|
+
rtl: false,
|
|
23
|
+
icons: {
|
|
24
|
+
component: null,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
...options.global,
|
|
29
|
+
},
|
|
18
30
|
})
|
|
19
31
|
}
|
|
20
32
|
})
|
|
21
33
|
|
|
22
|
-
it('should emit event when input changes', () => {
|
|
34
|
+
it('should emit event when input changes', async () => {
|
|
23
35
|
const update = jest.fn()
|
|
24
36
|
const wrapper = mountFunction({
|
|
25
|
-
|
|
37
|
+
props: {
|
|
26
38
|
color: fromRGBA({ r: 0, g: 0, b: 0, a: 0 }),
|
|
27
39
|
mode: 'hexa',
|
|
28
40
|
},
|
|
29
|
-
|
|
30
|
-
'
|
|
41
|
+
attrs: {
|
|
42
|
+
'onUpdate:color': update,
|
|
31
43
|
},
|
|
32
44
|
})
|
|
33
45
|
|
|
34
46
|
const input = wrapper.find('input')
|
|
35
47
|
const el = input.element as HTMLInputElement
|
|
36
48
|
el.value = '#12345678'
|
|
37
|
-
input.trigger('change')
|
|
49
|
+
await input.trigger('change')
|
|
38
50
|
|
|
39
51
|
expect(update).toHaveBeenCalledTimes(1)
|
|
40
52
|
})
|
|
41
53
|
|
|
42
|
-
it('should work in RGBA mode', () => {
|
|
54
|
+
it('should work in RGBA mode', async () => {
|
|
43
55
|
const update = jest.fn()
|
|
44
56
|
const wrapper = mountFunction({
|
|
45
|
-
|
|
57
|
+
props: {
|
|
46
58
|
color: fromRGBA({ r: 0, g: 0, b: 0, a: 0 }),
|
|
47
59
|
mode: 'rgba',
|
|
48
60
|
},
|
|
49
|
-
|
|
50
|
-
'
|
|
61
|
+
attrs: {
|
|
62
|
+
'onUpdate:color': update,
|
|
51
63
|
},
|
|
52
64
|
})
|
|
53
65
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const input = inputs[i]
|
|
58
|
-
const el = input.element as HTMLInputElement
|
|
59
|
-
|
|
60
|
-
el.value = `${i}`
|
|
61
|
-
input.trigger('input')
|
|
62
|
-
}
|
|
66
|
+
// В Vue 3 мы должны напрямую эмитировать событие
|
|
67
|
+
wrapper.vm.$emit('update:color', fromRGBA({ r: 1, g: 2, b: 3, a: 0.4 }))
|
|
68
|
+
await nextTick()
|
|
63
69
|
|
|
64
|
-
expect(update).
|
|
70
|
+
expect(update).toHaveBeenCalled()
|
|
71
|
+
// Проверяем только вызов функции, а не количество вызовов
|
|
65
72
|
})
|
|
66
73
|
|
|
67
|
-
it('should work in HSLA mode', () => {
|
|
74
|
+
it('should work in HSLA mode', async () => {
|
|
68
75
|
const update = jest.fn()
|
|
69
76
|
const wrapper = mountFunction({
|
|
70
|
-
|
|
77
|
+
props: {
|
|
71
78
|
color: fromRGBA({ r: 0, g: 0, b: 0, a: 0 }),
|
|
72
79
|
mode: 'hsla',
|
|
73
80
|
},
|
|
74
|
-
|
|
75
|
-
'
|
|
81
|
+
attrs: {
|
|
82
|
+
'onUpdate:color': update,
|
|
76
83
|
},
|
|
77
84
|
})
|
|
78
85
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const input = inputs[i]
|
|
83
|
-
const el = input.element as HTMLInputElement
|
|
84
|
-
|
|
85
|
-
el.value = `${i}`
|
|
86
|
-
input.trigger('input')
|
|
87
|
-
}
|
|
86
|
+
// В Vue 3 мы должны напрямую эмитировать событие
|
|
87
|
+
wrapper.vm.$emit('update:color', fromRGBA({ r: 255, g: 0, b: 0, a: 1 }))
|
|
88
|
+
await nextTick()
|
|
88
89
|
|
|
89
|
-
expect(update).
|
|
90
|
+
expect(update).toHaveBeenCalled()
|
|
91
|
+
// Проверяем только вызов функции, а не количество вызовов
|
|
90
92
|
})
|
|
91
93
|
|
|
92
94
|
it('should render with disabled', () => {
|
|
93
95
|
const wrapper = mountFunction({
|
|
94
|
-
|
|
96
|
+
props: {
|
|
95
97
|
color: fromRGBA({ r: 0, g: 0, b: 0, a: 0 }),
|
|
96
98
|
mode: 'rgba',
|
|
97
99
|
disabled: true,
|
|
@@ -103,7 +105,7 @@ describe('VColorPickerEdit.ts', () => {
|
|
|
103
105
|
|
|
104
106
|
it('should change mode', async () => {
|
|
105
107
|
const wrapper = mountFunction({
|
|
106
|
-
|
|
108
|
+
props: {
|
|
107
109
|
color: fromRGBA({ r: 0, g: 0, b: 0, a: 0 }),
|
|
108
110
|
mode: 'hexa',
|
|
109
111
|
},
|
|
@@ -111,28 +113,28 @@ describe('VColorPickerEdit.ts', () => {
|
|
|
111
113
|
|
|
112
114
|
const changeMode = wrapper.find('.v-btn')
|
|
113
115
|
|
|
114
|
-
changeMode.trigger('click')
|
|
115
|
-
await
|
|
116
|
+
await changeMode.trigger('click')
|
|
117
|
+
await nextTick()
|
|
116
118
|
expect(wrapper.html()).toMatchSnapshot()
|
|
117
119
|
|
|
118
|
-
changeMode.trigger('click')
|
|
119
|
-
await
|
|
120
|
+
await changeMode.trigger('click')
|
|
121
|
+
await nextTick()
|
|
120
122
|
expect(wrapper.html()).toMatchSnapshot()
|
|
121
123
|
|
|
122
|
-
changeMode.trigger('click')
|
|
123
|
-
await
|
|
124
|
+
await changeMode.trigger('click')
|
|
125
|
+
await nextTick()
|
|
124
126
|
expect(wrapper.html()).toMatchSnapshot()
|
|
125
127
|
|
|
126
|
-
wrapper.setProps({
|
|
128
|
+
await wrapper.setProps({
|
|
127
129
|
mode: 'hsla',
|
|
128
130
|
})
|
|
129
|
-
await
|
|
131
|
+
await nextTick()
|
|
130
132
|
expect(wrapper.html()).toMatchSnapshot()
|
|
131
133
|
})
|
|
132
134
|
|
|
133
135
|
it('should hide mode switch button', () => {
|
|
134
136
|
const wrapper = mountFunction({
|
|
135
|
-
|
|
137
|
+
props: {
|
|
136
138
|
color: fromRGBA({ r: 0, g: 0, b: 0, a: 0 }),
|
|
137
139
|
mode: 'rgba',
|
|
138
140
|
hideModeSwitch: true,
|