@syncfusion/ej2-inputs 20.3.56 → 20.4.38

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 (122) hide show
  1. package/.eslintrc.json +16 -1
  2. package/CHANGELOG.md +7 -4
  3. package/dist/ej2-inputs.min.js +2 -2
  4. package/dist/ej2-inputs.umd.min.js +2 -2
  5. package/dist/ej2-inputs.umd.min.js.map +1 -1
  6. package/dist/es6/ej2-inputs.es2015.js +889 -67
  7. package/dist/es6/ej2-inputs.es2015.js.map +1 -1
  8. package/dist/es6/ej2-inputs.es5.js +913 -67
  9. package/dist/es6/ej2-inputs.es5.js.map +1 -1
  10. package/dist/global/ej2-inputs.min.js +2 -2
  11. package/dist/global/ej2-inputs.min.js.map +1 -1
  12. package/dist/global/index.d.ts +1 -1
  13. package/package.json +9 -9
  14. package/rating.d.ts +4 -0
  15. package/rating.js +4 -0
  16. package/src/color-picker/color-picker-model.d.ts +4 -4
  17. package/src/color-picker/color-picker.d.ts +4 -4
  18. package/src/color-picker/color-picker.js +4 -2
  19. package/src/common/signature-base.d.ts +0 -1
  20. package/src/common/signature-base.js +4 -9
  21. package/src/index.d.ts +1 -0
  22. package/src/index.js +1 -0
  23. package/src/input/input.d.ts +1 -0
  24. package/src/input/input.js +5 -1
  25. package/src/maskedtextbox/base/mask-base.d.ts +1 -0
  26. package/src/maskedtextbox/base/mask-base.js +20 -13
  27. package/src/maskedtextbox/maskedtextbox/maskedtextbox-model.d.ts +1 -0
  28. package/src/maskedtextbox/maskedtextbox/maskedtextbox.d.ts +1 -0
  29. package/src/maskedtextbox/maskedtextbox/maskedtextbox.js +16 -7
  30. package/src/numerictextbox/numerictextbox.js +24 -11
  31. package/src/rating/index.d.ts +5 -0
  32. package/src/rating/index.js +4 -0
  33. package/src/rating/rating-model.d.ts +185 -0
  34. package/src/rating/rating.d.ts +344 -0
  35. package/src/rating/rating.js +783 -0
  36. package/src/slider/slider.js +4 -2
  37. package/src/textbox/textbox.js +11 -10
  38. package/src/uploader/uploader-model.d.ts +10 -1
  39. package/src/uploader/uploader.d.ts +8 -0
  40. package/src/uploader/uploader.js +41 -12
  41. package/styles/bootstrap-dark.css +264 -0
  42. package/styles/bootstrap-dark.scss +1 -0
  43. package/styles/bootstrap.css +264 -0
  44. package/styles/bootstrap.scss +1 -0
  45. package/styles/bootstrap4.css +267 -2
  46. package/styles/bootstrap4.scss +1 -0
  47. package/styles/bootstrap5-dark.css +265 -0
  48. package/styles/bootstrap5-dark.scss +1 -0
  49. package/styles/bootstrap5.css +265 -0
  50. package/styles/bootstrap5.scss +1 -0
  51. package/styles/color-picker/_theme.scss +2 -2
  52. package/styles/color-picker/bootstrap4.css +2 -2
  53. package/styles/fabric-dark.css +264 -0
  54. package/styles/fabric-dark.scss +1 -0
  55. package/styles/fabric.css +264 -0
  56. package/styles/fabric.scss +1 -0
  57. package/styles/fluent-dark.css +264 -0
  58. package/styles/fluent-dark.scss +1 -0
  59. package/styles/fluent.css +264 -0
  60. package/styles/fluent.scss +1 -0
  61. package/styles/highcontrast-light.css +264 -0
  62. package/styles/highcontrast-light.scss +1 -0
  63. package/styles/highcontrast.css +264 -0
  64. package/styles/highcontrast.scss +1 -0
  65. package/styles/material-dark.css +264 -0
  66. package/styles/material-dark.scss +1 -0
  67. package/styles/material.css +264 -0
  68. package/styles/material.scss +1 -0
  69. package/styles/rating/_all.scss +2 -0
  70. package/styles/rating/_bootstrap-dark-definition.scss +45 -0
  71. package/styles/rating/_bootstrap-definition.scss +45 -0
  72. package/styles/rating/_bootstrap4-definition.scss +45 -0
  73. package/styles/rating/_bootstrap5-dark-definition.scss +1 -0
  74. package/styles/rating/_bootstrap5-definition.scss +45 -0
  75. package/styles/rating/_fabric-dark-definition.scss +45 -0
  76. package/styles/rating/_fabric-definition.scss +45 -0
  77. package/styles/rating/_fluent-dark-definition.scss +1 -0
  78. package/styles/rating/_fluent-definition.scss +45 -0
  79. package/styles/rating/_fusionnew-definition.scss +45 -0
  80. package/styles/rating/_highcontrast-definition.scss +45 -0
  81. package/styles/rating/_highcontrast-light-definition.scss +45 -0
  82. package/styles/rating/_layout.scss +203 -0
  83. package/styles/rating/_material-dark-definition.scss +45 -0
  84. package/styles/rating/_material-definition.scss +45 -0
  85. package/styles/rating/_material3-definition.scss +45 -0
  86. package/styles/rating/_tailwind-dark-definition.scss +1 -0
  87. package/styles/rating/_tailwind-definition.scss +45 -0
  88. package/styles/rating/_theme.scss +158 -0
  89. package/styles/rating/bootstrap-dark.css +263 -0
  90. package/styles/rating/bootstrap-dark.scss +4 -0
  91. package/styles/rating/bootstrap.css +263 -0
  92. package/styles/rating/bootstrap.scss +4 -0
  93. package/styles/rating/bootstrap4.css +264 -0
  94. package/styles/rating/bootstrap4.scss +4 -0
  95. package/styles/rating/bootstrap5-dark.css +264 -0
  96. package/styles/rating/bootstrap5-dark.scss +4 -0
  97. package/styles/rating/bootstrap5.css +264 -0
  98. package/styles/rating/bootstrap5.scss +4 -0
  99. package/styles/rating/fabric-dark.css +263 -0
  100. package/styles/rating/fabric-dark.scss +4 -0
  101. package/styles/rating/fabric.css +263 -0
  102. package/styles/rating/fabric.scss +4 -0
  103. package/styles/rating/fluent-dark.css +263 -0
  104. package/styles/rating/fluent-dark.scss +4 -0
  105. package/styles/rating/fluent.css +263 -0
  106. package/styles/rating/fluent.scss +4 -0
  107. package/styles/rating/highcontrast-light.css +263 -0
  108. package/styles/rating/highcontrast-light.scss +4 -0
  109. package/styles/rating/highcontrast.css +263 -0
  110. package/styles/rating/highcontrast.scss +4 -0
  111. package/styles/rating/material-dark.css +264 -0
  112. package/styles/rating/material-dark.scss +4 -0
  113. package/styles/rating/material.css +264 -0
  114. package/styles/rating/material.scss +4 -0
  115. package/styles/rating/tailwind-dark.css +269 -0
  116. package/styles/rating/tailwind-dark.scss +4 -0
  117. package/styles/rating/tailwind.css +269 -0
  118. package/styles/rating/tailwind.scss +4 -0
  119. package/styles/tailwind-dark.css +270 -0
  120. package/styles/tailwind-dark.scss +1 -0
  121. package/styles/tailwind.css +270 -0
  122. package/styles/tailwind.scss +1 -0
@@ -0,0 +1,783 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ };
20
+ import { addClass, Event, attributes, compile, Component, EventHandler, getUniqueID, select } from '@syncfusion/ej2-base';
21
+ import { isNullOrUndefined, KeyboardEvents, NotifyPropertyChanges, Property, remove, removeClass } from '@syncfusion/ej2-base';
22
+ import { Tooltip } from '@syncfusion/ej2-popups';
23
+ var ICONCSS = 'e-rating-icon e-icons e-star-filled';
24
+ var ITEMLIST = 'e-rating-item-list';
25
+ var ITEMCONTAINER = 'e-rating-item-container';
26
+ var SELECTED = 'e-rating-selected';
27
+ var INTERMEDIATE = 'e-rating-intermediate';
28
+ var LABEL = 'e-rating-label';
29
+ var RESET = 'e-icons e-reset';
30
+ var HIDDEN = 'e-rating-hidden';
31
+ var DISABLED = 'e-disabled';
32
+ var READONLY = 'e-rating-readonly';
33
+ var RTL = 'e-rtl';
34
+ var ANIMATION = 'e-rating-animation';
35
+ var FULLTEMPLATE = 'e-rating-full';
36
+ var EMPTYTEMPLATE = 'e-rating-empty';
37
+ var SELECTEDVALUE = 'e-selected-value';
38
+ var RATINGVALUE = '--rating-value';
39
+ /**
40
+ * Defines the position of the label in the rating.
41
+ */
42
+ export var LabelPosition;
43
+ (function (LabelPosition) {
44
+ /**
45
+ * Shows the label above the rating.
46
+ */
47
+ LabelPosition["Top"] = "Top";
48
+ /**
49
+ * Shows the label below the rating.
50
+ */
51
+ LabelPosition["Bottom"] = "Bottom";
52
+ /**
53
+ * Shows the label to the left of rating.
54
+ */
55
+ LabelPosition["Left"] = "Left";
56
+ /**
57
+ * Shows the label to the right of rating.
58
+ */
59
+ LabelPosition["Right"] = "Right";
60
+ })(LabelPosition || (LabelPosition = {}));
61
+ /**
62
+ * Defines the minimum increase in the value in Rating Control.
63
+ */
64
+ export var PrecisionType;
65
+ (function (PrecisionType) {
66
+ /**
67
+ * Process the value as whole numbers.
68
+ */
69
+ PrecisionType["Full"] = "Full";
70
+ /**
71
+ * Process the value in terms of 0.5 (half).
72
+ */
73
+ PrecisionType["Half"] = "Half";
74
+ /**
75
+ * Process the value in terms of 0.25 (quarter).
76
+ */
77
+ PrecisionType["Quarter"] = "Quarter";
78
+ /**
79
+ * Process the value in terms of 0.1.
80
+ */
81
+ PrecisionType["Exact"] = "Exact";
82
+ })(PrecisionType || (PrecisionType = {}));
83
+ var Rating = /** @class */ (function (_super) {
84
+ __extends(Rating, _super);
85
+ /**
86
+ * Constructor for creating the widget
87
+ *
88
+ * @param {RatingModel} options - Specifies the rating model
89
+ * @param {string|HTMLButtonElement} element - Specifies the target element
90
+ */
91
+ function Rating(options, element) {
92
+ var _this = _super.call(this, options, element) || this;
93
+ _this.itemElements = [];
94
+ _this.tooltipOpen = false;
95
+ return _this;
96
+ }
97
+ Rating.prototype.preRender = function () {
98
+ if (!this.element.id) {
99
+ this.element.id = getUniqueID('e-' + this.getModuleName());
100
+ }
101
+ this.keyConfigs = {
102
+ downarrow: 'downarrow',
103
+ leftarrow: 'leftarrow',
104
+ rightarrow: 'rightarrow',
105
+ uparrow: 'uparrow',
106
+ space: 'space'
107
+ };
108
+ };
109
+ Rating.prototype.render = function () {
110
+ this.initialize();
111
+ this.updateMinValue();
112
+ this.updateTemplateFunction();
113
+ this.renderItems();
114
+ this.updatePrecision();
115
+ this.displayLabel();
116
+ };
117
+ Rating.prototype.initialize = function () {
118
+ this.wrapper = this.createElement('div', { className: 'e-' + this.getModuleName() + '-container ' });
119
+ this.element.parentNode.insertBefore(this.wrapper, this.element);
120
+ this.wrapper.appendChild(this.element);
121
+ if ((this.element.getAttribute('name') == null)) {
122
+ this.element.setAttribute('name', this.element.id);
123
+ }
124
+ attributes(this.element, { 'aria-label': 'rating' });
125
+ this.renderItemList();
126
+ this.updateReset();
127
+ this.updateDisabled();
128
+ this.wrapper.classList[this.readOnly ? 'add' : 'remove'](READONLY);
129
+ this.wrapper.classList[!this.visible ? 'add' : 'remove'](HIDDEN);
130
+ this.wrapper.classList[this.enableRtl ? 'add' : 'remove'](RTL);
131
+ this.wrapper.classList[this.enableAnimation ? 'add' : 'remove'](ANIMATION);
132
+ if (this.cssClass) {
133
+ addClass([this.wrapper], this.cssClass.split(' '));
134
+ }
135
+ this.updateTooltip();
136
+ this.wireKeyboardEvent();
137
+ };
138
+ Rating.prototype.updateDisabled = function () {
139
+ this.wrapper.classList[this.disabled ? 'add' : 'remove'](DISABLED);
140
+ attributes(this.ratingItemList, { 'tabindex': (this.disabled) ? '-1' : '0' });
141
+ if (this.allowReset) {
142
+ this.updateResetButton();
143
+ }
144
+ };
145
+ Rating.prototype.updateResetButton = function () {
146
+ var isDisabled = (this.value <= this.min) || this.disabled;
147
+ this.resetElement.classList[isDisabled ? 'add' : 'remove'](DISABLED);
148
+ attributes(this.resetElement, { 'aria-label': 'resetbutton', 'role': 'button',
149
+ 'tabindex': (isDisabled ? '-1' : '0'), 'aria-hidden': isDisabled.toString() });
150
+ };
151
+ Rating.prototype.renderItemList = function () {
152
+ var _this = this;
153
+ this.ratingItemList = this.createElement('div', {
154
+ className: ITEMLIST,
155
+ id: this.element.id + '_item-list',
156
+ attrs: { 'tabindex': '0' }
157
+ });
158
+ attributes(this.ratingItemList, { 'aria-label': 'rating', 'role': 'slider' });
159
+ this.wrapper.appendChild(this.ratingItemList);
160
+ EventHandler.add(this.ratingItemList, 'touchmove', function (e) { return _this.touchMoveHandler(e); }, this);
161
+ EventHandler.add(this.ratingItemList, 'touchend', this.touchEndHandler, this);
162
+ };
163
+ Rating.prototype.touchMoveHandler = function (e) {
164
+ var rect = this.ratingItemList.getBoundingClientRect();
165
+ var x = e.touches[0].clientX - rect.x;
166
+ var currValue = (x / rect.width) * this.itemsCount;
167
+ currValue = (this.enableRtl) ? (this.itemsCount - currValue) : currValue;
168
+ currValue = currValue < this.min ? this.min : currValue > this.itemsCount ? this.itemsCount : currValue;
169
+ currValue = this.validateValue(currValue);
170
+ var element = currValue === 0 ? null : this.itemElements[parseInt((Math.ceil(currValue) - 1).toString(), 10)];
171
+ if (currValue === this.currentValue) {
172
+ if (this.showTooltip && element) {
173
+ this.openRatingTooltip(element, false);
174
+ }
175
+ return;
176
+ }
177
+ var previousValue = this.currentValue;
178
+ this.updateCurrentValue(currValue);
179
+ this.triggerChange(e, currValue);
180
+ if (this.showTooltip) {
181
+ if (element) {
182
+ if (Math.ceil(currValue) !== Math.ceil(previousValue)) {
183
+ this.closeRatingTooltip();
184
+ }
185
+ this.openRatingTooltip(element, true);
186
+ }
187
+ else {
188
+ this.closeRatingTooltip();
189
+ }
190
+ }
191
+ };
192
+ Rating.prototype.touchEndHandler = function () {
193
+ this.closeRatingTooltip();
194
+ };
195
+ Rating.prototype.updateTemplateFunction = function () {
196
+ this.emptyTemplateFunction = this.emptyTemplate ? this.getTemplateString(this.emptyTemplate) : null;
197
+ this.fullTemplateFunction = this.fullTemplate ? this.getTemplateString(this.fullTemplate) : null;
198
+ };
199
+ Rating.prototype.renderItems = function () {
200
+ var _this = this;
201
+ for (var i = 0; i < this.itemsCount; i++) {
202
+ var ratingItemContainer = this.createElement('span', { className: ITEMCONTAINER });
203
+ var spanItem = this.createElement('span', { className: 'e-rating-item' });
204
+ var ratingValue = this.getRatingValue(this.value, i);
205
+ this.renderItemContent(spanItem, ratingValue, i);
206
+ ratingItemContainer.appendChild(spanItem);
207
+ this.wireItemsEvents(ratingItemContainer, i + 1);
208
+ this.itemElements.push(ratingItemContainer);
209
+ var eventArgs = { element: ratingItemContainer, value: i + 1 };
210
+ this.trigger('beforeItemRender', eventArgs, function (args) {
211
+ _this.ratingItemList.appendChild(args.element);
212
+ });
213
+ }
214
+ attributes(this.ratingItemList, { 'aria-valuemax': this.itemsCount.toString() });
215
+ if (this.disabled) {
216
+ attributes(this.ratingItemList, { 'tabindex': '-1' });
217
+ }
218
+ };
219
+ Rating.prototype.renderItemContent = function (spanEle, val, index, isrerender) {
220
+ if (isrerender === void 0) { isrerender = false; }
221
+ if (isrerender) {
222
+ this.removeItemContent(spanEle);
223
+ }
224
+ if (this.fullTemplate && val === 1) {
225
+ spanEle.classList.add(FULLTEMPLATE);
226
+ spanEle.append(this.fullTemplateFunction({ index: index, ratingValue: val }, this, 'ratingFullTemplate', (this.element.id + 'fullTemplate'), this.isStringTemplate)[0]);
227
+ }
228
+ else if (this.emptyTemplate) {
229
+ spanEle.classList.add(EMPTYTEMPLATE);
230
+ spanEle.append(this.emptyTemplateFunction({ index: index, ratingValue: val }, this, 'ratingEmptyTemplate', (this.element.id + 'emptyTemplate'), this.isStringTemplate)[0]);
231
+ }
232
+ else {
233
+ addClass([spanEle], ICONCSS.split(' '));
234
+ }
235
+ };
236
+ Rating.prototype.removeItemContent = function (spanEle) {
237
+ spanEle.classList.remove(FULLTEMPLATE, EMPTYTEMPLATE);
238
+ removeClass([spanEle], ICONCSS.split(' '));
239
+ if (spanEle.firstChild) {
240
+ spanEle.removeChild(spanEle.firstChild);
241
+ }
242
+ };
243
+ Rating.prototype.updateTooltip = function () {
244
+ if (this.showTooltip) {
245
+ this.tooltipObj = new Tooltip({
246
+ target: '.e-rating-item-container', windowCollision: true,
247
+ opensOn: 'Custom', cssClass: 'e-rating-tooltip'
248
+ });
249
+ this.tooltipObj.appendTo('#' + this.ratingItemList.id);
250
+ }
251
+ else {
252
+ if (!isNullOrUndefined(this.tooltipObj)) {
253
+ this.tooltipObj.destroy();
254
+ this.tooltipObj = null;
255
+ }
256
+ }
257
+ };
258
+ Rating.prototype.updateMinValue = function () {
259
+ this.min = this.validateValue(this.min);
260
+ if (this.min > 0 && this.value < this.min) {
261
+ this.triggerChange(null, this.min, false);
262
+ }
263
+ attributes(this.ratingItemList, { 'aria-valuemin': this.min.toString() });
264
+ };
265
+ Rating.prototype.updatePrecision = function () {
266
+ this.min = this.validateValue(this.min);
267
+ this.triggerChange(null, this.validateValue(this.value), false);
268
+ this.updateItemValue();
269
+ };
270
+ Rating.prototype.validateValue = function (currentValue) {
271
+ if (currentValue > this.itemsCount) {
272
+ currentValue = this.itemsCount;
273
+ }
274
+ else if (currentValue < 0) {
275
+ currentValue = 0;
276
+ }
277
+ else {
278
+ currentValue = (this.precision === PrecisionType.Full) ? Math.round(currentValue) :
279
+ (this.precision === PrecisionType.Half) ? (Math.round(currentValue * 2) / 2) :
280
+ (this.precision === PrecisionType.Quarter) ? (Math.round(currentValue * 4) / 4) : (Math.round(currentValue * 10) / 10);
281
+ }
282
+ return currentValue;
283
+ };
284
+ Rating.prototype.getRatingValue = function (value, i) {
285
+ return (this.enableSingleSelection && this.precision === PrecisionType.Full) ? ((value === i + 1) ? 1 : 0) :
286
+ (value >= i + 1) ? 1 : ((value < i) ? 0 : (value - i));
287
+ };
288
+ Rating.prototype.updateItemValue = function () {
289
+ for (var i = 0; i < this.itemsCount; i++) {
290
+ var itemElement = this.itemElements[parseInt(i.toString(), 10)];
291
+ itemElement.classList.remove(SELECTED, INTERMEDIATE, SELECTEDVALUE);
292
+ var ratingValue = this.getRatingValue(this.currentValue, i);
293
+ if (ratingValue === 1) {
294
+ itemElement.classList.add(SELECTED);
295
+ }
296
+ else if (ratingValue > 0) {
297
+ itemElement.classList.add(INTERMEDIATE);
298
+ }
299
+ else if ((this.precision === PrecisionType.Full) && (i + 1 <= this.value) && (!this.enableSingleSelection)) {
300
+ itemElement.classList.add(SELECTEDVALUE);
301
+ }
302
+ this.updateItemContent(ratingValue, i);
303
+ itemElement.style.setProperty(RATINGVALUE, (ratingValue * 100) + '%');
304
+ itemElement.classList[((this.value === 0) && (i === 0)) || (this.value === i + 1) || ((ratingValue > 0) && (ratingValue < 1)) ? 'add' : 'remove']('e-rating-focus');
305
+ }
306
+ if (this.allowReset) {
307
+ this.updateResetButton();
308
+ }
309
+ attributes(this.ratingItemList, { 'aria-valuenow': this.currentValue.toString() });
310
+ attributes(this.element, { 'value': this.value.toString() });
311
+ };
312
+ Rating.prototype.updateItemContent = function (ratingValue, index) {
313
+ if (!this.fullTemplate && !this.emptyTemplate) {
314
+ return;
315
+ }
316
+ var spanEle = this.itemElements[parseInt(index.toString(), 10)].querySelector('.e-rating-item');
317
+ if (this.fullTemplate && ratingValue === 1) {
318
+ if (spanEle.classList.contains(FULLTEMPLATE)) {
319
+ return;
320
+ }
321
+ this.removeItemContent(spanEle);
322
+ spanEle.classList.add(FULLTEMPLATE);
323
+ spanEle.append(this.fullTemplateFunction({ ratingValue: ratingValue, index: index }, this, 'ratingFullTemplate', (this.element.id + 'fullTemplate'), this.isStringTemplate)[0]);
324
+ }
325
+ else if (this.emptyTemplate) {
326
+ this.removeItemContent(spanEle);
327
+ spanEle.classList.add(EMPTYTEMPLATE);
328
+ spanEle.append(this.emptyTemplateFunction({ ratingValue: ratingValue, index: index }, this, 'ratingFullTemplate', (this.element.id + 'fullTemplate'), this.isStringTemplate)[0]);
329
+ }
330
+ else {
331
+ this.removeItemContent(spanEle);
332
+ addClass([spanEle], ICONCSS.split(' '));
333
+ }
334
+ this.renderReactTemplates();
335
+ };
336
+ Rating.prototype.updateTooltipContent = function (isChange) {
337
+ if (this.showTooltip) {
338
+ var content = void 0;
339
+ if (this.tooltipTemplate) {
340
+ var templateFunction = this.getTemplateString(this.tooltipTemplate);
341
+ content = templateFunction({ value: this.currentValue }, this, 'ratingTooltipTemplate', (this.element.id + 'tooltipTemplate'), this.isStringTemplate)[0];
342
+ }
343
+ else {
344
+ content = this.currentValue.toString();
345
+ }
346
+ this.tooltipObj.setProperties({ content: content }, isChange);
347
+ this.renderReactTemplates();
348
+ }
349
+ };
350
+ Rating.prototype.getTemplateString = function (template) {
351
+ var stringContent = '';
352
+ try {
353
+ var tempEle = select(template);
354
+ if (tempEle) {
355
+ //Return innerHTML incase of jsrenderer script else outerHTML
356
+ stringContent = tempEle.tagName === 'SCRIPT' ? tempEle.innerHTML : tempEle.outerHTML;
357
+ }
358
+ else {
359
+ stringContent = template;
360
+ }
361
+ }
362
+ catch (e) {
363
+ stringContent = template;
364
+ }
365
+ return compile(stringContent);
366
+ };
367
+ Rating.prototype.displayLabel = function () {
368
+ if (this.showLabel) {
369
+ this.spanLabel = this.createElement('span', { className: LABEL });
370
+ this.updateLabel();
371
+ this.updateLabelPosition();
372
+ }
373
+ else {
374
+ if (this.wrapper.contains(this.spanLabel)) {
375
+ remove(this.spanLabel);
376
+ this.spanLabel = null;
377
+ }
378
+ }
379
+ };
380
+ Rating.prototype.updateLabel = function () {
381
+ if (this.showLabel) {
382
+ if (this.labelTemplate) {
383
+ if (this.spanLabel.firstChild) {
384
+ this.spanLabel.removeChild(this.spanLabel.firstChild);
385
+ }
386
+ var templateFunction = this.getTemplateString(this.labelTemplate);
387
+ this.spanLabel.append(templateFunction({ value: this.currentValue }, this, 'ratingLabelTemplate', (this.element.id + 'labelTemplate'), this.isStringTemplate)[0]);
388
+ }
389
+ else {
390
+ this.spanLabel.textContent = this.currentValue + ' / ' + this.itemsCount;
391
+ }
392
+ this.renderReactTemplates();
393
+ }
394
+ };
395
+ Rating.prototype.updateReset = function () {
396
+ if (this.allowReset) {
397
+ this.resetElement = this.createElement('span', { className: RESET });
398
+ this.updateResetButton();
399
+ EventHandler.add(this.resetElement, 'click', this.resetClicked, this);
400
+ this.wrapper.insertBefore(this.resetElement, this.ratingItemList);
401
+ }
402
+ else {
403
+ if (this.wrapper.contains(this.resetElement)) {
404
+ remove(this.resetElement);
405
+ this.resetElement = null;
406
+ }
407
+ }
408
+ };
409
+ Rating.prototype.updateLabelPosition = function () {
410
+ this.clearLabelPosition();
411
+ this.spanLabel.classList.add('e-label-' + this.labelPosition.toLowerCase());
412
+ if (this.labelPosition === 'Left' || this.labelPosition === 'Top') {
413
+ this.wrapper.firstChild.after(this.spanLabel);
414
+ }
415
+ else {
416
+ this.wrapper.appendChild(this.spanLabel);
417
+ }
418
+ };
419
+ Rating.prototype.clearLabelPosition = function () {
420
+ var removeCss = this.spanLabel.classList.value.match(/(e-label-[top|bottom|right|left]+)/g);
421
+ if (removeCss) {
422
+ removeClass([this.spanLabel], removeCss);
423
+ }
424
+ };
425
+ Rating.prototype.wireItemsEvents = function (itemElement, index) {
426
+ var _this = this;
427
+ EventHandler.add(itemElement, 'click', function (e) { return _this.clickHandler(e); }, this);
428
+ EventHandler.add(itemElement, 'mousemove', function (e) { return _this.mouseMoveHandler(index, e); }, this);
429
+ EventHandler.add(itemElement, 'mouseleave', this.mouseLeaveHandler, this);
430
+ };
431
+ Rating.prototype.clickHandler = function (e) {
432
+ this.currentValue = (this.min > 0 && this.currentValue < this.min) ? this.min : this.currentValue;
433
+ this.triggerChange(e, this.currentValue);
434
+ this.updateItemValue();
435
+ this.updateLabel();
436
+ if (this.allowReset) {
437
+ this.updateResetButton();
438
+ }
439
+ };
440
+ Rating.prototype.triggerChange = function (e, val, isInteracted) {
441
+ if (isInteracted === void 0) { isInteracted = true; }
442
+ val = this.validateValue(val);
443
+ this.currentValue = val;
444
+ if (this.currentValue === this.value) {
445
+ return;
446
+ }
447
+ var eventArgs = { event: e, isInteracted: isInteracted, value: val, previousValue: this.value };
448
+ this.setProperties({ value: val }, true);
449
+ this.trigger('valueChanged', eventArgs);
450
+ };
451
+ Rating.prototype.mouseMoveHandler = function (index, e) {
452
+ var currValue = this.calculateCurrentValue(index, e);
453
+ currValue = this.validateValue(currValue);
454
+ var element = this.itemElements[parseInt((index - 1).toString(), 10)];
455
+ if (currValue === this.currentValue) {
456
+ this.openRatingTooltip(element, false);
457
+ return;
458
+ }
459
+ this.updateCurrentValue(currValue);
460
+ this.openRatingTooltip(element, true);
461
+ var eventArgs = { element: element, event: e, value: currValue };
462
+ this.trigger('onItemHover', eventArgs);
463
+ };
464
+ Rating.prototype.openRatingTooltip = function (element, isChange) {
465
+ if (this.showTooltip) {
466
+ if (!this.tooltipOpen) {
467
+ this.updateTooltipContent(false);
468
+ this.tooltipObj.open(element); //eslint-disable-line
469
+ this.tooltipOpen = true;
470
+ }
471
+ else if (isChange) {
472
+ this.updateTooltipContent(true);
473
+ this.tooltipObj.refresh(element);
474
+ }
475
+ }
476
+ };
477
+ Rating.prototype.closeRatingTooltip = function () {
478
+ if (this.tooltipOpen) {
479
+ this.tooltipObj.close();
480
+ this.tooltipOpen = false;
481
+ }
482
+ };
483
+ Rating.prototype.updateCurrentValue = function (currValue) {
484
+ this.currentValue = currValue;
485
+ this.updateItemValue();
486
+ this.updateLabel();
487
+ };
488
+ Rating.prototype.mouseLeaveHandler = function () {
489
+ this.closeRatingTooltip();
490
+ this.updateCurrentValue(this.value);
491
+ };
492
+ Rating.prototype.calculateCurrentValue = function (index, args) {
493
+ var currentValue = index;
494
+ if (this.precision !== PrecisionType.Full) {
495
+ currentValue = args.offsetX / this.itemElements[index - 1].clientWidth;
496
+ currentValue = (this.enableRtl) ? (1 - currentValue) : currentValue;
497
+ if (this.precision === PrecisionType.Quarter) {
498
+ currentValue = currentValue <= 0.25 ? 0.25 : currentValue <= 0.5 ? 0.5 : currentValue < 0.75 ? 0.75 : 1.0;
499
+ }
500
+ else if (this.precision === PrecisionType.Half) {
501
+ currentValue = currentValue <= 0.5 ? 0.5 : 1;
502
+ }
503
+ currentValue = currentValue + index - 1;
504
+ }
505
+ return currentValue;
506
+ };
507
+ /**
508
+ * Reset’s the value to minimum.
509
+ *
510
+ * @returns {void}
511
+ */
512
+ Rating.prototype.reset = function () {
513
+ this.resetClicked(null, false);
514
+ };
515
+ Rating.prototype.resetClicked = function (e, isInteracted) {
516
+ if (isInteracted === void 0) { isInteracted = true; }
517
+ this.triggerChange(e, this.min, isInteracted);
518
+ this.updateItemValue();
519
+ this.updateLabel();
520
+ this.updateResetButton();
521
+ };
522
+ Rating.prototype.wireKeyboardEvent = function () {
523
+ this.keyboardModuleRating = new KeyboardEvents(this.wrapper, {
524
+ keyAction: this.keyActionHandler.bind(this),
525
+ keyConfigs: this.keyConfigs,
526
+ eventName: 'keydown'
527
+ });
528
+ };
529
+ Rating.prototype.keyActionHandler = function (e) {
530
+ if (this.disabled || this.readOnly) {
531
+ return;
532
+ }
533
+ if (e.target.classList.contains(ITEMLIST)) {
534
+ switch (e.action) {
535
+ case 'uparrow':
536
+ this.handleNavigation(e, true);
537
+ break;
538
+ case 'downarrow':
539
+ this.handleNavigation(e, false);
540
+ break;
541
+ case 'leftarrow':
542
+ this.handleNavigation(e, this.enableRtl);
543
+ break;
544
+ case 'rightarrow':
545
+ this.handleNavigation(e, !this.enableRtl);
546
+ break;
547
+ }
548
+ }
549
+ if (this.allowReset && e.target.classList.contains('e-reset')) {
550
+ switch (e.action) {
551
+ case 'space':
552
+ this.resetClicked(e);
553
+ break;
554
+ }
555
+ }
556
+ };
557
+ Rating.prototype.handleNavigation = function (e, isIncrease) {
558
+ if ((!isIncrease && (this.value > this.min)) || (isIncrease && (this.value < this.itemsCount))) {
559
+ var currentValue = (this.precision === PrecisionType.Full) ? 1 : (this.precision === PrecisionType.Half) ? 0.5 :
560
+ (this.precision === PrecisionType.Quarter) ? 0.25 : Math.round(0.1 * 10) / 10;
561
+ currentValue = isIncrease ? this.value + currentValue : this.value - currentValue;
562
+ this.triggerChange(e, (currentValue));
563
+ this.updateItemValue();
564
+ this.updateLabel();
565
+ if (this.allowReset) {
566
+ this.updateResetButton();
567
+ }
568
+ }
569
+ };
570
+ Rating.prototype.updateContent = function () {
571
+ for (var i = 0; i < this.itemsCount; i++) {
572
+ var itemElement = this.itemElements[parseInt(i.toString(), 10)].firstElementChild;
573
+ this.renderItemContent(itemElement, this.getRatingValue(this.value, i), i, true);
574
+ }
575
+ };
576
+ /**
577
+ * To get component name.
578
+ *
579
+ * @returns {string} - Module Name
580
+ * @private
581
+ */
582
+ Rating.prototype.getModuleName = function () {
583
+ return 'rating';
584
+ };
585
+ /**
586
+ * To get the properties to be maintained in the persisted state.
587
+ *
588
+ * @returns {string} - Persist data
589
+ */
590
+ Rating.prototype.getPersistData = function () {
591
+ return this.addOnPersist([]);
592
+ };
593
+ Rating.prototype.removeItemElements = function () {
594
+ for (var i = 0; i < this.itemElements.length; i++) {
595
+ remove(this.itemElements[parseInt(i.toString(), 10)]);
596
+ }
597
+ this.itemElements = [];
598
+ };
599
+ /**
600
+ * Destroys the Rating instance.
601
+ *
602
+ * @returns {void}
603
+ */
604
+ Rating.prototype.destroy = function () {
605
+ var _this = this;
606
+ _super.prototype.destroy.call(this);
607
+ // unwires the events and detach the li elements
608
+ this.removeItemElements();
609
+ if (this.spanLabel) {
610
+ remove(this.spanLabel);
611
+ this.spanLabel = null;
612
+ }
613
+ if (this.resetElement) {
614
+ remove(this.resetElement);
615
+ this.resetElement = null;
616
+ }
617
+ if (this.showTooltip) {
618
+ this.tooltipObj.destroy();
619
+ this.tooltipObj = null;
620
+ }
621
+ remove(this.ratingItemList);
622
+ this.ratingItemList = null;
623
+ this.wrapper.parentNode.insertBefore(this.element, this.wrapper);
624
+ remove(this.wrapper);
625
+ this.wrapper = null;
626
+ this.keyboardModuleRating.destroy();
627
+ ['value', 'aria-label', 'name'].forEach(function (attr) {
628
+ _this.element.removeAttribute(attr);
629
+ });
630
+ };
631
+ /**
632
+ * Called internally if any of the property value changed.
633
+ *
634
+ * @param {RatingModel} newProp - Specifies new properties
635
+ * @param {RatingModel} oldProp - Specifies old properties
636
+ * @returns {void}
637
+ * @private
638
+ */
639
+ Rating.prototype.onPropertyChanged = function (newProp, oldProp) {
640
+ for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) {
641
+ var prop = _a[_i];
642
+ switch (prop) {
643
+ case 'value':
644
+ this.triggerChange(null, (this.value > this.min) ? this.value : this.min, false);
645
+ this.updateItemValue();
646
+ this.updateLabel();
647
+ break;
648
+ case 'min':
649
+ this.updateMinValue();
650
+ this.updateItemValue();
651
+ this.updateLabel();
652
+ break;
653
+ case 'showLabel':
654
+ this.displayLabel();
655
+ break;
656
+ case 'visible':
657
+ this.wrapper.classList[!this.visible ? 'add' : 'remove'](HIDDEN);
658
+ break;
659
+ case 'disabled':
660
+ this.updateDisabled();
661
+ break;
662
+ case 'readOnly':
663
+ this.wrapper.classList[this.readOnly ? 'add' : 'remove'](READONLY);
664
+ break;
665
+ case 'allowReset':
666
+ this.updateReset();
667
+ break;
668
+ case 'enableRtl':
669
+ this.wrapper.classList[this.enableRtl ? 'add' : 'remove'](RTL);
670
+ break;
671
+ case 'cssClass':
672
+ if (oldProp.cssClass) {
673
+ removeClass([this.wrapper], oldProp.cssClass.split(' '));
674
+ }
675
+ if (newProp.cssClass) {
676
+ addClass([this.wrapper], newProp.cssClass.split(' '));
677
+ }
678
+ break;
679
+ case 'labelPosition':
680
+ this.updateLabelPosition();
681
+ break;
682
+ case 'showTooltip':
683
+ this.updateTooltip();
684
+ break;
685
+ case 'precision':
686
+ this.updatePrecision();
687
+ this.updateLabel();
688
+ break;
689
+ case 'enableSingleSelection':
690
+ this.updateItemValue();
691
+ break;
692
+ case 'enableAnimation':
693
+ this.wrapper.classList[this.enableAnimation ? 'add' : 'remove'](ANIMATION);
694
+ break;
695
+ case 'emptyTemplate':
696
+ case 'fullTemplate':
697
+ this.updateTemplateFunction();
698
+ this.updateContent();
699
+ break;
700
+ case 'labelTemplate':
701
+ this.updateLabel();
702
+ break;
703
+ case 'itemsCount':
704
+ this.removeItemElements();
705
+ this.renderItems();
706
+ this.updateItemValue();
707
+ this.updateLabel();
708
+ break;
709
+ }
710
+ }
711
+ };
712
+ __decorate([
713
+ Property(false)
714
+ ], Rating.prototype, "allowReset", void 0);
715
+ __decorate([
716
+ Property('')
717
+ ], Rating.prototype, "cssClass", void 0);
718
+ __decorate([
719
+ Property(false)
720
+ ], Rating.prototype, "disabled", void 0);
721
+ __decorate([
722
+ Property(true)
723
+ ], Rating.prototype, "enableAnimation", void 0);
724
+ __decorate([
725
+ Property('')
726
+ ], Rating.prototype, "emptyTemplate", void 0);
727
+ __decorate([
728
+ Property(false)
729
+ ], Rating.prototype, "enableSingleSelection", void 0);
730
+ __decorate([
731
+ Property('')
732
+ ], Rating.prototype, "fullTemplate", void 0);
733
+ __decorate([
734
+ Property(5)
735
+ ], Rating.prototype, "itemsCount", void 0);
736
+ __decorate([
737
+ Property(LabelPosition.Right)
738
+ ], Rating.prototype, "labelPosition", void 0);
739
+ __decorate([
740
+ Property('')
741
+ ], Rating.prototype, "labelTemplate", void 0);
742
+ __decorate([
743
+ Property(0.0)
744
+ ], Rating.prototype, "min", void 0);
745
+ __decorate([
746
+ Property(PrecisionType.Full)
747
+ ], Rating.prototype, "precision", void 0);
748
+ __decorate([
749
+ Property(false)
750
+ ], Rating.prototype, "readOnly", void 0);
751
+ __decorate([
752
+ Property(false)
753
+ ], Rating.prototype, "showLabel", void 0);
754
+ __decorate([
755
+ Property(true)
756
+ ], Rating.prototype, "showTooltip", void 0);
757
+ __decorate([
758
+ Property('')
759
+ ], Rating.prototype, "tooltipTemplate", void 0);
760
+ __decorate([
761
+ Property(0.0)
762
+ ], Rating.prototype, "value", void 0);
763
+ __decorate([
764
+ Property(true)
765
+ ], Rating.prototype, "visible", void 0);
766
+ __decorate([
767
+ Event()
768
+ ], Rating.prototype, "beforeItemRender", void 0);
769
+ __decorate([
770
+ Event()
771
+ ], Rating.prototype, "created", void 0);
772
+ __decorate([
773
+ Event()
774
+ ], Rating.prototype, "onItemHover", void 0);
775
+ __decorate([
776
+ Event()
777
+ ], Rating.prototype, "valueChanged", void 0);
778
+ Rating = __decorate([
779
+ NotifyPropertyChanges
780
+ ], Rating);
781
+ return Rating;
782
+ }(Component));
783
+ export { Rating };