@open-rlb/ng-bootstrap 3.1.24 → 3.1.25

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { signal, Component, input, booleanAttribute, effect, Host, Self, Optional, Directive, Injectable, output, contentChild, computed, contentChildren, viewChild, numberAttribute, model, ViewChild, isSignal, Pipe, ChangeDetectionStrategy, inject, ViewContainerRef, Renderer2, DOCUMENT, Inject, HostListener, InjectionToken, viewChildren, untracked, EventEmitter, Output, NgModule } from '@angular/core';
2
+ import { signal, Component, input, booleanAttribute, effect, Host, Self, Optional, Directive, Injectable, output, contentChild, computed, contentChildren, viewChild, numberAttribute, model, ViewChild, isSignal, Pipe, ChangeDetectionStrategy, inject, ViewContainerRef, Renderer2, DestroyRef, DOCUMENT, Inject, HostListener, InjectionToken, viewChildren, untracked, EventEmitter, Output, NgModule } from '@angular/core';
3
3
  import { Collapse, Carousel, Dropdown, Modal, Toast, Offcanvas, ScrollSpy, Popover, Tooltip } from 'bootstrap';
4
4
  import * as i2 from '@angular/router';
5
5
  import { RouterModule } from '@angular/router';
@@ -4212,7 +4212,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
4212
4212
 
4213
4213
  class NavbarDropdownItemComponent {
4214
4214
  constructor() {
4215
- this.listeners = [];
4215
+ this.viewContainerRef = inject(ViewContainerRef);
4216
+ this.renderer = inject(Renderer2);
4217
+ this.destroyRef = inject(DestroyRef);
4218
+ this.template = viewChild.required('template');
4216
4219
  this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : {}), alias: 'disabled', transform: booleanAttribute });
4217
4220
  this.dropdown = input(false, { ...(ngDevMode ? { debugName: "dropdown" } : {}), alias: 'dropdown', transform: booleanAttribute });
4218
4221
  this.href = input(undefined, ...(ngDevMode ? [{ debugName: "href" }] : []));
@@ -4223,8 +4226,6 @@ class NavbarDropdownItemComponent {
4223
4226
  this.statusChanged = output({ alias: 'status-changed' });
4224
4227
  this._autoClose = computed(() => {
4225
4228
  switch (this.autoClose()) {
4226
- case 'default':
4227
- return 'true';
4228
4229
  case 'inside':
4229
4230
  return 'inside';
4230
4231
  case 'outside':
@@ -4235,22 +4236,37 @@ class NavbarDropdownItemComponent {
4235
4236
  return 'true';
4236
4237
  }
4237
4238
  }, ...(ngDevMode ? [{ debugName: "_autoClose" }] : []));
4238
- this.template = viewChild.required('template');
4239
- this.viewContainerRef = inject(ViewContainerRef);
4240
- this.renderer = inject(Renderer2);
4239
+ effect(() => {
4240
+ const template = this.template();
4241
+ const dropdownEnabled = this.dropdown();
4242
+ const templateView = this.viewContainerRef.createEmbeddedView(template);
4243
+ this.element = templateView.rootNodes[0];
4244
+ this.viewContainerRef.element.nativeElement.remove();
4245
+ const anchor = this.element.querySelector('a');
4246
+ if (!anchor || !dropdownEnabled)
4247
+ return;
4248
+ this.dropdownInstance = Dropdown.getOrCreateInstance(anchor);
4249
+ const unsubShow = this.renderer.listen(anchor, 'show.bs.dropdown', () => this.statusChanged.emit('show'));
4250
+ const unsubShown = this.renderer.listen(anchor, 'shown.bs.dropdown', () => this.statusChanged.emit('shown'));
4251
+ const unsubHide = this.renderer.listen(anchor, 'hide.bs.dropdown', () => this.statusChanged.emit('hide'));
4252
+ const unsubHidden = this.renderer.listen(anchor, 'hidden.bs.dropdown', () => this.statusChanged.emit('hidden'));
4253
+ this.destroyRef.onDestroy(() => {
4254
+ unsubShow();
4255
+ unsubShown();
4256
+ unsubHide();
4257
+ unsubHidden();
4258
+ this.dropdownInstance?.dispose();
4259
+ });
4260
+ });
4241
4261
  }
4242
- ngOnInit() {
4243
- const templateView = this.viewContainerRef.createEmbeddedView(this.template());
4244
- this.element = templateView.rootNodes[0];
4245
- this.viewContainerRef.element.nativeElement.remove();
4246
- const anchor = this.element.querySelector('a');
4247
- if (anchor && this.dropdown()) {
4248
- this.listeners.push(this.renderer.listen(anchor, 'show.bs.dropdown', () => this.statusChanged.emit('show')), this.renderer.listen(anchor, 'shown.bs.dropdown', () => this.statusChanged.emit('shown')), this.renderer.listen(anchor, 'hide.bs.dropdown', () => this.statusChanged.emit('hide')), this.renderer.listen(anchor, 'hidden.bs.dropdown', () => this.statusChanged.emit('hidden')));
4249
- }
4262
+ open() {
4263
+ this.dropdownInstance?.show();
4250
4264
  }
4251
- ngOnDestroy() {
4252
- this.listeners.forEach(unsub => unsub());
4253
- this.listeners = [];
4265
+ close() {
4266
+ this.dropdownInstance?.hide();
4267
+ }
4268
+ toggleDropdown() {
4269
+ this.dropdownInstance?.toggle();
4254
4270
  }
4255
4271
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: NavbarDropdownItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
4256
4272
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.1", type: NavbarDropdownItemComponent, isStandalone: false, selector: "rlb-navbar-dropdown-item", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, dropdown: { classPropertyName: "dropdown", publicName: "dropdown", isSignal: true, isRequired: false, transformFunction: null }, href: { classPropertyName: "href", publicName: "href", isSignal: true, isRequired: false, transformFunction: null }, cssClass: { classPropertyName: "cssClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, toggle: { classPropertyName: "toggle", publicName: "toggle", isSignal: true, isRequired: false, transformFunction: null }, autoClose: { classPropertyName: "autoClose", publicName: "auto-close", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { click: "click", statusChanged: "status-changed" }, viewQueries: [{ propertyName: "template", first: true, predicate: ["template"], descendants: true, isSignal: true }], ngImport: i0, template: `
@@ -4271,6 +4287,7 @@ class NavbarDropdownItemComponent {
4271
4287
  >
4272
4288
  <ng-content select=":not(rlb-dropdown-container)"></ng-content>
4273
4289
  </a>
4290
+
4274
4291
  <ng-content select="rlb-dropdown-container"></ng-content>
4275
4292
  </li>
4276
4293
  </ng-template>
@@ -4298,13 +4315,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
4298
4315
  >
4299
4316
  <ng-content select=":not(rlb-dropdown-container)"></ng-content>
4300
4317
  </a>
4318
+
4301
4319
  <ng-content select="rlb-dropdown-container"></ng-content>
4302
4320
  </li>
4303
4321
  </ng-template>
4304
4322
  `,
4305
4323
  standalone: false,
4306
4324
  }]
4307
- }], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], dropdown: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdown", required: false }] }], href: [{ type: i0.Input, args: [{ isSignal: true, alias: "href", required: false }] }], cssClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], toggle: [{ type: i0.Input, args: [{ isSignal: true, alias: "toggle", required: false }] }], autoClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "auto-close", required: false }] }], click: [{ type: i0.Output, args: ["click"] }], statusChanged: [{ type: i0.Output, args: ["status-changed"] }], template: [{ type: i0.ViewChild, args: ['template', { isSignal: true }] }] } });
4325
+ }], ctorParameters: () => [], propDecorators: { template: [{ type: i0.ViewChild, args: ['template', { isSignal: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], dropdown: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdown", required: false }] }], href: [{ type: i0.Input, args: [{ isSignal: true, alias: "href", required: false }] }], cssClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], toggle: [{ type: i0.Input, args: [{ isSignal: true, alias: "toggle", required: false }] }], autoClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "auto-close", required: false }] }], click: [{ type: i0.Output, args: ["click"] }], statusChanged: [{ type: i0.Output, args: ["status-changed"] }] } });
4308
4326
 
4309
4327
  class NavbarItemComponent {
4310
4328
  constructor(viewContainerRef) {