@firestitch/chip 12.0.0 → 13.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.
@@ -10,436 +10,431 @@ import { Subject } from 'rxjs';
10
10
  import { takeUntil, debounceTime } from 'rxjs/operators';
11
11
  import { find } from 'lodash-es';
12
12
 
13
- class FsChipsService {
14
- constructor() {
15
- this.chips = [];
16
- this._chipItemsChanged$ = new Subject();
17
- this._selectionChanged$ = new Subject();
18
- this._destroy$ = new Subject();
19
- }
20
- get selectionChanged$() {
21
- return this._selectionChanged$.
22
- pipe(takeUntil(this._destroy$));
23
- }
24
- get chipItemsChanged$() {
25
- return this._chipItemsChanged$
26
- .pipe(takeUntil(this._destroy$), debounceTime(50));
27
- }
28
- ngOnDestroy() {
29
- this._destroy$.next();
30
- this._destroy$.complete();
31
- }
32
- selectionChanged(selected, value) {
33
- this._selectionChanged$.next({
34
- selected: selected,
35
- value: value,
36
- });
37
- }
38
- register(chip) {
39
- this.chips.push(chip);
40
- this._chipItemsChanged$.next();
41
- }
42
- destroy(chip) {
43
- const index = this.chips.indexOf(chip);
44
- if (index > -1) {
45
- this.chips.splice(index, 1);
46
- this._chipItemsChanged$.next();
47
- }
48
- }
49
- }
50
- FsChipsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsChipsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
51
- FsChipsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsChipsService });
52
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsChipsService, decorators: [{
53
- type: Injectable
13
+ class FsChipsService {
14
+ constructor() {
15
+ this.chips = [];
16
+ this._chipItemsChanged$ = new Subject();
17
+ this._selectionChanged$ = new Subject();
18
+ this._destroy$ = new Subject();
19
+ }
20
+ get selectionChanged$() {
21
+ return this._selectionChanged$.
22
+ pipe(takeUntil(this._destroy$));
23
+ }
24
+ get chipItemsChanged$() {
25
+ return this._chipItemsChanged$
26
+ .pipe(takeUntil(this._destroy$), debounceTime(50));
27
+ }
28
+ ngOnDestroy() {
29
+ this._destroy$.next();
30
+ this._destroy$.complete();
31
+ }
32
+ selectionChanged(selected, value) {
33
+ this._selectionChanged$.next({
34
+ selected: selected,
35
+ value: value,
36
+ });
37
+ }
38
+ register(chip) {
39
+ this.chips.push(chip);
40
+ this._chipItemsChanged$.next();
41
+ }
42
+ destroy(chip) {
43
+ const index = this.chips.indexOf(chip);
44
+ if (index > -1) {
45
+ this.chips.splice(index, 1);
46
+ this._chipItemsChanged$.next();
47
+ }
48
+ }
49
+ }
50
+ FsChipsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsChipsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
51
+ FsChipsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsChipsService });
52
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsChipsService, decorators: [{
53
+ type: Injectable
54
54
  }], ctorParameters: function () { return []; } });
55
55
 
56
- class FsChipsComponent {
57
- constructor(_cdRef, _chipsService) {
58
- this._cdRef = _cdRef;
59
- this._chipsService = _chipsService;
60
- this.classFsChips = true;
61
- this.classHasChips = false;
62
- this.multiple = true;
63
- this.onChange = () => { };
64
- this.onTouch = () => { };
65
- this._value = [];
66
- this._destroy$ = new Subject();
67
- this.subscribeToItemsChange();
68
- this.subscribeToSelectionChange();
69
- }
70
- get chips() {
71
- return this._chipsService.chips;
72
- }
73
- set value(value) {
74
- if (this._value !== value) {
75
- this._value = value;
76
- this.onChange(this._value);
77
- this.onTouch(this._value);
78
- }
79
- }
80
- get value() {
81
- return this._value;
82
- }
83
- ngOnDestroy() {
84
- this._destroy$.next();
85
- this._destroy$.complete();
86
- }
87
- writeValue(value) {
88
- if (value !== this.value) {
89
- this._value = value;
90
- }
91
- this.updateChips();
92
- }
93
- registerOnChange(fn) { this.onChange = fn; }
94
- registerOnTouched(fn) { this.onTouch = fn; }
95
- /**
96
- * Update ngModel value when selection changed
97
- */
98
- subscribeToSelectionChange() {
99
- this._chipsService.selectionChanged$
100
- .pipe(takeUntil(this._destroy$))
101
- .subscribe(({ selected, value }) => {
102
- if (!selected) {
103
- const valueIndex = this.value.findIndex((item) => {
104
- return this.compareFn(item, value);
105
- });
106
- if (valueIndex > -1) {
107
- this.value.splice(valueIndex, 1);
108
- this.onChange(this._value);
109
- this.onTouch(this._value);
110
- }
111
- }
112
- else {
113
- this.value.push(value);
114
- this.onChange(this._value);
115
- this.onTouch(this._value);
116
- }
117
- });
118
- }
119
- /**
120
- * Update selection if item was added or removed
121
- */
122
- subscribeToItemsChange() {
123
- this._chipsService.chipItemsChanged$
124
- .pipe(takeUntil(this._destroy$))
125
- .subscribe(() => {
126
- this.classHasChips = !!this._chipsService.chips.length;
127
- this.updateChips();
128
- });
129
- }
130
- compareFn(o1, o2) {
131
- if (this.compare) {
132
- return this.compare(o1, o2);
133
- }
134
- return o1 === o2;
135
- }
136
- updateChips() {
137
- if (this.multiple && Array.isArray(this.value) && this.chips) {
138
- this.chips.forEach((chip) => {
139
- chip.selected = find(this.value, (o) => {
140
- return this.compareFn(o, chip.value);
141
- }) !== undefined;
142
- });
143
- }
144
- this._cdRef.markForCheck();
145
- }
146
- }
147
- FsChipsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsChipsComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: FsChipsService }], target: i0.ɵɵFactoryTarget.Component });
148
- FsChipsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsChipsComponent, selector: "fs-chips", inputs: { compare: "compare", multiple: "multiple" }, host: { properties: { "class.fs-chips": "this.classFsChips", "class.has-chips": "this.classHasChips" } }, providers: [
149
- {
150
- provide: NG_VALUE_ACCESSOR,
151
- useExisting: forwardRef(() => FsChipsComponent),
152
- multi: true,
153
- },
154
- FsChipsService,
155
- ], ngImport: i0, template: "<ng-content></ng-content>\n", styles: [""], changeDetection: i0.ChangeDetectionStrategy.OnPush });
156
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsChipsComponent, decorators: [{
157
- type: Component,
158
- args: [{
159
- selector: 'fs-chips',
160
- templateUrl: 'chips.component.html',
161
- styleUrls: ['chips.component.scss'],
162
- providers: [
163
- {
164
- provide: NG_VALUE_ACCESSOR,
165
- useExisting: forwardRef(() => FsChipsComponent),
166
- multi: true,
167
- },
168
- FsChipsService,
169
- ],
170
- changeDetection: ChangeDetectionStrategy.OnPush,
171
- }]
172
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: FsChipsService }]; }, propDecorators: { classFsChips: [{
173
- type: HostBinding,
174
- args: ['class.fs-chips']
175
- }], classHasChips: [{
176
- type: HostBinding,
177
- args: ['class.has-chips']
178
- }], compare: [{
179
- type: Input
180
- }], multiple: [{
181
- type: Input
56
+ class FsChipsComponent {
57
+ constructor(_cdRef, _chipsService) {
58
+ this._cdRef = _cdRef;
59
+ this._chipsService = _chipsService;
60
+ this.classFsChips = true;
61
+ this.classHasChips = false;
62
+ this.multiple = true;
63
+ this._value = [];
64
+ this._destroy$ = new Subject();
65
+ this._subscribeToItemsChange();
66
+ this._subscribeToSelectionChange();
67
+ }
68
+ get chips() {
69
+ return this._chipsService.chips;
70
+ }
71
+ set value(value) {
72
+ if (this._value !== value) {
73
+ this._value = value;
74
+ this.onChange(this._value);
75
+ this.onTouch(this._value);
76
+ }
77
+ }
78
+ get value() {
79
+ return this._value;
80
+ }
81
+ ngOnDestroy() {
82
+ this._destroy$.next();
83
+ this._destroy$.complete();
84
+ }
85
+ writeValue(value) {
86
+ if (value !== this.value) {
87
+ this._value = value;
88
+ }
89
+ this._updateChips();
90
+ }
91
+ registerOnChange(fn) {
92
+ this.onChange = fn;
93
+ }
94
+ registerOnTouched(fn) {
95
+ this.onTouch = fn;
96
+ }
97
+ /**
98
+ * Update ngModel value when selection changed
99
+ */
100
+ _subscribeToSelectionChange() {
101
+ this._chipsService.selectionChanged$
102
+ .pipe(takeUntil(this._destroy$))
103
+ .subscribe(({ selected, value }) => {
104
+ if (!selected) {
105
+ const valueIndex = this.value.findIndex((item) => {
106
+ return this._compareFn(item, value);
107
+ });
108
+ if (valueIndex > -1) {
109
+ this.value.splice(valueIndex, 1);
110
+ this.onChange(this._value);
111
+ this.onTouch(this._value);
112
+ }
113
+ }
114
+ else {
115
+ this.value.push(value);
116
+ this.onChange(this._value);
117
+ this.onTouch(this._value);
118
+ }
119
+ });
120
+ }
121
+ /**
122
+ * Update selection if item was added or removed
123
+ */
124
+ _subscribeToItemsChange() {
125
+ this._chipsService.chipItemsChanged$
126
+ .pipe(takeUntil(this._destroy$))
127
+ .subscribe(() => {
128
+ this.classHasChips = !!this._chipsService.chips.length;
129
+ this._updateChips();
130
+ });
131
+ }
132
+ _compareFn(o1, o2) {
133
+ if (this.compare) {
134
+ return this.compare(o1, o2);
135
+ }
136
+ return o1 === o2;
137
+ }
138
+ _updateChips() {
139
+ if (this.multiple && Array.isArray(this.value) && this.chips) {
140
+ this.chips.forEach((chip) => {
141
+ chip.selected = find(this.value, (o) => {
142
+ return this._compareFn(o, chip.value);
143
+ }) !== undefined;
144
+ });
145
+ }
146
+ this._cdRef.markForCheck();
147
+ }
148
+ }
149
+ FsChipsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsChipsComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: FsChipsService }], target: i0.ɵɵFactoryTarget.Component });
150
+ FsChipsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: FsChipsComponent, selector: "fs-chips", inputs: { compare: "compare", multiple: "multiple" }, host: { properties: { "class.fs-chips": "this.classFsChips", "class.has-chips": "this.classHasChips" } }, providers: [
151
+ {
152
+ provide: NG_VALUE_ACCESSOR,
153
+ useExisting: forwardRef(() => FsChipsComponent),
154
+ multi: true,
155
+ },
156
+ FsChipsService,
157
+ ], ngImport: i0, template: "<ng-content></ng-content>\n", styles: [":host{display:flex;flex-wrap:wrap}:host.has-chips{margin-top:-5px}:host ::ng-deep .fs-chip{margin-right:5px;margin-top:5px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
158
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsChipsComponent, decorators: [{
159
+ type: Component,
160
+ args: [{ selector: 'fs-chips', providers: [
161
+ {
162
+ provide: NG_VALUE_ACCESSOR,
163
+ useExisting: forwardRef(() => FsChipsComponent),
164
+ multi: true,
165
+ },
166
+ FsChipsService,
167
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-content></ng-content>\n", styles: [":host{display:flex;flex-wrap:wrap}:host.has-chips{margin-top:-5px}:host ::ng-deep .fs-chip{margin-right:5px;margin-top:5px}\n"] }]
168
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: FsChipsService }]; }, propDecorators: { classFsChips: [{
169
+ type: HostBinding,
170
+ args: ['class.fs-chips']
171
+ }], classHasChips: [{
172
+ type: HostBinding,
173
+ args: ['class.has-chips']
174
+ }], compare: [{
175
+ type: Input
176
+ }], multiple: [{
177
+ type: Input
182
178
  }] } });
183
179
 
184
- class FsChipComponent {
185
- constructor(_cdRef, _chips) {
186
- this._cdRef = _cdRef;
187
- this._chips = _chips;
188
- this.fsChip = true;
189
- this._outlined = false;
190
- this._selectable = false;
191
- this._image = false;
192
- this._selected = false;
193
- this._removable = false;
194
- this.styleBackgroundColor = '';
195
- this.styleColor = '';
196
- this.styleBorderColor = '';
197
- this.classSmall = false;
198
- this.classTiny = false;
199
- this.classMicro = false;
200
- this.value = null;
201
- this.selectedToggled = new EventEmitter();
202
- this.removed = new EventEmitter();
203
- this.$destroy = new Subject();
204
- this._backgroundColor = '';
205
- this._color = '';
206
- }
207
- set setSize(value) {
208
- this._size = value;
209
- this.classSmall = value === 'small';
210
- this.classTiny = value === 'tiny';
211
- this.classMicro = value === 'micro';
212
- }
213
- ;
214
- click() {
215
- if (this.selectable) {
216
- this.selected = !this.selected;
217
- this.selectedToggled.emit({ value: this.value, selected: this.selected });
218
- if (this._chips) {
219
- this._chips.selectionChanged(this.selected, this.value);
220
- }
221
- }
222
- }
223
- set backgroundColor(value) {
224
- this._backgroundColor = value;
225
- this.updateStyles();
226
- }
227
- ;
228
- set borderColor(value) {
229
- this.styleBorderColor = value;
230
- this.updateStyles();
231
- }
232
- set color(value) {
233
- this._color = value;
234
- this.updateStyles();
235
- }
236
- get color() {
237
- return this._color;
238
- }
239
- set outlined(value) {
240
- this._outlined = value;
241
- this.updateStyles();
242
- }
243
- ;
244
- get outlined() {
245
- return this._outlined;
246
- }
247
- set removable(value) {
248
- this._removable = value;
249
- this._cdRef.markForCheck();
250
- }
251
- ;
252
- get removable() {
253
- return this._removable;
254
- }
255
- set selectable(value) {
256
- this._selectable = value;
257
- }
258
- ;
259
- get selectable() {
260
- return this._selectable;
261
- }
262
- set selected(value) {
263
- this._selected = value;
264
- this._cdRef.markForCheck();
265
- }
266
- ;
267
- get selected() {
268
- return this._selected;
269
- }
270
- set image(value) {
271
- this._image = value;
272
- this._cdRef.markForCheck();
273
- }
274
- ;
275
- get image() {
276
- return this._image;
277
- }
278
- ngOnInit() {
279
- if (this._chips) {
280
- this._chips.register(this);
281
- }
282
- }
283
- ngOnDestroy() {
284
- if (this._chips) {
285
- this._chips.destroy(this);
286
- }
287
- this.$destroy.next();
288
- this.$destroy.complete();
289
- }
290
- remove(event) {
291
- this.removed.next(event);
292
- }
293
- isContrastYIQBlack(hexcolor) {
294
- if (!hexcolor) {
295
- return true;
296
- }
297
- hexcolor = hexcolor.replace('#', '');
298
- const r = parseInt(hexcolor.substr(0, 2), 16);
299
- const g = parseInt(hexcolor.substr(2, 2), 16);
300
- const b = parseInt(hexcolor.substr(4, 2), 16);
301
- const yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
302
- return yiq >= 200;
303
- }
304
- updateStyles() {
305
- this.styleBackgroundColor = this._backgroundColor;
306
- if (this._color) {
307
- this.styleColor = this._color;
308
- }
309
- else if (!this._outlined) {
310
- this.styleColor = this.isContrastYIQBlack(this.styleBackgroundColor) ? '#474747' : '#fff';
311
- }
312
- if (this._outlined) {
313
- this.styleBackgroundColor = '';
314
- if (this._color) {
315
- this.styleBorderColor = this._color;
316
- }
317
- }
318
- this._cdRef.markForCheck();
319
- }
320
- }
321
- FsChipComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsChipComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: FsChipsService, optional: true }], target: i0.ɵɵFactoryTarget.Component });
322
- FsChipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsChipComponent, selector: "fs-chip", inputs: { setSize: ["size", "setSize"], value: "value", backgroundColor: "backgroundColor", borderColor: "borderColor", color: "color", outlined: "outlined", removable: "removable", selectable: "selectable", selected: "selected", image: "image" }, outputs: { selectedToggled: "selectedToggled", removed: "removed" }, host: { listeners: { "click": "click()" }, properties: { "class.fs-chip": "this.fsChip", "class.outlined": "this._outlined", "class.selectable": "this._selectable", "class.imaged": "this._image", "class.selected": "this._selected", "class.removable": "this._removable", "style.backgroundColor": "this.styleBackgroundColor", "style.color": "this.styleColor", "style.borderColor": "this.styleBorderColor", "class.small": "this.classSmall", "class.tiny": "this.classTiny", "class.micro": "this.classMicro" } }, ngImport: i0, template: "<img *ngIf=\"image\" [src]=\"image\" class=\"image\" alt=\"\">\n<div class=\"fs-chip-content\">\n <ng-content></ng-content>\n</div>\n<div class=\"selected-check\" *ngIf=\"selected\">\n <mat-icon [style.color]=\"styleColor\">check</mat-icon>\n</div>\n<a *ngIf=\"removable\" class=\"remove\" (click)=\"remove($event)\">\n <mat-icon [style.color]=\"styleColor\">cancel</mat-icon>\n</a>\n", styles: [""], components: [{ type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
323
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsChipComponent, decorators: [{
324
- type: Component,
325
- args: [{
326
- selector: 'fs-chip',
327
- templateUrl: 'chip.component.html',
328
- styleUrls: ['chip.component.scss'],
329
- changeDetection: ChangeDetectionStrategy.OnPush,
330
- }]
331
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: FsChipsService, decorators: [{
332
- type: Optional
333
- }] }]; }, propDecorators: { fsChip: [{
334
- type: HostBinding,
335
- args: ['class.fs-chip']
336
- }], _outlined: [{
337
- type: HostBinding,
338
- args: ['class.outlined']
339
- }], _selectable: [{
340
- type: HostBinding,
341
- args: ['class.selectable']
342
- }], _image: [{
343
- type: HostBinding,
344
- args: ['class.imaged']
345
- }], _selected: [{
346
- type: HostBinding,
347
- args: ['class.selected']
348
- }], _removable: [{
349
- type: HostBinding,
350
- args: ['class.removable']
351
- }], styleBackgroundColor: [{
352
- type: HostBinding,
353
- args: ['style.backgroundColor']
354
- }], styleColor: [{
355
- type: HostBinding,
356
- args: ['style.color']
357
- }], styleBorderColor: [{
358
- type: HostBinding,
359
- args: ['style.borderColor']
360
- }], classSmall: [{
361
- type: HostBinding,
362
- args: ['class.small']
363
- }], classTiny: [{
364
- type: HostBinding,
365
- args: ['class.tiny']
366
- }], classMicro: [{
367
- type: HostBinding,
368
- args: ['class.micro']
369
- }], setSize: [{
370
- type: Input,
371
- args: ['size']
372
- }], click: [{
373
- type: HostListener,
374
- args: ['click']
375
- }], value: [{
376
- type: Input
377
- }], backgroundColor: [{
378
- type: Input
379
- }], borderColor: [{
380
- type: Input
381
- }], color: [{
382
- type: Input
383
- }], outlined: [{
384
- type: Input
385
- }], removable: [{
386
- type: Input
387
- }], selectable: [{
388
- type: Input
389
- }], selected: [{
390
- type: Input
391
- }], image: [{
392
- type: Input
393
- }], selectedToggled: [{
394
- type: Output
395
- }], removed: [{
396
- type: Output
180
+ class FsChipComponent {
181
+ constructor(_cdRef, _chips) {
182
+ this._cdRef = _cdRef;
183
+ this._chips = _chips;
184
+ this.fsChip = true;
185
+ this._outlined = false;
186
+ this._selectable = false;
187
+ this._image = false;
188
+ this._selected = false;
189
+ this._removable = false;
190
+ this.styleBackgroundColor = '';
191
+ this.styleColor = '';
192
+ this.styleBorderColor = '';
193
+ this.classSmall = false;
194
+ this.classTiny = false;
195
+ this.classMicro = false;
196
+ this.selectedToggled = new EventEmitter();
197
+ this.removed = new EventEmitter();
198
+ this.$destroy = new Subject();
199
+ this._backgroundColor = '';
200
+ this._color = '';
201
+ }
202
+ set setSize(value) {
203
+ this._size = value;
204
+ this.classSmall = value === 'small';
205
+ this.classTiny = value === 'tiny';
206
+ this.classMicro = value === 'micro';
207
+ }
208
+ ;
209
+ click() {
210
+ if (this.selectable) {
211
+ this.selected = !this.selected;
212
+ this.selectedToggled.emit({ value: this.value, selected: this.selected });
213
+ if (this._chips) {
214
+ this._chips.selectionChanged(this.selected, this.value);
215
+ }
216
+ }
217
+ }
218
+ set backgroundColor(value) {
219
+ this._backgroundColor = value;
220
+ this.updateStyles();
221
+ }
222
+ ;
223
+ set borderColor(value) {
224
+ this.styleBorderColor = value;
225
+ this.updateStyles();
226
+ }
227
+ set color(value) {
228
+ this._color = value;
229
+ this.updateStyles();
230
+ }
231
+ get color() {
232
+ return this._color;
233
+ }
234
+ set outlined(value) {
235
+ this._outlined = value;
236
+ this.updateStyles();
237
+ }
238
+ ;
239
+ get outlined() {
240
+ return this._outlined;
241
+ }
242
+ set removable(value) {
243
+ this._removable = value;
244
+ this._cdRef.markForCheck();
245
+ }
246
+ ;
247
+ get removable() {
248
+ return this._removable;
249
+ }
250
+ set selectable(value) {
251
+ this._selectable = value;
252
+ }
253
+ ;
254
+ get selectable() {
255
+ return this._selectable;
256
+ }
257
+ set selected(value) {
258
+ this._selected = value;
259
+ this._cdRef.markForCheck();
260
+ }
261
+ ;
262
+ get selected() {
263
+ return this._selected;
264
+ }
265
+ set image(value) {
266
+ this._image = value;
267
+ this._cdRef.markForCheck();
268
+ }
269
+ ;
270
+ get image() {
271
+ return this._image;
272
+ }
273
+ ngOnInit() {
274
+ if (this._chips) {
275
+ this._chips.register(this);
276
+ }
277
+ }
278
+ ngOnDestroy() {
279
+ if (this._chips) {
280
+ this._chips.destroy(this);
281
+ }
282
+ this.$destroy.next();
283
+ this.$destroy.complete();
284
+ }
285
+ remove(event) {
286
+ this.removed.next(event);
287
+ }
288
+ isContrastYIQBlack(hexcolor) {
289
+ if (!hexcolor) {
290
+ return true;
291
+ }
292
+ hexcolor = hexcolor.replace('#', '');
293
+ const r = parseInt(hexcolor.substr(0, 2), 16);
294
+ const g = parseInt(hexcolor.substr(2, 2), 16);
295
+ const b = parseInt(hexcolor.substr(4, 2), 16);
296
+ const yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
297
+ return yiq >= 200;
298
+ }
299
+ updateStyles() {
300
+ this.styleBackgroundColor = this._backgroundColor;
301
+ if (this._color) {
302
+ this.styleColor = this._color;
303
+ }
304
+ else if (!this._outlined) {
305
+ this.styleColor = this.isContrastYIQBlack(this.styleBackgroundColor) ? '#474747' : '#fff';
306
+ }
307
+ if (this._outlined) {
308
+ this.styleBackgroundColor = '';
309
+ if (this._color) {
310
+ this.styleBorderColor = this._color;
311
+ }
312
+ }
313
+ this._cdRef.markForCheck();
314
+ }
315
+ }
316
+ FsChipComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsChipComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: FsChipsService, optional: true }], target: i0.ɵɵFactoryTarget.Component });
317
+ FsChipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: FsChipComponent, selector: "fs-chip", inputs: { setSize: ["size", "setSize"], value: "value", icon: "icon", backgroundColor: "backgroundColor", borderColor: "borderColor", color: "color", outlined: "outlined", removable: "removable", selectable: "selectable", selected: "selected", image: "image" }, outputs: { selectedToggled: "selectedToggled", removed: "removed" }, host: { listeners: { "click": "click()" }, properties: { "class.fs-chip": "this.fsChip", "class.outlined": "this._outlined", "class.selectable": "this._selectable", "class.imaged": "this._image", "class.selected": "this._selected", "class.removable": "this._removable", "style.backgroundColor": "this.styleBackgroundColor", "style.color": "this.styleColor", "style.borderColor": "this.styleBorderColor", "class.small": "this.classSmall", "class.tiny": "this.classTiny", "class.micro": "this.classMicro", "class.iconed": "this.icon" } }, ngImport: i0, template: "<img *ngIf=\"image\" [src]=\"image\" class=\"image\" alt=\"\">\n<ng-container *ngIf=\"icon\">\n <mat-icon class=\"icon\">{{icon}}</mat-icon>\n</ng-container>\n<div class=\"fs-chip-content\">\n <ng-content></ng-content>\n</div>\n<div class=\"selected-check\" *ngIf=\"selected\">\n <mat-icon [style.color]=\"styleColor\">check</mat-icon>\n</div>\n<a *ngIf=\"removable\" class=\"remove\" (click)=\"remove($event)\">\n <mat-icon [style.color]=\"styleColor\">cancel</mat-icon>\n</a>\n", styles: [":host{-webkit-user-select:none;user-select:none;transition:box-shadow .28s cubic-bezier(.4,0,.2,1);display:inline-flex;padding:0 12px;border-radius:16px;align-items:center;cursor:default;height:30px;background-color:#e0e0e0;overflow:hidden}:host.imaged{overflow:visible;padding-left:0}:host.imaged.outlined .image{margin-left:-2px}:host.iconed:not(.imaged){padding-left:5px}:host.removable,:host.selected{padding-right:3px}:host.selectable{cursor:pointer}:host.outlined{background-color:transparent;border:1px solid #e0e0e0;box-sizing:border-box}:host .icon{margin-right:5px}:host .image{height:30px;width:30px;border-radius:50%;object-fit:cover;margin-left:-1px;margin-right:8px}:host .fs-chip-content{max-width:250px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .selected-check{margin:0 5px;display:flex}:host .remove{display:flex;margin-left:5px;cursor:pointer}:host.micro{padding:0 5px;height:16px;line-height:normal}:host.micro .fs-chip-content{font-size:65%}:host.micro .image{height:100%;width:16px;margin-right:2px}:host.micro .remove{margin-left:1px}:host.micro .selected-check{margin:0 1px 0 0}:host.micro.imaged{padding-left:0}:host.micro.removable,:host.micro.selected{padding-right:0}:host.micro mat-icon{width:12px;height:12px;font-size:11px}:host.tiny{padding:0 6px;height:18px;line-height:normal}:host.tiny .fs-chip-content{font-size:75%}:host.tiny .image{height:18px;width:18px;margin-right:3px}:host.tiny.iconed:not(.imaged){padding-left:3px}:host.tiny .remove{margin-left:2px}:host.tiny .selected-check{margin:0 1px 0 0}:host.tiny.imaged{padding-left:0}:host.tiny.removable,:host.tiny.selected{padding-right:0}:host.tiny mat-icon{height:15px;width:15px;font-size:15px}:host.small{padding:0 8px;font-size:85%;height:25px;line-height:normal}:host.small .image{height:25px;width:25px;margin-right:5px}:host.small.iconed:not(.imaged){padding-left:4px}:host.small.imaged{padding-left:0}:host.small .remove{margin-left:3px}:host.small .selected-check{margin:0 2px 0 0}:host.small .selected-check mat-icon{transform:scale(.7)}:host.small.removable,:host.small.selected{padding-right:0}:host.small mat-icon{height:22px;width:22px;font-size:20px}\n"], components: [{ type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
318
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsChipComponent, decorators: [{
319
+ type: Component,
320
+ args: [{ selector: 'fs-chip', changeDetection: ChangeDetectionStrategy.OnPush, template: "<img *ngIf=\"image\" [src]=\"image\" class=\"image\" alt=\"\">\n<ng-container *ngIf=\"icon\">\n <mat-icon class=\"icon\">{{icon}}</mat-icon>\n</ng-container>\n<div class=\"fs-chip-content\">\n <ng-content></ng-content>\n</div>\n<div class=\"selected-check\" *ngIf=\"selected\">\n <mat-icon [style.color]=\"styleColor\">check</mat-icon>\n</div>\n<a *ngIf=\"removable\" class=\"remove\" (click)=\"remove($event)\">\n <mat-icon [style.color]=\"styleColor\">cancel</mat-icon>\n</a>\n", styles: [":host{-webkit-user-select:none;user-select:none;transition:box-shadow .28s cubic-bezier(.4,0,.2,1);display:inline-flex;padding:0 12px;border-radius:16px;align-items:center;cursor:default;height:30px;background-color:#e0e0e0;overflow:hidden}:host.imaged{overflow:visible;padding-left:0}:host.imaged.outlined .image{margin-left:-2px}:host.iconed:not(.imaged){padding-left:5px}:host.removable,:host.selected{padding-right:3px}:host.selectable{cursor:pointer}:host.outlined{background-color:transparent;border:1px solid #e0e0e0;box-sizing:border-box}:host .icon{margin-right:5px}:host .image{height:30px;width:30px;border-radius:50%;object-fit:cover;margin-left:-1px;margin-right:8px}:host .fs-chip-content{max-width:250px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .selected-check{margin:0 5px;display:flex}:host .remove{display:flex;margin-left:5px;cursor:pointer}:host.micro{padding:0 5px;height:16px;line-height:normal}:host.micro .fs-chip-content{font-size:65%}:host.micro .image{height:100%;width:16px;margin-right:2px}:host.micro .remove{margin-left:1px}:host.micro .selected-check{margin:0 1px 0 0}:host.micro.imaged{padding-left:0}:host.micro.removable,:host.micro.selected{padding-right:0}:host.micro mat-icon{width:12px;height:12px;font-size:11px}:host.tiny{padding:0 6px;height:18px;line-height:normal}:host.tiny .fs-chip-content{font-size:75%}:host.tiny .image{height:18px;width:18px;margin-right:3px}:host.tiny.iconed:not(.imaged){padding-left:3px}:host.tiny .remove{margin-left:2px}:host.tiny .selected-check{margin:0 1px 0 0}:host.tiny.imaged{padding-left:0}:host.tiny.removable,:host.tiny.selected{padding-right:0}:host.tiny mat-icon{height:15px;width:15px;font-size:15px}:host.small{padding:0 8px;font-size:85%;height:25px;line-height:normal}:host.small .image{height:25px;width:25px;margin-right:5px}:host.small.iconed:not(.imaged){padding-left:4px}:host.small.imaged{padding-left:0}:host.small .remove{margin-left:3px}:host.small .selected-check{margin:0 2px 0 0}:host.small .selected-check mat-icon{transform:scale(.7)}:host.small.removable,:host.small.selected{padding-right:0}:host.small mat-icon{height:22px;width:22px;font-size:20px}\n"] }]
321
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: FsChipsService, decorators: [{
322
+ type: Optional
323
+ }] }]; }, propDecorators: { fsChip: [{
324
+ type: HostBinding,
325
+ args: ['class.fs-chip']
326
+ }], _outlined: [{
327
+ type: HostBinding,
328
+ args: ['class.outlined']
329
+ }], _selectable: [{
330
+ type: HostBinding,
331
+ args: ['class.selectable']
332
+ }], _image: [{
333
+ type: HostBinding,
334
+ args: ['class.imaged']
335
+ }], _selected: [{
336
+ type: HostBinding,
337
+ args: ['class.selected']
338
+ }], _removable: [{
339
+ type: HostBinding,
340
+ args: ['class.removable']
341
+ }], styleBackgroundColor: [{
342
+ type: HostBinding,
343
+ args: ['style.backgroundColor']
344
+ }], styleColor: [{
345
+ type: HostBinding,
346
+ args: ['style.color']
347
+ }], styleBorderColor: [{
348
+ type: HostBinding,
349
+ args: ['style.borderColor']
350
+ }], classSmall: [{
351
+ type: HostBinding,
352
+ args: ['class.small']
353
+ }], classTiny: [{
354
+ type: HostBinding,
355
+ args: ['class.tiny']
356
+ }], classMicro: [{
357
+ type: HostBinding,
358
+ args: ['class.micro']
359
+ }], setSize: [{
360
+ type: Input,
361
+ args: ['size']
362
+ }], click: [{
363
+ type: HostListener,
364
+ args: ['click']
365
+ }], value: [{
366
+ type: Input
367
+ }], icon: [{
368
+ type: Input
369
+ }, {
370
+ type: HostBinding,
371
+ args: ['class.iconed']
372
+ }], backgroundColor: [{
373
+ type: Input
374
+ }], borderColor: [{
375
+ type: Input
376
+ }], color: [{
377
+ type: Input
378
+ }], outlined: [{
379
+ type: Input
380
+ }], removable: [{
381
+ type: Input
382
+ }], selectable: [{
383
+ type: Input
384
+ }], selected: [{
385
+ type: Input
386
+ }], image: [{
387
+ type: Input
388
+ }], selectedToggled: [{
389
+ type: Output
390
+ }], removed: [{
391
+ type: Output
397
392
  }] } });
398
393
 
399
- class FsChipModule {
400
- static forRoot() {
401
- return {
402
- ngModule: FsChipModule
403
- };
404
- }
405
- }
406
- FsChipModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsChipModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
407
- FsChipModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsChipModule, declarations: [FsChipsComponent,
408
- FsChipComponent], imports: [CommonModule,
409
- MatIconModule,
410
- FsLabelModule], exports: [FsChipsComponent,
411
- FsChipComponent] });
412
- FsChipModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsChipModule, imports: [[
413
- CommonModule,
414
- MatIconModule,
415
- FsLabelModule
416
- ]] });
417
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsChipModule, decorators: [{
418
- type: NgModule,
419
- args: [{
420
- imports: [
421
- CommonModule,
422
- MatIconModule,
423
- FsLabelModule
424
- ],
425
- exports: [
426
- FsChipsComponent,
427
- FsChipComponent,
428
- ],
429
- declarations: [
430
- FsChipsComponent,
431
- FsChipComponent,
432
- ]
433
- }]
394
+ class FsChipModule {
395
+ static forRoot() {
396
+ return {
397
+ ngModule: FsChipModule
398
+ };
399
+ }
400
+ }
401
+ FsChipModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsChipModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
402
+ FsChipModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsChipModule, declarations: [FsChipsComponent,
403
+ FsChipComponent], imports: [CommonModule,
404
+ MatIconModule,
405
+ FsLabelModule], exports: [FsChipsComponent,
406
+ FsChipComponent] });
407
+ FsChipModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsChipModule, imports: [[
408
+ CommonModule,
409
+ MatIconModule,
410
+ FsLabelModule
411
+ ]] });
412
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsChipModule, decorators: [{
413
+ type: NgModule,
414
+ args: [{
415
+ imports: [
416
+ CommonModule,
417
+ MatIconModule,
418
+ FsLabelModule
419
+ ],
420
+ exports: [
421
+ FsChipsComponent,
422
+ FsChipComponent,
423
+ ],
424
+ declarations: [
425
+ FsChipsComponent,
426
+ FsChipComponent,
427
+ ]
428
+ }]
434
429
  }] });
435
430
 
436
- /*
437
- * Public API Surface of fs-menu
431
+ /*
432
+ * Public API Surface of fs-menu
438
433
  */
439
434
 
440
- /**
441
- * Generated bundle index. Do not edit.
435
+ /**
436
+ * Generated bundle index. Do not edit.
442
437
  */
443
438
 
444
439
  export { FsChipComponent, FsChipModule, FsChipsComponent };
445
- //# sourceMappingURL=firestitch-chip.js.map
440
+ //# sourceMappingURL=firestitch-chip.mjs.map