myrta-ui 1.1.27 → 1.1.28

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.
@@ -4256,9 +4256,6 @@ const getErrorMessageHelper = (key, invalidMessages, messages, params) => {
4256
4256
 
4257
4257
  const requiredValidation = (value, validations, key, invalidMessages) => {
4258
4258
  const result = { isValid: true, message: null };
4259
- console.log(validations);
4260
- console.log(key);
4261
- console.log();
4262
4259
  if (Array.isArray(value) && validations.type !== 'single' && validations[key]) {
4263
4260
  value.forEach((field, idx) => {
4264
4261
  if ((field === '' || field === null || field === undefined)) {
@@ -17423,8 +17420,13 @@ class FormulaEditorComponent {
17423
17420
  endOffset: 0
17424
17421
  };
17425
17422
  this.searchText = '';
17426
- this.operatorList = ['+', '-', '*', '/'];
17427
- this.bracketList = ['(', ')'];
17423
+ this._operatorList = ['+', '-', '*', '/'];
17424
+ this._bracketList = ['(', ')'];
17425
+ this._itemList = [];
17426
+ this._modifiedItemList = {
17427
+ items: {},
17428
+ regExp: new RegExp(''),
17429
+ };
17428
17430
  this.value = '';
17429
17431
  this.visibleValue = '';
17430
17432
  this.isFocused = false;
@@ -17435,8 +17437,6 @@ class FormulaEditorComponent {
17435
17437
  // SAVE STATE
17436
17438
  this.uuid = v4();
17437
17439
  this.fields = [];
17438
- // TODO items
17439
- this.items = [];
17440
17440
  this.disabled = false;
17441
17441
  this.readonly = false;
17442
17442
  this.placeholder = '';
@@ -17453,11 +17453,17 @@ class FormulaEditorComponent {
17453
17453
  this.onTouched = () => {
17454
17454
  };
17455
17455
  }
17456
+ set items(items) {
17457
+ const itemsMap = Object.fromEntries(items.map(obj => [obj.label, obj.sysName]));
17458
+ this._itemList = items;
17459
+ this._modifiedItemList.items = itemsMap;
17460
+ this._modifiedItemList.regExp = new RegExp(items.map(s => s.label).join('|'), 'g');
17461
+ }
17456
17462
  get getErrorMessage() {
17457
17463
  return this.invalidMessage || ErrorMessagesEnum[this.errorModel.errorType];
17458
17464
  }
17459
17465
  get filteredList() {
17460
- return this.items.filter(item => item.label.includes(this.searchText));
17466
+ return this._itemList.filter(item => item.label.includes(this.searchText));
17461
17467
  }
17462
17468
  get getInvalid() {
17463
17469
  return this.errorModel.isError || this.invalid;
@@ -17476,15 +17482,15 @@ class FormulaEditorComponent {
17476
17482
  }
17477
17483
  writeValue(outsideValue) {
17478
17484
  if (outsideValue !== null) {
17479
- const { value, visibleValue } = this._transformValue(this._modifiedValue(outsideValue));
17485
+ const { visibleValue } = this._transformValue(this._modifiedValue(outsideValue));
17480
17486
  this.value = outsideValue;
17481
17487
  this.visibleValue = visibleValue;
17482
17488
  this._detector.detectChanges();
17483
17489
  }
17484
17490
  }
17485
17491
  onInput(event) {
17486
- const { value, searchText } = this._transformValue(this._modifiedValue(this._inputValue), false);
17487
- this.updateValue(value);
17492
+ const { searchText } = this._transformValue(this._modifiedValue(this._inputValue), false);
17493
+ // this.updateValue(value);
17488
17494
  this.searchText = searchText;
17489
17495
  this._storeCursorPosition();
17490
17496
  }
@@ -17520,10 +17526,7 @@ class FormulaEditorComponent {
17520
17526
  this.onTouched();
17521
17527
  }
17522
17528
  _modifiedValue(value) {
17523
- const labelsMap = Object.fromEntries(this.items.map(obj => [obj.label, obj.sysName]));
17524
- const str = this.items.map(s => s.label);
17525
- const reg = new RegExp(str.join('|'), 'g');
17526
- return value.replace(reg, match => `{${labelsMap[match]}}`);
17529
+ return value.replace(this._modifiedItemList.regExp, match => `{${this._modifiedItemList.items[match]}}`);
17527
17530
  }
17528
17531
  _transformValue(content, analise = false) {
17529
17532
  const valueArray = content.split(/[\s\u00A0]+/).filter(Boolean);
@@ -17533,16 +17536,16 @@ class FormulaEditorComponent {
17533
17536
  let searchText = '';
17534
17537
  valueArray.forEach((item) => {
17535
17538
  const clearedItem = item.trim();
17536
- const findItem = this.items.find(v => clearedItem.includes(v.sysName));
17539
+ const findItem = this._itemList.find(v => clearedItem.includes(v.sysName));
17537
17540
  if (findItem) {
17538
17541
  visibleValueArray.push(createTag(findItem.label));
17539
17542
  originalValueArray.push(createTagOutside(findItem.sysName));
17540
17543
  }
17541
- else if (this.bracketList.find(v => v === clearedItem)) {
17544
+ else if (this._bracketList.find(v => v === clearedItem)) {
17542
17545
  visibleValueArray.push(createBracket(clearedItem));
17543
17546
  originalValueArray.push(clearedItem);
17544
17547
  }
17545
- else if (this.operatorList.find(v => v === clearedItem)) {
17548
+ else if (this._operatorList.find(v => v === clearedItem)) {
17546
17549
  visibleValueArray.push(createOperator(clearedItem));
17547
17550
  originalValueArray.push(clearedItem);
17548
17551
  }
@@ -17560,8 +17563,6 @@ class FormulaEditorComponent {
17560
17563
  if (analise) {
17561
17564
  this._checkErrors(originalValueArray, isInterpretationError);
17562
17565
  }
17563
- console.log(visibleValueArray);
17564
- console.log(originalValueArray);
17565
17566
  return {
17566
17567
  value: originalValueArray.join(' '),
17567
17568
  visibleValue: visibleValueArray.join(' '),
@@ -17571,8 +17572,8 @@ class FormulaEditorComponent {
17571
17572
  _checkErrors(valueArray, isInterpretationError) {
17572
17573
  this._disableError();
17573
17574
  this._toggleError(checkBracketErrors(valueArray));
17574
- this._toggleError(checkDividerErrors(valueArray, this.items));
17575
- this._toggleError(checkSequenceErrors(valueArray, this.operatorList, this.bracketList));
17575
+ this._toggleError(checkDividerErrors(valueArray, this._itemList));
17576
+ this._toggleError(checkSequenceErrors(valueArray, this._operatorList, this._bracketList));
17576
17577
  this._toggleError(checkInterpretationErrors(isInterpretationError));
17577
17578
  }
17578
17579
  _toggleError(errorModel) {
@@ -17640,27 +17641,12 @@ class FormulaEditorComponent {
17640
17641
  });
17641
17642
  }
17642
17643
  clickOut(event) {
17643
- // console.dir(event);
17644
- // console.log(this._modifiedValue(this._inputValue));
17645
17644
  if (!this.eRef.nativeElement.contains(event.target)) {
17646
- const { value, visibleValue } = this._transformValue(this._modifiedValue(this._inputValue), true);
17647
- //
17648
- // this.updateValue(value);
17645
+ const { visibleValue } = this._transformValue(this._modifiedValue(this._inputValue), true);
17649
17646
  this.updateVisibleValue(visibleValue);
17650
- //
17651
17647
  this.isFocused = false;
17652
17648
  this._detector.detectChanges();
17653
17649
  }
17654
- // if (!this.eRef.nativeElement.contains(event.target)) {
17655
- // console.log(this._inputValue);
17656
- // const {value, visibleValue} = this._transformValue(this._inputValue, true);
17657
- //
17658
- // this.updateValue(value);
17659
- // this.updateVisibleValue(visibleValue);
17660
- //
17661
- // this.isFocused = false;
17662
- // this._detector.detectChanges();
17663
- // }
17664
17650
  }
17665
17651
  registerOnChange(fn) {
17666
17652
  this.onChange = fn;
@@ -17670,7 +17656,7 @@ class FormulaEditorComponent {
17670
17656
  }
17671
17657
  }
17672
17658
  FormulaEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaEditorComponent, deps: [{ token: DOCUMENT }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
17673
- FormulaEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: FormulaEditorComponent, selector: "mrx-formula-editor", inputs: { fields: "fields", items: "items", disabled: "disabled", readonly: "readonly", placeholder: "placeholder", customClasses: "customClasses", invalid: "invalid", invalidMessage: "invalidMessage", checkInvalid: "checkInvalid" }, outputs: { changed: "changed", blurred: "blurred", modelChange: "modelChange" }, host: { listeners: { "document:click": "clickOut($event)" } }, providers: [{
17659
+ FormulaEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: FormulaEditorComponent, selector: "mrx-formula-editor", inputs: { fields: "fields", disabled: "disabled", readonly: "readonly", placeholder: "placeholder", customClasses: "customClasses", invalid: "invalid", invalidMessage: "invalidMessage", checkInvalid: "checkInvalid", items: "items" }, outputs: { changed: "changed", blurred: "blurred", modelChange: "modelChange" }, host: { listeners: { "document:click": "clickOut($event)" } }, providers: [{
17674
17660
  provide: NG_VALUE_ACCESSOR,
17675
17661
  useExisting: forwardRef(() => FormulaEditorComponent),
17676
17662
  multi: true
@@ -17687,8 +17673,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
17687
17673
  args: [DOCUMENT]
17688
17674
  }] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }]; }, propDecorators: { fields: [{
17689
17675
  type: Input
17690
- }], items: [{
17691
- type: Input
17692
17676
  }], disabled: [{
17693
17677
  type: Input
17694
17678
  }], readonly: [{
@@ -17703,6 +17687,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
17703
17687
  type: Input
17704
17688
  }], checkInvalid: [{
17705
17689
  type: Input
17690
+ }], items: [{
17691
+ type: Input
17706
17692
  }], inputElement: [{
17707
17693
  type: ViewChild,
17708
17694
  args: ['inputElement', { static: true }]