@progress/kendo-vue-inputs 3.4.3 → 3.4.5-dev.202207300828
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/cdn/js/kendo-vue-inputs.js +1 -1
- package/dist/es/checkbox/Checkbox.js +3 -3
- package/dist/es/colors/ColorContrastLabels.js +8 -4
- package/dist/es/colors/ColorContrastSvg.js +65 -44
- package/dist/es/colors/ColorGradient.d.ts +3 -1
- package/dist/es/colors/ColorGradient.js +160 -57
- package/dist/es/colors/ColorInput.d.ts +3 -0
- package/dist/es/colors/ColorInput.js +82 -58
- package/dist/es/colors/ColorPalette.js +31 -17
- package/dist/es/colors/ColorPicker.d.ts +1 -0
- package/dist/es/colors/ColorPicker.js +90 -70
- package/dist/es/colors/FlatColorPicker.d.ts +41 -5
- package/dist/es/colors/FlatColorPicker.js +307 -110
- package/dist/es/colors/HexInput.d.ts +1 -0
- package/dist/es/colors/HexInput.js +33 -13
- package/dist/es/colors/Picker.js +20 -12
- package/dist/es/colors/interfaces/ColorGradientChangeEvent.d.ts +4 -0
- package/dist/es/colors/interfaces/ColorGradientProps.d.ts +12 -0
- package/dist/es/colors/interfaces/ColorPaletteChangeEvent.d.ts +0 -3
- package/dist/es/colors/interfaces/ColorPaletteProps.d.ts +8 -3
- package/dist/es/colors/interfaces/ColorPickerActiveColorClick.d.ts +0 -3
- package/dist/es/colors/interfaces/ColorPickerBlurEvent.d.ts +0 -3
- package/dist/es/colors/interfaces/ColorPickerChangeEvent.d.ts +4 -3
- package/dist/es/colors/interfaces/ColorPickerFocusEvent.d.ts +0 -3
- package/dist/es/colors/interfaces/ColorPickerPaletteSettings.d.ts +0 -3
- package/dist/es/colors/interfaces/ColorPickerPopupSettings.d.ts +0 -3
- package/dist/es/colors/interfaces/ColorPickerProps.d.ts +30 -4
- package/dist/es/colors/interfaces/ColorPickerView.d.ts +0 -3
- package/dist/es/colors/interfaces/FlatColorPickerViewChangeEvent.d.ts +13 -0
- package/dist/es/colors/interfaces/FlatColorPickerViewChangeEvent.js +0 -0
- package/dist/es/colors/interfaces/PickerProps.d.ts +4 -0
- package/dist/es/colors/utils/color-cache.d.ts +13 -0
- package/dist/es/colors/utils/color-cache.js +14 -0
- package/dist/es/colors/utils/color-parser.d.ts +7 -1
- package/dist/es/colors/utils/color-parser.js +11 -2
- package/dist/es/input/Input.d.ts +4 -0
- package/dist/es/input/Input.js +9 -4
- package/dist/es/input-separator/InputSeparator.js +1 -1
- package/dist/es/maskedtextbox/MaskedTextBox.js +1 -1
- package/dist/es/messages/index.d.ts +45 -0
- package/dist/es/messages/index.js +46 -0
- package/dist/es/numerictextbox/NumericTextBox.js +4 -1
- package/dist/es/numerictextbox/interfaces/NumericTextBoxProps.d.ts +4 -0
- package/dist/es/package-metadata.js +1 -1
- package/dist/es/radiobutton/RadioButton.js +2 -2
- package/dist/es/radiobutton/RadioGroup.js +2 -2
- package/dist/es/range-slider/RangeSlider.js +2 -2
- package/dist/es/slider/Slider.js +3 -3
- package/dist/es/slider/SliderLabel.js +1 -1
- package/dist/es/switch/Switch.js +1 -1
- package/dist/es/textarea/TextArea.js +1 -1
- package/dist/npm/checkbox/Checkbox.js +3 -3
- package/dist/npm/colors/ColorContrastLabels.js +8 -4
- package/dist/npm/colors/ColorContrastSvg.js +65 -44
- package/dist/npm/colors/ColorGradient.d.ts +3 -1
- package/dist/npm/colors/ColorGradient.js +161 -56
- package/dist/npm/colors/ColorInput.d.ts +3 -0
- package/dist/npm/colors/ColorInput.js +82 -57
- package/dist/npm/colors/ColorPalette.js +31 -17
- package/dist/npm/colors/ColorPicker.d.ts +1 -0
- package/dist/npm/colors/ColorPicker.js +91 -71
- package/dist/npm/colors/FlatColorPicker.d.ts +41 -5
- package/dist/npm/colors/FlatColorPicker.js +307 -107
- package/dist/npm/colors/HexInput.d.ts +1 -0
- package/dist/npm/colors/HexInput.js +31 -11
- package/dist/npm/colors/Picker.js +19 -11
- package/dist/npm/colors/interfaces/ColorGradientChangeEvent.d.ts +4 -0
- package/dist/npm/colors/interfaces/ColorGradientProps.d.ts +12 -0
- package/dist/npm/colors/interfaces/ColorPaletteChangeEvent.d.ts +0 -3
- package/dist/npm/colors/interfaces/ColorPaletteProps.d.ts +8 -3
- package/dist/npm/colors/interfaces/ColorPickerActiveColorClick.d.ts +0 -3
- package/dist/npm/colors/interfaces/ColorPickerBlurEvent.d.ts +0 -3
- package/dist/npm/colors/interfaces/ColorPickerChangeEvent.d.ts +4 -3
- package/dist/npm/colors/interfaces/ColorPickerFocusEvent.d.ts +0 -3
- package/dist/npm/colors/interfaces/ColorPickerPaletteSettings.d.ts +0 -3
- package/dist/npm/colors/interfaces/ColorPickerPopupSettings.d.ts +0 -3
- package/dist/npm/colors/interfaces/ColorPickerProps.d.ts +30 -4
- package/dist/npm/colors/interfaces/ColorPickerView.d.ts +0 -3
- package/dist/npm/colors/interfaces/FlatColorPickerViewChangeEvent.d.ts +13 -0
- package/dist/npm/colors/interfaces/FlatColorPickerViewChangeEvent.js +2 -0
- package/dist/npm/colors/interfaces/PickerProps.d.ts +4 -0
- package/dist/npm/colors/utils/color-cache.d.ts +13 -0
- package/dist/npm/colors/utils/color-cache.js +15 -1
- package/dist/npm/colors/utils/color-parser.d.ts +7 -1
- package/dist/npm/colors/utils/color-parser.js +12 -3
- package/dist/npm/input/Input.d.ts +4 -0
- package/dist/npm/input/Input.js +9 -4
- package/dist/npm/input-separator/InputSeparator.js +1 -1
- package/dist/npm/maskedtextbox/MaskedTextBox.js +1 -1
- package/dist/npm/messages/index.d.ts +45 -0
- package/dist/npm/messages/index.js +47 -1
- package/dist/npm/numerictextbox/NumericTextBox.js +4 -1
- package/dist/npm/numerictextbox/interfaces/NumericTextBoxProps.d.ts +4 -0
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/radiobutton/RadioButton.js +2 -2
- package/dist/npm/radiobutton/RadioGroup.js +2 -2
- package/dist/npm/range-slider/RangeSlider.js +2 -2
- package/dist/npm/slider/Slider.js +3 -3
- package/dist/npm/slider/SliderLabel.js +1 -1
- package/dist/npm/switch/Switch.js +1 -1
- package/dist/npm/textarea/TextArea.js +1 -1
- package/package.json +11 -11
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import * as Vue from 'vue';
|
|
3
3
|
var allVue = Vue;
|
|
4
4
|
var gh = allVue.h;
|
|
5
|
-
var isV3 = allVue.version[0] === '3';
|
|
6
|
-
import { Draggable, guid, classNames, focusFirstFocusableChild, getTabIndex } from '@progress/kendo-vue-common';
|
|
5
|
+
var isV3 = allVue.version && allVue.version[0] === '3';
|
|
6
|
+
import { Draggable, guid, classNames, focusFirstFocusableChild, getTabIndex, Keys, setRef, getRef, focusContainer } from '@progress/kendo-vue-common';
|
|
7
7
|
import { validatePackage } from '@progress/kendo-vue-common';
|
|
8
8
|
import { packageMetadata } from '../package-metadata';
|
|
9
9
|
import { Slider } from './../main';
|
|
@@ -13,6 +13,8 @@ import { cacheHsva, removeCachedColor, getCachedHsva, getCachedRgba, getCachedHe
|
|
|
13
13
|
import { ColorInput } from './ColorInput';
|
|
14
14
|
import { ColorContrastLabels } from './ColorContrastLabels';
|
|
15
15
|
import { ColorContrastSvg } from './ColorContrastSvg';
|
|
16
|
+
import { provideLocalizationService } from '@progress/kendo-vue-intl';
|
|
17
|
+
import { colorGradientDragHandle, messages } from '../messages';
|
|
16
18
|
var FORMAT = 'rgba';
|
|
17
19
|
var DEFAULT_SELECTED_COLOR = 'rgba(255, 255, 255, 1)';
|
|
18
20
|
/**
|
|
@@ -21,14 +23,27 @@ var DEFAULT_SELECTED_COLOR = 'rgba(255, 255, 255, 1)';
|
|
|
21
23
|
|
|
22
24
|
var ColorGradientVue2 = {
|
|
23
25
|
name: 'KendoColorGradient',
|
|
26
|
+
model: {
|
|
27
|
+
event: 'changemodel'
|
|
28
|
+
},
|
|
24
29
|
// @ts-ignore
|
|
25
30
|
emits: {
|
|
26
31
|
'change': null,
|
|
27
32
|
'focus': null,
|
|
28
33
|
'blur': null,
|
|
34
|
+
'changemodel': null,
|
|
35
|
+
'update:modelValue': null,
|
|
36
|
+
'update:modelRgbaValue': null,
|
|
29
37
|
'keydown': null
|
|
30
38
|
},
|
|
39
|
+
inject: {
|
|
40
|
+
kendoLocalizationService: {
|
|
41
|
+
default: null
|
|
42
|
+
}
|
|
43
|
+
},
|
|
31
44
|
props: {
|
|
45
|
+
modelValue: String,
|
|
46
|
+
modelRgbaValue: String,
|
|
32
47
|
defaultValue: String,
|
|
33
48
|
value: String,
|
|
34
49
|
opacity: {
|
|
@@ -39,7 +54,12 @@ var ColorGradientVue2 = {
|
|
|
39
54
|
disabled: Boolean,
|
|
40
55
|
id: String,
|
|
41
56
|
ariaLabelledBy: String,
|
|
42
|
-
ariaDescribedBy: String
|
|
57
|
+
ariaDescribedBy: String,
|
|
58
|
+
tabIndex: Number,
|
|
59
|
+
innerTabIndex: {
|
|
60
|
+
type: Number,
|
|
61
|
+
default: undefined
|
|
62
|
+
}
|
|
43
63
|
},
|
|
44
64
|
created: function created() {
|
|
45
65
|
validatePackage(packageMetadata);
|
|
@@ -50,9 +70,9 @@ var ColorGradientVue2 = {
|
|
|
50
70
|
return this.$props.value === undefined;
|
|
51
71
|
},
|
|
52
72
|
computedValue: function computedValue() {
|
|
53
|
-
var value = this.value || this.defaultValue || this.currentValue || parseColor(DEFAULT_SELECTED_COLOR, FORMAT);
|
|
73
|
+
var value = this.value || this.defaultValue || this.modelValue || this.modelRgbaValue || this.currentValue || parseColor(DEFAULT_SELECTED_COLOR, FORMAT);
|
|
54
74
|
|
|
55
|
-
if (!isPresent(parseColor(value, 'hex'))) {
|
|
75
|
+
if (!isPresent(parseColor(value, 'hex', this.opacity))) {
|
|
56
76
|
// Validate/sanitize the input.
|
|
57
77
|
value = DEFAULT_SELECTED_COLOR;
|
|
58
78
|
}
|
|
@@ -66,10 +86,13 @@ var ColorGradientVue2 = {
|
|
|
66
86
|
return this.currentRgba || getCachedRgba(this.guid, this.computedValue) || getRGBA(this.computedValue);
|
|
67
87
|
},
|
|
68
88
|
hex: function hex() {
|
|
69
|
-
return this.currentHex || getCachedHex(this.guid, this.computedValue) || parseColor(this.computedValue, 'hex');
|
|
89
|
+
return this.currentHex || getCachedHex(this.guid, this.computedValue) || parseColor(this.computedValue, 'hex', this.opacity);
|
|
70
90
|
},
|
|
71
91
|
computedBgColor: function computedBgColor() {
|
|
72
|
-
return this.
|
|
92
|
+
return this.currentBgColor || getColorFromHue(this.hsva.h);
|
|
93
|
+
},
|
|
94
|
+
computedTabIndex: function computedTabIndex() {
|
|
95
|
+
return this.innerTabIndex !== undefined ? this.innerTabIndex : this.focused ? 0 : -1;
|
|
73
96
|
}
|
|
74
97
|
},
|
|
75
98
|
data: function data() {
|
|
@@ -79,7 +102,8 @@ var ColorGradientVue2 = {
|
|
|
79
102
|
isFirstRender: true,
|
|
80
103
|
currentHsva: undefined,
|
|
81
104
|
currentRgba: undefined,
|
|
82
|
-
currentHex: undefined
|
|
105
|
+
currentHex: undefined,
|
|
106
|
+
focused: false
|
|
83
107
|
};
|
|
84
108
|
},
|
|
85
109
|
mounted: function mounted() {
|
|
@@ -100,8 +124,7 @@ var ColorGradientVue2 = {
|
|
|
100
124
|
removeCachedColor(this.guid);
|
|
101
125
|
},
|
|
102
126
|
updated: function updated() {
|
|
103
|
-
|
|
104
|
-
this.setAlphaSliderBackground(this.computedBgColor); // }
|
|
127
|
+
this.setAlphaSliderBackground(this.computedBgColor);
|
|
105
128
|
},
|
|
106
129
|
// @ts-ignore
|
|
107
130
|
setup: !isV3 ? undefined : function () {
|
|
@@ -120,6 +143,8 @@ var ColorGradientVue2 = {
|
|
|
120
143
|
var className = classNames('k-colorgradient', {
|
|
121
144
|
'k-disabled': this.$props.disabled
|
|
122
145
|
});
|
|
146
|
+
var localizationService = provideLocalizationService(this);
|
|
147
|
+
var dragHandle = localizationService.toLanguageString(colorGradientDragHandle, messages[colorGradientDragHandle]);
|
|
123
148
|
|
|
124
149
|
var renderRectangleDragHandle = function renderRectangleDragHandle() {
|
|
125
150
|
var style = {};
|
|
@@ -134,7 +159,24 @@ var ColorGradientVue2 = {
|
|
|
134
159
|
|
|
135
160
|
return h("div", {
|
|
136
161
|
"class": "k-hsv-draghandle k-draghandle",
|
|
137
|
-
|
|
162
|
+
role: "slider",
|
|
163
|
+
attrs: this.v3 ? undefined : {
|
|
164
|
+
role: "slider",
|
|
165
|
+
"aria-label": dragHandle + ("" + (this.value || 'none')),
|
|
166
|
+
"aria-valuenow": Math.round(this.hsva.s * 100),
|
|
167
|
+
"aria-valuetext": "\n saturation: " + Math.round(this.hsva.s * 100) + "%,\n value: " + Math.round(this.hsva.v * 100) + "%",
|
|
168
|
+
tabindex: this.computedTabIndex
|
|
169
|
+
},
|
|
170
|
+
"aria-label": dragHandle + ("" + (this.value || 'none')),
|
|
171
|
+
"aria-valuenow": Math.round(this.hsva.s * 100),
|
|
172
|
+
"aria-valuetext": "\n saturation: " + Math.round(this.hsva.s * 100) + "%,\n value: " + Math.round(this.hsva.v * 100) + "%",
|
|
173
|
+
tabindex: this.computedTabIndex,
|
|
174
|
+
onKeydown: this.dragKeyDown,
|
|
175
|
+
on: this.v3 ? undefined : {
|
|
176
|
+
"keydown": this.dragKeyDown
|
|
177
|
+
},
|
|
178
|
+
style: style,
|
|
179
|
+
ref: setRef(this, 'draghandle')
|
|
138
180
|
});
|
|
139
181
|
};
|
|
140
182
|
|
|
@@ -142,23 +184,25 @@ var ColorGradientVue2 = {
|
|
|
142
184
|
id: this.$props.id,
|
|
143
185
|
attrs: this.v3 ? undefined : {
|
|
144
186
|
id: this.$props.id,
|
|
145
|
-
|
|
187
|
+
role: this.$props.tabIndex !== -1 ? 'textbox' : undefined,
|
|
188
|
+
"aria-disabled": this.$props.disabled,
|
|
146
189
|
tabindex: getTabIndex(this.$props.tabIndex, this.$props.disabled),
|
|
147
190
|
"aria-labelledby": this.$props.ariaLabelledBy,
|
|
148
191
|
"aria-describedby": this.$props.ariaDescribedBy
|
|
149
192
|
},
|
|
150
193
|
"class": className,
|
|
151
|
-
|
|
194
|
+
role: this.$props.tabIndex !== -1 ? 'textbox' : undefined,
|
|
195
|
+
"aria-disabled": this.$props.disabled,
|
|
152
196
|
tabindex: getTabIndex(this.$props.tabIndex, this.$props.disabled),
|
|
153
197
|
"aria-labelledby": this.$props.ariaLabelledBy,
|
|
154
198
|
"aria-describedby": this.$props.ariaDescribedBy,
|
|
155
|
-
|
|
199
|
+
onFocusin: this.onFocus,
|
|
156
200
|
on: this.v3 ? undefined : {
|
|
157
|
-
"
|
|
158
|
-
"
|
|
201
|
+
"focusin": this.onFocus,
|
|
202
|
+
"focusout": this.onBlur,
|
|
159
203
|
"keydown": this.onKeyDownHandler
|
|
160
204
|
},
|
|
161
|
-
|
|
205
|
+
onFocusout: this.onBlur,
|
|
162
206
|
onKeydown: this.onKeyDownHandler
|
|
163
207
|
}, [h("div", {
|
|
164
208
|
"class": "k-colorgradient-canvas k-hstack"
|
|
@@ -182,6 +226,10 @@ var ColorGradientVue2 = {
|
|
|
182
226
|
style: {
|
|
183
227
|
touchAction: 'none'
|
|
184
228
|
},
|
|
229
|
+
tabindex: -1,
|
|
230
|
+
attrs: _this2.v3 ? undefined : {
|
|
231
|
+
tabindex: -1
|
|
232
|
+
},
|
|
185
233
|
onClick: _this2.onGradientWrapperClick,
|
|
186
234
|
on: _this2.v3 ? undefined : {
|
|
187
235
|
"click": _this2.onGradientWrapperClick
|
|
@@ -192,24 +240,29 @@ var ColorGradientVue2 = {
|
|
|
192
240
|
style: {
|
|
193
241
|
touchAction: 'none'
|
|
194
242
|
},
|
|
243
|
+
tabindex: -1,
|
|
244
|
+
attrs: _this2.v3 ? undefined : {
|
|
245
|
+
tabindex: -1
|
|
246
|
+
},
|
|
195
247
|
onClick: _this2.onGradientWrapperClick,
|
|
196
248
|
on: _this2.v3 ? undefined : {
|
|
197
249
|
"click": _this2.onGradientWrapperClick
|
|
198
250
|
}
|
|
199
|
-
}, [renderRectangleDragHandle.call(_this2)])]), this.
|
|
251
|
+
}, [renderRectangleDragHandle.call(_this2)])]), this.backgroundColor && !this.isFirstRender && h(ColorContrastSvg, {
|
|
200
252
|
metrics: this.gradientWrapper ? this.getGradientRectMetrics() : undefined,
|
|
201
253
|
attrs: this.v3 ? undefined : {
|
|
202
254
|
metrics: this.gradientWrapper ? this.getGradientRectMetrics() : undefined,
|
|
203
255
|
hsva: this.hsva,
|
|
204
|
-
backgroundColor: this.
|
|
256
|
+
backgroundColor: this.backgroundColor
|
|
205
257
|
},
|
|
206
258
|
hsva: this.hsva,
|
|
207
|
-
backgroundColor: this.
|
|
259
|
+
backgroundColor: this.backgroundColor
|
|
208
260
|
})]), h("div", {
|
|
209
261
|
"class": "k-hsv-controls k-hstack"
|
|
210
262
|
}, [h(Slider, {
|
|
211
|
-
|
|
263
|
+
tabIndex: this.computedTabIndex,
|
|
212
264
|
attrs: this.v3 ? undefined : {
|
|
265
|
+
tabIndex: this.computedTabIndex,
|
|
213
266
|
value: this.hsva.h,
|
|
214
267
|
buttons: false,
|
|
215
268
|
vertical: true,
|
|
@@ -218,6 +271,7 @@ var ColorGradientVue2 = {
|
|
|
218
271
|
step: 5,
|
|
219
272
|
disabled: this.$props.disabled
|
|
220
273
|
},
|
|
274
|
+
value: this.hsva.h,
|
|
221
275
|
buttons: false,
|
|
222
276
|
vertical: true,
|
|
223
277
|
min: 0,
|
|
@@ -225,17 +279,14 @@ var ColorGradientVue2 = {
|
|
|
225
279
|
step: 5,
|
|
226
280
|
onChange: this.onHueSliderChange,
|
|
227
281
|
on: this.v3 ? undefined : {
|
|
228
|
-
"change": this.onHueSliderChange
|
|
229
|
-
"focus": this.onFocus,
|
|
230
|
-
"blur": this.onBlur
|
|
282
|
+
"change": this.onHueSliderChange
|
|
231
283
|
},
|
|
232
|
-
onFocus: this.onFocus,
|
|
233
|
-
onBlur: this.onBlur,
|
|
234
284
|
"class": "k-hue-slider k-colorgradient-slider",
|
|
235
285
|
disabled: this.$props.disabled
|
|
236
286
|
}), this.$props.opacity && h(Slider, {
|
|
237
|
-
|
|
287
|
+
tabIndex: this.computedTabIndex,
|
|
238
288
|
attrs: this.v3 ? undefined : {
|
|
289
|
+
tabIndex: this.computedTabIndex,
|
|
239
290
|
value: isPresent(this.hsva.a) ? this.hsva.a * 100 : 100,
|
|
240
291
|
buttons: false,
|
|
241
292
|
vertical: true,
|
|
@@ -244,6 +295,7 @@ var ColorGradientVue2 = {
|
|
|
244
295
|
step: 1,
|
|
245
296
|
disabled: this.$props.disabled
|
|
246
297
|
},
|
|
298
|
+
value: isPresent(this.hsva.a) ? this.hsva.a * 100 : 100,
|
|
247
299
|
buttons: false,
|
|
248
300
|
vertical: true,
|
|
249
301
|
min: 0,
|
|
@@ -251,77 +303,73 @@ var ColorGradientVue2 = {
|
|
|
251
303
|
step: 1,
|
|
252
304
|
onChange: this.onAlphaSliderChange,
|
|
253
305
|
on: this.v3 ? undefined : {
|
|
254
|
-
"change": this.onAlphaSliderChange
|
|
255
|
-
"focus": this.onFocus,
|
|
256
|
-
"blur": this.onBlur
|
|
306
|
+
"change": this.onAlphaSliderChange
|
|
257
307
|
},
|
|
258
|
-
onFocus: this.onFocus,
|
|
259
|
-
onBlur: this.onBlur,
|
|
260
308
|
"class": "k-alpha-slider k-colorgradient-slider",
|
|
261
309
|
disabled: this.$props.disabled,
|
|
262
310
|
ref: this.v3 ? function (el) {
|
|
263
311
|
_this.alphaSliderRef = el;
|
|
264
312
|
} : 'alphaSlider'
|
|
265
313
|
})])]), h(ColorInput, {
|
|
266
|
-
|
|
314
|
+
tabIndex: this.computedTabIndex,
|
|
267
315
|
attrs: this.v3 ? undefined : {
|
|
316
|
+
tabIndex: this.computedTabIndex,
|
|
268
317
|
rgba: this.rgba,
|
|
269
318
|
hex: this.hex,
|
|
270
319
|
opacity: this.$props.opacity,
|
|
271
320
|
disabled: this.$props.disabled
|
|
272
321
|
},
|
|
322
|
+
rgba: this.rgba,
|
|
273
323
|
onRgbachange: this.onRgbaChange,
|
|
274
324
|
on: this.v3 ? undefined : {
|
|
275
325
|
"rgbachange": this.onRgbaChange,
|
|
276
|
-
"focus": this.onFocus,
|
|
277
|
-
"blur": this.onBlur,
|
|
278
326
|
"hexchange": this.onHexChange
|
|
279
327
|
},
|
|
280
328
|
hex: this.hex,
|
|
281
|
-
onFocus: this.onFocus,
|
|
282
|
-
onBlur: this.onBlur,
|
|
283
329
|
onHexchange: this.onHexChange,
|
|
284
330
|
opacity: this.$props.opacity,
|
|
285
|
-
disabled: this.$props.disabled
|
|
286
|
-
|
|
287
|
-
|
|
331
|
+
disabled: this.$props.disabled,
|
|
332
|
+
ref: 'colorInput'
|
|
333
|
+
}), this.backgroundColor && h(ColorContrastLabels, {
|
|
334
|
+
bgColor: getRGBA(this.backgroundColor),
|
|
288
335
|
attrs: this.v3 ? undefined : {
|
|
289
|
-
bgColor: getRGBA(this.
|
|
336
|
+
bgColor: getRGBA(this.backgroundColor),
|
|
290
337
|
rgba: this.rgba
|
|
291
338
|
},
|
|
292
339
|
rgba: this.rgba
|
|
293
340
|
})]);
|
|
294
341
|
},
|
|
295
342
|
methods: {
|
|
296
|
-
// getDerivedStateFromProps(props: ColorGradientProps, state: ColorGradientState) {
|
|
297
|
-
// if (props.value && !state.isFirstRender) {
|
|
298
|
-
// // The component is in controlled mode.
|
|
299
|
-
// return ColorGradientWithoutContext.getStateFromValue(props.value, state.guid);
|
|
300
|
-
// }
|
|
301
|
-
// return null;
|
|
302
|
-
// },
|
|
303
343
|
onKeyDownHandler: function onKeyDownHandler(e) {
|
|
344
|
+
var element = this.$el;
|
|
345
|
+
|
|
346
|
+
if (this.innerTabIndex === undefined) {
|
|
347
|
+
this.focused = focusContainer(e, element);
|
|
348
|
+
}
|
|
349
|
+
|
|
304
350
|
this.$emit('keydown', e);
|
|
305
351
|
},
|
|
306
352
|
onHexChange: function onHexChange(hex, value, event) {
|
|
353
|
+
var rgba = getRGBA(value);
|
|
354
|
+
|
|
307
355
|
if (this.isUncontrolled) {
|
|
308
356
|
var hsva = getHSV(value);
|
|
309
357
|
this.currentHsva = hsva;
|
|
310
358
|
this.currentBgColor = getColorFromHue(hsva.h);
|
|
311
|
-
this.currentRgba =
|
|
359
|
+
this.currentRgba = rgba;
|
|
312
360
|
this.currentHex = hex;
|
|
313
361
|
} else {
|
|
314
362
|
cacheHex(this.guid, value, hex);
|
|
315
363
|
}
|
|
316
364
|
|
|
317
|
-
this.dispatchChangeEvent(value, event,
|
|
365
|
+
this.dispatchChangeEvent(value, event.event, hex, value);
|
|
318
366
|
},
|
|
319
367
|
onRgbaChange: function onRgbaChange(rgba, event) {
|
|
320
368
|
var value = getColorFromRGBA(rgba);
|
|
369
|
+
var hex = parseColor(value, 'hex', this.opacity);
|
|
321
370
|
|
|
322
371
|
if (this.isUncontrolled) {
|
|
323
372
|
var hsva = getHSV(value);
|
|
324
|
-
var hex = parseColor(value, 'hex');
|
|
325
373
|
this.currentHsva = hsva;
|
|
326
374
|
this.currentBgColor = getColorFromHue(hsva.h);
|
|
327
375
|
this.currentRgba = rgba;
|
|
@@ -330,7 +378,7 @@ var ColorGradientVue2 = {
|
|
|
330
378
|
cacheRgba(this.guid, value, rgba);
|
|
331
379
|
}
|
|
332
380
|
|
|
333
|
-
this.dispatchChangeEvent(value, event.event);
|
|
381
|
+
this.dispatchChangeEvent(value, event.event, hex, value);
|
|
334
382
|
},
|
|
335
383
|
onAlphaSliderChange: function onAlphaSliderChange(event) {
|
|
336
384
|
this.handleHsvaChange(Object.assign({}, this.hsva, {
|
|
@@ -350,8 +398,53 @@ var ColorGradientVue2 = {
|
|
|
350
398
|
this.gradientWrapper.classList.remove('k-dragging');
|
|
351
399
|
},
|
|
352
400
|
onGradientWrapperClick: function onGradientWrapperClick(event) {
|
|
401
|
+
this.firstFocusable = getRef(this, 'draghandle');
|
|
402
|
+
this.firstFocusable.focus();
|
|
353
403
|
this.changePosition(event);
|
|
354
404
|
},
|
|
405
|
+
move: function move(e, prop, d) {
|
|
406
|
+
var c = this.hsva;
|
|
407
|
+
c[prop] += d * (e.shiftKey ? 0.01 : 0.05);
|
|
408
|
+
|
|
409
|
+
if (c[prop] < 0) {
|
|
410
|
+
c[prop] = 0;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (c[prop] > 1) {
|
|
414
|
+
c[prop] = 1;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
e.preventDefault();
|
|
418
|
+
this.handleHsvaChange(c, e);
|
|
419
|
+
},
|
|
420
|
+
dragKeyDown: function dragKeyDown(e) {
|
|
421
|
+
switch (e.keyCode) {
|
|
422
|
+
case Keys.left:
|
|
423
|
+
this.move(e, 's', -1);
|
|
424
|
+
break;
|
|
425
|
+
|
|
426
|
+
case Keys.right:
|
|
427
|
+
this.move(e, 's', 1);
|
|
428
|
+
break;
|
|
429
|
+
|
|
430
|
+
case Keys.up:
|
|
431
|
+
this.move(e, 'v', 1);
|
|
432
|
+
break;
|
|
433
|
+
|
|
434
|
+
case Keys.down:
|
|
435
|
+
this.move(e, 'v', -1);
|
|
436
|
+
break;
|
|
437
|
+
|
|
438
|
+
case Keys.enter:
|
|
439
|
+
break;
|
|
440
|
+
|
|
441
|
+
case Keys.esc:
|
|
442
|
+
break;
|
|
443
|
+
|
|
444
|
+
default:
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
},
|
|
355
448
|
changePosition: function changePosition(event) {
|
|
356
449
|
var gradientRectMetrics = this.getGradientRectMetrics();
|
|
357
450
|
var deltaX = event.clientX - gradientRectMetrics.left;
|
|
@@ -366,9 +459,10 @@ var ColorGradientVue2 = {
|
|
|
366
459
|
},
|
|
367
460
|
handleHsvaChange: function handleHsvaChange(hsva, event) {
|
|
368
461
|
var value = getColorFromHSV(hsva);
|
|
462
|
+
var hex = parseColor(value, 'hex', this.opacity);
|
|
463
|
+
var rgba = parseColor(value, 'rgba');
|
|
369
464
|
|
|
370
465
|
if (this.isUncontrolled) {
|
|
371
|
-
var hex = parseColor(value, 'hex');
|
|
372
466
|
this.currentHsva = hsva;
|
|
373
467
|
this.currentBgColor = getColorFromHue(hsva.h);
|
|
374
468
|
this.currentRgba = getRGBA(value);
|
|
@@ -377,14 +471,18 @@ var ColorGradientVue2 = {
|
|
|
377
471
|
cacheHsva(this.guid, value, hsva);
|
|
378
472
|
}
|
|
379
473
|
|
|
380
|
-
this.dispatchChangeEvent(value, event);
|
|
474
|
+
this.dispatchChangeEvent(value, event, hex, rgba);
|
|
381
475
|
},
|
|
382
|
-
dispatchChangeEvent: function dispatchChangeEvent(value, event) {
|
|
476
|
+
dispatchChangeEvent: function dispatchChangeEvent(value, event, hex, rgbaValue) {
|
|
383
477
|
this.currentValue = value;
|
|
478
|
+
this.$emit('changemodel', hex);
|
|
479
|
+
this.$emit('update:modelRgbaValue', rgbaValue);
|
|
480
|
+
this.$emit('update:modelValue', hex);
|
|
384
481
|
this.$emit('change', {
|
|
385
482
|
event: event,
|
|
386
483
|
target: this,
|
|
387
|
-
value:
|
|
484
|
+
value: hex,
|
|
485
|
+
rgbaValue: rgbaValue
|
|
388
486
|
});
|
|
389
487
|
},
|
|
390
488
|
onFocus: function onFocus(event) {
|
|
@@ -418,7 +516,12 @@ var ColorGradientVue2 = {
|
|
|
418
516
|
};
|
|
419
517
|
},
|
|
420
518
|
focus: function focus() {
|
|
421
|
-
|
|
519
|
+
var _this = this;
|
|
520
|
+
|
|
521
|
+
this.focused = true;
|
|
522
|
+
setTimeout(function () {
|
|
523
|
+
focusFirstFocusableChild(_this.$el);
|
|
524
|
+
}, 1);
|
|
422
525
|
}
|
|
423
526
|
}
|
|
424
527
|
};
|
|
@@ -9,6 +9,7 @@ import { RGBA } from './models/rgba';
|
|
|
9
9
|
* @hidden
|
|
10
10
|
*/
|
|
11
11
|
export interface ColorInputProps {
|
|
12
|
+
tabIndex?: number;
|
|
12
13
|
rgba: RGBA;
|
|
13
14
|
onRgbaChange?: (rgba: RGBA, event: NumericTextBoxChangeEvent) => void;
|
|
14
15
|
hex: string;
|
|
@@ -20,6 +21,8 @@ export interface ColorInputProps {
|
|
|
20
21
|
* @hidden
|
|
21
22
|
*/
|
|
22
23
|
export interface ColorInputState {
|
|
24
|
+
lastFocusable: any;
|
|
25
|
+
hexInputId: string;
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* @hidden
|