@aaamb/ngx-design-system 1.3.9 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +17 -0
- package/.nvmrc +1 -0
- package/.postcssrc.json +5 -0
- package/.storybook/main.ts +20 -0
- package/.storybook/preview.ts +23 -0
- package/.storybook/storybook.css +1 -0
- package/.storybook/tsconfig.json +19 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +20 -0
- package/.vscode/tasks.json +42 -0
- package/CHANGELOG.md +10 -0
- package/LOCAL_DEVELOPMENT.md +129 -0
- package/angular.json +74 -0
- package/bitbucket-pipelines.yml +41 -0
- package/iac/bin/app.ts +42 -0
- package/iac/cdk.json +82 -0
- package/iac/lib/config/environments.ts +19 -0
- package/iac/lib/config/types.ts +13 -0
- package/iac/lib/stacks/certificate-stack.ts +34 -0
- package/iac/lib/stacks/frontend-stack.ts +120 -0
- package/iac/lib/stacks/index.ts +2 -0
- package/iac/package-lock.json +726 -0
- package/iac/package.json +25 -0
- package/iac/tsconfig.json +24 -0
- package/ng-package.json +8 -0
- package/package.json +58 -14
- package/src/components/button/button-green.stories.ts +101 -0
- package/src/components/button/button-text.stories.ts +105 -0
- package/src/components/button/button-white.stories.ts +105 -0
- package/src/components/button/button.component.stories.ts +91 -0
- package/src/components/button/button.component.ts +93 -0
- package/src/components/checkbox/checkbox.component.html +30 -0
- package/src/components/checkbox/checkbox.component.stories.ts +183 -0
- package/src/components/checkbox/checkbox.component.ts +211 -0
- package/src/components/datepicker-selector/datepicker-selector.component.html +103 -0
- package/src/components/datepicker-selector/datepicker-selector.component.stories.ts +123 -0
- package/src/components/datepicker-selector/datepicker-selector.component.ts +337 -0
- package/src/components/error-message/error-message.component.html +3 -0
- package/src/components/error-message/error-message.component.ts +13 -0
- package/src/components/filter-button/filter-button.component.html +286 -0
- package/src/components/filter-button/filter-button.component.stories.ts +123 -0
- package/src/components/filter-button/filter-button.component.ts +582 -0
- package/src/components/icon/icon.component.ts +20 -0
- package/src/components/icon/icon.html +1424 -0
- package/src/components/icon/icon.stories.ts +49 -0
- package/src/components/icon/icons-list.stories.ts +42 -0
- package/src/components/input/input.component.stories.ts +101 -0
- package/src/components/input/input.component.ts +317 -0
- package/src/components/input/input.html +160 -0
- package/src/components/input-datepicker/input-datepicker.component.ts +356 -0
- package/src/components/input-datepicker/input-datepicker.html +69 -0
- package/src/components/input-datepicker/input-datepicker.stories.ts +99 -0
- package/src/components/input-rangepicker/input-rangepicker.component.ts +365 -0
- package/src/components/input-rangepicker/input-rangepicker.html +54 -0
- package/src/components/input-rangepicker/input-rangepicker.stories.ts +88 -0
- package/src/components/input-weekpicker/input-weekpicker.component.ts +417 -0
- package/src/components/input-weekpicker/input-weekpicker.html +54 -0
- package/src/components/input-weekpicker/input-weekpicker.stories.ts +103 -0
- package/src/components/label/label.component.html +20 -0
- package/src/components/label/label.component.ts +22 -0
- package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.html +32 -0
- package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.stories.ts +57 -0
- package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.ts +48 -0
- package/src/components/modals/feedback-modal/feedback-modal.component.html +118 -0
- package/src/components/modals/feedback-modal/feedback-modal.component.stories.ts +93 -0
- package/src/components/modals/feedback-modal/feedback-modal.component.ts +187 -0
- package/src/components/modals/help-modal/help-modal.component.html +32 -0
- package/src/components/modals/help-modal/help-modal.component.stories.ts +76 -0
- package/src/components/modals/help-modal/help-modal.component.ts +54 -0
- package/src/components/modals/information-modal/information-modal.component.html +24 -0
- package/src/components/modals/information-modal/information-modal.component.stories.ts +62 -0
- package/src/components/modals/information-modal/information-modal.component.ts +35 -0
- package/src/components/modals/main-modal/main-modal.component.html +85 -0
- package/src/components/modals/main-modal/main-modal.component.stories.ts +127 -0
- package/src/components/modals/main-modal/main-modal.component.ts +85 -0
- package/src/components/modals/notification-modal/notification-modal.component.html +22 -0
- package/src/components/modals/notification-modal/notification-modal.component.stories.ts +59 -0
- package/src/components/modals/notification-modal/notification-modal.component.ts +37 -0
- package/src/components/selectors/multiple-selector/multiple-selector.component.html +51 -0
- package/src/components/selectors/multiple-selector/multiple-selector.component.stories.ts +306 -0
- package/src/components/selectors/multiple-selector/multiple-selector.component.ts +308 -0
- package/src/components/selectors/single-selector/single-selector.component.html +46 -0
- package/src/components/selectors/single-selector/single-selector.component.stories.ts +294 -0
- package/src/components/selectors/single-selector/single-selector.component.ts +239 -0
- package/src/components/side-nav/side-nav.component.stories.ts +176 -0
- package/src/components/side-nav/side-nav.component.ts +325 -0
- package/src/components/snackbar/snackbar.component.ts +150 -0
- package/src/components/snackbar/snackbar.html +21 -0
- package/src/components/snackbar/snackbar.stories.ts +51 -0
- package/src/components/state/state.component.ts +30 -0
- package/src/components/state/state.html +13 -0
- package/src/components/state/state.stories.ts +74 -0
- package/src/components/table/table.component.html +466 -0
- package/src/components/table/table.component.scss +28 -0
- package/src/components/table/table.component.stories.ts +655 -0
- package/src/components/table/table.component.ts +475 -0
- package/src/components/tabs/tabs.component.stories.ts +114 -0
- package/src/components/tabs/tabs.component.ts +69 -0
- package/src/core/types.ts +494 -0
- package/src/public-api.ts +23 -0
- package/tsconfig.json +37 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +13 -0
- package/fesm2022/aaamb-ngx-design-system.mjs +0 -4075
- package/fesm2022/aaamb-ngx-design-system.mjs.map +0 -1
- package/styles/compiled.css +0 -2
- package/types/aaamb-ngx-design-system.d.ts +0 -1142
|
@@ -0,0 +1,294 @@
|
|
|
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 { SingleSelectorComponent } from './single-selector.component';
|
|
6
|
+
import {
|
|
7
|
+
AdsIconName,
|
|
8
|
+
AdsSingleSelectorAsyncOptions,
|
|
9
|
+
AdsSingleSelectorOption,
|
|
10
|
+
AdsSingleSelectorOptionOrGroup,
|
|
11
|
+
} from '../../../core/types';
|
|
12
|
+
|
|
13
|
+
const defaultOptions: AdsSingleSelectorOption[] = [
|
|
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<SingleSelectorComponent> = {
|
|
22
|
+
title: 'Components/Selectors/SingleSelector',
|
|
23
|
+
component: SingleSelectorComponent,
|
|
24
|
+
args: {
|
|
25
|
+
label: 'Country',
|
|
26
|
+
placeholder: 'Search and select',
|
|
27
|
+
allowClear: true,
|
|
28
|
+
disabled: false,
|
|
29
|
+
loading: false,
|
|
30
|
+
options: defaultOptions,
|
|
31
|
+
errorMessage: '',
|
|
32
|
+
labelIconName: null,
|
|
33
|
+
},
|
|
34
|
+
argTypes: {
|
|
35
|
+
label: { control: 'text' },
|
|
36
|
+
placeholder: { control: 'text' },
|
|
37
|
+
allowClear: { control: 'boolean' },
|
|
38
|
+
disabled: { control: 'boolean' },
|
|
39
|
+
loading: { control: 'boolean' },
|
|
40
|
+
options: { control: 'object' },
|
|
41
|
+
errorMessage: { control: 'text' },
|
|
42
|
+
labelIconName: {
|
|
43
|
+
control: 'boolean',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
render: (args) => {
|
|
47
|
+
const form = new FormGroup({
|
|
48
|
+
country: new FormControl<string | number | null>(null),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
moduleMetadata: {
|
|
53
|
+
imports: [CommonModule, ReactiveFormsModule],
|
|
54
|
+
},
|
|
55
|
+
props: {
|
|
56
|
+
...args,
|
|
57
|
+
form,
|
|
58
|
+
},
|
|
59
|
+
template: `
|
|
60
|
+
<div class="max-w-md space-y-4">
|
|
61
|
+
<form [formGroup]="form">
|
|
62
|
+
<ads-single-selector
|
|
63
|
+
formControlName="country"
|
|
64
|
+
[label]="label"
|
|
65
|
+
[placeholder]="placeholder"
|
|
66
|
+
[allowClear]="allowClear"
|
|
67
|
+
[disabled]="disabled"
|
|
68
|
+
[loading]="loading"
|
|
69
|
+
[options]="options"
|
|
70
|
+
[errorMessage]="errorMessage"
|
|
71
|
+
[labelIconName]="labelIconName ? 'plus' : null"
|
|
72
|
+
></ads-single-selector>
|
|
73
|
+
</form>
|
|
74
|
+
|
|
75
|
+
<p class="m-0 text-sm text-green-base">Value: {{ form.controls.country.value }}</p>
|
|
76
|
+
</div>
|
|
77
|
+
`,
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default meta;
|
|
83
|
+
type Story = StoryObj<SingleSelectorComponent>;
|
|
84
|
+
|
|
85
|
+
export const Playground: Story = {};
|
|
86
|
+
|
|
87
|
+
export const AsyncObservableOptions: Story = {
|
|
88
|
+
render: (args) => {
|
|
89
|
+
const form = new FormGroup({
|
|
90
|
+
country: new FormControl<string | number | null>(null),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const asyncOptions: AdsSingleSelectorAsyncOptions = of(defaultOptions).pipe(
|
|
94
|
+
delay(1200),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
moduleMetadata: {
|
|
99
|
+
imports: [CommonModule, ReactiveFormsModule],
|
|
100
|
+
},
|
|
101
|
+
props: {
|
|
102
|
+
...args,
|
|
103
|
+
form,
|
|
104
|
+
asyncOptions,
|
|
105
|
+
},
|
|
106
|
+
template: `
|
|
107
|
+
<div class="max-w-md space-y-4">
|
|
108
|
+
<form [formGroup]="form">
|
|
109
|
+
<ads-single-selector
|
|
110
|
+
formControlName="country"
|
|
111
|
+
[label]="label"
|
|
112
|
+
[placeholder]="placeholder"
|
|
113
|
+
[allowClear]="allowClear"
|
|
114
|
+
[disabled]="disabled"
|
|
115
|
+
[asyncOptions]="asyncOptions"
|
|
116
|
+
[errorMessage]="errorMessage"
|
|
117
|
+
[labelIconName]="labelIconName ? 'plus' : null"
|
|
118
|
+
></ads-single-selector>
|
|
119
|
+
</form>
|
|
120
|
+
|
|
121
|
+
<p class="m-0 text-sm text-green-base">Value: {{ form.controls.country.value }}</p>
|
|
122
|
+
</div>
|
|
123
|
+
`,
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const AsyncPromiseOptions: Story = {
|
|
129
|
+
render: (args) => {
|
|
130
|
+
const form = new FormGroup({
|
|
131
|
+
country: new FormControl<string | number | null>(null),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const asyncOptions: AdsSingleSelectorAsyncOptions = new Promise(
|
|
135
|
+
(resolve) => {
|
|
136
|
+
setTimeout(() => resolve(defaultOptions), 1200);
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
moduleMetadata: {
|
|
142
|
+
imports: [CommonModule, ReactiveFormsModule],
|
|
143
|
+
},
|
|
144
|
+
props: {
|
|
145
|
+
...args,
|
|
146
|
+
form,
|
|
147
|
+
asyncOptions,
|
|
148
|
+
},
|
|
149
|
+
template: `
|
|
150
|
+
<div class="max-w-md space-y-4">
|
|
151
|
+
<form [formGroup]="form">
|
|
152
|
+
<ads-single-selector
|
|
153
|
+
formControlName="country"
|
|
154
|
+
[label]="label"
|
|
155
|
+
[placeholder]="placeholder"
|
|
156
|
+
[allowClear]="allowClear"
|
|
157
|
+
[disabled]="disabled"
|
|
158
|
+
[asyncOptions]="asyncOptions"
|
|
159
|
+
[errorMessage]="errorMessage"
|
|
160
|
+
[labelIconName]="labelIconName ? 'plus' : null"
|
|
161
|
+
></ads-single-selector>
|
|
162
|
+
</form>
|
|
163
|
+
|
|
164
|
+
<p class="m-0 text-sm text-green-base">Value: {{ form.controls.country.value }}</p>
|
|
165
|
+
</div>
|
|
166
|
+
`,
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export const WithGroupedOptions: Story = {
|
|
172
|
+
render: (args) => {
|
|
173
|
+
const form = new FormGroup({
|
|
174
|
+
country: new FormControl<string | number | null>(null),
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const groupedOptions: AdsSingleSelectorOptionOrGroup[] = [
|
|
178
|
+
{
|
|
179
|
+
label: 'North America',
|
|
180
|
+
children: [
|
|
181
|
+
{ label: 'Mexico', value: 'mx' },
|
|
182
|
+
{ label: 'Canada', value: 'ca' },
|
|
183
|
+
{ label: 'United States', value: 'us' },
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
label: 'South America',
|
|
188
|
+
children: [
|
|
189
|
+
{ label: 'Colombia', value: 'co' },
|
|
190
|
+
{ label: 'Argentina', value: 'ar' },
|
|
191
|
+
{ label: 'Chile', value: 'cl' },
|
|
192
|
+
{ label: 'Peru', value: 'pe' },
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
label: 'Other',
|
|
197
|
+
children: [
|
|
198
|
+
{ label: 'Spain', value: 'es' },
|
|
199
|
+
{ label: 'Brazil', value: 'br' },
|
|
200
|
+
],
|
|
201
|
+
},
|
|
202
|
+
];
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
moduleMetadata: {
|
|
206
|
+
imports: [CommonModule, ReactiveFormsModule],
|
|
207
|
+
},
|
|
208
|
+
props: {
|
|
209
|
+
...args,
|
|
210
|
+
form,
|
|
211
|
+
groupedOptions,
|
|
212
|
+
},
|
|
213
|
+
template: `
|
|
214
|
+
<div class="max-w-md space-y-4">
|
|
215
|
+
<form [formGroup]="form">
|
|
216
|
+
<ads-single-selector
|
|
217
|
+
formControlName="country"
|
|
218
|
+
[label]="label"
|
|
219
|
+
[placeholder]="placeholder"
|
|
220
|
+
[allowClear]="allowClear"
|
|
221
|
+
[disabled]="disabled"
|
|
222
|
+
[options]="groupedOptions"
|
|
223
|
+
[errorMessage]="errorMessage"
|
|
224
|
+
[labelIconName]="labelIconName ? 'plus' : null"
|
|
225
|
+
></ads-single-selector>
|
|
226
|
+
</form>
|
|
227
|
+
|
|
228
|
+
<p class="m-0 text-sm text-green-base">Value: {{ form.controls.country.value }}</p>
|
|
229
|
+
</div>
|
|
230
|
+
`,
|
|
231
|
+
};
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export const WithAsyncGroupedOptions: Story = {
|
|
236
|
+
render: (args) => {
|
|
237
|
+
const form = new FormGroup({
|
|
238
|
+
country: new FormControl<string | number | null>(null),
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
const groupedOptions: AdsSingleSelectorOptionOrGroup[] = [
|
|
242
|
+
{
|
|
243
|
+
label: 'North America',
|
|
244
|
+
children: [
|
|
245
|
+
{ label: 'Mexico', value: 'mx' },
|
|
246
|
+
{ label: 'Canada', value: 'ca' },
|
|
247
|
+
{ label: 'United States', value: 'us' },
|
|
248
|
+
],
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
label: 'South America',
|
|
252
|
+
children: [
|
|
253
|
+
{ label: 'Colombia', value: 'co' },
|
|
254
|
+
{ label: 'Argentina', value: 'ar' },
|
|
255
|
+
{ label: 'Chile', value: 'cl' },
|
|
256
|
+
{ label: 'Peru', value: 'pe' },
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
];
|
|
260
|
+
|
|
261
|
+
const asyncOptions: AdsSingleSelectorAsyncOptions = of(groupedOptions).pipe(
|
|
262
|
+
delay(1200),
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
return {
|
|
266
|
+
moduleMetadata: {
|
|
267
|
+
imports: [CommonModule, ReactiveFormsModule],
|
|
268
|
+
},
|
|
269
|
+
props: {
|
|
270
|
+
...args,
|
|
271
|
+
form,
|
|
272
|
+
asyncOptions,
|
|
273
|
+
},
|
|
274
|
+
template: `
|
|
275
|
+
<div class="max-w-md space-y-4">
|
|
276
|
+
<form [formGroup]="form">
|
|
277
|
+
<ads-single-selector
|
|
278
|
+
formControlName="country"
|
|
279
|
+
[label]="label"
|
|
280
|
+
[placeholder]="placeholder"
|
|
281
|
+
[allowClear]="allowClear"
|
|
282
|
+
[disabled]="disabled"
|
|
283
|
+
[asyncOptions]="asyncOptions"
|
|
284
|
+
[errorMessage]="errorMessage"
|
|
285
|
+
[labelIconName]="labelIconName ? 'plus' : null"
|
|
286
|
+
></ads-single-selector>
|
|
287
|
+
</form>
|
|
288
|
+
|
|
289
|
+
<p class="m-0 text-sm text-green-base">Value: {{ form.controls.country.value }}</p>
|
|
290
|
+
</div>
|
|
291
|
+
`,
|
|
292
|
+
};
|
|
293
|
+
},
|
|
294
|
+
};
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import {
|
|
3
|
+
Component,
|
|
4
|
+
CUSTOM_ELEMENTS_SCHEMA,
|
|
5
|
+
effect,
|
|
6
|
+
forwardRef,
|
|
7
|
+
input,
|
|
8
|
+
output,
|
|
9
|
+
signal,
|
|
10
|
+
} from '@angular/core';
|
|
11
|
+
import {
|
|
12
|
+
ControlValueAccessor,
|
|
13
|
+
FormsModule,
|
|
14
|
+
NG_VALUE_ACCESSOR,
|
|
15
|
+
} from '@angular/forms';
|
|
16
|
+
import { NzFilterOptionType, NzSelectModule } from 'ng-zorro-antd/select';
|
|
17
|
+
import { Observable, Subscription } from 'rxjs';
|
|
18
|
+
import {
|
|
19
|
+
AdsIconName,
|
|
20
|
+
AdsSingleSelectorAsyncOptions,
|
|
21
|
+
AdsSingleSelectorOption,
|
|
22
|
+
AdsSingleSelectorOptionOrGroup,
|
|
23
|
+
AdsSingleSelectorValue,
|
|
24
|
+
} from '../../../core/types';
|
|
25
|
+
import { ErrorMessageComponent } from '../../error-message/error-message.component';
|
|
26
|
+
import { LabelComponent } from '../../label/label.component';
|
|
27
|
+
|
|
28
|
+
@Component({
|
|
29
|
+
selector: 'ads-single-selector',
|
|
30
|
+
standalone: true,
|
|
31
|
+
imports: [
|
|
32
|
+
CommonModule,
|
|
33
|
+
FormsModule,
|
|
34
|
+
NzSelectModule,
|
|
35
|
+
LabelComponent,
|
|
36
|
+
ErrorMessageComponent,
|
|
37
|
+
],
|
|
38
|
+
templateUrl: './single-selector.component.html',
|
|
39
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
40
|
+
providers: [
|
|
41
|
+
{
|
|
42
|
+
provide: NG_VALUE_ACCESSOR,
|
|
43
|
+
useExisting: forwardRef(() => SingleSelectorComponent),
|
|
44
|
+
multi: true,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
})
|
|
48
|
+
export class SingleSelectorComponent implements ControlValueAccessor {
|
|
49
|
+
|
|
50
|
+
label = input<string>('');
|
|
51
|
+
placeholder = input<string>('Select an option');
|
|
52
|
+
disabled = input<boolean>(false);
|
|
53
|
+
allowClear = input<boolean>(true);
|
|
54
|
+
loading = input<boolean>(false);
|
|
55
|
+
options = input<AdsSingleSelectorOptionOrGroup[]>([]);
|
|
56
|
+
asyncOptions = input<AdsSingleSelectorAsyncOptions | null>(null);
|
|
57
|
+
value = input<AdsSingleSelectorValue | null>(null);
|
|
58
|
+
errorMessage = input<string>('Please select at least one option.');
|
|
59
|
+
labelIconName = input<AdsIconName | null>(null);
|
|
60
|
+
|
|
61
|
+
onLabelButtonClick = output<void>();
|
|
62
|
+
valueChange = output<AdsSingleSelectorValue | null>();
|
|
63
|
+
|
|
64
|
+
private cvaMode = false;
|
|
65
|
+
private cvaDisabled = false;
|
|
66
|
+
private asyncLoading = signal<boolean>(false);
|
|
67
|
+
private optionsSubscription: Subscription | null = null;
|
|
68
|
+
private asyncRequestId = 0;
|
|
69
|
+
|
|
70
|
+
currentValue = signal<AdsSingleSelectorValue | null>(null);
|
|
71
|
+
resolvedOptions = signal<AdsSingleSelectorOptionOrGroup[]>([]);
|
|
72
|
+
|
|
73
|
+
private onChange: (value: AdsSingleSelectorValue | null) => void = () => {};
|
|
74
|
+
private onTouched: () => void = () => {};
|
|
75
|
+
|
|
76
|
+
readonly filterOption: NzFilterOptionType = (input, option) => {
|
|
77
|
+
const label = String(option?.nzLabel ?? '').toLowerCase();
|
|
78
|
+
return label.includes(input.toLowerCase());
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
constructor() {
|
|
82
|
+
effect(() => {
|
|
83
|
+
if (!this.cvaMode) {
|
|
84
|
+
this.currentValue.set(this.value());
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
effect(() => {
|
|
89
|
+
const providedAsyncOptions = this.asyncOptions();
|
|
90
|
+
|
|
91
|
+
if (!providedAsyncOptions) {
|
|
92
|
+
this.cancelAsyncOptionsSubscription();
|
|
93
|
+
this.asyncLoading.set(false);
|
|
94
|
+
this.resolvedOptions.set(this.options());
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.loadAsyncOptions(providedAsyncOptions);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
ngOnDestroy(): void {
|
|
103
|
+
this.cancelAsyncOptionsSubscription();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
isDisabled(): boolean {
|
|
107
|
+
return this.disabled() || this.cvaDisabled;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
onSelectionChange(value: AdsSingleSelectorValue | null): void {
|
|
111
|
+
this.currentValue.set(value);
|
|
112
|
+
this.onChange(value);
|
|
113
|
+
this.valueChange.emit(value);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
onBlur(): void {
|
|
117
|
+
this.onTouched();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
isLoading(): boolean {
|
|
121
|
+
return this.loading() || this.asyncLoading();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
writeValue(value: any): void {
|
|
125
|
+
this.cvaMode = true;
|
|
126
|
+
|
|
127
|
+
if (value === undefined) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (
|
|
132
|
+
typeof value === 'string' ||
|
|
133
|
+
typeof value === 'number' ||
|
|
134
|
+
typeof value === 'boolean' ||
|
|
135
|
+
value === null
|
|
136
|
+
) {
|
|
137
|
+
this.currentValue.set(value);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.currentValue.set(null);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
registerOnChange(fn: (value: AdsSingleSelectorValue | null) => void): void {
|
|
145
|
+
this.onChange = fn;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
registerOnTouched(fn: () => void): void {
|
|
149
|
+
this.onTouched = fn;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
setDisabledState(isDisabled: boolean): void {
|
|
153
|
+
this.cvaDisabled = isDisabled;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private loadAsyncOptions(source: AdsSingleSelectorAsyncOptions): void {
|
|
157
|
+
this.cancelAsyncOptionsSubscription();
|
|
158
|
+
|
|
159
|
+
const requestId = ++this.asyncRequestId;
|
|
160
|
+
this.asyncLoading.set(true);
|
|
161
|
+
|
|
162
|
+
if (this.isPromise(source)) {
|
|
163
|
+
source
|
|
164
|
+
.then((items) => {
|
|
165
|
+
this.applyAsyncOptionsResult(requestId, items);
|
|
166
|
+
})
|
|
167
|
+
.catch(() => {
|
|
168
|
+
this.applyAsyncOptionsResult(requestId, []);
|
|
169
|
+
})
|
|
170
|
+
.finally(() => {
|
|
171
|
+
this.finishAsyncOptionsRequest(requestId);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
this.optionsSubscription = (
|
|
178
|
+
source as Observable<AdsSingleSelectorOptionOrGroup[]>
|
|
179
|
+
).subscribe({
|
|
180
|
+
next: (items: AdsSingleSelectorOptionOrGroup[]) => {
|
|
181
|
+
this.applyAsyncOptionsResult(requestId, items);
|
|
182
|
+
},
|
|
183
|
+
error: () => {
|
|
184
|
+
this.applyAsyncOptionsResult(requestId, []);
|
|
185
|
+
this.finishAsyncOptionsRequest(requestId);
|
|
186
|
+
},
|
|
187
|
+
complete: () => {
|
|
188
|
+
this.finishAsyncOptionsRequest(requestId);
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private applyAsyncOptionsResult(
|
|
194
|
+
requestId: number,
|
|
195
|
+
options: AdsSingleSelectorOptionOrGroup[],
|
|
196
|
+
): void {
|
|
197
|
+
if (requestId !== this.asyncRequestId) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
this.resolvedOptions.set(options);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
private finishAsyncOptionsRequest(requestId: number): void {
|
|
205
|
+
if (requestId !== this.asyncRequestId) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
this.asyncLoading.set(false);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
private cancelAsyncOptionsSubscription(): void {
|
|
213
|
+
if (!this.optionsSubscription) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
this.optionsSubscription.unsubscribe();
|
|
218
|
+
this.optionsSubscription = null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private isPromise(
|
|
222
|
+
value: AdsSingleSelectorAsyncOptions,
|
|
223
|
+
): value is Promise<AdsSingleSelectorOption[]> {
|
|
224
|
+
return (
|
|
225
|
+
typeof (value as Promise<AdsSingleSelectorOption[]>).then === 'function'
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
onLabelClicked(): void {
|
|
230
|
+
this.onLabelButtonClick.emit();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
isOptionGroup(
|
|
235
|
+
item: AdsSingleSelectorOptionOrGroup,
|
|
236
|
+
): item is { label: string; children: AdsSingleSelectorOption[] } {
|
|
237
|
+
return 'children' in item;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/angular';
|
|
2
|
+
import { SideNavComponent } from './side-nav.component';
|
|
3
|
+
import { AdsSideNavOption, AdsSideNavRoute } from '../../core/types';
|
|
4
|
+
|
|
5
|
+
const normalizeRoute = (route: AdsSideNavRoute): string => {
|
|
6
|
+
if (Array.isArray(route)) {
|
|
7
|
+
return `/${route
|
|
8
|
+
.map((segment) => String(segment).replace(/^\/+|\/+$/g, ''))
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
.join('/')}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (typeof route === 'string') {
|
|
14
|
+
return route.startsWith('/') ? route : `/${route}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return '/';
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const meta: Meta<SideNavComponent> = {
|
|
21
|
+
title: 'Components/Side Nav',
|
|
22
|
+
component: SideNavComponent,
|
|
23
|
+
argTypes: {
|
|
24
|
+
isCollapsed: {
|
|
25
|
+
control: 'boolean',
|
|
26
|
+
},
|
|
27
|
+
activePath: {
|
|
28
|
+
control: 'text',
|
|
29
|
+
},
|
|
30
|
+
logoSrc: {
|
|
31
|
+
control: 'text',
|
|
32
|
+
},
|
|
33
|
+
collapsedLogoSrc: {
|
|
34
|
+
control: 'text',
|
|
35
|
+
},
|
|
36
|
+
footerLogoSrc: {
|
|
37
|
+
control: 'text',
|
|
38
|
+
},
|
|
39
|
+
logoAlt: {
|
|
40
|
+
control: 'text',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
render: (args) => ({
|
|
44
|
+
props: {
|
|
45
|
+
...args,
|
|
46
|
+
onOptionSelected: (route: AdsSideNavRoute) => {
|
|
47
|
+
const path = normalizeRoute(route);
|
|
48
|
+
args.activePath = path;
|
|
49
|
+
},
|
|
50
|
+
onChildSelected: (path: string) => {
|
|
51
|
+
args.activePath = path;
|
|
52
|
+
},
|
|
53
|
+
onActivePathChange: (path: string) => {
|
|
54
|
+
args.activePath = path;
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
template: `
|
|
58
|
+
<div class="h-screen bg-neutral-disabled-bg p-4">
|
|
59
|
+
<div
|
|
60
|
+
class="h-full transition-all duration-300"
|
|
61
|
+
[ngClass]="isCollapsed ? 'w-20' : 'w-80'"
|
|
62
|
+
>
|
|
63
|
+
<ads-side-nav
|
|
64
|
+
[options]="options"
|
|
65
|
+
[isCollapsed]="isCollapsed"
|
|
66
|
+
[activePath]="activePath"
|
|
67
|
+
[logoSrc]="logoSrc"
|
|
68
|
+
[collapsedLogoSrc]="collapsedLogoSrc"
|
|
69
|
+
[footerLogoSrc]="footerLogoSrc"
|
|
70
|
+
[logoAlt]="logoAlt"
|
|
71
|
+
[footerButton]="footerButton"
|
|
72
|
+
[footerButtons]="footerButtons"
|
|
73
|
+
(optionSelected)="onOptionSelected($event)"
|
|
74
|
+
(childSelected)="onChildSelected($event)"
|
|
75
|
+
(activePathChange)="onActivePathChange($event)"
|
|
76
|
+
></ads-side-nav>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
`,
|
|
80
|
+
}),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default meta;
|
|
84
|
+
type Story = StoryObj<SideNavComponent>;
|
|
85
|
+
|
|
86
|
+
const sampleOptions: AdsSideNavOption[] = [
|
|
87
|
+
{
|
|
88
|
+
icon: 'chart_bars',
|
|
89
|
+
name: 'Dashboard',
|
|
90
|
+
url: ['dashboard'],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
icon: 'receipt',
|
|
94
|
+
name: 'Charge Entry',
|
|
95
|
+
children: [
|
|
96
|
+
{ name: 'Encounters', url: '/charge-entry/encounters' },
|
|
97
|
+
{ name: 'Bulk Add', url: '/charge-entry/bulk' },
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
icon: 'calendar',
|
|
102
|
+
name: 'Dialysis',
|
|
103
|
+
url: ['dialysis'],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
icon: 'people',
|
|
107
|
+
name: 'Patients',
|
|
108
|
+
children: [
|
|
109
|
+
{ name: 'Patients List', url: '/patients/list' },
|
|
110
|
+
{ name: 'Patients Cards', url: '/patients/cards' },
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
export const Expanded: Story = {
|
|
116
|
+
args: {
|
|
117
|
+
isCollapsed: false,
|
|
118
|
+
activePath: '/dashboard',
|
|
119
|
+
options: [...sampleOptions],
|
|
120
|
+
logoSrc:
|
|
121
|
+
'https://sandbox.app.charge-capture.rcmsuite.io/images/logos/chargeCaptureLogo.svg',
|
|
122
|
+
collapsedLogoSrc:
|
|
123
|
+
'https://sandbox.app.charge-capture.rcmsuite.io/images/logos/aaamb-simplified-logo.svg',
|
|
124
|
+
footerLogoSrc:
|
|
125
|
+
'https://sandbox.app.charge-capture.rcmsuite.io/images/logos/aaamb-logo-white.svg',
|
|
126
|
+
|
|
127
|
+
logoAlt: 'AAAMB logo',
|
|
128
|
+
footerButton: {
|
|
129
|
+
icon: 'chat',
|
|
130
|
+
text: 'Feedback',
|
|
131
|
+
callback: () => {
|
|
132
|
+
console.log('Footer button clicked');
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
footerButtons: [
|
|
136
|
+
{
|
|
137
|
+
icon: 'info',
|
|
138
|
+
text: 'help center',
|
|
139
|
+
callback: () => {
|
|
140
|
+
console.log('Help Center Clicked');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const Collapsed: Story = {
|
|
148
|
+
args: {
|
|
149
|
+
isCollapsed: true,
|
|
150
|
+
activePath: '/charge-entry/encounters',
|
|
151
|
+
options: [...sampleOptions],
|
|
152
|
+
logoSrc:
|
|
153
|
+
'https://sandbox.app.charge-capture.rcmsuite.io/images/logos/chargeCaptureLogo.svg',
|
|
154
|
+
collapsedLogoSrc:
|
|
155
|
+
'https://sandbox.app.charge-capture.rcmsuite.io/images/logos/aaamb-simplified-logo.svg',
|
|
156
|
+
footerLogoSrc:
|
|
157
|
+
'https://sandbox.app.charge-capture.rcmsuite.io/images/logos/aaamb-logo-white.svg',
|
|
158
|
+
logoAlt: 'AAAMB logo',
|
|
159
|
+
footerButton: {
|
|
160
|
+
icon: 'chat',
|
|
161
|
+
text: 'Feedback',
|
|
162
|
+
callback: () => {
|
|
163
|
+
console.log('Footer button clicked');
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
footerButtons: [
|
|
167
|
+
{
|
|
168
|
+
icon: 'info',
|
|
169
|
+
text: 'help center',
|
|
170
|
+
callback: () => {
|
|
171
|
+
console.log('Footer button clicked');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
};
|