@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.
- package/esm2020/lib/components/gravity-button/gravity-button.component.mjs +22 -0
- package/esm2020/lib/components/gravity-calendar/gravity-calendar.component.mjs +90 -0
- package/esm2020/lib/components/gravity-checkbox/gravity-checkbox.component.mjs +23 -0
- package/esm2020/lib/components/gravity-dropdown-list/gravity-dropdown-list.component.mjs +43 -0
- package/esm2020/lib/components/gravity-radio-button/gravity-radio-button.component.mjs +30 -0
- package/esm2020/lib/components/gravity-switch/gravity-switch.component.mjs +17 -0
- package/esm2020/lib/components/gravity-text-field/gravity-text-field.component.mjs +62 -0
- package/esm2020/lib/gravity-design-system.module.mjs +76 -6
- package/esm2020/lib/vendor/gravity-tooltip/gravity-tooltip.component.mjs +205 -0
- package/esm2020/lib/vendor/gravity-tooltip/gravity-tooltip.directive.mjs +480 -0
- package/esm2020/lib/vendor/gravity-tooltip/gravity-tooltip.module.mjs +41 -0
- package/esm2020/lib/vendor/gravity-tooltip/index.mjs +4 -0
- package/esm2020/lib/vendor/gravity-tooltip/options.interface.mjs +2 -0
- package/esm2020/lib/vendor/gravity-tooltip/options.mjs +38 -0
- package/esm2020/lib/vendor/gravity-tooltip/options.service.mjs +7 -0
- package/esm2020/public-api.mjs +11 -3
- package/fesm2015/progressio_resources-gravity-design-system.mjs +1085 -28
- package/fesm2015/progressio_resources-gravity-design-system.mjs.map +1 -1
- package/fesm2020/progressio_resources-gravity-design-system.mjs +1083 -28
- package/fesm2020/progressio_resources-gravity-design-system.mjs.map +1 -1
- package/lib/components/gravity-button/gravity-button.component.d.ts +17 -0
- package/lib/components/gravity-calendar/gravity-calendar.component.d.ts +40 -0
- package/lib/components/gravity-checkbox/gravity-checkbox.component.d.ts +8 -0
- package/lib/components/gravity-dropdown-list/gravity-dropdown-list.component.d.ts +36 -0
- package/lib/components/gravity-radio-button/gravity-radio-button.component.d.ts +13 -0
- package/lib/components/gravity-switch/gravity-switch.component.d.ts +6 -0
- package/lib/components/gravity-text-field/gravity-text-field.component.d.ts +35 -0
- package/lib/gravity-design-system.module.d.ts +16 -2
- package/lib/vendor/gravity-tooltip/gravity-tooltip.component.d.ts +42 -0
- package/lib/vendor/gravity-tooltip/gravity-tooltip.directive.d.ts +112 -0
- package/lib/vendor/gravity-tooltip/gravity-tooltip.module.d.ts +12 -0
- package/lib/vendor/gravity-tooltip/index.d.ts +3 -0
- package/lib/vendor/gravity-tooltip/options.d.ts +24 -0
- package/lib/vendor/gravity-tooltip/options.interface.d.ts +40 -0
- package/lib/vendor/gravity-tooltip/options.service.d.ts +7 -0
- package/package.json +9 -2
- package/public-api.d.ts +8 -2
- package/src/lib/assets/icons/calendar.svg +14 -0
- package/src/lib/assets/icons/check.svg +3 -0
- package/src/lib/assets/icons/copy.svg +8 -0
- package/src/lib/assets/icons/download.svg +7 -0
- package/src/lib/assets/icons/edit.svg +8 -0
- package/src/lib/assets/icons/eye_closed.svg +8 -0
- package/src/lib/assets/icons/eye_open.svg +6 -0
- package/src/lib/assets/icons/forgot_password.svg +7 -0
- package/src/lib/assets/icons/lock.svg +6 -0
- package/src/lib/assets/icons/logout.svg +9 -0
- package/src/lib/assets/icons/mail.svg +6 -0
- package/src/lib/assets/icons/radio-off.svg +3 -0
- package/src/lib/assets/icons/radio-on.svg +3 -0
- package/src/lib/assets/icons/search.svg +8 -0
- package/src/lib/assets/icons/settings.svg +12 -0
- package/src/lib/assets/icons/show_less.svg +6 -0
- package/src/lib/assets/icons/show_more.svg +6 -0
- package/src/lib/assets/icons/uncheck.svg +3 -0
- package/src/lib/assets/icons/user.svg +6 -0
- package/src/lib/assets/icons/x.svg +6 -0
- package/src/lib/assets/json/icons.json +91 -0
- package/src/lib/styles/_card_highlight.scss +40 -0
- package/src/lib/styles/_datepicker.scss +101 -0
- package/src/lib/styles/_icons.scss +11 -0
- package/src/lib/styles/_link.scss +25 -0
- package/src/lib/styles/_shared.scss +19 -0
- package/src/lib/styles/fundamentals/colors/themes/_hero.theme.scss +253 -195
- package/src/lib/styles/fundamentals/colors/tokens/_hero.tokens.scss +307 -194
- package/src/lib/styles/fundamentals/typography/_hero.typography.scss +0 -1
- package/src/lib/styles/gravity-design-system.scss +7 -0
- package/src/lib/styles/overwrite/pretty-checkbox/_core.scss +120 -0
- package/src/lib/styles/overwrite/pretty-checkbox/_variables.scss +39 -0
- package/src/lib/styles/overwrite/pretty-checkbox/elements/default/_outline.scss +41 -0
- package/src/lib/styles/overwrite/pretty-checkbox/elements/switch/_fill.scss +7 -0
- package/src/lib/styles/overwrite/pretty-checkbox/elements/switch/_general.scss +47 -0
- package/src/lib/styles/overwrite/pretty-checkbox/elements/switch/_mixin.scss +15 -0
- package/src/lib/styles/overwrite/pretty-checkbox/pretty-checkbox.scss +29 -0
- package/src/lib/vendor/gravity-tooltip/gravity-tooltip.component.html +9 -0
- package/src/lib/vendor/gravity-tooltip/gravity-tooltip.component.sass +134 -0
- package/src/lib/vendor/gravity-tooltip/gravity-tooltip.component.ts +215 -0
- package/src/lib/vendor/gravity-tooltip/gravity-tooltip.directive.ts +506 -0
- package/src/lib/vendor/gravity-tooltip/gravity-tooltip.module.ts +33 -0
- package/src/lib/vendor/gravity-tooltip/index.ts +3 -0
- package/src/lib/vendor/gravity-tooltip/options.interface.ts +37 -0
- package/src/lib/vendor/gravity-tooltip/options.service.ts +8 -0
- package/src/lib/vendor/gravity-tooltip/options.ts +38 -0
- package/esm2020/lib/gravity-design-system.component.mjs +0 -19
- package/esm2020/lib/gravity-design-system.service.mjs +0 -11
- package/lib/gravity-design-system.component.d.ts +0 -5
- package/lib/gravity-design-system.service.d.ts +0 -5
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {ModuleWithProviders, NgModule} from '@angular/core';
|
|
2
|
+
import {CommonModule} from '@angular/common';
|
|
3
|
+
import {GravityTooltipDirective} from './gravity-tooltip.directive';
|
|
4
|
+
import {GravityTooltipComponent} from './gravity-tooltip.component';
|
|
5
|
+
import {TooltipOptions} from './options.interface';
|
|
6
|
+
import {TooltipOptionsService} from './options.service';
|
|
7
|
+
|
|
8
|
+
@NgModule({
|
|
9
|
+
declarations: [
|
|
10
|
+
GravityTooltipDirective,
|
|
11
|
+
GravityTooltipComponent
|
|
12
|
+
],
|
|
13
|
+
imports: [
|
|
14
|
+
CommonModule
|
|
15
|
+
],
|
|
16
|
+
exports: [
|
|
17
|
+
GravityTooltipDirective,
|
|
18
|
+
GravityTooltipComponent
|
|
19
|
+
]
|
|
20
|
+
})
|
|
21
|
+
export class GravityTooltipModule {
|
|
22
|
+
static forRoot(initOptions: TooltipOptions): ModuleWithProviders<GravityTooltipModule> {
|
|
23
|
+
return {
|
|
24
|
+
ngModule: GravityTooltipModule,
|
|
25
|
+
providers: [
|
|
26
|
+
{
|
|
27
|
+
provide: TooltipOptionsService,
|
|
28
|
+
useValue: initOptions
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface TooltipOptions {
|
|
2
|
+
'placement'?: string;
|
|
3
|
+
'autoPlacement'?: boolean;
|
|
4
|
+
'content-type'?: 'string' | 'html' | 'template';
|
|
5
|
+
'contentType'?: 'string' | 'html' | 'template';
|
|
6
|
+
'delay'?: number;
|
|
7
|
+
'show-delay'?: number;
|
|
8
|
+
'showDelay'?: number;
|
|
9
|
+
'hide-delay'?: number;
|
|
10
|
+
'hideDelay'?: number;
|
|
11
|
+
'hide-delay-mobile'?: number;
|
|
12
|
+
'hideDelayMobile'?: number;
|
|
13
|
+
'hideDelayTouchscreen'?: number;
|
|
14
|
+
'z-index'?: number;
|
|
15
|
+
'zIndex'?: number;
|
|
16
|
+
'animation-duration'?: number;
|
|
17
|
+
'animationDuration'?: number;
|
|
18
|
+
'animation-duration-default'?: number;
|
|
19
|
+
'animationDurationDefault'?: number;
|
|
20
|
+
'trigger'?: string;
|
|
21
|
+
'tooltip-class'?: string;
|
|
22
|
+
'tooltipClass'?: string;
|
|
23
|
+
'display'?: boolean;
|
|
24
|
+
'display-mobile'?: boolean;
|
|
25
|
+
'displayMobile'?: boolean;
|
|
26
|
+
'displayTouchscreen'?: boolean;
|
|
27
|
+
'shadow'?: boolean;
|
|
28
|
+
'theme'?: "dark" | "light";
|
|
29
|
+
'offset'?: number;
|
|
30
|
+
'width'?: string;
|
|
31
|
+
'max-width'?: string;
|
|
32
|
+
'maxWidth'?: string;
|
|
33
|
+
'id'?: string | number;
|
|
34
|
+
'hideDelayAfterClick'?: number;
|
|
35
|
+
'pointerEvents'?: 'auto' | 'none';
|
|
36
|
+
'position'?: { top: number, left: number };
|
|
37
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { TooltipOptions } from './options.interface';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This is not a real service, but it looks like it from the outside.
|
|
6
|
+
* It's just an InjectionToken used to import the config (initOptions) object, provided from the outside
|
|
7
|
+
*/
|
|
8
|
+
export const TooltipOptionsService = new InjectionToken<TooltipOptions>('TooltipOptions');
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const defaultOptions = {
|
|
2
|
+
'placement': 'top',
|
|
3
|
+
'autoPlacement': true,
|
|
4
|
+
'contentType': 'string',
|
|
5
|
+
'showDelay': 0,
|
|
6
|
+
'hideDelay': 300,
|
|
7
|
+
'hideDelayMobile': 0,
|
|
8
|
+
'hideDelayTouchscreen': 0,
|
|
9
|
+
'zIndex': 0,
|
|
10
|
+
'animationDuration': 300,
|
|
11
|
+
'animationDurationDefault': 300,
|
|
12
|
+
'trigger': 'hover',
|
|
13
|
+
'tooltipClass': '',
|
|
14
|
+
'display': true,
|
|
15
|
+
'displayMobile': true,
|
|
16
|
+
'displayTouchscreen': true,
|
|
17
|
+
'shadow': true,
|
|
18
|
+
'theme': 'dark',
|
|
19
|
+
'offset': 8,
|
|
20
|
+
'maxWidth': '',
|
|
21
|
+
'id': false,
|
|
22
|
+
'hideDelayAfterClick': 2000
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const backwardCompatibilityOptions: any = {
|
|
26
|
+
'delay': 'showDelay',
|
|
27
|
+
'show-delay': 'showDelay',
|
|
28
|
+
'hide-delay': 'hideDelay',
|
|
29
|
+
'hide-delay-mobile': 'hideDelayTouchscreen',
|
|
30
|
+
'hideDelayMobile': 'hideDelayTouchscreen',
|
|
31
|
+
'z-index': 'zIndex',
|
|
32
|
+
'animation-duration': 'animationDuration',
|
|
33
|
+
'animation-duration-default': 'animationDurationDefault',
|
|
34
|
+
'tooltip-class': 'tooltipClass',
|
|
35
|
+
'display-mobile': 'displayTouchscreen',
|
|
36
|
+
'displayMobile': 'displayTouchscreen',
|
|
37
|
+
'max-width': 'maxWidth'
|
|
38
|
+
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
export class GravityDesignSystemComponent {
|
|
4
|
-
}
|
|
5
|
-
GravityDesignSystemComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: GravityDesignSystemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
6
|
-
GravityDesignSystemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: GravityDesignSystemComponent, selector: "lib-gravity-design-system", ngImport: i0, template: `
|
|
7
|
-
<p>
|
|
8
|
-
gravity-design-system works!
|
|
9
|
-
</p>
|
|
10
|
-
`, isInline: true });
|
|
11
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: GravityDesignSystemComponent, decorators: [{
|
|
12
|
-
type: Component,
|
|
13
|
-
args: [{ selector: 'lib-gravity-design-system', template: `
|
|
14
|
-
<p>
|
|
15
|
-
gravity-design-system works!
|
|
16
|
-
</p>
|
|
17
|
-
` }]
|
|
18
|
-
}] });
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3Jhdml0eS1kZXNpZ24tc3lzdGVtLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL2dyYXZpdHktZGVzaWduLXN5c3RlbS9zcmMvbGliL2dyYXZpdHktZGVzaWduLXN5c3RlbS5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFDLFNBQVMsRUFBQyxNQUFNLGVBQWUsQ0FBQzs7QUFXeEMsTUFBTSxPQUFPLDRCQUE0Qjs7eUhBQTVCLDRCQUE0Qjs2R0FBNUIsNEJBQTRCLGlFQVA3Qjs7OztHQUlUOzJGQUdVLDRCQUE0QjtrQkFUeEMsU0FBUzsrQkFDRSwyQkFBMkIsWUFDM0I7Ozs7R0FJVCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7Q29tcG9uZW50fSBmcm9tICdAYW5ndWxhci9jb3JlJztcblxuQENvbXBvbmVudCh7XG4gIHNlbGVjdG9yOiAnbGliLWdyYXZpdHktZGVzaWduLXN5c3RlbScsXG4gIHRlbXBsYXRlOiBgXG4gICAgPHA+XG4gICAgICBncmF2aXR5LWRlc2lnbi1zeXN0ZW0gd29ya3MhXG4gICAgPC9wPlxuICBgLFxuICBzdHlsZXM6IFtdXG59KVxuZXhwb3J0IGNsYXNzIEdyYXZpdHlEZXNpZ25TeXN0ZW1Db21wb25lbnQge1xufVxuIl19
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
export class GravityDesignSystemService {
|
|
4
|
-
}
|
|
5
|
-
GravityDesignSystemService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: GravityDesignSystemService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
6
|
-
GravityDesignSystemService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: GravityDesignSystemService, providedIn: 'root' });
|
|
7
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: GravityDesignSystemService, decorators: [{
|
|
8
|
-
type: Injectable,
|
|
9
|
-
args: [{ providedIn: 'root' }]
|
|
10
|
-
}] });
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3Jhdml0eS1kZXNpZ24tc3lzdGVtLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9ncmF2aXR5LWRlc2lnbi1zeXN0ZW0vc3JjL2xpYi9ncmF2aXR5LWRlc2lnbi1zeXN0ZW0uc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUMsVUFBVSxFQUFDLE1BQU0sZUFBZSxDQUFDOztBQUd6QyxNQUFNLE9BQU8sMEJBQTBCOzt1SEFBMUIsMEJBQTBCOzJIQUExQiwwQkFBMEIsY0FEZCxNQUFNOzJGQUNsQiwwQkFBMEI7a0JBRHRDLFVBQVU7bUJBQUMsRUFBQyxVQUFVLEVBQUUsTUFBTSxFQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHtJbmplY3RhYmxlfSBmcm9tICdAYW5ndWxhci9jb3JlJztcblxuQEluamVjdGFibGUoe3Byb3ZpZGVkSW46ICdyb290J30pXG5leHBvcnQgY2xhc3MgR3Jhdml0eURlc2lnblN5c3RlbVNlcnZpY2Uge1xufVxuIl19
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
export declare class GravityDesignSystemComponent {
|
|
3
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<GravityDesignSystemComponent, never>;
|
|
4
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<GravityDesignSystemComponent, "lib-gravity-design-system", never, {}, {}, never, never, false, never>;
|
|
5
|
-
}
|