@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
|
@@ -51,7 +51,7 @@ export default baseMixins.extend({
|
|
|
51
51
|
...this.$attrs,
|
|
52
52
|
height: this.windowGroup.internalHeight,
|
|
53
53
|
...this.$listeners,
|
|
54
|
-
}, { default: getSlot(this), placeholder: this.$slots.placeholder }),
|
|
54
|
+
}, { default: () => getSlot(this), placeholder: this.$slots.placeholder }),
|
|
55
55
|
]
|
|
56
56
|
},
|
|
57
57
|
genWindowItem () {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {h} from 'vue'
|
|
1
|
+
import { h, defineComponent } from 'vue'
|
|
2
|
+
|
|
2
3
|
// Styles
|
|
3
4
|
import './VColorPicker.sass'
|
|
4
5
|
|
|
@@ -11,7 +12,6 @@ import VColorPickerSwatches from './VColorPickerSwatches'
|
|
|
11
12
|
|
|
12
13
|
// Helpers
|
|
13
14
|
import { VColorPickerColor, parseColor, fromRGBA, extractColor, hasAlpha } from './util'
|
|
14
|
-
import mixins from '../../util/mixins'
|
|
15
15
|
import { deepEqual } from '../../util/helpers'
|
|
16
16
|
|
|
17
17
|
// Mixins
|
|
@@ -19,11 +19,13 @@ import Elevatable from '../../mixins/elevatable'
|
|
|
19
19
|
import Themeable from '../../mixins/themeable'
|
|
20
20
|
|
|
21
21
|
// Types
|
|
22
|
-
import { VNode, PropType } from 'vue'
|
|
22
|
+
import type { VNode, PropType } from 'vue'
|
|
23
23
|
|
|
24
|
-
export default
|
|
24
|
+
export default defineComponent({
|
|
25
25
|
name: 'v-color-picker',
|
|
26
26
|
|
|
27
|
+
mixins: [Elevatable, Themeable],
|
|
28
|
+
|
|
27
29
|
props: {
|
|
28
30
|
canvasHeight: {
|
|
29
31
|
type: [String, Number],
|
|
@@ -59,20 +61,23 @@ export default mixins(Elevatable, Themeable).extend({
|
|
|
59
61
|
},
|
|
60
62
|
},
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
emits: ['update:modelValue', 'update:color', 'update:mode'],
|
|
65
|
+
|
|
66
|
+
data () {
|
|
67
|
+
return {
|
|
68
|
+
internalValue: fromRGBA({ r: 255, g: 0, b: 0, a: 1 }),
|
|
69
|
+
}
|
|
70
|
+
},
|
|
65
71
|
|
|
66
72
|
computed: {
|
|
67
73
|
hideAlpha (): boolean {
|
|
68
74
|
if (!this.modelValue) return false
|
|
69
|
-
|
|
70
75
|
return !hasAlpha(this.modelValue)
|
|
71
76
|
},
|
|
72
77
|
},
|
|
73
78
|
|
|
74
79
|
watch: {
|
|
75
|
-
|
|
80
|
+
modelValue: {
|
|
76
81
|
handler (color: any) {
|
|
77
82
|
this.updateColor(parseColor(color, this.internalValue))
|
|
78
83
|
},
|
|
@@ -90,6 +95,7 @@ export default mixins(Elevatable, Themeable).extend({
|
|
|
90
95
|
this.$emit('update:color', this.internalValue)
|
|
91
96
|
}
|
|
92
97
|
},
|
|
98
|
+
|
|
93
99
|
genCanvas (): VNode {
|
|
94
100
|
return h(VColorPickerCanvas, {
|
|
95
101
|
color: this.internalValue,
|
|
@@ -100,6 +106,7 @@ export default mixins(Elevatable, Themeable).extend({
|
|
|
100
106
|
'onUpdate:color': this.updateColor
|
|
101
107
|
})
|
|
102
108
|
},
|
|
109
|
+
|
|
103
110
|
genControls (): VNode {
|
|
104
111
|
return h('div', {
|
|
105
112
|
class: 'v-color-picker__controls',
|
|
@@ -108,6 +115,7 @@ export default mixins(Elevatable, Themeable).extend({
|
|
|
108
115
|
!this.hideInputs && this.genEdit(),
|
|
109
116
|
])
|
|
110
117
|
},
|
|
118
|
+
|
|
111
119
|
genEdit (): VNode {
|
|
112
120
|
return h(VColorPickerEdit, {
|
|
113
121
|
color: this.internalValue,
|
|
@@ -116,49 +124,38 @@ export default mixins(Elevatable, Themeable).extend({
|
|
|
116
124
|
hideModeSwitch: this.hideModeSwitch,
|
|
117
125
|
mode: this.mode,
|
|
118
126
|
'onUpdate:color': this.updateColor,
|
|
119
|
-
'onUpdate:mode': (v:
|
|
127
|
+
'onUpdate:mode': (v: string) => this.$emit('update:mode', v),
|
|
120
128
|
})
|
|
121
129
|
},
|
|
130
|
+
|
|
122
131
|
genPreview (): VNode {
|
|
123
132
|
return h(VColorPickerPreview, {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
},
|
|
129
|
-
on: {
|
|
130
|
-
'update:color': this.updateColor,
|
|
131
|
-
},
|
|
133
|
+
color: this.internalValue,
|
|
134
|
+
disabled: this.disabled,
|
|
135
|
+
hideAlpha: this.hideAlpha,
|
|
136
|
+
'onUpdate:color': this.updateColor,
|
|
132
137
|
})
|
|
133
138
|
},
|
|
139
|
+
|
|
134
140
|
genSwatches (): VNode {
|
|
135
141
|
return h(VColorPickerSwatches, {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
color: this.internalValue,
|
|
142
|
-
maxHeight: this.swatchesMaxHeight,
|
|
143
|
-
},
|
|
144
|
-
on: {
|
|
145
|
-
'update:color': this.updateColor,
|
|
146
|
-
},
|
|
142
|
+
disabled: this.disabled,
|
|
143
|
+
swatches: this.swatches,
|
|
144
|
+
color: this.internalValue,
|
|
145
|
+
maxHeight: this.swatchesMaxHeight,
|
|
146
|
+
'onUpdate:color': this.updateColor,
|
|
147
147
|
})
|
|
148
148
|
},
|
|
149
149
|
},
|
|
150
150
|
|
|
151
151
|
render (): VNode {
|
|
152
152
|
return h(VSheet, {
|
|
153
|
-
class: 'v-color-picker',
|
|
154
|
-
class: {
|
|
153
|
+
class: ['v-color-picker', {
|
|
155
154
|
'v-color-picker--flat': this.flat,
|
|
156
155
|
...this.themeClasses,
|
|
157
156
|
...this.elevationClasses,
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
maxWidth: this.width,
|
|
161
|
-
},
|
|
157
|
+
}],
|
|
158
|
+
maxWidth: this.width,
|
|
162
159
|
}, [
|
|
163
160
|
!this.hideCanvas && this.genCanvas(),
|
|
164
161
|
(!this.hideSliders || !this.hideInputs) && this.genControls(),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {h} from 'vue'
|
|
1
|
+
import { h, defineComponent } from 'vue'
|
|
2
|
+
|
|
2
3
|
// Styles
|
|
3
4
|
import './VColorPickerCanvas.sass'
|
|
4
5
|
|
|
@@ -7,7 +8,7 @@ import { clamp, convertToUnit } from '../../util/helpers'
|
|
|
7
8
|
import { fromHSVA, VColorPickerColor, fromRGBA } from './util'
|
|
8
9
|
|
|
9
10
|
// Types
|
|
10
|
-
import {
|
|
11
|
+
import type { VNode, PropType } from 'vue'
|
|
11
12
|
|
|
12
13
|
export default defineComponent({
|
|
13
14
|
name: 'v-color-picker-canvas',
|
|
@@ -32,6 +33,8 @@ export default defineComponent({
|
|
|
32
33
|
},
|
|
33
34
|
},
|
|
34
35
|
|
|
36
|
+
emits: ['update:color'],
|
|
37
|
+
|
|
35
38
|
data () {
|
|
36
39
|
return {
|
|
37
40
|
boundingRect: {
|
|
@@ -44,18 +47,20 @@ export default defineComponent({
|
|
|
44
47
|
},
|
|
45
48
|
|
|
46
49
|
computed: {
|
|
47
|
-
dot ()
|
|
50
|
+
dot () {
|
|
48
51
|
if (!this.color) return { x: 0, y: 0 }
|
|
49
52
|
|
|
50
53
|
return {
|
|
51
|
-
x: this.color.hsva.s * parseInt(this.width, 10),
|
|
52
|
-
y: (1 - this.color.hsva.v) * parseInt(this.height, 10),
|
|
54
|
+
x: this.color.hsva.s * parseInt(String(this.width), 10),
|
|
55
|
+
y: (1 - this.color.hsva.v) * parseInt(String(this.height), 10),
|
|
53
56
|
}
|
|
54
57
|
},
|
|
55
58
|
},
|
|
56
59
|
|
|
57
60
|
watch: {
|
|
58
|
-
'color.hue'
|
|
61
|
+
'color.hue' () {
|
|
62
|
+
this.updateCanvas()
|
|
63
|
+
},
|
|
59
64
|
},
|
|
60
65
|
|
|
61
66
|
mounted () {
|
|
@@ -63,22 +68,13 @@ export default defineComponent({
|
|
|
63
68
|
},
|
|
64
69
|
|
|
65
70
|
methods: {
|
|
66
|
-
emitColor (x: number, y: number) {
|
|
67
|
-
const { left, top, width, height } = this.boundingRect
|
|
68
|
-
|
|
69
|
-
this.$emit('update:color', fromHSVA({
|
|
70
|
-
h: this.color.hue,
|
|
71
|
-
s: clamp(x - left, 0, width) / width,
|
|
72
|
-
v: 1 - clamp(y - top, 0, height) / height,
|
|
73
|
-
a: this.color.alpha,
|
|
74
|
-
}))
|
|
75
|
-
},
|
|
76
71
|
updateCanvas () {
|
|
77
72
|
if (!this.color) return
|
|
78
73
|
|
|
79
74
|
const canvas = this.$refs.canvas as HTMLCanvasElement
|
|
80
|
-
|
|
75
|
+
if (!canvas) return
|
|
81
76
|
|
|
77
|
+
const ctx = canvas.getContext('2d')
|
|
82
78
|
if (!ctx) return
|
|
83
79
|
|
|
84
80
|
const saturationGradient = ctx.createLinearGradient(0, 0, canvas.width, 0)
|
|
@@ -93,12 +89,35 @@ export default defineComponent({
|
|
|
93
89
|
ctx.fillStyle = valueGradient
|
|
94
90
|
ctx.fillRect(0, 0, canvas.width, canvas.height)
|
|
95
91
|
},
|
|
92
|
+
|
|
93
|
+
emitColor (x: number, y: number) {
|
|
94
|
+
const { left, top, width, height } = this.boundingRect
|
|
95
|
+
|
|
96
|
+
this.$emit('update:color', fromHSVA({
|
|
97
|
+
h: this.color!.hue,
|
|
98
|
+
s: clamp(x - left, 0, width) / width,
|
|
99
|
+
v: 1 - clamp(y - top, 0, height) / height,
|
|
100
|
+
a: this.color!.alpha,
|
|
101
|
+
}))
|
|
102
|
+
},
|
|
103
|
+
|
|
96
104
|
handleClick (e: MouseEvent) {
|
|
97
105
|
if (this.disabled) return
|
|
98
106
|
|
|
99
107
|
this.boundingRect = this.$el.getBoundingClientRect()
|
|
100
108
|
this.emitColor(e.clientX, e.clientY)
|
|
101
109
|
},
|
|
110
|
+
|
|
111
|
+
handleMouseMove (e: MouseEvent) {
|
|
112
|
+
if (this.disabled) return
|
|
113
|
+
this.emitColor(e.clientX, e.clientY)
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
handleMouseUp () {
|
|
117
|
+
window.removeEventListener('mousemove', this.handleMouseMove)
|
|
118
|
+
window.removeEventListener('mouseup', this.handleMouseUp)
|
|
119
|
+
},
|
|
120
|
+
|
|
102
121
|
handleMouseDown (e: MouseEvent) {
|
|
103
122
|
// To prevent selection while moving cursor
|
|
104
123
|
e.preventDefault()
|
|
@@ -110,34 +129,24 @@ export default defineComponent({
|
|
|
110
129
|
window.addEventListener('mousemove', this.handleMouseMove)
|
|
111
130
|
window.addEventListener('mouseup', this.handleMouseUp)
|
|
112
131
|
},
|
|
113
|
-
handleMouseMove (e: MouseEvent) {
|
|
114
|
-
if (this.disabled) return
|
|
115
132
|
|
|
116
|
-
this.emitColor(e.clientX, e.clientY)
|
|
117
|
-
},
|
|
118
|
-
handleMouseUp () {
|
|
119
|
-
window.removeEventListener('mousemove', this.handleMouseMove)
|
|
120
|
-
window.removeEventListener('mouseup', this.handleMouseUp)
|
|
121
|
-
},
|
|
122
133
|
genCanvas (): VNode {
|
|
123
134
|
return h('canvas', {
|
|
124
135
|
ref: 'canvas',
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
height: this.height,
|
|
128
|
-
},
|
|
136
|
+
width: this.width,
|
|
137
|
+
height: this.height,
|
|
129
138
|
})
|
|
130
139
|
},
|
|
140
|
+
|
|
131
141
|
genDot (): VNode {
|
|
132
|
-
const radius = parseInt(this.dotSize, 10) / 2
|
|
142
|
+
const radius = parseInt(String(this.dotSize), 10) / 2
|
|
133
143
|
const x = convertToUnit(this.dot.x - radius)
|
|
134
144
|
const y = convertToUnit(this.dot.y - radius)
|
|
135
145
|
|
|
136
146
|
return h('div', {
|
|
137
|
-
class: 'v-color-picker__canvas-dot',
|
|
138
|
-
class: {
|
|
147
|
+
class: ['v-color-picker__canvas-dot', {
|
|
139
148
|
'v-color-picker__canvas-dot--disabled': this.disabled,
|
|
140
|
-
},
|
|
149
|
+
}],
|
|
141
150
|
style: {
|
|
142
151
|
width: convertToUnit(this.dotSize),
|
|
143
152
|
height: convertToUnit(this.dotSize),
|
|
@@ -154,10 +163,8 @@ export default defineComponent({
|
|
|
154
163
|
width: convertToUnit(this.width),
|
|
155
164
|
height: convertToUnit(this.height),
|
|
156
165
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
mousedown: this.handleMouseDown,
|
|
160
|
-
},
|
|
166
|
+
onClick: this.handleClick,
|
|
167
|
+
onMousedown: this.handleMouseDown,
|
|
161
168
|
}, [
|
|
162
169
|
this.genCanvas(),
|
|
163
170
|
this.genDot(),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {h} from 'vue'
|
|
1
|
+
import { h, defineComponent } from 'vue'
|
|
2
|
+
|
|
2
3
|
// Styles
|
|
3
4
|
import './VColorPickerEdit.sass'
|
|
4
5
|
|
|
@@ -10,7 +11,7 @@ import VIcon from '../VIcon'
|
|
|
10
11
|
import { parseHex } from '../../util/colorUtils'
|
|
11
12
|
|
|
12
13
|
// Types
|
|
13
|
-
import {
|
|
14
|
+
import type { VNode, PropType } from 'vue'
|
|
14
15
|
import { VColorPickerColor, fromRGBA, fromHexa, fromHSLA } from './util'
|
|
15
16
|
|
|
16
17
|
type Input = [string, number, string]
|
|
@@ -48,7 +49,10 @@ export default defineComponent({
|
|
|
48
49
|
name: 'v-color-picker-edit',
|
|
49
50
|
|
|
50
51
|
props: {
|
|
51
|
-
color:
|
|
52
|
+
color: {
|
|
53
|
+
type: Object as PropType<VColorPickerColor>,
|
|
54
|
+
required: true,
|
|
55
|
+
},
|
|
52
56
|
disabled: Boolean,
|
|
53
57
|
hideAlpha: Boolean,
|
|
54
58
|
hideModeSwitch: Boolean,
|
|
@@ -59,48 +63,48 @@ export default defineComponent({
|
|
|
59
63
|
},
|
|
60
64
|
},
|
|
61
65
|
|
|
66
|
+
emits: ['update:color', 'update:mode'],
|
|
67
|
+
|
|
62
68
|
data () {
|
|
63
69
|
return {
|
|
64
|
-
modes,
|
|
65
70
|
internalMode: this.mode,
|
|
66
71
|
}
|
|
67
72
|
},
|
|
68
73
|
|
|
69
74
|
computed: {
|
|
70
75
|
currentMode (): Mode {
|
|
71
|
-
return
|
|
76
|
+
return modes[this.internalMode]
|
|
72
77
|
},
|
|
73
78
|
},
|
|
74
79
|
|
|
75
80
|
watch: {
|
|
76
|
-
mode (mode) {
|
|
81
|
+
mode (mode: string) {
|
|
77
82
|
this.internalMode = mode
|
|
78
83
|
},
|
|
79
84
|
},
|
|
80
85
|
|
|
81
|
-
created () {
|
|
82
|
-
this.internalMode = this.mode
|
|
83
|
-
},
|
|
84
|
-
|
|
85
86
|
methods: {
|
|
86
87
|
getValue (v: any, type: string) {
|
|
87
88
|
if (type === 'float') return Math.round(v * 100) / 100
|
|
88
89
|
else if (type === 'int') return Math.round(v)
|
|
89
90
|
else return 0
|
|
90
91
|
},
|
|
92
|
+
|
|
91
93
|
parseValue (v: string, type: string) {
|
|
92
94
|
if (type === 'float') return parseFloat(v)
|
|
93
95
|
else if (type === 'int') return parseInt(v, 10) || 0
|
|
94
96
|
else return 0
|
|
95
97
|
},
|
|
98
|
+
|
|
96
99
|
changeMode () {
|
|
97
|
-
const
|
|
98
|
-
const index =
|
|
99
|
-
const newMode =
|
|
100
|
+
const modeKeys = Object.keys(modes)
|
|
101
|
+
const index = modeKeys.indexOf(this.internalMode)
|
|
102
|
+
const newMode = modeKeys[(index + 1) % modeKeys.length]
|
|
100
103
|
this.internalMode = newMode
|
|
101
104
|
this.$emit('update:mode', newMode)
|
|
102
105
|
},
|
|
103
|
-
|
|
106
|
+
|
|
107
|
+
genInput (target: string, attrs: any, value: any, onChange: any): VNode {
|
|
104
108
|
return h('div', {
|
|
105
109
|
class: 'v-color-picker__input',
|
|
106
110
|
}, [
|
|
@@ -108,14 +112,15 @@ export default defineComponent({
|
|
|
108
112
|
key: target,
|
|
109
113
|
...attrs,
|
|
110
114
|
value,
|
|
111
|
-
|
|
115
|
+
onChange,
|
|
112
116
|
}),
|
|
113
117
|
h('span', target.toUpperCase()),
|
|
114
118
|
])
|
|
115
119
|
},
|
|
120
|
+
|
|
116
121
|
genInputs (): VNode[] | VNode {
|
|
117
122
|
if (this.internalMode === 'hexa') {
|
|
118
|
-
const hex = this.color
|
|
123
|
+
const hex = this.color!.hexa
|
|
119
124
|
const value = this.hideAlpha && hex.endsWith('FF') ? hex.substr(0, 7) : hex
|
|
120
125
|
return this.genInput(
|
|
121
126
|
'hex',
|
|
@@ -124,17 +129,15 @@ export default defineComponent({
|
|
|
124
129
|
disabled: this.disabled,
|
|
125
130
|
},
|
|
126
131
|
value,
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.$emit('update:color', this.currentMode.from(parseHex(el.value)))
|
|
131
|
-
},
|
|
132
|
+
(e: Event) => {
|
|
133
|
+
const el = e.target as HTMLInputElement
|
|
134
|
+
this.$emit('update:color', this.currentMode.from(parseHex(el.value)))
|
|
132
135
|
}
|
|
133
136
|
)
|
|
134
137
|
} else {
|
|
135
138
|
const inputs = this.hideAlpha ? this.currentMode.inputs!.slice(0, -1) : this.currentMode.inputs!
|
|
136
139
|
return inputs.map(([target, max, type]) => {
|
|
137
|
-
const value = this.color[this.internalMode as keyof VColorPickerColor] as any
|
|
140
|
+
const value = this.color![this.internalMode as keyof VColorPickerColor] as any
|
|
138
141
|
return this.genInput(
|
|
139
142
|
target,
|
|
140
143
|
{
|
|
@@ -145,30 +148,29 @@ export default defineComponent({
|
|
|
145
148
|
disabled: this.disabled,
|
|
146
149
|
},
|
|
147
150
|
this.getValue(value[target], type),
|
|
148
|
-
{
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
))
|
|
157
|
-
},
|
|
151
|
+
(e: Event) => {
|
|
152
|
+
const el = e.target as HTMLInputElement
|
|
153
|
+
const newVal = this.parseValue(el.value || '0', type)
|
|
154
|
+
|
|
155
|
+
this.$emit('update:color', this.currentMode.from(
|
|
156
|
+
Object.assign({}, value, { [target]: newVal }),
|
|
157
|
+
this.color!.alpha
|
|
158
|
+
))
|
|
158
159
|
}
|
|
159
160
|
)
|
|
160
161
|
})
|
|
161
162
|
}
|
|
162
163
|
},
|
|
164
|
+
|
|
163
165
|
genSwitch (): VNode {
|
|
164
166
|
return h(VBtn, {
|
|
165
167
|
small: true,
|
|
166
168
|
icon: true,
|
|
167
169
|
disabled: this.disabled,
|
|
168
170
|
onClick: this.changeMode,
|
|
169
|
-
},
|
|
170
|
-
h(VIcon, '$unfold')
|
|
171
|
-
|
|
171
|
+
}, {
|
|
172
|
+
default: () => [h(VIcon, {}, '$unfold')]
|
|
173
|
+
})
|
|
172
174
|
},
|
|
173
175
|
},
|
|
174
176
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {h} from 'vue'
|
|
1
|
+
import { h, defineComponent } from 'vue'
|
|
2
|
+
|
|
2
3
|
// Styles
|
|
3
4
|
import './VColorPickerPreview.sass'
|
|
4
5
|
|
|
@@ -9,36 +10,74 @@ import VSlider from '../VSlider/VSlider'
|
|
|
9
10
|
import { RGBtoCSS, RGBAtoCSS } from '../../util/colorUtils'
|
|
10
11
|
|
|
11
12
|
// Types
|
|
12
|
-
import {
|
|
13
|
-
import { VColorPickerColor
|
|
13
|
+
import type { VNode, PropType } from 'vue'
|
|
14
|
+
import type { VColorPickerColor } from './util'
|
|
15
|
+
import { fromHSVA } from './util'
|
|
14
16
|
|
|
15
17
|
export default defineComponent({
|
|
16
18
|
name: 'v-color-picker-preview',
|
|
17
19
|
|
|
18
20
|
props: {
|
|
19
|
-
color:
|
|
21
|
+
color: {
|
|
22
|
+
type: Object as PropType<VColorPickerColor>,
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
20
25
|
disabled: Boolean,
|
|
21
26
|
hideAlpha: Boolean,
|
|
22
27
|
},
|
|
23
28
|
|
|
29
|
+
emits: ['update:color'],
|
|
30
|
+
|
|
24
31
|
methods: {
|
|
25
32
|
genAlpha (): VNode {
|
|
33
|
+
if (!this.color) return h('div')
|
|
26
34
|
return this.genTrack({
|
|
27
35
|
class: 'v-color-picker__alpha',
|
|
28
36
|
thumbColor: 'grey lighten-2',
|
|
29
37
|
hideDetails: true,
|
|
30
|
-
|
|
38
|
+
modelValue: this.color.alpha,
|
|
31
39
|
step: 0,
|
|
32
40
|
min: 0,
|
|
33
41
|
max: 1,
|
|
34
42
|
style: {
|
|
35
43
|
backgroundImage: this.disabled
|
|
36
44
|
? undefined
|
|
37
|
-
: `linear-gradient(to ${this.$vuetify
|
|
45
|
+
: `linear-gradient(to ${this.$vuetify?.rtl ? 'left' : 'right'}, transparent, ${RGBtoCSS(this.color.rgba)})`,
|
|
46
|
+
},
|
|
47
|
+
'onUpdate:modelValue': (val: number) => {
|
|
48
|
+
if (this.color && this.color.alpha !== val) {
|
|
49
|
+
this.$emit('update:color', fromHSVA({ ...this.color.hsva, a: val }))
|
|
50
|
+
}
|
|
38
51
|
},
|
|
39
|
-
onInput: (val: number) => this.color.alpha !== val && this.$emit('update:color', fromHSVA({ ...this.color.hsva, a: val })),
|
|
40
52
|
})
|
|
41
53
|
},
|
|
54
|
+
|
|
55
|
+
genHue (): VNode {
|
|
56
|
+
if (!this.color) return h('div')
|
|
57
|
+
return this.genTrack({
|
|
58
|
+
class: 'v-color-picker__hue',
|
|
59
|
+
thumbColor: 'grey lighten-2',
|
|
60
|
+
hideDetails: true,
|
|
61
|
+
modelValue: this.color.hue,
|
|
62
|
+
step: 0,
|
|
63
|
+
min: 0,
|
|
64
|
+
max: 360,
|
|
65
|
+
'onUpdate:modelValue': (val: number) => {
|
|
66
|
+
if (this.color && this.color.hue !== val) {
|
|
67
|
+
this.$emit('update:color', fromHSVA({ ...this.color.hsva, h: val }))
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
genTrack (options: Record<string, any>): VNode {
|
|
74
|
+
return h(VSlider, {
|
|
75
|
+
class: 'v-color-picker__track',
|
|
76
|
+
disabled: this.disabled,
|
|
77
|
+
...options,
|
|
78
|
+
})
|
|
79
|
+
},
|
|
80
|
+
|
|
42
81
|
genSliders (): VNode {
|
|
43
82
|
return h('div', {
|
|
44
83
|
class: 'v-color-picker__sliders',
|
|
@@ -47,37 +86,18 @@ export default defineComponent({
|
|
|
47
86
|
!this.hideAlpha && this.genAlpha(),
|
|
48
87
|
])
|
|
49
88
|
},
|
|
89
|
+
|
|
50
90
|
genDot (): VNode {
|
|
51
91
|
return h('div', {
|
|
52
92
|
class: 'v-color-picker__dot',
|
|
53
93
|
}, [
|
|
54
94
|
h('div', {
|
|
55
95
|
style: {
|
|
56
|
-
background: RGBAtoCSS(this.color.rgba),
|
|
96
|
+
background: this.color ? RGBAtoCSS(this.color.rgba) : 'transparent',
|
|
57
97
|
},
|
|
58
98
|
}),
|
|
59
99
|
])
|
|
60
100
|
},
|
|
61
|
-
genHue (): VNode {
|
|
62
|
-
return this.genTrack({
|
|
63
|
-
class: 'v-color-picker__hue',
|
|
64
|
-
thumbColor: 'grey lighten-2',
|
|
65
|
-
hideDetails: true,
|
|
66
|
-
value: this.color.hue,
|
|
67
|
-
step: 0,
|
|
68
|
-
min: 0,
|
|
69
|
-
max: 360,
|
|
70
|
-
onInput: (val: number) => this.color.hue !== val && this.$emit('update:color', fromHSVA({ ...this.color.hsva, h: val })),
|
|
71
|
-
})
|
|
72
|
-
},
|
|
73
|
-
genTrack (options: VNodeData): VNode {
|
|
74
|
-
return h(VSlider, {
|
|
75
|
-
class: 'v-color-picker__track',
|
|
76
|
-
...options,
|
|
77
|
-
disabled: this.disabled,
|
|
78
|
-
...options.props
|
|
79
|
-
})
|
|
80
|
-
},
|
|
81
101
|
},
|
|
82
102
|
|
|
83
103
|
render (): VNode {
|