myrta-ui 1.1.25 → 1.1.27
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 +33 -17
- package/esm2020/lib/services/mrx-form-validator/mrx-form-validator.mjs +1 -1
- package/esm2020/lib/services/mrx-form-validator/validations/max-value.validation.mjs +2 -2
- package/esm2020/lib/services/mrx-form-validator/validations/min-value.validation.mjs +2 -2
- package/esm2020/lib/services/mrx-form-validator/validations/required.validation.mjs +7 -4
- package/fesm2015/myrta-ui.mjs +40 -21
- package/fesm2015/myrta-ui.mjs.map +1 -1
- package/fesm2020/myrta-ui.mjs +40 -21
- package/fesm2020/myrta-ui.mjs.map +1 -1
- package/lib/services/mrx-form-validator/validations/max-value.validation.d.ts +1 -2
- package/lib/services/mrx-form-validator/validations/min-value.validation.d.ts +1 -2
- package/package.json +1 -1
package/fesm2020/myrta-ui.mjs
CHANGED
|
@@ -4256,7 +4256,10 @@ 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
|
-
|
|
4259
|
+
console.log(validations);
|
|
4260
|
+
console.log(key);
|
|
4261
|
+
console.log();
|
|
4262
|
+
if (Array.isArray(value) && validations.type !== 'single' && validations[key]) {
|
|
4260
4263
|
value.forEach((field, idx) => {
|
|
4261
4264
|
if ((field === '' || field === null || field === undefined)) {
|
|
4262
4265
|
result.message = getErrorMessageHelper(key, invalidMessages, validations.messages);
|
|
@@ -4264,11 +4267,11 @@ const requiredValidation = (value, validations, key, invalidMessages) => {
|
|
|
4264
4267
|
}
|
|
4265
4268
|
});
|
|
4266
4269
|
}
|
|
4267
|
-
else if (Array.isArray(value) && validations.type === 'single' && value.length === 0) {
|
|
4270
|
+
else if (Array.isArray(value) && validations.type === 'single' && value.length === 0 && validations[key]) {
|
|
4268
4271
|
result.message = getErrorMessageHelper(key, invalidMessages, validations.messages);
|
|
4269
4272
|
result.isValid = false;
|
|
4270
4273
|
}
|
|
4271
|
-
else if (String(value) === '' || String(value) === 'false' || value === null || value === undefined || String(value) === '<p><br></p>') {
|
|
4274
|
+
else if ((String(value) === '' || String(value) === 'false' || value === null || value === undefined || String(value) === '<p><br></p>') && validations[key]) {
|
|
4272
4275
|
result.message = getErrorMessageHelper(key, invalidMessages, validations.messages);
|
|
4273
4276
|
result.isValid = false;
|
|
4274
4277
|
}
|
|
@@ -4315,7 +4318,7 @@ const minLengthValidation = (value, validations, key, invalidMessages) => {
|
|
|
4315
4318
|
|
|
4316
4319
|
const minValueValidation = (value, validations, key, invalidMessages) => {
|
|
4317
4320
|
const result = { isValid: true, message: null };
|
|
4318
|
-
if (parseInt(value)
|
|
4321
|
+
if (parseInt(value) < Number(validations[key])) {
|
|
4319
4322
|
result.message = getErrorMessageHelper(key, invalidMessages, validations.messages, Number(validations[key]));
|
|
4320
4323
|
result.isValid = false;
|
|
4321
4324
|
}
|
|
@@ -4324,7 +4327,7 @@ const minValueValidation = (value, validations, key, invalidMessages) => {
|
|
|
4324
4327
|
|
|
4325
4328
|
const maxValueValidation = (value, validations, key, invalidMessages) => {
|
|
4326
4329
|
const result = { isValid: true, message: null };
|
|
4327
|
-
if (parseInt(value)
|
|
4330
|
+
if (parseInt(value) > Number(validations[key])) {
|
|
4328
4331
|
result.message = getErrorMessageHelper(key, invalidMessages, validations.messages, Number(validations[key]));
|
|
4329
4332
|
result.isValid = false;
|
|
4330
4333
|
}
|
|
@@ -17473,13 +17476,14 @@ class FormulaEditorComponent {
|
|
|
17473
17476
|
}
|
|
17474
17477
|
writeValue(outsideValue) {
|
|
17475
17478
|
if (outsideValue !== null) {
|
|
17479
|
+
const { value, visibleValue } = this._transformValue(this._modifiedValue(outsideValue));
|
|
17476
17480
|
this.value = outsideValue;
|
|
17477
|
-
this.visibleValue =
|
|
17481
|
+
this.visibleValue = visibleValue;
|
|
17478
17482
|
this._detector.detectChanges();
|
|
17479
17483
|
}
|
|
17480
17484
|
}
|
|
17481
17485
|
onInput(event) {
|
|
17482
|
-
const { value, searchText } = this._transformValue(this._inputValue, false);
|
|
17486
|
+
const { value, searchText } = this._transformValue(this._modifiedValue(this._inputValue), false);
|
|
17483
17487
|
this.updateValue(value);
|
|
17484
17488
|
this.searchText = searchText;
|
|
17485
17489
|
this._storeCursorPosition();
|
|
@@ -17494,9 +17498,9 @@ class FormulaEditorComponent {
|
|
|
17494
17498
|
}
|
|
17495
17499
|
insertTag(whiteListItem) {
|
|
17496
17500
|
this._restoreCursorPosition(this.inputElement.nativeElement);
|
|
17497
|
-
this._insertPositionText(whiteListItem.
|
|
17501
|
+
this._insertPositionText(`{${whiteListItem.sysName}}`);
|
|
17498
17502
|
setTimeout(() => {
|
|
17499
|
-
const { value, visibleValue } = this._transformValue(this._inputValue, false);
|
|
17503
|
+
const { value, visibleValue } = this._transformValue(this._modifiedValue(this._inputValue), false);
|
|
17500
17504
|
this.updateValue(value);
|
|
17501
17505
|
this.updateVisibleValue(visibleValue);
|
|
17502
17506
|
});
|
|
@@ -17516,21 +17520,20 @@ class FormulaEditorComponent {
|
|
|
17516
17520
|
this.onTouched();
|
|
17517
17521
|
}
|
|
17518
17522
|
_modifiedValue(value) {
|
|
17519
|
-
const
|
|
17520
|
-
|
|
17521
|
-
|
|
17522
|
-
|
|
17523
|
-
}).join(' ');
|
|
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]}}`);
|
|
17524
17527
|
}
|
|
17525
17528
|
_transformValue(content, analise = false) {
|
|
17526
|
-
const valueArray = content.split(/[\s\u00A0]+/).filter(
|
|
17529
|
+
const valueArray = content.split(/[\s\u00A0]+/).filter(Boolean);
|
|
17527
17530
|
const visibleValueArray = [];
|
|
17528
17531
|
const originalValueArray = [];
|
|
17529
17532
|
let isInterpretationError = false;
|
|
17530
17533
|
let searchText = '';
|
|
17531
17534
|
valueArray.forEach((item) => {
|
|
17532
17535
|
const clearedItem = item.trim();
|
|
17533
|
-
const findItem = this.items.find(v => clearedItem.includes(v.
|
|
17536
|
+
const findItem = this.items.find(v => clearedItem.includes(v.sysName));
|
|
17534
17537
|
if (findItem) {
|
|
17535
17538
|
visibleValueArray.push(createTag(findItem.label));
|
|
17536
17539
|
originalValueArray.push(createTagOutside(findItem.sysName));
|
|
@@ -17557,6 +17560,8 @@ class FormulaEditorComponent {
|
|
|
17557
17560
|
if (analise) {
|
|
17558
17561
|
this._checkErrors(originalValueArray, isInterpretationError);
|
|
17559
17562
|
}
|
|
17563
|
+
console.log(visibleValueArray);
|
|
17564
|
+
console.log(originalValueArray);
|
|
17560
17565
|
return {
|
|
17561
17566
|
value: originalValueArray.join(' '),
|
|
17562
17567
|
visibleValue: visibleValueArray.join(' '),
|
|
@@ -17616,9 +17621,9 @@ class FormulaEditorComponent {
|
|
|
17616
17621
|
}
|
|
17617
17622
|
this._selection = document.getSelection();
|
|
17618
17623
|
if (this._selection) {
|
|
17619
|
-
this._selection.removeAllRanges();
|
|
17620
|
-
this._selection.addRange(this._range);
|
|
17621
|
-
element.focus();
|
|
17624
|
+
// this._selection.removeAllRanges();
|
|
17625
|
+
// this._selection.addRange(this._range);
|
|
17626
|
+
// element.focus();
|
|
17622
17627
|
}
|
|
17623
17628
|
}
|
|
17624
17629
|
_placeCaretAtEnd() {
|
|
@@ -17635,13 +17640,27 @@ class FormulaEditorComponent {
|
|
|
17635
17640
|
});
|
|
17636
17641
|
}
|
|
17637
17642
|
clickOut(event) {
|
|
17643
|
+
// console.dir(event);
|
|
17644
|
+
// console.log(this._modifiedValue(this._inputValue));
|
|
17638
17645
|
if (!this.eRef.nativeElement.contains(event.target)) {
|
|
17639
|
-
const { value, visibleValue } = this._transformValue(this._inputValue, true);
|
|
17640
|
-
|
|
17646
|
+
const { value, visibleValue } = this._transformValue(this._modifiedValue(this._inputValue), true);
|
|
17647
|
+
//
|
|
17648
|
+
// this.updateValue(value);
|
|
17641
17649
|
this.updateVisibleValue(visibleValue);
|
|
17650
|
+
//
|
|
17642
17651
|
this.isFocused = false;
|
|
17643
17652
|
this._detector.detectChanges();
|
|
17644
17653
|
}
|
|
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
|
+
// }
|
|
17645
17664
|
}
|
|
17646
17665
|
registerOnChange(fn) {
|
|
17647
17666
|
this.onChange = fn;
|