@progress/kendo-angular-inputs 15.2.0-develop.1 → 15.2.0-develop.3
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/esm2020/index.mjs +6 -0
- package/esm2020/inputs.module.mjs +7 -3
- package/esm2020/package-metadata.mjs +2 -2
- package/esm2020/rating/directives/rating-hovered-item.directive.mjs +24 -0
- package/esm2020/rating/directives/rating-item.directive.mjs +24 -0
- package/esm2020/rating/directives/rating-selected-item.directive.mjs +24 -0
- package/esm2020/rating/models/precision.mjs +5 -0
- package/esm2020/rating/models/rating-item.interface.mjs +5 -0
- package/esm2020/rating/models/selection.mjs +5 -0
- package/esm2020/rating/rating.component.mjs +710 -0
- package/esm2020/rating.module.mjs +68 -0
- package/fesm2015/progress-kendo-angular-inputs.mjs +840 -31
- package/fesm2020/progress-kendo-angular-inputs.mjs +839 -31
- package/index.d.ts +5 -0
- package/inputs.module.d.ts +2 -1
- package/package.json +10 -10
- package/rating/directives/rating-hovered-item.directive.d.ts +17 -0
- package/rating/directives/rating-item.directive.d.ts +17 -0
- package/rating/directives/rating-selected-item.directive.d.ts +17 -0
- package/rating/models/precision.d.ts +13 -0
- package/rating/models/rating-item.interface.d.ts +32 -0
- package/rating/models/selection.d.ts +13 -0
- package/rating/rating.component.d.ts +180 -0
- package/rating.module.d.ts +47 -0
|
@@ -0,0 +1,710 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { ChangeDetectorRef, Component, ContentChild, ElementRef, EventEmitter, forwardRef, HostBinding, Input, NgZone, Output, Renderer2 } from '@angular/core';
|
|
6
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
7
|
+
import { L10N_PREFIX, LocalizationService } from '@progress/kendo-angular-l10n';
|
|
8
|
+
import { isDocumentAvailable, KendoInput, Keys } from '@progress/kendo-angular-common';
|
|
9
|
+
import { validatePackage } from '@progress/kendo-licensing';
|
|
10
|
+
import { packageMetadata } from '../package-metadata';
|
|
11
|
+
import { starIcon, starOutlineIcon } from '@progress/kendo-svg-icons';
|
|
12
|
+
import { Subscription } from 'rxjs';
|
|
13
|
+
import { areSame } from '../common/utils';
|
|
14
|
+
import { RatingItemTemplateDirective } from './directives/rating-item.directive';
|
|
15
|
+
import { RatingHoveredItemTemplateDirective } from './directives/rating-hovered-item.directive';
|
|
16
|
+
import { RatingSelectedItemTemplateDirective } from './directives/rating-selected-item.directive';
|
|
17
|
+
import * as i0 from "@angular/core";
|
|
18
|
+
import * as i1 from "@progress/kendo-angular-l10n";
|
|
19
|
+
import * as i2 from "@progress/kendo-angular-icons";
|
|
20
|
+
import * as i3 from "@angular/common";
|
|
21
|
+
/**
|
|
22
|
+
* Represents the [Kendo UI Rating component for Angular]({% slug overview_rating %}).
|
|
23
|
+
*/
|
|
24
|
+
export class RatingComponent {
|
|
25
|
+
constructor(element, renderer, localizationService, cdr, zone) {
|
|
26
|
+
this.element = element;
|
|
27
|
+
this.renderer = renderer;
|
|
28
|
+
this.localizationService = localizationService;
|
|
29
|
+
this.cdr = cdr;
|
|
30
|
+
this.zone = zone;
|
|
31
|
+
/**
|
|
32
|
+
* Determines whether the Rating is disabled ([see example]({% slug disabledstate_rating %})). To learn how to disable the component in reactive forms, refer to the article on [Forms Support](slug:formssupport_rating#toc-managing-the-rating-disabled-state-in-reactive-forms).
|
|
33
|
+
*
|
|
34
|
+
* @default false
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
this.disabled = false;
|
|
38
|
+
/**
|
|
39
|
+
* Determines whether the Rating is in its read-only state ([see example]({% slug readonly_rating %})).
|
|
40
|
+
*
|
|
41
|
+
* @default false
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
this.readonly = false;
|
|
45
|
+
/**
|
|
46
|
+
* Specifies the [tabindex](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) of the Rating.
|
|
47
|
+
*
|
|
48
|
+
* @default 0
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
this.tabindex = 0;
|
|
52
|
+
/**
|
|
53
|
+
* Sets the number of rating items ([see example]({% slug itemscount_rating %})).
|
|
54
|
+
*
|
|
55
|
+
* @default 5
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
this.itemsCount = 5;
|
|
59
|
+
/**
|
|
60
|
+
* Sets custom Rating SVG icon. It is the icon that is used for not selected/hovered state. [see example]({% slug icon_rating %}).
|
|
61
|
+
*/
|
|
62
|
+
this.svgIcon = starIcon;
|
|
63
|
+
/**
|
|
64
|
+
* Sets custom Rating SVG icon. It is the icon that is used for selected/hovered state. [see example]({% slug icon_rating %}).
|
|
65
|
+
*/
|
|
66
|
+
this.svgIconOutline = starOutlineIcon;
|
|
67
|
+
/**
|
|
68
|
+
* Fires each time the user selects a new value.
|
|
69
|
+
*/
|
|
70
|
+
this.valueChange = new EventEmitter();
|
|
71
|
+
this.hostClass = true;
|
|
72
|
+
this.valueMin = 0;
|
|
73
|
+
this.ariaRole = 'slider';
|
|
74
|
+
/**
|
|
75
|
+
* @hidden
|
|
76
|
+
*/
|
|
77
|
+
this.ratingItems = [];
|
|
78
|
+
this.ngChange = (_) => { };
|
|
79
|
+
this.ngTouched = () => { };
|
|
80
|
+
this._selection = 'continuous';
|
|
81
|
+
this._precision = 'item';
|
|
82
|
+
this.subscriptions = new Subscription();
|
|
83
|
+
validatePackage(packageMetadata);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The initial value of the Rating component.
|
|
87
|
+
* The component can use either NgModel or the `value` binding but not both of them at the same time.
|
|
88
|
+
*
|
|
89
|
+
*/
|
|
90
|
+
set value(value) {
|
|
91
|
+
this._value = value;
|
|
92
|
+
this.updateRatingItems();
|
|
93
|
+
}
|
|
94
|
+
get value() {
|
|
95
|
+
return this._value;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Sets the selection mode of the Rating ([see example]({% slug selection_rating %})).
|
|
99
|
+
*
|
|
100
|
+
* @default 'continuous'
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
103
|
+
set selection(selection) {
|
|
104
|
+
this._selection = selection;
|
|
105
|
+
this.updateRatingItems();
|
|
106
|
+
}
|
|
107
|
+
get selection() {
|
|
108
|
+
return this._selection;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Determines the precision of the Rating ([see example]({% slug precision_rating %})).
|
|
112
|
+
*
|
|
113
|
+
* @default 'item'
|
|
114
|
+
*
|
|
115
|
+
*/
|
|
116
|
+
set precision(precision) {
|
|
117
|
+
this._precision = precision;
|
|
118
|
+
this.updateRatingItems();
|
|
119
|
+
}
|
|
120
|
+
get precision() {
|
|
121
|
+
return this._precision;
|
|
122
|
+
}
|
|
123
|
+
get isControlInvalid() {
|
|
124
|
+
return (this.control?.invalid)?.toString();
|
|
125
|
+
}
|
|
126
|
+
get valueMax() {
|
|
127
|
+
return this.itemsCount;
|
|
128
|
+
}
|
|
129
|
+
get valueNow() {
|
|
130
|
+
return this.value;
|
|
131
|
+
}
|
|
132
|
+
ngOnInit() {
|
|
133
|
+
this.subscriptions.add(this.localizationService
|
|
134
|
+
.changes
|
|
135
|
+
.subscribe(({ rtl }) => {
|
|
136
|
+
this.direction = rtl ? 'rtl' : 'ltr';
|
|
137
|
+
}));
|
|
138
|
+
this.subscriptions.add(this.renderer.listen(this.element.nativeElement, 'blur', () => this.ngTouched()));
|
|
139
|
+
this.subscriptions.add(this.renderer.listen(this.element.nativeElement, 'keydown', event => this.onKeyDown(event)));
|
|
140
|
+
this.createRatingItems();
|
|
141
|
+
}
|
|
142
|
+
ngAfterViewInit() {
|
|
143
|
+
const items = this.element.nativeElement.querySelectorAll('.k-rating-item');
|
|
144
|
+
this.zone.runOutsideAngular(() => {
|
|
145
|
+
items.forEach((item, index) => this.subscriptions.add(this.renderer.listen(item, 'mousemove', (event) => this.onMouseMove(index, event))));
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
ngOnDestroy() {
|
|
149
|
+
this.subscriptions.unsubscribe();
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Focuses the Rating component.
|
|
153
|
+
*/
|
|
154
|
+
focus() {
|
|
155
|
+
if (isDocumentAvailable() && !this.disabled) {
|
|
156
|
+
this.element.nativeElement.focus();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Blurs the Rating component.
|
|
161
|
+
*/
|
|
162
|
+
blur() {
|
|
163
|
+
if (isDocumentAvailable()) {
|
|
164
|
+
this.element.nativeElement.blur();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* @hidden
|
|
169
|
+
*/
|
|
170
|
+
createRatingItems() {
|
|
171
|
+
for (let i = 0; i < this.itemsCount; i++) {
|
|
172
|
+
const item = {
|
|
173
|
+
title: this.isHalf(i, this.value) ? String(i + 0.5) : String(i + 1),
|
|
174
|
+
selected: this.isSelected(i, this.value),
|
|
175
|
+
selectedIndicator: false,
|
|
176
|
+
hovered: false,
|
|
177
|
+
half: this.isHalf(i, this.value)
|
|
178
|
+
};
|
|
179
|
+
this.ratingItems.push(item);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @hidden
|
|
184
|
+
*/
|
|
185
|
+
onMouseEnter(event) {
|
|
186
|
+
this.rect = event.target.getBoundingClientRect();
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @hidden
|
|
190
|
+
*/
|
|
191
|
+
onMouseMove(value, event) {
|
|
192
|
+
const halfPrecision = this.precision === 'half';
|
|
193
|
+
const isFirstHalf = halfPrecision && this.isFirstHalf(this.rect, event.clientX);
|
|
194
|
+
this.zone.run(() => this.ratingItems.forEach((item, index) => {
|
|
195
|
+
item.title = (halfPrecision && value === index && isFirstHalf) ? String(index + 0.5) : String(index + 1);
|
|
196
|
+
item.selected = item.hovered = this.isSelected(index, value + 1);
|
|
197
|
+
item.selectedIndicator = this.isSelected(index, this.value);
|
|
198
|
+
item.half = (halfPrecision && value === index) ? isFirstHalf : false;
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* @hidden
|
|
203
|
+
*/
|
|
204
|
+
onMouseOut() {
|
|
205
|
+
this.rect = null;
|
|
206
|
+
this.updateRatingItems();
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* @hidden
|
|
210
|
+
* Called when the status of the component changes to or from `disabled`.
|
|
211
|
+
* Depending on the value, it enables or disables the appropriate DOM element.
|
|
212
|
+
*
|
|
213
|
+
* @param isDisabled
|
|
214
|
+
*/
|
|
215
|
+
setDisabledState(isDisabled) {
|
|
216
|
+
this.disabled = isDisabled;
|
|
217
|
+
this.cdr.markForCheck();
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* @hidden
|
|
221
|
+
*/
|
|
222
|
+
changeValue(index, event) {
|
|
223
|
+
const rect = event.target.getBoundingClientRect();
|
|
224
|
+
const isFirstHalf = this.isFirstHalf(rect, event.clientX);
|
|
225
|
+
const value = (this.precision === 'half' && isFirstHalf) ? index + 0.5 : index + 1;
|
|
226
|
+
if (!areSame(this.value, value)) {
|
|
227
|
+
this.value = value;
|
|
228
|
+
this.ngChange(this.value);
|
|
229
|
+
this.valueChange.emit(this.value);
|
|
230
|
+
this.updateRatingItems();
|
|
231
|
+
this.cdr.markForCheck();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* @hidden
|
|
236
|
+
*/
|
|
237
|
+
updateRatingItems() {
|
|
238
|
+
this.ratingItems.forEach((item, index) => {
|
|
239
|
+
item.title = this.isHalf(index, this.value) ? String(index + 0.5) : String(index + 1);
|
|
240
|
+
item.selected = this.isSelected(index, this.value);
|
|
241
|
+
item.selectedIndicator = this.isSelected(index, this.value);
|
|
242
|
+
item.hovered = false;
|
|
243
|
+
item.half = this.isHalf(index, this.value);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* @hidden
|
|
248
|
+
*/
|
|
249
|
+
writeValue(value) {
|
|
250
|
+
this.value = value;
|
|
251
|
+
this.updateRatingItems();
|
|
252
|
+
this.cdr.markForCheck();
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* @hidden
|
|
256
|
+
*/
|
|
257
|
+
registerOnChange(fn) {
|
|
258
|
+
this.ngChange = fn;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* @hidden
|
|
262
|
+
*/
|
|
263
|
+
registerOnTouched(fn) {
|
|
264
|
+
this.ngTouched = fn;
|
|
265
|
+
}
|
|
266
|
+
isSelected(index, value) {
|
|
267
|
+
return this.selection === 'single' ? index === Math.ceil(value - 1) : index <= Math.ceil(value - 1);
|
|
268
|
+
}
|
|
269
|
+
isHalf(index, value) {
|
|
270
|
+
return (this.precision === 'half' && (value > index) && (value < index + 1));
|
|
271
|
+
}
|
|
272
|
+
isFirstHalf(rect, clientX) {
|
|
273
|
+
const elementPosition = rect.x + (rect.width / 2);
|
|
274
|
+
return this.direction === 'ltr' ? clientX < elementPosition : clientX > elementPosition;
|
|
275
|
+
}
|
|
276
|
+
onKeyDown(event) {
|
|
277
|
+
const decreaseValue = () => {
|
|
278
|
+
if (this.value <= 0) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
this.value = (this.precision === 'half') ? this.value - 0.5 : this.value - 1;
|
|
282
|
+
this.ngChange(this.value);
|
|
283
|
+
this.valueChange.emit(this.value);
|
|
284
|
+
this.updateRatingItems();
|
|
285
|
+
this.cdr.markForCheck();
|
|
286
|
+
};
|
|
287
|
+
const increaseValue = () => {
|
|
288
|
+
if (this.value >= this.itemsCount) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
this.value = (this.precision === 'half') ? this.value + 0.5 : this.value + 1;
|
|
292
|
+
this.ngChange(this.value);
|
|
293
|
+
this.valueChange.emit(this.value);
|
|
294
|
+
this.updateRatingItems();
|
|
295
|
+
this.cdr.markForCheck();
|
|
296
|
+
};
|
|
297
|
+
const setMinValue = () => {
|
|
298
|
+
if (!areSame(this.value, this.valueMin)) {
|
|
299
|
+
this.value = this.valueMin;
|
|
300
|
+
this.ngChange(this.value);
|
|
301
|
+
this.valueChange.emit(this.value);
|
|
302
|
+
this.updateRatingItems();
|
|
303
|
+
this.cdr.markForCheck();
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
const setMaxValue = () => {
|
|
307
|
+
if (!areSame(this.value, this.valueMax)) {
|
|
308
|
+
this.value = this.valueMax;
|
|
309
|
+
this.ngChange(this.value);
|
|
310
|
+
this.valueChange.emit(this.value);
|
|
311
|
+
this.updateRatingItems();
|
|
312
|
+
this.cdr.markForCheck();
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
if (event.keyCode === Keys.ArrowDown) {
|
|
316
|
+
decreaseValue();
|
|
317
|
+
}
|
|
318
|
+
if (event.keyCode === Keys.ArrowLeft) {
|
|
319
|
+
if (this.direction === 'ltr') {
|
|
320
|
+
decreaseValue();
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
increaseValue();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (event.keyCode === Keys.ArrowUp) {
|
|
327
|
+
increaseValue();
|
|
328
|
+
}
|
|
329
|
+
if (event.keyCode === Keys.ArrowRight) {
|
|
330
|
+
if (this.direction === 'ltr') {
|
|
331
|
+
increaseValue();
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
decreaseValue();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (event.keyCode === Keys.Home) {
|
|
338
|
+
setMinValue();
|
|
339
|
+
}
|
|
340
|
+
if (event.keyCode === Keys.End) {
|
|
341
|
+
setMaxValue();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
RatingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: RatingComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1.LocalizationService }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
346
|
+
RatingComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: RatingComponent, selector: "kendo-rating", inputs: { disabled: "disabled", readonly: "readonly", tabindex: "tabindex", itemsCount: "itemsCount", value: "value", selection: "selection", precision: "precision", label: "label", icon: "icon", svgIcon: "svgIcon", svgIconOutline: "svgIconOutline" }, outputs: { valueChange: "valueChange" }, host: { properties: { "attr.aria-disabled": "this.disabled", "class.k-disabled": "this.disabled", "attr.aria-readonly": "this.readonly", "class.k-readonly": "this.readonly", "attr.tabindex": "this.tabindex", "class.k-rating": "this.hostClass", "attr.dir": "this.direction", "attr.aria-invalid": "this.isControlInvalid", "attr.aria-valuemin": "this.valueMin", "attr.aria-valuemax": "this.valueMax", "attr.aria-valuenow": "this.valueNow", "attr.role": "this.ariaRole" } }, providers: [
|
|
347
|
+
LocalizationService,
|
|
348
|
+
{ provide: L10N_PREFIX, useValue: 'kendo.rating' },
|
|
349
|
+
{
|
|
350
|
+
multi: true,
|
|
351
|
+
provide: NG_VALUE_ACCESSOR,
|
|
352
|
+
useExisting: forwardRef(() => RatingComponent) /* eslint-disable-line*/
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
provide: KendoInput,
|
|
356
|
+
useExisting: forwardRef(() => RatingComponent)
|
|
357
|
+
}
|
|
358
|
+
], queries: [{ propertyName: "itemTemplate", first: true, predicate: RatingItemTemplateDirective, descendants: true }, { propertyName: "hoveredItemTemplate", first: true, predicate: RatingHoveredItemTemplateDirective, descendants: true }, { propertyName: "selectedItemTemplate", first: true, predicate: RatingSelectedItemTemplateDirective, descendants: true }], exportAs: ["kendoRating"], ngImport: i0, template: `
|
|
359
|
+
<span class="k-rating-container">
|
|
360
|
+
<span
|
|
361
|
+
*ngFor="let item of ratingItems; index as i"
|
|
362
|
+
class="k-rating-item"
|
|
363
|
+
[title]="item.title"
|
|
364
|
+
[ngClass]="{
|
|
365
|
+
'k-selected': item.selected || item.selectedIndicator,
|
|
366
|
+
'k-hover': item.hovered
|
|
367
|
+
}"
|
|
368
|
+
(mouseenter)="onMouseEnter($event)"
|
|
369
|
+
(mouseout)="onMouseOut()"
|
|
370
|
+
(click)="changeValue(i, $event)"
|
|
371
|
+
>
|
|
372
|
+
<ng-container *ngIf="!item.half">
|
|
373
|
+
<ng-container *ngIf="!itemTemplate">
|
|
374
|
+
<kendo-icon-wrapper
|
|
375
|
+
*ngIf="!icon"
|
|
376
|
+
size="xlarge"
|
|
377
|
+
[name]="item.selected || item.hovered ? 'star' : 'star-outline'"
|
|
378
|
+
[svgIcon]="item.selected || item.hovered ? svgIcon : svgIconOutline"
|
|
379
|
+
>
|
|
380
|
+
</kendo-icon-wrapper>
|
|
381
|
+
|
|
382
|
+
<kendo-icon-wrapper
|
|
383
|
+
*ngIf="icon"
|
|
384
|
+
size="xlarge"
|
|
385
|
+
[name]="item.selected || item.hovered ? icon : icon + '-outline'"
|
|
386
|
+
>
|
|
387
|
+
</kendo-icon-wrapper>
|
|
388
|
+
</ng-container>
|
|
389
|
+
|
|
390
|
+
<ng-template
|
|
391
|
+
*ngIf="itemTemplate && (!item.selected && !item.hovered)"
|
|
392
|
+
[ngTemplateOutlet]="itemTemplate?.templateRef"
|
|
393
|
+
>
|
|
394
|
+
</ng-template>
|
|
395
|
+
|
|
396
|
+
<ng-template
|
|
397
|
+
*ngIf="hoveredItemTemplate && item.hovered"
|
|
398
|
+
[ngTemplateOutlet]="hoveredItemTemplate?.templateRef"
|
|
399
|
+
>
|
|
400
|
+
</ng-template>
|
|
401
|
+
|
|
402
|
+
<ng-template
|
|
403
|
+
*ngIf="selectedItemTemplate && (item.selected && !item.hovered)"
|
|
404
|
+
[ngTemplateOutlet]="selectedItemTemplate?.templateRef"
|
|
405
|
+
>
|
|
406
|
+
</ng-template>
|
|
407
|
+
</ng-container>
|
|
408
|
+
|
|
409
|
+
<ng-container *ngIf="item.half">
|
|
410
|
+
<ng-container *ngIf="!itemTemplate">
|
|
411
|
+
<span class="k-rating-precision-complement">
|
|
412
|
+
<kendo-icon-wrapper
|
|
413
|
+
*ngIf="!icon"
|
|
414
|
+
size="xlarge"
|
|
415
|
+
[name]="'star-outline'"
|
|
416
|
+
[svgIcon]="svgIconOutline"
|
|
417
|
+
>
|
|
418
|
+
</kendo-icon-wrapper>
|
|
419
|
+
|
|
420
|
+
<kendo-icon-wrapper
|
|
421
|
+
*ngIf="icon"
|
|
422
|
+
size="xlarge"
|
|
423
|
+
[name]="icon + '-outline'"
|
|
424
|
+
>
|
|
425
|
+
</kendo-icon-wrapper>
|
|
426
|
+
</span>
|
|
427
|
+
|
|
428
|
+
<span
|
|
429
|
+
class="k-rating-precision-part"
|
|
430
|
+
[ngStyle]="{'clipPath': direction === 'rtl' ? 'inset(0 0 0 50%)' : 'inset(0 50% 0 0)'}"
|
|
431
|
+
>
|
|
432
|
+
<kendo-icon-wrapper
|
|
433
|
+
*ngIf="!icon"
|
|
434
|
+
size="xlarge"
|
|
435
|
+
[name]="'star'"
|
|
436
|
+
[svgIcon]="svgIcon"
|
|
437
|
+
>
|
|
438
|
+
</kendo-icon-wrapper>
|
|
439
|
+
|
|
440
|
+
<kendo-icon-wrapper
|
|
441
|
+
*ngIf="icon"
|
|
442
|
+
size="xlarge"
|
|
443
|
+
[name]="icon"
|
|
444
|
+
>
|
|
445
|
+
</kendo-icon-wrapper>
|
|
446
|
+
</span>
|
|
447
|
+
</ng-container>
|
|
448
|
+
|
|
449
|
+
<span
|
|
450
|
+
class="k-rating-precision-complement"
|
|
451
|
+
>
|
|
452
|
+
<ng-template
|
|
453
|
+
[ngTemplateOutlet]="itemTemplate?.templateRef"
|
|
454
|
+
>
|
|
455
|
+
</ng-template>
|
|
456
|
+
</span>
|
|
457
|
+
|
|
458
|
+
<span
|
|
459
|
+
*ngIf="hoveredItemTemplate && item.hovered"
|
|
460
|
+
class="k-rating-precision-part"
|
|
461
|
+
[ngStyle]="{'clipPath': direction === 'rtl' ? 'inset(0 0 0 50%)' : 'inset(0 50% 0 0)'}"
|
|
462
|
+
>
|
|
463
|
+
<ng-template
|
|
464
|
+
[ngTemplateOutlet]="hoveredItemTemplate?.templateRef"
|
|
465
|
+
>
|
|
466
|
+
</ng-template>
|
|
467
|
+
</span>
|
|
468
|
+
|
|
469
|
+
<span
|
|
470
|
+
*ngIf="selectedItemTemplate && (item.selected && !item.hovered)"
|
|
471
|
+
class="k-rating-precision-part"
|
|
472
|
+
[ngStyle]="{'clipPath': direction === 'rtl' ? 'inset(0 0 0 50%)' : 'inset(0 50% 0 0)'}"
|
|
473
|
+
>
|
|
474
|
+
<ng-template
|
|
475
|
+
[ngTemplateOutlet]="selectedItemTemplate?.templateRef"
|
|
476
|
+
>
|
|
477
|
+
</ng-template>
|
|
478
|
+
</span>
|
|
479
|
+
|
|
480
|
+
<span [style.width.px]="24" [style.height.px]="24" [style.display]="'block'"></span>
|
|
481
|
+
</ng-container>
|
|
482
|
+
</span>
|
|
483
|
+
</span>
|
|
484
|
+
|
|
485
|
+
<span
|
|
486
|
+
*ngIf="label"
|
|
487
|
+
class="k-rating-label"
|
|
488
|
+
>{{ label }}</span>
|
|
489
|
+
`, isInline: true, components: [{ type: i2.IconWrapperComponent, selector: "kendo-icon-wrapper", inputs: ["name", "svgIcon", "innerCssClass", "customFontClass", "size"], exportAs: ["kendoIconWrapper"] }], directives: [{ type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
490
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: RatingComponent, decorators: [{
|
|
491
|
+
type: Component,
|
|
492
|
+
args: [{
|
|
493
|
+
exportAs: 'kendoRating',
|
|
494
|
+
providers: [
|
|
495
|
+
LocalizationService,
|
|
496
|
+
{ provide: L10N_PREFIX, useValue: 'kendo.rating' },
|
|
497
|
+
{
|
|
498
|
+
multi: true,
|
|
499
|
+
provide: NG_VALUE_ACCESSOR,
|
|
500
|
+
useExisting: forwardRef(() => RatingComponent) /* eslint-disable-line*/
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
provide: KendoInput,
|
|
504
|
+
useExisting: forwardRef(() => RatingComponent)
|
|
505
|
+
}
|
|
506
|
+
],
|
|
507
|
+
selector: 'kendo-rating',
|
|
508
|
+
template: `
|
|
509
|
+
<span class="k-rating-container">
|
|
510
|
+
<span
|
|
511
|
+
*ngFor="let item of ratingItems; index as i"
|
|
512
|
+
class="k-rating-item"
|
|
513
|
+
[title]="item.title"
|
|
514
|
+
[ngClass]="{
|
|
515
|
+
'k-selected': item.selected || item.selectedIndicator,
|
|
516
|
+
'k-hover': item.hovered
|
|
517
|
+
}"
|
|
518
|
+
(mouseenter)="onMouseEnter($event)"
|
|
519
|
+
(mouseout)="onMouseOut()"
|
|
520
|
+
(click)="changeValue(i, $event)"
|
|
521
|
+
>
|
|
522
|
+
<ng-container *ngIf="!item.half">
|
|
523
|
+
<ng-container *ngIf="!itemTemplate">
|
|
524
|
+
<kendo-icon-wrapper
|
|
525
|
+
*ngIf="!icon"
|
|
526
|
+
size="xlarge"
|
|
527
|
+
[name]="item.selected || item.hovered ? 'star' : 'star-outline'"
|
|
528
|
+
[svgIcon]="item.selected || item.hovered ? svgIcon : svgIconOutline"
|
|
529
|
+
>
|
|
530
|
+
</kendo-icon-wrapper>
|
|
531
|
+
|
|
532
|
+
<kendo-icon-wrapper
|
|
533
|
+
*ngIf="icon"
|
|
534
|
+
size="xlarge"
|
|
535
|
+
[name]="item.selected || item.hovered ? icon : icon + '-outline'"
|
|
536
|
+
>
|
|
537
|
+
</kendo-icon-wrapper>
|
|
538
|
+
</ng-container>
|
|
539
|
+
|
|
540
|
+
<ng-template
|
|
541
|
+
*ngIf="itemTemplate && (!item.selected && !item.hovered)"
|
|
542
|
+
[ngTemplateOutlet]="itemTemplate?.templateRef"
|
|
543
|
+
>
|
|
544
|
+
</ng-template>
|
|
545
|
+
|
|
546
|
+
<ng-template
|
|
547
|
+
*ngIf="hoveredItemTemplate && item.hovered"
|
|
548
|
+
[ngTemplateOutlet]="hoveredItemTemplate?.templateRef"
|
|
549
|
+
>
|
|
550
|
+
</ng-template>
|
|
551
|
+
|
|
552
|
+
<ng-template
|
|
553
|
+
*ngIf="selectedItemTemplate && (item.selected && !item.hovered)"
|
|
554
|
+
[ngTemplateOutlet]="selectedItemTemplate?.templateRef"
|
|
555
|
+
>
|
|
556
|
+
</ng-template>
|
|
557
|
+
</ng-container>
|
|
558
|
+
|
|
559
|
+
<ng-container *ngIf="item.half">
|
|
560
|
+
<ng-container *ngIf="!itemTemplate">
|
|
561
|
+
<span class="k-rating-precision-complement">
|
|
562
|
+
<kendo-icon-wrapper
|
|
563
|
+
*ngIf="!icon"
|
|
564
|
+
size="xlarge"
|
|
565
|
+
[name]="'star-outline'"
|
|
566
|
+
[svgIcon]="svgIconOutline"
|
|
567
|
+
>
|
|
568
|
+
</kendo-icon-wrapper>
|
|
569
|
+
|
|
570
|
+
<kendo-icon-wrapper
|
|
571
|
+
*ngIf="icon"
|
|
572
|
+
size="xlarge"
|
|
573
|
+
[name]="icon + '-outline'"
|
|
574
|
+
>
|
|
575
|
+
</kendo-icon-wrapper>
|
|
576
|
+
</span>
|
|
577
|
+
|
|
578
|
+
<span
|
|
579
|
+
class="k-rating-precision-part"
|
|
580
|
+
[ngStyle]="{'clipPath': direction === 'rtl' ? 'inset(0 0 0 50%)' : 'inset(0 50% 0 0)'}"
|
|
581
|
+
>
|
|
582
|
+
<kendo-icon-wrapper
|
|
583
|
+
*ngIf="!icon"
|
|
584
|
+
size="xlarge"
|
|
585
|
+
[name]="'star'"
|
|
586
|
+
[svgIcon]="svgIcon"
|
|
587
|
+
>
|
|
588
|
+
</kendo-icon-wrapper>
|
|
589
|
+
|
|
590
|
+
<kendo-icon-wrapper
|
|
591
|
+
*ngIf="icon"
|
|
592
|
+
size="xlarge"
|
|
593
|
+
[name]="icon"
|
|
594
|
+
>
|
|
595
|
+
</kendo-icon-wrapper>
|
|
596
|
+
</span>
|
|
597
|
+
</ng-container>
|
|
598
|
+
|
|
599
|
+
<span
|
|
600
|
+
class="k-rating-precision-complement"
|
|
601
|
+
>
|
|
602
|
+
<ng-template
|
|
603
|
+
[ngTemplateOutlet]="itemTemplate?.templateRef"
|
|
604
|
+
>
|
|
605
|
+
</ng-template>
|
|
606
|
+
</span>
|
|
607
|
+
|
|
608
|
+
<span
|
|
609
|
+
*ngIf="hoveredItemTemplate && item.hovered"
|
|
610
|
+
class="k-rating-precision-part"
|
|
611
|
+
[ngStyle]="{'clipPath': direction === 'rtl' ? 'inset(0 0 0 50%)' : 'inset(0 50% 0 0)'}"
|
|
612
|
+
>
|
|
613
|
+
<ng-template
|
|
614
|
+
[ngTemplateOutlet]="hoveredItemTemplate?.templateRef"
|
|
615
|
+
>
|
|
616
|
+
</ng-template>
|
|
617
|
+
</span>
|
|
618
|
+
|
|
619
|
+
<span
|
|
620
|
+
*ngIf="selectedItemTemplate && (item.selected && !item.hovered)"
|
|
621
|
+
class="k-rating-precision-part"
|
|
622
|
+
[ngStyle]="{'clipPath': direction === 'rtl' ? 'inset(0 0 0 50%)' : 'inset(0 50% 0 0)'}"
|
|
623
|
+
>
|
|
624
|
+
<ng-template
|
|
625
|
+
[ngTemplateOutlet]="selectedItemTemplate?.templateRef"
|
|
626
|
+
>
|
|
627
|
+
</ng-template>
|
|
628
|
+
</span>
|
|
629
|
+
|
|
630
|
+
<span [style.width.px]="24" [style.height.px]="24" [style.display]="'block'"></span>
|
|
631
|
+
</ng-container>
|
|
632
|
+
</span>
|
|
633
|
+
</span>
|
|
634
|
+
|
|
635
|
+
<span
|
|
636
|
+
*ngIf="label"
|
|
637
|
+
class="k-rating-label"
|
|
638
|
+
>{{ label }}</span>
|
|
639
|
+
`
|
|
640
|
+
}]
|
|
641
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1.LocalizationService }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }]; }, propDecorators: { itemTemplate: [{
|
|
642
|
+
type: ContentChild,
|
|
643
|
+
args: [RatingItemTemplateDirective]
|
|
644
|
+
}], hoveredItemTemplate: [{
|
|
645
|
+
type: ContentChild,
|
|
646
|
+
args: [RatingHoveredItemTemplateDirective]
|
|
647
|
+
}], selectedItemTemplate: [{
|
|
648
|
+
type: ContentChild,
|
|
649
|
+
args: [RatingSelectedItemTemplateDirective]
|
|
650
|
+
}], disabled: [{
|
|
651
|
+
type: Input
|
|
652
|
+
}, {
|
|
653
|
+
type: HostBinding,
|
|
654
|
+
args: ['attr.aria-disabled']
|
|
655
|
+
}, {
|
|
656
|
+
type: HostBinding,
|
|
657
|
+
args: ['class.k-disabled']
|
|
658
|
+
}], readonly: [{
|
|
659
|
+
type: Input
|
|
660
|
+
}, {
|
|
661
|
+
type: HostBinding,
|
|
662
|
+
args: ['attr.aria-readonly']
|
|
663
|
+
}, {
|
|
664
|
+
type: HostBinding,
|
|
665
|
+
args: ['class.k-readonly']
|
|
666
|
+
}], tabindex: [{
|
|
667
|
+
type: Input
|
|
668
|
+
}, {
|
|
669
|
+
type: HostBinding,
|
|
670
|
+
args: ['attr.tabindex']
|
|
671
|
+
}], itemsCount: [{
|
|
672
|
+
type: Input
|
|
673
|
+
}], value: [{
|
|
674
|
+
type: Input
|
|
675
|
+
}], selection: [{
|
|
676
|
+
type: Input
|
|
677
|
+
}], precision: [{
|
|
678
|
+
type: Input
|
|
679
|
+
}], label: [{
|
|
680
|
+
type: Input
|
|
681
|
+
}], icon: [{
|
|
682
|
+
type: Input
|
|
683
|
+
}], svgIcon: [{
|
|
684
|
+
type: Input
|
|
685
|
+
}], svgIconOutline: [{
|
|
686
|
+
type: Input
|
|
687
|
+
}], valueChange: [{
|
|
688
|
+
type: Output
|
|
689
|
+
}], hostClass: [{
|
|
690
|
+
type: HostBinding,
|
|
691
|
+
args: ['class.k-rating']
|
|
692
|
+
}], direction: [{
|
|
693
|
+
type: HostBinding,
|
|
694
|
+
args: ['attr.dir']
|
|
695
|
+
}], isControlInvalid: [{
|
|
696
|
+
type: HostBinding,
|
|
697
|
+
args: ['attr.aria-invalid']
|
|
698
|
+
}], valueMin: [{
|
|
699
|
+
type: HostBinding,
|
|
700
|
+
args: ['attr.aria-valuemin']
|
|
701
|
+
}], valueMax: [{
|
|
702
|
+
type: HostBinding,
|
|
703
|
+
args: ['attr.aria-valuemax']
|
|
704
|
+
}], valueNow: [{
|
|
705
|
+
type: HostBinding,
|
|
706
|
+
args: ['attr.aria-valuenow']
|
|
707
|
+
}], ariaRole: [{
|
|
708
|
+
type: HostBinding,
|
|
709
|
+
args: ['attr.role']
|
|
710
|
+
}] } });
|