@cqa-lib/cqa-ui 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.
@@ -0,0 +1,967 @@
1
+ import * as i0 from '@angular/core';
2
+ import { EventEmitter, Component, HostBinding, Input, Output, HostListener, ViewChildren, ViewChild, ChangeDetectionStrategy, NgModule, InjectionToken, Injector, Injectable } from '@angular/core';
3
+ import * as i2 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import * as i2$1 from '@angular/forms';
6
+ import { FormsModule } from '@angular/forms';
7
+ import * as i1 from '@angular/material/icon';
8
+ import { MatIconModule } from '@angular/material/icon';
9
+ import * as i1$1 from '@angular/cdk/overlay';
10
+ import { OverlayModule, OverlayConfig } from '@angular/cdk/overlay';
11
+ import * as i3 from '@angular/cdk/portal';
12
+ import { TemplatePortal, CdkPortalOutlet, PortalModule, ComponentPortal } from '@angular/cdk/portal';
13
+ import { __awaiter } from 'tslib';
14
+ import { filter } from 'rxjs/operators';
15
+ import { Subject } from 'rxjs';
16
+
17
+ class ButtonComponent {
18
+ constructor() {
19
+ this.id = 'cqa-ui-root';
20
+ this.display = 'contents';
21
+ this.variant = 'filled';
22
+ this.disabled = false;
23
+ this.iconPosition = 'start';
24
+ this.type = 'button';
25
+ this.clicked = new EventEmitter();
26
+ // Internal state tracking
27
+ this.isHovered = false;
28
+ this.isFocused = false;
29
+ this.isPressed = false;
30
+ }
31
+ get hasIcon() {
32
+ return !!this.icon;
33
+ }
34
+ get buttonClasses() {
35
+ const baseClasses = [
36
+ 'flex',
37
+ 'flex-col',
38
+ 'justify-center',
39
+ 'items-center',
40
+ 'p-0',
41
+ 'gap-2',
42
+ 'rounded-lg',
43
+ 'cursor-pointer',
44
+ 'font-inter',
45
+ 'font-semibold',
46
+ 'text-sm',
47
+ 'leading-[14px]',
48
+ 'transition-all',
49
+ 'duration-200',
50
+ 'outline-none'
51
+ ];
52
+ if (this.disabled) {
53
+ baseClasses.push('cursor-not-allowed');
54
+ }
55
+ // Add variant and state specific classes
56
+ const variantClasses = this.getVariantClasses();
57
+ return [...baseClasses, ...variantClasses].join(' ');
58
+ }
59
+ get stateLayerClasses() {
60
+ const classes = [
61
+ 'flex',
62
+ 'flex-row',
63
+ 'justify-center',
64
+ 'items-center',
65
+ 'gap-2',
66
+ 'w-full',
67
+ 'h-full',
68
+ 'py-[10px]',
69
+ 'px-6',
70
+ ];
71
+ return classes.join(' ');
72
+ }
73
+ get labelClasses() {
74
+ const classes = [
75
+ 'flex',
76
+ 'items-center',
77
+ 'text-center',
78
+ 'font-inter',
79
+ 'font-semibold',
80
+ 'text-sm',
81
+ 'leading-[14px]',
82
+ 'flex-none',
83
+ this.textClass,
84
+ ];
85
+ if (this.disabled) {
86
+ classes.push('opacity-[0.38]');
87
+ }
88
+ return classes.join(' ');
89
+ }
90
+ get iconClasses() {
91
+ const classes = [
92
+ 'flex',
93
+ 'items-center',
94
+ 'justify-center',
95
+ 'w-[14px]',
96
+ 'h-[14px]',
97
+ 'shrink-0',
98
+ 'flex-none'
99
+ ];
100
+ if (this.disabled) {
101
+ classes.push('opacity-[0.38]');
102
+ }
103
+ return classes.join(' ');
104
+ }
105
+ getVariantClasses() {
106
+ const classes = [];
107
+ if (this.variant === 'filled') {
108
+ if (this.disabled) {
109
+ classes.push('bg-primary-muted');
110
+ }
111
+ else {
112
+ classes.push('bg-primary');
113
+ if (this.isHovered) {
114
+ classes.push('shadow-[0px_1px_2px_rgba(0,0,0,0.3),0px_1px_3px_1px_rgba(0,0,0,0.15)]');
115
+ }
116
+ }
117
+ }
118
+ else if (this.variant === 'outlined') {
119
+ if (this.disabled) {
120
+ classes.push('bg-transparent', 'border', 'border-primary-muted');
121
+ }
122
+ else {
123
+ if (this.isFocused) {
124
+ classes.push('bg-primary-surface-alt', 'border', 'border-primary-hover', 'shadow-[0px_4px_4px_rgba(0,0,0,0.25)]');
125
+ }
126
+ else if (this.isHovered || this.isPressed) {
127
+ classes.push('bg-primary-surface', 'border', 'border-primary');
128
+ }
129
+ else {
130
+ classes.push('bg-transparent', 'border', 'border-slate');
131
+ }
132
+ }
133
+ }
134
+ else if (this.variant === 'text') {
135
+ if (this.disabled) {
136
+ classes.push('bg-transparent');
137
+ }
138
+ else {
139
+ classes.push('bg-transparent');
140
+ if (this.isHovered || this.isFocused || this.isPressed) {
141
+ classes.push('bg-primary-surface');
142
+ }
143
+ }
144
+ }
145
+ else if (this.variant === 'elevated') {
146
+ if (this.disabled) {
147
+ classes.push('bg-primary-muted', 'shadow-none');
148
+ }
149
+ else {
150
+ if (this.isFocused) {
151
+ classes.push('bg-primary-surface-alt', 'shadow-[0px_4px_4px_rgba(0,0,0,0.25)]');
152
+ }
153
+ else if (this.isPressed) {
154
+ classes.push('bg-primary-surface', 'shadow-[0px_1px_2px_rgba(0,0,0,0.3),0px_1px_3px_1px_rgba(0,0,0,0.15)]');
155
+ }
156
+ else if (this.isHovered) {
157
+ classes.push('bg-primary-surface-alt', 'shadow-[0px_1px_2px_rgba(0,0,0,0.3),0px_2px_6px_2px_rgba(0,0,0,0.15)]');
158
+ }
159
+ else {
160
+ classes.push('bg-primary-surface', 'shadow-[0px_1px_2px_rgba(0,0,0,0.3),0px_1px_3px_1px_rgba(0,0,0,0.15)]');
161
+ }
162
+ }
163
+ }
164
+ else if (this.variant === 'tonal') {
165
+ if (this.disabled) {
166
+ classes.push('bg-primary-muted');
167
+ }
168
+ else {
169
+ if (this.isHovered) {
170
+ classes.push('bg-tonal-hover', 'shadow-[0px_1px_2px_rgba(0,0,0,0.3),0px_1px_3px_1px_rgba(0,0,0,0.15)]');
171
+ }
172
+ else {
173
+ classes.push('bg-primary-surface-alt');
174
+ }
175
+ }
176
+ }
177
+ return classes;
178
+ }
179
+ get textClass() {
180
+ if (this.disabled) {
181
+ if (this.variant === 'outlined' || this.variant === 'text') {
182
+ return 'text-ink';
183
+ }
184
+ return 'text-ink-muted';
185
+ }
186
+ switch (this.variant) {
187
+ case 'filled':
188
+ return 'text-surface-default';
189
+ case 'outlined':
190
+ if (this.isFocused || this.isHovered || this.isPressed) {
191
+ return 'text-primary-hover';
192
+ }
193
+ return 'text-slate';
194
+ case 'text':
195
+ case 'elevated':
196
+ return 'text-primary-hover';
197
+ case 'tonal':
198
+ return 'text-ink';
199
+ default:
200
+ return '';
201
+ }
202
+ }
203
+ onMouseEnter() {
204
+ if (!this.disabled) {
205
+ this.isHovered = true;
206
+ }
207
+ }
208
+ onMouseLeave() {
209
+ this.isHovered = false;
210
+ this.isPressed = false;
211
+ }
212
+ onMouseDown() {
213
+ if (!this.disabled) {
214
+ this.isPressed = true;
215
+ }
216
+ }
217
+ onMouseUp() {
218
+ this.isPressed = false;
219
+ }
220
+ onFocus() {
221
+ if (!this.disabled) {
222
+ this.isFocused = true;
223
+ }
224
+ }
225
+ onBlur() {
226
+ this.isFocused = false;
227
+ this.isPressed = false;
228
+ }
229
+ onClick(event) {
230
+ if (!this.disabled) {
231
+ this.clicked.emit(event);
232
+ }
233
+ }
234
+ }
235
+ ButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: ButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
236
+ ButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: ButtonComponent, selector: "cqa-button", inputs: { variant: "variant", disabled: "disabled", icon: "icon", iconPosition: "iconPosition", type: "type" }, outputs: { clicked: "clicked" }, host: { listeners: { "mouseenter": "onMouseEnter()", "mouseleave": "onMouseLeave()", "mousedown": "onMouseDown()", "mouseup": "onMouseUp()", "focus": "onFocus()", "blur": "onBlur()" }, properties: { "attr.id": "this.id", "style.display": "this.display" } }, ngImport: i0, template: "<button\n [type]=\"type\"\n [disabled]=\"disabled\"\n [attr.aria-disabled]=\"disabled\"\n [class]=\"buttonClasses\"\n (click)=\"onClick($event)\"\n>\n <span [class]=\"stateLayerClasses\">\n <span *ngIf=\"icon && iconPosition === 'start'\" [class]=\"iconClasses\" [ngClass]=\"textClass\">\n <mat-icon class=\"text-[18px] leading-[18px] w-[18px] h-[18px]\">\n {{ icon }}\n </mat-icon>\n </span>\n <span [class]=\"labelClasses\" [ngClass]=\"textClass\">\n <ng-content></ng-content>\n </span>\n <span *ngIf=\"icon && iconPosition === 'end'\" [class]=\"iconClasses\" [ngClass]=\"textClass\">\n <mat-icon class=\"text-[18px] leading-[18px] w-[18px] h-[18px]\">\n {{ icon }}\n </mat-icon>\n </span>\n </span>\n</button>\n\n", components: [{ type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
237
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: ButtonComponent, decorators: [{
238
+ type: Component,
239
+ args: [{ selector: 'cqa-button', template: "<button\n [type]=\"type\"\n [disabled]=\"disabled\"\n [attr.aria-disabled]=\"disabled\"\n [class]=\"buttonClasses\"\n (click)=\"onClick($event)\"\n>\n <span [class]=\"stateLayerClasses\">\n <span *ngIf=\"icon && iconPosition === 'start'\" [class]=\"iconClasses\" [ngClass]=\"textClass\">\n <mat-icon class=\"text-[18px] leading-[18px] w-[18px] h-[18px]\">\n {{ icon }}\n </mat-icon>\n </span>\n <span [class]=\"labelClasses\" [ngClass]=\"textClass\">\n <ng-content></ng-content>\n </span>\n <span *ngIf=\"icon && iconPosition === 'end'\" [class]=\"iconClasses\" [ngClass]=\"textClass\">\n <mat-icon class=\"text-[18px] leading-[18px] w-[18px] h-[18px]\">\n {{ icon }}\n </mat-icon>\n </span>\n </span>\n</button>\n\n", styles: [] }]
240
+ }], propDecorators: { id: [{
241
+ type: HostBinding,
242
+ args: ['attr.id']
243
+ }], display: [{
244
+ type: HostBinding,
245
+ args: ['style.display']
246
+ }], variant: [{
247
+ type: Input
248
+ }], disabled: [{
249
+ type: Input
250
+ }], icon: [{
251
+ type: Input
252
+ }], iconPosition: [{
253
+ type: Input
254
+ }], type: [{
255
+ type: Input
256
+ }], clicked: [{
257
+ type: Output
258
+ }], onMouseEnter: [{
259
+ type: HostListener,
260
+ args: ['mouseenter']
261
+ }], onMouseLeave: [{
262
+ type: HostListener,
263
+ args: ['mouseleave']
264
+ }], onMouseDown: [{
265
+ type: HostListener,
266
+ args: ['mousedown']
267
+ }], onMouseUp: [{
268
+ type: HostListener,
269
+ args: ['mouseup']
270
+ }], onFocus: [{
271
+ type: HostListener,
272
+ args: ['focus']
273
+ }], onBlur: [{
274
+ type: HostListener,
275
+ args: ['blur']
276
+ }] } });
277
+
278
+ class SearchBarComponent {
279
+ constructor() {
280
+ this.id = 'cqa-ui-root';
281
+ /** Placeholder text for the input */
282
+ this.placeholder = 'Search';
283
+ /** Initial value or externally controlled value */
284
+ this.value = '';
285
+ /** Disable interactions */
286
+ this.disabled = false;
287
+ /** Whether the clear button should be visible when there is text */
288
+ this.showClear = true;
289
+ /** Accessible label for the input */
290
+ this.ariaLabel = 'Search';
291
+ /** Automatically focus the input when rendered */
292
+ this.autoFocus = false;
293
+ /** Search bar size */
294
+ this.size = 'md';
295
+ /** Stretch to fill container width */
296
+ this.fullWidth = false;
297
+ /** Emit on value changes (e.g. for two-way binding) */
298
+ this.valueChange = new EventEmitter();
299
+ /** Emit when user submits search (Enter key or form submit) */
300
+ this.search = new EventEmitter();
301
+ /** Emit when the value is cleared via the clear button */
302
+ this.cleared = new EventEmitter();
303
+ this.inputValue = '';
304
+ this.widthClasses = {
305
+ sm: 'w-[295px]',
306
+ md: 'w-[395px]',
307
+ lg: 'w-[495px]',
308
+ };
309
+ }
310
+ get displayStyle() {
311
+ return this.fullWidth ? 'block' : 'inline-block';
312
+ }
313
+ get widthStyle() {
314
+ return this.fullWidth ? '100%' : 'auto';
315
+ }
316
+ ngOnChanges(changes) {
317
+ var _a;
318
+ if (changes['value'] && changes['value'].currentValue !== undefined) {
319
+ const newValue = (_a = changes['value'].currentValue) !== null && _a !== void 0 ? _a : '';
320
+ if (newValue !== this.inputValue) {
321
+ this.inputValue = newValue;
322
+ }
323
+ }
324
+ }
325
+ onInput(event) {
326
+ var _a;
327
+ const target = event.target;
328
+ const nextValue = (_a = target === null || target === void 0 ? void 0 : target.value) !== null && _a !== void 0 ? _a : '';
329
+ this.inputValue = nextValue;
330
+ this.valueChange.emit(this.inputValue);
331
+ }
332
+ onSubmit(event) {
333
+ event.preventDefault();
334
+ if (this.disabled) {
335
+ return;
336
+ }
337
+ this.search.emit(this.inputValue.trim());
338
+ }
339
+ clear() {
340
+ if (this.disabled || this.inputValue === '') {
341
+ return;
342
+ }
343
+ this.inputValue = '';
344
+ this.valueChange.emit('');
345
+ this.cleared.emit();
346
+ }
347
+ }
348
+ SearchBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: SearchBarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
349
+ SearchBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: SearchBarComponent, selector: "cqa-search-bar", inputs: { placeholder: "placeholder", value: "value", disabled: "disabled", showClear: "showClear", ariaLabel: "ariaLabel", autoFocus: "autoFocus", size: "size", fullWidth: "fullWidth" }, outputs: { valueChange: "valueChange", search: "search", cleared: "cleared" }, host: { properties: { "attr.id": "this.id", "style.display": "this.displayStyle", "style.width": "this.widthStyle" } }, usesOnChanges: true, ngImport: i0, template: "<form\n class=\"inline-flex items-center gap-2 px-6 py-3 text-[14px] border border-gray-200 rounded-md bg-white shadow-sm transition-colors\"\n [ngClass]=\"fullWidth ? 'w-full' : widthClasses[size]\"\n (submit)=\"onSubmit($event)\"\n>\n <span\n class=\"flex-none flex items-center justify-center text-gray-400 w-4 h-4\"\n [ngClass]=\"{ 'opacity-[0.38]': disabled }\"\n >\n <mat-icon\n class=\"flex items-center justify-center leading-none p-0\"\n [style.width.px]=\"16\"\n [style.height.px]=\"16\"\n [style.fontSize.px]=\"16\"\n >\n search\n </mat-icon>\n </span>\n\n <input\n type=\"text\"\n class=\"flex-1 min-w-[180px] border-none outline-none bg-transparent placeholder:text-gray-400 disabled:text-gray-400 disabled:cursor-not-allowed font-['SF_Pro_Text'] font-normal text-[12.3px] leading-none tracking-normal align-middle text-[#99999E]\"\n style=\"font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; letter-spacing: 0;\"\n [placeholder]=\"placeholder\"\n [value]=\"inputValue\"\n (input)=\"onInput($event)\"\n [disabled]=\"disabled\"\n [attr.aria-label]=\"ariaLabel\"\n autocomplete=\"off\"\n autocapitalize=\"none\"\n spellcheck=\"false\"\n [attr.autofocus]=\"autoFocus ? '' : null\"\n />\n\n <button\n *ngIf=\"showClear && inputValue\"\n type=\"button\"\n class=\"flex items-center justify-center p-0 w-4 h-4 border-0 bg-transparent cursor-pointer text-gray-500 hover:text-gray-700 disabled:text-gray-300 transition-colors leading-none\"\n (click)=\"clear()\"\n [disabled]=\"disabled\"\n aria-label=\"Clear search\"\n >\n <mat-icon\n class=\"flex items-center justify-center leading-none p-0\"\n [style.width.px]=\"16\"\n [style.height.px]=\"16\"\n [style.fontSize.px]=\"16\"\n [ngClass]=\"{ 'opacity-[0.38]': disabled }\"\n >\n close\n </mat-icon>\n </button>\n</form>\n", components: [{ type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i2$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i2$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i2$1.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
350
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: SearchBarComponent, decorators: [{
351
+ type: Component,
352
+ args: [{ selector: 'cqa-search-bar', template: "<form\n class=\"inline-flex items-center gap-2 px-6 py-3 text-[14px] border border-gray-200 rounded-md bg-white shadow-sm transition-colors\"\n [ngClass]=\"fullWidth ? 'w-full' : widthClasses[size]\"\n (submit)=\"onSubmit($event)\"\n>\n <span\n class=\"flex-none flex items-center justify-center text-gray-400 w-4 h-4\"\n [ngClass]=\"{ 'opacity-[0.38]': disabled }\"\n >\n <mat-icon\n class=\"flex items-center justify-center leading-none p-0\"\n [style.width.px]=\"16\"\n [style.height.px]=\"16\"\n [style.fontSize.px]=\"16\"\n >\n search\n </mat-icon>\n </span>\n\n <input\n type=\"text\"\n class=\"flex-1 min-w-[180px] border-none outline-none bg-transparent placeholder:text-gray-400 disabled:text-gray-400 disabled:cursor-not-allowed font-['SF_Pro_Text'] font-normal text-[12.3px] leading-none tracking-normal align-middle text-[#99999E]\"\n style=\"font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; letter-spacing: 0;\"\n [placeholder]=\"placeholder\"\n [value]=\"inputValue\"\n (input)=\"onInput($event)\"\n [disabled]=\"disabled\"\n [attr.aria-label]=\"ariaLabel\"\n autocomplete=\"off\"\n autocapitalize=\"none\"\n spellcheck=\"false\"\n [attr.autofocus]=\"autoFocus ? '' : null\"\n />\n\n <button\n *ngIf=\"showClear && inputValue\"\n type=\"button\"\n class=\"flex items-center justify-center p-0 w-4 h-4 border-0 bg-transparent cursor-pointer text-gray-500 hover:text-gray-700 disabled:text-gray-300 transition-colors leading-none\"\n (click)=\"clear()\"\n [disabled]=\"disabled\"\n aria-label=\"Clear search\"\n >\n <mat-icon\n class=\"flex items-center justify-center leading-none p-0\"\n [style.width.px]=\"16\"\n [style.height.px]=\"16\"\n [style.fontSize.px]=\"16\"\n [ngClass]=\"{ 'opacity-[0.38]': disabled }\"\n >\n close\n </mat-icon>\n </button>\n</form>\n", styles: [] }]
353
+ }], propDecorators: { id: [{
354
+ type: HostBinding,
355
+ args: ['attr.id']
356
+ }], displayStyle: [{
357
+ type: HostBinding,
358
+ args: ['style.display']
359
+ }], widthStyle: [{
360
+ type: HostBinding,
361
+ args: ['style.width']
362
+ }], placeholder: [{
363
+ type: Input
364
+ }], value: [{
365
+ type: Input
366
+ }], disabled: [{
367
+ type: Input
368
+ }], showClear: [{
369
+ type: Input
370
+ }], ariaLabel: [{
371
+ type: Input
372
+ }], autoFocus: [{
373
+ type: Input
374
+ }], size: [{
375
+ type: Input
376
+ }], fullWidth: [{
377
+ type: Input
378
+ }], valueChange: [{
379
+ type: Output
380
+ }], search: [{
381
+ type: Output
382
+ }], cleared: [{
383
+ type: Output
384
+ }] } });
385
+
386
+ class SegmentControlComponent {
387
+ constructor() {
388
+ this.id = 'cqa-ui-root';
389
+ this.display = 'inline-block';
390
+ this.segments = [
391
+ { label: 'Tab Group', value: 'tab-group-1' },
392
+ { label: 'Tab Group', value: 'tab-group-2' },
393
+ ];
394
+ this.disabled = false;
395
+ this.valueChange = new EventEmitter();
396
+ this.indicatorStyle = {};
397
+ this.indicatorVisible = false;
398
+ }
399
+ ngOnChanges(changes) {
400
+ if (changes['segments'] || changes['value']) {
401
+ this.ensureSelectedValue();
402
+ }
403
+ }
404
+ ngAfterViewInit() {
405
+ this.buttonChangesSub = this.segmentButtons.changes.subscribe(() => this.updateIndicator());
406
+ this.ensureSelectedValue();
407
+ this.updateIndicator();
408
+ }
409
+ ngOnDestroy() {
410
+ var _a, _b;
411
+ (_b = (_a = this.buttonChangesSub) === null || _a === void 0 ? void 0 : _a.unsubscribe) === null || _b === void 0 ? void 0 : _b.call(_a);
412
+ }
413
+ trackByValue(_index, option) {
414
+ return option.value;
415
+ }
416
+ isSelected(option) {
417
+ return option.value === this.value;
418
+ }
419
+ select(option, index) {
420
+ if (this.disabled || option.disabled) {
421
+ return;
422
+ }
423
+ const nextValue = option.value;
424
+ if (nextValue !== this.value) {
425
+ this.value = nextValue;
426
+ this.valueChange.emit(nextValue);
427
+ }
428
+ this.focusButton(index);
429
+ this.updateIndicator();
430
+ }
431
+ onKeyDown(event, currentIndex) {
432
+ if (this.disabled) {
433
+ return;
434
+ }
435
+ switch (event.key) {
436
+ case 'ArrowRight':
437
+ case 'ArrowDown':
438
+ event.preventDefault();
439
+ this.moveSelection(1, currentIndex);
440
+ break;
441
+ case 'ArrowLeft':
442
+ case 'ArrowUp':
443
+ event.preventDefault();
444
+ this.moveSelection(-1, currentIndex);
445
+ break;
446
+ case 'Home':
447
+ event.preventDefault();
448
+ this.selectFirstEnabled();
449
+ break;
450
+ case 'End':
451
+ event.preventDefault();
452
+ this.selectLastEnabled();
453
+ break;
454
+ case ' ':
455
+ case 'Enter':
456
+ event.preventDefault();
457
+ this.select(this.segments[currentIndex], currentIndex);
458
+ break;
459
+ default:
460
+ break;
461
+ }
462
+ }
463
+ moveSelection(step, startIndex) {
464
+ const enabledIndexes = this.getEnabledIndexes();
465
+ if (enabledIndexes.length === 0) {
466
+ return;
467
+ }
468
+ const currentEnabledIndex = enabledIndexes.indexOf(startIndex);
469
+ const fallbackIndex = this.getSelectedIndex(enabledIndexes);
470
+ const baseIndex = currentEnabledIndex >= 0 ? currentEnabledIndex : fallbackIndex;
471
+ const nextPosition = (baseIndex + step + enabledIndexes.length) % enabledIndexes.length;
472
+ const targetIndex = enabledIndexes[nextPosition];
473
+ this.select(this.segments[targetIndex], targetIndex);
474
+ }
475
+ selectFirstEnabled() {
476
+ const enabledIndexes = this.getEnabledIndexes();
477
+ if (enabledIndexes.length > 0) {
478
+ const index = enabledIndexes[0];
479
+ this.select(this.segments[index], index);
480
+ this.updateIndicator();
481
+ }
482
+ }
483
+ selectLastEnabled() {
484
+ const enabledIndexes = this.getEnabledIndexes();
485
+ if (enabledIndexes.length > 0) {
486
+ const index = enabledIndexes[enabledIndexes.length - 1];
487
+ this.select(this.segments[index], index);
488
+ this.updateIndicator();
489
+ }
490
+ }
491
+ getEnabledIndexes() {
492
+ return this.segments
493
+ .map((option, index) => ({ option, index }))
494
+ .filter(({ option }) => !option.disabled)
495
+ .map(({ index }) => index);
496
+ }
497
+ getSelectedIndex(enabledIndexes) {
498
+ const current = this.segments.findIndex((option) => option.value === this.value && !option.disabled);
499
+ if (current >= 0) {
500
+ return enabledIndexes.indexOf(current);
501
+ }
502
+ return 0;
503
+ }
504
+ ensureSelectedValue() {
505
+ const enabled = this.segments.filter((option) => !option.disabled);
506
+ if (enabled.length === 0) {
507
+ this.value = undefined;
508
+ return;
509
+ }
510
+ if (!this.value || !this.segments.some((option) => option.value === this.value)) {
511
+ this.value = enabled[0].value;
512
+ this.valueChange.emit(this.value);
513
+ const index = this.segments.indexOf(enabled[0]);
514
+ this.focusButton(index);
515
+ this.updateIndicator(index);
516
+ return;
517
+ }
518
+ const selected = this.segments.find((option) => option.value === this.value);
519
+ if (selected === null || selected === void 0 ? void 0 : selected.disabled) {
520
+ this.value = enabled[0].value;
521
+ this.valueChange.emit(this.value);
522
+ const index = this.segments.indexOf(enabled[0]);
523
+ this.focusButton(index);
524
+ this.updateIndicator(index);
525
+ }
526
+ this.updateIndicator();
527
+ }
528
+ focusButton(index) {
529
+ queueMicrotask(() => {
530
+ var _a, _b;
531
+ const button = (_b = (_a = this.segmentButtons) === null || _a === void 0 ? void 0 : _a.get(index)) === null || _b === void 0 ? void 0 : _b.nativeElement;
532
+ button === null || button === void 0 ? void 0 : button.focus();
533
+ });
534
+ }
535
+ updateIndicator(preferredIndex) {
536
+ queueMicrotask(() => {
537
+ var _a, _b, _c, _d, _e;
538
+ const container = (_a = this.segmentContainer) === null || _a === void 0 ? void 0 : _a.nativeElement;
539
+ const buttons = (_c = (_b = this.segmentButtons) === null || _b === void 0 ? void 0 : _b.toArray()) !== null && _c !== void 0 ? _c : [];
540
+ if (!container || buttons.length === 0) {
541
+ this.indicatorVisible = false;
542
+ this.indicatorStyle = {};
543
+ return;
544
+ }
545
+ const index = preferredIndex !== null && preferredIndex !== void 0 ? preferredIndex : buttons.findIndex((button, idx) => { var _a; return ((_a = this.segments[idx]) === null || _a === void 0 ? void 0 : _a.value) === this.value; });
546
+ if (index === -1) {
547
+ this.indicatorVisible = false;
548
+ this.indicatorStyle = {};
549
+ return;
550
+ }
551
+ const buttonEl = (_d = buttons[index]) === null || _d === void 0 ? void 0 : _d.nativeElement;
552
+ if (!buttonEl) {
553
+ this.indicatorVisible = false;
554
+ this.indicatorStyle = {};
555
+ return;
556
+ }
557
+ const containerRect = container.getBoundingClientRect();
558
+ const buttonRect = buttonEl.getBoundingClientRect();
559
+ const offsetLeft = buttonEl.offsetLeft;
560
+ const offsetTop = buttonEl.offsetTop;
561
+ const width = buttonEl.offsetWidth;
562
+ const height = buttonEl.offsetHeight;
563
+ const isDisabled = this.disabled || ((_e = this.segments[index]) === null || _e === void 0 ? void 0 : _e.disabled);
564
+ this.indicatorStyle = {
565
+ width: `${width}px`,
566
+ height: `${height}px`,
567
+ left: `${offsetLeft}px`,
568
+ top: `${offsetTop}px`,
569
+ backgroundColor: isDisabled ? '#9BA0F4' : '#3F43EE',
570
+ };
571
+ this.indicatorVisible = true;
572
+ });
573
+ }
574
+ get isIndicatorVisible() {
575
+ return this.indicatorVisible;
576
+ }
577
+ }
578
+ SegmentControlComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: SegmentControlComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
579
+ SegmentControlComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: SegmentControlComponent, selector: "cqa-segment-control", inputs: { segments: "segments", value: "value", disabled: "disabled" }, outputs: { valueChange: "valueChange" }, host: { properties: { "attr.id": "this.id", "style.display": "this.display" } }, viewQueries: [{ propertyName: "segmentContainer", first: true, predicate: ["segmentContainer"], descendants: true }, { propertyName: "segmentButtons", predicate: ["segmentButton"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div\n #segmentContainer\n class=\"relative inline-flex flex-row items-start p-[3.5px] h-[31.5px] bg-[#F5F5F5] rounded-[8px]\"\n role=\"tablist\"\n [attr.aria-disabled]=\"disabled || null\"\n>\n <div\n class=\"absolute rounded-[8px] transition-all duration-200 ease-in-out pointer-events-none\"\n [class.opacity-0]=\"!isIndicatorVisible\"\n [ngStyle]=\"indicatorStyle\"\n aria-hidden=\"true\"\n ></div>\n\n <button\n *ngFor=\"let segment of segments; index as index; trackBy: trackByValue\"\n #segmentButton\n type=\"button\"\n role=\"tab\"\n class=\"relative z-10 flex flex-col justify-center items-center px-[14px] py-[3.5px] h-[25px] rounded-[8px] transition-all duration-200 ease-in-out whitespace-nowrap text-center focus:outline-none focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 flex-none\"\n [ngClass]=\"{\n 'text-white font-medium': isSelected(segment),\n 'text-[#99999E]': !isSelected(segment) && !(disabled || segment.disabled),\n 'cursor-not-allowed': disabled || segment.disabled,\n 'text-[#C7C7C7]': (disabled || segment.disabled) && !isSelected(segment),\n 'hover:text-black': !isSelected(segment) && !disabled && !segment.disabled\n }\"\n [disabled]=\"disabled || segment.disabled\"\n [attr.aria-selected]=\"isSelected(segment)\"\n [attr.tabindex]=\"!disabled && !segment.disabled ? (isSelected(segment) ? 0 : -1) : -1\"\n (click)=\"select(segment, index)\"\n (keydown)=\"onKeyDown($event, index)\"\n >\n <span class=\"flex items-center justify-center h-[18px] font-['Inter'] font-normal text-[12px] leading-[12px] text-center align-middle\">\n {{ segment.label }}\n </span>\n </button>\n</div>\n", directives: [{ type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
580
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: SegmentControlComponent, decorators: [{
581
+ type: Component,
582
+ args: [{ selector: 'cqa-segment-control', template: "<div\n #segmentContainer\n class=\"relative inline-flex flex-row items-start p-[3.5px] h-[31.5px] bg-[#F5F5F5] rounded-[8px]\"\n role=\"tablist\"\n [attr.aria-disabled]=\"disabled || null\"\n>\n <div\n class=\"absolute rounded-[8px] transition-all duration-200 ease-in-out pointer-events-none\"\n [class.opacity-0]=\"!isIndicatorVisible\"\n [ngStyle]=\"indicatorStyle\"\n aria-hidden=\"true\"\n ></div>\n\n <button\n *ngFor=\"let segment of segments; index as index; trackBy: trackByValue\"\n #segmentButton\n type=\"button\"\n role=\"tab\"\n class=\"relative z-10 flex flex-col justify-center items-center px-[14px] py-[3.5px] h-[25px] rounded-[8px] transition-all duration-200 ease-in-out whitespace-nowrap text-center focus:outline-none focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 flex-none\"\n [ngClass]=\"{\n 'text-white font-medium': isSelected(segment),\n 'text-[#99999E]': !isSelected(segment) && !(disabled || segment.disabled),\n 'cursor-not-allowed': disabled || segment.disabled,\n 'text-[#C7C7C7]': (disabled || segment.disabled) && !isSelected(segment),\n 'hover:text-black': !isSelected(segment) && !disabled && !segment.disabled\n }\"\n [disabled]=\"disabled || segment.disabled\"\n [attr.aria-selected]=\"isSelected(segment)\"\n [attr.tabindex]=\"!disabled && !segment.disabled ? (isSelected(segment) ? 0 : -1) : -1\"\n (click)=\"select(segment, index)\"\n (keydown)=\"onKeyDown($event, index)\"\n >\n <span class=\"flex items-center justify-center h-[18px] font-['Inter'] font-normal text-[12px] leading-[12px] text-center align-middle\">\n {{ segment.label }}\n </span>\n </button>\n</div>\n", styles: [] }]
583
+ }], propDecorators: { id: [{
584
+ type: HostBinding,
585
+ args: ['attr.id']
586
+ }], display: [{
587
+ type: HostBinding,
588
+ args: ['style.display']
589
+ }], segments: [{
590
+ type: Input
591
+ }], value: [{
592
+ type: Input
593
+ }], disabled: [{
594
+ type: Input
595
+ }], valueChange: [{
596
+ type: Output
597
+ }], segmentButtons: [{
598
+ type: ViewChildren,
599
+ args: ['segmentButton']
600
+ }], segmentContainer: [{
601
+ type: ViewChild,
602
+ args: ['segmentContainer']
603
+ }] } });
604
+
605
+ class DialogComponent {
606
+ constructor(viewContainerRef, cdr) {
607
+ this.viewContainerRef = viewContainerRef;
608
+ this.cdr = cdr;
609
+ this.id = 'cqa-ui-root';
610
+ this.display = 'block';
611
+ this.contentAttached = false;
612
+ }
613
+ attachTemplate(template, context) {
614
+ var _a, _b;
615
+ if (!this.portalOutlet) {
616
+ return;
617
+ }
618
+ const templateContext = context !== null && context !== void 0 ? context : {
619
+ $implicit: (_a = this.config) === null || _a === void 0 ? void 0 : _a.data,
620
+ data: (_b = this.config) === null || _b === void 0 ? void 0 : _b.data,
621
+ };
622
+ const portal = new TemplatePortal(template, this.viewContainerRef, templateContext);
623
+ this.portalOutlet.attachTemplatePortal(portal);
624
+ this.markContentAttached();
625
+ }
626
+ attachComponent(component) {
627
+ if (!this.portalOutlet) {
628
+ return undefined;
629
+ }
630
+ const componentRef = this.portalOutlet.attachComponentPortal(component);
631
+ this.markContentAttached();
632
+ return componentRef;
633
+ }
634
+ onButtonClick(button) {
635
+ var _a;
636
+ return __awaiter(this, void 0, void 0, function* () {
637
+ const closeOnClick = (_a = button.closeOnClick) !== null && _a !== void 0 ? _a : true;
638
+ let handlerResult = undefined;
639
+ if (button.handler) {
640
+ handlerResult = button.handler(this.dialogRef);
641
+ }
642
+ const resolved = handlerResult instanceof Promise ? yield handlerResult : handlerResult;
643
+ if (!closeOnClick || resolved === false) {
644
+ return;
645
+ }
646
+ this.dialogRef.close(resolved);
647
+ });
648
+ }
649
+ get buttonAlignmentClass() {
650
+ var _a, _b;
651
+ const alignment = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.buttonAlignment) !== null && _b !== void 0 ? _b : 'right';
652
+ return this.mapAlignmentToClass(alignment);
653
+ }
654
+ get panelClassList() {
655
+ var _a;
656
+ const baseClasses = [
657
+ 'relative',
658
+ 'w-full',
659
+ 'bg-white',
660
+ 'rounded-2xl',
661
+ 'shadow-md',
662
+ 'border',
663
+ 'border-[#E5E7EB]',
664
+ 'p-6',
665
+ 'text-left',
666
+ ];
667
+ const custom = (_a = this.config) === null || _a === void 0 ? void 0 : _a.panelClass;
668
+ if (!custom) {
669
+ return baseClasses;
670
+ }
671
+ return Array.isArray(custom) ? [...baseClasses, ...custom] : [...baseClasses, custom];
672
+ }
673
+ get panelStyles() {
674
+ var _a, _b, _c;
675
+ return {
676
+ width: (_a = this.config) === null || _a === void 0 ? void 0 : _a.width,
677
+ maxWidth: (_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.maxWidth) !== null && _c !== void 0 ? _c : '480px',
678
+ };
679
+ }
680
+ buttonVariant(button) {
681
+ const role = this.normalizeRole(button.role);
682
+ switch (role) {
683
+ case 'secondary':
684
+ return 'outlined';
685
+ case 'text':
686
+ return 'text';
687
+ case 'tonal':
688
+ return 'tonal';
689
+ case 'elevated':
690
+ return 'elevated';
691
+ case 'filled':
692
+ case 'primary':
693
+ case 'warn':
694
+ default:
695
+ return 'filled';
696
+ }
697
+ }
698
+ buttonHostClasses(button) {
699
+ const role = this.normalizeRole(button.role);
700
+ if (role === 'warn') {
701
+ return ['cqa-dialog-btn-warn'];
702
+ }
703
+ return [];
704
+ }
705
+ mapAlignmentToClass(alignment) {
706
+ switch (alignment) {
707
+ case 'left':
708
+ return 'justify-start';
709
+ case 'center':
710
+ return 'justify-center';
711
+ case 'right':
712
+ default:
713
+ return 'justify-end';
714
+ }
715
+ }
716
+ markContentAttached() {
717
+ this.contentAttached = true;
718
+ this.cdr.markForCheck();
719
+ }
720
+ normalizeRole(role) {
721
+ return (role !== null && role !== void 0 ? role : 'secondary').trim().split(/\s+/)[0];
722
+ }
723
+ }
724
+ DialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DialogComponent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
725
+ DialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: DialogComponent, selector: "cqa-dialog", host: { properties: { "attr.id": "this.id", "style.display": "this.display" } }, viewQueries: [{ propertyName: "portalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true, static: true }], ngImport: i0, template: "<div class=\"flex w-full justify-center px-4 sm:px-6\">\n <div [ngClass]=\"panelClassList\" [ngStyle]=\"panelStyles\">\n <div class=\"flex flex-col gap-5\">\n <div class=\"flex flex-col gap-3\">\n <h2 class=\"text-lg font-semibold text-[#111827]\">\n {{ config.title }}\n </h2>\n\n <p *ngIf=\"config.description\" class=\"text-sm leading-6 text-[#4B5563]\">\n {{ config.description }}\n </p>\n\n <div\n *ngIf=\"config.warning\"\n class=\"rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm leading-5 text-red-700\"\n >\n {{ config.warning }}\n </div>\n </div>\n\n <div class=\"text-sm text-[#111827]\" [class.hidden]=\"!contentAttached\">\n <ng-template cdkPortalOutlet></ng-template>\n </div>\n\n <div class=\"mt-4 flex flex-wrap gap-3\" [ngClass]=\"buttonAlignmentClass\">\n <cqa-button\n *ngFor=\"let button of config.buttons\"\n type=\"button\"\n [variant]=\"buttonVariant(button)\"\n [ngClass]=\"buttonHostClasses(button)\"\n (clicked)=\"onButtonClick(button)\"\n >\n {{ button.label }}\n </cqa-button>\n </div>\n </div>\n </div>\n</div>\n\n\n", components: [{ type: ButtonComponent, selector: "cqa-button", inputs: ["variant", "disabled", "icon", "iconPosition", "type"], outputs: ["clicked"] }], directives: [{ type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
726
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DialogComponent, decorators: [{
727
+ type: Component,
728
+ args: [{ selector: 'cqa-dialog', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"flex w-full justify-center px-4 sm:px-6\">\n <div [ngClass]=\"panelClassList\" [ngStyle]=\"panelStyles\">\n <div class=\"flex flex-col gap-5\">\n <div class=\"flex flex-col gap-3\">\n <h2 class=\"text-lg font-semibold text-[#111827]\">\n {{ config.title }}\n </h2>\n\n <p *ngIf=\"config.description\" class=\"text-sm leading-6 text-[#4B5563]\">\n {{ config.description }}\n </p>\n\n <div\n *ngIf=\"config.warning\"\n class=\"rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm leading-5 text-red-700\"\n >\n {{ config.warning }}\n </div>\n </div>\n\n <div class=\"text-sm text-[#111827]\" [class.hidden]=\"!contentAttached\">\n <ng-template cdkPortalOutlet></ng-template>\n </div>\n\n <div class=\"mt-4 flex flex-wrap gap-3\" [ngClass]=\"buttonAlignmentClass\">\n <cqa-button\n *ngFor=\"let button of config.buttons\"\n type=\"button\"\n [variant]=\"buttonVariant(button)\"\n [ngClass]=\"buttonHostClasses(button)\"\n (clicked)=\"onButtonClick(button)\"\n >\n {{ button.label }}\n </cqa-button>\n </div>\n </div>\n </div>\n</div>\n\n\n", styles: [] }]
729
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { id: [{
730
+ type: HostBinding,
731
+ args: ['attr.id']
732
+ }], display: [{
733
+ type: HostBinding,
734
+ args: ['style.display']
735
+ }], portalOutlet: [{
736
+ type: ViewChild,
737
+ args: [CdkPortalOutlet, { static: true }]
738
+ }] } });
739
+
740
+ class RootWrapperComponent {
741
+ constructor() {
742
+ this.display = 'inline-block';
743
+ this.fullWidth = false;
744
+ }
745
+ get rootStyles() {
746
+ const styles = {
747
+ display: this.fullWidth ? 'block' : this.display
748
+ };
749
+ if (this.fullWidth) {
750
+ styles['width'] = '100%';
751
+ }
752
+ else if (this.width) {
753
+ styles['width'] = this.width;
754
+ }
755
+ return styles;
756
+ }
757
+ }
758
+ RootWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: RootWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
759
+ RootWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: RootWrapperComponent, selector: "cqa-ui-root", inputs: { display: "display", width: "width", fullWidth: "fullWidth" }, ngImport: i0, template: "<div id=\"cqa-ui-root\" [ngStyle]=\"rootStyles\">\n <ng-content></ng-content>\n</div>\n\n", directives: [{ type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
760
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: RootWrapperComponent, decorators: [{
761
+ type: Component,
762
+ args: [{ selector: 'cqa-ui-root', styles: [], template: "<div id=\"cqa-ui-root\" [ngStyle]=\"rootStyles\">\n <ng-content></ng-content>\n</div>\n\n" }]
763
+ }], propDecorators: { display: [{
764
+ type: Input
765
+ }], width: [{
766
+ type: Input
767
+ }], fullWidth: [{
768
+ type: Input
769
+ }] } });
770
+
771
+ // import { CardComponent } from './card/card.component';
772
+ // import { InputComponent } from './input/input.component';
773
+ // import { IconButtonComponent } from './icon-button/icon-button.component';
774
+ class UiKitModule {
775
+ }
776
+ UiKitModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UiKitModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
777
+ UiKitModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UiKitModule, declarations: [ButtonComponent,
778
+ SearchBarComponent,
779
+ SegmentControlComponent,
780
+ DialogComponent,
781
+ RootWrapperComponent], imports: [CommonModule,
782
+ FormsModule,
783
+ MatIconModule,
784
+ OverlayModule,
785
+ PortalModule], exports: [ButtonComponent,
786
+ SearchBarComponent,
787
+ SegmentControlComponent,
788
+ DialogComponent,
789
+ RootWrapperComponent] });
790
+ UiKitModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UiKitModule, imports: [[
791
+ CommonModule,
792
+ FormsModule,
793
+ MatIconModule,
794
+ OverlayModule,
795
+ PortalModule
796
+ ]] });
797
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UiKitModule, decorators: [{
798
+ type: NgModule,
799
+ args: [{
800
+ declarations: [
801
+ ButtonComponent,
802
+ SearchBarComponent,
803
+ SegmentControlComponent,
804
+ DialogComponent,
805
+ RootWrapperComponent,
806
+ // CardComponent,
807
+ // InputComponent,
808
+ // IconButtonComponent
809
+ ],
810
+ imports: [
811
+ CommonModule,
812
+ FormsModule,
813
+ MatIconModule,
814
+ OverlayModule,
815
+ PortalModule
816
+ ],
817
+ exports: [
818
+ ButtonComponent,
819
+ SearchBarComponent,
820
+ SegmentControlComponent,
821
+ DialogComponent,
822
+ RootWrapperComponent,
823
+ // CardComponent,
824
+ // InputComponent,
825
+ // IconButtonComponent
826
+ ]
827
+ }]
828
+ }] });
829
+
830
+ class DialogRef {
831
+ constructor(overlayRef) {
832
+ this.overlayRef = overlayRef;
833
+ this.closed$ = new Subject();
834
+ this.isClosed = false;
835
+ this.overlayRef.detachments().subscribe(() => {
836
+ this.finishClose(undefined);
837
+ });
838
+ }
839
+ close(result) {
840
+ if (this.isClosed) {
841
+ return;
842
+ }
843
+ this.finishClose(result);
844
+ this.overlayRef.dispose();
845
+ }
846
+ afterClosed() {
847
+ return this.closed$.asObservable();
848
+ }
849
+ setComponentInstance(instance) {
850
+ this.componentInstance = instance;
851
+ }
852
+ getComponentInstance() {
853
+ return this.componentInstance;
854
+ }
855
+ finishClose(result) {
856
+ if (this.isClosed) {
857
+ return;
858
+ }
859
+ this.isClosed = true;
860
+ this.closed$.next(result);
861
+ this.closed$.complete();
862
+ }
863
+ }
864
+
865
+ const DIALOG_REF = new InjectionToken('CQA_DIALOG_REF');
866
+ const DIALOG_DATA = new InjectionToken('CQA_DIALOG_DATA');
867
+
868
+ class DialogService {
869
+ constructor(overlay, injector) {
870
+ this.overlay = overlay;
871
+ this.injector = injector;
872
+ }
873
+ open(config) {
874
+ var _a, _b, _c;
875
+ this.assertValidConfig(config);
876
+ const overlayRef = this.overlay.create(this.buildOverlayConfig(config));
877
+ const dialogRef = new DialogRef(overlayRef);
878
+ const injector = Injector.create({
879
+ parent: this.injector,
880
+ providers: [
881
+ { provide: DIALOG_REF, useValue: dialogRef },
882
+ { provide: DIALOG_DATA, useValue: config.data },
883
+ ],
884
+ });
885
+ const containerPortal = new ComponentPortal(DialogComponent, undefined, injector);
886
+ const containerRef = overlayRef.attach(containerPortal);
887
+ const containerInstance = containerRef.instance;
888
+ containerInstance.config = config;
889
+ containerInstance.dialogRef = dialogRef;
890
+ if (((_a = config.content) === null || _a === void 0 ? void 0 : _a.type) === 'template') {
891
+ containerInstance.attachTemplate(config.content.template, (_b = config.content.context) !== null && _b !== void 0 ? _b : {
892
+ $implicit: config.data,
893
+ data: config.data,
894
+ });
895
+ }
896
+ if (((_c = config.content) === null || _c === void 0 ? void 0 : _c.type) === 'component') {
897
+ const componentPortal = new ComponentPortal(config.content.component, undefined, Injector.create({
898
+ parent: injector,
899
+ providers: [
900
+ { provide: DIALOG_REF, useValue: dialogRef },
901
+ { provide: DIALOG_DATA, useValue: config.data },
902
+ ],
903
+ }));
904
+ const componentRef = containerInstance.attachComponent(componentPortal);
905
+ if (componentRef && config.content.inputs) {
906
+ Object.entries(config.content.inputs).forEach(([key, value]) => {
907
+ componentRef.instance[key] = value;
908
+ });
909
+ componentRef.changeDetectorRef.markForCheck();
910
+ }
911
+ if (componentRef) {
912
+ dialogRef.setComponentInstance(componentRef.instance);
913
+ }
914
+ }
915
+ containerRef.changeDetectorRef.markForCheck();
916
+ if (!config.disableClose) {
917
+ overlayRef.backdropClick().subscribe(() => dialogRef.close());
918
+ overlayRef
919
+ .keydownEvents()
920
+ .pipe(filter((event) => {
921
+ return event.key === 'Escape' || event.key === 'Esc';
922
+ }))
923
+ .subscribe(() => dialogRef.close());
924
+ }
925
+ return dialogRef;
926
+ }
927
+ assertValidConfig(config) {
928
+ if (!config.title) {
929
+ throw new Error('Dialog title is required.');
930
+ }
931
+ if (!config.buttons || config.buttons.length < 2) {
932
+ throw new Error('Dialog requires at least two buttons to be provided.');
933
+ }
934
+ }
935
+ buildOverlayConfig(config) {
936
+ var _a;
937
+ const panelClass = Array.isArray(config.panelClass)
938
+ ? config.panelClass
939
+ : config.panelClass
940
+ ? [config.panelClass]
941
+ : [];
942
+ return new OverlayConfig({
943
+ hasBackdrop: true,
944
+ backdropClass: ['cdk-overlay-dark-backdrop', 'cqa-dialog-backdrop'],
945
+ scrollStrategy: this.overlay.scrollStrategies.block(),
946
+ positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),
947
+ width: config.width,
948
+ maxWidth: (_a = config.maxWidth) !== null && _a !== void 0 ? _a : '90vw',
949
+ panelClass: ['cqa-dialog-panel', ...panelClass],
950
+ });
951
+ }
952
+ }
953
+ DialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DialogService, deps: [{ token: i1$1.Overlay }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
954
+ DialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DialogService, providedIn: 'root' });
955
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DialogService, decorators: [{
956
+ type: Injectable,
957
+ args: [{
958
+ providedIn: 'root',
959
+ }]
960
+ }], ctorParameters: function () { return [{ type: i1$1.Overlay }, { type: i0.Injector }]; } });
961
+
962
+ /**
963
+ * Generated bundle index. Do not edit.
964
+ */
965
+
966
+ export { ButtonComponent, DIALOG_DATA, DIALOG_REF, DialogComponent, DialogRef, DialogService, RootWrapperComponent, SearchBarComponent, SegmentControlComponent, UiKitModule };
967
+ //# sourceMappingURL=cqa-lib-cqa-ui.mjs.map