@progress/kendo-vue-inputs 4.3.4-dev.202405030811 → 4.4.0-dev.202405091413

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 (53) hide show
  1. package/dist/cdn/js/kendo-vue-inputs.js +1 -1
  2. package/dist/es/main.d.ts +1 -0
  3. package/dist/es/main.js +1 -0
  4. package/dist/es/package-metadata.js +1 -1
  5. package/dist/es/rating/Rating.d.ts +61 -0
  6. package/dist/es/rating/Rating.js +400 -0
  7. package/dist/es/rating/RatingItem.d.ts +46 -0
  8. package/dist/es/rating/RatingItem.js +272 -0
  9. package/dist/es/rating/interfaces/RatingEvents.d.ts +47 -0
  10. package/dist/es/rating/interfaces/RatingEvents.js +1 -0
  11. package/dist/es/rating/interfaces/RatingItemProps.d.ts +92 -0
  12. package/dist/es/rating/interfaces/RatingItemProps.js +1 -0
  13. package/dist/es/rating/interfaces/RatingProps.d.ts +116 -0
  14. package/dist/es/rating/interfaces/RatingProps.js +1 -0
  15. package/dist/es/rating/utils/index.d.ts +24 -0
  16. package/dist/es/rating/utils/index.js +60 -0
  17. package/dist/es/rating/utils/rating-reducer.d.ts +32 -0
  18. package/dist/es/rating/utils/rating-reducer.js +63 -0
  19. package/dist/esm/main.d.ts +1 -0
  20. package/dist/esm/main.js +1 -0
  21. package/dist/esm/package-metadata.js +1 -1
  22. package/dist/esm/rating/Rating.d.ts +61 -0
  23. package/dist/esm/rating/Rating.js +400 -0
  24. package/dist/esm/rating/RatingItem.d.ts +46 -0
  25. package/dist/esm/rating/RatingItem.js +272 -0
  26. package/dist/esm/rating/interfaces/RatingEvents.d.ts +47 -0
  27. package/dist/esm/rating/interfaces/RatingEvents.js +1 -0
  28. package/dist/esm/rating/interfaces/RatingItemProps.d.ts +92 -0
  29. package/dist/esm/rating/interfaces/RatingItemProps.js +1 -0
  30. package/dist/esm/rating/interfaces/RatingProps.d.ts +116 -0
  31. package/dist/esm/rating/interfaces/RatingProps.js +1 -0
  32. package/dist/esm/rating/utils/index.d.ts +24 -0
  33. package/dist/esm/rating/utils/index.js +60 -0
  34. package/dist/esm/rating/utils/rating-reducer.d.ts +32 -0
  35. package/dist/esm/rating/utils/rating-reducer.js +63 -0
  36. package/dist/npm/main.d.ts +1 -0
  37. package/dist/npm/main.js +1 -0
  38. package/dist/npm/package-metadata.js +1 -1
  39. package/dist/npm/rating/Rating.d.ts +61 -0
  40. package/dist/npm/rating/Rating.js +407 -0
  41. package/dist/npm/rating/RatingItem.d.ts +46 -0
  42. package/dist/npm/rating/RatingItem.js +279 -0
  43. package/dist/npm/rating/interfaces/RatingEvents.d.ts +47 -0
  44. package/dist/npm/rating/interfaces/RatingEvents.js +2 -0
  45. package/dist/npm/rating/interfaces/RatingItemProps.d.ts +92 -0
  46. package/dist/npm/rating/interfaces/RatingItemProps.js +2 -0
  47. package/dist/npm/rating/interfaces/RatingProps.d.ts +116 -0
  48. package/dist/npm/rating/interfaces/RatingProps.js +2 -0
  49. package/dist/npm/rating/utils/index.d.ts +24 -0
  50. package/dist/npm/rating/utils/index.js +72 -0
  51. package/dist/npm/rating/utils/rating-reducer.d.ts +32 -0
  52. package/dist/npm/rating/utils/rating-reducer.js +67 -0
  53. package/package.json +13 -13
package/dist/es/main.d.ts CHANGED
@@ -41,3 +41,4 @@ export * from './textarea/interfaces/TextAreaChangeEvent';
41
41
  export * from './textarea/interfaces/TextAreaFocusEvent';
42
42
  export * from './signature/Signature';
43
43
  export * from './signature/interfaces/main';
44
+ export * from './rating/Rating';
package/dist/es/main.js CHANGED
@@ -39,3 +39,4 @@ export * from './textarea/interfaces/TextAreaChangeEvent';
39
39
  export * from './textarea/interfaces/TextAreaFocusEvent';
40
40
  export * from './signature/Signature';
41
41
  export * from './signature/interfaces/main';
42
+ export * from './rating/Rating';
@@ -5,7 +5,7 @@ export var packageMetadata = {
5
5
  name: '@progress/kendo-vue-inputs',
6
6
  productName: 'Kendo UI for Vue',
7
7
  productCodes: ['KENDOUIVUE', 'KENDOUICOMPLETE'],
8
- publishDate: 1714723247,
8
+ publishDate: 1715263381,
9
9
  version: '',
10
10
  licensingDocsUrl: 'https://www.telerik.com/kendo-vue-ui/my-license/?utm_medium=product&utm_source=kendovue&utm_campaign=kendo-ui-vue-purchase-license-keys-warning'
11
11
  };
@@ -0,0 +1,61 @@
1
+ import { DefineComponent, RecordPropsDefinition, ComponentOptions, Vue2type } from '../additionalTypes';
2
+ import { RatingItemMouseEvent } from './interfaces/RatingEvents';
3
+ import { RatingProps } from './interfaces/RatingProps';
4
+ import { RatingActionDispatch } from './utils/rating-reducer';
5
+ declare type DefaultData<V> = object | ((this: V) => RatingData);
6
+ declare type DefaultMethods<V> = {
7
+ [key: string]: (this: V, ...args: any[]) => any;
8
+ };
9
+ /**
10
+ * @hidden
11
+ */
12
+ export interface RatingData {
13
+ defaultValue: number;
14
+ }
15
+ /**
16
+ * @hidden
17
+ */
18
+ export interface RatingState {
19
+ inputRef: any;
20
+ }
21
+ /**
22
+ * @hidden
23
+ */
24
+ export interface RatingMethods {
25
+ [key: string]: any;
26
+ handleChange: (newValue: number, e: PointerEvent) => void;
27
+ handleKeyDown: (e: KeyboardEvent) => void;
28
+ handleFocus: (e: FocusEvent) => void;
29
+ handleBlur: (e: FocusEvent) => void;
30
+ handleItemClick: (eventData: RatingItemMouseEvent) => void;
31
+ handleMouseLeave: (eventData: RatingItemMouseEvent) => void;
32
+ handleMouseMove: (eventData: RatingItemMouseEvent) => void;
33
+ dispatchValue: (action: RatingActionDispatch) => void;
34
+ dispatchHover: (action: RatingActionDispatch) => void;
35
+ }
36
+ /**
37
+ * @hidden
38
+ */
39
+ export interface RatingComputed {
40
+ [key: string]: any;
41
+ base: number;
42
+ }
43
+ /**
44
+ * @hidden
45
+ */
46
+ export interface RatingHandle {
47
+ }
48
+ /**
49
+ * @hidden
50
+ */
51
+ export interface RatingAllMethods extends Vue2type, RatingMethods, RatingComputed, RatingState {
52
+ }
53
+ /**
54
+ * @hidden
55
+ */
56
+ declare let RatingVue2: ComponentOptions<RatingAllMethods, DefaultData<RatingData>, DefaultMethods<RatingAllMethods>, RatingComputed, RecordPropsDefinition<RatingProps>>;
57
+ /**
58
+ * @hidden
59
+ */
60
+ declare const Rating: DefineComponent<RatingProps, any, RatingData, RatingComputed, RatingMethods, {}, {}, {}, string, RatingProps, RatingProps, {}>;
61
+ export { Rating, RatingVue2 };
@@ -0,0 +1,400 @@
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
+ for (var p in s) {
6
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
7
+ }
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ // @ts-ignore
14
+ import * as Vue from 'vue';
15
+ var allVue = Vue;
16
+ var gh = allVue.h;
17
+ var isV3 = allVue.version && allVue.version[0] === '3';
18
+ var ref = allVue.ref;
19
+ import { Keys, classNames, getListeners, getTabIndex, templateRendering, validatePackage } from '@progress/kendo-vue-common';
20
+ import { packageMetadata } from '../package-metadata';
21
+ import { RatingItem } from './RatingItem';
22
+ import { calcIsFirstHalf, getRemainder, isHalf, isSelected, toRound } from './utils';
23
+ import { provideLocalizationService } from '@progress/kendo-vue-intl';
24
+ import { messages, ratingAriaLabel } from '../messages/main';
25
+ import { RATING_ACTION, ratingReducer } from './utils/rating-reducer';
26
+ /**
27
+ * @hidden
28
+ */
29
+ var RatingVue2 = {
30
+ name: 'Rating',
31
+ // @ts-ignore
32
+ emits: {
33
+ 'change': null,
34
+ 'keydown': null,
35
+ 'focus': null,
36
+ 'blur': null,
37
+ 'click': null,
38
+ 'mouseleave': null,
39
+ 'mousemove': null
40
+ },
41
+ props: {
42
+ min: {
43
+ type: Number,
44
+ default: 1
45
+ },
46
+ max: {
47
+ type: Number,
48
+ default: 5
49
+ },
50
+ step: {
51
+ type: Number,
52
+ default: 1
53
+ },
54
+ item: {
55
+ type: [String, Object, Function]
56
+ },
57
+ precision: {
58
+ default: 'item',
59
+ validator: function validator(value) {
60
+ return ['item', 'half'].includes(value);
61
+ }
62
+ },
63
+ selection: {
64
+ default: 'continues',
65
+ validator: function validator(value) {
66
+ return ['continues', 'single'].includes(value);
67
+ }
68
+ },
69
+ value: Number,
70
+ icon: String,
71
+ svgIconOutline: Object,
72
+ svgIcon: Object,
73
+ tabIndex: Number,
74
+ disabled: Boolean,
75
+ readonly: Boolean,
76
+ id: String,
77
+ half: Boolean,
78
+ defaultValue: Number,
79
+ label: String
80
+ },
81
+ created: function created() {
82
+ validatePackage(packageMetadata);
83
+ },
84
+ inject: {
85
+ kendoLocalizationService: {
86
+ default: null
87
+ }
88
+ },
89
+ data: function data() {
90
+ return {
91
+ focused: false,
92
+ currentValue: this.defaultValue || null,
93
+ currentHovered: null
94
+ };
95
+ },
96
+ // @ts-ignore
97
+ setup: !isV3 ? undefined : function () {
98
+ var v3 = !!isV3;
99
+ var inputRef = ref(null);
100
+ return {
101
+ v3: v3,
102
+ inputRef: inputRef
103
+ };
104
+ },
105
+ computed: {
106
+ base: function base() {
107
+ return this.$props.step / (this.$props.precision === 'half' ? 2 : 1);
108
+ },
109
+ computedValue: function computedValue() {
110
+ return this.$props.value !== undefined ? this.$props.value : this.$data.currentValue;
111
+ }
112
+ },
113
+ render: function render(createElement) {
114
+ var _this = this;
115
+ var h = gh || createElement;
116
+ var ls = provideLocalizationService(this);
117
+ var _a = this.$props,
118
+ min = _a.min,
119
+ max = _a.max,
120
+ step = _a.step,
121
+ id = _a.id,
122
+ dir = _a.dir,
123
+ label = _a.label,
124
+ selection = _a.selection,
125
+ precision = _a.precision,
126
+ svgIcon = _a.svgIcon,
127
+ icon = _a.icon,
128
+ item = _a.item,
129
+ value = _a.value,
130
+ tabIndex = _a.tabIndex,
131
+ disabled = _a.disabled,
132
+ readonly = _a.readonly,
133
+ ariaLabelledBy = _a.ariaLabelledBy,
134
+ ariaDescribedBy = _a.ariaDescribedBy,
135
+ svgIconOutline = _a.svgIconOutline;
136
+ var items = Array.from({
137
+ length: max - min + 1
138
+ }, function (_, i) {
139
+ return min + i;
140
+ });
141
+ var remainder = getRemainder(toRound(max - min, this.base), step);
142
+ var stateValue = this.computedValue;
143
+ var stateHover = this.$data.currentHovered;
144
+ return h("span", {
145
+ id: id,
146
+ attrs: this.v3 ? undefined : {
147
+ id: id,
148
+ role: "slider",
149
+ dir: dir,
150
+ tabIndex: getTabIndex(tabIndex, disabled, undefined),
151
+ "aria-valuemin": min,
152
+ "aria-valuemax": max,
153
+ "aria-valuenow": value !== null ? value : undefined,
154
+ "aria-disabled": disabled ? 'true' : undefined,
155
+ "aria-label": ls.toLanguageString(ratingAriaLabel, messages[ratingAriaLabel]),
156
+ "aria-labelledby": ariaLabelledBy,
157
+ "aria-describedby": ariaDescribedBy
158
+ },
159
+ ref: 'ratingRef',
160
+ role: "slider",
161
+ dir: dir,
162
+ tabIndex: getTabIndex(tabIndex, disabled, undefined),
163
+ "class": classNames('k-rating', {
164
+ 'k-rtl': dir === 'rtl',
165
+ 'k-readonly': readonly,
166
+ 'k-disabled': disabled
167
+ }),
168
+ onKeydown: this.handleKeyDown,
169
+ on: this.v3 ? undefined : {
170
+ "keydown": this.handleKeyDown,
171
+ "focus": this.handleFocus,
172
+ "blur": this.handleBlur,
173
+ "click": function click() {
174
+ return _this.$data.focused = true;
175
+ }
176
+ },
177
+ onFocus: this.handleFocus,
178
+ onBlur: this.handleBlur,
179
+ onClick: function click() {
180
+ return _this.$data.focused = true;
181
+ },
182
+ "aria-valuemin": min,
183
+ "aria-valuemax": max,
184
+ "aria-valuenow": value !== null ? value : undefined,
185
+ "aria-disabled": disabled ? 'true' : undefined,
186
+ "aria-label": ls.toLanguageString(ratingAriaLabel, messages[ratingAriaLabel]),
187
+ "aria-labelledby": ariaLabelledBy,
188
+ "aria-describedby": ariaDescribedBy
189
+ }, [h("input", {
190
+ id: 'rating',
191
+ attrs: this.v3 ? undefined : {
192
+ id: 'rating',
193
+ readOnly: readonly,
194
+ disabled: disabled
195
+ },
196
+ "class": 'k-hidden',
197
+ readOnly: readonly,
198
+ disabled: disabled
199
+ }), h("span", {
200
+ "class": 'k-rating-container'
201
+ }, [items.map(function (_itemRating) {
202
+ var itemValue = toRound(_itemRating + remainder, this.base);
203
+ var half = precision === 'half' ? isHalf(itemValue, stateHover !== null ? stateHover : stateValue !== null ? stateValue : 0, step) : false;
204
+ var haveSelectedValue = isSelected(itemValue, stateValue, step, selection);
205
+ var selected = isSelected(itemValue, stateHover !== null ? stateHover : stateValue, step, selection);
206
+ var hovered = isSelected(itemValue, stateHover, step, selection);
207
+ var itemTemplate = templateRendering.call(this, item, getListeners.call(this));
208
+ var defaultItemTemplate = h(RatingItem, {
209
+ afterHovered: stateHover,
210
+ attrs: this.v3 ? undefined : {
211
+ afterHovered: stateHover,
212
+ value: itemValue,
213
+ dir: dir,
214
+ title: String(half ? toRound(itemValue - step / 2, this.base) : itemValue),
215
+ icon: icon,
216
+ svgIcon: svgIcon,
217
+ svgIconOutline: svgIconOutline,
218
+ haveSelectedValue: haveSelectedValue,
219
+ half: half,
220
+ selected: selected,
221
+ hovered: hovered,
222
+ item: item,
223
+ itemTemplate: itemTemplate
224
+ },
225
+ key: itemValue,
226
+ value: itemValue,
227
+ dir: dir,
228
+ title: String(half ? toRound(itemValue - step / 2, this.base) : itemValue),
229
+ icon: icon,
230
+ svgIcon: svgIcon,
231
+ svgIconOutline: svgIconOutline,
232
+ haveSelectedValue: haveSelectedValue,
233
+ half: half,
234
+ selected: selected,
235
+ hovered: hovered,
236
+ item: item,
237
+ itemTemplate: itemTemplate,
238
+ onClick: this.handleItemClick,
239
+ on: this.v3 ? undefined : {
240
+ "click": this.handleItemClick,
241
+ "mousemove": this.handleMouseMove,
242
+ "mouseleave": this.handleMouseLeave
243
+ },
244
+ onMousemove: this.handleMouseMove,
245
+ onMouseleave: this.handleMouseLeave
246
+ });
247
+ return defaultItemTemplate;
248
+ }, this)]), label && h("span", {
249
+ "class": 'k-rating-label'
250
+ }, [label])]);
251
+ },
252
+ methods: {
253
+ handleFocus: function handleFocus(event) {
254
+ this.$emit('focus', event);
255
+ },
256
+ handleBlur: function handleBlur(event) {
257
+ this.$emit('blur', event);
258
+ },
259
+ handleChange: function handleChange(newValue, event) {
260
+ this.$emit('change', {
261
+ value: newValue,
262
+ target: this.$refs.ratingRef,
263
+ event: event
264
+ });
265
+ },
266
+ handleKeyDown: function handleKeyDown(event) {
267
+ if (this.$props.readonly || this.$props.disabled) {
268
+ return;
269
+ }
270
+ switch (event.keyCode) {
271
+ case Keys.right:
272
+ event.preventDefault();
273
+ this.dispatchValue({
274
+ type: this.$props.dir === 'rtl' ? RATING_ACTION.decrease : RATING_ACTION.increase,
275
+ event: event
276
+ });
277
+ break;
278
+ case Keys.left:
279
+ event.preventDefault();
280
+ this.dispatchValue({
281
+ type: this.$props.dir === 'rtl' ? RATING_ACTION.increase : RATING_ACTION.decrease,
282
+ event: event
283
+ });
284
+ break;
285
+ case Keys.home:
286
+ event.preventDefault();
287
+ this.dispatchValue({
288
+ type: this.$props.dir === 'rtl' ? RATING_ACTION.min : RATING_ACTION.max,
289
+ event: event
290
+ });
291
+ break;
292
+ case Keys.end:
293
+ event.preventDefault();
294
+ this.dispatchValue({
295
+ type: this.$props.dir === 'rtl' ? RATING_ACTION.max : RATING_ACTION.min,
296
+ event: event
297
+ });
298
+ break;
299
+ case Keys.esc:
300
+ event.preventDefault();
301
+ this.dispatchValue({
302
+ type: RATING_ACTION.deselect,
303
+ event: event
304
+ });
305
+ break;
306
+ default:
307
+ break;
308
+ }
309
+ this.$emit('keydown', {
310
+ value: this.$data.currentValue,
311
+ event: event
312
+ });
313
+ },
314
+ handleItemClick: function handleItemClick(eventData) {
315
+ var event = eventData.event,
316
+ value = eventData.value,
317
+ target = eventData.target;
318
+ if (!target || !value || this.$props.readonly || this.$props.disabled) {
319
+ return;
320
+ }
321
+ if (this.$props.precision === 'half') {
322
+ var rect = target.getBoundingClientRect();
323
+ var isFirstHalf = calcIsFirstHalf(this.$props.dir ? this.$props.dir : 'ltr', rect, eventData.event.clientX);
324
+ var payload = isFirstHalf ? toRound(value - this.$props.step / 2, this.base) : value;
325
+ this.dispatchValue({
326
+ type: RATING_ACTION.select,
327
+ payload: payload,
328
+ event: event
329
+ });
330
+ } else {
331
+ this.dispatchValue({
332
+ type: RATING_ACTION.select,
333
+ payload: value,
334
+ event: event
335
+ });
336
+ }
337
+ this.$emit('click', event);
338
+ },
339
+ handleMouseMove: function handleMouseMove(eventData) {
340
+ var event = eventData.event,
341
+ value = eventData.value,
342
+ target = eventData.target;
343
+ if (!target || !value) {
344
+ return;
345
+ }
346
+ if (this.$props.precision === 'half') {
347
+ var rect = target.getBoundingClientRect();
348
+ var isFirstHalf = calcIsFirstHalf(this.$props.dir ? this.$props.dir : 'ltr', rect, event.clientX);
349
+ var payload = isFirstHalf ? value - this.$props.step / 2 : value;
350
+ this.dispatchHover({
351
+ type: RATING_ACTION.select,
352
+ payload: payload,
353
+ event: event
354
+ });
355
+ } else {
356
+ this.dispatchHover({
357
+ type: RATING_ACTION.select,
358
+ payload: value,
359
+ event: event
360
+ });
361
+ }
362
+ },
363
+ handleMouseLeave: function handleMouseLeave(eventData) {
364
+ this.dispatchHover({
365
+ type: RATING_ACTION.reset,
366
+ event: eventData.event
367
+ });
368
+ },
369
+ dispatchValue: function dispatchValue(action) {
370
+ var args = {
371
+ state: this.$props.value,
372
+ min: this.$props.min,
373
+ max: this.$props.max,
374
+ step: this.base
375
+ };
376
+ var state = args.state || this.$data.currentValue;
377
+ var newState = ratingReducer(state, __assign(__assign({}, action), args));
378
+ var event = action.event;
379
+ this.handleChange(newState, event);
380
+ this.$data.currentValue = newState;
381
+ },
382
+ dispatchHover: function dispatchHover(action) {
383
+ var args = {
384
+ state: this.$props.value,
385
+ min: this.$props.min,
386
+ max: this.$props.max,
387
+ step: this.base,
388
+ precision: this.$props.precision
389
+ };
390
+ var state = args.state;
391
+ var newState = ratingReducer(state, __assign(__assign({}, action), args));
392
+ this.$data.currentHovered = newState;
393
+ }
394
+ }
395
+ };
396
+ /**
397
+ * @hidden
398
+ */
399
+ var Rating = RatingVue2;
400
+ export { Rating, RatingVue2 };
@@ -0,0 +1,46 @@
1
+ import { DefineComponent, RecordPropsDefinition, ComponentOptions, Vue2type } from '../additionalTypes';
2
+ import { RatingItemProps } from './interfaces/RatingItemProps';
3
+ declare type DefaultData<V> = object | ((this: V) => {});
4
+ declare type DefaultMethods<V> = {
5
+ [key: string]: (this: V, ...args: any[]) => any;
6
+ };
7
+ /**
8
+ * @hidden
9
+ */
10
+ export interface RatingItemState {
11
+ }
12
+ /**
13
+ * @hidden
14
+ */
15
+ export interface RatingItemComputed {
16
+ [key: string]: any;
17
+ }
18
+ /**
19
+ * @hidden
20
+ */
21
+ export interface RatingItemMethods {
22
+ [key: string]: any;
23
+ handleClick: (e: MouseEvent) => void;
24
+ handleKeyDown: (e: KeyboardEvent) => void;
25
+ handleFocus: (e: FocusEvent) => void;
26
+ handleBlur: (e: FocusEvent) => void;
27
+ handleMouseEnter: (e: MouseEvent) => void;
28
+ handleMouseLeave: (e: MouseEvent) => void;
29
+ handleMouseMove: (e: MouseEvent) => void;
30
+ }
31
+ /**
32
+ * @hidden
33
+ */
34
+ export interface RatingItemData {
35
+ }
36
+ /**
37
+ * @hidden
38
+ */
39
+ export interface RatingItemAll extends Vue2type, RatingItemMethods, RatingItemData, RatingItemComputed, RatingItemState {
40
+ }
41
+ /**
42
+ * @hidden
43
+ */
44
+ declare let RatingItemVue2: ComponentOptions<RatingItemAll, DefaultData<RatingItemData>, DefaultMethods<RatingItemAll>, RatingItemComputed, RecordPropsDefinition<RatingItemProps>>;
45
+ declare const RatingItem: DefineComponent<RatingItemProps, any, RatingItemData, RatingItemComputed, RatingItemMethods, {}, {}, {}, string, RatingItemProps, RatingItemProps, {}>;
46
+ export { RatingItem, RatingItemVue2 };