cps-ui-kit 0.0.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.
- package/README.md +24 -0
- package/assets/icons/absa-logo.svg +12 -0
- package/assets/icons/access-denied.svg +12 -0
- package/assets/icons/access-menu.svg +11 -0
- package/assets/icons/access-unlock.svg +19 -0
- package/assets/icons/access.svg +9 -0
- package/assets/icons/add-domain.svg +8 -0
- package/assets/icons/add.svg +7 -0
- package/assets/icons/avatar-top-menu.svg +13 -0
- package/assets/icons/avatar.svg +8 -0
- package/assets/icons/bell.svg +7 -0
- package/assets/icons/book.svg +7 -0
- package/assets/icons/bookmark.svg +6 -0
- package/assets/icons/briefcase.svg +12 -0
- package/assets/icons/browse.svg +9 -0
- package/assets/icons/burger-arrow.svg +7 -0
- package/assets/icons/caret-down.svg +6 -0
- package/assets/icons/change.svg +6 -0
- package/assets/icons/checked.svg +15 -0
- package/assets/icons/chevron-down-2.svg +8 -0
- package/assets/icons/chevron-down.svg +6 -0
- package/assets/icons/circle.svg +6 -0
- package/assets/icons/close-x-2.svg +6 -0
- package/assets/icons/close-x.svg +8 -0
- package/assets/icons/community.svg +12 -0
- package/assets/icons/construction.svg +10 -0
- package/assets/icons/controls.svg +29 -0
- package/assets/icons/csv.svg +9 -0
- package/assets/icons/cub.svg +6 -0
- package/assets/icons/database.svg +12 -0
- package/assets/icons/datepicker.svg +8 -0
- package/assets/icons/delete.svg +6 -0
- package/assets/icons/dislike.svg +13 -0
- package/assets/icons/dots.svg +6 -0
- package/assets/icons/download.svg +12 -0
- package/assets/icons/dq.svg +24 -0
- package/assets/icons/dropdown-menu.svg +8 -0
- package/assets/icons/edit.svg +9 -0
- package/assets/icons/expand.svg +9 -0
- package/assets/icons/export.svg +6 -0
- package/assets/icons/eye.svg +8 -0
- package/assets/icons/filter.svg +8 -0
- package/assets/icons/filter_2.svg +11 -0
- package/assets/icons/follow.svg +13 -0
- package/assets/icons/glossary.svg +16 -0
- package/assets/icons/graph.svg +27 -0
- package/assets/icons/grid-view.svg +6 -0
- package/assets/icons/grid.svg +9 -0
- package/assets/icons/health.svg +6 -0
- package/assets/icons/heart.svg +6 -0
- package/assets/icons/help-circle.svg +7 -0
- package/assets/icons/home.svg +21 -0
- package/assets/icons/insight.svg +9 -0
- package/assets/icons/issues.svg +7 -0
- package/assets/icons/jpeg.svg +8 -0
- package/assets/icons/kris.svg +28 -0
- package/assets/icons/last-seen-product.svg +8 -0
- package/assets/icons/like.svg +7 -0
- package/assets/icons/line-vertical.svg +39 -0
- package/assets/icons/lock.svg +7 -0
- package/assets/icons/logout.svg +16 -0
- package/assets/icons/menu-expand.svg +17 -0
- package/assets/icons/minus.svg +10 -0
- package/assets/icons/multiple_users.svg +8 -0
- package/assets/icons/open.svg +7 -0
- package/assets/icons/path.svg +7 -0
- package/assets/icons/pdf.svg +9 -0
- package/assets/icons/plus.svg +6 -0
- package/assets/icons/projects.svg +10 -0
- package/assets/icons/question.svg +13 -0
- package/assets/icons/questions.svg +23 -0
- package/assets/icons/rectangle-rounded.svg +7 -0
- package/assets/icons/refresh-browse.svg +6 -0
- package/assets/icons/remove.svg +9 -0
- package/assets/icons/right.svg +7 -0
- package/assets/icons/schema_filter.svg +7 -0
- package/assets/icons/search.svg +9 -0
- package/assets/icons/settings.svg +9 -0
- package/assets/icons/sliders.svg +13 -0
- package/assets/icons/smart.svg +7 -0
- package/assets/icons/star.svg +6 -0
- package/assets/icons/stepper-completed.svg +6 -0
- package/assets/icons/success.svg +8 -0
- package/assets/icons/suggestion.svg +7 -0
- package/assets/icons/survivorship.svg +25 -0
- package/assets/icons/table-row-error.svg +6 -0
- package/assets/icons/table-row-success.svg +7 -0
- package/assets/icons/table-row-warning.svg +9 -0
- package/assets/icons/toast-error.svg +12 -0
- package/assets/icons/toast-info.svg +12 -0
- package/assets/icons/toast-success.svg +7 -0
- package/assets/icons/toast-warning.svg +12 -0
- package/assets/icons/tools.svg +18 -0
- package/assets/icons/user.svg +7 -0
- package/assets/icons/users.svg +10 -0
- package/assets/icons/vector-down.svg +7 -0
- package/assets/icons/vector-right.svg +6 -0
- package/assets/icons/vector-up.svg +7 -0
- package/assets/icons/vector.svg +7 -0
- package/assets/icons/wallet.svg +10 -0
- package/assets/icons/warning-circle.svg +12 -0
- package/assets/icons/warning.svg +7 -0
- package/assets/icons/widget-button-icon.svg +9 -0
- package/assets/icons/xls.svg +9 -0
- package/esm2020/cps-ui-kit.mjs +5 -0
- package/esm2020/lib/components/cps-button/cps-button.component.mjs +136 -0
- package/esm2020/lib/components/cps-checkbox/cps-checkbox.component.mjs +73 -0
- package/esm2020/lib/components/cps-chip/cps-chip.component.mjs +58 -0
- package/esm2020/lib/components/cps-icon/cps-icon.component.mjs +163 -0
- package/esm2020/lib/components/cps-input/cps-input.component.mjs +168 -0
- package/esm2020/lib/components/cps-radio/cps-radio.component.mjs +76 -0
- package/esm2020/lib/components/cps-select/cps-select.component.mjs +302 -0
- package/esm2020/lib/components/cps-tag/cps-tag.component.mjs +103 -0
- package/esm2020/lib/directives/click-outside.directive.mjs +32 -0
- package/esm2020/lib/pipes/combine-labels.pipe.mjs +24 -0
- package/esm2020/lib/pipes/label-by-value.pipe.mjs +15 -0
- package/esm2020/lib/utils/colors-utils.mjs +55 -0
- package/esm2020/lib/utils/size-utils.mjs +22 -0
- package/esm2020/public-api.mjs +12 -0
- package/fesm2015/cps-ui-kit.mjs +1210 -0
- package/fesm2015/cps-ui-kit.mjs.map +1 -0
- package/fesm2020/cps-ui-kit.mjs +1184 -0
- package/fesm2020/cps-ui-kit.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/cps-button/cps-button.component.d.ts +28 -0
- package/lib/components/cps-checkbox/cps-checkbox.component.d.ts +25 -0
- package/lib/components/cps-chip/cps-chip.component.d.ts +16 -0
- package/lib/components/cps-icon/cps-icon.component.d.ts +18 -0
- package/lib/components/cps-input/cps-input.component.d.ts +50 -0
- package/lib/components/cps-radio/cps-radio.component.d.ts +30 -0
- package/lib/components/cps-select/cps-select.component.d.ts +54 -0
- package/lib/components/cps-tag/cps-tag.component.d.ts +29 -0
- package/lib/directives/click-outside.directive.d.ts +10 -0
- package/lib/pipes/combine-labels.pipe.d.ts +7 -0
- package/lib/pipes/label-by-value.pipe.d.ts +7 -0
- package/lib/utils/colors-utils.d.ts +6 -0
- package/lib/utils/size-utils.d.ts +5 -0
- package/package.json +40 -0
- package/public-api.d.ts +8 -0
- package/styles/_colors.scss +456 -0
- package/styles/_variables.scss +1 -0
- package/styles/bootstrap-grid.css +4071 -0
- package/styles/styles.scss +2 -0
|
@@ -0,0 +1,1184 @@
|
|
|
1
|
+
import * as i2 from '@angular/common';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { Component, Input, EventEmitter, Self, Optional, Output, ViewChild, Directive, HostListener, Pipe, HostBinding } from '@angular/core';
|
|
5
|
+
import { Subscription } from 'rxjs';
|
|
6
|
+
import * as i1 from '@angular/forms';
|
|
7
|
+
import { FormsModule } from '@angular/forms';
|
|
8
|
+
|
|
9
|
+
const isSameDomain = (styleSheet) => {
|
|
10
|
+
if (!styleSheet.href) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return styleSheet.href.indexOf(window.location.origin) === 0;
|
|
14
|
+
};
|
|
15
|
+
const isStyleRule = (rule) => rule.type === 1;
|
|
16
|
+
const isValidCSSColor = (val) => {
|
|
17
|
+
if (val === 'currentColor')
|
|
18
|
+
return true;
|
|
19
|
+
const element = document.createElement('div');
|
|
20
|
+
element.style.backgroundColor = val;
|
|
21
|
+
return element && element.style.backgroundColor !== '';
|
|
22
|
+
};
|
|
23
|
+
const isDark = (color) => {
|
|
24
|
+
let r = 0;
|
|
25
|
+
let g = 0;
|
|
26
|
+
let b = 0;
|
|
27
|
+
if (color.match(/^rgb/)) {
|
|
28
|
+
const colorMatched = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);
|
|
29
|
+
r = colorMatched[1];
|
|
30
|
+
g = colorMatched[2];
|
|
31
|
+
b = colorMatched[3];
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const colorNum = +('0x' + color.slice(1).replace(color.length < 5 && /./g, '$&$&'));
|
|
35
|
+
r = colorNum >> 16;
|
|
36
|
+
g = (colorNum >> 8) & 255;
|
|
37
|
+
b = colorNum & 255;
|
|
38
|
+
}
|
|
39
|
+
const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b));
|
|
40
|
+
// Using the HSP value, determine whether the color is light or dark
|
|
41
|
+
return hsp <= 127.5;
|
|
42
|
+
};
|
|
43
|
+
const getCpsColors = () => [...document.styleSheets].filter(isSameDomain).reduce((finalArr, sheet) => finalArr.concat([...sheet.cssRules].filter(isStyleRule).reduce((propValArr, rule) => {
|
|
44
|
+
const props = [...rule.style]
|
|
45
|
+
.map((propName) => [
|
|
46
|
+
propName.trim(),
|
|
47
|
+
rule.style.getPropertyValue(propName).trim()
|
|
48
|
+
])
|
|
49
|
+
.filter(([propName]) => propName.indexOf('--cps-color') === 0);
|
|
50
|
+
return [...propValArr, ...props];
|
|
51
|
+
}, [])), []);
|
|
52
|
+
const getCSSColor = (val) => {
|
|
53
|
+
return isValidCSSColor(val) ? val : `var(--cps-color-${val})`;
|
|
54
|
+
};
|
|
55
|
+
const getTextColor = (backgroundColor) => {
|
|
56
|
+
if (isDark(backgroundColor)) {
|
|
57
|
+
return '#FFFFFF';
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return '#000000';
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const convertSize = (size) => {
|
|
65
|
+
const res = String(size).trim();
|
|
66
|
+
if (!res) {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
if (/^\d+(\.\d+)?$/i.test(res)) {
|
|
70
|
+
return res + 'px';
|
|
71
|
+
}
|
|
72
|
+
if (/^\d+(\.\d+)?(px|rem|em|%)$/i.test(res)) {
|
|
73
|
+
return res;
|
|
74
|
+
}
|
|
75
|
+
throw new Error(`Invalid size value: ${size}`);
|
|
76
|
+
};
|
|
77
|
+
const parseSize = (size) => {
|
|
78
|
+
const match = size.match(/^(\d+(?:\.\d+)?)(px|rem|em|%)$/);
|
|
79
|
+
if (!match)
|
|
80
|
+
throw new Error(`Invalid size value: ${size}`);
|
|
81
|
+
const value = parseFloat(match[1]);
|
|
82
|
+
const unit = match[2];
|
|
83
|
+
return { value, unit };
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const iconNames = [
|
|
87
|
+
'absa-logo',
|
|
88
|
+
'access',
|
|
89
|
+
'access-denied',
|
|
90
|
+
'access-menu',
|
|
91
|
+
'access-unlock',
|
|
92
|
+
'add',
|
|
93
|
+
'add-domain',
|
|
94
|
+
'avatar',
|
|
95
|
+
'avatar-top-menu',
|
|
96
|
+
'bell',
|
|
97
|
+
'book',
|
|
98
|
+
'bookmark',
|
|
99
|
+
'browse',
|
|
100
|
+
'burger-arrow',
|
|
101
|
+
'caret-down',
|
|
102
|
+
'change',
|
|
103
|
+
'checked',
|
|
104
|
+
'chevron-down',
|
|
105
|
+
'chevron-down-2',
|
|
106
|
+
'circle',
|
|
107
|
+
'close-x',
|
|
108
|
+
'close-x-2',
|
|
109
|
+
'community',
|
|
110
|
+
'construction',
|
|
111
|
+
'controls',
|
|
112
|
+
'csv',
|
|
113
|
+
'cub',
|
|
114
|
+
'database',
|
|
115
|
+
'datepicker',
|
|
116
|
+
'delete',
|
|
117
|
+
'dislike',
|
|
118
|
+
'dots',
|
|
119
|
+
'download',
|
|
120
|
+
'dq',
|
|
121
|
+
'dropdown-menu',
|
|
122
|
+
'edit',
|
|
123
|
+
'expand',
|
|
124
|
+
'export',
|
|
125
|
+
'eye',
|
|
126
|
+
'filter',
|
|
127
|
+
'filter_2',
|
|
128
|
+
'follow',
|
|
129
|
+
'glossary',
|
|
130
|
+
'graph',
|
|
131
|
+
'grid',
|
|
132
|
+
'grid-view',
|
|
133
|
+
'health',
|
|
134
|
+
'heart',
|
|
135
|
+
'help-circle',
|
|
136
|
+
'home',
|
|
137
|
+
'insight',
|
|
138
|
+
'issues',
|
|
139
|
+
'jpeg',
|
|
140
|
+
'kris',
|
|
141
|
+
'last-seen-product',
|
|
142
|
+
'like',
|
|
143
|
+
'line-vertical',
|
|
144
|
+
'lock',
|
|
145
|
+
'logout',
|
|
146
|
+
'menu-expand',
|
|
147
|
+
'minus',
|
|
148
|
+
'multiple_users',
|
|
149
|
+
'open',
|
|
150
|
+
'path',
|
|
151
|
+
'pdf',
|
|
152
|
+
'plus',
|
|
153
|
+
'projects',
|
|
154
|
+
'question',
|
|
155
|
+
'questions',
|
|
156
|
+
'rectangle-rounded',
|
|
157
|
+
'refresh-browse',
|
|
158
|
+
'remove',
|
|
159
|
+
'right',
|
|
160
|
+
'schema_filter',
|
|
161
|
+
'search',
|
|
162
|
+
'settings',
|
|
163
|
+
'smart',
|
|
164
|
+
'star',
|
|
165
|
+
'stepper-completed',
|
|
166
|
+
'success',
|
|
167
|
+
'suggestion',
|
|
168
|
+
'survivorship',
|
|
169
|
+
'table-row-error',
|
|
170
|
+
'table-row-success',
|
|
171
|
+
'table-row-warning',
|
|
172
|
+
'toast-error',
|
|
173
|
+
'toast-info',
|
|
174
|
+
'toast-success',
|
|
175
|
+
'toast-warning',
|
|
176
|
+
'tools',
|
|
177
|
+
'user',
|
|
178
|
+
'users',
|
|
179
|
+
'vector',
|
|
180
|
+
'vector-down',
|
|
181
|
+
'vector-right',
|
|
182
|
+
'vector-up',
|
|
183
|
+
'wallet',
|
|
184
|
+
'warning',
|
|
185
|
+
'widget-button-icon',
|
|
186
|
+
'xls'
|
|
187
|
+
];
|
|
188
|
+
class CpsIconComponent {
|
|
189
|
+
constructor() {
|
|
190
|
+
this.icon = '';
|
|
191
|
+
this.size = 'small';
|
|
192
|
+
this.color = 'currentColor';
|
|
193
|
+
this.iconColor = 'currentColor';
|
|
194
|
+
this.url = '../../../../assets/icons/';
|
|
195
|
+
this.cvtSize = '';
|
|
196
|
+
this.classesList = ['icon'];
|
|
197
|
+
}
|
|
198
|
+
ngOnChanges() {
|
|
199
|
+
this.iconColor = getCSSColor(this.color);
|
|
200
|
+
this.setClasses();
|
|
201
|
+
}
|
|
202
|
+
setClasses() {
|
|
203
|
+
switch (this.size) {
|
|
204
|
+
case 'fill': {
|
|
205
|
+
this.classesList.push('icon--fill');
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
case 'xsmall': {
|
|
209
|
+
this.classesList.push('icon--xsmall');
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
case 'small': {
|
|
213
|
+
this.classesList.push('icon--small');
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
case 'normal': {
|
|
217
|
+
this.classesList.push('icon--normal');
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
case 'large': {
|
|
221
|
+
this.classesList.push('icon--large');
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
default:
|
|
225
|
+
this.cvtSize = convertSize(this.size);
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
CpsIconComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsIconComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
231
|
+
CpsIconComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CpsIconComponent, isStandalone: true, selector: "cps-icon", inputs: { icon: "icon", size: "size", color: "color" }, usesOnChanges: true, ngImport: i0, template: "<i *ngIf=\"icon\" [ngClass]=\"classesList\" [style.color]=\"iconColor\" [ngStyle]=\"{width: cvtSize || 'none', height: cvtSize || 'none'}\">\n <svg>\n <use attr.xlink:href=\"{{ url }}{{ icon }}.svg#{{ icon }}\"></use>\n </svg>\n</i>\n", styles: [":host{display:inline-flex}:host .icon--fill{width:100%;height:100%}:host .icon--xsmall{width:12px;height:12px}:host .icon--small{width:16px;height:16px}:host .icon--normal{width:24px;height:24px}:host .icon--large{width:32px;height:32px}svg{color:inherit;fill:currentColor;height:100%;width:100%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
232
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsIconComponent, decorators: [{
|
|
233
|
+
type: Component,
|
|
234
|
+
args: [{ standalone: true, imports: [CommonModule], selector: 'cps-icon', template: "<i *ngIf=\"icon\" [ngClass]=\"classesList\" [style.color]=\"iconColor\" [ngStyle]=\"{width: cvtSize || 'none', height: cvtSize || 'none'}\">\n <svg>\n <use attr.xlink:href=\"{{ url }}{{ icon }}.svg#{{ icon }}\"></use>\n </svg>\n</i>\n", styles: [":host{display:inline-flex}:host .icon--fill{width:100%;height:100%}:host .icon--xsmall{width:12px;height:12px}:host .icon--small{width:16px;height:16px}:host .icon--normal{width:24px;height:24px}:host .icon--large{width:32px;height:32px}svg{color:inherit;fill:currentColor;height:100%;width:100%}\n"] }]
|
|
235
|
+
}], propDecorators: { icon: [{
|
|
236
|
+
type: Input
|
|
237
|
+
}], size: [{
|
|
238
|
+
type: Input
|
|
239
|
+
}], color: [{
|
|
240
|
+
type: Input
|
|
241
|
+
}] } });
|
|
242
|
+
|
|
243
|
+
class CpsInputComponent {
|
|
244
|
+
set value(value) {
|
|
245
|
+
this._value = value;
|
|
246
|
+
this.onChange(value);
|
|
247
|
+
}
|
|
248
|
+
get value() {
|
|
249
|
+
return this._value;
|
|
250
|
+
}
|
|
251
|
+
constructor(_control, _elementRef, cdRef) {
|
|
252
|
+
this._control = _control;
|
|
253
|
+
this._elementRef = _elementRef;
|
|
254
|
+
this.cdRef = cdRef;
|
|
255
|
+
this.label = '';
|
|
256
|
+
this.placeholder = 'Please enter';
|
|
257
|
+
this.hint = '';
|
|
258
|
+
this.disabled = false;
|
|
259
|
+
this.width = '100%';
|
|
260
|
+
this.type = 'text';
|
|
261
|
+
this.loading = false;
|
|
262
|
+
this.clearable = false;
|
|
263
|
+
this.prefixIcon = '';
|
|
264
|
+
this.prefixIconSize = 'small';
|
|
265
|
+
this.prefixText = '';
|
|
266
|
+
this.hideDetails = false;
|
|
267
|
+
this.valueChanged = new EventEmitter();
|
|
268
|
+
this._statusChangesSubscription = new Subscription();
|
|
269
|
+
this._value = '';
|
|
270
|
+
this.error = '';
|
|
271
|
+
this.currentType = '';
|
|
272
|
+
this.prefixWidth = '';
|
|
273
|
+
this.cvtWidth = '';
|
|
274
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
275
|
+
this.onChange = (event) => { };
|
|
276
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
277
|
+
this.onTouched = () => { };
|
|
278
|
+
if (this._control) {
|
|
279
|
+
this._control.valueAccessor = this;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
ngOnInit() {
|
|
283
|
+
this.currentType = this.type;
|
|
284
|
+
this.cvtWidth = convertSize(this.width);
|
|
285
|
+
this._statusChangesSubscription = this._control?.statusChanges?.subscribe(() => {
|
|
286
|
+
this._checkErrors();
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
ngAfterViewInit() {
|
|
290
|
+
let w = 0;
|
|
291
|
+
if (this.prefixText) {
|
|
292
|
+
w = this.prefixTextSpan?.nativeElement?.offsetWidth + 22;
|
|
293
|
+
}
|
|
294
|
+
if (this.prefixIcon) {
|
|
295
|
+
w += 38 - (this.prefixText ? 14 : 0);
|
|
296
|
+
}
|
|
297
|
+
this.prefixWidth = w > 0 ? `${w}px` : '';
|
|
298
|
+
this.cdRef.detectChanges();
|
|
299
|
+
}
|
|
300
|
+
ngOnDestroy() {
|
|
301
|
+
this._statusChangesSubscription?.unsubscribe();
|
|
302
|
+
}
|
|
303
|
+
_checkErrors() {
|
|
304
|
+
const errors = this._control?.errors;
|
|
305
|
+
if (!this._control?.control?.touched || !errors) {
|
|
306
|
+
this.error = '';
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if ('required' in errors) {
|
|
310
|
+
this.error = 'Field is required';
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if ('minlength' in errors) {
|
|
314
|
+
// eslint-disable-next-line dot-notation
|
|
315
|
+
this.error = `Field must contain at least ${errors['minlength'].requiredLength} characters`;
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const errArr = Object.values(errors);
|
|
319
|
+
if (errArr.length < 1) {
|
|
320
|
+
this.error = '';
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const message = errArr.find((msg) => typeof msg === 'string');
|
|
324
|
+
this.error = message || 'Unknown error';
|
|
325
|
+
}
|
|
326
|
+
registerOnChange(fn) {
|
|
327
|
+
this.onChange = fn;
|
|
328
|
+
}
|
|
329
|
+
registerOnTouched(fn) {
|
|
330
|
+
this.onTouched = fn;
|
|
331
|
+
}
|
|
332
|
+
writeValue(value) {
|
|
333
|
+
this.value = value;
|
|
334
|
+
}
|
|
335
|
+
updateValueEvent(event) {
|
|
336
|
+
const value = event?.target?.value || '';
|
|
337
|
+
this._updateValue(value);
|
|
338
|
+
}
|
|
339
|
+
_updateValue(value) {
|
|
340
|
+
this.writeValue(value);
|
|
341
|
+
this.onChange(value);
|
|
342
|
+
this.valueChanged.emit(value);
|
|
343
|
+
}
|
|
344
|
+
clear() {
|
|
345
|
+
if (this.value !== '')
|
|
346
|
+
this._updateValue('');
|
|
347
|
+
}
|
|
348
|
+
togglePassword() {
|
|
349
|
+
this.currentType = this.currentType === 'password' ? 'text' : 'password';
|
|
350
|
+
}
|
|
351
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
352
|
+
setDisabledState(disabled) { }
|
|
353
|
+
onBlur() {
|
|
354
|
+
this._control?.control?.markAsTouched();
|
|
355
|
+
this._checkErrors();
|
|
356
|
+
}
|
|
357
|
+
focus() {
|
|
358
|
+
this._elementRef?.nativeElement?.querySelector('input')?.focus();
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
CpsInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsInputComponent, deps: [{ token: i1.NgControl, optional: true, self: true }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
362
|
+
CpsInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CpsInputComponent, isStandalone: true, selector: "cps-input", inputs: { label: "label", placeholder: "placeholder", hint: "hint", disabled: "disabled", width: "width", type: "type", loading: "loading", clearable: "clearable", prefixIcon: "prefixIcon", prefixIconSize: "prefixIconSize", prefixText: "prefixText", hideDetails: "hideDetails", value: "value" }, outputs: { valueChanged: "valueChanged" }, viewQueries: [{ propertyName: "prefixTextSpan", first: true, predicate: ["prefixTextSpan"], descendants: true }], ngImport: i0, template: "<div class=\"input-container\">\n <label class=\"label-text\" [ngClass]=\"{ 'label-text-disabled': disabled }\">{{\n label\n }}</label>\n\n <div\n class=\"input-wrap\"\n [ngClass]=\"{\n password: type === 'password',\n 'input-wrap-error': error,\n clearable: clearable,\n }\"\n >\n <input\n [type]=\"currentType\"\n [value]=\"value\"\n (input)=\"updateValueEvent($event)\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n [ngStyle]=\"{\n width: cvtWidth,\n 'padding-left': prefixWidth || 'none'\n }\"\n (blur)=\"onBlur()\"\n />\n\n <div class=\"prefix\">\n <span *ngIf=\"prefixIcon\" class=\"prefix-icon\">\n <cps-icon [icon]=\"prefixIcon\" [size]=\"prefixIconSize\"></cps-icon>\n </span>\n\n <span *ngIf=\"prefixText\" class=\"prefix-text\" #prefixTextSpan>\n {{ prefixText }}\n </span>\n </div>\n\n <div class=\"action-btns\">\n <span *ngIf=\"clearable\" class=\"clear-btn\">\n <cps-icon icon=\"delete\" size=\"small\" (click)=\"clear()\"></cps-icon>\n </span>\n\n <span\n *ngIf=\"type === 'password'\"\n class=\"password-show-btn\"\n [ngClass]=\"{ 'password-show-btn-active': currentType === 'text' }\"\n >\n <cps-icon icon=\"eye\" size=\"18px\" (click)=\"togglePassword()\"></cps-icon>\n </span>\n </div>\n </div>\n\n <div *ngIf=\"loading\" class=\"progress-bar\" [ngStyle]=\"{ width: cvtWidth }\">\n <div class=\"progress-bar-line inc\"></div>\n <div class=\"progress-bar-line dec\"></div>\n </div>\n <div *ngIf=\"!error && !hideDetails\" class=\"hint-text\">{{ hint }}</div>\n <div *ngIf=\"error && !hideDetails\" class=\"error-text\">{{ error }}</div>\n</div>\n", styles: [":host .input-container{gap:.2rem!important;display:flex!important;flex-direction:column!important;font-family:Source Sans Pro,sans-serif}:host .input-container .input-wrap{position:relative;overflow:hidden}:host .input-container .input-wrap:hover input:enabled{border:1px solid var(--cps-color-calm)}:host .input-container .input-wrap-error input{border-color:#c33!important}:host .input-container .input-wrap-error input:not(:focus){background:#fef3f2!important}:host .input-container .input-wrap input{font-size:1rem;color:var(--cps-color-text-dark);background:#ffffff;padding:.375rem .75rem;line-height:1.5;border:1px solid var(--cps-color-text-lightest);transition-duration:.2s;-webkit-appearance:none;appearance:none;border-radius:4px;width:100%}:host .input-container .input-wrap input:focus{border:1px solid var(--cps-color-calm);outline:0}:host .input-container .input-wrap input:disabled{background-color:#f7f7f7;opacity:1}:host .input-container .input-wrap input:focus+.prefix>.prefix-icon,:host .input-container .input-wrap input:hover+.prefix>.prefix-icon{color:var(--cps-color-calm)}:host .input-container .input-wrap .action-btns{display:flex;align-items:center;position:absolute;top:50%;right:.75rem;margin-top:-.5rem}:host .input-container .input-wrap .action-btns .clear-btn{cursor:pointer;color:var(--cps-color-calm)}:host .input-container .input-wrap .action-btns .clear-btn cps-icon{opacity:.5;transition-duration:.2s}:host .input-container .input-wrap .action-btns .clear-btn cps-icon:hover{opacity:1}:host .input-container .input-wrap .action-btns .password-show-btn{margin-left:.5rem;cursor:pointer;color:var(--cps-color-text-mild)}:host .input-container .input-wrap .action-btns .password-show-btn-active{color:var(--cps-color-calm)}:host .input-container .input-wrap .action-btns .password-show-btn cps-icon{transition-duration:.2s}:host .input-container .input-wrap .action-btns .password-show-btn cps-icon:hover{color:var(--cps-color-calm)}:host .input-container .input-wrap .prefix{height:-webkit-fill-available;display:flex;align-items:center;position:absolute;top:50%;left:.75rem;transform:translateY(-50%)}:host .input-container .input-wrap .prefix:hover .prefix-icon{color:var(--cps-color-calm)}:host .input-container .input-wrap .prefix-icon{transition-duration:.2s;height:-webkit-fill-available;margin-right:.5rem}:host .input-container .input-wrap .prefix-text{color:var(--cps-color-text-mild)}:host .input-container .password.clearable>input{padding-right:3.8rem}:host .input-container .password>input,:host .input-container .clearable>input{padding-right:2.2rem}:host .input-container .hint-text{color:var(--cps-color-text-mild);font-size:.75rem;min-height:1.125rem;cursor:default}:host .input-container .error-text{color:#c33;font-weight:700;font-size:.75rem;min-height:1.125rem;cursor:default}:host .input-container .label-text{color:var(--cps-color-text-dark);font-size:.875rem}:host .input-container .label-text-disabled{color:var(--cps-color-text-mild)}:host .input-container ::placeholder{color:var(--cps-color-text-lightest);font-style:italic;opacity:1}:host .input-container .progress-bar{margin-top:-6px;margin-bottom:1px;position:relative;height:3px;overflow-x:hidden;border-radius:4px}:host .input-container .progress-bar-line{position:absolute;background:var(--cps-color-calm);opacity:.3;height:3px;left:-5%;top:0}:host .input-container .progress-bar .inc{animation:increase 2s infinite}:host .input-container .progress-bar .dec{animation:decrease 2s .5s infinite}@keyframes increase{0%{left:-5%;width:5%}to{left:130%;width:100%}}@keyframes decrease{0%{left:-80%;width:80%}to{left:110%;width:10%}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: CpsIconComponent, selector: "cps-icon", inputs: ["icon", "size", "color"] }] });
|
|
363
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsInputComponent, decorators: [{
|
|
364
|
+
type: Component,
|
|
365
|
+
args: [{ standalone: true, imports: [CommonModule, CpsIconComponent], selector: 'cps-input', template: "<div class=\"input-container\">\n <label class=\"label-text\" [ngClass]=\"{ 'label-text-disabled': disabled }\">{{\n label\n }}</label>\n\n <div\n class=\"input-wrap\"\n [ngClass]=\"{\n password: type === 'password',\n 'input-wrap-error': error,\n clearable: clearable,\n }\"\n >\n <input\n [type]=\"currentType\"\n [value]=\"value\"\n (input)=\"updateValueEvent($event)\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n [ngStyle]=\"{\n width: cvtWidth,\n 'padding-left': prefixWidth || 'none'\n }\"\n (blur)=\"onBlur()\"\n />\n\n <div class=\"prefix\">\n <span *ngIf=\"prefixIcon\" class=\"prefix-icon\">\n <cps-icon [icon]=\"prefixIcon\" [size]=\"prefixIconSize\"></cps-icon>\n </span>\n\n <span *ngIf=\"prefixText\" class=\"prefix-text\" #prefixTextSpan>\n {{ prefixText }}\n </span>\n </div>\n\n <div class=\"action-btns\">\n <span *ngIf=\"clearable\" class=\"clear-btn\">\n <cps-icon icon=\"delete\" size=\"small\" (click)=\"clear()\"></cps-icon>\n </span>\n\n <span\n *ngIf=\"type === 'password'\"\n class=\"password-show-btn\"\n [ngClass]=\"{ 'password-show-btn-active': currentType === 'text' }\"\n >\n <cps-icon icon=\"eye\" size=\"18px\" (click)=\"togglePassword()\"></cps-icon>\n </span>\n </div>\n </div>\n\n <div *ngIf=\"loading\" class=\"progress-bar\" [ngStyle]=\"{ width: cvtWidth }\">\n <div class=\"progress-bar-line inc\"></div>\n <div class=\"progress-bar-line dec\"></div>\n </div>\n <div *ngIf=\"!error && !hideDetails\" class=\"hint-text\">{{ hint }}</div>\n <div *ngIf=\"error && !hideDetails\" class=\"error-text\">{{ error }}</div>\n</div>\n", styles: [":host .input-container{gap:.2rem!important;display:flex!important;flex-direction:column!important;font-family:Source Sans Pro,sans-serif}:host .input-container .input-wrap{position:relative;overflow:hidden}:host .input-container .input-wrap:hover input:enabled{border:1px solid var(--cps-color-calm)}:host .input-container .input-wrap-error input{border-color:#c33!important}:host .input-container .input-wrap-error input:not(:focus){background:#fef3f2!important}:host .input-container .input-wrap input{font-size:1rem;color:var(--cps-color-text-dark);background:#ffffff;padding:.375rem .75rem;line-height:1.5;border:1px solid var(--cps-color-text-lightest);transition-duration:.2s;-webkit-appearance:none;appearance:none;border-radius:4px;width:100%}:host .input-container .input-wrap input:focus{border:1px solid var(--cps-color-calm);outline:0}:host .input-container .input-wrap input:disabled{background-color:#f7f7f7;opacity:1}:host .input-container .input-wrap input:focus+.prefix>.prefix-icon,:host .input-container .input-wrap input:hover+.prefix>.prefix-icon{color:var(--cps-color-calm)}:host .input-container .input-wrap .action-btns{display:flex;align-items:center;position:absolute;top:50%;right:.75rem;margin-top:-.5rem}:host .input-container .input-wrap .action-btns .clear-btn{cursor:pointer;color:var(--cps-color-calm)}:host .input-container .input-wrap .action-btns .clear-btn cps-icon{opacity:.5;transition-duration:.2s}:host .input-container .input-wrap .action-btns .clear-btn cps-icon:hover{opacity:1}:host .input-container .input-wrap .action-btns .password-show-btn{margin-left:.5rem;cursor:pointer;color:var(--cps-color-text-mild)}:host .input-container .input-wrap .action-btns .password-show-btn-active{color:var(--cps-color-calm)}:host .input-container .input-wrap .action-btns .password-show-btn cps-icon{transition-duration:.2s}:host .input-container .input-wrap .action-btns .password-show-btn cps-icon:hover{color:var(--cps-color-calm)}:host .input-container .input-wrap .prefix{height:-webkit-fill-available;display:flex;align-items:center;position:absolute;top:50%;left:.75rem;transform:translateY(-50%)}:host .input-container .input-wrap .prefix:hover .prefix-icon{color:var(--cps-color-calm)}:host .input-container .input-wrap .prefix-icon{transition-duration:.2s;height:-webkit-fill-available;margin-right:.5rem}:host .input-container .input-wrap .prefix-text{color:var(--cps-color-text-mild)}:host .input-container .password.clearable>input{padding-right:3.8rem}:host .input-container .password>input,:host .input-container .clearable>input{padding-right:2.2rem}:host .input-container .hint-text{color:var(--cps-color-text-mild);font-size:.75rem;min-height:1.125rem;cursor:default}:host .input-container .error-text{color:#c33;font-weight:700;font-size:.75rem;min-height:1.125rem;cursor:default}:host .input-container .label-text{color:var(--cps-color-text-dark);font-size:.875rem}:host .input-container .label-text-disabled{color:var(--cps-color-text-mild)}:host .input-container ::placeholder{color:var(--cps-color-text-lightest);font-style:italic;opacity:1}:host .input-container .progress-bar{margin-top:-6px;margin-bottom:1px;position:relative;height:3px;overflow-x:hidden;border-radius:4px}:host .input-container .progress-bar-line{position:absolute;background:var(--cps-color-calm);opacity:.3;height:3px;left:-5%;top:0}:host .input-container .progress-bar .inc{animation:increase 2s infinite}:host .input-container .progress-bar .dec{animation:decrease 2s .5s infinite}@keyframes increase{0%{left:-5%;width:5%}to{left:130%;width:100%}}@keyframes decrease{0%{left:-80%;width:80%}to{left:110%;width:10%}}\n"] }]
|
|
366
|
+
}], ctorParameters: function () { return [{ type: i1.NgControl, decorators: [{
|
|
367
|
+
type: Self
|
|
368
|
+
}, {
|
|
369
|
+
type: Optional
|
|
370
|
+
}] }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { label: [{
|
|
371
|
+
type: Input
|
|
372
|
+
}], placeholder: [{
|
|
373
|
+
type: Input
|
|
374
|
+
}], hint: [{
|
|
375
|
+
type: Input
|
|
376
|
+
}], disabled: [{
|
|
377
|
+
type: Input
|
|
378
|
+
}], width: [{
|
|
379
|
+
type: Input
|
|
380
|
+
}], type: [{
|
|
381
|
+
type: Input
|
|
382
|
+
}], loading: [{
|
|
383
|
+
type: Input
|
|
384
|
+
}], clearable: [{
|
|
385
|
+
type: Input
|
|
386
|
+
}], prefixIcon: [{
|
|
387
|
+
type: Input
|
|
388
|
+
}], prefixIconSize: [{
|
|
389
|
+
type: Input
|
|
390
|
+
}], prefixText: [{
|
|
391
|
+
type: Input
|
|
392
|
+
}], hideDetails: [{
|
|
393
|
+
type: Input
|
|
394
|
+
}], value: [{
|
|
395
|
+
type: Input
|
|
396
|
+
}], valueChanged: [{
|
|
397
|
+
type: Output
|
|
398
|
+
}], prefixTextSpan: [{
|
|
399
|
+
type: ViewChild,
|
|
400
|
+
args: ['prefixTextSpan']
|
|
401
|
+
}] } });
|
|
402
|
+
|
|
403
|
+
class CpsChipComponent {
|
|
404
|
+
constructor() {
|
|
405
|
+
this.label = '';
|
|
406
|
+
this.icon = '';
|
|
407
|
+
this.iconPosition = 'before';
|
|
408
|
+
this.closable = false;
|
|
409
|
+
this.disabled = false;
|
|
410
|
+
this.closed = new EventEmitter();
|
|
411
|
+
this.classesList = ['chip'];
|
|
412
|
+
}
|
|
413
|
+
ngOnChanges() {
|
|
414
|
+
this.setClasses();
|
|
415
|
+
}
|
|
416
|
+
setClasses() {
|
|
417
|
+
if (this.disabled)
|
|
418
|
+
this.classesList.push('chip-disabled');
|
|
419
|
+
if (this.icon && this.label) {
|
|
420
|
+
switch (this.iconPosition) {
|
|
421
|
+
case 'before': {
|
|
422
|
+
this.classesList.push('chip--icon-before');
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
case 'after': {
|
|
426
|
+
this.classesList.push('chip--icon-after');
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
onCloseClick(event) {
|
|
433
|
+
event.stopPropagation();
|
|
434
|
+
this.closed.emit();
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
CpsChipComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsChipComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
438
|
+
CpsChipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CpsChipComponent, isStandalone: true, selector: "cps-chip", inputs: { label: "label", icon: "icon", iconPosition: "iconPosition", closable: "closable", disabled: "disabled" }, outputs: { closed: "closed" }, usesOnChanges: true, ngImport: i0, template: "<div [ngClass]=\"classesList\">\n <cps-icon\n *ngIf=\"icon\"\n class=\"chip-icon\"\n [icon]=\"icon\"\n color=\"text-darkest\"\n ></cps-icon>\n <span class=\"chip-label\">{{ label }}</span>\n <cps-icon\n *ngIf=\"closable\"\n class=\"chip-close-icon\"\n icon=\"close-x\"\n size=\"xsmall\"\n color=\"text-darkest\"\n (click)=\"onCloseClick($event)\"\n ></cps-icon>\n</div>\n", styles: [":host{width:-moz-fit-content;width:fit-content;display:inline-block;-webkit-user-select:none;user-select:none}:host .chip{display:inline-flex;background-color:var(--cps-color-bg-dark);border-radius:14px;padding:4px 12px;cursor:default}:host .chip-close-icon{margin-left:6px;cursor:pointer}:host .chip-close-icon:hover ::ng-deep .icon{color:var(--cps-color-calm)!important}:host .chip-label{font-size:14px;color:var(--cps-color-text-darkest)}:host .chip.chip-disabled{pointer-events:none;background-color:var(--cps-color-bg-mid)}:host .chip.chip-disabled .chip-label{color:var(--cps-color-text-light)}:host .chip.chip-disabled .chip-icon ::ng-deep .icon,:host .chip.chip-disabled .chip-close-icon ::ng-deep .icon{color:var(--cps-color-text-light)!important}:host .chip.chip--icon-before .chip-icon{margin-right:6px}:host .chip.chip--icon-after .chip-icon{margin-left:6px;order:1}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: CpsIconComponent, selector: "cps-icon", inputs: ["icon", "size", "color"] }] });
|
|
439
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsChipComponent, decorators: [{
|
|
440
|
+
type: Component,
|
|
441
|
+
args: [{ standalone: true, imports: [CommonModule, CpsIconComponent], selector: 'cps-chip', template: "<div [ngClass]=\"classesList\">\n <cps-icon\n *ngIf=\"icon\"\n class=\"chip-icon\"\n [icon]=\"icon\"\n color=\"text-darkest\"\n ></cps-icon>\n <span class=\"chip-label\">{{ label }}</span>\n <cps-icon\n *ngIf=\"closable\"\n class=\"chip-close-icon\"\n icon=\"close-x\"\n size=\"xsmall\"\n color=\"text-darkest\"\n (click)=\"onCloseClick($event)\"\n ></cps-icon>\n</div>\n", styles: [":host{width:-moz-fit-content;width:fit-content;display:inline-block;-webkit-user-select:none;user-select:none}:host .chip{display:inline-flex;background-color:var(--cps-color-bg-dark);border-radius:14px;padding:4px 12px;cursor:default}:host .chip-close-icon{margin-left:6px;cursor:pointer}:host .chip-close-icon:hover ::ng-deep .icon{color:var(--cps-color-calm)!important}:host .chip-label{font-size:14px;color:var(--cps-color-text-darkest)}:host .chip.chip-disabled{pointer-events:none;background-color:var(--cps-color-bg-mid)}:host .chip.chip-disabled .chip-label{color:var(--cps-color-text-light)}:host .chip.chip-disabled .chip-icon ::ng-deep .icon,:host .chip.chip-disabled .chip-close-icon ::ng-deep .icon{color:var(--cps-color-text-light)!important}:host .chip.chip--icon-before .chip-icon{margin-right:6px}:host .chip.chip--icon-after .chip-icon{margin-left:6px;order:1}\n"] }]
|
|
442
|
+
}], propDecorators: { label: [{
|
|
443
|
+
type: Input
|
|
444
|
+
}], icon: [{
|
|
445
|
+
type: Input
|
|
446
|
+
}], iconPosition: [{
|
|
447
|
+
type: Input
|
|
448
|
+
}], closable: [{
|
|
449
|
+
type: Input
|
|
450
|
+
}], disabled: [{
|
|
451
|
+
type: Input
|
|
452
|
+
}], closed: [{
|
|
453
|
+
type: Output
|
|
454
|
+
}] } });
|
|
455
|
+
|
|
456
|
+
class ClickOutsideDirective {
|
|
457
|
+
// eslint-disable-next-line no-useless-constructor
|
|
458
|
+
constructor(elementRef) {
|
|
459
|
+
this.elementRef = elementRef;
|
|
460
|
+
this.clickOutside = new EventEmitter();
|
|
461
|
+
}
|
|
462
|
+
onClick(target) {
|
|
463
|
+
if (!this.elementRef?.nativeElement?.classList?.contains('focused'))
|
|
464
|
+
return;
|
|
465
|
+
const clickedInside = this.elementRef?.nativeElement?.contains(target);
|
|
466
|
+
if (!clickedInside) {
|
|
467
|
+
this.clickOutside.emit();
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
ClickOutsideDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ClickOutsideDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
472
|
+
ClickOutsideDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: ClickOutsideDirective, isStandalone: true, selector: "[clickOutside]", outputs: { clickOutside: "clickOutside" }, host: { listeners: { "document:click": "onClick($event.target)" } }, ngImport: i0 });
|
|
473
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ClickOutsideDirective, decorators: [{
|
|
474
|
+
type: Directive,
|
|
475
|
+
args: [{
|
|
476
|
+
standalone: true,
|
|
477
|
+
selector: '[clickOutside]'
|
|
478
|
+
}]
|
|
479
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { clickOutside: [{
|
|
480
|
+
type: Output
|
|
481
|
+
}], onClick: [{
|
|
482
|
+
type: HostListener,
|
|
483
|
+
args: ['document:click', ['$event.target']]
|
|
484
|
+
}] } });
|
|
485
|
+
|
|
486
|
+
class LabelByValuePipe {
|
|
487
|
+
transform(value, options, valueKey, labelKey) {
|
|
488
|
+
const option = options.find((opt) => opt[valueKey] === value);
|
|
489
|
+
return option ? option[labelKey] : 'unknown';
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
LabelByValuePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LabelByValuePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
493
|
+
LabelByValuePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: LabelByValuePipe, isStandalone: true, name: "labelByValue" });
|
|
494
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LabelByValuePipe, decorators: [{
|
|
495
|
+
type: Pipe,
|
|
496
|
+
args: [{ standalone: true, name: 'labelByValue' }]
|
|
497
|
+
}] });
|
|
498
|
+
|
|
499
|
+
class CombineLabelsPipe {
|
|
500
|
+
transform(values, options, valueKey, labelKey, returnObject) {
|
|
501
|
+
return values
|
|
502
|
+
.map((v) => {
|
|
503
|
+
if (returnObject) {
|
|
504
|
+
return v[labelKey];
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
const option = options.find((opt) => opt[valueKey] === v);
|
|
508
|
+
return option ? option[labelKey] : 'unknown';
|
|
509
|
+
}
|
|
510
|
+
})
|
|
511
|
+
.join(', ');
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
CombineLabelsPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CombineLabelsPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
515
|
+
CombineLabelsPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: CombineLabelsPipe, isStandalone: true, name: "combineLabels" });
|
|
516
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CombineLabelsPipe, decorators: [{
|
|
517
|
+
type: Pipe,
|
|
518
|
+
args: [{ standalone: true, name: 'combineLabels' }]
|
|
519
|
+
}] });
|
|
520
|
+
|
|
521
|
+
class CpsSelectComponent {
|
|
522
|
+
set value(value) {
|
|
523
|
+
value = this._convertValue(value);
|
|
524
|
+
this._value = value;
|
|
525
|
+
this.onChange(value);
|
|
526
|
+
}
|
|
527
|
+
get value() {
|
|
528
|
+
return this._value;
|
|
529
|
+
}
|
|
530
|
+
constructor(_control) {
|
|
531
|
+
this._control = _control;
|
|
532
|
+
this.label = '';
|
|
533
|
+
this.placeholder = 'Please select';
|
|
534
|
+
this.hint = '';
|
|
535
|
+
this.returnObject = true;
|
|
536
|
+
this.multiple = false;
|
|
537
|
+
this.disabled = false;
|
|
538
|
+
this.width = '100%';
|
|
539
|
+
this.selectAll = true;
|
|
540
|
+
this.chips = true;
|
|
541
|
+
this.closableChips = true;
|
|
542
|
+
this.clearable = false;
|
|
543
|
+
this.openOnClear = true;
|
|
544
|
+
this.options = [];
|
|
545
|
+
this.optionLabel = 'label';
|
|
546
|
+
this.optionValue = 'value'; // works only if returnObject === false (TODO potentially can be of any type)
|
|
547
|
+
this.optionInfo = 'info';
|
|
548
|
+
this.hideDetails = false;
|
|
549
|
+
this._value = undefined;
|
|
550
|
+
this.valueChanged = new EventEmitter();
|
|
551
|
+
this._statusChangesSubscription = new Subscription();
|
|
552
|
+
this.error = '';
|
|
553
|
+
this.cvtWidth = '';
|
|
554
|
+
this.isOpened = false;
|
|
555
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
556
|
+
this.onChange = (event) => { };
|
|
557
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
558
|
+
this.onTouched = () => { };
|
|
559
|
+
if (this._control) {
|
|
560
|
+
this._control.valueAccessor = this;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
ngOnChanges(changes) {
|
|
564
|
+
// eslint-disable-next-line dot-notation
|
|
565
|
+
if ('_value' in changes && changes['_value'].isFirstChange()) {
|
|
566
|
+
this.value = this._convertValue(this.value);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
ngOnInit() {
|
|
570
|
+
this.cvtWidth = convertSize(this.width);
|
|
571
|
+
if (this.multiple && !this._value) {
|
|
572
|
+
this._value = [];
|
|
573
|
+
}
|
|
574
|
+
this._statusChangesSubscription = this._control?.statusChanges?.subscribe(() => {
|
|
575
|
+
this._checkErrors();
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
ngOnDestroy() {
|
|
579
|
+
this._statusChangesSubscription?.unsubscribe();
|
|
580
|
+
}
|
|
581
|
+
toggleOptions(dd, show) {
|
|
582
|
+
if (this.disabled || !dd)
|
|
583
|
+
return;
|
|
584
|
+
if (typeof show === 'boolean') {
|
|
585
|
+
if (show)
|
|
586
|
+
dd.classList.add('active');
|
|
587
|
+
else
|
|
588
|
+
dd.classList.remove('active');
|
|
589
|
+
}
|
|
590
|
+
else
|
|
591
|
+
dd.classList.toggle('active');
|
|
592
|
+
this.isOpened = dd.classList.contains('active');
|
|
593
|
+
if (this.isOpened) {
|
|
594
|
+
const selected = this.selectContainer.nativeElement.querySelector('.selected');
|
|
595
|
+
if (selected)
|
|
596
|
+
selected.scrollIntoView();
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
// private _filterOptions() {
|
|
600
|
+
// if (!this.optionsFilter || !this.multiple) return;
|
|
601
|
+
// this.filteredOptions = this.options.filter((o) => {
|
|
602
|
+
// if (this.returnObject) {
|
|
603
|
+
// return !this.value.find((v: any) => v === o);
|
|
604
|
+
// }
|
|
605
|
+
// return !this.value.find((v: any) => v === o[this.optionValue]);
|
|
606
|
+
// });
|
|
607
|
+
// }
|
|
608
|
+
select(option, byValue) {
|
|
609
|
+
const val = byValue
|
|
610
|
+
? option
|
|
611
|
+
: this.returnObject
|
|
612
|
+
? option
|
|
613
|
+
: option[this.optionValue];
|
|
614
|
+
if (this.multiple) {
|
|
615
|
+
let res = [];
|
|
616
|
+
if (this.value.includes(val)) {
|
|
617
|
+
res = this.value.filter((v) => v !== val);
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
this.options.forEach((o) => {
|
|
621
|
+
const ov = this.returnObject ? o : o[this.optionValue];
|
|
622
|
+
if (this.value.some((v) => v === ov) || val === ov) {
|
|
623
|
+
res.push(ov);
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
this.updateValue(res);
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
this.updateValue(val);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
onOptionClick(option, dd) {
|
|
634
|
+
this.select(option, false);
|
|
635
|
+
if (!this.multiple) {
|
|
636
|
+
this.toggleOptions(dd, false);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
toggleAll() {
|
|
640
|
+
let res = [];
|
|
641
|
+
if (this.value.length < this.options.length) {
|
|
642
|
+
if (this.returnObject) {
|
|
643
|
+
res = this.options;
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
this.options.forEach((o) => {
|
|
647
|
+
res.push(o[this.optionValue]);
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
this.updateValue(res);
|
|
652
|
+
}
|
|
653
|
+
_checkErrors() {
|
|
654
|
+
const errors = this._control?.errors;
|
|
655
|
+
if (!this._control?.control?.touched || !errors) {
|
|
656
|
+
this.error = '';
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
if ('required' in errors) {
|
|
660
|
+
this.error = 'Field is required';
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
const errArr = Object.values(errors);
|
|
664
|
+
if (errArr.length < 1) {
|
|
665
|
+
this.error = '';
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
const message = errArr.find((msg) => typeof msg === 'string');
|
|
669
|
+
this.error = message || 'Unknown error';
|
|
670
|
+
}
|
|
671
|
+
registerOnChange(fn) {
|
|
672
|
+
this.onChange = fn;
|
|
673
|
+
}
|
|
674
|
+
registerOnTouched(fn) {
|
|
675
|
+
this.onTouched = fn;
|
|
676
|
+
}
|
|
677
|
+
_convertValue(value) {
|
|
678
|
+
if (!this.returnObject) {
|
|
679
|
+
if (this.multiple) {
|
|
680
|
+
if (Array.isArray(value)) {
|
|
681
|
+
const temp = [];
|
|
682
|
+
value.forEach((v) => {
|
|
683
|
+
if (typeof v !== 'string') {
|
|
684
|
+
temp.push(v ? v[this.optionValue] : '');
|
|
685
|
+
}
|
|
686
|
+
else
|
|
687
|
+
temp.push(v);
|
|
688
|
+
});
|
|
689
|
+
value = temp;
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
if (!value)
|
|
693
|
+
value = [];
|
|
694
|
+
else {
|
|
695
|
+
if (typeof value !== 'string') {
|
|
696
|
+
value = [value[this.optionValue]];
|
|
697
|
+
}
|
|
698
|
+
else
|
|
699
|
+
value = [value];
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
else {
|
|
704
|
+
if (typeof value !== 'string') {
|
|
705
|
+
value = value ? value[this.optionValue] : '';
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
else {
|
|
710
|
+
if (this.multiple) {
|
|
711
|
+
if (!Array.isArray(value)) {
|
|
712
|
+
value = [value];
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return value;
|
|
717
|
+
}
|
|
718
|
+
writeValue(value) {
|
|
719
|
+
value = this._convertValue(value);
|
|
720
|
+
this.value = value;
|
|
721
|
+
}
|
|
722
|
+
updateValue(value) {
|
|
723
|
+
this.writeValue(value);
|
|
724
|
+
this.onChange(value);
|
|
725
|
+
this.valueChanged.emit(value);
|
|
726
|
+
}
|
|
727
|
+
clear(dd, event) {
|
|
728
|
+
event.stopPropagation();
|
|
729
|
+
if ((!this.multiple && this.value) ||
|
|
730
|
+
(this.multiple && this.value?.length > 0)) {
|
|
731
|
+
if (this.openOnClear) {
|
|
732
|
+
this.toggleOptions(dd, true);
|
|
733
|
+
}
|
|
734
|
+
const val = this.multiple ? [] : this.returnObject ? undefined : '';
|
|
735
|
+
this.updateValue(val);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
739
|
+
setDisabledState(disabled) { }
|
|
740
|
+
onBlur() {
|
|
741
|
+
this._control?.control?.markAsTouched();
|
|
742
|
+
this._checkErrors();
|
|
743
|
+
}
|
|
744
|
+
focus() {
|
|
745
|
+
this.selectContainer?.nativeElement?.focus();
|
|
746
|
+
this.toggleOptions(this.selectContainer?.nativeElement, true);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
CpsSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsSelectComponent, deps: [{ token: i1.NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
750
|
+
CpsSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CpsSelectComponent, isStandalone: true, selector: "cps-select", inputs: { label: "label", placeholder: "placeholder", hint: "hint", returnObject: "returnObject", multiple: "multiple", disabled: "disabled", width: "width", selectAll: "selectAll", chips: "chips", closableChips: "closableChips", clearable: "clearable", openOnClear: "openOnClear", options: "options", optionLabel: "optionLabel", optionValue: "optionValue", optionInfo: "optionInfo", hideDetails: "hideDetails", _value: ["value", "_value"] }, outputs: { valueChanged: "valueChanged" }, viewQueries: [{ propertyName: "selectContainer", first: true, predicate: ["selectContainer"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div\n [ngStyle]=\"{ width: cvtWidth }\"\n class=\"cps-select\"\n tabindex=\"0\"\n [ngClass]=\"{ disabled: disabled, error: error }\"\n #selectContainer\n (keydown.escape)=\"toggleOptions(selectContainer, false)\"\n (blur)=\"onBlur()\"\n>\n <label *ngIf=\"label\" class=\"cps-select-label\">{{ label }}</label>\n <div\n [class.focused]=\"isOpened\"\n (clickOutside)=\"toggleOptions(selectContainer, false)\"\n >\n <div class=\"cps-select-box\" (click)=\"toggleOptions(selectContainer)\">\n <div\n class=\"cps-select-box-placeholder\"\n *ngIf=\"(!value && !multiple) || (value?.length < 1 && multiple)\"\n >\n {{ placeholder }}\n </div>\n <div\n class=\"cps-select-box-items\"\n *ngIf=\"(value && !multiple) || (value?.length > 0 && multiple)\"\n >\n <span *ngIf=\"!multiple\" class=\"single-item\">\n {{\n returnObject\n ? value[optionLabel]\n : (value | labelByValue : options : optionValue : optionLabel)\n }}</span\n >\n <div *ngIf=\"multiple && !chips\" class=\"text-group\">\n <span>\n {{\n value\n | combineLabels\n : options\n : optionValue\n : optionLabel\n : returnObject\n }}</span\n >\n </div>\n\n <div *ngIf=\"multiple && chips\" class=\"chips-group\">\n <cps-chip\n *ngFor=\"let val of value\"\n [disabled]=\"disabled\"\n [closable]=\"closableChips\"\n (closed)=\"select(val, true)\"\n [label]=\"\n returnObject\n ? val[optionLabel]\n : (val | labelByValue : options : optionValue : optionLabel)\n \"\n >\n </cps-chip>\n </div>\n </div>\n <span class=\"cps-select-box-icons\">\n <span *ngIf=\"clearable && !disabled\" class=\"cps-select-box-clear-icon\">\n <cps-icon\n icon=\"delete\"\n size=\"small\"\n (click)=\"clear(selectContainer, $event)\"\n ></cps-icon>\n </span>\n <span class=\"cps-select-box-chevron\">\n <cps-icon\n icon=\"chevron-down\"\n size=\"small\"\n color=\"text-dark\"\n ></cps-icon>\n </span>\n </span>\n </div>\n\n <div class=\"cps-select-options\">\n <div\n class=\"cps-select-options-option select-all-option\"\n [class.allselected]=\"value?.length === options.length\"\n *ngIf=\"multiple && selectAll\"\n (click)=\"toggleAll()\"\n >\n <span>\n <span *ngIf=\"multiple\" class=\"cps-select-options-option-check\">\n </span>\n <span class=\"cps-select-options-option-label\">Select all</span>\n </span>\n </div>\n <div\n class=\"cps-select-options-option\"\n *ngFor=\"let option of options\"\n (click)=\"onOptionClick(option, selectContainer)\"\n [class.selected]=\"\n multiple\n ? returnObject\n ? value?.includes(option)\n : value?.includes(option[optionValue])\n : returnObject\n ? option === value\n : option[optionValue] === value\n \"\n >\n <span>\n <span *ngIf=\"multiple\" class=\"cps-select-options-option-check\">\n </span>\n <span class=\"cps-select-options-option-label\">{{\n option[optionLabel]\n }}</span>\n </span>\n\n <span class=\"cps-select-options-option-info\">{{\n option[optionInfo]\n }}</span>\n </div>\n </div>\n </div>\n <div *ngIf=\"!error && !hideDetails\" class=\"cps-select-hint\">{{ hint }}</div>\n <div *ngIf=\"error && !hideDetails\" class=\"cps-select-error\">{{ error }}</div>\n</div>\n", styles: [":host{display:flex}:host .cps-select{position:relative;width:100%;outline:none;font-family:Source Sans Pro,sans-serif}:host .cps-select.active .cps-select-options{display:block}:host .cps-select.active .cps-select-box{border:1px solid var(--cps-color-calm)}:host .cps-select .cps-select-label{display:inline-block;margin-bottom:.2rem;color:var(--cps-color-text-dark);font-size:.875rem}:host .cps-select .cps-select-box{overflow:hidden;justify-content:space-between;min-height:38px;width:100%;cursor:pointer;background:white;font-size:1rem;outline:none;padding:0 12px;border-radius:4px;align-items:center;display:flex;border:1px solid var(--cps-color-text-lightest);transition-duration:.2s}:host .cps-select .cps-select-box-placeholder{color:var(--cps-color-text-lightest);font-style:italic}:host .cps-select .cps-select-box-items .text-group,:host .cps-select .cps-select-box-items .single-item{color:var(--cps-color-text-dark);padding-top:3px;padding-bottom:3px}:host .cps-select .cps-select-box-items .chips-group cps-chip{padding-bottom:3px;padding-top:3px;padding-right:4px}text-group :host .cps-select .cps-select-box:hover{border:1px solid var(--cps-color-calm)}:host .cps-select .cps-select-box .cps-select-box-icons{display:flex}:host .cps-select .cps-select-box .cps-select-box-icons .cps-select-box-clear-icon{display:flex;color:var(--cps-color-calm);margin-left:8px}:host .cps-select .cps-select-box .cps-select-box-icons .cps-select-box-clear-icon cps-icon{opacity:.5;transition-duration:.2s}:host .cps-select .cps-select-box .cps-select-box-icons .cps-select-box-clear-icon cps-icon:hover{opacity:1}:host .cps-select .cps-select-box .cps-select-box-icons .cps-select-box-chevron{display:flex;margin-left:8px;transition-duration:.2s}:host .cps-select.active .cps-select-box-chevron{top:22px;transform:rotate(180deg)}:host .cps-select .cps-select-options{z-index:1001;position:absolute;width:100%;background:white;box-shadow:0 5px 20px #0000000d;border-radius:4px;overflow-x:hidden;display:none;max-height:240px;overflow-y:auto;box-shadow:0 2px 4px -1px #0003,0 4px 5px #00000024,0 1px 10px #0000001f}:host .cps-select .cps-select-options .cps-select-options-option{padding:12px;justify-content:space-between;display:flex;cursor:pointer}:host .cps-select .cps-select-options .cps-select-options-option:hover{background:#f8f4f5}:host .cps-select .cps-select-options .cps-select-options-option-label{color:var(--cps-color-text-dark)}:host .cps-select .cps-select-options .cps-select-options-option-info{color:var(--cps-color-text-light)}:host .cps-select .cps-select-options .cps-select-options-option-check{background-color:transparent;border:0;width:16px;height:16px;cursor:pointer;display:inline-block;vertical-align:middle;box-sizing:border-box;position:relative;flex-shrink:0;transition:border-color 90ms cubic-bezier(0,0,.2,.1),background-color 90ms cubic-bezier(0,0,.2,.1);margin-right:8px;opacity:0}:host .cps-select .cps-select-options .cps-select-options-option-check:after{color:var(--cps-color-calm);top:4px;left:1px;width:8px;height:3px;border-left:2px solid currentColor;transform:rotate(-45deg);opacity:1;box-sizing:content-box;position:absolute;content:\"\";border-bottom:2px solid currentColor;transition:opacity 90ms cubic-bezier(0,0,.2,.1)}:host .cps-select .cps-select-options .cps-select-options-option.selected,:host .cps-select .cps-select-options .cps-select-options-option.allselected{font-weight:600}:host .cps-select .cps-select-options .cps-select-options-option.selected .cps-select-options-option-label,:host .cps-select .cps-select-options .cps-select-options-option.allselected .cps-select-options-option-label{color:var(--cps-color-calm)}:host .cps-select .cps-select-options .cps-select-options-option.selected .cps-select-options-option-check,:host .cps-select .cps-select-options .cps-select-options-option.allselected .cps-select-options-option-check{opacity:1}:host .cps-select .cps-select-options .cps-select-options-option.selected{background:#efe4e7}:host .cps-select .cps-select-hint{color:var(--cps-color-text-mild);font-size:.75rem;min-height:1.125rem;cursor:default;margin-top:.2rem}:host .cps-select .cps-select-error{color:#c33;font-weight:700;font-size:.75rem;min-height:1.125rem;cursor:default;margin-top:.2rem}:host .cps-select.disabled{pointer-events:none}:host .cps-select.disabled .cps-select-box{background:#f7f7f7}:host .cps-select.disabled .cps-select-box-items{color:var(--cps-color-text-light)}:host .cps-select.disabled .cps-select-box-items .text-group,:host .cps-select.disabled .cps-select-box-items .single-item{color:var(--cps-color-text-light)}:host .cps-select.disabled .cps-select-label{color:var(--cps-color-text-mild)}:host .cps-select.error .cps-select-box{border-color:#c33!important;background:#fef3f2!important}:host .cps-select .select-all-option{border-bottom:1px solid lightgrey;font-weight:600}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: ClickOutsideDirective, selector: "[clickOutside]", outputs: ["clickOutside"] }, { kind: "component", type: CpsIconComponent, selector: "cps-icon", inputs: ["icon", "size", "color"] }, { kind: "component", type: CpsChipComponent, selector: "cps-chip", inputs: ["label", "icon", "iconPosition", "closable", "disabled"], outputs: ["closed"] }, { kind: "pipe", type: LabelByValuePipe, name: "labelByValue" }, { kind: "pipe", type: CombineLabelsPipe, name: "combineLabels" }] });
|
|
751
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsSelectComponent, decorators: [{
|
|
752
|
+
type: Component,
|
|
753
|
+
args: [{ standalone: true, imports: [
|
|
754
|
+
CommonModule,
|
|
755
|
+
FormsModule,
|
|
756
|
+
ClickOutsideDirective,
|
|
757
|
+
CpsIconComponent,
|
|
758
|
+
CpsChipComponent,
|
|
759
|
+
LabelByValuePipe,
|
|
760
|
+
CombineLabelsPipe
|
|
761
|
+
], selector: 'cps-select', template: "<div\n [ngStyle]=\"{ width: cvtWidth }\"\n class=\"cps-select\"\n tabindex=\"0\"\n [ngClass]=\"{ disabled: disabled, error: error }\"\n #selectContainer\n (keydown.escape)=\"toggleOptions(selectContainer, false)\"\n (blur)=\"onBlur()\"\n>\n <label *ngIf=\"label\" class=\"cps-select-label\">{{ label }}</label>\n <div\n [class.focused]=\"isOpened\"\n (clickOutside)=\"toggleOptions(selectContainer, false)\"\n >\n <div class=\"cps-select-box\" (click)=\"toggleOptions(selectContainer)\">\n <div\n class=\"cps-select-box-placeholder\"\n *ngIf=\"(!value && !multiple) || (value?.length < 1 && multiple)\"\n >\n {{ placeholder }}\n </div>\n <div\n class=\"cps-select-box-items\"\n *ngIf=\"(value && !multiple) || (value?.length > 0 && multiple)\"\n >\n <span *ngIf=\"!multiple\" class=\"single-item\">\n {{\n returnObject\n ? value[optionLabel]\n : (value | labelByValue : options : optionValue : optionLabel)\n }}</span\n >\n <div *ngIf=\"multiple && !chips\" class=\"text-group\">\n <span>\n {{\n value\n | combineLabels\n : options\n : optionValue\n : optionLabel\n : returnObject\n }}</span\n >\n </div>\n\n <div *ngIf=\"multiple && chips\" class=\"chips-group\">\n <cps-chip\n *ngFor=\"let val of value\"\n [disabled]=\"disabled\"\n [closable]=\"closableChips\"\n (closed)=\"select(val, true)\"\n [label]=\"\n returnObject\n ? val[optionLabel]\n : (val | labelByValue : options : optionValue : optionLabel)\n \"\n >\n </cps-chip>\n </div>\n </div>\n <span class=\"cps-select-box-icons\">\n <span *ngIf=\"clearable && !disabled\" class=\"cps-select-box-clear-icon\">\n <cps-icon\n icon=\"delete\"\n size=\"small\"\n (click)=\"clear(selectContainer, $event)\"\n ></cps-icon>\n </span>\n <span class=\"cps-select-box-chevron\">\n <cps-icon\n icon=\"chevron-down\"\n size=\"small\"\n color=\"text-dark\"\n ></cps-icon>\n </span>\n </span>\n </div>\n\n <div class=\"cps-select-options\">\n <div\n class=\"cps-select-options-option select-all-option\"\n [class.allselected]=\"value?.length === options.length\"\n *ngIf=\"multiple && selectAll\"\n (click)=\"toggleAll()\"\n >\n <span>\n <span *ngIf=\"multiple\" class=\"cps-select-options-option-check\">\n </span>\n <span class=\"cps-select-options-option-label\">Select all</span>\n </span>\n </div>\n <div\n class=\"cps-select-options-option\"\n *ngFor=\"let option of options\"\n (click)=\"onOptionClick(option, selectContainer)\"\n [class.selected]=\"\n multiple\n ? returnObject\n ? value?.includes(option)\n : value?.includes(option[optionValue])\n : returnObject\n ? option === value\n : option[optionValue] === value\n \"\n >\n <span>\n <span *ngIf=\"multiple\" class=\"cps-select-options-option-check\">\n </span>\n <span class=\"cps-select-options-option-label\">{{\n option[optionLabel]\n }}</span>\n </span>\n\n <span class=\"cps-select-options-option-info\">{{\n option[optionInfo]\n }}</span>\n </div>\n </div>\n </div>\n <div *ngIf=\"!error && !hideDetails\" class=\"cps-select-hint\">{{ hint }}</div>\n <div *ngIf=\"error && !hideDetails\" class=\"cps-select-error\">{{ error }}</div>\n</div>\n", styles: [":host{display:flex}:host .cps-select{position:relative;width:100%;outline:none;font-family:Source Sans Pro,sans-serif}:host .cps-select.active .cps-select-options{display:block}:host .cps-select.active .cps-select-box{border:1px solid var(--cps-color-calm)}:host .cps-select .cps-select-label{display:inline-block;margin-bottom:.2rem;color:var(--cps-color-text-dark);font-size:.875rem}:host .cps-select .cps-select-box{overflow:hidden;justify-content:space-between;min-height:38px;width:100%;cursor:pointer;background:white;font-size:1rem;outline:none;padding:0 12px;border-radius:4px;align-items:center;display:flex;border:1px solid var(--cps-color-text-lightest);transition-duration:.2s}:host .cps-select .cps-select-box-placeholder{color:var(--cps-color-text-lightest);font-style:italic}:host .cps-select .cps-select-box-items .text-group,:host .cps-select .cps-select-box-items .single-item{color:var(--cps-color-text-dark);padding-top:3px;padding-bottom:3px}:host .cps-select .cps-select-box-items .chips-group cps-chip{padding-bottom:3px;padding-top:3px;padding-right:4px}text-group :host .cps-select .cps-select-box:hover{border:1px solid var(--cps-color-calm)}:host .cps-select .cps-select-box .cps-select-box-icons{display:flex}:host .cps-select .cps-select-box .cps-select-box-icons .cps-select-box-clear-icon{display:flex;color:var(--cps-color-calm);margin-left:8px}:host .cps-select .cps-select-box .cps-select-box-icons .cps-select-box-clear-icon cps-icon{opacity:.5;transition-duration:.2s}:host .cps-select .cps-select-box .cps-select-box-icons .cps-select-box-clear-icon cps-icon:hover{opacity:1}:host .cps-select .cps-select-box .cps-select-box-icons .cps-select-box-chevron{display:flex;margin-left:8px;transition-duration:.2s}:host .cps-select.active .cps-select-box-chevron{top:22px;transform:rotate(180deg)}:host .cps-select .cps-select-options{z-index:1001;position:absolute;width:100%;background:white;box-shadow:0 5px 20px #0000000d;border-radius:4px;overflow-x:hidden;display:none;max-height:240px;overflow-y:auto;box-shadow:0 2px 4px -1px #0003,0 4px 5px #00000024,0 1px 10px #0000001f}:host .cps-select .cps-select-options .cps-select-options-option{padding:12px;justify-content:space-between;display:flex;cursor:pointer}:host .cps-select .cps-select-options .cps-select-options-option:hover{background:#f8f4f5}:host .cps-select .cps-select-options .cps-select-options-option-label{color:var(--cps-color-text-dark)}:host .cps-select .cps-select-options .cps-select-options-option-info{color:var(--cps-color-text-light)}:host .cps-select .cps-select-options .cps-select-options-option-check{background-color:transparent;border:0;width:16px;height:16px;cursor:pointer;display:inline-block;vertical-align:middle;box-sizing:border-box;position:relative;flex-shrink:0;transition:border-color 90ms cubic-bezier(0,0,.2,.1),background-color 90ms cubic-bezier(0,0,.2,.1);margin-right:8px;opacity:0}:host .cps-select .cps-select-options .cps-select-options-option-check:after{color:var(--cps-color-calm);top:4px;left:1px;width:8px;height:3px;border-left:2px solid currentColor;transform:rotate(-45deg);opacity:1;box-sizing:content-box;position:absolute;content:\"\";border-bottom:2px solid currentColor;transition:opacity 90ms cubic-bezier(0,0,.2,.1)}:host .cps-select .cps-select-options .cps-select-options-option.selected,:host .cps-select .cps-select-options .cps-select-options-option.allselected{font-weight:600}:host .cps-select .cps-select-options .cps-select-options-option.selected .cps-select-options-option-label,:host .cps-select .cps-select-options .cps-select-options-option.allselected .cps-select-options-option-label{color:var(--cps-color-calm)}:host .cps-select .cps-select-options .cps-select-options-option.selected .cps-select-options-option-check,:host .cps-select .cps-select-options .cps-select-options-option.allselected .cps-select-options-option-check{opacity:1}:host .cps-select .cps-select-options .cps-select-options-option.selected{background:#efe4e7}:host .cps-select .cps-select-hint{color:var(--cps-color-text-mild);font-size:.75rem;min-height:1.125rem;cursor:default;margin-top:.2rem}:host .cps-select .cps-select-error{color:#c33;font-weight:700;font-size:.75rem;min-height:1.125rem;cursor:default;margin-top:.2rem}:host .cps-select.disabled{pointer-events:none}:host .cps-select.disabled .cps-select-box{background:#f7f7f7}:host .cps-select.disabled .cps-select-box-items{color:var(--cps-color-text-light)}:host .cps-select.disabled .cps-select-box-items .text-group,:host .cps-select.disabled .cps-select-box-items .single-item{color:var(--cps-color-text-light)}:host .cps-select.disabled .cps-select-label{color:var(--cps-color-text-mild)}:host .cps-select.error .cps-select-box{border-color:#c33!important;background:#fef3f2!important}:host .cps-select .select-all-option{border-bottom:1px solid lightgrey;font-weight:600}\n"] }]
|
|
762
|
+
}], ctorParameters: function () { return [{ type: i1.NgControl, decorators: [{
|
|
763
|
+
type: Self
|
|
764
|
+
}, {
|
|
765
|
+
type: Optional
|
|
766
|
+
}] }]; }, propDecorators: { label: [{
|
|
767
|
+
type: Input
|
|
768
|
+
}], placeholder: [{
|
|
769
|
+
type: Input
|
|
770
|
+
}], hint: [{
|
|
771
|
+
type: Input
|
|
772
|
+
}], returnObject: [{
|
|
773
|
+
type: Input
|
|
774
|
+
}], multiple: [{
|
|
775
|
+
type: Input
|
|
776
|
+
}], disabled: [{
|
|
777
|
+
type: Input
|
|
778
|
+
}], width: [{
|
|
779
|
+
type: Input
|
|
780
|
+
}], selectAll: [{
|
|
781
|
+
type: Input
|
|
782
|
+
}], chips: [{
|
|
783
|
+
type: Input
|
|
784
|
+
}], closableChips: [{
|
|
785
|
+
type: Input
|
|
786
|
+
}], clearable: [{
|
|
787
|
+
type: Input
|
|
788
|
+
}], openOnClear: [{
|
|
789
|
+
type: Input
|
|
790
|
+
}], options: [{
|
|
791
|
+
type: Input
|
|
792
|
+
}], optionLabel: [{
|
|
793
|
+
type: Input
|
|
794
|
+
}], optionValue: [{
|
|
795
|
+
type: Input
|
|
796
|
+
}], optionInfo: [{
|
|
797
|
+
type: Input
|
|
798
|
+
}], hideDetails: [{
|
|
799
|
+
type: Input
|
|
800
|
+
}], _value: [{
|
|
801
|
+
type: Input,
|
|
802
|
+
args: ['value']
|
|
803
|
+
}], valueChanged: [{
|
|
804
|
+
type: Output
|
|
805
|
+
}], selectContainer: [{
|
|
806
|
+
type: ViewChild,
|
|
807
|
+
args: ['selectContainer']
|
|
808
|
+
}] } });
|
|
809
|
+
|
|
810
|
+
class CpsButtonComponent {
|
|
811
|
+
constructor() {
|
|
812
|
+
this.color = 'calm';
|
|
813
|
+
this.contentColor = 'white'; // works only with solid type
|
|
814
|
+
this.type = 'solid';
|
|
815
|
+
this.label = '';
|
|
816
|
+
this.icon = '';
|
|
817
|
+
this.iconPosition = 'before';
|
|
818
|
+
this.size = 'normal';
|
|
819
|
+
this.width = 0;
|
|
820
|
+
this.height = 0;
|
|
821
|
+
this.disabled = false;
|
|
822
|
+
this.loading = false;
|
|
823
|
+
this.clicked = new EventEmitter();
|
|
824
|
+
this.buttonColor = '';
|
|
825
|
+
this.textColor = '';
|
|
826
|
+
this.cvtWidth = '';
|
|
827
|
+
this.cvtHeight = '';
|
|
828
|
+
this.cvtFontSize = '';
|
|
829
|
+
this.cvtIconSize = '';
|
|
830
|
+
this.classesList = [];
|
|
831
|
+
}
|
|
832
|
+
ngOnInit() {
|
|
833
|
+
this.buttonColor = getCSSColor(this.color);
|
|
834
|
+
this.textColor =
|
|
835
|
+
this.type === 'solid' ? getCSSColor(this.contentColor) : this.buttonColor;
|
|
836
|
+
this.setClasses();
|
|
837
|
+
}
|
|
838
|
+
setClasses() {
|
|
839
|
+
this.classesList = ['button'];
|
|
840
|
+
if (this.width) {
|
|
841
|
+
this.cvtWidth = convertSize(this.width);
|
|
842
|
+
}
|
|
843
|
+
if (this.height) {
|
|
844
|
+
this.cvtHeight = convertSize(this.height);
|
|
845
|
+
if (this.cvtHeight) {
|
|
846
|
+
const parsedHeight = parseSize(this.cvtHeight);
|
|
847
|
+
const unit = parsedHeight.unit;
|
|
848
|
+
const size = parsedHeight.value * 0.4;
|
|
849
|
+
const isPx = unit === 'px';
|
|
850
|
+
this.cvtFontSize = `${isPx ? Math.floor(size) : size}${unit}`;
|
|
851
|
+
this.cvtIconSize = `${isPx ? Math.ceil(size) : size}${unit}`;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
switch (this.size) {
|
|
856
|
+
case 'normal': {
|
|
857
|
+
this.classesList.push('button--normal');
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
case 'large': {
|
|
861
|
+
this.classesList.push('button--large');
|
|
862
|
+
break;
|
|
863
|
+
}
|
|
864
|
+
case 'small': {
|
|
865
|
+
this.classesList.push('button--small');
|
|
866
|
+
break;
|
|
867
|
+
}
|
|
868
|
+
case 'xsmall': {
|
|
869
|
+
this.classesList.push('button--xsmall');
|
|
870
|
+
break;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
switch (this.type) {
|
|
875
|
+
case 'solid': {
|
|
876
|
+
this.classesList.push('button--solid');
|
|
877
|
+
break;
|
|
878
|
+
}
|
|
879
|
+
case 'outlined': {
|
|
880
|
+
this.classesList.push('button--outlined');
|
|
881
|
+
break;
|
|
882
|
+
}
|
|
883
|
+
case 'borderless': {
|
|
884
|
+
this.classesList.push('button--borderless');
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
if (this.icon && this.label) {
|
|
889
|
+
switch (this.iconPosition) {
|
|
890
|
+
case 'before': {
|
|
891
|
+
this.classesList.push('button--icon-before');
|
|
892
|
+
break;
|
|
893
|
+
}
|
|
894
|
+
case 'after': {
|
|
895
|
+
this.classesList.push('button--icon-after');
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
onClick(event) {
|
|
902
|
+
this.clicked.emit(event);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
CpsButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
906
|
+
CpsButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CpsButtonComponent, isStandalone: true, selector: "cps-button", inputs: { color: "color", contentColor: "contentColor", type: "type", label: "label", icon: "icon", iconPosition: "iconPosition", size: "size", width: "width", height: "height", disabled: "disabled", loading: "loading" }, outputs: { clicked: "clicked" }, host: { properties: { "style.width": "this.cvtWidth" } }, ngImport: i0, template: "<div>\n <button\n type=\"button\"\n [ngClass]=\"classesList\"\n [disabled]=\"disabled || loading\"\n [class.spinner]=\"loading\"\n (click)=\"onClick($event)\"\n [ngStyle]=\"{\n 'background-color': type==='solid' ? buttonColor : 'transparent',\n color: textColor,\n height: cvtHeight || 'none',\n }\"\n >\n <div class=\"button__content\">\n <cps-icon\n *ngIf=\"icon\"\n class=\"button__icon\"\n [icon]=\"icon\"\n [color]=\"disabled ? 'text-light' : textColor\"\n [size]=\"cvtIconSize\"\n >\n </cps-icon>\n <span\n class=\"button__text\"\n *ngIf=\"label\"\n [ngStyle]=\"{ 'font-size': cvtFontSize || null }\"\n >{{ label }}</span\n >\n </div>\n </button>\n</div>\n", styles: [":host{width:-moz-fit-content;width:fit-content;display:inline-block}:host .button{width:100%;letter-spacing:normal;display:inline-flex;align-items:center;justify-content:center;position:relative;border-radius:4px;border:none;cursor:pointer;outline:none;padding:0 16px;font-weight:500}:host .button:hover:not(:active):not(:disabled){background-image:linear-gradient(hsla(0,0%,100%,.1) 0 0);box-shadow:0 2px 4px #0c0c0d33}:host .button:active:not(:disabled){background-image:linear-gradient(hsla(0,0%,0%,.1) 0 0)}:host .button__content{display:inline-flex}:host .button__icon{align-self:center}:host .button:disabled{cursor:default}:host .button--solid{border:0}:host .button--solid:disabled{background-color:var(--cps-color-line-mid)!important;color:var(--cps-color-text-light)!important}:host .button--outlined{border:2px solid;box-sizing:border-box}:host .button--outlined:disabled{border-color:var(--cps-color-line-dark)!important;color:var(--cps-color-text-light)!important}:host .button--borderless:disabled{color:var(--cps-color-text-light)!important}:host .button--borderless:hover:not(:active):not(:disabled){box-shadow:0 1px 4px #0c0c0d1a}:host .button--large{min-height:48px}:host .button--large .button__icon{width:20px;height:20px}:host .button--large .button__text{font-size:20px}:host .button--large.spinner{min-width:56px}:host .button--large.spinner:after{width:22px;height:22px}:host .button--normal{min-height:40px}:host .button--normal .button__icon{width:16px;height:16px}:host .button--normal .button__text{font-size:16px}:host .button--normal.spinner{min-width:48px}:host .button--small{min-height:32px}:host .button--small .button__icon{width:14px;height:14px}:host .button--small .button__text{font-size:14px}:host .button--small.spinner{min-width:40px}:host .button--small.spinner:after{width:14px;height:14px}:host .button--xsmall{min-height:24px}:host .button--xsmall .button__icon{width:12px;height:12px}:host .button--xsmall .button__text{font-size:12px}:host .button--xsmall.spinner{min-width:32px}:host .button--xsmall.spinner:after{width:10px;height:10px}:host .button.button--icon-before .button__icon{margin-right:8px}:host .button.button--icon-after .button__icon{margin-left:8px;order:1}:host .spinner{position:relative}:host .spinner:after{content:\"\";position:absolute;border-radius:100%;width:18px;height:18px;border:2px solid transparent;border-left-color:currentColor;border-top-color:currentColor;animation:spin .75s linear infinite;inset:0;margin:auto}:host .spinner .button__content{visibility:hidden}@keyframes spin{to{transform:rotate(1turn)}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: CpsIconComponent, selector: "cps-icon", inputs: ["icon", "size", "color"] }] });
|
|
907
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsButtonComponent, decorators: [{
|
|
908
|
+
type: Component,
|
|
909
|
+
args: [{ standalone: true, imports: [CommonModule, CpsIconComponent], selector: 'cps-button', template: "<div>\n <button\n type=\"button\"\n [ngClass]=\"classesList\"\n [disabled]=\"disabled || loading\"\n [class.spinner]=\"loading\"\n (click)=\"onClick($event)\"\n [ngStyle]=\"{\n 'background-color': type==='solid' ? buttonColor : 'transparent',\n color: textColor,\n height: cvtHeight || 'none',\n }\"\n >\n <div class=\"button__content\">\n <cps-icon\n *ngIf=\"icon\"\n class=\"button__icon\"\n [icon]=\"icon\"\n [color]=\"disabled ? 'text-light' : textColor\"\n [size]=\"cvtIconSize\"\n >\n </cps-icon>\n <span\n class=\"button__text\"\n *ngIf=\"label\"\n [ngStyle]=\"{ 'font-size': cvtFontSize || null }\"\n >{{ label }}</span\n >\n </div>\n </button>\n</div>\n", styles: [":host{width:-moz-fit-content;width:fit-content;display:inline-block}:host .button{width:100%;letter-spacing:normal;display:inline-flex;align-items:center;justify-content:center;position:relative;border-radius:4px;border:none;cursor:pointer;outline:none;padding:0 16px;font-weight:500}:host .button:hover:not(:active):not(:disabled){background-image:linear-gradient(hsla(0,0%,100%,.1) 0 0);box-shadow:0 2px 4px #0c0c0d33}:host .button:active:not(:disabled){background-image:linear-gradient(hsla(0,0%,0%,.1) 0 0)}:host .button__content{display:inline-flex}:host .button__icon{align-self:center}:host .button:disabled{cursor:default}:host .button--solid{border:0}:host .button--solid:disabled{background-color:var(--cps-color-line-mid)!important;color:var(--cps-color-text-light)!important}:host .button--outlined{border:2px solid;box-sizing:border-box}:host .button--outlined:disabled{border-color:var(--cps-color-line-dark)!important;color:var(--cps-color-text-light)!important}:host .button--borderless:disabled{color:var(--cps-color-text-light)!important}:host .button--borderless:hover:not(:active):not(:disabled){box-shadow:0 1px 4px #0c0c0d1a}:host .button--large{min-height:48px}:host .button--large .button__icon{width:20px;height:20px}:host .button--large .button__text{font-size:20px}:host .button--large.spinner{min-width:56px}:host .button--large.spinner:after{width:22px;height:22px}:host .button--normal{min-height:40px}:host .button--normal .button__icon{width:16px;height:16px}:host .button--normal .button__text{font-size:16px}:host .button--normal.spinner{min-width:48px}:host .button--small{min-height:32px}:host .button--small .button__icon{width:14px;height:14px}:host .button--small .button__text{font-size:14px}:host .button--small.spinner{min-width:40px}:host .button--small.spinner:after{width:14px;height:14px}:host .button--xsmall{min-height:24px}:host .button--xsmall .button__icon{width:12px;height:12px}:host .button--xsmall .button__text{font-size:12px}:host .button--xsmall.spinner{min-width:32px}:host .button--xsmall.spinner:after{width:10px;height:10px}:host .button.button--icon-before .button__icon{margin-right:8px}:host .button.button--icon-after .button__icon{margin-left:8px;order:1}:host .spinner{position:relative}:host .spinner:after{content:\"\";position:absolute;border-radius:100%;width:18px;height:18px;border:2px solid transparent;border-left-color:currentColor;border-top-color:currentColor;animation:spin .75s linear infinite;inset:0;margin:auto}:host .spinner .button__content{visibility:hidden}@keyframes spin{to{transform:rotate(1turn)}}\n"] }]
|
|
910
|
+
}], propDecorators: { color: [{
|
|
911
|
+
type: Input
|
|
912
|
+
}], contentColor: [{
|
|
913
|
+
type: Input
|
|
914
|
+
}], type: [{
|
|
915
|
+
type: Input
|
|
916
|
+
}], label: [{
|
|
917
|
+
type: Input
|
|
918
|
+
}], icon: [{
|
|
919
|
+
type: Input
|
|
920
|
+
}], iconPosition: [{
|
|
921
|
+
type: Input
|
|
922
|
+
}], size: [{
|
|
923
|
+
type: Input
|
|
924
|
+
}], width: [{
|
|
925
|
+
type: Input
|
|
926
|
+
}], height: [{
|
|
927
|
+
type: Input
|
|
928
|
+
}], disabled: [{
|
|
929
|
+
type: Input
|
|
930
|
+
}], loading: [{
|
|
931
|
+
type: Input
|
|
932
|
+
}], clicked: [{
|
|
933
|
+
type: Output
|
|
934
|
+
}], cvtWidth: [{
|
|
935
|
+
type: HostBinding,
|
|
936
|
+
args: ['style.width']
|
|
937
|
+
}] } });
|
|
938
|
+
|
|
939
|
+
class CpsCheckboxComponent {
|
|
940
|
+
set value(value) {
|
|
941
|
+
this._value = value;
|
|
942
|
+
this.onChange(value);
|
|
943
|
+
}
|
|
944
|
+
get value() {
|
|
945
|
+
return this._value;
|
|
946
|
+
}
|
|
947
|
+
constructor(_control, _elementRef) {
|
|
948
|
+
this._control = _control;
|
|
949
|
+
this._elementRef = _elementRef;
|
|
950
|
+
this.label = '';
|
|
951
|
+
this.disabled = false;
|
|
952
|
+
this.valueChanged = new EventEmitter();
|
|
953
|
+
this._value = false;
|
|
954
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
955
|
+
this.onChange = (event) => { };
|
|
956
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
957
|
+
this.onTouched = () => { };
|
|
958
|
+
if (this._control) {
|
|
959
|
+
this._control.valueAccessor = this;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
registerOnChange(fn) {
|
|
963
|
+
this.onChange = fn;
|
|
964
|
+
}
|
|
965
|
+
registerOnTouched(fn) {
|
|
966
|
+
this.onTouched = fn;
|
|
967
|
+
}
|
|
968
|
+
writeValue(value) {
|
|
969
|
+
this.value = value;
|
|
970
|
+
}
|
|
971
|
+
updateValueEvent(event) {
|
|
972
|
+
event.preventDefault();
|
|
973
|
+
if (this.disabled)
|
|
974
|
+
return;
|
|
975
|
+
this._updateValue(!this.value);
|
|
976
|
+
}
|
|
977
|
+
_updateValue(value) {
|
|
978
|
+
this.writeValue(value);
|
|
979
|
+
this.onChange(value);
|
|
980
|
+
this.valueChanged.emit(value);
|
|
981
|
+
}
|
|
982
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
983
|
+
setDisabledState(disabled) { }
|
|
984
|
+
focus() {
|
|
985
|
+
this._elementRef?.nativeElement?.querySelector('input')?.focus();
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
CpsCheckboxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsCheckboxComponent, deps: [{ token: i1.NgControl, optional: true, self: true }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
989
|
+
CpsCheckboxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CpsCheckboxComponent, isStandalone: true, selector: "cps-checkbox", inputs: { label: "label", disabled: "disabled", value: "value" }, outputs: { valueChanged: "valueChanged" }, ngImport: i0, template: "<div class=\"checkbox-container\">\n <label\n class=\"checkbox\"\n [ngStyle]=\"{ cursor: disabled ? 'default' : 'pointer' }\"\n >\n <span class=\"label\" [ngClass]=\"{ 'label-disabled': disabled }\">{{\n label\n }}</span>\n <input\n type=\"checkbox\"\n [disabled]=\"disabled\"\n [checked]=\"value\"\n (change)=\"updateValueEvent($event)\"\n />\n <span class=\"indicator\"></span>\n </label>\n</div>\n", styles: [":host{min-width:max-content;display:inline-block}:host .checkbox-container{line-height:normal}:host .checkbox-container label.checkbox{padding-left:1.75rem;position:relative;-webkit-user-select:none;user-select:none}:host .checkbox-container label.checkbox input[type=checkbox]{display:none}:host .checkbox-container label.checkbox input[type=checkbox]:hover:not(:disabled)~.indicator{border-color:var(--cps-color-calm)}:host .checkbox-container label.checkbox input[type=checkbox]:checked~.indicator{color:#fff;background:var(--cps-color-calm) url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+DQo8c3ZnIHdpZHRoPSIxMiIgaGVpZ2h0PSI5IiB2aWV3Qm94PSIwIDAgMTIgOSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPHBhdGggZD0iTTQuNTc1IDguOTc3cy0uNDA0LS4wMDctLjUzNi0uMTY1TC4wNTcgNS42NGwuODI5LTEuMjI3TDQuNDcgNy4yNjggMTAuOTIxLjA4NmwuOTIzIDEuMTAzLTYuODYzIDcuNjRjLS4xMzQtLjAwMy0uNDA2LjE0OC0uNDA2LjE0OHoiIGZpbGw9IiNGRkYiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPg0KPC9zdmc+) 50% 40% no-repeat;border:2px solid var(--cps-color-calm)}:host .checkbox-container label.checkbox input[type=checkbox]:disabled:checked~.indicator{background:var(--cps-color-text-lightest) url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+DQo8c3ZnIHdpZHRoPSIxMiIgaGVpZ2h0PSI5IiB2aWV3Qm94PSIwIDAgMTIgOSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPHBhdGggZD0iTTQuNTc1IDguOTc3cy0uNDA0LS4wMDctLjUzNi0uMTY1TC4wNTcgNS42NGwuODI5LTEuMjI3TDQuNDcgNy4yNjggMTAuOTIxLjA4NmwuOTIzIDEuMTAzLTYuODYzIDcuNjRjLS4xMzQtLjAwMy0uNDA2LjE0OC0uNDA2LjE0OHoiIGZpbGw9IiNGRkYiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPg0KPC9zdmc+) 50% 40% no-repeat;border-color:var(--cps-color-text-lightest)}:host .checkbox-container label.checkbox input[type=checkbox]:disabled~.indicator{border-color:var(--cps-color-text-light)}:host .checkbox-container label.checkbox .label{top:1px;position:relative;color:var(--cps-color-text-dark)}:host .checkbox-container label.checkbox .label-disabled{color:var(--cps-color-text-light)}:host .checkbox-container label.checkbox .indicator{border-radius:2px;position:absolute;left:0;width:18px;height:18px;border:2px solid var(--cps-color-text-dark);pointer-events:none;-webkit-user-select:none;user-select:none}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
990
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsCheckboxComponent, decorators: [{
|
|
991
|
+
type: Component,
|
|
992
|
+
args: [{ standalone: true, imports: [CommonModule], selector: 'cps-checkbox', template: "<div class=\"checkbox-container\">\n <label\n class=\"checkbox\"\n [ngStyle]=\"{ cursor: disabled ? 'default' : 'pointer' }\"\n >\n <span class=\"label\" [ngClass]=\"{ 'label-disabled': disabled }\">{{\n label\n }}</span>\n <input\n type=\"checkbox\"\n [disabled]=\"disabled\"\n [checked]=\"value\"\n (change)=\"updateValueEvent($event)\"\n />\n <span class=\"indicator\"></span>\n </label>\n</div>\n", styles: [":host{min-width:max-content;display:inline-block}:host .checkbox-container{line-height:normal}:host .checkbox-container label.checkbox{padding-left:1.75rem;position:relative;-webkit-user-select:none;user-select:none}:host .checkbox-container label.checkbox input[type=checkbox]{display:none}:host .checkbox-container label.checkbox input[type=checkbox]:hover:not(:disabled)~.indicator{border-color:var(--cps-color-calm)}:host .checkbox-container label.checkbox input[type=checkbox]:checked~.indicator{color:#fff;background:var(--cps-color-calm) url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+DQo8c3ZnIHdpZHRoPSIxMiIgaGVpZ2h0PSI5IiB2aWV3Qm94PSIwIDAgMTIgOSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPHBhdGggZD0iTTQuNTc1IDguOTc3cy0uNDA0LS4wMDctLjUzNi0uMTY1TC4wNTcgNS42NGwuODI5LTEuMjI3TDQuNDcgNy4yNjggMTAuOTIxLjA4NmwuOTIzIDEuMTAzLTYuODYzIDcuNjRjLS4xMzQtLjAwMy0uNDA2LjE0OC0uNDA2LjE0OHoiIGZpbGw9IiNGRkYiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPg0KPC9zdmc+) 50% 40% no-repeat;border:2px solid var(--cps-color-calm)}:host .checkbox-container label.checkbox input[type=checkbox]:disabled:checked~.indicator{background:var(--cps-color-text-lightest) url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+DQo8c3ZnIHdpZHRoPSIxMiIgaGVpZ2h0PSI5IiB2aWV3Qm94PSIwIDAgMTIgOSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPHBhdGggZD0iTTQuNTc1IDguOTc3cy0uNDA0LS4wMDctLjUzNi0uMTY1TC4wNTcgNS42NGwuODI5LTEuMjI3TDQuNDcgNy4yNjggMTAuOTIxLjA4NmwuOTIzIDEuMTAzLTYuODYzIDcuNjRjLS4xMzQtLjAwMy0uNDA2LjE0OC0uNDA2LjE0OHoiIGZpbGw9IiNGRkYiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPg0KPC9zdmc+) 50% 40% no-repeat;border-color:var(--cps-color-text-lightest)}:host .checkbox-container label.checkbox input[type=checkbox]:disabled~.indicator{border-color:var(--cps-color-text-light)}:host .checkbox-container label.checkbox .label{top:1px;position:relative;color:var(--cps-color-text-dark)}:host .checkbox-container label.checkbox .label-disabled{color:var(--cps-color-text-light)}:host .checkbox-container label.checkbox .indicator{border-radius:2px;position:absolute;left:0;width:18px;height:18px;border:2px solid var(--cps-color-text-dark);pointer-events:none;-webkit-user-select:none;user-select:none}\n"] }]
|
|
993
|
+
}], ctorParameters: function () { return [{ type: i1.NgControl, decorators: [{
|
|
994
|
+
type: Self
|
|
995
|
+
}, {
|
|
996
|
+
type: Optional
|
|
997
|
+
}] }, { type: i0.ElementRef }]; }, propDecorators: { label: [{
|
|
998
|
+
type: Input
|
|
999
|
+
}], disabled: [{
|
|
1000
|
+
type: Input
|
|
1001
|
+
}], value: [{
|
|
1002
|
+
type: Input
|
|
1003
|
+
}], valueChanged: [{
|
|
1004
|
+
type: Output
|
|
1005
|
+
}] } });
|
|
1006
|
+
|
|
1007
|
+
class CpsRadioComponent {
|
|
1008
|
+
set value(value) {
|
|
1009
|
+
this._value = value;
|
|
1010
|
+
this.onChange(value);
|
|
1011
|
+
}
|
|
1012
|
+
get value() {
|
|
1013
|
+
return this._value;
|
|
1014
|
+
}
|
|
1015
|
+
constructor(_control) {
|
|
1016
|
+
this._control = _control;
|
|
1017
|
+
this.options = [];
|
|
1018
|
+
this.groupLabel = '';
|
|
1019
|
+
this.vertical = false;
|
|
1020
|
+
this.disabled = false;
|
|
1021
|
+
this.valueChanged = new EventEmitter();
|
|
1022
|
+
this._value = undefined;
|
|
1023
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1024
|
+
this.onChange = (event) => { };
|
|
1025
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1026
|
+
this.onTouched = () => { };
|
|
1027
|
+
if (this._control) {
|
|
1028
|
+
this._control.valueAccessor = this;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
registerOnChange(fn) {
|
|
1032
|
+
this.onChange = fn;
|
|
1033
|
+
}
|
|
1034
|
+
registerOnTouched(fn) {
|
|
1035
|
+
this.onTouched = fn;
|
|
1036
|
+
}
|
|
1037
|
+
writeValue(value) {
|
|
1038
|
+
this.value = value;
|
|
1039
|
+
}
|
|
1040
|
+
updateValueEvent(event) {
|
|
1041
|
+
event.preventDefault();
|
|
1042
|
+
if (this.disabled)
|
|
1043
|
+
return;
|
|
1044
|
+
const value = event?.target?.value || '';
|
|
1045
|
+
this._updateValue(value);
|
|
1046
|
+
}
|
|
1047
|
+
_updateValue(value) {
|
|
1048
|
+
this.writeValue(value);
|
|
1049
|
+
this.onChange(value);
|
|
1050
|
+
this.valueChanged.emit(value);
|
|
1051
|
+
}
|
|
1052
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1053
|
+
setDisabledState(disabled) { }
|
|
1054
|
+
}
|
|
1055
|
+
CpsRadioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsRadioComponent, deps: [{ token: i1.NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
1056
|
+
CpsRadioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CpsRadioComponent, isStandalone: true, selector: "cps-radio", inputs: { options: "options", groupLabel: "groupLabel", vertical: "vertical", disabled: "disabled", value: "value" }, outputs: { valueChanged: "valueChanged" }, ngImport: i0, template: "<div class=\"radio-group\">\n <div class=\"radio-group-label\" *ngIf=\"groupLabel\">\n <span>{{ groupLabel }}</span>\n </div>\n <div\n class=\"radio-group-content\"\n [ngClass]=\"\n vertical\n ? 'radio-group-content-vertical'\n : 'radio-group-content-horizontal'\n \"\n >\n <label\n *ngFor=\"let option of options\"\n class=\"radio-group-content-button\"\n [ngStyle]=\"{\n cursor: option.disabled || disabled ? 'default' : 'pointer'\n }\"\n >\n <input\n type=\"radio\"\n [disabled]=\"option.disabled || disabled\"\n [value]=\"option.value\"\n [checked]=\"value === option.value\"\n (change)=\"updateValueEvent($event)\"\n />\n <span class=\"radio-group-content-button-label\">{{ option.label }}</span>\n </label>\n </div>\n</div>\n", styles: [":host{width:-moz-fit-content;width:fit-content;display:inline-block}:host .radio-group-label{color:var(--cps-color-text-dark);margin-bottom:.75rem}:host .radio-group-content{margin-left:.5rem;gap:1.25rem}:host .radio-group-content-vertical{display:grid}:host .radio-group-content-horizontal{display:flex;flex-direction:row;flex-wrap:wrap}:host .radio-group-content-button{display:grid;grid-template-columns:1em auto;gap:.75em}:host .radio-group-content-button-label{font-size:1rem;align-self:center;color:var(--cps-color-text-dark)}:host .radio-group-content-button input[type=radio]{-webkit-appearance:none;appearance:none;background-color:transparent;margin:0;cursor:pointer;font:inherit;color:var(--cps-color-text-dark);width:1.25em;height:1.25em;border:.15em solid currentColor;border-radius:50%;transform:translateY(-.075em);display:grid;place-content:center}:host .radio-group-content-button input[type=radio]:hover,:host .radio-group-content-button input[type=radio]:checked{color:var(--cps-color-calm)}:host .radio-group-content-button input[type=radio]:disabled{color:var(--cps-color-text-lightest);cursor:default}:host .radio-group-content-button input[type=radio]:before{content:\"\";width:.625em;height:.625em;border-radius:50%;transform:scale(0);transition:.12s transform ease-in-out;box-shadow:inset 1em 1em var(--cps-color-calm);background-color:CanvasText}:host .radio-group-content-button input[type=radio][disabled]:before{box-shadow:inset 1em 1em var(--cps-color-text-lightest)}:host .radio-group-content-button input[type=radio]:disabled+.radio-group-content-button-label{color:var(--cps-color-text-light)}:host .radio-group-content-button input[type=radio]:checked:before{transform:scale(1)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
1057
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsRadioComponent, decorators: [{
|
|
1058
|
+
type: Component,
|
|
1059
|
+
args: [{ standalone: true, imports: [CommonModule], selector: 'cps-radio', template: "<div class=\"radio-group\">\n <div class=\"radio-group-label\" *ngIf=\"groupLabel\">\n <span>{{ groupLabel }}</span>\n </div>\n <div\n class=\"radio-group-content\"\n [ngClass]=\"\n vertical\n ? 'radio-group-content-vertical'\n : 'radio-group-content-horizontal'\n \"\n >\n <label\n *ngFor=\"let option of options\"\n class=\"radio-group-content-button\"\n [ngStyle]=\"{\n cursor: option.disabled || disabled ? 'default' : 'pointer'\n }\"\n >\n <input\n type=\"radio\"\n [disabled]=\"option.disabled || disabled\"\n [value]=\"option.value\"\n [checked]=\"value === option.value\"\n (change)=\"updateValueEvent($event)\"\n />\n <span class=\"radio-group-content-button-label\">{{ option.label }}</span>\n </label>\n </div>\n</div>\n", styles: [":host{width:-moz-fit-content;width:fit-content;display:inline-block}:host .radio-group-label{color:var(--cps-color-text-dark);margin-bottom:.75rem}:host .radio-group-content{margin-left:.5rem;gap:1.25rem}:host .radio-group-content-vertical{display:grid}:host .radio-group-content-horizontal{display:flex;flex-direction:row;flex-wrap:wrap}:host .radio-group-content-button{display:grid;grid-template-columns:1em auto;gap:.75em}:host .radio-group-content-button-label{font-size:1rem;align-self:center;color:var(--cps-color-text-dark)}:host .radio-group-content-button input[type=radio]{-webkit-appearance:none;appearance:none;background-color:transparent;margin:0;cursor:pointer;font:inherit;color:var(--cps-color-text-dark);width:1.25em;height:1.25em;border:.15em solid currentColor;border-radius:50%;transform:translateY(-.075em);display:grid;place-content:center}:host .radio-group-content-button input[type=radio]:hover,:host .radio-group-content-button input[type=radio]:checked{color:var(--cps-color-calm)}:host .radio-group-content-button input[type=radio]:disabled{color:var(--cps-color-text-lightest);cursor:default}:host .radio-group-content-button input[type=radio]:before{content:\"\";width:.625em;height:.625em;border-radius:50%;transform:scale(0);transition:.12s transform ease-in-out;box-shadow:inset 1em 1em var(--cps-color-calm);background-color:CanvasText}:host .radio-group-content-button input[type=radio][disabled]:before{box-shadow:inset 1em 1em var(--cps-color-text-lightest)}:host .radio-group-content-button input[type=radio]:disabled+.radio-group-content-button-label{color:var(--cps-color-text-light)}:host .radio-group-content-button input[type=radio]:checked:before{transform:scale(1)}\n"] }]
|
|
1060
|
+
}], ctorParameters: function () { return [{ type: i1.NgControl, decorators: [{
|
|
1061
|
+
type: Self
|
|
1062
|
+
}, {
|
|
1063
|
+
type: Optional
|
|
1064
|
+
}] }]; }, propDecorators: { options: [{
|
|
1065
|
+
type: Input
|
|
1066
|
+
}], groupLabel: [{
|
|
1067
|
+
type: Input
|
|
1068
|
+
}], vertical: [{
|
|
1069
|
+
type: Input
|
|
1070
|
+
}], disabled: [{
|
|
1071
|
+
type: Input
|
|
1072
|
+
}], value: [{
|
|
1073
|
+
type: Input
|
|
1074
|
+
}], valueChanged: [{
|
|
1075
|
+
type: Output
|
|
1076
|
+
}] } });
|
|
1077
|
+
|
|
1078
|
+
class CpsTagComponent {
|
|
1079
|
+
set value(value) {
|
|
1080
|
+
this._value = value;
|
|
1081
|
+
this.onChange(value);
|
|
1082
|
+
}
|
|
1083
|
+
get value() {
|
|
1084
|
+
return this._value;
|
|
1085
|
+
}
|
|
1086
|
+
constructor(_control) {
|
|
1087
|
+
this._control = _control;
|
|
1088
|
+
this.type = 'custom'; // higher precedence over color
|
|
1089
|
+
this.label = '';
|
|
1090
|
+
this.color = '';
|
|
1091
|
+
this.disabled = false;
|
|
1092
|
+
this.selectable = false;
|
|
1093
|
+
this.valueChanged = new EventEmitter();
|
|
1094
|
+
this.classesList = [];
|
|
1095
|
+
this.tagColor = '';
|
|
1096
|
+
this._value = false;
|
|
1097
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1098
|
+
this.onChange = (event) => { };
|
|
1099
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1100
|
+
this.onTouched = () => { };
|
|
1101
|
+
if (this._control) {
|
|
1102
|
+
this._control.valueAccessor = this;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
ngOnChanges() {
|
|
1106
|
+
this.setClasses();
|
|
1107
|
+
}
|
|
1108
|
+
setClasses() {
|
|
1109
|
+
this.classesList = ['tag'];
|
|
1110
|
+
if (this.selectable) {
|
|
1111
|
+
this.classesList.push('tag--selectable');
|
|
1112
|
+
}
|
|
1113
|
+
if (this.disabled) {
|
|
1114
|
+
this.classesList.push('tag--disabled');
|
|
1115
|
+
}
|
|
1116
|
+
switch (this.type) {
|
|
1117
|
+
case 'security': {
|
|
1118
|
+
this.classesList.push('tag--security');
|
|
1119
|
+
break;
|
|
1120
|
+
}
|
|
1121
|
+
case 'classification': {
|
|
1122
|
+
this.classesList.push('tag--classification');
|
|
1123
|
+
break;
|
|
1124
|
+
}
|
|
1125
|
+
default:
|
|
1126
|
+
if (this.color)
|
|
1127
|
+
this.tagColor = getCSSColor(this.color);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
registerOnChange(fn) {
|
|
1131
|
+
this.onChange = fn;
|
|
1132
|
+
}
|
|
1133
|
+
registerOnTouched(fn) {
|
|
1134
|
+
this.onTouched = fn;
|
|
1135
|
+
}
|
|
1136
|
+
writeValue(value) {
|
|
1137
|
+
this.value = value;
|
|
1138
|
+
}
|
|
1139
|
+
toggleSelected() {
|
|
1140
|
+
if (this.disabled || !this.selectable)
|
|
1141
|
+
return;
|
|
1142
|
+
this._updateValue(!this.value);
|
|
1143
|
+
}
|
|
1144
|
+
_updateValue(value) {
|
|
1145
|
+
this.writeValue(value);
|
|
1146
|
+
this.onChange(value);
|
|
1147
|
+
this.valueChanged.emit(value);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
CpsTagComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsTagComponent, deps: [{ token: i1.NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
1151
|
+
CpsTagComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CpsTagComponent, isStandalone: true, selector: "cps-tag", inputs: { type: "type", label: "label", color: "color", disabled: "disabled", selectable: "selectable", value: "value" }, outputs: { valueChanged: "valueChanged" }, usesOnChanges: true, ngImport: i0, template: "<div\n [ngClass]=\"classesList\"\n [class.unselected]=\"!value && selectable\"\n [ngStyle]=\"{ 'border-color': tagColor || 'none' }\"\n (click)=\"toggleSelected()\"\n>\n <p>{{ label }}</p>\n</div>\n", styles: [":host{width:-moz-fit-content;width:fit-content;display:inline-block;-webkit-user-select:none;user-select:none}:host .tag{min-height:25px;align-items:center;padding:0 10px;background-color:#fff;display:inline-flex;cursor:default;border:solid 1px;border-left:solid 4px}:host .tag.tag--security{border-color:var(--cps-color-warn)}:host .tag.tag--classification{border-color:var(--cps-color-info)}:host .tag.tag--selectable{cursor:pointer}:host .tag.tag--selectable:hover:not(:active):not(:disabled){box-shadow:1px 3px 4px #0000001a}:host .tag.tag--disabled{pointer-events:none;border-color:var(--cps-color-line-dark)!important}:host .tag.tag--disabled p{color:var(--cps-color-text-light)}:host .tag.unselected{border-color:var(--cps-color-text-light)!important}:host .tag p{margin:0;font-size:11px;color:var(--cps-color-text-dark)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
1152
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsTagComponent, decorators: [{
|
|
1153
|
+
type: Component,
|
|
1154
|
+
args: [{ standalone: true, imports: [CommonModule], selector: 'cps-tag', template: "<div\n [ngClass]=\"classesList\"\n [class.unselected]=\"!value && selectable\"\n [ngStyle]=\"{ 'border-color': tagColor || 'none' }\"\n (click)=\"toggleSelected()\"\n>\n <p>{{ label }}</p>\n</div>\n", styles: [":host{width:-moz-fit-content;width:fit-content;display:inline-block;-webkit-user-select:none;user-select:none}:host .tag{min-height:25px;align-items:center;padding:0 10px;background-color:#fff;display:inline-flex;cursor:default;border:solid 1px;border-left:solid 4px}:host .tag.tag--security{border-color:var(--cps-color-warn)}:host .tag.tag--classification{border-color:var(--cps-color-info)}:host .tag.tag--selectable{cursor:pointer}:host .tag.tag--selectable:hover:not(:active):not(:disabled){box-shadow:1px 3px 4px #0000001a}:host .tag.tag--disabled{pointer-events:none;border-color:var(--cps-color-line-dark)!important}:host .tag.tag--disabled p{color:var(--cps-color-text-light)}:host .tag.unselected{border-color:var(--cps-color-text-light)!important}:host .tag p{margin:0;font-size:11px;color:var(--cps-color-text-dark)}\n"] }]
|
|
1155
|
+
}], ctorParameters: function () { return [{ type: i1.NgControl, decorators: [{
|
|
1156
|
+
type: Self
|
|
1157
|
+
}, {
|
|
1158
|
+
type: Optional
|
|
1159
|
+
}] }]; }, propDecorators: { type: [{
|
|
1160
|
+
type: Input
|
|
1161
|
+
}], label: [{
|
|
1162
|
+
type: Input
|
|
1163
|
+
}], color: [{
|
|
1164
|
+
type: Input
|
|
1165
|
+
}], disabled: [{
|
|
1166
|
+
type: Input
|
|
1167
|
+
}], selectable: [{
|
|
1168
|
+
type: Input
|
|
1169
|
+
}], value: [{
|
|
1170
|
+
type: Input
|
|
1171
|
+
}], valueChanged: [{
|
|
1172
|
+
type: Output
|
|
1173
|
+
}] } });
|
|
1174
|
+
|
|
1175
|
+
/*
|
|
1176
|
+
* Public API Surface of cps-ui-kit
|
|
1177
|
+
*/
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* Generated bundle index. Do not edit.
|
|
1181
|
+
*/
|
|
1182
|
+
|
|
1183
|
+
export { CpsButtonComponent, CpsCheckboxComponent, CpsChipComponent, CpsIconComponent, CpsInputComponent, CpsRadioComponent, CpsSelectComponent, CpsTagComponent, iconNames };
|
|
1184
|
+
//# sourceMappingURL=cps-ui-kit.mjs.map
|