@progress/kendo-angular-label 3.1.3 → 4.0.0-dev.202204131904

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 (76) hide show
  1. package/bundles/kendo-angular-label.umd.js +5 -0
  2. package/{dist/es2015 → esm2015}/floating-label/floating-label-input-adapter.js +0 -0
  3. package/{dist/es2015 → esm2015}/floating-label/floating-label.component.js +74 -79
  4. package/{dist/es2015 → esm2015}/floating-label/floating-label.module.js +14 -11
  5. package/{dist/es → esm2015}/floating-label/models/label-position.js +1 -0
  6. package/{dist/es2015/shared.module.d.ts → esm2015/kendo-angular-label.js} +2 -3
  7. package/esm2015/label/label.component.js +158 -0
  8. package/{dist/es2015 → esm2015}/label.directive.js +21 -24
  9. package/{dist/es2015 → esm2015}/label.module.js +16 -11
  10. package/esm2015/localization/custom-messages.component.js +41 -0
  11. package/esm2015/localization/localized-messages.directive.js +39 -0
  12. package/esm2015/localization/messages.js +23 -0
  13. package/{dist/es → esm2015}/main.js +2 -0
  14. package/{dist/es2015 → esm2015}/package-metadata.js +1 -1
  15. package/esm2015/shared.module.js +29 -0
  16. package/{dist/es2015 → esm2015}/util.js +0 -0
  17. package/{dist/fesm2015/index.js → fesm2015/kendo-angular-label.js} +245 -205
  18. package/{dist/es2015/floating-label → floating-label}/floating-label-input-adapter.d.ts +2 -1
  19. package/{dist/es2015/floating-label → floating-label}/floating-label.component.d.ts +6 -3
  20. package/{dist/es2015/floating-label → floating-label}/floating-label.module.d.ts +7 -0
  21. package/{dist/es2015/floating-label → floating-label}/models/label-position.d.ts +0 -0
  22. package/{dist/es2015/floating-label/models/label-position.js → kendo-angular-label.d.ts} +5 -0
  23. package/{dist/es2015/label → label}/label.component.d.ts +3 -0
  24. package/{dist/es2015/label.directive.d.ts → label.directive.d.ts} +4 -1
  25. package/{dist/es2015/label.module.d.ts → label.module.d.ts} +9 -0
  26. package/{dist/es2015/localization → localization}/custom-messages.component.d.ts +4 -1
  27. package/{dist/es2015/localization → localization}/localized-messages.directive.d.ts +3 -0
  28. package/{dist/es2015/localization → localization}/messages.d.ts +3 -0
  29. package/{dist/es2015/main.d.ts → main.d.ts} +2 -0
  30. package/{dist/es2015/package-metadata.d.ts → package-metadata.d.ts} +0 -0
  31. package/package.json +34 -107
  32. package/schematics/ngAdd/index.js +5 -2
  33. package/schematics/ngAdd/index.js.map +1 -1
  34. package/shared.module.d.ts +15 -0
  35. package/{dist/es2015/util.d.ts → util.d.ts} +0 -0
  36. package/dist/cdn/js/kendo-angular-label.js +0 -20
  37. package/dist/cdn/main.js +0 -5
  38. package/dist/es/floating-label/floating-label-input-adapter.js +0 -58
  39. package/dist/es/floating-label/floating-label.component.js +0 -312
  40. package/dist/es/floating-label/floating-label.module.js +0 -52
  41. package/dist/es/index.js +0 -11
  42. package/dist/es/label/label.component.js +0 -137
  43. package/dist/es/label.directive.js +0 -140
  44. package/dist/es/label.module.js +0 -63
  45. package/dist/es/localization/custom-messages.component.js +0 -44
  46. package/dist/es/localization/localized-messages.directive.js +0 -35
  47. package/dist/es/localization/messages.js +0 -22
  48. package/dist/es/package-metadata.js +0 -15
  49. package/dist/es/shared.module.js +0 -27
  50. package/dist/es/util.js +0 -33
  51. package/dist/es2015/index.d.ts +0 -11
  52. package/dist/es2015/index.js +0 -11
  53. package/dist/es2015/index.metadata.json +0 -1
  54. package/dist/es2015/label/label.component.js +0 -146
  55. package/dist/es2015/localization/custom-messages.component.js +0 -36
  56. package/dist/es2015/localization/localized-messages.directive.js +0 -34
  57. package/dist/es2015/localization/messages.js +0 -16
  58. package/dist/es2015/main.js +0 -10
  59. package/dist/es2015/shared.module.js +0 -24
  60. package/dist/fesm5/index.js +0 -858
  61. package/dist/npm/floating-label/floating-label-input-adapter.js +0 -60
  62. package/dist/npm/floating-label/floating-label.component.js +0 -314
  63. package/dist/npm/floating-label/floating-label.module.js +0 -54
  64. package/dist/npm/floating-label/models/label-position.js +0 -6
  65. package/dist/npm/index.js +0 -17
  66. package/dist/npm/label/label.component.js +0 -139
  67. package/dist/npm/label.directive.js +0 -142
  68. package/dist/npm/label.module.js +0 -65
  69. package/dist/npm/localization/custom-messages.component.js +0 -46
  70. package/dist/npm/localization/localized-messages.directive.js +0 -37
  71. package/dist/npm/localization/messages.js +0 -24
  72. package/dist/npm/main.js +0 -18
  73. package/dist/npm/package-metadata.js +0 -17
  74. package/dist/npm/shared.module.js +0 -29
  75. package/dist/npm/util.js +0 -35
  76. package/dist/systemjs/kendo-angular-label.js +0 -5
@@ -1,858 +0,0 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the project root for more information
4
- *-------------------------------------------------------------------------------------------*/
5
- import { __decorate, __metadata, __extends } from 'tslib';
6
- import { Input, HostBinding, Directive, ElementRef, Renderer2, NgZone, forwardRef, Component, NgModule, EventEmitter, isDevMode, Output, ContentChild, ChangeDetectorRef, ViewChild } from '@angular/core';
7
- import { isDocumentAvailable, guid, hasObservers, KendoInput } from '@progress/kendo-angular-common';
8
- import { ComponentMessages, LocalizationService, L10N_PREFIX } from '@progress/kendo-angular-l10n';
9
- import { CommonModule } from '@angular/common';
10
- import { NgControl } from '@angular/forms';
11
- import { validatePackage } from '@progress/kendo-licensing';
12
- import { Observable, Subscription } from 'rxjs';
13
-
14
- /**
15
- * @hidden
16
- */
17
- var isUploadComponent = function (component) { return component.wrapper && (component.wrapper.tagName === 'KENDO-UPLOAD' || component.wrapper.tagName === 'KENDO-FILESELECT'); };
18
- /**
19
- * @hidden
20
- */
21
- var isInputElement = function (component) { return component instanceof HTMLElement; };
22
- /**
23
- * @hidden
24
- */
25
- var inputElementHasAttr = function (element, attribute) { return element.hasAttribute(attribute); };
26
- /**
27
- * @hidden
28
- */
29
- var getWrappedNativeInput = function (element) { return element.querySelector('kendo-label > input, kendo-label > textarea, kendo-label > select'); };
30
- /**
31
- * @hidden
32
- */
33
- var getRootElement = function (element) {
34
- if (!element) {
35
- return null;
36
- }
37
- var rootElement = element;
38
- while (rootElement.parentElement) {
39
- rootElement = rootElement.parentElement;
40
- }
41
- return rootElement;
42
- };
43
-
44
- /**
45
- * Represents the [Kendo UI Label directive for Angular]({% slug overview_label %}).
46
- * The Label associates a focusable Angular component or an HTML element
47
- * with a `label` tag by using the `[for]` property binding.
48
- *
49
- * To associate a component by using the `label` element, either:
50
- * * Set the `[for]` property binding to a
51
- * [template reference variable]({{ site.data.urls.angular['templatesyntax'] }}#template-reference-variables--var-), or
52
- * * Set the `[for]` property binding to an `id` HTML string value.
53
- *
54
- * @example
55
- * ```ts
56
- * _@Component({
57
- * selector: 'my-app',
58
- * template: `
59
- * <div class="row example-wrapper" style="min-height: 450px;">
60
- * <div class="col-xs-12 col-md-6 example-col">
61
- * <label [for]="datepicker">DatePicker: </label>
62
- * <kendo-datepicker #datepicker></kendo-datepicker>
63
- * </div>
64
- *
65
- * <div class="col-xs-12 col-md-6 example-col">
66
- * <label for="input">Input: </label>
67
- * <input id="input" />
68
- * </div>
69
- * </div>
70
- * `
71
- * })
72
- * class AppComponent { }
73
- * ```
74
- */
75
- var LabelDirective = /** @class */ (function () {
76
- function LabelDirective(label, renderer, zone) {
77
- var _this = this;
78
- this.label = label;
79
- this.renderer = renderer;
80
- this.zone = zone;
81
- this.labelClass = true;
82
- this.handleClick = function () {
83
- var component = _this.getFocusableComponent();
84
- if (!component) {
85
- return;
86
- }
87
- if (isUploadComponent(component)) {
88
- component.fileSelect.nativeElement.click();
89
- }
90
- if (component.focus) {
91
- component.focus();
92
- }
93
- };
94
- }
95
- Object.defineProperty(LabelDirective.prototype, "labelFor", {
96
- get: function () {
97
- if (typeof this.for === 'string') {
98
- return this.for;
99
- }
100
- if (!isDocumentAvailable()) {
101
- return null;
102
- }
103
- var component = this.getFocusableComponent() || {};
104
- if (isInputElement(component) && !inputElementHasAttr(component, 'id')) {
105
- this.renderer.setAttribute(component, 'id', "k-" + guid());
106
- }
107
- return component.focusableId || component.id || null;
108
- },
109
- enumerable: true,
110
- configurable: true
111
- });
112
- /**
113
- * @hidden
114
- */
115
- LabelDirective.prototype.ngAfterViewInit = function () {
116
- var _this = this;
117
- this.setAriaLabelledby();
118
- this.zone.runOutsideAngular(function () { return _this.clickListener = _this.renderer.listen(_this.label.nativeElement, 'click', _this.handleClick); });
119
- };
120
- /**
121
- * @hidden
122
- */
123
- LabelDirective.prototype.ngOnDestroy = function () {
124
- if (this.clickListener) {
125
- this.clickListener();
126
- }
127
- };
128
- /**
129
- * @hidden
130
- */
131
- LabelDirective.prototype.setAriaLabelledby = function () {
132
- if (!isDocumentAvailable()) {
133
- return;
134
- }
135
- var component = this.getFocusableComponent();
136
- if (component && component.focusableId) {
137
- var rootElement = getRootElement(this.label.nativeElement);
138
- var labelTarget = rootElement.querySelector("#" + component.focusableId);
139
- if (!labelTarget) {
140
- return;
141
- }
142
- var labelElement = this.label.nativeElement;
143
- var id = labelElement.id || "k-" + guid();
144
- if (!labelElement.getAttribute('id')) {
145
- this.renderer.setAttribute(labelElement, 'id', id);
146
- }
147
- this.renderer.setAttribute(labelTarget, 'aria-labelledby', id);
148
- }
149
- };
150
- LabelDirective.prototype.getFocusableComponent = function () {
151
- var target = this.for;
152
- return target && target.focus !== undefined ? target : null;
153
- };
154
- __decorate([
155
- Input(),
156
- __metadata("design:type", Object)
157
- ], LabelDirective.prototype, "for", void 0);
158
- __decorate([
159
- HostBinding('attr.for'),
160
- __metadata("design:type", String),
161
- __metadata("design:paramtypes", [])
162
- ], LabelDirective.prototype, "labelFor", null);
163
- __decorate([
164
- HostBinding('class.k-label'),
165
- __metadata("design:type", Boolean)
166
- ], LabelDirective.prototype, "labelClass", void 0);
167
- LabelDirective = __decorate([
168
- Directive({
169
- selector: 'label[for]' //tslint:disable-line:directive-selector
170
- }),
171
- __metadata("design:paramtypes", [ElementRef, Renderer2, NgZone])
172
- ], LabelDirective);
173
- return LabelDirective;
174
- }());
175
-
176
- /**
177
- * @hidden
178
- */
179
- var Messages = /** @class */ (function (_super) {
180
- __extends(Messages, _super);
181
- function Messages() {
182
- return _super !== null && _super.apply(this, arguments) || this;
183
- }
184
- __decorate([
185
- Input(),
186
- __metadata("design:type", String)
187
- ], Messages.prototype, "optional", void 0);
188
- return Messages;
189
- }(ComponentMessages));
190
-
191
- /**
192
- * @hidden
193
- */
194
- var LocalizedMessagesDirective = /** @class */ (function (_super) {
195
- __extends(LocalizedMessagesDirective, _super);
196
- function LocalizedMessagesDirective(service) {
197
- var _this = _super.call(this) || this;
198
- _this.service = service;
199
- return _this;
200
- }
201
- LocalizedMessagesDirective_1 = LocalizedMessagesDirective;
202
- var LocalizedMessagesDirective_1;
203
- LocalizedMessagesDirective = LocalizedMessagesDirective_1 = __decorate([
204
- Directive({
205
- providers: [
206
- {
207
- provide: Messages,
208
- useExisting: forwardRef(function () { return LocalizedMessagesDirective_1; })
209
- }
210
- ],
211
- selector: "\n [kendoLabelLocalizedMessages],\n [kendoFloatingLabelLocalizedMessages]\n "
212
- }),
213
- __metadata("design:paramtypes", [LocalizationService])
214
- ], LocalizedMessagesDirective);
215
- return LocalizedMessagesDirective;
216
- }(Messages));
217
-
218
- /**
219
- * Custom component messages override default component messages
220
- * ([see example]({% slug label_globalization %}#toc-localization)).
221
- */
222
- var CustomMessagesComponent = /** @class */ (function (_super) {
223
- __extends(CustomMessagesComponent, _super);
224
- function CustomMessagesComponent(service) {
225
- var _this = _super.call(this) || this;
226
- _this.service = service;
227
- return _this;
228
- }
229
- CustomMessagesComponent_1 = CustomMessagesComponent;
230
- Object.defineProperty(CustomMessagesComponent.prototype, "override", {
231
- get: function () {
232
- return true;
233
- },
234
- enumerable: true,
235
- configurable: true
236
- });
237
- var CustomMessagesComponent_1;
238
- CustomMessagesComponent = CustomMessagesComponent_1 = __decorate([
239
- Component({
240
- providers: [
241
- {
242
- provide: Messages,
243
- useExisting: forwardRef(function () { return CustomMessagesComponent_1; })
244
- }
245
- ],
246
- selector: 'kendo-label-messages, kendo-floatinglabel-messages',
247
- template: ""
248
- }),
249
- __metadata("design:paramtypes", [LocalizationService])
250
- ], CustomMessagesComponent);
251
- return CustomMessagesComponent;
252
- }(Messages));
253
-
254
- var SHARED_DIRECTIVES = [
255
- LocalizedMessagesDirective,
256
- CustomMessagesComponent
257
- ];
258
- /**
259
- * @hidden
260
- */
261
- var SharedDirectivesModule = /** @class */ (function () {
262
- function SharedDirectivesModule() {
263
- }
264
- SharedDirectivesModule = __decorate([
265
- NgModule({
266
- declarations: [SHARED_DIRECTIVES],
267
- exports: [SHARED_DIRECTIVES]
268
- })
269
- ], SharedDirectivesModule);
270
- return SharedDirectivesModule;
271
- }());
272
-
273
- /**
274
- * @hidden
275
- */
276
- var packageMetadata = {
277
- name: '@progress/kendo-angular-label',
278
- productName: 'Kendo UI for Angular',
279
- productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
280
- publishDate: 1646219058,
281
- version: '',
282
- licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
283
- };
284
-
285
- /**
286
- * @hidden
287
- */
288
- var FloatingLabelInputAdapter = /** @class */ (function () {
289
- function FloatingLabelInputAdapter(component, formControl) {
290
- this.component = component;
291
- var isObservableOrEventEmitter = function (event) { return event instanceof Observable || event instanceof EventEmitter; };
292
- if (isObservableOrEventEmitter(component.onFocus)) {
293
- this.onFocus = component.onFocus;
294
- }
295
- if (isObservableOrEventEmitter(component.autoFillStart)) {
296
- this.autoFillStart = component.autoFillStart;
297
- }
298
- if (isObservableOrEventEmitter(component.autoFillEnd)) {
299
- this.autoFillEnd = component.autoFillEnd;
300
- }
301
- if (isObservableOrEventEmitter(component.onBlur)) {
302
- this.onBlur = component.onBlur;
303
- }
304
- if (formControl) {
305
- this.onValueChange = formControl.valueChanges;
306
- }
307
- else if (component.onValueChange) {
308
- this.onValueChange = component.onValueChange;
309
- }
310
- }
311
- Object.defineProperty(FloatingLabelInputAdapter.prototype, "focusableId", {
312
- get: function () {
313
- var component = this.component;
314
- if ('focusableId' in component) {
315
- return component.focusableId;
316
- }
317
- else if ('id' in component) {
318
- return component.id;
319
- }
320
- return "";
321
- },
322
- set: function (value) {
323
- var component = this.component;
324
- if ('focusableId' in component) {
325
- component.focusableId = value;
326
- }
327
- else if ('id' in component) {
328
- component.id = value;
329
- }
330
- },
331
- enumerable: true,
332
- configurable: true
333
- });
334
- return FloatingLabelInputAdapter;
335
- }());
336
-
337
- var isFunction = function (x) { return Object.prototype.toString.call(x) === '[object Function]'; };
338
- /**
339
- * Represents the [Kendo UI FloatingLabel component for Angular]({% slug overview_floatinglabel %}).
340
- * Provides floating labels to `input` elements.
341
- *
342
- * The FloatingLabel supports both Template and Reactive Forms and
343
- * [can contain Kendo UI for Angular Input components such as `kendo-combobox` and `kendo-numerictextbox`,
344
- * or HTML Input elements with the `kendoTextBox` directive applied]({% slug overview_floatinglabel %}#toc-implementing-floating-labels).
345
- *
346
- * @example
347
- * ```ts
348
- *
349
- * _@Component({
350
- * selector: 'my-app',
351
- * template: `
352
- * <kendo-floatinglabel text="First name">
353
- * <input [(ngModel)]="name" kendoTextBox />
354
- * </kendo-floatinglabel>
355
- * `
356
- * })
357
- * class AppComponent {
358
- * public name = 'John';
359
- * }
360
- *
361
- * ```
362
- */
363
- var FloatingLabelComponent = /** @class */ (function () {
364
- function FloatingLabelComponent(elementRef, renderer, changeDetectorRef, localization) {
365
- this.elementRef = elementRef;
366
- this.renderer = renderer;
367
- this.changeDetectorRef = changeDetectorRef;
368
- this.localization = localization;
369
- this.hostClasses = true;
370
- /**
371
- * Fires after the floating label position is changed.
372
- */
373
- this.positionChange = new EventEmitter();
374
- /**
375
- * @hidden
376
- */
377
- this.focused = false;
378
- /**
379
- * @hidden
380
- */
381
- this.empty = true;
382
- /**
383
- * @hidden
384
- */
385
- this.invalid = false;
386
- /**
387
- * @hidden
388
- */
389
- this.labelId = "k-" + guid();
390
- this.autoFillStarted = false;
391
- validatePackage(packageMetadata);
392
- this.direction = localization.rtl ? 'rtl' : 'ltr';
393
- this.renderer.removeAttribute(this.elementRef.nativeElement, "id");
394
- }
395
- Object.defineProperty(FloatingLabelComponent.prototype, "labelPosition", {
396
- /**
397
- * Represents the current floating label position.
398
- */
399
- get: function () {
400
- if (!this.empty) {
401
- return 'Out';
402
- }
403
- return this.focused ? 'Out' : 'In';
404
- },
405
- enumerable: true,
406
- configurable: true
407
- });
408
- Object.defineProperty(FloatingLabelComponent.prototype, "focusedClass", {
409
- get: function () {
410
- return this.focused;
411
- },
412
- enumerable: true,
413
- configurable: true
414
- });
415
- Object.defineProperty(FloatingLabelComponent.prototype, "invalidClass", {
416
- get: function () {
417
- return this.invalid;
418
- },
419
- enumerable: true,
420
- configurable: true
421
- });
422
- /**
423
- * @hidden
424
- */
425
- FloatingLabelComponent.prototype.ngAfterContentInit = function () {
426
- this.validateSetup();
427
- var control = new FloatingLabelInputAdapter(this.kendoInput || this.formControl.valueAccessor, this.formControl);
428
- this.addHandlers(control);
429
- this.setLabelFor(control);
430
- };
431
- FloatingLabelComponent.prototype.ngAfterViewInit = function () {
432
- if (this.kendoInput) {
433
- this.setAriaLabelledby(this.kendoInput);
434
- }
435
- };
436
- /**
437
- * @hidden
438
- */
439
- FloatingLabelComponent.prototype.ngOnDestroy = function () {
440
- if (this.subscription) {
441
- this.subscription.unsubscribe();
442
- }
443
- };
444
- /**
445
- * @hidden
446
- */
447
- FloatingLabelComponent.prototype.textFor = function (key) {
448
- return this.localization.get(key);
449
- };
450
- FloatingLabelComponent.prototype.subscribe = function (control, eventName, handler) {
451
- if (control[eventName] instanceof EventEmitter) {
452
- var subscription = control[eventName].subscribe(handler);
453
- if (!this.subscription) {
454
- this.subscription = subscription;
455
- }
456
- else {
457
- this.subscription.add(subscription);
458
- }
459
- }
460
- };
461
- FloatingLabelComponent.prototype.updateState = function () {
462
- var empty = function (value) {
463
- // zero is not an empty value (e.g., NumericTextBox)
464
- if (value === 0 || value === false) {
465
- return false;
466
- }
467
- // empty arrays are an empty value (e.g., MultiSelect)
468
- if (Array.isArray(value) && !value.length) {
469
- return true;
470
- }
471
- return !value;
472
- };
473
- var formControl = this.formControl;
474
- if (formControl) {
475
- var valueAccessor = formControl.valueAccessor;
476
- if (isFunction(valueAccessor.isEmpty)) {
477
- this.empty = valueAccessor.isEmpty();
478
- }
479
- else {
480
- this.empty = empty(formControl.value);
481
- }
482
- this.invalid = formControl.invalid && (formControl.touched || formControl.dirty);
483
- }
484
- else {
485
- this.empty = isFunction(this.kendoInput.isEmpty) ?
486
- this.kendoInput.isEmpty() : empty(this.kendoInput.value);
487
- }
488
- if (this.empty) {
489
- this.renderer.addClass(this.elementRef.nativeElement, 'k-state-empty');
490
- }
491
- else {
492
- this.renderer.removeClass(this.elementRef.nativeElement, 'k-state-empty');
493
- }
494
- this.changeDetectorRef.markForCheck();
495
- };
496
- FloatingLabelComponent.prototype.setAriaLabelledby = function (component) {
497
- var componentId = component.focusableId || component.id;
498
- if (componentId) {
499
- var focusableElement = this.elementRef.nativeElement.querySelector("#" + componentId);
500
- this.renderer.setAttribute(focusableElement, 'aria-labelledby', this.labelId);
501
- }
502
- };
503
- FloatingLabelComponent.prototype.setLabelFor = function (control) {
504
- var controlId = control.focusableId || control.id;
505
- if (this.id && controlId) {
506
- // input wins
507
- this.id = controlId;
508
- }
509
- else if (this.id) {
510
- control.focusableId = this.id;
511
- }
512
- else if (controlId) {
513
- this.id = controlId;
514
- }
515
- else {
516
- var id = "k-" + guid();
517
- control.focusableId = id;
518
- this.id = id;
519
- }
520
- };
521
- FloatingLabelComponent.prototype.handleAutofill = function (control) {
522
- var _this = this;
523
- this.subscribe(control, 'autoFillStart', function () {
524
- _this.autoFillStarted = true;
525
- _this.renderer.removeClass(_this.elementRef.nativeElement, 'k-state-empty');
526
- });
527
- this.subscribe(control, 'autoFillEnd', function () {
528
- if (_this.autoFillStarted) {
529
- _this.autoFillStarted = false;
530
- if (_this.empty) {
531
- _this.renderer.addClass(_this.elementRef.nativeElement, 'k-state-empty');
532
- }
533
- }
534
- });
535
- };
536
- FloatingLabelComponent.prototype.addHandlers = function (control) {
537
- var _this = this;
538
- var setFocus = function (isFocused) { return function () {
539
- _this.focused = isFocused;
540
- _this.updateState();
541
- if (!_this.empty) {
542
- return;
543
- }
544
- if (hasObservers(_this.positionChange)) {
545
- _this.positionChange.emit(isFocused ? 'Out' : 'In');
546
- }
547
- }; };
548
- this.subscribe(control, 'onFocus', setFocus(true));
549
- this.subscribe(control, 'onBlur', setFocus(false));
550
- this.handleAutofill(control);
551
- var updateState = function () { return _this.updateState(); };
552
- updateState();
553
- this.subscribe(control, 'onValueChange', updateState);
554
- };
555
- FloatingLabelComponent.prototype.validateSetup = function () {
556
- if (!this.formControl && !this.kendoInput) {
557
- if (isDevMode()) {
558
- throw new Error("The FloatingLabelComponent requires a Kendo Input component" +
559
- " or a forms-bound component to function properly.");
560
- }
561
- return;
562
- }
563
- };
564
- __decorate([
565
- HostBinding('class.k-floating-label-container'),
566
- __metadata("design:type", Boolean)
567
- ], FloatingLabelComponent.prototype, "hostClasses", void 0);
568
- __decorate([
569
- HostBinding('class.k-state-focused'),
570
- __metadata("design:type", Boolean),
571
- __metadata("design:paramtypes", [])
572
- ], FloatingLabelComponent.prototype, "focusedClass", null);
573
- __decorate([
574
- HostBinding('class.k-state-invalid'),
575
- __metadata("design:type", Boolean),
576
- __metadata("design:paramtypes", [])
577
- ], FloatingLabelComponent.prototype, "invalidClass", null);
578
- __decorate([
579
- HostBinding('attr.dir'),
580
- __metadata("design:type", String)
581
- ], FloatingLabelComponent.prototype, "direction", void 0);
582
- __decorate([
583
- Input(),
584
- __metadata("design:type", Object)
585
- ], FloatingLabelComponent.prototype, "labelCssStyle", void 0);
586
- __decorate([
587
- Input(),
588
- __metadata("design:type", Object)
589
- ], FloatingLabelComponent.prototype, "labelCssClass", void 0);
590
- __decorate([
591
- Input(),
592
- __metadata("design:type", String)
593
- ], FloatingLabelComponent.prototype, "id", void 0);
594
- __decorate([
595
- Input(),
596
- __metadata("design:type", String)
597
- ], FloatingLabelComponent.prototype, "text", void 0);
598
- __decorate([
599
- Input(),
600
- __metadata("design:type", Boolean)
601
- ], FloatingLabelComponent.prototype, "optional", void 0);
602
- __decorate([
603
- Output(),
604
- __metadata("design:type", EventEmitter)
605
- ], FloatingLabelComponent.prototype, "positionChange", void 0);
606
- __decorate([
607
- ContentChild(KendoInput, { static: false }),
608
- __metadata("design:type", Object)
609
- ], FloatingLabelComponent.prototype, "kendoInput", void 0);
610
- __decorate([
611
- ContentChild(NgControl, { static: false }),
612
- __metadata("design:type", NgControl)
613
- ], FloatingLabelComponent.prototype, "formControl", void 0);
614
- FloatingLabelComponent = __decorate([
615
- Component({
616
- selector: 'kendo-floatinglabel',
617
- exportAs: 'kendoFloatingLabel',
618
- providers: [
619
- LocalizationService,
620
- {
621
- provide: L10N_PREFIX,
622
- useValue: 'kendo.floatinglabel'
623
- }
624
- ],
625
- template: "\n <ng-container kendoFloatingLabelLocalizedMessages\n i18n-optional=\"kendo.floatinglabel.optional|The text for the optional segment of a FloatingLabel component\"\n optional=\"Optional\"\n >\n </ng-container>\n <ng-content></ng-content>\n <label *ngIf=\"text\" [ngClass]=\"labelCssClass\" [ngStyle]=\"labelCssStyle\" [for]=\"id\" [attr.id]=\"labelId\" class=\"k-label\">\n {{ text }}<span *ngIf=\"optional\" class=\"k-label-optional\">({{textFor('optional')}})</span>\n </label>\n "
626
- }),
627
- __metadata("design:paramtypes", [ElementRef,
628
- Renderer2,
629
- ChangeDetectorRef,
630
- LocalizationService])
631
- ], FloatingLabelComponent);
632
- return FloatingLabelComponent;
633
- }());
634
-
635
- var COMPONENT_DIRECTIVES = [FloatingLabelComponent];
636
- /**
637
- * Represents the [NgModule]({{ site.data.urls.angular['ngmoduleapi'] }})
638
- * definition for the TextBox directive.
639
- *
640
- * @example
641
- *
642
- * ```ts-no-run
643
- *
644
- * // The browser platform with a compiler
645
- * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
646
- *
647
- * import { NgModule } from '@angular/core';
648
- *
649
- * // Import the app component
650
- * import { AppComponent } from './app.component';
651
- *
652
- * // Define the app module
653
- * _@NgModule({
654
- * declarations: [AppComponent], // declare app component
655
- * imports: [BrowserModule, FloatingLabelModule], // import FloatingLabel module
656
- * bootstrap: [AppComponent]
657
- * })
658
- * export class AppModule {}
659
- *
660
- * // Compile and launch the module
661
- * platformBrowserDynamic().bootstrapModule(AppModule);
662
- *
663
- * ```
664
- */
665
- var FloatingLabelModule = /** @class */ (function () {
666
- function FloatingLabelModule() {
667
- }
668
- FloatingLabelModule = __decorate([
669
- NgModule({
670
- declarations: COMPONENT_DIRECTIVES.slice(),
671
- exports: COMPONENT_DIRECTIVES.concat([SharedDirectivesModule]),
672
- imports: [CommonModule, SharedDirectivesModule]
673
- })
674
- ], FloatingLabelModule);
675
- return FloatingLabelModule;
676
- }());
677
-
678
- /**
679
- * Represents the [Kendo UI Label component for Angular]({% slug label_basic %}).
680
- *
681
- * Associates a label with input elements or components.
682
- *
683
- * @example
684
- * ```ts
685
- *
686
- * _@Component({
687
- * selector: 'my-app',
688
- * template: `
689
- * <kendo-label [for]="input" text="First name">
690
- * <input [(ngModel)]="name" kendoTextBox #input />
691
- * </kendo-label>
692
- * `
693
- * })
694
- * class AppComponent {
695
- * public name = 'John';
696
- * }
697
- *
698
- * ```
699
- */
700
- var LabelComponent = /** @class */ (function () {
701
- function LabelComponent(elementRef, renderer, localization) {
702
- this.elementRef = elementRef;
703
- this.renderer = renderer;
704
- this.localization = localization;
705
- this.subscriptions = new Subscription();
706
- validatePackage(packageMetadata);
707
- this.direction = localization.rtl ? 'rtl' : 'ltr';
708
- this.renderer.removeAttribute(this.elementRef.nativeElement, 'id');
709
- }
710
- /**
711
- * @hidden
712
- */
713
- LabelComponent.prototype.ngAfterContentInit = function () {
714
- if (this.for) {
715
- this.control = this.for;
716
- return;
717
- }
718
- var wrappedNativeInput = getWrappedNativeInput(this.elementRef.nativeElement);
719
- if (wrappedNativeInput) {
720
- if (!wrappedNativeInput.hasAttribute('id')) {
721
- this.renderer.setAttribute(wrappedNativeInput, 'id', "k-" + guid());
722
- }
723
- this.control = wrappedNativeInput;
724
- return;
725
- }
726
- this.control = this.kendoInput;
727
- };
728
- /**
729
- * @hidden
730
- */
731
- LabelComponent.prototype.ngOnInit = function () {
732
- var _this = this;
733
- this.subscriptions.add(this.localization.changes.subscribe(function (_a) {
734
- var rtl = _a.rtl;
735
- _this.direction = rtl ? 'rtl' : 'ltr';
736
- }));
737
- };
738
- /**
739
- * @hidden
740
- */
741
- LabelComponent.prototype.ngAfterViewInit = function () {
742
- this.labelDirective.setAriaLabelledby();
743
- };
744
- /**
745
- * @hidden
746
- */
747
- LabelComponent.prototype.ngOnDestroy = function () {
748
- if (this.subscriptions) {
749
- this.subscriptions.unsubscribe();
750
- }
751
- };
752
- /**
753
- * @hidden
754
- */
755
- LabelComponent.prototype.textFor = function (key) {
756
- return this.localization.get(key);
757
- };
758
- __decorate([
759
- HostBinding('attr.dir'),
760
- __metadata("design:type", String)
761
- ], LabelComponent.prototype, "direction", void 0);
762
- __decorate([
763
- Input(),
764
- __metadata("design:type", String)
765
- ], LabelComponent.prototype, "text", void 0);
766
- __decorate([
767
- Input(),
768
- __metadata("design:type", Object)
769
- ], LabelComponent.prototype, "for", void 0);
770
- __decorate([
771
- Input(),
772
- __metadata("design:type", Boolean)
773
- ], LabelComponent.prototype, "optional", void 0);
774
- __decorate([
775
- ViewChild(LabelDirective, { static: true }),
776
- __metadata("design:type", LabelDirective)
777
- ], LabelComponent.prototype, "labelDirective", void 0);
778
- __decorate([
779
- ContentChild(KendoInput, { static: true }),
780
- __metadata("design:type", Object)
781
- ], LabelComponent.prototype, "kendoInput", void 0);
782
- LabelComponent = __decorate([
783
- Component({
784
- selector: 'kendo-label',
785
- exportAs: 'kendoLabel',
786
- providers: [
787
- LocalizationService,
788
- {
789
- provide: L10N_PREFIX,
790
- useValue: 'kendo.label'
791
- }
792
- ],
793
- template: "\n <ng-container kendoLabelLocalizedMessages\n i18n-optional=\"kendo.label.optional|The text for the optional segment of a Label component\"\n optional=\"Optional\"\n >\n </ng-container>\n <label\n [for]=\"control\"\n [class.k-label-empty]=\"!text\">\n {{ text }}<span *ngIf=\"optional\" class=\"k-label-optional\">({{textFor('optional')}})</span>\n </label>\n <ng-content></ng-content>\n "
794
- }),
795
- __metadata("design:paramtypes", [ElementRef,
796
- Renderer2,
797
- LocalizationService])
798
- ], LabelComponent);
799
- return LabelComponent;
800
- }());
801
-
802
- var COMPONENT_DIRECTIVES$1 = [
803
- LabelDirective,
804
- LabelComponent
805
- ];
806
- /**
807
- * The exported package module.
808
- *
809
- * The package exports:
810
- * - `LabelDirective`&mdash;The Label directive class.
811
- * - `LabelComponent`&mdash;The Label component class
812
- * - `FLoatingLabel`&mdash;The FloatingLabel component class.
813
- *
814
- * @example
815
- *
816
- * ```ts-no-run
817
- * // Import the Label module
818
- * import { LabelModule } from '@progress/kendo-angular-label';
819
- *
820
- * // The browser platform with a compiler
821
- * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
822
- *
823
- * import { NgModule } from '@angular/core';
824
- *
825
- * // Import the app component
826
- * import { AppComponent } from './app.component';
827
- *
828
- * // Define the app module
829
- * _@NgModule({
830
- * declarations: [AppComponent], // declare app component
831
- * imports: [BrowserModule, LabelModule], // import Label module
832
- * bootstrap: [AppComponent]
833
- * })
834
- * export class AppModule {}
835
- *
836
- * // Compile and launch the module
837
- * platformBrowserDynamic().bootstrapModule(AppModule);
838
- *
839
- * ```
840
- */
841
- var LabelModule = /** @class */ (function () {
842
- function LabelModule() {
843
- }
844
- LabelModule = __decorate([
845
- NgModule({
846
- imports: [CommonModule, SharedDirectivesModule],
847
- declarations: COMPONENT_DIRECTIVES$1.slice(),
848
- exports: COMPONENT_DIRECTIVES$1.concat([FloatingLabelModule, SharedDirectivesModule])
849
- })
850
- ], LabelModule);
851
- return LabelModule;
852
- }());
853
-
854
- /**
855
- * Generated bundle index. Do not edit.
856
- */
857
-
858
- export { LocalizedMessagesDirective, Messages, SharedDirectivesModule, LabelDirective, LabelModule, FloatingLabelModule, FloatingLabelComponent, LabelComponent, CustomMessagesComponent };