imm-element-ui 2.8.2 → 2.8.4

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.
@@ -1509,7 +1509,7 @@ const _fieldUtils = {
1509
1509
  if (field.type == 'upload') {
1510
1510
  return _fieldUtils.toUploadValue(field, raw);
1511
1511
  }
1512
- return raw || '';
1512
+ return raw ?? '';
1513
1513
  },
1514
1514
  toTreeSelectValue: (field, raw) => {
1515
1515
  if (field.treeSelectProps?.selectionMode == 'single') {
@@ -5404,7 +5404,7 @@ class CellEditSelectFieldComponent {
5404
5404
  if (!this.params.rawOptions && typeof this.params.getOptions === 'function') {
5405
5405
  if (isObservable(this.params.getOptions(this.params.data))) {
5406
5406
  this.params.getOptions(this.params.data).subscribe((res) => {
5407
- this.params.options = res.hasOwnPropertys('data') ? res.data : (res || []);
5407
+ this.params.options = res.hasOwnPropertys('data') ? res.data : res || [];
5408
5408
  });
5409
5409
  }
5410
5410
  else {
@@ -5425,7 +5425,7 @@ class CellEditSelectFieldComponent {
5425
5425
  width: `${cellWidth}px`,
5426
5426
  background: 'var(--ag-background-color)',
5427
5427
  height: '40px',
5428
- alignItems: 'center'
5428
+ alignItems: 'center',
5429
5429
  };
5430
5430
  this.params.panelStyle = {
5431
5431
  width: `${cellWidth}px`,
@@ -5443,145 +5443,158 @@ class CellEditSelectFieldComponent {
5443
5443
  });
5444
5444
  }
5445
5445
  updateNameField(nameField, event) {
5446
- const oldValue = this.params.data[nameField.field];
5446
+ const oldValue = this.params.data?.[nameField.field];
5447
5447
  const valueField = this.params.optionValue || 'value';
5448
5448
  const item = this.params.options.find((op) => op?.[valueField] === event.value);
5449
5449
  const newValue = item ? item[nameField.key] : null;
5450
- const grid = this.params.grid();
5451
- let e = {
5452
- colDef: nameField,
5453
- oldValue,
5454
- newValue,
5455
- rowIndex: this.params.node.rowIndex,
5456
- data: { id: this.params.data.id },
5457
- };
5458
- grid.cellValueChanged(e);
5459
- this.params.data[nameField.field] = newValue;
5450
+ const grid = this.getGrid();
5451
+ if (grid?.cellValueChanged) {
5452
+ let e = {
5453
+ colDef: nameField,
5454
+ oldValue,
5455
+ newValue,
5456
+ rowIndex: this.params.node?.rowIndex,
5457
+ data: { id: this.params.data?.id },
5458
+ };
5459
+ grid.cellValueChanged(e);
5460
+ }
5461
+ if (this.params.data) {
5462
+ this.params.data[nameField.field] = newValue;
5463
+ }
5464
+ }
5465
+ getGrid() {
5466
+ if (typeof this.params.grid === 'function') {
5467
+ return this.params.grid();
5468
+ }
5469
+ if (typeof this.params.context?.grid === 'function') {
5470
+ return this.params.context.grid();
5471
+ }
5472
+ return undefined;
5460
5473
  }
5461
5474
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CellEditSelectFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
5462
5475
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: CellEditSelectFieldComponent, isStandalone: true, selector: "ng-component", viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true, read: ViewContainerRef }], ngImport: i0, template: `
5463
- <p-select
5464
- [(ngModel)]="value"
5465
- [scrollHeight]="params.scrollHeight || '200px'"
5466
- [filter]="params.filter"
5467
- [name]="params.name"
5468
- [options]="params.options"
5469
- [placeholder]="params.placeholder"
5470
- [class]="params.class"
5471
- [style]="params.style"
5472
- [panelStyle]="params.panelStyle"
5473
- [panelStyleClass]="params.panelStyleClass"
5474
- [readonly]="params.readonly"
5475
- [editable]="params.editable"
5476
- [appendTo]="params.appendTo || 'body'"
5477
- [tabindex]="params.tabindex"
5478
- [placeholder]="params.placeholder"
5479
- [loadingIcon]="params.loadingIcon"
5480
- [filterPlaceholder]="params.filterPlaceholder"
5481
- [filterLocale]="params.filterLocale"
5482
- [variant]="params.variant"
5483
- [inputId]="params.inputId"
5484
- [dataKey]="params.dataKey"
5485
- [filterBy]="params.filterBy"
5486
- [filterFields]="params.filterFields"
5487
- [autofocus]="params.autofocus ?? true"
5488
- [resetFilterOnHide]="params.resetFilterOnHide"
5489
- [checkmark]="params.checkmark"
5490
- [dropdownIcon]="params.dropdownIcon"
5491
- [loading]="params.loading"
5492
- [optionLabel]="params.optionLabel"
5493
- [optionValue]="params.optionValue"
5494
- [optionDisabled]="params.optionDisabled"
5495
- [optionGroupLabel]="params.optionGroupLabel"
5496
- [optionGroupChildren]="params.optionGroupChildren || 'items'"
5497
- [group]="params.group"
5498
- [showClear]="params.showClear"
5499
- [emptyFilterMessage]="params.emptyFilterMessage"
5500
- [emptyMessage]="params.emptyMessage"
5501
- [lazy]="params.lazy"
5502
- [virtualScroll]="params.virtualScroll"
5503
- [virtualScrollItemSize]="params.virtualScrollItemSize"
5504
- [virtualScrollOptions]="params.virtualScrollOptions"
5505
- [overlayOptions]="params.overlayOptions"
5506
- [size]="params.size"
5507
- [ariaFilterLabel]="params.ariaFilterLabel"
5508
- [ariaLabel]="params.ariaLabel"
5509
- [ariaLabelledBy]="params.ariaLabelledBy"
5510
- [filterMatchMode]="params.filterMatchMode"
5511
- [maxlength]="params.maxlength"
5512
- [tooltip]="params.tooltip"
5513
- [tooltipPosition]="params.tooltipPosition || 'right'"
5514
- [tooltipPositionStyle]="params.tooltipPositionStyle || 'absolute'"
5515
- [tooltipStyleClass]="params.tooltipStyleClass"
5516
- [focusOnHover]="params.focusOnHover == undefined ? true : params.focusOnHover"
5517
- [fluid]="params.fluid == undefined ? true : params.fluid"
5518
- [filterValue]="params.filterValue"
5519
- (onChange)="onChange($event)" />
5520
- `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$2.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i2$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: SelectModule }, { kind: "component", type: i2$7.Select, selector: "p-select", inputs: ["id", "scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "loadingIcon", "filterPlaceholder", "filterLocale", "variant", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "checkmark", "dropdownIcon", "loading", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "size", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "fluid", "disabled", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "filterValue", "options"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }] }); }
5476
+ <p-select
5477
+ [(ngModel)]="value"
5478
+ [scrollHeight]="params.scrollHeight || '200px'"
5479
+ [filter]="params.filter"
5480
+ [name]="params.name"
5481
+ [options]="params.options"
5482
+ [placeholder]="params.placeholder"
5483
+ [class]="params.class"
5484
+ [style]="params.style"
5485
+ [panelStyle]="params.panelStyle"
5486
+ [panelStyleClass]="params.panelStyleClass"
5487
+ [readonly]="params.readonly"
5488
+ [editable]="params.editable"
5489
+ [appendTo]="params.appendTo || 'body'"
5490
+ [tabindex]="params.tabindex"
5491
+ [placeholder]="params.placeholder"
5492
+ [loadingIcon]="params.loadingIcon"
5493
+ [filterPlaceholder]="params.filterPlaceholder"
5494
+ [filterLocale]="params.filterLocale"
5495
+ [variant]="params.variant"
5496
+ [inputId]="params.inputId"
5497
+ [dataKey]="params.dataKey"
5498
+ [filterBy]="params.filterBy"
5499
+ [filterFields]="params.filterFields"
5500
+ [autofocus]="params.autofocus ?? true"
5501
+ [resetFilterOnHide]="params.resetFilterOnHide"
5502
+ [checkmark]="params.checkmark"
5503
+ [dropdownIcon]="params.dropdownIcon"
5504
+ [loading]="params.loading"
5505
+ [optionLabel]="params.optionLabel"
5506
+ [optionValue]="params.optionValue"
5507
+ [optionDisabled]="params.optionDisabled"
5508
+ [optionGroupLabel]="params.optionGroupLabel"
5509
+ [optionGroupChildren]="params.optionGroupChildren || 'items'"
5510
+ [group]="params.group"
5511
+ [showClear]="params.showClear"
5512
+ [emptyFilterMessage]="params.emptyFilterMessage"
5513
+ [emptyMessage]="params.emptyMessage"
5514
+ [lazy]="params.lazy"
5515
+ [virtualScroll]="params.virtualScroll"
5516
+ [virtualScrollItemSize]="params.virtualScrollItemSize"
5517
+ [virtualScrollOptions]="params.virtualScrollOptions"
5518
+ [overlayOptions]="params.overlayOptions"
5519
+ [size]="params.size"
5520
+ [ariaFilterLabel]="params.ariaFilterLabel"
5521
+ [ariaLabel]="params.ariaLabel"
5522
+ [ariaLabelledBy]="params.ariaLabelledBy"
5523
+ [filterMatchMode]="params.filterMatchMode"
5524
+ [maxlength]="params.maxlength"
5525
+ [tooltip]="params.tooltip"
5526
+ [tooltipPosition]="params.tooltipPosition || 'right'"
5527
+ [tooltipPositionStyle]="params.tooltipPositionStyle || 'absolute'"
5528
+ [tooltipStyleClass]="params.tooltipStyleClass"
5529
+ [focusOnHover]="params.focusOnHover == undefined ? true : params.focusOnHover"
5530
+ [fluid]="params.fluid == undefined ? true : params.fluid"
5531
+ [filterValue]="params.filterValue"
5532
+ (onChange)="onChange($event)" />
5533
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$2.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i2$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: SelectModule }, { kind: "component", type: i2$7.Select, selector: "p-select", inputs: ["id", "scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "loadingIcon", "filterPlaceholder", "filterLocale", "variant", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "checkmark", "dropdownIcon", "loading", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "size", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "fluid", "disabled", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "filterValue", "options"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }] }); }
5521
5534
  }
5522
5535
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CellEditSelectFieldComponent, decorators: [{
5523
5536
  type: Component,
5524
5537
  args: [{
5525
5538
  standalone: true,
5526
5539
  template: `
5527
- <p-select
5528
- [(ngModel)]="value"
5529
- [scrollHeight]="params.scrollHeight || '200px'"
5530
- [filter]="params.filter"
5531
- [name]="params.name"
5532
- [options]="params.options"
5533
- [placeholder]="params.placeholder"
5534
- [class]="params.class"
5535
- [style]="params.style"
5536
- [panelStyle]="params.panelStyle"
5537
- [panelStyleClass]="params.panelStyleClass"
5538
- [readonly]="params.readonly"
5539
- [editable]="params.editable"
5540
- [appendTo]="params.appendTo || 'body'"
5541
- [tabindex]="params.tabindex"
5542
- [placeholder]="params.placeholder"
5543
- [loadingIcon]="params.loadingIcon"
5544
- [filterPlaceholder]="params.filterPlaceholder"
5545
- [filterLocale]="params.filterLocale"
5546
- [variant]="params.variant"
5547
- [inputId]="params.inputId"
5548
- [dataKey]="params.dataKey"
5549
- [filterBy]="params.filterBy"
5550
- [filterFields]="params.filterFields"
5551
- [autofocus]="params.autofocus ?? true"
5552
- [resetFilterOnHide]="params.resetFilterOnHide"
5553
- [checkmark]="params.checkmark"
5554
- [dropdownIcon]="params.dropdownIcon"
5555
- [loading]="params.loading"
5556
- [optionLabel]="params.optionLabel"
5557
- [optionValue]="params.optionValue"
5558
- [optionDisabled]="params.optionDisabled"
5559
- [optionGroupLabel]="params.optionGroupLabel"
5560
- [optionGroupChildren]="params.optionGroupChildren || 'items'"
5561
- [group]="params.group"
5562
- [showClear]="params.showClear"
5563
- [emptyFilterMessage]="params.emptyFilterMessage"
5564
- [emptyMessage]="params.emptyMessage"
5565
- [lazy]="params.lazy"
5566
- [virtualScroll]="params.virtualScroll"
5567
- [virtualScrollItemSize]="params.virtualScrollItemSize"
5568
- [virtualScrollOptions]="params.virtualScrollOptions"
5569
- [overlayOptions]="params.overlayOptions"
5570
- [size]="params.size"
5571
- [ariaFilterLabel]="params.ariaFilterLabel"
5572
- [ariaLabel]="params.ariaLabel"
5573
- [ariaLabelledBy]="params.ariaLabelledBy"
5574
- [filterMatchMode]="params.filterMatchMode"
5575
- [maxlength]="params.maxlength"
5576
- [tooltip]="params.tooltip"
5577
- [tooltipPosition]="params.tooltipPosition || 'right'"
5578
- [tooltipPositionStyle]="params.tooltipPositionStyle || 'absolute'"
5579
- [tooltipStyleClass]="params.tooltipStyleClass"
5580
- [focusOnHover]="params.focusOnHover == undefined ? true : params.focusOnHover"
5581
- [fluid]="params.fluid == undefined ? true : params.fluid"
5582
- [filterValue]="params.filterValue"
5583
- (onChange)="onChange($event)" />
5584
- `,
5540
+ <p-select
5541
+ [(ngModel)]="value"
5542
+ [scrollHeight]="params.scrollHeight || '200px'"
5543
+ [filter]="params.filter"
5544
+ [name]="params.name"
5545
+ [options]="params.options"
5546
+ [placeholder]="params.placeholder"
5547
+ [class]="params.class"
5548
+ [style]="params.style"
5549
+ [panelStyle]="params.panelStyle"
5550
+ [panelStyleClass]="params.panelStyleClass"
5551
+ [readonly]="params.readonly"
5552
+ [editable]="params.editable"
5553
+ [appendTo]="params.appendTo || 'body'"
5554
+ [tabindex]="params.tabindex"
5555
+ [placeholder]="params.placeholder"
5556
+ [loadingIcon]="params.loadingIcon"
5557
+ [filterPlaceholder]="params.filterPlaceholder"
5558
+ [filterLocale]="params.filterLocale"
5559
+ [variant]="params.variant"
5560
+ [inputId]="params.inputId"
5561
+ [dataKey]="params.dataKey"
5562
+ [filterBy]="params.filterBy"
5563
+ [filterFields]="params.filterFields"
5564
+ [autofocus]="params.autofocus ?? true"
5565
+ [resetFilterOnHide]="params.resetFilterOnHide"
5566
+ [checkmark]="params.checkmark"
5567
+ [dropdownIcon]="params.dropdownIcon"
5568
+ [loading]="params.loading"
5569
+ [optionLabel]="params.optionLabel"
5570
+ [optionValue]="params.optionValue"
5571
+ [optionDisabled]="params.optionDisabled"
5572
+ [optionGroupLabel]="params.optionGroupLabel"
5573
+ [optionGroupChildren]="params.optionGroupChildren || 'items'"
5574
+ [group]="params.group"
5575
+ [showClear]="params.showClear"
5576
+ [emptyFilterMessage]="params.emptyFilterMessage"
5577
+ [emptyMessage]="params.emptyMessage"
5578
+ [lazy]="params.lazy"
5579
+ [virtualScroll]="params.virtualScroll"
5580
+ [virtualScrollItemSize]="params.virtualScrollItemSize"
5581
+ [virtualScrollOptions]="params.virtualScrollOptions"
5582
+ [overlayOptions]="params.overlayOptions"
5583
+ [size]="params.size"
5584
+ [ariaFilterLabel]="params.ariaFilterLabel"
5585
+ [ariaLabel]="params.ariaLabel"
5586
+ [ariaLabelledBy]="params.ariaLabelledBy"
5587
+ [filterMatchMode]="params.filterMatchMode"
5588
+ [maxlength]="params.maxlength"
5589
+ [tooltip]="params.tooltip"
5590
+ [tooltipPosition]="params.tooltipPosition || 'right'"
5591
+ [tooltipPositionStyle]="params.tooltipPositionStyle || 'absolute'"
5592
+ [tooltipStyleClass]="params.tooltipStyleClass"
5593
+ [focusOnHover]="params.focusOnHover == undefined ? true : params.focusOnHover"
5594
+ [fluid]="params.fluid == undefined ? true : params.fluid"
5595
+ [filterValue]="params.filterValue"
5596
+ (onChange)="onChange($event)" />
5597
+ `,
5585
5598
  imports: [FormsModule, ReactiveFormsModule, SelectModule],
5586
5599
  }]
5587
5600
  }], propDecorators: { input: [{
@@ -5744,18 +5757,31 @@ class CellEditAsyncSelectFieldComponent {
5744
5757
  };
5745
5758
  }
5746
5759
  updateNameField(nameField, event) {
5747
- const oldValue = this.params.data[nameField.field];
5760
+ const oldValue = this.params.data?.[nameField.field];
5748
5761
  const newValue = this.resolveNameFieldValue(nameField, event.value);
5749
- const grid = this.params.grid();
5750
- const e = {
5751
- colDef: nameField,
5752
- oldValue,
5753
- newValue,
5754
- rowIndex: this.params.node.rowIndex,
5755
- data: { id: this.params.data.id },
5756
- };
5757
- grid.cellValueChanged(e);
5758
- this.params.data[nameField.field] = newValue;
5762
+ const grid = this.getGrid();
5763
+ if (grid?.cellValueChanged) {
5764
+ const e = {
5765
+ colDef: nameField,
5766
+ oldValue,
5767
+ newValue,
5768
+ rowIndex: this.params.node?.rowIndex,
5769
+ data: { id: this.params.data?.id },
5770
+ };
5771
+ grid.cellValueChanged(e);
5772
+ }
5773
+ if (this.params.data) {
5774
+ this.params.data[nameField.field] = newValue;
5775
+ }
5776
+ }
5777
+ getGrid() {
5778
+ if (typeof this.params.grid === 'function') {
5779
+ return this.params.grid();
5780
+ }
5781
+ if (typeof this.params.context?.grid === 'function') {
5782
+ return this.params.context.grid();
5783
+ }
5784
+ return undefined;
5759
5785
  }
5760
5786
  resolveNameFieldValue(nameField, value) {
5761
5787
  const valueField = this.params.optionValue || 'value';
@@ -5777,7 +5803,9 @@ class CellEditAsyncSelectFieldComponent {
5777
5803
  if (value === '' || value == null) {
5778
5804
  return [];
5779
5805
  }
5780
- return String(value).split(',').filter((item) => item !== '');
5806
+ return String(value)
5807
+ .split(',')
5808
+ .filter((item) => item !== '');
5781
5809
  }
5782
5810
  toValueString(value) {
5783
5811
  if (Array.isArray(value)) {
@@ -9846,6 +9874,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
9846
9874
  args: ['fieldLabelRef', { static: false }]
9847
9875
  }] } });
9848
9876
 
9877
+ const nonEmptyRequired = (control) => (control.value === false ? null : Validators.required(control));
9849
9878
  class FormComponent {
9850
9879
  onResize() {
9851
9880
  this.reCalcLabelSize();
@@ -9987,7 +10016,7 @@ class FormComponent {
9987
10016
  handleFieldControl(field) {
9988
10017
  const key = field.key || '';
9989
10018
  const isDisplayOnly = !!field.extra?.displayOnly;
9990
- const validators = isDisplayOnly ? null : fieldUtils.props(field)?.required ? (field.validators ? field.validators : Validators.required) : null;
10019
+ const validators = isDisplayOnly ? null : fieldUtils.props(field)?.required ? (field.validators ? field.validators : nonEmptyRequired) : null;
9991
10020
  let fieldControl = this.options().form?.get(key);
9992
10021
  if (!fieldControl) {
9993
10022
  fieldControl = new FieldControl(null, validators || undefined);
@@ -10089,7 +10118,7 @@ class FormComponent {
10089
10118
  const validators = field.extra?.displayOnly
10090
10119
  ? null
10091
10120
  : fieldUtils.props(field)?.required
10092
- ? (field?.validators ? field?.validators : Validators.required)
10121
+ ? (field?.validators ? field?.validators : nonEmptyRequired)
10093
10122
  : null;
10094
10123
  field.fieldControl?.setValidators(validators);
10095
10124
  }