chrv-components 1.12.220 → 1.12.221

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.
Binary file
@@ -4214,22 +4214,49 @@ class ChrPopoverDirective {
4214
4214
  throw "A string matching the target element's [id] attribute must be set";
4215
4215
  if (!this.targetElement())
4216
4216
  throw "Could not find target element. Check that it's [id] attribute is set with the proper value";
4217
- if (!this.hostElement)
4217
+ if (!this.hostElement())
4218
4218
  throw 'Could not get a reference to the host element';
4219
+ const host = this.hostElement();
4219
4220
  if (this.chrPopoverOnHover()) {
4220
4221
  this.setupSubject();
4221
4222
  this.setupHostListeners();
4222
4223
  this.setupTargetListeners();
4223
4224
  }
4224
4225
  this.renderer.setAttribute(this.targetElement(), 'popover', 'manual');
4225
- this.renderer.setAttribute(this.hostElement(), 'popovertarget', this.targetElementId());
4226
+ this.renderer.setAttribute(host, 'popovertarget', this.targetElementId());
4226
4227
  this.renderer.setStyle(this.targetElement(), 'position-area', this.chrPopoverPosition());
4227
4228
  this.renderer.addClass(this.targetElement(), 'card');
4228
4229
  this.renderer.addClass(this.targetElement(), 'glass');
4229
4230
  this.renderer.setStyle(this.targetElement(), 'border', 'none');
4231
+ const isNativePopoverTrigger = host instanceof HTMLButtonElement ||
4232
+ (host instanceof HTMLInputElement && host.type === 'button');
4233
+ if (!this.chrPopoverOnHover() && !isNativePopoverTrigger) {
4234
+ this.renderer.listen(this.hostElement(), 'click', () => {
4235
+ if (this.isOpen()) {
4236
+ this.hidePopover();
4237
+ }
4238
+ else {
4239
+ this.showPopover();
4240
+ }
4241
+ });
4242
+ }
4243
+ }
4244
+ onOutsideClick(event) {
4245
+ const isOpen = this.isOpen();
4246
+ if (!isOpen)
4247
+ return;
4248
+ const targetElement = this.targetElement();
4249
+ const hostElement = this.hostElement();
4250
+ const clickedNode = event.target;
4251
+ if (targetElement &&
4252
+ !targetElement.contains(clickedNode) &&
4253
+ hostElement &&
4254
+ !hostElement.contains(clickedNode)) {
4255
+ this.hidePopover();
4256
+ }
4230
4257
  }
4231
4258
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: ChrPopoverDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
4232
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.8", type: ChrPopoverDirective, isStandalone: true, selector: "[chrPopover]", inputs: { chrPopover: { classPropertyName: "chrPopover", publicName: "chrPopover", isSignal: true, isRequired: true, transformFunction: null }, chrPopoverPosition: { classPropertyName: "chrPopoverPosition", publicName: "chrPopoverPosition", isSignal: true, isRequired: false, transformFunction: null }, chrPopoverData: { classPropertyName: "chrPopoverData", publicName: "chrPopoverData", isSignal: true, isRequired: false, transformFunction: null }, chrPopoverOnHover: { classPropertyName: "chrPopoverOnHover", publicName: "chrPopoverOnHover", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "keyup.escape": "hidePopover()", "document:mousemove": "updateLastKnownMousePosition($event)" } }, ngImport: i0 }); }
4259
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.8", type: ChrPopoverDirective, isStandalone: true, selector: "[chrPopover]", inputs: { chrPopover: { classPropertyName: "chrPopover", publicName: "chrPopover", isSignal: true, isRequired: true, transformFunction: null }, chrPopoverPosition: { classPropertyName: "chrPopoverPosition", publicName: "chrPopoverPosition", isSignal: true, isRequired: false, transformFunction: null }, chrPopoverData: { classPropertyName: "chrPopoverData", publicName: "chrPopoverData", isSignal: true, isRequired: false, transformFunction: null }, chrPopoverOnHover: { classPropertyName: "chrPopoverOnHover", publicName: "chrPopoverOnHover", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "keyup.escape": "hidePopover()", "document:mousemove": "updateLastKnownMousePosition($event)", "document:click": "onOutsideClick($event)" }, properties: { "style.cursor": "'pointer'", "attr.role": "'button'" } }, ngImport: i0 }); }
4233
4260
  }
4234
4261
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: ChrPopoverDirective, decorators: [{
4235
4262
  type: Directive,
@@ -4238,6 +4265,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
4238
4265
  host: {
4239
4266
  '(keyup.escape)': 'hidePopover()',
4240
4267
  '(document:mousemove)': 'updateLastKnownMousePosition($event)',
4268
+ '[style.cursor]': "'pointer'",
4269
+ '[attr.role]': "'button'",
4270
+ '(document:click)': 'onOutsideClick($event)',
4241
4271
  },
4242
4272
  }]
4243
4273
  }], propDecorators: { chrPopover: [{ type: i0.Input, args: [{ isSignal: true, alias: "chrPopover", required: true }] }], chrPopoverPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "chrPopoverPosition", required: false }] }], chrPopoverData: [{ type: i0.Input, args: [{ isSignal: true, alias: "chrPopoverData", required: false }] }], chrPopoverOnHover: [{ type: i0.Input, args: [{ isSignal: true, alias: "chrPopoverOnHover", required: false }] }] } });