@progressio_resources/gravity-design-system 1.0.6 → 1.0.7

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 (87) hide show
  1. package/esm2020/lib/components/gravity-button/gravity-button.component.mjs +22 -0
  2. package/esm2020/lib/components/gravity-calendar/gravity-calendar.component.mjs +90 -0
  3. package/esm2020/lib/components/gravity-checkbox/gravity-checkbox.component.mjs +23 -0
  4. package/esm2020/lib/components/gravity-dropdown-list/gravity-dropdown-list.component.mjs +43 -0
  5. package/esm2020/lib/components/gravity-radio-button/gravity-radio-button.component.mjs +30 -0
  6. package/esm2020/lib/components/gravity-switch/gravity-switch.component.mjs +17 -0
  7. package/esm2020/lib/components/gravity-text-field/gravity-text-field.component.mjs +62 -0
  8. package/esm2020/lib/gravity-design-system.module.mjs +76 -6
  9. package/esm2020/lib/vendor/gravity-tooltip/gravity-tooltip.component.mjs +205 -0
  10. package/esm2020/lib/vendor/gravity-tooltip/gravity-tooltip.directive.mjs +480 -0
  11. package/esm2020/lib/vendor/gravity-tooltip/gravity-tooltip.module.mjs +41 -0
  12. package/esm2020/lib/vendor/gravity-tooltip/index.mjs +4 -0
  13. package/esm2020/lib/vendor/gravity-tooltip/options.interface.mjs +2 -0
  14. package/esm2020/lib/vendor/gravity-tooltip/options.mjs +38 -0
  15. package/esm2020/lib/vendor/gravity-tooltip/options.service.mjs +7 -0
  16. package/esm2020/public-api.mjs +11 -3
  17. package/fesm2015/progressio_resources-gravity-design-system.mjs +1085 -28
  18. package/fesm2015/progressio_resources-gravity-design-system.mjs.map +1 -1
  19. package/fesm2020/progressio_resources-gravity-design-system.mjs +1083 -28
  20. package/fesm2020/progressio_resources-gravity-design-system.mjs.map +1 -1
  21. package/lib/components/gravity-button/gravity-button.component.d.ts +17 -0
  22. package/lib/components/gravity-calendar/gravity-calendar.component.d.ts +40 -0
  23. package/lib/components/gravity-checkbox/gravity-checkbox.component.d.ts +8 -0
  24. package/lib/components/gravity-dropdown-list/gravity-dropdown-list.component.d.ts +36 -0
  25. package/lib/components/gravity-radio-button/gravity-radio-button.component.d.ts +13 -0
  26. package/lib/components/gravity-switch/gravity-switch.component.d.ts +6 -0
  27. package/lib/components/gravity-text-field/gravity-text-field.component.d.ts +35 -0
  28. package/lib/gravity-design-system.module.d.ts +16 -2
  29. package/lib/vendor/gravity-tooltip/gravity-tooltip.component.d.ts +42 -0
  30. package/lib/vendor/gravity-tooltip/gravity-tooltip.directive.d.ts +112 -0
  31. package/lib/vendor/gravity-tooltip/gravity-tooltip.module.d.ts +12 -0
  32. package/lib/vendor/gravity-tooltip/index.d.ts +3 -0
  33. package/lib/vendor/gravity-tooltip/options.d.ts +24 -0
  34. package/lib/vendor/gravity-tooltip/options.interface.d.ts +40 -0
  35. package/lib/vendor/gravity-tooltip/options.service.d.ts +7 -0
  36. package/package.json +9 -2
  37. package/public-api.d.ts +8 -2
  38. package/src/lib/assets/icons/calendar.svg +14 -0
  39. package/src/lib/assets/icons/check.svg +3 -0
  40. package/src/lib/assets/icons/copy.svg +8 -0
  41. package/src/lib/assets/icons/download.svg +7 -0
  42. package/src/lib/assets/icons/edit.svg +8 -0
  43. package/src/lib/assets/icons/eye_closed.svg +8 -0
  44. package/src/lib/assets/icons/eye_open.svg +6 -0
  45. package/src/lib/assets/icons/forgot_password.svg +7 -0
  46. package/src/lib/assets/icons/lock.svg +6 -0
  47. package/src/lib/assets/icons/logout.svg +9 -0
  48. package/src/lib/assets/icons/mail.svg +6 -0
  49. package/src/lib/assets/icons/radio-off.svg +3 -0
  50. package/src/lib/assets/icons/radio-on.svg +3 -0
  51. package/src/lib/assets/icons/search.svg +8 -0
  52. package/src/lib/assets/icons/settings.svg +12 -0
  53. package/src/lib/assets/icons/show_less.svg +6 -0
  54. package/src/lib/assets/icons/show_more.svg +6 -0
  55. package/src/lib/assets/icons/uncheck.svg +3 -0
  56. package/src/lib/assets/icons/user.svg +6 -0
  57. package/src/lib/assets/icons/x.svg +6 -0
  58. package/src/lib/assets/json/icons.json +91 -0
  59. package/src/lib/styles/_card_highlight.scss +40 -0
  60. package/src/lib/styles/_datepicker.scss +101 -0
  61. package/src/lib/styles/_icons.scss +11 -0
  62. package/src/lib/styles/_link.scss +25 -0
  63. package/src/lib/styles/_shared.scss +19 -0
  64. package/src/lib/styles/fundamentals/colors/themes/_hero.theme.scss +13 -10
  65. package/src/lib/styles/fundamentals/colors/tokens/_hero.tokens.scss +15 -13
  66. package/src/lib/styles/fundamentals/typography/_hero.typography.scss +0 -1
  67. package/src/lib/styles/gravity-design-system.scss +7 -0
  68. package/src/lib/styles/overwrite/pretty-checkbox/_core.scss +120 -0
  69. package/src/lib/styles/overwrite/pretty-checkbox/_variables.scss +39 -0
  70. package/src/lib/styles/overwrite/pretty-checkbox/elements/default/_outline.scss +41 -0
  71. package/src/lib/styles/overwrite/pretty-checkbox/elements/switch/_fill.scss +7 -0
  72. package/src/lib/styles/overwrite/pretty-checkbox/elements/switch/_general.scss +47 -0
  73. package/src/lib/styles/overwrite/pretty-checkbox/elements/switch/_mixin.scss +15 -0
  74. package/src/lib/styles/overwrite/pretty-checkbox/pretty-checkbox.scss +29 -0
  75. package/src/lib/vendor/gravity-tooltip/gravity-tooltip.component.html +9 -0
  76. package/src/lib/vendor/gravity-tooltip/gravity-tooltip.component.sass +134 -0
  77. package/src/lib/vendor/gravity-tooltip/gravity-tooltip.component.ts +215 -0
  78. package/src/lib/vendor/gravity-tooltip/gravity-tooltip.directive.ts +506 -0
  79. package/src/lib/vendor/gravity-tooltip/gravity-tooltip.module.ts +33 -0
  80. package/src/lib/vendor/gravity-tooltip/index.ts +3 -0
  81. package/src/lib/vendor/gravity-tooltip/options.interface.ts +37 -0
  82. package/src/lib/vendor/gravity-tooltip/options.service.ts +8 -0
  83. package/src/lib/vendor/gravity-tooltip/options.ts +38 -0
  84. package/esm2020/lib/gravity-design-system.component.mjs +0 -19
  85. package/esm2020/lib/gravity-design-system.service.mjs +0 -11
  86. package/lib/gravity-design-system.component.d.ts +0 -5
  87. package/lib/gravity-design-system.service.d.ts +0 -5
@@ -0,0 +1,215 @@
1
+ import {Component, ElementRef, EventEmitter, HostBinding, HostListener, Input, OnInit, Renderer2} from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'tooltip',
5
+ templateUrl: './gravity-tooltip.component.html',
6
+ host: {'class': 'tooltip'},
7
+ styleUrls: ['./gravity-tooltip.component.sass']
8
+ })
9
+
10
+ export class GravityTooltipComponent implements OnInit {
11
+ _show: boolean = false;
12
+ events = new EventEmitter();
13
+
14
+ @Input() data: any;
15
+
16
+ @HostBinding('style.top') hostStyleTop!: string;
17
+ @HostBinding('style.left') hostStyleLeft!: string;
18
+ @HostBinding('style.z-index') hostStyleZIndex!: number;
19
+ @HostBinding('style.transition') hostStyleTransition!: string;
20
+ @HostBinding('style.width') hostStyleWidth!: string;
21
+ @HostBinding('style.max-width') hostStyleMaxWidth!: string;
22
+ @HostBinding('style.pointer-events') hostStylePointerEvents!: string;
23
+ @HostBinding('class.tooltip-show') hostClassShow!: boolean;
24
+ @HostBinding('class.tooltip-shadow') hostClassShadow!: boolean;
25
+ @HostBinding('class.tooltip-light') hostClassLight!: boolean;
26
+
27
+ @HostListener('transitionend', ['$event'])
28
+ transitionEnd() {
29
+ if (this.show) {
30
+ this.events.emit({
31
+ type: 'shown'
32
+ });
33
+ }
34
+ }
35
+
36
+ @Input() set show(value: boolean) {
37
+ if (value) {
38
+ this.setPosition();
39
+ }
40
+ this._show = this.hostClassShow = value;
41
+ }
42
+
43
+ get show(): boolean {
44
+ return this._show;
45
+ }
46
+
47
+ get placement() {
48
+ return this.data.options.placement;
49
+ }
50
+
51
+ get autoPlacement() {
52
+ return this.data.options.autoPlacement;
53
+ }
54
+
55
+ get element() {
56
+ return this.data.element;
57
+ }
58
+
59
+ get elementPosition() {
60
+ return this.data.elementPosition;
61
+ }
62
+
63
+ get options() {
64
+ return this.data.options;
65
+ }
66
+
67
+ get value() {
68
+ return this.data.value;
69
+ }
70
+
71
+ get tooltipOffset(): number {
72
+ return Number(this.data.options.offset);
73
+ }
74
+
75
+ get isThemeLight() {
76
+ return this.options['theme'] === 'light';
77
+ }
78
+
79
+ constructor(private elementRef: ElementRef, private renderer: Renderer2) {
80
+ }
81
+
82
+ ngOnInit() {
83
+ this.setCustomClass();
84
+ this.setStyles();
85
+ }
86
+
87
+ setPosition(): void {
88
+ if (this.setHostStyle(this.placement)) {
89
+ this.setPlacementClass(this.placement);
90
+ return;
91
+ } else {
92
+ /* Is tooltip outside the visible area */
93
+ const placements = ['top', 'right', 'bottom', 'left'];
94
+ let isPlacementSet;
95
+
96
+ for (const placement of placements) {
97
+ if (this.setHostStyle(placement)) {
98
+ this.setPlacementClass(placement);
99
+ isPlacementSet = true;
100
+ return;
101
+ }
102
+ }
103
+
104
+ /* Set original placement */
105
+ if (!isPlacementSet) {
106
+ this.setHostStyle(this.placement, true);
107
+ this.setPlacementClass(this.placement);
108
+ }
109
+ }
110
+ }
111
+
112
+
113
+ setPlacementClass(placement: string): void {
114
+ this.renderer.addClass(this.elementRef.nativeElement, 'tooltip-' + placement);
115
+ }
116
+
117
+ setHostStyle(placement: string, disableAutoPlacement: boolean = false): boolean {
118
+ const isSvg = this.element instanceof SVGElement;
119
+ const tooltip = this.elementRef.nativeElement;
120
+ const isCustomPosition = !this.elementPosition.right;
121
+
122
+ let elementHeight = isSvg ? this.element.getBoundingClientRect().height : this.element.offsetHeight;
123
+ let elementWidth = isSvg ? this.element.getBoundingClientRect().width : this.element.offsetWidth;
124
+ const tooltipHeight = tooltip.clientHeight;
125
+ const tooltipWidth = tooltip.clientWidth;
126
+ const scrollY = window.pageYOffset;
127
+
128
+ if (isCustomPosition) {
129
+ elementHeight = 0;
130
+ elementWidth = 0;
131
+ }
132
+
133
+ let topStyle;
134
+ let leftStyle;
135
+
136
+ if (placement === 'top') {
137
+ topStyle = (this.elementPosition.top + scrollY) - (tooltipHeight + this.tooltipOffset);
138
+ }
139
+
140
+ if (placement === 'bottom') {
141
+ topStyle = (this.elementPosition.top + scrollY) + elementHeight + this.tooltipOffset;
142
+ }
143
+
144
+ if (placement === 'top' || placement === 'bottom') {
145
+ leftStyle = (this.elementPosition.left + elementWidth / 2) - tooltipWidth / 2;
146
+ }
147
+
148
+ if (placement === 'left') {
149
+ leftStyle = this.elementPosition.left - tooltipWidth - this.tooltipOffset;
150
+ }
151
+
152
+ if (placement === 'right') {
153
+ leftStyle = this.elementPosition.left + elementWidth + this.tooltipOffset;
154
+ }
155
+
156
+ if (placement === 'left' || placement === 'right') {
157
+ topStyle = (this.elementPosition.top + scrollY) + elementHeight / 2 - tooltip.clientHeight / 2;
158
+ }
159
+
160
+ /* Is tooltip outside the visible area */
161
+ if (this.autoPlacement && !disableAutoPlacement) {
162
+ const topEdge = topStyle;
163
+ const bottomEdge = topStyle + tooltipHeight;
164
+ const leftEdge = leftStyle;
165
+ const rightEdge = leftStyle + tooltipWidth;
166
+ const bodyHeight = window.innerHeight + scrollY;
167
+ const bodyWidth = document.body.clientWidth;
168
+
169
+ if (topEdge < 0 || bottomEdge > bodyHeight || leftEdge < 0 || rightEdge > bodyWidth) {
170
+ return false;
171
+ }
172
+ }
173
+
174
+ this.hostStyleTop = topStyle + 'px';
175
+ this.hostStyleLeft = leftStyle + 'px';
176
+ return true;
177
+ }
178
+
179
+ setZIndex(): void {
180
+ if (this.options['zIndex'] !== 0) {
181
+ this.hostStyleZIndex = this.options['zIndex'];
182
+ }
183
+ }
184
+
185
+ setPointerEvents(): void {
186
+ if (this.options['pointerEvents']) {
187
+ this.hostStylePointerEvents = this.options['pointerEvents'];
188
+ }
189
+ }
190
+
191
+ setCustomClass() {
192
+ if (this.options['tooltipClass']) {
193
+ this.options['tooltipClass'].split(' ').forEach((className: any) => {
194
+ this.renderer.addClass(this.elementRef.nativeElement, className);
195
+ });
196
+ }
197
+ }
198
+
199
+ setAnimationDuration() {
200
+ if (Number(this.options['animationDuration']) != this.options['animationDurationDefault']) {
201
+ this.hostStyleTransition = 'opacity ' + this.options['animationDuration'] + 'ms';
202
+ }
203
+ }
204
+
205
+ setStyles() {
206
+ this.setZIndex();
207
+ this.setPointerEvents();
208
+ this.setAnimationDuration();
209
+
210
+ this.hostClassShadow = this.options['shadow'];
211
+ this.hostClassLight = this.isThemeLight;
212
+ this.hostStyleMaxWidth = this.options['maxWidth'];
213
+ this.hostStyleWidth = this.options['width'] ? this.options['width'] : '';
214
+ }
215
+ }
@@ -0,0 +1,506 @@
1
+ import {
2
+ ApplicationRef,
3
+ ComponentFactoryResolver,
4
+ Directive,
5
+ ElementRef,
6
+ EmbeddedViewRef,
7
+ EventEmitter,
8
+ HostListener,
9
+ Inject,
10
+ Injector,
11
+ Input,
12
+ OnChanges,
13
+ Optional,
14
+ Output,
15
+ SimpleChanges,
16
+ TemplateRef
17
+ } from '@angular/core';
18
+ import {GravityTooltipComponent} from './gravity-tooltip.component';
19
+ import {TooltipOptionsService} from './options.service';
20
+ import {backwardCompatibilityOptions, defaultOptions} from './options';
21
+ import {TooltipOptions} from './options.interface';
22
+
23
+ export interface AdComponent {
24
+ data: any;
25
+ show: boolean;
26
+ close: boolean;
27
+ events: any;
28
+ }
29
+
30
+ @Directive({
31
+ selector: '[tooltip]',
32
+ exportAs: 'tooltip',
33
+ })
34
+
35
+ export class GravityTooltipDirective implements OnChanges {
36
+
37
+ hideTimeoutId!: number;
38
+ destroyTimeoutId!: number;
39
+ hideAfterClickTimeoutId!: number;
40
+ createTimeoutId!: number;
41
+ showTimeoutId!: number;
42
+ componentRef: any;
43
+ elementPosition: any;
44
+ _id: any;
45
+ _options: any = {};
46
+ _defaultOptions: any;
47
+ _destroyDelay!: number;
48
+ componentSubscribe: any;
49
+ _contentType: "string" | "html" | "template" = "string";
50
+ _showDelay!: number;
51
+ _hideDelay!: number;
52
+ _zIndex!: number;
53
+ _tooltipClass!: string;
54
+ _animationDuration!: number;
55
+ _maxWidth!: string;
56
+
57
+ @Input('options') set options(value: TooltipOptions) {
58
+ if (value && defaultOptions) {
59
+ this._options = value;
60
+ }
61
+ }
62
+
63
+ get options() {
64
+ return this._options;
65
+ }
66
+
67
+ @Input('tooltip') tooltipValue!: string | TemplateRef<any>;
68
+ @Input('placement') placement!: string;
69
+ @Input('autoPlacement') autoPlacement!: boolean;
70
+
71
+ // Content type
72
+ @Input('content-type') set contentTypeBackwardCompatibility(value: "string" | "html" | "template") {
73
+ if (value) {
74
+ this._contentType = value;
75
+ }
76
+ }
77
+
78
+ @Input('contentType') set contentType(value: "string" | "html" | "template") {
79
+ if (value) {
80
+ this._contentType = value;
81
+ }
82
+ }
83
+
84
+ get contentType() {
85
+ return this._contentType;
86
+ }
87
+
88
+ @Input('hide-delay-mobile') hideDelayMobile!: number;
89
+ @Input('hideDelayTouchscreen') hideDelayTouchscreen!: number;
90
+
91
+ // z-index
92
+ @Input('z-index') set zIndexBackwardCompatibility(value: number) {
93
+ if (value) {
94
+ this._zIndex = value;
95
+ }
96
+ }
97
+
98
+ @Input('zIndex') set zIndex(value: number) {
99
+ if (value) {
100
+ this._zIndex = value;
101
+ }
102
+ }
103
+
104
+ get zIndex() {
105
+ return this._zIndex;
106
+ }
107
+
108
+ // Animation duration
109
+ @Input('animation-duration') set animationDurationBackwardCompatibility(value: number) {
110
+ if (value) {
111
+ this._animationDuration = value;
112
+ }
113
+ }
114
+
115
+ @Input('animationDuration') set animationDuration(value: number) {
116
+ if (value) {
117
+ this._animationDuration = value;
118
+ }
119
+ }
120
+
121
+ get animationDuration() {
122
+ return this._animationDuration;
123
+ }
124
+
125
+
126
+ @Input('trigger') trigger!: string;
127
+
128
+ // Tooltip class
129
+ @Input('tooltip-class') set tooltipClassBackwardCompatibility(value: string) {
130
+ if (value) {
131
+ this._tooltipClass = value;
132
+ }
133
+ }
134
+
135
+ @Input('tooltipClass') set tooltipClass(value: string) {
136
+ if (value) {
137
+ this._tooltipClass = value;
138
+ }
139
+ }
140
+
141
+ get tooltipClass() {
142
+ return this._tooltipClass;
143
+ }
144
+
145
+ @Input('display') display!: boolean;
146
+ @Input('display-mobile') displayMobile!: boolean;
147
+ @Input('displayTouchscreen') displayTouchscreen!: boolean;
148
+ @Input('shadow') shadow!: boolean;
149
+ @Input('theme') theme!: "dark" | "light";
150
+ @Input('offset') offset!: number;
151
+ @Input('width') width!: string;
152
+
153
+ // Max width
154
+ @Input('max-width') set maxWidthBackwardCompatibility(value: string) {
155
+ if (value) {
156
+ this._maxWidth = value;
157
+ }
158
+ }
159
+
160
+ @Input('maxWidth') set maxWidth(value: string) {
161
+ if (value) {
162
+ this._maxWidth = value;
163
+ }
164
+ }
165
+
166
+ get maxWidth() {
167
+ return this._maxWidth;
168
+ }
169
+
170
+
171
+ @Input('id') id: any;
172
+
173
+ // Show delay
174
+ @Input('show-delay') set showDelayBackwardCompatibility(value: number) {
175
+ if (value) {
176
+ this._showDelay = value;
177
+ }
178
+ }
179
+
180
+ @Input('showDelay') set showDelay(value: number) {
181
+ if (value) {
182
+ this._showDelay = value;
183
+ }
184
+ }
185
+
186
+ get showDelay() {
187
+ return this._showDelay;
188
+ }
189
+
190
+ // Hide delay
191
+ @Input('hide-delay') set hideDelayBackwardCompatibility(value: number) {
192
+ if (value) {
193
+ this._hideDelay = value;
194
+ }
195
+ }
196
+
197
+ @Input('hideDelay') set hideDelay(value: number) {
198
+ if (value) {
199
+ this._hideDelay = value;
200
+ }
201
+ }
202
+
203
+ get hideDelay() {
204
+ return this._hideDelay;
205
+ }
206
+
207
+ @Input('hideDelayAfterClick') hideDelayAfterClick!: number;
208
+ @Input('pointerEvents') pointerEvents!: 'auto' | 'none';
209
+ @Input('position') position!: { top: number, left: number };
210
+
211
+ get isTooltipDestroyed() {
212
+ return this.componentRef && this.componentRef.hostView.destroyed;
213
+ }
214
+
215
+ get destroyDelay() {
216
+ if (this._destroyDelay) {
217
+ return this._destroyDelay;
218
+ } else {
219
+ return Number(this.getHideDelay()) + Number(this.options['animationDuration']);
220
+ }
221
+ }
222
+
223
+ set destroyDelay(value: number) {
224
+ this._destroyDelay = value;
225
+ }
226
+
227
+ get tooltipPosition() {
228
+ if (this.options['position']) {
229
+ return this.options['position'];
230
+ } else {
231
+ return this.elementPosition;
232
+ }
233
+ }
234
+
235
+ @Output() events: EventEmitter<any> = new EventEmitter<any>();
236
+
237
+ constructor(
238
+ @Optional() @Inject(TooltipOptionsService) private initOptions: any,
239
+ private elementRef: ElementRef,
240
+ private componentFactoryResolver: ComponentFactoryResolver,
241
+ private appRef: ApplicationRef,
242
+ private injector: Injector) {
243
+ }
244
+
245
+ @HostListener('focusin')
246
+ @HostListener('mouseenter')
247
+ onMouseEnter() {
248
+ if (this.isDisplayOnHover == false) {
249
+ return;
250
+ }
251
+
252
+ this.show();
253
+ }
254
+
255
+ @HostListener('focusout')
256
+ @HostListener('mouseleave')
257
+ onMouseLeave() {
258
+ if (this.options['trigger'] === 'hover') {
259
+ this.destroyTooltip();
260
+ }
261
+ }
262
+
263
+ @HostListener('click')
264
+ onClick() {
265
+ if (this.isDisplayOnClick == false) {
266
+ return;
267
+ }
268
+
269
+ this.show();
270
+ this.hideAfterClickTimeoutId = window.setTimeout(() => {
271
+ this.destroyTooltip();
272
+ }, this.options['hideDelayAfterClick'])
273
+ }
274
+
275
+ ngOnInit(): void {
276
+ }
277
+
278
+ ngOnChanges(changes: SimpleChanges) {
279
+ this.initOptions = this.renameProperties(this.initOptions);
280
+ let changedOptions = this.getProperties(changes);
281
+ changedOptions = this.renameProperties(changedOptions);
282
+
283
+ this.applyOptionsDefault(defaultOptions, changedOptions);
284
+ }
285
+
286
+ ngOnDestroy(): void {
287
+ this.destroyTooltip({
288
+ fast: true
289
+ });
290
+
291
+ if (this.componentSubscribe) {
292
+ this.componentSubscribe.unsubscribe();
293
+ }
294
+ }
295
+
296
+ getShowDelay() {
297
+ return this.options['showDelay'];
298
+ }
299
+
300
+ getHideDelay() {
301
+ const hideDelay = this.options['hideDelay'];
302
+ const hideDelayTouchscreen = this.options['hideDelayTouchscreen'];
303
+
304
+ return this.isTouchScreen ? hideDelayTouchscreen : hideDelay;
305
+ }
306
+
307
+ getProperties(changes: SimpleChanges) {
308
+ let directiveProperties: any = {};
309
+ let customProperties: any = {};
310
+ let allProperties: any;
311
+
312
+ for (var prop in changes) {
313
+ if (prop !== 'options' && prop !== 'tooltipValue') {
314
+ directiveProperties[prop] = changes[prop].currentValue;
315
+ }
316
+ if (prop === 'options') {
317
+ customProperties = changes[prop].currentValue;
318
+ }
319
+ }
320
+
321
+ allProperties = Object.assign({}, customProperties, directiveProperties);
322
+ return allProperties;
323
+ }
324
+
325
+ renameProperties(options: any) {
326
+ for (var prop in options) {
327
+ if (backwardCompatibilityOptions[prop]) {
328
+ options[backwardCompatibilityOptions[prop]] = options[prop];
329
+ delete options[prop];
330
+ }
331
+ }
332
+
333
+ return options;
334
+ }
335
+
336
+ getElementPosition(): void {
337
+ this.elementPosition = this.elementRef.nativeElement.getBoundingClientRect();
338
+ }
339
+
340
+ createTooltip(): void {
341
+ this.clearTimeouts();
342
+ this.getElementPosition();
343
+
344
+ this.createTimeoutId = window.setTimeout(() => {
345
+ this.appendComponentToBody(GravityTooltipComponent);
346
+ }, this.getShowDelay());
347
+
348
+ this.showTimeoutId = window.setTimeout(() => {
349
+ this.showTooltipElem();
350
+ }, this.getShowDelay());
351
+ }
352
+
353
+ destroyTooltip(options = {
354
+ fast: false
355
+ }): void {
356
+ this.clearTimeouts();
357
+
358
+ if (this.isTooltipDestroyed == false) {
359
+ this.hideTimeoutId = window.setTimeout(() => {
360
+ this.hideTooltip();
361
+ }, options.fast ? 0 : this.getHideDelay());
362
+
363
+ this.destroyTimeoutId = window.setTimeout(() => {
364
+ if (!this.componentRef || this.isTooltipDestroyed) {
365
+ return;
366
+ }
367
+
368
+ this.appRef.detachView(this.componentRef.hostView);
369
+ this.componentRef.destroy();
370
+ this.events.emit({
371
+ type: 'hidden',
372
+ position: this.tooltipPosition
373
+ });
374
+ }, options.fast ? 0 : this.destroyDelay);
375
+ }
376
+ }
377
+
378
+ showTooltipElem(): void {
379
+ this.clearTimeouts();
380
+ (<AdComponent>this.componentRef.instance).show = true;
381
+ this.events.emit({
382
+ type: 'show',
383
+ position: this.tooltipPosition
384
+ });
385
+ }
386
+
387
+ hideTooltip(): void {
388
+ if (!this.componentRef || this.isTooltipDestroyed) {
389
+ return;
390
+ }
391
+ (<AdComponent>this.componentRef.instance).show = false;
392
+ this.events.emit({
393
+ type: 'hide',
394
+ position: this.tooltipPosition
395
+ });
396
+ }
397
+
398
+ appendComponentToBody(component: any): void {
399
+ this.componentRef = this.componentFactoryResolver
400
+ .resolveComponentFactory(component)
401
+ .create(this.injector);
402
+
403
+ (<AdComponent>this.componentRef.instance).data = {
404
+ value: this.tooltipValue,
405
+ element: this.elementRef.nativeElement,
406
+ elementPosition: this.tooltipPosition,
407
+ options: this.options
408
+ }
409
+ this.appRef.attachView(this.componentRef.hostView);
410
+ const domElem = (this.componentRef.hostView as EmbeddedViewRef<any>).rootNodes[0] as HTMLElement;
411
+ document.body.appendChild(domElem);
412
+
413
+ this.componentSubscribe = (<AdComponent>this.componentRef.instance).events.subscribe((event: any) => {
414
+ this.handleEvents(event);
415
+ });
416
+ }
417
+
418
+ clearTimeouts(): void {
419
+ if (this.createTimeoutId) {
420
+ clearTimeout(this.createTimeoutId);
421
+ }
422
+
423
+ if (this.showTimeoutId) {
424
+ clearTimeout(this.showTimeoutId);
425
+ }
426
+
427
+ if (this.hideTimeoutId) {
428
+ clearTimeout(this.hideTimeoutId);
429
+ }
430
+
431
+ if (this.destroyTimeoutId) {
432
+ clearTimeout(this.destroyTimeoutId);
433
+ }
434
+ }
435
+
436
+ get isDisplayOnHover(): boolean {
437
+ if (this.options['display'] == false) {
438
+ return false;
439
+ }
440
+
441
+ if (this.options['displayTouchscreen'] == false && this.isTouchScreen) {
442
+ return false;
443
+ }
444
+
445
+ return this.options['trigger'] === 'hover';
446
+ }
447
+
448
+ get isDisplayOnClick(): boolean {
449
+ if (this.options['display'] == false) {
450
+ return false;
451
+ }
452
+
453
+ if (this.options['displayTouchscreen'] == false && this.isTouchScreen) {
454
+ return false;
455
+ }
456
+
457
+ return this.options['trigger'] == 'click';
458
+
459
+
460
+ }
461
+
462
+ get isTouchScreen() {
463
+ var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
464
+ var mq = function (query: any) {
465
+ return window.matchMedia(query).matches;
466
+ }
467
+
468
+ if (('ontouchstart' in window)) {
469
+ return true;
470
+ }
471
+
472
+ // include the 'heartz' as a way to have a non matching MQ to help terminate the join
473
+ // https://git.io/vznFH
474
+ var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
475
+ return mq(query);
476
+ }
477
+
478
+ applyOptionsDefault(defaultOptions: any, options: any): void {
479
+ this.options = Object.assign({}, defaultOptions, this.initOptions || {}, this.options, options);
480
+ }
481
+
482
+ handleEvents(event: any) {
483
+ if (event.type === 'shown') {
484
+ this.events.emit({
485
+ type: 'shown',
486
+ position: this.tooltipPosition
487
+ });
488
+ }
489
+ }
490
+
491
+ public show() {
492
+ if (!this.tooltipValue) {
493
+ return;
494
+ }
495
+
496
+ if (!this.componentRef || this.isTooltipDestroyed) {
497
+ this.createTooltip();
498
+ } else if (!this.isTooltipDestroyed) {
499
+ this.showTooltipElem();
500
+ }
501
+ }
502
+
503
+ public hide() {
504
+ this.destroyTooltip();
505
+ }
506
+ }