@klippa/ngx-enhancy-forms 1.2.0 → 2.0.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/README.md +179 -23
- package/bundles/klippa-ngx-enhancy-forms.umd.js +248 -84
- package/bundles/klippa-ngx-enhancy-forms.umd.js.map +1 -1
- package/bundles/klippa-ngx-enhancy-forms.umd.min.js +2 -2
- package/bundles/klippa-ngx-enhancy-forms.umd.min.js.map +1 -1
- package/esm2015/klippa-ngx-enhancy-forms.js +2 -17
- package/esm2015/lib/elements/button/button.component.js +3 -3
- package/esm2015/lib/elements/checkbox/checkbox.component.js +1 -1
- package/esm2015/lib/elements/datepicker/datepicker.component.js +111 -0
- package/esm2015/lib/elements/email/email-input.component.js +6 -2
- package/esm2015/lib/elements/loading-indicator/loading-indicator.component.js +2 -2
- package/esm2015/lib/elements/number-input/number-input.component.js +1 -1
- package/esm2015/lib/elements/password-field/password-field.component.js +11 -4
- package/esm2015/lib/elements/select/select.component.js +2 -8
- package/esm2015/lib/elements/sortable-items/sortable-items.component.js +1 -1
- package/esm2015/lib/elements/text-input/text-input.component.js +1 -1
- package/esm2015/lib/elements/toggle/toggle.component.js +1 -1
- package/esm2015/lib/elements/value-accessor-base/value-accessor-base.component.js +1 -1
- package/esm2015/lib/form/form-caption/form-caption.component.js +1 -1
- package/esm2015/lib/form/form-element/form-element.component.js +29 -5
- package/esm2015/lib/form/form-error/form-error.component.js +1 -1
- package/esm2015/lib/form/form-submit-button/form-submit-button.component.js +2 -2
- package/esm2015/lib/form/form.component.js +1 -1
- package/esm2015/lib/material.module.js +17 -0
- package/esm2015/lib/ngx-enhancy-forms.module.js +11 -6
- package/esm2015/lib/types.js +2 -0
- package/esm2015/lib/util/values.js +1 -1
- package/esm2015/lib/validators/dateValidator.js +6 -0
- package/esm2015/public-api.js +20 -1
- package/fesm2015/klippa-ngx-enhancy-forms.js +216 -57
- package/fesm2015/klippa-ngx-enhancy-forms.js.map +1 -1
- package/klippa-ngx-enhancy-forms.d.ts +1 -16
- package/klippa-ngx-enhancy-forms.metadata.json +1 -1
- package/lib/elements/datepicker/datepicker.component.d.ts +26 -0
- package/lib/elements/password-field/password-field.component.d.ts +1 -0
- package/lib/elements/select/select.component.d.ts +1 -3
- package/lib/form/form-element/form-element.component.d.ts +9 -2
- package/lib/form/form-error/form-error.component.d.ts +2 -1
- package/lib/material.module.d.ts +2 -0
- package/lib/types.d.ts +15 -0
- package/lib/validators/dateValidator.d.ts +3 -0
- package/package.json +8 -9
- package/public-api.d.ts +19 -0
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { Component, Input, Host, Optional, ViewChild, ContentChild, TemplateRef,
|
|
1
|
+
import { Component, Input, InjectionToken, Host, Optional, Inject, ViewChild, HostBinding, ContentChild, TemplateRef, NgModule } from '@angular/core';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
3
|
import { FormGroup, FormArray, FormControl, ControlContainer, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
|
|
4
4
|
import { isString } from 'lodash';
|
|
5
|
-
import { NgSelectModule } from '@ng-select/ng-select';
|
|
6
5
|
import { SortablejsModule } from 'ngx-sortablejs';
|
|
6
|
+
import { NgSelectModule } from '@ng-select/ng-select';
|
|
7
|
+
import { MAT_NATIVE_DATE_FORMATS, MAT_DATE_FORMATS, MatNativeDateModule } from '@angular/material/core';
|
|
8
|
+
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
9
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
10
|
+
import { MatInputModule } from '@angular/material/input';
|
|
11
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
7
12
|
|
|
8
13
|
class FormComponent {
|
|
9
14
|
constructor() {
|
|
@@ -74,14 +79,33 @@ FormComponent.propDecorators = {
|
|
|
74
79
|
formGroup: [{ type: Input }]
|
|
75
80
|
};
|
|
76
81
|
|
|
82
|
+
const FORM_ERROR_MESSAGES = new InjectionToken('form.error.messages');
|
|
83
|
+
const DEFAULT_ERROR_MESSAGES = {
|
|
84
|
+
min: "Use a number larger than %min%",
|
|
85
|
+
max: "Use a number smaller than %max%",
|
|
86
|
+
required: "This field is required",
|
|
87
|
+
email: "Use a valid email address",
|
|
88
|
+
minLength: "Has to be longer than %minLength% character(s)",
|
|
89
|
+
maxLength: "Has to be shorter than %maxLength% character(s)",
|
|
90
|
+
pattern: "This input is not valid",
|
|
91
|
+
matchPassword: "Passwords must match",
|
|
92
|
+
date: "Enter a valid date",
|
|
93
|
+
};
|
|
77
94
|
class FormElementComponent {
|
|
78
|
-
constructor(parent) {
|
|
95
|
+
constructor(parent, customMessages) {
|
|
79
96
|
this.parent = parent;
|
|
97
|
+
this.customMessages = customMessages;
|
|
80
98
|
this.direction = 'horizontal';
|
|
81
99
|
this.captionSpacing = 'percentages';
|
|
82
100
|
this.swapInputAndCaption = false;
|
|
101
|
+
this.errorMessages = DEFAULT_ERROR_MESSAGES;
|
|
83
102
|
this.customErrorHandlers = [];
|
|
84
103
|
}
|
|
104
|
+
substituteParameters(message, parameters) {
|
|
105
|
+
return Object.keys(parameters).reduce((msg, key) => {
|
|
106
|
+
return msg.replace(`%${key}%`, parameters[key]);
|
|
107
|
+
}, message);
|
|
108
|
+
}
|
|
85
109
|
registerControl(formControl) {
|
|
86
110
|
this.attachedControl = formControl;
|
|
87
111
|
this.parent.registerControl(formControl, this);
|
|
@@ -129,16 +153,21 @@ class FormElementComponent {
|
|
|
129
153
|
// to give some breathing room, we scroll 100px more to the top
|
|
130
154
|
(_a = this.getScrollableParent(this.internalComponentRef.nativeElement)) === null || _a === void 0 ? void 0 : _a.scrollBy(0, -100);
|
|
131
155
|
}
|
|
156
|
+
getErrorMessages(key) {
|
|
157
|
+
var _a, _b, _c;
|
|
158
|
+
return (_c = (_b = (_a = this.customMessages) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : this.errorMessages[key];
|
|
159
|
+
}
|
|
132
160
|
}
|
|
133
161
|
FormElementComponent.decorators = [
|
|
134
162
|
{ type: Component, args: [{
|
|
135
163
|
selector: 'klp-form-element',
|
|
136
|
-
template: "<ng-template #errorRef>\n\t<div *ngIf=\"getErrorToShow()\" class=\"errorContainer\">\n\t\t<div *ngIf=\"showDefaultError('min')\"
|
|
164
|
+
template: "<ng-template #errorRef>\n\t<div *ngIf=\"getErrorToShow()\" class=\"errorContainer\">\n\t\t<div *ngIf=\"showDefaultError('min')\">{{substituteParameters(getErrorMessages(\"min\"), {min: attachedControl.errors.min.min})}}</div>\n\t\t<div *ngIf=\"showDefaultError('max')\">{{substituteParameters(getErrorMessages(\"max\"), {max: attachedControl.errors.max.max})}}</div>\n\t\t<div *ngIf=\"showDefaultError('required')\">{{getErrorMessages(\"required\")}}</div>\n\t\t<div *ngIf=\"showDefaultError('email')\">{{getErrorMessages(\"email\")}}</div>\n\t\t<div *ngIf=\"showDefaultError('minlength')\">{{substituteParameters(getErrorMessages(\"minLength\"), {minLength: attachedControl.errors.minlength.requiredLength})}}</div>\n\t\t<div *ngIf=\"showDefaultError('maxlength')\">{{substituteParameters(getErrorMessages(\"maxLength\"), {maxLength: attachedControl.errors.maxlength.requiredLength})}}</div>\n\t\t<div *ngIf=\"showDefaultError('pattern')\">{{getErrorMessages(\"pattern\")}}</div>\n\t\t<div *ngIf=\"showDefaultError('MatchPassword')\">{{getErrorMessages(\"matchPassword\")}}</div>\n\t\t<div *ngIf=\"showDefaultError('date')\">{{getErrorMessages(\"date\")}}</div>\n\t\t<div *ngIf=\"showDefaultError('message')\">{{attachedControl.errors.message.value}}</div>\n\t\t<div [ngTemplateOutlet]=\"getCustomErrorHandler(getErrorToShow())?.templateRef\"></div>\n\t</div>\n</ng-template>\n<ng-container *ngIf=\"direction === 'horizontal'\" [ngTemplateOutlet]=\"errorRef\"></ng-container>\n<div *ngIf=\"attachedControl\" class=\"componentContainer\" [ngClass]=\"{vertical: direction === 'vertical', reverseOrder: swapInputAndCaption}\" #internalComponentRef>\n\t<div class=\"caption\" [ngClass]=\"{ hasErrors: getErrorToShow() && attachedControl.touched, percentageSpacing: captionSpacing === 'percentages' }\">\n\t\t<div *ngIf=\"captionRef\" [ngTemplateOutlet]=\"captionRef\"></div>\n\t\t<div *ngIf=\"!captionRef\">{{caption}}</div>\n\t</div>\n\t<ng-container *ngIf=\"direction === 'vertical'\" [ngTemplateOutlet]=\"errorRef\"></ng-container>\n\t<div class=\"inputContainer\" [ngClass]=\"{ percentageSpacing: captionSpacing === 'percentages' }\">\n\t\t<ng-content></ng-content>\n\t</div>\n</div>\n",
|
|
137
165
|
styles: [":host{display:block;margin-top:1.25rem}.componentContainer{align-items:center;display:flex}.componentContainer.reverseOrder{flex-direction:row-reverse;justify-content:flex-end}.componentContainer.vertical{display:block;margin-bottom:1rem}.componentContainer.vertical .inputContainer{margin-top:.3125rem}.componentContainer.vertical .errorContainer{margin-left:0}.caption{color:#515365;flex:0 0 auto;font-weight:700}.caption.percentageSpacing{flex:0 0 40%}.caption.hasErrors{color:#ff8000}.inputContainer{flex:0 0 auto}.inputContainer.percentageSpacing{flex:0 0 60%}.errorContainer{color:#ff8000;margin-left:40%}"]
|
|
138
166
|
},] }
|
|
139
167
|
];
|
|
140
168
|
FormElementComponent.ctorParameters = () => [
|
|
141
|
-
{ type: FormComponent, decorators: [{ type: Host }, { type: Optional }] }
|
|
169
|
+
{ type: FormComponent, decorators: [{ type: Host }, { type: Optional }] },
|
|
170
|
+
{ type: undefined, decorators: [{ type: Inject, args: [FORM_ERROR_MESSAGES,] }, { type: Optional }] }
|
|
142
171
|
];
|
|
143
172
|
FormElementComponent.propDecorators = {
|
|
144
173
|
caption: [{ type: Input }],
|
|
@@ -269,6 +298,43 @@ ValueAccessorBase.propDecorators = {
|
|
|
269
298
|
formControl: [{ type: Input }]
|
|
270
299
|
};
|
|
271
300
|
|
|
301
|
+
class ButtonComponent {
|
|
302
|
+
constructor() {
|
|
303
|
+
this.variant = 'white';
|
|
304
|
+
this.size = 'medium';
|
|
305
|
+
this.fullWidth = false;
|
|
306
|
+
this.hasBorder = true;
|
|
307
|
+
this.disabled = false;
|
|
308
|
+
this.isLoading = false;
|
|
309
|
+
this.type = 'button';
|
|
310
|
+
}
|
|
311
|
+
get _() {
|
|
312
|
+
return this.fullWidth;
|
|
313
|
+
}
|
|
314
|
+
onClick(event) {
|
|
315
|
+
if (this.disabled) {
|
|
316
|
+
event.stopPropagation();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
ButtonComponent.decorators = [
|
|
321
|
+
{ type: Component, args: [{
|
|
322
|
+
selector: 'klp-form-button',
|
|
323
|
+
template: "<button class=\"buttonFundamentals\"\n\t[ngClass]=\"[\n\t\tvariant,\n\t\tsize,\n\t\tfullWidth ? 'fullWidth' : '',\n\t\thasBorder ? '' : 'no-border',\n\t\tdisabled ? 'disabled' : ''\n\t]\"\n\t[type]=\"type\"\n\t(click)=\"onClick($event)\"\n>\n\t<div class=\"caption\" [ngClass]=\"{invisible: isLoading}\">\n\t\t<ng-content></ng-content>\n\t</div>\n\t<div class=\"loadingSpinnerContainer\" *ngIf=\"isLoading\">\n\t\t<klp-form-loading-indicator variant=\"spinner\" size=\"small\"></klp-form-loading-indicator>\n\t</div>\n</button>\n",
|
|
324
|
+
styles: [":host{display:inline-block}:host._fullWidth{display:block}.buttonFundamentals{border:1px solid #e6ecf5;border-radius:5px;color:#888da8;cursor:pointer;font-size:13px;font-weight:700;letter-spacing:1px;padding:10px 20px}.fullWidth{width:100%}.no-border{border:none}.caption.invisible{visibility:hidden}button{position:relative}.loadingSpinnerContainer{align-items:center;bottom:0;display:flex;justify-content:center;left:0;position:absolute;right:0;top:0}.small{padding-bottom:.375rem;padding-top:.375rem}.large{line-height:2}.white{background-color:#fff;border-color:#d4deee;color:#515365;font-weight:500}.white:active,.white:hover{background-color:#edf2f8;border-color:#edf2f8;color:#515365}.white:focus{text-decoration:underline}.greenFilled{background-color:#27bb5f;border-color:#27bb5f;color:#fff}.greenFilled:hover{background-color:#2bd06a;border-color:#2bd06a;color:#fff}.greenFilled:focus{text-decoration:underline}.greenFilled:active{background-color:#23a654;border-color:#23a654}.greenOutlined{background-color:#fff;border-color:#27bb5f;color:#27bb5f}.greenOutlined:hover{background-color:#2bd06a;border-color:#2bd06a;color:#fff}.greenOutlined:focus{text-decoration:underline}.greenOutlined:active{background-color:#23a654;border-color:#23a654}.greenLink{background:none;border:none;color:#27bb5f;padding:0}.greenLink:focus,.greenLink:hover{text-decoration:underline}.contextMenuItem{background-color:#fff;border-color:#fff;color:#888da8}.contextMenuItem:hover{background-color:#f6f7fb;border-color:#f6f7fb}.contextMenuItem:active,.contextMenuItem:focus{text-decoration:underline}.redFilled{background-color:#ff3c7e;border-color:#ff3c7e;color:#fff}.redFilled:hover{background-color:#ff568f;border-color:#ff568f;color:#fff}.redFilled:focus{text-decoration:underline}.redFilled:active{background-color:#ff236d;border-color:#ff236d}.redOutlined{background-color:#fff;border-color:#ff3c7e;color:#ff3c7e}.redOutlined:hover{background-color:#ff568f;border-color:#ff568f;color:#fff}.redOutlined:focus{text-decoration:underline}.redOutlined:active{background-color:#ff236d;border-color:#ff236d}.orangeFilled{background-color:#ff8000;border-color:#ff8000;color:#fff}.orangeFilled:hover{background-color:#ff8d1a;border-color:#ff8d1a;color:#fff}.orangeFilled:focus{text-decoration:underline}.orangeFilled:active{background-color:#e67300;border-color:#e67300}"]
|
|
325
|
+
},] }
|
|
326
|
+
];
|
|
327
|
+
ButtonComponent.propDecorators = {
|
|
328
|
+
variant: [{ type: Input }],
|
|
329
|
+
size: [{ type: Input }],
|
|
330
|
+
fullWidth: [{ type: Input }],
|
|
331
|
+
hasBorder: [{ type: Input }],
|
|
332
|
+
disabled: [{ type: Input }],
|
|
333
|
+
isLoading: [{ type: Input }],
|
|
334
|
+
type: [{ type: Input }],
|
|
335
|
+
_: [{ type: HostBinding, args: ['class._fullWidth',] }]
|
|
336
|
+
};
|
|
337
|
+
|
|
272
338
|
class CheckboxComponent extends ValueAccessorBase {
|
|
273
339
|
}
|
|
274
340
|
CheckboxComponent.decorators = [
|
|
@@ -285,11 +351,15 @@ CheckboxComponent.propDecorators = {
|
|
|
285
351
|
};
|
|
286
352
|
|
|
287
353
|
class EmailInputComponent extends ValueAccessorBase {
|
|
354
|
+
constructor() {
|
|
355
|
+
super(...arguments);
|
|
356
|
+
this.placeholder = '';
|
|
357
|
+
}
|
|
288
358
|
}
|
|
289
359
|
EmailInputComponent.decorators = [
|
|
290
360
|
{ type: Component, args: [{
|
|
291
361
|
selector: 'klp-form-email-input',
|
|
292
|
-
template: "<input\n\ttype=\"email\"\n\tclass=\"form-control\"\n\t[(ngModel)]=\"innerValue\"\n\t(input)=\"setInnerValueAndNotify($event.target.value)\"\n\t[placeholder]=\"placeholder
|
|
362
|
+
template: "<input\n\ttype=\"email\"\n\tclass=\"form-control\"\n\t[(ngModel)]=\"innerValue\"\n\t(input)=\"setInnerValueAndNotify($event.target.value)\"\n\t[placeholder]=\"placeholder\"\n\t(blur)=\"touch()\"\n/>\n",
|
|
293
363
|
providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: EmailInputComponent, multi: true }],
|
|
294
364
|
styles: [":host,input{display:block}input{-moz-transition:all .2s ease-in;-ms-transition:all .2s ease-in;-o-transition:all .2s ease-in;-webkit-transition:all .2s ease-in;border:1px solid #e6ecf5;border-radius:2px;box-shadow:none;color:#888da8;font-size:14px;height:42px;outline:none;padding:.375rem .625rem;transition:all .2s ease-in;width:100%}input::-webkit-input-placeholder{color:#adadad}input:-moz-placeholder,input::-moz-placeholder{color:#adadad}input:-ms-input-placeholder{color:#adadad}input:focus{border-color:#3ed778;box-shadow:none;outline:0 none}input.input-sm{height:30px}input.input-lg{height:50px}input.error{background-color:#ffeff4;border-color:#ff3c7e}input.valid{background-color:#ebfaeb;border-color:#37c936;color:#278d26}.showErrors{border-color:#ff8000}"]
|
|
295
365
|
},] }
|
|
@@ -298,6 +368,24 @@ EmailInputComponent.propDecorators = {
|
|
|
298
368
|
placeholder: [{ type: Input }]
|
|
299
369
|
};
|
|
300
370
|
|
|
371
|
+
class LoadingIndicatorComponent {
|
|
372
|
+
constructor() {
|
|
373
|
+
this.variant = '3dots';
|
|
374
|
+
this.size = 'medium';
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
LoadingIndicatorComponent.decorators = [
|
|
378
|
+
{ type: Component, args: [{
|
|
379
|
+
selector: 'klp-form-loading-indicator',
|
|
380
|
+
template: "<div class=\"threeDots\" [class]=\"size\" *ngIf=\"variant === '3dots'\">\n\t<div></div>\n\t<div></div>\n\t<div></div>\n\t<div></div>\n</div>\n\n<div class=\"spinner\" [class]=\"size\" *ngIf=\"variant === 'spinner'\">\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"48\" height=\"48\" viewBox=\"0 0 48 48\">\n\t\t<circle cx=\"24\" cy=\"4\" r=\"4\" fill=\"currentColor\" />\n\t\t<circle cx=\"12.19\" cy=\"7.86\" r=\"3.7\" fill=\"currentColor\" />\n\t\t<circle cx=\"5.02\" cy=\"17.68\" r=\"3.4\" fill=\"currentColor\" />\n\t\t<circle cx=\"5.02\" cy=\"30.32\" r=\"3.1\" fill=\"currentColor\" />\n\t\t<circle cx=\"12.19\" cy=\"40.14\" r=\"2.8\" fill=\"currentColor\" />\n\t\t<circle cx=\"24\" cy=\"44\" r=\"2.5\" fill=\"currentColor\" />\n\t\t<circle cx=\"35.81\" cy=\"40.14\" r=\"2.2\" fill=\"currentColor\" />\n\t\t<circle cx=\"42.98\" cy=\"30.32\" r=\"1.9\" fill=\"currentColor\" />\n\t\t<circle cx=\"42.98\" cy=\"17.68\" r=\"1.6\" fill=\"currentColor\" />\n\t\t<circle cx=\"35.81\" cy=\"7.86\" r=\"1.3\" fill=\"currentColor\" />\n\t</svg>\n</div>\n\n<div class=\"textInput\" *ngIf=\"variant === 'textInput'\">\n\t<input\n\t\tdisabled\n\t\ttype=\"text\"\n\t\tclass=\"form-control\"\n\t\tplaceholder=\"Loading...\"\n\t>\n</div>\n\n<div class=\"picker\" *ngIf=\"variant === 'picker'\">\n\t<input\n\t\tdisabled\n\t\ttype=\"text\"\n\t\tclass=\"form-control\"\n\t\tplaceholder=\"Loading...\"\n\t>\n\t<div class=\"chevronDown\"></div>\n</div>\n",
|
|
381
|
+
styles: [".threeDots,:host{display:block}.threeDots{height:var(--base);position:relative;width:calc(var(--base)*4)}.threeDots.tiny{--base:4px}.threeDots.small{--base:8px}.threeDots.medium{--base:12px}.threeDots.large{--base:18px}.threeDots.huge{--base:26px}.threeDots div{-webkit-animation-timing-function:cubic-bezier(0,1,1,0);animation-timing-function:cubic-bezier(0,1,1,0);background:#27bb5f;border-radius:50%;height:var(--base);position:absolute;top:0;width:var(--base)}.threeDots div:first-child{-webkit-animation:lds-ellipsis1 .6s infinite;animation:lds-ellipsis1 .6s infinite}.threeDots div:nth-child(2),.threeDots div:nth-child(3){-webkit-animation:lds-ellipsis2 .6s infinite;animation:lds-ellipsis2 .6s infinite}.threeDots div:nth-child(3){left:calc(var(--base)*1.5)}.threeDots div:nth-child(4){-webkit-animation:lds-ellipsis3 .6s infinite;animation:lds-ellipsis3 .6s infinite;left:calc(var(--base)*3)}@-webkit-keyframes lds-ellipsis1{0%{transform:scale(0)}to{transform:scale(1)}}@keyframes lds-ellipsis1{0%{transform:scale(0)}to{transform:scale(1)}}@-webkit-keyframes lds-ellipsis3{0%{transform:scale(1)}to{transform:scale(0)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}to{transform:scale(0)}}@-webkit-keyframes lds-ellipsis2{0%{transform:translate(0)}to{transform:translate(150%)}}@keyframes lds-ellipsis2{0%{transform:translate(0)}to{transform:translate(150%)}}.spinner.tiny svg{height:1rem;width:1rem}.spinner.small svg{height:1.6rem;width:1.6rem}.spinner.medium svg{height:2.5rem;width:2.5rem}.spinner.large svg{height:3rem;width:3rem}.spinner.huge svg{height:4rem;width:4rem}.spinner svg{-moz-animation-duration:1.2s;-moz-animation-iteration-count:infinite;-moz-animation-name:rotate;-moz-animation-timing-function:linear;-moz-transition-property:-moz-transform;-webkit-animation-duration:1.2s;-webkit-animation-iteration-count:infinite;-webkit-animation-name:rotate;-webkit-animation-timing-function:linear;-webkit-transition-duration:1.2s;-webkit-transition-property:-webkit-transform;animation-duration:1.2s;animation-iteration-count:infinite;animation-name:rotate;animation-timing-function:linear;transition-property:transform}@-webkit-keyframes rotate{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(1turn)}}@keyframes rotate{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.picker{position:relative}.picker .chevronDown{border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid #888da8;height:0;position:absolute;right:23px;top:18px;width:0}"]
|
|
382
|
+
},] }
|
|
383
|
+
];
|
|
384
|
+
LoadingIndicatorComponent.propDecorators = {
|
|
385
|
+
variant: [{ type: Input }],
|
|
386
|
+
size: [{ type: Input }]
|
|
387
|
+
};
|
|
388
|
+
|
|
301
389
|
class NumberInputComponent extends ValueAccessorBase {
|
|
302
390
|
}
|
|
303
391
|
NumberInputComponent.decorators = [
|
|
@@ -313,31 +401,32 @@ NumberInputComponent.propDecorators = {
|
|
|
313
401
|
};
|
|
314
402
|
|
|
315
403
|
class PasswordFieldComponent extends ValueAccessorBase {
|
|
404
|
+
constructor() {
|
|
405
|
+
super(...arguments);
|
|
406
|
+
this.placeholder = 'Password';
|
|
407
|
+
}
|
|
316
408
|
}
|
|
317
409
|
PasswordFieldComponent.decorators = [
|
|
318
410
|
{ type: Component, args: [{
|
|
319
|
-
selector: 'klp-password-field',
|
|
320
|
-
template: "<input\n\ttype=\"password\"\n\tclass=\"form-control\"\n [ngClass]=\"{showErrors: isInErrorState()}\"\n\t[(ngModel)]=\"innerValue\"\n\t(input)=\"setInnerValueAndNotify($event.target.value)\"\n\
|
|
411
|
+
selector: 'klp-form-password-field',
|
|
412
|
+
template: "<input\n\ttype=\"password\"\n\tclass=\"form-control\"\n [ngClass]=\"{showErrors: isInErrorState()}\"\n\t[(ngModel)]=\"innerValue\"\n\t(input)=\"setInnerValueAndNotify($event.target.value)\"\n\t[placeholder]=\"placeholder\"\n\t(blur)=\"touch()\"\n/>\n",
|
|
321
413
|
providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: PasswordFieldComponent, multi: true }],
|
|
322
414
|
styles: [":host,input{display:block}input{-moz-transition:all .2s ease-in;-ms-transition:all .2s ease-in;-o-transition:all .2s ease-in;-webkit-transition:all .2s ease-in;border:1px solid #e6ecf5;border-radius:2px;box-shadow:none;color:#888da8;font-size:14px;height:42px;outline:none;padding:.375rem .625rem;transition:all .2s ease-in;width:100%}input::-webkit-input-placeholder{color:#adadad}input:-moz-placeholder,input::-moz-placeholder{color:#adadad}input:-ms-input-placeholder{color:#adadad}input:focus{border-color:#3ed778;box-shadow:none;outline:0 none}input.input-sm{height:30px}input.input-lg{height:50px}input.error{background-color:#ffeff4;border-color:#ff3c7e}input.valid{background-color:#ebfaeb;border-color:#37c936;color:#278d26}.showErrors{border-color:#ff8000}"]
|
|
323
415
|
},] }
|
|
324
416
|
];
|
|
417
|
+
PasswordFieldComponent.propDecorators = {
|
|
418
|
+
placeholder: [{ type: Input }]
|
|
419
|
+
};
|
|
325
420
|
|
|
326
421
|
class SelectComponent extends ValueAccessorBase {
|
|
327
422
|
constructor(parent, controlContainer) {
|
|
328
423
|
super(parent, controlContainer);
|
|
329
424
|
this.parent = parent;
|
|
330
425
|
this.controlContainer = controlContainer;
|
|
426
|
+
this.placeholder = 'Pick an option';
|
|
331
427
|
this.multiple = false;
|
|
332
428
|
this.clearable = true;
|
|
333
429
|
}
|
|
334
|
-
ngOnInit() {
|
|
335
|
-
super.ngOnInit();
|
|
336
|
-
if (!this.placeholder) {
|
|
337
|
-
// this.placeholder = this.translate.instant(_('Pick an option'));
|
|
338
|
-
this.placeholder = ('Pick an option');
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
430
|
}
|
|
342
431
|
SelectComponent.decorators = [
|
|
343
432
|
{ type: Component, args: [{
|
|
@@ -503,7 +592,7 @@ class FormSubmitButtonComponent {
|
|
|
503
592
|
FormSubmitButtonComponent.decorators = [
|
|
504
593
|
{ type: Component, args: [{
|
|
505
594
|
selector: 'klp-form-submit-button',
|
|
506
|
-
template: "<klp-button\n\t\t[variant]=\"variant\"\n\t\t(click)=\"submitForm()\"\n\t\t[disabled]=\"isLoading\"\n\t\t[isLoading]=\"isLoading\"\n\t\t[fullWidth]=\"fullWidth\"\n\t\ttype=\"submit\"\n\t\t[ngClass]=\"fullWidth ? 'fullWidth' : ''\"\n\t>\n\t<ng-content></ng-content>\n</klp-button>\n",
|
|
595
|
+
template: "<klp-form-button\n\t\t[variant]=\"variant\"\n\t\t(click)=\"submitForm()\"\n\t\t[disabled]=\"isLoading\"\n\t\t[isLoading]=\"isLoading\"\n\t\t[fullWidth]=\"fullWidth\"\n\t\ttype=\"submit\"\n\t\t[ngClass]=\"fullWidth ? 'fullWidth' : ''\"\n\t>\n\t<ng-content></ng-content>\n</klp-form-button>\n",
|
|
507
596
|
styles: [":host{display:inline-block}:host._fullWidth{display:block}.fullWidth{width:100%}"]
|
|
508
597
|
},] }
|
|
509
598
|
];
|
|
@@ -518,60 +607,127 @@ FormSubmitButtonComponent.propDecorators = {
|
|
|
518
607
|
_: [{ type: HostBinding, args: ['class._fullWidth',] }]
|
|
519
608
|
};
|
|
520
609
|
|
|
521
|
-
|
|
610
|
+
const invalidDateKey = '--invalid_date--';
|
|
611
|
+
function dateValidator(control) {
|
|
612
|
+
const invalid = control.value === invalidDateKey;
|
|
613
|
+
return invalid ? { date: control.value } : null;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const KLP_DATE_FORMATS = new InjectionToken('klp.form.date.formats');
|
|
617
|
+
function matDateFormatsFactory(component, dateFormats) {
|
|
618
|
+
var _a;
|
|
619
|
+
return (_a = dateFormats === null || dateFormats === void 0 ? void 0 : dateFormats(component.format)) !== null && _a !== void 0 ? _a : MAT_NATIVE_DATE_FORMATS;
|
|
620
|
+
}
|
|
621
|
+
class DatepickerComponent extends ValueAccessorBase {
|
|
522
622
|
constructor() {
|
|
523
|
-
|
|
524
|
-
this.
|
|
525
|
-
this.
|
|
526
|
-
this.
|
|
527
|
-
this.
|
|
528
|
-
this.
|
|
529
|
-
this.
|
|
623
|
+
super(...arguments);
|
|
624
|
+
this.minDate = undefined;
|
|
625
|
+
this.maxDate = undefined;
|
|
626
|
+
this.placeholder = 'Select date';
|
|
627
|
+
this.clearable = false;
|
|
628
|
+
this.minDateStartOfDay = undefined;
|
|
629
|
+
this.maxDateEndOfDay = undefined;
|
|
630
|
+
}
|
|
631
|
+
ngOnChanges(changes) {
|
|
632
|
+
if (changes.minDate) {
|
|
633
|
+
this.setMinDate(changes.minDate.currentValue);
|
|
634
|
+
}
|
|
635
|
+
if (changes.maxDate) {
|
|
636
|
+
this.setMaxDate(changes.maxDate.currentValue);
|
|
637
|
+
}
|
|
530
638
|
}
|
|
531
|
-
|
|
532
|
-
|
|
639
|
+
setMinDate(minDate) {
|
|
640
|
+
if (minDate) {
|
|
641
|
+
this.minDateStartOfDay = new Date(minDate);
|
|
642
|
+
this.minDateStartOfDay.setHours(0, 0, 0, 0);
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
this.minDateStartOfDay = undefined;
|
|
646
|
+
}
|
|
533
647
|
}
|
|
534
|
-
|
|
535
|
-
if (
|
|
536
|
-
|
|
648
|
+
setMaxDate(maxDate) {
|
|
649
|
+
if (maxDate) {
|
|
650
|
+
this.maxDateEndOfDay = new Date(maxDate);
|
|
651
|
+
this.maxDateEndOfDay.setHours(23, 59, 59, 999);
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
this.maxDateEndOfDay = undefined;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
// dateChanged is called when the output of the datepicker is changed and
|
|
658
|
+
// parsed correctly. If the date is invalid, it will be called the first time
|
|
659
|
+
// with null but never again until a valid input is provided.
|
|
660
|
+
dateChanged(event) {
|
|
661
|
+
const nativeInputValue = this.nativeInputRef.nativeElement.value;
|
|
662
|
+
const date = event.value;
|
|
663
|
+
if (isNullOrUndefined(date) && stringIsSetAndNotEmpty(nativeInputValue)) {
|
|
664
|
+
this.setInnerValueAndNotify(invalidDateKey);
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
this.setInnerValueAndNotify(date);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
writeValue(value) {
|
|
671
|
+
super.writeValue(value);
|
|
672
|
+
this.valueForMaterialDatePicker = value === invalidDateKey ? null : value;
|
|
673
|
+
}
|
|
674
|
+
// nativeValueChanged is called when the internal text value changes, but not
|
|
675
|
+
// when the date is changed via the date picker. We need this so that we can
|
|
676
|
+
// determine if the datepicker is empty or invalid.
|
|
677
|
+
nativeValueChanged(event) {
|
|
678
|
+
const nativeInputValue = event.target.value;
|
|
679
|
+
const date = this.valueForMaterialDatePicker;
|
|
680
|
+
if (this.datePickerRef.opened) {
|
|
681
|
+
// if the user is typing instead of using the picker, close it.
|
|
682
|
+
this.datePickerRef.close();
|
|
683
|
+
}
|
|
684
|
+
if (isNullOrUndefined(date) && stringIsSetAndNotEmpty(nativeInputValue)) {
|
|
685
|
+
this.setInnerValueAndNotify(invalidDateKey);
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
this.setInnerValueAndNotify(date);
|
|
537
689
|
}
|
|
538
690
|
}
|
|
691
|
+
resetToNull() {
|
|
692
|
+
this.setInnerValueAndNotify(null);
|
|
693
|
+
this.valueForMaterialDatePicker = null;
|
|
694
|
+
this.nativeInputRef.nativeElement.value = null;
|
|
695
|
+
}
|
|
539
696
|
}
|
|
540
|
-
|
|
697
|
+
DatepickerComponent.decorators = [
|
|
541
698
|
{ type: Component, args: [{
|
|
542
|
-
selector: 'klp-
|
|
543
|
-
template: "<
|
|
544
|
-
|
|
699
|
+
selector: 'klp-form-datepicker',
|
|
700
|
+
template: "<div class=\"componentContainer\" [ngClass]=\"{showErrors: isInErrorState()}\">\n\t<mat-form-field [floatLabel]=\"'never'\">\n\t\t<input\n\t\t\t#nativeInput\n\t\t\tmatInput\n\t\t\t[matDatepicker]=\"picker\"\n\t\t\t[(ngModel)]=\"valueForMaterialDatePicker\"\n\t\t\t(dateInput)=\"dateChanged($event)\"\n\t\t\t(input)=\"nativeValueChanged($event)\"\n\t\t\t[min]=\"minDateStartOfDay\"\n\t\t\t[max]=\"maxDateEndOfDay\"\n\t\t\t[placeholder]=\"placeholder\"\n\t\t\t(click)=\"picker.open()\"\n\t\t\t(blur)=\"touch()\"\n\t\t>\n\t\t<mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n\t\t<mat-datepicker #picker\n\t\t></mat-datepicker>\n\t</mat-form-field>\n\t<button *ngIf=\"clearable\" class=\"clearButton\" (click)=\"resetToNull()\">\u00D7</button>\n</div>\n",
|
|
701
|
+
providers: [
|
|
702
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: DatepickerComponent, multi: true },
|
|
703
|
+
{ provide: MAT_DATE_FORMATS,
|
|
704
|
+
deps: [DatepickerComponent, [new Optional(), KLP_DATE_FORMATS]],
|
|
705
|
+
useFactory: matDateFormatsFactory,
|
|
706
|
+
}
|
|
707
|
+
],
|
|
708
|
+
styles: [":host{display:block}:host ::ng-deep mat-form-field{display:block;height:100%}:host ::ng-deep mat-form-field.mat-focused .mat-form-field-label,:host ::ng-deep mat-form-field .mat-form-field-label{color:#adadad}:host ::ng-deep .mat-datepicker-toggle-active{color:#666}:host ::ng-deep .mat-form-field-wrapper{padding-bottom:none}:host ::ng-deep .mat-form-field-flex{flex-direction:row-reverse}:host ::ng-deep .mat-form-field-infix{border-top:none}:host ::ng-deep .mat-form-field-suffix{margin-right:.625rem}:host ::ng-deep .mat-form-field-suffix:hover .mat-button-focus-overlay{opacity:.1}:host ::ng-deep .mat-form-field-underline{display:none}.componentContainer{-moz-transition:all .2s ease-in;-ms-transition:all .2s ease-in;-o-transition:all .2s ease-in;-webkit-transition:all .2s ease-in;border:1px solid #e6ecf5;border-radius:2px;box-shadow:none;color:#888da8;display:block;font-size:14px;height:42px;padding:.375rem .625rem;position:relative;transition:all .2s ease-in;width:100%}.componentContainer::-webkit-input-placeholder{color:#adadad}.componentContainer:-moz-placeholder,.componentContainer::-moz-placeholder{color:#adadad}.componentContainer:-ms-input-placeholder{color:#adadad}.componentContainer:focus{border-color:#3ed778;box-shadow:none;outline:0 none}.componentContainer.input-sm{height:30px}.componentContainer.input-lg{height:50px}.componentContainer.error{background-color:#ffeff4;border-color:#ff3c7e}.componentContainer.valid{background-color:#ebfaeb;border-color:#37c936;color:#278d26}.componentContainer.showErrors{border-color:#ff8000}.componentContainer .clearButton{align-items:center;background:none;border:none;bottom:0;color:#7b7b7b;display:flex;font-size:18px;position:absolute;right:1.25rem;top:0}"]
|
|
545
709
|
},] }
|
|
546
710
|
];
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
_: [{ type: HostBinding, args: ['class._fullWidth',] }]
|
|
711
|
+
DatepickerComponent.propDecorators = {
|
|
712
|
+
minDate: [{ type: Input }],
|
|
713
|
+
maxDate: [{ type: Input }],
|
|
714
|
+
format: [{ type: Input }],
|
|
715
|
+
placeholder: [{ type: Input }],
|
|
716
|
+
clearable: [{ type: Input }],
|
|
717
|
+
nativeInputRef: [{ type: ViewChild, args: ['nativeInput',] }],
|
|
718
|
+
datePickerRef: [{ type: ViewChild, args: ['picker',] }]
|
|
556
719
|
};
|
|
557
720
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
this.variant = '3dots';
|
|
561
|
-
this.size = 'medium';
|
|
562
|
-
}
|
|
721
|
+
// material.module.ts
|
|
722
|
+
class MaterialModule {
|
|
563
723
|
}
|
|
564
|
-
|
|
565
|
-
{ type:
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
724
|
+
MaterialModule.decorators = [
|
|
725
|
+
{ type: NgModule, args: [{
|
|
726
|
+
imports: [MatDatepickerModule, MatFormFieldModule, MatNativeDateModule, MatInputModule, MatButtonModule],
|
|
727
|
+
exports: [MatDatepickerModule, MatFormFieldModule, MatNativeDateModule, MatInputModule, MatButtonModule],
|
|
728
|
+
providers: [MatDatepickerModule],
|
|
569
729
|
},] }
|
|
570
730
|
];
|
|
571
|
-
LoadingIndicatorComponent.propDecorators = {
|
|
572
|
-
variant: [{ type: Input }],
|
|
573
|
-
size: [{ type: Input }]
|
|
574
|
-
};
|
|
575
731
|
|
|
576
732
|
class NgxEnhancyFormsModule {
|
|
577
733
|
}
|
|
@@ -582,11 +738,13 @@ NgxEnhancyFormsModule.decorators = [
|
|
|
582
738
|
FormsModule,
|
|
583
739
|
NgSelectModule,
|
|
584
740
|
SortablejsModule,
|
|
741
|
+
MaterialModule,
|
|
585
742
|
],
|
|
586
743
|
declarations: [
|
|
587
744
|
ValueAccessorBase,
|
|
588
745
|
ButtonComponent,
|
|
589
746
|
CheckboxComponent,
|
|
747
|
+
DatepickerComponent,
|
|
590
748
|
EmailInputComponent,
|
|
591
749
|
LoadingIndicatorComponent,
|
|
592
750
|
NumberInputComponent,
|
|
@@ -604,6 +762,7 @@ NgxEnhancyFormsModule.decorators = [
|
|
|
604
762
|
exports: [
|
|
605
763
|
ValueAccessorBase,
|
|
606
764
|
ButtonComponent,
|
|
765
|
+
DatepickerComponent,
|
|
607
766
|
CheckboxComponent,
|
|
608
767
|
EmailInputComponent,
|
|
609
768
|
LoadingIndicatorComponent,
|
|
@@ -630,5 +789,5 @@ NgxEnhancyFormsModule.decorators = [
|
|
|
630
789
|
* Generated bundle index. Do not edit.
|
|
631
790
|
*/
|
|
632
791
|
|
|
633
|
-
export {
|
|
792
|
+
export { ButtonComponent, CheckboxComponent, DEFAULT_ERROR_MESSAGES, DatepickerComponent, EmailInputComponent, FORM_ERROR_MESSAGES, FormCaptionComponent, FormComponent, FormElementComponent, FormErrorComponent, FormSubmitButtonComponent, KLP_DATE_FORMATS, LoadingIndicatorComponent, NgxEnhancyFormsModule, NumberInputComponent, PasswordFieldComponent, SelectComponent, SortableItemsComponent, TextInputComponent, ToggleComponent, ValueAccessorBase, dateValidator, invalidDateKey, matDateFormatsFactory, MaterialModule as ɵa };
|
|
634
793
|
//# sourceMappingURL=klippa-ngx-enhancy-forms.js.map
|