myrta-ui 1.1.26 → 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.
- package/esm2020/lib/components/form/formula-editor/formula-editor.component.mjs +35 -30
- package/esm2020/lib/services/mrx-form-validator/validations/callback.validation.mjs +2 -2
- package/esm2020/lib/services/mrx-form-validator/validations/email.validation.mjs +1 -1
- package/esm2020/lib/services/mrx-form-validator/validations/max-length.validation.mjs +1 -1
- package/esm2020/lib/services/mrx-form-validator/validations/min-length.validation.mjs +2 -2
- package/esm2020/lib/services/mrx-form-validator/validations/pattern.validation.mjs +1 -1
- package/esm2020/lib/services/mrx-form-validator/validations/required.validation.mjs +4 -4
- package/fesm2015/myrta-ui.mjs +37 -32
- package/fesm2015/myrta-ui.mjs.map +1 -1
- package/fesm2020/myrta-ui.mjs +37 -32
- package/fesm2020/myrta-ui.mjs.map +1 -1
- package/lib/components/form/formula-editor/formula-editor.component.d.ts +7 -6
- package/lib/services/mrx-form-validator/validations/callback.validation.d.ts +1 -2
- package/lib/services/mrx-form-validator/validations/email.validation.d.ts +1 -2
- package/lib/services/mrx-form-validator/validations/max-length.validation.d.ts +1 -2
- package/lib/services/mrx-form-validator/validations/min-length.validation.d.ts +1 -2
- package/lib/services/mrx-form-validator/validations/pattern.validation.d.ts +1 -2
- package/lib/services/mrx-form-validator/validations/required.validation.d.ts +1 -2
- package/package.json +1 -1
package/fesm2020/myrta-ui.mjs
CHANGED
|
@@ -4256,7 +4256,7 @@ 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
|
-
if (Array.isArray(value) && validations.type !== 'single') {
|
|
4259
|
+
if (Array.isArray(value) && validations.type !== 'single' && validations[key]) {
|
|
4260
4260
|
value.forEach((field, idx) => {
|
|
4261
4261
|
if ((field === '' || field === null || field === undefined)) {
|
|
4262
4262
|
result.message = getErrorMessageHelper(key, invalidMessages, validations.messages);
|
|
@@ -4264,11 +4264,11 @@ const requiredValidation = (value, validations, key, invalidMessages) => {
|
|
|
4264
4264
|
}
|
|
4265
4265
|
});
|
|
4266
4266
|
}
|
|
4267
|
-
else if (Array.isArray(value) && validations.type === 'single' && value.length === 0) {
|
|
4267
|
+
else if (Array.isArray(value) && validations.type === 'single' && value.length === 0 && validations[key]) {
|
|
4268
4268
|
result.message = getErrorMessageHelper(key, invalidMessages, validations.messages);
|
|
4269
4269
|
result.isValid = false;
|
|
4270
4270
|
}
|
|
4271
|
-
else if (String(value) === '' || String(value) === 'false' || value === null || value === undefined || String(value) === '<p><br></p>') {
|
|
4271
|
+
else if ((String(value) === '' || String(value) === 'false' || value === null || value === undefined || String(value) === '<p><br></p>') && validations[key]) {
|
|
4272
4272
|
result.message = getErrorMessageHelper(key, invalidMessages, validations.messages);
|
|
4273
4273
|
result.isValid = false;
|
|
4274
4274
|
}
|
|
@@ -17420,8 +17420,13 @@ class FormulaEditorComponent {
|
|
|
17420
17420
|
endOffset: 0
|
|
17421
17421
|
};
|
|
17422
17422
|
this.searchText = '';
|
|
17423
|
-
this.
|
|
17424
|
-
this.
|
|
17423
|
+
this._operatorList = ['+', '-', '*', '/'];
|
|
17424
|
+
this._bracketList = ['(', ')'];
|
|
17425
|
+
this._itemList = [];
|
|
17426
|
+
this._modifiedItemList = {
|
|
17427
|
+
items: {},
|
|
17428
|
+
regExp: new RegExp(''),
|
|
17429
|
+
};
|
|
17425
17430
|
this.value = '';
|
|
17426
17431
|
this.visibleValue = '';
|
|
17427
17432
|
this.isFocused = false;
|
|
@@ -17432,8 +17437,6 @@ class FormulaEditorComponent {
|
|
|
17432
17437
|
// SAVE STATE
|
|
17433
17438
|
this.uuid = v4();
|
|
17434
17439
|
this.fields = [];
|
|
17435
|
-
// TODO items
|
|
17436
|
-
this.items = [];
|
|
17437
17440
|
this.disabled = false;
|
|
17438
17441
|
this.readonly = false;
|
|
17439
17442
|
this.placeholder = '';
|
|
@@ -17450,11 +17453,17 @@ class FormulaEditorComponent {
|
|
|
17450
17453
|
this.onTouched = () => {
|
|
17451
17454
|
};
|
|
17452
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
|
+
}
|
|
17453
17462
|
get getErrorMessage() {
|
|
17454
17463
|
return this.invalidMessage || ErrorMessagesEnum[this.errorModel.errorType];
|
|
17455
17464
|
}
|
|
17456
17465
|
get filteredList() {
|
|
17457
|
-
return this.
|
|
17466
|
+
return this._itemList.filter(item => item.label.includes(this.searchText));
|
|
17458
17467
|
}
|
|
17459
17468
|
get getInvalid() {
|
|
17460
17469
|
return this.errorModel.isError || this.invalid;
|
|
@@ -17473,14 +17482,15 @@ class FormulaEditorComponent {
|
|
|
17473
17482
|
}
|
|
17474
17483
|
writeValue(outsideValue) {
|
|
17475
17484
|
if (outsideValue !== null) {
|
|
17485
|
+
const { visibleValue } = this._transformValue(this._modifiedValue(outsideValue));
|
|
17476
17486
|
this.value = outsideValue;
|
|
17477
|
-
this.visibleValue =
|
|
17487
|
+
this.visibleValue = visibleValue;
|
|
17478
17488
|
this._detector.detectChanges();
|
|
17479
17489
|
}
|
|
17480
17490
|
}
|
|
17481
17491
|
onInput(event) {
|
|
17482
|
-
const {
|
|
17483
|
-
this.updateValue(value);
|
|
17492
|
+
const { searchText } = this._transformValue(this._modifiedValue(this._inputValue), false);
|
|
17493
|
+
// this.updateValue(value);
|
|
17484
17494
|
this.searchText = searchText;
|
|
17485
17495
|
this._storeCursorPosition();
|
|
17486
17496
|
}
|
|
@@ -17494,9 +17504,9 @@ class FormulaEditorComponent {
|
|
|
17494
17504
|
}
|
|
17495
17505
|
insertTag(whiteListItem) {
|
|
17496
17506
|
this._restoreCursorPosition(this.inputElement.nativeElement);
|
|
17497
|
-
this._insertPositionText(whiteListItem.
|
|
17507
|
+
this._insertPositionText(`{${whiteListItem.sysName}}`);
|
|
17498
17508
|
setTimeout(() => {
|
|
17499
|
-
const { value, visibleValue } = this._transformValue(this._inputValue, false);
|
|
17509
|
+
const { value, visibleValue } = this._transformValue(this._modifiedValue(this._inputValue), false);
|
|
17500
17510
|
this.updateValue(value);
|
|
17501
17511
|
this.updateVisibleValue(visibleValue);
|
|
17502
17512
|
});
|
|
@@ -17516,30 +17526,26 @@ class FormulaEditorComponent {
|
|
|
17516
17526
|
this.onTouched();
|
|
17517
17527
|
}
|
|
17518
17528
|
_modifiedValue(value) {
|
|
17519
|
-
|
|
17520
|
-
return clearedValue.map(v => {
|
|
17521
|
-
const findItem = this.items.find(w => `{${w.sysName}}` === v);
|
|
17522
|
-
return findItem ? findItem.label : v;
|
|
17523
|
-
}).join(' ');
|
|
17529
|
+
return value.replace(this._modifiedItemList.regExp, match => `{${this._modifiedItemList.items[match]}}`);
|
|
17524
17530
|
}
|
|
17525
17531
|
_transformValue(content, analise = false) {
|
|
17526
|
-
const valueArray = content.split(/[\s\u00A0]+/).filter(
|
|
17532
|
+
const valueArray = content.split(/[\s\u00A0]+/).filter(Boolean);
|
|
17527
17533
|
const visibleValueArray = [];
|
|
17528
17534
|
const originalValueArray = [];
|
|
17529
17535
|
let isInterpretationError = false;
|
|
17530
17536
|
let searchText = '';
|
|
17531
17537
|
valueArray.forEach((item) => {
|
|
17532
17538
|
const clearedItem = item.trim();
|
|
17533
|
-
const findItem = this.
|
|
17539
|
+
const findItem = this._itemList.find(v => clearedItem.includes(v.sysName));
|
|
17534
17540
|
if (findItem) {
|
|
17535
17541
|
visibleValueArray.push(createTag(findItem.label));
|
|
17536
17542
|
originalValueArray.push(createTagOutside(findItem.sysName));
|
|
17537
17543
|
}
|
|
17538
|
-
else if (this.
|
|
17544
|
+
else if (this._bracketList.find(v => v === clearedItem)) {
|
|
17539
17545
|
visibleValueArray.push(createBracket(clearedItem));
|
|
17540
17546
|
originalValueArray.push(clearedItem);
|
|
17541
17547
|
}
|
|
17542
|
-
else if (this.
|
|
17548
|
+
else if (this._operatorList.find(v => v === clearedItem)) {
|
|
17543
17549
|
visibleValueArray.push(createOperator(clearedItem));
|
|
17544
17550
|
originalValueArray.push(clearedItem);
|
|
17545
17551
|
}
|
|
@@ -17566,8 +17572,8 @@ class FormulaEditorComponent {
|
|
|
17566
17572
|
_checkErrors(valueArray, isInterpretationError) {
|
|
17567
17573
|
this._disableError();
|
|
17568
17574
|
this._toggleError(checkBracketErrors(valueArray));
|
|
17569
|
-
this._toggleError(checkDividerErrors(valueArray, this.
|
|
17570
|
-
this._toggleError(checkSequenceErrors(valueArray, this.
|
|
17575
|
+
this._toggleError(checkDividerErrors(valueArray, this._itemList));
|
|
17576
|
+
this._toggleError(checkSequenceErrors(valueArray, this._operatorList, this._bracketList));
|
|
17571
17577
|
this._toggleError(checkInterpretationErrors(isInterpretationError));
|
|
17572
17578
|
}
|
|
17573
17579
|
_toggleError(errorModel) {
|
|
@@ -17616,9 +17622,9 @@ class FormulaEditorComponent {
|
|
|
17616
17622
|
}
|
|
17617
17623
|
this._selection = document.getSelection();
|
|
17618
17624
|
if (this._selection) {
|
|
17619
|
-
this._selection.removeAllRanges();
|
|
17620
|
-
this._selection.addRange(this._range);
|
|
17621
|
-
element.focus();
|
|
17625
|
+
// this._selection.removeAllRanges();
|
|
17626
|
+
// this._selection.addRange(this._range);
|
|
17627
|
+
// element.focus();
|
|
17622
17628
|
}
|
|
17623
17629
|
}
|
|
17624
17630
|
_placeCaretAtEnd() {
|
|
@@ -17636,8 +17642,7 @@ class FormulaEditorComponent {
|
|
|
17636
17642
|
}
|
|
17637
17643
|
clickOut(event) {
|
|
17638
17644
|
if (!this.eRef.nativeElement.contains(event.target)) {
|
|
17639
|
-
const {
|
|
17640
|
-
this.updateValue(value);
|
|
17645
|
+
const { visibleValue } = this._transformValue(this._modifiedValue(this._inputValue), true);
|
|
17641
17646
|
this.updateVisibleValue(visibleValue);
|
|
17642
17647
|
this.isFocused = false;
|
|
17643
17648
|
this._detector.detectChanges();
|
|
@@ -17651,7 +17656,7 @@ class FormulaEditorComponent {
|
|
|
17651
17656
|
}
|
|
17652
17657
|
}
|
|
17653
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 });
|
|
17654
|
-
FormulaEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: FormulaEditorComponent, selector: "mrx-formula-editor", inputs: { fields: "fields",
|
|
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: [{
|
|
17655
17660
|
provide: NG_VALUE_ACCESSOR,
|
|
17656
17661
|
useExisting: forwardRef(() => FormulaEditorComponent),
|
|
17657
17662
|
multi: true
|
|
@@ -17668,8 +17673,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
|
|
|
17668
17673
|
args: [DOCUMENT]
|
|
17669
17674
|
}] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }]; }, propDecorators: { fields: [{
|
|
17670
17675
|
type: Input
|
|
17671
|
-
}], items: [{
|
|
17672
|
-
type: Input
|
|
17673
17676
|
}], disabled: [{
|
|
17674
17677
|
type: Input
|
|
17675
17678
|
}], readonly: [{
|
|
@@ -17684,6 +17687,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
|
|
|
17684
17687
|
type: Input
|
|
17685
17688
|
}], checkInvalid: [{
|
|
17686
17689
|
type: Input
|
|
17690
|
+
}], items: [{
|
|
17691
|
+
type: Input
|
|
17687
17692
|
}], inputElement: [{
|
|
17688
17693
|
type: ViewChild,
|
|
17689
17694
|
args: ['inputElement', { static: true }]
|