@klippa/ngx-enhancy-forms 2.1.0 → 2.3.1

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.
@@ -4,432 +4,95 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.klippa = global.klippa || {}, global.klippa["ngx-enhancy-forms"] = {}), global.ng.core, global.ng.common, global.ng.forms, global.lodash, global.ngxSortablejs, global.ngSelect, global.ng.material.core, global.ng.material.datepicker, global.ng.material.formField, global.ng.material.input, global.ng.material.button));
5
5
  })(this, (function (exports, core, common, forms, lodash, ngxSortablejs, ngSelect, core$1, datepicker, formField, input, button) { 'use strict';
6
6
 
7
- var invalidFieldsSymbol = Symbol('Not all fields are valid');
8
- var FormComponent = /** @class */ (function () {
9
- function FormComponent() {
10
- // we keep track of what form controls are actually rendered. Only those count when looking at form validation
11
- this.activeControls = [];
12
- }
13
- FormComponent.prototype.registerControl = function (formControl, formElement) {
14
- this.activeControls.push({ formControl: formControl, formElement: formElement });
15
- };
16
- FormComponent.prototype.unregisterControl = function (formControl) {
17
- this.activeControls = this.activeControls.filter(function (e) { return e.formControl !== formControl; });
18
- };
19
- FormComponent.prototype.disableInactiveFormGroupControls = function (formGroup) {
20
- var _this = this;
21
- Object.values(formGroup.controls).forEach(function (value) {
22
- if (value instanceof forms.FormGroup) {
23
- _this.disableInactiveFormGroupControls(value);
24
- }
25
- else if (value instanceof forms.FormArray) {
26
- _this.disableInactiveFormArrayControls(value);
27
- }
28
- else if (value instanceof forms.FormControl) {
29
- _this.disableInactiveFormControl(value);
30
- }
31
- });
32
- };
33
- FormComponent.prototype.disableInactiveFormArrayControls = function (formArray) {
34
- var _this = this;
35
- formArray.controls.forEach(function (value) {
36
- if (value instanceof forms.FormGroup) {
37
- _this.disableInactiveFormGroupControls(value);
38
- }
39
- else if (value instanceof forms.FormArray) {
40
- _this.disableInactiveFormArrayControls(value);
41
- }
42
- else if (value instanceof forms.FormControl) {
43
- _this.disableInactiveFormControl(value);
44
- }
45
- });
46
- };
47
- FormComponent.prototype.disableInactiveFormControl = function (control) {
48
- if (this.activeControls.some(function (e) { return e.formControl === control; })) {
49
- control.enable();
50
- }
51
- else {
52
- control.disable();
53
- }
54
- };
55
- FormComponent.prototype.trySubmit = function () {
56
- var _a, _b;
57
- this.formGroup.markAllAsTouched();
58
- this.disableInactiveFormGroupControls(this.formGroup);
59
- if (this.formGroup.valid) {
60
- return Promise.resolve(this.formGroup.value);
61
- }
62
- else {
63
- (_b = (_a = this.activeControls.find(function (e) { return !e.formControl.valid; })) === null || _a === void 0 ? void 0 : _a.formElement) === null || _b === void 0 ? void 0 : _b.scrollTo();
64
- return Promise.reject(invalidFieldsSymbol);
65
- }
66
- };
67
- return FormComponent;
68
- }());
69
- FormComponent.decorators = [
70
- { type: core.Component, args: [{
71
- selector: 'klp-form',
72
- template: "<form>\n\t<ng-content></ng-content>\n</form>\n\n\n",
73
- styles: [":host{display:block}:host.row{display:flex}"]
74
- },] }
75
- ];
76
- FormComponent.propDecorators = {
77
- formGroup: [{ type: core.Input }]
78
- };
7
+ /*! *****************************************************************************
8
+ Copyright (c) Microsoft Corporation.
79
9
 
80
- var FORM_ERROR_MESSAGES = new core.InjectionToken('form.error.messages');
81
- var DEFAULT_ERROR_MESSAGES = {
82
- min: "Use a number larger than %min%",
83
- max: "Use a number smaller than %max%",
84
- required: "This field is required",
85
- email: "Use a valid email address",
86
- minLength: "Has to be longer than %minLength% character(s)",
87
- maxLength: "Has to be shorter than %maxLength% character(s)",
88
- pattern: "This input is not valid",
89
- matchPassword: "Passwords must match",
90
- date: "Enter a valid date",
10
+ Permission to use, copy, modify, and/or distribute this software for any
11
+ purpose with or without fee is hereby granted.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
+ PERFORMANCE OF THIS SOFTWARE.
20
+ ***************************************************************************** */
21
+ /* global Reflect, Promise */
22
+ var extendStatics = function (d, b) {
23
+ extendStatics = Object.setPrototypeOf ||
24
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25
+ function (d, b) { for (var p in b)
26
+ if (Object.prototype.hasOwnProperty.call(b, p))
27
+ d[p] = b[p]; };
28
+ return extendStatics(d, b);
91
29
  };
92
- var FormElementComponent = /** @class */ (function () {
93
- function FormElementComponent(parent, customMessages) {
94
- this.parent = parent;
95
- this.customMessages = customMessages;
96
- this.direction = 'horizontal';
97
- this.captionSpacing = 'percentages';
98
- this.swapInputAndCaption = false;
99
- this.errorMessages = DEFAULT_ERROR_MESSAGES;
100
- this.customErrorHandlers = [];
101
- }
102
- FormElementComponent.prototype.substituteParameters = function (message, parameters) {
103
- return Object.keys(parameters).reduce(function (msg, key) {
104
- return msg.replace("%" + key + "%", parameters[key]);
105
- }, message);
106
- };
107
- FormElementComponent.prototype.registerControl = function (formControl) {
108
- this.attachedControl = formControl;
109
- this.parent.registerControl(formControl, this);
110
- };
111
- FormElementComponent.prototype.unregisterControl = function (formControl) {
112
- this.attachedControl = null;
113
- this.parent.unregisterControl(formControl);
114
- };
115
- FormElementComponent.prototype.getAttachedControl = function () {
116
- return this.attachedControl;
117
- };
118
- FormElementComponent.prototype.registerErrorHandler = function (error, templateRef) {
119
- this.customErrorHandlers.push({ error: error, templateRef: templateRef });
120
- };
121
- FormElementComponent.prototype.registerCaption = function (templateRef) {
122
- this.captionRef = templateRef;
123
- };
124
- FormElementComponent.prototype.getErrorToShow = function () {
125
- var _a, _b, _c;
126
- if (((_a = this.attachedControl) === null || _a === void 0 ? void 0 : _a.touched) === true && ((_b = this.attachedControl) === null || _b === void 0 ? void 0 : _b.errors)) {
127
- return Object.keys((_c = this.attachedControl) === null || _c === void 0 ? void 0 : _c.errors)[0];
128
- }
129
- return null;
130
- };
131
- FormElementComponent.prototype.getCustomErrorHandler = function (error) {
132
- return this.customErrorHandlers.find(function (e) { return e.error === error; });
133
- };
134
- FormElementComponent.prototype.showDefaultError = function (error) {
135
- return this.getErrorToShow() === error && !this.customErrorHandlers.some(function (e) { return e.error === error; });
136
- };
137
- FormElementComponent.prototype.getScrollableParent = function (node) {
138
- if (node == null) {
139
- return null;
140
- }
141
- if (node.scrollHeight > node.clientHeight) {
142
- return node;
143
- }
144
- else {
145
- return this.getScrollableParent(node.parentNode);
30
+ function __extends(d, b) {
31
+ if (typeof b !== "function" && b !== null)
32
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
33
+ extendStatics(d, b);
34
+ function __() { this.constructor = d; }
35
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36
+ }
37
+ var __assign = function () {
38
+ __assign = Object.assign || function __assign(t) {
39
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
40
+ s = arguments[i];
41
+ for (var p in s)
42
+ if (Object.prototype.hasOwnProperty.call(s, p))
43
+ t[p] = s[p];
146
44
  }
45
+ return t;
147
46
  };
148
- FormElementComponent.prototype.scrollTo = function () {
149
- var _a;
150
- this.internalComponentRef.nativeElement.scrollIntoView(true);
151
- // to give some breathing room, we scroll 100px more to the top
152
- (_a = this.getScrollableParent(this.internalComponentRef.nativeElement)) === null || _a === void 0 ? void 0 : _a.scrollBy(0, -100);
153
- };
154
- FormElementComponent.prototype.getErrorMessages = function (key) {
155
- var _a, _b, _c;
156
- 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];
157
- };
158
- return FormElementComponent;
159
- }());
160
- FormElementComponent.decorators = [
161
- { type: core.Component, args: [{
162
- selector: 'klp-form-element',
163
- 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",
164
- 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%}"]
165
- },] }
166
- ];
167
- FormElementComponent.ctorParameters = function () { return [
168
- { type: FormComponent, decorators: [{ type: core.Host }, { type: core.Optional }] },
169
- { type: undefined, decorators: [{ type: core.Inject, args: [FORM_ERROR_MESSAGES,] }, { type: core.Optional }] }
170
- ]; };
171
- FormElementComponent.propDecorators = {
172
- caption: [{ type: core.Input }],
173
- direction: [{ type: core.Input }],
174
- captionSpacing: [{ type: core.Input }],
175
- swapInputAndCaption: [{ type: core.Input }],
176
- internalComponentRef: [{ type: core.ViewChild, args: ['internalComponentRef',] }]
47
+ return __assign.apply(this, arguments);
177
48
  };
178
-
179
- function stringIsSetAndNotEmpty(s) {
180
- return lodash.isString(s) && s.length > 0;
181
- }
182
- function isNullOrUndefined(value) {
183
- return value === null || value === undefined;
184
- }
185
- function numberIsSet(value) {
186
- return isValueSet(value) && typeof value === 'number';
49
+ function __rest(s, e) {
50
+ var t = {};
51
+ for (var p in s)
52
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
53
+ t[p] = s[p];
54
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
55
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
56
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
57
+ t[p[i]] = s[p[i]];
58
+ }
59
+ return t;
187
60
  }
188
- function isValueSet(value) {
189
- return value !== null && value !== undefined;
61
+ function __decorate(decorators, target, key, desc) {
62
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
63
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
64
+ r = Reflect.decorate(decorators, target, key, desc);
65
+ else
66
+ for (var i = decorators.length - 1; i >= 0; i--)
67
+ if (d = decorators[i])
68
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
69
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
190
70
  }
191
- function stringOrArrayIsSetAndEmpty(value) {
192
- return value !== null && value !== undefined && value.length === 0;
71
+ function __param(paramIndex, decorator) {
72
+ return function (target, key) { decorator(target, key, paramIndex); };
193
73
  }
194
- function useIfStringIsSet(s) {
195
- if (stringIsSetAndNotEmpty(s)) {
196
- return s;
197
- }
198
- return undefined;
74
+ function __metadata(metadataKey, metadataValue) {
75
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
76
+ return Reflect.metadata(metadataKey, metadataValue);
199
77
  }
200
- function useIfArrayIsSetWithOneItem(a) {
201
- if (!isNullOrUndefined(a) && a.length === 1) {
202
- return a[0];
203
- }
204
- return undefined;
205
- }
206
- function convertParentToChild(originalClass, newClass) {
207
- return Object.assign(newClass, originalClass);
208
- }
209
- function truncateString(s, length) {
210
- if (s.length < length) {
211
- return s;
212
- }
213
- return s.substring(0, length) + '...';
214
- }
215
-
216
- /**
217
- * This component is a base in order to create a component that supports ngModel.
218
- * Some important things to know about it:
219
- *
220
- * innerValue = your own inner state, which you should use to store the current state of what ngModel should be.
221
- * writeValue() = called by angular, when ngModel is changed from OUTSIDE of the component. Feel free to patch this method if you need inner logic to happen when ngModel is altered from the outside. Always remember to also call the super.writeValue if you do!
222
- * setInnerValueAndNotify() = call this when you want your ngModel to be updated from INSIDE of your component, and provide it to the OUTSIDE.
223
- * ngOnInit() = Used to support the angular reactive forms framework. If you use ngOnInit in your own component (which happens fairly often) you must not forget to call the super.ngOnInit() method.
224
- */
225
- var ValueAccessorBase = /** @class */ (function () {
226
- function ValueAccessorBase(parent, controlContainer) {
227
- this.parent = parent;
228
- this.controlContainer = controlContainer;
229
- this.changed = new Array();
230
- this.touched = new Array();
231
- this.disabled = false;
232
- // we support both providing just the formControlName and the full formControl
233
- this.formControlName = null;
234
- this.formControl = null;
235
- }
236
- ValueAccessorBase.prototype.ngOnInit = function () {
237
- var _this = this;
238
- var _a, _b, _c;
239
- if (this.formControl) {
240
- this.attachedFormControl = this.formControl;
241
- }
242
- else if (stringIsSetAndNotEmpty(this.formControlName)) {
243
- this.attachedFormControl = (_a = this.controlContainer) === null || _a === void 0 ? void 0 : _a.control.get(this.formControlName);
244
- if (isNullOrUndefined(this.attachedFormControl)) {
245
- throw new Error("Form element '" + this.formControlName + "' with caption '" + ((_b = this.parent) === null || _b === void 0 ? void 0 : _b.caption) + "' is not declared in your FormGroup.");
246
- }
247
- }
248
- if (this.attachedFormControl) {
249
- this.disabled = this.attachedFormControl.disabled;
250
- this.attachedFormControl.statusChanges.subscribe(function () {
251
- _this.disabled = _this.attachedFormControl.disabled;
252
- });
253
- (_c = this.parent) === null || _c === void 0 ? void 0 : _c.registerControl(this.attachedFormControl);
254
- }
255
- };
256
- ValueAccessorBase.prototype.isInErrorState = function () {
257
- return this.attachedFormControl && this.attachedFormControl.status === 'INVALID' && this.attachedFormControl.touched;
258
- };
259
- ValueAccessorBase.prototype.ngOnDestroy = function () {
260
- var _a;
261
- if (this.attachedFormControl) {
262
- (_a = this.parent) === null || _a === void 0 ? void 0 : _a.unregisterControl(this.attachedFormControl);
263
- }
264
- };
265
- ValueAccessorBase.prototype.touch = function () {
266
- this.touched.forEach(function (f) { return f(); });
267
- };
268
- ValueAccessorBase.prototype.writeValue = function (value) {
269
- this.innerValue = value;
270
- };
271
- ValueAccessorBase.prototype.registerOnChange = function (fn) {
272
- this.changed.push(fn);
273
- };
274
- ValueAccessorBase.prototype.registerOnTouched = function (fn) {
275
- this.touched.push(fn);
276
- };
277
- ValueAccessorBase.prototype.setInnerValueAndNotify = function (value) {
278
- this.innerValue = value;
279
- this.changed.forEach(function (fn) { return fn(value); });
280
- };
281
- ValueAccessorBase.prototype.resetToNull = function () {
282
- this.setInnerValueAndNotify(null);
283
- };
284
- return ValueAccessorBase;
285
- }());
286
- ValueAccessorBase.decorators = [
287
- { type: core.Component, args: [{
288
- selector: '',
289
- template: ''
290
- },] }
291
- ];
292
- ValueAccessorBase.ctorParameters = function () { return [
293
- { type: FormElementComponent, decorators: [{ type: core.Host }, { type: core.Optional }] },
294
- { type: forms.ControlContainer, decorators: [{ type: core.Host }, { type: core.Optional }] }
295
- ]; };
296
- ValueAccessorBase.propDecorators = {
297
- disabled: [{ type: core.Input }],
298
- formControlName: [{ type: core.Input }],
299
- formControl: [{ type: core.Input }]
300
- };
301
-
302
- var ButtonComponent = /** @class */ (function () {
303
- function ButtonComponent() {
304
- this.variant = 'white';
305
- this.size = 'medium';
306
- this.fullWidth = false;
307
- this.hasBorder = true;
308
- this.disabled = false;
309
- this.isLoading = false;
310
- this.type = 'button';
311
- }
312
- Object.defineProperty(ButtonComponent.prototype, "_", {
313
- get: function () {
314
- return this.fullWidth;
315
- },
316
- enumerable: false,
317
- configurable: true
318
- });
319
- ButtonComponent.prototype.onClick = function (event) {
320
- if (this.disabled) {
321
- event.stopPropagation();
322
- }
323
- };
324
- return ButtonComponent;
325
- }());
326
- ButtonComponent.decorators = [
327
- { type: core.Component, args: [{
328
- selector: 'klp-form-button',
329
- 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",
330
- 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}"]
331
- },] }
332
- ];
333
- ButtonComponent.propDecorators = {
334
- variant: [{ type: core.Input }],
335
- size: [{ type: core.Input }],
336
- fullWidth: [{ type: core.Input }],
337
- hasBorder: [{ type: core.Input }],
338
- disabled: [{ type: core.Input }],
339
- isLoading: [{ type: core.Input }],
340
- type: [{ type: core.Input }],
341
- _: [{ type: core.HostBinding, args: ['class._fullWidth',] }]
342
- };
343
-
344
- /*! *****************************************************************************
345
- Copyright (c) Microsoft Corporation.
346
-
347
- Permission to use, copy, modify, and/or distribute this software for any
348
- purpose with or without fee is hereby granted.
349
-
350
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
351
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
352
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
353
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
354
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
355
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
356
- PERFORMANCE OF THIS SOFTWARE.
357
- ***************************************************************************** */
358
- /* global Reflect, Promise */
359
- var extendStatics = function (d, b) {
360
- extendStatics = Object.setPrototypeOf ||
361
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
362
- function (d, b) { for (var p in b)
363
- if (Object.prototype.hasOwnProperty.call(b, p))
364
- d[p] = b[p]; };
365
- return extendStatics(d, b);
366
- };
367
- function __extends(d, b) {
368
- if (typeof b !== "function" && b !== null)
369
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
370
- extendStatics(d, b);
371
- function __() { this.constructor = d; }
372
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
373
- }
374
- var __assign = function () {
375
- __assign = Object.assign || function __assign(t) {
376
- for (var s, i = 1, n = arguments.length; i < n; i++) {
377
- s = arguments[i];
378
- for (var p in s)
379
- if (Object.prototype.hasOwnProperty.call(s, p))
380
- t[p] = s[p];
381
- }
382
- return t;
383
- };
384
- return __assign.apply(this, arguments);
385
- };
386
- function __rest(s, e) {
387
- var t = {};
388
- for (var p in s)
389
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
390
- t[p] = s[p];
391
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
392
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
393
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
394
- t[p[i]] = s[p[i]];
395
- }
396
- return t;
397
- }
398
- function __decorate(decorators, target, key, desc) {
399
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
400
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
401
- r = Reflect.decorate(decorators, target, key, desc);
402
- else
403
- for (var i = decorators.length - 1; i >= 0; i--)
404
- if (d = decorators[i])
405
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
406
- return c > 3 && r && Object.defineProperty(target, key, r), r;
407
- }
408
- function __param(paramIndex, decorator) {
409
- return function (target, key) { decorator(target, key, paramIndex); };
410
- }
411
- function __metadata(metadataKey, metadataValue) {
412
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
413
- return Reflect.metadata(metadataKey, metadataValue);
414
- }
415
- function __awaiter(thisArg, _arguments, P, generator) {
416
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
417
- return new (P || (P = Promise))(function (resolve, reject) {
418
- function fulfilled(value) { try {
419
- step(generator.next(value));
420
- }
421
- catch (e) {
422
- reject(e);
423
- } }
424
- function rejected(value) { try {
425
- step(generator["throw"](value));
426
- }
427
- catch (e) {
428
- reject(e);
429
- } }
430
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
431
- step((generator = generator.apply(thisArg, _arguments || [])).next());
432
- });
78
+ function __awaiter(thisArg, _arguments, P, generator) {
79
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
80
+ return new (P || (P = Promise))(function (resolve, reject) {
81
+ function fulfilled(value) { try {
82
+ step(generator.next(value));
83
+ }
84
+ catch (e) {
85
+ reject(e);
86
+ } }
87
+ function rejected(value) { try {
88
+ step(generator["throw"](value));
89
+ }
90
+ catch (e) {
91
+ reject(e);
92
+ } }
93
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
94
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
95
+ });
433
96
  }
434
97
  function __generator(thisArg, body) {
435
98
  var _ = { label: 0, sent: function () { if (t[0] & 1)
@@ -659,6 +322,398 @@
659
322
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
660
323
  }
661
324
 
325
+ function stringIsSetAndNotEmpty(s) {
326
+ return lodash.isString(s) && s.length > 0;
327
+ }
328
+ function isNullOrUndefined(value) {
329
+ return value === null || value === undefined;
330
+ }
331
+ function numberIsSet(value) {
332
+ return isValueSet(value) && typeof value === 'number';
333
+ }
334
+ function isValueSet(value) {
335
+ return value !== null && value !== undefined;
336
+ }
337
+ function stringOrArrayIsSetAndEmpty(value) {
338
+ return value !== null && value !== undefined && value.length === 0;
339
+ }
340
+ function useIfStringIsSet(s) {
341
+ if (stringIsSetAndNotEmpty(s)) {
342
+ return s;
343
+ }
344
+ return undefined;
345
+ }
346
+ function useIfArrayIsSetWithOneItem(a) {
347
+ if (!isNullOrUndefined(a) && a.length === 1) {
348
+ return a[0];
349
+ }
350
+ return undefined;
351
+ }
352
+ function convertParentToChild(originalClass, newClass) {
353
+ return Object.assign(newClass, originalClass);
354
+ }
355
+ function truncateString(s, length) {
356
+ if (s.length < length) {
357
+ return s;
358
+ }
359
+ return s.substring(0, length) + '...';
360
+ }
361
+
362
+ var invalidFieldsSymbol = Symbol('Not all fields are valid');
363
+ // Only used as a 'marker' to define a property will be filled in by a sub form
364
+ var SubForm = /** @class */ (function (_super) {
365
+ __extends(SubForm, _super);
366
+ function SubForm() {
367
+ return _super.call(this, {}, null) || this;
368
+ }
369
+ return SubForm;
370
+ }(forms.FormGroup));
371
+ var FormComponent = /** @class */ (function () {
372
+ function FormComponent(parent, surroundingFormGroupName) {
373
+ this.parent = parent;
374
+ this.surroundingFormGroupName = surroundingFormGroupName;
375
+ // we keep track of what form controls are actually rendered. Only those count when looking at form validation
376
+ this.activeControls = [];
377
+ }
378
+ FormComponent.prototype.ngOnInit = function () {
379
+ var _a;
380
+ if (this.parent && isValueSet((_a = this.surroundingFormGroupName) === null || _a === void 0 ? void 0 : _a.name)) {
381
+ var groupName = String(this.surroundingFormGroupName.name);
382
+ var groupToOverwrite = this.parent.formGroup.get(groupName);
383
+ if (groupToOverwrite instanceof SubForm) {
384
+ this.parent.formGroup.setControl(groupName, this.formGroup);
385
+ }
386
+ }
387
+ };
388
+ FormComponent.prototype.registerControl = function (formControl, formElement) {
389
+ this.activeControls.push({ formControl: formControl, formElement: formElement });
390
+ if (this.parent) {
391
+ this.parent.registerControl(formControl, formElement);
392
+ }
393
+ };
394
+ FormComponent.prototype.unregisterControl = function (formControl) {
395
+ this.activeControls = this.activeControls.filter(function (e) { return e.formControl !== formControl; });
396
+ if (this.parent) {
397
+ this.parent.unregisterControl(formControl);
398
+ }
399
+ };
400
+ FormComponent.prototype.addFormGroupControls = function (formGroup, result) {
401
+ var _this = this;
402
+ Object.values(formGroup.controls).forEach(function (value) {
403
+ if (value instanceof forms.FormGroup) {
404
+ _this.addFormGroupControls(value, result);
405
+ }
406
+ else if (value instanceof forms.FormArray) {
407
+ _this.addFormArrayControls(value, result);
408
+ }
409
+ else if (value instanceof forms.FormControl) {
410
+ _this.addFormControl(value, result);
411
+ }
412
+ });
413
+ };
414
+ FormComponent.prototype.addFormArrayControls = function (formArray, result) {
415
+ var _this = this;
416
+ formArray.controls.forEach(function (value) {
417
+ if (value instanceof forms.FormGroup) {
418
+ _this.addFormGroupControls(value, result);
419
+ }
420
+ else if (value instanceof forms.FormArray) {
421
+ _this.addFormArrayControls(value, result);
422
+ }
423
+ else if (value instanceof forms.FormControl) {
424
+ _this.addFormControl(value, result);
425
+ }
426
+ });
427
+ };
428
+ FormComponent.prototype.getAllFormControls = function () {
429
+ var result = [];
430
+ this.addFormGroupControls(this.formGroup, result);
431
+ return result;
432
+ };
433
+ FormComponent.prototype.addFormControl = function (control, result) {
434
+ result.push(control);
435
+ };
436
+ FormComponent.prototype.disableInactiveFormControl = function (control) {
437
+ if (!this.activeControls.some(function (e) { return e.formControl === control; })) {
438
+ control.disable();
439
+ }
440
+ };
441
+ FormComponent.prototype.trySubmit = function () {
442
+ var _this = this;
443
+ var _a, _b;
444
+ this.formGroup.markAllAsTouched();
445
+ var allControls = this.getAllFormControls();
446
+ var originalDisabledStates = allControls.map(function (e) {
447
+ return { control: e, disabled: e.disabled };
448
+ });
449
+ allControls.forEach(function (e) { return _this.disableInactiveFormControl(e); });
450
+ var values = this.formGroup.value;
451
+ if (this.formGroup.valid) {
452
+ this.setDisabledStatesForAllControls(originalDisabledStates);
453
+ return Promise.resolve(values);
454
+ }
455
+ else {
456
+ (_b = (_a = this.activeControls.find(function (e) { return !e.formControl.valid; })) === null || _a === void 0 ? void 0 : _a.formElement) === null || _b === void 0 ? void 0 : _b.scrollTo();
457
+ this.setDisabledStatesForAllControls(originalDisabledStates);
458
+ return Promise.reject(invalidFieldsSymbol);
459
+ }
460
+ };
461
+ FormComponent.prototype.setDisabledStatesForAllControls = function (originalDisabledStates) {
462
+ originalDisabledStates.forEach(function (e) {
463
+ if (e.disabled) {
464
+ e.control.disable();
465
+ }
466
+ else {
467
+ e.control.enable();
468
+ }
469
+ });
470
+ };
471
+ return FormComponent;
472
+ }());
473
+ FormComponent.decorators = [
474
+ { type: core.Component, args: [{
475
+ selector: 'klp-form',
476
+ template: "<form>\n\t<ng-content></ng-content>\n</form>\n\n\n",
477
+ styles: [":host{display:block}:host.row{display:flex}"]
478
+ },] }
479
+ ];
480
+ FormComponent.ctorParameters = function () { return [
481
+ { type: FormComponent, decorators: [{ type: core.SkipSelf }, { type: core.Optional }] },
482
+ { type: forms.FormGroupName, decorators: [{ type: core.Optional }] }
483
+ ]; };
484
+ FormComponent.propDecorators = {
485
+ formGroup: [{ type: core.Input }]
486
+ };
487
+
488
+ var FORM_ERROR_MESSAGES = new core.InjectionToken('form.error.messages');
489
+ var DEFAULT_ERROR_MESSAGES = {
490
+ min: "Use a number larger than %min%",
491
+ max: "Use a number smaller than %max%",
492
+ required: "This field is required",
493
+ email: "Use a valid email address",
494
+ minLength: "Has to be longer than %minLength% character(s)",
495
+ maxLength: "Has to be shorter than %maxLength% character(s)",
496
+ pattern: "This input is not valid",
497
+ matchPassword: "Passwords must match",
498
+ date: "Enter a valid date",
499
+ };
500
+ var FormElementComponent = /** @class */ (function () {
501
+ function FormElementComponent(parent, customMessages) {
502
+ this.parent = parent;
503
+ this.customMessages = customMessages;
504
+ this.direction = 'horizontal';
505
+ this.captionSpacing = 'percentages';
506
+ this.swapInputAndCaption = false;
507
+ this.errorMessages = DEFAULT_ERROR_MESSAGES;
508
+ this.customErrorHandlers = [];
509
+ }
510
+ FormElementComponent.prototype.substituteParameters = function (message, parameters) {
511
+ return Object.keys(parameters).reduce(function (msg, key) {
512
+ return msg.replace("%" + key + "%", parameters[key]);
513
+ }, message);
514
+ };
515
+ FormElementComponent.prototype.registerControl = function (formControl) {
516
+ // console.log('register');
517
+ // console.log(this.caption);
518
+ this.attachedControl = formControl;
519
+ this.parent.registerControl(formControl, this);
520
+ };
521
+ FormElementComponent.prototype.unregisterControl = function (formControl) {
522
+ this.attachedControl = null;
523
+ this.parent.unregisterControl(formControl);
524
+ };
525
+ FormElementComponent.prototype.getAttachedControl = function () {
526
+ return this.attachedControl;
527
+ };
528
+ FormElementComponent.prototype.registerErrorHandler = function (error, templateRef) {
529
+ this.customErrorHandlers.push({ error: error, templateRef: templateRef });
530
+ };
531
+ FormElementComponent.prototype.registerCaption = function (templateRef) {
532
+ this.captionRef = templateRef;
533
+ };
534
+ FormElementComponent.prototype.getErrorToShow = function () {
535
+ var _a, _b, _c;
536
+ if (((_a = this.attachedControl) === null || _a === void 0 ? void 0 : _a.touched) === true && ((_b = this.attachedControl) === null || _b === void 0 ? void 0 : _b.errors)) {
537
+ return Object.keys((_c = this.attachedControl) === null || _c === void 0 ? void 0 : _c.errors)[0];
538
+ }
539
+ return null;
540
+ };
541
+ FormElementComponent.prototype.getCustomErrorHandler = function (error) {
542
+ return this.customErrorHandlers.find(function (e) { return e.error === error; });
543
+ };
544
+ FormElementComponent.prototype.showDefaultError = function (error) {
545
+ return this.getErrorToShow() === error && !this.customErrorHandlers.some(function (e) { return e.error === error; });
546
+ };
547
+ FormElementComponent.prototype.getScrollableParent = function (node) {
548
+ if (node == null) {
549
+ return null;
550
+ }
551
+ if (node.scrollHeight > node.clientHeight) {
552
+ return node;
553
+ }
554
+ else {
555
+ return this.getScrollableParent(node.parentNode);
556
+ }
557
+ };
558
+ FormElementComponent.prototype.scrollTo = function () {
559
+ var _a;
560
+ this.internalComponentRef.nativeElement.scrollIntoView(true);
561
+ // to give some breathing room, we scroll 100px more to the top
562
+ (_a = this.getScrollableParent(this.internalComponentRef.nativeElement)) === null || _a === void 0 ? void 0 : _a.scrollBy(0, -100);
563
+ };
564
+ FormElementComponent.prototype.getErrorMessages = function (key) {
565
+ var _a, _b, _c;
566
+ 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];
567
+ };
568
+ return FormElementComponent;
569
+ }());
570
+ FormElementComponent.decorators = [
571
+ { type: core.Component, args: [{
572
+ selector: 'klp-form-element',
573
+ 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",
574
+ 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%}"]
575
+ },] }
576
+ ];
577
+ FormElementComponent.ctorParameters = function () { return [
578
+ { type: FormComponent, decorators: [{ type: core.Host }, { type: core.Optional }] },
579
+ { type: undefined, decorators: [{ type: core.Inject, args: [FORM_ERROR_MESSAGES,] }, { type: core.Optional }] }
580
+ ]; };
581
+ FormElementComponent.propDecorators = {
582
+ caption: [{ type: core.Input }],
583
+ direction: [{ type: core.Input }],
584
+ captionSpacing: [{ type: core.Input }],
585
+ swapInputAndCaption: [{ type: core.Input }],
586
+ internalComponentRef: [{ type: core.ViewChild, args: ['internalComponentRef',] }]
587
+ };
588
+
589
+ /**
590
+ * This component is a base in order to create a component that supports ngModel.
591
+ * Some important things to know about it:
592
+ *
593
+ * innerValue = your own inner state, which you should use to store the current state of what ngModel should be.
594
+ * writeValue() = called by angular, when ngModel is changed from OUTSIDE of the component. Feel free to patch this method if you need inner logic to happen when ngModel is altered from the outside. Always remember to also call the super.writeValue if you do!
595
+ * setInnerValueAndNotify() = call this when you want your ngModel to be updated from INSIDE of your component, and provide it to the OUTSIDE.
596
+ * ngOnInit() = Used to support the angular reactive forms framework. If you use ngOnInit in your own component (which happens fairly often) you must not forget to call the super.ngOnInit() method.
597
+ */
598
+ var ValueAccessorBase = /** @class */ (function () {
599
+ function ValueAccessorBase(parent, controlContainer) {
600
+ this.parent = parent;
601
+ this.controlContainer = controlContainer;
602
+ this.changed = new Array();
603
+ this.touched = new Array();
604
+ this.disabled = false;
605
+ // we support both providing just the formControlName and the full formControl
606
+ this.formControlName = null;
607
+ this.formControl = null;
608
+ }
609
+ ValueAccessorBase.prototype.ngOnInit = function () {
610
+ var _this = this;
611
+ var _a, _b, _c;
612
+ if (this.formControl) {
613
+ this.attachedFormControl = this.formControl;
614
+ }
615
+ else if (stringIsSetAndNotEmpty(this.formControlName)) {
616
+ this.attachedFormControl = (_a = this.controlContainer) === null || _a === void 0 ? void 0 : _a.control.get(this.formControlName);
617
+ if (isNullOrUndefined(this.attachedFormControl)) {
618
+ throw new Error("Form element '" + this.formControlName + "' with caption '" + ((_b = this.parent) === null || _b === void 0 ? void 0 : _b.caption) + "' is not declared in your FormGroup.");
619
+ }
620
+ }
621
+ if (this.attachedFormControl) {
622
+ this.disabled = this.attachedFormControl.disabled;
623
+ this.attachedFormControl.statusChanges.subscribe(function () {
624
+ _this.disabled = _this.attachedFormControl.disabled;
625
+ });
626
+ (_c = this.parent) === null || _c === void 0 ? void 0 : _c.registerControl(this.attachedFormControl);
627
+ }
628
+ };
629
+ ValueAccessorBase.prototype.isInErrorState = function () {
630
+ return this.attachedFormControl && this.attachedFormControl.status === 'INVALID' && this.attachedFormControl.touched;
631
+ };
632
+ ValueAccessorBase.prototype.ngOnDestroy = function () {
633
+ var _a;
634
+ if (this.attachedFormControl) {
635
+ (_a = this.parent) === null || _a === void 0 ? void 0 : _a.unregisterControl(this.attachedFormControl);
636
+ }
637
+ };
638
+ ValueAccessorBase.prototype.touch = function () {
639
+ this.touched.forEach(function (f) { return f(); });
640
+ };
641
+ ValueAccessorBase.prototype.writeValue = function (value) {
642
+ this.innerValue = value;
643
+ };
644
+ ValueAccessorBase.prototype.registerOnChange = function (fn) {
645
+ this.changed.push(fn);
646
+ };
647
+ ValueAccessorBase.prototype.registerOnTouched = function (fn) {
648
+ this.touched.push(fn);
649
+ };
650
+ ValueAccessorBase.prototype.setInnerValueAndNotify = function (value) {
651
+ this.innerValue = value;
652
+ this.changed.forEach(function (fn) { return fn(value); });
653
+ };
654
+ ValueAccessorBase.prototype.resetToNull = function () {
655
+ this.setInnerValueAndNotify(null);
656
+ };
657
+ return ValueAccessorBase;
658
+ }());
659
+ ValueAccessorBase.decorators = [
660
+ { type: core.Component, args: [{
661
+ selector: '',
662
+ template: ''
663
+ },] }
664
+ ];
665
+ ValueAccessorBase.ctorParameters = function () { return [
666
+ { type: FormElementComponent, decorators: [{ type: core.Host }, { type: core.Optional }] },
667
+ { type: forms.ControlContainer, decorators: [{ type: core.Host }, { type: core.Optional }] }
668
+ ]; };
669
+ ValueAccessorBase.propDecorators = {
670
+ disabled: [{ type: core.Input }],
671
+ formControlName: [{ type: core.Input }],
672
+ formControl: [{ type: core.Input }]
673
+ };
674
+
675
+ var ButtonComponent = /** @class */ (function () {
676
+ function ButtonComponent() {
677
+ this.variant = 'white';
678
+ this.size = 'medium';
679
+ this.fullWidth = false;
680
+ this.hasBorder = true;
681
+ this.disabled = false;
682
+ this.isLoading = false;
683
+ this.type = 'button';
684
+ }
685
+ Object.defineProperty(ButtonComponent.prototype, "_", {
686
+ get: function () {
687
+ return this.fullWidth;
688
+ },
689
+ enumerable: false,
690
+ configurable: true
691
+ });
692
+ ButtonComponent.prototype.onClick = function (event) {
693
+ if (this.disabled) {
694
+ event.stopPropagation();
695
+ }
696
+ };
697
+ return ButtonComponent;
698
+ }());
699
+ ButtonComponent.decorators = [
700
+ { type: core.Component, args: [{
701
+ selector: 'klp-form-button',
702
+ 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",
703
+ 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}"]
704
+ },] }
705
+ ];
706
+ ButtonComponent.propDecorators = {
707
+ variant: [{ type: core.Input }],
708
+ size: [{ type: core.Input }],
709
+ fullWidth: [{ type: core.Input }],
710
+ hasBorder: [{ type: core.Input }],
711
+ disabled: [{ type: core.Input }],
712
+ isLoading: [{ type: core.Input }],
713
+ type: [{ type: core.Input }],
714
+ _: [{ type: core.HostBinding, args: ['class._fullWidth',] }]
715
+ };
716
+
662
717
  var CheckboxComponent = /** @class */ (function (_super) {
663
718
  __extends(CheckboxComponent, _super);
664
719
  function CheckboxComponent() {
@@ -768,6 +823,7 @@
768
823
  _this.placeholder = 'Pick an option';
769
824
  _this.multiple = false;
770
825
  _this.clearable = true;
826
+ _this.onSearch = new core.EventEmitter();
771
827
  return _this;
772
828
  }
773
829
  return SelectComponent;
@@ -775,7 +831,7 @@
775
831
  SelectComponent.decorators = [
776
832
  { type: core.Component, args: [{
777
833
  selector: 'klp-form-select',
778
- template: "<ng-select\n\t[placeholder]=\"placeholder\"\n\tbindLabel=\"name\"\n\tbindValue=\"id\"\n\t[items]=\"options\"\n\t[clearable]=\"clearable\"\n\t[(ngModel)]=\"innerValue\"\n\t[ngClass]=\"{showErrors: isInErrorState()}\"\n\t(change)=\"setInnerValueAndNotify(innerValue)\"\n\t[multiple]=\"multiple\"\n\t[disabled]=\"disabled\"\n\t(blur)=\"touch()\"\n\t[dropdownPosition]=\"dropdownPosition\"\n\t[searchFn]=\"customSearchFn\"\n>\n\t<ng-template let-item=\"item\" ng-option-tmp>\n\t\t{{ item.name }}\n\t\t<div *ngIf=\"item.description\" class=\"dropdown-item-description\">\n\t\t\t{{ item.description }}\n\t\t</div>\n\t</ng-template>\n</ng-select>\n",
834
+ template: "<ng-select\n\t[placeholder]=\"placeholder\"\n\tbindLabel=\"name\"\n\tbindValue=\"id\"\n\t[items]=\"options\"\n\t[clearable]=\"clearable\"\n\t[(ngModel)]=\"innerValue\"\n\t[ngClass]=\"{showErrors: isInErrorState()}\"\n\t(change)=\"setInnerValueAndNotify(innerValue)\"\n\t[multiple]=\"multiple\"\n\t[disabled]=\"disabled\"\n\t(blur)=\"touch()\"\n\t(search)=\"onSearch.emit($event.term)\"\n\t[dropdownPosition]=\"dropdownPosition\"\n\t[searchFn]=\"customSearchFn\"\n>\n\t<ng-template let-item=\"item\" ng-option-tmp>\n\t\t{{ item.name }}\n\t\t<div *ngIf=\"item.description\" class=\"dropdown-item-description\">\n\t\t\t{{ item.description }}\n\t\t</div>\n\t</ng-template>\n</ng-select>\n",
779
835
  providers: [{ provide: forms.NG_VALUE_ACCESSOR, useExisting: SelectComponent, multi: true }],
780
836
  styles: [":host{display:block}.showErrors ::ng-deep .ng-select-container,:host.showErrors ::ng-deep .ng-select-container{border-color:#ff8000}:host ::ng-deep ng-select.ng-select .ng-select-container{color:#888da8}:host ::ng-deep .ng-select.ng-select-opened>.ng-select-container{background:#fff;border-color:#3ed778}:host ::ng-deep .ng-select.ng-select-opened>.ng-select-container:hover{box-shadow:none}:host ::ng-deep .ng-select.ng-select-opened>.ng-select-container .ng-arrow{border-color:transparent transparent #999;border-width:0 5px 5px;top:-2px}:host ::ng-deep .ng-select.ng-select-opened>.ng-select-container .ng-arrow:hover{border-color:transparent transparent #666}:host ::ng-deep .ng-select.ng-select-opened.ng-select-bottom>.ng-select-container{border-bottom-left-radius:0;border-bottom-right-radius:0}:host ::ng-deep .ng-select.ng-select-opened.ng-select-top>.ng-select-container{border-top-left-radius:0;border-top-right-radius:0}:host ::ng-deep .ng-select.ng-select-disabled>.ng-select-container{background-color:#f9f9f9}:host ::ng-deep .ng-select .ng-has-value .ng-placeholder{display:none}:host ::ng-deep .ng-select .ng-select-container{align-items:center;background-clip:padding-box;background-color:#fff;border:1px solid #e6ecf5;border-radius:4px;border-radius:2px;box-shadow:none;box-sizing:border-box;color:#888da8;display:flex;flex-direction:row;font-size:1rem;font-size:14px;line-height:1.5;margin:0;min-height:42px;outline:none;overflow:visible;padding:.375rem .75rem;transition-delay:0s;transition-duration:.2s;transition-property:all;transition-timing-function:ease-in;width:100%}:host ::ng-deep .ng-select .ng-select-container:hover{box-shadow:0 1px 0 rgba(0,0,0,.06)}:host ::ng-deep .ng-select .ng-select-container .ng-value-container{align-items:center;overflow:hidden;padding-left:10px}:host ::ng-deep .ng-select .ng-select-container .ng-value-container .ng-placeholder{color:#aaa}:host ::ng-deep .ng-select.ng-select-single .ng-select-container{height:42px}:host ::ng-deep .ng-select.ng-select-single .ng-select-container .ng-value-container .ng-input{left:0;padding-left:10px;padding-right:50px;top:5px}:host ::ng-deep .ng-select.ng-select-multiple.ng-select-disabled>.ng-select-container .ng-value-container .ng-value{background-color:#f9f9f9;border:1px solid #e3e3e3}:host ::ng-deep .ng-select.ng-select-multiple.ng-select-disabled>.ng-select-container .ng-value-container .ng-value .ng-value-label{padding:0 5px}:host ::ng-deep .ng-select.ng-select-multiple .ng-select-container .ng-value-container{padding-left:7px;padding-right:10px;padding-top:2px}:host ::ng-deep .ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value{background-color:#e7faee;border:1px solid #93e8b3;border-radius:2px;display:flex;font-size:.9em;margin-bottom:5px;margin-right:5px;overflow:hidden}:host ::ng-deep .ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value.ng-value-disabled{background-color:#f9f9f9;border:1px solid #e3e3e3}:host ::ng-deep .ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value.ng-value-disabled .ng-value-label{padding-left:5px}:host ::ng-deep .ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value .ng-value-label{display:inline-block;overflow:hidden;padding:0 5px;text-overflow:ellipsis}:host ::ng-deep .ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value .ng-value-icon{display:inline-block;padding:0 5px}:host ::ng-deep .ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value .ng-value-icon:hover{background-color:#93e8b3}:host ::ng-deep .ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value .ng-value-icon.left{border-right:1px solid #93e8b3}:host ::ng-deep .ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value .ng-value-icon.right{border-left:1px solid #c2e0ff}:host ::ng-deep .ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-input{padding-bottom:3px;padding-left:3px}:host ::ng-deep ng-select.ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-placeholder{padding-bottom:3px;padding-left:3px;position:static;top:5px}:host ::ng-deep .ng-select .ng-clear-wrapper{color:#999}:host ::ng-deep .ng-select .ng-clear-wrapper .ng-clear:hover{color:#ff3c7e}:host ::ng-deep .ng-select .ng-spinner-zone{padding-right:5px;padding-top:5px}:host ::ng-deep .ng-select .ng-arrow-wrapper{padding-right:5px;width:25px}:host ::ng-deep .ng-select .ng-arrow-wrapper:hover .ng-arrow{border-top-color:#666}:host ::ng-deep .ng-select .ng-arrow-wrapper .ng-arrow{border-color:#999 transparent transparent;border-style:solid;border-width:5px 5px 2.5px}:host ::ng-deep .ng-dropdown-panel{background-color:#fff;border:1px solid #3ed778;box-shadow:0 1px 0 rgba(0,0,0,.06)}:host ::ng-deep .ng-dropdown-panel.ng-select-bottom{border-bottom-left-radius:4px;border-bottom-right-radius:4px;border-top-color:#e6e6e6;margin-top:-1px;top:100%}:host ::ng-deep .ng-dropdown-panel.ng-select-bottom .ng-dropdown-panel-items .ng-option:last-child{border-bottom-left-radius:4px;border-bottom-right-radius:4px}:host ::ng-deep .ng-dropdown-panel.ng-select-top{border-bottom-color:#e6e6e6;border-top-left-radius:4px;border-top-right-radius:4px;bottom:100%;margin-bottom:-1px}:host ::ng-deep .ng-dropdown-panel.ng-select-top .ng-dropdown-panel-items .ng-option:first-child{border-top-left-radius:4px;border-top-right-radius:4px}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-header{border-bottom:1px solid #ccc;padding:5px 7px}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-footer{border-top:1px solid #ccc;padding:5px 7px}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items{margin-bottom:1px}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-optgroup{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;color:rgba(0,0,0,.54);cursor:default;cursor:pointer;font-weight:500;padding:8px 10px;user-select:none}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-optgroup.ng-option-disabled{cursor:default}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-optgroup.ng-option-marked{background-color:#ebf5ff}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-optgroup.ng-option-selected{background-color:#f5faff;font-weight:600}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-option{background-color:#fff;color:rgba(0,0,0,.87);padding:8px 10px}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-option.ng-option-selected{background-color:#e7faee;color:#333}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-option.ng-option-selected .ng-option-label{font-weight:600}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-option.ng-option-marked{background-color:#e7faee;color:#333}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-option.ng-option-disabled{color:#ccc}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-option.ng-option-child{padding-left:22px}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-option .ng-tag-label{font-size:80%;font-weight:400;padding-right:5px}:host ::ng-deep ng-select.ng-select .ng-select-container .ng-value-container{padding-left:0}:host ::ng-deep ng-select.ng-select.ng-select-single .ng-select-container .ng-value-container .ng-input{color:#888da8;top:9px}:host ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-option,:host ::ng-deep .ng-select .ng-select-container .ng-value-container .ng-input>input{color:#888da8}:host ::ng-deep .ng-select.ng-select-auto-grow{max-width:inherit}:host ::ng-deep .ng-select.ng-select-auto-grow .ng-dropdown-panel{width:auto}"]
781
837
  },] }
@@ -790,7 +846,8 @@
790
846
  multiple: [{ type: core.Input }],
791
847
  clearable: [{ type: core.Input }],
792
848
  dropdownPosition: [{ type: core.Input }],
793
- customSearchFn: [{ type: core.Input }]
849
+ customSearchFn: [{ type: core.Input }],
850
+ onSearch: [{ type: core.Output }]
794
851
  };
795
852
 
796
853
  var SortableItemsComponent = /** @class */ (function (_super) {
@@ -1191,6 +1248,7 @@
1191
1248
  exports.PasswordFieldComponent = PasswordFieldComponent;
1192
1249
  exports.SelectComponent = SelectComponent;
1193
1250
  exports.SortableItemsComponent = SortableItemsComponent;
1251
+ exports.SubForm = SubForm;
1194
1252
  exports.TextInputComponent = TextInputComponent;
1195
1253
  exports.ToggleComponent = ToggleComponent;
1196
1254
  exports.ValueAccessorBase = ValueAccessorBase;