@klippa/ngx-enhancy-forms 8.0.0 → 8.1.2
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/klippa-ngx-enhancy-forms.umd.js +93 -0
- package/bundles/klippa-ngx-enhancy-forms.umd.js.map +1 -1
- package/bundles/klippa-ngx-enhancy-forms.umd.min.js +1 -1
- package/bundles/klippa-ngx-enhancy-forms.umd.min.js.map +1 -1
- package/esm2015/lib/elements/hour-minute-input/hour-minute-input.component.js +86 -0
- package/esm2015/lib/ngx-enhancy-forms.module.js +4 -1
- package/esm2015/lib/validators/timeValidator.js +6 -0
- package/esm2015/public-api.js +2 -1
- package/fesm2015/klippa-ngx-enhancy-forms.js +90 -1
- package/fesm2015/klippa-ngx-enhancy-forms.js.map +1 -1
- package/klippa-ngx-enhancy-forms.metadata.json +1 -1
- package/lib/elements/hour-minute-input/hour-minute-input.component.d.ts +16 -0
- package/lib/validators/timeValidator.d.ts +3 -0
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
|
@@ -1910,6 +1910,96 @@
|
|
|
1910
1910
|
},] }
|
|
1911
1911
|
];
|
|
1912
1912
|
|
|
1913
|
+
var invalidTimeKey = '--invalid_time--';
|
|
1914
|
+
function timeValidator(control) {
|
|
1915
|
+
var invalid = control.value === invalidTimeKey;
|
|
1916
|
+
return invalid ? { date: control.value } : null;
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
var HourMinuteInputComponent = /** @class */ (function (_super) {
|
|
1920
|
+
__extends(HourMinuteInputComponent, _super);
|
|
1921
|
+
function HourMinuteInputComponent() {
|
|
1922
|
+
var _this = _super.apply(this, __spread(arguments)) || this;
|
|
1923
|
+
_this.hoursTouched = false;
|
|
1924
|
+
_this.minutesTouched = false;
|
|
1925
|
+
return _this;
|
|
1926
|
+
}
|
|
1927
|
+
HourMinuteInputComponent.prototype.formatHours = function () {
|
|
1928
|
+
if (!stringIsSetAndFilled(this.hours)) {
|
|
1929
|
+
this.hours = '0';
|
|
1930
|
+
}
|
|
1931
|
+
};
|
|
1932
|
+
HourMinuteInputComponent.prototype.formatMinutes = function () {
|
|
1933
|
+
if (!stringIsSetAndFilled(this.minutes)) {
|
|
1934
|
+
this.minutes = '0';
|
|
1935
|
+
}
|
|
1936
|
+
};
|
|
1937
|
+
HourMinuteInputComponent.prototype.formatTime = function () {
|
|
1938
|
+
if (Number.isFinite(Number(this.hours)) && this.hours.length === 1) {
|
|
1939
|
+
this.hours = '0' + this.hours;
|
|
1940
|
+
}
|
|
1941
|
+
if (Number.isFinite(Number(this.minutes)) && this.minutes.length === 1) {
|
|
1942
|
+
this.minutes = '0' + this.minutes;
|
|
1943
|
+
}
|
|
1944
|
+
};
|
|
1945
|
+
HourMinuteInputComponent.prototype.writeValue = function (value) {
|
|
1946
|
+
if (Number.isFinite(value)) {
|
|
1947
|
+
this.hours = Math.floor(value / 60) + '';
|
|
1948
|
+
this.minutes = value % 60 + '';
|
|
1949
|
+
this.formatTime();
|
|
1950
|
+
_super.prototype.writeValue.call(this, value);
|
|
1951
|
+
}
|
|
1952
|
+
else {
|
|
1953
|
+
this.hours = '';
|
|
1954
|
+
this.minutes = '';
|
|
1955
|
+
_super.prototype.writeValue.call(this, invalidTimeKey);
|
|
1956
|
+
}
|
|
1957
|
+
};
|
|
1958
|
+
HourMinuteInputComponent.prototype.notifyNewTime = function () {
|
|
1959
|
+
var parsedHours = Number(this.hours);
|
|
1960
|
+
var parsedMinutes = Number(this.minutes);
|
|
1961
|
+
// when all inputs are empty
|
|
1962
|
+
if (!stringIsSetAndFilled(this.hours) && !stringIsSetAndFilled(this.minutes)) {
|
|
1963
|
+
this.setInnerValueAndNotify(null);
|
|
1964
|
+
return;
|
|
1965
|
+
}
|
|
1966
|
+
// if we have valid time
|
|
1967
|
+
if (Number.isFinite(parsedHours) &&
|
|
1968
|
+
parsedHours >= 0 &&
|
|
1969
|
+
parsedHours <= 9999 &&
|
|
1970
|
+
Number.isFinite(parsedMinutes) &&
|
|
1971
|
+
parsedMinutes >= 0 &&
|
|
1972
|
+
parsedMinutes <= 59) {
|
|
1973
|
+
this.setInnerValueAndNotify(parsedHours * 60 + parsedMinutes);
|
|
1974
|
+
return;
|
|
1975
|
+
}
|
|
1976
|
+
// all other cases, we are not in a valid state
|
|
1977
|
+
this.setInnerValueAndNotify(invalidTimeKey);
|
|
1978
|
+
};
|
|
1979
|
+
HourMinuteInputComponent.prototype.touchHours = function () {
|
|
1980
|
+
this.hoursTouched = true;
|
|
1981
|
+
this.determineAllTouched();
|
|
1982
|
+
};
|
|
1983
|
+
HourMinuteInputComponent.prototype.touchMinutes = function () {
|
|
1984
|
+
this.minutesTouched = true;
|
|
1985
|
+
this.determineAllTouched();
|
|
1986
|
+
};
|
|
1987
|
+
HourMinuteInputComponent.prototype.determineAllTouched = function () {
|
|
1988
|
+
if (this.hoursTouched && this.minutesTouched) {
|
|
1989
|
+
this.touch();
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
return HourMinuteInputComponent;
|
|
1993
|
+
}(ValueAccessorBase));
|
|
1994
|
+
HourMinuteInputComponent.decorators = [
|
|
1995
|
+
{ type: core.Component, args: [{
|
|
1996
|
+
selector: 'klp-form-hour-minute-input',
|
|
1997
|
+
template: "<div class=\"componentContainer\" [ngClass]=\"{disabled: disabled}\">\n\t<input class=\"hourInput\" maxlength=\"4\" placeholder=\"____\" [disabled]=\"disabled\" [(ngModel)]=\"hours\" (blur)=\"formatHours(); formatTime(); touchHours(); notifyNewTime()\" (ngModelChange)=\"notifyNewTime()\">\n\t<div class=\"divider\">:</div>\n\t<input maxlength=\"2\" placeholder=\"__\" [disabled]=\"disabled\" [(ngModel)]=\"minutes\" (blur)=\"formatMinutes(); formatTime(); touchMinutes(); notifyNewTime()\" (ngModelChange)=\"notifyNewTime()\">\n</div>\n",
|
|
1998
|
+
providers: [{ provide: forms.NG_VALUE_ACCESSOR, useExisting: HourMinuteInputComponent, multi: true }],
|
|
1999
|
+
styles: [":host{display:flex}.componentContainer{align-items:center;background:#fff;border:1px solid #e6ecf5;display:flex;flex:0 0 auto;height:42px;padding:6px .625rem}.componentContainer.disabled{background:#f9f9f9;cursor:not-allowed}.componentContainer input{border:none;color:#888da8;padding:0;text-align:center;width:20px}.componentContainer input.hourInput{width:40px}.componentContainer input::-moz-placeholder{color:#adadad}.componentContainer input:-ms-input-placeholder{color:#adadad}.componentContainer input::placeholder{color:#adadad}.componentContainer .divider{margin:0 .3125rem}"]
|
|
2000
|
+
},] }
|
|
2001
|
+
];
|
|
2002
|
+
|
|
1913
2003
|
var NgxEnhancyFormsModule = /** @class */ (function () {
|
|
1914
2004
|
function NgxEnhancyFormsModule() {
|
|
1915
2005
|
}
|
|
@@ -1948,6 +2038,7 @@
|
|
|
1948
2038
|
FormSubmitButtonComponent,
|
|
1949
2039
|
FormComponent,
|
|
1950
2040
|
SubFormDirective,
|
|
2041
|
+
HourMinuteInputComponent
|
|
1951
2042
|
],
|
|
1952
2043
|
exports: [
|
|
1953
2044
|
ValueAccessorBase,
|
|
@@ -1973,6 +2064,7 @@
|
|
|
1973
2064
|
FormSubmitButtonComponent,
|
|
1974
2065
|
FormComponent,
|
|
1975
2066
|
SubFormDirective,
|
|
2067
|
+
HourMinuteInputComponent
|
|
1976
2068
|
]
|
|
1977
2069
|
},] }
|
|
1978
2070
|
];
|
|
@@ -2001,6 +2093,7 @@
|
|
|
2001
2093
|
exports.FormElementComponent = FormElementComponent;
|
|
2002
2094
|
exports.FormErrorComponent = FormErrorComponent;
|
|
2003
2095
|
exports.FormSubmitButtonComponent = FormSubmitButtonComponent;
|
|
2096
|
+
exports.HourMinuteInputComponent = HourMinuteInputComponent;
|
|
2004
2097
|
exports.KLP_DATE_FORMATS = KLP_DATE_FORMATS;
|
|
2005
2098
|
exports.LoadingIndicatorComponent = LoadingIndicatorComponent;
|
|
2006
2099
|
exports.MultipleValueAccessorBase = MultipleValueAccessorBase;
|