@stemy/ngx-utils 19.3.0 → 19.3.1

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.
@@ -5954,8 +5954,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
5954
5954
 
5955
5955
  const rectProps = ["x", "y", "width", "height"];
5956
5956
  class DropdownContentDirective {
5957
- constructor(vcr, dropdown, templateRef) {
5957
+ constructor(vcr, rootElem, dropdown, templateRef) {
5958
5958
  this.vcr = vcr;
5959
+ this.rootElem = rootElem;
5959
5960
  this.dropdown = dropdown;
5960
5961
  this.templateRef = templateRef;
5961
5962
  if (!this.dropdown) {
@@ -5975,20 +5976,12 @@ class DropdownContentDirective {
5975
5976
  this.destroyView();
5976
5977
  }
5977
5978
  createView(init = false) {
5978
- if (!this.root) {
5979
- const rootNode = this.vcr.element.nativeElement.getRootNode();
5980
- if (rootNode === document) {
5981
- this.root = document.body;
5982
- }
5983
- else {
5984
- this.root = rootNode;
5985
- }
5986
- }
5987
5979
  const ref = this.dropdown.nativeElement;
5988
5980
  const content = this.createWrapper();
5989
5981
  this.dropdown.contentElement = content;
5990
5982
  // Set up floating UI positioning settings
5991
5983
  const placement = this.dropdown.placement || "bottom";
5984
+ const strategy = this.dropdown.attachToRoot && this.rootElem ? "fixed" : "absolute";
5992
5985
  const middleware = [];
5993
5986
  if (this.dropdown.autoPlacement) {
5994
5987
  middleware.push(autoPlacement(this.dropdown.autoPlacement));
@@ -5996,15 +5989,16 @@ class DropdownContentDirective {
5996
5989
  // Set up floating UI auto update
5997
5990
  this.cleanUp = autoUpdate(ref, content, () => {
5998
5991
  computePosition(ref, content, {
5999
- strategy: "fixed",
5992
+ strategy,
6000
5993
  placement,
6001
5994
  middleware
6002
5995
  }).then(({ x, y, placement }) => {
6003
5996
  Object.assign(content.style, {
6004
5997
  opacity: init ? "0" : "1",
6005
- position: "fixed",
5998
+ position: strategy,
6006
5999
  left: `${x}px`,
6007
6000
  top: `${y}px`,
6001
+ zIndex: 1,
6008
6002
  });
6009
6003
  const refRect = ref.getBoundingClientRect();
6010
6004
  const contentRect = content.getBoundingClientRect();
@@ -6035,8 +6029,8 @@ class DropdownContentDirective {
6035
6029
  const wrapper = document.createElement("div");
6036
6030
  const ref = this.vcr.createEmbeddedView(this.templateRef);
6037
6031
  ref.rootNodes.forEach(node => wrapper.appendChild(node));
6038
- if (this.dropdown.attachToRoot) {
6039
- this.root.appendChild(wrapper);
6032
+ if (this.dropdown.attachToRoot && this.rootElem) {
6033
+ this.rootElem.appendChild(wrapper);
6040
6034
  const referenceStyles = getCssVariables(this.dropdown.nativeElement);
6041
6035
  const wrapperStyles = getCssVariables(wrapper);
6042
6036
  Object.keys(referenceStyles).forEach(key => {
@@ -6046,18 +6040,32 @@ class DropdownContentDirective {
6046
6040
  });
6047
6041
  }
6048
6042
  else {
6049
- this.vcr.element.nativeElement?.appendChild(wrapper);
6043
+ const anchor = this.vcr.element.nativeElement;
6044
+ anchor?.parentElement?.appendChild(wrapper);
6050
6045
  }
6046
+ const autoPlacement = this.dropdown.autoPlacement;
6051
6047
  if (this.lastPlacement) {
6052
6048
  wrapper.classList.add(this.lastPlacement);
6053
6049
  }
6050
+ if (autoPlacement) {
6051
+ const vertical = autoPlacement.allowedPlacements.some(p => p.includes("top") || p.includes("bottom"));
6052
+ const horizontal = autoPlacement.allowedPlacements.some(p => p.includes("left") || p.includes("right"));
6053
+ if (vertical && horizontal) {
6054
+ wrapper.classList.add(`dropdown-content-axis-both`);
6055
+ }
6056
+ else {
6057
+ const axis = vertical ? "vertical" : "horizontal";
6058
+ wrapper.classList.add(`dropdown-content-axis-${axis}`);
6059
+ }
6060
+ }
6061
+ wrapper.classList.add("dropdown-content-wrap");
6054
6062
  return wrapper;
6055
6063
  }
6056
6064
  initialize() {
6057
6065
  this.createView(true);
6058
6066
  setTimeout(() => this.destroyView());
6059
6067
  }
6060
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: DropdownContentDirective, deps: [{ token: i0.ViewContainerRef }, { token: DropdownDirective, optional: true }, { token: i0.TemplateRef, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
6068
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: DropdownContentDirective, deps: [{ token: i0.ViewContainerRef }, { token: ROOT_ELEMENT, optional: true }, { token: DropdownDirective, optional: true }, { token: i0.TemplateRef, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
6061
6069
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.5", type: DropdownContentDirective, isStandalone: false, selector: "[dropdownContent]", exportAs: ["dropdown-content"], ngImport: i0 }); }
6062
6070
  }
6063
6071
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: DropdownContentDirective, decorators: [{
@@ -6067,7 +6075,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
6067
6075
  selector: "[dropdownContent]",
6068
6076
  exportAs: "dropdown-content",
6069
6077
  }]
6070
- }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: DropdownDirective, decorators: [{
6078
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: HTMLElement, decorators: [{
6079
+ type: Optional
6080
+ }, {
6081
+ type: Inject,
6082
+ args: [ROOT_ELEMENT]
6083
+ }] }, { type: DropdownDirective, decorators: [{
6071
6084
  type: Optional
6072
6085
  }] }, { type: i0.TemplateRef, decorators: [{
6073
6086
  type: Optional