@scion/components 15.0.1 → 16.0.0

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 (88) hide show
  1. package/dimension/dimension.directive.d.ts +2 -2
  2. package/esm2022/dimension/dimension.directive.mjs +84 -0
  3. package/esm2022/dimension/dimension.module.mjs +39 -0
  4. package/esm2022/sashbox/element-ref.directive.mjs +28 -0
  5. package/esm2022/sashbox/sash-initializer.directive.mjs +33 -0
  6. package/esm2022/sashbox/sash.directive.mjs +145 -0
  7. package/esm2022/sashbox/sashbox.component.mjs +279 -0
  8. package/esm2022/sashbox/sashbox.module.mjs +70 -0
  9. package/esm2022/splitter/splitter.component.mjs +228 -0
  10. package/esm2022/splitter/splitter.module.mjs +43 -0
  11. package/esm2022/throbber/ellipsis-throbber/ellipsis-throbber.component.mjs +26 -0
  12. package/esm2022/throbber/ripple-throbber/ripple-throbber.component.mjs +26 -0
  13. package/esm2022/throbber/roller-throbber/roller-throbber.component.mjs +26 -0
  14. package/esm2022/throbber/spinner-throbber/spinner-throbber.component.mjs +27 -0
  15. package/esm2022/throbber/throbber.component.mjs +68 -0
  16. package/esm2022/throbber/throbber.module.mjs +49 -0
  17. package/esm2022/viewport/native-scrollbar-track-size-provider.service.mjs +115 -0
  18. package/esm2022/viewport/scrollable.directive.mjs +94 -0
  19. package/esm2022/viewport/scrollbar/scrollbar.component.mjs +323 -0
  20. package/esm2022/viewport/viewport.component.mjs +282 -0
  21. package/esm2022/viewport/viewport.module.mjs +51 -0
  22. package/{fesm2015 → fesm2022}/scion-components-dimension.mjs +12 -7
  23. package/{fesm2015 → fesm2022}/scion-components-dimension.mjs.map +1 -1
  24. package/{fesm2020 → fesm2022}/scion-components-sashbox.mjs +47 -42
  25. package/{fesm2020 → fesm2022}/scion-components-sashbox.mjs.map +1 -1
  26. package/{fesm2020 → fesm2022}/scion-components-splitter.mjs +22 -17
  27. package/{fesm2020 → fesm2022}/scion-components-splitter.mjs.map +1 -1
  28. package/{fesm2020 → fesm2022}/scion-components-throbber.mjs +28 -23
  29. package/{fesm2015 → fesm2022}/scion-components-throbber.mjs.map +1 -1
  30. package/{fesm2020 → fesm2022}/scion-components-viewport.mjs +65 -60
  31. package/{fesm2015 → fesm2022}/scion-components-viewport.mjs.map +1 -1
  32. package/package.json +27 -43
  33. package/sashbox/sash-initializer.directive.d.ts +1 -1
  34. package/sashbox/sash.directive.d.ts +1 -1
  35. package/sashbox/sashbox.component.d.ts +1 -1
  36. package/splitter/splitter.component.d.ts +1 -1
  37. package/throbber/throbber.component.d.ts +1 -1
  38. package/viewport/_scrollbar.scss +1 -1
  39. package/viewport/scrollable.directive.d.ts +1 -1
  40. package/viewport/scrollbar/scrollbar.component.d.ts +1 -1
  41. package/viewport/viewport.component.d.ts +2 -2
  42. package/esm2020/dimension/dimension.directive.mjs +0 -83
  43. package/esm2020/dimension/dimension.module.mjs +0 -38
  44. package/esm2020/sashbox/element-ref.directive.mjs +0 -27
  45. package/esm2020/sashbox/sash-initializer.directive.mjs +0 -32
  46. package/esm2020/sashbox/sash.directive.mjs +0 -144
  47. package/esm2020/sashbox/sashbox.component.mjs +0 -278
  48. package/esm2020/sashbox/sashbox.module.mjs +0 -69
  49. package/esm2020/splitter/splitter.component.mjs +0 -227
  50. package/esm2020/splitter/splitter.module.mjs +0 -42
  51. package/esm2020/throbber/ellipsis-throbber/ellipsis-throbber.component.mjs +0 -25
  52. package/esm2020/throbber/ripple-throbber/ripple-throbber.component.mjs +0 -25
  53. package/esm2020/throbber/roller-throbber/roller-throbber.component.mjs +0 -25
  54. package/esm2020/throbber/spinner-throbber/spinner-throbber.component.mjs +0 -26
  55. package/esm2020/throbber/throbber.component.mjs +0 -67
  56. package/esm2020/throbber/throbber.module.mjs +0 -48
  57. package/esm2020/viewport/native-scrollbar-track-size-provider.service.mjs +0 -114
  58. package/esm2020/viewport/scrollable.directive.mjs +0 -93
  59. package/esm2020/viewport/scrollbar/scrollbar.component.mjs +0 -322
  60. package/esm2020/viewport/viewport.component.mjs +0 -281
  61. package/esm2020/viewport/viewport.module.mjs +0 -50
  62. package/fesm2015/scion-components-sashbox.mjs +0 -554
  63. package/fesm2015/scion-components-sashbox.mjs.map +0 -1
  64. package/fesm2015/scion-components-splitter.mjs +0 -284
  65. package/fesm2015/scion-components-splitter.mjs.map +0 -1
  66. package/fesm2015/scion-components-throbber.mjs +0 -214
  67. package/fesm2015/scion-components-viewport.mjs +0 -861
  68. package/fesm2015/scion-components.mjs +0 -4
  69. package/fesm2015/scion-components.mjs.map +0 -1
  70. package/fesm2020/scion-components-dimension.mjs +0 -135
  71. package/fesm2020/scion-components-dimension.mjs.map +0 -1
  72. package/fesm2020/scion-components-throbber.mjs.map +0 -1
  73. package/fesm2020/scion-components-viewport.mjs.map +0 -1
  74. /package/{esm2020 → esm2022}/dimension/public_api.mjs +0 -0
  75. /package/{esm2020 → esm2022}/dimension/scion-components-dimension.mjs +0 -0
  76. /package/{esm2020 → esm2022}/public-api.mjs +0 -0
  77. /package/{esm2020 → esm2022}/sashbox/public_api.mjs +0 -0
  78. /package/{esm2020 → esm2022}/sashbox/sashbox-accessor.mjs +0 -0
  79. /package/{esm2020 → esm2022}/sashbox/scion-components-sashbox.mjs +0 -0
  80. /package/{esm2020 → esm2022}/scion-components.mjs +0 -0
  81. /package/{esm2020 → esm2022}/splitter/public_api.mjs +0 -0
  82. /package/{esm2020 → esm2022}/splitter/scion-components-splitter.mjs +0 -0
  83. /package/{esm2020 → esm2022}/throbber/public_api.mjs +0 -0
  84. /package/{esm2020 → esm2022}/throbber/scion-components-throbber.mjs +0 -0
  85. /package/{esm2020 → esm2022}/viewport/public_api.mjs +0 -0
  86. /package/{esm2020 → esm2022}/viewport/scion-components-viewport.mjs +0 -0
  87. /package/{fesm2020 → fesm2022}/scion-components.mjs +0 -0
  88. /package/{fesm2020 → fesm2022}/scion-components.mjs.map +0 -0
@@ -1,861 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, Inject, NgZone, Component, ChangeDetectionStrategy, ViewChild, HostBinding, Input, Directive, EventEmitter, ViewEncapsulation, Output, HostListener, NgModule } from '@angular/core';
3
- import * as i2 from '@angular/common';
4
- import { DOCUMENT, CommonModule } from '@angular/common';
5
- import { coerceElement } from '@angular/cdk/coercion';
6
- import { BehaviorSubject, Subject, fromEvent, of, merge, timer } from 'rxjs';
7
- import { debounceTime, startWith, map, distinctUntilChanged, takeUntil, switchMap, first, withLatestFrom, takeWhile } from 'rxjs/operators';
8
- import * as i3 from '@angular/cdk/scrolling';
9
- import { ScrollingModule } from '@angular/cdk/scrolling';
10
- import { fromDimension$, fromMutation$ } from '@scion/toolkit/observable';
11
- import { subscribeInside, filterArray } from '@scion/toolkit/operators';
12
-
13
- /*
14
- * Copyright (c) 2018-2019 Swiss Federal Railways
15
- *
16
- * This program and the accompanying materials are made
17
- * available under the terms of the Eclipse Public License 2.0
18
- * which is available at https://www.eclipse.org/legal/epl-2.0/
19
- *
20
- * SPDX-License-Identifier: EPL-2.0
21
- */
22
- /**
23
- * Provides the native scrollbar tracksize.
24
- *
25
- * @dynamic ignore 'strictMetadataEmit' errors due to the usage of {@link Document} as ambient type for DI.
26
- */
27
- class SciNativeScrollbarTrackSizeProvider {
28
- constructor(_document, _zone) {
29
- this._document = _document;
30
- this._zone = _zone;
31
- this._trackSize$ = new BehaviorSubject(null);
32
- this._destroy$ = new Subject();
33
- this.installNativeScrollbarTrackSizeListener();
34
- }
35
- /**
36
- * Returns an {Observable} which emits the native scrollbar track size, if any, or else `null`.
37
- *
38
- * Upon subscription, it emits the track size immediately, and then continuously emits when the track size changes.
39
- */
40
- get trackSize$() {
41
- return this._trackSize$;
42
- }
43
- /**
44
- * Returns the native scrollbar track size, if any, or else `null`.
45
- */
46
- get trackSize() {
47
- return this._trackSize$.getValue();
48
- }
49
- /**
50
- * Computes the native scrollbar track size.
51
- *
52
- * @returns native track size, or `null` if the native scrollbars sit on top of the content.
53
- */
54
- computeTrackSize() {
55
- // create temporary viewport and viewport client with native scrollbars to compute scrolltrack width
56
- const viewportDiv = this._document.createElement('div');
57
- setStyle(viewportDiv, {
58
- position: 'absolute',
59
- overflow: 'scroll',
60
- height: '100px',
61
- width: '100px',
62
- border: 0,
63
- visibility: 'hidden',
64
- });
65
- const viewportClientDiv = this._document.createElement('div');
66
- setStyle(viewportClientDiv, {
67
- height: '100%',
68
- width: '100%',
69
- border: 0,
70
- });
71
- viewportDiv.appendChild(viewportClientDiv);
72
- this._document.body.appendChild(viewportDiv);
73
- const trackSize = {
74
- hScrollbarTrackHeight: viewportDiv.offsetHeight - viewportClientDiv.offsetHeight,
75
- vScrollbarTrackWidth: viewportDiv.offsetWidth - viewportClientDiv.offsetWidth,
76
- };
77
- // destroy temporary viewport
78
- this._document.body.removeChild(viewportDiv);
79
- if (trackSize.hScrollbarTrackHeight === 0 && trackSize.vScrollbarTrackWidth === 0) {
80
- return null;
81
- }
82
- return trackSize;
83
- }
84
- installNativeScrollbarTrackSizeListener() {
85
- // We compute the size of the native scrollbar track when the browser fires the onresize window event.
86
- // This event is also fired on page zoom or when displaying a hidden document. Hidden documents do not have
87
- // a scrollbar track size until being displayed, e.g., after showing hidden iframes.
88
- this._zone.runOutsideAngular(() => {
89
- fromEvent(window, 'resize')
90
- .pipe(debounceTime(5), startWith(null), // trigger the initial computation
91
- map(() => this.computeTrackSize()), distinctUntilChanged((t1, t2) => JSON.stringify(t1) === JSON.stringify(t2)), takeUntil(this._destroy$))
92
- .subscribe(trackSize => {
93
- this._zone.run(() => this._trackSize$.next(trackSize));
94
- });
95
- });
96
- }
97
- ngOnDestroy() {
98
- this._destroy$.next();
99
- }
100
- }
101
- SciNativeScrollbarTrackSizeProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: SciNativeScrollbarTrackSizeProvider, deps: [{ token: DOCUMENT }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
102
- SciNativeScrollbarTrackSizeProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: SciNativeScrollbarTrackSizeProvider, providedIn: 'root' });
103
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: SciNativeScrollbarTrackSizeProvider, decorators: [{
104
- type: Injectable,
105
- args: [{ providedIn: 'root' }]
106
- }], ctorParameters: function () {
107
- return [{ type: Document, decorators: [{
108
- type: Inject,
109
- args: [DOCUMENT]
110
- }] }, { type: i0.NgZone }];
111
- } });
112
- /**
113
- * Applies the given style(s) to the given element.
114
- *
115
- * Specify styles to be modified by passing a dictionary containing CSS property names (hyphen case).
116
- * To remove a style, set its value to `null`.
117
- *
118
- * @ignore
119
- */
120
- function setStyle(element, style) {
121
- Object.keys(style).forEach(key => element.style.setProperty(key, style[key]));
122
- }
123
-
124
- /*
125
- * Copyright (c) 2018-2019 Swiss Federal Railways
126
- *
127
- * This program and the accompanying materials are made
128
- * available under the terms of the Eclipse Public License 2.0
129
- * which is available at https://www.eclipse.org/legal/epl-2.0/
130
- *
131
- * SPDX-License-Identifier: EPL-2.0
132
- */
133
- /**
134
- * Renders a vertical or horizontal scrollbar.
135
- *
136
- * The scrollbar features the following functionality:
137
- * - allows to move the thumb by mouse or touch
138
- * - enlarges the thumb if the mouse pointer is near the thumb
139
- * - allows paging on mousedown on the scroll track
140
- *
141
- * ### CSS styling:
142
- *
143
- * You can override the following CSS variables:
144
- *
145
- * - sci-scrollbar-color: Sets the color of the scrollbar (by default, uses `rgb(78, 78, 78)`).
146
- *
147
- * Example:
148
- *
149
- * ```css
150
- *
151
- * sci-scrollbar {
152
- * --sci-scrollbar-color: blue;
153
- * }
154
- * ```
155
- */
156
- class SciScrollbarComponent {
157
- constructor(_host, _document, _zone) {
158
- this._host = _host;
159
- this._document = _document;
160
- this._zone = _zone;
161
- this._destroy$ = new Subject();
162
- this._viewportChange$ = new Subject();
163
- this._lastDragPosition = null;
164
- this._overflow = false;
165
- this._thumbSizeFr = 0;
166
- this._thumbPositionFr = 0;
167
- /**
168
- * Specifies the direction of the scrollbar.
169
- *
170
- * By default, if not specified, renders a vertical scrollbar.
171
- */
172
- this.direction = 'vscroll';
173
- this._viewportChange$
174
- .pipe(switchMap(() => {
175
- if (!this._viewport) {
176
- return of(undefined);
177
- }
178
- return merge(this.viewportScrollChange$(), this.viewportDimensionChange$({ debounceTime: SciScrollbarComponent.VIEWPORT_RESIZE_DEBOUNCE_TIME }), this.viewportClientDimensionChange$({ debounceTime: SciScrollbarComponent.VIEWPORT_RESIZE_DEBOUNCE_TIME }));
179
- }), subscribeInside(continueFn => this._zone.runOutsideAngular(continueFn)), takeUntil(this._destroy$))
180
- .subscribe(() => {
181
- if (this._viewport) {
182
- this.renderScrollPosition();
183
- }
184
- else {
185
- this.unsetScrollPosition();
186
- }
187
- });
188
- }
189
- get vertical() {
190
- return this.direction === 'vscroll';
191
- }
192
- get horizontal() {
193
- return this.direction === 'hscroll';
194
- }
195
- get scrolling() {
196
- return this._lastDragPosition !== null;
197
- }
198
- /**
199
- * The viewport to provide scrollbars for.
200
- */
201
- set setViewport(viewport) {
202
- this._viewport = viewport;
203
- this._viewportChange$.next();
204
- }
205
- /**
206
- * Computes the scroll position and updates CSS variables to render the scroll position in the UI.
207
- */
208
- renderScrollPosition() {
209
- NgZone.assertNotInAngularZone();
210
- const viewportSize = this.viewportSize;
211
- const viewportClientSize = this.viewportClientSize;
212
- const thumbPositionFr = this.scrollPosition / viewportClientSize;
213
- const thumbSizeFr = viewportSize / viewportClientSize;
214
- const overflow = viewportClientSize > viewportSize;
215
- if (thumbPositionFr !== this._thumbPositionFr || thumbSizeFr !== this._thumbSizeFr) {
216
- this._thumbPositionFr = thumbPositionFr;
217
- this._thumbSizeFr = thumbSizeFr;
218
- this.setCssVariable('--ɵsci-scrollbar-thumb-position-fr', thumbPositionFr);
219
- this.setCssVariable('--ɵsci-scrollbar-thumb-size-fr', thumbSizeFr);
220
- }
221
- if (overflow !== this._overflow) {
222
- this._overflow = overflow;
223
- overflow ? this._host.nativeElement.classList.add('overflow') : this._host.nativeElement.classList.remove('overflow');
224
- }
225
- }
226
- /**
227
- * Clears CSS variables used for rendering the scroll position in the UI.
228
- */
229
- unsetScrollPosition() {
230
- NgZone.assertNotInAngularZone();
231
- this._thumbPositionFr = 0;
232
- this._thumbSizeFr = 0;
233
- this._overflow = false;
234
- this.setCssVariable('--ɵsci-scrollbar-thumb-position-fr', 0);
235
- this.setCssVariable('--ɵsci-scrollbar-thumb-size-fr', 0);
236
- this._host.nativeElement.classList.remove('overflow');
237
- }
238
- /* @docs-private */
239
- onTouchStart(event) {
240
- event.preventDefault();
241
- this._lastDragPosition = this.vertical ? event.touches[0].screenY : event.touches[0].screenX;
242
- }
243
- /* @docs-private */
244
- onTouchMove(event) {
245
- event.preventDefault();
246
- const newDragPositionPx = this.vertical ? event.touches[0].screenY : event.touches[0].screenX;
247
- const scrollbarPanPx = newDragPositionPx - this._lastDragPosition;
248
- const viewportPanPx = this.toViewportPanPx(scrollbarPanPx);
249
- this._lastDragPosition = newDragPositionPx;
250
- this.moveViewportClient(viewportPanPx);
251
- }
252
- /* @docs-private */
253
- onTouchEnd(event) {
254
- event.preventDefault();
255
- this._lastDragPosition = null;
256
- }
257
- /* @docs-private */
258
- onMouseDown(mousedownEvent) {
259
- if (mousedownEvent.button !== 0) {
260
- return;
261
- }
262
- mousedownEvent.preventDefault();
263
- this._lastDragPosition = this.vertical ? mousedownEvent.screenY : mousedownEvent.screenX;
264
- // Listen for 'mousemove' events
265
- this._zone.runOutsideAngular(() => {
266
- const mousemoveListener = merge(fromEvent(this._document, 'mousemove'), fromEvent(this._document, 'sci-mousemove'))
267
- .pipe(takeUntil(this._destroy$))
268
- .subscribe(mousemoveEvent => {
269
- mousemoveEvent.preventDefault();
270
- const newDragPositionPx = this.vertical ? mousemoveEvent.screenY : mousemoveEvent.screenX;
271
- const scrollbarPanPx = newDragPositionPx - this._lastDragPosition;
272
- const viewportPanPx = this.toViewportPanPx(scrollbarPanPx);
273
- this._lastDragPosition = newDragPositionPx;
274
- this.moveViewportClient(viewportPanPx);
275
- });
276
- // Listen for 'mouseup' events; use 'capture phase' and 'stop propagation' to not close overlays
277
- merge(fromEvent(this._document, 'mouseup', { capture: true }), fromEvent(this._document, 'sci-mouseup'))
278
- .pipe(first(), takeUntil(this._destroy$))
279
- .subscribe(mouseupEvent => {
280
- mouseupEvent.stopPropagation();
281
- mousemoveListener.unsubscribe();
282
- this._lastDragPosition = null;
283
- });
284
- });
285
- }
286
- /* @docs-private */
287
- onScrollTrackMouseDown(event, direction) {
288
- const signum = (direction === 'up' ? -1 : +1);
289
- this.scrollWhileMouseDown(this.toViewportPanPx(signum * this.thumbSize), event);
290
- }
291
- /**
292
- * Projects the given scrollbar scroll pixels into viewport scroll pixels.
293
- */
294
- toViewportPanPx(scrollbarPanPx) {
295
- const scrollRangePx = this.trackSize - this.thumbSize;
296
- const scrollRatio = scrollbarPanPx / scrollRangePx;
297
- return scrollRatio * (this.viewportClientSize - this.viewportSize);
298
- }
299
- /**
300
- * Moves the viewport client by the specified numbers of pixels.
301
- */
302
- moveViewportClient(viewportPanPx) {
303
- if (this.vertical) {
304
- this._viewport.scrollTop += viewportPanPx;
305
- }
306
- else {
307
- this._viewport.scrollLeft += viewportPanPx;
308
- }
309
- }
310
- /**
311
- * Indicates if the content overflows.
312
- */
313
- get overflow() {
314
- return this._overflow;
315
- }
316
- /**
317
- * Scrolls continuously while holding the mouse pressed, or until the mouse leaves the scrolltrack.
318
- */
319
- scrollWhileMouseDown(viewportScrollPx, mousedownEvent) {
320
- // The `EventTarget` type of `Event.target` is not yet compatible with `FromEventTarget` used in `fromEvent`.
321
- // This will be fixed in rxjs version 7.0.0. Refer to https://github.com/ReactiveX/rxjs/commit/5f022d784570684632e6fd5ae247fc259ee34c4b
322
- // for more details.
323
- const scrollTrackElement = mousedownEvent.target;
324
- // scroll continuously every 50ms after an initial delay of 250ms
325
- timer(250, 50)
326
- .pipe(
327
- // continue chain with latest mouse event
328
- withLatestFrom(merge(of(mousedownEvent), fromEvent(scrollTrackElement, 'mousemove')), (tick, event) => event),
329
- // start immediately
330
- startWith(mousedownEvent),
331
- // stop scrolling if the thumb hits the mouse pointer position
332
- takeWhile((event) => scrollTrackElement === this._document.elementFromPoint(event.clientX, event.clientY)), debounceTime(10),
333
- // stop scrolling on mouseout or mouseup
334
- takeUntil(merge(fromEvent(scrollTrackElement, 'mouseout'), fromEvent(scrollTrackElement, 'mouseup'))))
335
- .subscribe(() => {
336
- this.moveViewportClient(viewportScrollPx);
337
- });
338
- }
339
- /**
340
- * Emits whenever the viewport scrolls.
341
- */
342
- viewportScrollChange$() {
343
- return fromEvent(this._viewport, 'scroll', { passive: true }).pipe(map(() => undefined));
344
- }
345
- /**
346
- * Emits on subscription, and then each time the size of the viewport changes.
347
- */
348
- viewportDimensionChange$(options) {
349
- return fromDimension$(this._viewport)
350
- .pipe(
351
- // Debouncing is particularly important in the context of Angular animations, since they continuously
352
- // trigger resize events. Debouncing prevents the scrollbar from flickering, for example, when the user
353
- // expands a panel that contains a viewport.
354
- debounceTime(options.debounceTime), map(() => undefined));
355
- }
356
- /**
357
- * Emits on subscription, and then each time the size or style property of the viewport client changes.
358
- */
359
- viewportClientDimensionChange$(options) {
360
- return this.children$(this._viewport)
361
- .pipe(switchMap(children => merge(...children.map(child => merge(fromDimension$(child),
362
- // Observe style mutations since some transformations change the scroll position without necessarily triggering a dimension change,
363
- // e.g., `scale` or `translate` used by some virtual scroll implementations
364
- fromMutation$(child, { subtree: false, childList: false, attributeFilter: ['style'] }))))),
365
- // Debouncing is particularly important in the context of Angular animations, since they continuously
366
- // trigger resize events. Debouncing prevents the scrollbar from flickering, for example, when the user
367
- // expands a panel that contains a viewport.
368
- debounceTime(options.debounceTime), map(() => undefined));
369
- }
370
- /**
371
- * Emits the children of the passed element, and then each time child elements are added or removed.
372
- */
373
- children$(element) {
374
- return fromMutation$(element, { subtree: false, childList: true })
375
- .pipe(startWith(undefined), map(() => Array.from(element.children)), filterArray((child) => child instanceof HTMLElement));
376
- }
377
- setCssVariable(key, value) {
378
- this._host.nativeElement.style.setProperty(key, value);
379
- }
380
- get viewportSize() {
381
- return this._viewport ? (this.vertical ? this._viewport.clientHeight : this._viewport.clientWidth) : 0;
382
- }
383
- get viewportClientSize() {
384
- return this._viewport ? (this.vertical ? this._viewport.scrollHeight : this._viewport.scrollWidth) : 0;
385
- }
386
- get scrollPosition() {
387
- return this._viewport ? (this.vertical ? this._viewport.scrollTop : this._viewport.scrollLeft) : 0;
388
- }
389
- get thumbSize() {
390
- const thumbElement = this.thumbElement.nativeElement;
391
- return this.vertical ? thumbElement.clientHeight : thumbElement.clientWidth;
392
- }
393
- get trackSize() {
394
- const trackElement = this._host.nativeElement;
395
- return this.vertical ? trackElement.clientHeight : trackElement.clientWidth;
396
- }
397
- /* @docs-private */
398
- ngOnDestroy() {
399
- this._destroy$.next();
400
- }
401
- }
402
- /**
403
- * Timeout for debouncing viewport resize events that trigger the scroll position computation.
404
- *
405
- * Debouncing is particularly important in the context of Angular animations, since they continuously
406
- * trigger resize events. Debouncing prevents the scrollbar from flickering, for example, when the user
407
- * expands a panel that contains a viewport.
408
- *
409
- * @internal
410
- */
411
- SciScrollbarComponent.VIEWPORT_RESIZE_DEBOUNCE_TIME = 50;
412
- SciScrollbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: SciScrollbarComponent, deps: [{ token: i0.ElementRef }, { token: DOCUMENT }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
413
- SciScrollbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.2", type: SciScrollbarComponent, selector: "sci-scrollbar", inputs: { direction: "direction", setViewport: ["viewport", "setViewport"] }, host: { properties: { "class.vertical": "this.vertical", "class.horizontal": "this.horizontal", "class.scrolling": "this.scrolling" } }, viewQueries: [{ propertyName: "thumbElement", first: true, predicate: ["thumb_handle"], descendants: true, static: true }], ngImport: i0, template: "<!-- scrolltrack to move the viewport client upwards (paging) -->\n<div class=\"scrolltrack-start\" (mousedown)=\"onScrollTrackMouseDown($event, 'up')\"></div>\n\n<!-- scrollthumb -->\n<div #thumb_handle\n class=\"thumb-handle\"\n [class.vertical]=\"vertical\"\n [class.horizontal]=\"horizontal\"\n (mousedown)=\"onMouseDown($event)\"\n (touchstart)=\"onTouchStart($event)\"\n (touchmove)=\"onTouchMove($event)\"\n (touchend)=\"onTouchEnd($event)\"\n (touchcancel)=\"onTouchEnd($event)\">\n <div class=\"thumb\"\n [class.vertical]=\"vertical\"\n [class.horizontal]=\"horizontal\">\n </div>\n</div>\n\n<!-- scrolltrack to move the viewport client downwards (paging) -->\n<div class=\"scrolltrack-end\" (mousedown)=\"onScrollTrackMouseDown($event, 'down')\"></div>\n", styles: ["@charset \"UTF-8\";:host{display:flex;border:2px solid transparent;box-sizing:border-box;--sci-scrollbar-color: rgb(78, 78, 78);--\\275sci-scrollbar-thumb-position-fr: 0;--\\275sci-scrollbar-thumb-size-fr: 0}:host.vertical{flex-direction:column}:host.horizontal{flex-direction:row}:host>div.scrolltrack-start{flex-grow:var(--\\275sci-scrollbar-thumb-position-fr)}:host>div.thumb-handle{flex-basis:20px;display:flex;flex-grow:var(--\\275sci-scrollbar-thumb-size-fr);align-items:center}:host>div.thumb-handle.vertical{flex-direction:column}:host>div.thumb-handle.horizontal{flex-direction:row}:host>div.thumb-handle>div.thumb{flex:auto;border-radius:4px;background-color:var(--sci-scrollbar-color);opacity:.4;transition-duration:125ms;transition-property:width,height;transition-timing-function:ease-out}:host>div.thumb-handle>div.thumb.vertical{width:60%}:host>div.thumb-handle>div.thumb.horizontal{height:60%}:host>div.scrolltrack-end{flex-grow:calc(1 - (var(--\\275sci-scrollbar-thumb-position-fr) + var(--\\275sci-scrollbar-thumb-size-fr)))}:host-context:not(.overflow){display:none}:host-context:hover>div.thumb-handle>div.thumb,:host-context(.scrolling)>div.thumb-handle>div.thumb{background-color:var(--sci-scrollbar-color);opacity:.75}:host-context:hover>div.thumb-handle>div.thumb.vertical,:host-context(.scrolling)>div.thumb-handle>div.thumb.vertical{width:100%}:host-context:hover>div.thumb-handle>div.thumb.horizontal,:host-context(.scrolling)>div.thumb-handle>div.thumb.horizontal{height:100%}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
414
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: SciScrollbarComponent, decorators: [{
415
- type: Component,
416
- args: [{ selector: 'sci-scrollbar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<!-- scrolltrack to move the viewport client upwards (paging) -->\n<div class=\"scrolltrack-start\" (mousedown)=\"onScrollTrackMouseDown($event, 'up')\"></div>\n\n<!-- scrollthumb -->\n<div #thumb_handle\n class=\"thumb-handle\"\n [class.vertical]=\"vertical\"\n [class.horizontal]=\"horizontal\"\n (mousedown)=\"onMouseDown($event)\"\n (touchstart)=\"onTouchStart($event)\"\n (touchmove)=\"onTouchMove($event)\"\n (touchend)=\"onTouchEnd($event)\"\n (touchcancel)=\"onTouchEnd($event)\">\n <div class=\"thumb\"\n [class.vertical]=\"vertical\"\n [class.horizontal]=\"horizontal\">\n </div>\n</div>\n\n<!-- scrolltrack to move the viewport client downwards (paging) -->\n<div class=\"scrolltrack-end\" (mousedown)=\"onScrollTrackMouseDown($event, 'down')\"></div>\n", styles: ["@charset \"UTF-8\";:host{display:flex;border:2px solid transparent;box-sizing:border-box;--sci-scrollbar-color: rgb(78, 78, 78);--\\275sci-scrollbar-thumb-position-fr: 0;--\\275sci-scrollbar-thumb-size-fr: 0}:host.vertical{flex-direction:column}:host.horizontal{flex-direction:row}:host>div.scrolltrack-start{flex-grow:var(--\\275sci-scrollbar-thumb-position-fr)}:host>div.thumb-handle{flex-basis:20px;display:flex;flex-grow:var(--\\275sci-scrollbar-thumb-size-fr);align-items:center}:host>div.thumb-handle.vertical{flex-direction:column}:host>div.thumb-handle.horizontal{flex-direction:row}:host>div.thumb-handle>div.thumb{flex:auto;border-radius:4px;background-color:var(--sci-scrollbar-color);opacity:.4;transition-duration:125ms;transition-property:width,height;transition-timing-function:ease-out}:host>div.thumb-handle>div.thumb.vertical{width:60%}:host>div.thumb-handle>div.thumb.horizontal{height:60%}:host>div.scrolltrack-end{flex-grow:calc(1 - (var(--\\275sci-scrollbar-thumb-position-fr) + var(--\\275sci-scrollbar-thumb-size-fr)))}:host-context:not(.overflow){display:none}:host-context:hover>div.thumb-handle>div.thumb,:host-context(.scrolling)>div.thumb-handle>div.thumb{background-color:var(--sci-scrollbar-color);opacity:.75}:host-context:hover>div.thumb-handle>div.thumb.vertical,:host-context(.scrolling)>div.thumb-handle>div.thumb.vertical{width:100%}:host-context:hover>div.thumb-handle>div.thumb.horizontal,:host-context(.scrolling)>div.thumb-handle>div.thumb.horizontal{height:100%}\n"] }]
417
- }], ctorParameters: function () {
418
- return [{ type: i0.ElementRef }, { type: undefined, decorators: [{
419
- type: Inject,
420
- args: [DOCUMENT]
421
- }] }, { type: i0.NgZone }];
422
- }, propDecorators: { thumbElement: [{
423
- type: ViewChild,
424
- args: ['thumb_handle', { static: true }]
425
- }], vertical: [{
426
- type: HostBinding,
427
- args: ['class.vertical']
428
- }], horizontal: [{
429
- type: HostBinding,
430
- args: ['class.horizontal']
431
- }], scrolling: [{
432
- type: HostBinding,
433
- args: ['class.scrolling']
434
- }], direction: [{
435
- type: Input
436
- }], setViewport: [{
437
- type: Input,
438
- args: ['viewport']
439
- }] } });
440
-
441
- /*
442
- * Copyright (c) 2018-2019 Swiss Federal Railways
443
- *
444
- * This program and the accompanying materials are made
445
- * available under the terms of the Eclipse Public License 2.0
446
- * which is available at https://www.eclipse.org/legal/epl-2.0/
447
- *
448
- * SPDX-License-Identifier: EPL-2.0
449
- */
450
- /**
451
- * Makes the host element natively scrollable and hides native scrollbars by default, unless native scrollbars
452
- * already sit on top of the viewport (e.g. in OS X).
453
- *
454
- * Because there is no cross-browser API to hide scrollbars without losing native scroll support, we set 'overflow'
455
- * to 'scroll' but shift the native scrollbars out of the visible viewport area. The shift offset is computed upfront.
456
- *
457
- * This directive expects its host element to be the only child in document flow in its parent DOM element. It makes the host element
458
- * fill up the entire space (width and height set to 100%). The parent element must have its CSS `overflow` property set to `hidden`
459
- * to hide the pushed out native scrollbars.
460
- */
461
- class SciScrollableDirective {
462
- constructor(_host, _renderer, nativeScrollbarTrackSizeProvider) {
463
- this._host = _host;
464
- this._renderer = _renderer;
465
- this._destroy$ = new Subject();
466
- this._inputChange$ = new Subject();
467
- /**
468
- * Controls whether to display native scrollbars.
469
- * Has no effect if the native scrollbar sits on top of the content, e.g. in OS X.
470
- */
471
- this.isDisplayNativeScrollbar = false;
472
- merge(nativeScrollbarTrackSizeProvider.trackSize$, this._inputChange$.pipe(map(() => nativeScrollbarTrackSizeProvider.trackSize)))
473
- .pipe(takeUntil(this._destroy$))
474
- .subscribe(nativeScrollbarTrackSize => {
475
- if (nativeScrollbarTrackSize === null) { // the native scrollbar sits on top of the content
476
- this.useNativeScrollbars();
477
- }
478
- else {
479
- this.isDisplayNativeScrollbar ? this.useNativeScrollbars() : this.shiftNativeScrollbars(nativeScrollbarTrackSize);
480
- }
481
- });
482
- }
483
- /**
484
- * Uses the native scrollbars when content overflows.
485
- */
486
- useNativeScrollbars() {
487
- this.setStyle(this._host.nativeElement, {
488
- overflow: 'auto',
489
- width: '100%',
490
- height: '100%',
491
- marginRight: 0,
492
- marginBottom: 0,
493
- });
494
- }
495
- /**
496
- * Shifts the native scrollbars out of the visible viewport area.
497
- */
498
- shiftNativeScrollbars(nativeScrollbarTrackSize) {
499
- this.setStyle(this._host.nativeElement, {
500
- overflow: 'scroll',
501
- width: `calc(100% + ${nativeScrollbarTrackSize.vScrollbarTrackWidth}px`,
502
- height: `calc(100% + ${nativeScrollbarTrackSize.hScrollbarTrackHeight}px`,
503
- marginRight: `-${nativeScrollbarTrackSize.vScrollbarTrackWidth}px`,
504
- marginBottom: `-${nativeScrollbarTrackSize.hScrollbarTrackHeight}px`,
505
- });
506
- }
507
- setStyle(element, style) {
508
- Object.keys(style).forEach(key => this._renderer.setStyle(element, key, style[key]));
509
- }
510
- ngOnChanges(changes) {
511
- this._inputChange$.next();
512
- }
513
- ngOnDestroy() {
514
- this._destroy$.next();
515
- }
516
- }
517
- SciScrollableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: SciScrollableDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: SciNativeScrollbarTrackSizeProvider }], target: i0.ɵɵFactoryTarget.Directive });
518
- SciScrollableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.2", type: SciScrollableDirective, selector: "[sciScrollable]", inputs: { isDisplayNativeScrollbar: ["sciScrollableDisplayNativeScrollbar", "isDisplayNativeScrollbar"] }, usesOnChanges: true, ngImport: i0 });
519
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: SciScrollableDirective, decorators: [{
520
- type: Directive,
521
- args: [{
522
- selector: '[sciScrollable]',
523
- }]
524
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: SciNativeScrollbarTrackSizeProvider }]; }, propDecorators: { isDisplayNativeScrollbar: [{
525
- type: Input,
526
- args: ['sciScrollableDisplayNativeScrollbar']
527
- }] } });
528
-
529
- /*
530
- * Copyright (c) 2018-2019 Swiss Federal Railways
531
- *
532
- * This program and the accompanying materials are made
533
- * available under the terms of the Eclipse Public License 2.0
534
- * which is available at https://www.eclipse.org/legal/epl-2.0/
535
- *
536
- * SPDX-License-Identifier: EPL-2.0
537
- */
538
- /**
539
- * Represents a viewport with slotted content (`<ng-content>`) used as scrollable content. By default, content is added to a CSS grid layout.
540
- *
541
- * The viewport component displays scrollbars when its content overflows. Scrollbars are displayed on top of the content, not next to it.
542
- * The component uses the native scrollbars of the operating system if they are already sitting on top, or falls back and renders scrollbars on top otherwise.
543
- * The viewport remains natively scrollable with the native scrollbars shifted out of the viewport's visible area. Consequently, the viewport keeps supporting
544
- * native scrolling features such as touch gestures, scroll speed acceleration, or scrolling near the viewport edges during drag-and-drop operations.
545
- *
546
- * ```html
547
- * <sci-viewport>
548
- * your content
549
- * </sci-viewport>
550
- * ```
551
- *
552
- * ## Adding the viewport to a layout
553
- *
554
- * Typically you would add the viewport component to a flexible layout, filling the remaining space vertically and horizontally, such as a flexbox container
555
- * with the viewport's `flex` CSS property set to either `flex: auto` or `flex: 1 1 0`.
556
- *
557
- * The viewport is sized according to its content width and height. It grows to absorb any free space, thus overflowing its content only when encountering
558
- * a layout constraint. Depending on the layout, different steps may be necessary to prevent the viewport from growing to infinity.
559
- *
560
- * - If practical, give the viewport a fixed size or a maximum size.
561
- * - If you add the viewport to a flexbox layout, make sure that it cannot exceed the available space. Instead, the viewport should fill the remaining space,
562
- * vertically and horizontally. Be aware that, by default, a flex item does not shrink below its minimum content size. To change this, set the viewport's
563
- * `flex-basis` to `0` (instead of `auto`), or use the CSS shorthand property `flex: 1 1 0`. The `flex-basis` defines the default size of a flex item before
564
- * the remaining extra space is distributed. If the viewport does not appear after setting this property, check its parent elements' content sizes.
565
- * As an alternative to setting `flex: 1 1 0`, change the setting to `flex: auto` and hide the overflow in the parent element, as follows: `overflow: hidden`.
566
- * Another approach would be to set the minimum height of all parents to `0`, as follows: `min-height: 0`.
567
- *
568
- * For the complete documentation on the flex layout and its features, refer to https://developer.mozilla.org/en-US/docs/Web/CSS/flex.
569
- *
570
- *
571
- * ## Layouting the viewport's slotted content
572
- *
573
- * By default, the viewport's content is added to a CSS grid container with a single column, filling remaining space vertically and horizontally.
574
- * Using the `::part(content)` pseudo element selector, you can configure the grid container or apply a different layout, such as a flex or flow layout.
575
- *
576
- * #### Example of adding slotted content to a CSS flex container.
577
- * ```css
578
- * sci-viewport::part(content) {
579
- * display: flex;
580
- * flex-direction: column;
581
- * }
582
- * ```
583
- *
584
- * #### Example of configuring CSS grid container with two columns
585
- * ```css
586
- * sci-viewport::part(content) {
587
- * grid-template-columns: 1fr 1fr;
588
- * gap: 1em;
589
- * }
590
- * ```
591
- *
592
- * ## Styling of scrollbars
593
- *
594
- * You can override the following CSS variables to control the appearance of the scrollbar:
595
- *
596
- * - sci-viewport-scrollbar-color: Sets the color of the scrollbar (by default, uses `rgb(78, 78, 78)`).
597
- *
598
- * ```css
599
- * sci-viewport {
600
- * --sci-viewport-scrollbar-color: blue;
601
- * }
602
- * ```
603
- */
604
- class SciViewportComponent {
605
- constructor(host, nativeScrollbarTrackSizeProvider) {
606
- this.host = host;
607
- this.nativeScrollbarTrackSizeProvider = nativeScrollbarTrackSizeProvider;
608
- this._scrollbarStyle = 'on-top';
609
- /**
610
- * Emits upon a scroll event.
611
- *
612
- * You can add [sciDimension] directive to the viewport or viewport client to be notified about layout changes.
613
- */
614
- this.scroll = new EventEmitter(); // eslint-disable-line @angular-eslint/no-output-native
615
- }
616
- /** @internal */
617
- set setViewport(viewport) {
618
- this._viewportElement = coerceElement(viewport);
619
- }
620
- /** @internal */
621
- set setViewportClient(viewportClient) {
622
- this._viewportClient = coerceElement(viewportClient);
623
- }
624
- /**
625
- * Controls whether to use native scrollbars or, which is by default, emulated scrollbars that sit on top of the viewport client.
626
- * In the latter, the viewport client remains natively scrollable.
627
- */
628
- set scrollbarStyle(scrollbarStyle) {
629
- this._scrollbarStyle = scrollbarStyle || 'on-top';
630
- }
631
- get scrollbarStyle() {
632
- return this._scrollbarStyle;
633
- }
634
- focus() {
635
- var _a;
636
- (_a = this._viewportElement) === null || _a === void 0 ? void 0 : _a.focus();
637
- }
638
- onScroll(event) {
639
- this.scroll.emit(event);
640
- }
641
- /**
642
- * Returns the number of pixels that the viewport client is scrolled vertically.
643
- *
644
- * @see Element.scrollTop
645
- */
646
- get scrollTop() {
647
- return this._viewportElement.scrollTop;
648
- }
649
- /**
650
- * Sets the number of pixels that the viewport client is scrolled vertically.
651
- *
652
- * @see Element.scrollTop
653
- */
654
- set scrollTop(scrollTop) {
655
- this._viewportElement.scrollTop = scrollTop;
656
- }
657
- /**
658
- * Returns the number of pixels that the viewport client is scrolled horizontally.
659
- *
660
- * @see Element.scrollLeft
661
- */
662
- get scrollLeft() {
663
- return this._viewportElement.scrollLeft;
664
- }
665
- /**
666
- * Sets the number of pixels that the viewport client is scrolled horizontally.
667
- *
668
- * @see Element.scrollLeft
669
- */
670
- set scrollLeft(scrollLeft) {
671
- this._viewportElement.scrollLeft = scrollLeft;
672
- }
673
- /**
674
- * Returns the height of the viewport client.
675
- *
676
- * @see Element.scrollHeight
677
- */
678
- get scrollHeight() {
679
- return this._viewportElement.scrollHeight;
680
- }
681
- /**
682
- * Returns the width of the viewport client.
683
- *
684
- * @see Element.scrollWidth
685
- */
686
- get scrollWidth() {
687
- return this._viewportElement.scrollWidth;
688
- }
689
- /**
690
- * Returns the viewport {HTMLElement}.
691
- */
692
- get viewportElement() {
693
- return this._viewportElement;
694
- }
695
- /**
696
- * Returns the viewport client {HTMLElement}.
697
- */
698
- get viewportClientElement() {
699
- return this._viewportClient;
700
- }
701
- /**
702
- * Checks if the specified element is scrolled into the viewport.
703
- *
704
- * @param element - the element to be checked
705
- * @param fit - control if the element must fully or partially fit into the viewport
706
- * @return `true` if the element is scrolled into the viewport, or `false` otherwise.
707
- */
708
- isElementInView(element, fit) {
709
- const elTop = this.computeOffset(element, 'top');
710
- if (elTop === null) {
711
- return false;
712
- }
713
- const elLeft = this.computeOffset(element, 'left');
714
- if (elLeft === null) {
715
- return false;
716
- }
717
- // Consider elements as scrolled into view when there is no viewport overflow.
718
- // The calculation of whether an element is scrolled into view may be wrong by a few pixels if the viewport contains elements with decimal sizes.
719
- // This can happen because `offsetLeft` and `offsetTop` operate on an integer (not a decimal), losing precision that can accumulate.
720
- // To avoid incorrect calculation when there is no viewport overflow, we consider all contained elements as scrolled into the view.
721
- if (this._viewportElement.scrollWidth <= this._viewportElement.clientWidth && this._viewportElement.scrollHeight <= this._viewportElement.clientHeight) {
722
- return true;
723
- }
724
- const elBottom = elTop + coerceElement(element).offsetHeight;
725
- const elRight = elLeft + coerceElement(element).offsetWidth;
726
- const vpTop = this._viewportElement.scrollTop;
727
- const vpLeft = this._viewportElement.scrollLeft;
728
- const vpBottom = vpTop + this._viewportElement.clientHeight;
729
- const vpRight = vpLeft + this._viewportElement.clientWidth;
730
- if (fit === 'full') {
731
- return (elTop >= vpTop && elBottom <= vpBottom) && (elLeft >= vpLeft && elRight <= vpRight);
732
- }
733
- else {
734
- return (elBottom >= vpTop && elTop <= vpBottom) && (elRight >= vpLeft && elLeft <= vpRight);
735
- }
736
- }
737
- /**
738
- * Scrolls the specified element into the viewport.
739
- *
740
- * @param element - the element to scroll into the viewport
741
- * @param offset - the gap between the element and the viewport
742
- */
743
- scrollIntoView(element, offset = 50) {
744
- const top = this.computeOffset(element, 'top');
745
- if (top === null) {
746
- return;
747
- }
748
- const left = this.computeOffset(element, 'left');
749
- if (left === null) {
750
- return;
751
- }
752
- this._viewportElement.scrollTop = top - offset;
753
- this._viewportElement.scrollLeft = left - offset;
754
- }
755
- /**
756
- * Computes the distance of the element to the viewport's left or top border.
757
- *
758
- * @return distance of the element to the viewport's left or top border, or `null` if not contained
759
- * in the viewport or the element or any ancestor has the `display` property set to `none`.
760
- */
761
- computeOffset(element, border) {
762
- let offset = 0;
763
- let el = coerceElement(element);
764
- do {
765
- offset += (border === 'left' ? el.offsetLeft : el.offsetTop);
766
- const offsetParent = el.offsetParent;
767
- if (offsetParent === null) {
768
- // `offsetParent` is `null` in the following situations:
769
- // - The element or any ancestor has the `display` property set to `none`
770
- // - The element has the position property set to fixed (Firefox returns <body>).
771
- // - The element is <body> or <html>.
772
- // See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent.
773
- return null;
774
- }
775
- if (!(offsetParent instanceof HTMLElement)) {
776
- return null;
777
- }
778
- el = offsetParent;
779
- } while (el !== this.host.nativeElement);
780
- return offset;
781
- }
782
- }
783
- SciViewportComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: SciViewportComponent, deps: [{ token: i0.ElementRef }, { token: SciNativeScrollbarTrackSizeProvider }], target: i0.ɵɵFactoryTarget.Component });
784
- SciViewportComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.2", type: SciViewportComponent, selector: "sci-viewport", inputs: { scrollbarStyle: "scrollbarStyle" }, outputs: { scroll: "scroll" }, host: { listeners: { "focus": "focus()" } }, viewQueries: [{ propertyName: "setViewport", first: true, predicate: ["viewport"], descendants: true, static: true }, { propertyName: "setViewportClient", first: true, predicate: ["viewport_client"], descendants: true, static: true }], ngImport: i0, template: "<!-- viewport and viewport client -->\n<div #viewport\n class=\"viewport\"\n tabindex=\"-1\"\n sciScrollable [sciScrollableDisplayNativeScrollbar]=\"scrollbarStyle === 'native'\"\n cdkScrollable\n (scroll)=\"onScroll($event)\">\n <div #viewport_client class=\"viewport-client\" part=\"content\">\n <slot></slot>\n </div>\n</div>\n\n<!-- render emulated scrollbars which sit on-top -->\n<ng-container *ngIf=\"scrollbarStyle === 'on-top' && (nativeScrollbarTrackSizeProvider.trackSize$ | async) !== null\">\n <sci-scrollbar [direction]=\"'vscroll'\" [viewport]=\"viewport\"></sci-scrollbar>\n <sci-scrollbar [direction]=\"'hscroll'\" [viewport]=\"viewport\"></sci-scrollbar>\n</ng-container>\n", styles: [":host{--sci-viewport-content-grid-template-columns: auto;--sci-viewport-content-grid-template-rows: unset;--sci-viewport-content-grid-auto-columns: unset;--sci-viewport-content-grid-auto-rows: auto;--sci-viewport-content-grid-gap: 0 0;--sci-viewport-scrollbar-color: rgb(78, 78, 78);display:grid;grid-template-columns:100%;grid-template-rows:100%;position:relative;overflow:hidden;outline:none}:host:not(:hover):not(:active) sci-scrollbar:not(.scrolling){opacity:0}:host>div.viewport{display:grid;position:relative;outline:none;-webkit-overflow-scrolling:touch}:host>div.viewport>div.viewport-client{display:grid;grid-template-columns:var(--sci-viewport-content-grid-template-columns);grid-template-rows:var(--sci-viewport-content-grid-template-rows);grid-auto-rows:var(--sci-viewport-content-grid-auto-rows);grid-auto-columns:var(--sci-viewport-content-grid-auto-columns);gap:var(--sci-viewport-content-grid-gap)}:host>sci-scrollbar{--sci-scrollbar-color: var(--sci-viewport-scrollbar-color);position:absolute;transition-duration:1s;transition-property:opacity;transition-timing-function:ease-out}:host>sci-scrollbar.vertical{top:0;right:0;bottom:0;left:unset;width:12px}:host>sci-scrollbar.horizontal{top:unset;right:0;bottom:0;left:0;height:12px}\n"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.CdkScrollable, selector: "[cdk-scrollable], [cdkScrollable]" }, { kind: "component", type: SciScrollbarComponent, selector: "sci-scrollbar", inputs: ["direction", "viewport"] }, { kind: "directive", type: SciScrollableDirective, selector: "[sciScrollable]", inputs: ["sciScrollableDisplayNativeScrollbar"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }], encapsulation: i0.ViewEncapsulation.ShadowDom });
785
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: SciViewportComponent, decorators: [{
786
- type: Component,
787
- args: [{ selector: 'sci-viewport', encapsulation: ViewEncapsulation.ShadowDom, template: "<!-- viewport and viewport client -->\n<div #viewport\n class=\"viewport\"\n tabindex=\"-1\"\n sciScrollable [sciScrollableDisplayNativeScrollbar]=\"scrollbarStyle === 'native'\"\n cdkScrollable\n (scroll)=\"onScroll($event)\">\n <div #viewport_client class=\"viewport-client\" part=\"content\">\n <slot></slot>\n </div>\n</div>\n\n<!-- render emulated scrollbars which sit on-top -->\n<ng-container *ngIf=\"scrollbarStyle === 'on-top' && (nativeScrollbarTrackSizeProvider.trackSize$ | async) !== null\">\n <sci-scrollbar [direction]=\"'vscroll'\" [viewport]=\"viewport\"></sci-scrollbar>\n <sci-scrollbar [direction]=\"'hscroll'\" [viewport]=\"viewport\"></sci-scrollbar>\n</ng-container>\n", styles: [":host{--sci-viewport-content-grid-template-columns: auto;--sci-viewport-content-grid-template-rows: unset;--sci-viewport-content-grid-auto-columns: unset;--sci-viewport-content-grid-auto-rows: auto;--sci-viewport-content-grid-gap: 0 0;--sci-viewport-scrollbar-color: rgb(78, 78, 78);display:grid;grid-template-columns:100%;grid-template-rows:100%;position:relative;overflow:hidden;outline:none}:host:not(:hover):not(:active) sci-scrollbar:not(.scrolling){opacity:0}:host>div.viewport{display:grid;position:relative;outline:none;-webkit-overflow-scrolling:touch}:host>div.viewport>div.viewport-client{display:grid;grid-template-columns:var(--sci-viewport-content-grid-template-columns);grid-template-rows:var(--sci-viewport-content-grid-template-rows);grid-auto-rows:var(--sci-viewport-content-grid-auto-rows);grid-auto-columns:var(--sci-viewport-content-grid-auto-columns);gap:var(--sci-viewport-content-grid-gap)}:host>sci-scrollbar{--sci-scrollbar-color: var(--sci-viewport-scrollbar-color);position:absolute;transition-duration:1s;transition-property:opacity;transition-timing-function:ease-out}:host>sci-scrollbar.vertical{top:0;right:0;bottom:0;left:unset;width:12px}:host>sci-scrollbar.horizontal{top:unset;right:0;bottom:0;left:0;height:12px}\n"] }]
788
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: SciNativeScrollbarTrackSizeProvider }]; }, propDecorators: { setViewport: [{
789
- type: ViewChild,
790
- args: ['viewport', { static: true }]
791
- }], setViewportClient: [{
792
- type: ViewChild,
793
- args: ['viewport_client', { static: true }]
794
- }], scrollbarStyle: [{
795
- type: Input
796
- }], scroll: [{
797
- type: Output
798
- }], focus: [{
799
- type: HostListener,
800
- args: ['focus']
801
- }] } });
802
-
803
- /*
804
- * Copyright (c) 2018-2019 Swiss Federal Railways
805
- *
806
- * This program and the accompanying materials are made
807
- * available under the terms of the Eclipse Public License 2.0
808
- * which is available at https://www.eclipse.org/legal/epl-2.0/
809
- *
810
- * SPDX-License-Identifier: EPL-2.0
811
- */
812
- /**
813
- * Provides a viewport component with scrollbars that sit on top of the viewport client.
814
- */
815
- class SciViewportModule {
816
- }
817
- SciViewportModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: SciViewportModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
818
- SciViewportModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.2", ngImport: i0, type: SciViewportModule, declarations: [SciViewportComponent,
819
- SciScrollbarComponent,
820
- SciScrollableDirective], imports: [CommonModule,
821
- ScrollingModule], exports: [SciViewportComponent,
822
- SciScrollbarComponent,
823
- SciScrollableDirective] });
824
- SciViewportModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: SciViewportModule, imports: [CommonModule,
825
- ScrollingModule] });
826
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: SciViewportModule, decorators: [{
827
- type: NgModule,
828
- args: [{
829
- imports: [
830
- CommonModule,
831
- ScrollingModule,
832
- ],
833
- declarations: [
834
- SciViewportComponent,
835
- SciScrollbarComponent,
836
- SciScrollableDirective,
837
- ],
838
- exports: [
839
- SciViewportComponent,
840
- SciScrollbarComponent,
841
- SciScrollableDirective,
842
- ],
843
- }]
844
- }] });
845
-
846
- /*
847
- * Copyright (c) 2018-2019 Swiss Federal Railways
848
- *
849
- * This program and the accompanying materials are made
850
- * available under the terms of the Eclipse Public License 2.0
851
- * which is available at https://www.eclipse.org/legal/epl-2.0/
852
- *
853
- * SPDX-License-Identifier: EPL-2.0
854
- */
855
-
856
- /**
857
- * Generated bundle index. Do not edit.
858
- */
859
-
860
- export { SciNativeScrollbarTrackSizeProvider, SciScrollableDirective, SciScrollbarComponent, SciViewportComponent, SciViewportModule };
861
- //# sourceMappingURL=scion-components-viewport.mjs.map