@coreui/angular 4.3.9 → 4.3.10

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.
@@ -5152,6 +5152,12 @@ class BackdropService {
5152
5152
  this.backdropClick$ = this.backdropClick.asObservable();
5153
5153
  this.renderer = rendererFactory.createRenderer(null, null);
5154
5154
  }
5155
+ get scrollbarWidth() {
5156
+ // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
5157
+ const documentWidth = this.document.documentElement.clientWidth;
5158
+ const scrollbarWidth = Math.abs((window?.innerWidth ?? documentWidth) - documentWidth);
5159
+ return `${scrollbarWidth}px`;
5160
+ }
5155
5161
  setBackdrop(type = 'modal') {
5156
5162
  const backdropElement = this.renderer.createElement('div');
5157
5163
  this.renderer.addClass(backdropElement, `${type}-backdrop`);
@@ -5187,7 +5193,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.2", ngImpor
5187
5193
  args: [{
5188
5194
  providedIn: 'root'
5189
5195
  }]
5190
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
5196
+ }], ctorParameters: function () { return [{ type: Document, decorators: [{
5191
5197
  type: Inject,
5192
5198
  args: [DOCUMENT]
5193
5199
  }] }, { type: i0.RendererFactory2 }]; } });
@@ -5291,14 +5297,8 @@ class ModalComponent {
5291
5297
  set show(value) {
5292
5298
  this._show = value;
5293
5299
  }
5294
- get scrollbarWidth() {
5295
- // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
5296
- const documentWidth = this.document.documentElement.clientWidth;
5297
- const scrollbarWidth = Math.abs((window?.innerWidth ?? documentWidth) - documentWidth);
5298
- return `${scrollbarWidth}px`;
5299
- }
5300
5300
  animateStart(event) {
5301
- const scrollbarWidth = this.scrollbarWidth;
5301
+ const scrollbarWidth = this.backdropService.scrollbarWidth;
5302
5302
  if (event.toState === 'visible') {
5303
5303
  this.renderer.setStyle(this.document.body, 'overflow', 'hidden');
5304
5304
  this.renderer.setStyle(this.document.body, 'padding-right', scrollbarWidth);
@@ -5566,18 +5566,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.2", ngImpor
5566
5566
  }]
5567
5567
  }], ctorParameters: function () { return []; } });
5568
5568
 
5569
+ var _OffcanvasComponent_scroll, _OffcanvasComponent_visible, _OffcanvasComponent_activeBackdrop, _OffcanvasComponent_scrollbarWidth, _OffcanvasComponent_stateToggleSubscription, _OffcanvasComponent_backdropClickSubscription, _OffcanvasComponent_layoutChangeSubscription, _OffcanvasComponent_show;
5569
5570
  let nextId = 0;
5570
5571
  class OffcanvasComponent {
5571
- constructor(document, platformId, renderer, hostElement, offcanvasService, backdropService) {
5572
+ constructor(document, platformId, renderer, hostElement, offcanvasService, backdropService, breakpointObserver) {
5572
5573
  this.document = document;
5573
5574
  this.platformId = platformId;
5574
5575
  this.renderer = renderer;
5575
5576
  this.hostElement = hostElement;
5576
5577
  this.offcanvasService = offcanvasService;
5577
5578
  this.backdropService = backdropService;
5579
+ this.breakpointObserver = breakpointObserver;
5578
5580
  /**
5579
5581
  * Apply a backdrop on body while offcanvas is open.
5580
- * @type boolean
5582
+ * @type boolean | 'static'
5581
5583
  * @default true
5582
5584
  */
5583
5585
  this.backdrop = true;
@@ -5593,7 +5595,14 @@ class OffcanvasComponent {
5593
5595
  * @default 'start'
5594
5596
  */
5595
5597
  this.placement = 'start';
5596
- this._scroll = false;
5598
+ /**
5599
+ * Responsive offcanvas property hides content outside the viewport from a specified breakpoint and down.
5600
+ * @type boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
5601
+ * @default true
5602
+ * @since 4.3.10
5603
+ */
5604
+ this.responsive = true;
5605
+ _OffcanvasComponent_scroll.set(this, false);
5597
5606
  this.id = `offcanvas-${this.placement}-${nextId++}`;
5598
5607
  /**
5599
5608
  * Default role for offcanvas. [docs]
@@ -5607,166 +5616,220 @@ class OffcanvasComponent {
5607
5616
  * @default true
5608
5617
  */
5609
5618
  this.ariaModal = true;
5619
+ _OffcanvasComponent_visible.set(this, false);
5610
5620
  /**
5611
5621
  * Event triggered on visible change.
5612
5622
  */
5613
5623
  this.visibleChange = new EventEmitter();
5624
+ _OffcanvasComponent_activeBackdrop.set(this, void 0);
5625
+ _OffcanvasComponent_scrollbarWidth.set(this, void 0);
5626
+ _OffcanvasComponent_stateToggleSubscription.set(this, void 0);
5627
+ _OffcanvasComponent_backdropClickSubscription.set(this, void 0);
5628
+ _OffcanvasComponent_layoutChangeSubscription.set(this, void 0);
5629
+ _OffcanvasComponent_show.set(this, false);
5614
5630
  }
5615
5631
  /**
5616
5632
  * Allow body scrolling while offcanvas is visible.
5617
5633
  * @type boolean
5634
+ * @default false
5618
5635
  */
5619
5636
  set scroll(value) {
5620
- this._scroll = coerceBooleanProperty(value);
5637
+ __classPrivateFieldSet(this, _OffcanvasComponent_scroll, coerceBooleanProperty(value), "f");
5621
5638
  }
5622
- ;
5623
5639
  get scroll() {
5624
- return this._scroll;
5640
+ return __classPrivateFieldGet(this, _OffcanvasComponent_scroll, "f");
5625
5641
  }
5626
5642
  /**
5627
5643
  * Toggle the visibility of offcanvas component.
5628
5644
  * @type boolean
5645
+ * @default false
5629
5646
  */
5630
5647
  set visible(value) {
5631
- this._visible = coerceBooleanProperty(value);
5632
- if (value) {
5648
+ __classPrivateFieldSet(this, _OffcanvasComponent_visible, coerceBooleanProperty(value), "f");
5649
+ if (__classPrivateFieldGet(this, _OffcanvasComponent_visible, "f")) {
5633
5650
  this.setBackdrop(this.backdrop);
5634
5651
  this.setFocus();
5635
5652
  }
5636
5653
  else {
5637
5654
  this.setBackdrop(false);
5638
5655
  }
5639
- this.setScroll();
5656
+ this.layoutChangeSubscribe(__classPrivateFieldGet(this, _OffcanvasComponent_visible, "f"));
5640
5657
  this.visibleChange.emit(value);
5641
5658
  }
5642
5659
  get visible() {
5643
- return this._visible;
5660
+ return __classPrivateFieldGet(this, _OffcanvasComponent_visible, "f");
5644
5661
  }
5645
5662
  get hostClasses() {
5646
5663
  return {
5647
- offcanvas: true,
5664
+ offcanvas: typeof this.responsive === 'boolean',
5665
+ [`offcanvas-${this.responsive}`]: typeof this.responsive !== 'boolean',
5648
5666
  [`offcanvas-${this.placement}`]: !!this.placement,
5649
- show: this.visible,
5667
+ show: this.show
5650
5668
  };
5651
5669
  }
5652
5670
  get ariaHidden() {
5653
5671
  return this.visible ? null : true;
5654
5672
  }
5655
- ;
5656
5673
  get tabIndex() {
5657
5674
  return '-1';
5658
5675
  }
5659
- get animateType() {
5660
- return this.visible;
5676
+ get animateTrigger() {
5677
+ return this.visible ? 'visible' : 'hidden';
5678
+ }
5679
+ get show() {
5680
+ return this.visible && __classPrivateFieldGet(this, _OffcanvasComponent_show, "f");
5681
+ }
5682
+ set show(value) {
5683
+ __classPrivateFieldSet(this, _OffcanvasComponent_show, value, "f");
5684
+ }
5685
+ animateStart(event) {
5686
+ const scrollbarWidth = __classPrivateFieldGet(this, _OffcanvasComponent_scrollbarWidth, "f");
5687
+ if (event.toState === 'visible') {
5688
+ if (!this.scroll) {
5689
+ this.renderer.setStyle(this.document.body, 'overflow', 'hidden');
5690
+ this.renderer.setStyle(this.document.body, 'padding-right', scrollbarWidth);
5691
+ }
5692
+ this.renderer.addClass(this.hostElement.nativeElement, 'showing');
5693
+ }
5694
+ else {
5695
+ this.renderer.addClass(this.hostElement.nativeElement, 'hiding');
5696
+ }
5697
+ }
5698
+ animateDone(event) {
5699
+ setTimeout(() => {
5700
+ if (event.toState === 'visible') {
5701
+ this.renderer.removeClass(this.hostElement.nativeElement, 'showing');
5702
+ }
5703
+ if (event.toState === 'hidden') {
5704
+ this.renderer.removeClass(this.hostElement.nativeElement, 'hiding');
5705
+ this.renderer.removeStyle(this.document.body, 'overflow');
5706
+ this.renderer.removeStyle(this.document.body, 'paddingRight');
5707
+ }
5708
+ });
5709
+ this.show = this.visible;
5661
5710
  }
5662
5711
  onKeyDownHandler(event) {
5663
- if (event.key === 'Escape' && this.keyboard && this.visible) {
5712
+ if (event.key === 'Escape' &&
5713
+ this.keyboard &&
5714
+ this.visible &&
5715
+ this.backdrop !== 'static') {
5664
5716
  this.offcanvasService.toggle({ show: false, id: this.id });
5665
5717
  }
5666
5718
  }
5667
5719
  ngOnInit() {
5668
- this.setScroll();
5720
+ __classPrivateFieldSet(this, _OffcanvasComponent_scrollbarWidth, this.backdropService.scrollbarWidth, "f");
5669
5721
  this.stateToggleSubscribe();
5722
+ // hotfix to avoid end offcanvas flicker on first render
5723
+ this.renderer.setStyle(this.hostElement.nativeElement, 'display', 'flex');
5670
5724
  }
5671
5725
  ngOnDestroy() {
5672
5726
  this.offcanvasService.toggle({ show: false, id: this.id });
5673
5727
  this.stateToggleSubscribe(false);
5674
5728
  }
5675
- ngOnChanges(changes) {
5676
- if (changes['scroll']) {
5677
- this.setScroll();
5678
- }
5679
- }
5680
5729
  stateToggleSubscribe(subscribe = true) {
5681
5730
  if (subscribe) {
5682
- this.stateToggleSubscription = this.offcanvasService.offcanvasState$.subscribe((action) => {
5731
+ __classPrivateFieldSet(this, _OffcanvasComponent_stateToggleSubscription, this.offcanvasService.offcanvasState$.subscribe((action) => {
5683
5732
  if (this === action.offcanvas || this.id === action.id) {
5684
5733
  if ('show' in action) {
5685
- this.visible = action?.show === 'toggle' ? !this.visible : action.show;
5734
+ this.visible =
5735
+ action?.show === 'toggle' ? !this.visible : action.show;
5686
5736
  }
5687
5737
  }
5688
- });
5738
+ }), "f");
5689
5739
  }
5690
5740
  else {
5691
- this.stateToggleSubscription.unsubscribe();
5741
+ __classPrivateFieldGet(this, _OffcanvasComponent_stateToggleSubscription, "f").unsubscribe();
5692
5742
  }
5693
5743
  }
5694
5744
  backdropClickSubscribe(subscribe = true) {
5695
5745
  if (subscribe) {
5696
- this.backdropClickSubscription = this.backdropService.backdropClick$.subscribe((clicked) => {
5746
+ __classPrivateFieldSet(this, _OffcanvasComponent_backdropClickSubscription, this.backdropService.backdropClick$.subscribe((clicked) => {
5697
5747
  this.offcanvasService.toggle({ show: !clicked, id: this.id });
5698
- });
5748
+ }), "f");
5699
5749
  }
5700
5750
  else {
5701
- this.backdropClickSubscription?.unsubscribe();
5751
+ __classPrivateFieldGet(this, _OffcanvasComponent_backdropClickSubscription, "f")?.unsubscribe();
5702
5752
  }
5703
5753
  }
5704
5754
  setBackdrop(setBackdrop) {
5705
- if (setBackdrop) {
5706
- this.activeBackdrop = this.backdropService.setBackdrop('offcanvas');
5707
- this.backdropClickSubscribe();
5708
- }
5709
- else {
5710
- this.activeBackdrop = this.backdropService.clearBackdrop(this.activeBackdrop);
5711
- this.backdropClickSubscribe(false);
5712
- }
5755
+ __classPrivateFieldSet(this, _OffcanvasComponent_scrollbarWidth, this.backdropService.scrollbarWidth, "f");
5756
+ __classPrivateFieldSet(this, _OffcanvasComponent_activeBackdrop, !!setBackdrop ? this.backdropService.setBackdrop('offcanvas')
5757
+ : this.backdropService.clearBackdrop(__classPrivateFieldGet(this, _OffcanvasComponent_activeBackdrop, "f")), "f");
5758
+ setBackdrop === true ? this.backdropClickSubscribe()
5759
+ : this.backdropClickSubscribe(false);
5713
5760
  }
5714
5761
  setFocus() {
5715
5762
  if (isPlatformBrowser(this.platformId)) {
5716
5763
  setTimeout(() => this.hostElement.nativeElement.focus());
5717
5764
  }
5718
5765
  }
5719
- setScroll() {
5720
- if (this.visible) {
5721
- if (!this.scroll) {
5722
- this.renderer.setStyle(this.document.body, 'overflow', 'hidden');
5723
- this.renderer.setStyle(this.document.body, 'paddingRight.px', '0');
5766
+ get responsiveBreakpoint() {
5767
+ if (typeof this.responsive !== 'string') {
5768
+ return false;
5769
+ }
5770
+ const element = this.document.documentElement;
5771
+ const responsiveBreakpoint = this.responsive;
5772
+ const breakpointValue = getComputedStyle(element).getPropertyValue(`--cui-breakpoint-${responsiveBreakpoint.trim()}`) || false;
5773
+ return breakpointValue ? `${parseFloat(breakpointValue.trim()) - 0.02}px` : false;
5774
+ }
5775
+ layoutChangeSubscribe(subscribe = true) {
5776
+ if (subscribe) {
5777
+ if (!this.responsiveBreakpoint) {
5778
+ return;
5724
5779
  }
5725
- return;
5780
+ const responsiveBreakpoint = `(max-width: ${this.responsiveBreakpoint})`;
5781
+ const layoutChanges = this.breakpointObserver.observe([responsiveBreakpoint]);
5782
+ __classPrivateFieldSet(this, _OffcanvasComponent_layoutChangeSubscription, layoutChanges
5783
+ .pipe(filter(breakpointState => !breakpointState.matches))
5784
+ .subscribe((breakpointState) => {
5785
+ this.visible = breakpointState.matches;
5786
+ }), "f");
5726
5787
  }
5727
- if (!this.scroll) {
5728
- this.renderer.removeStyle(this.document.body, 'overflow');
5729
- this.renderer.removeStyle(this.document.body, 'paddingRight');
5788
+ else {
5789
+ __classPrivateFieldGet(this, _OffcanvasComponent_layoutChangeSubscription, "f")?.unsubscribe();
5730
5790
  }
5731
5791
  }
5732
5792
  }
5733
- OffcanvasComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: OffcanvasComponent, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: OffcanvasService }, { token: BackdropService }], target: i0.ɵɵFactoryTarget.Component });
5734
- OffcanvasComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.2", type: OffcanvasComponent, selector: "c-offcanvas", inputs: { backdrop: "backdrop", keyboard: "keyboard", placement: "placement", scroll: "scroll", id: "id", role: "role", ariaModal: "ariaModal", visible: "visible" }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "document:keydown": "onKeyDownHandler($event)" }, properties: { "attr.role": "this.role", "attr.aria-modal": "this.ariaModal", "class": "this.hostClasses", "attr.aria-hidden": "this.ariaHidden", "attr.tabindex": "this.tabIndex", "@showHide": "this.animateType" } }, exportAs: ["cOffcanvas"], usesOnChanges: true, ngImport: i0, template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content></ng-content>\n</div>\n\n", styles: [""], dependencies: [{ kind: "directive", type: i3$1.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }], animations: [
5793
+ _OffcanvasComponent_scroll = new WeakMap(), _OffcanvasComponent_visible = new WeakMap(), _OffcanvasComponent_activeBackdrop = new WeakMap(), _OffcanvasComponent_scrollbarWidth = new WeakMap(), _OffcanvasComponent_stateToggleSubscription = new WeakMap(), _OffcanvasComponent_backdropClickSubscription = new WeakMap(), _OffcanvasComponent_layoutChangeSubscription = new WeakMap(), _OffcanvasComponent_show = new WeakMap();
5794
+ OffcanvasComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: OffcanvasComponent, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: OffcanvasService }, { token: BackdropService }, { token: i1$2.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Component });
5795
+ OffcanvasComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.2", type: OffcanvasComponent, selector: "c-offcanvas", inputs: { backdrop: "backdrop", keyboard: "keyboard", placement: "placement", responsive: "responsive", scroll: "scroll", id: "id", role: "role", ariaModal: "ariaModal", visible: "visible" }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "@showHide.start": "animateStart($event)", "@showHide.done": "animateDone($event)", "document:keydown": "onKeyDownHandler($event)" }, properties: { "attr.role": "this.role", "attr.aria-modal": "this.ariaModal", "class": "this.hostClasses", "attr.aria-hidden": "this.ariaHidden", "attr.tabindex": "this.tabIndex", "@showHide": "this.animateTrigger" } }, exportAs: ["cOffcanvas"], ngImport: i0, template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content></ng-content>\n</div>\n\n", styles: [":host{display:none}\n"], dependencies: [{ kind: "directive", type: i3$1.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }], animations: [
5735
5796
  trigger('showHide', [
5736
- state('true', style({
5737
- visibility: 'visible',
5797
+ state('visible', style({
5798
+ // visibility: 'visible'
5738
5799
  })),
5739
- state('false', style({
5740
- visibility: 'hidden',
5800
+ state('hidden', style({
5801
+ // visibility: 'hidden'
5741
5802
  })),
5742
- transition('true => false', [animate('300ms')]),
5743
- ]),
5803
+ transition('visible <=> *', [animate('300ms')])
5804
+ ])
5744
5805
  ] });
5745
5806
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: OffcanvasComponent, decorators: [{
5746
5807
  type: Component,
5747
5808
  args: [{ selector: 'c-offcanvas', animations: [
5748
5809
  trigger('showHide', [
5749
- state('true', style({
5750
- visibility: 'visible',
5810
+ state('visible', style({
5811
+ // visibility: 'visible'
5751
5812
  })),
5752
- state('false', style({
5753
- visibility: 'hidden',
5813
+ state('hidden', style({
5814
+ // visibility: 'hidden'
5754
5815
  })),
5755
- transition('true => false', [animate('300ms')]),
5756
- ]),
5757
- ], exportAs: 'cOffcanvas', template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content></ng-content>\n</div>\n\n" }]
5758
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
5816
+ transition('visible <=> *', [animate('300ms')])
5817
+ ])
5818
+ ], exportAs: 'cOffcanvas', template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content></ng-content>\n</div>\n\n", styles: [":host{display:none}\n"] }]
5819
+ }], ctorParameters: function () { return [{ type: Document, decorators: [{
5759
5820
  type: Inject,
5760
5821
  args: [DOCUMENT]
5761
5822
  }] }, { type: undefined, decorators: [{
5762
5823
  type: Inject,
5763
5824
  args: [PLATFORM_ID]
5764
- }] }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: OffcanvasService }, { type: BackdropService }]; }, propDecorators: { backdrop: [{
5825
+ }] }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: OffcanvasService }, { type: BackdropService }, { type: i1$2.BreakpointObserver }]; }, propDecorators: { backdrop: [{
5765
5826
  type: Input
5766
5827
  }], keyboard: [{
5767
5828
  type: Input
5768
5829
  }], placement: [{
5769
5830
  type: Input
5831
+ }], responsive: [{
5832
+ type: Input
5770
5833
  }], scroll: [{
5771
5834
  type: Input
5772
5835
  }], id: [{
@@ -5794,9 +5857,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.2", ngImpor
5794
5857
  }], tabIndex: [{
5795
5858
  type: HostBinding,
5796
5859
  args: ['attr.tabindex']
5797
- }], animateType: [{
5860
+ }], animateTrigger: [{
5798
5861
  type: HostBinding,
5799
5862
  args: ['@showHide']
5863
+ }], animateStart: [{
5864
+ type: HostListener,
5865
+ args: ['@showHide.start', ['$event']]
5866
+ }], animateDone: [{
5867
+ type: HostListener,
5868
+ args: ['@showHide.done', ['$event']]
5800
5869
  }], onKeyDownHandler: [{
5801
5870
  type: HostListener,
5802
5871
  args: ['document:keydown', ['$event']]
@@ -7028,7 +7097,7 @@ class SidebarComponent {
7028
7097
  }), "f");
7029
7098
  }
7030
7099
  else {
7031
- __classPrivateFieldGet(this, _SidebarComponent_stateToggleSubscription, "f").unsubscribe();
7100
+ __classPrivateFieldGet(this, _SidebarComponent_stateToggleSubscription, "f")?.unsubscribe();
7032
7101
  }
7033
7102
  }
7034
7103
  layoutChangeSubscribe(subscribe = true) {