@progress/kendo-vue-inputs 3.4.0 → 3.4.1-dev.202206280838

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 (50) hide show
  1. package/dist/cdn/js/kendo-vue-inputs.js +1 -1
  2. package/dist/es/colors/ColorContrastLabels.d.ts +49 -0
  3. package/dist/es/colors/ColorContrastLabels.js +79 -0
  4. package/dist/es/colors/ColorContrastSvg.d.ts +50 -0
  5. package/dist/es/colors/ColorContrastSvg.js +108 -0
  6. package/dist/es/colors/ColorGradient.d.ts +51 -0
  7. package/dist/es/colors/ColorGradient.js +407 -0
  8. package/dist/es/colors/ColorInput.d.ts +54 -0
  9. package/dist/es/colors/ColorInput.js +268 -0
  10. package/dist/es/colors/FlatColorPicker.d.ts +103 -0
  11. package/dist/es/colors/FlatColorPicker.js +294 -0
  12. package/dist/es/colors/HexInput.d.ts +51 -0
  13. package/dist/es/colors/HexInput.js +71 -0
  14. package/dist/es/colors/interfaces/ColorGradientChangeEvent.d.ts +9 -0
  15. package/dist/es/colors/interfaces/ColorGradientChangeEvent.js +0 -0
  16. package/dist/es/colors/interfaces/ColorGradientProps.d.ts +56 -0
  17. package/dist/es/colors/interfaces/ColorGradientProps.js +0 -0
  18. package/dist/es/main.d.ts +1 -0
  19. package/dist/es/main.js +1 -0
  20. package/dist/es/messages/index.d.ts +15 -0
  21. package/dist/es/messages/index.js +15 -0
  22. package/dist/es/numerictextbox/NumericTextBox.d.ts +4 -0
  23. package/dist/es/package-metadata.js +1 -1
  24. package/dist/es/range-slider/RangeSlider.js +2 -2
  25. package/dist/es/slider/Slider.d.ts +4 -0
  26. package/dist/npm/colors/ColorContrastLabels.d.ts +49 -0
  27. package/dist/npm/colors/ColorContrastLabels.js +91 -0
  28. package/dist/npm/colors/ColorContrastSvg.d.ts +50 -0
  29. package/dist/npm/colors/ColorContrastSvg.js +119 -0
  30. package/dist/npm/colors/ColorGradient.d.ts +51 -0
  31. package/dist/npm/colors/ColorGradient.js +426 -0
  32. package/dist/npm/colors/ColorInput.d.ts +54 -0
  33. package/dist/npm/colors/ColorInput.js +283 -0
  34. package/dist/npm/colors/FlatColorPicker.d.ts +103 -0
  35. package/dist/npm/colors/FlatColorPicker.js +309 -0
  36. package/dist/npm/colors/HexInput.d.ts +51 -0
  37. package/dist/npm/colors/HexInput.js +83 -0
  38. package/dist/npm/colors/interfaces/ColorGradientChangeEvent.d.ts +9 -0
  39. package/dist/npm/colors/interfaces/ColorGradientChangeEvent.js +2 -0
  40. package/dist/npm/colors/interfaces/ColorGradientProps.d.ts +56 -0
  41. package/dist/npm/colors/interfaces/ColorGradientProps.js +2 -0
  42. package/dist/npm/main.d.ts +1 -0
  43. package/dist/npm/main.js +1 -0
  44. package/dist/npm/messages/index.d.ts +15 -0
  45. package/dist/npm/messages/index.js +16 -1
  46. package/dist/npm/numerictextbox/NumericTextBox.d.ts +4 -0
  47. package/dist/npm/package-metadata.js +1 -1
  48. package/dist/npm/range-slider/RangeSlider.js +2 -2
  49. package/dist/npm/slider/Slider.d.ts +4 -0
  50. package/package.json +11 -11
@@ -0,0 +1,407 @@
1
+ var __assign = this && this.__assign || function () {
2
+ __assign = Object.assign || function (t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+
6
+ for (var p in s) {
7
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
+ }
9
+ }
10
+
11
+ return t;
12
+ };
13
+
14
+ return __assign.apply(this, arguments);
15
+ }; // @ts-ignore
16
+
17
+
18
+ import * as Vue from 'vue';
19
+ var allVue = Vue;
20
+ var gh = allVue.h;
21
+ import { Draggable, guid, classNames, focusFirstFocusableChild, getTabIndex } from '@progress/kendo-vue-common';
22
+ import { validatePackage } from '@progress/kendo-vue-common';
23
+ import { packageMetadata } from '../package-metadata';
24
+ import { Slider } from './../main';
25
+ import { fitIntoBounds, isPresent } from './utils/misc';
26
+ import { getColorFromHue, parseColor, getHSV, getColorFromHSV, getRGBA, getColorFromRGBA } from './utils/color-parser';
27
+ import { cacheHsva, removeCachedColor, getCachedHsva, getCachedRgba, getCachedHex, cacheRgba, cacheHex } from './utils/color-cache';
28
+ import { ColorInput } from './ColorInput';
29
+ import { ColorContrastLabels } from './ColorContrastLabels';
30
+ import { ColorContrastSvg } from './ColorContrastSvg';
31
+ var FORMAT = 'rgba';
32
+ var DEFAULT_SELECTED_COLOR = 'rgba(255, 255, 255, 1)';
33
+ /**
34
+ * @hidden
35
+ */
36
+
37
+ var ColorGradientVue2 = {
38
+ name: 'KendoColorGradient',
39
+ // @ts-ignore
40
+ emits: {
41
+ 'change': null,
42
+ 'focus': null
43
+ },
44
+ props: {
45
+ defaultValue: String,
46
+ value: String,
47
+ opacity: {
48
+ type: Boolean,
49
+ default: true
50
+ },
51
+ backgroundColor: String,
52
+ disabled: Boolean,
53
+ id: String,
54
+ ariaLabelledBy: String,
55
+ ariaDescribedBy: String
56
+ },
57
+ created: function created() {
58
+ validatePackage(packageMetadata);
59
+ this.guid = guid();
60
+ },
61
+ computed: {
62
+ isUncontrolled: function isUncontrolled() {
63
+ return this.$props.value === undefined;
64
+ },
65
+ computedValue: function computedValue() {
66
+ var value = this.value || this.defaultValue || parseColor(DEFAULT_SELECTED_COLOR, FORMAT);
67
+
68
+ if (!isPresent(parseColor(this.value, 'hex'))) {
69
+ // Validate/sanitize the input.
70
+ value = DEFAULT_SELECTED_COLOR;
71
+ }
72
+
73
+ return value;
74
+ },
75
+ hsva: function hsva() {
76
+ return getCachedHsva(this.guid, this.computedValue) || getHSV(this.computedValue);
77
+ },
78
+ rgba: function rgba() {
79
+ return getCachedRgba(this.guid, this.computedValue) || getRGBA(this.computedValue);
80
+ },
81
+ hex: function hex() {
82
+ return getCachedHex(this.guid, this.computedValue) || parseColor(this.computedValue, 'hex');
83
+ },
84
+ computedBgColor: function computedBgColor() {
85
+ return this.backgroundColor !== undefined ? this.backgroundColor : this.currentBgColor || getColorFromHue(this.hsva.h);
86
+ }
87
+ },
88
+ data: function data() {
89
+ return {
90
+ currentBgColor: undefined,
91
+ isFirstRender: true
92
+ };
93
+ },
94
+ mounted: function mounted() {
95
+ this.setAlphaSliderBackground(this.computedBgColor);
96
+
97
+ if (this.$el) {
98
+ this.draggable = this.$refs.draggable;
99
+ this.gradientWrapper = this.draggable && this.draggable.element;
100
+ }
101
+
102
+ this.alphaSlider = this.v3 ? this.alphaSliderRef : this.$refs.alphaSlider;
103
+
104
+ if (this.isFirstRender) {
105
+ this.isFirstRender = false;
106
+ }
107
+ },
108
+ destroyed: function destroyed() {
109
+ removeCachedColor(this.guid);
110
+ },
111
+ updated: function updated() {// if (prevState.backgroundColor !== this.backgroundColor) {
112
+ // this.setAlphaSliderBackground(this.backgroundColor);
113
+ // }
114
+ },
115
+ // private alphaSlider: any;
116
+ // @ts-ignore
117
+ setup: !gh ? undefined : function () {
118
+ var v3 = !!gh;
119
+ return {
120
+ v3: v3
121
+ };
122
+ },
123
+ // @ts-ignore
124
+ render: function render(createElement) {
125
+ var _this2 = this;
126
+
127
+ var _this = this;
128
+
129
+ var h = gh || createElement;
130
+ var className = classNames('k-colorgradient', {
131
+ 'k-disabled': this.$props.disabled
132
+ });
133
+
134
+ var renderRectangleDragHandle = function renderRectangleDragHandle() {
135
+ var style = {};
136
+
137
+ if (!this.isFirstRender) {
138
+ var gradientRectMetrics = this.getGradientRectMetrics();
139
+ var top_1 = (1 - this.hsva.v) * gradientRectMetrics.height;
140
+ var left = this.hsva.s * gradientRectMetrics.width;
141
+ style.top = top_1 + "px";
142
+ style.left = left + "px";
143
+ }
144
+
145
+ return h("div", {
146
+ "class": "k-hsv-draghandle k-draghandle",
147
+ style: style
148
+ });
149
+ };
150
+
151
+ return h("div", {
152
+ id: this.$props.id,
153
+ attrs: this.v3 ? undefined : {
154
+ id: this.$props.id,
155
+ "aria-disabled": this.$props.disabled ? 'true' : undefined,
156
+ tabIndex: getTabIndex(this.$props.tabIndex, this.$props.disabled),
157
+ "aria-labelledby": this.$props.ariaLabelledBy,
158
+ "aria-describedby": this.$props.ariaDescribedBy
159
+ },
160
+ "class": className,
161
+ "aria-disabled": this.$props.disabled ? 'true' : undefined,
162
+ tabIndex: getTabIndex(this.$props.tabIndex, this.$props.disabled),
163
+ "aria-labelledby": this.$props.ariaLabelledBy,
164
+ "aria-describedby": this.$props.ariaDescribedBy,
165
+ onFocus: this.onFocus,
166
+ on: this.v3 ? undefined : {
167
+ "focus": this.onFocus
168
+ }
169
+ }, [h("div", {
170
+ "class": "k-colorgradient-canvas k-hstack"
171
+ }, [h("div", {
172
+ "class": "k-hsv-rectangle",
173
+ style: {
174
+ background: this.computedBgColor
175
+ }
176
+ }, [// @ts-ignore function children
177
+ h(Draggable, {
178
+ onDrag: this.onDrag,
179
+ on: this.v3 ? undefined : {
180
+ "drag": this.onDrag,
181
+ "release": this.onRelease
182
+ },
183
+ onRelease: this.onRelease,
184
+ ref: 'draggable'
185
+ }, this.v3 ? function () {
186
+ return [h("div", {
187
+ "class": "k-hsv-gradient",
188
+ style: {
189
+ touchAction: 'none'
190
+ },
191
+ onClick: _this2.onGradientWrapperClick,
192
+ on: _this2.v3 ? undefined : {
193
+ "click": _this2.onGradientWrapperClick
194
+ }
195
+ }, [renderRectangleDragHandle.call(_this2)])];
196
+ } : [h("div", {
197
+ "class": "k-hsv-gradient",
198
+ style: {
199
+ touchAction: 'none'
200
+ },
201
+ onClick: _this2.onGradientWrapperClick,
202
+ on: _this2.v3 ? undefined : {
203
+ "click": _this2.onGradientWrapperClick
204
+ }
205
+ }, [renderRectangleDragHandle.call(_this2)])]), this.computedBgColor && !this.isFirstRender && h(ColorContrastSvg, {
206
+ metrics: this.gradientWrapper ? this.getGradientRectMetrics() : undefined,
207
+ attrs: this.v3 ? undefined : {
208
+ metrics: this.gradientWrapper ? this.getGradientRectMetrics() : undefined,
209
+ hsva: this.hsva,
210
+ backgroundColor: this.computedBgColor
211
+ },
212
+ hsva: this.hsva,
213
+ backgroundColor: this.computedBgColor
214
+ })]), h("div", {
215
+ "class": "k-hsv-controls k-hstack"
216
+ }, [h(Slider, {
217
+ value: this.hsva.h,
218
+ attrs: this.v3 ? undefined : {
219
+ value: this.hsva.h,
220
+ buttons: false,
221
+ vertical: true,
222
+ min: 0,
223
+ max: 360,
224
+ step: 5,
225
+ disabled: this.$props.disabled
226
+ },
227
+ buttons: false,
228
+ vertical: true,
229
+ min: 0,
230
+ max: 360,
231
+ step: 5,
232
+ onChange: this.onHueSliderChange,
233
+ on: this.v3 ? undefined : {
234
+ "change": this.onHueSliderChange
235
+ },
236
+ "class": "k-hue-slider k-colorgradient-slider",
237
+ disabled: this.$props.disabled
238
+ }), this.$props.opacity && h(Slider, {
239
+ value: isPresent(this.hsva.a) ? this.hsva.a * 100 : 100,
240
+ attrs: this.v3 ? undefined : {
241
+ value: isPresent(this.hsva.a) ? this.hsva.a * 100 : 100,
242
+ buttons: false,
243
+ vertical: true,
244
+ min: 0,
245
+ max: 100,
246
+ step: 1,
247
+ disabled: this.$props.disabled
248
+ },
249
+ buttons: false,
250
+ vertical: true,
251
+ min: 0,
252
+ max: 100,
253
+ step: 1,
254
+ onChange: this.onAlphaSliderChange,
255
+ on: this.v3 ? undefined : {
256
+ "change": this.onAlphaSliderChange
257
+ },
258
+ "class": "k-alpha-slider k-colorgradient-slider",
259
+ disabled: this.$props.disabled,
260
+ ref: this.v3 ? function (el) {
261
+ _this.alphaSliderRef = el;
262
+ } : 'alphaSlider'
263
+ })])]), h(ColorInput, {
264
+ rgba: this.rgba,
265
+ attrs: this.v3 ? undefined : {
266
+ rgba: this.rgba,
267
+ hex: this.hex,
268
+ opacity: this.$props.opacity,
269
+ disabled: this.$props.disabled
270
+ },
271
+ onRgbaChange: this.onRgbaChange,
272
+ on: this.v3 ? undefined : {
273
+ "rgbaChange": this.onRgbaChange,
274
+ "hexChange": this.onHexChange
275
+ },
276
+ hex: this.hex,
277
+ onHexChange: this.onHexChange,
278
+ opacity: this.$props.opacity,
279
+ disabled: this.$props.disabled
280
+ }), this.computedBgColor && h(ColorContrastLabels, {
281
+ bgColor: getRGBA(this.computedBgColor),
282
+ attrs: this.v3 ? undefined : {
283
+ bgColor: getRGBA(this.computedBgColor),
284
+ rgba: this.rgba
285
+ },
286
+ rgba: this.rgba
287
+ })]);
288
+ },
289
+ methods: {
290
+ // getDerivedStateFromProps(props: ColorGradientProps, state: ColorGradientState) {
291
+ // if (props.value && !state.isFirstRender) {
292
+ // // The component is in controlled mode.
293
+ // return ColorGradientWithoutContext.getStateFromValue(props.value, state.guid);
294
+ // }
295
+ // return null;
296
+ // },
297
+ onHexChange: function onHexChange(hex, value, event) {
298
+ if (this.isUncontrolled) {
299
+ var hsva = getHSV(value);
300
+ this.hsva = hsva;
301
+ this.cu = getColorFromHue(hsva.h);
302
+ this.rgba = getRGBA(value);
303
+ this.hex = hex;
304
+ } else {
305
+ cacheHex(this.guid, value, hex);
306
+ }
307
+
308
+ this.dispatchChangeEvent(value, event, event.nativeEvent);
309
+ },
310
+ onRgbaChange: function onRgbaChange(rgba, event) {
311
+ var value = getColorFromRGBA(rgba);
312
+
313
+ if (this.isUncontrolled) {
314
+ var hsva = getHSV(value);
315
+ var hex = parseColor(value, 'hex');
316
+ this.hsva = hsva;
317
+ this.currentBgColor = getColorFromHue(hsva.h);
318
+ this.rgba = rgba;
319
+ this.hex = hex;
320
+ } else {
321
+ cacheRgba(this.guid, value, rgba);
322
+ }
323
+
324
+ this.dispatchChangeEvent(value, event.event);
325
+ },
326
+ onAlphaSliderChange: function onAlphaSliderChange(event) {
327
+ this.handleHsvaChange(Object.assign({}, this.hsva, {
328
+ a: event.value / 100
329
+ }), event.event);
330
+ },
331
+ onHueSliderChange: function onHueSliderChange(event) {
332
+ this.handleHsvaChange(Object.assign({}, this.hsva, {
333
+ h: event.value
334
+ }), event.event);
335
+ },
336
+ onDrag: function onDrag(e) {
337
+ this.gradientWrapper.classList.add('k-dragging');
338
+ this.changePosition(e);
339
+ },
340
+ onRelease: function onRelease() {
341
+ this.gradientWrapper.classList.remove('k-dragging');
342
+ },
343
+ onGradientWrapperClick: function onGradientWrapperClick(event) {
344
+ this.changePosition(event);
345
+ },
346
+ changePosition: function changePosition(event) {
347
+ var gradientRectMetrics = this.getGradientRectMetrics();
348
+ var deltaX = event.clientX - gradientRectMetrics.left;
349
+ var deltaY = event.clientY - gradientRectMetrics.top;
350
+ var left = fitIntoBounds(deltaX, 0, gradientRectMetrics.width);
351
+ var top = fitIntoBounds(deltaY, 0, gradientRectMetrics.height);
352
+ var hsva = Object.assign({}, this.hsva, {
353
+ s: left / gradientRectMetrics.width,
354
+ v: 1 - top / gradientRectMetrics.height
355
+ });
356
+ this.handleHsvaChange(hsva, event, event.event);
357
+ },
358
+ handleHsvaChange: function handleHsvaChange(hsva, event) {
359
+ var value = getColorFromHSV(hsva);
360
+
361
+ if (this.isUncontrolled) {
362
+ var hex = parseColor(value, 'hex');
363
+ this.hsva = hsva;
364
+ this.currentBgColor = getColorFromHue(hsva.h);
365
+ this.rgba = getRGBA(value);
366
+ this.hex = hex;
367
+ } else {
368
+ cacheHsva(this.guid, value, hsva);
369
+ }
370
+
371
+ this.dispatchChangeEvent(value, event);
372
+ },
373
+ dispatchChangeEvent: function dispatchChangeEvent(value, event) {
374
+ this.$emit('change', {
375
+ event: event,
376
+ target: this,
377
+ value: value
378
+ });
379
+ },
380
+ onFocus: function onFocus(nativeEvent) {
381
+ if (this.$props.onFocus) {
382
+ this.$props.onFocus.call(undefined, {
383
+ nativeEvent: nativeEvent,
384
+ target: this
385
+ });
386
+ }
387
+ },
388
+ setAlphaSliderBackground: function setAlphaSliderBackground(backgroundColor) {
389
+ if (this.$props.opacity && this.alphaSlider && this.alphaSlider.sliderTrack) {
390
+ this.alphaSlider.sliderTrack.style.background = "linear-gradient(to top, transparent, " + backgroundColor + ")";
391
+ }
392
+ },
393
+ getGradientRectMetrics: function getGradientRectMetrics() {
394
+ var clientRect = this.gradientWrapper.getBoundingClientRect();
395
+ return __assign({}, clientRect);
396
+ },
397
+ focus: function focus() {
398
+ focusFirstFocusableChild(this.$el);
399
+ }
400
+ }
401
+ };
402
+ /**
403
+ * @hidden
404
+ */
405
+
406
+ var ColorGradient = ColorGradientVue2;
407
+ export { ColorGradient, ColorGradientVue2 };
@@ -0,0 +1,54 @@
1
+ import { DefineComponent, RecordPropsDefinition, ComponentOptions, Vue2type } from '../additionalTypes';
2
+ declare type DefaultData<V> = object | ((this: V) => {});
3
+ declare type DefaultMethods<V> = {
4
+ [key: string]: (this: V, ...args: any[]) => any;
5
+ };
6
+ import { NumericTextBoxChangeEvent } from '../main';
7
+ import { RGBA } from './models/rgba';
8
+ /**
9
+ * @hidden
10
+ */
11
+ export interface ColorInputProps {
12
+ rgba: RGBA;
13
+ onRgbaChange?: (rgba: RGBA, event: NumericTextBoxChangeEvent) => void;
14
+ hex: string;
15
+ onHexChange?: any;
16
+ opacity: boolean;
17
+ disabled?: boolean;
18
+ }
19
+ /**
20
+ * @hidden
21
+ */
22
+ export interface ColorInputState {
23
+ }
24
+ /**
25
+ * @hidden
26
+ */
27
+ export interface ColorInputComputed {
28
+ [key: string]: any;
29
+ }
30
+ /**
31
+ * @hidden
32
+ */
33
+ export interface ColorInputMethods {
34
+ [key: string]: any;
35
+ }
36
+ /**
37
+ * @hidden
38
+ */
39
+ export interface ColorInputData {
40
+ }
41
+ /**
42
+ * @hidden
43
+ */
44
+ export interface ColorInputAll extends Vue2type, ColorInputMethods, ColorInputData, ColorInputComputed, ColorInputState {
45
+ }
46
+ /**
47
+ * @hidden
48
+ */
49
+ declare let ColorInputVue2: ComponentOptions<ColorInputAll, DefaultData<ColorInputData>, DefaultMethods<ColorInputAll>, ColorInputComputed, RecordPropsDefinition<ColorInputProps>>;
50
+ /**
51
+ * @hidden
52
+ */
53
+ declare const ColorInput: DefineComponent<ColorInputProps, any, ColorInputData, ColorInputComputed, ColorInputMethods, {}, {}, {}, string, ColorInputProps, ColorInputProps, {}>;
54
+ export { ColorInput, ColorInputVue2 };