@aaamb/ngx-design-system 1.3.6 → 1.3.8

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.
Files changed (108) hide show
  1. package/fesm2022/aaamb-ngx-design-system.mjs +4075 -0
  2. package/fesm2022/aaamb-ngx-design-system.mjs.map +1 -0
  3. package/package.json +14 -58
  4. package/styles/compiled.css +2 -0
  5. package/types/aaamb-ngx-design-system.d.ts +1142 -0
  6. package/.editorconfig +0 -17
  7. package/.nvmrc +0 -1
  8. package/.postcssrc.json +0 -5
  9. package/.storybook/main.ts +0 -20
  10. package/.storybook/preview.ts +0 -23
  11. package/.storybook/storybook.css +0 -1
  12. package/.storybook/tsconfig.json +0 -19
  13. package/.vscode/extensions.json +0 -4
  14. package/.vscode/launch.json +0 -20
  15. package/.vscode/tasks.json +0 -42
  16. package/CHANGELOG.md +0 -10
  17. package/LOCAL_DEVELOPMENT.md +0 -129
  18. package/angular.json +0 -74
  19. package/bitbucket-pipelines.yml +0 -41
  20. package/iac/bin/app.ts +0 -42
  21. package/iac/cdk.json +0 -82
  22. package/iac/lib/config/environments.ts +0 -19
  23. package/iac/lib/config/types.ts +0 -13
  24. package/iac/lib/stacks/certificate-stack.ts +0 -34
  25. package/iac/lib/stacks/frontend-stack.ts +0 -120
  26. package/iac/lib/stacks/index.ts +0 -2
  27. package/iac/package-lock.json +0 -726
  28. package/iac/package.json +0 -25
  29. package/iac/tsconfig.json +0 -24
  30. package/ng-package.json +0 -8
  31. package/src/components/button/button-green.stories.ts +0 -101
  32. package/src/components/button/button-text.stories.ts +0 -105
  33. package/src/components/button/button-white.stories.ts +0 -105
  34. package/src/components/button/button.component.stories.ts +0 -91
  35. package/src/components/button/button.component.ts +0 -93
  36. package/src/components/checkbox/checkbox.component.html +0 -30
  37. package/src/components/checkbox/checkbox.component.stories.ts +0 -183
  38. package/src/components/checkbox/checkbox.component.ts +0 -211
  39. package/src/components/datepicker-selector/datepicker-selector.component.html +0 -103
  40. package/src/components/datepicker-selector/datepicker-selector.component.stories.ts +0 -69
  41. package/src/components/datepicker-selector/datepicker-selector.component.ts +0 -287
  42. package/src/components/error-message/error-message.component.html +0 -3
  43. package/src/components/error-message/error-message.component.ts +0 -13
  44. package/src/components/filter-button/filter-button.component.html +0 -286
  45. package/src/components/filter-button/filter-button.component.stories.ts +0 -123
  46. package/src/components/filter-button/filter-button.component.ts +0 -582
  47. package/src/components/icon/icon.component.ts +0 -20
  48. package/src/components/icon/icon.html +0 -1333
  49. package/src/components/icon/icon.stories.ts +0 -49
  50. package/src/components/icon/icons-list.stories.ts +0 -42
  51. package/src/components/input/input.component.stories.ts +0 -101
  52. package/src/components/input/input.component.ts +0 -317
  53. package/src/components/input/input.html +0 -160
  54. package/src/components/input-datepicker/input-datepicker.component.ts +0 -356
  55. package/src/components/input-datepicker/input-datepicker.html +0 -69
  56. package/src/components/input-datepicker/input-datepicker.stories.ts +0 -99
  57. package/src/components/input-rangepicker/input-rangepicker.component.ts +0 -365
  58. package/src/components/input-rangepicker/input-rangepicker.html +0 -54
  59. package/src/components/input-rangepicker/input-rangepicker.stories.ts +0 -88
  60. package/src/components/input-weekpicker/input-weekpicker.component.ts +0 -417
  61. package/src/components/input-weekpicker/input-weekpicker.html +0 -54
  62. package/src/components/input-weekpicker/input-weekpicker.stories.ts +0 -103
  63. package/src/components/label/label.component.html +0 -20
  64. package/src/components/label/label.component.ts +0 -22
  65. package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.html +0 -32
  66. package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.stories.ts +0 -57
  67. package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.ts +0 -48
  68. package/src/components/modals/feedback-modal/feedback-modal.component.html +0 -118
  69. package/src/components/modals/feedback-modal/feedback-modal.component.stories.ts +0 -93
  70. package/src/components/modals/feedback-modal/feedback-modal.component.ts +0 -187
  71. package/src/components/modals/help-modal/help-modal.component.html +0 -32
  72. package/src/components/modals/help-modal/help-modal.component.stories.ts +0 -76
  73. package/src/components/modals/help-modal/help-modal.component.ts +0 -54
  74. package/src/components/modals/information-modal/information-modal.component.html +0 -24
  75. package/src/components/modals/information-modal/information-modal.component.stories.ts +0 -62
  76. package/src/components/modals/information-modal/information-modal.component.ts +0 -35
  77. package/src/components/modals/main-modal/main-modal.component.html +0 -85
  78. package/src/components/modals/main-modal/main-modal.component.stories.ts +0 -127
  79. package/src/components/modals/main-modal/main-modal.component.ts +0 -85
  80. package/src/components/modals/notification-modal/notification-modal.component.html +0 -22
  81. package/src/components/modals/notification-modal/notification-modal.component.stories.ts +0 -59
  82. package/src/components/modals/notification-modal/notification-modal.component.ts +0 -37
  83. package/src/components/selectors/multiple-selector/multiple-selector.component.html +0 -51
  84. package/src/components/selectors/multiple-selector/multiple-selector.component.stories.ts +0 -306
  85. package/src/components/selectors/multiple-selector/multiple-selector.component.ts +0 -308
  86. package/src/components/selectors/single-selector/single-selector.component.html +0 -46
  87. package/src/components/selectors/single-selector/single-selector.component.stories.ts +0 -294
  88. package/src/components/selectors/single-selector/single-selector.component.ts +0 -239
  89. package/src/components/side-nav/side-nav.component.stories.ts +0 -157
  90. package/src/components/side-nav/side-nav.component.ts +0 -306
  91. package/src/components/snackbar/snackbar.component.ts +0 -150
  92. package/src/components/snackbar/snackbar.html +0 -21
  93. package/src/components/snackbar/snackbar.stories.ts +0 -51
  94. package/src/components/state/state.component.ts +0 -30
  95. package/src/components/state/state.html +0 -13
  96. package/src/components/state/state.stories.ts +0 -74
  97. package/src/components/table/table.component.html +0 -441
  98. package/src/components/table/table.component.scss +0 -28
  99. package/src/components/table/table.component.stories.ts +0 -655
  100. package/src/components/table/table.component.ts +0 -475
  101. package/src/components/tabs/tabs.component.stories.ts +0 -114
  102. package/src/components/tabs/tabs.component.ts +0 -69
  103. package/src/core/types.ts +0 -486
  104. package/src/public-api.ts +0 -23
  105. package/tsconfig.json +0 -37
  106. package/tsconfig.lib.json +0 -17
  107. package/tsconfig.lib.prod.json +0 -9
  108. package/tsconfig.spec.json +0 -13
@@ -1,306 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/angular';
2
- import { CommonModule } from '@angular/common';
3
- import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
4
- import { delay, of } from 'rxjs';
5
- import { MultipleSelectorComponent } from './multiple-selector.component';
6
- import {
7
- AdsIconName,
8
- AdsMultipleSelectorAsyncOptions,
9
- AdsMultipleSelectorOption,
10
- AdsMultipleSelectorOptionOrGroup,
11
- } from '../../../core/types';
12
-
13
- const defaultOptions: AdsMultipleSelectorOption[] = [
14
- { label: 'Mexico', value: 'mx' },
15
- { label: 'Colombia', value: 'co' },
16
- { label: 'Argentina', value: 'ar' },
17
- { label: 'Chile', value: 'cl' },
18
- { label: 'Peru', value: 'pe' },
19
- ];
20
-
21
- const meta: Meta<MultipleSelectorComponent> = {
22
- title: 'Components/Selectors/MultipleSelector',
23
- component: MultipleSelectorComponent,
24
- args: {
25
- label: 'Countries',
26
- placeholder: 'Search and select',
27
- allowClear: true,
28
- disabled: false,
29
- loading: false,
30
- itemName: 'country',
31
- pluralItemName: 'countries',
32
- options: defaultOptions,
33
- errorMessage: '',
34
- labelIconName: null,
35
- },
36
- argTypes: {
37
- label: { control: 'text' },
38
- placeholder: { control: 'text' },
39
- allowClear: { control: 'boolean' },
40
- disabled: { control: 'boolean' },
41
- loading: { control: 'boolean' },
42
- itemName: { control: 'text' },
43
- pluralItemName: { control: 'text' },
44
- options: { control: 'object' },
45
- errorMessage: { control: 'text' },
46
- labelIconName: { control: 'boolean' },
47
- },
48
- render: (args) => {
49
- const form = new FormGroup({
50
- countries: new FormControl<(string | number)[]>([]),
51
- });
52
-
53
- return {
54
- moduleMetadata: {
55
- imports: [CommonModule, ReactiveFormsModule],
56
- },
57
- props: {
58
- ...args,
59
- form,
60
- },
61
- template: `
62
- <div class="max-w-md space-y-4">
63
- <form [formGroup]="form">
64
- <ads-multiple-selector
65
- formControlName="countries"
66
- [label]="label"
67
- [placeholder]="placeholder"
68
- [allowClear]="allowClear"
69
- [disabled]="disabled"
70
- [loading]="loading"
71
- [itemName]="itemName"
72
- [pluralItemName]="pluralItemName"
73
- [options]="options"
74
- [errorMessage]="errorMessage"
75
- [labelIconName]="labelIconName ? 'plus' : null"
76
- ></ads-multiple-selector>
77
- </form>
78
-
79
- <p class="m-0 text-sm text-green-base">Value: {{ form.controls.countries.value | json }}</p>
80
- </div>
81
- `,
82
- };
83
- },
84
- };
85
-
86
- export default meta;
87
- type Story = StoryObj<MultipleSelectorComponent>;
88
-
89
- export const Playground: Story = {};
90
-
91
- export const AsyncObservableOptions: Story = {
92
- render: (args) => {
93
- const form = new FormGroup({
94
- countries: new FormControl<(string | number)[]>([]),
95
- });
96
-
97
- const asyncOptions: AdsMultipleSelectorAsyncOptions = of(
98
- defaultOptions,
99
- ).pipe(delay(1200));
100
-
101
- return {
102
- moduleMetadata: {
103
- imports: [CommonModule, ReactiveFormsModule],
104
- },
105
- props: {
106
- ...args,
107
- form,
108
- asyncOptions,
109
- },
110
- template: `
111
- <div class="max-w-md space-y-4">
112
- <form [formGroup]="form">
113
- <ads-multiple-selector
114
- formControlName="countries"
115
- [label]="label"
116
- [placeholder]="placeholder"
117
- [allowClear]="allowClear"
118
- [disabled]="disabled"
119
- [itemName]="itemName"
120
- [pluralItemName]="pluralItemName"
121
- [asyncOptions]="asyncOptions"
122
- [errorMessage]="errorMessage"
123
- [labelIconName]="labelIconName ? 'plus' : null"
124
- ></ads-multiple-selector>
125
- </form>
126
-
127
- <p class="m-0 text-sm text-green-base">Value: {{ form.controls.countries.value | json }}</p>
128
- </div>
129
- `,
130
- };
131
- },
132
- };
133
-
134
- export const AsyncPromiseOptions: Story = {
135
- render: (args) => {
136
- const form = new FormGroup({
137
- countries: new FormControl<(string | number)[]>([]),
138
- });
139
-
140
- const asyncOptions: AdsMultipleSelectorAsyncOptions = new Promise(
141
- (resolve) => {
142
- setTimeout(() => resolve(defaultOptions), 1200);
143
- },
144
- );
145
-
146
- return {
147
- moduleMetadata: {
148
- imports: [CommonModule, ReactiveFormsModule],
149
- },
150
- props: {
151
- ...args,
152
- form,
153
- asyncOptions,
154
- },
155
- template: `
156
- <div class="max-w-md space-y-4">
157
- <form [formGroup]="form">
158
- <ads-multiple-selector
159
- formControlName="countries"
160
- [label]="label"
161
- [placeholder]="placeholder"
162
- [allowClear]="allowClear"
163
- [disabled]="disabled"
164
- [itemName]="itemName"
165
- [pluralItemName]="pluralItemName"
166
- [asyncOptions]="asyncOptions"
167
- [errorMessage]="errorMessage"
168
- [labelIconName]="labelIconName ? 'plus' : null"
169
- ></ads-multiple-selector>
170
- </form>
171
-
172
- <p class="m-0 text-sm text-green-base">Value: {{ form.controls.countries.value | json }}</p>
173
- </div>
174
- `,
175
- };
176
- },
177
- };
178
-
179
- export const WithGroupedOptions: Story = {
180
- render: (args) => {
181
- const form = new FormGroup({
182
- countries: new FormControl<(string | number)[]>([]),
183
- });
184
-
185
- const groupedOptions: AdsMultipleSelectorOptionOrGroup[] = [
186
- {
187
- label: 'North America',
188
- children: [
189
- { label: 'Mexico', value: 'mx' },
190
- { label: 'Canada', value: 'ca' },
191
- { label: 'United States', value: 'us' },
192
- ],
193
- },
194
- {
195
- label: 'South America',
196
- children: [
197
- { label: 'Colombia', value: 'co' },
198
- { label: 'Argentina', value: 'ar' },
199
- { label: 'Chile', value: 'cl' },
200
- { label: 'Peru', value: 'pe' },
201
- ],
202
- },
203
- {
204
- label: 'Other',
205
- children: [
206
- { label: 'Spain', value: 'es' },
207
- { label: 'Brazil', value: 'br' },
208
- ],
209
- },
210
- ];
211
-
212
- return {
213
- moduleMetadata: {
214
- imports: [CommonModule, ReactiveFormsModule],
215
- },
216
- props: {
217
- ...args,
218
- form,
219
- options: groupedOptions,
220
- },
221
- template: `
222
- <div class="max-w-md space-y-4">
223
- <form [formGroup]="form">
224
- <ads-multiple-selector
225
- formControlName="countries"
226
- [label]="label"
227
- [placeholder]="placeholder"
228
- [allowClear]="allowClear"
229
- [disabled]="disabled"
230
- [itemName]="itemName"
231
- [pluralItemName]="pluralItemName"
232
- [options]="groupedOptions"
233
- [errorMessage]="errorMessage"
234
- [labelIconName]="labelIconName ? 'plus' : null"
235
- ></ads-multiple-selector>
236
- </form>
237
-
238
- <p class="m-0 text-sm text-green-base">Value: {{ form.controls.countries.value | json }}</p>
239
- </div>
240
- `,
241
- };
242
- },
243
- };
244
-
245
- export const WithAsyncGroupedOptions: Story = {
246
- render: (args) => {
247
- const form = new FormGroup({
248
- countries: new FormControl<(string | number)[]>([]),
249
- });
250
-
251
- const groupedOptions: AdsMultipleSelectorOptionOrGroup[] = [
252
- {
253
- label: 'North America',
254
- children: [
255
- { label: 'Mexico', value: 'mx' },
256
- { label: 'Canada', value: 'ca' },
257
- { label: 'United States', value: 'us' },
258
- ],
259
- },
260
- {
261
- label: 'South America',
262
- children: [
263
- { label: 'Colombia', value: 'co' },
264
- { label: 'Argentina', value: 'ar' },
265
- { label: 'Chile', value: 'cl' },
266
- { label: 'Peru', value: 'pe' },
267
- ],
268
- },
269
- ];
270
-
271
- const asyncOptions: AdsMultipleSelectorAsyncOptions = of(groupedOptions).pipe(
272
- delay(1200),
273
- );
274
-
275
- return {
276
- moduleMetadata: {
277
- imports: [CommonModule, ReactiveFormsModule],
278
- },
279
- props: {
280
- ...args,
281
- form,
282
- asyncOptions,
283
- },
284
- template: `
285
- <div class="max-w-md space-y-4">
286
- <form [formGroup]="form">
287
- <ads-multiple-selector
288
- formControlName="countries"
289
- [label]="label"
290
- [placeholder]="placeholder"
291
- [allowClear]="allowClear"
292
- [disabled]="disabled"
293
- [itemName]="itemName"
294
- [pluralItemName]="pluralItemName"
295
- [asyncOptions]="asyncOptions"
296
- [errorMessage]="errorMessage"
297
- [labelIconName]="labelIconName ? 'plus' : null"
298
- ></ads-multiple-selector>
299
- </form>
300
-
301
- <p class="m-0 text-sm text-green-base">Value: {{ form.controls.countries.value | json }}</p>
302
- </div>
303
- `,
304
- };
305
- },
306
- };
@@ -1,308 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import {
3
- Component,
4
- CUSTOM_ELEMENTS_SCHEMA,
5
- effect,
6
- forwardRef,
7
- input,
8
- OnDestroy,
9
- output,
10
- signal,
11
- } from '@angular/core';
12
- import {
13
- ControlValueAccessor,
14
- FormsModule,
15
- NG_VALUE_ACCESSOR,
16
- } from '@angular/forms';
17
- import { Subscription, Observable } from 'rxjs';
18
- import { NzFilterOptionType, NzSelectModule } from 'ng-zorro-antd/select';
19
- import {
20
- AdsIconName,
21
- AdsMultipleSelectorAsyncOptions,
22
- AdsMultipleSelectorOption,
23
- AdsMultipleSelectorOptionGroup,
24
- AdsMultipleSelectorOptionOrGroup,
25
- AdsMultipleSelectorValue,
26
- } from '../../../core/types';
27
- import { LabelComponent } from '../../label/label.component';
28
- import { ErrorMessageComponent } from '../../error-message/error-message.component';
29
-
30
- @Component({
31
- selector: 'ads-multiple-selector',
32
- standalone: true,
33
- imports: [
34
- CommonModule,
35
- FormsModule,
36
- NzSelectModule,
37
- LabelComponent,
38
- ErrorMessageComponent,
39
- ],
40
- templateUrl: './multiple-selector.component.html',
41
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
42
- providers: [
43
- {
44
- provide: NG_VALUE_ACCESSOR,
45
- useExisting: forwardRef(() => MultipleSelectorComponent),
46
- multi: true,
47
- },
48
- ],
49
- })
50
- export class MultipleSelectorComponent
51
- implements ControlValueAccessor, OnDestroy
52
- {
53
- label = input<string>('');
54
- placeholder = input<string>('Select one or more options');
55
- disabled = input<boolean>(false);
56
- allowClear = input<boolean>(true);
57
- loading = input<boolean>(false);
58
- options = input<AdsMultipleSelectorOptionOrGroup[]>([]);
59
- asyncOptions = input<AdsMultipleSelectorAsyncOptions | null>(null);
60
- value = input<AdsMultipleSelectorValue[]>([]);
61
- itemName = input<string>('item');
62
- pluralItemName = input<string>('items');
63
- errorMessage = input<string>('Please select at least one option.');
64
- labelIconName = input<AdsIconName | null>(null);
65
-
66
- onLabelButtonClick = output<void>();
67
- valueChange = output<AdsMultipleSelectorValue[]>();
68
-
69
- private cvaMode = false;
70
- private cvaDisabled = false;
71
- private asyncLoading = signal<boolean>(false);
72
- private optionsSubscription: Subscription | null = null;
73
- private asyncRequestId = 0;
74
- private baseOptions = signal<AdsMultipleSelectorOptionOrGroup[]>([]);
75
-
76
- currentValue = signal<AdsMultipleSelectorValue[]>([]);
77
- resolvedOptions = signal<AdsMultipleSelectorOptionOrGroup[]>([]);
78
-
79
- private onChange: (value: AdsMultipleSelectorValue[]) => void = () => {};
80
- private onTouched: () => void = () => {};
81
-
82
- readonly filterOption: NzFilterOptionType = (input, option) => {
83
- const label = String(option?.nzLabel ?? '').toLowerCase();
84
- return label.includes(input.toLowerCase());
85
- };
86
-
87
- constructor() {
88
- effect(() => {
89
- if (!this.cvaMode) {
90
- this.currentValue.set(this.normalizeValues(this.value()));
91
- this.reorderOptions();
92
- }
93
- });
94
-
95
- effect(() => {
96
- const providedAsyncOptions = this.asyncOptions();
97
-
98
- if (!providedAsyncOptions) {
99
- this.cancelAsyncOptionsSubscription();
100
- this.asyncLoading.set(false);
101
- this.baseOptions.set(this.options());
102
- this.reorderOptions();
103
- return;
104
- }
105
-
106
- this.loadAsyncOptions(providedAsyncOptions);
107
- });
108
- }
109
-
110
- ngOnDestroy(): void {
111
- this.cancelAsyncOptionsSubscription();
112
- }
113
-
114
- isDisabled(): boolean {
115
- return this.disabled() || this.cvaDisabled;
116
- }
117
-
118
- isLoading(): boolean {
119
- return this.loading() || this.asyncLoading();
120
- }
121
-
122
- onSelectionChange(values: AdsMultipleSelectorValue[]): void {
123
- const normalizedValues = this.normalizeValues(values);
124
- this.currentValue.set(normalizedValues);
125
- this.reorderOptions();
126
- this.onChange(normalizedValues);
127
- this.valueChange.emit(normalizedValues);
128
- }
129
-
130
- onBlur(): void {
131
- this.onTouched();
132
- }
133
-
134
- selectedItemsSummary(selectedCount: number): string {
135
- const name =
136
- selectedCount > 1 ? `${this.pluralItemName()}` : this.itemName();
137
- return `${selectedCount} ${name} selected`;
138
- }
139
-
140
- writeValue(value: unknown): void {
141
- this.cvaMode = true;
142
-
143
- if (Array.isArray(value)) {
144
- this.currentValue.set(this.normalizeValues(value));
145
- this.reorderOptions();
146
- return;
147
- }
148
-
149
- this.currentValue.set([]);
150
- this.reorderOptions();
151
- }
152
-
153
- registerOnChange(fn: (value: AdsMultipleSelectorValue[]) => void): void {
154
- this.onChange = fn;
155
- }
156
-
157
- registerOnTouched(fn: () => void): void {
158
- this.onTouched = fn;
159
- }
160
-
161
- setDisabledState(isDisabled: boolean): void {
162
- this.cvaDisabled = isDisabled;
163
- }
164
-
165
- private loadAsyncOptions(source: AdsMultipleSelectorAsyncOptions): void {
166
- this.cancelAsyncOptionsSubscription();
167
-
168
- const requestId = ++this.asyncRequestId;
169
- this.asyncLoading.set(true);
170
-
171
- if (this.isPromise(source)) {
172
- source
173
- .then((items) => {
174
- this.applyAsyncOptionsResult(requestId, items);
175
- })
176
- .catch(() => {
177
- this.applyAsyncOptionsResult(requestId, []);
178
- })
179
- .finally(() => {
180
- this.finishAsyncOptionsRequest(requestId);
181
- });
182
-
183
- return;
184
- }
185
-
186
- this.optionsSubscription = (
187
- source as Observable<AdsMultipleSelectorOptionOrGroup[]>
188
- ).subscribe({
189
- next: (items: AdsMultipleSelectorOptionOrGroup[]) => {
190
- this.applyAsyncOptionsResult(requestId, items);
191
- },
192
- error: () => {
193
- this.applyAsyncOptionsResult(requestId, []);
194
- this.finishAsyncOptionsRequest(requestId);
195
- },
196
- complete: () => {
197
- this.finishAsyncOptionsRequest(requestId);
198
- },
199
- });
200
- }
201
-
202
- private applyAsyncOptionsResult(
203
- requestId: number,
204
- options: AdsMultipleSelectorOptionOrGroup[],
205
- ): void {
206
- if (requestId !== this.asyncRequestId) {
207
- return;
208
- }
209
-
210
- this.baseOptions.set(options);
211
- this.reorderOptions();
212
- }
213
-
214
- private finishAsyncOptionsRequest(requestId: number): void {
215
- if (requestId !== this.asyncRequestId) {
216
- return;
217
- }
218
-
219
- this.asyncLoading.set(false);
220
- }
221
-
222
- private reorderOptions(): void {
223
- const selectedValues = this.currentValue();
224
- const baseOptions = this.baseOptions();
225
-
226
- if (!selectedValues.length) {
227
- this.resolvedOptions.set(baseOptions);
228
- return;
229
- }
230
-
231
- const groups: AdsMultipleSelectorOptionGroup[] = [];
232
- const flatOptions: AdsMultipleSelectorOption[] = [];
233
- const selectedSet = new Set(selectedValues);
234
-
235
- for (const item of baseOptions) {
236
- if ('children' in item) {
237
- groups.push(item);
238
- } else {
239
- flatOptions.push(item);
240
- }
241
- }
242
-
243
- const selectedByValue = new Map<
244
- AdsMultipleSelectorValue,
245
- AdsMultipleSelectorOption
246
- >();
247
- for (const option of flatOptions) {
248
- selectedByValue.set(option.value, option);
249
- }
250
-
251
- const selectedOptions: AdsMultipleSelectorOption[] = [];
252
- for (const value of selectedValues) {
253
- const option = selectedByValue.get(value);
254
- if (option) {
255
- selectedOptions.push(option);
256
- }
257
- }
258
-
259
- const unselectedOptions = flatOptions.filter(
260
- (option) => !selectedSet.has(option.value),
261
- );
262
-
263
- this.resolvedOptions.set([
264
- ...groups,
265
- ...selectedOptions,
266
- ...unselectedOptions,
267
- ]);
268
- }
269
-
270
- private normalizeValues(values: unknown[]): AdsMultipleSelectorValue[] {
271
- const normalizedValues: AdsMultipleSelectorValue[] = [];
272
-
273
- for (const value of values) {
274
- if (typeof value === 'string' || typeof value === 'number') {
275
- normalizedValues.push(value);
276
- }
277
- }
278
-
279
- return normalizedValues;
280
- }
281
-
282
- private cancelAsyncOptionsSubscription(): void {
283
- if (!this.optionsSubscription) {
284
- return;
285
- }
286
-
287
- this.optionsSubscription.unsubscribe();
288
- this.optionsSubscription = null;
289
- }
290
-
291
- private isPromise(
292
- value: AdsMultipleSelectorAsyncOptions,
293
- ): value is Promise<AdsMultipleSelectorOption[]> {
294
- return (
295
- typeof (value as Promise<AdsMultipleSelectorOption[]>).then === 'function'
296
- );
297
- }
298
-
299
- onLabelClicked(): void {
300
- this.onLabelButtonClick.emit();
301
- }
302
-
303
- isOptionGroup(
304
- item: AdsMultipleSelectorOptionOrGroup,
305
- ): item is { label: string; children: AdsMultipleSelectorOption[] } {
306
- return 'children' in item;
307
- }
308
- }
@@ -1,46 +0,0 @@
1
- <div class="flex w-full flex-col">
2
- <ads-label
3
- [text]="label()"
4
- [iconName]="labelIconName()"
5
- (iconClicked)="onLabelClicked()"
6
- ></ads-label>
7
-
8
- <nz-select
9
- class="w-full"
10
- [ngModel]="currentValue()"
11
- [nzPlaceHolder]="placeholder()"
12
- [nzShowSearch]="true"
13
- [nzAllowClear]="allowClear()"
14
- [nzDisabled]="isDisabled()"
15
- [nzLoading]="isLoading()"
16
- [nzFilterOption]="filterOption"
17
- (ngModelChange)="onSelectionChange($event)"
18
- (nzBlur)="onBlur()"
19
- [nzStatus]="errorMessage() ? 'error' : ''"
20
- >
21
- @for (option of resolvedOptions(); track $index) {
22
- @if (isOptionGroup(option)) {
23
- <nz-option-group [nzLabel]="option.label">
24
- @for (item of option.children; track item.value) {
25
- <nz-option
26
- [nzValue]="item.value"
27
- [nzLabel]="item.label"
28
- [nzDisabled]="item.disabled"
29
- ></nz-option>
30
- }
31
- </nz-option-group>
32
- } @else {
33
- <nz-option
34
- [nzValue]="option.value"
35
- [nzLabel]="option.label"
36
- [nzDisabled]="option.disabled"
37
- ></nz-option>
38
- }
39
- }
40
- </nz-select>
41
-
42
- <ads-error-message
43
- [hasError]="!!errorMessage()"
44
- [errorMessage]="errorMessage()"
45
- ></ads-error-message>
46
- </div>