@progressio_resources/gravity-design-system 1.0.5 → 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 +253 -195
  65. package/src/lib/styles/fundamentals/colors/tokens/_hero.tokens.scss +307 -194
  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,7 @@
1
+ @import "./fundamentals/colors/tokens/hero.tokens";
2
+ @import "./fundamentals/typography/hero.typography";
3
+ @import "./overwrite/pretty-checkbox/pretty-checkbox.scss";
4
+ @import "./card_highlight";
5
+ @import "./datepicker";
6
+ @import "./icons";
7
+ @import "./link";
@@ -0,0 +1,120 @@
1
+ @charset "utf-8";
2
+
3
+ .#{$pretty--class-name} * {
4
+ box-sizing: border-box;
5
+ }
6
+
7
+ //Throw error on invalid input types.
8
+ .#{$pretty--class-name} input:not([type='checkbox']):not([type='radio']) {
9
+ display: none;
10
+
11
+ @if $pretty--debug {
12
+ + *:after {
13
+ content: $pretty--err-message;
14
+ border: 1px solid #dedede;
15
+ border-left: 3px solid #d9534f;
16
+ padding: 9px;
17
+ font-size: 1em;
18
+ font-weight: 600;
19
+ color: #d9534f;
20
+ position: absolute;
21
+ z-index: 3;
22
+ background: #fbfbfb;
23
+ top: 0;
24
+ left: 0;
25
+ }
26
+ }
27
+ }
28
+
29
+ .#{$pretty--class-name} {
30
+ position: relative;
31
+ display: inline-block;
32
+ margin-right: 1em;
33
+ white-space: nowrap;
34
+ line-height: 1;
35
+
36
+ &:not(.p-switch){
37
+ input[type="checkbox"] {
38
+ &:not(:checked) ~ .state label:before {
39
+ border-color: var(--outline-checkbox-off-primary);
40
+ }
41
+
42
+ &:checked ~ .state {
43
+ label:after {
44
+ background-color: var(--bg-checkbox-on-primary);
45
+ }
46
+
47
+ svg-icon svg path {
48
+ fill: var(--on-bg-checkbox-on-primary);
49
+ stroke: var(--on-bg-checkbox-on-primary);
50
+ }
51
+ }
52
+ &:disabled ~ .state {
53
+ label:before {
54
+ border-color: var(--bg-button-disabled);
55
+ }
56
+ }
57
+ &:disabled:checked ~ .state {
58
+ label:after {
59
+ background-color: var(--bg-button-disabled);
60
+ }
61
+
62
+ svg-icon svg path {
63
+ fill: var(--on-bg-disabled);
64
+ stroke: var(--on-bg-disabled);
65
+ }
66
+ }
67
+
68
+ }
69
+ }
70
+
71
+ input {
72
+ position: absolute;
73
+ left: 0;
74
+ top: 0;
75
+ min-width: 1em;
76
+ width: 100%;
77
+ height: 100%;
78
+ z-index: $pretty--z-index-front;
79
+ opacity: 0;
80
+ margin: 0;
81
+ padding: 0;
82
+ cursor: pointer;
83
+ }
84
+
85
+ .state {
86
+ label {
87
+ position: initial;
88
+ display: inline-block;
89
+ font-weight: normal;
90
+ margin: 0;
91
+ text-indent: $pretty--label-text-offset;
92
+ min-width: $pretty--box-size;
93
+
94
+ &:before,
95
+ &:after {
96
+ content: '';
97
+ width: $pretty--box-size;
98
+ height: $pretty--box-size;
99
+ display: block;
100
+ box-sizing: border-box;
101
+ border-radius: 0;
102
+ border: 1px solid transparent;
103
+ z-index: $pretty--z-index-back;
104
+ position: absolute;
105
+ left: 0;
106
+ top: $pretty-top-offset;
107
+ background-color: transparent;
108
+ }
109
+
110
+ &:before {
111
+ border-color: $pretty--color-default;
112
+ }
113
+ }
114
+
115
+ &.p-is-hover,
116
+ &.p-is-indeterminate {
117
+ display: none;
118
+ }
119
+ }
120
+ }
@@ -0,0 +1,39 @@
1
+ $pretty--class-name: pretty !default;
2
+
3
+ // colors
4
+ $pretty--color-default: #bdc3c7 !default;
5
+ $pretty--color-primary: #428bca !default;
6
+ $pretty--color-info: #5bc0de !default;
7
+ $pretty--color-success: #5cb85c !default;
8
+ $pretty--color-warning: #f0ad4e !default;
9
+ $pretty--color-danger: #d9534f !default;
10
+ $pretty--color-dark: #5a656b !default;
11
+
12
+ // z-index
13
+ $pretty--z-index-back: 0 !default;
14
+ $pretty--z-index-between: 1 !default;
15
+ $pretty--z-index-front: 2 !default;
16
+
17
+ // box
18
+ $pretty--curve-radius: 20% !default;
19
+ $pretty--box-size: calc(1em + 2px) !default;
20
+
21
+ // text
22
+ $pretty--label-text-offset: 1.5em !default;
23
+ $pretty--label-text-offset-switch: 2.5em !default;
24
+
25
+ // scale
26
+ $pretty--2x: 1.2em !default;
27
+
28
+ // color set
29
+ $pretty--colors: (primary, $pretty--color-primary), (info, $pretty--color-info), (success, $pretty--color-success), (warning, $pretty--color-warning), (danger, $pretty--color-danger) !default;
30
+
31
+ // position
32
+ $pretty-top: 7;
33
+ $pretty-top-switch: ($pretty-top * 2) * 1%;
34
+ $pretty-top-offset: calc((0% - (100% - 1em)) - #{$pretty-top * 1%});
35
+ $pretty-top-offset-switch: calc((0% - (100% - 1em)) - #{$pretty-top-switch});
36
+
37
+ // dev
38
+ $pretty--debug: false !default;
39
+ $pretty--err-message: 'Error: Invalid input type!' !default;
@@ -0,0 +1,41 @@
1
+ .#{$pretty--class-name}.p-default {
2
+ .state label {
3
+ &:after {
4
+ transform: scale(0.6);
5
+ }
6
+ }
7
+
8
+ input:checked ~ .state label {
9
+ &:after {
10
+ background-color: $pretty--color-default !important;
11
+ }
12
+ }
13
+
14
+ input[type='radio'] {
15
+ &:not(:checked) ~ .state label:before {
16
+ border-color: var(--radio-button-off-primary);
17
+ }
18
+
19
+ &:checked ~ .state label {
20
+ &:before {
21
+ border-color: var(--radio-button-on-primary);
22
+ }
23
+
24
+ &:after {
25
+ background-color: var(--radio-button-on-primary) !important;
26
+ }
27
+ }
28
+
29
+ &:disabled ~ .state {
30
+ label:before {
31
+ border-color: var(--outline-disabled);
32
+ }
33
+ }
34
+ &:disabled:checked ~ .state {
35
+ label:after {
36
+ background-color: var(--outline-disabled);
37
+ }
38
+ }
39
+
40
+ }
41
+ }
@@ -0,0 +1,7 @@
1
+ @use 'mixin';
2
+
3
+ .#{$pretty--class-name}.p-switch.p-fill {
4
+ input:checked:not(:disabled) ~ .state {
5
+ @include mixin.switchColor(bg-switch-on-primary);
6
+ }
7
+ }
@@ -0,0 +1,47 @@
1
+ @use 'mixin';
2
+
3
+ .#{$pretty--class-name}.p-switch {
4
+ input{
5
+ min-width:2em;
6
+ &:checked ~ .state, &:disabled ~ .state {
7
+ @include mixin.switchColor(bg-switch-disabled-primary);
8
+ }
9
+ }
10
+
11
+ .state {
12
+ position: relative;
13
+
14
+ &:before {
15
+ content: '';
16
+ border: 1px solid var(--bg-switch-off-primary);
17
+ background-color: var(--bg-switch-off-primary);
18
+ border-radius: 60px;
19
+ width: 2em;
20
+ box-sizing: unset;
21
+ height: $pretty--box-size;
22
+ position: absolute;
23
+ top: 0;
24
+ top: $pretty-top-offset-switch;
25
+ z-index: $pretty--z-index-back;
26
+ transition: all 0.5s ease;
27
+ }
28
+
29
+ label {
30
+ text-indent: $pretty--label-text-offset-switch;
31
+
32
+ &:before,
33
+ &:after {
34
+ transition: all 0.5s ease;
35
+ border-radius: 100%;
36
+ left: 0;
37
+ border-color: transparent;
38
+ transform: scale(0.8);
39
+ }
40
+
41
+ &:before{
42
+ border: 1px solid var(--on-bg-switch-off-primary);
43
+ background-color: var(--on-bg-switch-off-primary);
44
+ }
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,15 @@
1
+ @mixin switchColor($varColorName) {
2
+ &:before {
3
+ border-color: var(--#{$varColorName});
4
+ background-color: var(--#{$varColorName});
5
+ }
6
+
7
+ label:before {
8
+ opacity: 0;
9
+ }
10
+
11
+ label:after {
12
+ background-color: var(--on-#{$varColorName}) !important;
13
+ left: 1em;
14
+ }
15
+ }
@@ -0,0 +1,29 @@
1
+ @import './variables';
2
+ @import './core';
3
+
4
+
5
+ @import 'node_modules/pretty-checkbox/src/scss/essentials/keyframes';
6
+ @import 'node_modules/pretty-checkbox/src/scss/essentials/functions';
7
+ @import 'node_modules/pretty-checkbox/src/scss/essentials/mixins';
8
+ @import 'node_modules/pretty-checkbox/src/scss/elements/default/fill';
9
+ @import './elements/default/outline';
10
+ @import 'node_modules/pretty-checkbox/src/scss/elements/default/thick';
11
+ @import 'node_modules/pretty-checkbox/src/scss/elements/font-icon/general';
12
+ @import 'node_modules/pretty-checkbox/src/scss/elements/svg/general';
13
+ @import 'node_modules/pretty-checkbox/src/scss/elements/image/general';
14
+ @import './elements/switch/general';
15
+ @import './elements/switch/fill';
16
+ @import 'node_modules/pretty-checkbox/src/scss/elements/switch/slim';
17
+ @import 'node_modules/pretty-checkbox/src/scss/states/hover';
18
+ @import 'node_modules/pretty-checkbox/src/scss/states/focus';
19
+ @import 'node_modules/pretty-checkbox/src/scss/states/indeterminate';
20
+ @import 'node_modules/pretty-checkbox/src/scss/extras/toggle';
21
+ @import 'node_modules/pretty-checkbox/src/scss/extras/plain';
22
+ @import 'node_modules/pretty-checkbox/src/scss/extras/round';
23
+ @import 'node_modules/pretty-checkbox/src/scss/extras/curve';
24
+ @import 'node_modules/pretty-checkbox/src/scss/extras/animation';
25
+ @import 'node_modules/pretty-checkbox/src/scss/extras/disabled';
26
+ @import 'node_modules/pretty-checkbox/src/scss/extras/locked';
27
+ @import 'node_modules/pretty-checkbox/src/scss/extras/colors';
28
+ @import 'node_modules/pretty-checkbox/src/scss/extras/bigger';
29
+ @import 'node_modules/pretty-checkbox/src/scss/extras/print';
@@ -0,0 +1,9 @@
1
+ <div *ngIf="isThemeLight" class="tooltip-arrow"></div>
2
+
3
+ <div *ngIf="options['contentType'] === 'template' else htmlOrStringTemplate">
4
+ <ng-container *ngTemplateOutlet="value"></ng-container>
5
+ </div>
6
+
7
+ <ng-template #htmlOrStringTemplate>
8
+ <div [innerHTML]="value"></div>
9
+ </ng-template>
@@ -0,0 +1,134 @@
1
+ \:host
2
+ max-width: 200px
3
+ background-color: var(--bg-tooltip-primary)
4
+ color: var(--on-bg-tooltip-primary)
5
+ text-align: center
6
+ border-radius: 6px
7
+ padding: 5px 8px
8
+ position: absolute
9
+ pointer-events: none
10
+ z-index: 1000
11
+ display: block
12
+ opacity: 0
13
+ -webkit-transition: opacity 300ms
14
+ -moz-transition: opacity 300ms
15
+ -o-transition: opacity 300ms
16
+ transition: opacity 300ms
17
+ top: 0
18
+ left: 0
19
+
20
+ \:host.tooltip-show
21
+ opacity: 1
22
+
23
+ \:host.tooltip-shadow
24
+ box-shadow: 0 7px 15px -5px rgba(0, 0, 0, 0.4)
25
+
26
+ \:host.tooltip-light.tooltip-shadow
27
+ box-shadow: 0 5px 15px -5px rgba(0, 0, 0, 0.4)
28
+
29
+ \:host.tooltip::after
30
+ content: ""
31
+ position: absolute
32
+ border-style: solid
33
+
34
+ \:host.tooltip-top::after
35
+ top: 100%
36
+ left: 50%
37
+ margin-left: -5px
38
+ border-width: 5px
39
+ border-color: var(--bg-tooltip-primary) transparent transparent transparent
40
+
41
+ \:host.tooltip-bottom::after
42
+ bottom: 100%
43
+ left: 50%
44
+ margin-left: -5px
45
+ border-width: 5px
46
+ border-color: transparent transparent var(--bg-tooltip-primary) transparent
47
+
48
+ \:host.tooltip-left::after
49
+ top: 50%
50
+ left: 100%
51
+ margin-top: -5px
52
+ border-width: 5px
53
+ border-color: transparent transparent transparent var(--bg-tooltip-primary)
54
+
55
+ \:host.tooltip-right::after
56
+ top: 50%
57
+ right: 100%
58
+ margin-top: -5px
59
+ border-width: 5px
60
+ border-color: transparent var(--bg-tooltip-primary) transparent transparent
61
+
62
+ // Light
63
+ \:host.tooltip-light::after
64
+ display: none
65
+
66
+ \:host.tooltip-light
67
+ border: 1px solid rgba(0, 0, 0, .06)
68
+ background-color: #fff
69
+ color: black
70
+
71
+ .tooltip-arrow
72
+ position: absolute
73
+ width: 10px
74
+ height: 10px
75
+ transform: rotate(135deg)
76
+ background-color: rgba(0, 0, 0, .07)
77
+
78
+ .tooltip-arrow::after
79
+ background-color: #fff
80
+ content: ''
81
+ display: block
82
+ position: absolute
83
+ width: 10px
84
+ height: 10px
85
+
86
+ \:host.tooltip-top.tooltip-light
87
+ margin-top: -2px
88
+
89
+ .tooltip-arrow
90
+ top: 100%
91
+ left: 50%
92
+ margin-top: -4px
93
+ margin-left: -5px
94
+ background: linear-gradient(to bottom left, rgba(0, 0, 0, .07) 50%, transparent 50%)
95
+
96
+ .tooltip-arrow::after
97
+ top: 1px
98
+ right: 1px
99
+
100
+ \:host.tooltip-bottom.tooltip-light
101
+ .tooltip-arrow
102
+ bottom: 100%
103
+ left: 50%
104
+ margin-bottom: -4px
105
+ margin-left: -5px
106
+ background: linear-gradient(to top right, rgba(0, 0, 0, .1) 50%, transparent 50%)
107
+
108
+ .tooltip-arrow::after
109
+ top: -1px
110
+ right: -1px
111
+
112
+ \:host.tooltip-left.tooltip-light
113
+ .tooltip-arrow
114
+ top: 50%
115
+ left: 100%
116
+ margin-top: -5px
117
+ margin-left: -4px
118
+ background: linear-gradient(to bottom right, rgba(0, 0, 0, .07) 50%, transparent 50%)
119
+
120
+ .tooltip-arrow::after
121
+ top: 1px
122
+ right: -1px
123
+
124
+ \:host.tooltip-right.tooltip-light
125
+ .tooltip-arrow
126
+ top: 50%
127
+ right: 100%
128
+ margin-top: -5px
129
+ margin-right: -4px
130
+ background: linear-gradient(to top left, rgba(0, 0, 0, .07) 50%, transparent 50%)
131
+
132
+ .tooltip-arrow::after
133
+ top: -1px
134
+ right: 1px
@@ -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
+ }