@covalent/core 3.1.2-beta.6 → 3.1.2-beta.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 (44) hide show
  1. package/bundles/covalent-core-side-sheet.umd.js +1396 -0
  2. package/bundles/covalent-core-side-sheet.umd.js.map +1 -0
  3. package/bundles/covalent-core-side-sheet.umd.min.js +16 -0
  4. package/bundles/covalent-core-side-sheet.umd.min.js.map +1 -0
  5. package/dialogs/_dialog-theme.scss +1 -0
  6. package/esm2015/side-sheet/covalent-core-side-sheet.js +12 -0
  7. package/esm2015/side-sheet/index.js +7 -0
  8. package/esm2015/side-sheet/public-api.js +11 -0
  9. package/esm2015/side-sheet/side-sheet-container.js +388 -0
  10. package/esm2015/side-sheet/side-sheet-ref.js +47 -0
  11. package/esm2015/side-sheet/side-sheet.animation.js +20 -0
  12. package/esm2015/side-sheet/side-sheet.config.js +12 -0
  13. package/esm2015/side-sheet/side-sheet.content-directives.js +255 -0
  14. package/esm2015/side-sheet/side-sheet.js +312 -0
  15. package/esm2015/side-sheet/side-sheet.module.js +36 -0
  16. package/fesm2015/covalent-core-side-sheet.js +1070 -0
  17. package/fesm2015/covalent-core-side-sheet.js.map +1 -0
  18. package/package.json +1 -1
  19. package/side-sheet/README.md +66 -0
  20. package/side-sheet/covalent-core-side-sheet.d.ts +6 -0
  21. package/side-sheet/covalent-core-side-sheet.metadata.json +1 -0
  22. package/side-sheet/index.d.ts +1 -0
  23. package/side-sheet/package.json +11 -0
  24. package/side-sheet/public-api.d.ts +5 -0
  25. package/side-sheet/side-sheet-container.d.ts +92 -0
  26. package/side-sheet/side-sheet-ref.d.ts +9 -0
  27. package/side-sheet/side-sheet.animation.d.ts +4 -0
  28. package/side-sheet/side-sheet.config.d.ts +3 -0
  29. package/side-sheet/side-sheet.content-directives.d.ts +50 -0
  30. package/side-sheet/side-sheet.d.ts +56 -0
  31. package/side-sheet/side-sheet.module.d.ts +2 -0
  32. package/side-sheet/side-sheet.scss +69 -0
  33. package/side-sheet/side-sheet.theme.scss +8 -0
  34. package/theming/_all-theme.scss +2 -0
  35. package/theming/prebuilt/blue-grey-deep-orange.css +5 -1
  36. package/theming/prebuilt/blue-grey-deep-orange.css.map +1 -1
  37. package/theming/prebuilt/blue-orange.css +5 -1
  38. package/theming/prebuilt/blue-orange.css.map +1 -1
  39. package/theming/prebuilt/indigo-pink.css +5 -1
  40. package/theming/prebuilt/indigo-pink.css.map +1 -1
  41. package/theming/prebuilt/orange-light-blue.css +5 -1
  42. package/theming/prebuilt/orange-light-blue.css.map +1 -1
  43. package/theming/prebuilt/teal-orange.css +5 -1
  44. package/theming/prebuilt/teal-orange.css.map +1 -1
@@ -0,0 +1,1070 @@
1
+ import { EventEmitter, Directive, ElementRef, ChangeDetectorRef, Optional, Inject, ViewChild, Component, ViewEncapsulation, ChangeDetectionStrategy, Injector, TemplateRef, InjectFlags, Type, InjectionToken, Injectable, SkipSelf, Input, NgModule } from '@angular/core';
2
+ import { BasePortalOutlet, CdkPortalOutlet, ComponentPortal, TemplatePortal, PortalModule } from '@angular/cdk/portal';
3
+ import { AnimationDurations, AnimationCurves, MatCommonModule } from '@angular/material/core';
4
+ import { MatDialogConfig, MatDialogRef, MAT_DIALOG_DATA, MAT_DIALOG_DEFAULT_OPTIONS, MatDialogModule } from '@angular/material/dialog';
5
+ import { OverlayConfig, Overlay } from '@angular/cdk/overlay';
6
+ import { FocusTrapFactory, FocusMonitor } from '@angular/cdk/a11y';
7
+ import { DOCUMENT } from '@angular/common';
8
+ import { trigger, state, style, transition, animate } from '@angular/animations';
9
+ import { Subject, of } from 'rxjs';
10
+ import { Directionality } from '@angular/cdk/bidi';
11
+
12
+ /**
13
+ * @fileoverview added by tsickle
14
+ * Generated from: side-sheet.animation.ts
15
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
16
+ */
17
+ /** @type {?} */
18
+ const tdSideSheetAnimations = {
19
+ /**
20
+ * Animation that is applied on the side-sheet container by default.
21
+ */
22
+ sideSheetContainer: trigger('sideSheetContainer', [
23
+ state('void, exit', style({ transform: 'translateX(100%)' })),
24
+ state('enter', style({ transform: 'translateX(0%)', opacity: 1 })),
25
+ transition('* => enter', animate(`${AnimationDurations.ENTERING} ${AnimationCurves.ACCELERATION_CURVE}`, style({ transform: 'translateX(0)', opacity: 1 }))),
26
+ transition('* => void, * => exit', animate(`${AnimationDurations.EXITING} ${AnimationCurves.ACCELERATION_CURVE}`, style({ transform: 'translateX(100%)' }))),
27
+ ]),
28
+ };
29
+
30
+ /**
31
+ * @fileoverview added by tsickle
32
+ * Generated from: side-sheet.config.ts
33
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
34
+ */
35
+ /**
36
+ * @template D
37
+ */
38
+ class CovalentSideSheetConfig extends MatDialogConfig {
39
+ }
40
+
41
+ /**
42
+ * @fileoverview added by tsickle
43
+ * Generated from: side-sheet-container.ts
44
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
45
+ */
46
+ /**
47
+ * @return {?}
48
+ */
49
+ function _getFocusedElementPierceShadowDom() {
50
+ /** @type {?} */
51
+ let activeElement = typeof document !== 'undefined' && document ? ((/** @type {?} */ (document.activeElement))) : null;
52
+ while (activeElement && activeElement.shadowRoot) {
53
+ /** @type {?} */
54
+ const newActiveElement = (/** @type {?} */ (activeElement.shadowRoot.activeElement));
55
+ if (newActiveElement === activeElement) {
56
+ break;
57
+ }
58
+ else {
59
+ activeElement = newActiveElement;
60
+ }
61
+ }
62
+ return activeElement;
63
+ }
64
+ /**
65
+ * Base class for the `CovalentSideSheetContainer`. The base class does not implement
66
+ * animations as these are left to implementers of the side-sheet container.
67
+ * @abstract
68
+ */
69
+ class _CovalentSideSheetContainerBase extends BasePortalOutlet {
70
+ /**
71
+ * @param {?} _elementRef
72
+ * @param {?} _focusTrapFactory
73
+ * @param {?} _changeDetectorRef
74
+ * @param {?} _document
75
+ * @param {?} _config
76
+ * @param {?=} _focusMonitor
77
+ */
78
+ constructor(_elementRef, _focusTrapFactory, _changeDetectorRef, _document, _config, _focusMonitor) {
79
+ super();
80
+ this._elementRef = _elementRef;
81
+ this._focusTrapFactory = _focusTrapFactory;
82
+ this._changeDetectorRef = _changeDetectorRef;
83
+ this._config = _config;
84
+ this._focusMonitor = _focusMonitor;
85
+ /**
86
+ * Emits when an animation state changes.
87
+ */
88
+ this._animationStateChanged = new EventEmitter();
89
+ /**
90
+ * Element that was focused before the side-sheet was opened. Save this to restore upon close.
91
+ */
92
+ this._elementFocusedBeforeSideSheetWasOpened = null;
93
+ /**
94
+ * Type of interaction that led to the side-sheet being closed. This is used to determine
95
+ * whether the focus style will be applied when returning focus to its original location
96
+ * after the side-sheet is closed.
97
+ */
98
+ this._closeInteractionType = null;
99
+ /**
100
+ * Attaches a DOM portal to the side-sheet container.
101
+ * @param portal Portal to be attached.
102
+ * @deprecated To be turned into a method.
103
+ */
104
+ this.attachDomPortal = (/**
105
+ * @param {?} portal
106
+ * @return {?}
107
+ */
108
+ (portal) => {
109
+ return this._portalOutlet.attachDomPortal(portal);
110
+ });
111
+ this._ariaLabelledBy = _config.ariaLabelledBy || null;
112
+ this._document = _document;
113
+ }
114
+ /**
115
+ * Initializes the side-sheet container with the attached content.
116
+ * @return {?}
117
+ */
118
+ _initializeWithAttachedContent() {
119
+ this._setupFocusTrap();
120
+ // Save the previously focused element. This element will be re-focused
121
+ // when the side-sheet closes.
122
+ this._capturePreviouslyFocusedElement();
123
+ }
124
+ /**
125
+ * Attach a ComponentPortal as content to this side-sheet container.
126
+ * @template T
127
+ * @param {?} portal Portal to be attached as the side-sheet content.
128
+ * @return {?}
129
+ */
130
+ attachComponentPortal(portal) {
131
+ return this._portalOutlet.attachComponentPortal(portal);
132
+ }
133
+ /**
134
+ * Attach a TemplatePortal as content to this side-sheet container.
135
+ * @template C
136
+ * @param {?} portal Portal to be attached as the side-sheet content.
137
+ * @return {?}
138
+ */
139
+ attachTemplatePortal(portal) {
140
+ return this._portalOutlet.attachTemplatePortal(portal);
141
+ }
142
+ /**
143
+ * Moves focus back into the side-sheet if it was moved out.
144
+ * @return {?}
145
+ */
146
+ _recaptureFocus() {
147
+ if (!this._containsFocus()) {
148
+ this._trapFocus();
149
+ }
150
+ }
151
+ /**
152
+ * Moves the focus inside the focus trap. When autoFocus is not set to 'side-sheet', if focus
153
+ * cannot be moved then focus will go to the side-sheet container.
154
+ * @protected
155
+ * @return {?}
156
+ */
157
+ _trapFocus() {
158
+ /** @type {?} */
159
+ const element = this._elementRef.nativeElement;
160
+ if (!this._config.autoFocus) {
161
+ if (!this._containsFocus()) {
162
+ element.focus();
163
+ }
164
+ }
165
+ else {
166
+ this._focusTrap.focusInitialElementWhenReady().then((/**
167
+ * @param {?} focusedSuccessfully
168
+ * @return {?}
169
+ */
170
+ (focusedSuccessfully) => {
171
+ // If we weren't able to find a focusable element in the side-sheet, then focus the side-sheet
172
+ // container instead.
173
+ if (!focusedSuccessfully) {
174
+ this._focusSideSheetContainer();
175
+ }
176
+ }));
177
+ }
178
+ }
179
+ /**
180
+ * Restores focus to the element that was focused before the side-sheet opened.
181
+ * @protected
182
+ * @return {?}
183
+ */
184
+ _restoreFocus() {
185
+ /** @type {?} */
186
+ const previousElement = this._elementFocusedBeforeSideSheetWasOpened;
187
+ // We need the extra check, because IE can set the `activeElement` to null in some cases.
188
+ if (this._config.restoreFocus && previousElement && typeof previousElement.focus === 'function') {
189
+ /** @type {?} */
190
+ const activeElement = _getFocusedElementPierceShadowDom();
191
+ /** @type {?} */
192
+ const element = this._elementRef.nativeElement;
193
+ // Make sure that focus is still inside the side-sheet or is on the body (usually because a
194
+ // non-focusable element like the backdrop was clicked) before moving it. It's possible that
195
+ // the consumer moved it themselves before the animation was done, in which case we shouldn't
196
+ // do anything.
197
+ if (!activeElement ||
198
+ activeElement === this._document.body ||
199
+ activeElement === element ||
200
+ element.contains(activeElement)) {
201
+ if (this._focusMonitor) {
202
+ this._focusMonitor.focusVia(previousElement, this._closeInteractionType);
203
+ this._closeInteractionType = null;
204
+ }
205
+ else {
206
+ previousElement.focus();
207
+ }
208
+ }
209
+ }
210
+ if (this._focusTrap) {
211
+ this._focusTrap.destroy();
212
+ }
213
+ }
214
+ /**
215
+ * Sets up the focus trap.
216
+ * @private
217
+ * @return {?}
218
+ */
219
+ _setupFocusTrap() {
220
+ this._focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement);
221
+ }
222
+ /**
223
+ * Captures the element that was focused before the side-sheet was opened.
224
+ * @private
225
+ * @return {?}
226
+ */
227
+ _capturePreviouslyFocusedElement() {
228
+ if (this._document) {
229
+ this._elementFocusedBeforeSideSheetWasOpened = _getFocusedElementPierceShadowDom();
230
+ }
231
+ }
232
+ /**
233
+ * Focuses the side-sheet container.
234
+ * @private
235
+ * @return {?}
236
+ */
237
+ _focusSideSheetContainer() {
238
+ // Note that there is no focus method when rendering on the server.
239
+ if (this._elementRef.nativeElement.focus) {
240
+ this._elementRef.nativeElement.focus();
241
+ }
242
+ }
243
+ /**
244
+ * Returns whether focus is inside the side-sheet.
245
+ * @private
246
+ * @return {?}
247
+ */
248
+ _containsFocus() {
249
+ /** @type {?} */
250
+ const element = this._elementRef.nativeElement;
251
+ /** @type {?} */
252
+ const activeElement = _getFocusedElementPierceShadowDom();
253
+ return element === activeElement || element.contains(activeElement);
254
+ }
255
+ }
256
+ _CovalentSideSheetContainerBase.decorators = [
257
+ { type: Directive }
258
+ ];
259
+ /** @nocollapse */
260
+ _CovalentSideSheetContainerBase.ctorParameters = () => [
261
+ { type: ElementRef },
262
+ { type: FocusTrapFactory },
263
+ { type: ChangeDetectorRef },
264
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] },
265
+ { type: CovalentSideSheetConfig },
266
+ { type: FocusMonitor }
267
+ ];
268
+ _CovalentSideSheetContainerBase.propDecorators = {
269
+ _portalOutlet: [{ type: ViewChild, args: [CdkPortalOutlet, { static: true },] }]
270
+ };
271
+ if (false) {
272
+ /**
273
+ * @type {?}
274
+ * @protected
275
+ */
276
+ _CovalentSideSheetContainerBase.prototype._document;
277
+ /**
278
+ * The portal outlet inside of this container into which the side-sheet content will be loaded.
279
+ * @type {?}
280
+ */
281
+ _CovalentSideSheetContainerBase.prototype._portalOutlet;
282
+ /**
283
+ * The class that traps and manages focus within the side-sheet.
284
+ * @type {?}
285
+ * @private
286
+ */
287
+ _CovalentSideSheetContainerBase.prototype._focusTrap;
288
+ /**
289
+ * Emits when an animation state changes.
290
+ * @type {?}
291
+ */
292
+ _CovalentSideSheetContainerBase.prototype._animationStateChanged;
293
+ /**
294
+ * Element that was focused before the side-sheet was opened. Save this to restore upon close.
295
+ * @type {?}
296
+ * @private
297
+ */
298
+ _CovalentSideSheetContainerBase.prototype._elementFocusedBeforeSideSheetWasOpened;
299
+ /**
300
+ * Type of interaction that led to the side-sheet being closed. This is used to determine
301
+ * whether the focus style will be applied when returning focus to its original location
302
+ * after the side-sheet is closed.
303
+ * @type {?}
304
+ */
305
+ _CovalentSideSheetContainerBase.prototype._closeInteractionType;
306
+ /**
307
+ * ID of the element that should be considered as the side-sheet's label.
308
+ * @type {?}
309
+ */
310
+ _CovalentSideSheetContainerBase.prototype._ariaLabelledBy;
311
+ /**
312
+ * ID for the container DOM element.
313
+ * @type {?}
314
+ */
315
+ _CovalentSideSheetContainerBase.prototype._id;
316
+ /**
317
+ * Attaches a DOM portal to the side-sheet container.
318
+ * \@param portal Portal to be attached.
319
+ * @deprecated To be turned into a method.
320
+ * @type {?}
321
+ */
322
+ _CovalentSideSheetContainerBase.prototype.attachDomPortal;
323
+ /**
324
+ * @type {?}
325
+ * @protected
326
+ */
327
+ _CovalentSideSheetContainerBase.prototype._elementRef;
328
+ /**
329
+ * @type {?}
330
+ * @protected
331
+ */
332
+ _CovalentSideSheetContainerBase.prototype._focusTrapFactory;
333
+ /**
334
+ * @type {?}
335
+ * @protected
336
+ */
337
+ _CovalentSideSheetContainerBase.prototype._changeDetectorRef;
338
+ /**
339
+ * The side-sheet configuration.
340
+ * @type {?}
341
+ */
342
+ _CovalentSideSheetContainerBase.prototype._config;
343
+ /**
344
+ * @type {?}
345
+ * @private
346
+ */
347
+ _CovalentSideSheetContainerBase.prototype._focusMonitor;
348
+ /**
349
+ * Starts the side-sheet exit animation.
350
+ * @abstract
351
+ * @return {?}
352
+ */
353
+ _CovalentSideSheetContainerBase.prototype._startExitAnimation = function () { };
354
+ }
355
+ /**
356
+ * Internal component that wraps the generated side-sheet content.
357
+ * This animation below is the only reason for duplicating most of the Material dialog code
358
+ */
359
+ class CovalentSideSheetContainer extends _CovalentSideSheetContainerBase {
360
+ constructor() {
361
+ super(...arguments);
362
+ /**
363
+ * State of the side-sheet animation.
364
+ */
365
+ this._state = 'enter';
366
+ }
367
+ /**
368
+ * Callback, invoked whenever an animation on the host completes.
369
+ * @param {?} __0
370
+ * @return {?}
371
+ */
372
+ _onAnimationDone({ toState, totalTime }) {
373
+ if (toState === 'enter') {
374
+ this._trapFocus();
375
+ this._animationStateChanged.next({ state: 'opened', totalTime });
376
+ }
377
+ else if (toState === 'exit') {
378
+ this._restoreFocus();
379
+ this._animationStateChanged.next({ state: 'closed', totalTime });
380
+ }
381
+ }
382
+ /**
383
+ * Starts the side-sheet exit animation.
384
+ * @return {?}
385
+ */
386
+ _startExitAnimation() {
387
+ this._state = 'exit';
388
+ this._changeDetectorRef.markForCheck();
389
+ }
390
+ }
391
+ CovalentSideSheetContainer.decorators = [
392
+ { type: Component, args: [{
393
+ selector: 'td-side-sheet-container',
394
+ template: `
395
+ <ng-template cdkPortalOutlet></ng-template>
396
+ `,
397
+ encapsulation: ViewEncapsulation.None,
398
+ changeDetection: ChangeDetectionStrategy.Default,
399
+ animations: [tdSideSheetAnimations.sideSheetContainer],
400
+ host: {
401
+ 'class': 'td-side-sheet-container',
402
+ 'tabindex': '-1',
403
+ 'aria-modal': 'true',
404
+ '[id]': '_id',
405
+ '[attr.role]': '_config.role',
406
+ '[attr.aria-labelledby]': '_config.ariaLabel ? null : _ariaLabelledBy',
407
+ '[attr.aria-label]': '_config.ariaLabel',
408
+ '[attr.aria-describedby]': '_config.ariaDescribedBy || null',
409
+ '[@sideSheetContainer]': '_state',
410
+ '(@sideSheetContainer.done)': '_onAnimationDone($event)',
411
+ },
412
+ styles: [".td-side-sheet-container{background-color:#fff;box-shadow:0 8px 10px -5px rgba(0,0,0,.2),0 16px 24px 2px rgba(0,0,0,.14),0 6px 30px 5px rgba(0,0,0,.12);box-sizing:border-box;display:block;height:100%;max-height:inherit;min-height:inherit;outline:0;overflow:auto;padding:24px;width:100%}.td-side-sheet-wrapper{-ms-flex-direction:column;display:-ms-flexbox;display:flex;flex-direction:column;height:100%}.td-side-sheet-content{-ms-flex:1;-webkit-overflow-scrolling:touch;flex:1;margin:0 -24px;overflow:auto;padding:0 24px}.td-side-sheet-title{margin:-16px 0 20px}.td-side-sheet-actions,.td-side-sheet-title{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex}.td-side-sheet-actions{-ms-flex-pack:justify;-ms-flex-wrap:wrap;box-sizing:content-box;flex-wrap:wrap;justify-content:space-between;margin:0 -16px -24px;padding:8px 0}.td-side-sheet-actions[align=end]{-ms-flex-pack:end;justify-content:flex-end}.td-side-sheet-actions[align=center]{-ms-flex-pack:center;justify-content:center}.td-side-sheet-actions .mat-button-base+.mat-button-base,.td-side-sheet-actions .mat-mdc-button-base+.mat-mdc-button-base{margin-left:8px}[dir=rtl] .td-side-sheet-actions .mat-button-base+.mat-button-base,[dir=rtl] .td-side-sheet-actions .mat-mdc-button-base+.mat-mdc-button-base{margin-left:0;margin-right:8px}"]
413
+ }] }
414
+ ];
415
+ if (false) {
416
+ /**
417
+ * State of the side-sheet animation.
418
+ * @type {?}
419
+ */
420
+ CovalentSideSheetContainer.prototype._state;
421
+ }
422
+
423
+ /**
424
+ * @fileoverview added by tsickle
425
+ * Generated from: side-sheet-ref.ts
426
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
427
+ */
428
+ // Counter for unique dialog ids.
429
+ /** @type {?} */
430
+ let uniqueId = 0;
431
+ // Create a new side sheet ref to change the id of the ref
432
+ /**
433
+ * @template T, R
434
+ */
435
+ class CovalentSideSheetRef extends MatDialogRef {
436
+ /**
437
+ * @param {?} overlayRef
438
+ * @param {?} _containerInstance
439
+ * @param {?=} id
440
+ */
441
+ constructor(overlayRef, _containerInstance, id = `td-side-sheet-${uniqueId++}`) {
442
+ super(overlayRef, _containerInstance, id);
443
+ this._containerInstance = _containerInstance;
444
+ this.id = id;
445
+ }
446
+ }
447
+ if (false) {
448
+ /** @type {?} */
449
+ CovalentSideSheetRef.prototype._containerInstance;
450
+ /** @type {?} */
451
+ CovalentSideSheetRef.prototype.id;
452
+ }
453
+ /**
454
+ * @template R
455
+ * @param {?} ref
456
+ * @param {?} interactionType
457
+ * @param {?=} result
458
+ * @return {?}
459
+ */
460
+ function _closeSideSheetVia(ref, interactionType, result) {
461
+ // Some mock dialog ref instances in tests do not have the `_containerInstance` property.
462
+ // For those, we keep the behavior as is and do not deal with the interaction type.
463
+ if (ref._containerInstance !== undefined) {
464
+ ref._containerInstance._closeInteractionType = interactionType;
465
+ }
466
+ return ref.close(result);
467
+ }
468
+
469
+ /**
470
+ * @fileoverview added by tsickle
471
+ * Generated from: side-sheet.ts
472
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
473
+ */
474
+ /**
475
+ * @template C
476
+ */
477
+ class _CovalentSideSheetBase {
478
+ /**
479
+ * @param {?} _overlay
480
+ * @param {?} _injector
481
+ * @param {?} _defaultOptions
482
+ * @param {?} _parentSideSheet
483
+ * @param {?} _sideSheetRefConstructor
484
+ * @param {?} _sideSheetContainerType
485
+ * @param {?} _sideSheetDataToken
486
+ */
487
+ constructor(_overlay, _injector, _defaultOptions, _parentSideSheet, _sideSheetRefConstructor, _sideSheetContainerType, _sideSheetDataToken) {
488
+ this._overlay = _overlay;
489
+ this._injector = _injector;
490
+ this._defaultOptions = _defaultOptions;
491
+ this._parentSideSheet = _parentSideSheet;
492
+ this._sideSheetRefConstructor = _sideSheetRefConstructor;
493
+ this._sideSheetContainerType = _sideSheetContainerType;
494
+ this._sideSheetDataToken = _sideSheetDataToken;
495
+ this._openSideSheetsAtThisLevel = [];
496
+ this._afterAllClosedAtThisLevel = new Subject();
497
+ this._afterOpenedAtThisLevel = new Subject();
498
+ this.defaultSidebarConfig = {
499
+ minWidth: '400px',
500
+ };
501
+ }
502
+ /**
503
+ * Keeps track of the currently-open side-sheets.
504
+ * @return {?}
505
+ */
506
+ get openSideSheets() {
507
+ return this._parentSideSheet ? this._parentSideSheet.openSideSheets : this._openSideSheetsAtThisLevel;
508
+ }
509
+ /**
510
+ * @template T, D, R
511
+ * @param {?} componentOrTemplateRef
512
+ * @param {?=} config
513
+ * @return {?}
514
+ */
515
+ open(componentOrTemplateRef, config) {
516
+ config = Object.assign(Object.assign(Object.assign({}, this.defaultSidebarConfig), config), (this._defaultOptions || new CovalentSideSheetConfig()));
517
+ /** @type {?} */
518
+ const overlayRef = this._createOverlay(config);
519
+ /** @type {?} */
520
+ const sideSheetContainer = this._attachSideSheetContainer(overlayRef, config);
521
+ /** @type {?} */
522
+ const sideSheetRef = this._attachSideSheetContent(componentOrTemplateRef, sideSheetContainer, overlayRef, config);
523
+ this.openSideSheets.push(sideSheetRef);
524
+ // Notify the side-sheet container that the content has been attached.
525
+ sideSheetContainer._initializeWithAttachedContent();
526
+ return sideSheetRef;
527
+ }
528
+ /**
529
+ * @return {?}
530
+ */
531
+ ngOnDestroy() {
532
+ // Only close the side-sheets at this level on destroy
533
+ // since the parent service may still be active.
534
+ this._closeSideSheets(this._openSideSheetsAtThisLevel);
535
+ this._afterAllClosedAtThisLevel.complete();
536
+ this._afterOpenedAtThisLevel.complete();
537
+ // Clean up any subscriptions to side-sheet that never finished opening.
538
+ if (this._animationStateSubscriptions) {
539
+ this._animationStateSubscriptions.unsubscribe();
540
+ }
541
+ }
542
+ /**
543
+ * Closes all of the currently-open side-sheets.
544
+ * @return {?}
545
+ */
546
+ closeAll() {
547
+ this._closeSideSheets(this.openSideSheets);
548
+ }
549
+ /**
550
+ * @private
551
+ * @template T
552
+ * @param {?} config
553
+ * @return {?}
554
+ */
555
+ _createOverlay(config) {
556
+ /** @type {?} */
557
+ const overlayConfig = new OverlayConfig({
558
+ positionStrategy: this._overlay.position().global(),
559
+ scrollStrategy: this._overlay.scrollStrategies.block(),
560
+ panelClass: config.panelClass,
561
+ hasBackdrop: config.hasBackdrop,
562
+ direction: config.direction,
563
+ minWidth: config.minWidth,
564
+ minHeight: config.minHeight,
565
+ maxWidth: config.maxWidth,
566
+ });
567
+ /** @type {?} */
568
+ const overlayRef = this._overlay.create(overlayConfig);
569
+ /** @type {?} */
570
+ const positionStrategy = (/** @type {?} */ (overlayRef.getConfig().positionStrategy));
571
+ positionStrategy.right('0px');
572
+ return overlayRef;
573
+ }
574
+ /**
575
+ * Attaches a container to a side-sheets's already-created overlay.
576
+ * @private
577
+ * @param {?} overlay Reference to the side-sheet's underlying overlay.
578
+ * @param {?} config The side-sheet configuration.
579
+ * @return {?} A promise resolving to a ComponentRef for the attached container.
580
+ */
581
+ _attachSideSheetContainer(overlay, config) {
582
+ /** @type {?} */
583
+ const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
584
+ /** @type {?} */
585
+ const injector = Injector.create({
586
+ parent: userInjector || this._injector,
587
+ providers: [{ provide: CovalentSideSheetConfig, useValue: config }],
588
+ });
589
+ /** @type {?} */
590
+ const containerPortal = new ComponentPortal(this._sideSheetContainerType, config.viewContainerRef, injector, config.componentFactoryResolver);
591
+ /** @type {?} */
592
+ const containerRef = overlay.attach(containerPortal);
593
+ return containerRef.instance;
594
+ }
595
+ /**
596
+ * Attaches the user-provided component to the already-created side sheet container.
597
+ * @private
598
+ * @template T, R
599
+ * @param {?} componentOrTemplateRef The type of component being loaded into the side-sheet,
600
+ * or a TemplateRef to instantiate as the content.
601
+ * @param {?} sideSheetContainer
602
+ * @param {?} overlayRef Reference to the overlay in which the side-sheet resides.
603
+ * @param {?} config The side-sheet configuration.
604
+ * @return {?} A promise resolving to the CovalentSideSheetRef that should be returned to the user.
605
+ */
606
+ _attachSideSheetContent(componentOrTemplateRef, sideSheetContainer, overlayRef, config) {
607
+ // Create a reference to the side-sheet we're creating in order to give the user a handle
608
+ // to modify and close it.
609
+ /** @type {?} */
610
+ const sideSheetRef = new this._sideSheetRefConstructor(overlayRef, sideSheetContainer, config.id);
611
+ if (componentOrTemplateRef instanceof TemplateRef) {
612
+ sideSheetContainer.attachTemplatePortal(new TemplatePortal(componentOrTemplateRef, (/** @type {?} */ (null)), (/** @type {?} */ ({
613
+ $implicit: config.data,
614
+ sideSheetRef,
615
+ }))));
616
+ }
617
+ else {
618
+ /** @type {?} */
619
+ const injector = this._createInjector(config, sideSheetRef, sideSheetContainer);
620
+ /** @type {?} */
621
+ const contentRef = sideSheetContainer.attach(new ComponentPortal(componentOrTemplateRef, config.viewContainerRef, injector));
622
+ sideSheetRef.componentInstance = contentRef.instance;
623
+ }
624
+ sideSheetRef.updateSize(config.width, config.height);
625
+ return sideSheetRef;
626
+ }
627
+ /**
628
+ * @private
629
+ * @template T
630
+ * @param {?} config
631
+ * @param {?} sideSheetRef
632
+ * @param {?} sideSheetContainer
633
+ * @return {?}
634
+ */
635
+ _createInjector(config, sideSheetRef, sideSheetContainer) {
636
+ /** @type {?} */
637
+ const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
638
+ // The side-sheet container should be provided as the side-sheet container and the side-sheet's
639
+ // content are created out of the same `ViewContainerRef` and as such, are siblings
640
+ // for injector purposes. To allow the hierarchy that is expected, the side-sheet
641
+ // container is explicitly provided in the injector.
642
+ /** @type {?} */
643
+ const providers = [
644
+ { provide: this._sideSheetContainerType, useValue: sideSheetContainer },
645
+ { provide: this._sideSheetDataToken, useValue: config.data },
646
+ { provide: this._sideSheetRefConstructor, useValue: sideSheetRef },
647
+ ];
648
+ if (config.direction &&
649
+ (!userInjector || !userInjector.get(Directionality, null, InjectFlags.Optional))) {
650
+ providers.push({
651
+ provide: Directionality,
652
+ useValue: { value: config.direction, change: of() },
653
+ });
654
+ }
655
+ return Injector.create({ parent: userInjector || this._injector, providers });
656
+ }
657
+ /**
658
+ * Closes all of the side-sheet in an array.
659
+ * @private
660
+ * @param {?} sideSheets
661
+ * @return {?}
662
+ */
663
+ _closeSideSheets(sideSheets) {
664
+ /** @type {?} */
665
+ let i = sideSheets.length;
666
+ while (i--) {
667
+ sideSheets[i].close();
668
+ }
669
+ }
670
+ }
671
+ _CovalentSideSheetBase.decorators = [
672
+ { type: Directive }
673
+ ];
674
+ /** @nocollapse */
675
+ _CovalentSideSheetBase.ctorParameters = () => [
676
+ { type: Overlay },
677
+ { type: Injector },
678
+ { type: undefined },
679
+ { type: undefined },
680
+ { type: Type },
681
+ { type: Type },
682
+ { type: InjectionToken }
683
+ ];
684
+ if (false) {
685
+ /**
686
+ * @type {?}
687
+ * @private
688
+ */
689
+ _CovalentSideSheetBase.prototype._openSideSheetsAtThisLevel;
690
+ /**
691
+ * @type {?}
692
+ * @private
693
+ */
694
+ _CovalentSideSheetBase.prototype._afterAllClosedAtThisLevel;
695
+ /**
696
+ * @type {?}
697
+ * @private
698
+ */
699
+ _CovalentSideSheetBase.prototype._afterOpenedAtThisLevel;
700
+ /**
701
+ * @type {?}
702
+ * @private
703
+ */
704
+ _CovalentSideSheetBase.prototype._animationStateSubscriptions;
705
+ /**
706
+ * @type {?}
707
+ * @private
708
+ */
709
+ _CovalentSideSheetBase.prototype.defaultSidebarConfig;
710
+ /**
711
+ * @type {?}
712
+ * @private
713
+ */
714
+ _CovalentSideSheetBase.prototype._overlay;
715
+ /**
716
+ * @type {?}
717
+ * @private
718
+ */
719
+ _CovalentSideSheetBase.prototype._injector;
720
+ /**
721
+ * @type {?}
722
+ * @private
723
+ */
724
+ _CovalentSideSheetBase.prototype._defaultOptions;
725
+ /**
726
+ * @type {?}
727
+ * @private
728
+ */
729
+ _CovalentSideSheetBase.prototype._parentSideSheet;
730
+ /**
731
+ * @type {?}
732
+ * @private
733
+ */
734
+ _CovalentSideSheetBase.prototype._sideSheetRefConstructor;
735
+ /**
736
+ * @type {?}
737
+ * @private
738
+ */
739
+ _CovalentSideSheetBase.prototype._sideSheetContainerType;
740
+ /**
741
+ * @type {?}
742
+ * @private
743
+ */
744
+ _CovalentSideSheetBase.prototype._sideSheetDataToken;
745
+ }
746
+ /**
747
+ * Service to open Covalent Design side-sheet.
748
+ */
749
+ class CovalentSideSheet extends _CovalentSideSheetBase {
750
+ /**
751
+ * @param {?} overlay
752
+ * @param {?} injector
753
+ * @param {?} defaultOptions
754
+ * @param {?} parentSideSheet
755
+ */
756
+ constructor(overlay, injector, defaultOptions, parentSideSheet) {
757
+ super(overlay, injector, defaultOptions, parentSideSheet, CovalentSideSheetRef, CovalentSideSheetContainer, MAT_DIALOG_DATA);
758
+ }
759
+ }
760
+ CovalentSideSheet.decorators = [
761
+ { type: Injectable }
762
+ ];
763
+ /** @nocollapse */
764
+ CovalentSideSheet.ctorParameters = () => [
765
+ { type: Overlay },
766
+ { type: Injector },
767
+ { type: CovalentSideSheetConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] },
768
+ { type: CovalentSideSheet, decorators: [{ type: Optional }, { type: SkipSelf }] }
769
+ ];
770
+
771
+ /**
772
+ * @fileoverview added by tsickle
773
+ * Generated from: side-sheet.content-directives.ts
774
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
775
+ */
776
+ /**
777
+ * Counter used to generate unique IDs for dialog elements.
778
+ * @type {?}
779
+ */
780
+ let dialogElementUid = 0;
781
+ /**
782
+ * Button that will close the current dialog.
783
+ */
784
+ class CovalentSideSheetClose {
785
+ /**
786
+ * @param {?} dialogRef
787
+ * @param {?} _elementRef
788
+ * @param {?} _dialog
789
+ */
790
+ constructor(dialogRef, _elementRef, _dialog) {
791
+ this.dialogRef = dialogRef;
792
+ this._elementRef = _elementRef;
793
+ this._dialog = _dialog;
794
+ /**
795
+ * Default to "button" to prevents accidental form submits.
796
+ */
797
+ this.type = 'button';
798
+ }
799
+ /**
800
+ * @return {?}
801
+ */
802
+ ngOnInit() {
803
+ if (!this.dialogRef) {
804
+ // When this directive is included in a dialog via TemplateRef (rather than being
805
+ // in a Component), the DialogRef isn't available via injection because embedded
806
+ // views cannot be given a custom injector. Instead, we look up the DialogRef by
807
+ // ID. This must occur in `onInit`, as the ID binding for the dialog container won't
808
+ // be resolved at constructor time.
809
+ this.dialogRef = (/** @type {?} */ (getClosestDialog(this._elementRef, this._dialog.openSideSheets)));
810
+ }
811
+ }
812
+ /**
813
+ * @param {?} changes
814
+ * @return {?}
815
+ */
816
+ ngOnChanges(changes) {
817
+ /** @type {?} */
818
+ const proxiedChange = changes['_CovalentSideSheetClose'] || changes['_CovalentSideSheetCloseResult'];
819
+ if (proxiedChange) {
820
+ this.dialogResult = proxiedChange.currentValue;
821
+ }
822
+ }
823
+ /**
824
+ * @param {?} event
825
+ * @return {?}
826
+ */
827
+ _onButtonClick(event) {
828
+ // Determinate the focus origin using the click event, because using the FocusMonitor will
829
+ // result in incorrect origins. Most of the time, close buttons will be auto focused in the
830
+ // dialog, and therefore clicking the button won't result in a focus change. This means that
831
+ // the FocusMonitor won't detect any origin change, and will always output `program`.
832
+ _closeSideSheetVia(this.dialogRef, event.screenX === 0 && event.screenY === 0 ? 'keyboard' : 'mouse', this.dialogResult);
833
+ }
834
+ }
835
+ CovalentSideSheetClose.decorators = [
836
+ { type: Directive, args: [{
837
+ selector: '[td-side-sheet-close], [CovalentSideSheetClose]',
838
+ exportAs: 'CovalentSideSheetClose',
839
+ host: {
840
+ '(click)': '_onButtonClick($event)',
841
+ '[attr.aria-label]': 'ariaLabel || null',
842
+ '[attr.type]': 'type',
843
+ },
844
+ },] }
845
+ ];
846
+ /** @nocollapse */
847
+ CovalentSideSheetClose.ctorParameters = () => [
848
+ { type: CovalentSideSheetRef, decorators: [{ type: Optional }] },
849
+ { type: ElementRef },
850
+ { type: CovalentSideSheet }
851
+ ];
852
+ CovalentSideSheetClose.propDecorators = {
853
+ ariaLabel: [{ type: Input, args: ['aria-label',] }],
854
+ type: [{ type: Input }],
855
+ dialogResult: [{ type: Input, args: ['td-side-sheet-close',] }],
856
+ _CovalentSideSheetClose: [{ type: Input, args: ['CovalentSideSheetClose',] }]
857
+ };
858
+ if (false) {
859
+ /**
860
+ * Screenreader label for the button.
861
+ * @type {?}
862
+ */
863
+ CovalentSideSheetClose.prototype.ariaLabel;
864
+ /**
865
+ * Default to "button" to prevents accidental form submits.
866
+ * @type {?}
867
+ */
868
+ CovalentSideSheetClose.prototype.type;
869
+ /**
870
+ * Dialog close input.
871
+ * @type {?}
872
+ */
873
+ CovalentSideSheetClose.prototype.dialogResult;
874
+ /** @type {?} */
875
+ CovalentSideSheetClose.prototype._CovalentSideSheetClose;
876
+ /** @type {?} */
877
+ CovalentSideSheetClose.prototype.dialogRef;
878
+ /**
879
+ * @type {?}
880
+ * @private
881
+ */
882
+ CovalentSideSheetClose.prototype._elementRef;
883
+ /**
884
+ * @type {?}
885
+ * @private
886
+ */
887
+ CovalentSideSheetClose.prototype._dialog;
888
+ }
889
+ /**
890
+ * Title of a side sheet element. Stays fixed to the top of the side sheet when scrolling.
891
+ */
892
+ class CovalentSideSheetTitle {
893
+ /**
894
+ * @param {?} _dialogRef
895
+ * @param {?} _elementRef
896
+ * @param {?} _dialog
897
+ */
898
+ constructor(_dialogRef, _elementRef, _dialog) {
899
+ this._dialogRef = _dialogRef;
900
+ this._elementRef = _elementRef;
901
+ this._dialog = _dialog;
902
+ /**
903
+ * Unique id for the dialog title. If none is supplied, it will be auto-generated.
904
+ */
905
+ this.id = `td-side-sheet-title-${dialogElementUid++}`;
906
+ }
907
+ /**
908
+ * @return {?}
909
+ */
910
+ ngOnInit() {
911
+ if (this._dialogRef) {
912
+ Promise.resolve().then((/**
913
+ * @return {?}
914
+ */
915
+ () => {
916
+ /** @type {?} */
917
+ const container = this._dialogRef._containerInstance;
918
+ if (container && !container._ariaLabelledBy) {
919
+ container._ariaLabelledBy = this.id;
920
+ }
921
+ }));
922
+ }
923
+ else {
924
+ this._dialogRef = (/** @type {?} */ (getClosestDialog(this._elementRef, this._dialog.openSideSheets)));
925
+ }
926
+ }
927
+ }
928
+ CovalentSideSheetTitle.decorators = [
929
+ { type: Directive, args: [{
930
+ selector: '[td-side-sheet-title], [CovalentSideSheetTitle]',
931
+ exportAs: 'CovalentSideSheetTitle',
932
+ host: {
933
+ 'class': 'td-side-sheet-title',
934
+ '[id]': 'id',
935
+ },
936
+ },] }
937
+ ];
938
+ /** @nocollapse */
939
+ CovalentSideSheetTitle.ctorParameters = () => [
940
+ { type: CovalentSideSheetRef, decorators: [{ type: Optional }] },
941
+ { type: ElementRef },
942
+ { type: CovalentSideSheet }
943
+ ];
944
+ CovalentSideSheetTitle.propDecorators = {
945
+ id: [{ type: Input }]
946
+ };
947
+ if (false) {
948
+ /**
949
+ * Unique id for the dialog title. If none is supplied, it will be auto-generated.
950
+ * @type {?}
951
+ */
952
+ CovalentSideSheetTitle.prototype.id;
953
+ /**
954
+ * @type {?}
955
+ * @private
956
+ */
957
+ CovalentSideSheetTitle.prototype._dialogRef;
958
+ /**
959
+ * @type {?}
960
+ * @private
961
+ */
962
+ CovalentSideSheetTitle.prototype._elementRef;
963
+ /**
964
+ * @type {?}
965
+ * @private
966
+ */
967
+ CovalentSideSheetTitle.prototype._dialog;
968
+ }
969
+ /**
970
+ * Scrollable content container of a dialog.
971
+ */
972
+ class CovalentSideSheetContent {
973
+ }
974
+ CovalentSideSheetContent.decorators = [
975
+ { type: Directive, args: [{
976
+ selector: `[td-side-sheet-content], td-side-sheet-content, [CovalentSideSheetContent]`,
977
+ host: { class: 'td-side-sheet-content' },
978
+ },] }
979
+ ];
980
+ /**
981
+ * Container for the bottom action buttons in a dialog.
982
+ * Stays fixed to the bottom when scrolling.
983
+ */
984
+ class CovalentSideSheetActions {
985
+ }
986
+ CovalentSideSheetActions.decorators = [
987
+ { type: Directive, args: [{
988
+ selector: `[td-side-sheet-actions], td-side-sheet-actions, [CovalentSideSheetActions]`,
989
+ host: { class: 'td-side-sheet-actions' },
990
+ },] }
991
+ ];
992
+ /**
993
+ * Container for the wrapper part of the dialog
994
+ */
995
+ class CovalentSideSheetWrapper {
996
+ }
997
+ CovalentSideSheetWrapper.decorators = [
998
+ { type: Directive, args: [{
999
+ selector: `[td-side-sheet-wrapper], td-side-sheet-wrapper, [CovalentSideSheetWrapper]`,
1000
+ host: { class: 'td-side-sheet-wrapper' },
1001
+ },] }
1002
+ ];
1003
+ /**
1004
+ * Finds the closest CovalentSideSheetRef to an element by looking at the DOM.
1005
+ * @param {?} element Element relative to which to look for a dialog.
1006
+ * @param {?} openDialogs References to the currently-open dialogs.
1007
+ * @return {?}
1008
+ */
1009
+ function getClosestDialog(element, openDialogs) {
1010
+ /** @type {?} */
1011
+ let parent = element.nativeElement.parentElement;
1012
+ while (parent && !parent.classList.contains('td-side-sheet-container')) {
1013
+ parent = parent.parentElement;
1014
+ }
1015
+ return parent ? openDialogs.find((/**
1016
+ * @param {?} dialog
1017
+ * @return {?}
1018
+ */
1019
+ (dialog) => dialog.id === (/** @type {?} */ (parent)).id)) : null;
1020
+ }
1021
+
1022
+ /**
1023
+ * @fileoverview added by tsickle
1024
+ * Generated from: side-sheet.module.ts
1025
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1026
+ */
1027
+ class CovalentSideSheetModule {
1028
+ }
1029
+ CovalentSideSheetModule.decorators = [
1030
+ { type: NgModule, args: [{
1031
+ declarations: [
1032
+ CovalentSideSheetContainer,
1033
+ CovalentSideSheetActions,
1034
+ CovalentSideSheetClose,
1035
+ CovalentSideSheetContent,
1036
+ CovalentSideSheetTitle,
1037
+ CovalentSideSheetWrapper,
1038
+ ],
1039
+ exports: [
1040
+ CovalentSideSheetActions,
1041
+ CovalentSideSheetClose,
1042
+ CovalentSideSheetContent,
1043
+ CovalentSideSheetTitle,
1044
+ CovalentSideSheetWrapper,
1045
+ ],
1046
+ imports: [PortalModule, MatDialogModule, MatCommonModule],
1047
+ providers: [CovalentSideSheet],
1048
+ },] }
1049
+ ];
1050
+
1051
+ /**
1052
+ * @fileoverview added by tsickle
1053
+ * Generated from: public-api.ts
1054
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1055
+ */
1056
+
1057
+ /**
1058
+ * @fileoverview added by tsickle
1059
+ * Generated from: index.ts
1060
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1061
+ */
1062
+
1063
+ /**
1064
+ * @fileoverview added by tsickle
1065
+ * Generated from: covalent-core-side-sheet.ts
1066
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1067
+ */
1068
+
1069
+ export { CovalentSideSheet, CovalentSideSheetActions, CovalentSideSheetClose, CovalentSideSheetConfig, CovalentSideSheetContent, CovalentSideSheetModule, CovalentSideSheetRef, CovalentSideSheetTitle, CovalentSideSheetWrapper, _CovalentSideSheetBase, _closeSideSheetVia, _CovalentSideSheetContainerBase as ɵa, CovalentSideSheetContainer as ɵb, tdSideSheetAnimations as ɵc };
1070
+ //# sourceMappingURL=covalent-core-side-sheet.js.map