@metadev/lux 0.17.0 → 0.18.0
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/bundles/metadev-lux.umd.js +73 -5
- package/bundles/metadev-lux.umd.js.map +1 -1
- package/esm2015/lib/helperFns.js +17 -1
- package/esm2015/lib/input/input.component.js +55 -7
- package/fesm2015/metadev-lux.js +69 -5
- package/fesm2015/metadev-lux.js.map +1 -1
- package/lib/helperFns.d.ts +2 -0
- package/lib/input/input.component.d.ts +12 -0
- package/metadev-lux.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -35,6 +35,22 @@
|
|
|
35
35
|
var re = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
36
36
|
return re.test(String(value).toLowerCase().trim());
|
|
37
37
|
};
|
|
38
|
+
var isValidUrl = function (value) {
|
|
39
|
+
var re = /^([a-z]+?:\/\/)?((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3}))(\:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=-]*)?(\#[-a-z\d_]*)?$/i;
|
|
40
|
+
return re.test(String(value).toLowerCase().trim());
|
|
41
|
+
};
|
|
42
|
+
var isValidColor = function (value) {
|
|
43
|
+
value = String(value).toLowerCase();
|
|
44
|
+
// valid values for CSS color property, yet not valid colors by themselves
|
|
45
|
+
if (value === 'currentcolor' ||
|
|
46
|
+
value === 'inherit' ||
|
|
47
|
+
value === 'initial' ||
|
|
48
|
+
value === 'revert' ||
|
|
49
|
+
value === 'unset') {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return CSS.supports('color', value);
|
|
53
|
+
};
|
|
38
54
|
// date functions
|
|
39
55
|
var isValidDate = function (date) { return exists(date) ? !isNaN(date.getTime()) : false; };
|
|
40
56
|
var normalizeDate = function (value) {
|
|
@@ -1490,13 +1506,17 @@
|
|
|
1490
1506
|
required: 'Required field.',
|
|
1491
1507
|
min: 'Minimum value is $min.',
|
|
1492
1508
|
max: 'Maximum value is $max.',
|
|
1493
|
-
email: 'Format should match example@example.com.'
|
|
1509
|
+
email: 'Format should match example@example.com.',
|
|
1510
|
+
url: 'Format should match https://example.com.',
|
|
1511
|
+
color: 'Format should match #XXXXXX.'
|
|
1494
1512
|
},
|
|
1495
1513
|
es: {
|
|
1496
1514
|
required: 'El campo es obligatorio.',
|
|
1497
1515
|
min: 'El valor mínimo es $min.',
|
|
1498
1516
|
max: 'El valor máximo es $max.',
|
|
1499
|
-
email: 'El campo debe tener un formato como ejemplo@ejemplo.com.'
|
|
1517
|
+
email: 'El campo debe tener un formato como ejemplo@ejemplo.com.',
|
|
1518
|
+
url: 'El campo debe tener un formato como https://ejemplo.com.',
|
|
1519
|
+
color: 'El campo debe tener un formato como #XXXXXX.'
|
|
1500
1520
|
}
|
|
1501
1521
|
};
|
|
1502
1522
|
this.lang = languageDetector();
|
|
@@ -1514,6 +1534,13 @@
|
|
|
1514
1534
|
enumerable: false,
|
|
1515
1535
|
configurable: true
|
|
1516
1536
|
});
|
|
1537
|
+
Object.defineProperty(InputComponent.prototype, "color", {
|
|
1538
|
+
get: function () {
|
|
1539
|
+
return this.checkColor();
|
|
1540
|
+
},
|
|
1541
|
+
enumerable: false,
|
|
1542
|
+
configurable: true
|
|
1543
|
+
});
|
|
1517
1544
|
Object.defineProperty(InputComponent.prototype, "disabled", {
|
|
1518
1545
|
get: function () {
|
|
1519
1546
|
return this._disabled;
|
|
@@ -1669,6 +1696,14 @@
|
|
|
1669
1696
|
result = result || {};
|
|
1670
1697
|
result.email = { value: value, reason: 'Invalid email.' };
|
|
1671
1698
|
}
|
|
1699
|
+
if (this.type === 'url' && hasValue(value) && !isValidUrl(value)) {
|
|
1700
|
+
result = result || {};
|
|
1701
|
+
result.url = { value: value, reason: 'Invalid URL.' };
|
|
1702
|
+
}
|
|
1703
|
+
if (this.type === 'color' && hasValue(value) && !isValidColor(value)) {
|
|
1704
|
+
result = result || {};
|
|
1705
|
+
result.color = { value: value, reason: 'Invalid color.' };
|
|
1706
|
+
}
|
|
1672
1707
|
if (this.type === 'number' && hasValue(value) && !isValidNumber(value)) {
|
|
1673
1708
|
result = result || {};
|
|
1674
1709
|
result.numeric = { value: value, reason: 'Invalid number.' };
|
|
@@ -1735,11 +1770,24 @@
|
|
|
1735
1770
|
};
|
|
1736
1771
|
InputComponent.prototype.onChangeValue = function (newValue) {
|
|
1737
1772
|
this.value = newValue;
|
|
1773
|
+
if (this.isColor()) {
|
|
1774
|
+
this.colorpicker.nativeElement.value = undefined;
|
|
1775
|
+
}
|
|
1738
1776
|
this.markAsTouched();
|
|
1739
1777
|
};
|
|
1740
1778
|
InputComponent.prototype.onKeyPress = function (event) {
|
|
1741
1779
|
this.keyPress.emit(event);
|
|
1742
1780
|
};
|
|
1781
|
+
InputComponent.prototype.onColorPicked = function (newValue) {
|
|
1782
|
+
this.onChangeValue(newValue);
|
|
1783
|
+
this.setValueInControl(newValue);
|
|
1784
|
+
};
|
|
1785
|
+
InputComponent.prototype.isUrl = function () {
|
|
1786
|
+
return this.type === 'url';
|
|
1787
|
+
};
|
|
1788
|
+
InputComponent.prototype.isColor = function () {
|
|
1789
|
+
return this.type === 'color';
|
|
1790
|
+
};
|
|
1743
1791
|
InputComponent.prototype.isNumber = function () {
|
|
1744
1792
|
return this.type === 'number';
|
|
1745
1793
|
};
|
|
@@ -1753,7 +1801,11 @@
|
|
|
1753
1801
|
return this.currency === 'USD';
|
|
1754
1802
|
};
|
|
1755
1803
|
InputComponent.prototype.hasPostfix = function () {
|
|
1756
|
-
return (this.currency === 'EUR' ||
|
|
1804
|
+
return (this.currency === 'EUR' ||
|
|
1805
|
+
this.isPercentage() ||
|
|
1806
|
+
this.isPermillage() ||
|
|
1807
|
+
(this.isUrl() && !!this.value) ||
|
|
1808
|
+
this.isColor());
|
|
1757
1809
|
};
|
|
1758
1810
|
InputComponent.prototype.checkClassName = function () {
|
|
1759
1811
|
return this.disabled
|
|
@@ -1764,11 +1816,22 @@
|
|
|
1764
1816
|
? 'readonly'
|
|
1765
1817
|
: '';
|
|
1766
1818
|
};
|
|
1819
|
+
InputComponent.prototype.checkColor = function () {
|
|
1820
|
+
return this.type === 'color' && isValidColor(this.value)
|
|
1821
|
+
? this.value
|
|
1822
|
+
: 'initial';
|
|
1823
|
+
};
|
|
1767
1824
|
InputComponent.prototype.checkType = function (type) {
|
|
1768
1825
|
switch (type) {
|
|
1769
1826
|
case 'email':
|
|
1770
1827
|
this.setEmailPatterns();
|
|
1771
1828
|
break;
|
|
1829
|
+
case 'url':
|
|
1830
|
+
this.setUrlPatterns();
|
|
1831
|
+
break;
|
|
1832
|
+
case 'color':
|
|
1833
|
+
this.setColorPatterns();
|
|
1834
|
+
break;
|
|
1772
1835
|
case 'date':
|
|
1773
1836
|
this.setDatePatterns();
|
|
1774
1837
|
break;
|
|
@@ -1795,6 +1858,10 @@
|
|
|
1795
1858
|
}
|
|
1796
1859
|
};
|
|
1797
1860
|
InputComponent.prototype.setEmailPatterns = function () { };
|
|
1861
|
+
InputComponent.prototype.setUrlPatterns = function () { };
|
|
1862
|
+
InputComponent.prototype.setColorPatterns = function () {
|
|
1863
|
+
this.domain = 'text';
|
|
1864
|
+
};
|
|
1798
1865
|
InputComponent.prototype.setDatePatterns = function () {
|
|
1799
1866
|
this.min = this.min || '1900-01-01';
|
|
1800
1867
|
this.max = this.max || '2100-01-01';
|
|
@@ -1832,7 +1899,7 @@
|
|
|
1832
1899
|
InputComponent.decorators = [
|
|
1833
1900
|
{ type: i0.Component, args: [{
|
|
1834
1901
|
selector: 'lux-input',
|
|
1835
|
-
template: "<div *ngIf=\"currency && currency === 'USD'\" class=\"prefix rounded-left symbol\" [ngClass]=\"className\">\n <span>$</span>\n</div>\n<input\n #input\n *ngIf=\"type !== 'textarea'\"\n [class]=\"hasPrefix() ? (hasPostfix() ? 'infix' : 'postfix rounded-right') : (hasPostfix() ? 'prefix rounded-left' : 'rounded')\"\n [ngClass]=\"className\"\n placement=\"top\"\n [id]=\"inputId\"\n [type]=\"domain\"\n [attr.value]=\"value\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.disabled]=\"disabled === true ? 'true' : undefined\"\n [attr.readonly]=\"readonly === true ? 'true' : undefined\"\n [attr.min]=\"min?.toString() || undefined\"\n [attr.max]=\"max?.toString() || undefined\"\n [attr.step]=\"step?.toString() || undefined\"\n [attr.pattern]=\"pattern || undefined\"\n [placeholder]=\"placeholder\"\n (keyup)=\"onKeyUp(input.value)\"\n (change)=\"onChangeValue(input.value)\"\n (keypress)=\"onKeyPress($event)\"\n (blur)=\"onLostFocus()\"\n/>\n<textarea\n #textarea\n *ngIf=\"type === 'textarea'\"\n class=\"rounded\"\n [ngClass]=\"className\"\n placement=\"top\"\n [id]=\"inputId\"\n [attr.value]=\"value\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.disabled]=\"disabled === true ? 'true' : undefined\"\n [attr.readonly]=\"readonly === true ? 'true' : undefined\"\n [attr.cols]=\"cols?.toString() || undefined\"\n [attr.rows]=\"rows?.toString() || undefined\"\n [placeholder]=\"placeholder\"\n (keyup)=\"onKeyUp(textarea.value)\"\n (change)=\"onChangeValue(textarea.value)\"\n (keypress)=\"onKeyPress($event)\"\n (blur)=\"onLostFocus()\"\n></textarea>\n<div *ngIf=\"currency && currency === 'EUR'\" class=\"postfix rounded-right symbol\" [ngClass]=\"className\">\n <span>\u20AC</span>\n</div>\n<div *ngIf=\"isPercentage()\" class=\"postfix rounded-right symbol\" [ngClass]=\"className\">\n <span>%</span>\n</div>\n<div *ngIf=\"isPermillage()\" class=\"postfix rounded-right symbol\" [ngClass]=\"className\">\n <span>\u2030</span>\n</div>\n\n<div *ngIf=\"inlineErrors && lastErrors && (dirty || touched)\" class=\"alert\">\n <div *ngIf=\"lastErrors.required\">\n {{ userErrors[this.lang].required }}\n </div>\n <div *ngIf=\"lastErrors.email\">{{ userErrors[this.lang].email }}</div>\n <div *ngIf=\"lastErrors.min\">\n {{ userErrors[this.lang].min.replace('$min', lastErrors.min.min) }}\n </div>\n <div *ngIf=\"lastErrors.max\">\n {{ userErrors[this.lang].max.replace('$max', lastErrors.max.max) }}\n </div>\n</div>\n",
|
|
1902
|
+
template: "<div *ngIf=\"currency && currency === 'USD'\" class=\"prefix rounded-left symbol\" [ngClass]=\"className\">\n <span>$</span>\n</div>\n<input\n #input\n *ngIf=\"type !== 'textarea'\"\n [class]=\"hasPrefix() ? (hasPostfix() ? 'infix' : 'postfix rounded-right') : (hasPostfix() ? 'prefix rounded-left' : 'rounded')\"\n [ngClass]=\"className\"\n placement=\"top\"\n [id]=\"inputId\"\n [type]=\"domain\"\n [attr.value]=\"value\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.disabled]=\"disabled === true ? 'true' : undefined\"\n [attr.readonly]=\"readonly === true ? 'true' : undefined\"\n [attr.min]=\"min?.toString() || undefined\"\n [attr.max]=\"max?.toString() || undefined\"\n [attr.step]=\"step?.toString() || undefined\"\n [attr.pattern]=\"pattern || undefined\"\n [placeholder]=\"placeholder\"\n (keyup)=\"onKeyUp(input.value)\"\n (change)=\"onChangeValue(input.value)\"\n (keypress)=\"onKeyPress($event)\"\n (blur)=\"onLostFocus()\"\n/>\n<textarea\n #textarea\n *ngIf=\"type === 'textarea'\"\n class=\"rounded\"\n [ngClass]=\"className\"\n placement=\"top\"\n [id]=\"inputId\"\n [attr.value]=\"value\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.disabled]=\"disabled === true ? 'true' : undefined\"\n [attr.readonly]=\"readonly === true ? 'true' : undefined\"\n [attr.cols]=\"cols?.toString() || undefined\"\n [attr.rows]=\"rows?.toString() || undefined\"\n [placeholder]=\"placeholder\"\n (keyup)=\"onKeyUp(textarea.value)\"\n (change)=\"onChangeValue(textarea.value)\"\n (keypress)=\"onKeyPress($event)\"\n (blur)=\"onLostFocus()\"\n></textarea>\n<div *ngIf=\"currency && currency === 'EUR'\" class=\"postfix rounded-right symbol\" [ngClass]=\"className\">\n <span>\u20AC</span>\n</div>\n<div *ngIf=\"isPercentage()\" class=\"postfix rounded-right symbol\" [ngClass]=\"className\">\n <span>%</span>\n</div>\n<div *ngIf=\"isPermillage()\" class=\"postfix rounded-right symbol\" [ngClass]=\"className\">\n <span>\u2030</span>\n</div>\n<div *ngIf=\"isUrl() && !!value\" class=\"postfix rounded-right symbol clickable\" [ngClass]=\"className\">\n <a href=\"{{ value }}\" target=\"_blank\">\n <span class=\"icon-external\"></span>\n </a>\n</div>\n<div *ngIf=\"isColor()\" class=\"postfix rounded-right bordered transparency\" [ngClass]=\"className\">\n <div class=\"rounded-right full-space\" [ngStyle]=\"{'background-color': color}\">\n <input\n #colorpicker\n class=\"minimal-space clickable invisible rounded-right full-space\"\n [id]=\"inputId + '$colorpicker'\"\n type=\"color\"\n [attr.value]=\"value\"\n [attr.disabled]=\"disabled === true ? 'true' : undefined\"\n [attr.readonly]=\"readonly === true ? 'true' : undefined\"\n (change)=\"onColorPicked(colorpicker.value)\"\n (keypress)=\"onKeyPress($event)\"\n (blur)=\"onLostFocus()\"\n />\n </div>\n</div>\n\n<div *ngIf=\"inlineErrors && lastErrors && (dirty || touched)\" class=\"alert\">\n <div *ngIf=\"lastErrors.required\">\n {{ userErrors[this.lang].required }}\n </div>\n <div *ngIf=\"lastErrors.email\">{{ userErrors[this.lang].email }}</div>\n <div *ngIf=\"lastErrors.url\">{{ userErrors[this.lang].url }}</div>\n <div *ngIf=\"lastErrors.min\">\n {{ userErrors[this.lang].min.replace('$min', lastErrors.min.min) }}\n </div>\n <div *ngIf=\"lastErrors.max\">\n {{ userErrors[this.lang].max.replace('$max', lastErrors.max.max) }}\n </div>\n</div>\n",
|
|
1836
1903
|
providers: [
|
|
1837
1904
|
{
|
|
1838
1905
|
provide: forms.NG_VALUE_ACCESSOR,
|
|
@@ -1845,7 +1912,7 @@
|
|
|
1845
1912
|
useExisting: i0.forwardRef(function () { return InputComponent; })
|
|
1846
1913
|
}
|
|
1847
1914
|
],
|
|
1848
|
-
styles: [":focus{z-index:1}input,select,textarea{border:1px solid #495057;border:var(--lux-input-border, 1px solid) var(--lux-input-border-color, #495057);margin:0;margin:var(--lux-input-margin, 0rem);padding:0 .5rem;padding:var(--lux-input-padding, 0rem .5rem)}.alert{padding:.2rem 2rem;background:#fe2e2e;background:var(--lux-alert-background, #fe2e2e);color:#fff;color:var(--lux-alert-color, white);font-family:Consolas,monospace;width:45%;margin-right:1rem;display:inline-block}.symbol{display:inline-block;align-items:baseline;padding:0 .5rem;margin-bottom:0;font-weight:400;color:default;color:var(--lux-symbol-color, default);text-align:center;white-space:nowrap;background:default;background:var(--lux-symbol-background, default);font-size:1rem;font-size:var(--lux-symbol-font-size, 1rem)}.bordered,.symbol{border:1px solid #495057;border:var(--lux-input-border, 1px solid) var(--lux-input-border-color, #495057)}.rounded,.rounded-right,.rounded-middle,.rounded-left{border-radius:.25rem;border-radius:var(--lux-border-radius, .25rem)}.rounded-left{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-middle{border-radius:0}.rounded-right{border-top-left-radius:0;border-bottom-left-radius:0}.prefix{border-right:none}.infix{border-left:none;border-right:none}.postfix{border-left:none;display:flex;align-items:center}:host{display:flex;align-items:stretch}.readonly{border:none}.readonly:focus{border:none;outline:none}.disabled{background-color:#f1f1f1;background-color:var(--lux-disabled-color, #f1f1f1);border-color:#6d6d6d;border-color:var(--lux-disabled-border-color, #6d6d6d)}\n"]
|
|
1915
|
+
styles: [":focus{z-index:1}input,select,textarea{border:1px solid #495057;border:var(--lux-input-border, 1px solid) var(--lux-input-border-color, #495057);margin:0;margin:var(--lux-input-margin, 0rem);padding:0 .5rem;padding:var(--lux-input-padding, 0rem .5rem)}.alert{padding:.2rem 2rem;background:#fe2e2e;background:var(--lux-alert-background, #fe2e2e);color:#fff;color:var(--lux-alert-color, white);font-family:Consolas,monospace;width:45%;margin-right:1rem;display:inline-block}.symbol{display:inline-block;align-items:baseline;padding:0 .5rem;margin-bottom:0;font-weight:400;color:default;color:var(--lux-symbol-color, default);text-align:center;white-space:nowrap;background:default;background:var(--lux-symbol-background, default);font-size:1rem;font-size:var(--lux-symbol-font-size, 1rem)}.bordered,.symbol{border:1px solid #495057;border:var(--lux-input-border, 1px solid) var(--lux-input-border-color, #495057)}.rounded,.rounded-right,.rounded-middle,.rounded-left{border-radius:.25rem;border-radius:var(--lux-border-radius, .25rem)}.rounded-left{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-middle{border-radius:0}.rounded-right{border-top-left-radius:0;border-bottom-left-radius:0}.prefix{border-right:none}.infix{border-left:none;border-right:none}.postfix{border-left:none;display:flex;align-items:center}:host{display:flex;align-items:stretch;min-height:1.5rem}.readonly{border:none}.readonly:focus{border:none;outline:none}.disabled{background-color:#f1f1f1;background-color:var(--lux-disabled-color, #f1f1f1);border-color:#6d6d6d;border-color:var(--lux-disabled-border-color, #6d6d6d)}.clickable{cursor:pointer}.full-space{width:100%;height:100%;margin:0;padding:0}.minimal-space,.icon,.icon-external{min-width:1rem;min-height:1rem}.icon,.icon-external{display:inline-block;background-size:1rem 1rem;background-position:center;background-repeat:no-repeat;width:1.5rem;width:var(--lux-autocomplete-icon-width, 1.5rem);z-index:1}.icon-external{background:url(/assets/img/external.svg) no-repeat center;background:var(--lux-input-icon-external, url(/assets/img/external.svg) no-repeat center);background-size:1rem;background-position-y:.1rem;height:100%}.invisible{opacity:0}.transparency{background-image:conic-gradient(white 0deg 90deg,lightgray 90deg 180deg,white 180deg 270deg,lightgray 270deg 360deg)}\n"]
|
|
1849
1916
|
},] }
|
|
1850
1917
|
];
|
|
1851
1918
|
InputComponent.ctorParameters = function () { return [
|
|
@@ -1854,6 +1921,7 @@
|
|
|
1854
1921
|
InputComponent.propDecorators = {
|
|
1855
1922
|
input: [{ type: i0.ViewChild, args: ['input', { static: false },] }],
|
|
1856
1923
|
textarea: [{ type: i0.ViewChild, args: ['textarea', { static: false },] }],
|
|
1924
|
+
colorpicker: [{ type: i0.ViewChild, args: ['colorpicker', { static: false },] }],
|
|
1857
1925
|
rows: [{ type: i0.Input }],
|
|
1858
1926
|
cols: [{ type: i0.Input }],
|
|
1859
1927
|
step: [{ type: i0.Input }],
|