@dimailn/vuetify 2.7.2-alpha24 → 2.7.2-alpha25

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.
Files changed (74) hide show
  1. package/dist/vuetify.js +241 -230
  2. package/dist/vuetify.js.map +1 -1
  3. package/dist/vuetify.min.css +1 -1
  4. package/dist/vuetify.min.js +2 -2
  5. package/es5/components/VBtn/VBtn.js +16 -16
  6. package/es5/components/VBtn/VBtn.js.map +1 -1
  7. package/es5/components/VColorPicker/VColorPicker.js +18 -31
  8. package/es5/components/VColorPicker/VColorPicker.js.map +1 -1
  9. package/es5/components/VColorPicker/VColorPickerCanvas.js +45 -46
  10. package/es5/components/VColorPicker/VColorPickerCanvas.js.map +1 -1
  11. package/es5/components/VColorPicker/VColorPickerEdit.js +27 -26
  12. package/es5/components/VColorPicker/VColorPickerEdit.js.map +1 -1
  13. package/es5/components/VColorPicker/VColorPickerPreview.js +41 -30
  14. package/es5/components/VColorPicker/VColorPickerPreview.js.map +1 -1
  15. package/es5/components/VColorPicker/VColorPickerSwatches.js +13 -10
  16. package/es5/components/VColorPicker/VColorPickerSwatches.js.map +1 -1
  17. package/es5/components/VDataTable/VDataTable.js +7 -11
  18. package/es5/components/VDataTable/VDataTable.js.map +1 -1
  19. package/es5/components/VInput/VInput.js +20 -6
  20. package/es5/components/VInput/VInput.js.map +1 -1
  21. package/es5/components/VSlider/VSlider.js +23 -18
  22. package/es5/components/VSlider/VSlider.js.map +1 -1
  23. package/es5/components/VTooltip/VTooltip.js +3 -7
  24. package/es5/components/VTooltip/VTooltip.js.map +1 -1
  25. package/es5/framework.js +1 -1
  26. package/lib/components/VBtn/VBtn.js +18 -19
  27. package/lib/components/VBtn/VBtn.js.map +1 -1
  28. package/lib/components/VColorPicker/VColorPicker.js +29 -37
  29. package/lib/components/VColorPicker/VColorPicker.js.map +1 -1
  30. package/lib/components/VColorPicker/VColorPickerCanvas.js +41 -43
  31. package/lib/components/VColorPicker/VColorPickerCanvas.js.map +1 -1
  32. package/lib/components/VColorPicker/VColorPickerEdit.js +25 -31
  33. package/lib/components/VColorPicker/VColorPickerEdit.js.map +1 -1
  34. package/lib/components/VColorPicker/VColorPickerPreview.js +45 -32
  35. package/lib/components/VColorPicker/VColorPickerPreview.js.map +1 -1
  36. package/lib/components/VColorPicker/VColorPickerSwatches.js +15 -9
  37. package/lib/components/VColorPicker/VColorPickerSwatches.js.map +1 -1
  38. package/lib/components/VDataTable/VDataTable.js +3 -4
  39. package/lib/components/VDataTable/VDataTable.js.map +1 -1
  40. package/lib/components/VInput/VInput.js +12 -4
  41. package/lib/components/VInput/VInput.js.map +1 -1
  42. package/lib/components/VSlider/VSlider.js +26 -21
  43. package/lib/components/VSlider/VSlider.js.map +1 -1
  44. package/lib/components/VTooltip/VTooltip.js +6 -9
  45. package/lib/components/VTooltip/VTooltip.js.map +1 -1
  46. package/lib/framework.js +1 -1
  47. package/package.json +1 -1
  48. package/src/components/VBtn/VBtn.ts +18 -16
  49. package/src/components/VBtn/__tests__/VBtn.spec.ts +257 -242
  50. package/src/components/VBtn/__tests__/__snapshots__/VBtn.spec.ts.snap +13 -73
  51. package/src/components/VColorPicker/VColorPicker.ts +32 -35
  52. package/src/components/VColorPicker/VColorPickerCanvas.ts +44 -37
  53. package/src/components/VColorPicker/VColorPickerEdit.ts +37 -35
  54. package/src/components/VColorPicker/VColorPickerPreview.ts +48 -28
  55. package/src/components/VColorPicker/VColorPickerSwatches.ts +23 -12
  56. package/src/components/VColorPicker/__tests__/VColorPicker.spec.ts +47 -47
  57. package/src/components/VColorPicker/__tests__/VColorPickerCanvas.spec.ts +15 -13
  58. package/src/components/VColorPicker/__tests__/VColorPickerEdit.spec.ts +52 -50
  59. package/src/components/VColorPicker/__tests__/VColorPickerPreview.spec.ts +101 -30
  60. package/src/components/VColorPicker/__tests__/__snapshots__/VColorPicker.spec.ts.snap +200 -157
  61. package/src/components/VColorPicker/__tests__/__snapshots__/VColorPickerEdit.spec.ts.snap +28 -11
  62. package/src/components/VDataTable/VDataTable.ts +3 -3
  63. package/src/components/VInput/VInput.ts +8 -2
  64. package/src/components/VInput/__tests__/VInput.spec.ts +170 -234
  65. package/src/components/VInput/__tests__/__snapshots__/VInput.spec.ts.snap +50 -101
  66. package/src/components/VSkeletonLoader/__tests__/VSkeletonLoader.spec.ts +22 -15
  67. package/src/components/VSkeletonLoader/__tests__/__snapshots__/VSkeletonLoader.spec.ts.snap +60 -60
  68. package/src/components/VSlider/VSlider.ts +43 -27
  69. package/src/components/VSlider/__tests__/VSlider.spec.ts +188 -286
  70. package/src/components/VSlider/__tests__/__snapshots__/VSlider.spec.ts.snap +157 -246
  71. package/src/components/VTabs/__tests__/VTab.spec.ts +3 -3
  72. package/src/components/VTabs/__tests__/VTabsBar.spec.ts +2 -2
  73. package/src/components/VTooltip/VTooltip.ts +20 -20
  74. package/src/components/VTooltip/__tests__/VTooltip.spec.ts +60 -75
@@ -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 mixins(Elevatable, Themeable).extend({
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
- data: () => ({
63
- internalValue: fromRGBA({ r: 255, g: 0, b: 0, a: 1 }),
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
- value: {
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: Mode) => this.$emit('update: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
- props: {
125
- color: this.internalValue,
126
- disabled: this.disabled,
127
- hideAlpha: this.hideAlpha,
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
- props: {
137
- dark: this.dark,
138
- light: this.light,
139
- disabled: this.disabled,
140
- swatches: this.swatches,
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
- props: {
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 { defineComponent, VNode, PropType } from 'vue'
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 (): { x: number, y: number} {
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': 'updateCanvas',
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
- const ctx = canvas.getContext('2d')
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
- attrs: {
126
- width: this.width,
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
- on: {
158
- click: this.handleClick,
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 { defineComponent, VNode, PropType } from 'vue'
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: Object as PropType<VColorPickerColor>,
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 this.modes[this.internalMode]
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 modes = Object.keys(this.modes)
98
- const index = modes.indexOf(this.internalMode)
99
- const newMode = modes[(index + 1) % modes.length]
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
- genInput (target: string, attrs: any, value: any, on: any): VNode {
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
- ...on,
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.hexa
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
- change: (e: Event) => {
129
- const el = e.target as HTMLInputElement
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
- input: (e: Event) => {
150
- const el = e.target as HTMLInputElement
151
- const newVal = this.parseValue(el.value || '0', type)
152
-
153
- this.$emit('update:color', this.currentMode.from(
154
- Object.assign({}, value, { [target]: newVal }),
155
- this.color.alpha
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 { defineComponent, VNode, VNodeData, PropType } from 'vue'
13
- import { VColorPickerColor, fromHSVA } from './util'
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: Object as PropType<VColorPickerColor>,
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
- value: this.color.alpha,
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.rtl ? 'left' : 'right'}, transparent, ${RGBtoCSS(this.color.rgba)})`,
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 {
@@ -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 mixins from '../../util/mixins'
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 mixins(Themeable).extend({
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: Object as PropType<VColorPickerColor>,
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
- on: {
75
- // TODO: Less hacky way of catching transparent
76
- click: () => this.disabled || this.$emit('update:color', fromHex(color === 'transparent' ? '#00000000' : color)),
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
- genSwatches () {
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),