chrv-components 1.12.143 → 1.12.145

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
@@ -4026,10 +4026,7 @@ class ChrPopoverDirective {
4026
4026
  x: -1,
4027
4027
  y: -1,
4028
4028
  });
4029
- // private readonly isInsidePopover$ = new BehaviorSubject<boolean>(false);
4030
4029
  this.destroyRef = inject(DestroyRef);
4031
- // private readonly isInsideHost = signal(false);
4032
- // private readonly isInsideTarget = signal(false);
4033
4030
  this._targetElementView = signal(null, /* @ts-ignore */
4034
4031
  ...(ngDevMode ? [{ debugName: "_targetElementView" }] : /* istanbul ignore next */ []));
4035
4032
  this.targetElement = computed(() => {
@@ -4058,27 +4055,6 @@ class ChrPopoverDirective {
4058
4055
  y: event.clientY,
4059
4056
  });
4060
4057
  };
4061
- // private isInsideHostBoundingBox = (event: MouseEvent) => {
4062
- // const hostRect = this.hostElement().getBoundingClientRect();
4063
- // return this.isInsideRect(event, hostRect);
4064
- // };
4065
- // private isInsideTargetBoundingBox = (event: MouseEvent) => {
4066
- // const trgRect = this.targetElement().getBoundingClientRect();
4067
- // return this.isInsideRect(event, trgRect);
4068
- // };
4069
- // private isInsideRect = (event: MouseEvent, rect: DOMRect) => {
4070
- // var x = event.clientX;
4071
- // if (x < rect.left || x >= rect.right) return false;
4072
- // var y = event.clientY;
4073
- // if (y < rect.top || y >= rect.bottom) return false;
4074
- // return true;
4075
- // };
4076
- // updateMousePosition = (event: MouseEvent) => {
4077
- // this.lastKnowMousePosition.next({
4078
- // x: event.clientX,
4079
- // y: event.clientY,
4080
- // });
4081
- // };
4082
4058
  this.setupSubject = () => {
4083
4059
  combineLatest([
4084
4060
  this.isHostHovered$,
@@ -4100,93 +4076,28 @@ class ChrPopoverDirective {
4100
4076
  };
4101
4077
  this.setupHostListeners = () => {
4102
4078
  this.renderer.listen(this.hostElement(), 'mouseenter', (event) => {
4103
- // this.isInsidePopover$.next(true);
4104
- // this.isHostHovered$.next({
4105
- // hover: true,
4106
- // position: { x: event.clientX, y: event.clientY },
4107
- // });
4108
- // this.lastKnownMousePosition$.next({
4109
- // x: event.clientX,
4110
- // y: event.clientY,
4111
- // });
4112
4079
  this.isHostHovered$.next(true);
4113
- // if (!this.isOpen()) {
4114
- // this.showPopover();
4115
- // }
4116
4080
  });
4117
4081
  this.renderer.listen(this.hostElement(), 'mouseleave', (event) => {
4118
- // this.isInsideHost.set(false);
4119
- // setTimeout(() => {
4120
- // if (!this.isInsideTarget() && !this.isInsideHostBoundingBox(event)) {
4121
- // this.hidePopover();
4122
- // }
4123
- // }, 100);
4124
- // this.isInsidePopover$.next(false);
4125
- // if (this.isPointerInsideElements(event)) {
4126
- // return;
4127
- // }
4128
- // this.isHostHovered$.next({
4129
- // hover: false,
4130
- // position: { x: event.clientX, y: event.clientY },
4131
- // });
4132
- // this.lastKnownMousePosition$.next({
4133
- // x: event.clientX,
4134
- // y: event.clientY,
4135
- // });
4136
4082
  this.isHostHovered$.next(false);
4137
4083
  });
4138
4084
  };
4139
4085
  this.setupTargetListeners = () => {
4140
4086
  this.renderer.listen(this.targetElement(), 'mouseenter', (event) => {
4141
- // this.isInsideTarget.set(true);
4142
- // this.shopPopover();
4143
- // this.isTargetHovered$.next({
4144
- // hover: true,
4145
- // position: { x: event.clientX, y: event.clientY },
4146
- // });
4147
- // this.lastKnownMousePosition$.next({
4148
- // x: event.clientX,
4149
- // y: event.clientY,
4150
- // });
4151
4087
  this.isTargetHovered$.next(true);
4152
- // this.isInsidePopover$.next(true);
4153
4088
  });
4154
4089
  this.renderer.listen(this.targetElement(), 'mouseleave', (event) => {
4155
- // this.isInsideTarget.set(false);
4156
- // this.isInsidePopover$.next(false);
4157
- // if (this.isPointerInsideElements(event)) {
4158
- // return;
4159
- // }
4160
- // this.isTargetHovered$.next({
4161
- // hover: false,
4162
- // position: { x: event.clientX, y: event.clientY },
4163
- // });
4164
- // this.lastKnownMousePosition$.next({
4165
- // x: event.clientX,
4166
- // y: event.clientY,
4167
- // });
4168
4090
  this.isTargetHovered$.next(false);
4169
- // setTimeout(() => {
4170
- // if (!this.isInsideHost() && !this.isInsideTargetBoundingBox(event))
4171
- // this.hidePopover();
4172
- // }, 100);
4173
4091
  });
4174
4092
  };
4175
4093
  this.showPopover = () => {
4176
4094
  this.isOpen.set(true);
4177
- // this.isInsidePopover$.next(true);
4178
4095
  this.targetElement().showPopover({ source: this.hostElement() });
4179
4096
  };
4180
4097
  this.hidePopover = () => {
4181
4098
  this.isOpen.set(false);
4182
- // this.isInsidePopover$.next(false);
4183
4099
  this.targetElement().hidePopover();
4184
4100
  };
4185
- this.isEventInsideRect = (event, rect) => {
4186
- const x = event.clientX;
4187
- const y = event.clientY;
4188
- return this.isInsideRect(x, y, rect);
4189
- };
4190
4101
  this.isInsideRect = (x, y, rect) => {
4191
4102
  return (x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);
4192
4103
  };
@@ -4202,20 +4113,15 @@ class ChrPopoverDirective {
4202
4113
  const rect = this.targetElement().getBoundingClientRect();
4203
4114
  return this.isInsideRect(x, y, rect);
4204
4115
  };
4205
- this.isPointerInsideElements = (x, y) => {
4206
- // private isPointerInsideElements = (event: MouseEvent): boolean => {
4207
- const hostRect = this.hostElement().getBoundingClientRect();
4208
- const targetRect = this.targetElement().getBoundingClientRect();
4209
- return (this.isInsideRect(x, y, hostRect) || this.isInsideRect(x, y, targetRect));
4210
- };
4211
4116
  }
4212
4117
  ngOnInit() {
4213
4118
  const maybeTemplate = this.chrPopover();
4214
4119
  const templateData = this.chrPopoverData();
4215
4120
  if (maybeTemplate instanceof TemplateRef) {
4216
- const ref = this.viewContainerRef.createEmbeddedView(maybeTemplate, {
4217
- $implicit: templateData,
4218
- });
4121
+ const data = typeof templateData === 'object'
4122
+ ? { $implicit: templateData, ...templateData }
4123
+ : { $implicit: templateData };
4124
+ const ref = this.viewContainerRef.createEmbeddedView(maybeTemplate, data);
4219
4125
  this._targetElementView.set(ref.rootNodes[0]);
4220
4126
  }
4221
4127
  }
@@ -4455,22 +4361,23 @@ class ChrInputComponent {
4455
4361
  }
4456
4362
  }
4457
4363
  };
4458
- this.ensureDefaultDisplayValue = () => {
4459
- const value = this.value() || this.ngControl()?.value;
4364
+ // private ensureDefaultDisplayValue = () => {
4365
+ // const value = this.value() || this.ngControl()?.value;
4366
+ // if (value === null || value === undefined) {
4367
+ // this.displayValue.set('');
4368
+ // return;
4369
+ // }
4370
+ // this.displayValue.set(this.formatValue(value));
4371
+ // };
4372
+ this.formatValue = (value) => {
4460
4373
  const type = this.type();
4461
- if (value === null || value === undefined) {
4462
- this.displayValue.set('');
4463
- return;
4464
- }
4465
4374
  switch (type) {
4466
4375
  case 'date':
4467
- this.displayValue.set(formatDate$1(value, 'yyyy-MM-dd'));
4468
- break;
4376
+ return formatDate$1(value, 'yyyy-MM-dd');
4469
4377
  case 'datetime':
4470
- this.displayValue.set(formatDate$1(value, "yyyy-MM-dd'T'HH:mm"));
4471
- break;
4378
+ return formatDate$1(value, "yyyy-MM-dd'T'HH:mm");
4472
4379
  default:
4473
- this.displayValue.set(value);
4380
+ return value;
4474
4381
  }
4475
4382
  };
4476
4383
  this.onChange = (value) => {
@@ -4486,10 +4393,10 @@ class ChrInputComponent {
4486
4393
  }
4487
4394
  else
4488
4395
  this._changeSubject.next(value);
4489
- // this.input.emit(value);
4490
4396
  };
4491
4397
  this.writeValue = (value) => {
4492
4398
  this.value.set(value ?? null);
4399
+ this.displayValue.set(this.formatValue(value));
4493
4400
  };
4494
4401
  this.registerOnChange = (fn) => {
4495
4402
  this._onChange = (v) => {
@@ -4548,7 +4455,7 @@ class ChrInputComponent {
4548
4455
  this.configureEventListeners();
4549
4456
  this.ensureNgControl();
4550
4457
  this.ensureOutputType();
4551
- this.ensureDefaultDisplayValue();
4458
+ // this.ensureDefaultDisplayValue();
4552
4459
  }
4553
4460
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: ChrInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
4554
4461
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: ChrInputComponent, isStandalone: true, selector: "chr-input", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, displayValue: { classPropertyName: "displayValue", publicName: "displayValue", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, outputType: { classPropertyName: "outputType", publicName: "outputType", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, debounceTime: { classPropertyName: "debounceTime", publicName: "debounceTime", isSignal: true, isRequired: false, transformFunction: null }, isDisabled: { classPropertyName: "isDisabled", publicName: "isDisabled", isSignal: true, isRequired: false, transformFunction: null }, isFocused: { classPropertyName: "isFocused", publicName: "isFocused", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, minLength: { classPropertyName: "minLength", publicName: "minLength", isSignal: true, isRequired: false, transformFunction: null }, maxLength: { classPropertyName: "maxLength", publicName: "maxLength", isSignal: true, isRequired: false, transformFunction: null }, ngControl: { classPropertyName: "ngControl", publicName: "ngControl", isSignal: true, isRequired: false, transformFunction: null }, tooltip: { classPropertyName: "tooltip", publicName: "tooltip", isSignal: true, isRequired: false, transformFunction: null }, tooltipPosition: { classPropertyName: "tooltipPosition", publicName: "tooltipPosition", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { id: "idChange", name: "nameChange", value: "valueChange", displayValue: "displayValueChange", outputType: "outputTypeChange", isDisabled: "isDisabledChange", isFocused: "isFocusedChange", ngControl: "ngControlChange", input: "input", debouncedInput: "debouncedInput", focus: "focus", enter: "enter", blur: "blur" }, providers: [], ngImport: i0, template: "<div class=\"input-wrapper\" [attr.data-state]=\"state()\">\n <div class=\"input-row\">\n <label [for]=\"id()\">\n {{label()}}\n @if(required()){\n <span class=\"required\">*</span>\n }\n </label>\n <input [multiple]=\"\" class=\"input\" #htmlInput [id]=\"id()\" [name]=\"name()\" placeholder=\" \"\n [value]=\"displayValue()\" (focus)=\"focus.emit()\" (blur)=\"blur.emit()\" [disabled]=\"isDisabled()\"\n [type]=\"type() == 'time-seconds' ? 'time' : type()\" (input)=\"input.emit($event);onChange($event)\"\n [step]=\"type() == 'time-seconds' ? 1 : step()\" (keyup.enter)=\"enter.emit()\" />\n <span class=\"indicators\">\n <!-- Indicators projection -->\n <ng-content select=\"chr-input-indicators\"></ng-content>\n @if(tooltip() != null){\n <button type=\"button\" class=\"material-symbols tooltip-indicator\"\n [chrPopover]=\"providedTooltipTemplate() || tooltipTemplate\" [chrPopoverOnHover]=\"false\"\n [chrPopoverPosition]=\"tooltipPosition()\">info</button>\n }\n </span>\n </div>\n</div>\n<!-- Default \"space-consuming\" Content Projection -->\n<div class=\"data\">\n <ng-content select=\"chr-input-data\">\n <!-- Fallback to default projection-->\n <ng-content></ng-content>\n </ng-content>\n</div>\n<!-- No-height slot. Should be used for \"overlay\" type data-->\n<div class=\"data-overlay\">\n @if(isTouched()){\n @let error = getLastError();\n @if(error != null){\n <div class=\"error card glass\">\n {{getLastError() ?? null}}\n </div>\n }\n }\n <ng-content select=\"chr-input-data-overlay\">\n </ng-content>\n</div>\n\n<ng-template #tooltipTemplate>\n <span>{{tooltip()}}</span>\n</ng-template>", styles: [":host{display:flex;flex-direction:column;flex:1 1 auto;min-width:0}.input-wrapper{--chr-input-current-color: var(--text-neutral-color);position:relative;min-height:1.5rem;display:flex;flex:1 1 auto;min-width:0;flex-direction:column;border-bottom:.125rem solid var(--chr-input-current-color)}.input-wrapper .input-row{display:flex;flex:1 1 auto;flex-wrap:nowrap}.input-wrapper .input-row .input{min-width:0}.input-wrapper .input-row .indicators{display:flex;flex-direction:row;flex:1 1 auto;flex-wrap:nowrap;min-width:fit-content;gap:.25rem;max-width:fit-content;align-items:center;padding-left:.125rem;color:var(--chr-input-current-color);font-size:.75rem!important}.input-wrapper .input-row .indicators:has(chr-input-indicators:not(:empty)),.input-wrapper .input-row .indicators:has(:nth-child(2)){border-left:.125rem solid color-mix(in srgb,var(--chr-input-current-color) 40%,transparent 60%)}.input-wrapper .tooltip-indicator{cursor:pointer;font-size:1.25rem;padding:0;color:var(--chr-input-current-color)}.input-wrapper .tooltip-indicator:hover{color:var(--primary-color)}.input-wrapper .required{color:var(--error-color)}.input-wrapper:has(.input:focus){--chr-input-current-color: var(--primary-color)}.input-wrapper[data-state=IDLE]{--chr-input-current-color: color-mix(in srgb, var(--text-neutral-color) 90%, transparent 10%) }.input-wrapper[data-state=INVALID],.input-wrapper[data-state=DISABLED]{--chr-input-current-color: var(--error-color)}.input-wrapper[data-state=PENDING],.input-wrapper[data-state=WARNING]{--chr-input-current-color: var(--warn-color)}.input-wrapper label{position:absolute;top:50%;color:var(--chr-input-current-color);transform:translateY(-50%);transition:transfom 125ms ease-in-out,position 125ms ease-in-out,top 125ms ease-in-out,font-size 125ms ease-in-out,left 125ms ease-in-out;font-size:.85rem;font-weight:700}.input-wrapper label:after{content:\":\"}.input-wrapper label:has(~.input:focus),.input-wrapper label:has(~.input:not(:placeholder-shown)){top:-.25rem;left:0;font-size:75%}.input-wrapper .input{width:100%;outline:none;border:none;padding:0;padding-right:.125rem;background-color:transparent}.data-overlay{height:0;grid-area:data / data;display:flex;flex-direction:column;flex-wrap:nowrap}.data{grid-area:data / data;display:flex;flex-direction:column;flex-wrap:nowrap}.error{grid-area:data / data;display:flex;flex:1 1 auto;flex-direction:row;flex-wrap:wrap;min-width:calc(100% - .5rem);max-width:min-content;color:var(--error-color);padding:.25rem;background-color:var(--background-color);z-index:2}.error:empty{display:none}.input[disabled]{--chr-input-disabled-neutral-muted-color: color-mix(in srgb, var(--text-neutral-color) 15%, transparent 85%);background:repeating-linear-gradient(45deg,var(--chr-input-disabled-neutral-muted-color),var(--chr-input-disabled-neutral-muted-color) .625rem,var(--background-color) .625rem,var(--background-color) 1.25rem);cursor:not-allowed}.input{accent-color:var(--primary-color)}.input ::-webkit-datetime-edit,.input ::-webkit-datetime-edit-fields-wrapper,.input ::-webkit-datetime-edit-text,.input ::-webkit-datetime-edit-month-field,.input ::-webkit-datetime-edit-day-field,.input ::-webkit-datetime-edit-year-field,.input ::-webkit-inner-spin-button,.input ::-webkit-calendar-picker-indicator{place-self:end;justify-self:end;background-color:red}.input[type=range]{color:red}.input[type=range]:after{content:attr(value)}.input[type=textarea]::-webkit-scrollbar{display:none!important}.no-scrollbar{-ms-overflow-style:none!important;scrollbar-width:none!important}\n"], dependencies: [{ kind: "directive", type: ChrPopoverDirective, selector: "[chrPopover]", inputs: ["chrPopover", "chrPopoverPosition", "chrPopoverData", "chrPopoverOnHover"] }] }); }
@@ -4748,8 +4655,12 @@ class ChrSearchSelectInputComponent extends ChrInputComponent {
4748
4655
  ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
4749
4656
  this.display = input((v) => v || '', /* @ts-ignore */
4750
4657
  ...(ngDevMode ? [{ debugName: "display" }] : /* istanbul ignore next */ []));
4751
- this.writeValue = (value) => {
4752
- this.value.set(value);
4658
+ this.formatValue = (value) => {
4659
+ const displayFn = this.display();
4660
+ const formated = displayFn(value);
4661
+ if (formated == undefined || formated == null)
4662
+ return '';
4663
+ return formated;
4753
4664
  };
4754
4665
  /**
4755
4666
  * Force the value to be null when the user types.
@@ -4799,8 +4710,8 @@ class ChrTagSelectInputComponent extends ChrInputComponent {
4799
4710
  ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
4800
4711
  this.display = input((v) => v || '', /* @ts-ignore */
4801
4712
  ...(ngDevMode ? [{ debugName: "display" }] : /* istanbul ignore next */ []));
4802
- this.writeValue = (value) => {
4803
- this.value.set(value);
4713
+ this.formatValue = (value) => {
4714
+ return '';
4804
4715
  };
4805
4716
  /**
4806
4717
  * Signal calculé renvoyant le tableau d'éléments sélectionnés